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 del_comment()
    {
        $json['msg'] = '';
        if (!User::is_login() || User::is_block()) {
            $json['msg'] = "not_perm";
            die(json_encode($json));
        }
        $id = (int) Url::get("id");
        if ($id) {
            $comment = DB::fetch("SELECT * FROM comment WHERE id={$id} LIMIT 1");
            if (count($comment) == 0) {
                exit;
            }
            if (User::have_permit(ADMIN_ITEM) || User::id() == $comment['receiver_user_id'] && $comment['sender_user_id'] == 0) {
                EClassApi::update_cache_comment($comment['item_id']);
                if (DB::delete('comment', 'id=' . $id)) {
                    $subItemId = $comment['sub_item_id'];
                    $itemId = $comment['item_id'];
                    if (MEMCACHE_ON) {
                        //eb_memcache::do_put('update_comment_sub_' . $itemId . '_' . $subItemId, 1); /*ngannv #update_comment_sub tìm thêm trong ajax_item_detai.ajax*/
                        eb_memcache::do_remove('comment_sub_' . $itemId . '_' . $subItemId);
                    }
                    $countChild = $comment['have_child'];
                    if ($countChild > 0) {
                        DB::delete('comment', 'parent_id=' . $id);
                    }
                    $countChildDel = $countChild + 1;
                    if ($subItemId > 0) {
                        DB::query("UPDATE item_sub SET comment_count=comment_count-{$countChildDel} WHERE id={$subItemId} LIMIT 1");
                        /*SubItem chưa có cache nên tạm thời truy vấn lại để lấy số comment*/
                        $subCommentRes = DB::fetch("SELECT comment_count FROM item_sub WHERE id={$subItemId} LIMIT 1");
                        if (!empty($subCommentRes)) {
                            $json['countCommentSubItem'] = $subCommentRes['comment_count'];
                        }
                    } else {
                        DB::query("UPDATE item SET reply_count=reply_count-{$countChildDel} WHERE id={$itemId} LIMIT 1");
                        $itemReset = Item::get_item($itemId);
                        $item_memcache = $itemReset;
                        if ($itemReset) {
                            $item_memcache['reply_count'] = $itemReset['reply_count'] - $countChildDel;
                            if (SORL_FILTER_ON) {
                                $solr = new Solr_Search();
                                $solr->doUpdateItem($itemId);
                            }
                            if (MEMCACHE_ON) {
                                eb_memcache::do_put("item:{$itemId}", $item_memcache);
                            }
                            $caheFile = 'fb_' . $itemReset['id'];
                            StaticCache::delCache($caheFile);
                            $json['countCommentItem'] = $item_memcache['reply_count'];
                        }
                    }
                    if ($comment['parent_id'] > 0) {
                        $item_id = $comment['item_id'];
                        if ($comment['parent_id'] > 0) {
                            DB::query('UPDATE 	comment
								   SET 		have_child = have_child-1
								   WHERE 	id=' . $comment['parent_id'] . ' ');
                            if ($comment['display'] == 1) {
                                DB::query('UPDATE comment SET display = 1 where item_id = ' . $comment['item_id'] . ' AND parent_id = ' . $comment['parent_id'] . ' AND display = 0 order by id DESC limit 1');
                            }
                        }
                    }
                    /*Đếm lại commemnt*/
                    $json['msg'] = EClassApi::getParam('id');
                    exit(json_encode($json));
                } else {
                    $json['msg'] = "unsuccess";
                    exit(json_encode($json));
                }
            } else {
                $json['msg'] = "not_perm";
                exit(json_encode($json));
            }
        } else {
            $json['msg'] = "not_perm";
            exit(json_encode($json));
        }
    }
 /**
  * The output buffer callback used to capture the output and cache it.
  *
  * @see StaticCache::init()
  * @param string $buffer The output buffer contents
  * @return string $buffer unchanged
  */
 public static function store_final_output($buffer)
 {
     // prevent caching of 404 responses
     if (!URL::get_matched_rule() || URL::get_matched_rule()->name == 'display_404') {
         return $buffer;
     }
     $request_id = StaticCache::get_request_id();
     $query_id = StaticCache::get_query_id();
     $expire = Options::get('staticcache__expire', StaticCache::EXPIRE);
     // get cache if exists
     if (Cache::has(array(StaticCache::GROUP_NAME, $request_id))) {
         $cache = Cache::get(array(StaticCache::GROUP_NAME, $request_id));
     } else {
         $cache = array();
     }
     // don't cache cookie headers (ie. session cookies)
     $headers = headers_list();
     foreach ($headers as $i => $head) {
         if (stripos($head, 'cookie') !== false) {
             unset($headers[$i]);
         }
     }
     // see if we want compression and store cache
     $cache[$query_id] = array('headers' => $headers, 'request_uri' => Site::get_url('host') . $_SERVER['REQUEST_URI']);
     if (Options::get('staticcache__compress') && extension_loaded('zlib')) {
         $cache[$query_id]['body'] = gzcompress($buffer, StaticCache::GZ_COMPRESSION);
         $cache[$query_id]['compressed'] = true;
     } else {
         $cache[$query_id]['body'] = $buffer;
         $cache[$query_id]['compressed'] = false;
     }
     Cache::set(array(StaticCache::GROUP_NAME, $request_id), $cache, $expire);
     return $buffer;
 }
Exemple #8
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();
 }
 function action_item_comment()
 {
     $act_ = Url::get('act_');
     $comment_id = (int) Url::get('c_item_id', 0);
     $content = '';
     $json = "";
     if (!User::is_login()) {
         $json = '({"msg":"no_login"})';
         echo $json;
         exit;
     }
     if (User::is_block() || !$comment_id || $act_ != 'skip' && $act_ != 'reply') {
         $json = '({"msg":"no_perm"})';
         echo $json;
         exit;
     }
     $comment_row = DB::select('comment', "id={$comment_id}");
     if (!$comment_row) {
         $json = '({"msg":"no_perm"})';
         echo $json;
         exit;
     }
     //if($comment_row['sender_user_id'] == User::id() ||  ($act_=='reply' && $comment_row['status']==1)){//Không được trả lời cho chính mình! hoặc trả lời phản hồi đã đc trả lời rồi!
     if ($comment_row['sender_user_id'] == User::id()) {
         //Không được trả lời cho chính mình!
         $json = '({"msg":"success"})';
         echo $json;
         exit;
     }
     $item_id = $comment_row['item_id'];
     $item = Item::get_item($item_id);
     $item_memcache = $item;
     if (!($item && $item['user_id'] == User::id())) {
         $json = '({"msg":"no_perm"})';
         echo $json;
         exit;
     }
     if ($act_ == 'reply' && $item["state"] == 1 && !User::have_permit(ADMIN_ITEM)) {
         $json = '({"msg":"no_perm"})';
         echo $json;
         exit;
     }
     $json = '({"msg":"success"';
     if ($act_ == 'reply') {
         $content = trim(AZLib::getParam('content'));
         if (!$content) {
             $json = '({"msg":"short_content"})';
             echo $json;
             exit;
         }
         if (AZLib::checkBadWord($content)) {
             $json = '({"msg":"bad_word"})';
             echo $json;
             exit;
         }
         $content = preg_replace("/\n/", "<br />", $content);
         $content = str_replace('<br /><br />', '&nbsp;', $content);
         if ($comment_row['parent_id']) {
             $parent_id = $comment_row['parent_id'];
             if ($comment_row['sender_user_id']) {
                 $content = '@<a href="' . WEB_DIR . $comment_row['sender_user_name'] . '" class="fast_reply_link" title="' . $comment_row['sender_user_name'] . '">' . $comment_row['sender_user_name'] . '</a>: ' . $content;
             } else {
                 $content = '<font color="#999">@<span style="text-decoration:underline">' . $comment_row['sender_user_name'] . '</span> </font>: ' . $content;
             }
         } else {
             $parent_id = $comment_row['id'];
         }
         $comment = array('content' => $content, 'item_id' => $item['id'], 'time' => time(), 'order_time' => time(), 'post_ip' => AZLib::ip(), 'parent_id' => $parent_id, 'receiver_user_id' => $item['user_id'], 'receiver_user_name' => $item['user_name'], 'display' => 1, 'status' => 1);
         $comment['sender_user_id'] = User::id();
         $comment['sender_user_name'] = User::user_name();
         if ($comment_row['sender_user_id']) {
             $comment['replied_user_id'] = $comment_row['sender_user_id'];
             $comment['replied_user_name'] = $comment_row['sender_user_name'];
         }
         $id = DB::insert('comment', $comment);
         if ($id) {
             $re = DB::query("SELECT id FROM comment WHERE parent_id = {$parent_id} AND display = 1 ORDER BY id DESC LIMIT 3,1");
             if ($re) {
                 if ($row = mysql_fetch_assoc($re)) {
                     if ($row) {
                         DB::query("UPDATE comment SET display = 0 WHERE parent_id = {$parent_id} AND display = 1 AND id<={$row['id']}");
                     }
                 }
             }
             if ($comment_id == $parent_id) {
                 DB::query("UPDATE comment SET status = 1, have_child = have_child + 1, order_time = " . time() . " WHERE id = {$comment_id}");
             } else {
                 DB::query("UPDATE comment SET have_child = have_child + 1, order_time = " . time() . " WHERE id = {$parent_id}");
                 DB::query("UPDATE comment SET status = 1 WHERE id = {$comment_id}");
             }
             if ($comment_row['sender_user_id']) {
                 DB::query('UPDATE user SET total_new_comment = total_new_comment + 1 WHERE id=' . $comment_row['sender_user_id']);
                 User::getUser($comment_row['sender_user_id'], 0, 1);
             }
             //Cập nhật đã đọc - trả lời cho feed
             DB::query("UPDATE feed SET status = 1 WHERE ref_id = {$comment_id} AND type=1");
         }
         $total_feedback = DB::count('comment', 'item_id="' . $item['id'] . '"');
         DB::update_id('item', array('reply_count' => $total_feedback), $item['id']);
         if (MEMCACHE_ON) {
             $caheFile = 'fb_' . $item['id'];
             StaticCache::delCache($caheFile);
             $item_memcache['reply_count'] = $total_feedback;
             AZMemcache::do_put("item:{$item['id']}", $item_memcache);
         }
         //Cập nhật cron job
         //...
     } else {
         if ($comment_row['status'] == 0) {
             DB::query("UPDATE comment SET status = 1 WHERE id = {$comment_id}");
         }
         //Cập nhật đã đọc - trả lời cho feed
         DB::query("UPDATE feed SET status = 1 WHERE ref_id = {$comment_id} AND type=1");
     }
     DB::query('UPDATE user SET total_new_comment = total_new_comment - 1 WHERE id=' . User::id() . ' AND total_new_comment>0');
     User::getUser(User::id(), 0, 1);
     $json .= "})";
     echo $json;
     //exit;
     System::halt();
 }
