Exemple #1
0
 function draw()
 {
     $set_tag_search = "";
     $url_root = WEB_ROOT . 'search?keywords=';
     if (StaticCache::notExistCache($this->cachefile, 300)) {
         StaticCache::startCache();
         global $display;
         $this->beginForm();
         $set_tag_search = "";
         $color_max_rand = array(0 => 'color:#F60', 1 => 'color:#09C', 2 => 'color:#090', 3 => 'color:#666');
         $count_color_max_rand = count($color_max_rand);
         $re = DB::query('SELECT id, keywords, hit FROM tag_search  ORDER BY rand() LIMIT 500');
         if ($re) {
             while ($item = mysql_fetch_assoc($re)) {
                 $font_size = 12;
                 //mac dinh font =12px
                 $max_font = 25;
                 // font max = 25px
                 $font_color = "";
                 // color when max font
                 $font_size += round($item["hit"] / 5000);
                 if ($font_size > $max_font) {
                     $font_size = $max_font;
                 }
                 $font_color = $color_max_rand[rand(0, $count_color_max_rand - 1)];
                 $set_tag_search .= ($set_tag_search ? ', ' : '') . '<a target="_blank" href="' . $url_root . urlencode($item["keywords"]) . '&id=' . $item["id"] . '"><span style="font-size:' . $font_size . 'px;' . $font_color . '">' . $item["keywords"] . '</span></a>';
             }
         }
         $display->add('items', $set_tag_search);
         $display->output('MoreSearch');
         $this->endForm();
         StaticCache::endCache();
     }
 }
Exemple #2
0
    function draw()
    {
        global $display;
        if (CGlobal::$curCategory) {
            $page_no = (int) Url::get('page_no', 1);
            if ($page_no <= 0) {
                $page_no = 1;
            }
            if (User::have_permit(ADMIN_ITEM)) {
                $subDir = 'list_item_admin';
            } else {
                $subDir = 'list_item';
            }
            //if(StaticCache::notExistCache('c'.CGlobal::$curCategory.'_'.$page_no,30,false,$subDir)){
            if (StaticCache::notExistCache('c' . CGlobal::$curCategory . '_' . $page_no, 1, FALSE, $subDir)) {
                StaticCache::startCache();
                $this->draw_from();
                StaticCache::endCache();
            }
            if (User::have_permit(ADMIN_ITEM)) {
                echo '<script>
						jQuery(document).ready(function(){		
							jQuery("div.admin_button").show();
							jQuery(".mod_menu").show();
						});
						
						function check_permit(catid){
							return true;
						}
					</script>';
            }
        } else {
            Url::redirect_url(WEB_DIR, 301);
        }
    }
Exemple #3
0
 function draw()
 {
     if (StaticCache::notExistCache('error_page', 604800)) {
         //thời gian cache 1 tuần 24*7*3600 =604800;
         StaticCache::startCache();
         global $display;
         $display->add('category_id', CGlobal::$curCategory);
         $display->add('base_url', WEB_ROOT);
         $display->output('404_error');
         StaticCache::endCache();
     }
 }
Exemple #4
0
 function item_same_category()
 {
     global $display;
     $p_item_same = (int) Url::get('p_item_same', 1);
     //        if ($p_item_same == 0 || $p_item_same == 1) {
     if ($p_item_same == 0) {
         if (StaticCache::notExistCache('item_same_cat_' . CGlobal::$curCategory . '_' . CGlobal::$curCity, 60)) {
             StaticCache::startCache();
             $this->item_same_category_form();
             StaticCache::endCache();
         }
     } else {
         $this->item_same_category_form();
     }
 }
