protected function _content() { global $dbtable_prefix; global $page_last_modified_time; switch ($this->config['mode']) { case 'new': $query = "SELECT a.`fk_user_id`,UNIX_TIMESTAMP(a.`last_changed`) as `last_changed` FROM `{$dbtable_prefix}user_profiles` a WHERE a.`_photo`<>'' AND a.`del`=0 AND a.`status`=" . STAT_APPROVED . " ORDER BY a.`date_added` DESC"; break; case 'vote': $query = "SELECT a.`fk_user_id`,UNIX_TIMESTAMP(b.`last_changed`) as `last_changed` FROM `{$dbtable_prefix}user_stats` a,`{$dbtable_prefix}user_profiles` b WHERE a.`fk_user_id`=b.`fk_user_id` AND a.`stat`='vote_score' AND b.`_photo`<>'' AND b.`status`=" . STAT_APPROVED . " AND b.`del`=0 ORDER BY a.`value` DESC"; break; case 'views': $query = "SELECT a.`fk_user_id`,UNIX_TIMESTAMP(b.`last_changed`) as `last_changed` FROM `{$dbtable_prefix}user_stats` a,`{$dbtable_prefix}user_profiles` b WHERE a.`fk_user_id`=b.`fk_user_id` AND a.`stat`='total_views' AND b.`_photo`<>'' AND b.`status`=" . STAT_APPROVED . " AND b.`del`=0 ORDER BY a.`value` DESC"; break; case 'comm': $query = "SELECT a.`fk_user_id`,UNIX_TIMESTAMP(b.`last_changed`) as `last_changed` FROM `{$dbtable_prefix}user_stats` a,`{$dbtable_prefix}user_profiles` b WHERE a.`fk_user_id`=b.`fk_user_id` AND a.`stat`='total_comments' AND b.`_photo`<>'' AND b.`status`=" . STAT_APPROVED . " AND b.`del`=0 ORDER BY a.`value` DESC"; break; } $query .= " LIMIT 15"; if (!($res = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } $user_ids = array(); while ($rsrow = mysql_fetch_assoc($res)) { $user_ids[] = $rsrow['fk_user_id']; if ($page_last_modified_time < $rsrow['last_changed']) { $page_last_modified_time = $rsrow['last_changed']; } } if (!empty($user_ids)) { require_once _BASEPATH_ . '/includes/classes/user_cache.class.php'; $user_cache = new user_cache(); $loop = $user_cache->get_cache_tpl($user_ids, 'result_user'); unset($user_cache); if (!empty($loop)) { $loop[0]['class'] = 'first'; $loop = array_slice($loop, 0, $this->config['total']); $this->tpl->set_file('widget.content', 'widgets/members/display.html'); $this->tpl->set_loop('loop', $loop); $this->tpl->process('widget.content', 'widget.content', TPL_LOOP | TPL_OPTLOOP); $this->tpl->drop_loop('loop'); unset($loop); } } }
$query = "SELECT `photo_id`,`photo` FROM `{$dbtable_prefix}user_photos` WHERE `fk_user_id`=" . $output['uid'] . " AND `is_private`=0 AND `status`=" . STAT_APPROVED . " AND `del`=0"; if (!($res = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } if (mysql_num_rows($res)) { while (count($user_photos) < 3 && ($rsrow = mysql_fetch_assoc($res))) { if (is_file(_PHOTOPATH_ . '/t1/' . $rsrow['photo'])) { $user_photos[] = $rsrow; } } $user_photos[0]['class'] = 'first'; $output['num_photos'] = mysql_num_rows($res); } // get the profile require_once _BASEPATH_ . '/includes/classes/user_cache.class.php'; $user_cache = new user_cache(); $tpl->set_file('no_access', 'static/pcat_no_access.html'); $j = 0; foreach ($_pcats as $pcat_id => $pcat) { if ((int) $pcat['access_level'] & (int) $_SESSION[_LICENSE_KEY_]['user']['membership']) { $temp = $user_cache->get_categ($output['uid'], $pcat_id); if (!empty($temp)) { $categs[$j]['content'] = $temp; // if you prefer a custom layout use {profile.categ_1},{profile.categ_2},etc in <skin>/profile.html, // uncomment the line below, remove $tpl->set_loop, // $output['categ_'.$pcat_id]=$temp; ++$j; } } else { // not allowed to view this member info // maybe we should say something here like "upgrade your membership to view this info"...
if (isset($_COOKIE['sco_app']['rv_mode']) && $_COOKIE['sco_app']['rv_mode'] == 'g') { $rv_mode = 'gallery_view'; } elseif (isset($_GET['v']) && ($_GET['v'] == 'g' || $_GET['v'] == 'l')) { 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']); }
File: my_networks.php $Revision$ Software by: DateMill (http://www.datemill.com) Copyright by: DateMill (http://www.datemill.com) Support at: http://www.datemill.com/forum ******************************************************************************* * See the "docs/licenses/etano.txt" file for license. * ******************************************************************************/ require 'includes/common.inc.php'; require _BASEPATH_ . '/includes/user_functions.inc.php'; require _BASEPATH_ . '/includes/network_functions.inc.php'; require _BASEPATH_ . '/skins_site/' . get_my_skin() . '/lang/net.inc.php'; check_login_member('manage_networks'); $tpl = new phemplate(_BASEPATH_ . '/skins_site/' . get_my_skin() . '/', 'remove_nonjs'); require _BASEPATH_ . '/includes/classes/user_cache.class.php'; $user_cache = new user_cache(get_my_skin()); $query = "SELECT `net_id`,`network` FROM `{$dbtable_prefix}networks`"; if (!($res = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } $networks = array(); $i = 0; while ($rsrow = mysql_fetch_assoc($res)) { $rsrow['network'] = sanitize_and_format($rsrow['network'], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]); $net_members = get_network_members($_SESSION[_LICENSE_KEY_]['user']['user_id'], $rsrow['net_id'], 4); if (!empty($net_members)) { $rsrow['members'] = $user_cache->get_cache_tpl($net_members, 'result_user'); } if (!empty($rsrow['members'])) { $rsrow['see_all'] = true; $networks[] = $rsrow;
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; }