本文整理汇总了PHP中cpg_getimagesize函数的典型用法代码示例。如果您正苦于以下问题:PHP cpg_getimagesize函数的具体用法?PHP cpg_getimagesize怎么用?PHP cpg_getimagesize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpg_getimagesize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cpgUserLastComment
function cpgUserLastComment($uid)
{
global $CONFIG, $FORBIDDEN_SET;
$result = cpg_db_query("SELECT COUNT(*), MAX(msg_id) FROM {$CONFIG['TABLE_COMMENTS']} AS c INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.pid = c.pid WHERE approval = 'YES' AND author_id = '{$uid}' {$FORBIDDEN_SET}");
list($comment_count, $lastcom_id) = mysql_fetch_row($result);
mysql_free_result($result);
$lastComArray = array('count' => 0);
if ($comment_count) {
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body FROM {$CONFIG['TABLE_COMMENTS']} AS c INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.pid = c.pid WHERE msg_id = {$lastcom_id}";
$result = cpg_db_query($sql);
if (mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
$pic_url = get_pic_url($row, 'thumb');
if (!is_image($row['filename'])) {
$image_info = cpg_getimagesize(urldecode($pic_url));
$row['pwidth'] = $image_info[0];
$row['pheight'] = $image_info[1];
}
$image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']);
$lastcom = '<img src="' . $pic_url . '" class="image"' . $image_size['geom'] . ' border="0" alt="" />';
$lastComArray = array('thumb' => $lastcom, 'comment' => $row['msg_body'], 'msg_date' => $row['msg_date'], 'count' => $comment_count);
}
mysql_free_result($result);
}
return $lastComArray;
}
示例2: exif_parse_file
function exif_parse_file($filename, $pid)
{
global $CONFIG, $lang_picinfo;
if (!is_readable($filename)) {
return false;
}
$size = cpg_getimagesize($filename);
if ($size[2] != 2) {
return false;
// Not a JPEG file
}
//String containing all the available exif tags.
$exif_info = "AFFocusPosition|Adapter|ColorMode|ColorSpace|ComponentsConfiguration|CompressedBitsPerPixel|Contrast|CustomerRender|DateTimeOriginal|DateTimedigitized|DigitalZoom|DigitalZoomRatio|ExifImageHeight|ExifImageWidth|ExifInteroperabilityOffset|ExifOffset|ExifVersion|ExposureBiasValue|ExposureMode|ExposureProgram|ExposureTime|FNumber|FileSource|Flash|FlashPixVersion|FlashSetting|FocalLength|FocusMode|GainControl|IFD1Offset|ISOSelection|ISOSetting|ISOSpeedRatings|ImageAdjustment|ImageDescription|ImageSharpening|LightSource|Make|ManualFocusDistance|MaxApertureValue|MeteringMode|Model|NoiseReduction|Orientation|Quality|ResolutionUnit|Saturation|SceneCaptureMode|SceneType|Sharpness|Software|WhiteBalance|YCbCrPositioning|xResolution|yResolution";
$exif_names = explode("|", $exif_info);
//Check if we have the data of the said file in the table
$result = cpg_db_query("SELECT exifData FROM {$CONFIG['TABLE_EXIF']} WHERE pid = {$pid}");
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
$exif = unserialize($row['exifData']);
// Convert old EXIF data style to new one
if (array_key_exists('Errors', $exif)) {
$exif = cpg_exif_strip_data($exif, $exif_names);
cpg_db_query("UPDATE {$CONFIG['TABLE_EXIF']} SET exifData = '" . addslashes(serialize($exif)) . "' WHERE pid = '{$pid}'");
}
} else {
// No data in the table - read it from the image file
$exifRawData = read_exif_data_raw($filename, 0);
$exif = cpg_exif_strip_data($exifRawData, $exif_names);
// Insert it into table for future reference
cpg_db_query("INSERT INTO {$CONFIG['TABLE_EXIF']} (pid, exifData) VALUES ({$pid}, '" . addslashes(serialize($exif)) . "')");
}
$exifParsed = array();
$exifCurrentData = array_keys(array_filter(explode("|", $CONFIG['show_which_exif'])));
foreach ($exifCurrentData as $i) {
$name = $exif_names[$i];
if (isset($exif[$name])) {
$exifParsed[$lang_picinfo[$name]] = $exif[$name];
}
}
ksort($exifParsed);
return $exifParsed;
}
示例3: imageObject
function imageObject($directory, $filename, $previous = null)
{
$this->directory = $directory;
$this->filename = $filename;
$this->previous = $previous;
$this->truecolor = true;
if (file_exists($directory . $filename)) {
$this->filesize = round(filesize($directory . $filename) / 1000);
if ($this->filesize > 0) {
$size = cpg_getimagesize($directory . $filename);
// For IM we don't need an Image Resource (work directly on file :)
if ($size && !$this->imgRes) {
$this->imgRes = true;
}
$this->width = $size[0];
$this->height = $size[1];
$this->string = $size[3];
}
}
}
示例4: imageObject
function imageObject($directory, $filename, $previous = null)
{
$this->directory = $directory;
$this->filename = $filename;
$this->previous = $previous;
$this->imgRes = $previous->imgRes;
if (file_exists($directory . $filename)) {
$this->filesize = round(filesize($directory . $filename) / 1000);
if ($this->filesize > 0) {
$size = cpg_getimagesize($directory . $filename);
if ($size && !$this->imgRes) {
$this->imgRes = $this->getimgRes($directory . $filename, $size[2]);
}
if (function_exists('imagecreatetruecolor')) {
$this->truecolor = true;
}
$this->width = $size[0];
$this->height = $size[1];
$this->string = $size[3];
}
}
}
示例5: theme_html_picture
function theme_html_picture()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER, $LINEBREAK;
global $album, $lang_date, $template_display_media;
global $lang_display_image_php, $lang_picinfo, $lang_common, $lang_errors;
$superCage = Inspekt::makeSuperCage();
$pid = $CURRENT_PIC_DATA['pid'];
$pic_title = '';
if (!isset($USER['liv']) || !is_array($USER['liv'])) {
$USER['liv'] = array();
}
// Add 1 to hit counter
if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && !in_array($pid, $USER['liv']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) {
add_hit($pid);
if (count($USER['liv']) > 4) {
array_shift($USER['liv']);
}
array_push($USER['liv'], $pid);
}
if ($CURRENT_PIC_DATA['title'] != '') {
$pic_title .= $CURRENT_PIC_DATA['title'] . $LINEBREAK;
}
if ($CURRENT_PIC_DATA['caption'] != '') {
$pic_title .= $CURRENT_PIC_DATA['caption'] . $LINEBREAK;
}
if ($CURRENT_PIC_DATA['keywords'] != '') {
$pic_title .= $lang_common['keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
}
if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) {
template_extract_block($template_display_media, 'img_desc');
} else {
if (!$CURRENT_PIC_DATA['title']) {
template_extract_block($template_display_media, 'title');
}
if (!$CURRENT_PIC_DATA['caption']) {
template_extract_block($template_display_media, 'caption');
}
}
$CURRENT_PIC_DATA['menu'] = html_picture_menu();
//((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';
$image_size = array();
if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'])) {
$picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
} else {
$picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
}
$pic_title = '';
$mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']);
if ($mime_content['content'] == 'movie' || $mime_content['content'] == 'audio') {
if ($CURRENT_PIC_DATA['pwidth'] == 0 || $CURRENT_PIC_DATA['pheight'] == 0) {
$resize_method = $CONFIG['picture_use'] == "thumb" ? $CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use'] : $CONFIG['picture_use'];
if ($resize_method == 'ht') {
$pwidth = $CONFIG['picture_width'] * 4 / 3;
$pheight = $CONFIG['picture_width'];
} else {
$pwidth = $CONFIG['picture_width'];
$pheight = $CONFIG['picture_width'] * 3 / 4;
}
$CURRENT_PIC_DATA['pwidth'] = $pwidth;
// Default width
// Set default height; if file is a movie
if ($mime_content['content'] == 'movie') {
$CURRENT_PIC_DATA['pheight'] = $pheight;
// Default height
}
}
$ctrl_offset['mov'] = 15;
$ctrl_offset['wmv'] = 45;
$ctrl_offset['swf'] = 0;
$ctrl_offset['rm'] = 0;
$ctrl_offset_default = 45;
$ctrl_height = isset($ctrl_offset[$mime_content['extension']]) ? $ctrl_offset[$mime_content['extension']] : $ctrl_offset_default;
$image_size['whole'] = 'width="' . $CURRENT_PIC_DATA['pwidth'] . '" height="' . ($CURRENT_PIC_DATA['pheight'] + $ctrl_height) . '"';
}
if ($mime_content['content'] == 'image') {
list($image_size['width'], $image_size['height'], , $image_size['geom']) = cpg_getimagesize(urldecode($picture_url));
if ($CURRENT_PIC_DATA['mode'] != 'fullsize') {
$winsizeX = $CURRENT_PIC_DATA['pwidth'] + $CONFIG['fullsize_padding_x'];
//the +'s are the mysterious FF and IE paddings
$winsizeY = $CURRENT_PIC_DATA['pheight'] + $CONFIG['fullsize_padding_y'];
//the +'s are the mysterious FF and IE paddings
if ($CONFIG['transparent_overlay'] == 1) {
$pic_html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td background=\"" . $picture_url . "\" width=\"{$image_size['width']}\" height=\"{$image_size['height']}\" class=\"image\">";
$pic_html_href_close = '</a>' . $LINEBREAK;
if (!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) {
if ($CONFIG['allow_user_registration'] == 0) {
$pic_html_href_close = '';
} else {
$pic_html .= '<a href="javascript:;" onclick="alert(\'' . sprintf($lang_errors['login_needed'], '', '', '', '') . '\');">';
}
} elseif (USER_ID && USER_ACCESS_LEVEL <= 2) {
$pic_html .= '<a href="javascript:;" onclick="alert(\'' . sprintf($lang_errors['access_intermediate_only'], '', '', '', '') . '\');">';
} else {
$pic_html .= "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid={$pid}&fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width={$winsizeX},height={$winsizeY}')\">";
}
$pic_title = $lang_display_image_php['view_fs'] . $LINEBREAK . '==============' . $LINEBREAK . $pic_title;
$pic_html .= "<img src=\"images/image.gif?id=" . floor(rand() * 1000 + rand()) . "\" width=\"{$image_size['width']}\" height=\"{$image_size['height']}\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
$pic_html .= $pic_html_href_close . '</td></tr></table>';
//PLUGIN FILTER
$pic_html = CPGPluginAPI::filter('html_image_reduced_overlay', $pic_html);
//.........这里部分代码省略.........
示例6: picrow
/**
* picrow()
*
* return the HTML code for a row to be displayed for an image
* the row contains a checkbox, the image name, a thumbnail
*
* @param $picfile the full path of the file that contains the picture
* @param $picid the name of the check box
* @return the HTML code
*/
function picrow($picfile, $picid, $albid)
{
global $CONFIG, $expic_array, $picrowCounter;
$encoded_picfile = urlencode(base64_encode($picfile));
$picname = $CONFIG['fullpath'] . $picfile;
$pic_url = urlencode($picfile);
$pic_fname = basename($picfile);
$pic_dirname = dirname($picname);
$thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname;
if ($CONFIG['display_thumbs_batch_add'] == 1) {
if (file_exists($thumb_file)) {
$thumb_info = cpg_getimagesize($picname);
$thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48);
$img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" alt="" />';
} elseif (is_image($picname)) {
$img = '<img src="showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0" alt="" />';
} else {
$file['filepath'] = $pic_dirname . '/';
$file['filename'] = $pic_fname;
$filepathname = get_pic_url($file, 'thumb');
$img = '<img src="' . $filepathname . '" class="thumbnail" width="48" border="0" alt="" />';
}
} else {
$img = '';
}
if (filesize($picname) && is_readable($picname)) {
// for video support, maybe check: http://www.getid3.org/
// for now, hack in something that works (don't check !$fullimagesize)
$fullimagesize = cpg_getimagesize($picname);
$winsizeX = $fullimagesize[0] + 16;
$winsizeY = $fullimagesize[1] + 16;
// $checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked';
$picfile_replaced_forbidden = dirname($picfile) . '/' . replace_forbidden(basename($picfile));
if ($CONFIG['batch_add_hide_existing_files'] && isset($expic_array[$picfile_replaced_forbidden])) {
return;
}
if ($picrowCounter++ % 2) {
$rowStyle = 'tableb';
} else {
$rowStyle = 'tableb tableb_alternate';
}
$checked = isset($expic_array[$picfile_replaced_forbidden]) || !is_known_filetype($pic_fname) ? '' : 'checked="checked"';
$return = <<<EOT
<tr>
<td class="{$rowStyle}" valign="middle" width="30">
<input name="pics[]" id="checkbox_p_{$picid}" type="checkbox" value="{$picid}" {$checked} />
<input name="album_lb_id_{$picid}" type="hidden" value="{$albid}" />
<input name="picfile_{$picid}" type="hidden" value="{$encoded_picfile}" />
</td>
EOT;
// if $fullimagesize is not null, then assume it's an image
if ($fullimagesize) {
$return .= <<<EOT
<td class="{$rowStyle}" valign="middle">
<a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">{$pic_fname}</a>
</td>
<td class="{$rowStyle}" valign="middle" align="center">
<a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&picfile={$pic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">
EOT;
} else {
// assume it's not an image so hope that browser can display/play it with a helper app
$nonpic_url = rawurldecode($pic_url);
$return .= <<<EOT
<td class="{$rowStyle}" valign="middle">
<a href="javascript:;" onclick= "MM_openBrWindow('{$CONFIG['fullpath']}{$nonpic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">{$pic_fname}</a>
</td>
<td class="{$rowStyle}" valign="middle" align="center">
<a href="javascript:;" onclick= "MM_openBrWindow('{$CONFIG['fullpath']}{$nonpic_url}', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width={$winsizeX}, height={$winsizeY}')">
EOT;
}
if ($CONFIG['display_thumbs_batch_add'] == 1) {
$return .= <<<EOT
<img src="images/spacer.gif" width="1" height="48" border="0" alt="" />
EOT;
}
$return .= <<<EOT
{$img}</a><br />
</td>
<td class="{$rowStyle}" valign="middle" width="100" height="40">
<p id="p_{$picid}" name="addpic.php?pic_file={$encoded_picfile}"></p>
</td>
</tr>
EOT;
return $return;
} else {
$winsizeX = 300;
$winsizeY = 300;
$return = <<<EOT
<tr>
//.........这里部分代码省略.........
示例7: refresh_db
function refresh_db()
{
global $CONFIG, $lang_util_php, $lang_common;
$superCage = Inspekt::makeSuperCage();
if ($superCage->post->keyExists('albumid')) {
$albumid = $superCage->post->getInt('albumid');
} else {
$albumid = 0;
}
$albstr = $albumid ? "WHERE aid = {$albumid}" : '';
$numpics = $superCage->post->getInt('refresh_numpics');
if ($superCage->post->keyExists('refresh_startpic')) {
$startpic = $superCage->post->getInt('refresh_startpic');
} else {
$startpic = 0;
}
starttable('100%', $lang_util_php['update_result'], 3);
echo "<tr><th class=\"tableh2\">{$lang_util_php['file']}</th><th class=\"tableh2\">{$lang_util_php['problem']}</th><th class=\"tableh2\">{$lang_util_php['status']}</th></tr>";
$outcome = 'none';
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} {$albstr} ORDER BY pid ASC LIMIT {$startpic}, {$numpics}");
$count = mysql_num_rows($result);
$found = 0;
while ($row = mysql_fetch_assoc($result)) {
extract($row, EXTR_PREFIX_ALL, "db");
unset($prob);
$full_pic_url = $CONFIG['fullpath'] . $db_filepath . $db_filename;
$thumb_url = $CONFIG['fullpath'] . $db_filepath . $CONFIG['thumb_pfx'] . $db_filename;
$normal_url = $CONFIG['fullpath'] . $db_filepath . $CONFIG['normal_pfx'] . $db_filename;
$url = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . "displayimage.php?pos=-{$db_pid}" . '" target="_blank">' . "{$db_title} ({$db_pid})" . '</a>';
if (file_exists($full_pic_url)) {
$filesize = filesize($full_pic_url);
$dimensions = cpg_getimagesize($full_pic_url);
if ($filesize) {
$thumb_filesize = filesize($thumb_url);
$normal_filesize = filesize($normal_url);
$total_filesize = $filesize + $thumb_filesize + $normal_filesize;
if ($total_filesize != $db_total_filesize) {
$prob .= "{$lang_util_php['incorrect_filesize']}<br />{$lang_util_php['database']}{$db_total_filesize}{$lang_util_php['bytes']}<br />{$lang_util_php['actual']}{$total_filesize}{$lang_util_php['bytes']}<br />";
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET total_filesize = '{$total_filesize}' WHERE pid = '{$db_pid}' LIMIT 1");
$outcome = $lang_util_php['updated'];
}
if ($filesize != $db_filesize) {
$prob .= "{$lang_util_php['incorrect_filesize']}<br />{$lang_util_php['database']}{$db_filesize}{$lang_util_php['bytes']}<br />{$lang_util_php['actual']}{$filesize}{$lang_util_php['bytes']}<br />";
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filesize = '{$filesize}' WHERE pid = '{$db_pid}' LIMIT 1");
$outcome = $lang_util_php['updated'];
}
} else {
$prob .= $lang_util_php['filesize_error'] . '<br />';
$outcome = $lang_util_php['skipped'];
}
if ($dimensions) {
if ($dimensions[0] != $db_pwidth || $dimensions[1] != $db_pheight) {
$prob .= "{$lang_util_php['incorect_dimension']}<br />{$lang_util_php['database']}{$db_pwidth}x{$db_pheight}<br />{$lang_util_php['actual']}{$dimensions[0]}x{$dimensions[1]}<br />";
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET pwidth = '{$dimensions[0]}', pheight = '{$dimensions[1]}' WHERE pid = '{$db_pid}' LIMIT 1");
$outcome = $lang_util_php['updated'];
}
} else {
$prob .= $lang_util_php['dimension_error'] . '<br />';
$outcome = $lang_util_php['skipped'];
}
} else {
$prob .= sprintf($lang_util_php['fullpic_error'], $full_pic_url) . '<br />';
$outcome = $lang_util_php['cannot_fix'];
}
if ($prob) {
echo "<tr><td class=\"tableb\">{$url}</td><td class=\"tableb\">{$prob}</td><td class=\"tableb\">{$outcome}</td></tr>";
} else {
echo "<tr><td class=\"tableb\">{$url}</td><td class=\"tableb\">{$lang_util_php['no_prob_detect']}</td><td class=\"tableb\">{$lang_common['ok']}</td></tr>";
}
}
endtable();
if ($outcome == 'none') {
echo $lang_util_php['no_prob_found'];
}
if ($count == $numpics) {
$startpic += $numpics;
list($timestamp, $form_token) = getFormToken();
echo <<<EOT
<form name="cpgform4" id="cpgform4" action="util.php" method="post">
<input type="hidden" name="action" value="refresh_db" />
<input type="hidden" name="refresh_numpics" value="{$numpics}" />
<input type="hidden" name="refresh_startpic" value="{$startpic}" />
<input type="hidden" name="albumid" value="{$albumid}" />
<button type="submit" class="button" name="submit" id="submit" value="{$lang_util_php['continue']}">{$lang_util_php['continue']} {$icon_array['continue']}</button>
<input type="hidden" name="form_token" value="{$form_token}" />
<input type="hidden" name="timestamp" value="{$timestamp}" />
</form>
EOT;
}
mysql_free_result($result);
}
示例8: cpgUserLastComment
function cpgUserLastComment($uid)
{
global $CONFIG;
$result = cpg_db_query("SELECT count(*), MAX(msg_id) FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE c.pid = p.pid AND approval='YES' AND author_id = '{$uid}' {$FORBIDDEN_SET}");
$nbEnr = mysql_fetch_array($result);
$comment_count = $nbEnr[0];
$lastcom_id = $nbEnr[1];
mysql_free_result($result);
$lastcom = '';
if ($comment_count) {
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body, approval " . "FROM {$CONFIG['TABLE_COMMENTS']} AS c, {$CONFIG['TABLE_PICTURES']} AS p " . "WHERE msg_id='" . $lastcom_id . "' AND approval = 'YES' AND c.pid = p.pid";
$result = cpg_db_query($sql);
if (mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
mysql_free_result($result);
$pic_url = get_pic_url($row, 'thumb');
if (!is_image($row['filename'])) {
$image_info = cpg_getimagesize(urldecode($pic_url));
$row['pwidth'] = $image_info[0];
$row['pheight'] = $image_info[1];
}
$image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']);
$mime_content = cpg_get_type($row['filename']);
$lastcom = '<img src="' . $pic_url . '" class="image"' . $image_size['geom'] . ' border="0" alt="" />';
}
}
$lastComArray = array();
$lastComArray['thumb'] = $lastcom;
$lastComArray['comment'] = $row['msg_body'];
$lastComArray['msg_date'] = $row['msg_date'];
$lastComArray['count'] = $comment_count;
return $lastComArray;
}
示例9: foreach
EOT;
$i = 100;
$lb = '';
$j = 1;
if (count($rowset) > 0) {
foreach ($rowset as $picture) {
$get_photo_name = $picture['title'];
$picname = $CONFIG['fullpath'] . $picture['filepath'] . $picture['filename'];
$pic_url = urlencode($picture['filename']);
$pic_fname = basename($picture['filename']);
$pic_dirname = dirname($picname);
$thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname;
$img = '';
if (file_exists($thumb_file)) {
$thumb_info = cpg_getimagesize($picname);
$thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48);
$img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" alt="" title="' . $get_photo_name . '" />';
} elseif (is_image($picname)) {
$img = '<img src="showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0" alt="" title="' . $get_photo_name . '" />';
} else {
$file['filepath'] = $pic_dirname . '/';
$file['filename'] = $pic_fname;
$filepathname = get_pic_url($file, 'thumb');
$img = '<img src="' . $filepathname . '" class="thumbnail" width="48" border="0" alt="" title="' . $get_photo_name . '" />';
}
$unique_id = uniqid(rand());
$pic_title = $picture['title'] ? "<strong>{$picture['title']}</strong><br />\n" : '';
$lb .= <<<EOT
<tr id="sort-{$picture['pid']}">
<td class="dragHandle"></td>
示例10: cpg_die
$uploaded_pic = $dest_dir . $picture_name;
CPGPluginAPI::action('upload_html_pre_move', $superCage->files->getRaw("/userpicture/tmp_name"));
// Move the picture into its final location
// getRaw is safe here since this filename is generated by the server
if (!move_uploaded_file($superCage->files->getRaw("/userpicture/tmp_name"), $uploaded_pic)) {
cpg_die(CRITICAL_ERROR, sprintf($lang_db_input_php['err_move'], $picture_name, $dest_dir), __FILE__, __LINE__, true);
}
// Change file permission
chmod($uploaded_pic, octdec($CONFIG['default_file_mode']));
// Get picture information
// Check that picture file size is lower than the maximum allowed
if (filesize($uploaded_pic) > $CONFIG['max_upl_size'] * 1024) {
@unlink($uploaded_pic);
cpg_die(ERROR, sprintf($lang_db_input_php['err_imgsize_too_large'], $CONFIG['max_upl_size']), __FILE__, __LINE__);
} elseif (is_image($picture_name)) {
$imginfo = cpg_getimagesize($uploaded_pic);
if ($imginfo == null) {
// getimagesize does not recognize the file as a picture
@unlink($uploaded_pic);
cpg_die(ERROR, $lang_db_input_php['err_invalid_img'], __FILE__, __LINE__, true);
} elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && $CONFIG['GIF_support'] == 0) {
// JPEG and PNG only are allowed with GD
@unlink($uploaded_pic);
cpg_die(ERROR, $lang_errors['gd_file_type_err'], __FILE__, __LINE__, true);
// Check that picture size (in pixels) is lower than the maximum allowed
}
// Image is ok
}
// Upload is ok
// Create thumbnail and internediate image and add the image into the DB
$result = add_picture($album, $filepath, $picture_name, 0, $title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip, $superCage->post->getInt('width'), $superCage->post->getInt('height'));
示例11: resize_image
/**
* resize_image()
*
* Create a file containing a resized image
*
* @param $src_file the source file
* @param $dest_file the destination file
* @param $new_size the size of the square within which the new image must fit
* @param $method the method used for image resizing
* @return 'true' in case of success
*/
function resize_image($src_file, $dest_file, $new_size, $method, $thumb_use)
{
global $CONFIG, $ERROR;
global $lang_errors;
$imginfo = cpg_getimagesize($src_file);
if ($imginfo == null) {
return false;
}
// GD can only handle JPG & PNG images
//if ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($method == 'gd1' || $method == 'gd2')) {
if ($imginfo[2] != GIS_JPG && $imageinfo[2] != GIS_PNG && $CONFIG['GIF_support'] == 0) {
$ERROR = $lang_errors['gd_file_type_err'];
return false;
}
// height/width
$srcWidth = $imginfo[0];
$srcHeight = $imginfo[1];
if ($thumb_use == 'ht') {
$ratio = $srcHeight / $new_size;
} elseif ($thumb_use == 'wd') {
$ratio = $srcWidth / $new_size;
} else {
$ratio = max($srcWidth, $srcHeight) / $new_size;
}
$ratio = max($ratio, 1.0);
$destWidth = (int) ($srcWidth / $ratio);
$destHeight = (int) ($srcHeight / $ratio);
// Method for thumbnails creation
switch ($method) {
case "im":
if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
// get the basedir, remove '/include'
$cur_dir = substr(dirname(__FILE__), 0, -8);
$src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"';
$im_dest_file = str_replace('%', '%%', '"' . $cur_dir . '\\' . strtr($dest_file, '/', '\\') . '"');
} else {
$src_file = escapeshellarg($src_file);
$im_dest_file = str_replace('%', '%%', escapeshellarg($dest_file));
}
$output = array();
/*
* Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files.
* By Aditya Mooley <aditya@sanisoft.com>
*/
if (eregi("win", $_ENV['OS'])) {
$cmd = "\"" . str_replace("\\", "/", $CONFIG['impath']) . "convert\" -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} -geometry {$destWidth}x{$destHeight} " . str_replace("\\", "/", $src_file) . " " . str_replace("\\", "/", $im_dest_file);
exec("\"{$cmd}\"", $output, $retval);
} else {
$cmd = "{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} -geometry {$destWidth}x{$destHeight} {$src_file} {$im_dest_file}";
exec($cmd, $output, $retval);
}
if ($retval) {
$ERROR = "Error executing ImageMagick - Return value: {$retval}";
if ($CONFIG['debug_mode']) {
// Re-execute the command with the backtit operator in order to get all outputs
// will not work is safe mode is enabled
$output = `{$cmd} 2>&1`;
$ERROR .= "<br /><br /><div align=\"left\">Cmd line : <br /><font size=\"2\">" . nl2br(htmlspecialchars($cmd)) . "</font></div>";
$ERROR .= "<br /><br /><div align=\"left\">The convert program said:<br /><font size=\"2\">";
$ERROR .= nl2br(htmlspecialchars($output));
$ERROR .= "</font></div>";
}
@unlink($dest_file);
return false;
}
break;
case "gd1":
if (!function_exists('imagecreatefromjpeg')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
}
if ($imginfo[2] == GIS_JPG) {
$src_img = imagecreatefromjpeg($src_file);
} else {
$src_img = imagecreatefrompng($src_file);
}
if (!$src_img) {
$ERROR = $lang_errors['invalid_image'];
return false;
}
$dst_img = imagecreate($destWidth, $destHeight);
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
imagedestroy($src_img);
imagedestroy($dst_img);
break;
case "gd2":
if (!function_exists('imagecreatefromjpeg')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
}
//.........这里部分代码省略.........
示例12: list_cat_albums
/**
* list_cat_albums()
*
* This has been added to list the albums in a category, used for showing first level albums, largely a repetition of code elsewhere
* Redone for a cleaner approach
* @param integer $cat Category id for which albums are needed
*/
function list_cat_albums($cat, $catdata)
{
global $CONFIG, $lang_date, $FORBIDDEN_SET_DATA;
global $lang_list_albums;
$PAGE = 1;
if ($cat == 0) {
return '';
}
$cat_owner_id = $cat > 10000 ? 10000 - $cat : 10001;
$cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $cat_owner_id);
$cpg_privatepic_data = cpg_get_system_thumb('private.jpg', $cat_owner_id);
$alb_per_page = $CONFIG['albums_per_page'];
//unused code {SaWey}
/*$maxTab = $CONFIG['max_tabs'];
$album_filter = '';
$pic_filter = '';
if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) {
$album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET);
$pic_filter = ' and ' . $FORBIDDEN_SET;
}*/
$nbAlb = $catdata['details']['alb_count'];
if ($nbAlb == 0) {
return;
}
$totalPages = ceil($nbAlb / $alb_per_page);
$alb_list = array();
$approved = ' AND approved=\'YES\'';
$forbidden_set_string = count($FORBIDDEN_SET_DATA) > 0 ? ' AND aid NOT IN (' . implode(', ', $FORBIDDEN_SET_DATA) . ')' : '';
$last_pids = array();
$last_pid_data = array();
foreach ($catdata['subalbums'] as $aid => $album) {
if ($CONFIG['link_pic_count'] == 1 || $album['pic_count'] == 0) {
if (!empty($album['keyword'])) {
$keyword = $album['keyword'] ? "AND (keywords like '%" . addslashes($album['keyword']) . "%' {$forbidden_set_string})" : '';
$query = "SELECT count(pid) AS link_pic_count, max(pid) AS link_last_pid, max(ctime) AS link_last_upload " . " FROM {$CONFIG['TABLE_PICTURES']} " . " WHERE ((aid != '{$aid}' {$forbidden_set_string}) {$keyword}) {$approved}";
$result = cpg_db_query($query);
$link_stat = $result->fetchAssoc(true);
$catdata['subalbums'][$aid]['link_pic_count'] = $link_stat['link_pic_count'];
$catdata['subalbums'][$aid]['last_pid'] = !empty($album['last_pid']) && $album['last_pid'] > $link_stat['link_last_pid'] ? $album['last_pid'] : $link_stat['link_last_pid'];
if ($CONFIG['link_last_upload'] && $link_stat['link_pic_count'] > 0) {
$catdata['subalbums'][$aid]['last_upload'] = $album['last_upload'] > $link_stat['link_last_upload'] ? $album['last_upload'] : $link_stat['link_last_upload'];
}
}
}
if ($catdata['subalbums'][$aid]['last_pid']) {
$last_pids[] = $catdata['subalbums'][$aid]['last_pid'];
}
if ($album['thumb'] > 0) {
$last_pids[] = $album['thumb'];
}
}
if (count($last_pids)) {
$result = cpg_db_query("SELECT pid, filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} WHERE pid IN (" . implode(',', $last_pids) . ")");
while ($row = $result->fetchAssoc()) {
$last_pid_data[$row['pid']] = $row;
unset($last_pid_data[$row['pid']]['pid']);
}
$result->free();
}
unset($last_pids);
foreach ($catdata['subalbums'] as $aid => $album) {
// Inserts a thumbnail if the album contains 1 or more images
//unused code {SaWey}
//$visibility = $album['visibility'];
$keyword = $album['keyword'] ? "OR (keywords like '%" . addslashes($album['keyword']) . "%' {$forbidden_set_string})" : '';
if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
//test for visibility
if ($album['pic_count'] > 0 || !empty($album['link_pic_count'])) {
if (!empty($last_pid_data[$album['thumb']]['filename'])) {
$picture = $last_pid_data[$album['thumb']];
} elseif ($album['thumb'] < 0) {
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} WHERE ((aid = '{$aid}' {$forbidden_set_string}) {$keyword}) {$approved} " . "ORDER BY RAND() LIMIT 0,1";
$result = cpg_db_query($sql);
$picture = $result->fetchAssoc(true);
} else {
$picture = $last_pid_data[$album['last_pid']];
}
$pic_url = get_pic_url($picture, 'thumb');
if (!is_image($picture['filename'])) {
$image_info = cpg_getimagesize(urldecode($pic_url));
$picture['pwidth'] = $image_info[0];
$picture['pheight'] = $image_info[1];
}
//thumb cropping
if (array_key_exists('system_icon', $picture) && $picture['system_icon'] == true) {
$image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], true, 'cat_thumb');
} else {
$image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], false, 'cat_thumb');
}
$alb_list[$aid]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image thumbnail\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\" />";
} else {
//.........这里部分代码省略.........
示例13: makethumbnail
function makethumbnail($src_file, $newSize, $method)
{
global $CONFIG;
$content_type = array(GIS_GIF => 'gif', GIS_JPG => 'jpeg', GIS_PNG => 'png');
// Checks that file exists and is readable
if (!filesize($src_file) || !is_readable($src_file)) {
header("Content-type: image/png");
fpassthru(fopen(READ_ERROR_ICON, 'rb'));
exit;
}
// find the image size, no size => unknow type
$imginfo = cpg_getimagesize($src_file);
if ($imginfo == null) {
header("Content-type: image/png");
fpassthru(fopen(UNKNOW_ICON, 'rb'));
exit;
}
// GD can't handle gif images
//if ($imginfo[2] == GIS_GIF && ($method == 'gd1' || $method == 'gd2')) {
if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 0) {
header("Content-type: image/png");
fpassthru(fopen(GIF_ICON, 'rb'));
exit;
}
// height/width
$srcWidth = $imginfo[0];
$srcHeight = $imginfo[1];
$ratio = max($srcWidth, $srcHeight) / $newSize;
$ratio = max($ratio, 1.0);
$destWidth = (int) ($srcWidth / $ratio);
$destHeight = (int) ($srcHeight / $ratio);
// Choose method for thumb creation
switch ($method) {
case "im":
if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
$cur_dir = dirname(__FILE__);
$src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"';
} else {
$src_file = escapeshellarg($src_file);
}
header("Content-type: image/" . $content_type[$imginfo[2]]);
passthru("{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} -antialias -geometry {$destWidth}x{$destHeight} {$src_file} -");
break;
case "gd2":
if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 1) {
$src_img = imagecreatefromgif($src_file);
} elseif ($imginfo[2] == GIS_JPG) {
$src_img = imagecreatefromjpeg($src_file);
} else {
$src_img = imagecreatefrompng($src_file);
}
if ($imginfo[2] == GIS_GIF) {
$dst_img = imagecreate($destWidth, $destHeight);
} else {
$dst_img = imagecreatetruecolor($destWidth, $destHeight);
}
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
header("Content-type: image/jpeg");
imagejpeg($dst_img);
imagedestroy($src_img);
imagedestroy($dst_img);
break;
}
}
示例14: cpg_getimagesize
/**
* function cpg_getimagesize()
*
* Try to get the size of an image, this is custom built as some webhosts disable this function or do weird things with it
*
* @param string $image
* @param boolean $force_cpg_function
* @return array $size
*/
function cpg_getimagesize($image, $force_cpg_function = false)
{
if (!function_exists('getimagesize') || $force_cpg_function) {
// custom function borrowed from http://www.wischik.com/lu/programmer/get-image-size.html
$f = @fopen($image, 'rb');
if ($f === false) {
return false;
}
fseek($f, 0, SEEK_END);
$len = ftell($f);
if ($len < 24) {
fclose($f);
return false;
}
fseek($f, 0);
$buf = fread($f, 24);
if ($buf === false) {
fclose($f);
return false;
}
if (ord($buf[0]) == 255 && ord($buf[1]) == 216 && ord($buf[2]) == 255 && ord($buf[3]) == 224 && $buf[6] == 'J' && $buf[7] == 'F' && $buf[8] == 'I' && $buf[9] == 'F') {
$pos = 2;
while (ord($buf[2]) == 255) {
if (ord($buf[3]) == 192 || ord($buf[3]) == 193 || ord($buf[3]) == 194 || ord($buf[3]) == 195 || ord($buf[3]) == 201 || ord($buf[3]) == 202 || ord($buf[3]) == 203) {
break;
// we've found the image frame
}
$pos += 2 + (ord($buf[4]) << 8) + ord($buf[5]);
if ($pos + 12 > $len) {
break;
// too far
}
fseek($f, $pos);
$buf = $buf[0] . $buf[1] . fread($f, 12);
}
}
fclose($f);
// GIF:
if ($buf[0] == 'G' && $buf[1] == 'I' && $buf[2] == 'F') {
$x = ord($buf[6]) + (ord($buf[7]) << 8);
$y = ord($buf[8]) + (ord($buf[9]) << 8);
$type = 1;
}
// JPEG:
if (ord($buf[0]) == 255 && ord($buf[1]) == 216 && ord($buf[2]) == 255) {
$y = (ord($buf[7]) << 8) + ord($buf[8]);
$x = (ord($buf[9]) << 8) + ord($buf[10]);
$type = 2;
}
// PNG:
if (ord($buf[0]) == 0x89 && $buf[1] == 'P' && $buf[2] == 'N' && $buf[3] == 'G' && ord($buf[4]) == 0xd && ord($buf[5]) == 0xa && ord($buf[6]) == 0x1a && ord($buf[7]) == 0xa && $buf[12] == 'I' && $buf[13] == 'H' && $buf[14] == 'D' && $buf[15] == 'R') {
$x = (ord($buf[16]) << 24) + (ord($buf[17]) << 16) + (ord($buf[18]) << 8) + (ord($buf[19]) << 0);
$y = (ord($buf[20]) << 24) + (ord($buf[21]) << 16) + (ord($buf[22]) << 8) + (ord($buf[23]) << 0);
$type = 3;
}
// added ! from source line since it doesn't work otherwise
if (!isset($x, $y, $type)) {
return false;
}
return array($x, $y, $type, 'height="' . $x . '" width="' . $y . '"');
} else {
$size = getimagesize($image);
if (!$size) {
//false was returned
return cpg_getimagesize($image, true);
} elseif (!isset($size[0]) || !isset($size[1])) {
//webhost possibly changed getimagesize functionality
return cpg_getimagesize($image, true);
} else {
//function worked as expected, return the results
return $size;
}
}
}
示例15: cpg_die
}
$path_to_image = $dest_dir . $uniqueName;
//Now we upload the file.
if (!move_uploaded_file($_FILES['file']['tmp_name'], $path_to_image)) {
// The file upload has failed.
cpg_die(12);
}
// Change file permission
@chmod($path_to_image, octdec($CONFIG['default_file_mode']));
//silence the output in case chmod is disabled
// Create a testing alias.
$picture_alias = $matches[1] . "." . $matches[2];
// Check to see if the filename is consistent with that of a picture.
if (is_image($picture_alias)) {
// If it is, get the picture information
$imginfo = cpg_getimagesize($path_to_image);
// If cpg_getimagesize does not recognize the file as a picture, delete the picture.
if ($imginfo === 'FALSE') {
@unlink($path_to_image);
// The file upload has failed -- the image is not an image or it is corrupt.
cpg_die(13);
// JPEG and PNG only are allowed with GD. If the image is not allowed for GD,delete it.
//} elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($CONFIG['thumb_method'] == 'gd1' || $CONFIG['thumb_method'] == 'gd2')) {
} elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && $CONFIG['GIF_support'] == 0 && $CONFIG['thumb_method'] != 'im' && $CONFIG['thumb_method'] != 'gd2') {
@unlink($path_to_image);
// The file upload has failed -- the image is not allowed with GD.
cpg_die(14);
// Check that picture size (in pixels) is lower than the maximum allowed. If not, delete it.
} elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
// Yet to implement in API
if (USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) {