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; }
} } else { //echo 'RSS'; $page->page = '{content}'; } // Allow Addons/Functions to pass back custom jscript. global $jscript, $jscript_last; $jscript = ''; $jscript_last = ''; //Load Content $page->replace_tags(array('content')); //Replace Permission tags first $page->replace_permission_tags(); $page->replace_urls(); $page->replace_meta_template_tags(); $page->auto_replace_tags(); // Load js last to make sure all custom js was added $page->replace_tags(array('load_js', 'load_js_last')); //Replace Languages $page->replace_lang_template_tags(); $page->replace_css_template_tags(); $page->output_page(); $conn->Close(); // Close Buffer $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; // Display TIme $end_time = $misc->getmicrotime(); $render_time = sprintf('%.3f', $end_time - $start_time); if (isset($_GET['popup']) && $_GET['popup'] == 'blank') {
function edit_post_comments() { global $conn, $lang, $config; $security = login::loginCheck('can_access_blog_manager', true); $display = ''; $blog_user_type = intval($_SESSION['blog_user_type']); if ($security === true) { require_once $config['basepath'] . '/include/misc.inc.php'; $misc = new misc(); //Load the Core Template require_once $config['basepath'] . '/include/class/template/core.inc.php'; $page = new page_user(); require_once $config['basepath'] . '/include/user.inc.php'; $userclass = new user(); require_once $config['basepath'] . '/include/blog_functions.inc.php'; $blog_functions = new blog_functions(); //Load TEmplate File $page->load_page($config['admin_template_path'] . '/blog_edit_comments.html'); // Do we need to save? if (isset($_GET['id'])) { $post_id = intval($_GET['id']); //Get Blog Post Information $blog_title = $blog_functions->get_blog_title($post_id); $page->page = $page->parse_template_section($page->page, 'blog_title', $blog_title); $blog_author = $blog_functions->get_blog_author($post_id); $page->page = $page->parse_template_section($page->page, 'blog_author', $blog_author); $blog_date_posted = $blog_functions->get_blog_date($post_id); $page->page = $page->parse_template_section($page->page, 'blog_date_posted', $blog_date_posted); //Handle any deletions and comment approvals before we load the comments if (isset($_GET['caction']) && $_GET['caction'] == 'delete') { if (isset($_GET['cid'])) { $cid = intval($_GET['cid']); //Do permission checks. if ($blog_user_type < 4) { //Throw Error $display .= '<div class="error_message">' . $lang['blog_permission_denied'] . '</div><br />'; unset($_GET['caction']); $display .= $this->edit_post_comments(); return $display; } //Delete $sql = 'DELETE FROM ' . $config['table_prefix'] . 'blogcomments WHERE blogcomments_id = ' . $cid . ' AND blogmain_id = ' . $post_id; //Load Record Set $recordSet = $conn->Execute($sql); if (!$recordSet) { $misc->log_error($sql); } } } if (isset($_GET['caction']) && $_GET['caction'] == 'approve') { if (isset($_GET['cid'])) { $cid = intval($_GET['cid']); //Do permission checks. if ($blog_user_type < 4) { //Throw Error $display .= '<div class="error_message">' . $lang['blog_permission_denied'] . '</div><br />'; unset($_GET['caction']); $display .= $this->edit_post_comments(); return $display; } //Delete $sql = 'UPDATE ' . $config['table_prefix'] . 'blogcomments SET blogcomments_moderated = 1 WHERE blogcomments_id = ' . $cid . ' AND blogmain_id = ' . $post_id; //Load Record Set $recordSet = $conn->Execute($sql); if (!$recordSet) { $misc->log_error($sql); } } } //Ok Load the comments. $sql = 'SELECT * FROM ' . $config['table_prefix'] . 'blogcomments WHERE blogmain_id = ' . $post_id . ' ORDER BY blogcomments_timestamp ASC'; //Load Record Set $recordSet = $conn->Execute($sql); if (!$recordSet) { $misc->log_error($sql); } //Handle Next prev $num_rows = $recordSet->RecordCount(); if (!isset($_GET['cur_page'])) { $_GET['cur_page'] = 0; } $limit_str = $_GET['cur_page'] * $config['listings_per_page']; $recordSet = $conn->SelectLimit($sql, $config['listings_per_page'], $limit_str); if ($recordSet === false) { $misc->log_error($sql); } $blog_comment_template = ''; while (!$recordSet->EOF) { //Load DB Values $comment_author_id = $misc->make_db_unsafe($recordSet->fields['userdb_id']); $blogcomments_id = $misc->make_db_unsafe($recordSet->fields['blogcomments_id']); $blogcomments_moderated = $misc->make_db_unsafe($recordSet->fields['blogcomments_moderated']); $blogcomments_timestamp = $misc->make_db_unsafe($recordSet->fields['blogcomments_timestamp']); $blogcomments_text = html_entity_decode($misc->make_db_unsafe($recordSet->fields['blogcomments_text']), ENT_NOQUOTES, $config['charset']); //Load Template Block $blog_comment_template .= $page->get_template_section('blog_article_comment_item_block'); //Lookup Blog Author.. $author_type = $userclass->get_user_type($comment_author_id); if ($author_type == 'member') { $author_display = $userclass->get_user_name($comment_author_id); } else { $author_display = $userclass->get_user_last_name($comment_author_id) . ', ' . $userclass->get_user_first_name($comment_author_id); } $blog_comment_template = $page->parse_template_section($blog_comment_template, 'blog_comment_author', $author_display); if ($config['date_format'] == 1) { $format = "m/d/Y"; } elseif ($config['date_format'] == 2) { $format = "Y/d/m"; } elseif ($config['date_format'] == 3) { $format = "d/m/Y"; } $blog_comment_date_posted = date($format, "{$blogcomments_timestamp}"); $blog_comment_template = $page->parse_template_section($blog_comment_template, 'blog_comment_date_posted', $blog_comment_date_posted); $blog_comment_template = $page->parse_template_section($blog_comment_template, 'blog_comment_text', $blogcomments_text); //Add Delete COmment Link //{blog_comment_delete_url} $blog_comment_delete_url = 'index.php?action=edit_blog_post_comments&id=' . $post_id . '&caction=delete&cid=' . $blogcomments_id; $blog_comment_template = $page->parse_template_section($blog_comment_template, 'blog_comment_delete_url', $blog_comment_delete_url); $blog_comment_approve_url = 'index.php?action=edit_blog_post_comments&id=' . $post_id . '&caction=approve&cid=' . $blogcomments_id; $blog_comment_template = $page->parse_template_section($blog_comment_template, 'blog_comment_approve_url', $blog_comment_approve_url); //Do Security Checks if ($blog_user_type < 4) { $blog_comment_template = $page->remove_template_block('blog_article_comment_approve', $blog_comment_template); $blog_comment_template = $page->remove_template_block('blog_article_comment_delete', $blog_comment_template); } //Handle Moderation if ($blogcomments_moderated == 1) { $blog_comment_template = $page->remove_template_block('blog_article_comment_approve', $blog_comment_template); } else { $blog_comment_template = $page->cleanup_template_block('blog_article_comment_approve', $blog_comment_template); } $recordSet->MoveNext(); } $page->replace_template_section('blog_article_comment_item_block', $blog_comment_template); $next_prev = $misc->next_prev($num_rows, $_GET['cur_page'], "", 'blog', TRUE); $page->replace_tag('next_prev', $next_prev); $page->replace_permission_tags(); $page->auto_replace_tags('', true); $display .= $page->return_page(); } } return $display; }