* @copyright Transparent Technologies 2004 * @link http://www.open-realty.org Open-Realty Project * @link http://www.transparent-tech.com Transparent Technologies * @link http://www.open-realty.org/license_info.html Open-Realty License */ // Set Error Handling to E_ALL class image_handler { var $debug = false; function exec_curl($array) { $array = @explode("?", $array); $link = curl_init(); curl_setopt($link, CURLOPT_URL, $array[0]); curl_setopt($link, CURLOPT_VERBOSE, 0); curl_setopt($link, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($link, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($link, CURLOPT_RETURNTRANSFER, 1); curl_setopt($link, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($link, CURLOPT_MAXREDIRS, 6); curl_setopt($link, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($link, CURLOPT_TIMEOUT, 60); $results = curl_exec($link); if (curl_errno($link) > 0) { curl_close($link); return false; } curl_close($link); return $results; } function save_remote_file($url, $id, $type = 'listings', $owner, $replace_image = false, $append_file_name = false, $caption='', $description='') { error_reporting(E_ALL ^ E_WARNING); // deals with incoming uploads global $config, $conn; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); // Get file name from URL and remove any bad filename chars. $url_parts = explode('/', $url); $num = count($url_parts)-1; $file_name = $url_parts[$num]; $badchararray = array(" ", "'", "\"", "$", "&", "%", "-", "#", "^", "*", "(", ")", "~", "@", "/", "?", "="); $file_name = str_replace($badchararray, "", $file_name); $file_name = stripslashes(strtolower($file_name)); if ($append_file_name == true) { $save_name = $id . '_' . $file_name; }else { $save_name = $file_name; } // Now that we know the filename check if the file exist. If it does do not redownload the image. if (file_exists($config["listings_upload_path"] . '/' . $save_name) && $replace_image == false) { $thumb_name = 'thumb_' . $save_name; // Get Max Image Rank $sql = "SELECT MAX(listingsimages_rank) AS max_rank FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = '$id')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $rank = $recordSet->fields['max_rank']; $rank++; $caption = $misc->make_db_safe($caption); $description = $misc->make_db_safe($description); $sql = "INSERT INTO " . $config['table_prefix'] . "listingsimages (listingsdb_id, userdb_id, listingsimages_file_name, listingsimages_thumb_file_name,listingsimages_rank,listingsimages_caption,listingsimages_description) VALUES ('$id', '$owner', '$save_name', '$thumb_name',$rank,$caption,$description)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } return true; } // Image doesn't exist locally yet, so get it. if (!ini_get('allow_url_fopen')) { $imagecontent = $this->exec_curl($url); }else { $imagecontent = file_get_contents($url); } // Check to see if image existed on the remote server, if not skip it. if ($imagecontent === false) { return false; } // Ok we have a good file, so now lets save it. $handle = fopen($config["listings_upload_path"] . '/' . $save_name, "wb"); fwrite($handle, $imagecontent); fclose($handle); // Verify File type $extension = substr(strrchr($save_name, "."), 1); if (!in_array($extension, explode(',', $config['allowed_upload_extensions']))) { unlink($config["listings_upload_path"] . '/' . $save_name); return false; } if (exif_imagetype($config["listings_upload_path"] . '/' . $save_name) === false) { unlink($config["listings_upload_path"] . '/' . $save_name); return false; } // Image is saved, check file widht/height. // $imagedata = GetImageSize($config["listings_upload_path"].'/'.$save_name); // $imagewidth = $imagedata[0]; // $imageheight = $imagedata[1]; $thumb_name = $save_name; // by default -- no difference... unless... // Make the thumbnial image. if ($config['make_thumbnail'] == '1') { // if the option to make a thumbnail is activated... $make_thumb = 'make_thumb_' . $config['thumbnail_prog']; $thumb_name = $this->$make_thumb ($save_name, $config['listings_upload_path']); } // end if $config[make_thumbnail] === "1" // Get highest image rank from current db. $sql = "SELECT MAX(listingsimages_rank) AS max_rank FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = '$id')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $rank = $recordSet->fields['max_rank']; $rank++; // Insert image with next highest rank. $sql = "INSERT INTO " . $config['table_prefix'] . "listingsimages (listingsdb_id, userdb_id, listingsimages_file_name, listingsimages_thumb_file_name,listingsimages_rank) VALUES ('$id', '$owner', '$save_name', '$thumb_name',$rank)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } return true; } function renderUserImages($user) { // grabs the listings for a given user global $conn, $config, $lang; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); $display = ''; $user = $misc->make_db_safe($user); // grab the images $sql = "SELECT userimages_id, userimages_caption, userimages_thumb_file_name FROM " . $config['table_prefix'] . "userimages WHERE userdb_id = $user ORDER BY userimages_rank"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $num_images = $recordSet->RecordCount(); if ($num_images > 0) { while (!$recordSet->EOF) { $caption = $misc->make_db_unsafe ($recordSet->fields['userimages_caption']); $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_thumb_file_name']); // $file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_file_name']); $imageID = $misc->make_db_unsafe ($recordSet->fields['userimages_id']); // gotta grab the image size $imagedata = GetImageSize("$config[user_upload_path]/$thumb_file_name"); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $shrinkage = $config['thumbnail_width'] / $imagewidth; $displaywidth = $imagewidth * $shrinkage; $displayheight = $imageheight * $shrinkage; $display .= " "; $display .= "
"; $display .= "$caption

"; $recordSet->MoveNext(); } }else { $display .= "\"\"
"; } // end ($num_images > 0) return $display; } // end function renderUserImages function get_image_caption() { global $conn, $config, $lang; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); $sql_imageID = $misc->make_db_safe($_GET['image_id']); $sql = "SELECT listingsimages_caption FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsimages_id = $sql_imageID)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $caption = $misc->make_db_unsafe ($recordSet->fields['listingsimages_caption']); return $caption; } function view_image($type) { global $conn, $config, $lang; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); $display = ''; if (!isset($_GET['image_id'])) { return $lang['image_not_found']; } $sql_imageID = $misc->make_db_safe($_GET['image_id']); if ($type == "listing") { // get the image data $sql = "SELECT listingsimages_caption, listingsimages_file_name, listingsimages_description, listingsdb_id FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsimages_id = $sql_imageID)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $caption = $misc->make_db_unsafe ($recordSet->fields['listingsimages_caption']); $file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']); $description = $misc->make_db_unsafe ($recordSet->fields['listingsimages_description']); $listing_id = $misc->make_db_unsafe ($recordSet->fields['listingsdb_id']); $recordSet->MoveNext(); } $display .= '
'; $display .= ''; if ($caption != "") { $display .= "$caption - "; } $display .= '' . $lang['return_to_listing'] . '
'; $display .= '' . $caption . ''; $display .= '
'; $display .= $description ; $display .= '
'; } // end if ($type == "listing") elseif ($type == "userimage") { // get the image data $sql = "SELECT userimages_caption, userimages_file_name, userimages_description, userdb_id FROM " . $config['table_prefix'] . "userimages WHERE (userimages_id = $sql_imageID)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $caption = $misc->make_db_unsafe ($recordSet->fields['userimages_caption']); $file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_file_name']); $description = $misc->make_db_unsafe ($recordSet->fields['userimages_description']); $user_id = $recordSet->fields['userdb_id']; $recordSet->MoveNext(); } $display .= ''; $display .= ''; $display .= ' '; $display .= ''; $display .= '
'; $display .= '

