function replace_admin_actions()
 {
     global $config, $lang;
     require_once $config['basepath'] . '/include/login.inc.php';
     $login = new login();
     $login_status = $login->loginCheck('Agent');
     if ($login_status !== true) {
         // Run theese commands even if not logged in.
         $data = '';
         switch ($_GET['action']) {
             case 'send_forgot':
                 require_once $config['basepath'] . '/include/login.inc.php';
                 $data = login::forgot_password();
                 break;
             case 'forgot':
                 require_once $config['basepath'] . '/include/login.inc.php';
                 $data = login::forgot_password_reset();
                 break;
             default:
                 $data .= $login_status;
                 break;
         }
     } else {
         switch ($_GET['action']) {
             case 'index':
                 require_once $config['basepath'] . '/include/admin.inc.php';
                 $admin = new general_admin();
                 $data = $admin->index_page();
                 break;
             case 'edit_page':
                 require_once $config['basepath'] . '/include/editor.inc.php';
                 $listing = new editor();
                 $data = $listing->page_edit();
                 break;
             case 'edit_user_images':
                 require_once $config['basepath'] . '/include/images.inc.php';
                 $images = new image_handler();
                 $data = $images->edit_user_images();
                 break;
             case 'edit_listing_images':
                 require_once $config['basepath'] . '/include/images.inc.php';
                 $images = new image_handler();
                 $data = $images->edit_listing_images();
                 break;
             case 'edit_vtour_images':
                 require_once $config['basepath'] . '/include/images.inc.php';
                 $images = new image_handler();
                 $data = $images->edit_vtour_images();
                 break;
             case 'edit_listing_files':
                 require_once $config['basepath'] . '/include/files.inc.php';
                 $files = new file_handler();
                 $data = $files->edit_listing_files();
                 break;
             case 'edit_user_files':
                 require_once $config['basepath'] . '/include/files.inc.php';
                 $files = new file_handler();
                 $data = $files->edit_user_files();
                 break;
             case 'add_listing':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->add_listing();
                 break;
             case 'edit_my_listings':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->edit_listings();
                 break;
             case 'edit_listings':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->edit_listings(false);
                 break;
             case 'configure':
                 require_once $config['basepath'] . '/include/controlpanel.inc.php';
                 $listing_editor = new configurator();
                 $data = $listing_editor->show_configurator();
                 break;
             case 'edit_listing_template':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listing_template();
                 break;
             case 'edit_listings_template_field_order':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listings_template_field_order();
                 break;
             case 'edit_agent_template_field_order':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_template_field_order($type = 'agent');
                 break;
             case 'edit_member_template_field_order':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_template_field_order($type = 'member');
                 break;
             case 'edit_agent_template_add_field':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->add_user_template_field($type = 'agent');
                 break;
             case 'edit_member_template_add_field':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $type = 'member';
                 $data = $listing->add_user_template_field($type);
                 break;
             case 'edit_listing_template_search':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listing_template_search();
                 break;
             case 'edit_listing_template_search_results':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listing_template_search_results();
                 break;
             case 'user_manager':
                 require_once $config['basepath'] . '/include/user_manager.inc.php';
                 $user_managment = new user_managment();
                 $data = $user_managment->show_user_manager();
                 break;
             case 'edit_user_template':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_user_template();
                 break;
             case 'edit_listing_template_add_field':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->add_listing_template_field();
                 break;
             case 'add_page':
                 require_once $config['basepath'] . '/include/editor.inc.php';
                 $listing = new editor();
                 $data = $listing->add_page();
                 break;
             case 'view_log':
                 require_once $config['basepath'] . '/include/log.inc.php';
                 $data = log::view();
                 break;
             case 'clear_log':
                 require_once $config['basepath'] . '/include/log.inc.php';
                 $data = log::clear_log();
                 break;
             case 'show_property_classes':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::show_classes();
                 break;
             case 'modify_property_class':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::modify_property_class();
                 break;
             case 'delete_property_class':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::delete_property_class();
                 break;
             case 'insert_property_class':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::insert_property_class();
                 break;
             case 'add_listing_property_class':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->add_listing_logic();
                 break;
                 //Todo Finish Adding Blog Items
             //Todo Finish Adding Blog Items
             case 'edit_blog':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->blog_edit_index();
                 break;
             case 'edit_blog_post':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->blog_edit();
                 break;
             case 'add_blog':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->add_post();
                 break;
             case 'edit_blog_post_comments':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->edit_post_comments();
                 break;
             case 'addon_manager':
                 require_once $config['basepath'] . '/include/addon_manager.inc.php';
                 $am = new addon_manager();
                 $data = $am->display_addon_manager();
                 break;
             case 'send_notifications':
                 require_once $config['basepath'] . '/include/notification.inc.php';
                 $notify = new notification();
                 $data = $notify->NotifyUsersOfAllNewListings();
                 break;
             default:
                 // Handle Addons
                 $addon_name = array();
                 if (preg_match("/^addon_(.\\S*?)_.*/", $_GET['action'], $addon_name)) {
                     include_once $config['basepath'] . '/addons/' . $addon_name[1] . '/addon.inc.php';
                     $function_name = $addon_name[1] . '_run_action_admin_template';
                     $data = $function_name();
                 }
         }
     }
     return $data;
 }
 function view_favorites()
 {
     global $config, $lang, $conn;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     $security = login::loginCheck('Member');
     if ($security === true) {
         $display = '';
         $display .= '<h3>' . $lang['favorite_listings'] . '</h3>';
         $userID = $misc->make_db_safe($_SESSION['userID']);
         $sql = "SELECT listingsdb_id FROM " . $config['table_prefix'] . "userfavoritelistings WHERE userdb_id = {$userID}";
         $recordSet = $conn->Execute($sql);
         if ($recordSet == false) {
             log_error($sql);
         }
         $num_columns = $recordSet->RecordCount();
         if ($num_columns == 0) {
             $display .= $lang['no_listing_in_favorites'] . '<br /><br />';
         } else {
             $recordNum = 0;
             $listings = '';
             while (!$recordSet->EOF) {
                 if ($recordNum == 0) {
                     $listings .= $recordSet->fields['listingsdb_id'];
                 } else {
                     $listings .= "," . $recordSet->fields['listingsdb_id'];
                 }
                 $recordNum++;
                 $recordSet->MoveNext();
             }
             $_GET['listing_id'] = $listings;
             require_once $config['basepath'] . '/include/search.inc.php';
             $search = new search_page();
             $display .= $search->search_results();
         }
         // End else
         return $display;
     } else {
         return $security;
     }
 }
 public static function renderTemplateAreaNoCaption($templateArea, $listingID)
 {
     // renders all the elements in a given template area on the listing pages
     // this time without the corresponding captions
     global $conn, $config, $lang;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     require_once $config['basepath'] . '/include/login.inc.php';
     $listingID = $misc->make_db_extra_safe($listingID);
     $templateArea = $misc->make_db_extra_safe($templateArea);
     $sql = "SELECT listingsdbelements_field_value, listingsformelements_field_type, listingsformelements_field_caption, listingsformelements_display_priv FROM " . $config['table_prefix'] . "listingsdbelements, " . $config['table_prefix'] . "listingsformelements WHERE ((" . $config['table_prefix'] . "listingsdbelements.listingsdb_id = {$listingID}) AND (listingsformelements_field_name = listingsdbelements_field_name) AND (listingsformelements_location = {$templateArea})) ORDER BY listingsformelements_rank ASC";
     $recordSet = $conn->Execute($sql);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     $display = '';
     while (!$recordSet->EOF) {
         $field_value = $misc->make_db_unsafe($recordSet->fields['listingsdbelements_field_value']);
         $field_type = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_type']);
         $field_caption = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_caption']);
         $display_priv = $misc->make_db_unsafe($recordSet->fields['listingsformelements_display_priv']);
         $display_status = false;
         if ($display_priv == 1) {
             $display_status = login::loginCheck('Member', true);
         } elseif ($display_priv == 2) {
             $display_status = login::loginCheck('Agent', true);
         } elseif ($display_priv == 3) {
             $display_status = login::loginCheck('Admin', true);
         } else {
             $display_status = true;
         }
         if ($display_status === true) {
             if ($field_value != "") {
                 if ($field_type == "select-multiple" or $field_type == "option" or $field_type == "checkbox") {
                     // handle field types with multiple options
                     $feature_index_list = explode("||", $field_value);
                     sort($feature_index_list);
                     $list_count = count($feature_index_list);
                     $l = 1;
                     foreach ($feature_index_list as $feature_list_item) {
                         if ($l < $list_count) {
                             $display .= $feature_list_item;
                             $display .= $config['feature_list_separator'];
                             $l++;
                         } else {
                             $display .= $feature_list_item;
                         }
                     }
                     // end while
                 } elseif ($field_type == "price") {
                     $money_amount = $misc->international_num_format($field_value, $config['number_decimals_price_fields']);
                     $display .= "<strong>{$field_caption}</strong>: " . $misc->money_formats($money_amount);
                 } elseif ($field_type == "number") {
                     $display .= "<strong>{$field_caption}</strong>: " . $misc->international_num_format($field_value, $config['number_decimals_number_fields']);
                 } elseif ($field_type == "url") {
                     $display .= "<a href=\"{$field_value}\" onclick=\"window.open(this.href,'_blank','location=1,resizable=1,status=1,scrollbars=1,toolbar=1,menubar=1');return false\">{$field_value}</a>";
                 } elseif ($field_type == "email") {
                     $display .= "<a href=\"mailto:{$field_value}\">{$field_value}</a>";
                 } elseif ($field_type == "text" or $field_type == "textarea") {
                     if ($config['add_linefeeds'] === "1") {
                         $field_value = nl2br($field_value);
                         //replace returns with <br />
                     }
                     // end if
                     $display .= "{$field_value}";
                 } elseif ($field_type == "Date") {
                     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";
                     }
                     $field_value = date($format, $field_value);
                     $display .= "{$field_value}";
                 } else {
                     $display .= "{$field_value}";
                 }
                 // end else
                 $display .= '<br />';
             } else {
                 if ($field_type == "price" && $config["zero_price"] == "1") {
                     $display .= $lang['call_for_price'] . '<br />';
                 }
                 // end if
             }
             // end else
         }
         $recordSet->MoveNext();
     }
     // end while
     return $display;
 }
 function show_classes()
 {
     global $conn, $config, $lang;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     // Verify User is an Admin
     $security = login::loginCheck('edit_property_classes', true);
     $display = '';
     if ($security === true) {
         $display .= '<span class="section_header">' . $lang['property_class_editor'] . '</span><br /><br />';
         $display .= '<table align="center" class="admin_property_class_table">';
         $display .= '<tr>';
         $display .= '<td><strong>' . $lang['property_class_id'] . '</strong></td><td><strong>' . $lang['property_class_name'] . '</strong></td><td><strong>' . $lang['property_class_rank'] . '</strong></td><td><strong>' . $lang['action'] . '</strong></td>';
         $display .= '</tr>';
         $sql = 'SELECT * FROM ' . $config['table_prefix'] . 'class ORDER BY class_rank';
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         while (!$recordSet->EOF) {
             $class_name = $misc->make_db_unsafe($recordSet->fields['class_name']);
             $class_id = $misc->make_db_unsafe($recordSet->fields['class_id']);
             $class_rank = $misc->make_db_unsafe($recordSet->fields['class_rank']);
             $display .= '<tr><td>' . $class_id . '</td><td>' . $class_name . '</td><td>' . $class_rank . '</td><td><a href="index.php?action=delete_property_class&amp;id=' . $class_id . '" onclick="return confirmDelete(\'' . $lang['delete_prop_class'] . '\')">' . $lang['delete'] . '</a> <a href="index.php?action=modify_property_class&amp;id=' . $class_id . '">' . $lang['modify'] . '</a></td></tr>';
             $recordSet->MoveNext();
         }
         $display .= '</table>';
         $display .= '<br /><a href="index.php?action=insert_property_class">' . $lang['property_class_insert'] . '</a>';
     } else {
     }
     return $display;
 }
 function verify_email()
 {
     global $conn, $config, $lang;
     $display = '';
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     if (isset($_GET['id']) && isset($_GET['key'])) {
         $userID = $misc->make_db_unsafe($_GET['id']);
         $sql = 'SELECT userdb_id, userdb_user_name, userdb_user_password, userdb_emailaddress, userdb_is_agent FROM ' . $config['table_prefix'] . 'userdb WHERE userdb_id = ' . $userID;
         $recordSet = $conn->Execute($sql);
         if ($recordSet === false) {
             $misc->log_error($sql);
         }
         $user_id = $misc->make_db_unsafe($recordSet->fields['userdb_id']);
         $user_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_name']);
         $user_pass = $misc->make_db_unsafe($recordSet->fields['userdb_user_password']);
         $emailAddress = $misc->make_db_unsafe($recordSet->fields['userdb_emailaddress']);
         if (md5($user_id . ':' . $emailAddress) == $_GET['key']) {
             $valid = true;
         }
         if ($recordSet->fields['userdb_is_agent'] == 'yes') {
             $type = 'agent';
         } else {
             $type = 'member';
         }
         if ($config['moderate_' . $type . 's'] == 0) {
             if ($type == 'agent') {
                 if ($config["agent_default_active"] == 0) {
                     $set_active = "no";
                 } else {
                     $set_active = "yes";
                 }
             } else {
                 $set_active = "yes";
             }
         } else {
             $set_active = "no";
         }
         $sql_set_active = $misc->make_db_safe($set_active);
         if ($valid == true) {
             if ($config['email_notification_of_new_users'] == 1) {
                 // if the site admin should be notified when a new user is added
                 $message = $_SERVER['REMOTE_ADDR'] . ' -- ' . date('F j, Y, g:i:s a') . "\r\n\r\n" . $lang['admin_new_user'] . ":\r\n" . $config['baseurl'] . '/admin/index.php?action=user_manager&edit=' . $userID . "\r\n";
                 $header = 'From: ' . $config['admin_name'] . ' <' . $config['admin_email'] . ">\r\n";
                 $header .= "X-Sender: {$config['admin_email']}\r\n";
                 $header .= "Return-Path: {$config['admin_email']}\r\n";
                 mail("{$config['admin_email']}", "{$lang['admin_new_user']}", $message, $header);
             }
             // end if
             $verified = $misc->make_db_safe('yes');
             $sql = 'UPDATE ' . $config['table_prefix'] . 'userdb SET userdb_active = ' . $sql_set_active . ', userdb_email_verified = ' . $verified . ' WHERE userdb_id = ' . $userID;
             $recordSet = $conn->Execute($sql);
             if ($recordSet === false) {
                 $misc->log_error($sql);
             }
             $display .= '<p class="notice">' . $lang['verify_email_thanks'] . '</p>';
             if ($config['moderate_' . $type . 's'] == 1) {
                 // if moderation is turned on...
                 $display .= '<p>' . $lang['admin_new_user_moderated'] . '</p>';
             } else {
                 //log the user in
                 $_SESSION['username'] = $user_name;
                 $_SESSION['userpassword'] = $user_pass;
                 login::loginCheck('Member');
                 $display .= '<p>' . $lang['you_may_now_view_priv'] . '</p>';
             }
         } else {
             $display .= '<p class="notice">' . $lang['verify_email_invalid_link'] . '</div>';
         }
     } else {
         $display .= '<p class="notice">' . $lang['verify_email_invalid_link'] . '</div>';
     }
     return $display;
 }
