Exemplo n.º 1
0
 function AdminNews($row)
 {
     Module::Module($row);
     if (User::is_admin()) {
         $cmd = Url::get('cmd');
         switch ($cmd) {
             case "edit":
             case "add_item":
                 require_once 'forms/detail.php';
                 $this->add_form(new AdminNewsDetail());
                 break;
             case "delete":
                 $url = urldecode(Url::get('url'));
                 $id = Url::get('id');
                 if (!is_numeric($id)) {
                     Url::redirect('admin_news_item');
                     return;
                 }
                 DB::delete_id('news_item', $id);
                 eb_memcache::do_remove('news_item:' . $id);
                 Url::redirect_url($url);
                 break;
             default:
                 require_once 'forms/list.php';
                 $this->add_form(new AdminNewsForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
Exemplo n.º 2
0
 function AdminNewsCategory($row)
 {
     Module::Module($row);
     if (User::is_admin()) {
         $cmd = Url::get('cmd');
         switch ($cmd) {
             case "edit":
             case "add_category":
                 require_once 'forms/detail.php';
                 $this->add_form(new AdminNewsCategoryDetail());
                 break;
             case "delete":
                 $id = Url::get('id');
                 if (!is_numeric($id)) {
                     Url::redirect('admin_news_category');
                     return;
                 }
                 DB::delete_id('news_category', $id);
                 eb_memcache::do_remove('news_category/all');
                 eb_memcache::do_remove('news_category:' . $id);
                 Url::redirect('admin_news_category');
                 break;
             default:
                 require_once 'forms/list.php';
                 $this->add_form(new AdminNewsCategoryForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
Exemplo n.º 3
0
Arquivo: Util.php Projeto: hqd276/bigs
 static function getAssets($type)
 {
     $assets = eb_memcache::do_get('cpvm_' . $type);
     if (!$assets) {
         $assets = Assets::get_collection(null, null, null, $type);
         eb_memcache::do_put('cpvm_' . $type, $assets, 24 * 60 * 60);
     }
     return $assets;
 }
Exemplo n.º 4
0
 function on_submit()
 {
     $status = (int) Url::get('status');
     $sms_total = (int) Url::get('sms_total');
     $user_name = Url::get('user_name', '');
     $note = Url::get('note', '');
     if ($user_name != '') {
         if (DB::select("sms_user_active", "user_name='{$user_name}'")) {
             $this->setFormError("user_name", "Thành viên này đã tồn tại trong danh sách quản lý THÀNH VIÊN CHỨNG THỰC");
         } else {
             if ($status == 1) {
                 //Kích hoạt
                 $user = User::getByUserName($user_name);
                 $this->a_row['a_time'] = TIME_NOW;
                 if ($user) {
                     if ($user['level'] == 0) {
                         DB::query("UPDATE account SET level = 1 WHERE id={$user['id']}");
                         if (MEMCACHE_ON) {
                             $user['level'] = 1;
                             eb_memcache::do_put("user:{$user['id']}", $user);
                         }
                     }
                 } else {
                     $this->setFormError('', "Tài khoản không tồn tại!");
                 }
             } else {
                 //Bỏ Kích hoạt
                 $this->a_row['a_time'] = 0;
                 $user = User::getByUserName($user_name);
                 if ($user) {
                     if ($user['level'] == 1) {
                         DB::query("UPDATE account SET level = 0 WHERE id={$user['id']}");
                         if (MEMCACHE_ON) {
                             $user['level'] = 0;
                             eb_memcache::do_put("user:{$user['id']}", $user);
                         }
                     }
                 } else {
                     $this->setFormError('', "Tài khoản không tồn tại!");
                 }
             }
             if (!$this->errNum) {
                 $this->a_row['user_id'] = $user['id'];
                 $this->a_row['user_name'] = $user['user_name'];
                 $this->a_row['sms_total'] = (int) ($sms_total <= 0 ? 0 : $sms_total);
                 $this->a_row['status'] = $status;
                 $this->a_row['note'] = $note;
                 DB::insert("sms_user_active", $this->a_row);
                 Url::redirect_current();
             }
         }
     } else {
         $this->setFormError('user_name', "Bạn chưa nhập vào tài khoản!");
     }
 }
Exemplo n.º 5
0
 function on_submit()
 {
     $status = (int) Url::get('status');
     $sms_total = (int) Url::get('sms_total');
     $note = Url::get('note', '');
     if ($status == 1 && $this->a_row['status'] != 1) {
         //Kích hoạt
         if ($this->a_row['user_id']) {
             $user = User::getUser($this->a_row['user_id']);
             if ($user) {
                 if ($user['level'] == 0) {
                     DB::query("UPDATE account SET level = 1 WHERE id={$user['id']}");
                     if (MEMCACHE_ON) {
                         $user['level'] = 1;
                         eb_memcache::do_put("user:{$user['id']}", $user);
                     }
                 }
             } else {
                 $this->setFormError("user_name", "Tài khoản không tồn tại!");
             }
         }
     } elseif (($status == 0 || $status == 2) && $this->a_row['status'] == 1) {
         //Bỏ Kích hoạt
         if ($this->a_row['user_id']) {
             $user = User::getUser($this->a_row['user_id']);
             if ($user) {
                 if ($user['level'] == 1) {
                     DB::query("UPDATE account SET level = 0 WHERE id={$user['id']}");
                     if (MEMCACHE_ON) {
                         $user['level'] = 0;
                         eb_memcache::do_put("user:{$user['id']}", $user);
                     }
                 }
             } else {
                 $this->setFormError("user_name", "Tài khoản không tồn tại!");
             }
         }
     }
     if (!$this->errNum) {
         $array = array('status' => $status, 'note' => $note, 'm_time' => TIME_NOW, 'm_user_name' => User::user_name(), 'sms_total' => (int) ($sms_total <= 0 ? 0 : $sms_total));
         if ($status == 1) {
             $array['a_time'] = TIME_NOW;
         } else {
             $array['a_time'] = 0;
         }
         DB::update("sms_user_active", $array, "id=" . $this->a_row['id']);
         Url::redirect_current();
     }
 }
Exemplo n.º 6
0
 static function connect()
 {
     if (!CGlobal::$memcache_connect_id && !eb_memcache::$crashed) {
         if (!function_exists('memcache_connect')) {
             //dl("php_memcache.dll");
             //dl("php_xdebug.dll");
             eb_memcache::$crashed = 1;
             return FALSE;
         }
         eb_memcache::$identifier = MEMCACHE_ID;
         //eb_memcache::$identifier = 'chonmon.vn';
         if (!CGlobal::$memcache_server || !count(CGlobal::$memcache_server)) {
             eb_memcache::$crashed = 1;
             return FALSE;
         }
         if (DEBUG) {
             $rtime = microtime();
             $rtime = explode(" ", $rtime);
             $rtime = $rtime[1] + $rtime[0];
             $start_rb = $rtime;
         }
         for ($i = 0, $n = count(CGlobal::$memcache_server); $i < $n; $i++) {
             $server = CGlobal::$memcache_server[$i];
             if ($i < 1) {
                 CGlobal::$memcache_connect_id = memcache_connect($server['host'], $server['port']);
             } else {
                 memcache_add_server(CGlobal::$memcache_connect_id, $server['host'], $server['port']);
             }
             if (DEBUG) {
                 $mtime = microtime();
                 $mtime = explode(" ", $mtime);
                 $mtime = $mtime[1] + $mtime[0];
                 $end_rb = $mtime;
                 $load_time = round($end_rb - $start_rb, 5) . "s";
                 CGlobal::$conn_debug .= " <b>Connect to Memcache server : {$server['host']} : {$server['port']} </b> [in {$load_time}]<br>\n";
             }
         }
         if (!CGlobal::$memcache_connect_id) {
             eb_memcache::$crashed = 1;
             return FALSE;
         }
         if (function_exists('memcache_set_compress_threshold')) {
             memcache_set_compress_threshold(CGlobal::$memcache_connect_id, 20000, 0.2);
         }
         //memcache_debug( eb_memcache::$debug );
     }
     return CGlobal::$memcache_connect_id;
 }
Exemplo n.º 7
0
 function on_submit()
 {
     $id = intval(Url::get('id'));
     $data['title'] = Url::get('title');
     $data['title_en'] = Url::get('title_en');
     $data['category_id'] = intval(trim(Url::get('category_id', 0)));
     $data['description'] = Url::get('description');
     $data['description_en'] = Url::get('description_en');
     $data['content'] = Url::get('content');
     $data['content_en'] = Url::get('content_en');
     $data['image'] = '';
     $data['keywords'] = Url::get('keywords');
     $data['post_day'] = trim(Url::get('post_day'));
     if (!empty($data['post_day'])) {
         $data['post_day'] = EClassApi::render_time($data['post_day']);
     } else {
         $data['post_day'] = time();
     }
     $data['is_active'] = Url::get('is_active', 0);
     $data['hot_article'] = Url::get('hot_article', 0);
     $data['top_home'] = Url::get('top_home', 0);
     if (empty($data['shortcut'])) {
         $data['shortcut'] = strtolower(EClassApi::safe_title($data['title']));
     } else {
         $data['shortcut'] = strtolower(EClassApi::safe_title(Url::get('shorcut')));
     }
     if (isset($_FILES["file"]) && $_FILES["file"]["size"] > 0) {
         $store_in = 'files/news/' . date('Y/m/d') . '/';
         if (!file_exists($store_in)) {
             mkdir($store_in, 0775, true);
         }
         move_uploaded_file($_FILES["file"]["tmp_name"], $store_in . $_FILES["file"]["name"]);
         $data['image'] = $store_in . $_FILES["file"]["name"];
     } else {
         unset($data['image']);
     }
     if (intval($id) == 0) {
         $data['uid'] = User::id();
         $id = DB::insert('news_item', $data);
         $this->setSuccessMessage('news/item/form', serialize($data));
         $this->setSuccessMessage('news/item/success', 'Lưu thông tin bài viết [' . $data['title'] . '] thành công');
     } else {
         DB::update('news_item', $data, 'id=' . $id);
         $this->setSuccessMessage('news/item/success', 'Cập nhật thông tin bài viết [' . $data['title'] . '] thành công');
     }
     Url::redirect_url('admin_news_item.html?cmd=edit&id=' . $id);
     eb_memcache::do_remove('news_item:' . $id);
 }
Exemplo n.º 8
0
<?php

require_once '../../../core/config.php';
//System Config...
require_once '../../../core/Init.php';
//System Init...
require_once '../../../core/DB.php';
//System Api...
$token = Url::get('t', '');
$user = eb_memcache::do_get($token);
if (!$user) {
    Util::requestToMobile(false, 19);
}
$user = eb_memcache::do_remove($token);
// $_SESSION['token']='';
User::LogOut();
Util::requestToMobile(true, 35);
Exemplo n.º 9
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;
 }
Exemplo n.º 10
0
 static function update_category($data, $conds)
 {
     $data = NewsCategory::safe_data($data);
     $id = DB::update('news_category', $data, $conds);
     eb_memcache::do_remove('news_category/all');
     if (empty($id)) {
         return false;
     }
     return $id;
 }
Exemplo n.º 11
0
	function update_user_online(){
		$user_id   = isset($_SESSION['user_id'])?(int)$_SESSION['user_id']:0;
		
		if($user_id)
		{
			$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('EClass')){
				$page		=EClass::$page['name'];
				$page_id	=(int)EClass::$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{
				EClassApi::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
												  	session_expires = ".time().", 
												  	session_referer = '".addslashes($ref_url)."',
												  	session_ip 		= '".$_SERVER['SERVER_ADDR'].'::'.$_SERVER['REMOTE_ADDR']."', 
												  	page 			= '$page',	
												  	page_id 		= $page_id,
												  	category_id 	= ".CGlobal::$curCategory.",
												  	item_id 		= $item_id,
												  	user_id 		= '$user_id',
												  	user_name		= '$user_name',
												  	login_type		= '$login_type',
												  	open_id			= '$open_id'
												WHERE session_id 	= '$session_id'";
			}
			else{
				$sql = "INSERT INTO "._SESS_TABLE." 
								  (
								  	session_id, 
								  	session_expires,  
								  	session_referer, 
								  	session_ip,   
								  	page,  
								  	page_id, 
								  	category_id, 
								  	item_id, 
								  	user_id,  
								  	user_name,
								  	login_type,
								  	open_id
								  	) 
		                   VALUES (
		                   			'$session_id', 				
		                   			".time().", 			
		                   			'".addslashes($ref_url)."', 	   
		                   			'".$_SERVER['SERVER_ADDR'].'::'.$_SERVER['REMOTE_ADDR']."',	
		                   			'$page',	  
		                   			$page_id,		   
		                   			".CGlobal::$curCategory.", 		 
		                   			$item_id, 	  
		                   			$user_id ,		
		                   			'$user_name' ,		
		                   			$login_type ,		
		                   			'$open_id')";
			}
		                   
			DB::query($sql,__LINE__.__FILE__);
			
			if(User::is_login() && MEMCACHE_ON){//Nếu đã đăng nhập
				$user = User::$current->data;
				if($user && !isset($user['last_login']) || (isset($user['last_login']) && $user['last_login']<(TIME_NOW-300))){
					DB::query("UPDATE account SET last_login="******" WHERE id={$user['id']}");
					
					$user_memcache = eb_memcache::do_get("user:{$user['id']}");
					if($user_memcache){
						$user_memcache['last_login'] = TIME_NOW;
						eb_memcache::do_put("user:{$user['id']}", $user_memcache);
					}
				}
			}
		}
	}
Exemplo n.º 12
0
 function remove_favourite()
 {
     $json = array();
     if (!User::is_login()) {
         $json['msg'] = 'no_login';
         die(json_encode($json));
     }
     $uid = User::id();
     $fid = EClassApi::getParam('fid');
     DB::delete('account_food_favourites', 'uid=' . $uid . ' AND fid=' . $fid);
     // get count like of food
     $sql = 'SELECT count_like, rid FROM food_res WHERE id = ' . $fid . ' ORDER BY id DESC LIMIT 0, 1';
     $result = DB::query($sql);
     $row = mysql_fetch_assoc($result);
     mysql_free_result($result);
     $count_like = intval($row['count_like']) - 1;
     $update_row = array('count_like' => $count_like);
     DB::update_id('food_res', $update_row, $fid);
     if (MEMCACHE_ON) {
         eb_memcache::do_remove('list_favourites_' . $uid);
         eb_memcache::do_remove('supplier_food_' . $row['rid']);
         eb_memcache::do_remove('supplier_spec_food_' . $row['rid']);
     }
     $json['fid'] = $fid;
     $json['msg'] = 'success';
     die(json_encode($json));
 }
Exemplo n.º 13
0
 public function getItemAdvertiseById($id)
 {
     $item = '';
     if (MEMCACHE_ON) {
         $item = eb_memcache::do_get('item_advertise_widget_' . $id);
     }
     if (!$item) {
         $result = DB::query("SELECT * FROM advertise WHERE status = 1 AND id = {$id}");
         $item = array();
         if ($result) {
             while ($row = mysql_fetch_assoc($result)) {
                 $row['image'] = EClassApi::getImageThumb($row['images'], 130, 110, 0, IMAGE_SERVER_NO);
                 $row['price'] = EClassApi::numberFormat($row['price']);
                 $item = $row;
             }
             eb_memcache::do_put('item_advertise_widget_' . $id, $item);
         }
     }
     return $item;
 }
Exemplo n.º 14
0
	function UserActive($row){
		Module::Module($row);
		
		if(User::is_admin() || User::have_permit(user_active_all_perm)){
			$cmd	=	Url::get('cmd');
			switch($cmd)
			{		
				case 'del':
					if(User::is_root()){
						$a_id	=	Url::get('id');
						
						if($a_id){
							$sms_user_active = DB::select('sms_user_active',"id=$a_id");
							
							if($sms_user_active){
								//if($sms_user_active['status'] == 1 && $sms_user_active['user_id']){
								if($sms_user_active['user_id']){
									$user = User::getUser($sms_user_active['user_id']);
									
									if($user && $user['level'] == 1){
										DB::query("UPDATE account SET level = 0 WHERE id={$user['id']}");
										
										if(MEMCACHE_ON){
											$user['level'] = 0;
											
											eb_memcache::do_put("user:{$user['id']}",$user);
										}
									}
								}
								
								DB::delete('sms_user_active',"id=$a_id");
							}
						}
					}
					Url::redirect_current();
					break;
				case 'active':
					$a_id	=	Url::get('id');
					if($a_id)
					{
						$sms_user_active = DB::select('sms_user_active',"id=$a_id");
						
						if($sms_user_active){
							if($sms_user_active['user_id']){
								$user = User::getUser($sms_user_active['user_id']);
								
								if($user && $user['level'] == 0){
									DB::query("UPDATE account SET level = 1 WHERE id={$user['id']}");
									
									if(MEMCACHE_ON){
										$user['level'] = 1;
										
										eb_memcache::do_put("user:{$user['id']}",$user);
									}
								}
							}
							
							DB::query("UPDATE sms_user_active SET status = 1, a_time=".TIME_NOW.", m_time=".TIME_NOW.", m_user_name='".User::user_name()."' WHERE id=$a_id");
						}
					}
					Url::redirect_current();
					break;
				case 'deactive':
					$a_id	=	Url::get('id');
					if($a_id){
						
						$sms_user_active = DB::select('sms_user_active',"id=$a_id");
						
						if($sms_user_active){
							if($sms_user_active['user_id']){
								$user = User::getUser($sms_user_active['user_id']);
								
								if($user && $user['level'] == 1){
									DB::query("UPDATE account SET level = 0 WHERE id={$user['id']}");
									
									if(MEMCACHE_ON){
										$user['level'] = 0;
										
										eb_memcache::do_put("user:{$user['id']}",$user);
									}
								}
							}
					 		DB::query("UPDATE sms_user_active SET status = 0, a_time=0, m_time=".TIME_NOW.", m_user_name='".User::user_name()."' WHERE id=$a_id");
						}
					}
					Url::redirect_current();
					break;
				case 'edit':
					require_once 'forms/UserActiveEdit.php';
					$this->add_form(new UserActiveEditForm());
					break;
				case 'add':
					require_once 'forms/UserActiveAdd.php';
					$this->add_form(new UserActiveAddForm());
					break;
				default: 
					require_once 'forms/UserActive.php';
					$this->add_form(new UserActiveForm());
					break;
			}
		}
		else{
			Url::access_denied();
		}
	}
Exemplo n.º 15
0
 function editItemMobi()
 {
     $itemId = Url::get('item_id', '');
     $status = Url::get('status');
     $json = array();
     if (!$itemId) {
         $json['msg'] = "error_item";
         die(json_encode($json));
     }
     $data = array('status' => $status);
     eb_memcache::do_remove("item:" . $itemId);
     DB::update('item', $data, "id={$itemId}");
     $json['msg'] = "success";
     die(json_encode($json));
 }
Exemplo n.º 16
0
 function category_new_delete()
 {
     $id = Url::get('id');
     echo DB::update('products_category', array('published' => -1), "id={$id}");
     eb_memcache::do_remove('categories_new');
     exit;
 }
Exemplo n.º 17
0
 function on_submit()
 {
     $insert_arr = array('filter_name' => trim(Url::get('filter_name', '')), 'zone_id' => Url::get('zone_id', 0), 'cat_product_id' => Url::get('cat_product_id', 0), 'filter_type' => Url::get('filter_type', 0), 'status' => Url::get('status', 0), 'description' => Url::get('description', ''), 'lbl_price_search' => Url::get('lbl_price_search', ''), 'interval_price_search' => Url::get('interval_price_search', 0), 'orders' => Url::get('orders', 0), 'link_fix' => Url::get('link_fix', ''), 'type' => Url::get('type', 0));
     $file_name = strtolower($_FILES['image']['name']);
     $upload_path = 'category/';
     $max_upload_file_size = 2 * 1024 * 1024;
     $file_ext = EClassApi::getExtension(strtolower($file_name));
     if ($file_name && in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png')) && filesize($_FILES['image']['tmp_name']) < $max_upload_file_size) {
         $new_path = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(EClassApi::make_safe_name(basename($file_name, $file_ext)), 0, 36) . $file_ext;
         $insert_arr['image'] = $new_path;
         @EClassApi::ftp_image_put_file($new_path, $_FILES['image']['tmp_name'], IMAGE_SERVER_NO);
     }
     $filter_value = array();
     $value = Url::get('value');
     $title = Url::get('title', array());
     $description = Url::get('des_filter');
     $image = '';
     $status = Url::get('status_filter');
     $order = Url::get('order');
     $bold = Url::get('bold_filter');
     foreach ($title as $key => $val) {
         if ($val != '') {
             $filter_value[$key]['title'] = $val;
             $filter_value[$key]['value'] = $value[$key];
             $filter_value[$key]['description'] = $description[$key];
             $filter_value[$key]['status'] = $status[$key];
             $filter_value[$key]['bold'] = $bold[$key];
             $filter_value[$key]['order'] = $order[$key];
             $file_name = strtolower($_FILES['image']['name']);
             $upload_path = 'category/';
             $max_upload_file_size = 2 * 1024 * 1024;
             $file_ext = EClassApi::getExtension(strtolower($file_name));
             if ($file_name && in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png')) && filesize($_FILES['images_filter']['tmp_name'][$key]) < $max_upload_file_size) {
                 $new_path = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(EClassApi::make_safe_name(basename($file_name, $file_ext)), 0, 36) . $file_ext;
                 $filter_value[$key]['image'] = $new_path;
                 @EClassApi::ftp_image_put_file($new_path, $_FILES['images_filter']['tmp_name'][$key], IMAGE_SERVER_NO);
             }
         }
     }
     $insert_arr['filter_value'] = json_encode($filter_value);
     if ($insert_arr['filter_name'] == '') {
         Url::redirect_current();
     }
     DB::insert('products_filter', $insert_arr);
     if (MEMCACHE_ON) {
         eb_memcache::do_remove('allProductFilter');
         eb_memcache::do_remove('ProductFilter_' . $insert_arr['cat_product_id']);
     }
     Url::redirect_current();
 }
Exemplo n.º 18
0
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm(1);
     $arrVar['id'] = Url::get('id', 0);
     $options = "";
     if ($arrVar['id'] == 0) {
         Url::redirect_current();
     }
     EClassApi::getCats();
     $where = '';
     $filter = DB::fetch_all_array("select * from products_filter where id={$arrVar['id']}");
     $filte_value = json_decode($filter[0]['filter_value']);
     $arrVar['filter'] = $filter[0];
     $arrVar['filter_value'] = $filte_value;
     $item_per_page = 50;
     $limit = '';
     $sql_count = "SELECT COUNT(*) AS total FROM products_extra_fields_group {$where}";
     $total = DB::fetch($sql_count, 'total', 0);
     if ($total) {
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Nhóm trường', 'Trang');
         $re = DB::query("SELECT * FROM products_extra_fields_group {$where} order by id desc  {$limit}");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $products_extra_fields_group[$row['id']] = $row;
             }
         }
     }
     $filter_count = 0;
     foreach ($filte_value as $key => $val) {
         if ($filter_count < $val->order) {
             $filter_count = $val->order;
         }
     }
     if (count($filte_value) > $filter_count) {
         $filter_count = count($filte_value);
     }
     $categories = eb_memcache::do_get('categories_new');
     if (!is_array($categories)) {
         //if($total){
         require_once ROOT_PATH . 'core/ECPagging.php';
         $re = DB::query("SELECT * FROM products_category  order by orders");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $categories[$row['parent_id']][$row['id']] = $row;
             }
         }
         eb_memcache::do_put('categories_new', $categories);
     }
     print_category($categories, 0, $options, $filter[0]['zone_id'], $filter[0]['cat_product_id']);
     $arrVar['options'] = $options;
     $arrVar['filter_count'] = $filter_count;
     $arrVar['zones'] = CGlobal::$allZones;
     $arrVar['paging'] = $paging;
     $arrVar['products_extra_fields_group'] = $products_extra_fields_group;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilterEdit', $arrVar);
     $this->endForm();
 }
Exemplo n.º 19
0
}
if (strlen($password) < 6 || strlen($password) > 20) {
    Util::requestToMobile(false, 8);
}
if (substr($user_name, 0, 3) != 'fb_' && substr($user_name, 0, 3) != 'zm_') {
    if (!ctype_alnum($user_name)) {
        Util::requestToMobile(false, 9);
    }
}
if (DB::exists('SELECT id FROM `account` WHERE `user_name`="' . $user_name . '"')) {
    Util::requestToMobile(false, 12);
} else {
    $user_info = array('user_name' => $user_name, 'full_name' => $full_name, 'password' => md5($password), 'create_time' => TIME_NOW, 'is_active' => (int) (bool) USER_ACTIVE_ON, 'reg_ip' => EClassApi::ip(), 'mobile' => $mobile);
    $id = DB::insert('account', $user_info);
    $user_info['id'] = $id;
    //update to memcache
    eb_memcache::do_put('user_' . $user_name, $user_info);
    if ($id) {
        User::LogIn($id);
        $_SESSION['user_name'] = $user_name;
        $token = md5(time() . "_" . $id . "egame!@#\$");
        $_SESSION['token'] = $token;
        $user = array('id' => $id, 'un' => $user_name, 'fn' => $full_name);
        eb_memcache::do_put($token, array('user' => $user, 'timeout' => time()), 3600 * 24 * 30);
        $data['u'] = $user;
        $data['t'] = $token;
        Util::requestToMobile(true, 13, $data);
    } else {
        Util::requestToMobile(false, 14, $data);
    }
}
Exemplo n.º 20
0
    function gallery_update() {//Cập nhật ảnh cho thư viện
        if (User::have_permit(ADMIN_IMAGE) && (int) Url::get('user_id', 0) && (int) Url::get('user_id', 0) != User::id()) {
            $user_id = (int) Url::get('user_id', 0);
        } else {
            $user_id = User::id();
        }

        $image_id = (int) $_GET['image_id'];
        $json['error'] = 'not_updated'; //not_uploaded
        $json['url_error'] = '';
        $json['original_image_url'] = '';

        if (User::is_login()) {
            if (User::is_foodnet_team() || User::level() > 0) {
                if ($image_id) {
                    $des = substr(EClassApi::trimSpace(EClassApi::cleanHtml($_POST['des_update'])), 0, 50);
                    $image = DB::select('item_image', 'id=' . $image_id . ' AND root_id=0 AND user_id=' . $user_id);

                    if ($image) {
                        $upload_path = EClassApi::folderUpload($user_id);

                        if (EClassApi::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) {//Check dir for upload
                            if (isset($_FILES['img_upload_update']) && !$_FILES['img_upload_update']['error'] && $_FILES['img_upload_update']['name']) {
                                if (getimagesize($_FILES['img_upload_update']['tmp_name']) && $_FILES['img_upload_update']['size'] <= Item::MAX_UPLOAD_SIZE) {
                                    $file_name = $_FILES['img_upload_update']['name'];
                                    $sourceName = $_FILES['img_upload_update']['tmp_name'];
                                    $file_ext = EClassApi::getExtension($file_name);

                                    if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) {
                                        $original_image_url = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(EClassApi::make_safe_name(basename(strtolower($file_name), $file_ext)), 0, 36) . $file_ext;

                                        if (EClassApi::ftp_image_put_file($original_image_url, $sourceName, IMAGE_SERVER_NO)) {
                                            if (DB::update('item_image', array(
                                                        'des' => $des,
                                                        'img_server' => IMAGE_SERVER_NO,
                                                        'original_image_url' => $original_image_url
                                                            ), 'id=' . $image_id . ' OR root_id=' . $image_id)) {
                                                if ($image['original_image_url']) {
                                                    EClassApi::ftp_image_delete_file($image['original_image_url'], $image['img_server']);

                                                    if (MEMCACHE_ON) {

                                                        $sql = "SELECT * FROM item	WHERE original_image_url='{$image['original_image_url']}' AND status IN(1,2)  AND user_id=" . $user_id;
                                                        $re = DB::query($sql);

                                                        while ($item_memcache = mysql_fetch_assoc($re)) {
                                                            $item_memcache['img_server'] = IMAGE_SERVER_NO;
                                                            $item_memcache['original_image_url'] = $original_image_url;
                                                            eb_memcache::do_put("item:" . $item_memcache['id'], $item_memcache);
                                                             if(SORL_FILTER_ON){
                                                               $solr = new Solr_Search();
                                                               $solr->doUpdateItem($item_memcache['id']);
                                                               }
                                                        }
                                                    }

                                                    DB::query("UPDATE item SET img_server = " . (int) IMAGE_SERVER_NO . ", original_image_url='{$original_image_url}' WHERE original_image_url='{$image['original_image_url']}' AND status IN(1,2)  AND user_id=" . $user_id);

                                                }
                                                $json['img_server'] = IMAGE_SERVER_NO;
                                                $json['original_image_url'] = $original_image_url;
                                                $json['error'] = 'success';
                                            } else {
                                                $json['error'] = 'not_updated';
                                            }
                                        }
                                    } else {
                                        $json['error'] = 'ext_invalid'; //Sai định dạng file
                                    }
                                } else {
                                    $json['error'] = 'over_max_size'; //Sai định dạng file hoặc upload dung lượng quá lớn
                                }
                            } elseif ($_POST['url_update']) {
                                $url = $_POST['url_update'];

                                $tem_cache_dir = DIR_CACHE . 'user_images/';
                                EClassApi::CheckDir($tem_cache_dir);

                                $tem_cache_file = User::user_name() . md5($url) . '.gif';
                                $image_content = disguise_curl($url);

                                if ($image_content) {
                                    if (@file_put_contents($tem_cache_dir . $tem_cache_file, $image_content)) {
                                        if (getimagesize($tem_cache_dir . $tem_cache_file) && filesize($tem_cache_dir . $tem_cache_file) <= Item::MAX_UPLOAD_SIZE) {
                                            $sourceName = $tem_cache_dir . $tem_cache_file;
                                            $original_image_url = $upload_path . TIME_NOW . '_' . $tem_cache_file;

                                            if (EClassApi::ftp_image_put_file($original_image_url, $sourceName, IMAGE_SERVER_NO)) {
                                                if (DB::update('item_image', array(
                                                            'des' => $des,
                                                            'img_server' => IMAGE_SERVER_NO,
                                                            'original_image_url' => $original_image_url)
                                                                , 'id=' . $image_id . ' OR root_id=' . $image_id)) {
                                                    if ($image['original_image_url']) {
                                                        EClassApi::ftp_image_delete_file($image['original_image_url'], $image['imng_server']);
                                                        if (MEMCACHE_ON) {
                                                            $sql = "SELECT * FROM item	WHERE original_image_url='{$image['original_image_url']}' AND status IN(1,2)  AND user_id=" . $user_id;
                                                            $re = DB::query($sql);

                                                            while ($item_memcache = mysql_fetch_assoc($re)) {
                                                                $item_memcache['img_server'] = IMAGE_SERVER_NO;
                                                                $item_memcache['original_image_url'] = $original_image_url;
                                                                eb_memcache::do_put("item:" . $item_memcache['id'], $item_memcache);
                                                                if(SORL_FILTER_ON){
                                                                   $solr = new Solr_Search();
                                                                   $solr->doUpdateItem($item_memcache['id']);
                                                                   }
                                                            }
                                                        }

                                                        DB::query("UPDATE item SET original_image_url='{$original_image_url}' WHERE original_image_url='{$image['original_image_url']}' AND status IN(1,2) AND user_id=" . $user_id);

                                                    }
                                                    $json['url_error'] = 'success';
                                                    $json['img_server'] = IMAGE_SERVER_NO;
                                                    $json['original_image_url'] = $original_image_url;
                                                } else {
                                                    $json['url_error'] = 'not_updated';
                                                }
                                            }
                                            else
                                                $json['url_error'] = 'not_uploaded';
                                        }
                                        else
                                            $json['url_error'] = 'over_max_size';

                                        @unlink($tem_cache_dir . $tem_cache_file);
                                    }
                                    else
                                        $json['url_error'] = 'not_cache_file';
                                }
                                else
                                    $json['url_error'] = 'not_get_img';
                            }
                            else {
                                if ($des != $image['des']) {
                                    if (DB::update('item_image', array('des' => $des), 'id=' . $image_id)) {
                                        $json['error'] = 'success';
                                    } else {
                                        $json['error'] = 'not_updated';
                                    }
                                } else {
                                    $json['error'] = 'success';
                                }
                            }
                        }
                        $json['des'] = $des;

                        //get Item_id
                        $sql = "SELECT item_id FROM item_image WHERE (id = $image_id OR root_id = $image_id) " . (User::have_permit(ADMIN_IMAGE) ? '' : " AND user_id=" . User::id());
                        $re = DB::query($sql);

                        if ($re) {
                            $item = mysql_fetch_assoc($re);
                            if ($item["item_id"]) {
                                require_once ROOT_PATH . 'core/Item.php';
                                Item::get_item_images($item["item_id"], 1);
                            }
                        }
                    } else {
                        $json['error'] = 'not_exit';
                    }

                    //get Item_id
                    $sql = "SELECT item_id FROM item_image WHERE id = $image_id";
                    $re = DB::query($sql);
                    if ($re) {
                        $item = mysql_fetch_assoc($re);
                        require_once ROOT_PATH . 'core/Item.php';
                        Item::get_item_images($item["item_id"], 1);
                    }
                }
            }
        } else {
            $json['error'] = 'not_login';
        }

        echo json_encode($json);
        exit();
    }