Exemple #5
0
 function update_user_online()
 {
     $user_id = isset($_SESSION['user_id']) ? (int) $_SESSION['user_id'] : 0;
     $session_id = session_id();
     $page = '';
     $page_id = 0;
     $user_name = isset($_SESSION['user_name']) ? $_SESSION['user_name'] : 0;
     $login_type = isset($_SESSION['openid_url']) && $_SESSION['openid_url'] != '' ? 1 : 0;
     $open_id = isset($_SESSION['openid_url']) && $_SESSION['openid_url'] != '' ? $_SESSION['openid_url'] : '';
     if (class_exists('AZNet')) {
         $page = AZNet::$page['name'];
         $page_id = (int) AZNet::$page['id'];
     }
     if (($page == 'ItemDetail' || $page == 'item_detail') && isset($_GET['id']) && $_GET['id']) {
         $item_id = (int) $_GET['id'];
     } else {
         $item_id = 0;
     }
     if (in_array(basename($_SERVER['PHP_SELF']), array('ebxml.php', 'ajax.php', 'captcha.php'))) {
         $ref_url = '';
     } else {
         AZLib::check_uri();
         $ref_url = CGlobal::$query_string;
     }
     $sql = "SELECT  session_referer, page, page_id, item_id FROM " . _SESS_TABLE . " WHERE session_id = '{$session_id}'";
     $result = DB::query($sql, __LINE__ . __FILE__);
     if (mysql_num_rows($result)) {
         $s_row = mysql_fetch_assoc($result);
     } else {
         $s_row = array();
     }
     if ($s_row) {
         if ($ref_url == '' || in_array(basename($_SERVER['PHP_SELF']), array('ebxml.php', 'ajax.php', 'captcha.php'))) {
             $ref_url = stripslashes($s_row['session_referer']);
         }
         if (!$page) {
             $page = $s_row['page'];
         }
         if (!$page_id) {
             $page_id = (int) $s_row['page_id'];
         }
         if (!$item_id) {
             $item_id = (int) $s_row['item_id'];
         }
         $sql = "UPDATE " . _SESS_TABLE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tsession_expires = " . time() . ", \r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tsession_referer = '" . addslashes($ref_url) . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tsession_ip \t\t= '" . $_SERVER['SERVER_ADDR'] . '::' . $_SERVER['REMOTE_ADDR'] . "', \r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tpage \t\t\t= '{$page}',\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tpage_id \t\t= {$page_id},\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tcategory_id \t= " . CGlobal::$curCategory . ",\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \titem_id \t\t= {$item_id},\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tuser_id \t\t= '{$user_id}',\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tuser_name\t\t= '{$user_name}',\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \tlogin_type\t\t= '{$login_type}',\r\n\t\t\t\t\t\t\t\t\t\t\t\t  \topen_id\t\t\t= '{$open_id}'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE session_id \t= '{$session_id}'";
     } else {
         $sql = "INSERT INTO " . _SESS_TABLE . " \r\n\t\t\t\t\t\t\t\t  (\r\n\t\t\t\t\t\t\t\t  \tsession_id, \r\n\t\t\t\t\t\t\t\t  \tsession_expires,  \r\n\t\t\t\t\t\t\t\t  \tsession_referer, \r\n\t\t\t\t\t\t\t\t  \tsession_ip,   \r\n\t\t\t\t\t\t\t\t  \tpage,  \r\n\t\t\t\t\t\t\t\t  \tpage_id, \r\n\t\t\t\t\t\t\t\t  \tcategory_id, \r\n\t\t\t\t\t\t\t\t  \titem_id, \r\n\t\t\t\t\t\t\t\t  \tuser_id,  \r\n\t\t\t\t\t\t\t\t  \tuser_name,\r\n\t\t\t\t\t\t\t\t  \tlogin_type,\r\n\t\t\t\t\t\t\t\t  \topen_id\r\n\t\t\t\t\t\t\t\t  \t) \r\n\t\t                   VALUES (\r\n\t\t                   \t\t\t'{$session_id}', \t\t\t\t\r\n\t\t                   \t\t\t" . time() . ", \t\t\t\r\n\t\t                   \t\t\t'" . addslashes($ref_url) . "', \t   \r\n\t\t                   \t\t\t'" . $_SERVER['SERVER_ADDR'] . '::' . $_SERVER['REMOTE_ADDR'] . "',\t\r\n\t\t                   \t\t\t'{$page}',\t  \r\n\t\t                   \t\t\t{$page_id},\t\t   \r\n\t\t                   \t\t\t" . CGlobal::$curCategory . ", \t\t \r\n\t\t                   \t\t\t{$item_id}, \t  \r\n\t\t                   \t\t\t{$user_id} ,\t\t\r\n\t\t                   \t\t\t'{$user_name}' ,\t\t\r\n\t\t                   \t\t\t{$login_type} ,\t\t\r\n\t\t                   \t\t\t'{$open_id}')";
     }
     DB::query($sql, __LINE__ . __FILE__);
     if (User::is_login() && MEMCACHE_ON) {
         $user = User::$current->data;
         if ($user && !isset($user['last_login']) || isset($user['last_login']) && $user['last_login'] < TIME_NOW - 300) {
             DB::query("UPDATE user SET last_login="******" WHERE id={$user['id']}");
             $user_memcache = AZMemcache::do_get("user:{$user['id']}");
             if ($user_memcache) {
                 $user_memcache['last_login'] = TIME_NOW;
                 AZMemcache::do_put("user:{$user['id']}", $user_memcache);
             }
         }
     }
     if (StaticCache::notExistCache('del_exs', 1)) {
         //Run 1 cronjob/15s
         StaticCache::startCache();
         StaticCache::endCache();
         DB::query("DELETE FROM " . _SESS_TABLE . " WHERE session_expires <= " . (time() - _SESS_TIME_EXPIRE));
     }
 }