示例#6
0
 function renderUserInfo($user)
 {
     global $conn, $config, $lang;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     $display = '';
     $formDB = user::determine_user_formtype($user);
     $user = $misc->make_db_safe($user);
     ///agentformelements_id, agentformelements_field_type, agentformelements_field_name, agentformelements_field_caption, agentformelements_default_text, agentformelements_field_elements, agentformelements_rank, agentformelements_required, agentformelements_display_priv
     $priv_sql = '';
     if ($formDB == 'agentformelements') {
         //Check Users Permissions.
         $display_agent = login::loginCheck('Agent', true);
         $display_member = login::loginCheck('Member', true);
         if ($display_agent == TRUE) {
             $priv_sql = 'AND ' . $formDB . '_display_priv <= 2 ';
         } elseif ($display_member == TRUE) {
             $priv_sql = 'AND ' . $formDB . '_display_priv <= 1 ';
         } else {
             $priv_sql = 'AND ' . $formDB . '_display_priv = 0 ';
         }
     }
     $sql = 'SELECT userdbelements_field_value, ' . $formDB . '_field_type, ' . $formDB . '_field_caption FROM ' . $config['table_prefix'] . 'userdbelements, ' . $config['table_prefix'] . $formDB . ' WHERE ((userdb_id = ' . $user . ') AND (userdbelements_field_name = ' . $formDB . '_field_name)) ' . $priv_sql . ' ORDER BY ' . $formDB . '_rank ASC';
     $recordSet = $conn->Execute($sql);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     while (!$recordSet->EOF) {
         $field_value = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         $field_type = $misc->make_db_unsafe($recordSet->fields[$formDB . '_field_type']);
         $field_caption = $misc->make_db_unsafe($recordSet->fields[$formDB . '_field_caption']);
         if ($field_value != "") {
             if ($field_type == "select-multiple" or $field_type == "option" or $field_type == "checkbox") {
                 // handle field types with multiple options
                 $display .= "<strong>{$field_caption}</strong><br />";
                 $feature_index_list = explode("||", $field_value);
                 foreach ($feature_index_list as $feature_list_item) {
                     $display .= $feature_list_item;
                     $display .= $config['feature_list_separator'];
                 }
                 // end while
             } elseif ($field_type == "price") {
                 $money_amount = $misc->international_num_format($field_value);
                 $display .= "<br /><strong>{$field_caption}</strong>: " . money_formats($money_amount);
             } elseif ($field_type == "number") {
                 $display .= "<br /><strong>{$field_caption}</strong>: " . $misc->international_num_format($field_value);
             } elseif ($field_type == "url") {
                 $display .= "<br /><strong>{$field_caption}</strong>: <a href=\"{$field_value}\" onclick=\"window.open(this.href,'_blank','location=1,resizable=1,status=1,scrollbars=1,toolbar=1,menubar=1');return false\">{$field_value}</a>";
             } elseif ($field_type == "email") {
                 $display .= "<br /><strong>{$field_caption}</strong>: <a href=\"mailto:{$field_value}\">{$field_value}</a>";
             } elseif ($field_type == "date") {
                 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";
                 }
                 $field_value = date($format, "{$field_value}");
                 $display .= "<br /><strong>{$field_caption}</strong>: {$field_value}";
             } else {
                 if ($config['add_linefeeds'] === "1") {
                     $field_value = nl2br($field_value);
                     //replace returns with <br />
                 }
                 // end if
                 $display .= "<br /><strong>{$field_caption}</strong>: {$field_value}";
             }
             // end else
         }
         // end if ($field_value != "")
         $recordSet->MoveNext();
     }
     // end while
     return $display;
 }
 function edit_listings($only_my_listings = true)
 {
     global $conn, $lang, $config, $listingID;
     if ($only_my_listings == false) {
         $security = login::loginCheck('edit_all_listings', true);
     } else {
         $security = login::loginCheck('Agent', true);
     }
     $display = '';
     if ($security === true) {
         require_once $config['basepath'] . '/include/misc.inc.php';
         $misc = new misc();
         require_once $config['basepath'] . '/include/forms.inc.php';
         $forms = new forms();
         require_once $config['basepath'] . '/include/class/template/core.inc.php';
         $page = new page_user();
         // $display .= '<span class="section_header">'.$lang['listings_editor'].'<span><br /><br />';
         if (!isset($_GET['delete'])) {
             $_GET['delete'] = '';
         }
         if ($_GET['delete'] != '') {
             if ($_SESSION['admin_privs'] == 'yes' || $_SESSION['edit_all_listings'] == 'yes') {
                 listing_editor::delete_listing($_GET['delete'], false);
             } else {
                 listing_editor::delete_listing($_GET['delete'], true);
             }
         }
         if (!isset($_POST['action'])) {
             $_POST['action'] = '';
         }
         if ($_POST['action'] == "update_listing") {
             if ($_SESSION['admin_privs'] == 'yes' || $_SESSION['edit_all_listings'] == 'yes') {
                 $display .= listing_editor::update_listing(false);
             } else {
                 $display .= listing_editor::update_listing(true);
             }
         }
         // end if $action == "update listing"
         if (!isset($_GET['edit'])) {
             $_GET['edit'] = '';
         }
         if (isset($_POST['lookup_field']) && isset($_POST['lookup_value'])) {
             $_SESSION['edit_listing_qeb_lookup_field'] = $_POST['lookup_field'];
             $_SESSION['edit_listing_qeb_lookup_value'] = $_POST['lookup_value'];
         }
         if (isset($_SESSION['edit_listing_qeb_lookup_field']) && isset($_SESSION['edit_listing_qeb_lookup_value'])) {
             if ($_SESSION['edit_listing_qeb_lookup_field'] != 'listingsdb_id') {
                 $_POST['lookup_field'] = $_SESSION['edit_listing_qeb_lookup_field'];
                 $_POST['lookup_value'] = $_SESSION['edit_listing_qeb_lookup_value'];
             }
         }
         if (isset($_POST['filter'])) {
             $_SESSION['edit_listing_qeb_filter'] = $_POST['filter'];
         }
         if (isset($_SESSION['edit_listing_qeb_filter'])) {
             $_POST['filter'] = $_SESSION['edit_listing_qeb_filter'];
         }
         if (isset($_POST['agent_filter'])) {
             $_SESSION['edit_listing_qeb_agent_filter'] = $_POST['agent_filter'];
         }
         if (isset($_SESSION['edit_listing_qeb_agent_filter'])) {
             $_POST['agent_filter'] = $_SESSION['edit_listing_qeb_agent_filter'];
         }
         if (isset($_POST['pclass_filter'])) {
             $_SESSION['edit_listing_qeb_pclass_filter'] = $_POST['pclass_filter'];
         }
         if (isset($_SESSION['edit_listing_qeb_pclass_filter'])) {
             $_POST['pclass_filter'] = $_SESSION['edit_listing_qeb_pclass_filter'];
         }
         if (isset($_POST['lookup_field']) && isset($_POST['lookup_value']) && $_POST['lookup_field'] == 'listingsdb_id' && $_POST['lookup_value'] != '') {
             $_GET['edit'] = intval($_POST['lookup_value']);
         }
         if ($only_my_listings == TRUE) {
             unset($_POST['agent_filter']);
         }
         if ($_GET['edit'] != "") {
             $edit = intval($_GET['edit']);
             // first, grab the listings's main info
             if ($only_my_listings == true) {
                 $sql = "SELECT listingsdb_id, listingsdb_title, listingsdb_notes, userdb_id, listingsdb_last_modified, listingsdb_featured, listingsdb_active, listingsdb_mlsexport, listingsdb_expiration FROM " . $config['table_prefix'] . "listingsdb WHERE (listingsdb_id = {$edit}) AND (userdb_id = '{$_SESSION['userID']}')";
             } else {
                 $sql = "SELECT listingsdb_id, listingsdb_title, listingsdb_notes, userdb_id, listingsdb_last_modified, listingsdb_featured, listingsdb_active, listingsdb_mlsexport, listingsdb_expiration FROM " . $config['table_prefix'] . "listingsdb WHERE (listingsdb_id = {$edit})";
             }
             $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
             $recordSet = $conn->Execute($sql);
             if ($recordSet === false) {
                 $misc->log_error($sql);
             }
             if ($recordSet->RecordCount() > 0) {
                 // collect up the main DB's various fields
                 $listing_ID = $misc->make_db_unsafe($recordSet->fields['listingsdb_id']);
                 $edit_title = $misc->make_db_unsafe($recordSet->fields['listingsdb_title']);
                 $edit_notes = $misc->make_db_unsafe($recordSet->fields['listingsdb_notes']);
                 $edit_mlsexport = $misc->make_db_unsafe($recordSet->fields['listingsdb_mlsexport']);
                 $edit_or_owner = $recordSet->fields['userdb_id'];
                 $last_modified = $recordSet->UserTimeStamp($recordSet->fields['listingsdb_last_modified'], 'D M j G:i:s T Y');
                 $edit_featured = $recordSet->fields['listingsdb_featured'];
                 $edit_active = $recordSet->fields['listingsdb_active'];
                 $expiration = $recordSet->UserTimeStamp($recordSet->fields['listingsdb_expiration'], $config["date_format_timestamp"]);
                 // now, display all that stuff
                 $display .= '<table class="form_main">';
                 $display .= '<tr>';
                 $display .= '<td colspan="3" class="row_main">';
                 if ($only_my_listings == true) {
                     $display .= '<span class="section_header"><a href="index.php?action=edit_my_listings">' . $lang['listings_editor'] . '</a></span><br />';
                 } else {
                     $display .= '<span class="section_header"><a href="index.php?action=edit_listings">' . $lang['listings_editor'] . '</a></span><br />';
                 }
                 $display .= '<h3>' . $lang['admin_listings_editor_modify_listing'] . ' (<a href="' . $config['baseurl'] . '/index.php?action=listingview&amp;listingID=' . $listing_ID . '" target="_preview">' . $lang['preview'] . '</a>)</h3>';
                 $display .= '</td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td valign="top" align="center" class="row_main">';
                 $display .= '<b>' . $lang['images'] . '</b>';
                 $display .= '<br />';
                 $display .= '<hr width="75%" />';
                 $display .= '<form action="index.php?action=edit_listing_images" method="post" name="edit_listing_images"><input type="hidden" name="edit" value="' . $_GET['edit'] . '" /><a href="javascript:document.edit_listing_images.submit()">' . $lang['edit_images'] . '</a></form>';
                 $display .= '<br />';
                 $sql = "SELECT listingsimages_caption, listingsimages_file_name, listingsimages_thumb_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = {$edit}) ORDER BY listingsimages_rank";
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 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']);
                     // gotta grab the image size
                     $thumb_imagedata = GetImageSize("{$config['listings_upload_path']}/{$thumb_file_name}");
                     $thumb_imagewidth = $thumb_imagedata[0];
                     $thumb_imageheight = $thumb_imagedata[1];
                     $thumb_max_width = $config['thumbnail_width'];
                     $thumb_max_height = $config['thumbnail_height'];
                     $resize_by = $config['resize_thumb_by'];
                     $shrinkage = 1;
                     if ($thumb_max_width == $thumb_imagewidth || $thumb_max_height == $thumb_imageheight) {
                         $thumb_displaywidth = $thumb_imagewidth;
                         $thumb_displayheight = $thumb_imageheight;
                     } else {
                         if ($resize_by == 'width') {
                             $shrinkage = $thumb_imagewidth / $thumb_max_width;
                             $thumb_displaywidth = $thumb_max_width;
                             $thumb_displayheight = round($thumb_imageheight / $shrinkage);
                         } elseif ($resize_by == 'height') {
                             $shrinkage = $thumb_imageheight / $thumb_max_height;
                             $thumb_displayheight = $thumb_max_height;
                             $thumb_displaywidth = round($thumb_imagewidth / $shrinkage);
                         } elseif ($resize_by == 'both') {
                             $thumb_displayheight = $thumb_max_height;
                             $thumb_displaywidth = $thumb_max_width;
                         }
                     }
                     $display .= "<a href=\"{$config['listings_view_images_path']}/{$file_name}\" target=\"_thumb\"> ";
                     $display .= "<img src=\"{$config['listings_view_images_path']}/{$thumb_file_name}\" height=\"{$thumb_displayheight}\" width=\"{$thumb_displaywidth}\" alt=\"{$thumb_file_name}\" /></a><br /> ";
                     $display .= "<b>{$caption}</b><br /><br />";
                     $recordSet->MoveNext();
                 }
                 // end while
                 $display .= '</td>';
                 if ($_SESSION['admin_privs'] == "yes" || $_SESSION['havevtours'] == "yes") {
                     $display .= '<td valign="top" align="center" class="row_main">';
                     $display .= '<b>' . $lang['vtours'] . '</b>';
                     $display .= '<br />';
                     $display .= '<hr width="75%" />';
                     $display .= '<form action="index.php?action=edit_vtour_images" method="post" name="edit_vtour_images"><input type="hidden" name="edit" value="' . $edit . '" /><a href="javascript:document.edit_vtour_images.submit()">' . $lang['edit_vtours'] . '</a></form>';
                     $display .= '<br />';
                     $sql = "SELECT vtourimages_caption, vtourimages_file_name, vtourimages_thumb_file_name FROM " . $config['table_prefix'] . "vtourimages WHERE (listingsdb_id = '{$edit}') ORDER BY  vtourimages_rank";
                     $recordSet = $conn->Execute($sql);
                     if ($recordSet === false) {
                         $misc->log_error($sql);
                     }
                     while (!$recordSet->EOF) {
                         $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']);
                         $ext = substr(strrchr($file_name, '.'), 1);
                         if ($ext == 'jpg') {
                             // gotta grab the image size
                             $imagedata = GetImageSize("{$config['vtour_upload_path']}/{$thumb_file_name}");
                             $imagewidth = $imagedata[0];
                             $imageheight = $imagedata[1];
                             $shrinkage = $config['thumbnail_width'] / $imagewidth;
                             $displaywidth = $imagewidth * $shrinkage;
                             $displayheight = $imageheight * $shrinkage;
                             $display .= "<a href=\"{$config['vtour_view_images_path']}/{$file_name}\" target=\"_thumb\">";
                             $display .= "<img src=\"{$config['vtour_view_images_path']}/{$thumb_file_name}\" height=\"{$displayheight}\" width=\"{$displaywidth}\" alt=\"{$thumb_file_name}\" /></a><br /> ";
                             $display .= "<strong>{$caption}</strong><br /><br />";
                             $recordSet->MoveNext();
                         } elseif ($ext == 'egg') {
                             $display .= "<img src=\"{$config['baseurl']}/images/eggimage.gif\" alt=\"eggimage.gif\" /><br /> ";
                             $recordSet->MoveNext();
                         } else {
                             $display .= $file_name . '<br />' . $lang['unsupported_vtour'] . '<br /><br />';
                             $recordSet->MoveNext();
                         }
                     }
                     // end while
                     if ($_SESSION['admin_privs'] == "yes" || $_SESSION['havefiles'] == "yes") {
                         $display .= '<br />';
                     } else {
                         $display .= '</td>';
                     }
                 }
                 // Place the Files list and edit files link on the edit listing page if we are allowed to have files.
                 if ($_SESSION['admin_privs'] == "yes" || $_SESSION['havefiles'] == "yes") {
                     if ($_SESSION['admin_privs'] == "yes" || $_SESSION['havevtours'] == "yes") {
                         $display .= '<br />';
                     } else {
                         $display .= '<td valign="top" align="center" class="row_main">';
                     }
                     $display .= '<b>' . $lang['files'] . '</b>';
                     $display .= '<br />';
                     $display .= '<hr width="75%" />';
                     $display .= '<form action="index.php?action=edit_listing_files" method="post" name="edit_listing_files"><input type="hidden" name="edit" value="' . $_GET['edit'] . '" /><a href="javascript:document.edit_listing_files.submit()">' . $lang['edit_files'] . '</a></form>';
                     $display .= '<br />';
                     $sql = "SELECT listingsfiles_id, listingsfiles_caption, listingsfiles_file_name FROM " . $config['table_prefix'] . "listingsfiles WHERE (listingsdb_id = '{$_GET['edit']}')";
                     $recordSet = $conn->Execute($sql);
                     if ($recordSet === false) {
                         $misc->log_error($sql);
                     }
                     while (!$recordSet->EOF) {
                         $caption = $misc->make_db_unsafe($recordSet->fields['listingsfiles_caption']);
                         $file_name = $misc->make_db_unsafe($recordSet->fields['listingsfiles_file_name']);
                         $file_id = $misc->make_db_unsafe($recordSet->fields['listingsfiles_id']);
                         $iconext = substr(strrchr($file_name, '.'), 1);
                         $iconpath = $config["file_icons_path"] . '/' . $iconext . '.png';
                         if (file_exists($iconpath)) {
                             $icon = $config["listings_view_file_icons_path"] . '/' . $iconext . '.png';
                         } else {
                             $icon = $config["listings_view_file_icons_path"] . '/default.png';
                         }
                         $file_download_url = 'index.php?action=create_download&amp;ID=' . $edit . '&amp;file_id=' . $file_id . '&amp;type=listing';
                         $display .= '<a href="' . $config['baseurl'] . '/' . $file_download_url . '" target="_thumb">';
                         $display .= '<img src="' . $icon . '" height="' . $config["file_icon_height"] . '" width="' . $config["file_icon_width"] . '" alt="' . $file_name . '" /><br />';
                         $display .= '<strong>' . $file_name . '</strong></a><br />';
                         $display .= '<strong>' . $caption . '</strong><br /><br />';
                         $recordSet->MoveNext();
                     }
                     // end while
                     $display .= '</td>';
                 }
                 $display .= '<td class="row_main">';
                 //START FORM VALIDATION
                 if (isset($_POST['property_class'])) {
                     $class_sql = '';
                     foreach ($_POST['property_class'] as $class_id) {
                         if (empty($class_sql)) {
                             $class_sql .= ' class_id = ' . $class_id;
                         } else {
                             $class_sql .= ' OR class_id = ' . $class_id;
                         }
                         $display .= '<input type="hidden" name="property_class[]" value="' . $class_id . '" />';
                     }
                     $pclass_list = '';
                     $sql = "SELECT DISTINCT(listingsformelements_id) FROM  " . $config['table_prefix_no_lang'] . "classformelements WHERE " . $class_sql;
                     $recordSet = $conn->execute($sql);
                     if ($recordSet === false) {
                         $misc->log_error($sql);
                     }
                     while (!$recordSet->EOF) {
                         if (empty($pclass_list)) {
                             $pclass_list .= $recordSet->fields['listingsformelements_id'];
                         } else {
                             $pclass_list .= ',' . $recordSet->fields['listingsformelements_id'];
                         }
                         $recordSet->Movenext();
                     }
                     if ($pclass_list == '') {
                         $pclass_list = 0;
                     }
                     $sql = "SELECT listingsformelements_field_type, listingsformelements_field_name, listingsformelements_field_caption, listingsformelements_default_text, listingsformelements_field_elements, listingsformelements_required from " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_id IN (" . $pclass_list . ") ORDER BY listingsformelements_rank, listingsformelements_field_name";
                 } else {
                     $sql = "SELECT listingsformelements_field_type, listingsformelements_field_name, listingsformelements_field_caption, listingsformelements_default_text, listingsformelements_field_elements, listingsformelements_required from " . $config['table_prefix'] . "listingsformelements ORDER BY listingsformelements_rank, listingsformelements_field_name";
                 }
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 $display .= "\r\n<script type=\"text/javascript\" >\r\n";
                 $display .= "<!--\r\n";
                 $display .= "function validate_form()\r\n";
                 $display .= "{\r\n";
                 $display .= "var msg=\"\"\r\n";
                 $display .= "valid = true;\r\n";
                 $display .= "if ( document.update_listing.title.value == \"\" )\r\n";
                 $display .= "{\r\n";
                 $display .= "msg += '{$lang['forgot_field']} {$lang['admin_listings_editor_title']} {$lang['admin_template_editor_field']}.\\r\\n';\r\n";
                 $display .= "valid = false;\r\n";
                 $display .= "}\r\n";
                 while (!$recordSet->EOF) {
                     $field_name = $recordSet->fields['listingsformelements_field_name'];
                     $field_caption = $recordSet->fields['listingsformelements_field_caption'];
                     $required = $recordSet->fields['listingsformelements_required'];
                     if ($required == 'Yes') {
                         $display .= "if ( document.update_listing.{$field_name}.value == \"\" )\r\n";
                         $display .= "{\r\n";
                         $display .= "msg += '" . html_entity_decode($lang[forgot_field]) . " {$field_caption} " . html_entity_decode($lang[admin_template_editor_field]) . ".\\r\\n';\r\n";
                         $display .= "valid = false;\r\n";
                         $display .= "}\r\n";
                     }
                     $recordSet->MoveNext();
                 }
                 $display .= "if (msg != \"\")\r\n";
                 $display .= "{\r\n";
                 $display .= "alert (msg);";
                 $display .= "}\r\n";
                 $display .= "return valid;\r\n";
                 $display .= "}\r\n";
                 $display .= "//-->\r\n";
                 $display .= "</script>\r\n";
                 //END FORM VALIDATION
                 $display .= '<table>';
                 if ($only_my_listings == true) {
                     $display .= '<form name="update_listing" action="index.php?action=edit_my_listings&amp;edit=' . $_GET['edit'] . '" method="post" onsubmit="return validate_form ( );">';
                 } else {
                     $display .= '<form name="update_listing" action="index.php?action=edit_listings&amp;edit=' . $_GET['edit'] . '" method="post" onsubmit="return validate_form ( );">';
                 }
                 $display .= '<input type="hidden" name="action" value="update_listing">';
                 $display .= '<input type="hidden" name="edit" value="' . $_GET['edit'] . '">';
                 $display .= '<tr>';
                 $display .= '<td align="right"><b>' . $lang['admin_listings_editor_title'] . ': <font color="red">*</font></b></td>';
                 $display .= '<td align="left"> <input type="text" name="title" value="' . $edit_title . '"></td></tr>';
                 // Display Property Classes
                 $sql2 = 'SELECT class_id FROM ' . $config['table_prefix_no_lang'] . 'classlistingsdb WHERE listingsdb_id =' . $listing_ID;
                 $recordSet2 = $conn->execute($sql2);
                 if ($recordSet2 === false) {
                     $misc->log_error($sql2);
                 }
                 $selected_class_id = array();
                 while (!$recordSet2->EOF) {
                     $selected_class_id[] = $recordSet2->fields['class_id'];
                     $recordSet2->MoveNext();
                 }
                 $sql2 = 'SELECT class_id,class_name FROM ' . $config['table_prefix'] . 'class';
                 $recordSet2 = $conn->execute($sql2);
                 if ($recordSet2 === false) {
                     $misc->log_error($sql2);
                 }
                 $display .= '<tr><td align="right"><b>' . $lang['admin_listings_editor_property_class'] . '</b></td><td align="left">';
                 $display .= '<select name="pclass[]"';
                 if ($config["multiple_pclass_selection"] == '1') {
                     $display .= ' multiple="multiple" size="5"';
                 }
                 $display .= '>';
                 while (!$recordSet2->EOF) {
                     $class_id = $recordSet2->fields['class_id'];
                     $class_name = $misc->make_db_unsafe($recordSet2->fields['class_name']);
                     if (in_array($class_id, $selected_class_id, true)) {
                         $display .= '<option value="' . $class_id . '" selected="selected">' . $class_name . '</option>';
                     } else {
                         $display .= '<option value="' . $class_id . '">' . $class_name . '</option>';
                     }
                     $recordSet2->MoveNext();
                 }
                 $display .= '</select></td></tr>';
                 // End property Class Display
                 if ($_SESSION['featureListings'] == "yes" || $_SESSION['admin_privs'] == "yes") {
                     $display .= '<tr><td align="right"><b>' . $lang['admin_listings_editor_featured'] . ':</b></td><td align="left">';
                     $display .= '<select name="featured" size="1">';
                     $display .= '<option value="' . $edit_featured . '">' . $lang['' . $edit_featured . ''] . '</option>';
                     $display .= '<option value="">-----</option>';
                     $display .= '<option value="yes">' . $lang['yes'] . '</option>';
                     $display .= '<option value="no">' . $lang['no'] . '</option>';
                     $display .= '</select></td></tr>';
                 }
                 // end if ($featureListings == "yes")
                 if ($_SESSION['admin_privs'] == "yes" || $_SESSION['moderator'] == 'yes') {
                     $display .= '<tr><td align="right"><b>' . $lang['admin_listings_active'] . ':</b></td><td align="left">';
                     $display .= '<select name="edit_active" size="1">';
                     $display .= '<option value="' . $edit_active . '">' . $lang['' . $edit_active . ''] . '</option>';
                     $display .= '<option value="">-----</option>';
                     $display .= '<option value="yes">' . $lang['yes'] . '</option>';
                     $display .= '<option value="no">' . $lang['no'] . '</option>';
                     $display .= '</select></td></tr>';
                     if ($config['moderate_listings'] == 1 && $edit_active == 'no') {
                         $display .= '<tr><td align="right"><b>' . $lang['admin_send_notices'] . ':</b></td><td align="left">';
                         $display .= '<select name="send_notices" size="1">';
                         $display .= '<option value="no">' . $lang['no'] . '</option>';
                         $display .= '<option value="yes">' . $lang['yes'] . '</option>';
                         $display .= '</select>';
                         $display .= ' <a href="#" class="tooltip"><img src="images/info.gif" width="16" height="16" /><span>' . $lang['send_notices_tool_tip'] . '</span></a>';
                         $display .= '</td></tr>';
                     }
                 }
                 // end if ($featureListings == "yes")
                 if (($_SESSION['admin_privs'] == "yes" || $_SESSION['edit_expiration'] == "yes") && $config['use_expiration'] == "1") {
                     $display .= '<tr><td align="right" class="row_main"><b>' . $lang['expiration'] . ':</b></td><td align="left"><input type="text" name="edit_expiration" value="' . $expiration . '" onFocus="javascript:vDateType=\'' . $config['date_format'] . '\'" onKeyUp="DateFormat(this,this.value,event,false,\'' . $config['date_format'] . '\')" onBlur="DateFormat(this,this.value,event,true,\'' . $config['date_format'] . '\')" />(' . $config['date_format_long'] . ')</td></tr>';
                 }
                 // end if ($admin_privs == "yes" and $config[use_expiration] = "yes")
                 if ($config["export_listings"] == 1 && $_SESSION['export_listings'] == "yes") {
                     $display .= '<tr><td align="right"><strong>' . $lang['admin_listings_editor_mlsexport'] . ':</strong></td><td align="left">';
                     $display .= '<select name="mlsexport" size="1">';
                     $display .= '<option value="' . $edit_mlsexport . '">' . $lang['' . $edit_mlsexport . ''] . '</option>';
                     $display .= '<option value="">-----</option>';
                     $display .= '<option value="yes">' . $lang['yes'] . '</option>';
                     $display .= '<option value="no">' . $lang['no'] . '</option>';
                     $display .= '</select>';
                     $display .= '</td></tr>';
                 } else {
                     $display .= '<input type="hidden" name="mlsexport" value="no" />';
                 }
                 // Display Agent selection Option to reassign listing
                 if ($_SESSION['admin_privs'] == "yes" || $_SESSION['edit_all_listings'] == "yes") {
                     $display .= '<tr><td align="right"><b>' . $lang['listing_editor_listing_agent'] . ':</b></td>';
                     $display .= '<td align="left" class="row_main"><select name="or_owner" size="1">';
                     // find the name of the agent listed as ID in $edit_or_owner
                     $sql = "SELECT userdb_user_first_name, userdb_user_last_name FROM " . $config['table_prefix'] . "userdb WHERE (userdb_id = {$edit_or_owner})";
                     $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
                     $recordSet = $conn->Execute($sql);
                     if ($recordSet === false) {
                         $misc->log_error($sql);
                     }
                     // strip slashes so input appears correctly
                     $agent_first_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_first_name']);
                     $agent_last_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_last_name']);
                     $display .= "<option value=\"{$edit_or_owner}\">{$agent_last_name},{$agent_first_name}</option>";
                     // fill list with names of all agents
                     $sql = "SELECT userdb_id, userdb_user_first_name, userdb_user_last_name FROM " . $config['table_prefix'] . "userdb where userdb_is_agent = 'yes' or userdb_is_admin = 'yes' ORDER BY userdb_user_last_name,userdb_user_first_name";
                     $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
                     $recordSet = $conn->Execute($sql);
                     if ($recordSet === false) {
                         $misc->log_error($sql);
                     }
                     while (!$recordSet->EOF) {
                         // strip slashes so input appears correctly
                         $agent_ID = $recordSet->fields['userdb_id'];
                         $agent_first_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_first_name']);
                         $agent_last_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_last_name']);
                         $display .= "<option value=\"{$agent_ID}\">{$agent_last_name},{$agent_first_name}</option>";
                         $recordSet->MoveNext();
                     }
                     $display .= "</select></td>";
                     $display .= '</tr>';
                 } else {
                     $display .= '<input type="hidden" name="or_owner" value="' . $edit_or_owner . '" />';
                 }
                 // Show Notes Field
                 if ($config["show_notes_field"] == 1) {
                     $display .= '<tr><td align="right"><b>' . $lang['admin_listings_editor_notes'] . ':</b><br /><div class="small">(' . $lang['admin_listings_editor_notes_note'] . ')</div></td><td align="left"> <textarea name="notes" rows="6" cols="40">' . $edit_notes . '</textarea></td></tr>';
                 } else {
                     $display .= '<input type="hidden" name="notes" value="' . $edit_notes . '" />';
                 }
                 // Show Listing Fields for this property class
                 $sql = 'SELECT class_id from ' . $config['table_prefix_no_lang'] . 'classlistingsdb WHERE listingsdb_id =' . $edit;
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 $class_sql = '';
                 while (!$recordSet->EOF()) {
                     $class_id = $recordSet->fields['class_id'];
                     if (empty($class_sql)) {
                         $class_sql .= ' class_id = ' . $class_id;
                     } else {
                         $class_sql .= ' OR class_id = ' . $class_id;
                     }
                     $recordSet->MoveNext();
                 }
                 $class_list = '';
                 $sql = "SELECT DISTINCT(listingsformelements_id) FROM  " . $config['table_prefix_no_lang'] . "classformelements WHERE " . $class_sql;
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 while (!$recordSet->EOF) {
                     if (empty($class_list)) {
                         $class_list .= $recordSet->fields['listingsformelements_id'];
                     } else {
                         $class_list .= ',' . $recordSet->fields['listingsformelements_id'];
                     }
                     $recordSet->MoveNext();
                 }
                 if ($class_list == '') {
                     $class_list = 0;
                 }
                 $sql = "SELECT listingsformelements_field_name, listingsdbelements_field_value, listingsformelements_field_type, listingsformelements_field_caption, listingsformelements_default_text, listingsformelements_field_elements, listingsformelements_required, listingsformelements_field_length, listingsformelements_tool_tip FROM " . $config['table_prefix'] . "listingsformelements left join " . $config['table_prefix'] . "listingsdbelements on listingsdbelements_field_name = listingsformelements_field_name AND listingsdb_id = {$edit} WHERE listingsformelements_id IN (" . $class_list . ") ORDER BY listingsformelements_rank";
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 while (!$recordSet->EOF) {
                     $field_name = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_name']);
                     if (isset($_POST[$field_name])) {
                         if (is_array($_POST[$field_name])) {
                             $field_value = "";
                             foreach ($_POST[$field_name] as $feature_item) {
                                 $feature_item = $misc->make_db_unsafe($feature_item);
                                 $field_value .= "||{$feature_item}";
                             }
                             // end while
                             // now remove the first two characters
                             $feature_insert_length = strlen($field_value);
                             $feature_insert_length = $feature_insert_length - 2;
                             $field_value = substr($field_value, 2, $feature_insert_length);
                         } else {
                             $field_value = $misc->make_db_unsafe($recordSet->fields['listingsdbelements_field_value']);
                         }
                     } else {
                         $field_value = $misc->make_db_unsafe($recordSet->fields['listingsdbelements_field_value']);
                     }
                     $field_type = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_type']);
                     $field_caption = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_caption']);
                     $default_text = $misc->make_db_unsafe($recordSet->fields['listingsformelements_default_text']);
                     $field_elements = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_elements']);
                     $required = $misc->make_db_unsafe($recordSet->fields['listingsformelements_required']);
                     $field_length = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_length']);
                     $tool_tip = $misc->make_db_unsafe($recordSet->fields['listingsformelements_tool_tip']);
                     // pass the data to the function
                     $display .= $forms->renderExistingFormElement($field_type, $field_name, $field_value, $field_caption, $default_text, $required, $field_elements, $field_length, $tool_tip);
                     $recordSet->MoveNext();
                 }
                 //$editid = substr($edit, 1, -1) * 1;
                 if ($only_my_listings == true) {
                     $edit_link = $config['baseurl'] . '/admin/index.php?action=edit_my_listings&amp;edit=' . $edit;
                     $delete_link = $config['baseurl'] . '/admin/index.php?action=edit_my_listings&amp;delete=' . $edit;
                 } else {
                     $edit_link = $config['baseurl'] . '/admin/index.php?action=edit_listings&amp;edit=' . $edit;
                     $delete_link = $config['baseurl'] . '/admin/index.php?action=edit_listings&amp;delete=' . $edit;
                 }
                 $display .= '<tr><td colspan="2" align="center">' . $lang[required_form_text] . '</td></tr>';
                 $display .= '<tr><td colspan="2" align="center"><input type="submit" value="' . $lang[update_button] . '">  <a href="' . $delete_link . '" onclick="return confirmDelete()">' . $lang[admin_listings_editor_delete_listing] . '</a></td></tr></table></form>';
                 $display .= '</td></tr></table>';
             } else {
                 $display .= '<center><span class="redtext">' . $lang['admin_listings_editor_invalid_listing'] . '</span></center>';
                 $next_prev = '<center>' . $misc->next_prev($num_rows, $_GET['cur_page'], "", '', TRUE) . '</center>';
                 // put in the next/previous stuff
                 $display .= listing_editor::show_quick_edit_bar($next_prev, $only_my_listings);
             }
         } else {
             // show all the listings
             $sql_filter = '';
             if (isset($_POST['filter'])) {
                 if ($_POST['filter'] == 'active') {
                     $sql_filter = " AND listingsdb_active = 'yes' ";
                 }
                 if ($_POST['filter'] == 'inactive') {
                     $sql_filter = " AND listingsdb_active = 'no' ";
                 }
                 if ($_POST['filter'] == 'expired') {
                     $sql_filter = " AND listingsdb_expiration < " . $conn->DBDate(time());
                 }
                 if ($_POST['filter'] == 'featured') {
                     $sql_filter = " AND listingsdb_featured = 'yes' ";
                 }
                 if ($_POST['filter'] == 'created_1week') {
                     $sql_filter = " AND listingsdb_creation_date >= " . $conn->DBDate(date('Y-m-d', strtotime('-1 week')));
                 }
                 if ($_POST['filter'] == 'created_1month') {
                     $sql_filter = " AND listingsdb_creation_date >= " . $conn->DBDate(date('Y-m-d', strtotime('-1 month')));
                 }
                 if ($_POST['filter'] == 'created_3month') {
                     $sql_filter = " AND listingsdb_creation_date >= " . $conn->DBDate(date('Y-m-d', strtotime('-3 month')));
                 }
             }
             $lookup_sql = '';
             if (isset($_POST['lookup_field']) && isset($_POST['lookup_value']) && $_POST['lookup_field'] != 'listingsdb_id' && $_POST['lookup_field'] != 'listingsdb_title' && $_POST['lookup_value'] != '') {
                 $lookup_field = $misc->make_db_safe($_POST['lookup_field']);
                 $lookup_value = $misc->make_db_safe('%' . $_POST['lookup_value'] . '%');
                 $sql = 'SELECT listingsdb_id FROM ' . $config['table_prefix'] . 'listingsdbelements WHERE listingsdbelements_field_name = ' . $lookup_field . ' AND listingsdbelements_field_value LIKE ' . $lookup_value;
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 $listing_ids = array();
                 while (!$recordSet->EOF) {
                     $listing_ids[] = $recordSet->fields['listingsdb_id'];
                     $recordSet->MoveNext();
                 }
                 if (count($listing_ids) > 0) {
                     $listing_ids = implode(',', $listing_ids);
                 } else {
                     $listing_ids = '0';
                 }
                 $lookup_sql = ' AND listingsdb_id IN (' . $listing_ids . ') ';
             }
             if (isset($_POST['lookup_field']) && isset($_POST['lookup_value']) && $_POST['lookup_field'] == 'listingsdb_title' && $_POST['lookup_value'] != '') {
                 $lookup_value = $misc->make_db_safe('%' . $_POST['lookup_value'] . '%');
                 $sql = 'SELECT listingsdb_id FROM ' . $config['table_prefix'] . 'listingsdb WHERE listingsdb_title  LIKE ' . $lookup_value;
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 $listing_ids = array();
                 while (!$recordSet->EOF) {
                     $listing_ids[] = $recordSet->fields['listingsdb_id'];
                     $recordSet->MoveNext();
                 }
                 if (count($listing_ids) > 0) {
                     $listing_ids = implode(',', $listing_ids);
                 } else {
                     $listing_ids = '0';
                 }
                 $lookup_sql = ' AND listingsdb_id IN (' . $listing_ids . ') ';
             }
             if (isset($_POST['pclass_filter']) && $_POST['pclass_filter'] != '') {
                 $pclass_filter = $misc->make_db_safe($_POST['pclass_filter']);
                 $sql = 'SELECT listingsdb_id FROM ' . $config['table_prefix_no_lang'] . 'classlistingsdb WHERE class_id = ' . $pclass_filter;
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 $listing_ids = array();
                 while (!$recordSet->EOF) {
                     $listing_ids[] = $recordSet->fields['listingsdb_id'];
                     $recordSet->MoveNext();
                 }
                 if (count($listing_ids) > 0) {
                     $listing_ids = implode(',', $listing_ids);
                 } else {
                     $listing_ids = '0';
                 }
                 $pclass_sql = ' AND listingsdb_id IN (' . $listing_ids . ') ';
             }
             if (isset($_POST['agent_filter']) && $_POST['agent_filter'] != '') {
                 $agent_filter = $misc->make_db_safe($_POST['agent_filter']);
                 $sql = 'SELECT listingsdb_id FROM ' . $config['table_prefix'] . 'listingsdb WHERE userdb_id = ' . $agent_filter;
                 $recordSet = $conn->Execute($sql);
                 if ($recordSet === false) {
                     $misc->log_error($sql);
                 }
                 $listing_ids = array();
                 while (!$recordSet->EOF) {
                     $listing_ids[] = $recordSet->fields['listingsdb_id'];
                     $recordSet->MoveNext();
                 }
                 if (count($listing_ids) > 0) {
                     $listing_ids = implode(',', $listing_ids);
                 } else {
                     $listing_ids = '0';
                 }
                 $agent_sql = ' AND listingsdb_id IN (' . $listing_ids . ') ';
             }
             // grab the number of listings from the db
             if ($only_my_listings == true) {
                 $sql = "SELECT listingsdb_id, listingsdb_title, listingsdb_mlsexport, listingsdb_notes,\tlistingsdb_expiration, listingsdb_active, listingsdb_featured, listingsdb_hit_count, userdb_emailaddress FROM " . $config['table_prefix'] . "listingsdb, " . $config['table_prefix'] . "userdb WHERE " . $config['table_prefix'] . "listingsdb.userdb_id = " . $config['table_prefix'] . "userdb.userdb_id AND (" . $config['table_prefix'] . "userdb.userdb_id = '{$_SESSION['userID']}') {$sql_filter} {$lookup_sql} {$pclass_sql} {$agent_sql} ORDER BY listingsdb_id ASC";
             } else {
                 $sql = "SELECT listingsdb_id, listingsdb_title, listingsdb_mlsexport, listingsdb_notes,\tlistingsdb_expiration, listingsdb_active, listingsdb_featured, listingsdb_hit_count, userdb_emailaddress FROM " . $config['table_prefix'] . "listingsdb, " . $config['table_prefix'] . "userdb WHERE " . $config['table_prefix'] . "listingsdb.userdb_id = " . $config['table_prefix'] . "userdb.userdb_id {$sql_filter} {$lookup_sql} {$pclass_sql} {$agent_sql} ORDER BY listingsdb_id ASC";
             }
             $recordSet = $conn->Execute($sql);
             if ($recordSet === false) {
                 $misc->log_error($sql);
             }
             $num_rows = $recordSet->RecordCount();
             if (!isset($_GET['cur_page'])) {
                 $_GET['cur_page'] = 0;
             }
             $next_prev = '<center>' . $misc->next_prev($num_rows, $_GET['cur_page'], "", '', TRUE) . '</center>';
             // put in the next/previous stuff
             $display .= listing_editor::show_quick_edit_bar($next_prev, $only_my_listings);
             // build the string to select a certain number of listings per page
             $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);
             }
             $count = 0;
             $display .= "<br /><br />";
             $page->load_page($config['admin_template_path'] . '/edit_listings.html');
             $page->replace_lang_template_tags();
             $page->replace_tags();
             $addons = $page->load_addons();
             $listing_section = $page->get_template_section('listing_dataset');
             while (!$recordSet->EOF) {
                 // alternate the colors
                 if ($count == 0) {
                     $count = $count + 1;
                 } else {
                     $count = 0;
                 }
                 $listing .= $listing_section;
                 // strip slashes so input appears correctly
                 $title = $misc->make_db_unsafe($recordSet->fields['listingsdb_title']);
                 $notes = $misc->make_db_unsafe($recordSet->fields['listingsdb_notes']);
                 $active = $misc->make_db_unsafe($recordSet->fields['listingsdb_active']);
                 $featured = $misc->make_db_unsafe($recordSet->fields['listingsdb_featured']);
                 $mlsexport = $misc->make_db_unsafe($recordSet->fields['listingsdb_mlsexport']);
                 $email = $misc->make_db_unsafe($recordSet->fields['userdb_emailaddress']);
                 $formatted_expiration = $recordSet->UserTimeStamp($recordSet->fields['listingsdb_expiration'], $config["date_format_timestamp"]);
                 $listingID = $recordSet->fields['listingsdb_id'];
                 $hit_count = $misc->make_db_unsafe($recordSet->fields['listingsdb_hit_count']);
                 if ($active == 'yes') {
                     $active = '<span class="edit_listings_' . $active . '">' . $lang['yes'] . '</span>';
                 } elseif ($active == 'no') {
                     $active = '<span class="edit_listings_' . $active . '">' . $lang['no'] . '</span>';
                 }
                 if ($featured == 'yes') {
                     $featured = '<span class="edit_listings_' . $featured . '">' . $lang['yes'] . '</span>';
                 } elseif ($featured == 'no') {
                     $featured = '<span class="edit_listings_' . $featured . '">' . $lang['no'] . '</span>';
                 }
                 //Add filters to link
                 if (isset($_POST['lookup_field']) && isset($_POST['lookup_value'])) {
                     $_GET['lookup_field'] = $_POST['lookup_field'];
                     $_GET['lookup_value'] = $_POST['lookup_value'];
                 }
                 if (isset($_GET['lookup_field']) && isset($_GET['lookup_value'])) {
                     $_POST['lookup_field'] = $_GET['lookup_field'];
                     $_POST['lookup_value'] = $_GET['lookup_value'];
                 }
                 if ($only_my_listings == true) {
                     $edit_link = $config['baseurl'] . '/admin/index.php?action=edit_my_listings&amp;edit=' . $listingID;
                     $delete_link = $config['baseurl'] . '/admin/index.php?action=edit_my_listings&amp;delete=' . $listingID;
                 } else {
                     $edit_link = $config['baseurl'] . '/admin/index.php?action=edit_listings&amp;edit=' . $listingID;
                     $delete_link = $config['baseurl'] . '/admin/index.php?action=edit_listings&amp;delete=' . $listingID;
                 }
                 $email_link = 'mailto:' . $email;
                 $listing = $page->replace_listing_field_tags($listingID, $listing);
                 $listing = $page->parse_template_section($listing, 'listingid', $listingID);
                 $listing = $page->parse_template_section($listing, 'edit_listing_link', $edit_link);
                 $listing = $page->parse_template_section($listing, 'delete_listing_link', $delete_link);
                 $listing = $page->parse_template_section($listing, 'email_agent_link', $email_link);
                 $listing = $page->parse_template_section($listing, 'listing_active_status', $active);
                 $listing = $page->parse_template_section($listing, 'listing_featured_status', $featured);
                 $listing = $page->parse_template_section($listing, 'listing_expiration', $formatted_expiration);
                 $listing = $page->parse_template_section($listing, 'listing_notes', $notes);
                 $listing = $page->parse_template_section($listing, 'row_num_even_odd', $count);
                 $listing = $page->parse_template_section($listing, 'listing_hit_count', $hit_count);
                 $addon_fields = $page->get_addon_template_field_list($addons);
                 $listing = $page->parse_addon_tags($listing, $addon_fields);
                 if ($config["use_expiration"] == 0) {
                     $listing = $page->remove_template_block('show_expiration', $listing);
                 } else {
                     $listing = $page->cleanup_template_block('show_expiration', $listing);
                 }
                 $recordSet->MoveNext();
             }
             // end while
             $page->replace_template_section('listing_dataset', $listing);
             $page->replace_permission_tags();
             $display .= $page->return_page();
         }
         // end if $edit == ""
     } else {
         $display .= '<div class="error_text">' . $lang['access_denied'] . '</div>';
     }
     return $display;
 }
 /**
  * **************************************************************************\
  * Open-Realty - search_results Function										*
  * --------------------------------------------								*
  *   This is the search_results function. The listing_browse page is called is*
  * also now a funciton called search_results_old								*
  * \**************************************************************************
  */
 function search_results($return_ids_only = false)
 {
     $DEBUG_SQL = FALSE;
     global $config, $conn, $lang, $current_ID, $db_type;
     require_once $config['basepath'] . '/include/misc.inc.php';
     require_once $config['basepath'] . '/include/class/template/core.inc.php';
     $misc = new misc();
     $page = new page();
     // Load any addons
     $addons = $page->load_addons();
     $guidestring = "";
     $guidestring_with_sort = "";
     // Save GET
     // Deal with &amp; still being in the URL
     foreach ($_GET as $k => $v) {
         if (strpos($k, 'amp;') !== false) {
             $new_k = str_replace('amp;', '', $k);
             $_GET[$new_k] = $v;
             unset($_GET[$k]);
         }
     }
     //Deal with googlebot double encoding URLS.
     foreach ($_GET as $k => $v) {
         if (strpos($k, '%5B%5D') !== false) {
             $new_k = str_replace('%5B%5D', '', $k);
             $_GET[$new_k][] = $v;
             unset($_GET[$k]);
         }
     }
     foreach ($_GET as $k => $v) {
         if ($v != '' && $k != 'listingID' && $k != 'cur_page' && $k != 'action' && $k != 'PHPSESSID' && $k != 'sortby' && $k != 'sorttype' && $k != 'printer_friendly' && $k != 'template') {
             if (is_array($v)) {
                 foreach ($v as $vitem) {
                     $guidestring .= '&amp;' . urlencode("{$k}") . '[]=' . urlencode("{$vitem}");
                 }
             } else {
                 $guidestring .= '&amp;' . urlencode("{$k}") . '=' . urlencode("{$v}");
             }
         }
     }
     $display = '';
     // Now we get the GET and build our WHERE CLAUSE
     $searchresultSQL = '';
     // Set ImageONly to False
     $imageonly = false;
     $vtoursonly = false;
     $tablelist = array();
     $tablelist_fullname = array();
     $postalcode_dist_lat = '';
     $postalcode_dist_long = '';
     $postalcode_dist_dist = '';
     $latlong_dist_lat = '';
     $latlong_dist_long = '';
     $latlong_dist_dist = '';
     $city_dist_lat = '';
     $city_dist_long = '';
     $city_dist_dist = '';
     foreach ($_GET as $k => $v) {
         if ($k == "sortby") {
             $guidestring_with_sort = "{$k}={$v}";
         } elseif ($k == "sorttype") {
             $guidestring_with_sort = "{$k}={$v}&amp;";
         } elseif ($k == 'PageID') {
             $searchresultSQL .= '';
         } elseif ($k == "user_ID") {
             if ($v != '' && $v != 'Any Agent') {
                 if (is_array($v)) {
                     $sstring = '';
                     foreach ($v as $u) {
                         $u = $misc->make_db_safe($u);
                         if (empty($sstring)) {
                             $sstring .= $config['table_prefix'] . 'listingsdb.userdb_id = ' . $u;
                         } else {
                             $sstring .= ' OR ' . $config['table_prefix'] . 'listingsdb.userdb_id = ' . $u;
                         }
                     }
                     if ($searchresultSQL != '') {
                         $searchresultSQL .= ' AND ';
                     }
                     $searchresultSQL .= '(' . $sstring . ')';
                 } else {
                     $sql_v = $misc->make_db_safe($v);
                     if ($searchresultSQL != '') {
                         $searchresultSQL .= ' AND ';
                     }
                     $searchresultSQL .= '(' . $config['table_prefix'] . 'listingsdb.userdb_id = ' . $sql_v . ')';
                 }
             }
         } elseif ($k == "featuredOnly") {
             // $guidestring .= "&amp;$k=$v";
             if ($v == "yes") {
                 if ($searchresultSQL != '') {
                     $searchresultSQL .= ' AND ';
                 }
                 $searchresultSQL = $searchresultSQL . '(' . $config['table_prefix'] . 'listingsdb.listingsdb_featured = \'yes\')';
             }
         } elseif ($k == 'pclass') {
             $class_sql = '';
             foreach ($v as $class) {
                 // Ignore non numberic values
                 if (is_numeric($class)) {
                     if (!empty($class_sql)) {
                         $class_sql .= ' OR ';
                     }
                     $class_sql .= $config['table_prefix_no_lang'] . "classlistingsdb.class_id = {$class}";
                 }
             }
             if (!empty($class_sql)) {
                 if ($searchresultSQL != '') {
                     $searchresultSQL .= ' AND ';
                 }
                 $searchresultSQL = $searchresultSQL . '(' . $class_sql . ') AND ' . $config['table_prefix_no_lang'] . 'classlistingsdb.listingsdb_id = ' . $config['table_prefix'] . 'listingsdb.listingsdb_id';
                 $tablelist_fullname[] = $config['table_prefix_no_lang'] . "classlistingsdb";
             }
         } elseif ($k == "listing_id") {
             $listing_id = explode(',', $v);
             $i = 0;
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             foreach ($listing_id as $id) {
                 $id = $misc->make_db_safe($id);
                 if ($i == 0) {
                     $searchresultSQL .= '((' . $config['table_prefix'] . 'listingsdb.listingsdb_id = ' . $id . ')';
                 } else {
                     $searchresultSQL .= ' OR (' . $config['table_prefix'] . 'listingsdb.listingsdb_id = ' . $id . ')';
                 }
                 $i++;
             }
             $searchresultSQL .= ')';
         } elseif ($k == "imagesOnly") {
             // Grab only listings with images if that is what we need.
             if ($v == "yes") {
                 $imageonly = true;
             }
         } elseif ($k == "vtoursOnly") {
             // Grab only listings with images if that is what we need.
             if ($v == "yes") {
                 $vtoursonly = true;
             }
         } elseif ($k == 'listing_last_modified_equal') {
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $safe_v = $conn->DBTimeStamp($v);
             $searchresultSQL .= " listingsdb_last_modified = {$safe_v}";
             //listingsdb_last_modified
         } elseif ($k == 'listing_last_modified_greater') {
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $safe_v = $conn->DBTimeStamp($v);
             $searchresultSQL .= " listingsdb_last_modified > {$safe_v}";
             //listingsdb_last_modified
         } elseif ($k == 'listing_last_modified_less') {
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $safe_v = $conn->DBTimeStamp($v);
             $searchresultSQL .= " listingsdb_last_modified < {$safe_v}";
             //listingsdb_last_modified
         } elseif ($k == 'latlong_dist_lat' || $k == 'latlong_dist_long' || $k == 'latlong_dist_dist' && $v != '') {
             switch ($k) {
                 case 'latlong_dist_lat':
                     $latlong_dist_lat = $v;
                     break;
                 case 'latlong_dist_long':
                     $latlong_dist_long = $v;
                     break;
                 case 'latlong_dist_dist':
                     $latlong_dist_dist = $v;
                     break;
             }
         } elseif ($k == 'postalcode_dist_code' && $v != '') {
             $postalcode = $misc->make_db_safe($v);
             $sql = 'SELECT zipdist_latitude, zipdist_longitude FROM ' . $config['table_prefix_no_lang'] . 'zipdist WHERE zipdist_zipcode =' . $postalcode;
             $postalcode_recordSet = $conn->Execute($sql);
             if ($postalcode_recordSet === false) {
                 $misc->log_error($sql);
             }
             $postalcode_dist_lat = $misc->make_db_unsafe($postalcode_recordSet->fields['zipdist_latitude']);
             $postalcode_dist_long = $misc->make_db_unsafe($postalcode_recordSet->fields['zipdist_longitude']);
         } elseif ($k == 'postalcode_dist_dist' && $v != '') {
             $postalcode_dist_dist = $v;
         } elseif ($k == 'city_dist_code' && $v != '') {
             $city = $misc->make_db_safe($v);
             $sql = 'SELECT zipdist_latitude, zipdist_longitude FROM ' . $config['table_prefix_no_lang'] . 'zipdist WHERE zipdist_cityname =' . $city;
             $city_recordSet = $conn->Execute($sql);
             if ($city_recordSet === false) {
                 $misc->log_error($sql);
             }
             $city_dist_lat = $misc->make_db_unsafe($city_recordSet->fields['zipdist_latitude']);
             $city_dist_long = $misc->make_db_unsafe($city_recordSet->fields['zipdist_longitude']);
         } elseif ($k == 'city_dist_dist' && $v != '') {
             $city_dist_dist = $v;
         } elseif ($v != '' && $k != 'listingID' && $k != 'postalcode_dist_code' && $k != 'postalcode_dist_dist' && $k != 'city_dist_code' && $k != 'city_dist_dist' && $k != 'latlong_dist_lat' && $k != 'latlong_dist_long' && $k != 'latlong_dist_dist' && $k != 'cur_page' && $k != 'action' && $k != 'PHPSESSID' && $k != 'sortby' && $k != 'sorttype' && $k != 'printer_friendly' && $k != 'template' && $k != 'pclass' && $k != 'listing_last_modified_less' && $k != 'listing_last_modified_equal' && $k != 'listing_last_modified_greater') {
             if (!is_array($v)) {
                 if ($searchresultSQL != '') {
                     $searchresultSQL .= ' AND ';
                 }
                 //Handle NULL/NOTNULL Searches
                 if (substr($k, -5) == '-NULL' && $v == '1') {
                     $subk = substr($k, 0, -5);
                     $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND (`{$subk}`.listingsdbelements_field_value IS NULL OR `{$subk}`.listingsdbelements_field_value = ''))";
                     if (!in_array($subk, $tablelist)) {
                         $tablelist[] = $subk;
                     }
                 } elseif (substr($k, -8) == '-NOTNULL' && $v == '1') {
                     $subk = substr($k, 0, -8);
                     $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND (`{$subk}`.listingsdbelements_field_value IS NOT NULL  AND `{$subk}`.listingsdbelements_field_value <> ''))";
                     if (!in_array($subk, $tablelist)) {
                         $tablelist[] = $subk;
                     }
                 } elseif (substr($k, -4) == '-max') {
                     $subk = substr($k, 0, -4);
                     if ($db_type == 'mysql') {
                         $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as signed) <= '{$v}')";
                     } else {
                         $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as int4) <= '{$v}')";
                     }
                     if (!in_array($subk, $tablelist)) {
                         $tablelist[] = $subk;
                     }
                 } else {
                     if (substr($k, -4) == '-min') {
                         $subk = substr($k, 0, -4);
                         if ($db_type == 'mysql') {
                             $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as signed) >= '{$v}')";
                         } else {
                             $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as int4) >= '{$v}')";
                         }
                         if (!in_array($subk, $tablelist)) {
                             $tablelist[] = $subk;
                         }
                     } elseif (substr($k, -8) == '-maxdate') {
                         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";
                         }
                         $v = $misc->parseDate($v, $format);
                         $subk = urldecode(substr($k, 0, -8));
                         $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND `{$subk}`.listingsdbelements_field_value <= '{$v}')";
                         if (!in_array($subk, $tablelist)) {
                             $tablelist[] = $subk;
                         }
                     } else {
                         if (substr($k, -8) == '-mindate') {
                             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";
                             }
                             $v = $misc->parseDate($v, $format);
                             $subk = urldecode(substr($k, 0, -8));
                             $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND `{$subk}`.listingsdbelements_field_value >= '{$v}')";
                             if (!in_array($subk, $tablelist)) {
                                 $tablelist[] = $subk;
                             }
                         } else {
                             if (substr($k, -5) == '-date') {
                                 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";
                                 }
                                 $v = $misc->parseDate($v, $format);
                                 $subk = urldecode(substr($k, 0, -5));
                                 $searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND `{$subk}`.listingsdbelements_field_value = '{$v}')";
                                 if (!in_array($subk, $tablelist)) {
                                     $tablelist[] = $subk;
                                 }
                             } elseif ($k == 'searchtext') {
                                 $safe_v = addslashes($v);
                                 $searchresultSQL .= "((`{$k}`.listingsdbelements_field_value like '%{$safe_v}%') OR (listingsdb_title like '%{$safe_v}%'))";
                                 $tablelist[] = $k;
                             } else {
                                 $safe_v = $misc->make_db_safe($v);
                                 $searchresultSQL .= "(`{$k}`.listingsdbelements_field_name = '{$k}' AND `{$k}`.listingsdbelements_field_value = {$safe_v})";
                                 $tablelist[] = $k;
                             }
                         }
                     }
                 }
             } else {
                 // Make Sure Array is not empty
                 $use = false;
                 $comma_separated = implode(" ", $v);
                 if (trim($comma_separated) != '') {
                     $use = true;
                     if ($searchresultSQL != '') {
                         $searchresultSQL .= ' AND ';
                     }
                 }
                 if ($use === true) {
                     if (substr($k, -3) == '_or') {
                         $k = substr($k, 0, strlen($k) - 3);
                         $safe_k = addslashes($k);
                         $searchresultSQL .= "(`{$safe_k}`.listingsdbelements_field_name = '{$safe_k}' AND (";
                         $vitem_count = 0;
                         foreach ($v as $vitem) {
                             $safe_vitem = addslashes($vitem);
                             if ($vitem != '') {
                                 if ($vitem_count != 0) {
                                     $searchresultSQL .= " OR `{$safe_k}`.listingsdbelements_field_value LIKE '%{$safe_vitem}%'";
                                 } else {
                                     $searchresultSQL .= " `{$safe_k}`.listingsdbelements_field_value LIKE '%{$safe_vitem}%'";
                                 }
                                 $vitem_count++;
                             }
                         }
                         $searchresultSQL .= "))";
                         $tablelist[] = $safe_k;
                     } else {
                         $safe_k = addslashes($k);
                         $searchresultSQL .= "(`{$safe_k}`.listingsdbelements_field_name = '{$safe_k}' AND (";
                         $vitem_count = 0;
                         foreach ($v as $vitem) {
                             $safe_vitem = addslashes($vitem);
                             if ($vitem != '') {
                                 if ($vitem_count != 0) {
                                     $searchresultSQL .= " AND `{$safe_k}`.listingsdbelements_field_value LIKE '%{$safe_vitem}%'";
                                 } else {
                                     $searchresultSQL .= " `{$safe_k}`.listingsdbelements_field_value LIKE '%{$safe_vitem}%'";
                                 }
                                 $vitem_count++;
                             }
                         }
                         $searchresultSQL .= "))";
                         $tablelist[] = $safe_k;
                     }
                 }
             }
         }
     }
     if ($postalcode_dist_lat != '' && $postalcode_dist_long != '' && $postalcode_dist_dist != '') {
         $sql = "SELECT zipdist_zipcode FROM {$config['table_prefix_no_lang']}zipdist WHERE (POW((69.1*(zipdist_longitude-\"{$postalcode_dist_long}\")*cos({$postalcode_dist_lat}/57.3)),\"2\")+POW((69.1*(zipdist_latitude-\"{$postalcode_dist_lat}\")),\"2\"))<({$postalcode_dist_dist}*{$postalcode_dist_dist}) ";
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         $zipcodes = array();
         while (!$recordSet->EOF) {
             $zipcodes[] = $recordSet->fields['zipdist_zipcode'];
             $recordSet->MoveNext();
         }
         $pc_field_name = $config["map_zip"];
         // Build Search Query
         // Make Sure Array is not empty
         $use = false;
         $comma_separated = implode(" ", $zipcodes);
         if (trim($comma_separated) != '') {
             $use = true;
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
         }
         if ($use === true) {
             $searchresultSQL .= "(`{$pc_field_name}`.listingsdbelements_field_name = '{$pc_field_name}' AND (";
             $vitem_count = 0;
             foreach ($zipcodes as $vitem) {
                 $safe_vitem = addslashes($vitem);
                 if ($vitem != '') {
                     if ($vitem_count != 0) {
                         $searchresultSQL .= " OR `{$pc_field_name}`.listingsdbelements_field_value = '{$save_vitem}'";
                     } else {
                         $searchresultSQL .= " `{$pc_field_name}`.listingsdbelements_field_value = '{$safe_vitem}'";
                     }
                     $vitem_count++;
                 }
             }
             $searchresultSQL .= "))";
             $tablelist[] = $pc_field_name;
         }
     }
     if ($city_dist_lat != '' && $city_dist_long != '' && $city_dist_dist != '') {
         $sql = "SELECT zipdist_zipcode FROM {$config['table_prefix_no_lang']}zipdist WHERE (POW((69.1*(zipdist_longitude-\"{$city_dist_long}\")*cos({$city_dist_lat}/57.3)),\"2\")+POW((69.1*(zipdist_latitude-\"{$city_dist_lat}\")),\"2\"))<({$city_dist_dist}*{$city_dist_dist}) ";
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         $zipcodes = array();
         while (!$recordSet->EOF) {
             $zipcodes[] = $recordSet->fields['zipdist_zipcode'];
             $recordSet->MoveNext();
         }
         $pc_field_name = $config["map_zip"];
         // Build Search Query
         // Make Sure Array is not empty
         $use = false;
         $comma_separated = implode(" ", $zipcodes);
         if (trim($comma_separated) != '') {
             $use = true;
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
         }
         if ($use === true) {
             $searchresultSQL .= "(`{$pc_field_name}`.listingsdbelements_field_name = '{$pc_field_name}' AND (";
             $vitem_count = 0;
             foreach ($zipcodes as $vitem) {
                 $safe_vitem = addslashes($vitem);
                 if ($vitem != '') {
                     if ($vitem_count != 0) {
                         $searchresultSQL .= " OR `{$pc_field_name}`.listingsdbelements_field_value = '{$safe_vitem}'";
                     } else {
                         $searchresultSQL .= " `{$pc_field_name}`.listingsdbelements_field_value = '{$safe_vitem}'";
                     }
                     $vitem_count++;
                 }
             }
             $searchresultSQL .= "))";
             $tablelist[] = $pc_field_name;
         }
     }
     //Lat Long Distance
     if ($latlong_dist_lat != '' && $latlong_dist_long != '' && $latlong_dist_dist != '') {
         /*
         max_lon = lon1 + arcsin(sin(D/R)/cos(lat1))
         min_lon = lon1 - arcsin(sin(D/R)/cos(lat1))
         max_lat = lat1 + (180/pi)(D/R)
         min_lat = lat1 - (180/pi)(D/R)
         */
         //$max_long = $latlong_dist_long + asin(sin($latlong_dist_dist/3956)/cos($latlong_dist_lat));
         //$min_long = $latlong_dist_long - asin(sin($latlong_dist_dist/3956)/cos($latlong_dist_lat));
         //$max_lat = $latlong_dist_lat + (180/pi())*($latlong_dist_dist/3956);
         //$min_lat = $latlong_dist_lat - (180/pi())*($latlong_dist_dist/3956);
         /*
         Latitude:
         Apparently a degree of latitude expressed in miles does
         vary slighty by latitude
         
         (http://www.ncgia.ucsb.edu/education/curricula/giscc/units/u014/tables/table01.html)
         but for our purposes, I suggest we use 1 degree latitude
         
         = 69 miles.
         
         
         
         Longitude:
         This is more tricky one since it varies by latitude
         (http://www.ncgia.ucsb.edu/education/curricula/giscc/units/u014/tables/table02.html).
         The
         
         simplest formula seems to be:
         1 degree longitude expressed in miles = cos (latitude) *
         69.17 miles
         */
         //Get Correct Milage for ong based on lat.
         $cos_long = 69.17;
         if ($latlong_dist_lat >= 10) {
             $cos_long = 68.13;
         }
         if ($latlong_dist_lat >= 20) {
             $cos_long = 65.03;
         }
         if ($latlong_dist_lat >= 30) {
             $cos_long = 59.95;
         }
         if ($latlong_dist_lat >= 40) {
             $cos_long = 53.06;
         }
         if ($latlong_dist_lat >= 50) {
             $cos_long = 44.55;
         }
         if ($latlong_dist_lat >= 60) {
             $cos_long = 34.67;
         }
         if ($latlong_dist_lat >= 70) {
             $cos_long = 23.73;
         }
         if ($latlong_dist_lat >= 80) {
             $cos_long = 12.05;
         }
         if ($latlong_dist_lat >= 90) {
             $cos_long = 0;
         }
         $max_long = $latlong_dist_long + $latlong_dist_dist / (cos(deg2rad($latlong_dist_lat)) * $cos_long);
         $min_long = $latlong_dist_long - $latlong_dist_dist / (cos(deg2rad($latlong_dist_lat)) * $cos_long);
         $max_lat = $latlong_dist_lat + $latlong_dist_dist / 69;
         $min_lat = $latlong_dist_lat - $latlong_dist_dist / 69;
         //
         if ($max_lat < $min_lat) {
             $max_lat2 = $min_lat;
             $min_lat = $max_lat;
             $max_lat = $max_lat2;
         }
         if ($max_long < $min_long) {
             $max_long2 = $min_long;
             $min_long = $max_long;
             $max_long = $max_long2;
         }
         // Lat and Long Fields
         $sql = "SELECT listingsformelements_field_name FROM " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_field_type  = 'lat'";
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         $lat_field = $recordSet->fields['listingsformelements_field_name'];
         $sql = "SELECT listingsformelements_field_name FROM " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_field_type  = 'long'";
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         $long_field = $recordSet->fields['listingsformelements_field_name'];
         if ($lat_field != '' & $long_field != '') {
             $tablelist[] = $lat_field;
             $tablelist[] = $long_field;
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $searchresultSQL .= "(`{$lat_field}`.listingsdbelements_field_name = '{$lat_field}' AND `{$lat_field}`.listingsdbelements_field_value+0 <= '{$max_lat}')";
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $searchresultSQL .= "(`{$lat_field}`.listingsdbelements_field_name = '{$lat_field}' AND `{$lat_field}`.listingsdbelements_field_value+0 >= '{$min_lat}')";
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $searchresultSQL .= "(`{$long_field}`.listingsdbelements_field_name = '{$long_field}' AND `{$long_field}`.listingsdbelements_field_value+0 <= '{$max_long}')";
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $searchresultSQL .= "(`{$long_field}`.listingsdbelements_field_name = '{$long_field}' AND `{$long_field}`.listingsdbelements_field_value+0 >= '{$min_long}')";
         }
     }
     // Handle Sorting
     // sort the listings
     // this is the main SQL that grabs the listings
     // basic sort by title..
     $group_order_text = '';
     $sortby = '';
     $sorttype = '';
     if ($config["special_sortby"] != 'none') {
         $sortby = $config["special_sortby"] . ',';
         $sorttype = $config["special_sorttype"] . ',';
     }
     if (!isset($_GET['sortby'])) {
         $_GET['sortby'] = $config["sortby"];
     }
     if (!isset($_GET['sorttype'])) {
         $_GET['sorttype'] = $config["sorttype"];
     }
     $sortby .= $_GET['sortby'];
     $sorttype .= $_GET['sorttype'];
     $sql_sort_type = '';
     $sortby_array = explode(',', $sortby);
     $sorttype_array = explode(',', $sorttype);
     $sort_text = '';
     $order_text = '';
     $group_order_text = '';
     $tablelist_nosort = $tablelist;
     $sort_count = count($sortby_array);
     for ($x = 0; $x < $sort_count; $x++) {
         //make sure user input is sanitized before adding to query string
         $sortby_array[$x] = $misc->sanitize($sortby_array[$x]);
         $sorttype_array[$x] = $misc->sanitize($sorttype_array[$x], 4);
         //limit length to 4 characters as sorttype can only be ASC or DESC
         if ($sorttype_array[$x] != 'ASC' && $sorttype_array[$x] != 'DESC') {
             $sorttype_array[$x] = '';
         }
         if ($sortby_array[$x] == 'listingsdb_id') {
             if ($x == 0) {
                 $order_text .= 'ORDER BY listingsdb_id ' . $sorttype_array[$x];
             } else {
                 $order_text .= ',listingsdb_id ' . $sorttype_array[$x];
             }
         } elseif ($sortby_array[$x] == 'listingsdb_title') {
             if ($x == 0) {
                 $order_text .= 'ORDER BY listingsdb_title ' . $sorttype_array[$x];
             } else {
                 $order_text .= ',listingsdb_title ' . $sorttype_array[$x];
             }
         } elseif ($sortby_array[$x] == 'random') {
             if ($x == 0) {
                 $order_text .= 'ORDER BY rand() ' . $sorttype_array[$x];
             } else {
                 $order_text .= ',rand() ' . $sorttype_array[$x];
             }
         } elseif ($sortby_array[$x] == 'listingsdb_featured') {
             if ($x == 0) {
                 $order_text .= 'ORDER BY listingsdb_featured ' . $sorttype_array[$x];
             } else {
                 $order_text .= ',listingsdb_featured ' . $sorttype_array[$x];
             }
         } elseif ($sortby_array[$x] == 'listingsdb_last_modified') {
             if ($x == 0) {
                 $order_text .= 'ORDER BY listingsdb_last_modified ' . $sorttype_array[$x];
             } else {
                 $order_text .= ',listingsdb_last_modified ' . $sorttype_array[$x];
             }
         } elseif ($sortby_array[$x] == 'pclass') {
             if ($searchresultSQL != '') {
                 $searchresultSQL .= ' AND ';
             }
             $searchresultSQL .= $config['table_prefix_no_lang'] . 'classlistingsdb.listingsdb_id = ' . $config['table_prefix'] . 'listingsdb.listingsdb_id AND ' . $config['table_prefix_no_lang'] . 'classlistingsdb.class_id = ' . $config['table_prefix'] . 'class.class_id ';
             $tablelist_fullname[] = $config['table_prefix_no_lang'] . "classlistingsdb";
             $tablelist_fullname[] = $config['table_prefix'] . 'class';
             if ($x == 0) {
                 $order_text .= 'ORDER BY ' . $config['table_prefix'] . 'class.class_name ' . $sorttype_array[$x];
             } else {
                 $order_text .= ',' . $config['table_prefix'] . 'class.class_name ' . $sorttype_array[$x];
             }
         } else {
             // Check if field is a number or price field and cast the order.
             $sort_by_field = $misc->make_db_extra_safe($sortby_array[$x]);
             $sql_sort_type = 'SELECT listingsformelements_field_type FROM ' . $config['table_prefix'] . 'listingsformelements WHERE listingsformelements_field_name = ' . $sort_by_field;
             $recordSet_sort_type = $conn->Execute($sql_sort_type);
             if (!$recordSet_sort_type) {
                 $misc->log_error($sql_sort_type);
             }
             $field_type = $recordSet_sort_type->fields['listingsformelements_field_type'];
             if ($field_type == 'price' || $field_type == 'number' || $field_type == 'decimal') {
                 $tablelist[] = 'sort' . $x;
                 $sort_text .= 'AND (sort' . $x . '.listingsdbelements_field_name = ' . $sort_by_field . ') ';
                 global $db_type;
                 if ($db_type == 'mysql') {
                     if ($x == 0) {
                         $order_text .= ' ORDER BY CAST(sort' . $x . '.listingsdbelements_field_value as signed) ' . $sorttype_array[$x];
                         $group_order_text .= ',sort' . $x . '.listingsdbelements_field_value';
                     } else {
                         $order_text .= ',CAST(sort' . $x . '.listingsdbelements_field_value as signed) ' . $sorttype_array[$x];
                         $group_order_text .= ',sort' . $x . '.listingsdbelements_field_value';
                     }
                 } else {
                     if ($x == 0) {
                         $order_text .= ' ORDER BY CAST(sort' . $x . '.listingsdbelements_field_value as int4) ' . $sorttype_array[$x];
                         $group_order_text .= ',sort' . $x . '.listingsdbelements_field_value';
                     } else {
                         $order_text .= ',CAST(sort' . $x . '.listingsdbelements_field_value as int4) ' . $sorttype_array[$x];
                         $group_order_text .= ',sort' . $x . '.listingsdbelements_field_value';
                     }
                 }
             } else {
                 $tablelist[] = 'sort' . $x;
                 $sort_text .= 'AND (sort' . $x . '.listingsdbelements_field_name = ' . $sort_by_field . ') ';
                 if ($x == 0) {
                     $order_text .= ' ORDER BY sort' . $x . '.listingsdbelements_field_value ' . $sorttype_array[$x];
                 } else {
                     $order_text .= ', sort' . $x . '.listingsdbelements_field_value ' . $sorttype_array[$x];
                 }
                 $group_order_text .= ',sort' . $x . '.listingsdbelements_field_value';
             }
         }
     }
     $group_order_text = $group_order_text . ' ' . $order_text;
     if ($imageonly == true || $vtoursonly == true) {
         $order_text = "GROUP BY " . $config['table_prefix'] . "listingsdb.listingsdb_id, " . $config['table_prefix'] . "listingsdb.listingsdb_title " . $group_order_text;
     }
     if ($DEBUG_SQL) {
         echo '<strong>Sort Type SQL:</strong> ' . $sql_sort_type . '<br />';
         echo '<strong>Sort Text:</strong> ' . $sort_text . '<br />';
         echo '<strong>Order Text:</strong> ' . $order_text . '<br />';
     }
     $guidestring_with_sort = $guidestring_with_sort . $guidestring;
     // End of Sort
     $arrayLength = count($tablelist);
     if ($DEBUG_SQL) {
         echo '<strong>Table List Array Length:</strong> ' . $arrayLength . '<br />';
     }
     $string_table_list = '';
     for ($i = 0; $i < $arrayLength; $i++) {
         $string_table_list .= ' ,' . $config['table_prefix'] . 'listingsdbelements `' . $tablelist[$i] . '`';
     }
     $arrayLength = count($tablelist_nosort);
     $string_table_list_no_sort = '';
     for ($i = 0; $i < $arrayLength; $i++) {
         $string_table_list_no_sort .= ' ,' . $config['table_prefix'] . 'listingsdbelements `' . $tablelist[$i] . '`';
     }
     $arrayLength = count($tablelist_fullname);
     if ($DEBUG_SQL) {
         echo '<strong>Table List Array Length:</strong> ' . $arrayLength . '<br />';
     }
     for ($i = 0; $i < $arrayLength; $i++) {
         $string_table_list .= ' ,' . $tablelist_fullname[$i];
         $string_table_list_no_sort .= ' ,' . $tablelist_fullname[$i];
     }
     if ($DEBUG_SQL) {
         echo '<strong>Table List String:</strong> ' . $string_table_list . '<br />';
     }
     $arrayLength = count($tablelist);
     $string_where_clause = '';
     for ($i = 0; $i < $arrayLength; $i++) {
         $string_where_clause .= ' AND (' . $config['table_prefix'] . 'listingsdb.listingsdb_id = `' . $tablelist[$i] . '`.listingsdb_id)';
     }
     $arrayLength = count($tablelist_nosort);
     $string_where_clause_nosort = '';
     for ($i = 0; $i < $arrayLength; $i++) {
         $string_where_clause_nosort .= ' AND (' . $config['table_prefix'] . 'listingsdb.listingsdb_id = `' . $tablelist[$i] . '`.listingsdb_id)';
     }
     if ($imageonly) {
         $searchSQL = "SELECT distinct(" . $config['table_prefix'] . "listingsdb.listingsdb_id), " . $config['table_prefix'] . "listingsdb.userdb_id, " . $config['table_prefix'] . "listingsdb.listingsdb_title FROM " . $config['table_prefix'] . "listingsdb, " . $config['table_prefix'] . "listingsimages " . $string_table_list . " WHERE (listingsdb_active = 'yes') " . $string_where_clause . " AND (" . $config['table_prefix'] . "listingsimages.listingsdb_id = " . $config['table_prefix'] . "listingsdb.listingsdb_id) ";
         $searchSQLCount = "SELECT COUNT(distinct(" . $config['table_prefix'] . "listingsdb.listingsdb_id)) as total_listings FROM " . $config['table_prefix'] . "listingsdb, " . $config['table_prefix'] . "listingsimages " . $string_table_list_no_sort . " WHERE (listingsdb_active = 'yes') " . $string_where_clause_nosort . " AND (" . $config['table_prefix'] . "listingsimages.listingsdb_id = " . $config['table_prefix'] . "listingsdb.listingsdb_id) ";
     } elseif ($vtoursonly) {
         $searchSQL = "SELECT distinct(" . $config['table_prefix'] . "listingsdb.listingsdb_id), " . $config['table_prefix'] . "listingsdb.userdb_id, " . $config['table_prefix'] . "listingsdb.listingsdb_title FROM " . $config['table_prefix'] . "listingsdb, " . $config['table_prefix'] . "vtourimages " . $string_table_list . " WHERE (listingsdb_active = 'yes') " . $string_where_clause . " AND (" . $config['table_prefix'] . "vtourimages.listingsdb_id = " . $config['table_prefix'] . "listingsdb.listingsdb_id) ";
         $searchSQLCount = "SELECT COUNT(distinct(" . $config['table_prefix'] . "listingsdb.listingsdb_id)) as total_listings FROM " . $config['table_prefix'] . "listingsdb, " . $config['table_prefix'] . "vtourimages " . $string_table_list_no_sort . " WHERE (listingsdb_active = 'yes') " . $string_where_clause_nosort . " AND (" . $config['table_prefix'] . "vtourimages.listingsdb_id = " . $config['table_prefix'] . "listingsdb.listingsdb_id) ";
     } else {
         $searchSQL = "SELECT distinct(" . $config['table_prefix'] . "listingsdb.listingsdb_id), " . $config['table_prefix'] . "listingsdb.userdb_id,  " . $config['table_prefix'] . "listingsdb.listingsdb_title FROM " . $config['table_prefix'] . "listingsdb " . $string_table_list . " WHERE (listingsdb_active = 'yes') " . $string_where_clause;
         $searchSQLCount = "SELECT COUNT(distinct(" . $config['table_prefix'] . "listingsdb.listingsdb_id)) as total_listings FROM " . $config['table_prefix'] . "listingsdb " . $string_table_list_no_sort . " WHERE (listingsdb_active = 'yes') " . $string_where_clause_nosort;
     }
     if ($searchresultSQL != '') {
         $searchSQL .= " AND " . $searchresultSQL;
         $searchSQLCount .= " AND " . $searchresultSQL;
     }
     if ($config['use_expiration'] == 1) {
         $searchSQL .= " AND (listingsdb_expiration > " . $conn->DBDate(time()) . ")";
         $searchSQLCount .= " AND (listingsdb_expiration > " . $conn->DBDate(time()) . ")";
     }
     $sql = $searchSQL . " {$sort_text} {$order_text}";
     $searchSQLCount = $searchSQLCount;
     // We now have a complete SQL Query. Now grab the results
     $recordSet = $conn->Execute($searchSQLCount);
     if ($DEBUG_SQL) {
         echo '<strong>Listing Count:</strong> ' . $searchSQLCount . '<br />';
     }
     if (!$recordSet) {
         $misc->log_error($searchSQLCount);
     }
     // We have the results so now we need to stack them in arrays to use with the search_result.html template file
     // Load the templste
     require_once $config['basepath'] . '/include/class/template/core.inc.php';
     $page = new page_user();
     if (count($_GET['pclass']) == 1 && file_exists($config['template_path'] . '/search_results_class_' . $_GET['pclass'][0] . '.html')) {
         $page->load_page($config['template_path'] . '/search_results_class_' . $_GET['pclass'][0] . '.html');
     } else {
         $page->load_page($config['template_path'] . '/' . $config['search_result_template']);
     }
     // Get header section
     $header_section = $page->get_template_section('search_result_header');
     $search_result = '';
     // Ok we have the header section now get the result section
     $search_result_section = $page->get_template_section('search_result_dataset');
     // Get the number of rows(records) we have.
     // $num_rows = $recordSet->RecordCount();
     $num_rows = $recordSet->fields['total_listings'];
     if ($return_ids_only === true) {
         // If we are returning IDs only for the notify listing then get the id and move on.
         $id = array();
         $resultRecordSet = $conn->Execute($sql);
         if (!$resultRecordSet) {
             $misc->log_error($sql);
         }
         if ($DEBUG_SQL) {
             echo '<strong>Search SQL:</strong> ' . $sql . '<br />';
         }
         while (!$resultRecordSet->EOF) {
             $id[] = $resultRecordSet->fields['listingsdb_id'];
             $resultRecordSet->MoveNext();
         }
         // while
         return $id;
     } elseif ($return_ids_only === 'perpage') {
         $id = array();
         if (!isset($_GET['cur_page'])) {
             $_GET['cur_page'] = 0;
         }
         $limit_str = intval($_GET['cur_page']) * $config['listings_per_page'];
         $resultRecordSet = $conn->SelectLimit($sql, $config['listings_per_page'], $limit_str);
         if (!$resultRecordSet) {
             $misc->log_error($sql);
         }
         if ($DEBUG_SQL) {
             echo '<strong>Search SQL:</strong> ' . $sql . '<br />';
         }
         while (!$resultRecordSet->EOF) {
             $id[] = $resultRecordSet->fields['listingsdb_id'];
             $resultRecordSet->MoveNext();
         }
         // while
         return $id;
     } else {
         if ($num_rows > 0) {
             if (!isset($_GET['cur_page'])) {
                 $_GET['cur_page'] = 0;
             }
             // build the string to select a certain number of listings per page
             $limit_str = intval($_GET['cur_page']) * $config['listings_per_page'];
             $num_records = $config['listings_per_page'];
             $some_num = intval($_GET['cur_page']) + 1;
             $this_page_max = $some_num * $config['listings_per_page'];
             // Check if we're setting a maximum number of search results
             if ($config["max_search_results"] > 0) {
                 // Check if we've reached the max number of listings setting.
                 if ($this_page_max > $config["max_search_results"]) {
                     $num_records = $this_page_max - $config["max_search_results"];
                 }
                 // Failsafe check in case the max search results was set lower than the listings per page setting.
                 if ($config["max_search_results"] < $config['listings_per_page']) {
                     $num_records = $config["max_search_results"];
                 }
                 // Adjust the $num_rows for the next_prev function to show at the max the max results setting
                 if ($num_rows > $config["max_search_results"]) {
                     $num_rows = $config["max_search_results"];
                 }
             }
             if ($config['show_next_prev_listing_page'] == 1) {
                 // ************added for next prev navigation***********
                 $newurl = '';
                 foreach ($_GET as $k => $v) {
                     if ($v && $k != 'cur_page' && $k != 'PHPSESSID' && $k != 'action') {
                         if (is_array($v)) {
                             foreach ($v as $vitem) {
                                 $newurl .= '&amp;' . urlencode("{$k}") . '[]=' . urlencode("{$vitem}");
                             }
                         } else {
                             $newurl .= '&amp;' . urlencode("{$k}") . '=' . urlencode("{$v}");
                         }
                     }
                 }
                 $rtest = $conn->Execute($sql);
                 if (!$rtest) {
                     $misc->log_error($sql);
                 }
                 $_SESSION['results'] = array();
                 $_SESSION['titles'] = array();
                 while (!$rtest->EOF) {
                     $ID = $rtest->fields['listingsdb_id'];
                     $url_title = $rtest->fields['listingsdb_title'];
                     $url_title = str_replace("/", "", $url_title);
                     $url_title = strtolower(str_replace(" ", $config['seo_url_seperator'], $url_title));
                     $url_title = str_replace(" ", "+", $url_title);
                     $_SESSION['results'][] = $ID;
                     $_SESSION['titles'][] = $url_title;
                     $rtest->MoveNext();
                 }
                 $_SESSION['cur_page'] = intval($_GET['cur_page']);
                 $_SESSION['searchstring'] = $newurl;
                 $_SESSION['count'] = $num_rows;
                 // ************added for next prev navigation***********
             }
             // Store the next_prev code as a variable to place in the template
             $next_prev = $misc->next_prev($num_rows, intval($_GET['cur_page']), $guidestring_with_sort);
             $next_prev_bottom = $misc->next_prev($num_rows, intval($_GET['cur_page']), $guidestring_with_sort, 'bottom');
             $resultRecordSet = $conn->SelectLimit($sql, $num_records, $limit_str);
             if (!$resultRecordSet) {
                 $misc->log_error($sql);
             }
             if ($DEBUG_SQL) {
                 echo '<strong>Search SQL:</strong> ' . $sql . '<br />';
             }
             // Get the the fields marked as browseable.
             $sql = "SELECT listingsformelements_id, listingsformelements_field_caption, listingsformelements_field_name, listingsformelements_display_priv, listingsformelements_search_result_rank FROM " . $config['table_prefix'] . "listingsformelements WHERE (listingsformelements_display_on_browse = 'Yes') AND (listingsformelements_field_type <> 'textarea') ORDER BY listingsformelements_search_result_rank";
             $recordSet = $conn->Execute($sql);
             $num_columns = $recordSet->RecordCount();
             // Get header_title
             $field_caption = $lang['title'];
             $field_name = "listingsdb_title";
             $sorttypestring = '';
             $sort_type_count = 0;
             foreach ($sortby_array as $sortby) {
                 if ($sortby == $field_name) {
                     if (!isset($sorttype_array[$sort_type_count]) || $sorttype_array[$sort_type_count] == 'DESC') {
                         $reverse_sort = 'ASC';
                     } else {
                         $reverse_sort = 'DESC';
                     }
                     $sorttypestring = 'sorttype=' . $reverse_sort;
                 }
                 $sort_type_count++;
             }
             if ($sorttypestring == '') {
                 $sorttypestring = "sorttype=ASC";
             }
             // This is header_title it is the lang variable for title
             $header_title = '<a href="index.php?action=searchresults&amp;sortby=' . $field_name . '&amp;' . $sorttypestring . $guidestring . '">' . $field_caption . '</a>';
             $header_title_no_sort = $field_caption;
             // Get header_title
             $field_caption = $lang['header_pclass'];
             $field_name = "pclass";
             $sorttypestring = '';
             $sort_type_count = 0;
             foreach ($sortby_array as $sortby) {
                 if ($sortby == $field_name) {
                     if (!isset($sorttype_array[$sort_type_count]) || $sorttype_array[$sort_type_count] == 'DESC') {
                         $reverse_sort = 'ASC';
                     } else {
                         $reverse_sort = 'DESC';
                     }
                     $sorttypestring = 'sorttype=' . $reverse_sort;
                 }
                 $sort_type_count++;
             }
             if ($sorttypestring == '') {
                 $sorttypestring = "sorttype=ASC";
             }
             // This is header_title it is the lang variable for title
             $header_pclass = '<a href="index.php?action=searchresults&amp;sortby=' . $field_name . '&amp;' . $sorttypestring . $guidestring . '">' . $field_caption . '</a>';
             $header_pclass_no_sort = $field_caption;
             $field = array();
             $field_no_sort = array();
             while (!$recordSet->EOF) {
                 $x = $misc->make_db_unsafe($recordSet->fields['listingsformelements_search_result_rank']);
                 // Check for Translations if needed
                 if (!isset($_SESSION["users_lang"])) {
                     $field_caption = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_caption']);
                 } else {
                     $listingsformelements_id = $recordSet->fields['listingsformelements_id'];
                     $lang_sql = "SELECT listingsformelements_field_caption FROM " . $config['lang_table_prefix'] . "listingsformelements WHERE listingsformelements_id = {$listingsformelements_id}";
                     $lang_recordSet = $conn->Execute($lang_sql);
                     if (!$lang_recordSet) {
                         $misc->log_error($lang_sql);
                     }
                     if ($DEBUG_SQL) {
                         echo '<strong>ML: Field Caption SQL:</strong> ' . $lang_sql . '<br />';
                     }
                     $field_caption = $misc->masearch_result_datasetke_db_unsafe($lang_recordSet->fields['listingsformelements_field_caption']);
                 }
                 $field_name = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_name']);
                 $display_priv = $misc->make_db_unsafe($recordSet->fields['listingsformelements_display_priv']);
                 $display_status = false;
                 if ($display_priv == 1) {
                     $display_status = login::loginCheck('Member', true);
                 } elseif ($display_priv == 2) {
                     $display_status = login::loginCheck('Agent', true);
                 } else {
                     $display_status = true;
                 }
                 if ($display_status === true) {
                     $sorttypestring = '';
                     $sort_type_count = 0;
                     foreach ($sortby_array as $sortby) {
                         if ($sortby == $field_name) {
                             if (!isset($sorttype_array[$sort_type_count]) || $sorttype_array[$sort_type_count] == 'DESC') {
                                 $reverse_sort = 'ASC';
                             } else {
                                 $reverse_sort = 'DESC';
                             }
                             $sorttypestring = 'sorttype=' . $reverse_sort;
                         }
                         $sort_type_count++;
                     }
                     if ($sorttypestring == '') {
                         $sorttypestring = "sorttype=ASC";
                     }
                     $field[$x] = '<a href="index.php?action=searchresults&amp;sortby=' . $field_name . '&amp;' . $sorttypestring . $guidestring . '">' . $field_caption . '</a>';
                     $field_no_sort[$x] = $field_caption;
                 }
                 $recordSet->MoveNext();
             }
             // end while
             // We have all the header information so we can now parse that section
             $header_section = $page->parse_template_section($header_section, 'header_title', $header_title);
             $header_section = $page->parse_template_section($header_section, 'header_title_no_sort', $header_title_no_sort);
             $header_section = $page->parse_template_section($header_section, 'header_pclass', $header_pclass);
             $header_section = $page->parse_template_section($header_section, 'header_pclass_no_sort', $header_pclass_no_sort);
             foreach ($field as $x => $f) {
                 $header_section = $page->parse_template_section($header_section, 'header_' . $x, $f);
             }
             foreach ($field_no_sort as $x => $f) {
                 $header_section = $page->parse_template_section($header_section, 'header_' . $x . '_no_sort', $f);
             }
             // We have the title now we need the image
             $num_columns = $num_columns + 1;
             // add one for the image
             $count = 0;
             while (!$resultRecordSet->EOF) {
                 // Start a new section for each listing.
                 $search_result .= $search_result_section;
                 // alternate the colors
                 if ($count == 0) {
                     $count = $count + 1;
                 } else {
                     $count = 0;
                 }
                 $Title = $misc->make_db_unsafe($resultRecordSet->fields['listingsdb_title']);
                 $current_ID = $resultRecordSet->fields['listingsdb_id'];
                 $or_owner = $resultRecordSet->fields['userdb_id'];
                 if ($config['url_style'] == '1') {
                     $url = '<a href="index.php?action=listingview&amp;listingID=' . $current_ID . '">';
                 } else {
                     $url_title = str_replace("/", "", $Title);
                     $url_title = strtolower(str_replace(" ", $config['seo_url_seperator'], $url_title));
                     $url = '<a href="listing-' . misc::urlencode_to_sef($url_title) . '-' . $current_ID . '.html">';
                 }
                 $field_title = $url . $Title . '</a>';
                 // Insert the title as we grabbed it earlier
                 $search_result = $page->parse_template_section($search_result, 'field_title', $field_title);
                 $search_result = $page->parse_template_section($search_result, 'listingid', $current_ID);
                 $search_result = $page->replace_listing_field_tags($current_ID, $search_result);
                 //get distance for postal code distance searches
                 if (isset($_GET['postalcode_dist_dist'])) {
                     $sql3 = "SELECT listingsdbelements_field_value FROM " . $config['table_prefix'] . "listingsdbelements WHERE ((listingsdb_id = {$current_ID}) AND (listingsdbelements_field_name = '" . $config['map_zip'] . "'))";
                     $recordSet3 = $conn->Execute($sql3);
                     $sql4 = 'SELECT zipdist_latitude, zipdist_longitude FROM ' . $config['table_prefix_no_lang'] . 'zipdist WHERE zipdist_zipcode =' . $recordSet3->fields['listingsdbelements_field_value'];
                     $recordSet4 = $conn->Execute($sql4);
                     $postalcode_distance = round($this->calculate_mileage($postalcode_dist_lat, $recordSet4->fields['zipdist_latitude'], $postalcode_dist_long, $recordSet4->fields['zipdist_longitude']), 2) . ' ' . $lang['postalcode_miles_away'];
                     $search_result = $page->parse_template_section($search_result, 'postalcode_search_distance', $postalcode_distance);
                 }
                 // grab the rest of the listing's data
                 $sql2 = "SELECT listingsdbelements_field_name, listingsdbelements_field_value, listingsformelements_field_type, listingsformelements_display_priv, listingsformelements_search_result_rank  FROM " . $config['table_prefix'] . "listingsdbelements, " . $config['table_prefix'] . "listingsformelements WHERE ((listingsdb_id = {$current_ID}) AND (listingsformelements_display_on_browse = 'Yes')  " . "AND (listingsdbelements_field_name = listingsformelements_field_name)) ORDER BY listingsformelements_search_result_rank";
                 $recordSet2 = $conn->Execute($sql2);
                 if ($DEBUG_SQL) {
                     echo '<strong>Listing Data:</strong> ' . $sql2 . '<br />';
                 }
                 if (!$recordSet2) {
                     $misc->log_error($sql2);
                 }
                 $field = array();
                 $textarea = array();
                 while (!$recordSet2->EOF) {
                     $field_name = $misc->make_db_unsafe($recordSet2->fields['listingsdbelements_field_name']);
                     $field_value = $misc->make_db_unsafe($recordSet2->fields['listingsdbelements_field_value']);
                     $field_type = $misc->make_db_unsafe($recordSet2->fields['listingsformelements_field_type']);
                     $display_priv = $misc->make_db_unsafe($recordSet2->fields['listingsformelements_display_priv']);
                     $x = $misc->make_db_unsafe($recordSet2->fields['listingsformelements_search_result_rank']);
                     $display_status = false;
                     if ($display_priv == 1) {
                         $display_status = login::loginCheck('Member', true);
                     } elseif ($display_priv == 2) {
                         $display_status = login::loginCheck('Agent', true);
                     } else {
                         $display_status = true;
                     }
                     if ($display_status === true) {
                         switch ($field_type) {
                             case 'textarea':
                                 if ($config['add_linefeeds'] === "1") {
                                     $textarea[$x] = nl2br($field_value);
                                 } else {
                                     $textarea[$x] = $field_value;
                                 }
                                 break;
                             case "select-multiple":
                             case "option":
                             case "checkbox":
                                 // handle field types with multiple options
                                 $feature_index_list = explode("||", $field_value);
                                 $field[$x] = '';
                                 foreach ($feature_index_list as $feature_list_item) {
                                     $field[$x] .= $feature_list_item;
                                     $field[$x] .= $config['feature_list_separator'];
                                 }
                                 break;
                             case "price":
                                 $sql3 = "SELECT listingsdbelements_field_value FROM " . $config['table_prefix'] . "listingsdbelements WHERE ((listingsdb_id = {$current_ID}) AND (listingsdbelements_field_name = 'status'))";
                                 $recordSet3 = $conn->Execute($sql3);
                                 if (!$recordSet3) {
                                     $misc->log_error($sql3);
                                 }
                                 if ($DEBUG_SQL) {
                                     echo '<strong>Status Lookup for price field:</strong> ' . $sql3 . '<br />';
                                 }
                                 $status = $misc->make_db_unsafe($recordSet3->fields['listingsdbelements_field_value']);
                                 $recordSet3->Close();
                                 if ($field_value == "" && $config["zero_price"] == "1") {
                                     $money_amount = $misc->international_num_format($field_value, $config['number_decimals_price_fields']);
                                     if ($status == 'Sold') {
                                         $field[$x] = "<span style=\"text-decoration: line-through\">";
                                         $field[$x] .= "</span><br /><span style=\"color:red;\"><strong>{$lang['mark_as_sold']}</strong></span>";
                                     } elseif ($status == 'Pending') {
                                         $field[$x] .= "<br /><span style=\"color:green;\"><strong>{$lang['mark_as_pending']}</strong></span>";
                                     } else {
                                         $field[$x] = $lang['call_for_price'];
                                     }
                                 } else {
                                     $money_amount = $misc->international_num_format($field_value, $config['number_decimals_price_fields']);
                                     if ($status == 'Sold') {
                                         $field[$x] = "<span style=\"text-decoration: line-through\">";
                                         $field[$x] .= $misc->money_formats($money_amount);
                                         $field[$x] .= "</span><br /><span style=\"color:red;\"><strong>{$lang['mark_as_sold']}</strong></span>";
                                     } elseif ($status == 'Pending') {
                                         $field[$x] = $misc->money_formats($money_amount);
                                         $field[$x] .= "<br /><span style=\"color:green;\"><strong>{$lang['mark_as_pending']}</strong></span>";
                                     } else {
                                         $field[$x] = $misc->money_formats($money_amount);
                                     }
                                 }
                                 // end else
                                 break;
                             case "select":
                                 if ($field_name == "Mi_business") {
                                     $sql4 = "SELECT listingsdbelements_field_value FROM " . $config['table_prefix'] . "listingsdbelements WHERE ((listingsdb_id = {$current_ID}) AND (listingsdbelements_field_name = 'Mi_business'))";
                                     $recordSet4 = $conn->Execute($sql4);
                                     if (!$recordSet4) {
                                         $misc->log_error($sql4);
                                     } else {
                                         $requiredMigration = $misc->make_db_unsafe($recordSet4->fields['listingsdbelements_field_value']);
                                         $recordSet4->Close();
                                         if ($requiredMigration == 'Yes') {
                                             $field[$x] = '<strong style="color:red">Business Migration Ready 能用作投资移民申请</strong>';
                                         } else {
                                             $field[$x] = '';
                                         }
                                     }
                                 } else {
                                     $field[$x] = "{$field_value}";
                                 }
                                 break;
                             case "number":
                                 $field[$x] = $misc->international_num_format($field_value, $config['number_decimals_number_fields']);
                                 break;
                             case "url":
                                 $field[$x] = "<a href=\"{$field_value}\" target=\"_blank\">{$field_value}</a>";
                                 break;
                             case "email":
                                 $field[$x] = "<a href=\"mailto:{$field_value}\">{$field_value}</a>";
                                 break;
                             case "date":
                                 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";
                                 }
                                 if ($field_value > 0) {
                                     $field_value = date($format, "{$field_value}");
                                 }
                                 $field[$x] = "{$field_value}";
                                 break;
                             default:
                                 $field[$x] = "{$field_value}";
                                 break;
                         }
                         // end switch
                     }
                     $recordSet2->MoveNext();
                 }
                 // end while
                 foreach ($field as $x => $f) {
                     $search_result = $page->parse_template_section($search_result, 'field_' . $x, $f);
                 }
                 //Form URLS for TextArea
                 if ($config['url_style'] == '1') {
                     $preview = '... <a href="index.php?action=listingview&amp;listingID=' . $current_ID . '">' . $lang['more_info'] . '</a>';
                 } else {
                     $url_title = str_replace("/", "", $Title);
                     $url_title = strtolower(str_replace(" ", $config['seo_url_seperator'], $url_title));
                     $preview = '... <a href="listing-' . misc::urlencode_to_sef($url_title) . '-' . $current_ID . '.html">' . $lang['more_info'] . '</a>';
                 }
                 foreach ($textarea as $x => $f) {
                     // Normal Textarea
                     $search_result = $page->parse_template_section($search_result, 'textarea_' . $x, $f);
                     // Short textarea of first number of characters defined in site config with link to the listing
                     $p = substr(strip_tags($f), 0, $config['textarea_short_chars']);
                     $p = substr($p, 0, strrpos($p, ' '));
                     $search_result = $page->parse_template_section($search_result, 'textarea_' . $x . '_short', $p . '' . $preview);
                 }
                 //Cleanup Textareas
                 $search_result = preg_replace('/{textarea_(.*?)_short}/', $preview, $search_result);
                 $search_result = preg_replace('/{textarea_(.*?)}/', '', $search_result);
                 // Show Vtour indicator Image if vtour exists
                 require_once $config['basepath'] . '/include/vtour.inc.php';
                 $vtour_link = vtours::rendervtourlink($current_ID, true);
                 $search_result = $page->parse_template_section($search_result, 'vtour_button', $vtour_link);
                 // Show Creation Date
                 require_once $config['basepath'] . '/include/listing.inc.php';
                 $get_creation_date = listing_pages::get_creation_date($current_ID);
                 $search_result = $page->parse_template_section($search_result, 'get_creation_date', $get_creation_date);
                 // Show Featured
                 require_once $config['basepath'] . '/include/listing.inc.php';
                 $get_featured = listing_pages::get_featured($current_ID, 'no');
                 $search_result = $page->parse_template_section($search_result, 'get_featured', $get_featured);
                 // Show Featured Raw
                 require_once $config['basepath'] . '/include/listing.inc.php';
                 $get_featured_raw = listing_pages::get_featured($current_ID, 'yes');
                 $search_result = $page->parse_template_section($search_result, 'get_featured_raw', $get_featured_raw);
                 // Show Modified Date
                 require_once $config['basepath'] . '/include/listing.inc.php';
                 $get_modified_date = listing_pages::get_modified_date($current_ID);
                 $search_result = $page->parse_template_section($search_result, 'get_modified_date', $get_modified_date);
                 // Start {isfavorite} search result 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";
                         $search_result = $page->parse_template_section($search_result, 'isfavorite', $isfavorite);
                     } else {
                         $isfavorite = "yes";
                         $search_result = $page->parse_template_section($search_result, 'isfavorite', $isfavorite);
                     }
                 }
                 // End {isfavorite} search result template section tag
                 // Show Delete From Favorites Link if needed
                 $delete_from_fav = '';
                 if (isset($_SESSION['userID'])) {
                     $userID = $misc->make_db_safe($_SESSION['userID']);
                     $sql = "SELECT listingsdb_id FROM " . $config['table_prefix'] . "userfavoritelistings WHERE ((listingsdb_id = {$current_ID}) AND (userdb_id={$userID}))";
                     $recordSet = $conn->Execute($sql);
                     if (!$recordSet) {
                         $misc->log_error($sql);
                     }
                     if ($DEBUG_SQL) {
                         echo '<strong>Delete Favorite Lookup:</strong> ' . $sql . '<br />';
                     }
                     $num_rows = $recordSet->RecordCount();
                     if ($num_rows > 0) {
                         $delete_from_fav = '<a href="index.php?action=delete_favorites&amp;listingID=' . $current_ID . '" onclick="return confirmDelete()">' . $lang['delete_from_favorites'] . '</a>';
                     }
                 }
                 // Instert link into section
                 $search_result = $page->parse_template_section($search_result, 'delete_from_favorite', $delete_from_fav);
                 //Show Add To Favorites
                 $link_add_favorites = '';
                 if (isset($_SESSION['userID'])) {
                     $userID = $misc->make_db_safe($_SESSION['userID']);
                     $sql = "SELECT listingsdb_id FROM " . $config['table_prefix'] . "userfavoritelistings WHERE ((listingsdb_id = {$current_ID}) AND (userdb_id={$userID}))";
                     $recordSet = $conn->Execute($sql);
                     if (!$recordSet) {
                         $misc->log_error($sql);
                     }
                     if ($DEBUG_SQL) {
                         echo '<strong>Add Favorite Lookup:</strong> ' . $sql . '<br />';
                     }
                     $num_rows = $recordSet->RecordCount();
                     if ($num_rows == 0) {
                         $link_add_favorites = listing_pages::create_add_favorite_link();
                     }
                 } else {
                     $link_add_favorites = listing_pages::create_add_favorite_link();
                 }
                 // Instert link into section
                 $search_result = $page->parse_template_section($search_result, 'link_add_favorites', $link_add_favorites);
                 // Insert row number
                 $search_result = $page->parse_template_section($search_result, 'row_num_even_odd', $count);
                 $resultRecordSet->MoveNext();
                 // Replace Edit Listing links
                 require_once $config['basepath'] . '/include/listing.inc.php';
                 $edit_link = listing_pages::edit_listing_link();
                 $search_result = $page->parse_template_section($search_result, 'link_edit_listing', $edit_link);
                 $edit_link = listing_pages::edit_listing_link('yes');
                 $search_result = $page->parse_template_section($search_result, 'link_edit_listing_url', $edit_link);
                 // Replace addon fields.
                 $addon_fields = $page->get_addon_template_field_list($addons);
                 $search_result = $page->parse_addon_tags($search_result, $addon_fields);
                 $search_result = $page->cleanup_fields($search_result);
                 $search_result = $page->cleanup_images($search_result);
             }
             // end while
             $page->replace_template_section('search_result_header', $header_section);
             $page->replace_template_section('search_result_dataset', $search_result);
             $page->replace_permission_tags();
             $page->cleanup_template_sections($next_prev, $next_prev_bottom);
             $display = $page->return_page();
         } else {
             if (!isset($_GET['cur_page'])) {
                 $_GET['cur_page'] = 0;
             }
             // This search has no results. Display an error message and the search page again.
             $display .= search_page::create_searchpage(false, true);
         }
         return $display;
     }
 }
 function add_page()
 {
     global $conn, $lang, $config;
     $security = login::loginCheck('editpages', true);
     $display = '';
     if ($security === true) {
         require_once $config['basepath'] . '/include/misc.inc.php';
         $misc = new misc();
         // Do we need to save?
         if (isset($_POST['edit'])) {
             // Save page now
             $save_full = $_POST['ta'];
             $save_title = $misc->make_db_safe($_POST['title']);
             $save_description = $misc->make_db_safe($_POST['description']);
             $save_keywords = $misc->make_db_safe($_POST['keywords']);
             // $save_full_xhtml = urldecode($save_full);
             // $save_full_xhtml = $this->html2xhtml($save_full_xhtml);
             $save_full_xhtml = $misc->make_db_safe(editor::htmlEncodeText($save_full), TRUE);
             $sql = "INSERT INTO " . $config['table_prefix'] . "pagesmain (pagesmain_full,pagesmain_title,pagesmain_date,pagesmain_summary,pagesmain_no_visitors,pagesmain_complete,pagesmain_description,pagesmain_keywords) VALUES ({$save_full_xhtml},{$save_title}," . $conn->DBDate(time()) . ",'',0,1,{$save_description},{$save_keywords})";
             $recordSet = $conn->Execute($sql);
             if (!$recordSet) {
                 $misc->log_error($sql);
             }
             $display .= "<center><b>{$lang['page_saved']}</b></center><br />";
             $display .= $this->page_list();
             $display .= '<form action="index.php?action=edit_page" method="post" id="edit" name="edit">';
             $html = '';
             $sql = "SELECT pagesmain_full, pagesmain_title, pagesmain_complete, pagesmain_id, pagesmain_description, pagesmain_keywords  FROM " . $config['table_prefix'] . "pagesmain WHERE pagesmain_title = " . $save_title;
             $recordSet = $conn->Execute($sql);
             if (!$recordSet) {
                 $misc->log_error($sql);
             }
             // Save PageID to Session for Image Upload Plugin
             $_SESSION['PageID'] = $recordSet->fields['pagesmain_id'];
             // Pull the page from the database
             $display .= "<input type=\"hidden\" name=\"edit\" value=\"yes\" />";
             $display .= "<input type=\"hidden\" name=\"PageID\" value=\"" . $_SESSION['PageID'] . "\" />";
             $html = $misc->make_db_unsafe($recordSet->fields['pagesmain_full']);
             $title = $misc->make_db_unsafe($recordSet->fields['pagesmain_title']);
             $description = $misc->make_db_unsafe($recordSet->fields['pagesmain_description']);
             $keywords = $misc->make_db_unsafe($recordSet->fields['pagesmain_keywords']);
             // $complete = $misc->make_db_unsafe($recordSet->fields['pagesmain_complete']);
             $display .= $lang['title'] . ' <input type="text" name="title" value="' . $title . '" /><br /><br />';
             $display .= $lang['page_meta_description'] . ' <input type="text" size="50" name="description" value="' . $description . '" /><br /><br />';
             $display .= $lang['page_meta_keywords'] . ' <input type="text" size="50" name="keywords" value="' . $keywords . '" /><br /><br />';
             $display .= '<textarea name="ta" id="ta" style="height: 350px; width: 100%;">' . $html . '</textarea>';
             $display .= '<input type="submit" name="ok" value="' . $lang['submit'] . '"  style="margin-top:3px;"/>';
             $display .= '</form>';
             if ($_SESSION['PageID'] != '') {
                 $display .= '<form action="index.php?action=edit_page" method="post" id="delete" style="margin-top:3px;">';
                 $display .= '<input type="hidden" name="delete" value="yes" />';
                 $display .= '<input type="hidden" name="PageID" value="' . $_SESSION['PageID'] . '" />';
                 $display .= '<input type="submit" name="ok" value="' . $lang['delete_page'] . '" />';
                 $display .= '</form>';
             }
         } else {
             $display .= $this->page_list();
             $display .= '<form action="index.php?action=add_page" method="post" id="edit" name="edit">';
             $display .= "<input type=\"hidden\" name=\"edit\" value=\"yes\" />";
             $display .= $lang['title'] . ' <input type="text" name="title" value="" /><br /><br />';
             $display .= $lang['page_meta_description'] . ' <input type="text" size="50" name="description" value="" /><br /><br />';
             $display .= $lang['page_meta_keywords'] . ' <input type="text" size="50" name="keywords" value="" /><br /><br />';
             $display .= '<textarea name="ta" id="ta" style="height: 30em; width: 100%;"></textarea>';
             $display .= '<input type="submit" name="ok" value="' . $lang['submit'] . '" style="margin-top:3px;" />';
             $display .= '</form>';
         }
     } else {
         $display .= '<div class="error_text">' . $lang['access_denied'] . '</div>';
     }
     return $display;
 }
 function edit_listing_field($edit_listing_field_name)
 {
     // include global variables
     global $conn, $lang, $config;
     $security = login::loginCheck('edit_listing_template', true);
     if ($security === true) {
         // Include the misc Class
         require_once $config['basepath'] . '/include/misc.inc.php';
         $misc = new misc();
         $edit_listing_field_name = $misc->make_db_safe($edit_listing_field_name);
         $sql = "SELECT * FROM " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_field_name = {$edit_listing_field_name}";
         $recordSet = $conn->Execute($sql);
         if ($recordSet === false) {
             $misc->log_error($sql);
         }
         $id = $misc->make_db_unsafe($recordSet->fields['listingsformelements_id']);
         $field_type = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_type']);
         $field_name = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_name']);
         // Multi Lingual Support
         if (!isset($_SESSION["users_lang"])) {
             // Hold empty string for translation fields, as we are workgin with teh default lang
             $default_lang_field_caption = '';
             $default_lang_default_text = '';
             $default_lang_field_elements = '';
             $default_lang_search_label = '';
             $field_caption = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_caption']);
             $default_text = $misc->make_db_unsafe($recordSet->fields['listingsformelements_default_text']);
             $field_elements = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_elements']);
             $search_label = $misc->make_db_unsafe($recordSet->fields['listingsformelements_search_label']);
         } else {
             // Store default lang to show for tanslator
             $default_lang_field_caption = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_caption']);
             $default_lang_default_text = $misc->make_db_unsafe($recordSet->fields['listingsformelements_default_text']);
             $default_lang_field_elements = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_elements']);
             $default_lang_search_label = $misc->make_db_unsafe($recordSet->fields['listingsformelements_search_label']);
             $default_lang_tool_tip = $misc->make_db_unsafe($recordSet->fields['listingsformelements_tool_tip']);
             $field_id = $recordSet->fields['listingsformelements_id'];
             $lang_sql = "SELECT listingsformelements_field_caption,listingsformelements_default_text,listingsformelements_field_elements,listingsformelements_search_label FROM " . $config['lang_table_prefix'] . "listingsformelements WHERE listingsformelements_id = {$field_id}";
             $lang_recordSet = $conn->Execute($lang_sql);
             if (!$lang_recordSet) {
                 $misc->log_error($lang_sql);
             }
             $field_caption = $misc->make_db_unsafe($lang_recordSet->fields['listingsformelements_field_caption']);
             $default_text = $misc->make_db_unsafe($lang_recordSet->fields['listingsformelements_default_text']);
             $field_elements = $misc->make_db_unsafe($lang_recordSet->fields['listingsformelements_field_elements']);
             $search_label = $misc->make_db_unsafe($lang_recordSet->fields['listingsformelements_search_label']);
         }
         $rank = $misc->make_db_unsafe($recordSet->fields['listingsformelements_rank']);
         $search_rank = $misc->make_db_unsafe($recordSet->fields['listingsformelements_search_rank']);
         $search_result_rank = $misc->make_db_unsafe($recordSet->fields['listingsformelements_search_result_rank']);
         $required = $misc->make_db_unsafe($recordSet->fields['listingsformelements_required']);
         $location = $misc->make_db_unsafe($recordSet->fields['listingsformelements_location']);
         $display_on_browse = $misc->make_db_unsafe($recordSet->fields['listingsformelements_display_on_browse']);
         $display_priv = $misc->make_db_unsafe($recordSet->fields['listingsformelements_display_priv']);
         $search_step = $misc->make_db_unsafe($recordSet->fields['listingsformelements_search_step']);
         $searchable = $misc->make_db_unsafe($recordSet->fields['listingsformelements_searchable']);
         $search_type = $misc->make_db_unsafe($recordSet->fields['listingsformelements_search_type']);
         $field_length = $misc->make_db_unsafe($recordSet->fields['listingsformelements_field_length']);
         $tool_tip = $misc->make_db_unsafe($recordSet->fields['listingsformelements_tool_tip']);
         $display = '';
         $display .= '<br /><form action="' . $config['baseurl'] . '/admin/index.php?action=edit_listing_template" method="post"  id="update_field">';
         $display .= '<table align="center">';
         $display .= '<tr>';
         $display .= '<td colspan="2" align="center" class="templateEditorNew" valign="top"><hr><B>' . $lang['general_options'] . '</b></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_name'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left"><input type="hidden" name="update_id" value="' . $id . '"><input type="hidden" name="old_field_name" value="' . $field_name . '"><input type="text" name="edit_field" value="' . $field_name . '"></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_type'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left">';
         $display .= '<select name="field_type" size="1">';
         $display .= '<option value="' . $field_type . '" selected="selected">' . $lang[$field_type] . '</option>';
         $display .= '<option value="">-----</option>';
         $display .= '<option value="text">' . $lang['text'] . '</option>';
         $display .= '<option value="textarea" >' . $lang['textarea'] . '</option>';
         $display .= '<option value="select" >' . $lang['select'] . '</option>';
         $display .= '<option value="select-multiple">' . $lang['select-multiple'] . '</option>';
         $display .= '<option value="option" >' . $lang['option'] . '</option>';
         $display .= '<option value="checkbox" >' . $lang['checkbox'] . '</option>';
         $display .= '<option value="divider">' . $lang['divider'] . '</option>';
         $display .= '<option value="price">' . $lang['price'] . '</option>';
         $display .= '<option value="url">' . $lang['url'] . '</option>';
         $display .= '<option value="email">' . $lang['email'] . '</option>';
         $display .= '<option value="number">' . $lang['number'] . '</option>';
         $display .= '<option value="decimal">' . $lang['decimal'] . '</option>';
         $display .= '<option value="date">' . $lang['date'] . '</option>';
         $display .= '<option value="lat">' . $lang['lat'] . '</option>';
         $display .= '<option value="long">' . $lang['long'] . '</option>';
         $display .= '</select>';
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_required'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left">';
         $display .= '<select name="required" size="1">';
         $display .= '<option value="' . $required . '" selected="selected">' . $lang[strtolower($required)] . '</option>';
         $display .= '<option value="No">-----</option>';
         $display .= '<option value="No">' . $lang['no'] . '</option>';
         $display .= '<option value="Yes" >' . $lang['yes'] . '</option>';
         $display .= '</select>';
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_caption'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left"><input type=text name="field_caption" value = "' . $field_caption . '">';
         if (isset($_SESSION["users_lang"])) {
             // Show Fields value in default language.
             $display .= '<b>' . $lang['translate'] . '</b>' . ': ' . $default_lang_field_caption;
         }
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_elements'] . ':</b><br /><div class="small">(' . $lang['admin_template_editor_choices_separated'] . ')</div></td>';
         $display .= '<td class="templateEditorHead" align="left"><textarea name="field_elements" cols="80" rows="5">' . $field_elements . '</textarea>';
         if (isset($_SESSION["users_lang"])) {
             // Show Fields value in default language.
             $display .= '<br />' . '<b>' . $lang['translate'] . '</b>' . ': ' . $default_lang_field_elements;
         }
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_default_text'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left"><input type=text name="default_text" value = "' . $default_text . '">';
         if (isset($_SESSION["users_lang"])) {
             // Show Fields value in default language.
             $display .= '<b>' . $lang['translate'] . '</b>' . ': ' . $default_lang_default_text;
         }
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_tool_tip'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left"><textarea name="tool_tip" cols="80" rows="5">' . $tool_tip . '</textarea>';
         if (isset($_SESSION["users_lang"])) {
             // Show Fields value in default language.
             $display .= '<br />' . '<b>' . $lang['translate'] . '</b>' . ': ' . $default_lang_tool_tip;
         }
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_length'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left"><input type=text name="field_length" value = "' . $field_length . '"></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_display_priv'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left">';
         $display .= '<select name="display_priv" size="1">';
         $display .= '<option value="' . $display_priv . '" selected="selected">' . $lang['display_priv_' . $display_priv] . '</option>';
         $display .= '<option value="0">-----</option>';
         $display .= '<option value="0">' . $lang['display_priv_0'] . '</option>';
         $display .= '<option value="1" >' . $lang['display_priv_1'] . '</option>';
         $display .= '<option value="2" >' . $lang['display_priv_2'] . '</option>';
         $display .= '<option value="3" >' . $lang['display_priv_3'] . '</option>';
         $display .= '</select>';
         $display .= '</td>';
         $display .= '</tr>';
         // Property Class Selection
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_property_class'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left">';
         $display .= '<select name="property_class[]" multiple="multiple" size="5">';
         // get list of all property clases
         $sql = 'SELECT class_name, class_id FROM ' . $config['table_prefix'] . 'class ORDER BY class_rank';
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         while (!$recordSet->EOF()) {
             $class_id = $recordSet->fields['class_id'];
             $class_name = $recordSet->fields['class_name'];
             // check if this field is part of this class
             $sql = 'SELECT count(class_id) as exist FROM ' . $config['table_prefix_no_lang'] . 'classformelements WHERE listingsformelements_id = ' . $id . ' AND class_id =' . $class_id;
             $recordSet2 = $conn->Execute($sql);
             if (!$recordSet2) {
                 $misc->log_error($sql);
             }
             $select = $recordSet2->fields['exist'];
             if ($select > 0) {
                 $display .= '<option value="' . $class_id . '" selected="selected">' . $class_name . '</option>';
             } else {
                 $display .= '<option value="' . $class_id . '" >' . $class_name . '</option>';
             }
             $recordSet->MoveNext();
         }
         $display .= '</select>';
         $display .= '</td>';
         $display .= '</tr>';
         // LISTING PAGE OPTIONS
         $display .= '<tr>';
         $display .= '<td colspan="2" align="center" class="templateEditorNew" valign="top"><hr><B>' . $lang['listing_page_options'] . '</b></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_display_location'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left">';
         $display .= '<select name="location" size="1">';
         $display .= '<option value="' . $location . '" selected="selected">' . $location . '</option>';
         $display .= '<option value="">-- ' . $lang['do_not_display'] . ' --</option>';
         $sections = explode(',', $config['template_listing_sections']);
         foreach ($sections as $section) {
             $display .= '<option value="' . $section . '">' . $section . '</option>';
         }
         $display .= '</select>';
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_rank'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left" ><input type=text name="rank" value = "' . $rank . '"></td>';
         $display .= '</tr>';
         // Search Page Options
         $display .= '<tr>';
         $display .= '<td colspan="2" align="center" class="templateEditorNew" valign="top"><hr><B>' . $lang['search_options'] . '</b></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorNew" valign="top"><b>' . $lang['allow_searching'] . '</b></td>';
         $display .= '<td class="templateEditorNew"><input type="checkbox" name="searchable" value="1" ';
         if ($searchable) {
             $display .= 'checked="checked"';
         }
         $display .= '></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_rank_search'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left" ><input type=text name="search_rank" value = "' . $search_rank . '"></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorNew" valign="top"><b>' . $lang['search_label'] . '</b></td>';
         $display .= '<td class="templateEditorNew"><input type="text" name="search_label" value="' . htmlspecialchars($search_label, ENT_COMPAT, $config['charset']) . '">';
         if (isset($_SESSION["users_lang"])) {
             // Show Fields value in default language.
             $display .= '<b>' . $lang['translate'] . '</b>' . ': ' . $default_lang_search_label;
         }
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorNew" valign="top"><b>' . $lang['search_type'] . '</b></td>';
         $display .= '<td class="templateEditorNew">';
         $display .= '<select name="search_type">';
         if ($search_type != '') {
             $display .= '<option value="' . $search_type . '">' . $lang[$search_type . '_description'] . '</option>';
         }
         $display .= '<option></option>';
         $display .= '<option value="ptext">' . $lang['ptext_description'] . '</option>';
         $display .= '<option value="optionlist">' . $lang['optionlist_description'] . '</option>';
         $display .= '<option value="optionlist_or">' . $lang['optionlist_or_description'] . '</option>';
         $display .= '<option value="fcheckbox">' . $lang['fcheckbox_description'] . '</option>';
         $display .= '<option value="fcheckbox_or">' . $lang['fcheckbox_or_description'] . '</option>';
         $display .= '<option value="fpulldown">' . $lang['fpulldown_description'] . '</option>';
         $display .= '<option value="select">' . $lang['select_description'] . '</option>';
         $display .= '<option value="select_or">' . $lang['select_or_description'] . '</option>';
         $display .= '<option value="pulldown">' . $lang['pulldown_description'] . '</option>';
         $display .= '<option value="checkbox">' . $lang['checkbox_description'] . '</option>';
         $display .= '<option value="checkbox_or">' . $lang['checkbox_or_description'] . '</option>';
         $display .= '<option value="option">' . $lang['option_description'] . '</option>';
         $display .= '<option value="minmax">' . $lang['minmax_description'] . '</option>';
         $display .= '<option value="daterange">' . $lang['daterange_description'] . '</option>';
         $display .= '<option value="singledate">' . $lang['singledate_description'] . '</option>';
         $display .= '<option value="null_checkbox">' . $lang['null_checkbox_description'] . '</option>';
         $display .= '<option value="notnull_checkbox">' . $lang['notnull_checkbox_description'] . '</option>';
         $display .= '</select>';
         $display .= '</td>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorNew" valign="top"><font size="1">++ </font><b>' . $lang['step_by'] . '</b></td>';
         $display .= '<td class="templateEditorNew"><input type="text" name="search_step" value = "' . $search_step . '">';
         $display .= '<br /><font size="1">' . $lang['used_for_range_selections_only'] . '</font>';
         $display .= '</td>';
         $display .= '</tr>';
         // SEARCH RESULT OPTIONS
         $display .= '<tr>';
         $display .= '<td colspan="2" align="center" class="templateEditorNew" valign="top"><hr><B>' . $lang['search_result_options'] . '</b></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_display_browse'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left">';
         $display .= '<select name="display_on_browse" size="1">';
         $display .= '<option value="' . $display_on_browse . '" selected="selected">' . $lang[strtolower($display_on_browse)] . '</option>';
         $display .= '<option value="No">-----</option>';
         $display .= '<option value="No">' . $lang['no'] . '</option>';
         $display .= '<option value="Yes" >' . $lang['yes'] . '</option>';
         $display .= '</select>';
         $display .= '</td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top"><b>' . $lang['admin_template_editor_field_rank_search_result'] . ':</b></td>';
         $display .= '<td class="templateEditorHead" align="left" ><input type=text name="search_result_rank" value = "' . $search_result_rank . '"></td>';
         $display .= '</tr>';
         $display .= '<tr>';
         $display .= '<td align="right" class="templateEditorHead" valign="top">&nbsp;</td>';
         $display .= '<td class="templateEditorHead" align="left"><input type="submit" name="field_submit" value="' . $lang['update_button'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . $config['baseurl'] . '/admin/index.php?action=edit_listing_template&amp;delete_field=' . $field_name . '" onclick="return confirmDelete()">' . $lang['delete'] . '</a></td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</form>';
         return $display;
     } else {
         return '<div class="error_text">' . $lang['access_denied'] . '</div>';
     }
 }
示例#11
0
 function display_login($priv_level_needed)
 {
     // See if we just logged in and redirect.
     global $config;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     $login_status = login::loginCheck('Member', true);
     if ($login_status == true) {
         // Find referer UEL
         if (isset($_POST['referer']) && $_POST['referer'] != '') {
             $referer_url = $_POST['referer'];
         } elseif (isset($_SERVER['HTTP_REFERER'])) {
             //				echo $_SERVER['HTTP_REFERER'];
             $pos = strpos($_SERVER['HTTP_REFERER'], 'login');
             $pos2 = strpos($_SERVER['HTTP_REFERER'], 'admin');
             if ($pos !== false || $pos2 !== false) {
                 $referer_url = $config['baseurl'] . '/index.php';
             } else {
                 $referer_url = $_SERVER['HTTP_REFERER'];
             }
         } else {
             $referer_url = $config['baseurl'] . '/index.php';
         }
         header('Location: ' . $referer_url);
     } else {
         @session_destroy();
         $guidestring = '';
         $display = '';
         foreach ($_GET as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $vitem) {
                     $guidestring .= '&amp;' . urlencode("{$k}") . '[]=' . urlencode("{$vitem}");
                 }
             } else {
                 $guidestring .= '&amp;' . urlencode("{$k}") . '=' . urlencode("{$v}");
             }
         }
         global $lang, $config, $conn;
         if ($priv_level_needed == 'Member') {
             if ($config["allow_member_signup"] == 1) {
                 $display .= '<p><strong>' . $lang['visitor_alert_phrase'] . '</strong></p>';
             }
         } else {
             if ($config["allow_agent_signup"] == 1) {
                 $display .= '<p>' . $lang['admin_challenge_phrase'] . '</p>';
             }
         }
         if ($_GET['action'] == 'member_login') {
             if (isset($_POST['user_name'])) {
                 if (!$_POST['user_name'] || !$_POST['user_pass']) {
                     $display .= $lang['required_field_not_filled'];
                 } else {
                     /* Spruce up username, check length */
                     $_POST['user_name'] = trim($_POST['user_name']);
                     if (strlen($_POST['user_name']) > 30) {
                         $display .= $lang['username_excessive_length'];
                     }
                     /* Checks that username is in database and password is correct */
                     $md5pass = md5($_POST['user_pass']);
                     $result = login::confirm_user($_POST['user_name'], $md5pass);
                     /* Check error codes */
                     if ($result == 1) {
                         $display .= $lang['nonexistent_username'];
                     } elseif ($result == 2) {
                         $display .= $lang['incorrect_password'];
                     } elseif ($result == 3) {
                         $display .= $lang['inactive_user'];
                     }
                 }
             }
         }
         $display .= '<form action="" method="post">';
         $display .= '<input type="hidden" name="referer" value="' . $_SERVER['HTTP_REFERER'] . '" />';
         $display .= '<table border="0" cellspacing="0" cellpadding="3">';
         $display .= '<tr><td>' . $lang['admin_login_name'] . ':</td><td><input type="text" name="user_name" maxlength="30" /></td></tr>';
         $display .= '<tr><td>' . $lang['admin_password'] . ':</td><td><input type="password" name="user_pass" maxlength="30" /></td></tr>';
         $display .= '<tr><td colspan="2" align="left"><input type="checkbox" name="remember" />';
         $display .= '<span style="font-size:10px">' . $lang['remember_me'] . '</span></td></tr>';
         $display .= '<tr><td colspan="2" align="right"><input type="submit" value="' . $lang['login'] . '" /></td></tr>';
         $display .= '</table>';
         $display .= '</form><br />';
         $display .= '<form action="' . $config['baseurl'] . '/admin/index.php?action=send_forgot" method="post">' . $lang['enter_your_email_address_for_pass'] . '<br /><input type="text" name="email" /><br /><input type="submit" value="' . $lang['lookup'] . '" /></form>';
         // Run the cleanup for the forgot password table
         global $db_type;
         if ($db_type == 'mysql') {
             $sql = 'DELETE FROM ' . $config['table_prefix_no_lang'] . 'forgot WHERE forgot_time < NOW() - INTERVAL 1 DAY';
         } else {
             $sql = 'DELETE FROM ' . $config['table_prefix_no_lang'] . 'forgot WHERE forgot_time < NOW() - INTERVAL \'1 DAY\'';
         }
         $recordSet = $conn->execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         return $display;
     }
 }
 function view_saved_searches()
 {
     global $config, $lang, $conn;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     $display = '';
     $status = login::loginCheck('Member');
     if ($status === true) {
         $display .= '<h3>' . $lang['saved_searches'] . '</h3>';
         $userID = $misc->make_db_safe($_SESSION['userID']);
         $sql = "SELECT usersavedsearches_id, usersavedsearches_title, usersavedsearches_query_string FROM " . $config['table_prefix'] . "usersavedsearches WHERE userdb_id = {$userID} ORDER BY usersavedsearches_title";
         $recordSet = $conn->Execute($sql);
         if ($recordSet === false) {
             $misc->log_error($sql);
         }
         $num_columns = $recordSet->RecordCount();
         if ($num_columns == 0) {
             $display .= $lang['no_saved_searches'] . '<br /><br />';
         } else {
             while (!$recordSet->EOF) {
                 $title = $misc->make_db_unsafe($recordSet->fields['usersavedsearches_title']);
                 if ($title == '') {
                     $title = $lang['saved_search'];
                 }
                 $display .= '<a href="index.php?action=searchresults&amp;' . $misc->make_db_unsafe($recordSet->fields['usersavedsearches_query_string']) . '">' . $title . '</a>&nbsp;&nbsp;&nbsp;&nbsp;<div class="note"><a href="index.php?action=delete_search&amp;searchID=' . $misc->make_db_unsafe($recordSet->fields['usersavedsearches_id']) . '" onclick="return confirmDelete()">' . $lang['delete_search'] . '</a></div><br /><br />';
                 $recordSet->MoveNext();
             }
         }
     } else {
         $display = $status;
     }
     return $display;
 }