'; if ($caption != "") { $display .= "$caption - "; } $display .= '' . $lang['return_to_user'] . '

'; $display .= '
'; $display .= ' ' . $caption . ''; $display .= '
'; $display .= '
'; $display .= $description; $display .= '
'; } // end if ($type == "listing") return $display; } function edit_listing_images() { global $lang, $conn, $config; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); $display = ''; $edit = $_POST['edit']; $sql_edit = $misc->make_db_safe($_POST['edit']); if (!isset($_POST['action'])) { $_POST['action'] = ''; } // does this person have access to these listings? if (($_SESSION['edit_all_listings'] != "yes") && ($_SESSION['admin_privs'] != "yes")) { $sql = "SELECT userdb_id FROM " . $config['table_prefix'] . "listingsdb WHERE (listingsdb_id = $sql_edit)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $owner = $recordSet->fields['userdb_id']; $recordSet->MoveNext(); } if ($_SESSION['userID'] != $owner) { die ($_SESSION['edit_all_listings']); } } // end priv check if ($_POST['action'] == "update_pic") { $sql_edit = $misc->make_db_safe($_POST['edit']); $sql_caption = $misc->make_db_safe($_POST['caption']); $sql_description = $misc->make_db_safe($_POST['description']); $sql_rank = $misc->make_db_safe($_POST['rank']); $sql_pic = $misc->make_db_safe($_POST['pic']); if ($_SESSION['edit_all_listings'] == "yes") { $sql = "UPDATE " . $config['table_prefix'] . "listingsimages SET listingsimages_caption = $sql_caption, listingsimages_description = $sql_description, listingsimages_rank = $sql_rank WHERE ((listingsdb_id = $sql_edit) AND (listingsimages_file_name = $sql_pic))"; }else { $sql = "UPDATE " . $config['table_prefix'] . "listingsimages SET listingsimages_caption = $sql_caption, listingsimages_description = $sql_description, listingsimages_rank = $sql_rank WHERE ((listingsdb_id = $sql_edit) AND (listingsimages_file_name = $sql_pic) AND (userdb_id = $_SESSION[userID]))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $display .= "

$lang[image] '$_POST[pic]' $lang[has_been_updated]

"; $misc->log_action ($lang['log_updated_listing_image'] . $_POST['pic']); } if ($_POST['action'] == "delete_pic") { // get the data for the pic being deleted $sql_pic_id = $misc->make_db_safe($_POST['pic_id']); if ($_SESSION['edit_all_listings'] == "yes") { $sql = "SELECT listingsimages_file_name, listingsimages_thumb_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE ((listingsdb_id = $sql_edit) AND (listingsimages_id = $sql_pic_id))"; }else { $sql = "SELECT listingsimages_file_name, listingsimages_thumb_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE ((listingsdb_id = $sql_edit) AND (listingsimages_id = $sql_pic_id) AND (userdb_id = $_SESSION[userID]))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']); $recordSet->MoveNext(); } // end while // delete from the db if ($_SESSION['edit_all_listings'] == "yes") { $sql = "DELETE FROM " . $config['table_prefix'] . "listingsimages WHERE ((listingsdb_id = $sql_edit) AND (listingsimages_file_name = '$file_name'))"; }else { $sql = "DELETE FROM " . $config['table_prefix'] . "listingsimages WHERE ((listingsdb_id = $sql_edit) AND (listingsimages_file_name = '$file_name') AND (userdb_id = '$_SESSION[userID]'))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } // delete the files themselves // on widows, required php 4.11 or better (I think) if (!unlink("$config[listings_upload_path]/$file_name")) die("$lang[alert_site_admin]"); if ($file_name != $thumb_file_name) { if (!unlink("$config[listings_upload_path]/$thumb_file_name")) die("$lang[alert_site_admin]"); } $misc->log_action ("$lang[log_deleted_listing_image] $file_name"); $display .= "

$lang[image] '$file_name' $lang[has_been_deleted]

"; } if ($_POST['action'] == "upload") { if ($_SESSION['edit_all_listings'] == "yes") { // get the owner of the listing $sql = "SELECT userdb_id FROM " . $config['table_prefix'] . "listingsdb WHERE (listingsdb_id = $sql_edit)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $owner = $recordSet->fields['userdb_id']; $recordSet->MoveNext(); } $display .= $this->handleUpload("listings", $edit, $owner); }else { $display .= $this->handleUpload("listings", $edit, $_SESSION['userID']); } } // end if $action == "upload" if ($_SESSION['edit_all_listings'] == "yes") { $sql = "SELECT listingsimages_id, listingsimages_caption, listingsimages_file_name, listingsimages_thumb_file_name, listingsimages_description, listingsimages_rank FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = $sql_edit) ORDER BY listingsimages_rank"; }else { $sql = "SELECT listingsimages_id, listingsimages_caption, listingsimages_file_name, listingsimages_thumb_file_name, listingsimages_description, listingsimages_rank FROM " . $config['table_prefix'] . "listingsimages WHERE ((listingsdb_id = $sql_edit) AND (userdb_id = '$_SESSION[userID]')) ORDER BY listingsimages_rank"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $num_images = $recordSet->RecordCount(); $avaliable_iamges = $config["max_listings_uploads"] - $num_images; $x = 0; if ($num_images < $config['max_listings_uploads']) { $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= '
'; $display .= '

' . $lang['upload_a_picture'] . '

'; $display .= '
 '; $display .= '
'; $display .= ''; $display .= ''; $display .= ''; while ($x < $avaliable_iamges) { $display .= '' . $lang['upload_send_this_file'] . ':
'; $x++; } $display .= ''; $display .= '
'; $display .= '
'; } // end if $num_images <= $config[max_user_uploads] $display .= ''; $display .= ''; $display .= ''; $count = 0; while (!$recordSet->EOF) { // $edit = $misc->make_db_safe($_POST['edit']); $pic_id = $recordSet->fields['listingsimages_id']; $rank = $recordSet->fields['listingsimages_rank']; $caption = $misc->make_db_unsafe ($recordSet->fields['listingsimages_caption']); $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']); $description = $misc->make_db_unsafe ($recordSet->fields['listingsimages_description']); // gotta grab the image size $imagedata = GetImageSize("$config[listings_upload_path]/$file_name"); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $shrinkage = $config['thumbnail_width'] / $imagewidth; $displaywidth = $imagewidth * $shrinkage; $displayheight = $imageheight * $shrinkage; $filesize = filesize("$config[listings_upload_path]/$file_name"); $filesize = $filesize / 1000; // to get k // now grab the thumbnail data $thumb_imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name"); $thumb_imagewidth = $thumb_imagedata[0]; $thumb_imageheight = $thumb_imagedata[1]; $thumb_filesize = filesize("$config[listings_upload_path]/$thumb_file_name"); $thumb_filesize = $thumb_filesize / 1000; // alternate the colors if ($count == 0) { $count = 1; }else { $count = 0; } $display .= ""; $recordSet->MoveNext(); } // end while $display .= "
'; $display .= '