Exemple #6
0
 function build_user_rss()
 {
     $user_id = (int) EClassApi::getParam('user_id');
     $user = User::getUser($user_id);
     if ($user) {
         $subDir = 'rss1/' . floor($user_id / 1000);
         //echo
         $user_id = $user['id'];
         $user['full_name'] != '' ? $user_name = trim(XMLLib::_xml_encode_attribute($user['full_name'])) : ($user_name = trim(XMLLib::_xml_encode_attribute($user['user_name'])));
         $cachefile = 'rss1_user_' . $user_id;
         header("content-type: text/xml");
         if (StaticCache::notExistCache($cachefile, 3600, false, $subDir)) {
             StaticCache::startCache();
             $user_name = "Tin &#273;&#259;ng c&#7911;a " . $user_name;
             $rss = $this->build_rss_cat(0, $user_name, 100, $user_id);
             echo $rss;
             StaticCache::endCache();
         }
     } else {
         REWRITE_ON ? header("Location:" . WEB_ROOT . "rss/") : header("Location:" . WEB_ROOT . "?page=rss");
     }
     System::halt();
 }
Exemple #7
0
 /**
  * Garbage Collector
  * @param int life time (sec.)
  * @return bool
  * @see session.gc_divisor      100
  * @see session.gc_maxlifetime 1440
  * @see session.gc_probability    1
  * @usage execution rate 1/100
  *        (session.gc_probability/session.gc_divisor)
  */
 function gc()
 {
     if (StaticCache::notExistCache('del_exs', 1)) {
         //Run 1 cronjob/15s
         StaticCache::startCache();
         StaticCache::endCache();
         DB::query("DELETE FROM " . _SESS_TABLE . " WHERE session_expires <= " . (time() - _SESS_TIME_EXPIRE));
     }
     return true;
     /* 
     		$sql = "DELETE FROM "._SESS_TABLE." WHERE `session_expires` < ".(time() - _SESS_TIME_EXPIRE);
             $this->query($sql,__LINE__.__FILE__);                       
     
             if($this->effect_rows){//if row was created, return true
     			return true;
     		}*/
     return false;
     //an unknown error occured
 }
