<commit_before><?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * @author     <NAME>
 */
class Wkhtml
{
    static public function topdf($data, $download = FALSE)
    {
        $bin = Kohana::config('wkhtml.paths.bin');
        
        if ( ! file_exists($bin)) {
            throw new Kohana_Exception('wkhtml binary does not exist at: '.$bin);
        }
        
        // Create unique temporary file
        $uuid = uniqid('wkhtml_temp_', TRUE);
        
        // Store working files in cache
        $folder = Kohana::config('wkhtml.paths.temp');
        
        $file_in  = $folder . $uuid . '.html';
        $file_out = $folder . $uuid . '.pdf';
        
        // Write temporary file
        file_put_contents($file_in, $data);
        
        // Build command
        $cmd = $bin . ' ' . escapeshellarg($file_in) . ' ' . escapeshellarg($file_out);
        
        // Convert file
        passthru($cmd);
        
        // Delete HTML file
        unlink($file_in);
                
        // Handle any errors
        if ( ! file_exists($file_out)) {
            throw new Kohana_Exception('Unknown wkhtmltopdf error.');
        }
        
        // Force PDF download or return cache ID
        if ($download) {
            $filename = (is_string($download)) ? $download : 'print.pdf';
            
            Request::current()->response()->send_file($file_out, $filename);
        }
        
        return $file_out;
    }
}<commit_msg>Corrected configuration loading for 3.2<commit_after><?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * @author     <NAME>
 */
class Wkhtml
{
    static public function topdf($data, $download = FALSE)
    {
        $bin = Kohana::$config->load('wkhtml.paths.bin');

        if ( ! file_exists($bin)) {
            throw new Kohana_Exception('wkhtml binary does not exist at: '.$bin);
        }

        // Create unique temporary file
        $uuid = uniqid('wkhtml_temp_', TRUE);

        // Store working files in cache
        $folder = Kohana::$config->load('wkhtml.paths.temp');

        $file_in  = $folder . $uuid . '.html';
        $file_out = $folder . $uuid . '.pdf';

        // Write temporary file
        file_put_contents($file_in, $data);

        // Build command
        $cmd = $bin . ' ' . escapeshellarg($file_in) . ' ' . escapeshellarg($file_out);

        // Convert file
        passthru($cmd);

        // Delete HTML file
        unlink($file_in);

        // Handle any errors
        if ( ! file_exists($file_out)) {
            throw new Kohana_Exception('Unknown wkhtmltopdf error.');
        }

        // Force PDF download or return cache ID
        if ($download) {
            $filename = (is_string($download)) ? $download : 'print.pdf';

            Request::current()->response()->send_file($file_out, $filename);
        }

        return $file_out;
    }
}
{'fraction_non_alphanumeric': 0.13994471319972357, 'fraction_numerical': 0.000691085003455425, 'mean_word_length': 1.838235294117647, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5279233', 'n_tokens_mistral': 858, 'n_tokens_neox': 828, 'n_words': 198}