Exemple #10
0
<?php

if (REWRITE_ON) {
    ob_start();
    //start buffering//@ob_start('ob_gzhandler');
}
require_once ROOT_PATH . 'core/AutoLoader.php';
if (MEMCACHE_ON) {
    CGlobal::$memcache_server = $memcache_server;
}
unset($memcache_server, $server_list, $img_server, $img_ftp_server);
if (isset($_REQUEST['trigger']) && (int) $_REQUEST['trigger'] == 1) {
    EBArrCache::del_cache();
    ECCache::auto_delete();
    StaticCache::delCache();
    EClass::del_page_cache();
    exit;
}
if (isset($_GET['page']) && $_GET['page'] == 'error') {
    define('ERROR_PAGE', 1);
} else {
    define('ERROR_PAGE', 0);
}
if (!EClassApi::is_search_engine() && !defined('NO_SESSION') && !ERROR_PAGE) {
    if (SESSION_TYPE == 'db') {
        require_once ROOT_PATH . 'includes/session.class.php';
        //Session db store
    } elseif (SESSION_TYPE == 'memcache') {
        require_once ROOT_PATH . "includes/memcache.session.php";
        //Session memcache store
    } else {
Exemple #11
0
 static function endCache($return = false)
 {
     //if(!CACHE_ON)
     //return ;
     self::$curentContent = ob_get_contents();
     ob_end_clean();
     if (CACHE_ON) {
         if (MEMCACHE_ON) {
             if (self::$curentCacheFilePath != '') {
                 eb_memcache::do_put("scache:" . self::$curentCacheFilePath, self::$curentContent, self::$curentExpTime);
                 if (DEBUG) {
                     self::$pNum++;
                     if (class_exists('Module')) {
                         if (class_exists('Module') && Module::$name != '') {
                             $module_name = Module::$name;
                         } else {
                             $module_name = "-- Enbac system";
                         }
                     }
                     $info = "<b>" . $module_name . "</b><br /><font color=red><b>scache:" . self::$curentCacheFilePath . "</b></font><br /><b>Created:</b> " . date('d/m/Y H:i:s', TIME_NOW) . " <b>Expire:</b> " . (self::$curentExpTime ? self::$curentExpTime . ' sec ' : 'Forever');
                     self::$cacheFilesList .= "<li>" . $info . "</li>";
                 }
                 self::$curentCacheFilePath = '';
                 self::$curentExpTime = 0;
             } else {
                 if (DEBUG) {
                     self::$pNum++;
                     if (class_exists('Module') && Module::$name != '') {
                         $module_name = Module::$name;
                     } else {
                         $module_name = "-- Enbac system";
                     }
                     $info = "<b>" . $module_name . "</b><br /><font color=red><b>No file</b></font><br />";
                     self::$cacheFilesList .= "<li>" . $info . "</li>";
                 }
                 self::$curentExpTime = 0;
             }
         } else {
             if (self::$curentCacheFilePath != '') {
                 @file_put_contents(self::$curentCacheFilePath, self::$curentContent);
                 if (DEBUG) {
                     self::$pNum++;
                     if (class_exists('Module') && Module::$name != '') {
                         $module_name = Module::$name;
                     } else {
                         $module_name = "-- Enbac system";
                     }
                     $info = "<b>" . $module_name . "</b><br /><font color=red><b>" . self::$curentCacheFilePath . "</b></font><br /><b>Created:</b> " . date('d/m/Y H:i:s', TIME_NOW) . " <b>Expire:</b> " . (self::$curentExpTime ? date('d/m/Y H:i:s', self::$curentExpTime + TIME_NOW) : 'Forever');
                     self::$cacheFilesList .= "<li>" . $info . "</li>";
                 }
                 self::$curentCacheFilePath = '';
                 self::$curentExpTime = 0;
             } else {
                 if (DEBUG) {
                     self::$pNum++;
                     if (class_exists('Module') && Module::$name != '') {
                         $module_name = Module::$name;
                     } else {
                         $module_name = "-- Enbac system";
                     }
                     $info = "<b>" . $module_name . "</b><br /><font color=red><b>No file</b></font><br />";
                     self::$cacheFilesList .= "<li>" . $info . "</li>";
                 }
                 self::$curentExpTime = 0;
             }
         }
     }
     if ($return) {
         return self::$curentContent;
     } elseif (!self::$handleContent) {
         echo self::$curentContent;
     }
     return true;
 }
Exemple #12
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 #13
0
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>";
}
Exemple #14
0
 function fn_del_static_cache()
 {
     if (!User::is_login()) {
         echo "not_login";
         exit;
     }
     if (!User::have_permit(ADMIN_ITEM)) {
         echo "no_perm";
         exit;
     }
     $cache_file = Url::get('cache_file');
     StaticCache::delCache($cache_file);
     echo 'success';
     exit;
 }
Exemple #15
0
 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 #16
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();
 }