Exemplo n.º 1
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.º 2
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.º 3
0
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm(1);
     $options = "";
     EClassApi::getCats();
     $where = '';
     $group_id = Url::get('group_id', '');
     $group_name = Url::get('group_name', '');
     if ($group_id) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " id = '{$group_id}' ";
         $arrVar['group_id'] = $group_id;
     }
     if ($group_name) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " name = '{$group_name}' ";
         $arrVar['group_name'] = $group_name;
     }
     $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;
             }
         }
     }
     $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);
     //}
     $arrVar['options'] = $options;
     $arrVar['zones'] = CGlobal::$allZones;
     $arrVar['paging'] = $paging;
     $arrVar['products_extra_fields_group'] = $products_extra_fields_group;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilterAdd', $arrVar);
     $this->endForm();
 }
Exemplo n.º 4
0
 static function set($array)
 {
     if (CACHE_ON && self::$cache_file) {
         if (MEMCACHE_ON) {
             eb_memcache::do_put("acache:" . self::$cache_file, $array, self::$expire);
         } else {
             @file_put_contents(self::$cache_file, addslashes(serialize($array)));
         }
         self::$arr_cache = $array;
     }
     return true;
 }
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
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm(0);
     EClassApi::getCats();
     $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);
     }
     $arrVar['zones'] = CGlobal::$allZones;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilterSync', $arrVar);
     $this->endForm();
 }
Exemplo n.º 7
0
 static function get_category($cat_id, $refresh = true)
 {
     if (is_numeric($cat_id) && $cat_id > 0) {
         $sql = 'SELECT * FROM news_category WHERE id=' . $cat_id . ' LIMIT 0, 1';
         if ($refresh) {
             $query = DB::query($sql);
             $category = mysql_fetch_assoc($query);
             if (empty($category['shortcut'])) {
                 if (empty($category['name_en'])) {
                     $category['name_en'] = $category['name'];
                 }
                 $category['shortcut'] = strtolower(EClassApi::safe_title($category['name']));
             }
             eb_memcache::do_put('news_category/' . $cat_id, $category, 5000);
             mysql_free_result($query);
         } else {
             $category = eb_memcache::do_get('news_category:' . $cat_id);
             if (empty($category)) {
                 NewsCategory::get_category($cat_id, true);
             }
         }
         return $category;
     }
 }
Exemplo n.º 8
0
 function submit_payandship()
 {
     /*$site_code   = Url::get('site_code',"");
       $secure_hash = Url::get('secure_hash',"");*/
     $user_id = Url::get('user_id');
     $status = Url::get('status');
     $msg = "";
     /*if(!$site_code || !$secure_hash){
           if(DB::update('account',array('payship' => $payType, 'soha_site_code' => '', 'soha_secure_hash' => ''),'id='.$user_id)){
               DB::update('account_payship',array('status' => 1),'account_id='.$user_id);
               $msg = "success_des";
           }
       }
       else*/
     if ($status != 0) {
         $payType = 0;
         $userStatus = 1;
     } else {
         $payType = 2;
         $userStatus = 3;
     }
     if (DB::update('account', array('payship' => $payType), 'id=' . $user_id)) {
         DB::update('account_payship', array('status' => $userStatus), 'account_id=' . $user_id);
         if ($payType == 0) {
             $msg = "success_des";
         } else {
             $msg = "success";
         }
     }
     if (MEMCACHE_ON) {
         $user = eb_memcache::do_get("user:{$user_id}");
         if ($user) {
             $user['payship'] = $payType;
             //$user['soha_site_code'] = $site_code;
             //$user['soha_secure_hash'] = $secure_hash;
             eb_memcache::do_put("user:{$user_id}", $user);
         }
     }
     echo $msg;
     exit;
 }