Exemple #8
0
tbug('End of Page');
if (!isset($_GET['is_popup'])) {
    $mtime = microtime();
    $mtime = explode(" ", $mtime);
    $mtime = $mtime[1] + $mtime[0];
    $end_rb = $mtime;
    $page_load_time = round($end_rb - $start_rb, 5) . "s";
    $color = DEBUG ? "red" : "#FFFFFF";
    echo "<span style=''><div align='center'><span clear='left' style='color:{$color};'>Total load time ({$_SERVER['SERVER_ADDR']}) : {$page_load_time}</span>";
    if (CRONJOB_URL && StaticCache::notExistCache('cronjob', 15)) {
        //Run 1 cronjob/15s
        $mtime = microtime();
        $mtime = explode(" ", $mtime);
        $mtime = $mtime[1] + $mtime[0];
        $start_task = $mtime;
        StaticCache::startCache();
        StaticCache::endCache();
        if (@fopen(CRONJOB_URL, "r")) {
            $msg = "<span style='color:{$color};clear:both'>Run cronjob ";
            //echo "<img src='http://192.168.17.108/cronjob/task.gif' height='1' width='1'/>";
        } else {
            $msg = "<span style='color:{$color};clear:both'>Not run cronjob ";
        }
        $mtime = microtime();
        $mtime = explode(" ", $mtime);
        $mtime = $mtime[1] + $mtime[0];
        $end_task = $mtime;
        $page_load_time = round($end_task - $start_task, 5) . "s";
        echo $msg, " in {$page_load_time}</span>";
    }
    echo "</div></span>";
 function display_feedback()
 {
     global $display;
     $show_all = Url::get('show_all', 0);
     Item::$id = (int) Url::get('id', 0);
     Item::$item = Item::get_item(Item::$id);
     if (Item::$item) {
         if (!isset(Item::$item['display'])) {
             Item::$item['display'] = 1;
             if (isset(Item::$item['id'])) {
                 //Check trạng thái tin và quyền thao tác:
                 if (Item::$item['status'] != 1) {
                     //Tin không được kiểm duyệt
                     //Nếu tin chưa được kiểm duyệt ,chỉ admin hoặc chủ tin được xem!
                     if (Item::$item['status'] == 2) {
                         if (User::id() != Item::$item['user_id'] && !User::have_permit(ADMIN_ITEM) && !User::have_cat_permit(Item::$item['category_id'])) {
                             Item::$item['display'] = 0;
                         }
                     } else {
                         //Nếu tin ở trạng thái xóa
                         if (Item::$item['status'] == -1) {
                             if (!User::have_permit(ADMIN_ITEM)) {
                                 Item::$item['display'] = 0;
                                 //Url::access_denied();
                             }
                         }
                     }
                     //Nếu tin bị ẩn ,chỉ admin được xem!
                     if (Item::$item['status'] == 0) {
                         if (!User::is_admin()) {
                             Item::$item['display'] = 0;
                             //Url::access_denied();
                         }
                     }
                 }
             }
         }
         if (Item::$item['display']) {
             if ($show_all) {
                 $this->get_all_comment();
             } else {
                 if (StaticCache::notExistCache('fb_' . Item::$id, 0)) {
                     StaticCache::startCache();
                     $this->get_all_comment();
                     StaticCache::endCache();
                 }
             }
         }
     }
 }
Exemple #10
0
 function mini_profile()
 {
     $user_ids = EClassApi::getParam('user_ids');
     if ($user_ids) {
         $page_num = EClassApi::getParam('page_num');
         $st = '({';
         $topTxt = '';
         $sql = 'SELECT account.id, user_name, full_name, blast, create_time, address, mobile_phone, yahoo_id, show_email, email, website
                 FROM account WHERE id IN (' . $user_ids . ')';
         $re = DB::query($sql);
         $i = 0;
         if ($re) {
             while ($user = mysql_fetch_assoc($re)) {
                 $user_id = $user['id'];
                 if ($i > 0) {
                     $st .= ',';
                 }
                 $i++;
                 $topTxt = '';
                 if ($user) {
                     $subDir = 'item_user/' . floor($user_id / 1000);
                     $cachefile = 'top_item_' . $user_id;
                     // start cache
                     if (StaticCache::notExistCache($cachefile, 600, true, $subDir)) {
                         StaticCache::startCache();
                         $top_items = EClassApi::getTopItem($user_id);
                         if ($top_items) {
                             $topItem = '<div class=\'miniTopList\'>Giao dịch mới nhất:</div><div class=\'listCheap\'>';
                             foreach ($top_items as $item) {
                                 $link = WEB_DIR . ECRewrite::formatUrl("?page=item_detail&id=" . $item['id'] . "&ebname=" . EClassApi::safe_title($item['name']));
                                 $topItem .= '<div><span class=\'miniNews\'><a href=\'' . $link . '\' target=\'_blank\'>' . EClassApi::subString(stripslashes($item['name']), 0, 40, true) . '</a></span></div>';
                             }
                             $topItem .= '</div>';
                             echo $topItem;
                         }
                         StaticCache::endCache();
                     }
                     $topTxt = StaticCache::$curentContent;
                     // end cache
                     $user['blast'] = EClassApi::remove_4_js(EnbacLib::BBCode(EClassApi::cleanHtml($user['blast'])));
                     if (trim($user['blast'])) {
                         $user['blast'] = ' ' . $user['blast'];
                         if (strpos($user['blast'], 'http://')) {
                             $user_blast = $user['blast'];
                             while (strpos($user_blast, 'http://')) {
                                 $tmp = substr($user_blast, strpos($user_blast, 'http://'));
                                 if (strpos($tmp, ' ')) {
                                     $blast_url = substr($tmp, 0, strpos($tmp, ' '));
                                 } else {
                                     $blast_url = $tmp;
                                 }
                                 $user_blast = str_replace($blast_url, '', $user_blast);
                             }
                             $new_blast_url = ' <a href=\'' . $blast_url . '\' target=\'_blank\'>Click here</a>';
                             $user['blast'] = substr($user_blast . $new_blast_url, 1);
                         }
                     }
                     if ($user['blast'] == '') {
                         $user['blast'] = '...';
                     }
                     if ($user['website'] == '') {
                         $user['website'] = '';
                     } else {
                         $user['website_url'] = $user['website'];
                         if (strrpos($user['website_url'], 'ttp://') != 1) {
                             $user['website_url'] = 'http://' . $user['website_url'];
                         }
                         if (strlen($user['website']) > 8) {
                             if (strpos($user['website'], '/', 8) > 0) {
                                 $user['website'] = substr($user['website'], 0, strpos($user['website'], '/', 8));
                             }
                         }
                         $user['website'] = '<a href=\'' . $user['website_url'] . '\' target=\'_blank\' class=\'lineHeight15\'><strong>' . $user['website'] . '</strong></a>';
                     }
                     $st .= '"' . $user_id . '" : {';
                     $st .= '"user_id": "' . $user_id . '",';
                     $st .= '"user_name": "' . $user['user_name'] . '",';
                     $st .= '"sender_link": "' . Url::build('shop', array('user_name' => $user['user_name'])) . '",';
                     $st .= '"blast": "' . $user['blast'] . '",';
                     $st .= '"total_score": "0",';
                     $st .= '"full_name": "' . stripslashes($user['full_name']) . '",';
                     $st .= '"create_time": "' . date('d-m-Y', $user['create_time']) . '",';
                     $st .= '"address": "' . stripslashes($user['address']) . '",';
                     $st .= '"mobile_phone": "' . stripslashes($user['mobile_phone']) . '",';
                     $st .= '"yahoo_id": "' . stripslashes($user['yahoo_id']) . '",';
                     $st .= '"email": "' . ($user['show_email'] == 1 ? stripslashes($user['email']) : '') . '",';
                     $st .= '"website": "' . ($user['website'] ? stripslashes($user['website']) : '') . '",';
                     $st .= '"top_item": "' . addslashes($topTxt) . '"';
                     $st .= '}';
                 }
             }
         }
         $st .= '})';
     } else {
         $st = '({})';
     }
     header("content-type: text/javascript");
     echo $st;
     System::halt();
 }