' . $lang['edit_images'] . ' -- '; if ($_SESSION['edit_all_listings'] == "yes") { $display .= ""; }else { $display .= ""; } $display .= $lang['return_to_editing_listing']; $display .= '

$file_name
$lang[width]=$imagewidth
$lang[height]=$imageheight
$lang[size]=$filesize" . "k
"; $display .= "
$lang[thumbnail]:
"; $display .= " "; $display .= "
$lang[width]=$thumb_imagewidth
$lang[height]=$thumb_imageheight
$lang[size]=$thumb_filesize" . "k
"; $display .= "

$lang[delete]
"; $display .= "
"; $display .= "
"; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= "
$lang[admin_template_editor_field_rank]:
$lang[upload_rank_explanation]
$lang[upload_caption]:
$lang[upload_description]:
"; $display .= "
"; $display .= "

"; return $display; } function edit_user_images() { global $config, $lang, $conn; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); $display = ''; if (!isset($_POST['action'])) { $_POST['action'] = ''; } if ($_POST['action'] == "update_pic") { if ($_SESSION['edit_all_users'] == "yes") { $sql = "UPDATE " . $config['table_prefix'] . "userimages SET userimages_caption = '$_POST[caption]', userimages_description = '$_POST[description]', userimages_rank = '$_POST[rank]' WHERE ((userdb_id = '$_POST[edit]') AND (userimages_file_name = '$_POST[pic]'))"; }else { $sql = "UPDATE " . $config['table_prefix'] . "userimages SET userimages_caption = '$_POST[caption]', userimages_description = '$_POST[description]', userimages_rank = '$_POST[rank]' WHERE ((userimages_file_name = '$_POST[pic]') AND (userdb_id = '$_SESSION[userID] '))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $misc->log_action ("$lang[log_updated_user_image] $_POST[pic]"); $display .= "

$lang[image] '$_POST[pic]' $lang[has_been_updated]

"; } if ($_POST['action'] == "delete_pic") { // get the data for the pic being deleted $sql_pic_id = $misc->make_db_safe($_POST['pic_id']); if ($_SESSION['edit_all_users'] == "yes") { $sql = "SELECT userimages_file_name, userimages_thumb_file_name FROM " . $config['table_prefix'] . "userimages WHERE ((userdb_id = '$_POST[edit]') AND (userimages_id = $sql_pic_id))"; }else { $sql = "SELECT userimages_file_name, userimages_thumb_file_name FROM " . $config['table_prefix'] . "userimages WHERE ((userimages_id = $sql_pic_id) AND (userdb_id = '$_SESSION[userID]'))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_file_name']); if ($this->debug) { $display .= 'File Name: ' . $file_name . '
'; $display .= 'Thumbnail Name: ' . $thumb_file_name . '
'; } $recordSet->MoveNext(); } // end while // delete from the db if ($_SESSION['edit_all_users'] == "yes") { $sql = "DELETE FROM " . $config['table_prefix'] . "userimages WHERE ((userdb_id = '$_POST[edit]') AND (userimages_file_name = '$file_name'))"; }else { $sql = "DELETE FROM " . $config['table_prefix'] . "userimages WHERE ((userimages_file_name = '$file_name') AND (userdb_id = '$_SESSION[userID]'))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } // delete the files themselves // on widows, required php 4.11 or better (I think) if (!unlink("$config[user_upload_path]/$file_name")) { die("$lang[alert_site_admin]"); } if ($thumb_file_name != $file_name) { // if (substr("$thumb_file_name", -3) == "jpg" || substr("$thumb_file_name", -3) == "png") // { if (!unlink("$config[user_upload_path]/$thumb_file_name")) { die("$lang[alert_site_admin]"); }else { $display .= "

$lang[image] '$thumb_file_name' $lang[has_been_deleted]

"; } // } } $misc->log_action ("$lang[log_deleted_user_image] $file_name"); $display .= "

$lang[image] '$file_name' $lang[has_been_deleted]

"; } if ($_POST['action'] == "upload") { if ($_SESSION['edit_all_users'] == "yes") { $display .= $this->handleUpload("user", '', $_POST['edit']); }else { $display .= $this->handleUpload("user", '', $_SESSION['userID']); } } // end if $action == "upload" if ($_SESSION['edit_all_users'] == "yes") { if (!isset($_POST['edit'])) { if (isset($_POST['edit'])) { $_POST['edit'] = $_POST['edit']; }else { $display .= 'Error in calling function. You forgot to pass the ID to edit'; } } $sql = "SELECT userimages_id, userimages_caption, userimages_file_name, userimages_thumb_file_name, userimages_description, userimages_rank FROM " . $config['table_prefix'] . "userimages WHERE (userdb_id = '$_POST[edit]') ORDER BY userimages_rank"; }else { $sql = "SELECT userimages_id, userimages_caption, userimages_file_name, userimages_thumb_file_name, userimages_description, userimages_rank FROM " . $config['table_prefix'] . "userimages WHERE ((userdb_id = '$_SESSION[userID]')) ORDER BY userimages_rank"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $num_images = $recordSet->RecordCount(); $avaliable_iamges = $config["max_user_uploads"] - $num_images; $x = 0; if ($num_images < $config['max_user_uploads']) { $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= '
'; $display .= '

' . $lang['upload_a_picture'] . '

'; $display .= '
 '; $display .= '
'; $display .= ''; $display .= ''; $display .= ''; $display .= ''; while ($x < $avaliable_iamges) { $display .= '' . $lang['upload_send_this_file'] . ':
'; $x++; } $display .= ''; $display .= '
'; $display .= '
'; } // end if $num_images <= $config[max_user_uploads] $display .= ' '; $display .= ''; $count = 0; while (!$recordSet->EOF) { $pic_id = $recordSet->fields['userimages_id']; $rank = $recordSet->fields['userimages_rank']; $caption = $misc->make_db_unsafe ($recordSet->fields['userimages_caption']); $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_file_name']); $description = $misc->make_db_unsafe ($recordSet->fields['userimages_description']); // gotta grab the image size $imagedata = GetImageSize("$config[user_upload_path]/$file_name"); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $shrinkage = $config['thumbnail_width'] / $imagewidth; $displaywidth = $imagewidth * $shrinkage; $displayheight = $imageheight * $shrinkage; $filesize = filesize("$config[user_upload_path]/$file_name"); $filesize = $filesize / 1000; // to get k // now grab the thumbnail data $thumb_imagedata = GetImageSize("$config[user_upload_path]/$thumb_file_name"); $thumb_imagewidth = $thumb_imagedata[0]; $thumb_imageheight = $thumb_imagedata[1]; $thumb_filesize = filesize("$config[user_upload_path]/$thumb_file_name"); $thumb_filesize = $thumb_filesize / 1000; // alternate the colors if ($count == 0) { $count = $count + 1; }else { $count = 0; } $display .= ""; $recordSet->MoveNext(); } // end while $display .= "