Exemplo n.º 21
0
 static function remove_cache() {
     eb_memcache::do_remove(PREFIX_CONFIG_CACHE_COLLECTION);
     return true;
 }
Exemplo n.º 22
0
Arquivo: DB.php Projeto: hqd276/bigs
 static function getFields($table_name, $call_pos = '')
 {
     $fields = false;
     if (MEMCACHE_ON && isset($_GET['delcache']) && $_GET['delcache'] == 1) {
         eb_memcache::do_remove('fields_' . $table_name);
     }
     if (MEMCACHE_ON && !isset($_GET['delcache'])) {
         $fields = eb_memcache::do_get('fields_' . $table_name);
     }
     if (!$fields) {
         $q_select = "SHOW COLUMNS FROM {$table_name}";
         self::query($q_select, $call_pos);
         if (self::$db_result) {
             while ($r = mysql_fetch_assoc(self::$db_result)) {
                 $fields[$r['Field']]['key'] = $r['Key'];
                 $fields[$r['Field']]['extra'] = $r['Extra'];
                 $fields[$r['Field']]['name'] = $r['Field'];
                 $fields[$r['Field']]['data'] = '';
                 $strLength = strlen($r['Type']);
                 $len = stripos($r['Type'], '(') - $strLength;
                 $fields[$r['Field']]['type'] = substr($r['Type'], 0, $len);
                 $fields[$r['Field']]['type_length'] = substr($r['Type'], stripos($r['Type'], '(') + 1, -1);
             }
             if (MEMCACHE_ON) {
                 eb_memcache::do_put('fields_' . $table_name, $fields, 0);
             }
         }
     }
     $curTable['fields'] = $fields;
     return $curTable;
 }
