public function common($params) { $Register = Register::getInstance(); $output = ''; if (!strpos($params, '{{ users_rating }}')) { return $params; } $Cache = new Cache(); $Cache->lifeTime = 600; if ($Cache->check('pl_users_rating')) { $users = $Cache->read('pl_users_rating'); $users = json_decode($users, true); } else { $users = $this->DB->select('users', DB_ALL, array('order' => '`rating` DESC', 'limit' => $this->limit)); //$users = $this->DB->query($sql); $Cache->write(json_encode($users), 'pl_users_rating', array()); } if (!empty($users)) { foreach ($users as $key => $user) { $link = get_link($user['name'], getProfileUrl($user['id'])); $ava = file_exists(ROOT . '/sys/avatars/' . $user['id'] . '.jpg') ? get_url('/sys/avatars/' . $user['id'] . '.jpg') : get_url('/sys/img/noavatar.png'); $output .= sprintf($this->wrap, $ava, $link, $user['rating'], $user['posts']); } } $output .= '<div class="etopu">' . get_link('Весь рейтинг', '/users/index?order=rating') . '</div>'; return str_replace('{{ users_rating }}', $output, $params); }
$adm = true; } if ($this->ACL->turn(array($this->module, 'delete_comments'), false)) { $moder_panel .= get_link('', '/' . $this->module . '/delete_comment/' . $comment->getId(), array('class' => 'fps-delete', 'onClick' => "return confirm('" . __('Are you sure') . "')")) . ' '; $adm = true; } if ($adm) { $moder_panel = '<a target="_blank" href="https://apps.db.ripe.net/search/query.html?searchtext=' . h($ip) . '" class="fps-ip" title="IP: ' . h($ip) . '"></a>' . $moder_panel; } $img = array('alt' => 'User avatar', 'title' => h($comment->getName()), 'class' => 'ava'); if ($comment->getUser_id() && file_exists(ROOT . '/sys/avatars/' . $comment->getUser_id() . '.jpg')) { $markers['avatar'] = get_img('/sys/avatars/' . $comment->getUser_id() . '.jpg', $img); } else { $markers['avatar'] = get_img('/sys/img/noavatar.png', $img); } if ($comment->getUser_id()) { $markers['name_a'] = get_link(h($comment->getName()), getProfileUrl((int) $comment->getUser_id())); $markers['user_url'] = get_url(getProfileUrl((int) $comment->getUser_id())); $markers['avatar'] = get_link($markers['avatar'], $markers['user_url']); } else { $markers['name_a'] = h($comment->getName()); } $markers['moder_panel'] = $moder_panel; $markers['message'] = $this->Textarier->parseBBCodes($comment->getMessage(), $comment); $comment->setAdd_markers($markers); } } $html = $this->render('viewcomment.html', array('commentsr' => $comments)); } else { $html = ''; }
function getHtmlForStudent($student) { $description = strlen($student->description) > 1 ? $student->description . '...' : '-description not available -'; $color = 'orangeColor'; $html = '<h3 class="' . $color . ' clearfix">'; $html = $html . '<div class="descriptionArea">'; $html = $html . '<img style="margin-top:10px;height: 80px;width: 80px;" src="' . getProfileUrl($student) . '"/>'; $html = $html . '<div style="margin-left:100px; margin-top:-95px"><span class="title">' . $student->getUser()->name; if (HttpSession::currentUser()->getOrganization()->access_level > 4) { $html = $html . ' <span style="font-size:10px">( ' . $student->student_id . ' )</span></span>'; } $html = $html . '<p>' . $description . '</p>'; $html = $html . getLinkedInProfile($student) . '</div></div>'; //.getUniScorecard($student) $html = $html . '</h3>'; $html = $html . '<div class="contentData clearfix">'; //$html = $html . '<img height="79" width="65" src="'. $user->pic_url .'"/>'; $html = $html . '<p>'; $html = $html . getHtmlForStudentTechnologies($student); $html = $html . '</p>'; $html = $html . '</div>'; return $html; }
/** * default action */ function index($id = null, $s = null, $x = null) { // if isset ID - we need load page with this ID if (!empty($id)) { if (is_int($id)) { $id = (int) $id; if ($id < 2) { redirect('/pages/'); } $page = $this->Model->getById($id); if (empty($page) || !$page->getPublish()) { return $this->showInfoMessage(__('Can not find this page'), '/'); } } else { if (!preg_match('#^[\\dа-яa-z_\\-./]+$#ui', $id)) { redirect('/pages/'); } $page = $this->Model->getByUrl($id); if (empty($page)) { return $this->showInfoMessage(__('Can not find this page'), '/'); } } $this->Register['active_page_id'] = $page->getId(); $this->addToPageMetaContext('entity_title', h($page->getMeta_title())); $this->page_meta_keywords = $page->getMeta_keywords(); $this->page_meta_description = $page->getMeta_description(); $this->template = $page->getTemplate() ? $page->getTemplate() : 'default'; $source = $page->getContent(); $source = $this->renderString($source, array('entity' => $page)); // Tree line $navi['navigation'] = get_link(__('Home'), '/'); $cnots = array_filter(explode('.', $page->getPath())); if (false !== ($res = array_search(1, $cnots))) { unset($cnots[$res]); } if (!empty($cnots)) { $ids = "'" . implode("', '", $cnots) . "'"; $pages = $this->Model->getCollection(array("`id` IN (" . $ids . ")"), array('order' => 'path')); if (!empty($pages) && is_array($pages)) { foreach ($pages as $p) { $navi['navigation'] .= __('Separator') . get_link(__($p->getName()), '/' . $this->Model->buildUrl($p->getId())); } } } $navi['navigation'] .= __('Separator') . h($page->getName()); $this->_globalize($navi); return $this->_view($source); //may be need view latest materials } else { $this->page_title = $this->Register['Config']->read('title'); $latest_on_home = $this->Register['Config']->read('latest_on_home'); $navi = null; //vsyakiy sluchay:) //if we want view latest materials on home page if (is_array($latest_on_home) && count($latest_on_home) > 0) { // Navigation Block $navi = array(); $navi['add_link'] = $this->ACL->turn(array('news', 'add_materials'), false) ? get_link(__('Add material'), '/news/add_form') : ''; $navi['navigation'] = get_link(__('Home'), '/'); $this->_globalize($navi); if ($this->cached && $this->Cache->check($this->cacheKey)) { $html = $this->Cache->read($this->cacheKey); return $this->_view($html); } //create SQL query $entities = $this->Model->getEntitiesByHomePage($latest_on_home); //if we have records if (count($entities) > 0) { // Get users(authors) $uids = array(); $mod_mats = array('news' => array(), 'stat' => array(), 'loads' => array()); foreach ($entities as $key => $mat) { $uids[] = $mat->getAuthor_id(); switch ($mat->getSkey()) { case 'news': $mod_mats['news'][$key] = $mat; break; case 'stat': $mod_mats['stat'][$key] = $mat; break; case 'loads': $mod_mats['loads'][$key] = $mat; break; } } $uids = '(' . implode(', ', $uids) . ')'; $uModelClassName = $this->Register['ModManager']->getModelNameFromModule('users'); $uModel = new $uModelClassName(); $authors = $uModel->getCollection(array('`id` IN ' . $uids)); // Merge records with additional fields if (is_object($this->AddFields)) { if (!empty($mod_mats['news']) && count($mod_mats['news']) > 0) { $mod_mats['news'] = $this->AddFields->mergeRecords($mod_mats['news'], false, 'news'); } if (!empty($mod_mats['stat']) && count($mod_mats['stat']) > 0) { $mod_mats['stat'] = $this->AddFields->mergeRecords($mod_mats['stat'], false, 'stat'); } if (!empty($mod_mats['loads']) && count($mod_mats['loads']) > 0) { $mod_mats['loads'] = $this->AddFields->mergeRecords($mod_mats['loads'], false, 'loads'); } } $all_attaches = array('news' => array(), 'stat' => array()); foreach ($mod_mats as $module => $mats) { if (count($mats) > 0 && ($module == 'news' || $module == 'stat')) { $attach_ids = array(); foreach ($mats as $mat) { $attach_ids[] = $mat->getId(); } $ids = implode(', ', $attach_ids); $attModelClassName = $this->Register['ModManager']->getModelNameFromModule($module . 'Attaches'); $attModel = new $attModelClassName(); $attaches = $attModel->getCollection(array('`entity_id` IN (' . $ids . ')')); foreach ($mats as $mat) { if ($attaches) { foreach ($attaches as $attach) { if ($mat->getId() == $attach->getEntity_id()) { $currAttaches = $mat->getAttaches(); if (is_array($currAttaches)) { $currAttaches[] = $attach; } else { $currAttaches = array($attach); } $mat->setAttaches($currAttaches); } } } } } } $entities = $mod_mats['news'] + $mod_mats['stat'] + $mod_mats['loads']; ksort($entities); //if we have materials for view on home page (now we get their an create page) $info = null; foreach ($entities as $result) { foreach ($authors as $author) { if ($result->getAuthor_id() == $author->getId()) { $result->setAuthor($author); break; } } // Create and replace markers $markers = array(); $this->Register['current_vars'] = $result; //moder panel $markers['moder_panel'] = $this->_getAdminBar($result->getId(), $result->getSkey()); $entry_url = entryUrl($result, $result->getSkey()); $markers['entry_url'] = $entry_url; $matattaches = $result->getAttaches() && count($result->getAttaches()) ? $result->getAttaches() : array(); $announce = $result->getMain(); $announce = $this->Textarier->getAnnounce($announce, $result, Config::read('announce_lenght'), 0, $result->getSkey()); $markers['announce'] = $announce; $markers['profile_url'] = get_url(getProfileUrl($result->getAuthor_id())); $markers['module_title'] = $this->Register['Config']->read('title', $result->getSkey()); $result->setAdd_markers($markers); //set users_id that are on this page $this->setCacheTag(array('module_' . $result->getSkey(), 'record_id_' . $result->getId())); } $html = $this->render('list.html', array('entities' => $entities)); //write int cache if ($this->cached) { $this->Cache->write($html, $this->cacheKey, $this->cacheTags); } } if (empty($html)) { $html = __('Materials not found'); } return $this->_view($html); } return $this->_view(__('Materials not found')); } }
/** * Show comments by user. */ public function comments($id = null) { /* COMMENT BLOCK */ $total = $this->Model->getCountComments($id); $per_page = 25; /* pages nav */ list($pages, $page) = pagination($total, $per_page, $this->getModuleURL('comments/' . ($id ? $id : ''))); $this->_globalize(array('comments_pagination' => $pages)); $offset = ($page - 1) * $per_page; $comments = $this->Model->getComments($id, $offset, $per_page); if ($comments && is_array($comments)) { foreach ($comments as $index => $entity) { $module = $entity->getModule(); $markers = array(); // COMMENT ADMIN BAR $ip = $entity->getIp() ? $entity->getIp() : 'Unknown'; $moder_panel = ''; $adm = false; if ($this->ACL->turn(array($module, 'edit_comments'), false)) { $moder_panel .= get_link('', '/' . $module . '/edit_comment_form/' . $entity->getId(), array('class' => 'fps-edit')) . ' '; $adm = true; } if ($this->ACL->turn(array($module, 'delete_comments'), false)) { $moder_panel .= get_link('', '/' . $module . '/delete_comment/' . $entity->getId(), array('class' => 'fps-delete', 'onClick' => "return confirm('" . __('Are you sure') . "')")) . ' '; $adm = true; } if ($adm) { $moder_panel = '<a target="_blank" href="https://apps.db.ripe.net/search/query.html?searchtext=' . h($ip) . '" class="fps-ip" title="IP: ' . h($ip) . '"></a>' . $moder_panel; } $img = array('alt' => 'User avatar', 'title' => h($entity->getName()), 'class' => 'ava'); // Аватар if (file_exists(ROOT . '/sys/avatars/' . $entity->getUser_id() . '.jpg')) { $url = get_url('/sys/avatars/' . $entity->getUser_id() . '.jpg'); } else { $url = get_url('/sys/img/noavatar.png'); } $markers['avatar'] = '<img class="ava" src="' . $url . '" alt="User avatar" />'; if ($entity->getUser_id()) { $markers['name_a'] = get_link(h($entity->getName()), getProfileUrl((int) $entity->getUser_id())); $markers['user_url'] = get_url(getProfileUrl((int) $entity->getUser_id())); $markers['avatar'] = get_link($markers['avatar'], $markers['user_url']); } else { $markers['name_a'] = h($entity->getName()); } $markers['name'] = h($entity->getName()); $markers['moder_panel'] = $moder_panel; $markers['message'] = $this->Textarier->parseBBCodes($entity->getMessage(), $entity); if ($entity->getEditdate() != '0000-00-00 00:00:00') { $markers['editdate'] = 'Комментарий был изменён ' . $entity->getEditdate(); } else { $markers['editdate'] = ''; } $entity->setEntry_url(get_url('/' . $module . '/view/' . $entity->getEntity_id())); $entity->setAdd_markers($markers); $comments[$index] = $entity; } } $this->comments = $this->render('viewcomment.html', array('commentsr' => $comments)); $title = __('All comments'); if ($id && intval($id) > 0) { $user = $this->Model->getById(intval($id)); if ($user) { $title = __('User comments') . ' "' . h($user->getName()) . '"'; } } $this->addToPageMetaContext('entity_title', $title); $navi = array('add_link' => $this->ACL->turn(array($this->module, 'add_materials'), false) ? get_link(__('Add material'), $this->getModuleURL('add_form/')) : '', 'module_url' => get_url($this->getModuleURL()), 'category_url' => get_url($this->getModuleURL('comments/' . ($id ? $id : ''))), 'category_name' => $title, 'navigation' => get_link(__('Home'), '/') . __('Separator') . get_link(h($this->module_title), $this->getModuleURL()) . __('Separator') . $title); $this->_globalize($navi); return $this->_view(''); }
/** * @return forum statistic block */ protected function _get_stat() { $markers = array(); $result = $this->Model->getStats(); if (!empty($result[0]['last_user_id']) && !empty($result[0]['last_user_name'])) { $markers['new_user'] = get_link(h($result[0]['last_user_name']), getProfileUrl($result[0]['last_user_id'])); } $markers['count_users'] = getAllUsersCount(); $markers['count_posts'] = !empty($result[0]['posts_cnt']) ? $result[0]['posts_cnt'] : 0; $markers['count_themes'] = !empty($result[0]['themes_cnt']) ? $result[0]['themes_cnt'] : 0; $html = $this->render('get_stat.html', $markers); return $html; }
/** * Show materials by user. User ID must be integer and not null. */ public function user($id = null) { //turn access $this->ACL->turn(array($this->module, 'view_list')); $id = intval($id); if ($id < 1) { return $this->showInfoMessage(__('Can not find user'), '/' . $this->module . '/'); } $usersModel = $this->Register['ModManager']->getModelInstance('Users'); $user = $usersModel->getById($id); if (!$user) { return $this->showInfoMessage(__('Can not find user'), '/' . $this->module . '/'); } //формируем блок со списком разделов $this->_getCatsTree(); if ($this->cached && $this->Cache->check($this->cacheKey)) { $source = $this->Cache->read($this->cacheKey); return $this->_view($source); } // we need to know whether to show hidden $where = array('author_id' => $id); $where[] = $this->_getDeniSectionsCond(); $total = $this->Model->getTotal(array('cond' => $where)); list($pages, $page) = pagination($total, $this->Register['Config']->read('per_page', $this->module), '/' . $this->module . '/user/' . $id); $this->Register['pages'] = $pages; $this->Register['page'] = $page; $this->addToPageMetaContext('page', $page); $this->addToPageMetaContext('entity_title', sprintf(__('User materials'), h($user->getName()))); $navi = array(); $navi['add_link'] = $this->ACL->turn(array($this->module, 'add_materials'), false) ? get_link(__('Add material'), '/' . $this->module . '/add_form/') : ''; $navi['navigation'] = get_link(__('Home'), '/') . __('Separator') . get_link(h($this->module_title), '/' . $this->module . '/') . __('Separator') . sprintf(__('User materials'), h($user->getName())) . '"'; $navi['pagination'] = $pages; $navi['meta'] = __('Total materials') . $total; $navi['category_name'] = sprintf(__('User materials'), h($user->getName())); $this->_globalize($navi); if ($total <= 0) { $html = __('Materials not found'); return $this->_view($html); } $this->Model->bindModel('author'); $this->Model->bindModel('category'); $params = array('page' => $page, 'limit' => $this->Register['Config']->read('per_page', $this->module), 'order' => $this->Model->getOrderParam()); $records = $this->Model->getCollection($where, $params); // create markers foreach ($records as $entity) { $this->Register['current_vars'] = $entity; $markers = array(); $markers['moder_panel'] = $this->_getAdminBar($entity); $entry_url = entryUrl($entity, $this->module); $markers['entry_url'] = $entry_url; $markers['foto_alt'] = h(preg_replace('#[^\\w\\d ]+#ui', ' ', $entity->getTitle())); $markers['category_url'] = get_url('/' . $this->module . '/category/' . $entity->getCategory_id()); $markers['profile_url'] = getProfileUrl($entity->getAuthor_id()); //set users_id that are on this page $this->setCacheTag(array('user_id_' . $entity->getAuthor_id(), 'record_id_' . $entity->getId(), 'category_id_' . $id)); $entity->setAdd_markers($markers); } $source = $this->render('list.html', array('entities' => $records)); //write int cache if ($this->cached) { $this->Cache->write($source, $this->cacheKey, $this->cacheTags); } return $this->_view($source); }
public static function index() { $Register = Register::getInstance(); //ip if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '00.00.00.00'; } if (mb_strlen($ip) > 20 || !preg_match('#^\\d+\\.\\d+\\.\\d+\\.\\d+$#', $ip)) { $ip = '00.00.00.00'; } if (!file_exists(ROOT . '/sys/logs/counter_ips' . date("Y-m-d"))) { $counter_tmp_dirs = glob(ROOT . '/sys/logs/counter_ips*'); if (!empty($counter_tmp_dirs) && is_array($counter_tmp_dirs)) { foreach ($counter_tmp_dirs as $dir) { _unlink($dir); } } mkdir(ROOT . '/sys/logs/counter_ips' . date("Y-m-d"), 0777, true); } if (!file_exists(ROOT . '/sys/logs/counter_ips' . date("Y-m-d") . '/' . $ip . '.dat')) { $inc_ip = 1; $file = fopen(ROOT . '/sys/logs/counter_ips' . date("Y-m-d") . '/' . $ip . '.dat', 'w'); fclose($file); } else { $inc_ip = 0; } //visits from other sites if (!empty($_SERVER['HTTP_REFERER']) && !preg_match('#^http://' . $_SERVER['SERVER_NAME'] . '#', $_SERVER['HTTP_REFERER'])) { $other_site_view = 1; } else { $other_site_view = 0; } //user agent and bot identification $other_bot = 0; $yandex_bot = 0; $google_bot = 0; if (empty($_SERVER["HTTP_USER_AGENT"])) { $other_bot = 1; } else { if (strstr($_SERVER["HTTP_USER_AGENT"], "Yandex")) { $yandex_bot = 1; } elseif (strstr($_SERVER["HTTP_USER_AGENT"], "Googlebot")) { $google_bot = 1; } else { if (strstr($_SERVER["HTTP_USER_AGENT"], "StackRambler") || strstr($_SERVER["HTTP_USER_AGENT"], "Scooter") || strstr($_SERVER["HTTP_USER_AGENT"], "Fast") || strstr($_SERVER["HTTP_USER_AGENT"], "infoseek") || strstr($_SERVER["HTTP_USER_AGENT"], "YahooBot") || strstr($_SERVER["HTTP_USER_AGENT"], "aport") || strstr($_SERVER["HTTP_USER_AGENT"], "slurp") || strstr($_SERVER["HTTP_USER_AGENT"], "architextspider") || strstr($_SERVER["HTTP_USER_AGENT"], "lycos") || strstr($_SERVER["HTTP_USER_AGENT"], "grabber") || strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "bot") || strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "spider")) { $other_bot = 1; } } } //referer $referer = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; //check coocie if (isset($_COOKIE['counter']) || (!empty($other_bot) || !empty($yandex_bot) || !empty($google_bot))) { $cookie = 0; } else { $cookie = 1; //cookie die in 23:59:59 this day $curdate = date("n,j,Y"); $curdate = explode(',', $curdate); $timestamp = mktime(23, 59, 59, $curdate[0], $curdate[1], $curdate[2]); setcookie('counter', md5($ip), $timestamp, '/'); } $view = !empty($other_bot) || !empty($yandex_bot) || !empty($google_bot) ? 0 : 1; touchDir(ROOT . '/sys/logs/counter/', 0777); $tmp_datafile = ROOT . '/sys/logs/counter/' . date("Y-m-d") . '.dat'; if (file_exists($tmp_datafile) && is_readable($tmp_datafile)) { $stats = unserialize(file_get_contents($tmp_datafile)); $stats['views'] = $stats['views'] + $view; $stats['cookie'] = $stats['cookie'] + $cookie; $stats['ips'] = $stats['ips'] + $inc_ip; $stats['yandex_bot_views'] = $stats['yandex_bot_views'] + $yandex_bot; $stats['google_bot_views'] = $stats['google_bot_views'] + $google_bot; $stats['other_bot_views'] = $stats['other_bot_views'] + $other_bot; $stats['other_site_visits'] = $stats['other_site_visits'] + $other_site_view; } else { $stats = array('views' => 1, 'cookie' => 1, 'ips' => 1, 'yandex_bot_views' => $yandex_bot, 'google_bot_views' => $google_bot, 'other_bot_views' => $other_bot, 'other_site_visits' => $other_site_view); } $f = fopen($tmp_datafile, 'w+'); flock($f, LOCK_EX); fwrite($f, serialize($stats)); flock($f, LOCK_UN); fclose($f); //statistics data for counter image if (!file_exists(ROOT . '/sys/logs/overal_stats.dat')) { StatisticsModule::_updateOveralHits(); } $overal = unserialize(file_get_contents(ROOT . '/sys/logs/overal_stats.dat')); if (!isset($overal['hits'])) { $overal['hits'] = StatisticsModule::_updateOveralHits(); } $all_hits = (int) $overal['hits'] + $stats['views']; $hosts = $stats['cookie']; $hits = $stats['views']; //write into data base and delete file (one time in day) $tmp_files = glob(ROOT . '/sys/logs/counter/*.dat'); if (!empty($tmp_files) && count($tmp_files) > 1) { foreach ($tmp_files as $file) { $date = substr(strrchr($file, '/'), 1, 10); if ($date === date("Y-m-d")) { continue; } StatisticsModule::_writeIntoDataBase($date); unlink($file); StatisticsModule::_deleteOveralKey('hits'); } } self::viewCounter($all_hits, $hits, $hosts); //who online touchDir(ROOT . '/sys/logs/counter_online/'); $path = ROOT . '/sys/logs/counter_online/online.dat'; $users = array(); $guests = array(); $online_users = array(); if (file_exists($path) && is_readable($path)) { $data = unserialize(file_get_contents($path)); $users = !empty($data['users']) ? $data['users'] : array(); $guests = !empty($data['guests']) ? $data['guests'] : array(); } foreach ($users as $key => $user) { if ($user['expire'] < time()) { unset($users[$key]); break; } // online users list if (strstr($key, 'bot')) { $online_users[] = '<span class="botname">' . h($user['name']) . '</span>'; continue; } $color = ''; if (isset($user['status'])) { $group_info = $Register['ACL']->get_user_group($user['status']); if (!empty($group_info['color'])) { $color = 'color:#' . $group_info['color'] . ';'; } } $online_users[] = get_link(h($user['name']), getProfileUrl($key), array('style' => $color)); } foreach ($guests as $key => $guest) { if ($guest['expire'] < time()) { unset($guests[$key]); } } $_SESSION['online_users_list'] = count($online_users) ? implode(', ', $online_users) : ''; // Max users online in one time $all_online = intval(count($users) + count($guests)); if (!empty($overal['max_users_online']) && is_numeric($overal['max_users_online'])) { if ($overal['max_users_online'] < $all_online) { StatisticsModule::_updateOveralHits(array('max_users_online', 'max_users_online_date'), array($all_online, date("Y-m-d"))); } } else { StatisticsModule::_updateOveralHits(array('max_users_online', 'max_users_online_date'), array($all_online, date("Y-m-d"))); } if (empty($_SERVER['HTTP_USER_AGENT'])) { $_SERVER["HTTP_USER_AGENT"] = ''; } if (!empty($_SESSION['user']['id'])) { $users[$_SESSION['user']['id']] = array('expire' => time() + $Register['Config']->read('time_on_line') * 60, 'name' => $_SESSION['user']['name'], 'status' => $_SESSION['user']['status']); } else { if (strstr($_SERVER["HTTP_USER_AGENT"], "StackRambler")) { $users['bot_rambler'] = array('expire' => time() + $Register['Config']->read('time_on_line') * 60, 'name' => 'Rambler[bot]'); } else { if (strstr($_SERVER["HTTP_USER_AGENT"], "YahooBot")) { $users['bot_yahoo'] = array('expire' => time() + $Register['Config']->read('time_on_line') * 60, 'name' => 'Yahoo[bot]'); } else { if (strstr($_SERVER["HTTP_USER_AGENT"], "Yandex")) { $users['bot_yandex'] = array('expire' => time() + $Register['Config']->read('time_on_line') * 60, 'name' => 'Yandex[bot]'); } else { if (strstr($_SERVER["HTTP_USER_AGENT"], "Googlebot")) { $users['bot_google'] = array('expire' => time() + $Register['Config']->read('time_on_line') * 60, 'name' => 'Google[bot]'); } else { $guests[$ip] = array('expire' => time() + $Register['Config']->read('time_on_line') * 60); } } } } } file_put_contents($path, serialize(array('users' => $users, 'guests' => $guests))); return; }
/** * Default NewsModule action */ public function index($category_id = null) { $category_id = intval($category_id); //turn access $this->ACL->turn(array($this->module, 'view_catalog')); if ($this->cached && $this->Cache->check($this->cacheKey)) { $source = $this->Cache->read($this->cacheKey); return $this->_view($source); } if (!empty($category_id)) { $categoryModel = $this->Register['ModManager']->getModelInstance('shopCategories'); $category = $categoryModel->getById($category_id); if (!$category) { return $this->showInfoMessage(__('Can not find category'), '/' . $this->module . '/'); } $this->addToPageMetaContext('category_title', h($category->getTitle())); } $where = array("(quantity > 0 || hide_not_exists = '0')"); // get products only from allowed categories (.no_access field) $where[] = $this->_getDeniSectionsCond($category_id); $where[] = $this->__getProductsFiltersCond(); if (!$this->ACL->turn(array('other', 'can_see_hidden'), false)) { $where['available'] = 1; } if (!empty($tag)) { $tag = $this->Register['DB']->escape($tag); $where[] = "CONCAT(',', `tags`, ',') LIKE '%,{$tag},%'"; } if (!$category_id) { $where['view_on_home'] = 1; } //формируем блок со списком разделов $this->_getCatsTree($category_id); $total = $this->Model->getTotal(array('cond' => $where)); list($pages, $page) = pagination($total, Config::read('per_page', $this->module), '/' . $this->module . '/'); $this->Register['pages'] = $pages; $this->Register['page'] = $page; $this->addToPageMetaContext('page', $page); $navi = array(); $navi['add_link'] = ''; $navi['navigation'] = $this->_buildBreadCrumbs($category_id); $navi['pagination'] = $pages; $navi['meta'] = __('Total materials') . $total; $this->_globalize($navi); $this->Model->bindModel('attributes_group'); $this->Model->bindModel('attributes.content'); $this->Model->bindModel('vendor'); $this->Model->bindModel('category'); $this->Model->bindModel('author'); $this->Model->bindModel('attaches'); $params = array('page' => $page, 'limit' => $this->Register['Config']->read('per_page', $this->module), 'order' => $this->Model->getOrderParam()); $records = $this->Model->getCollection($where, $params); $filters = $this->__getProductsFilters($category_id); $filters .= $this->__getVendorsFilter($category_id); $this->_globalize(array('products_filters' => $filters)); // create markers foreach ($records as $result) { $result->setModer_panel($this->_getAdminBar($result)); $entry_url = entryUrl($result, $this->module); $result->setEntry_url($entry_url); // Cut announce $announce = $this->Textarier->getAnnounce($result->getMain(), $result, $this->Register['Config']->read('announce_lenght', $this->module)); $result->setAnnounce($announce); $result->setCategory_url(get_url('/' . $this->module . '/category/' . $result->getCategory_id())); $result->setProfile_url(getProfileUrl($result->getAuthor()->getId())); //set users_id that are on this page $this->setCacheTag(array('user_id_' . $result->getAuthor()->getId(), 'record_id_' . $result->getId())); if ($category_id) { $this->setCacheTag(array('category_id_' . $category_id)); } } $source = $this->render('list.html', array('context' => array('entities' => $records))); //write int cache if ($this->cached) { $this->Cache->write($source, $this->cacheKey, $this->cacheTags); } return $this->_view($source); }
/** DEPRECATED * @param string $page * @param string $modul - current module * @return data with head menu */ public function headMenu($page, $modul = NULL) { $Register = Register::getInstance(); $this->ACL = $this->Register['ACL']; $menu = get_link('Главная', '/'); if (isset($_SESSION['user']['name'])) { $menu = $menu . get_link('Мой профиль', getProfileUrl($_SESSION['user']['id'])) . get_link('Выход', '/users/logout/'); $menu = $menu . get_link('Пользователи', '/users/index/'); if ($modul == 'forum') { $menu = $menu . get_link('Поиск', '/search/'); } // Есть ли непрочитанные сообщения в папке "Входящие"? $cntNewMsg = UserAuth::countNewMessages(); if ($cntNewMsg < 1) { $menu = $menu . get_link('Личные сообщения', '/users/in_msg_box/'); } else { $menu = $menu . get_link('Новые сообщения', '/users/in_msg_box/', array('class' => 'newMessages')); } } else { $menu = $menu . get_link('Регистрация', '/users/add_form/') . get_link('Вход', '/users/login_form/'); } if (isset($_SESSION['user']['name']) and $this->ACL->turn(array('panel', 'entry'), false)) { $menu = $menu . get_link('Админка', '/admin/', array('target' => '_blank')); } $menu .= '<a onClick="add_favorite(this);" title="Добавить в закладки" href="javascript:void(0);" >В закладки</a>'; $html = str_replace('{headmenu}', $menu, $page); return $html; }