' . $lang['edit_images'] . ' --'; $display .= ''; $display .= $lang['return_to_editing_account']; $display .= '

$file_name
$lang[width]=$imagewidth
$lang[height]=$imageheight
$lang[size]=$filesize" . "k
"; $display .= "
$lang[thumbnail]:
"; $display .= " "; $display .= "
$lang[width]=$thumb_imagewidth
$lang[height]=$thumb_imageheight
$lang[size]=$thumb_filesize" . "k
"; // $display .= "

Delete
"; $display .= "

$lang[delete]
"; $display .= "
"; $display .= "
"; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= "
$lang[admin_template_editor_field_rank]:
$lang[upload_rank_explanation]
$lang[upload_caption]:
$lang[upload_description]:
"; $display .= "
"; $display .= "

"; return $display; } function renderListingsMainImageSlideShow($listingID) { // shows the images connected to a given image global $conn, $lang, $config; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); // grab the images $listingID = $misc->make_db_extra_safe($listingID); $sql = "SELECT listingsimages_id,listingsimages_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = $listingID) ORDER BY listingsimages_rank"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $width = "500"; if ($config["max_listings_upload_width"] < 500 && $config['resize_img'] == '1') { } $num_images = $recordSet->RecordCount(); $output = ''; if ($num_images > 0) { $output .= ' '; $output .= '
Slideshow image
'; $output .= ''; } // end if ($num_images > 0) else { if ($config['show_no_photo'] == 1) { $output .= '
'; } } return $output; } // end function renderListingsMainImageSlideShow function renderListingsImages($listingID, $showcap) { // shows the images connected to a given image global $conn, $lang, $config; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); // grab the images $listingID = $misc->make_db_extra_safe($listingID); $sql = "SELECT listingsimages_id, listingsimages_caption, listingsimages_thumb_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = $listingID) ORDER BY listingsimages_rank"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { log_error($sql); } $display = ''; $num_images = $recordSet->RecordCount(); if ($num_images > 0) { // $display .= ""; $display .= "$lang[images]

"; while (!$recordSet->EOF) { $caption = $misc->make_db_unsafe ($recordSet->fields['listingsimages_caption']); $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_thumb_file_name']); // $file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']); $imageID = $misc->make_db_unsafe ($recordSet->fields['listingsimages_id']); if ($thumb_file_name != "" && file_exists("$config[listings_upload_path]/$thumb_file_name")) { $imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name"); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $shrinkage = $config['thumbnail_width'] / $imagewidth; $displaywidth = $imagewidth * $shrinkage; $displayheight = $imageheight * $shrinkage; if ($config['url_style'] == '1') { $display .= ''; }else { $display .= ''; } $display .= "\"$thumb_file_name\"
"; if ($showcap == 'yes') { $display .= "".urldecode($caption)."