示例#13
0
 /**
  * configurator::show_configurator()
  * This function handles the display and updates for the site configurator.
  *
  * @param string $guidestring
  * @return
  */
 function show_configurator($guidestring = '')
 {
     global $conn, $lang, $config;
     $security = login::loginCheck('edit_site_config', true);
     $display = '';
     if ($security === true) {
         // Open Connection to the Control Panel Table
         require_once $config['basepath'] . '/include/misc.inc.php';
         $misc = new misc();
         // DISABLE MULTILINGUAL SUPPORT AS IT IS NOT READY FOR THIS RELEASE
         $ml_support = false;
         // Default Options
         $yes_no[0] = 'No';
         $yes_no[1] = 'Yes';
         $asc_desc['ASC'] = 'ASC';
         $asc_desc['DESC'] = 'DESC';
         // New Charset Settings - Current charsets supported by PHP 4.3.0 and up
         $charset['ISO-8859-1'] = 'ISO-8859-1';
         $charset['ISO-8859-15'] = 'ISO-8859-15';
         $charset['UTF-8'] = 'UTF-8';
         $charset['cp866'] = 'cp866';
         $charset['cp1251'] = 'cp1251';
         $charset['cp1252'] = 'cp1252';
         $charset['KOI8-R'] = 'KOI8-R';
         $charset['BIG5'] = 'BIG5';
         $charset['GB2312'] = 'GB2312';
         $charset['BIG5-HKSCS'] = 'BIG5-HKSCS';
         $charset['Shift_JIS'] = 'Shift_JIS';
         $charset['EUC-JP'] = 'EUC-JP';
         // New Global Maps
         $map_types['global_mapquest'] = $lang['global_mapquest'];
         $map_types['global_multimap'] = $lang['global_multimap'];
         // Map Options
         $map_types['mapquest_AD'] = $lang['mapquest_AD'];
         $map_types['mapquest_AE'] = $lang['mapquest_AE'];
         $map_types['mapquest_AF'] = $lang['mapquest_AF'];
         $map_types['mapquest_AG'] = $lang['mapquest_AG'];
         $map_types['mapquest_AI'] = $lang['mapquest_AI'];
         $map_types['mapquest_AL'] = $lang['mapquest_AL'];
         $map_types['mapquest_AM'] = $lang['mapquest_AM'];
         $map_types['mapquest_AN'] = $lang['mapquest_AN'];
         $map_types['mapquest_AO'] = $lang['mapquest_AO'];
         $map_types['mapquest_AR'] = $lang['mapquest_AR'];
         $map_types['mapquest_AS'] = $lang['mapquest_AS'];
         $map_types['mapquest_AT'] = $lang['mapquest_AT'];
         $map_types['mapquest_AU'] = $lang['mapquest_AU'];
         $map_types['mapquest_AW'] = $lang['mapquest_AW'];
         $map_types['mapquest_AZ'] = $lang['mapquest_AZ'];
         $map_types['mapquest_BA'] = $lang['mapquest_BA'];
         $map_types['mapquest_BB'] = $lang['mapquest_BB'];
         $map_types['mapquest_BD'] = $lang['mapquest_BD'];
         $map_types['mapquest_BE'] = $lang['mapquest_BE'];
         $map_types['mapquest_BF'] = $lang['mapquest_BF'];
         $map_types['mapquest_BG'] = $lang['mapquest_BG'];
         $map_types['mapquest_BH'] = $lang['mapquest_BH'];
         $map_types['mapquest_BI'] = $lang['mapquest_BI'];
         $map_types['mapquest_BJ'] = $lang['mapquest_BJ'];
         $map_types['mapquest_BM'] = $lang['mapquest_BM'];
         $map_types['mapquest_BN'] = $lang['mapquest_BN'];
         $map_types['mapquest_BO'] = $lang['mapquest_BO'];
         $map_types['mapquest_BR'] = $lang['mapquest_BR'];
         $map_types['mapquest_BS'] = $lang['mapquest_BS'];
         $map_types['mapquest_BT'] = $lang['mapquest_BT'];
         $map_types['mapquest_BV'] = $lang['mapquest_BV'];
         $map_types['mapquest_BW'] = $lang['mapquest_BW'];
         $map_types['mapquest_BY'] = $lang['mapquest_BY'];
         $map_types['mapquest_BZ'] = $lang['mapquest_BZ'];
         $map_types['mapquest_CA'] = $lang['mapquest_CA'];
         $map_types['mapquest_CC'] = $lang['mapquest_CC'];
         $map_types['mapquest_CD'] = $lang['mapquest_CD'];
         $map_types['mapquest_CF'] = $lang['mapquest_CF'];
         $map_types['mapquest_CG'] = $lang['mapquest_CG'];
         $map_types['mapquest_CH'] = $lang['mapquest_CH'];
         $map_types['mapquest_CI'] = $lang['mapquest_CI'];
         $map_types['mapquest_CK'] = $lang['mapquest_CK'];
         $map_types['mapquest_CL'] = $lang['mapquest_CL'];
         $map_types['mapquest_CM'] = $lang['mapquest_CM'];
         $map_types['mapquest_CN'] = $lang['mapquest_CN'];
         $map_types['mapquest_CO'] = $lang['mapquest_CO'];
         $map_types['mapquest_CR'] = $lang['mapquest_CR'];
         $map_types['mapquest_CS'] = $lang['mapquest_CS'];
         $map_types['mapquest_CU'] = $lang['mapquest_CU'];
         $map_types['mapquest_CV'] = $lang['mapquest_CV'];
         $map_types['mapquest_CX'] = $lang['mapquest_CX'];
         $map_types['mapquest_CY'] = $lang['mapquest_CY'];
         $map_types['mapquest_CZ'] = $lang['mapquest_CZ'];
         $map_types['mapquest_DE'] = $lang['mapquest_DE'];
         $map_types['mapquest_DJ'] = $lang['mapquest_DJ'];
         $map_types['mapquest_DK'] = $lang['mapquest_DK'];
         $map_types['mapquest_DM'] = $lang['mapquest_DM'];
         $map_types['mapquest_DO'] = $lang['mapquest_DO'];
         $map_types['mapquest_DZ'] = $lang['mapquest_DZ'];
         $map_types['mapquest_EC'] = $lang['mapquest_EC'];
         $map_types['mapquest_EE'] = $lang['mapquest_EE'];
         $map_types['mapquest_EG'] = $lang['mapquest_EG'];
         $map_types['mapquest_EH'] = $lang['mapquest_EH'];
         $map_types['mapquest_ER'] = $lang['mapquest_ER'];
         $map_types['mapquest_ES'] = $lang['mapquest_ES'];
         $map_types['mapquest_ET'] = $lang['mapquest_ET'];
         $map_types['mapquest_FI'] = $lang['mapquest_FI'];
         $map_types['mapquest_FJ'] = $lang['mapquest_FJ'];
         $map_types['mapquest_FK'] = $lang['mapquest_FK'];
         $map_types['mapquest_FM'] = $lang['mapquest_FM'];
         $map_types['mapquest_FO'] = $lang['mapquest_FO'];
         $map_types['mapquest_FR'] = $lang['mapquest_FR'];
         $map_types['multimap_FR'] = $lang['multimap_FR'];
         $map_types['mapquest_GA'] = $lang['mapquest_GA'];
         $map_types['mapquest_GB'] = $lang['mapquest_GB'];
         $map_types['mapquest_GD'] = $lang['mapquest_GD'];
         $map_types['mapquest_GE'] = $lang['mapquest_GE'];
         $map_types['mapquest_GF'] = $lang['mapquest_GF'];
         $map_types['mapquest_GH'] = $lang['mapquest_GH'];
         $map_types['mapquest_GI'] = $lang['mapquest_GI'];
         $map_types['mapquest_GL'] = $lang['mapquest_GL'];
         $map_types['mapquest_GM'] = $lang['mapquest_GM'];
         $map_types['mapquest_GN'] = $lang['mapquest_GN'];
         $map_types['mapquest_GP'] = $lang['mapquest_GP'];
         $map_types['mapquest_GQ'] = $lang['mapquest_GQ'];
         $map_types['mapquest_GR'] = $lang['mapquest_GR'];
         $map_types['mapquest_GS'] = $lang['mapquest_GS'];
         $map_types['mapquest_GT'] = $lang['mapquest_GT'];
         $map_types['mapquest_GU'] = $lang['mapquest_GU'];
         $map_types['mapquest_GW'] = $lang['mapquest_GW'];
         $map_types['mapquest_GY'] = $lang['mapquest_GY'];
         $map_types['mapquest_GZ'] = $lang['mapquest_GZ'];
         $map_types['mapquest_HK'] = $lang['mapquest_HK'];
         $map_types['mapquest_HM'] = $lang['mapquest_HM'];
         $map_types['mapquest_HN'] = $lang['mapquest_HN'];
         $map_types['mapquest_HR'] = $lang['mapquest_HR'];
         $map_types['mapquest_HT'] = $lang['mapquest_HT'];
         $map_types['mapquest_HU'] = $lang['mapquest_HU'];
         $map_types['mapquest_ID'] = $lang['mapquest_ID'];
         $map_types['mapquest_IE'] = $lang['mapquest_IE'];
         $map_types['mapquest_IL'] = $lang['mapquest_IL'];
         $map_types['mapquest_IN'] = $lang['mapquest_IN'];
         $map_types['mapquest_IO'] = $lang['mapquest_IO'];
         $map_types['mapquest_IQ'] = $lang['mapquest_IQ'];
         $map_types['mapquest_IR'] = $lang['mapquest_IR'];
         $map_types['mapquest_IS'] = $lang['mapquest_IS'];
         $map_types['mapquest_IT'] = $lang['mapquest_IT'];
         $map_types['mapquest_JM'] = $lang['mapquest_JM'];
         $map_types['mapquest_JO'] = $lang['mapquest_JO'];
         $map_types['mapquest_JP'] = $lang['mapquest_JP'];
         $map_types['mapquest_KE'] = $lang['mapquest_KE'];
         $map_types['mapquest_KG'] = $lang['mapquest_KG'];
         $map_types['mapquest_KH'] = $lang['mapquest_KH'];
         $map_types['mapquest_KI'] = $lang['mapquest_KI'];
         $map_types['mapquest_KM'] = $lang['mapquest_KM'];
         $map_types['mapquest_KN'] = $lang['mapquest_KN'];
         $map_types['mapquest_KP'] = $lang['mapquest_KP'];
         $map_types['mapquest_KR'] = $lang['mapquest_KR'];
         $map_types['mapquest_KW'] = $lang['mapquest_KW'];
         $map_types['mapquest_KY'] = $lang['mapquest_KY'];
         $map_types['mapquest_KZ'] = $lang['mapquest_KZ'];
         $map_types['mapquest_LA'] = $lang['mapquest_LA'];
         $map_types['mapquest_LB'] = $lang['mapquest_LB'];
         $map_types['mapquest_LC'] = $lang['mapquest_LC'];
         $map_types['mapquest_LI'] = $lang['mapquest_LI'];
         $map_types['mapquest_LK'] = $lang['mapquest_LK'];
         $map_types['mapquest_LR'] = $lang['mapquest_LR'];
         $map_types['mapquest_LS'] = $lang['mapquest_LS'];
         $map_types['mapquest_LT'] = $lang['mapquest_LT'];
         $map_types['mapquest_LU'] = $lang['mapquest_LU'];
         $map_types['mapquest_LV'] = $lang['mapquest_LV'];
         $map_types['mapquest_LY'] = $lang['mapquest_LY'];
         $map_types['mapquest_MA'] = $lang['mapquest_MA'];
         $map_types['mapquest_MC'] = $lang['mapquest_MC'];
         $map_types['mapquest_MD'] = $lang['mapquest_MD'];
         $map_types['mapquest_MG'] = $lang['mapquest_MG'];
         $map_types['mapquest_MH'] = $lang['mapquest_MH'];
         $map_types['mapquest_MK'] = $lang['mapquest_MK'];
         $map_types['mapquest_ML'] = $lang['mapquest_ML'];
         $map_types['mapquest_MM'] = $lang['mapquest_MM'];
         $map_types['mapquest_MN'] = $lang['mapquest_MN'];
         $map_types['mapquest_MO'] = $lang['mapquest_MO'];
         $map_types['mapquest_MP'] = $lang['mapquest_MP'];
         $map_types['mapquest_MQ'] = $lang['mapquest_MQ'];
         $map_types['mapquest_MR'] = $lang['mapquest_MR'];
         $map_types['mapquest_MS'] = $lang['mapquest_MS'];
         $map_types['mapquest_MT'] = $lang['mapquest_MT'];
         $map_types['mapquest_MU'] = $lang['mapquest_MU'];
         $map_types['mapquest_MV'] = $lang['mapquest_MV'];
         $map_types['mapquest_MW'] = $lang['mapquest_MW'];
         $map_types['mapquest_MX'] = $lang['mapquest_MX'];
         $map_types['mapquest_MY'] = $lang['mapquest_MY'];
         $map_types['mapquest_MZ'] = $lang['mapquest_MZ'];
         $map_types['mapquest_NA'] = $lang['mapquest_NA'];
         $map_types['mapquest_NC'] = $lang['mapquest_NC'];
         $map_types['mapquest_NE'] = $lang['mapquest_NE'];
         $map_types['mapquest_NF'] = $lang['mapquest_NF'];
         $map_types['mapquest_NG'] = $lang['mapquest_NG'];
         $map_types['mapquest_NI'] = $lang['mapquest_NI'];
         $map_types['mapquest_NL'] = $lang['mapquest_NL'];
         $map_types['mapquest_NO'] = $lang['mapquest_NO'];
         $map_types['mapquest_NP'] = $lang['mapquest_NP'];
         $map_types['mapquest_NR'] = $lang['mapquest_NR'];
         $map_types['mapquest_NU'] = $lang['mapquest_NU'];
         $map_types['mapquest_NZ'] = $lang['mapquest_NZ'];
         $map_types['mapquest_OM'] = $lang['mapquest_OM'];
         $map_types['mapquest_PA'] = $lang['mapquest_PA'];
         $map_types['mapquest_PE'] = $lang['mapquest_PE'];
         $map_types['mapquest_PF'] = $lang['mapquest_PF'];
         $map_types['mapquest_PG'] = $lang['mapquest_PG'];
         $map_types['mapquest_PH'] = $lang['mapquest_PH'];
         $map_types['mapquest_PK'] = $lang['mapquest_PK'];
         $map_types['mapquest_PL'] = $lang['mapquest_PL'];
         $map_types['mapquest_PM'] = $lang['mapquest_PM'];
         $map_types['mapquest_PN'] = $lang['mapquest_PN'];
         $map_types['mapquest_PR'] = $lang['mapquest_PR'];
         $map_types['mapquest_PS'] = $lang['mapquest_PS'];
         $map_types['mapquest_PT'] = $lang['mapquest_PT'];
         $map_types['mapquest_PW'] = $lang['mapquest_PW'];
         $map_types['mapquest_PY'] = $lang['mapquest_PY'];
         $map_types['mapquest_QA'] = $lang['mapquest_QA'];
         $map_types['mapquest_RE'] = $lang['mapquest_RE'];
         $map_types['mapquest_RO'] = $lang['mapquest_RO'];
         $map_types['mapquest_RU'] = $lang['mapquest_RU'];
         $map_types['mapquest_RW'] = $lang['mapquest_RW'];
         $map_types['mapquest_SA'] = $lang['mapquest_SA'];
         $map_types['mapquest_SB'] = $lang['mapquest_SB'];
         $map_types['mapquest_SC'] = $lang['mapquest_SC'];
         $map_types['mapquest_SD'] = $lang['mapquest_SD'];
         $map_types['mapquest_SE'] = $lang['mapquest_SE'];
         $map_types['mapquest_SG'] = $lang['mapquest_SG'];
         $map_types['mapquest_SH'] = $lang['mapquest_SH'];
         $map_types['mapquest_SI'] = $lang['mapquest_SI'];
         $map_types['mapquest_SJ'] = $lang['mapquest_SJ'];
         $map_types['mapquest_SK'] = $lang['mapquest_SK'];
         $map_types['mapquest_SL'] = $lang['mapquest_SL'];
         $map_types['mapquest_SM'] = $lang['mapquest_SM'];
         $map_types['mapquest_SN'] = $lang['mapquest_SN'];
         $map_types['mapquest_SO'] = $lang['mapquest_SO'];
         $map_types['mapquest_SR'] = $lang['mapquest_SR'];
         $map_types['mapquest_ST'] = $lang['mapquest_ST'];
         $map_types['mapquest_SV'] = $lang['mapquest_SV'];
         $map_types['mapquest_SY'] = $lang['mapquest_SY'];
         $map_types['mapquest_SZ'] = $lang['mapquest_SZ'];
         $map_types['mapquest_TC'] = $lang['mapquest_TC'];
         $map_types['mapquest_TD'] = $lang['mapquest_TD'];
         $map_types['mapquest_TF'] = $lang['mapquest_TF'];
         $map_types['mapquest_TG'] = $lang['mapquest_TG'];
         $map_types['mapquest_TH'] = $lang['mapquest_TH'];
         $map_types['mapquest_TJ'] = $lang['mapquest_TJ'];
         $map_types['mapquest_TK'] = $lang['mapquest_TK'];
         $map_types['mapquest_TM'] = $lang['mapquest_TM'];
         $map_types['mapquest_TN'] = $lang['mapquest_TN'];
         $map_types['mapquest_TO'] = $lang['mapquest_TO'];
         $map_types['mapquest_TP'] = $lang['mapquest_TP'];
         $map_types['mapquest_TR'] = $lang['mapquest_TR'];
         $map_types['mapquest_TT'] = $lang['mapquest_TT'];
         $map_types['mapquest_TV'] = $lang['mapquest_TV'];
         $map_types['mapquest_TW'] = $lang['mapquest_TW'];
         $map_types['mapquest_TZ'] = $lang['mapquest_TZ'];
         $map_types['mapquest_UA'] = $lang['mapquest_UA'];
         $map_types['mapquest_UG'] = $lang['mapquest_UG'];
         $map_types['multimap_GB'] = $lang['multimap_uk'];
         $map_types['google_us'] = $lang['google_us'];
         $map_types['mapquest_US'] = $lang['mapquest_US'];
         $map_types['yahoo_us'] = $lang['yahoo_us'];
         $map_types['mapquest_UY'] = $lang['mapquest_UY'];
         $map_types['mapquest_UZ'] = $lang['mapquest_UZ'];
         $map_types['mapquest_VA'] = $lang['mapquest_VA'];
         $map_types['mapquest_VC'] = $lang['mapquest_VC'];
         $map_types['mapquest_VE'] = $lang['mapquest_VE'];
         $map_types['mapquest_VG'] = $lang['mapquest_VG'];
         $map_types['mapquest_VI'] = $lang['mapquest_VI'];
         $map_types['mapquest_VN'] = $lang['mapquest_VN'];
         $map_types['mapquest_VU'] = $lang['mapquest_VU'];
         $map_types['mapquest_WF'] = $lang['mapquest_WF'];
         $map_types['mapquest_WS'] = $lang['mapquest_WS'];
         $map_types['mapquest_YE'] = $lang['mapquest_YE'];
         $map_types['mapquest_YT'] = $lang['mapquest_YT'];
         $map_types['mapquest_ZA'] = $lang['mapquest_ZA'];
         $map_types['mapquest_ZM'] = $lang['mapquest_ZM'];
         $map_types['mapquest_ZW'] = $lang['mapquest_ZW'];
         // Listing Template Field Names for Map Field Selection
         $sql = "SELECT listingsformelements_field_name, listingsformelements_field_caption FROM " . $config['table_prefix'] . "listingsformelements";
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         $listing_field_name_options[''] = '';
         while (!$recordSet->EOF) {
             $field_name = $recordSet->fields['listingsformelements_field_name'];
             $listing_field_name_options[$field_name] = $field_name . ' (' . $recordSet->fields['listingsformelements_field_caption'] . ')';
             $recordSet->MoveNext();
         }
         // Agent Template Field Names for Vcard Selection
         $sql = "SELECT agentformelements_field_name, agentformelements_field_caption FROM " . $config['table_prefix'] . "agentformelements";
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         $agent_field_name_options[''] = '';
         while (!$recordSet->EOF) {
             $field_name = $recordSet->fields['agentformelements_field_name'];
             $agent_field_name_options[$field_name] = $field_name . ' (' . $recordSet->fields['agentformelements_field_caption'] . ')';
             $recordSet->MoveNext();
         }
         // Listing Template Field Names for Search Field Selection
         $sql = "SELECT listingsformelements_field_name, listingsformelements_field_caption FROM " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_display_on_browse = 'Yes'";
         $recordSet = $conn->Execute($sql);
         $search_field_sortby_options['random'] = $lang['random'];
         $search_field_sortby_options['listingsdb_id'] = $lang['id'];
         $search_field_sortby_options['listingsdb_title'] = $lang['title'];
         $search_field_sortby_options['listingsdb_featured'] = $lang['featured'];
         $search_field_sortby_options['listingsdb_last_modified'] = $lang['last_modified'];
         $search_field_special_sortby_options['none'] = $lang['none'];
         $search_field_special_sortby_options['listingsdb_featured'] = $lang['featured'];
         $search_field_special_sortby_options['listingsdb_id'] = $lang['id'];
         $search_field_special_sortby_options['listingsdb_title'] = $lang['title'];
         $search_field_special_sortby_options['listingsdb_last_modified'] = $lang['last_modified'];
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         while (!$recordSet->EOF) {
             $field_name = $recordSet->fields['listingsformelements_field_name'];
             $search_field_sortby_options[$field_name] = $field_name . ' (' . $recordSet->fields['listingsformelements_field_caption'] . ')';
             $search_field_special_sortby_options[$field_name] = $field_name . ' (' . $recordSet->fields['listingsformelements_field_caption'] . ')';
             $recordSet->MoveNext();
         }
         $thumbnail_prog['gd'] = 'GD Libs';
         $thumbnail_prog['imagemagick'] = 'ImageMagick';
         $resize_opts['width'] = 'Width';
         $resize_opts['height'] = 'Height';
         $resize_opts['bestfit'] = 'Best Fit';
         $resize_opts['both'] = 'Both';
         $mainimage_opts['width'] = 'Width';
         $mainimage_opts['height'] = 'Height';
         $mainimage_opts['both'] = 'Both';
         $filedisplay['filename'] = 'Filename';
         $filedisplay['caption'] = 'Caption';
         $filedisplay['both'] = 'Both';
         // Generate GuideString
         $guidestring = '';
         foreach ($_GET as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $vitem) {
                     $guidestring .= '&amp;' . urlencode("{$k}") . '[]=' . urlencode("{$vitem}");
                 }
             } else {
                 $guidestring .= '&amp;' . urlencode("{$k}") . '=' . urlencode("{$v}");
             }
         }
         // Save any Post Data
         if (isset($_POST['controlpanel_admin_name'])) {
             if ($ml_support === true) {
                 // Setup any new Language Databases
                 require_once $config['basepath'] . '/include/multilingual.inc.php';
                 foreach ($_POST['controlpanel_configured_langs'] as $f) {
                     // $display .= $f;
                     $new_langs[] = $f;
                 }
                 $sql = 'SELECT controlpanel_configured_langs from ' . $config['table_prefix_no_lang'] . 'controlpanel';
                 $recordSet = $conn->Execute($sql);
                 if (!$recordSet) {
                     $misc->log_error($sql);
                 }
                 $old_langs = explode(',', $recordSet->fields['controlpanel_configured_langs']);
                 // Setup New Language Tables
                 foreach ($new_langs as $newlang) {
                     if (!in_array($newlang, $old_langs)) {
                         multilingual::setup_additional_language($newlang);
                     }
                 }
                 // Remove Old Language Tables
                 foreach ($old_langs as $oldlang) {
                     if (!in_array($oldlang, $new_langs)) {
                         multilingual::remove_additional_language($oldlang);
                     }
                 }
             }
             // Update ControlPanel
             $sql = 'UPDATE ' . $config['table_prefix_no_lang'] . 'controlpanel SET ';
             $sql_part = '';
             foreach ($_POST as $field => $value) {
                 if (is_array($value)) {
                     $value2 = '';
                     foreach ($value as $f) {
                         if ($value2 == '') {
                             $value2 = "{$f}";
                         } else {
                             $value2 .= ",{$f}";
                         }
                     }
                     $value2 = $misc->make_db_safe($value2);
                     if ($sql_part == '') {
                         $sql_part = "{$field} = {$value2}";
                     } else {
                         $sql_part .= " , {$field} = {$value2}";
                     }
                 } else {
                     $value = $misc->make_db_safe($value);
                     if ($sql_part == '') {
                         $sql_part = "{$field} = {$value}";
                     } else {
                         $sql_part .= " , {$field} = {$value}";
                     }
                 }
             }
             $sql .= $sql_part;
             $recordSet = $conn->Execute($sql);
             if (!$recordSet) {
                 $misc->log_error($sql);
             }
             $display .= '<br /><b>' . $lang['configuration_saved'] . '</b><br />';
         }
         // START SITE CONFIGURATOR
         $sql = 'SELECT * from ' . $config["table_prefix_no_lang"] . 'controlpanel';
         $recordSet = $conn->Execute($sql);
         if (!$recordSet) {
             $misc->log_error($sql);
         }
         // Include the Form Generation Class
         include $config['basepath'] . '/include/class/form_generation.inc.php';
         $formGen = new formGeneration();
         $display .= '<h2>' . $lang['open_realty_configurator'] . '</h2>';
         $display .= $formGen->startform('index.php?' . $guidestring);
         //Start tabbed page
         $display .= '<div class="tab-pane" id="tabPane1">';
         $display .= '<script type="text/javascript">' . "\r\n";
         $display .= 'tp1 = new WebFXTabPane( document.getElementById( "tabPane1" ) );' . "\r\n";
         $display .= '</script>' . "\r\n";
         //Tab 1
         $display .= '<div class="tab-page" id="tabPage1">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_general'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage1" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_general_info'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_name'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_admin_name', $misc->make_db_unsafe($recordSet->fields['controlpanel_admin_name']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_admin_name'])) . '</td>';
         $display .= '<td>' . $lang['admin_name_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['admin_email'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_admin_email', $misc->make_db_unsafe($recordSet->fields['controlpanel_admin_email']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_admin_email'])) . '</td>';
         $display .= '<td>' . $lang['admin_email_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['company_name'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_company_name', $misc->make_db_unsafe($recordSet->fields['controlpanel_company_name']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_company_name'])) . '</td>';
         $display .= '<td>' . $lang['company_name_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['company_location'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_company_location', $misc->make_db_unsafe($recordSet->fields['controlpanel_company_location']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_company_location'])) . '</td>';
         $display .= '<td>' . $lang['company_location_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['company_logo'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_company_logo', $misc->make_db_unsafe($recordSet->fields['controlpanel_company_logo']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_company_logo'])) . '</td>';
         $display .= '<td>' . $lang['company_logo_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['automatic_update_check'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_automatic_update_check', $misc->make_db_unsafe($recordSet->fields['controlpanel_automatic_update_check']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_automatic_update_check'])) . '</td>';
         $display .= '<td>' . $lang['automatic_update_check_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['demo_mode'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_demo_mode', $misc->make_db_unsafe($recordSet->fields['controlpanel_demo_mode']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_demo_mode'])) . '</td>';
         $display .= '<td>' . $lang['demo_mode_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset><br />';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_server_paths'] . '</b></legend>';
         $display .= '<table align="center" cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['base_url'] . '</strong></td>';
         $display .= '<td>' . $misc->make_db_unsafe($recordSet->fields['controlpanel_baseurl']) . '</td>';
         $display .= '<td>' . $lang['base_url_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['base_path'] . '</strong></td>';
         $display .= '<td>' . $misc->make_db_unsafe($recordSet->fields['controlpanel_basepath']) . '</td>';
         $display .= '<td>' . $lang['base_path_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset><br />';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_language_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="150"><strong>' . $lang['lang'] . '</strong></td>';
         // Get Language Options
         $dir = 0;
         $options = array();
         if ($handle = opendir($config['basepath'] . '/include/language')) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                     if (is_dir($config['basepath'] . '/include/language/' . $file)) {
                         $options[$file] = $file;
                         $dir++;
                     }
                 }
             }
             closedir($handle);
         }
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_lang', $misc->make_db_unsafe($recordSet->fields['controlpanel_lang']), false, 35, '', '', '', '', $options, $misc->make_db_unsafe($recordSet->fields['controlpanel_lang']), true) . '</td>';
         $display .= '<td>' . $lang['lang_desc'] . '</td>';
         $display .= '</tr>';
         if ($ml_support === true) {
             $display .= '<tr class=tdshade1>';
             $display .= '<td><strong>' . $lang['configured_langs'] . '</strong></td>';
             $dir = 0;
             $options = array();
             if ($handle = opendir($config['basepath'] . '/include/language')) {
                 while (false !== ($file = readdir($handle))) {
                     if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                         if (is_dir($config['basepath'] . '/include/language/' . $file)) {
                             $options[$file] = $file;
                             $dir++;
                         }
                     }
                 }
                 closedir($handle);
             }
             $selected = explode(',', $recordSet->fields['controlpanel_configured_langs']);
             $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_configured_langs[]', $misc->make_db_unsafe($recordSet->fields['controlpanel_configured_langs']), true, 8, '', '', '', '', $options, $selected) . '</td>';
             $display .= '<td>' . $lang['configured_langs_desc'] . '</td>';
             $display .= '</tr>';
         }
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End Tab1
         //Tab 2
         $display .= '<div class="tab-page" id="tabPage2">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_template'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage2" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_template_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $url_type[1] = $lang['url_standard'];
         $url_type[2] = $lang['url_search_friendly'];
         $url_seperator["+"] = $lang['url_seperator_default'];
         $url_seperator["-"] = $lang['url_seperator_hyphen'];
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['charset'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_charset', $misc->make_db_unsafe($recordSet->fields['controlpanel_charset']), false, 35, '', '', '', '', $charset, $misc->make_db_unsafe($recordSet->fields['controlpanel_charset'])) . '</td>';
         $display .= '<td>' . $lang['charset_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['template'] . '</strong></td>';
         // Get Template List
         $dir = 0;
         $options = array();
         if ($handle = opendir($config['basepath'] . '/template')) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                     if (is_dir($config['basepath'] . '/template/' . $file)) {
                         $options[$file] = $file;
                         $dir++;
                     }
                 }
             }
             closedir($handle);
         }
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_template']), false, 35, '', '', '', '', $options, $misc->make_db_unsafe($recordSet->fields['controlpanel_template'])) . '</td>';
         $display .= '<td>' . $lang['template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['admin_template'] . '</strong></td>';
         // Get Template List
         $dir = 0;
         $options = array();
         if ($handle = opendir($config['basepath'] . '/admin/template')) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                     if (is_dir($config['basepath'] . '/admin/template/' . $file)) {
                         $options[$file] = $file;
                         $dir++;
                     }
                 }
             }
             closedir($handle);
         }
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_admin_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_admin_template']), false, 35, '', '', '', '', $options, $misc->make_db_unsafe($recordSet->fields['controlpanel_admin_template'])) . '</td>';
         $display .= '<td>' . $lang['admin_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['listing_template'] . '</strong></td>';
         // Get Listing Template List
         $options = array();
         if ($handle = opendir($config['basepath'] . '/template/' . $config['template'])) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                     if (!is_dir($config['basepath'] . '/template/' . $config['template'] . '/' . $file)) {
                         if (substr($file, 0, 14) == 'listing_detail') {
                             $options[$file] = substr($file, 15, -5);
                         }
                     }
                 }
             }
             closedir($handle);
         }
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_listing_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_listing_template']), false, 35, '', '', '', '', $options, $misc->make_db_unsafe($recordSet->fields['controlpanel_listing_template'])) . '</td>';
         $display .= '<td>' . $lang['listing_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['template_listing_sections'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_template_listing_sections', $misc->make_db_unsafe($recordSet->fields['controlpanel_template_listing_sections']), false, 35, '', '', '', '', '', $misc->make_db_unsafe($recordSet->fields['controlpanel_template_listing_sections'])) . '</td>';
         $display .= '<td>' . $lang['template_listing_sections_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['search_result_template'] . '</strong></td>';
         // Get Search Result Template List
         $options = array();
         if ($handle = opendir($config['basepath'] . '/template/' . $config['template'])) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                     if (!is_dir($config['basepath'] . '/template/' . $config['template'] . '/' . $file)) {
                         if (substr($file, 0, 13) == 'search_result') {
                             $options[$file] = substr($file, 14, -5);
                         }
                     }
                 }
             }
             closedir($handle);
         }
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_search_result_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_search_result_template']), false, 35, '', '', '', '', $options, $misc->make_db_unsafe($recordSet->fields['controlpanel_search_result_template'])) . '</td>';
         $display .= '<td>' . $lang['search_result_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['view_agent_template'] . '</strong></td>';
         // Get View Agent Template List
         $options = array();
         if ($handle = opendir($config['basepath'] . '/template/' . $config['template'])) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                     if (!is_dir($config['basepath'] . '/template/' . $config['template'] . '/' . $file)) {
                         if (substr($file, 0, 10) == 'view_user_') {
                             $options[$file] = substr($file, 10, -5);
                         }
                     }
                 }
             }
             closedir($handle);
         }
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_template']), false, 35, '', '', '', '', $options, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_template'])) . '</td>';
         $display .= '<td>' . $lang['view_agent_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['vtour_template'] . '</strong></td>';
         // Get VTour Template List
         $options = array();
         if ($handle = opendir($config['basepath'] . '/template/' . $config['template'])) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
                     if (!is_dir($config['basepath'] . '/template/' . $config['template'] . '/' . $file)) {
                         if (substr($file, 0, 6) == 'vtour_') {
                             $options[$file] = substr($file, 6, -5);
                         }
                     }
                 }
             }
             closedir($handle);
         }
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vtour_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_template']), false, 35, '', '', '', '', $options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_template'])) . '</td>';
         $display .= '<td>' . $lang['vtour_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End Tab2
         //Start tab3
         $display .= '<div class="tab-page" id="tabPage3">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_seo'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage3" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_seo_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['url_type'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_url_style', $misc->make_db_unsafe($recordSet->fields['controlpanel_url_style']), false, 35, '', '', '', '', $url_type, $misc->make_db_unsafe($recordSet->fields['controlpanel_url_style'])) . '</td>';
         $display .= '<td>' . $lang['url_type_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['url_seperator'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_seo_url_seperator', $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_url_seperator']), false, 35, '', '', '', '', $url_seperator, $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_url_seperator'])) . '</td>';
         $display .= '<td>' . $lang['url_seperator_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['seo_default_title'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_seo_default_title', $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_default_title']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_default_title'])) . '</td>';
         $display .= '<td>' . $lang['seo_default_title_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['seo_default_keywords'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_seo_default_keywords', $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_default_keywords']), false, 35, '', '', '', '', $url_type, $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_default_keywords'])) . '</td>';
         $display .= '<td>' . $lang['seo_default_keywords_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['seo_default_description'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_seo_default_description', $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_default_description']), false, 35, '', '', '', '', $url_type, $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_default_description'])) . '</td>';
         $display .= '<td>' . $lang['seo_default_description_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['seo_listing_title'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_seo_listing_title', $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_listing_title']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_listing_title'])) . '</td>';
         $display .= '<td>' . $lang['seo_listing_title_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['seo_listing_keywords'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_seo_listing_keywords', $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_listing_keywords']), false, 35, '', '', '', '', $url_type, $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_listing_keywords'])) . '</td>';
         $display .= '<td>' . $lang['seo_listing_keywords_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['seo_listing_description'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_seo_listing_description', $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_listing_description']), false, 35, '', '', '', '', $url_type, $misc->make_db_unsafe($recordSet->fields['controlpanel_seo_listing_description'])) . '</td>';
         $display .= '<td>' . $lang['seo_listing_description_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab3
         //start tab4
         $display .= '<div class="tab-page" id="tabPage4">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_wysiwyg'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage4" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_wysiwyg_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['wysiwyg_editor'] . '</strong></td>';
         $wysiwyg_editor_list = array();
         $wysiwyg_editor_list['list'] = 'None';
         if (file_exists($config['basepath'] . '/include/class/fckeditor')) {
             $wysiwyg_editor_list['fckeditor'] = 'FCKeditor';
         }
         if (file_exists($config['basepath'] . '/include/class/xinha')) {
             $wysiwyg_editor_list['xinha'] = 'Xinha';
         }
         if (file_exists($config['basepath'] . '/include/class/tinymce')) {
             $wysiwyg_editor_list['tinymce'] = 'TinyMCE';
         }
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_wysiwyg_editor', $misc->make_db_unsafe($recordSet->fields['controlpanel_wysiwyg_editor']), false, 35, '', '', '', '', $wysiwyg_editor_list, $misc->make_db_unsafe($recordSet->fields['controlpanel_wysiwyg_editor'])) . '</td>';
         $display .= '<td>' . $lang['wysiwyg_editor_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['wysiwyg_show_edit'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_wysiwyg_show_edit', $misc->make_db_unsafe($recordSet->fields['controlpanel_wysiwyg_show_edit']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_wysiwyg_show_edit'])) . '</td>';
         $display .= '<td>' . $lang['wysiwyg_show_edit_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['wysiwyg_execute_php'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_wysiwyg_execute_php', $misc->make_db_unsafe($recordSet->fields['controlpanel_wysiwyg_execute_php']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_wysiwyg_execute_php'])) . '</td>';
         $display .= '<td>' . $lang['wysiwyg_execute_php_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset><br />';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_html_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['add_linefeeds'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_add_linefeeds', $misc->make_db_unsafe($recordSet->fields['controlpanel_add_linefeeds']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_add_linefeeds'])) . '</td>';
         $display .= '<td>' . $lang['add_linefeeds_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['strip_html'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_strip_html', $misc->make_db_unsafe($recordSet->fields['controlpanel_strip_html']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_strip_html'])) . '</td>';
         $display .= '<td>' . $lang['strip_html_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['allowed_html_tags'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_allowed_html_tags', $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_html_tags']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_html_tags'])) . '</td>';
         $display .= '<td>' . $lang['allowed_html_tags_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab4
         //start tab5
         $display .= '<div class="tab-page" id="tabPage5">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_numbers'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage5" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_number_formatting'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $number_format[1] = '1,000.00';
         $number_format[2] = '1.000,00';
         $number_format[3] = '1 000.00';
         $number_format[4] = '1 000,00';
         $number_format[5] = '1\'000,00';
         $number_format[6] = '1-000 00';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['number_format_style'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_number_format_style', $misc->make_db_unsafe($recordSet->fields['controlpanel_number_format_style']), false, 35, '', '', '', '', $number_format, $misc->make_db_unsafe($recordSet->fields['controlpanel_number_format_style'])) . '</td>';
         $display .= '<td>' . $lang['number_format_style_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['number_decimals_number_fields'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_number_decimals_number_fields', $misc->make_db_unsafe($recordSet->fields['controlpanel_number_decimals_number_fields']), false, 3, '', '', '', '', $number_format, $misc->make_db_unsafe($recordSet->fields['controlpanel_number_decimals_number_fields'])) . '</td>';
         $display .= '<td>' . $lang['number_decimals_number_fields_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['number_decimals_price_fields'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_number_decimals_price_fields', $misc->make_db_unsafe($recordSet->fields['controlpanel_number_decimals_price_fields']), false, 3, '', '', '', '', $number_format, $misc->make_db_unsafe($recordSet->fields['controlpanel_number_decimals_price_fields'])) . '</td>';
         $display .= '<td>' . $lang['number_decimals_price_fields_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['force_decimals'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_force_decimals', $misc->make_db_unsafe($recordSet->fields['controlpanel_force_decimals']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_force_decimals'])) . '</td>';
         $display .= '<td>' . $lang['force_decimals_desc'] . '</td>';
         $display .= '</tr>';
         $money_format[1] = $misc->make_db_unsafe($recordSet->fields['controlpanel_money_sign']) . '1';
         $money_format[2] = '1' . $misc->make_db_unsafe($recordSet->fields['controlpanel_money_sign']);
         $money_format[3] = $misc->make_db_unsafe($recordSet->fields['controlpanel_money_sign']) . ' 1';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['money_format'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_money_format', $misc->make_db_unsafe($recordSet->fields['controlpanel_money_format']), false, 35, '', '', '', '', $money_format, $misc->make_db_unsafe($recordSet->fields['controlpanel_money_format'])) . '</td>';
         $display .= '<td>' . $lang['money_format_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['money_sign'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_money_sign', $misc->make_db_unsafe($recordSet->fields['controlpanel_money_sign']), false, 2, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_money_sign'])) . '</td>';
         $display .= '<td>' . $lang['money_sign_desc'] . '</td>';
         $display .= '</tr>';
         $date_format[1] = 'mm/dd/yyyy';
         $date_format[2] = 'yyyy/dd/mm';
         $date_format[3] = 'dd/mm/yyyy';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['date_format'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_date_format', $misc->make_db_unsafe($recordSet->fields['controlpanel_date_format']), false, 2, '', '', '', '', $date_format, $misc->make_db_unsafe($recordSet->fields['controlpanel_date_format'])) . '</td>';
         $display .= '<td>' . $lang['date_format_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['zero_price_text'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_zero_price', $misc->make_db_unsafe($recordSet->fields['controlpanel_zero_price']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_zero_price'])) . '</td>';
         $display .= '<td>' . $lang['zero_price_text_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['site_config_price_field'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_price_field', $misc->make_db_unsafe($recordSet->fields['controlpanel_price_field']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_price_field'])) . '</td>';
         $display .= '<td>' . $lang['site_config_price_field_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab5
         //start tab6
         $display .= '<div class="tab-page" id="tabPage6">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_uploads'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage6" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_upload_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['allowed_upload_extensions'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_allowed_upload_extensions', $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_upload_extensions']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_upload_extensions'])) . '</td>';
         $display .= '<td>' . $lang['allowed_upload_extensions_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['allowed_upload_types'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_allowed_upload_types', $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_upload_types']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_upload_types'])) . '</td>';
         $display .= '<td>' . $lang['allowed_upload_types_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['make_thumbnail'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_make_thumbnail', $misc->make_db_unsafe($recordSet->fields['controlpanel_make_thumbnail']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_make_thumbnail'])) . '</td>';
         $display .= '<td>' . $lang['make_thumbnail_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['thumbnail_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_thumbnail_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_thumbnail_width']), false, 4, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_thumbnail_width'])) . '</td>';
         $display .= '<td>' . $lang['thumbnail_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['thumbnail_height'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_thumbnail_height', $misc->make_db_unsafe($recordSet->fields['controlpanel_thumbnail_height']), false, 4, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_thumbnail_height'])) . '</td>';
         $display .= '<td>' . $lang['thumbnail_height_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['resize_thumb_by'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_resize_thumb_by', $misc->make_db_unsafe($recordSet->fields['controlpanel_resize_thumb_by']), false, 4, '', '', '', '', $resize_opts, $misc->make_db_unsafe($recordSet->fields['controlpanel_resize_thumb_by'])) . '</td>';
         $display .= '<td>' . $lang['resize_thumb_by_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['thumbnail_prog'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_thumbnail_prog', $misc->make_db_unsafe($recordSet->fields['controlpanel_thumbnail_prog']), false, 4, '', '', '', '', $thumbnail_prog, $misc->make_db_unsafe($recordSet->fields['controlpanel_thumbnail_prog'])) . '</td>';
         $display .= '<td>' . $lang['thumbnail_prog_desc'] . '</td>';
         $display .= '</tr>';
         // Path
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['path_to_imagemagick'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_path_to_imagemagick', $misc->make_db_unsafe($recordSet->fields['controlpanel_path_to_imagemagick']), false, 25, '', '', '', '', $thumbnail_prog, $misc->make_db_unsafe($recordSet->fields['controlpanel_path_to_imagemagick'])) . '</td>';
         $display .= '<td>' . $lang['path_to_imagemagick_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['jpeg_quality'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_jpeg_quality', $misc->make_db_unsafe($recordSet->fields['controlpanel_jpeg_quality']), false, 4, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_jpeg_quality'])) . '</td>';
         $display .= '<td>' . $lang['jpeg_quality_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['resize_img'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_resize_img', $misc->make_db_unsafe($recordSet->fields['controlpanel_resize_img']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_resize_img'])) . '</td>';
         $display .= '<td>' . $lang['resize_img_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['resize_by'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_resize_by', $misc->make_db_unsafe($recordSet->fields['controlpanel_resize_by']), false, 4, '', '', '', '', $resize_opts, $misc->make_db_unsafe($recordSet->fields['controlpanel_resize_by'])) . '</td>';
         $display .= '<td>' . $lang['resize_by_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['gdversion2'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_gd_version', $misc->make_db_unsafe($recordSet->fields['controlpanel_gd_version']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_gd_version'])) . '</td>';
         $display .= '<td>' . $lang['gdversion2_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['show_no_photo'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_show_no_photo', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_no_photo']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_no_photo'])) . '</td>';
         $display .= '<td>' . $lang['show_no_photo_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset><br />';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_upload_limits'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_listings_uploads'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_listings_uploads', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_uploads']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_uploads'])) . '</td>';
         $display .= '<td>' . $lang['max_listings_uploads_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_listings_upload_size'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_listings_upload_size', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_upload_size']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_upload_size'])) . '</td>';
         $display .= '<td>' . $lang['max_listings_upload_size_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_listings_upload_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_listings_upload_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_upload_width']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_upload_width'])) . '</td>';
         $display .= '<td>' . $lang['max_listings_upload_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_listings_upload_height'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_listings_upload_height', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_upload_height']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_upload_width'])) . '</td>';
         $display .= '<td>' . $lang['max_listings_upload_height_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_user_uploads'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_user_uploads', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_uploads']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_uploads'])) . '</td>';
         $display .= '<td>' . $lang['max_user_uploads_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_user_upload_size'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_user_upload_size', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_upload_size']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_upload_size'])) . '</td>';
         $display .= '<td>' . $lang['max_user_upload_size_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_user_upload_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_user_upload_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_upload_width']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_upload_width'])) . '</td>';
         $display .= '<td>' . $lang['max_user_upload_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_user_upload_height'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_user_upload_height', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_upload_height']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_user_upload_width'])) . '</td>';
         $display .= '<td>' . $lang['max_user_upload_height_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_vtour_uploads'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_vtour_uploads', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_vtour_uploads']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_vtour_uploads'])) . '</td>';
         $display .= '<td>' . $lang['max_vtour_uploads_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_vtour_upload_size'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_vtour_upload_size', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_vtour_upload_size']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_vtour_upload_size'])) . '</td>';
         $display .= '<td>' . $lang['max_vtour_upload_size_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_vtour_upload_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_vtour_upload_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_vtour_upload_width']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_vtour_upload_width'])) . '</td>';
         $display .= '<td>' . $lang['max_vtour_upload_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['image_display_sizes'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['main_image_display_by'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_main_image_display_by', $misc->make_db_unsafe($recordSet->fields['controlpanel_main_image_display_by']), false, 7, '', '', '', '', $mainimage_opts, $misc->make_db_unsafe($recordSet->fields['controlpanel_main_image_display_by'])) . '</td>';
         $display .= '<td>' . $lang['main_image_display_by_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['main_image_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_main_image_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_main_image_width']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_main_image_width'])) . '</td>';
         $display .= '<td>' . $lang['main_image_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['main_image_height'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_main_image_height', $misc->make_db_unsafe($recordSet->fields['controlpanel_main_image_height']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_main_image_height'])) . '</td>';
         $display .= '<td>' . $lang['main_image_height_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['number_columns'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_number_columns', $misc->make_db_unsafe($recordSet->fields['controlpanel_number_columns']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_number_columns'])) . '</td>';
         $display .= '<td>' . $lang['number_columns_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab6
         //start tab7
         $display .= '<div class="tab-page" id="tabPage7">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_uploads_files'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage7" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_upload_file_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['allowed_upload_extensions'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_allowed_file_upload_extensions', $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_file_upload_extensions']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_allowed_file_upload_extensions'])) . '</td>';
         $display .= '<td>' . $lang['allowed_upload_extensions_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset><br />';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_upload_file_limits'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_file_uploads'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_listings_file_uploads', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_file_uploads']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_file_uploads'])) . '</td>';
         $display .= '<td>' . $lang['max_file_uploads_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_file_upload_size'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_listings_file_upload_size', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_file_upload_size']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_listings_file_upload_size'])) . '</td>';
         $display .= '<td>' . $lang['max_file_upload_size_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['max_user_file_uploads'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_users_file_uploads', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_users_file_uploads']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_users_file_uploads'])) . '</td>';
         $display .= '<td>' . $lang['max_user_file_uploads_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_user_file_upload_size'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_users_file_upload_size', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_users_file_upload_size']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_users_file_upload_size'])) . '</td>';
         $display .= '<td>' . $lang['max_user_file_upload_size_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['file_display_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['show_file_icon'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_show_file_icon', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_file_icon']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_file_icon'])) . '</td>';
         $display .= '<td>' . $lang['show_file_icon_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['show_file_display_option'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_file_display_option', $misc->make_db_unsafe($recordSet->fields['controlpanel_file_display_option']), false, 4, '', '', '', '', $filedisplay, $misc->make_db_unsafe($recordSet->fields['controlpanel_file_display_option'])) . '</td>';
         $display .= '<td>' . $lang['show_file_display_option_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['show_file_size'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_show_file_size', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_file_size']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_file_size'])) . '</td>';
         $display .= '<td>' . $lang['show_file_size_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['file_icon_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_icon_image_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_icon_image_width']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_icon_image_width'])) . '</td>';
         $display .= '<td>' . $lang['file_icon_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['file_icon_height'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_icon_image_height', $misc->make_db_unsafe($recordSet->fields['controlpanel_icon_image_height']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_icon_image_height'])) . '</td>';
         $display .= '<td>' . $lang['file_icon_height_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab7
         //start tab8
         $display .= '<div class="tab-page" id="tabPage8">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_search'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage8" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_search_options'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['search_step_max'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_search_step_max', $misc->make_db_unsafe($recordSet->fields['controlpanel_search_step_max']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_search_step_max'])) . '</td>';
         $display .= '<td>' . $lang['search_step_max_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['listings_per_page'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_listings_per_page', $misc->make_db_unsafe($recordSet->fields['controlpanel_listings_per_page']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_listings_per_page'])) . '</td>';
         $display .= '<td>' . $lang['listings_per_page_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['configured_search_sortby'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_search_sortby', $misc->make_db_unsafe($recordSet->fields['controlpanel_search_sortby']), false, 35, '', '', '', '', $search_field_sortby_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_search_sortby'])) . '</td>';
         $display .= '<td>' . $lang['configured_search_sortby_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['configured_search_sorttype'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_search_sorttype', $misc->make_db_unsafe($recordSet->fields['controlpanel_search_sorttype']), false, 35, '', '', '', '', $asc_desc, $misc->make_db_unsafe($recordSet->fields['controlpanel_search_sorttype'])) . '</td>';
         $display .= '<td>' . $lang['configured_search_sorttype_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['configured_special_search_sortby'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_special_search_sortby', $misc->make_db_unsafe($recordSet->fields['controlpanel_special_search_sortby']), false, 35, '', '', '', '', $search_field_special_sortby_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_special_search_sortby'])) . '</td>';
         $display .= '<td>' . $lang['configured_special_search_sortby_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['configured_special_search_sorttype'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_special_search_sorttype', $misc->make_db_unsafe($recordSet->fields['controlpanel_special_search_sorttype']), false, 35, '', '', '', '', $asc_desc, $misc->make_db_unsafe($recordSet->fields['controlpanel_special_search_sorttype'])) . '</td>';
         $display .= '<td>' . $lang['configured_special_search_sorttype_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['configured_show_count'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_configured_show_count', $misc->make_db_unsafe($recordSet->fields['controlpanel_configured_show_count']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_configured_show_count'])) . '</td>';
         $display .= '<td>' . $lang['configured_show_count_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['max_search_results'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_max_search_results', $misc->make_db_unsafe($recordSet->fields['controlpanel_max_search_results']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_max_search_results'])) . '</td>';
         $display .= '<td>' . $lang['max_search_results_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['search_list_separator'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_search_list_separator', $misc->make_db_unsafe($recordSet->fields['controlpanel_search_list_separator']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_search_list_separator'])) . '</td>';
         $display .= '<td>' . $lang['search_list_separator_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['textarea_short_chars'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_textarea_short_chars', $misc->make_db_unsafe($recordSet->fields['controlpanel_textarea_short_chars']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_textarea_short_chars'])) . '</td>';
         $display .= '<td>' . $lang['textarea_short_chars_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab8
         //start tab9
         $display .= '<div class="tab-page" id="tabPage9">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_vtours'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage9" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_vtour_options'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['vtour_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_vtour_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_width']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_width'])) . '</td>';
         $display .= '<td>' . $lang['vtour_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['vtour_height'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_vtour_height', $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_height']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_height'])) . '</td>';
         $display .= '<td>' . $lang['vtour_height_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['vtour_fov'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_vtour_fov', $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_fov']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_vtour_fov'])) . '</td>';
         $display .= '<td>' . $lang['vtour_fov_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="100"><strong>' . $lang['vt_popup_width'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_vt_popup_width', $misc->make_db_unsafe($recordSet->fields['controlpanel_vt_popup_width']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_vt_popup_width'])) . '</td>';
         $display .= '<td>' . $lang['vt_popup_width_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['vt_popup_height'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_vt_popup_height', $misc->make_db_unsafe($recordSet->fields['controlpanel_vt_popup_height']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_vt_popup_height'])) . '</td>';
         $display .= '<td>' . $lang['vt_popup_height_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab9
         //start tab10
         $display .= '<div class="tab-page" id="tabPage10">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_notify'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage10" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_notification_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['email_notification_of_new_users'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_email_notification_of_new_users', $misc->make_db_unsafe($recordSet->fields['controlpanel_email_notification_of_new_users']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_email_notification_of_new_users'])) . '</td>';
         $display .= '<td>' . $lang['email_notification_of_new_users_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['email_notification_of_new_listings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_email_notification_of_new_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_email_notification_of_new_listings']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_email_notification_of_new_listings'])) . '</td>';
         $display .= '<td>' . $lang['email_notification_of_new_listings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['email_users_notification_of_new_listings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_email_users_notification_of_new_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_email_users_notification_of_new_listings']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_email_users_notification_of_new_listings'])) . '</td>';
         $display .= '<td>' . $lang['email_users_notification_of_new_listings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['email_registration_information_to_new_users'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_email_information_to_new_users', $misc->make_db_unsafe($recordSet->fields['controlpanel_email_information_to_new_users']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_email_information_to_new_users'])) . '</td>';
         $display .= '<td>' . $lang['email_information_to_new_users_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['use_email_image_verification'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_use_email_image_verification', $misc->make_db_unsafe($recordSet->fields['controlpanel_use_email_image_verification']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_use_email_image_verification'])) . '</td>';
         $display .= '<td>' . $lang['use_email_image_verification_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['disable_referrer_check'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_disable_referrer_check', $misc->make_db_unsafe($recordSet->fields['controlpanel_disable_referrer_check']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_disable_referrer_check'])) . '</td>';
         $display .= '<td>' . $lang['disable_referrer_check_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['include_senders_ip'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_include_senders_ip', $misc->make_db_unsafe($recordSet->fields['controlpanel_include_senders_ip']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_include_senders_ip'])) . '</td>';
         $display .= '<td>' . $lang['include_senders_ip_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab10
         //start tab11
         $display .= '<div class="tab-page" id="tabPage11">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_users'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage11" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_member_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['moderate_members'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_moderate_members', $misc->make_db_unsafe($recordSet->fields['controlpanel_moderate_members']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_moderate_members'])) . '</td>';
         $display .= '<td>' . $lang['moderate_members_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['allow_member_signup'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_allow_member_signup', $misc->make_db_unsafe($recordSet->fields['controlpanel_allow_member_signup']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_allow_member_signup'])) . '</td>';
         $display .= '<td>' . $lang['allow_member_signup_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset><br />';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_agent_permissions'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['moderate_agents'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_moderate_agents', $misc->make_db_unsafe($recordSet->fields['controlpanel_moderate_agents']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_moderate_agents'])) . '</td>';
         $display .= '<td>' . $lang['moderate_agents_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['allow_agent_signup'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_allow_agent_signup', $misc->make_db_unsafe($recordSet->fields['controlpanel_allow_agent_signup']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_allow_agent_signup'])) . '</td>';
         $display .= '<td>' . $lang['allow_agent_signup_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_active'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_active', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_active']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_active'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_active_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_admin'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_admin', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_admin']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_admin'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_admin_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_edit_all_users'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_edit_all_users', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_all_users']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_all_users'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_edit_all_users_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_edit_all_listings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_edit_all_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_all_listings']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_all_listings'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_edit_all_listings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_feature'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_feature', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_feature']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_feature'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_feature_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_moderate'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_moderate', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_moderate']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_moderate'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_moderate_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_logview'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_logview', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_logview']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_logview'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_logview_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_edit_site_config'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_edit_site_config', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_site_config']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_site_config'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_edit_site_config_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_edit_member_template'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_edit_member_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_member_template']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_member_template'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_edit_member_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_edit_agent_template'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_edit_agent_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_agent_template']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_agent_template'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_edit_agent_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_edit_listing_template'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_edit_listing_template', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_listing_template']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_edit_listing_template'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_edit_listing_template_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_canExportListings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_can_export_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_can_export_listings']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_can_export_listings'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_canExportListings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_canChangeExpirations'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_canchangeexpirations', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_canchangeexpirations']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_canchangeexpirations'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_canChangeExpirations_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_editpages'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_editpages', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_editpages']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_editpages'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_editpages_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_havevtours'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_havevtours', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_havevtours']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_havevtours'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_havevtours_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['agent_default_havefiles'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_agent_default_havefiles', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_havefiles']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_havefiles'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_havefiles_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['agent_default_num_listings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_agent_default_num_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_num_listings']), false, 4, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_agent_default_num_listings'])) . '</td>';
         $display .= '<td>' . $lang['agent_default_num_listings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset><br />';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_agent_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['users_per_page'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_users_per_page', $misc->make_db_unsafe($recordSet->fields['controlpanel_users_per_page']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_users_per_page'])) . '</td>';
         $display .= '<td>' . $lang['users_per_page_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['admin_show_admin_on_agent_list'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_show_admin_on_agent_list', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_admin_on_agent_list']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_admin_on_agent_list'])) . '</td>';
         $display .= '<td>' . $lang['admin_show_admin_on_agent_list_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab11
         //Start tab12
         $display .= '<div class="tab-page" id="tabPage12">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_listings'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage12" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_listing_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['allow_multiple_pclasses_selection'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_multiple_pclass_selection', $misc->make_db_unsafe($recordSet->fields['controlpanel_multiple_pclass_selection']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_multiple_pclass_selection'])) . '</td>';
         $display .= '<td>' . $lang['allow_multiple_pclasses_selection_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['num_featured_listings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_num_featured_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_num_featured_listings']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_num_featured_listings'])) . '</td>';
         $display .= '<td>' . $lang['num_featured_listings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['use_expiration'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_use_expiration', $misc->make_db_unsafe($recordSet->fields['controlpanel_use_expiration']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_use_expiration'])) . '</td>';
         $display .= '<td>' . $lang['use_expiration_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['days_until_listings_expire'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_days_until_listings_expire', $misc->make_db_unsafe($recordSet->fields['controlpanel_days_until_listings_expire']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_days_until_listings_expire'])) . '</td>';
         $display .= '<td>' . $lang['days_until_listings_expire_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['moderate_listings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_moderate_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_moderate_listings']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_moderate_listings'])) . '</td>';
         $display .= '<td>' . $lang['moderate_listings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['export_listings'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_export_listings', $misc->make_db_unsafe($recordSet->fields['controlpanel_export_listings']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_export_listings'])) . '</td>';
         $display .= '<td>' . $lang['export_listings_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['show_listedby_admin'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_show_listedby_admin', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_listedby_admin']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_listedby_admin'])) . '</td>';
         $display .= '<td>' . $lang['show_listedby_admin_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['show_next_prev_listing_page'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_show_next_prev_listing_page', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_next_prev_listing_page']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_next_prev_listing_page'])) . '</td>';
         $display .= '<td>' . $lang['show_next_prev_listing_page_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['show_notes_field'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_show_notes_field', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_notes_field']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_notes_field'])) . '</td>';
         $display .= '<td>' . $lang['show_notes_field_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['feature_list_separator'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_feature_list_separator', $misc->make_db_unsafe($recordSet->fields['controlpanel_feature_list_separator']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_feature_list_separator'])) . '</td>';
         $display .= '<td>' . $lang['feature_list_separator_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab12
         //Start tab13
         $display .= '<div class="tab-page" id="tabPage13">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_map'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage13" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_heading_map_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['site_config_map_type'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_type', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_type']), false, 35, '', '', '', '', $map_types, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_type'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_type_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['site_config_map_address'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_address', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_address_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['site_config_map_address2'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_address2', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address2']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address2'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_address2_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['site_config_map_address3'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_address3', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address3']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address3'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_address3_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['site_config_map_address4'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_address4', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address4']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_address4'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_address4_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['site_config_map_city'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_city', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_city']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_city'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_city_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['site_config_map_state'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_state', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_state']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_state'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_state_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td><strong>' . $lang['site_config_map_zip'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_zip', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_zip']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_zip'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_zip_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td><strong>' . $lang['site_config_map_country'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_map_country', $misc->make_db_unsafe($recordSet->fields['controlpanel_map_country']), false, 35, '', '', '', '', $listing_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_map_country'])) . '</td>';
         $display .= '<td>' . $lang['site_config_map_country_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab13
         //Start tab14
         $display .= '<div class="tab-page" id="tabPage14">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_vcards'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage14" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['site_config_vcard_settings'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_phone'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_phone', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_phone']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_phone'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_phone_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_fax'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_fax', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_fax']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_fax'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_fax_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_mobile'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_mobile', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_mobile']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_mobile'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_mobile_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_address'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_address', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_address']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_address'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_address_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_city'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_city', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_city']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_city'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_city_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_state'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_state', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_state']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_state'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_state_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_zip'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_zip', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_zip']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_zip'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_zip_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_country'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_country', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_country']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_country'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_country_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_notes'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_notes', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_notes']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_notes'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_notes_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['site_config_vcard_url'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_vcard_url', $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_utl']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_vcard_url'])) . '</td>';
         $display .= '<td>' . $lang['site_config_vcard_url_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab14
         //Start tab15
         $display .= '<div class="tab-page" id="tabPage15">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_rss'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage15" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['rss_config'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['rss_title_featured'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_rss_title_featured', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_title_featured']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_title_featured'])) . '</td>';
         $display .= '<td>' . $lang['rss_title_featured_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['rss_desc_featured'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_rss_desc_featured', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_desc_featured']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_desc_featured'])) . '</td>';
         $display .= '<td>' . $lang['rss_desc_featured_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['rss_listingdesc_featured'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_rss_listingdesc_featured', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_listingdesc_featured']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_listingdesc_featured'])) . '</td>';
         $display .= '<td>' . $lang['rss_listingdesc_featured_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['rss_limit_featured'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_rss_limit_featured', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_limit_featured']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_limit_featured'])) . '</td>';
         $display .= '<td>' . $lang['rss_limit_featured_desc'] . '</td>';
         $display .= '</tr>';
         //Last modified RSS Feed
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['rss_title_lastmodified'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_rss_title_lastmodified', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_title_lastmodified']), false, 35, '', '', '', '', $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_title_lastmodified'])) . '</td>';
         $display .= '<td>' . $lang['rss_title_lastmodified_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['rss_desc_lastmodified'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_rss_desc_lastmodified', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_desc_lastmodified']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_desc_lastmodified'])) . '</td>';
         $display .= '<td>' . $lang['rss_desc_lastmodified_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['rss_listingdesc_lastmodified'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_rss_listingdesc_lastmodified', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_listingdesc_lastmodified']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_listingdesc_lastmodified'])) . '</td>';
         $display .= '<td>' . $lang['rss_listingdesc_lastmodified_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="100"><strong>' . $lang['rss_limit_lastmodified'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('text', 'controlpanel_rss_limit_lastmodified', $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_limit_lastmodified']), false, 7, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_rss_limit_lastmodified'])) . '</td>';
         $display .= '<td>' . $lang['rss_limit_lastmodified_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab15
         //Start tab16
         $display .= '<div class="tab-page" id="tabPage16">';
         $display .= '<h2 class="tab">' . $lang['site_config_tab_help'] . '</h2>';
         $display .= '<script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage16" ) );</script>';
         $display .= '<fieldset>';
         $display .= '<legend><b>' . $lang['help_config'] . '</b></legend>';
         $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['use_help_links'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('select', 'controlpanel_use_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_use_help_link']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['controlpanel_use_help_link'])) . '</td>';
         $display .= '<td>' . $lang['use_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_main_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_main_admin_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_main_admin_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_main_admin_help_link'])) . '</td>';
         $display .= '<td>' . $lang['main_admin_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_configure_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_configure_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_configure_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_configure_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_configure_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_add_listing_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_add_listing_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_add_listing_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_add_listing_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_add_listing_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listing_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listing_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listing_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_modify_listing_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_modify_listing_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_modify_listing_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_modify_listing_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_modify_listing_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_user_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_user_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_user_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_user_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_user_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_user_manager_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_user_manager_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_user_manager_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_user_manager_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_user_manager_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_page_editor_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_page_editor_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_page_editor_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_page_editor_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_page_editor_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listing_images_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listing_images_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_images_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_images_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listing_images_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_vtour_images_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_vtour_images_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_vtour_images_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_vtour_images_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_vtour_images_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listing_files_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listing_files_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_files_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_files_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listing_files_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_agent_template_add_field_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_agent_template_add_field_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_agent_template_add_field_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_agent_template_add_field_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_agent_template_add_field_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_agent_template_field_order_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_agent_template_field_order_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_agent_template_field_order_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_agent_template_field_order_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_agent_template_field_order_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_member_template_add_field_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_member_template_add_field_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_member_template_add_field_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_member_template_add_field_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_member_template_add_field_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_member_template_field_order_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_member_template_field_order_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_member_template_field_order_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_member_template_field_order_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_member_template_field_order_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listing_template_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listing_template_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listing_template_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listing_template_add_field_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listing_template_add_field_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_add_field_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_add_field_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listing_template_add_field_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listings_template_field_order_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listings_template_field_order_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listings_template_field_order_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listings_template_field_order_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listings_template_field_order_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listing_template_search_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listing_template_search_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_search_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_search_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listing_template_search_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_edit_listing_template_search_results_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_edit_listing_template_search_results_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_search_results_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_edit_listing_template_search_results_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_edit_listing_template_search_results_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_show_property_classes_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_show_property_classes_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_show_property_classes_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_show_property_classes_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_show_property_classes_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_view_log_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_view_log_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_view_log_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_view_log_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_view_log_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_user_template_member_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_user_template_member_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_user_template_member_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_user_template_member_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_user_template_member_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_user_template_agent_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_user_template_agent_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_user_template_agent_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_user_template_agent_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_user_template_agent_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_modify_property_class_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_modify_property_class_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_modify_property_class_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_modify_property_class_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_modify_property_class_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_insert_property_class_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_insert_property_class_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_insert_property_class_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_insert_property_class_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_insert_property_class_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_addon_transparentmaps_admin_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_addon_transparentmaps_admin_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentmaps_admin_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentmaps_admin_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_addon_transparentmaps_admin_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_addon_transparentmaps_geocode_all_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_addon_transparentmaps_geocode_all_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentmaps_geocode_all_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentmaps_geocode_all_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_addon_transparentmaps_geocode_all_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_addon_transparentRETS_config_server_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_addon_transparentRETS_config_server_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentRETS_config_server_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentRETS_config_server_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_addon_transparentRETS_config_server_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_addon_transparentRETS_config_imports_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_addon_transparentRETS_config_imports_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentRETS_config_imports_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_transparentRETS_config_imports_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_addon_transparentRETS_config_imports_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_addon_IDXManager_config_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_addon_IDXManager_config_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_IDXManager_config_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_IDXManager_config_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_addon_IDXManager_config_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade2>';
         $display .= '<td width="130"><strong>' . $lang['admin_addon_IDXManager_classmanager_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_addon_IDXManager_classmanager_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_IDXManager_classmanager_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_IDXManager_classmanager_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_addon_IDXManager_classmanager_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '<tr class=tdshade1>';
         $display .= '<td width="130"><strong>' . $lang['admin_addon_csvloader_admin_help_link'] . '</strong></td>';
         $display .= '<td>' . $formGen->createformitem('textarea', 'controlpanel_addon_csvloader_admin_help_link', $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_csvloader_admin_help_link']), false, 35, '', '', 5, 35, $agent_field_name_options, $misc->make_db_unsafe($recordSet->fields['controlpanel_addon_csvloader_admin_help_link'])) . '</td>';
         $display .= '<td>' . $lang['admin_addon_csvloader_admin_help_link_desc'] . '</td>';
         $display .= '</tr>';
         $display .= '</table>';
         $display .= '</fieldset>';
         $display .= '</div>';
         //End tab15
         //End tabbed page
         $display .= '</div>';
         // END OF SITE CONFIGURATOR
         $display .= '<table width="99%" align="center"><tr><td align="center">';
         if ($config["demo_mode"] != 1 || $_SESSION['admin_privs'] == 'yes') {
             $display .= $formGen->createformitem('submit', '', $lang['save_changes']);
         } else {
             $display .= $lang['demo_mode_no_changes'];
         }
         $display .= '</td></tr></table>';
         $display .= $formGen->endform();
     } else {
         $display .= '<div class="error_text">' . $lang['access_denied'] . '</div>';
     }
     return $display;
 }
示例#14
0
 function show_users($filter = '', $lookup_field = '', $lookup_value = '')
 {
     global $conn, $config, $lang;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     // Verify User is an Admin
     $security = login::loginCheck('edit_all_users', true);
     $display = '';
     $filter_sql = '';
     if ($filter == 'agents') {
         $filter_sql = " WHERE userdb_is_agent = 'yes'";
     } elseif ($filter == 'members') {
         $filter_sql = " WHERE userdb_is_agent = 'no' AND userdb_is_admin = 'no'";
     } elseif ($filter == 'admins') {
         $filter_sql = " WHERE userdb_is_admin = 'yes'";
     }
     if ($security === true) {
         $sql = "SELECT * FROM " . $config['table_prefix'] . "userdb {$filter_sql} ORDER BY userdb_id ";
         $recordSet = $conn->Execute($sql);
         if ($recordSet === false) {
             $misc->log_error($sql);
         }
         $num_rows = $recordSet->RecordCount();
         if (!isset($_GET['cur_page'])) {
             $_GET['cur_page'] = 0;
         }
         $display .= '<center>' . $misc->next_prev($num_rows, intval($_GET['cur_page'])) . '</center>';
         // put in the next/previous stuff
         // build the string to select a certain number of users per page
         $limit_str = intval($_GET['cur_page']) * $config['listings_per_page'];
         $recordSet = $conn->SelectLimit($sql, $config['listings_per_page'], $limit_str);
         if ($recordSet === false) {
             $misc->log_error($sql);
         }
         $count = 0;
         // $display .= "<br /><br />";
         while (!$recordSet->EOF) {
             // alternate the colors
             if ($count == 0) {
                 $count = $count + 1;
             } else {
                 $count = 0;
             }
             // strip slashes so input appears correctly
             $edit_ID = $recordSet->fields['userdb_id'];
             $edit_user_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_name']);
             $edit_user_first_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_first_name']);
             $edit_user_last_name = $misc->make_db_unsafe($recordSet->fields['userdb_user_last_name']);
             $edit_emailAddress = $misc->make_db_unsafe($recordSet->fields['userdb_emailaddress']);
             $edit_active = $recordSet->fields['userdb_active'];
             $edit_isAgent = $recordSet->fields['userdb_is_agent'];
             $edit_isAdmin = $recordSet->fields['userdb_is_admin'];
             $edit_canEditSiteConfig = $recordSet->fields['userdb_can_edit_site_config'];
             $edit_canEditMemberTemplate = $recordSet->fields['userdb_can_edit_member_template'];
             $edit_canEditAgentTemplate = $recordSet->fields['userdb_can_edit_agent_template'];
             $edit_canEditListingTemplate = $recordSet->fields['userdb_can_edit_listing_template'];
             $edit_canFeatureListings = $recordSet->fields['userdb_can_feature_listings'];
             $edit_canViewLogs = $recordSet->fields['userdb_can_view_logs'];
             $edit_canModerate = $recordSet->fields['userdb_can_moderate'];
             $edit_can_have_vtours = $recordSet->fields['userdb_can_have_vtours'];
             $edit_can_edit_expiration = $recordSet->fields['userdb_can_edit_expiration'];
             $edit_can_export_listings = $recordSet->fields['userdb_can_export_listings'];
             $edit_canEditAllListings = $recordSet->fields['userdb_can_edit_all_listings'];
             $edit_canEditAllUsers = $recordSet->fields['userdb_can_edit_all_users'];
             $edit_canEditPropertyClasses = $recordSet->fields['userdb_can_edit_property_classes'];
             // Determine user type
             if ($edit_isAgent == 'yes') {
                 $user_type = $lang['user_manager_agent'];
             } elseif ($edit_isAdmin == 'yes') {
                 $user_type = $lang['user_manager_admin'];
             } else {
                 $user_type = $lang['user_manager_member'];
             }
             // Layout Start
             $display .= '<table width="600"  border="0" align="center" cellpadding="0" cellspacing="0">';
             // $display .= '<tbody style="border-width:thin;border-style:solid;border-color:#FFFFFF;">';
             $display .= '<tr bgcolor="#330099">';
             $display .= '<td width="510" colspan="2" style="padding-left:2px">';
             $display .= '<span style="color:#FFFFFF;font-weight:bold;">' . $edit_user_first_name . ' ' . $edit_user_last_name . ' (' . $edit_ID . '): ' . $edit_emailAddress . '</span>';
             $display .= '</td>';
             $display .= '<td width="90" align="right">';
             $display .= '<a href="index.php?action=user_manager&amp;edit=' . $edit_ID . '"><img src="images/' . $config['lang'] . '/user_manager_edit.jpg" alt="' . $lang['user_manager_edit_user'] . '" width="16" height="16"></a>';
             $display .= '<img src="images/blank.gif" alt=" " width="16" height="16">';
             $display .= '<a href="index.php?action=user_manager&amp;delete=' . $edit_ID . '" onclick="return confirmDelete(\'' . $lang['delete_user'] . '\')"><img src="images/' . $config['lang'] . '/user_manager_delete.jpg" alt="' . $lang['user_manager_delete_user'] . '" width="16" height="16"></a>';
             $display .= '</td>';
             $display .= '</tr>';
             $display .= '<tr>';
             $display .= '<td colspan="2"><strong>' . $lang['user_manager_user_name'] . ': ' . $edit_user_name . '</strong></td>';
             $display .= '<td></td>';
             $display .= '</tr>';
             $display .= '<tr>';
             $display .= '<td colspan="2"><strong>' . $lang['user_manager_account_type'] . ': ' . $user_type . '</strong></td>';
             $display .= '<td></td>';
             $display .= '</tr>';
             $display .= '<tr>';
             $display .= '<td colspan="2"><strong>' . $lang['user_manager_active'] . ': ' . $edit_active . '</strong></td>';
             $display .= '<td></td>';
             $display .= '</tr>';
             if ($edit_isAgent == 'yes') {
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_admin'] . ': ' . $edit_isAdmin . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_vtour'] . ': ' . $edit_can_have_vtours . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_featured_listings'] . ': ' . $edit_canFeatureListings . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_edit_expiration'] . ': ' . $edit_can_edit_expiration . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_export_listings'] . ': ' . $edit_can_export_listings . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_edit_all_listings'] . ': ' . $edit_canEditAllListings . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_edit_all_users'] . ': ' . $edit_canEditAllUsers . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_edit_property_classes'] . ': ' . $edit_canEditPropertyClasses . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_moderate'] . ': ' . $edit_canModerate . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_view_logs'] . ': ' . $edit_canViewLogs . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_member_template_access'] . ': ' . $edit_canEditMemberTemplate . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_agent_template_access'] . ': ' . $edit_canEditAgentTemplate . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_listing_template_access'] . ': ' . $edit_canEditListingTemplate . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
                 $display .= '<tr>';
                 $display .= '<td colspan="2"><strong>' . $lang['user_manager_site_config_access'] . ': ' . $edit_canEditSiteConfig . '</strong></td>';
                 $display .= '<td></td>';
                 $display .= '</tr>';
             }
             // $display .= '</tbody>';
             $display .= '</table>';
             $recordSet->MoveNext();
         }
         // end while
     }
     // End Verify User isAdmin
     return $display;
 }
示例#15
0
/**
 * generate_admin_config_page()
 * This generates the html form for configuring the googlemap addon via the admin page.
 * @return The html form for configuring the googlemap addon
 */
function generate_admin_config_page()
{
    global $conn, $lang, $config;
    $security = login::loginCheck('Admin', true);
    $display = '';
    if ($security === true) {
        $api_version[1] = 1;
        $api_version[2] = 2;
        $map_type[1] = 'NORMAL_MAP';
        $map_type[2] = 'SATELLITE_MAP';
        $map_type[3] = 'HYBRID_MAP';
        $map_control[1] = 'none';
        $map_control[2] = 'LargeMapControl';
        $map_control[3] = 'SmallMapControl';
        $map_control[4] = 'SmallZoomControl';
        $map_anchor[1] = 'TOP_LEFT';
        $map_anchor[2] = 'TOP_RIGHT';
        $map_anchor[3] = 'BOTTOM_LEFT';
        $map_anchor[4] = 'BOTTOM_RIGHT';
        $type_control[1] = 'none';
        $type_control[2] = 'MapTypeControl';
        $scale_control[1] = 'none';
        $scale_control[2] = 'ScaleControl';
        $overview_control[1] = 'none';
        $overview_control[2] = 'OverviewMapControl';
        // Open Connection to the Control Panel Table
        require_once $config['basepath'] . '/include/misc.inc.php';
        $misc = new misc();
        // Include the Form Generation Class
        include_once $config['basepath'] . '/include/class/form_generation.inc.php';
        $formGen = new formGeneration();
        // Default Options
        $yes_no[0] = 'No';
        $yes_no[1] = 'Yes';
        $asc_desc['ASC'] = 'ASC';
        $asc_desc['DESC'] = 'DESC';
        // Save any Post Data
        if (isset($_POST['api_version'])) {
            // Update addon table
            $sql = 'UPDATE ' . $config['table_prefix_no_lang'] . 'addon_googlemap SET ';
            $sql_part = '';
            foreach ($_POST as $field => $value) {
                if (is_array($value)) {
                    $value2 = '';
                    foreach ($value as $f) {
                        if ($value2 == '') {
                            $value2 = "{$f}";
                        } else {
                            $value2 .= ",{$f}";
                        }
                    }
                    $value2 = $misc->make_db_safe($value2);
                    if ($sql_part == '') {
                        $sql_part = "{$field} = {$value2}";
                    } else {
                        $sql_part .= " , {$field} = {$value2}";
                    }
                } else {
                    $value = $misc->make_db_safe($value);
                    if ($sql_part == '') {
                        $sql_part = "{$field} = {$value}";
                    } else {
                        $sql_part .= " , {$field} = {$value}";
                    }
                }
            }
            $sql .= $sql_part;
            $recordSet = $conn->Execute($sql);
            if (!$recordSet) {
                $misc->log_error($sql);
            }
            $display .= '<br><b>' . $lang['configuration_saved'] . '</b><br>';
        }
        $sql = 'SELECT * from ' . $config["table_prefix_no_lang"] . 'addon_googlemap';
        $recordSet = $conn->Execute($sql);
        if (!$recordSet) {
            $misc->log_error($sql);
        }
        $display .= '<h2>Google Maps Addon Configuration. </h2><br /><br />';
        $display .= $formGen->startform('index.php?&amp;action=addon_googlemap_configure');
        // Start Map Options Section
        $display .= '<fieldset>';
        $display .= '<legend><b>Map Options</b></legend>';
        $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
        $display .= '<tr class=tdshade2>';
        $display .= '<td width="130"><strong>API Version</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'api_version', $misc->make_db_unsafe($recordSet->fields['api_version']), false, 35, '', '', '', '', $api_version, $misc->make_db_unsafe($recordSet->fields['api_version'])) . '</td>';
        $display .= '<td>Version of the Google Maps API to use.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>API Key</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'api_key', $misc->make_db_unsafe($recordSet->fields['api_key']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['api_key'])) . '</td>';
        $display .= '<td>Google API Key for your site (required).</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Open map in pop-up window</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'popup', $misc->make_db_unsafe($recordSet->fields['popup']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['popup'])) . '</td>';
        $display .= '<td>Yes to open map in a separate window, No to load map in the {content} tag.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Search Distance</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'search_dist', $misc->make_db_unsafe($recordSet->fields['search_dist']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['search_dist'])) . '</td>';
        $display .= '<td>Search distance (in miles) for properties.  This is only an approximation, based on the latitude and longitude values in the listings.  Note that this won\'t work for listings without latitude or longitude set.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Initial Zoom Level</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'initial_zoom_level', $misc->make_db_unsafe($recordSet->fields['initial_zoom_level']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['initial_zoom_level'])) . '</td>';
        $display .= '<td>Enter the initial zoom level for the map.  Note that with API version 1, lower numbers are higher zoom levels, while with version 2 higher numbers are higher zoom levels.  A good starting number would be 2 for API version 1 and 15 for API version 2.</td>';
        $display .= '</tr>';
        $display .= '<td><strong>Select the initial map type to display</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'map_type', $misc->make_db_unsafe($recordSet->fields['map_type']), false, 35, '', '', '', '', $map_type, $misc->make_db_unsafe($recordSet->fields['map_type'])) . '</td>';
        $display .= '<td>NORMAL_MAP is the regular google map.  SATELLITE_MAP is satellite imagery (not available at all zoom levels).  HYBRID_MAP is the satellite imagery with a partial map overlay.  Note that these can be selected by the user via the map type control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Map Height</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'map_height', $misc->make_db_unsafe($recordSet->fields['map_height']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['map_height'])) . '</td>';
        $display .= '<td>Enter the default map height.  You may use standard html/css designations: e.g., (500px, 100%, etc...)</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Map Width</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'map_width', $misc->make_db_unsafe($recordSet->fields['map_width']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['map_width'])) . '</td>';
        $display .= '<td>Enter the default map width.  You may use standard html/css designations: e.g., (500px, 100%, etc...)</td>';
        $display .= '</tr>';
        $display .= '</table>';
        $display .= '</fieldset><br />';
        // Start Icon Options Section
        $display .= '<fieldset>';
        $display .= '<legend><b>Listing Information Bubble Options</b></legend>';
        $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
        // *** NOT IMPLEMENTED YET ***
        //		$display .= '<tr class=tdshade2>';
        //		$display .= '<td width="130"><strong>Info Bubble Template</strong></td>';
        //		$display .= '<td>' . $formGen->createformitem('text', 'info_bubble_template', $misc->make_db_unsafe($recordSet->fields['info_bubble_template']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['info_bubble_template'])) . '</td>';
        //		$display .= '<td>Template to use for the pop-up information bubble for each listing on the map.</td>';
        //		$display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Icon Image</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_image', $misc->make_db_unsafe($recordSet->fields['icon_image']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_image'])) . '</td>';
        $display .= '<td>Image to use for the listing property icon.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Secondary Icon Image</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_image_other', $misc->make_db_unsafe($recordSet->fields['icon_image_other']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_image_other'])) . '</td>';
        $display .= '<td>Image to use for all the other property icons.  It is assumed that these two icons are the same size.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Icon Width</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_iconSize_x', $misc->make_db_unsafe($recordSet->fields['icon_iconSize_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_iconSize_x'])) . '</td>';
        $display .= '<td>Width of the icon file (in pixels).</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Icon Height</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_iconSize_y', $misc->make_db_unsafe($recordSet->fields['icon_iconSize_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_iconSize_y'])) . '</td>';
        $display .= '<td>Width of the icon file (in pixels).</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Icon Shadow Image</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_shadow', $misc->make_db_unsafe($recordSet->fields['icon_shadow']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_shadow'])) . '</td>';
        $display .= '<td>Image to use for the property icon shadows.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Shadow Width</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_shadowSize_x', $misc->make_db_unsafe($recordSet->fields['icon_shadowSize_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_shadowSize_x'])) . '</td>';
        $display .= '<td>Width of the icon shadow file (in pixels).</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Shadow Height</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_shadowSize_y', $misc->make_db_unsafe($recordSet->fields['icon_shadowSize_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_shadowSize_y'])) . '</td>';
        $display .= '<td>Width of the icon shadow file (in pixels).</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Icon Anchor X</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_iconAnchor_x', $misc->make_db_unsafe($recordSet->fields['icon_iconAnchor_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_iconAnchor_x'])) . '</td>';
        $display .= '<td>The x coordinate relative to the top left corner of the icon image at which this icon is anchored to the map.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Icon Anchor Y</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_iconAnchor_y', $misc->make_db_unsafe($recordSet->fields['icon_iconAnchor_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_iconAnchor_y'])) . '</td>';
        $display .= '<td>The y coordinate relative to the top left corner of the icon image at which this icon is anchored to the map.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Info Window Anchor X</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_infoWindowAnchor_x', $misc->make_db_unsafe($recordSet->fields['icon_infoWindowAnchor_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_infoWindowAnchor_x'])) . '</td>';
        $display .= '<td>The x coordinate relative to the top left corner of the icon image at which this icon is anchored to the map.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Info Window Anchor Y</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'icon_infoWindowAnchor_y', $misc->make_db_unsafe($recordSet->fields['icon_infoWindowAnchor_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['icon_infoWindowAnchor_y'])) . '</td>';
        $display .= '<td>The y coordinate relative to the top left corner of the icon image at which this icon is anchored to the map.</td>';
        $display .= '</tr>';
        $display .= '</table>';
        $display .= '</fieldset><br />';
        // Start Control Options Section
        $display .= '<fieldset>';
        $display .= '<legend><b>Map Control Options</b></legend>';
        $display .= '<table cellspacing="0" cellpadding="3" width="99%" border="0">';
        $display .= '<tr class=tdshade2>';
        $display .= '<td width="130"><strong>Map Control</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'map_control_type', $misc->make_db_unsafe($recordSet->fields['map_control_type']), false, 35, '', '', '', '', $map_control, $misc->make_db_unsafe($recordSet->fields['map_control_type'])) . '</td>';
        $display .= '<td>Map control to use.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Map Control Anchor</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'map_control_anchor', $misc->make_db_unsafe($recordSet->fields['map_control_anchor']), false, 35, '', '', '', '', $map_anchor, $misc->make_db_unsafe($recordSet->fields['map_control_anchor'])) . '</td>';
        $display .= '<td>Location on the map to display this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Map Control Padding X</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'map_control_padding_x', $misc->make_db_unsafe($recordSet->fields['map_control_padding_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['map_control_padding_x'])) . '</td>';
        $display .= '<td>Horizontal padding around this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Map Control Padding Y</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'map_control_padding_y', $misc->make_db_unsafe($recordSet->fields['map_control_padding_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['map_control_padding_y'])) . '</td>';
        $display .= '<td>Vertical padding around this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td width="130"><strong>Map Type Control</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'type_control', $misc->make_db_unsafe($recordSet->fields['type_control']), false, 35, '', '', '', '', $type_control, $misc->make_db_unsafe($recordSet->fields['type_control'])) . '</td>';
        $display .= '<td>Map type control to use.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Map Type Control Anchor</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'type_control_anchor', $misc->make_db_unsafe($recordSet->fields['type_control_anchor']), false, 35, '', '', '', '', $map_anchor, $misc->make_db_unsafe($recordSet->fields['type_control_anchor'])) . '</td>';
        $display .= '<td>Location on the map to display this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Map Type Control Padding X</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'type_padding_x', $misc->make_db_unsafe($recordSet->fields['type_padding_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['type_padding_x'])) . '</td>';
        $display .= '<td>Horizontal padding around this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Map Type Control Padding Y</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'type_padding_y', $misc->make_db_unsafe($recordSet->fields['type_padding_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['type_padding_y'])) . '</td>';
        $display .= '<td>Vertical padding around this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td width="130"><strong>Scale Control</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'scale_control', $misc->make_db_unsafe($recordSet->fields['scale_control']), false, 35, '', '', '', '', $scale_control, $misc->make_db_unsafe($recordSet->fields['scale_control'])) . '</td>';
        $display .= '<td>Map scale control to use.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Scale Control Anchor</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'scale_control_anchor', $misc->make_db_unsafe($recordSet->fields['scale_control_anchor']), false, 35, '', '', '', '', $map_anchor, $misc->make_db_unsafe($recordSet->fields['scale_control_anchor'])) . '</td>';
        $display .= '<td>Location on the map to display this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Scale Control Padding X</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'scale_padding_x', $misc->make_db_unsafe($recordSet->fields['scale_padding_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['scale_padding_x'])) . '</td>';
        $display .= '<td>Horizontal padding around this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Scale Control Padding Y</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'scale_padding_y', $misc->make_db_unsafe($recordSet->fields['scale_padding_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['scale_padding_y'])) . '</td>';
        $display .= '<td>Vertical padding around this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td width="130"><strong>Overview Control</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'overview_control', $misc->make_db_unsafe($recordSet->fields['overview_control']), false, 35, '', '', '', '', $overview_control, $misc->make_db_unsafe($recordSet->fields['overview_control'])) . '</td>';
        $display .= '<td>Map overview control.  This is not available with API Version 1.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Overview Control Anchor</strong></td>';
        $display .= '<td>' . $formGen->createformitem('select', 'overview_control_anchor', $misc->make_db_unsafe($recordSet->fields['overview_control_anchor']), false, 35, '', '', '', '', $map_anchor, $misc->make_db_unsafe($recordSet->fields['overview_control_anchor'])) . '</td>';
        $display .= '<td>Location on the map to display this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade2>';
        $display .= '<td><strong>Overview Control Padding X</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'overview_padding_x', $misc->make_db_unsafe($recordSet->fields['overview_padding_x']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['overview_padding_x'])) . '</td>';
        $display .= '<td>Horizontal padding around this control.</td>';
        $display .= '</tr>';
        $display .= '<tr class=tdshade1>';
        $display .= '<td><strong>Overview Control Padding Y</strong></td>';
        $display .= '<td>' . $formGen->createformitem('text', 'overview_padding_y', $misc->make_db_unsafe($recordSet->fields['overview_padding_y']), false, 35, '', '', '', '', $yes_no, $misc->make_db_unsafe($recordSet->fields['overview_padding_y'])) . '</td>';
        $display .= '<td>Vertical padding around this control.</td>';
        $display .= '</tr>';
        $display .= '</table>';
        $display .= '</fieldset><br />';
        $display .= '<table width="99%" align="right"><tr><td align="right">' . $formGen->createformitem('submit', '', 'Save Changes') . '</td></tr></table>';
        $display .= $formGen->endform();
    } else {
        $display .= '<div class="error_text">' . $lang['access_denied'] . '</div>';
    }
    return $display;
}
 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;
 }