Exemplo n.º 23
0
 static function get()
 {
     if (isset($_GET['delcache']) && (int) $_GET['delcache'] == 1) {
         self::auto_delete(self::_my_file());
         return false;
     }
     if (MEMCACHE_ON) {
         $arr = eb_memcache::do_get("qcache:" . self::_my_file());
         if ($arr !== false) {
             return $arr;
         }
     } else {
         $cfile = DIR_CACHE . 'db/' . self::_my_file();
         if (file_exists($cfile)) {
             self::$createdTime = filemtime($cfile);
             if (self::$expire > 0 && TIME_NOW < self::$createdTime + self::$expire || self::$expire == 0) {
                 return unserialize(stripslashes(@file_get_contents($cfile)));
             }
         }
     }
     return false;
 }
Exemplo n.º 24
0
    static function update_cache_comment($item_id)
    {
        if (MEMCACHE_ON) {
            $item_comment_cache_version = eb_memcache::do_get("comment_cache:" . $item_id . ":comment_cache_version");
            eb_memcache::do_put("comment_cache:" . $item_id . ":comment_cache_version", $item_comment_cache_version + 1);

        }

    }
Exemplo n.º 25
0
 function on_submit()
 {
     $zone_id = Url::get('zone_id');
     $cat_product_id = Url::get('cat_product_id');
     $check_filter = Url::get('check_filter');
     if (empty($check_filter)) {
         Url::redirect_current();
     }
     $products_extra_fields_id = "";
     foreach ($check_filter as $key => $val) {
         if ($products_extra_fields_id == '') {
             $products_extra_fields_id .= $val;
         } else {
             $products_extra_fields_id .= "," . $val;
         }
     }
     $sql = "select * from products_extra_fields where `group`=(SELECT extra_fields_group FROM products_category WHERE id={$cat_product_id}) AND published=1 AND id in ({$products_extra_fields_id}) ORDER BY ordering";
     $filters = DB::fetch_all($sql);
     $sql = "select id,filter_name from products_filter where filter_name in (select name from products_extra_fields  where `group`=(SELECT extra_fields_group FROM products_category WHERE" . " id={$cat_product_id}) AND published=1 AND id in ({$products_extra_fields_id})  ORDER BY ordering) and cat_product_id={$cat_product_id}";
     $re = DB::query($sql);
     $filters_exit = array();
     if ($re) {
         while ($row = mysql_fetch_array($re)) {
             $filters_exit[$row['id']] = $row['filter_name'];
         }
     }
     foreach ($filters as $key => $val) {
         $filter_items = json_decode($val['value']);
         $filter_value = array();
         foreach ($filter_items as $k => $v) {
             $filter_value[$k]['title'] = $v->name;
             $filter_value[$k]['value'] = "fin{$val['id']}:{$v->value}";
             $filter_value[$k]['description'] = '';
             $filter_value[$k]['status'] = 1;
             $filter_value[$k]['bold'] = 0;
             $filter_value[$k]['order'] = $k + 1;
         }
         $insert_arr['filter_value'] = json_encode($filter_value);
         if (!in_array($val['name'], $filters_exit)) {
             $insert_arr['filter_name'] = $val['name'];
             $insert_arr['zone_id'] = $zone_id;
             $insert_arr['cat_product_id'] = $cat_product_id;
             $insert_arr['status'] = 1;
             $insert_arr['type'] = 1;
             $insert_arr['filter_type'] = 2;
             $insert_arr['orders'] = 1;
             DB::insert('products_filter', $insert_arr);
         } else {
             $insert_arr['filter_name'] = $val['name'];
             DB::update('products_filter', $insert_arr, "filter_name='" . $val['name'] . "'");
         }
     }
     if (MEMCACHE_ON) {
         eb_memcache::do_remove('allProductFilter');
         eb_memcache::do_remove('ProductFilter_' . $cat_product_id);
     }
     Url::redirect_current();
     /*             $insert_arr=array(
                 'filter_name'=>trim(Url::get('filter_name','')),
                 'zone_id'=>Url::get('zone_id',0),
                 'cat_product_id'=>Url::get('cat_product_id',0),
                 'filter_type'=>Url::get('filter_type',0),
                 'status'=>Url::get('status',0),
                 'description'=>Url::get('description',''),
                 'lbl_price_search'=>Url::get('lbl_price_search',''),
                 'interval_price_search'=>Url::get('interval_price_search',0),
                 'orders'=> Url::get('orders',0),
                 'link_fix'=>Url::get('link_fix',''),
                 'type'=>Url::get('type',0),
     
             );*/
 }