"; } else { $display .= "
"; } } // end if ($thumb_file_name != "") $recordSet->MoveNext(); } // end while // $display .= ""; } // end if ($num_images > 0) else { if ($config['show_no_photo'] == 1) { $display .= "\"$lang[no_photo]\"
"; } } return $display; } // end function renderListingsImages function make_thumb_gd ($input_file_name, $input_file_path, $output_path = "") { // makes a thumbnail using the GD library global $config; $quality = $config['jpeg_quality']; // jpeg quality -- set in common.php if($output_path == ""){ $output_path=$input_file_path; } // first, grab the dimensions of the pic $imagedata = GetImageSize($input_file_path . '/' . $input_file_name); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $imagetype = $imagedata[2]; // type definitions // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP // 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order) // 9 = JPC, 10 = JP2, 11 = JPX $thumb_name = $input_file_name; //by default // the GD library, which this uses, can only resize GIF, JPG and PNG if ($imagetype == 1) { // it's a GIF // figure out the ratio to which it should be shrunk, if at all // see if GIF support is enabled if (imagetypes() &IMG_GIF) { $shrinkage = 1; if ($imagewidth > $config['thumbnail_width']) { $shrinkage = $config['thumbnail_width'] / $imagewidth; } $dest_height = $shrinkage * $imageheight; $dest_width = $config['thumbnail_width']; $src_img = imagecreatefromgif("$input_file_path/$input_file_name"); $dst_img = imageCreate($dest_width, $dest_height); // copy the original image info into the new image with new dimensions // checking to see which function is available ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); $thumb_name = "thumb_" . "$input_file_name"; imagegif($dst_img, "$output_path/$thumb_name"); @chmod("$output_path/$thumb_name", 0777); imagedestroy($src_img); imagedestroy($dst_img); } // end if GIF support is enabled } // end if $imagetype == 1 elseif ($imagetype == 2) { // it's a JPG // figure out the ratio to which it should be shrunk, if at all $shrinkage = 1; if ($imagewidth > $config['thumbnail_width']) { $shrinkage = $config['thumbnail_width'] / $imagewidth; } $dest_height = $shrinkage * $imageheight; $dest_width = $config['thumbnail_width']; $src_img = @imagecreatefromjpeg("$input_file_path/$input_file_name"); if (!$src_img) { /* See if it failed */ $im = imagecreatetruecolor(150, 30); /* Create a black image */ $bgc = imagecolorallocate($src_img, 255, 255, 255); $tc = imagecolorallocate($src_img, 0, 0, 0); imagefilledrectangle($src_img, 0, 0, 150, 30, $bgc); /* Output an errmsg */ imagestring($src_img, 1, 5, 5, "Error loading $input_file_name", $tc); } if ($config['gdversion2'] == false) { $dst_img = imageCreate($dest_width, $dest_height); }else { $dst_img = imageCreateTrueColor($dest_width, $dest_height); } // copy the original image info into the new image with new dimensions // checking to see which function is available if ($config['gdversion2'] == false) { ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); }else { ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); } $thumb_name = "thumb_" . "$input_file_name"; imagejpeg($dst_img, "$output_path/$thumb_name", $quality); @chmod("$output_path/$thumb_name", 0777); imagedestroy($src_img); imagedestroy($dst_img); } // end if $imagetype == 2 elseif ($imagetype == 3) { // it's a PNG // figure out the ratio to which it should be shrunk, if at all $shrinkage = 1; if ($imagewidth > $config['thumbnail_width']) { $shrinkage = $config['thumbnail_width'] / $imagewidth; } $dest_height = $shrinkage * $imageheight; $dest_width = $config['thumbnail_width']; $src_img = imagecreatefrompng("$input_file_path/$input_file_name"); $dst_img = imagecreate($dest_width, $dest_height); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); $thumb_name = "thumb_" . "$input_file_name"; imagepng($dst_img, "$output_path/$thumb_name"); @chmod("$output_path/$thumb_name", 0777); imagedestroy($src_img); imagedestroy($dst_img); } // end if $imagetype == 3 return $thumb_name; } // end function make_thumb_gd function resize_img_gd ($input_file_name, $input_file_path, $type) { // resizes image using the GD library global $config; $quality = $config['jpeg_quality']; // jpeg quality -- set in common.php $max_width = $config['max_' . $type . '_upload_width']; // first, grab the dimensions of the pic $imagedata = getimagesize($input_file_path . '/' . $input_file_name); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $imagetype = $imagedata[2]; // type definitions // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP // 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order) // 9 = JPC, 10 = JP2, 11 = JPX $img_name = $input_file_name; //by default // the GD library, which this uses, can only resize GIF, JPG and PNG if ($imagetype == 1) { // it's a GIF // see if GIF support is enabled if (imagetypes() &IMG_GIF) { // figure out the ratio to which it should be shrunk, if at all $shrinkage = 1; $shrinkage = $max_width / $imagewidth; $dest_height = $shrinkage * $imageheight; $dest_width = $max_width; $src_img = imagecreatefromgif("$input_file_path/$input_file_name"); $dst_img = imageCreate($dest_width, $dest_height); // copy the original image info into the new image with new dimensions // checking to see which function is available ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); $thumb_name = "thumb_" . "$input_file_name"; imagegif($dst_img, "$input_file_path/$img_name"); imagedestroy($src_img); imagedestroy($dst_img); } //end if GIF support is enabled } // end if $imagetype == 1 elseif ($imagetype == 2) { // it's a JPG // figure out the ratio to which it should be shrunk, if at all $shrinkage = 1; $shrinkage = $max_width / $imagewidth; $dest_height = $shrinkage * $imageheight; $dest_width = $max_width; $src_img = imagecreatefromjpeg("$input_file_path/$input_file_name"); if ($config['gdversion2'] == false) { $dst_img = imageCreate($dest_width, $dest_height); }else { $dst_img = imageCreateTrueColor($dest_width, $dest_height); } // copy the original image info into the new image with new dimensions // checking to see which function is available if ($config['gdversion2'] == false) { ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); }else { ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); } $img_name = "$input_file_name"; imagejpeg($dst_img, "$input_file_path/$img_name", $quality); imagedestroy($src_img); imagedestroy($dst_img); } // end if $imagetype == 2 elseif ($imagetype == 3) { // it's a PNG // figure out the ratio to which it should be shrunk, if at all $shrinkage = 1; $shrinkage = $max_width / $imagewidth; $dest_height = $shrinkage * $imageheight; $dest_width = $max_width; $src_img = imagecreatefrompng("$input_file_path/$input_file_name"); $dst_img = imagecreate($dest_width, $dest_height); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight); $img_name = "$input_file_name"; imagepng($dst_img, "$input_file_path/$img_name"); imagedestroy($src_img); imagedestroy($dst_img); } // end if $imagetype == 3 } // end function resize_img_gd function resize_img_imagemagick ($input_file_name, $input_file_path, $type) { // resizes image using ImageMagick global $config; // Specify your file details $current_file = $input_file_path . '/' . $input_file_name; $max_width = $config['max_' . $type . '_upload_width']; // Get the current info on the file $current_size = getimagesize($current_file); $current_img_width = $current_size[0]; $current_img_height = $current_size[1]; // $image_base = explode('.', $current_file); // This part gets the new thumbnail name // $image_basename = $image_base[0]; // $image_ext = $image_base[1]; $too_big_diff_ratio = $current_img_width / $max_width; $new_img_width = $max_width; $new_img_height = round($current_img_height / $too_big_diff_ratio); $path = $config['path_to_imagemagick']; $debug_path = '"' . $path . '" -geometry ' . $new_img_width . 'x' . $new_img_height . ' "' . $current_file . '" current_file'; // Convert the file $debug = exec($debug_path); } // end function resize_img_imagemagick function make_thumb_imagemagick ($input_file_name, $input_file_path) { // makes a thumbnail using ImageMagick global $config; // Specify your file details $current_file = "$input_file_path/$input_file_name"; $max_width = $config['thumbnail_width']; // Get the current info on the file $current_size = getimagesize($current_file); $current_img_width = $current_size[0]; $current_img_height = $current_size[1]; // $image_base = explode('.', $current_file); // This part gets the new thumbnail name // $image_basename = $image_base[0]; // $image_ext = $image_base[1]; $thumb_name = $input_file_path . "/thumb_" . $input_file_name; $thumb_name2 = "thumb_" . $input_file_name; $too_big_diff_ratio = $current_img_width / $max_width; $new_img_width = $max_width; $new_img_height = round($current_img_height / $too_big_diff_ratio); $path = $config['path_to_imagemagick']; // Convert the file $debug_path = '"' . $path . '" -geometry ' . $new_img_width . 'x' . $new_img_height . ' "' . $current_file . '" "' . $thumb_name . '"'; $debug = exec($debug_path); @chmod("$input_file_path/$thumb_name", 0777); return $thumb_name2; } // end function make_thumb function handleUpload($type, $edit, $owner) { // deals with incoming uploads global $config, $conn, $lang; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); $display = ''; global $config, $conn, $lang; $file_x = 0; if ($type == 'user') { $sql = "SELECT count(" . $type . "images_id) as num_images FROM " . $config['table_prefix'] . "" . $type . "images WHERE (userdb_id = $owner)"; }else { $sql = "SELECT count(" . $type . "images_id) as num_images FROM " . $config['table_prefix'] . "" . $type . "images WHERE (listingsdb_id = $edit)"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $num_images = $recordSet->fields['num_images']; $avaliable_iamges = $config['max_' . $type . '_uploads'] - $num_images; while ($file_x < $avaliable_iamges) { if (is_uploaded_file($_FILES['userfile']['tmp_name'][$file_x])) { $badchararray = array(" ", "'", "\"", "$", "&", "%", "-"); $realname = str_replace($badchararray, "", $_FILES['userfile']['name'][$file_x]); $realname = stripslashes(strtolower($realname)); $filename = $_FILES['userfile']['tmp_name'][$file_x]; $extension = substr(strrchr($realname, "."), 1); print ""; $filetype = $_FILES['userfile']['type'][$file_x]; print ""; // checking the filetype to make sure it's what we had in mind $pass_the_upload = "true"; if (!in_array($_FILES['userfile']['type'][$file_x], explode(',', $config['allowed_upload_types']))) { $pass_the_upload = "$realname $lang[upload_is_an_invalid_file_type]: $filetype"; } // check size $filesize = $_FILES['userfile']['size'][$file_x]; if ($config['max_' . $type . '_upload_size'] != 0 && $filesize > $config['max_' . $type . '_upload_size']) { $pass_the_upload = "$lang[upload_too_large]: " . $_FILES['userfile']['name'][$file_x]; } // check width $imagedata = GetImageSize("$filename"); $imagewidth = $imagedata[0]; if ($imagedata != false) { if ($imagewidth == '' || $imagewidth < 2 || $imagewidth > $config['max_' . $type . '_upload_width']) { if (($config['resize_img'] == '1' && $type == 'vtour') || $config['resize_img'] != '1') { $pass_the_upload = $lang['upload_too_wide']; } } } // check file extensions // invalid extension if (!in_array($extension, explode(',', $config['allowed_upload_extensions']))) { $pass_the_upload = "$lang[upload_invalid_extension] ($extension)."; } // security error if (strstr($_FILES['userfile']['name'][$file_x], "..") != "") { $pass_the_upload = "$lang[upload_security_violation]!"; } // make sure the file hasn't already been uploaded... if ($type == "listings") { $save_name = "$_POST[edit]" . "_" . "$realname"; $sql = "SELECT listingsimages_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE listingsimages_file_name = '$save_name'"; }elseif ($type == "vtour") { $save_name = "$_POST[edit]" . "_" . "$realname"; $sql = "SELECT vtourimages_file_name FROM " . $config['table_prefix'] . "vtourimages WHERE vtourimages_file_name = '$save_name'"; }elseif ($type == "user") { $save_name = "$owner" . "_" . "$realname"; $sql = "SELECT userimages_file_name FROM " . $config['table_prefix'] . "userimages WHERE userimages_file_name = '$save_name'"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $num = $recordSet->RecordCount(); if ($num > 0) { $pass_the_upload = "$lang[file_exists]!"; } if ($pass_the_upload == "true") { // the upload has passed the tests! if ($type == "listings") { move_uploaded_file($_FILES['userfile']['tmp_name'][$file_x], "$config[listings_upload_path]/$save_name"); $thumb_name = $save_name; // by default -- no difference... unless... if ($config['make_thumbnail'] == '1') { // if the option to make a thumbnail is activated... $make_thumb = 'make_thumb_' . $config['thumbnail_prog']; $thumb_name = image_handler::$make_thumb ($save_name, $config['listings_upload_path']); } // end if $config[make_thumbnail] === "1" if ($config['resize_img'] == '1' && $imagewidth > $config['max_' . $type . '_upload_width']) { // if the option to resize the images on upload is activated... $resize_img = 'resize_img_' . $config['thumbnail_prog']; $img_name = image_handler::$resize_img ($save_name, $config['listings_upload_path'], $type); } // end if $config[resize_img] === "1" // Get Max Image Rank $sql = "SELECT MAX(listingsimages_rank) AS max_rank FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = '$edit')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $rank = $recordSet->fields['max_rank']; $rank++; $sql = "INSERT INTO " . $config['table_prefix'] . "listingsimages (listingsdb_id, userdb_id, listingsimages_file_name, listingsimages_thumb_file_name,listingsimages_rank,listingsimages_caption,listingsimages_description,listingsimages_active) VALUES ('$edit', '$owner', '$save_name', '$thumb_name',$rank,'','','yes')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $misc->log_action ("$lang[log_uploaded_listing_image] $save_name"); @chmod("$config[listings_upload_path]/$save_name", 0777); } // end if $type == "listings" if ($type == "vtour") { move_uploaded_file($_FILES['userfile']['tmp_name'][$file_x], "$config[vtour_upload_path]/$save_name"); $thumb_name = $save_name; // by default -- no difference... unless... if ($config['make_thumbnail'] == '1' && $imagedata != false) { // if the option to make a thumbnail is activated... $make_thumb = 'make_thumb_' . $config['thumbnail_prog']; $thumb_name = image_handler::$make_thumb ($save_name, $config['vtour_upload_path']); } // end if $config[make_thumbnail] === "1" // Get Max Image Rank $sql = "SELECT MAX(vtourimages_rank) AS max_rank FROM " . $config['table_prefix'] . "vtourimages WHERE (listingsdb_id = '$edit')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $rank = $recordSet->fields['max_rank']; $rank++; $sql = "INSERT INTO " . $config['table_prefix'] . "vtourimages (listingsdb_id, userdb_id, vtourimages_file_name, vtourimages_thumb_file_name, vtourimages_rank,vtourimages_caption,vtourimages_description,vtourimages_active) VALUES ('$edit', '$owner', '$save_name', '$thumb_name',$rank,'','','yes')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $misc->log_action ("$lang[log_uploaded_listing_image] $save_name"); @chmod("$config[vtour_upload_path]/$save_name", 0777); } // end if $type == "vtour" if ($type == "user") { if ($this->debug) { $display .= 'Try to make Thumbnail? ' . $config['make_thumbnail'] . '
'; } move_uploaded_file($_FILES['userfile']['tmp_name'][$file_x], "$config[user_upload_path]/$save_name"); $thumb_name = $save_name; // by default -- no difference... unless... if ($config['make_thumbnail'] == 1) { // if the option to make a thumbnail is activated... // include ("$config[path_to_thumbnailer]"); $thumb_name = 'make_thumb_' . $config['thumbnail_prog']; $thumb_name = image_handler::$thumb_name($save_name, $config['user_upload_path']); } // end if $config[make_thumbnail] === "1" if ($config['resize_img'] == '1' && $imagewidth > $config['max_' . $type . '_upload_width']) { // if the option to make a thumbnail is activated... // include ("$config[path_to_thumbnailer]"); $resize_img = 'resize_img_' . $config['thumbnail_prog']; image_handler::$resize_img ($save_name, $config['user_upload_path'], $type); } // end if $config[resize_img] === "1" // Get Max Image Rank $sql = "SELECT MAX(userimages_rank) AS max_rank FROM " . $config['table_prefix'] . "userimages WHERE (userdb_id = '$owner')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $rank = $recordSet->fields['max_rank']; $rank++; $sql = "INSERT INTO " . $config['table_prefix'] . "userimages (userdb_id, userimages_file_name, userimages_thumb_file_name,userimages_rank,userimages_caption,userimages_description,userimages_active) VALUES ('$owner', '$save_name', '$thumb_name',$rank,'','','yes')"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $misc->log_action ("$lang[log_uploaded_user_image] $save_name"); @chmod("$config[user_upload_path]/$save_name", 0777); } // end if $type == "user" $display .= "

