Exemplo n.º 1
0
 function render_templated_files($ID, $type, $template)
 {
     global $conn, $lang, $config, $db_type;
     //Load the Core Template class and the Misc Class
     require_once $config['basepath'] . '/include/class/template/core.inc.php';
     $page = new page_user();
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     $folderid = $ID;
     $ID = $misc->make_db_extra_safe($ID);
     //Declare an empty display variable to hold all output from function.
     $display = '';
     if ($type == 'listing') {
         $file_upload_path = $config['listings_file_upload_path'];
         $file_view_path = $config['listings_view_file_path'];
         $sqltype = 'listings';
     } else {
         $file_upload_path = $config['users_file_upload_path'];
         $file_view_path = $config['users_view_file_path'];
         $sqltype = 'user';
     }
     $sql = "SELECT " . $type . "sfiles_id, " . $type . "sfiles_caption, " . $type . "sfiles_description, " . $type . "sfiles_file_name FROM " . $config['table_prefix'] . "" . $type . "sfiles WHERE (" . $sqltype . "db_id = {$ID}) ORDER BY " . $type . "sfiles_rank";
     $recordSet = $conn->Execute($sql);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     $num_files = $recordSet->RecordCount();
     if ($num_files >= 1) {
         //Load the File Template specified by the calling tag unless a template was specified in the calling template tag.
         $page->load_page($config['template_path'] . '/files_' . $type . '_' . $template . '.html');
         // Determine if the template uses rows.
         // First item in array is the row conent second item is the number of block per block row
         $file_template_row = $page->get_template_section_row('file_block_row');
         if (is_array($file_template_row)) {
             $row = $file_template_row[0];
             $col_count = $file_template_row[1];
             $uses_rows = true;
             $x = 1;
             //Create an empty array to hold the row contents
             $new_row_data = array();
         } else {
             $uses_rows = false;
         }
         $file_template_section = '';
         while (!$recordSet->EOF) {
             if ($uses_rows == true && $x > $col_count) {
                 //We are at then end of a row. Save the template section as a new row.
                 $new_row_data[] = $page->replace_template_section('file_block', $file_template_section, $row);
                 //$new_row_data[] = $file_template_section;
                 $file_template_section = $page->get_template_section('file_block');
                 $x = 1;
             } else {
                 $file_template_section .= $page->get_template_section('file_block');
             }
             $file_caption = $misc->make_db_unsafe($recordSet->fields[$type . 'sfiles_caption']);
             $file_filename = $misc->make_db_unsafe($recordSet->fields[$type . 'sfiles_file_name']);
             $file_id = $misc->make_db_unsafe($recordSet->fields[$type . 'sfiles_id']);
             $file_url = $file_view_path . '/' . $folderid . '/' . $file_filename;
             $file_download_url = 'index.php?action=create_download&ID=' . $folderid . '&file_id=' . $file_id . '&type=' . $type;
             $file_description = urldecode($misc->make_db_unsafe($recordSet->fields[$type . 'sfiles_description']));
             $file_icon_height = $config["file_icon_height"];
             $file_icon_width = $config["file_icon_width"];
             if ($file_filename != "" && file_exists("{$file_upload_path}/{$folderid}/{$file_filename}")) {
                 $ext = substr(strrchr($file_filename, '.'), 1);
                 $filesize = filesize($file_upload_path . '/' . $folderid . '/' . $file_filename);
                 if ($caption != '') {
                     $alt = $caption;
                 } else {
                     $alt = $thumb_file_name;
                 }
                 $iconpath = $config["file_icons_path"] . '/' . $ext . '.png';
                 if (file_exists($iconpath)) {
                     $file_icon = $config["listings_view_file_icons_path"] . '/' . $ext . '.png';
                 } else {
                     $file_icon = $config["listings_view_file_icons_path"] . '/default.png';
                 }
                 $file_filesize = $this->bytesize($filesize);
             }
             $file_template_section = $page->parse_template_section($file_template_section, 'file_url', $file_url);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_download_url', $file_download_url);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_filename', $file_filename);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_caption', $file_caption);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_description', $file_description);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_icon', $file_icon);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_icon_height', $file_icon_height);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_icon_width', $file_icon_width);
             $file_template_section = $page->parse_template_section($file_template_section, 'file_filesize', $file_filesize);
             $recordSet->MoveNext();
             if ($uses_rows == true) {
                 $x++;
             }
         }
         //END while (!$recordSet->EOF)
         if ($uses_rows == true) {
             $file_template_section = $page->cleanup_template_block('file', $file_template_section);
             $new_row_data[] = $page->replace_template_section('file_block', $file_template_section, $row);
             $replace_row = '';
             foreach ($new_row_data as $rows) {
                 $replace_row .= $rows;
             }
             $page->replace_template_section_row('file_block_row', $replace_row);
         } else {
             $page->replace_template_section('file_block', $file_template_section);
         }
         $page->replace_permission_tags();
         $display .= $page->return_page();
     }
     return $display;
 }