Exemplo n.º 26
0
 static function del_cache($cache_key = '')
 {
     if ($cache_key != '') {
         if (MEMCACHE_ON) {
             eb_memcache::do_remove("acache:{$cache_key}");
         } else {
             if (is_array(CGlobal::$my_server)) {
                 foreach (CGlobal::$my_server as $server) {
                     $link = "http://{$server}/?trigger=1&cache_arr={$cache_key}";
                     if (@fopen($link, "r")) {
                         //if(DEBUG){echo "run service in $link <br>";}
                     } else {
                         if (DEBUG) {
                             echo "error in {$link}  <br>";
                         }
                     }
                 }
             }
         }
         return true;
     } elseif (isset($_REQUEST['trigger'], $_REQUEST['cache_arr']) && $_REQUEST['trigger'] && $_REQUEST['cache_arr']) {
         $cache_arr = $_REQUEST['cache_arr'];
         @unlink(DIR_CACHE . "arr/{$cache_arr}.eb");
         if (MEMCACHE_ON) {
             eb_memcache::do_remove('acache:' . $cache_arr);
         }
         if (DEBUG) {
             echo "Deleted Array cache file : {$cache_arr}";
         }
         exit;
     }
 }
Exemplo n.º 27
0
 function get_all_comment()
 {
     global $display;
     $winner = array();
     global $user_id_arr, $stt, $item_per_page;
     $stt = 0;
     $is_admin_mod = array();
     $user_arr = array();
     $user_id_arr = array();
     $items = array();
     $limit = '';
     $divID = 'comment_list_all';
     $cmd = 'pagging_comment';
     $url_path = WEB_DIR . "ajax.php?act=comment&code=display_feedback&show_all=1&id=" . Item::$id . "&cmd=" . $cmd;
     $item_per_page = 50;
     if (Url::get('show_all') || Url::get('cmd') == $cmd) {
         $display->add('show_all', true);
     } else {
         $display->add('show_all', false);
     }
     $pagging = ECPagging::fb_pagging($limit, $item_per_page, true, 'fb_page', $url_path, $divID);
     $sql = "SELECT id, time, content, item_id, sender_email, sender_user_name, sender_user_id, have_child,receiver_user_id,sub_item_id FROM comment WHERE item_id=" . Item::$item['id'] . " AND sub_item_id=0 AND parent_id = 0 ORDER BY order_time DESC {$limit}";
     $comment_cache_version = eb_memcache::do_get("comment_cache:" . Item::$id . ":{$limit}:comment_cache_version");
     $item_comment_cache_version = eb_memcache::do_get("comment_cache:" . Item::$id . ":comment_cache_version");
     //echo "comment_cache:".Item::$id.":$limit:comment_cache_version".$item_comment_cache_version;
     if ($item_comment_cache_version != $comment_cache_version || $item_comment_cache_version == 0) {
         if ($item_comment_cache_version == 0) {
             $item_comment_cache_version = 1;
             eb_memcache::do_put("comment_cache:" . Item::$id . ":comment_cache_version", $item_comment_cache_version);
         }
         $items_all = $this->get_comment($sql);
         if ($items_all) {
             $items = $items_all['item'];
             if ($items_all['id_parent']) {
                 $sql_sub = "SELECT id, time, content, item_id, sender_email, sender_user_name, sender_user_id,parent_id,receiver_user_id,sub_item_id FROM comment WHERE parent_id IN({$items_all['id_parent']}) ORDER BY order_time DESC";
                 $subComment_all = $this->get_comment($sql_sub, 1);
                 if ($subComment_all) {
                     $sub_comments = $subComment_all['item'];
                     foreach ($sub_comments as $id => $subs) {
                         if (isset($items[$id])) {
                             $items[$id]['sub_comment'] = $subs;
                         }
                     }
                 }
             }
             unset($items_all);
             unset($subComment_all);
         }
         $display->add('show_fb_page', true);
         $display->add('pagging', $pagging);
         if ($user_id_arr) {
             $uid = implode(',', $user_id_arr);
             if ($uid != '') {
                 $re = DB::query("SELECT id, avatar_url, gids, block_time, img_server FROM account WHERE id IN({$uid})");
                 if ($re) {
                     while ($user = mysql_fetch_assoc($re)) {
                         $user_arr[$user['id']] = $user;
                     }
                 }
             }
         }
         if ($items && $user_arr) {
             foreach ($items as &$item) {
                 //add by nhatvt
                 $item['content'] = $this->process_description($item['content']);
                 //                echo $item['content'];exit;
                 //end
                 if (isset($item['sub_comment']) && $item['sub_comment']) {
                     foreach ($item['sub_comment'] as &$sub_item) {
                         if ($sub_item['sender_user_id']) {
                             if (isset($user_arr[$sub_item['sender_user_id']])) {
                                 $sub_item['avatar_url'] = $user_arr[$sub_item['sender_user_id']]['avatar_url'];
                                 $sub_item['block_time'] = $user_arr[$sub_item['sender_user_id']]['block_time'];
                                 $sub_item['gids'] = $user_arr[$sub_item['sender_user_id']]['gids'];
                                 $sub_item['img_server'] = $user_arr[$sub_item['sender_user_id']]['img_server'];
                             }
                             if ($sub_item['avatar_url']) {
                                 $sub_item['sender_avatar_url'] = EClassApi::getImageThumb($sub_item['avatar_url'], 60, 0, 1, $sub_item['img_server']);
                                 if ($sub_item['parent_id'] > 0) {
                                     $html_content = '<a href="' . $sub_item['sender_link'] . '"><img src="' . $sub_item['sender_avatar_url'] . '" width="40" class="lazyload"/></a>';
                                 } else {
                                     $html_content = '<a href="' . $sub_item['sender_link'] . '"><img src="' . $sub_item['sender_avatar_url'] . '" width="40" class="lazyload"/></a>';
                                 }
                             } else {
                                 $sub_item['sender_avatar_url'] = WEB_DIR . '_cache/eb_avatar/' . md5($item['sender_user_name']) . '.gif';
                                 //'style/avatar/1.png';
                                 $html_content = '<a href="' . $sub_item['sender_link'] . '"><img src="' . $sub_item['sender_avatar_url'] . '" width="40" height="40" class="lazyload"/></a>';
                             }
                             if ($sub_item['block_time'] > TIME_NOW) {
                                 $sub_item['is_block'] = 1;
                             } else {
                                 $sub_item['is_block'] = 0;
                             }
                             $sub_item['htmlContent'] = $html_content;
                             //set quyen quan tri
                             if ($sub_item['gids']) {
                                 $is_admin_mod = CGlobal::$group[User::check_admin($sub_item['gids'])];
                             } else {
                                 $is_admin_mod = array();
                             }
                             $sub_item['is_admin_mod'] = $is_admin_mod;
                         }
                     }
                 }
                 if ($item['sender_user_id']) {
                     if (isset($user_arr[$item['sender_user_id']])) {
                         $item['avatar_url'] = $user_arr[$item['sender_user_id']]['avatar_url'];
                         $item['block_time'] = $user_arr[$item['sender_user_id']]['block_time'];
                         $item['gids'] = $user_arr[$item['sender_user_id']]['gids'];
                         $item['img_server'] = $user_arr[$item['sender_user_id']]['img_server'];
                     }
                     if ($item['avatar_url']) {
                         $item['sender_avatar_url'] = EClassApi::getImageThumb($item['avatar_url'], 60, 0, 1, $item['img_server']);
                         $html_content = '<a href="' . $item['sender_link'] . '"><img src="' . $item['sender_avatar_url'] . '" width="40"/></a>';
                     } else {
                         $item['sender_avatar_url'] = 'style/avatar/1.png';
                         $html_content = '<a href="' . $item['sender_link'] . '"><img src="style/avatar/3.png" width="40" height="40" /></a>';
                     }
                     $item['htmlContent'] = $html_content;
                     if ($item['block_time'] > TIME_NOW) {
                         $item['is_block'] = 1;
                     } else {
                         $item['is_block'] = 0;
                     }
                     //set quyen quan tri
                     if ($item['gids']) {
                         $is_admin_mod = CGlobal::$group[User::check_admin($item['gids'])];
                     } else {
                         $is_admin_mod = array();
                     }
                     $item['is_admin_mod'] = $is_admin_mod;
                 }
             }
         }
         if (User::is_login() && Item::$item['user_id'] == User::id()) {
             $account = User::$current->data;
         } else {
             if (isset(Item::$item['user_id'])) {
                 $account = User::getUser(Item::$item['user_id']);
             }
             if (!$account) {
                 $account = array('id' => 0, 'user_name' => '', 'create_time' => '', 'blast' => '', 'email' => '', 'show_email' => '', 'skype_id' => '', 'yahoo_id' => '');
             }
         }
         if (User::is_login()) {
             if (User::$current->data['mobile_phone'] != '') {
                 $display->add('user_phone', true);
                 $user_phone = User::$current->data['mobile_phone'];
             } elseif (User::$current->data['home_phone'] != '') {
                 $display->add('user_phone', true);
                 $user_phone = User::$current->data['home_phone'];
             } else {
                 $display->add('user_phone', false);
                 $user_phone = '';
             }
             $display->add('cur_user_name', User::$current->data['user_name']);
             $display->add('cur_created_time', User::$current->data['create_time']);
             $cur_user_name = User::$current->data['user_name'];
             $cur_created_time = User::$current->data['create_time'];
             if (User::$current->data['avatar_url'] == '') {
                 $cur_avatar_url = 'style/avatar/1.png';
             } else {
                 $cur_avatar_url = EClassApi::getImageThumb(User::$current->data['avatar_url'], 60, 0, 1, User::$current->data['img_server']);
             }
         } else {
             $cur_user_name = '';
             $cur_created_time = '';
             $user_phone = '';
             $cur_avatar_url = 'style/avatar/2.png';
             $display->add('cur_user_name', '');
             $display->add('cur_created_time', '');
             $display->add('check_user_name', '');
             $display->add('user_phone', false);
         }
         $guest_name = 'Số điện thoại';
         $guest_email = 'Email';
         if (isset($_COOKIE['guest_name'])) {
             if ($_COOKIE['guest_name'] == 'undefined' || $_COOKIE['guest_email'] == 'undefined') {
                 $guest_name = 'Số điện thoại';
                 $guest_email = 'Email';
             } else {
                 $guest_name = $_COOKIE['guest_name'];
                 $guest_email = $_COOKIE['guest_email'];
             }
         }
         $display->add('cur_user_name', $cur_user_name);
         $display->add('guest_name', $guest_name);
         $display->add('guest_email', $guest_email);
         $display->add('check_user_name', $account['user_name']);
         $display->add('cur_id', (int) User::id());
         //$display->add('msg',$this->showFormErrorMessages(1));
         //$display->add('pagging',$pagging);
         // System::debug($items);
         $display->add('item_comments', $items);
         $display->add('item_id', Item::$item['id']);
         $display->add('category_id', Item::$item['category_id']);
         $display->add('item_name', Item::$item['name']);
         //rewrite URL
         $display->add('name_url', EClassApi::safe_title(Item::$item['name']));
         //End rewrite URL
         Item::$item['currency_id'] = 1;
         $display->add('currency_id', CGlobal::$currency[Item::$item['currency_id']]);
         $display->add('total_feedback', Item::$item['reply_count']);
         if (strtolower(Url::get('page')) == 'allfeedback' || Url::get('cmd') == $cmd) {
             echo '<div id="totalReplyCount" style="display:none;">' . Item::$item['reply_count'] . '</div>';
         }
         //echo EClassApi::parseBBCode($display->output('AllFeedback',true));
         $template = $display->output('AllFeedbackListold', true, 'AllFeedback');
         //$display->output('FeedBackItemList',false,'AllFeedback');
         eb_memcache::do_put("comment_cache:" . Item::$id . ":{$limit}", $template);
         eb_memcache::do_put("comment_cache:" . Item::$id . ":{$limit}:comment_cache_version", $item_comment_cache_version);
         //echo "updated:comment_cache:".Item::$id.":$limit:comment_cache_version".$item_comment_cache_version;
         echo $template;
     } else {
         //echo "cached:".Item::$id.":$limit:comment_cache_version".$item_comment_cache_version;
         $template = eb_memcache::do_get("comment_cache:" . Item::$id . ":{$limit}");
         echo $template;
     }
     EClassApi::update_cache_comment(Item::$id);
 }