$realname $lang[upload_success].

"; } // end if $pass_the_upload == "true" else { // the upload has failed... here's why... $display .= "

$lang[upload_failed] $pass_the_upload

"; } } // end if else { // print_r($_FILES); if ($_FILES['userfile']['error'][$file_x] != 4) { $display .= "$lang[upload_too_large]: " . $_FILES['userfile']['name'][$file_x] . ".
"; } } $file_x++; } return $display; } // end function handleUpload function renderListingsMainImage($listingID, $showdesc, $java) { // shows the main image global $config, $lang, $conn; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); // grab the images $listingID = $misc->make_db_extra_safe($listingID); $width = "500"; if ($config["max_listings_upload_width"] < 500 && $config['resize_img'] == '1') { } $sql = "SELECT listingsimages_id, listingsimages_caption, listingsimages_file_name, listingsimages_description FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = $listingID) ORDER BY listingsimages_rank"; $recordSet = $conn->SelectLimit($sql, 1, 0); if ($recordSet === false) { $misc->log_error($sql); } if ($java == 'yes') { $display = ""; } $num_images = $recordSet->RecordCount(); if ($num_images > 0) { while (!$recordSet->EOF) { $file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']); $caption = $misc->make_db_unsafe ($recordSet->fields['listingsimages_caption']); $description = $misc->make_db_unsafe ($recordSet->fields['listingsimages_description']); if ($java == 'yes') { if ($showdesc == 'yes') { $display .= "\"$caption\"
$description
"; } else { $display .= "\"$caption\"
"; } } else { if ($showdesc == 'yes') { $display .= "\"$caption\"
$description
"; } else { $display .= "\"$caption\"
"; } } $recordSet->MoveNext(); } // end while } // end if ($num_images > 0) else { if ($config['show_no_photo'] == 1) { $display .= "\"$lang[no_photo]\"
"; } } return $display; } // end function renderListingsMainImage function renderListingsImagesJava($listingID, $showcap) { // shows the images connected to a given image global $config, $lang, $conn, $style; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); // grab the images $listingID = $misc->make_db_extra_safe($listingID); $sql = "SELECT listingsimages_caption, listingsimages_file_name, listingsimages_thumb_file_name, listingsimages_description FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = $listingID) ORDER BY listingsimages_rank"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $display = ''; $num_images = $recordSet->RecordCount(); if ($num_images > 0) { // $display .= ""; while (!$recordSet->EOF) { $caption = $misc->make_db_unsafe ($recordSet->fields['listingsimages_caption']); $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']); // $imageID = $misc->make_db_unsafe ($recordSet->fields['listingsimages_id']); $description = $misc->make_db_unsafe ($recordSet->fields['listingsimages_description']); $description = str_replace('"','"',$description); $caption = str_replace('"','"',$caption); $description = str_replace(' ','%20',$description); $caption = str_replace(' ','%20',$caption); // gotta grab the image size $imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name"); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $shrinkage = $config['thumbnail_width'] / $imagewidth; $displaywidth = $imagewidth * $shrinkage; $displayheight = $imageheight * $shrinkage; $display .= " "; $display .= "\"$caption\"
"; if ($showcap == 'yes') { $display .= "".urldecode($caption)."

