/** * Optionally turn on GZip Compression, if configured * * @access public */ function serendipity_gzCompression() { global $serendipity; if (isset($serendipity['useGzip']) && serendipity_db_bool($serendipity['useGzip']) && function_exists('ob_gzhandler') && extension_loaded('zlib') && serendipity_ini_bool(ini_get('zlib.output_compression')) == false && serendipity_ini_bool(ini_get('session.use_trans_sid')) == false) { ob_start("ob_gzhandler"); } }
if (serendipity_ini_bool(ini_get('allow_url_fopen'))) { echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'ON'); } else { echo serendipity_installerResultDiagnose(S9Y_I_WARNING, 'OFF'); } ?> </td> </tr> <tr> <td>file_uploads</td> <td width="150"><strong><?php echo 'ON'; ?> </strong></td> <td width="150"><?php if (serendipity_ini_bool(ini_get('file_uploads'))) { echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, 'ON'); } else { echo serendipity_installerResultDiagnose(S9Y_I_ERROR, 'OFF'); } ?> </td> </tr> <tr> <td>post_max_size</td> <td width="150"><strong>10M</strong></td> <td width="150"><?php if (serendipity_ini_bytesize(ini_get('post_max_size')) >= 10 * 1024 * 1024) { echo serendipity_installerResultDiagnose(S9Y_I_SUCCESS, ini_get('post_max_size')); } else { echo serendipity_installerResultDiagnose(S9Y_I_WARNING, ini_get('post_max_size'));
/** * Create a thumbnail for an image * * LONG * * @access public * @param string The input image filename * @param string The directory to the image file * @param string The target size of the thumbnail (2-dimensional array width,height) * @param string Name of the thumbnail * @param bool Store thumbnail in temporary place? * @param bool Force enlarging of small images? * @return array The result size of the thumbnail */ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumbname = false, $is_temporary = false, $force_resize = false) { global $serendipity; if ($size === false) { $size = $serendipity['thumbSize']; } if ($size < 1) { return array(0, 0); } if ($thumbname === false) { $thumbname = $serendipity['thumbSuffix']; } $t = serendipity_parseFileName($file); $f = $t[0]; $suf = $t[1]; $infile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file; # echo 'From: ' . $infile . '<br />'; if ($is_temporary) { $temppath = dirname($thumbname); if (!is_dir($temppath)) { @mkdir($temppath); } $outfile = $thumbname; } else { $outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $thumbname . '.' . $suf; } $serendipity['last_outfile'] = $outfile; # echo 'To: ' . $outfile . '<br />'; $fdim = @serendipity_getimagesize($infile, '', $suf); if (isset($fdim['noimage'])) { $r = array(0, 0); } else { if ($serendipity['magick'] !== true) { if (is_array($size)) { // The caller wants a thumbnail with a specific size $r = serendipity_resize_image_gd($infile, $outfile, $size['width'], $size['height']); } else { // The caller wants a thumbnail constrained in the dimension set by config $calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']); $r = serendipity_resize_image_gd($infile, $outfile, $calc[0], $calc[1]); } } else { if (is_array($size)) { $r = $size; } else { $calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']); $r = array('width' => $calc[0], 'height' => $calc[1]); } $newSize = $r['width'] . 'x' . $r['height']; if ($fdim['mime'] == 'application/pdf') { $cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -flatten -scale ' . serendipity_escapeshellarg($newSize) . ' ' . serendipity_escapeshellarg($infile . '[0]') . ' ' . serendipity_escapeshellarg($outfile . '.png'); } else { if (!$force_resize && serendipity_ini_bool(ini_get('safe_mode')) === false) { $newSize .= '>'; // Tell imagemagick to not enlarge small images, only works if safe_mode is off (safe_mode turns > in to \>) } $cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -resize ' . serendipity_escapeshellarg($newSize) . ' ' . serendipity_escapeshellarg($infile) . ' ' . serendipity_escapeshellarg($outfile); } exec($cmd, $output, $result); if ($result != 0) { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) . '</div>'; $r = false; // return failure } else { touch($outfile); } unset($output, $result); } } return $r; }
/** * Create a thumbnail for an image * * LONG * * @access public * @param string The input image filename * @param string The directory to the image file * @param string The target size of the thumbnail (2-dimensional array width,height) * @param string Name of the thumbnail * @param bool Store thumbnail in temporary place? * @param bool Force enlarging of small images? * @return array The result size of the thumbnail */ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumbname = false, $is_temporary = false, $force_resize = false) { global $serendipity; if ($size === false) { $size = $serendipity['thumbSize']; } if ($size < 1) { return array(0, 0); } if ($thumbname === false) { $thumbname = $serendipity['thumbSuffix']; } $t = serendipity_parseFileName($file); $f = $t[0]; $suf = $t[1]; $infile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file; #echo 'From: ' . $infile . '<br />'; if ($is_temporary) { $temppath = dirname($thumbname); if (!is_dir($temppath)) { @mkdir($temppath); } $outfile = $thumbname; } else { $outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $thumbname . '.' . $suf; } $serendipity['last_outfile'] = $outfile; #echo 'To: ' . $outfile . '<br />'; $fdim = @serendipity_getimagesize($infile, '', $suf); if (isset($fdim['noimage'])) { $r = array(0, 0); } else { if ($serendipity['magick'] !== true) { if (is_array($size)) { // The caller wants a thumbnail with a specific size $r = serendipity_resize_image_gd($infile, $outfile, $size['width'], $size['height']); } else { // The caller wants a thumbnail constrained in the dimension set by config $calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']); $r = serendipity_resize_image_gd($infile, $outfile, $calc[0], $calc[1]); } } else { if (is_array($size)) { if ($fdim[0] > $size['width'] && $fdim[1] > $size['height']) { $r = $size; } else { return array(0, 0); // do not create any thumb, if image is smaller than defined sizes } } else { $calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']); $r = array('width' => $calc[0], 'height' => $calc[1]); } $newSize = $r['width'] . 'x' . $r['height']; if ($fdim['mime'] == 'application/pdf') { $cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -flatten -scale ' . serendipity_escapeshellarg($newSize) . ' ' . serendipity_escapeshellarg($infile . '[0]') . ' ' . serendipity_escapeshellarg($outfile . '.png'); } else { if (!$force_resize && serendipity_ini_bool(ini_get('safe_mode')) === false) { $newSize .= '>'; // tell imagemagick to not enlarge small images, only works if safe_mode is off (safe_mode turns > in to \>) } if (!$serendipity['imagemagick_nobang']) { $newSize .= '!'; } // force the first run image geometry exactly to given sizes, if there were rounding differences (see https://github.com/s9y/Serendipity/commit/94881ba4c0e3bdd4b5fac510e93977e239171c1c and comments) $cmd = escapeshellcmd($serendipity['convert'] . ' ' . $serendipity['imagemagick_thumb_parameters']) . ' -antialias -resize ' . serendipity_escapeshellarg($newSize) . ' ' . serendipity_escapeshellarg($infile) . ' ' . serendipity_escapeshellarg($outfile); } exec($cmd, $output, $result); if ($result != 0) { echo '<span class="msg_error"><span class="icon-attention-circled"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) . '</span>'; $r = false; // return failure } else { touch($outfile); } unset($output, $result); } } return $r; }