Exemplo n.º 28
0
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm();
     EClassApi::getCats();
     $where = '';
     $filter_id = Url::get('filter_id', '');
     $filter_name = Url::get('filter_name', '');
     $cat_product_id = Url::get('cat_product_id', '');
     $zone_id = Url::get('zone_id', '');
     $arrVar['zone_id'] = $zone_id;
     $arrVar['cat_product_id'] = $cat_product_id;
     if ($filter_id) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " id = '{$filter_id}' ";
         $arrVar['filter_id'] = $filter_id;
     }
     if ($filter_name) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " filter_name = '{$filter_name}' ";
         $arrVar['filter_name'] = $filter_name;
     }
     if ($cat_product_id) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " cat_product_id = '{$cat_product_id}' ";
     } else {
         if ($zone_id) {
             $where .= ($where != '' ? ' AND ' : 'WHERE ') . " zone_id = '{$zone_id}' ";
         }
     }
     $item_per_page = 50;
     $limit = '';
     $item_vips = array();
     $sql_count = "SELECT COUNT(*) AS total FROM products_filter {$where} ";
     $total = DB::fetch($sql_count, 'total', 0);
     $paging = '';
     $filters = array();
     if ($total) {
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 20, 'page_no', true);
         $re = DB::query("SELECT * FROM products_filter {$where} order by orders {$limit}");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $filters[$row['id']] = $row;
             }
         }
     }
     $categories = eb_memcache::do_get('categories_new');
     if (!is_array($categories)) {
         //if($total){
         require_once ROOT_PATH . 'core/ECPagging.php';
         $re = DB::query("SELECT * FROM products_category  order by orders");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $categories[$row['parent_id']][$row['id']] = $row;
             }
         }
         eb_memcache::do_put('categories_new', $categories);
     }
     print_category($categories, 0, $options, $zone_id, $cat_product_id);
     $arrVar['options'] = $options;
     $arrVar['zones'] = CGlobal::$allZones;
     $arrVar['filters'] = $filters;
     $arrVar['paging'] = $paging;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilter', $arrVar);
     $this->endForm();
 }