"; } else { $display .= "
"; } $recordSet->MoveNext(); } // end while // $display .= ""; } // end if ($num_images > 0) else { if ($config['show_no_photo'] == 1) { $display .= "\"$lang[no_photo]\"
"; } } return $display; } // end function renderListingsImagesJava function renderListingsImagesJavaRows($listingID) { // shows the images connected to a given image global $config, $lang, $conn, $style; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); // grab the images $var_reset = 1; // Reset the var (counter) (DO NOT CHANGE) $user_col_max = 4; // How Many To show Per Row $listingID = $misc->make_db_extra_safe($listingID); $sql = "SELECT listingsimages_caption, listingsimages_file_name, listingsimages_thumb_file_name, listingsimages_description FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = $listingID) ORDER BY listingsimages_rank"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $display = ''; $num_images = $recordSet->RecordCount(); if ($num_images > 0) { $display .= ""; while (!$recordSet->EOF) { $caption = $misc->make_db_unsafe ($recordSet->fields['listingsimages_caption']); $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']); $description = $misc->make_db_unsafe ($recordSet->fields['listingsimages_description']); $description = str_replace('"','"',$description); $caption = str_replace('"','"',$caption); $description = str_replace(' ','%20',$description); $caption = str_replace(' ','%20',$caption); // gotta grab the image size $imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name"); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $shrinkage = $config['thumbnail_width'] / $imagewidth; $displaywidth = $imagewidth * $shrinkage; $displayheight = $imageheight * $shrinkage; if ($var_reset == 1) { $display .= ""; } if ($caption=='') { $caption=$thumb_file_name; } $display .= ""; if ($var_reset == $user_col_max) { $display .= ""; $var_reset = 1; }else { $var_reset++; } $recordSet->MoveNext(); } // end while if ($var_reset != 1) { $display .= ""; } $display .= "
"; $display .= "\"$caption\""; $display .= "
"; } // end if ($num_images > 0) else { if ($config['show_no_photo'] == 1) { $display .= ""; $display .= "
\"$lang[no_photo]\"
"; } } return $display; } // end function renderListingsImagesJavaRows function edit_vtour_images() { global $lang, $conn, $config; require_once($config['basepath'] . '/include/misc.inc.php'); $misc = new misc(); $display = ''; $edit = $_POST['edit']; $sql_edit = $misc->make_db_safe($_POST['edit']); if (!isset($_POST['action'])) { $_POST['action'] = ''; } // does this person have access to these listings? if (($_SESSION['edit_all_listings'] != "yes") && ($_SESSION['admin_privs'] != "yes")) { $sql = "SELECT userdb_id FROM " . $config['table_prefix'] . "listingsdb WHERE (listingsdb_id = $sql_edit)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $owner = $recordSet->fields['userdb_id']; $recordSet->MoveNext(); } if ($_SESSION['userID'] != $owner) { die ($lang['priv_failure']); } } // end priv check if ($_POST['action'] == "update_pic") { $sql_edit = $misc->make_db_safe($_POST['edit']); $sql_caption = $misc->make_db_safe($_POST['caption']); $sql_description = $misc->make_db_safe($_POST['description']); $sql_rank = $misc->make_db_safe($_POST['rank']); $sql_pic = $misc->make_db_safe($_POST['pic']); if ($_SESSION['edit_all_listings'] == "yes") { $sql = "UPDATE " . $config['table_prefix'] . "vtourimages SET vtourimages_caption = $sql_caption, vtourimages_description = $sql_description, vtourimages_rank = $sql_rank WHERE ((listingsdb_id = $sql_edit) AND (vtourimages_file_name = $sql_pic))"; }else { $sql = "UPDATE " . $config['table_prefix'] . "vtourimages SET vtourimages_caption = $sql_caption, vtourimages_description = $sql_description, vtourimages_rank = $sql_rank WHERE ((listingsdb_id = $sql_edit) AND (vtourimages_file_name = $sql_pic) AND (userdb_id = $_SESSION[userID]))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $display .= "

$lang[image] '$_POST[pic]' $lang[has_been_updated]