Exemplo n.º 2
0
 function renderFeaturedListings($num_of_listings = 0, $template_name = '', $random = FALSE, $pclass = '', $latest = FALSE)
 {
     global $conn, $lang, $config, $db_type, $current_ID;
     //Load the Core Template class and the Misc Class
     require_once $config['basepath'] . '/include/class/template/core.inc.php';
     $page = new page_user();
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     //Declare an empty display variable to hold all output from function.
     $display = '';
     //If We have a $current_ID save it
     $old_current_ID = '';
     if ($current_ID != '') {
         $old_current_ID = $current_ID;
     }
     //Get the number of listing to display by default, unless user specified an override in the template file.
     if ($num_of_listings == 0) {
         $num_of_listings = $config['num_featured_listings'];
     }
     //Load a Random set of featured listings
     if ($db_type == 'mysql') {
         $rand = 'RAND()';
     } else {
         $rand = 'RANDOM()';
     }
     if ($latest == TRUE) {
         $rand = 'listingsdb_id DESC';
     }
     if ($random == TRUE || $latest == TRUE) {
         $sql_rand = '';
     } else {
         $sql_rand = "(listingsdb_featured = 'yes') AND";
     }
     if ($config['use_expiration'] === "1") {
         if ($pclass != '') {
             $sql = "SELECT " . $config['table_prefix'] . "listingsdb.listingsdb_id, listingsdb_title FROM " . $config['table_prefix'] . "listingsdb," . $config['table_prefix_no_lang'] . "classlistingsdb WHERe {$sql_rand} (listingsdb_active = 'yes') AND (listingsdb_expiration > " . $conn->DBDate(time()) . ") AND (" . $config['table_prefix'] . "listingsdb.listingsdb_id = " . $config['table_prefix_no_lang'] . "classlistingsdb.listingsdb_id) AND class_id = " . $pclass . " ORDER BY {$rand}";
         } else {
             $sql = "SELECT " . $config['table_prefix'] . "listingsdb.listingsdb_id, listingsdb_title FROM " . $config['table_prefix'] . "listingsdb WHERE {$sql_rand} (listingsdb_active = 'yes') AND (listingsdb_expiration > " . $conn->DBDate(time()) . ") ORDER BY {$rand}";
         }
     } else {
         if ($pclass != '') {
             $sql = "SELECT " . $config['table_prefix'] . "listingsdb.listingsdb_id, listingsdb_title FROM " . $config['table_prefix'] . "listingsdb," . $config['table_prefix_no_lang'] . "classlistingsdb WHERE {$sql_rand} (listingsdb_active = 'yes') AND (" . $config['table_prefix'] . "listingsdb.listingsdb_id = " . $config['table_prefix_no_lang'] . "classlistingsdb.listingsdb_id) AND class_id = " . $pclass . " ORDER BY {$rand}";
         } else {
             $sql = "SELECT " . $config['table_prefix'] . "listingsdb.listingsdb_id, listingsdb_title FROM " . $config['table_prefix'] . "listingsdb WHERE {$sql_rand} (listingsdb_active = 'yes') ORDER BY {$rand}";
         }
     }
     $recordSet = $conn->SelectLimit($sql, $num_of_listings, 0);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     //Find out how many listing were returned
     $returned_num_listings = $recordSet->RecordCount();
     if ($returned_num_listings >= 1) {
         //Load the Featured Listing Template specified in the Site Config unless a template was specified in the calling template tag.
         if ($template_name == '') {
             $page->load_page($config['template_path'] . '/' . $config['featured_listing_template']);
         } else {
             if ($random == TRUE) {
                 $page->load_page($config['template_path'] . '/random_listing_' . $template_name . '.html');
             } elseif ($latest == TRUE) {
                 $page->load_page($config['template_path'] . '/latest_listing_' . $template_name . '.html');
             } else {
                 $page->load_page($config['template_path'] . '/featured_listing_' . $template_name . '.html');
             }
         }
         // Determine if the template uses rows.
         // First item in array is the row conent second item is the number of block per block row
         $featured_template_row = $page->get_template_section_row('featured_listing_block_row');
         if (is_array($featured_template_row)) {
             $row = $featured_template_row[0];
             $col_count = $featured_template_row[1];
             $user_rows = true;
             $x = 1;
             //Create an empty array to hold the row conents
             $new_row_data = array();
         } else {
             $user_rows = false;
         }
         $featured_template_section = '';
         while (!$recordSet->EOF) {
             if ($user_rows == true && $x > $col_count) {
                 //We are at then end of a row. Save the template section as a new row.
                 $new_row_data[] = $page->replace_template_section('featured_listing_block', $featured_template_section, $row);
                 //$new_row_data[] = $featured_template_section;
                 $featured_template_section = $page->get_template_section('featured_listing_block');
                 $x = 1;
             } else {
                 $featured_template_section .= $page->get_template_section('featured_listing_block');
             }
             $listing_title = $misc->make_db_unsafe($recordSet->fields['listingsdb_title']);
             $current_ID = $misc->make_db_unsafe($recordSet->fields['listingsdb_id']);
             if ($config['url_style'] == '1') {
                 $featured_url = 'index.php?action=listingview&listingID=' . $current_ID;
             } else {
                 $url_title = str_replace("/", "", $listing_title);
                 $url_title = strtolower(str_replace(" ", $config['seo_url_seperator'], $url_title));
                 $featured_url = 'listing-' . misc::urlencode_to_sef($url_title) . '-' . $current_ID . '.html';
             }
             $featured_template_section = $page->replace_listing_field_tags($current_ID, $featured_template_section);
             $featured_template_section = $page->replace_listing_field_tags($current_ID, $featured_template_section);
             $featured_template_section = $page->parse_template_section($featured_template_section, 'featured_url', $featured_url);
             $featured_template_section = $page->parse_template_section($featured_template_section, 'listingid', $current_ID);
             // Start {isfavorite} featured template section tag
             if (isset($_SESSION['userID'])) {
                 $userID = $misc->make_db_safe($_SESSION['userID']);
                 $sql1 = "SELECT listingsdb_id FROM " . $config['table_prefix'] . "userfavoritelistings WHERE ((listingsdb_id = {$current_ID}) AND (userdb_id={$userID}))";
                 $recordSet1 = $conn->Execute($sql1);
                 if ($recordSet1 === false) {
                     $misc->log_error($sql1);
                 }
                 $favorite_listingsdb_id = $misc->make_db_unsafe($recordSet1->fields['listingsdb_id']);
                 if ($favorite_listingsdb_id !== $current_ID) {
                     $isfavorite = "no";
                     $featured_template_section = $page->parse_template_section($featured_template_section, 'isfavorite', $isfavorite);
                 } else {
                     $isfavorite = "yes";
                     $featured_template_section = $page->parse_template_section($featured_template_section, 'isfavorite', $isfavorite);
                 }
             }
             // End {isfavorite} featured template section tag
             // Setup Image Tags
             $sql2 = "SELECT listingsimages_thumb_file_name,listingsimages_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = {$current_ID}) ORDER BY listingsimages_rank";
             $recordSet2 = $conn->SelectLimit($sql2, 1, 0);
             if ($recordSet2 === false) {
                 $misc->log_error($sql2);
             }
             if ($recordSet2->RecordCount() > 0) {
                 $thumb_file_name = $misc->make_db_unsafe($recordSet2->fields['listingsimages_thumb_file_name']);
                 $file_name = $misc->make_db_unsafe($recordSet2->fields['listingsimages_file_name']);
                 if ($thumb_file_name != "" && file_exists("{$config['listings_upload_path']}/{$thumb_file_name}")) {
                     // gotta grab the thumbnail image size
                     $imagedata = GetImageSize("{$config['listings_upload_path']}/{$thumb_file_name}");
                     $imagewidth = $imagedata[0];
                     $imageheight = $imagedata[1];
                     $shrinkage = $config['thumbnail_width'] / $imagewidth;
                     $featured_thumb_width = $imagewidth * $shrinkage;
                     $featured_thumb_height = $imageheight * $shrinkage;
                     $featured_thumb_src = $config['listings_view_images_path'] . '/' . $thumb_file_name;
                     // gotta grab the thumbnail image size
                     $imagedata = GetImageSize("{$config['listings_upload_path']}/{$file_name}");
                     $imagewidth = $imagedata[0];
                     $imageheight = $imagedata[1];
                     $featured_width = $imagewidth;
                     $featured_height = $imageheight;
                     $featured_src = $config['listings_view_images_path'] . '/' . $file_name;
                 }
             } else {
                 if ($config['show_no_photo'] == 1) {
                     $imagedata = GetImageSize("images/nophoto.gif");
                     $imagewidth = $imagedata[0];
                     $imageheight = $imagedata[1];
                     $shrinkage = $config['thumbnail_width'] / $imagewidth;
                     $featured_thumb_width = $imagewidth * $shrinkage;
                     $featured_thumb_height = $imageheight * $shrinkage;
                     $featured_thumb_src = "images/nophoto.gif";
                     $featured_width = $featured_thumb_width;
                     $featured_height = $featured_thumb_height;
                     $featured_src = "images/nophoto.gif";
                 } else {
                     $featured_thumb_width = '';
                     $featured_thumb_height = '';
                     $featured_thumb_src = '';
                     $featured_width = '';
                     $featured_height = '';
                     $featured_src = '';
                 }
             }
             if (!empty($featured_thumb_src)) {
                 $featured_template_section = $page->parse_template_section($featured_template_section, 'featured_thumb_src', $featured_thumb_src);
                 $featured_template_section = $page->parse_template_section($featured_template_section, 'featured_thumb_height', $featured_thumb_height);
                 $featured_template_section = $page->parse_template_section($featured_template_section, 'featured_thumb_width', $featured_thumb_width);
                 $featured_template_section = $page->cleanup_template_block('featured_img', $featured_template_section);
             } else {
                 $featured_template_section = $page->remove_template_block('featured_img', $featured_template_section);
             }
             if (!empty($featured_src)) {
                 $featured_template_section = $page->parse_template_section($featured_template_section, 'featured_large_src', $featured_src);
                 $featured_template_section = $page->parse_template_section($featured_template_section, 'featured_large_height', $featured_height);
                 $featured_template_section = $page->parse_template_section($featured_template_section, 'featured_large_width', $featured_width);
                 $featured_template_section = $page->cleanup_template_block('featured_img_large', $featured_template_section);
             } else {
                 $featured_template_section = $page->remove_template_block('featured_img_large', $featured_template_section);
             }
             $recordSet->MoveNext();
             if ($user_rows == true) {
                 $x++;
             }
         }
         if ($user_rows == true) {
             $featured_template_section = $page->cleanup_template_block('featured_listing', $featured_template_section);
             $new_row_data[] = $page->replace_template_section('featured_listing_block', $featured_template_section, $row);
             $replace_row = '';
             foreach ($new_row_data as $rows) {
                 $replace_row .= $rows;
             }
             $page->replace_template_section_row('featured_listing_block_row', $replace_row);
         } else {
             $page->replace_template_section('featured_listing_block', $featured_template_section);
         }
         $page->replace_permission_tags();
         $page->auto_replace_tags();
         $display .= $page->return_page();
     }
     $current_ID = '';
     if ($old_current_ID != '') {
         $current_ID = $old_current_ID;
     }
     return $display;
 }
 function renderNotifyListings($listingIDArray, $search_title, $user_name, $email)
 {
     global $conn, $lang, $config, $db_type, $current_ID;
     //Load the Core Template class and the Misc Class
     require_once $config['basepath'] . '/include/class/template/core.inc.php';
     $page = new page_user();
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     require_once $config['basepath'] . '/include/listing.inc.php';
     $listingclass = new listing_pages();
     //Declare an empty display variable to hold all output from function.
     $display = '';
     //If We have a $current_ID save it
     $old_current_ID = '';
     if ($current_ID != '') {
         $old_current_ID = $current_ID;
     }
     //Load the Notify Listing Template specified in the Site Config
     $page->load_page($config['template_path'] . '/' . $config['notify_listings_template']);
     // Determine if the template uses rows.
     // First item in array is the row conent second item is the number of block per block row
     $notify_template_row = $page->get_template_section_row('notify_listing_block_row');
     if (is_array($notify_template_row)) {
         $row = $notify_template_row[0];
         $col_count = $notify_template_row[1];
         $user_rows = true;
         $x = 1;
         //Create an empty array to hold the row conents
         $new_row_data = array();
     } else {
         $user_rows = false;
     }
     $notify_template_section = '';
     foreach ($listingIDArray as $current_ID) {
         if ($user_rows == true && $x > $col_count) {
             //We are at then end of a row. Save the template section as a new row.
             $new_row_data[] = $page->replace_template_section('notify_listing_block', $notify_template_section, $row);
             //$new_row_data[] = $notify_template_section;
             $notify_template_section = $page->get_template_section('notify_listing_block');
             $x = 1;
         } else {
             $notify_template_section .= $page->get_template_section('notify_listing_block');
         }
         $listing_title = $listingclass->get_title($current_ID);
         if ($config['url_style'] == '1') {
             $notify_url = $config['baseurl'] . '/index.php?action=listingview&listingID=' . $current_ID;
             // #####
         } else {
             $url_title = str_replace("/", "", $listing_title);
             $url_title = strtolower(str_replace(" ", $config['seo_url_seperator'], $url_title));
             $notify_url = $config['baseurl'] . '/listing-' . misc::urlencode_to_sef($url_title) . '-' . $current_ID . '.html';
             // #####
         }
         $notify_template_section = $page->replace_listing_field_tags($current_ID, $notify_template_section);
         $notify_template_section = $page->replace_listing_field_tags($current_ID, $notify_template_section);
         $notify_template_section = $page->parse_template_section($notify_template_section, 'notify_url', $notify_url);
         $notify_template_section = $page->parse_template_section($notify_template_section, 'listingid', $current_ID);
         // Setup Image Tags
         $sql2 = "SELECT listingsimages_thumb_file_name,listingsimages_file_name\n\t\t\t\t\tFROM " . $config['table_prefix'] . "listingsimages\n\t\t\t\t\tWHERE (listingsdb_id = {$current_ID})\n\t\t\t\t\tORDER BY listingsimages_rank";
         $recordSet2 = $conn->SelectLimit($sql2, 1, 0);
         if ($recordSet2 === false) {
             $misc->log_error($sql2);
         }
         if ($recordSet2->RecordCount() > 0) {
             $thumb_file_name = $misc->make_db_unsafe($recordSet2->fields['listingsimages_thumb_file_name']);
             $file_name = $misc->make_db_unsafe($recordSet2->fields['listingsimages_file_name']);
             if ($thumb_file_name != "" && file_exists("{$config['listings_upload_path']}/{$thumb_file_name}")) {
                 // gotta grab the thumbnail image size
                 $imagedata = GetImageSize("{$config['listings_upload_path']}/{$thumb_file_name}");
                 $imagewidth = $imagedata[0];
                 $imageheight = $imagedata[1];
                 $shrinkage = $config['thumbnail_width'] / $imagewidth;
                 $notify_thumb_width = $imagewidth * $shrinkage;
                 $notify_thumb_height = $imageheight * $shrinkage;
                 $notify_thumb_src = $config['listings_view_images_path'] . '/' . $thumb_file_name;
                 // gotta grab the thumbnail image size
                 $imagedata = GetImageSize("{$config['listings_upload_path']}/{$file_name}");
                 $imagewidth = $imagedata[0];
                 $imageheight = $imagedata[1];
                 $notify_width = $imagewidth;
                 $notify_height = $imageheight;
                 $notify_src = $config['listings_view_images_path'] . '/' . $file_name;
             }
         } else {
             if ($config['show_no_photo'] == 1) {
                 $imagedata = GetImageSize($config['basepath'] . "/images/nophoto.gif");
                 $imagewidth = $imagedata[0];
                 $imageheight = $imagedata[1];
                 $shrinkage = $config['thumbnail_width'] / $imagewidth;
                 $notify_thumb_width = $imagewidth * $shrinkage;
                 $notify_thumb_height = $imageheight * $shrinkage;
                 $notify_thumb_src = $config['baseurl'] . '/images/nophoto.gif';
                 $notify_width = $notify_thumb_width;
                 $notify_height = $notify_thumb_height;
                 $notify_src = $config['baseurl'] . '/images/nophoto.gif';
             } else {
                 $notify_thumb_width = '';
                 $notify_thumb_height = '';
                 $notify_thumb_src = '';
                 $notify_width = '';
                 $notify_height = '';
                 $notify_src = '';
             }
         }
         if (!empty($notify_thumb_src)) {
             $notify_template_section = $page->parse_template_section($notify_template_section, 'notify_thumb_src', $notify_thumb_src);
             $notify_template_section = $page->parse_template_section($notify_template_section, 'notify_thumb_height', $notify_thumb_height);
             $notify_template_section = $page->parse_template_section($notify_template_section, 'notify_thumb_width', $notify_thumb_width);
             $notify_template_section = $page->cleanup_template_block('notify_img', $notify_template_section);
         } else {
             $notify_template_section = $page->remove_template_block('notify_img', $notify_template_section);
         }
         if (!empty($notify_src)) {
             $notify_template_section = $page->parse_template_section($notify_template_section, 'notify_large_src', $notify_src);
             $notify_template_section = $page->parse_template_section($notify_template_section, 'notify_large_height', $notify_height);
             $notify_template_section = $page->parse_template_section($notify_template_section, 'notify_large_width', $notify_width);
             $notify_template_section = $page->cleanup_template_block('notify_img_large', $notify_template_section);
         } else {
             $notify_template_section = $page->remove_template_block('notify_img_large', $notify_template_section);
         }
         if ($user_rows == true) {
             $x++;
         }
     }
     if ($user_rows == true) {
         $notify_template_section = $page->cleanup_template_block('notify_listing', $notify_template_section);
         $new_row_data[] = $page->replace_template_section('notify_listing_block', $notify_template_section, $row);
         $replace_row = '';
         foreach ($new_row_data as $rows) {
             $replace_row .= $rows;
         }
         $page->replace_template_section_row('notify_listing_block_row', $replace_row);
     } else {
         $page->replace_template_section('notify_listing_block', $notify_template_section);
     }
     $page->replace_permission_tags();
     $page->replace_urls();
     $page->auto_replace_tags();
     $page->replace_lang_template_tags();
     $display .= $page->return_page();
     $current_ID = '';
     if ($old_current_ID != '') {
         $current_ID = $old_current_ID;
     }
     return $display;
 }