Exemplo n.º 29
0
Arquivo: User.php Projeto: hqd276/bigs
    static function getUser($user_id, $update_cache = false, $delcache = false)
    {
        $user = array();
        /*if($user_id){
              $subDir='user/'.floor($user_id/1000);
              $user = ECCache::cache('SELECT * FROM account WHERE id='.(int)$user_id.' LIMIT 0,1',__LINE__.__FILE__,2592000,$update_cache,'',$subDir,$delcache);
          }
          if($user&&!$delcache){
              $user[0]['is_block'] = ($user[0]['block_time']>TIME_NOW || $user[0]['block_time']==-1)?true:false;
              return $user[0];
          }*/
        if ($user_id) {
            if (MEMCACHE_ON) {
                if ($delcache || $update_cache) { //Xoá cache
                    if (MEMCACHE_ON) {
                        eb_memcache::do_remove("user:$user_id");
                    }
                    return true;
                } else {
                    if (MEMCACHE_ON) {
                        $user = eb_memcache::do_get("user:$user_id");
                    }

                    if (!$user) {
                        $sql = "SELECT * FROM account WHERE id=" . (int)$user_id . " LIMIT 1";
                        $user = mysql_fetch_assoc(DB::query($sql));

                        //$user['is_block'] = ($user['block_time']>TIME_NOW || $user['block_time']==-1)?true:false;

                        if (MEMCACHE_ON && $user) {
                            eb_memcache::do_put("user:$user_id", $user);
                        }
                    }
                }
            } else { //cache file
                //echo "ddđ"; exit();
                $subDir = 'user/' . floor($user_id / 1000);
                $user = ECCache::cache('SELECT * FROM account WHERE id=' . (int)$user_id . ' LIMIT 0,1', __LINE__ . __FILE__, 2592000, intval($update_cache), '', $subDir, $delcache);

                if ($user && !$delcache) {
                    $user[0]['is_block'] = ($user[0]['block_time'] > TIME_NOW || $user[0]['block_time'] == -1) ? true : false;
                    return $user[0];
                }
            }
        }

        return $user;
    }
