示例#1
0
function MG_createDisplayImage($srcImage, $imageDisplay, $mimeExt, $mimeType, $aid, $dnc = 1)
{
    global $_CONF, $_TABLES, $_MG_CONF, $_SPECIAL_IMAGES_MIMETYPE;
    $imgsize = @getimagesize($srcImage);
    if ($imgsize == false && !in_array($mimeType, $_SPECIAL_IMAGES_MIMETYPE)) {
        return array(false, 'Unable to determine src image dimensions');
    }
    $imgwidth = $imgsize[0];
    $imgheight = $imgsize[1];
    $sql = "SELECT display_image_size " . "FROM {$_TABLES['mg_albums']} WHERE album_id = " . intval($aid);
    $result = DB_query($sql);
    $A = DB_fetchArray($result);
    list($dImageWidth, $dImageHeight) = MG_getImageSize($A['display_image_size']);
    if ($imgwidth == 0 || $imgheight == 0) {
        $imgwidth = $dImageWidth;
        $imgheight = $dImageHeight;
    }
    if ($mimeType == 'image/x-targa' || $mimeType == 'image/tga') {
        $fp = @fopen($srcImage, 'rb');
        if ($fp == false) {
            $imgwidth = 0;
            $imgheight = 0;
        } else {
            $data = fread($fp, filesize($srcImage));
            fclose($fp);
            $imgwidth = base_convert(bin2hex(strrev(substr($data, 12, 2))), 16, 10);
            $imgheight = base_convert(bin2hex(strrev(substr($data, 12, 2))), 16, 10);
        }
    }
    $tmpImage = '';
    if (in_array($mimeType, $_SPECIAL_IMAGES_MIMETYPE)) {
        $tmpImage = $_MG_CONF['tmp_path'] . 'wip' . rand() . '.jpg';
        list($rc, $msg) = MG_convertImageFormat($srcImage, $tmpImage, 'image/jpeg', 0);
        if ($rc == false) {
            COM_errorLog("MG_createDisplayImage: Error converting uploaded image to jpeg format.");
            @unlink($srcImage);
            return array(false, $msg);
        }
    }
    if ($tmpImage != '') {
        list($rc, $msg) = MG_resizeImage($tmpImage, $imageDisplay, $dImageHeight, $dImageWidth, '', 0, $_MG_CONF['jpg_quality']);
        //      list($rc,$msg) = MG_resizeImage($tmpImage, $imageDisplay, $imgheight,    $imgwidth,    '', 0, $_MG_CONF['jpg_quality']);
    } else {
        list($rc, $msg) = MG_resizeImage($srcImage, $imageDisplay, $dImageHeight, $dImageWidth, $mimeType, 0, $_MG_CONF['jpg_quality']);
        //      list($rc,$msg) = MG_resizeImage($srcImage, $imageDisplay, $imgheight,    $imgwidth,    $mimeType, 0, $_MG_CONF['jpg_quality']);
    }
    if ($rc == false) {
        @unlink($srcImage);
        @unlink($tmpImage);
        return array(false, $msg);
    }
    if ($tmpImage != '') {
        @unlink($tmpImage);
    }
    if ($_MG_CONF['discard_original'] != 1) {
        // discard original image file
        list($rc, $msg) = MG_processOriginal($srcImage, $mimeExt, $mimeType, $aid, $dnc);
        if ($rc == false) {
            @unlink($srcImage);
            @unlink($imageDisplay);
            @unlink($tmpImage);
            return array(false, $msg);
        }
    }
    return array(true, '');
}
示例#2
0
$T->set_block('page', 'noItems', 'nItems');
$T->set_var('header', $LANG_MG00['plugin']);
$T->set_var('site_url', $_MG_CONF['site_url']);
$T->set_var('plugin', 'mediagallery');
$T->set_var('using_jquery', 'jquery');
if ($album_data['access'] == 0) {
    $display = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
    $title = strip_tags($album_data['album_title']);
    $display = MG_createHTMLDocument($display, $title);
    COM_output($display);
    exit;
}
$album_title = $album_data['album_title'];
$album_desc = $album_data['album_desc'];
$album_parent = $album_data['album_parent'];
list($dImageWidth, $dImageHeight) = MG_getImageSize($album_data['display_image_size']);
if ($_MG_CONF['usage_tracking']) {
    MG_updateUsage('slideshow', $album_title, '', '');
}
$sql = MG_buildMediaSql(array('album_id' => $album_id, 'sortorder' => $sortOrder));
$result = DB_query($sql);
$total_media = 0;
$mediaObject = array();
while ($row = DB_fetchArray($result)) {
    if ($row['media_type'] != 0 || $row['media_filename'] == '') {
        continue;
    }
    $mediaObject[] = $row;
    $total_media++;
}
$noFullOption = 0;