Example #1
0
/**
 * Get the hashed filename
 *
 * @param  string   url of the item
 * @param  string   $cache_folder  name ob the sub-cache to adress
 * @param  string   ext file extension of the cache file
 */
function cache_get_filename($url, $cache_folder, $ext = '')
{
    $hash = md5($url) . ($ext ? '.' . $ext : '');
    $cache_file = cache_get_folder($cache_folder, $hash) . $hash;
    return $cache_file;
}
Example #2
-1
/**
 * Export PDF document
 *
 * @param   string  $where  WHERE clause for SQL statement
 */
function pdfexport($WHERE)
{
    global $config;
    $ypos = $config['pdf_font_size'];
    // Match the font size for proper vertical offset
    $page_width = $config['pdf_page_width'];
    $margin = $config['pdf_margin'];
    $left_margin = $config['pdf_left_margin'];
    $right_margin = $config['pdf_right_margin'];
    $mediaimg_width = $config['pdf_image_media_width'];
    $font_size = $config['pdf_font_size'];
    $image_height = $config['pdf_image_height'];
    $image_width = $config['pdf_image_width'];
    $font_title = $config['pdf_font_title'];
    $font_plot = $config['pdf_font_plot'];
    $text_length = $config['pdf_text_length'];
    $tempfolder = cache_get_folder('');
    if ($config['cache_pruning']) {
        cache_prune_folder($tempfolder, 3600, false, false, 'videodb*.pdf');
    }
    $filename = $tempfolder . 'videodb' . date('His', time()) . '.pdf';
    // setup pdf class
    $pdf = new PDF();
    $pdf->Open($filename);
    $pdf->VerifyFont($font_title);
    $pdf->VerifyFont($font_title, 'B');
    $pdf->VerifyFont($font_plot);
    $pdf->AddPage();
    $pdf->SetRightMargin($right_margin);
    // add downscaling
    if ($config['pdf_scale']) {
        $pdf->Scale = $config['pdf_scale'];
        $pdf->max_width = $config['pdf_image_max_width'];
        $pdf->max_height = $config['pdf_image_max_height'];
    }
    // get data
    $result = iconv_array('utf-8', 'iso-8859-1', exportData($WHERE));
    foreach ($result as $row) {
        set_time_limit(300);
        // rise per movie execution timeout limit if safe_mode is not set in php.ini
        $title = $row['title'];
        if ($row['subtitle']) {
            $title .= ' - ' . $row['subtitle'];
        }
        if ($row['diskid'] || $row['mediatype']) {
            $title .= ' [';
            if ($row['mediatype']) {
                $title .= $row['mediatype'] . ', ';
            }
            if ($row['diskid']) {
                $title .= $row['diskid'];
            }
            $title = preg_replace('/, $/', '', $title) . ']';
        }
        // get drilldown url for image
        $imdb = $row['imdbID'];
        $link = $imdb ? engineGetContentUrl($imdb, engineGetEngine($imdb)) : '';
        // title
        $pdf->SetFont($font_title, 'B', $font_size);
        $pdf->SetXY($left_margin + $image_width + $margin, $ypos);
        $pdf->Cell(0, 0, $title, 0, 1, 'L', 0, $link);
        // [muddle] technical details
        unset($tech['V']);
        if ($row['video_width'] and $row['video_height']) {
            $vw = $row['video_width'];
            $vh = $row['video_height'];
            $tech['V'] = "Video: ";
            if ($vw > 1920) {
                $tech['V'] .= "UHD " . $vw . "x" . $vh;
            } elseif ($vw > 1280) {
                $tech['V'] .= "HD 1080p";
            } elseif ($vw == 1280 or $vh == 720) {
                $tech['V'] .= "HD 720p";
            } elseif ($vw == 720 or $vw == 704) {
                $tech['V'] .= "SD ";
                if ($vh == 480) {
                    $tech['V'] .= "NTSC";
                } elseif ($vh == 576) {
                    $tech['V'] .= "PAL";
                } else {
                    $tech['V'] .= $vw . "x" . $vh;
                }
            } else {
                $tech['V'] .= "LORES " . $vw . "x" . $vh;
            }
        }
        unset($tech['A']);
        if ($row['audio_codec']) {
            $tech['A'] = "Audio: " . $row['audio_codec'];
        }
        unset($tech['D']);
        if ($row['created']) {
            $tech['D'] = "Date: " . $row['created'];
        }
        $techinfo = implode(", ", $tech);
        $pdf->SetFont($font_title, 'B', $font_size - 3);
        $pdf->SetXY($left_margin + $image_width + $margin, $ypos + 4);
        $pdf->Cell(0, 0, $techinfo, 0, 1, 'L', 0);
        // plot
        $plot = leftString($row['plot'], $text_length);
        $pdf->SetFont($font_plot, '', $font_size - 1);
        $pdf->SetXY($left_margin + $image_width + $margin, $ypos + 3 + 3);
        $pdf->SetLeftMargin($left_margin + $image_width + $margin);
        $pdf->WriteHTML($plot);
        // image
        $file = getThumbnail($row['imgurl']);
        if (preg_match('/^img.php/', $file)) {
            $file = img();
        }
        // image file present?
        if ($file) {
            $pdf->Image($file, $left_margin, $ypos - 2, $image_width, $image_height, '', $link);
        }
        // add mediatype image
        if ($type_image = getMediaImage($row['mediatype'])) {
            $pdf->Image('./images/media/' . $type_image, $page_width - $mediaimg_width - $right_margin, $ypos - 2, $mediaimg_width, 0, '', '');
        }
        // new position
        $ypos += $margin;
        if ($file or $plot) {
            $ypos += max($image_height, $font_size);
        } else {
            $ypos += $font_size;
        }
        if ($ypos > 250) {
            $ypos = $config['pdf_font_size'];
            $pdf->AddPage();
        }
    }
    $pdf->Output('videoDB.pdf', 'D');
    // get rid of temp file
    @unlink($filename);
}