Exemplo n.º 30
0
 function delete_register_service()
 {
     if (!User::is_login()) {
         echo "not_login";
         exit;
     }
     if (User::is_block()) {
         echo "no_permission";
         exit;
     }
     $user = User::$current->data;
     $id = (int) Url::get('service_id', 0);
     $aryOrderService = array();
     if ($id) {
         $aryOrderService = DB::select("order_services", "id={$id}");
     }
     $pr_info = array();
     if ($aryOrderService) {
         if ($aryOrderService['active'] != -2) {
             DB::update('order_services', array('active' => -2, 'time_del' => TIME_NOW, 'user_del' => User::user_name()), "id={$aryOrderService['id']}");
             DB::update('payment_scs', array('del_status' => -1), "order_service_id={$aryOrderService['id']}");
             //tra lai so tien khong su dung cho user
             $user_onDB = DB::select('account', "id={$user['id']}");
             $last_money_used = $user_onDB['money_used'] - $aryOrderService['price'] / 1000;
             if ($aryOrderService['payment_types'] == 5) {
                 $pr_info = DB::select('payment_premium', "log_id={$aryOrderService['id']}");
                 if ($pr_info) {
                     if ($pr_info['status'] != 2) {
                         DB::update('account', array('money_used' => $last_money_used), "user_name='{$user['user_name']}'");
                         DB::update('payment_premium', array('status' => 2), "log_id={$aryOrderService['id']}");
                     }
                 }
             }
             if (MEMCACHE_ON) {
                 $user['money_used'] = $last_money_used;
                 eb_memcache::do_put("user:{$user['id']}", $user);
             }
         }
         echo "success";
         exit;
     }
     echo "error";
     exit;
 }