Exemplo n.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
0
 function getItemVipCat()
 {
     EClassApi::getCities();
     EClassApi::getCats();
     //get ID VIP CAT
     if (MEMCACHE_ON) {
         $category_id = CGlobal::$curCategory;
         $id_vip_cat = eb_memcache::do_get("id_vip_cat:{$category_id}");
         if (!$id_vip_cat || $id_vip_cat['ex_time'] < TIME_NOW) {
             $id_vip_cat = $this->getIdVipCat();
             eb_memcache::do_put("id_vip_cat:{$category_id}", $id_vip_cat);
         }
     } else {
         $id_vip_cat = $this->getIdVipCat();
     }
     $str_item_id = '';
     if (isset($id_vip_cat['id'])) {
         foreach ($id_vip_cat['id'] as $val) {
             $str_item_id .= $str_item_id != '' ? ",{$val}" : "{$val}";
         }
     }
     $items = array();
     if ($str_item_id != '') {
         $sql = 'SELECT id, name, up_time, created_time, user_id, user_name, description, city_id, category_id, currency_id, price, original_image_url, img_server FROM item WHERE';
         $where = '';
         $where .= ($where != '' ? " AND " : "") . " id IN({$str_item_id})";
         $where .= ($where != '' ? " AND " : "") . " (status=1 OR status = 2)";
         $sql .= "{$where} ORDER BY up_time DESC";
         $items = array();
         $re = DB::query($sql);
         if ($re) {
             while ($value = mysql_fetch_assoc($re)) {
                 $value['price'] = EClassApi::convertCurrency($value['price'], $value['currency_id']);
                 $value['currency_id'] = 1;
                 if (isset(CGlobal::$allCategories[$value['category_id']])) {
                     $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']) . '&nice_name=' . CGlobal::$allCategories[$value['category_id']]['nice_name']);
                 } else {
                     $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']));
                 }
                 $value['item_time'] = date('h:i | d.m', $value['created_time']);
                 $value['price_name'] = 'Giá bán';
                 $value['item_type'] = 'Giao dịch bán';
                 $value['name'] = strip_tags(EClassApi::filter_title($value['name']));
                 if ($value['price'] && $value['price'] > 0) {
                     $value['price'] = number_format($value['price'], 0, ',', '.');
                     $value['currency_id'] = CGlobal::$currency[$value['currency_id']];
                 } else {
                     $value['price'] = 'Liên hệ';
                     $value['currency_id'] = '';
                 }
                 if ($value['original_image_url']) {
                     $value['original_image_url'] = EClassApi::getImageThumb($value['original_image_url'], 80, 80, 0, $value['img_server']);
                 } else {
                     $value['original_image_url'] = 'style/images/no-images-69x53.jpg';
                 }
                 $value['profile_url'] = WEB_DIR . $value['user_name'];
                 $value['user_name_title'] = $value['user_name'];
                 $value['user_name'] = strlen($value['user_name']) > 10 ? substr($value['user_name'], 0, 10) . '...' : $value['user_name'];
                 if (isset(CGlobal::$cities[$value['city_id']])) {
                     $value['city'] = CGlobal::$cities[$value['city_id']]['name'];
                 } else {
                     $value['city'] = "Toàn quốc";
                 }
                 $value['vip_cat_img'] = "style/images/item-list/item_vip.gif";
                 $value['can_buy'] = 0;
                 $items[$value['id']] = $value;
             }
         }
     }
     //        $items['str_item_id'] = $str_item_id;
     return $items;
 }