"; $misc->log_action ($lang['log_updated_listing_image'] . $_POST['pic']); } if ($_POST['action'] == "delete_pic") { // get the data for the pic being deleted $sql_pic_id = $misc->make_db_safe($_POST['pic_id']); if ($_SESSION['edit_all_listings'] == "yes") { $sql = "SELECT vtourimages_file_name, vtourimages_thumb_file_name FROM " . $config['table_prefix'] . "vtourimages WHERE ((listingsdb_id = $sql_edit) AND (vtourimages_id = $sql_pic_id))"; }else { $sql = "SELECT vtourimages_file_name, vtourimages_thumb_file_name FROM " . $config['table_prefix'] . "vtourimages WHERE ((listingsdb_id = $sql_edit) AND (vtourimages_id = $sql_pic_id) AND (userdb_id = $_SESSION[userID]))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['vtourimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['vtourimages_file_name']); $recordSet->MoveNext(); } // end while // delete from the db if ($_SESSION['edit_all_listings'] == "yes") { $sql = "DELETE FROM " . $config['table_prefix'] . "vtourimages WHERE ((listingsdb_id = $sql_edit) AND (vtourimages_file_name = '$file_name'))"; }else { $sql = "DELETE FROM " . $config['table_prefix'] . "vtourimages WHERE ((listingsdb_id = $sql_edit) AND (vtourimages_file_name = '$file_name') AND (userdb_id = '$_SESSION[userID]'))"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } // delete the files themselves // on widows, required php 4.11 or better (I think) if (!unlink("$config[vtour_upload_path]/$file_name")) die("$lang[alert_site_admin]"); if ($file_name != $thumb_file_name) { if (!unlink("$config[vtour_upload_path]/$thumb_file_name")) die("$lang[alert_site_admin]"); } $misc->log_action ("$lang[log_deleted_listing_image] $file_name"); $display .= "

$lang[image] '$file_name' $lang[has_been_deleted]

"; } if ($_POST['action'] == "upload") { if ($_SESSION['admin_privs'] == "yes") { // get the owner of the listing $sql = "SELECT userdb_id FROM " . $config['table_prefix'] . "listingsdb WHERE (listingsdb_id = $sql_edit)"; $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } while (!$recordSet->EOF) { $owner = $recordSet->fields['userdb_id']; $recordSet->MoveNext(); } $display .= $this->handleUpload("vtour", $edit, $owner); }else { $display .= $this->handleUpload("vtour", $edit, $_SESSION['userID']); } } // end if $action == "upload" if ($_SESSION['edit_all_listings'] == "yes") { $sql = "SELECT vtourimages_id, vtourimages_caption, vtourimages_file_name, vtourimages_thumb_file_name, vtourimages_description, vtourimages_rank FROM " . $config['table_prefix'] . "vtourimages WHERE (listingsdb_id = $sql_edit) ORDER BY vtourimages_rank"; }else { $sql = "SELECT vtourimages_id, vtourimages_caption, vtourimages_file_name, vtourimages_thumb_file_name, vtourimages_description, vtourimages_rank FROM " . $config['table_prefix'] . "vtourimages WHERE ((listingsdb_id = $sql_edit) AND (userdb_id = '$_SESSION[userID]')) ORDER BY vtourimages_rank"; } $recordSet = $conn->Execute($sql); if ($recordSet === false) { $misc->log_error($sql); } $display .= ''; $display .= ''; $display .= ''; $count = 0; $ext = ''; while (!$recordSet->EOF) { // $edit = $misc->make_db_safe($_POST['edit']); $pic_id = $recordSet->fields['vtourimages_id']; $rank = $recordSet->fields['vtourimages_rank']; $caption = $misc->make_db_unsafe ($recordSet->fields['vtourimages_caption']); $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['vtourimages_thumb_file_name']); $file_name = $misc->make_db_unsafe ($recordSet->fields['vtourimages_file_name']); $description = $misc->make_db_unsafe ($recordSet->fields['vtourimages_description']); $ext = substr(strrchr($file_name, '.'), 1); if ($ext == 'jpg') { // gotta grab the image size $imagedata = GetImageSize("$config[vtour_upload_path]/$file_name"); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $shrinkage = $config['thumbnail_width'] / $imagewidth; $displaywidth = $imagewidth * $shrinkage; $displayheight = $imageheight * $shrinkage; $filesize = filesize("$config[vtour_upload_path]/$file_name"); $filesize = $filesize / 1000; // to get k // now grab the thumbnail data $thumb_imagedata = GetImageSize("$config[vtour_upload_path]/$thumb_file_name"); $thumb_imagewidth = $thumb_imagedata[0]; $thumb_imageheight = $thumb_imagedata[1]; $thumb_filesize = filesize("$config[vtour_upload_path]/$thumb_file_name"); $thumb_filesize = $thumb_filesize / 1000; // alternate the colors if ($count == 0) { $count = 1; }else { $count = 0; } $display .= ""; $recordSet->MoveNext(); } // end if ext = jpg elseif ($ext == 'egg') { // alternate the colors if ($count == 0) { $count = 1; }else { $count = 0; } $display .= ""; $recordSet->MoveNext(); } // end elseif ext = egg // Unsupported VTour: Display that it's uploaded but let the user know Open-Realty doesn't support it else { // alternate the colors if ($count == 0) { $count = 1; }else { $count = 0; } $display .= ""; $display .= ""; $recordSet->MoveNext(); } // end else it's not a supported vtour } // end while $num_images = $recordSet->RecordCount(); $avaliable_iamges = $config["max_vtour_uploads"] - $num_images; $x = 0; if ($num_images < $config['max_vtour_uploads'] && $ext != 'egg') { $display .= '
'; $display .= '

' . $lang['edit_images'] . ' -- '; if ($_SESSION['edit_all_listings'] == "yes") { $display .= ""; }else { $display .= ""; } $display .= $lang['return_to_editing_listing']; $display .= '

$file_name
$lang[width]=$imagewidth
$lang[height]=$imageheight
$lang[size]=$filesize" . "k
"; $display .= "
$lang[thumbnail]:
"; $display .= " "; $display .= "
$lang[width]=$thumb_imagewidth
$lang[height]=$thumb_imageheight
$lang[size]=$thumb_filesize" . "k
"; $display .= "

$lang[delete]
"; $display .= "
"; $display .= "
"; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= "
$lang[admin_template_editor_field_rank]:
$lang[upload_rank_explanation]
$lang[upload_caption]:
$lang[upload_description]:
"; $display .= "
"; $display .= "

$file_name
"; $display .= " "; $display .= "

$lang[delete]
"; $display .= "
$lang[unsupported_vtour]
$file_name

$lang[size]=$filesize" . "k
"; $display .= "

$lang[delete]
"; $display .= "
"; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= ""; $display .= "
$lang[admin_template_editor_field_rank]:
$lang[upload_rank_explanation]
$lang[upload_caption]:
$lang[upload_description]:
"; $display .= "
"; $display .= "
'; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= ''; $display .= '
'; $display .= '

' . $lang['upload_a_picture'] . '

'; $display .= '
 '; $display .= '
'; $display .= ''; $display .= ''; $display .= ''; while ($x < $avaliable_iamges) { $display .= '' . $lang['upload_send_this_file'] . ':
'; $x++; } $display .= ''; $display .= '
'; $display .= '
'; } // end if $num_images <= $config[max_user_uploads] $display .= ""; return $display; } } // End ImageHandler Class ?>