function plogger_get_album_thumb() { $rv = $GLOBALS["current_album"]; // figure out the thumbnail as well $thumb_query = "SELECT * FROM `" . TABLE_PREFIX . "pictures` WHERE "; if ($rv["thumbnail_id"] > 0) { $thumb_query .= " `id`=" . $rv["thumbnail_id"]; } else { $thumb_query .= " `parent_album`='" . $rv["id"] . "' ORDER BY `date_submitted` DESC LIMIT 1"; } $thumb_result = run_query($thumb_query); $thumb_data = mysql_fetch_assoc($thumb_result); if ($thumb_data) { $rv["thumbnail_id"] = $thumb_data["id"]; $rv["thumbnail_path"] = $thumb_data["path"]; } return generate_thumb($rv['thumbnail_path'], $rv['thumbnail_id'], THUMB_SMALL); }
<?php // this will create a picture thumbnail on disk // first it will be used for import only. if (empty($_GET["img"])) { return "No such image"; } require_once "../plog-functions.php"; require_once "../plog-globals.php"; require_once "../plog-load_config.php"; require_once "plog-admin-functions.php"; $files = get_files($config['basedir'] . 'uploads'); $found = false; $up_dir = $config['basedir'] . 'uploads'; foreach ($files as $file) { if (md5($file) == $_GET["img"]) { $found = true; $rname = substr($file, strlen($up_dir) + 1); $thumbpath = generate_thumb($up_dir . '/' . $rname, "import", THUMB_SMALL); print '<img src="' . $thumbpath . '" /></div>'; //print "found $relative_name!"; break; } }
<?php require_once "plog-admin.php"; require_once "../plog-load_config.php"; // load configuration variables from database require_once "../plog-functions.php"; // this script will just show a small preview of the thumbnail in admin view if // you can't differentiate the small pics. echo '<html><head> <body>'; $src = $_REQUEST['src']; $picture = get_picture_by_id($src); $id = $picture["id"]; $thumbpath = generate_thumb($picture["path"], $picture["id"], THUMB_LARGE); $thumbdir = $config["basedir"] . "thumbs/lrg-{$id}-" . basename($picture["path"]); list($width, $height, $type, $attr) = getimagesize($thumbdir); // print $thumbdir; echo ' <script language="JavaScript"> <!-- this.resizeTo(' . $width . '+25,' . $height . '+70); this.moveTo((screen.width-' . $width . ')/2, (screen.height-' . $height . ')/2); --> </script>'; // generate XHTML with thumbnail and link to picture view. $imgtag = '<img class="photos" src="' . $thumbpath . '" alt="' . $src . '"/>'; $output = $imgtag; ?> <html>
if (is_file($meta_file)) { // Pull in meta information include $meta_file; if ($counter % 2 == 0) { $table_row_color = 'color-1'; } else { $table_row_color = 'color-2'; } // Generate small preview thumb, update thumb if preview.png has been updated $timestamp = @filemtime($theme_dir . $theme_folder_basename . '/preview.png'); $thumbnail_config[THUMB_THEME]['timestamp'] = $timestamp; $thumbnail_config[THUMB_THEME]['size'] = 150; $preview_thumb = generate_thumb($theme_folder_name . 'preview.png', $theme_name, THUMB_THEME); // Generate large Lightbox preview thumb, update thumb if preview.png has been updated $thumbnail_config[THUMB_THEME]['size'] = 500; $preview_thumb_large = generate_thumb($theme_folder_name . 'preview.png', $theme_name . '-large', THUMB_THEME); // Start a new table row (alternating colors) if ($config['theme_dir'] == $theme_folder_basename) { $table_class = 'activated'; } else { $table_class = $table_row_color; } $output .= "\n\t\t\t" . '<tr class="' . $table_class . '">'; $output .= "\n\t\t\t\t" . '<td class="width-175">'; if ($preview_thumb) { $output .= '<div class="img-shadow"><a rel="lightbox" href="' . $preview_thumb_large . '"><img src="' . $preview_thumb . '" alt="' . $theme_name . '" /></a></div>'; } $output .= '</td> <td class="align-left width-100"><strong>' . $theme_name . '</strong><br />Version ' . $version . '</td> <td style="padding-right: 50px;">' . $description . '<br />• ' . plog_tr('Released under the') . ' ' . $license . '.</td> <td class="align-left width-100"><a href="' . $url . '">' . $author . '</a></td>';
require_once dirname(dirname(__FILE__)) . '/plog-load-config.php'; require PLOGGER_DIR . 'plog-admin/plog-admin.php'; require_once PLOGGER_DIR . 'plog-admin/plog-admin-functions.php'; // This script will just show a small preview of the thumbnail in admin view if // you can't differentiate the small pics. echo ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <body>'; $src = $_REQUEST['src']; $picture = get_picture_by_id($src); $id = $picture['id']; $thumbpath = generate_thumb($picture['path'], $picture['id'], THUMB_LARGE); $thumbdir = $config['basedir'] . 'plog-content/thumbs/lrg-$id-' . basename($picture['path']); list($width, $height, $type, $attr) = getimagesize($thumbdir); echo ' <script type="text/javascript"> <!-- this.resizeTo(' . $width . '+25,' . $height . '+70); this.moveTo((screen.width-' . $width . ')/2, (screen.height-' . $height . ')/2); --> </script>'; // Generate XHTML with thumbnail and link to picture view $imgtag = '<img class="photos" src="' . $thumbpath . '" alt="' . $src . '" />'; ?> <?php echo $imgtag;
<?php // This is mostly an interface for the XML service to get thumbnail URLs // without having to generate the thumb at the time that the URL is // needed. require "plog-functions.php"; require "plog-globals.php"; /** * plog-thumb.php interface for XML service * * Purpose: Provide a link to a thumbnail for a picture even when the thumbnail * may not have been generated yet. * * @param int id (required) * @param int type (default 1, any of 1,2,3,4) */ if (!isset($_REQUEST["id"]) || intval($_REQUEST["id"]) == 0) { exit; } if (!isset($_REQUEST["type"])) { $_REQUEST["type"] = 1; } $query = "SELECT\r\n\t\t`path`,\r\n\t\t`id`\r\n\tFROM `plogger_pictures`\r\n\tWHERE `id`=" . intval($_REQUEST["id"]); $result = run_query($query); $thumb = mysql_fetch_assoc($result); $thumb["type"] = intval($_REQUEST["type"]); $path = generate_thumb($thumb["path"], $thumb["id"], $thumb["type"]); header("Location: " . $path); exit;
* * Purpose: Provide a link to a thumbnail for a picture even when the thumbnail * may not have been generated yet. * * @param int id (required) * @param int type (default 1, any of 1,2,3,4) */ if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) { exit; } if (!isset($_REQUEST['type'])) { $_REQUEST['type'] = 1; } $query = "SELECT `path`, `id` FROM `plogger_pictures` WHERE `id`=" . intval($_REQUEST['id']); $result = run_query($query); $thumb = mysqli_fetch_assoc($result); $thumb['type'] = intval($_REQUEST['type']); $path = generate_thumb($thumb['path'], $thumb['id'], $thumb['type']); // Make sure the generated url and the browser url have the same domain syntax $browser_www = strpos($_SERVER['HTTP_HOST'], 'www'); $thumb_www = strpos($path, 'www'); if ($browser_www !== $thumb_www) { if ($browser_www === false) { $path = str_replace('www', '', $path); } else { $path = str_replace('//', '//www.', $path); } } close_db(); header('Location: ' . $path); exit;
function plog_edit_album_form($album_id) { global $config, $thumbnail_config; $album_id = intval($album_id); $album = get_album_by_id($album_id); $auto_graphic = $config['gallery_url'] . 'plog-admin/images/auto.gif'; $page = isset($_GET['plog_page']) ? '&plog_page=' . intval($_GET['plog_page']) : ''; $output = "\n\t\t" . '<form class="edit width-700" action="' . $_SERVER['PHP_SELF'] . '?level=albums&id=' . $album['parent_id'] . $page . '" method="post">'; $images = '<option class="thumboption" value="0" style="padding-left: 100px; background-image: url(' . $auto_graphic . ');">' . plog_tr('automatic') . '</option>'; $sql = "SELECT id, caption, path FROM " . PLOGGER_TABLE_PREFIX . "pictures p WHERE p.parent_album = '" . $album_id . "'"; $result = run_query($sql); while ($row = $result->fetch()) { $selected = $row['id'] == $album['thumbnail_id'] ? ' selected="selected"' : ''; $style = 'class="thumboption" style="padding-left: ' . ($thumbnail_config[THUMB_SMALL]['size'] + 5) . 'px; background-image: url(' . generate_thumb(SmartStripSlashes($row['path']), $row['id']) . ');"'; $images .= "\n\t\t\t\t" . '<option ' . $style . ' value="' . $row['id'] . '"' . $selected . '>'; $images .= !empty($row['caption']) ? SmartStripSlashes($row['caption']) : SmartStripSlashes(basename($row['path'])); $images .= "</option>"; } $output .= "\n\t\t\t" . '<div> <div class="strong">' . plog_tr('Edit Album Properties') . '</div> <p> <label class="strong" for="name" accesskey="n">' . plog_tr('<em>N</em>ame') . ':</label><br /> <input size="61" name="name" id="name" value="' . htmlspecialchars(SmartStripSlashes($album['name'])) . '" /> </p> <p> <label class="strong" for="description" accesskey="d">' . plog_tr('<em>D</em>escription') . ':</label><br /> <input size="61" name="description" id="description" value="' . htmlspecialchars(SmartStripSlashes($album['description'])) . '" /> </p> <p> <span class="strong">Thumbnail:</span><br /> <select name="thumbnail_id" class="thumbselect width-450" id="thumbselect" onchange="updateThumbPreview(this)">' . $images . ' </select> <script type="text/javascript">updateThumbPreview(document.getElementById(\'thumbselect\'));</script> </p> <input type="hidden" name="pid" value="' . $album_id . '" /> <input type="hidden" name="action" value="update-album" /> <input class="submit" name="update" value="' . plog_tr('Update') . '" type="submit" /> <input class="submit-cancel" name="cancel" value="' . plog_tr('Cancel') . '" type="submit" /> </div> </form>' . "\n"; return $output; }
$table_row_color = "color-1"; } else { $table_row_color = "color-2"; } // start a new table row (alternating colors) $output .= "<tr class=\"{$table_row_color}\">"; // give the row a checkbox $output .= '<td width="15"><input type="CHECKBOX" name="Selected[]" VALUE="' . $row["id"] . '"></td>'; // give the row a thumbnail, we need to look up the parent picture for the comment $picture = get_picture_by_id($row["parent_id"]); $thumbpath = generate_thumb($picture["path"], $picture["id"], THUMB_SMALL); // generate XHTML with thumbnail and link to picture view. $imgtag = '<div class="img-shadow"><img src="' . $thumbpath . '" title="' . $picture["caption"] . '" alt="' . $picture["caption"] . '" /></div>'; //$target = 'plog-thumbpopup.php?src='.$picture["id"];; //$java = "javascript:this.ThumbPreviewPopup('$target')"; $output .= '<td><a href="' . generate_thumb($picture["path"], $picture["id"], THUMB_LARGE) . '" rel="lightbox" title="' . plogger_get_picture_caption() . '">' . $imgtag . '</a></td>'; foreach ($row as $key => $value) { $value = htmlspecialchars($value); $value = SmartStripSlashes($value); if ($key == "unix_date") { $output .= '<td>' . date($config["date_format"], $value) . '</td>'; } else { if ($key == "allow_comments") { if ($value) { $output .= "<td>" . plog_tr('Yes') . "</td>"; } else { $output .= "<td>" . plog_tr('No') . "</td>"; } } else { if (in_array($key, $allowedCommentKeys)) { $output .= "<td><p id=\"comment-{$key}-" . $row[id] . "\">{$value} </p></td>";
$err = NULL; // Short error code list($src_width, $src_height) = imgsize($File->get_full_path()); if (!$resample_all_images && check_thumbnail_sizes($thumb_type, $thumb_width, $thumb_height, $src_width, $src_height)) { // There is no need to resample, use original! $err = $File->get_af_thumb_path($size_name, $mimetype, true, $size_x); if ($err[0] != '!' && @copy($File->get_full_path(), $err)) { // File was saved. Ouput that same file immediately: // note: @copy returns FALSE on failure, if not muted it'll print the error on screen $err = $File->output_cached_thumb($size_name, $mimetype, $mtime, $size_x); } } else { // Resample list($err, $src_imh) = load_image($File->get_full_path(), $mimetype); if (empty($err)) { list($err, $dest_imh) = generate_thumb($src_imh, $thumb_type, $thumb_width, $thumb_height, $thumb_percent_blur, $size_x); if (empty($err)) { $err = $File->save_thumb_to_cache($dest_imh, $size_name, $mimetype, $thumb_quality, $size_x); if (empty($err)) { // File was saved. Ouput that same file immediately: // This is probably better than recompressing the memory image.. $err = $File->output_cached_thumb($size_name, $mimetype, $mtime, $size_x); } else { // File could not be saved. // fp> We might want to output dynamically... // $err = output_image( $dest_imh, $mimetype ); } } } } }
continue; } if (!is_dir($realdir . $delim . $thumbdir)) { $u = umask(0); if (is_writable($realdir) !== TRUE) { chmod($realdir, 0777); } if (!@mkdir($realdir . $delim . $thumbdir, 0777)) { echo '<p style="color: red; text-align: center">' . word('mkdir_error') . '</span>'; break; } umask($u); } $thumb = $realdir . $delim . $thumbdir . $delim . $filename . '.thumb.jpg'; if (!is_file($thumb) || filemtime($file) > filemtime($thumb)) { generate_thumb($thumb, $file); } if ($filenames) { echo '<div>'; } if ($included && $inline) { echo '<a href="?'; if (array_key_exists('dir', $_REQUEST)) { echo 'dir=' . urlencode($_REQUEST['dir']) . '&'; } echo 'pic=' . $i . html($urlsuffix); } else { echo '<a href="' . html("{$dirnamehttp}/{$filename}"); } echo '"><img src="' . html("{$dirnamehttp}/{$thumbdir}/{$filename}.thumb.jpg"); echo '" alt="' . html($filename) . '" style="';
/** * This will spit out a content-type header followed by a thumbnail for this file. * * @todo a million things (fp) but you get the idea... * The generated thumb will be saved to a cached file here (fp) * The cache will be accessed through the File object (fp) * @todo cleanup memory resources * * @param string requested size: 'thumbnail' */ function thumbnail($req_size) { load_funcs('/files/model/_image.funcs.php'); $size_name = $req_size; switch ($req_size) { case 'fit-720x500': $thumb_width = 720; $thumb_height = 500; $thumb_quality = 90; break; case 'fit-640x480': $thumb_width = 640; $thumb_height = 480; $thumb_quality = 90; break; case 'fit-400x320': $thumb_width = 400; $thumb_height = 320; $thumb_quality = 85; break; case 'fit-320x320': $thumb_width = 320; $thumb_height = 320; $thumb_quality = 85; break; case 'fit-80x80': default: $size_name = 'fit-80x80'; $thumb_width = 80; $thumb_height = 80; $thumb_quality = 75; } $mimetype = $this->Filetype->mimetype; // Try to output the cached thumbnail: $err = $this->output_cached_thumb($size_name, $mimetype); if ($err == '!Thumbnail not found in .evocache') { // The thumbnail wasn't already in the cache, try to generate and cache it now: $err = NULL; // Short error code list($err, $src_imh) = load_image($this->get_full_path(), $mimetype); if (empty($err)) { list($err, $dest_imh) = generate_thumb($src_imh, $thumb_width, $thumb_height); if (empty($err)) { $err = $this->save_thumb_to_cache($dest_imh, $size_name, $mimetype, $thumb_quality); if (empty($err)) { // File was saved. Ouput that same file immediately: // This is probably better than recompressing the memory image.. $err = $this->output_cached_thumb($size_name, $mimetype); } else { // File could not be saved. // fp> We might want to output dynamically... // $err = output_image( $dest_imh, $mimetype ); } } } } // ERROR IMAGE if (!empty($err)) { // Generate an error image and try to squeeze an error message inside: // Note: we write small and close to the upper left in order to have as much text as possible on small thumbs $err = substr($err, 1); // crop 1st car $car_width = ceil(($thumb_width - 4) / 6); // $err = 'w='.$car_width.' '.$err; $err = wordwrap($err, $car_width, "\n"); $err = split("\n", $err); // split into lines $im_handle = imagecreatetruecolor($thumb_width, $thumb_height); // Create a black image $text_color = imagecolorallocate($im_handle, 255, 0, 0); $y = 0; foreach ($err as $err_string) { imagestring($im_handle, 2, 2, $y, $err_string, $text_color); $y += 11; } header('Content-type: image/png'); imagepng($im_handle); } }
<?php // This will create a picture thumbnail on disk // First it will be used for import only. // Load configuration variables from database, plog-globals, & plog-includes/plog-functions require_once dirname(dirname(__FILE__)) . '/plog-load-config.php'; require_once PLOGGER_DIR . 'plog-admin/plog-admin-functions.php'; // Set up the default error message $found = plog_tr('No such image'); if (empty($_GET['img'])) { exit($found); } $files = get_files(PLOGGER_DIR . 'plog-content/uploads'); $up_dir = PLOGGER_DIR . 'plog-content/uploads'; foreach ($files as $file) { if (md5($file) == $_GET['img']) { $rname = substr($file, strlen($up_dir) + 1); $thumbpath = generate_thumb($up_dir . '/' . $rname, 'import-' . substr(md5($file), 0, 2), THUMB_SMALL); $found = '<img src="' . $thumbpath . '" alt="" /></div>'; //echo "found $relative_name!"; break; } } close_db(); close_ftp(); echo $found;
function plogger_get_album_thumb() { $rv = $GLOBALS['current_album']; // Figure out the thumbnail as well $thumb_query = "SELECT * FROM \"" . PLOGGER_TABLE_PREFIX . "pictures\" WHERE "; if ($rv['thumbnail_id'] > 0) { $thumb_query .= " \"id\"=" . $rv['thumbnail_id']; } else { $thumb_query .= " \"parent_album\"='" . $rv['id'] . "' ORDER BY \"date_submitted\" DESC LIMIT 1"; } $thumb_result = run_query($thumb_query); $thumb_data = $thumb_result->fetch(); if ($thumb_data) { $rv['thumbnail_id'] = $thumb_data['id']; $rv['thumbnail_path'] = $thumb_data['path']; } return generate_thumb($rv['thumbnail_path'], $rv['thumbnail_id'], THUMB_SMALL); }
/* The database query to pull random images from a specific collection. Uncomment and change the X to the ID of the desired collection. */ //$plog_random_images_query = "SELECT * FROM ".PLOGGER_TABLE_PREFIX."pictures WHERE `parent_collection` = X ORDER BY RAND() LIMIT $plog_random_images_amount"; $plog_random_images_result = mysqli_query($GLOBALS["PLOGGER_DBH"], $plog_random_images_query) or die("Could not execute query: {$plog_random_images_query}." . mysqli_error($GLOBALS["PLOGGER_DBH"])); $config['baseurl'] = $plog_random_images_site_url; /* The loop */ while ($row = mysqli_fetch_array($plog_random_images_result)) { $id = $row['id']; $path = $row['path']; $caption = SmartStripSlashes($row['caption']); $name = substr(basename($row['path']), 0, strrpos(basename($row['path']), '.')); $cap_or_name = !empty($caption) ? $caption : $name; ?> <a href="<?php echo generate_url('picture', $id); ?> " title="<?php echo addcslashes($cap_or_name, '"'); ?> "><img class="random-images-thumbnail" src="<?php echo generate_thumb($path, $id); ?> " alt="<?php echo $name; ?> " /></a><br /> <p class="random-images-caption"><?php echo $caption; ?> </p> <?php }
$thumburl = thumb($image, array('width' => $thumbwidth, 'quality' => $quality, 'crop' => $crop), false); if ($multisizes == true) { $ms_datasrcset = ""; if ($thumbwidth > 300) { $ms_datasrcset .= generate_thumb($image, $quality, $crop, 300); } if ($thumbwidth > 600) { $ms_datasrcset .= generate_thumb($image, $quality, $crop, 600); } if ($thumbwidth > 1200) { $ms_datasrcset .= generate_thumb($image, $quality, $crop, 1200); } if ($thumbwidth > 1600) { $ms_datasrcset .= generate_thumb($image, $quality, $crop, 1600); } $ms_datasrcset .= generate_thumb($image, $quality, $crop, $thumbwidth); } if ($feed == true) { $imagethumb = html::img($thumburl, array('class' => $class, 'alt' => html($alt))); $noscript = false; } // [1] Regular image; resized thumb (e.g. thumbs.width.default) if ($lazyload == false) { if ($multisizes == true) { $imagethumb = html::img($thumburl, array('data-sizes' => "auto", 'data-srcset' => $ms_datasrcset, 'class' => $class . ' lazyload', 'alt' => html($alt))); } else { $imagethumb = html::img($thumburl, array('class' => $class, 'alt' => html($alt))); } $noscript = false; } $placeholderSRC = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
$relative_name = substr($files[$i], strlen($upload_directory) + 1); if ($i == 0) { $output .= "\n\t\t\t" . '<form id="uploadForm" action="' . $_SERVER["PHP_SELF"] . $query . '" method="post" enctype="multipart/form-data"> <table style="width: 100%;" cellpadding="3" cellspacing="0"> <tr class="header"> <th class="table-header-left align-center width-15"><input name="allbox" type="checkbox" onclick="checkAll(document.getElementById(\'uploadForm\'));" checked="checked" /></th> <th class="table-header-middle align-left width-175" style="text-indent: 40px;">' . plog_tr('Thumb') . '</th> <th class="table-header-middle align-left width-200" style="text-align: left;">' . plog_tr('Filename') . '</th> <th class="table-header-middle align-left">' . plog_tr('Caption & Description (optional)') . '</th> <th class="table-header-right width-125">' . $comment . '</th> </tr>'; } // For each file within upload directory, list checkbox, thumbnail, caption box, description box, allow comments checkbox $table_row_color = $counter % 2 ? 'color-1' : 'color-2'; if (isset($_GET['nojs'])) { $thumbpath = generate_thumb($upload_directory . '/' . $relative_name, 'import-' . substr($file_key, 0, 2), THUMB_SMALL); } else { $thumbpath = $config['gallery_url'] . 'plog-admin/images/ajax-loader.gif'; } // Start a new table row (alternating colors) and generate XHTML with thumbnail and link to picture view. $output .= "\n\t\t\t\t" . '<tr class="' . $table_row_color . '"> <td class="align-center width-15"><p class="margin-5"><input type="checkbox" name="selected[]" value="' . $file_key . '" checked="checked" /></p></td> <td class="align-left width-175"><div class="img-shadow" id="pic_' . $file_key . '"><img src="' . $thumbpath . '" alt="thumbnail" /></div></td> <td class="align-left width-200 vertical-top">' . basename($files[$i]) . '</td> <td class="align-left vertical-top"> <input type="text" size="60" style="width: 95%;" name="captions[' . $file_key . ']" /><br /> <textarea name="descriptions[' . $file_key . ']" rows="4" cols="60" style="width: 95%;"></textarea> </td> <td class="align-center width-125"><input type="' . $comment_type . '" name="allow_comments[]" value="' . $file_key . '" /></td> </tr>'; $counter++;
function upgrade_images($num, $list) { $output = array(); $errors = array(); $count = 0; $list = array_slice($list, 0, $num); foreach ($list as $image) { if (!empty($image['id'])) { // Work on the images - move physical file, create directory if necessary and update path in database if (!makeDirs(PLOGGER_DIR . 'plog-content/images/' . dirname($image['new_path'] . '/'))) { $errors[] = plog_tr('Could not create directory') . ': ' . PLOGGER_DIR . 'plog-content/images/' . $image['new_path']; } else { if (!move_this(PLOGGER_DIR . $image['old_path'], PLOGGER_DIR . 'plog-content/images/' . $image['new_path'])) { $errors[] = plog_tr('Could not move file') . ': ' . PLOGGER_DIR . $image['old_path']; } else { @chmod(PLOGGER_DIR . $new_path, PLOGGER_CHMOD_DIR); $output[] = sprintf(plog_tr('Moved file %s -> %s'), '<strong>' . $image['old_path'] . '</strong>', '<strong>' . 'plog-content/images/' . $image['new_path'] . '</strong>'); // Update database $sql = "UPDATE " . PLOGGER_TABLE_PREFIX . "pictures SET path = '" . mysql_real_escape_string($image['new_path']) . "' WHERE id = '" . $image['id'] . "'"; run_query($sql); // Generate a new small thumbnail after database has been updated in case script times out $thumbpath = generate_thumb($image['new_path'], $image['id'], THUMB_SMALL); $count++; } } } else { if (!empty($image['uploads'])) { // Work on the uploads - move physical file and create directory in the uploads folder if necessary and update path in database if (!makeDirs(PLOGGER_DIR . dirname($image['new_path'] . '/'))) { $errors[] = plog_tr('Could not create directory') . ': ' . PLOGGER_DIR . $image['new_path']; } else { if (!move_this(PLOGGER_DIR . $image['old_path'], PLOGGER_DIR . $image['new_path'])) { $errors[] = plog_tr('Could not move file') . ': ' . PLOGGER_DIR . $image['old_path']; } else { @chmod(PLOGGER_DIR . $new_path, PLOGGER_CHMOD_DIR); $output[] = sprintf(plog_tr('Moved file %s -> %s'), '<strong>' . $image['old_path'] . '</strong>', '<strong>' . $image['new_path'] . '</strong>'); $count++; } } } else { if (!empty($image['container'])) { // Create the collection and album directory structure if (!makeDirs(PLOGGER_DIR . $image['new_path'] . '/')) { $errors[] = plog_tr('Could not create directory') . ': ' . PLOGGER_DIR . $image['new_path']; } else { $output[] = sprintf(plog_tr('Created directory %s'), '<strong>' . $image['new_path'] . '</strong>'); $count++; } } } } } return array('errors' => $errors, 'output' => $output, 'count' => $count); }
} if ($counter % 2 == 0) { $table_row_color = 'color-1'; } else { $table_row_color = 'color-2'; } // Start a new table row (alternating colors) $output .= "\n\t\t\t" . '<tr class="' . $table_row_color . '">'; // Give the row a checkbox $output .= "\n\t\t\t\t" . '<td class="align-center width-15"><p class="margin-5"><input type="checkbox" name="selected[]" value="' . $row['id'] . '" /></p></td>'; // Give the row a thumbnail, we need to look up the parent picture for the comment $picture = get_picture_by_id($row['parent_id']); $thumbpath = generate_thumb($picture['path'], $picture['id'], THUMB_SMALL); // Generate XHTML with thumbnail and link to picture view. $imgtag = '<img src="' . $thumbpath . '" title="' . htmlspecialchars(strip_tags($picture['caption']), ENT_QUOTES) . '" alt="' . htmlspecialchars(strip_tags($picture['caption']), ENT_QUOTES) . '" />'; $output .= "\n\t\t\t\t" . '<td class="align-center width-150"><div class="img-shadow"><a href="' . generate_thumb($picture['path'], $picture['id'], THUMB_LARGE) . '" rel="lightbox" title="' . htmlspecialchars($picture['caption'], ENT_QUOTES) . '">' . $imgtag . '</a></div></td>'; // Author / Email / Website $output .= "\n\t\t\t\t" . '<td class="align-left width-175"> <p class="margin-5 no-margin-bottom"><strong>' . plog_tr('Author') . ':</strong></p> <p class="margin-5 no-margin-top" id="comment-author-' . $row['id'] . '">' . $row['author'] . '</p> <p class="margin-5 no-margin-bottom"><strong>' . plog_tr('Email') . ':</strong></p> <p class="margin-5 no-margin-top" id="comment-email-' . $row['id'] . '">' . $row['email'] . '</p> <p class="margin-5 no-margin-bottom"><strong>' . plog_tr('Website') . ':</strong></p> <p class="margin-5 no-margin-top" id="comment-url-' . $row['id'] . '">' . $row['url'] . '</p> </td>'; // Date $output .= "\n\t\t\t\t" . '<td class="align-left width-100"><p class="margin-5">' . date($config['date_format'], $row['date']) . '</p></td>'; // Comment $output .= "\n\t\t\t\t" . '<td class="align-left vertical-top"><p class="margin-5" id="comment-comment-' . $row['id'] . '">' . $row['comment'] . '</p></td>'; // Actions panel $query = "?action=edit-comment&pid={$row['id']}";
/** * Prepare image file (Resize, Rotate and etc.) * * @param object File * @param string mimetype */ function prepare_uploaded_image($File, $mimetype) { global $Settings, $Messages; $thumb_width = $Settings->get('fm_resize_width'); $thumb_height = $Settings->get('fm_resize_height'); $thumb_quality = $Settings->get('fm_resize_quality'); $do_resize = false; if ($Settings->get('fm_resize_enable') && $thumb_width > 0 && $thumb_height > 0) { // Image resizing is enabled list($image_width, $image_height) = explode('x', $File->get_image_size()); if ($image_width > $thumb_width || $image_height > $thumb_height) { // This image should be resized $do_resize = true; } } load_funcs('files/model/_image.funcs.php'); $resized_imh = null; if ($do_resize) { // Resize image list($err, $src_imh) = load_image($File->get_full_path(), $mimetype); if (empty($err)) { list($err, $resized_imh) = generate_thumb($src_imh, 'fit', $thumb_width, $thumb_height); } if (empty($err)) { // Image was rezised successfully $Messages->add(sprintf(T_('%s was resized to %dx%d pixels.'), '<b>' . $File->get('name') . '</b>', imagesx($resized_imh), imagesy($resized_imh)), 'success'); } else { // Image was not rezised $Messages->add(sprintf(T_('%s could not be resized to target resolution of %dx%d pixels.'), '<b>' . $File->get('name') . '</b>', $thumb_width, $thumb_height), 'error'); // Error exists, exit here return; } } if ($mimetype == 'image/jpeg') { // JPEG, do autorotate if EXIF Orientation tag is defined $save_image = !$do_resize; // If image was be resized, we should save file only in the end of this function exif_orientation($File->get_full_path(), $resized_imh, $save_image); } if (!$resized_imh) { // Image resource is incorrect return; } if ($do_resize && empty($err)) { // Save resized image ( and also rotated image if this operation was done ) save_image($resized_imh, $File->get_full_path(), $mimetype, $thumb_quality); } }
$output .= "\n\t" . '<p class="errors">' . plog_tr('Nothing selected to move') . '!</p>' . "\n"; } } } break; case 'edit-picture': $level = 'picture'; // Show the edit picture form $photo = get_picture_by_id($id); if ($photo['allow_comments'] == 1) { $state = 'checked="checked"'; } else { $state = ''; } $output .= "\n\t\t" . '<form class="edit width-700" action="' . $_SERVER['PHP_SELF'] . '?level=pictures&id=' . $photo['parent_album'] . '" method="post">'; $thumbpath = generate_thumb(SmartStripSlashes($photo['path']), $photo['id'], THUMB_SMALL); $output .= "\n\t\t\t" . '<div style="float: right;"><img src="' . $thumbpath . '" alt="" /></div> <div> <div class="strong">' . plog_tr('Edit Image Properties') . '</div> <p> <label class="strong" accesskey="c" for="caption">' . plog_tr('<em>C</em>aption') . ':</label><br /> <input size="62" name="caption" id="caption" value="' . htmlspecialchars(SmartStripSlashes($photo['caption'])) . '" /> </p> <p> <label class="strong" for="description">' . plog_tr('Description') . ':</label><br /> <textarea name="description" id="description" cols="60" rows="5">' . htmlspecialchars(SmartStripSlashes($photo['description'])) . '</textarea> </p> <p><input type="checkbox" id="allow_comments" name="allow_comments" value="1" ' . $state . ' /><label class="strong" for="allow_comments" accesskey="w">' . plog_tr('Allo<em>w</em> Comments') . '?</label></p>'; $output .= "\n\t\t\t\t" . '<input type="hidden" name="pid" value="' . $photo['id'] . '" /> <input type="hidden" name="action" value="update-picture" /> <input class="submit" name="update" value="' . plog_tr('Update') . '" type="submit" />
/** * Prepare image file (Resize, Rotate and etc.) * * @param object File * @param string mimetype */ function prepare_uploaded_image($File, $mimetype) { global $Settings; $thumb_width = $Settings->get('fm_resize_width'); $thumb_height = $Settings->get('fm_resize_height'); $thumb_quality = $Settings->get('fm_resize_quality'); $do_resize = false; if ($Settings->get('fm_resize_enable') && $thumb_width > 0 && $thumb_height > 0) { // Image resizing is enabled list($image_width, $image_height) = explode('x', $File->get_image_size()); if ($image_width > $thumb_width || $image_height > $thumb_height) { // This image should be resized $do_resize = true; } } load_funcs('files/model/_image.funcs.php'); $resized_imh = null; if ($do_resize) { // Resize image list($err, $src_imh) = load_image($File->get_full_path(), $mimetype); if (empty($err)) { list($err, $resized_imh) = generate_thumb($src_imh, 'fit', $thumb_width, $thumb_height); } } if (!empty($err)) { // Error exists, Exit here return; } if ($mimetype == 'image/jpeg') { // JPEG, do autorotate if EXIF Orientation tag is defined $save_image = !$do_resize; // If image was be resized, we should save file only in the end of this function exif_orientation($File->get_full_path(), $resized_imh, $save_image); } if (!$resized_imh) { // Image resource is incorrect return; } if ($do_resize && empty($err)) { // Save resized image ( and also rotated image if this operation was done ) save_image($resized_imh, $File->get_full_path(), $mimetype, $thumb_quality); } }
function plog_edit_album_form($album_id) { global $thumbnail_config; $album_id = intval($album_id); $album = get_album_by_id($album_id); $auto_graphic = "../graphics/auto.gif"; $output .= '<form class="edit" action="' . $_SERVER["PHP_SELF"] . '?level=albums&id=' . $album["parent_id"] . '" method="post">'; $images = '<option class="thumboption" value="0" style="padding-left: 100px; background-image: url(' . $auto_graphic . '); background-repeat: no-repeat;">' . plog_tr('automatic') . '</option>'; $sql = "SELECT id,caption,path FROM " . TABLE_PREFIX . "pictures p WHERE p.parent_album = '" . $album_id . "'"; $result = run_query($sql); while ($row = mysql_fetch_assoc($result)) { $selected = $row["id"] == $album["thumbnail_id"] ? " selected" : ""; $style = 'class="thumboption" style="padding-left: ' . ($thumbnail_config[THUMB_SMALL]["size"] + 5) . 'px; background-image: url(' . generate_thumb(SmartStripSlashes($row["path"]), $row["id"]) . '); background-repeat: no-repeat;"'; $images .= "<option {$style} value='" . $row["id"] . "'" . $selected . ">"; $images .= !empty($row["caption"]) ? SmartStripSlashes($row["caption"]) : SmartStripSlashes(basename($row["path"])); $images .= "</option>\n"; } $output .= '<label for="name" accesskey="n"><em>N</em>ame:</label><br/><input size="30" name="name" id="name" value="' . SmartStripSlashes($album['name']) . '"><br/> <label for="description" accesskey="d"><em>D</em>escription:</label><br/><input size="80" name="description" id="description" value="' . SmartStripSlashes($album['description']) . '"><br/> Thumbnail:<br/><select name="thumbnail_id" class="thumbselect" id="thumbselect" onchange="updateThumbPreview(this)">' . $images . '</select> <script type="text/javascript">updateThumbPreview(document.getElementById(\'thumbselect\'));</script>'; $output .= '<input type="hidden" name="pid" value="' . $album_id . '"> <input type="hidden" name="action" value="update-album"> <tr><td><button class="submit" type="submit">' . plog_tr('Update') . '</button>'; $output .= '</form>'; return $output; }
function upload() { //http://docs.joomla.org/How_to_use_the_filesystem_package jimport('joomla.filesystem.file'); $params =& JComponentHelper::getParams('com_products'); require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'image_lib.php'; require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'functions.php'; $file = JRequest::getVar('uploadfile', '', 'files', 'array'); $upload_dir = JPATH_ROOT . DS . 'images' . DS . 'products'; $thumb_dir = $upload_dir . DS . 'thumbs'; $upload_dest = $upload_dir . DS . $file['name']; //file exists rename if (JFile::exists($upload_dest)) { $upload_dest = $upload_dir . DS . time() . '_' . $file['name']; } //now move uploaded file to new location if (!JFile::upload($file['tmp_name'], $upload_dest)) { echo json_encode(array('error' => true, 'message' => JText::_('Upload file failed'))); exit; } $thumb_width = $params->get('thump_width', 90); $thumb_height = $params->get('thump_height', 90); $thumb_width = $thumb_width > 0 ? $thumb_width : 90; $thumb_height = $thumb_height > 0 ? $thumb_height : 90; $configs = array('width' => $thumb_width, 'height' => $thumb_height, 'file_to_resize' => $upload_dest, 'thumb_dir' => $thumb_dir); $image_thumb = generate_thumb($configs); if ($image_thumb) { $pid = JRequest::getVar('pid', 0, 'post', 'int'); $row_img = JTable::getInstance('images', 'Table'); $row_img->filename = $image_thumb; $row_img->proid = $pid; if (!$row_img->store()) { echo json_encode(array('error' => false, 'message' => $row->getError())); } echo json_encode(array('error' => false, 'file' => $image_thumb, 'fid' => $row_img->id, 'pid' => $pid, 'message' => 'upload and resize image successfully')); } else { echo json_encode(array('error' => true, 'message' => 'error when try to resize image')); } }