Exemplo n.º 15
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.º 16
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.º 17
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.º 18
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.º 19
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.º 20
0
 function set_schedule_up()
 {
     $item_id = (int) Url::get('item_id', 0);
     $response = array();
     if ($item_id > 0 && User::is_login() && !User::is_block()) {
         $user = array();
         $item = array();
         $up_item = array();
         $up_items = array();
         $user = array();
         $item = Item::get_item($item_id);
         if ($item && $item['status'] != -1) {
             $response['item_id'] = $item_id;
             $response['reload_page'] = (int) Url::get('reload_page', 0);
             if (User::id() == $item['user_id']) {
                 $up_rows = array();
                 //Bản ghi up lịch
                 $user = DB::select('account', "id={$item['user_id']}");
                 $re = DB::query("SELECT * FROM up_item_schedule WHERE item_id={$item_id} ORDER BY run_order");
                 if ($re) {
                     while ($s_item = mysql_fetch_assoc($re)) {
                         $up_rows[] = $s_item;
                     }
                 }
                 if ($up_rows) {
                     $up_exist = true;
                     $up_item = $up_rows[0];
                     foreach ($up_rows as $u_item) {
                         if ($u_item['up_remain'] > $up_item['up_remain']) {
                             $up_item['up_remain'] = $u_item['up_remain'];
                         }
                     }
                     if ($up_item['up_remain'] < 0) {
                         $up_item['up_remain'] = 0;
                     }
                 } else {
                     $up_exist = false;
                     $up_item = array("up_remain" => 0, "time_add" => TIME_NOW);
                     /*$response['msg'] = "not_exist";
                     		
                     		echo json_encode($response);
                     		exit;*/
                 }
                 ##################################################################################
                 #Ngày up trong tuần
                 $week_day_arr = Url::get('week_day');
                 if ($week_day_arr) {
                     $week_day_tmp = array(2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0);
                     foreach ($week_day_arr as $wday => $val) {
                         if (isset($week_day_tmp[$wday])) {
                             $week_day_tmp[$wday] = (int) (bool) $val;
                         }
                     }
                     $week_day = implode('|', $week_day_tmp);
                 } else {
                     $response['msg'] = "choose_wday";
                     echo json_encode($response);
                     //'Bạn phải chọn ngày up trong tuần!'
                     exit;
                 }
                 ##################################################################################
                 ##################################################################################
                 #Thời điểm up mỗi ngày
                 $string_up_time = Url::get('string_up_time');
                 if ($string_up_time != '') {
                     $arr_time = explode('|', $string_up_time);
                     $run_hours = array();
                     //Giờ từng lượt up
                     $run_mins = array();
                     //Phút từng lượt up
                     $time_temp = array();
                     //Thời điểm up tính từ mốc 0 của thời gian
                     foreach ($arr_time as $value) {
                         $arr_temp = explode(':', $value);
                         $uTime = mktime($arr_temp[0], $arr_temp[1], 0, 0, 0, 0);
                         $complain = false;
                         /*foreach ($time_temp as $time_val)
                         		{
                         			if ($uTime == $time_val)
                         			{
                         				$complain = true;
                         			}
                         			else
                         			{
                         				$complain = false;
                         			}
                         		}
                         		if(!$complain)
                         		{
                         			$time_temp[] = $uTime;
                         		}	
                         		*/
                         if (!in_array($uTime, $time_temp)) {
                             $time_temp[] = $uTime;
                             //Cho vào mảng thời điểm up tạm
                         }
                     }
                     sort($time_temp);
                     //Sắp xếp thứ tự
                     foreach ($time_temp as $val) {
                         $run_hours[] = date('H', $val);
                         $run_mins[] = date('i', $val);
                     }
                     ##################################################################################
                     $up_remain = (int) Url::get('up_remain', 0);
                     //Tổng số lần up cho cả lịch up
                     if ($up_remain < 0) {
                         $up_remain = 0;
                     }
                     $run_times = array();
                     $last_time = 0;
                     $i = 1;
                     $first_time = 1;
                     //lần up đầu tiên
                     if ($run_hours) {
                         $wday_now = date('N', time()) - 1;
                         foreach ($run_hours as $stt => $hour) {
                             if (isset($run_mins[$stt])) {
                                 $cur_time = mktime($hour, $run_mins[$stt], 0, date('m', TIME_NOW), date('d', TIME_NOW), date('Y', TIME_NOW));
                                 if ($last_time) {
                                     if ($cur_time <= $last_time + 899) {
                                         continue;
                                         //Bỏ qua
                                         /*$response['msg'] 	= "run_hour_error";
                                         											$response['alert'] 	= "Thời gian lượt up thứ $i phải muộn hơn lần up thứ ".($i-1)." ít nhất 15 phút!";
                                         	
                                         											echo json_encode($response);
                                         											exit;*/
                                     }
                                 }
                                 $last_time = $cur_time;
                                 $arr = explode('|', $week_day);
                                 $wday_up = $wday_now;
                                 //Tính thời gian up kế tiếp của bản ghi
                                 $time_next_run = $cur_time;
                                 if ($time_next_run <= TIME_NOW + 5 || !isset($arr[$wday_up]) || isset($arr[$wday_up]) && !$arr[$wday_up]) {
                                     $first_time++;
                                     //$wday_up = $wday_now;
                                     $w_temp = $wday_up++;
                                     while ($wday_up < 7) {
                                         if (isset($arr[$wday_up]) && $arr[$wday_up]) {
                                             $time_next_run = $cur_time + 86400 * ($wday_up - $wday_now);
                                             if ($time_next_run > TIME_NOW + 5) {
                                                 //nếu thời gian up kế tiếp lớn hơn thời gian hiện tại + 5 giây
                                                 break;
                                             }
                                         }
                                         $wday_up++;
                                     }
                                     if (!isset($arr[$wday_up]) || isset($arr[$wday_up]) && !$arr[$wday_up]) {
                                         $wday_up = 0;
                                         //while ($wday_up<7){
                                         while ($wday_up < $w_temp) {
                                             if (isset($arr[$wday_up]) && $arr[$wday_up]) {
                                                 $time_next_run = $cur_time + 86400 * (7 - $wday_now + $wday_up);
                                                 if ($time_next_run > TIME_NOW + 5) {
                                                     //nếu thời gian up kế tiếp lớn hơn thời gian hiện tại + 5 giây
                                                     break;
                                                 }
                                             }
                                             $wday_up++;
                                         }
                                     }
                                 }
                                 $run_times[] = array('time_run' => str_pad($hour, 2, "0", STR_PAD_LEFT) . '-' . str_pad($run_mins[$stt], 2, "0", STR_PAD_LEFT), 'time_next_run' => $time_next_run);
                                 $i++;
                             }
                         }
                     }
                     if ($run_times) {
                         $up_per_day = count($run_times);
                         foreach ($run_times as $stt => $time) {
                             $stt++;
                             $up_items[] = array('run_order' => $stt, 'time_run' => $time['time_run'], 'time_next_run' => $time['time_next_run']);
                         }
                     } else {
                         $response['msg'] = "run_hour";
                         echo json_encode($response);
                         //'Bạn phải chọn ít nhất 1 lần up / ngày!'
                         exit;
                     }
                     if ($first_time > $up_per_day) {
                         $first_time = 1;
                     }
                     $up_item['status'] = (int) Url::get('status', 0);
                     //0:tat,1:bat
                     if ($up_remain <= 0) {
                         $response['msg'] = "up_zero";
                         echo json_encode($response);
                         //Chưa nhập lượt up
                         exit;
                     }
                     if ($up_item['up_remain'] != $up_remain) {
                         if ($user['up_item'] + $up_item['up_remain'] < $up_remain) {
                             //Tài khoản ko đủ để tăng tổng số lượt up sẽ dùng cho tin
                             $up_remain = $user['up_item'] + $up_item['up_remain'];
                             if ($up_remain <= 0) {
                                 $response['msg'] = "up_over";
                                 echo json_encode($response);
                                 //Chưa nhập lượt up
                                 exit;
                             }
                         }
                         $user_up_remain = $user['up_item'] + $up_item['up_remain'] - $up_remain;
                         if ($user_up_remain < 0) {
                             $user_up_remain = 0;
                         }
                         DB::query("UPDATE account SET up_item={$user_up_remain} WHERE id=" . $user['id']);
                         User::getUser($user['id'], 0, 1);
                     }
                     if ($up_item['status'] && $up_remain <= 0) {
                         $status = 2;
                     } elseif ($item["status"] == -1 || $item["status"] == 0 || $item["status"] == 2 || $item["status"] == 3) {
                         $status = 3;
                     } else {
                         $status = $up_item['status'];
                     }
                     #############################################################################
                     #Cập nhật cho tin
                     if ($item['is_up_auto'] != 1) {
                         DB::query("UPDATE item SET is_up_auto = 1 WHERE id= {$item_id}");
                         if (SORL_FILTER_ON) {
                             $solr = new Solr_Search();
                             $solr->doUpdateItem($item_id);
                         }
                         if (MEMCACHE_ON) {
                             $item['is_up_auto'] = 1;
                             eb_memcache::do_put("item:{$item_id}", $item);
                         }
                     }
                     #############################################################################
                     $del_ids = '';
                     $add_sql = '';
                     $up_total = $up_remain;
                     $up_item['up_remain'] = $up_remain;
                     if ($up_items) {
                         foreach ($up_items as $key => $u_item) {
                             if ($u_item['run_order'] < $first_time) {
                                 $up_remain = $up_total - ($up_per_day - $first_time) - $u_item['run_order'];
                             } else {
                                 $up_remain = $up_total - ($u_item['run_order'] - $first_time);
                             }
                             if (isset($up_rows[$key])) {
                                 DB::update('up_item_schedule', array('user_id' => $user['id'], 'user_name' => $user['user_name'], 'item_id' => $item['id'], 'des' => $item['name'], 'time_modify' => TIME_NOW, 'run_order' => $u_item['run_order'], 'up_per_day' => $up_per_day, 'week_day' => $week_day, 'time_run' => $u_item['time_run'], 'time_next_run' => $u_item['time_next_run'], 'up_remain' => $up_remain, 'up_total' => $up_total, 'status' => $status), "id={$up_rows[$key]['id']}");
                                 unset($up_rows[$key]);
                             } else {
                                 //$add_sql="INSERT INTO up_item_schedule (user_id,user_name,item_id,des,time_add,time_modify,run_order,week_day,time_run,time_next_run,up_remain,up_total,status) VALUES ".$add_sql;
                                 $add_sql .= ($add_sql ? ",\n" : "") . "({$user['id']},'{$user['user_name']}',{$item['id']},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$item['name']}',{$up_item['time_add']}," . TIME_NOW . ",{$u_item['run_order']},{$up_per_day},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$week_day}','{$u_item['time_run']}',{$u_item['time_next_run']},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$up_remain},{$up_total},{$status})";
                             }
                         }
                     }
                     if ($up_rows) {
                         foreach ($up_rows as $u_item) {
                             $del_ids .= ($del_ids ? ',' : '') . $u_item['id'];
                         }
                     }
                     if ($add_sql) {
                         $add_sql = "INSERT INTO up_item_schedule (user_id,user_name,item_id,des,time_add,time_modify,run_order,up_per_day,week_day,time_run,time_next_run,up_remain,up_total,status) VALUES " . $add_sql;
                         DB::query($add_sql);
                     }
                     if ($del_ids) {
                         DB::delete("up_item_schedule", "id IN({$del_ids})");
                     }
                     $response['msg'] = "success";
                     echo json_encode($response);
                     exit;
                 } else {
                     $response['msg'] = "run_hour";
                     echo json_encode($response);
                     //'Bạn phải chọn ít nhất 1 lần up / ngày!'
                     exit;
                 }
             }
         } else {
             //delete schedule here...
             DB::query("UPDATE up_item_schedule SET status=3 WHERE item_id={$item_id}");
             echo "item_not_exist";
             exit;
         }
     }
     $response['msg'] = "invalid";
     echo json_encode($response);
     exit;
 }
Exemplo n.º 21
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.º 22
0
 static function set($value)
 {
     if (MEMCACHE_ON) {
         eb_memcache::do_put('qcache:' . self::_my_file(), $value, self::$expire);
     } else {
         @file_put_contents(DIR_CACHE . 'db/' . self::_my_file(), addslashes(serialize($value)));
     }
     return true;
 }
Exemplo n.º 23
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.º 24
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;
 }