setcookie('sco_app[rv_mode]', $_GET['v'], mktime(0, 0, 0, date('m'), date('d'), date('Y') + 1), '/', $cookie_domain); if ($_GET['v'] == 'g') { $rv_mode = 'gallery_view'; } } $cell_css_classes = array(); for ($i = 0; isset($user_ids[$i]); ++$i) { if (isset($_list_of_online_members[$user_ids[$i]])) { $cell_css_classes[$i] = 'is_online'; } } require _BASEPATH_ . '/includes/classes/user_cache.class.php'; $user_cache = new user_cache(); $temp = $user_cache->get_cache_array($user_ids, 'result_user', $inject_by_uid); if (!empty($temp)) { $output['results'] = smart_table($temp, 5, $rv_mode, $cell_css_classes); $output['pager2'] = pager($output['totalrows'], $o, $r); } else { unset($output['totalrows']); } unset($user_cache, $temp); if (!$skip_cache) { // set $_GET for the pager. $_GET = array('search' => $output['search_md5'], 'v' => !empty($_GET['v']) ? $_GET['v'] : 'l'); } } else { unset($output['totalrows']); } $output['lang_253'] = sanitize_and_format($GLOBALS['_lang'][253], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]); $output['lang_254'] = sanitize_and_format($GLOBALS['_lang'][254], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]); $tpl->set_file('content', 'search.html');
/** * @deprecated 3.4 */ function awpcp_display_ads($where, $byl, $hidepager, $grouporderby, $adorcat, $before_content = '') { _deprecated_function(__FUNCTION__, '3.4', 'awpcp_display_listings'); global $wpdb; global $awpcp_plugin_path; global $hasregionsmodule; $output = ''; $awpcp_browsecats_pageid = awpcp_get_page_id_by_ref('browse-categories-page-name'); $browseadspageid = awpcp_get_page_id_by_ref('browse-ads-page-name'); $searchadspageid = awpcp_get_page_id_by_ref('search-ads-page-name'); // filters to provide alternative method of storing custom layouts (e.g. can be outside of this plugin's directory) if (has_action('awpcp_browse_ads_template_action') || has_filter('awpcp_browse_ads_template_filter')) { do_action('awpcp_browse_ads_template_action'); $output = apply_filters('awpcp_browse_ads_template_filter'); return; } else { if (file_exists("{$awpcp_plugin_path}/awpcp_display_ads_my_layout.php") && get_awpcp_option('activatemylayoutdisplayads')) { include "{$awpcp_plugin_path}/awpcp_display_ads_my_layout.php"; } else { $output .= "<div id=\"classiwrapper\">"; $uiwelcome = stripslashes_deep(get_awpcp_option('uiwelcome')); $output .= apply_filters('awpcp-content-before-listings-page', ''); $output .= "<div class=\"uiwelcome\">{$uiwelcome}</div>"; $output .= awpcp_menu_items(); if ($hasregionsmodule == 1) { // Do not show Region Control form when showing Search Ads page // search result. Changing the current location will redirect the user // to the form instead of a filterd version of the form and that's confusing if (is_page(awpcp_get_page_id_by_ref('search-ads-page-name')) && isset($_POST['a']) && $_POST['a'] == 'dosearch') { // do nothing } else { $output .= awpcp_region_control_selector(); } } $output .= $before_content; $tbl_ads = $wpdb->prefix . "awpcp_ads"; $from = "{$tbl_ads}"; $ads_exist = ads_exist(); if (!$ads_exist) { $showcategories = "<p style=\"padding:10px\">"; $showcategories .= __("There are currently no ads in the system", "AWPCP"); $showcategories .= "</p>"; $pager1 = ''; $pager2 = ''; } else { $awpcp_image_display_list = array(); if ($adorcat == 'cat') { $tpname = get_permalink($awpcp_browsecats_pageid); } elseif ($adorcat == 'search') { $tpname = get_permalink($searchadspageid); } elseif (preg_match('/^custom:/', $adorcat)) { $tpname = str_replace('custom:', '', $adorcat); } else { $tpname = get_permalink($browseadspageid); } $results = get_awpcp_option('adresultsperpage', 10); $results = absint(awpcp_request_param('results', $results)); $offset = absint(awpcp_request_param('offset', 0)); if ($results === 0) { $results = 10; } $args = array('order' => AWPCP_Ad::get_order_conditions($grouporderby), 'offset' => $offset, 'limit' => $results); $ads = AWPCP_Ad::get_enabled_ads($args, array($where)); // get_where_conditions() is called from get_enabled_ads(), we need the // WHERE conditions here to pass them to create_pager() $where = AWPCP_Ad::get_where_conditions(array($where)); if (!isset($hidepager) || empty($hidepager)) { //Unset the page and action here...these do the wrong thing on display ad unset($_GET['page_id']); unset($_POST['page_id']); //unset($params['page_id']); $pager1 = create_pager($from, join(' AND ', $where), $offset, $results, $tpname); $pager2 = create_pager($from, join(' AND ', $where), $offset, $results, $tpname); } else { $pager1 = ''; $pager2 = ''; } $items = awpcp_render_listings_items($ads, 'listings'); $opentable = ""; $closetable = ""; if (empty($ads)) { $showcategories = "<p style=\"padding:20px;\">"; $showcategories .= __("There were no ads found", "AWPCP"); $showcategories .= "</p>"; $pager1 = ''; $pager2 = ''; } else { $showcategories = smart_table($items, intval($results / $results), $opentable, $closetable); } } $show_category_id = absint(awpcp_request_param('category_id')); if (!isset($url_browsecatselect) || empty($url_browsecatselect)) { $url_browsecatselect = get_permalink($awpcp_browsecats_pageid); } if ($ads_exist) { $category_id = (int) awpcp_request_param('category_id', -1); $category_id = $category_id === -1 ? (int) get_query_var('cid') : $category_id; $output .= "<div class=\"changecategoryselect\"><form method=\"post\" action=\"{$url_browsecatselect}\">"; $output .= '<div class="awpcp-category-dropdown-container">'; $dropdown = new AWPCP_CategoriesDropdown(); $output .= $dropdown->render(array('context' => 'search', 'name' => 'category_id', 'selected' => $category_id)); $output .= '</div>'; $output .= "<input type=\"hidden\" name=\"a\" value=\"browsecat\" /> <input class=\"button\" type=\"submit\" value=\""; $output .= __("Change Category", "AWPCP"); $output .= "\" /></form></div>"; $output .= "<div class=\"pager\">{$pager1}</div><div class=\"fixfloat\"></div>"; $output .= "<div id='awpcpcatname' class=\"fixfloat\">"; if ($category_id > 0) { $output .= "<h3>" . __("Category: ", "AWPCP") . get_adcatname($category_id) . "</h3>"; } $output .= "</div>"; } $output .= apply_filters('awpcp-display-ads-before-list', ''); $output .= "{$showcategories}"; if ($ads_exist) { $output .= " <div class=\"pager\">{$pager2}</div>"; } $output .= apply_filters('awpcp-content-after-listings-page', ''); $output .= "</div>"; } } return $output; }
function search_alerts() { global $dbtable_prefix, $tplvars; $skin = get_default_skin_dir(); require_once _BASEPATH_ . '/includes/search_functions.inc.php'; require_once _BASEPATH_ . '/includes/access_levels.inc.php'; // require_once _BASEPATH_.'/includes/user_functions.inc.php'; $tplvars['tplrelpath'] = _BASEPATH_ . '/skins_site/' . $skin; $config['limit_results'] = 5; $query_strlen = 20000; $query = "SELECT a.`search_id`,a.`fk_user_id`,a.`title`,a.`search`,a.`search_qs`,a.`alert_last_id`,UNIX_TIMESTAMP(a.`alert_last_sent`) as `alert_last_sent`,b.`membership`,c.`_user` as `user`,b.`email` FROM `{$dbtable_prefix}user_searches` a,`" . USER_ACCOUNTS_TABLE . "` b,`{$dbtable_prefix}user_profiles` c WHERE a.`fk_user_id`=b.`" . USER_ACCOUNT_ID . "` AND a.`fk_user_id`=c.`fk_user_id` AND a.`alert`=1"; if (!($res = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } if (mysql_num_rows($res)) { $tpl = new phemplate(_BASEPATH_ . '/skins_site/' . $skin . '/emails/', 'remove_nonjs'); $tpl->set_file('temp', 'search_alert.html'); $tpl->set_var('tplvars', $tplvars); $subject = sprintf($GLOBALS['_lang'][217], _SITENAME_); $subject = sanitize_and_format($subject, TYPE_STRING, $GLOBALS['__field2format'][FIELD_TEXTFIELD]); require_once _BASEPATH_ . '/includes/classes/user_cache.class.php'; $user_cache = new user_cache($skin); $insert = "INSERT INTO `{$dbtable_prefix}queue_email` (`to`,`subject`,`message_body`) VALUES "; $iquery = $insert; $alert_intervals = array(); $now = time(); while ($rsrow = mysql_fetch_assoc($res)) { if (!isset($alert_intervals[$rsrow['fk_user_id']])) { $alert_intervals[$rsrow['fk_user_id']] = get_user_settings($rsrow['fk_user_id'], 'def_user_prefs', 'send_alert_interval') * 86400; } if ((int) $now - (int) $rsrow['alert_last_sent'] >= (int) $alert_intervals[$rsrow['fk_user_id']]) { $output = array(); $rsrow['search'] = unserialize($rsrow['search']); $rsrow['search']['min_user_id'] = $rsrow['alert_last_id']; $user_ids = search_results($rsrow['search'], $rsrow['membership']); if (!empty($user_ids)) { $GLOBALS['_list_of_online_members'] = get_online_ids(); $last_user_id = 0; for ($i = 0; isset($user_ids[$i]); ++$i) { if ($user_ids[$i] > $last_user_id) { $last_user_id = $user_ids[$i]; } } $user_ids = array_slice($user_ids, 0, $config['limit_results']); // last activity only for not online members $temp = array(); $inject_by_uid = array(); for ($i = 0; isset($user_ids[$i]); ++$i) { if (!isset($GLOBALS['_list_of_online_members'][$user_ids[$i]])) { $temp[] = $user_ids[$i]; } else { $inject_by_uid[$user_ids[$i]] = array('last_online' => $GLOBALS['_lang'][153]); } } if (!empty($temp)) { $time = mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y')); $query = "SELECT `" . USER_ACCOUNT_ID . "` as `uid`,UNIX_TIMESTAMP(`last_activity`) as `last_activity` FROM `" . USER_ACCOUNTS_TABLE . "` WHERE `" . USER_ACCOUNT_ID . "` IN ('" . join("','", $temp) . "')"; if (!($res2 = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } while ($rsrow2 = mysql_fetch_assoc($res2)) { $rsrow2['last_activity'] = $time - $rsrow2['last_activity']; if ($rsrow2['last_activity'] < 86400) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][154]); } elseif ($rsrow2['last_activity'] < 172800) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][155]); } elseif ($rsrow2['last_activity'] < 604800) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][156]); } elseif ($rsrow2['last_activity'] < 2419200) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][157]); } else { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][158]); } } } $cell_css_classes = array(); for ($i = 0; isset($user_ids[$i]); ++$i) { if (isset($GLOBALS['_list_of_online_members'][$user_ids[$i]])) { $cell_css_classes[$i] = 'is_online'; } } $output['results'] = smart_table($user_cache->get_cache_array($user_ids, 'result_user', $inject_by_uid), 5, 'list_view', $cell_css_classes); $output['title'] = sanitize_and_format($rsrow['title'], TYPE_STRING, $GLOBALS['__field2format'][TEXT_DB2DISPLAY]); $output['search_qs'] = $rsrow['search_qs']; $output['user'] = $rsrow['user']; $tpl->set_var('output', $output); $message_body = $tpl->process('', 'temp', TPL_LOOP | TPL_OPTLOOP | TPL_OPTIONAL | TPL_FINISH); $message_body = sanitize_and_format($message_body, TYPE_STRING, $GLOBALS['__field2format'][FIELD_TEXTAREA]); if (strlen($iquery) > $query_strlen) { $iquery = substr($iquery, 0, -1); if (!($res2 = @mysql_query($iquery))) { trigger_error(mysql_error(), E_USER_ERROR); } $iquery = $insert; } $iquery .= "('" . $rsrow['email'] . "','{$subject}','{$message_body}'),"; $query = "UPDATE `{$dbtable_prefix}user_searches` SET `alert_last_id`={$last_user_id},`alert_last_sent`=now() WHERE `search_id`=" . $rsrow['search_id']; @mysql_query($query); } } } if ($iquery != $insert) { $iquery = substr($iquery, 0, -1); if (!($res2 = @mysql_query($iquery))) { trigger_error(mysql_error(), E_USER_ERROR); } } } return true; }