Example #1
0
 function __construct()
 {
     Form::Form('HeaderForm');
     if (User::have_permit(ADMIN_LOGO)) {
         $this->link_css('style/aznet/ui.datepicker.css');
         $this->link_js('javascript/jquery/ui.datepicker.js');
     }
     if (User::is_login() && User::level()) {
         $this->link_header("<script>MM_preloadImages('style/images/newCart/icon_del.gif','style/images/newCart/Mua.png');</script>");
     }
     // session session_id()
     CGlobal::$cart_sess_id = isset($_COOKIE['cart_sess_id']) ? $_COOKIE['cart_sess_id'] : '';
     if (CGlobal::$cart_sess_id) {
         AZLib::my_setcookie('cart_sess_id', session_id(), time() + 3600 * 24 * 365);
     }
     $this->link_js(FOLDER_JS . 'jquery.min.js');
     $this->link_js(FOLDER_JS . 'jquery-ui.js');
     $this->link_js(FOLDER_JS . 'jcarousellite_1.0.1c4.js');
     $this->link_js(FOLDER_JS . 'ui/jquery.ui.core.js');
     $this->link_js(FOLDER_JS . 'ui/jquery.ui.widget.js');
     $this->link_js(FOLDER_JS . 'ui/jquery.ui.tabs.js');
     $this->link_js('static/lightbox/js/jquery.lightbox-0.5.js');
     $this->link_js('static/adgallery/jquery.ad-gallery.js');
     $this->link_css(FOLDER_CSS . 'menu.css@lang=vi-vn.css');
     $this->link_css(FOLDER_CSS . 'sanpham.css@lang=vi-vn.css');
     $this->link_css(FOLDER_CSS . 'style.css@lang=vi-vn.css');
     $this->link_css(FOLDER_CSS . 'style_new.css@lang=vi-vn.css');
     $this->link_css(FOLDER_CSS . 'tintuc.css@lang=vi-vn.css');
     $this->link_css(FOLDER_CSS . 'trangchu.css@lang=vi-vn.css');
     $this->link_css(FOLDER_CSS . 'custom.css');
     $this->link_css(FOLDER_CSS . 'home.css');
     $this->link_css(FOLDER_CSS . 'base/jquery.ui.all.css');
     $this->link_css('static/lightbox/css/jquery.lightbox-0.5.css');
     $this->link_css('static/adgallery/jquery.ad-gallery.css');
 }
 public function doMeta()
 {
     $error = false;
     //  Set our metadata
     Metadata::set(Input::except(['user', 'pass', '_token']));
     Metadata::set('theme', 'default');
     //  Check the Stripe API key is valid
     try {
         Stripe::setApiKey(Metadata::item('stripe_key'));
         Stripe\Balance::retrieve();
     } catch (Exception $e) {
         $error = 'That Stripe key doesn’t look valid!';
     }
     //  Create the user
     if (User::whereEmail(Input::get('user'))->exists()) {
         //  We're installing, can't have users already (I think)
         // $error = 'Somebody’s already signed up with that email address!';
     } else {
         User::create(['username' => 'admin', 'name' => 'Administrator', 'level' => User::level('admin'), 'email' => Input::get('user'), 'password' => Input::get('pass')]);
     }
     if ($error === false) {
         return Redirect::to('install/done');
     }
     View::share('error', $error);
     return self::showMeta();
 }
Example #3
0
 function item_image_upload()
 {
     //
     if ((User::have_permit(ADMIN_ITEM) || User::is_mod()) && (int) Url::get('user_id', 0) && (int) Url::get('user_id', 0) != User::id()) {
         $user_id = (int) Url::get('user_id', 0);
         $user_name = '';
         $user = User::getUser($user_id);
         if ($user) {
             $user_name = $user['user_name'];
         }
     } else {
         $user_id = User::id();
         $user_name = User::user_name();
     }
     $json['error'] = 'not_uploaded';
     $json['id'] = 0;
     $json['image_url'] = '';
     if (User::is_login()) {
         if (User::is_az_team() || User::level() > 0) {
             $upload_path = AZLib::folderUpload($user_id);
             if (AZLib::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) {
                 //Check dir for upload
                 if (isset($_FILES['img_upload']) && !$_FILES['img_upload']['error'] && $_FILES['img_upload']['name']) {
                     list($imagewidth, $imageheight, $imageType) = getimagesize($_FILES['img_upload']['tmp_name']);
                     if ($imagewidth && $_FILES['img_upload']['size'] <= Item::MAX_UPLOAD_SIZE) {
                         /* if(($imagewidth > 479)||($imageheight > 359))
                            {
                            if($imagewidth > 479)//&& ($imagewidth < 1281) && ($imageheight < 1025))
                            {
                            if($imageheight > 359)
                            { */
                         $file_name = $_FILES['img_upload']['name'];
                         $sourceName = $_FILES['img_upload']['tmp_name'];
                         $file_ext = AZLib::getExtension($file_name);
                         if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) {
                             $img_url = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(AZLib::make_safe_name(basename(strtolower($file_name), $file_ext)), 0, 36) . $file_ext;
                             /* $json['error'] = AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO);
                                echo json_encode($json);
                                exit; */
                             if (AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO)) {
                                 $image_id = DB::insert('item_image', array('des' => '', 'item_id' => 0, 'title' => '', 'position' => 0, 'img_server' => IMAGE_SERVER_NO, 'img_url' => $img_url, 'root_id' => 0, 'time' => TIME_NOW, 'user_id' => $user_id, 'user_name' => $user_name));
                                 if ($image_id) {
                                     $json['id'] = $image_id;
                                     $json['img_server'] = IMAGE_SERVER_NO;
                                     $json['image_url'] = $img_url;
                                     $json['error'] = 'success';
                                 }
                             }
                         } else {
                             $json['error'] = 'ext_invalid';
                             //Sai định dạng file
                         }
                         /* }
                            else
                            {
                            $json['error'] = 'height_not_allow';
                            }
                            }
                            else
                            {
                            $json['error'] = 'width_not_allow';
                            }
                            }
                            else
                            {
                            $json['error'] = 'width_n_height_not_allow';
                            } */
                     } else {
                         $json['error'] = 'over_max_size';
                         //Sai định dạng file hoặc upload dung lượng quá lớn
                     }
                 } elseif ($_POST['url'] && $_POST['url'] != 'Hoặc Url') {
                     $url = $_POST['url'];
                     $tem_cache_dir = DIR_CACHE . 'user_images/';
                     AZLib::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;
                                 $img_url = $upload_path . TIME_NOW . '_' . $tem_cache_file;
                                 //$json['error'] = AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO);
                                 //echo json_encode($json);
                                 //exit;
                                 if (AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO)) {
                                     $image_id = DB::insert('item_image', array('des' => '', 'item_id' => 0, 'title' => '', 'position' => 0, 'img_server' => IMAGE_SERVER_NO, 'img_url' => $img_url, 'root_id' => 0, 'time' => TIME_NOW, 'user_id' => $user_id, 'user_name' => $user_name));
                                     if ($image_id) {
                                         $json['id'] = $image_id;
                                         $json['img_server'] = IMAGE_SERVER_NO;
                                         $json['image_url'] = $img_url;
                                         $json['url_error'] = 'success';
                                     } else {
                                         $json['url_error'] = 'over_max_size';
                                     }
                                 } 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';
                     }
                 } elseif ($_FILES['img_upload']['error'] == 1) {
                     $json['error'] = 'over_max_size';
                 }
             }
         }
     } else {
         $json['error'] = 'not_login';
     }
     echo json_encode($json);
     exit;
 }
Example #4
0
 function item_same_category_form()
 {
     global $display;
     EClassApi::getCities();
     EClassApi::getCats();
     $p_item_same = (int) Url::get('p_item_same', 1);
     $itemVipCat = $this->getItemVipCat();
     /*$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 = '';
     
             if($itemVipCat['str_item_id'] != ''){
                 $where .= ( $where != '' ? " AND " : "") . " id NOT IN ({$itemVipCat['str_item_id']})";
                 unset ($itemVipCat['str_item_id']);
             }else{
                 unset ($itemVipCat['str_item_id']);
             }
             
             if (CGlobal::$curCategory) {
                 $where .= ( $where != '' ? " AND " : "") . " category_id = " . CGlobal::$curCategory;
             }
             $where .= ( $where != '' ? " AND " : "") . " status=1";
     
             if (CGlobal::$curCity) {
                 $where = " city_id = " . CGlobal::$curCity . ($where != '' ? " AND " : "") . $where;
             }
             $where	.= " AND sticky = 0 ";
             $sql .= "$where ORDER BY up_time DESC";*/
     $divID = 'item_same_cat';
     $code = 'item_same_cat';
     $url_path = WEB_DIR . "ajax.php?act=item&code=item_same_category&category_id=" . CGlobal::$curCategory;
     /*$limit = '';
             $item_per_page = 6;
             $i = 1;
     
             if($p_item_same == 1){
                 $item_per_page = 6 - count($itemVipCat);
             }
     
             require_once ROOT_PATH . 'core/ECPagging.php';
             $pagging = ECPagging::AjaxPagingNextCat($limit, $item_per_page, true, 'p_item_same', $url_path, $divID);
     
     
             if($p_item_same > 1){
                 $limit=' LIMIT '.((($p_item_same-1)*$item_per_page)-count($itemVipCat)).','.($item_per_page);
             }
     
             $sql .= $limit;
     
             $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 ($i <= $item_per_page) {
                         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'] = '';
     
                         $items[$value['id']] = $value;
                     }
                     $i++;
                 }
             }
     
             if ($i <= $item_per_page) {
                 $pagging = ECPagging::AjaxPagingNextCat($limit, $item_per_page, false, 'p_item_same', $url_path, $divID);
             }*/
     //mảng dữ liệu trống
     if (is_array($itemVipCat) && count($itemVipCat) > 0) {
         $countNull = 6 - count($itemVipCat);
     } else {
         $countNull = 6;
     }
     //Lấy zone
     foreach (CGlobal::$allCategories[CGlobal::$allCategories[CGlobal::$curCategory]['parent_id']]['zones'] as $val) {
         $zone = $val;
     }
     $no_image = 'style/images/service.png';
     switch ($zone) {
         case 2:
             //Thời trang
             $no_image = 'style/images/box_hot/thoi_trang.png';
             break;
         case 1:
             //Nhà cửa
             $no_image = 'style/images/box_hot/nha_cua.png';
             break;
         case 6:
             //Điện máy
             $no_image = 'style/images/box_hot/dien_may.png';
             break;
         case 3:
             //Hàng hiệu
             $no_image = 'style/images/box_hot/hang_hieu.png';
             break;
         case 5:
             //Ô tô
             $no_image = 'style/images/box_hot/oto.png';
             break;
         case 7:
             //Nhà đất
             $no_image = 'style/images/box_hot/nha_dat.png';
             break;
         default:
             break;
     }
     $items = array();
     for ($i = 0; $i < $countNull; $i++) {
         $value['can_buy'] = 1;
         $value['original_image_url'] = $no_image;
         $value['name'] = "BẠN MUỐN QUẢNG CÁO";
         $key = "null_" . $i;
         $items[$key] = $value;
     }
     if ($zone == 2 || $zone == 9) {
         $display->add('title', "Hàng mới về");
     } else {
         $display->add('title', "Sản phẩm hot");
     }
     $arr = User::$current->data;
     $item_ids = explode(',', $_REQUEST['recent_items']);
     if ($item_ids[0]) {
         $display->add('item_id', $item_ids[0]);
     }
     if (User::level()) {
         $phone = 0;
         if ($arr['mobile_phone'] != "") {
             $phone = $arr['mobile_phone'];
         } else {
             if ($arr['home_phone'] != "") {
                 $phone = $arr['home_phone'];
             }
         }
         $display->add('phone', $phone);
         $display->add('full_name', EClassApi::descriptionText($arr['full_name']));
     }
     //        $display->add('pagging', $pagging);
     $display->add('is_admin', User::have_permit(ADMIN_VIP_ITEM_CATEGORY));
     $display->add('zone', $zone);
     if (is_array($itemVipCat) && count($itemVipCat) > 0) {
         $items = $itemVipCat + $items;
     }
     $display->add('items', $items);
     //        $display->add('current_user_id', $arr['id']);
     if ($items) {
         if (Url::get('code') != $code) {
             echo '<div id="' . $divID . '">';
         } else {
             echo "<div>";
         }
         $display->output('ItemSameCategory', false, 'ItemSameCategory');
         echo "</div>";
     }
 }
Example #5
0
    $user = User::getUser($user_id);
    if ($user) {
        $user_name = $user['user_name'];
    }
    User::$current->data = $user;
    User::$current->groups = User::get_groups($user['gids']);
    $_SESSION['user_id'] = $user_id;
    $_SESSION['user_name'] = $user_name;
}
$arrRet['error'] = 'not_uploaded';
$arrRet['id'] = 0;
$arrRet['img_server'] = -1;
$arrRet['image_url'] = '';
$countImage = $_REQUEST['countImage'];
if (User::is_login()) {
    if (User::is_foodnet_team() || User::level() > 0) {
        $upload_path = EClassApi::folderUpload($user_id);
        if ($countImage <= 100) {
            if (EClassApi::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) {
                //Check dir for upload
                if (isset($_FILES['Filedata']) && $_FILES['Filedata']['name']) {
                    $file_name = $_FILES['Filedata']['name'];
                    $sourceName = $_FILES['Filedata']['tmp_name'];
                    $file_ext = EClassApi::getExtension($file_name);
                    if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) {
                        if (!$_FILES['Filedata']['error']) {
                            list($imagewidth, $imageheight, $imageType) = getimagesize($_FILES['Filedata']['tmp_name']);
                            if ($imagewidth && $_FILES['Filedata']['size'] <= Item::MAX_UPLOAD_SIZE) {
                                $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)) {
                                    $image_id = DB::insert('item_image', array('des' => '', 'item_id' => 0, 'title' => '', 'position' => 0, 'img_server' => IMAGE_SERVER_NO, 'original_image_url' => $original_image_url, 'root_id' => 0, 'time' => TIME_NOW, 'user_id' => $user_id, 'user_name' => $user_name));
Example #6
0
 function del_cart()
 {
     $data = array('msg' => '');
     if (User::is_login()) {
         if (User::level()) {
             $cart = false;
             $cart_item = false;
             $cart_item_id = (int) Url::get("cart_item_id");
             $cart_id = (int) Url::get("cart_id");
             $service_code = Url::get("service_code");
             if ($cart_id) {
                 $cart = DB::select("cart", "id={$cart_id}");
             }
             if (!$cart && $cart && $cart['user_id'] != User::id && $cart['status'] != 1) {
                 $data['msg'] = 'error';
                 echo json_encode($data);
                 exit;
             }
             if ($cart_item_id) {
                 $cart_item = DB::select("cart_services", "id={$cart_item_id}");
             }
             if (!$cart_item && $cart_item && $cart_item['user_id'] != User::id && $cart['status'] != 1) {
                 $data['msg'] = 'error';
                 echo json_encode($data);
                 exit;
             }
             DB::delete("cart_services", "id={$cart_item_id}");
             echo json_encode($data);
             exit;
         }
     } else {
         $data['msg'] = 'not_login';
         echo json_encode($data);
         exit;
     }
     $data['msg'] = 'no_perm';
     echo json_encode($data);
     exit;
 }
Example #7
0
 function get_schedule_config()
 {
     $data = array('msg' => '');
     if (User::is_login()) {
         $item_id = (int) Url::get('item_id', 0);
         if ($item_id > 0 && !User::is_block() && (User::is_az_team() || User::level() > 0)) {
             $user = array();
             $item = array();
             $up_item = array();
             $up_items = array();
             $user = array();
             $item = Item::get_item($item_id);
             $item_memcache = $item;
             if ($item && $item['status'] != -1) {
                 if (User::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_items[] = $s_item;
                         }
                     }
                     $user = DB::select('user', "id={$item['user_id']}");
                     global $display;
                     $run_times = '';
                     if ($up_items) {
                         $up_item = $up_items[0];
                         foreach ($up_items 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;
                         }
                         if ($up_item['week_day']) {
                             $arr = explode('|', $up_item['week_day']);
                             if ($arr) {
                                 foreach ($arr as $stt => $val) {
                                     $stt += 2;
                                     $display->add("week_day{$stt}", $val);
                                 }
                             }
                         }
                         foreach ($up_items as $run_time) {
                             if ($run_time['time_run']) {
                                 $arr = explode('-', $run_time['time_run']);
                                 $run_hour = $arr[0];
                                 $run_min = $arr[1];
                                 $run_times .= ($run_times != '' ? '|' : '') . $arr[0] . ':' . $arr[1];
                             }
                         }
                         $display->add('up_remain', (int) $up_item['up_remain']);
                         $display->add('status', (int) $up_item['status']);
                         $display->add('del_up', 1);
                     } else {
                         $display->add('up_remain', 0);
                         $display->add('status', 0);
                     }
                     $display->add('item_id', (int) $item['id']);
                     $display->add('reload_page', (int) Url::get('reload_page'));
                     $display->add('user_up_count', $user['up_item']);
                     $display->add('item_name', stripslashes($item['name']));
                     $display->add('user_name', $item['user_name']);
                     $display->add('item_url', "p{$item['id']}/" . AZLib::safe_title($item['name']) . ".html");
                     $data['html'] = $display->output('ScheduleConfig', 1, "Personal");
                     $data['run_times'] = $run_times;
                     echo json_encode($data);
                     exit;
                 }
             } else {
                 //delete schedule here...
                 DB::query("UPDATE up_item_schedule SET status=3 WHERE item_id={$item_id}");
                 $data['msg'] = 'item_not_exist';
                 echo json_encode($data);
                 exit;
             }
         }
     } else {
         $data['msg'] = 'not_login';
         echo json_encode($data);
         exit;
     }
     $data['msg'] = 'no_perm';
     echo json_encode($data);
     exit;
 }
Example #8
0
if (User::have_permit(ADMIN_ITEM) && (int) Url::get('user_id', 0) && (int) Url::get('user_id', 0) != User::id()) {
    $user_id = (int) Url::get('user_id', 0);
    $user_name = '';
    $user = User::getUser($user_id);
    if ($user) {
        $user_name = $user['user_name'];
    }
} else {
    $user_id = User::id();
    $user_name = User::user_name();
}
$json['error'] = 'not_uploaded';
$json['id'] = 0;
$json['image_url'] = '';
if (User::is_login()) {
    if (User::is_az_team() || User::level() > 0) {
        $upload_path = AZLib::folderUpload($user_id);
        if (AZLib::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) {
            //Check dir for upload
            $uploadFile = $_FILES["fast_upload_avatar"];
            if (isset($uploadFile) && $uploadFile['name']) {
                $file_name = $uploadFile['name'];
                $sourceName = $uploadFile['tmp_name'];
                $file_ext = AZLib::getExtension($file_name);
                if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) {
                    if (!$uploadFile['error']) {
                        list($imagewidth, $imageheight, $imageType) = getimagesize($uploadFile['tmp_name']);
                        if ($imagewidth && $uploadFile['size'] <= Item::MAX_UPLOAD_SIZE) {
                            $img_url = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(AZLib::make_safe_name(basename(strtolower($file_name), $file_ext)), 0, 36) . $file_ext;
                            if (AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO)) {
                                $image_id = DB::insert('item_image', array('des' => '', 'item_id' => 0, 'title' => '', 'position' => 0, 'img_server' => IMAGE_SERVER_NO, 'img_url' => $img_url, 'root_id' => 0, 'time' => TIME_NOW, 'user_id' => $user_id, 'user_name' => $user_name));
Example #9
0
 public function editable()
 {
     if (!isset($this->id)) {
         return false;
     }
     if (!User::$id) {
         return false;
     }
     if (User::root()) {
         return true;
     }
     if ($this->rev_by == User::$id) {
         return true;
     }
     if (!$this->folder->isEditor(User::$id)) {
         return false;
     }
     if (User::level($this->rev_by) == User::$user['level']) {
         return true;
     }
     return User::$user['level'] < User::level($this->rev_by);
 }
Example #10
0
 function up_item()
 {
     if (!User::is_login()) {
         echo "not_login";
         exit;
     } elseif (!User::is_admin() && User::is_block()) {
         //Nếu ko fải admin mà bị khóa hoặc chưa là THÀNH VIÊN CHÍNH THỨC
         echo "no_perm";
         exit;
     }
     $item_id = (int) Url::get('item_id');
     $up_tk = (int) Url::get('up');
     //0:up free; 1: up tài khoản
     if ($item_id) {
         $item = Item::get_item($item_id);
         $item_memcache = $item;
         $item_update = array();
         $have_permit = false;
         $up_log_sql = '';
         if (!$item) {
             echo "no_perm";
             exit;
         }
         if ($item["state"] == 1 || $item["status"] != 1) {
             //Nêu bị khóa hoặc tin bị xóa hoặc kiểm duyệt...
             echo "lock_topic";
             exit;
         }
         $user = DB::fetch('SELECT id, user_name, up_item, block_time, invalid_time FROM user WHERE id=' . $item['user_id']);
         if ($user['block_time'] > TIME_NOW || $user['block_time'] == -1) {
             echo "no_perm";
             exit;
         }
         $up_free = 0;
         $is_up_free = false;
         $up_type = 0;
         //Kiểu up: 0: up free; 1: up tay; 2: up lịch; 3: up lẻ
         $up_zone_id = 0;
         //Zone ID
         $up_top_cat = $item['level_1_catid'];
         //TopCatID
         $up_cat_id = $item['category_id'];
         //CatID
         $mid_noon = mktime(12, 0, 0, date('m', TIME_NOW), date('d', TIME_NOW), date('Y', TIME_NOW));
         //thời điểm giữa trưa cùng ngày
         //Là up free && hết lượt up tài khoản && ko fải là admin
         if (!$up_tk && User::level() && !User::have_permit(ADMIN_ITEM) && !User::have_cat_permit($item['category_id'])) {
             if (TIME_NOW < $mid_noon) {
                 $up_free = DB::select("up_free", "user_id=" . $user['id'] . " AND catid = {$up_top_cat} AND date ='" . date("Ymd", TIME_NOW) . "S'");
                 $str_time = 'buổi sáng';
                 $type_time = 1;
                 //buổi sáng
             } else {
                 $up_free = DB::select("up_free", "user_id=" . $user['id'] . " AND catid = {$up_top_cat} AND date ='" . date("Ymd", TIME_NOW) . "C'");
                 $str_time = 'buổi chiều tối';
                 $type_time = 2;
                 //buổi chiều tối
             }
             if (date("dmY", $item["up_time"]) == date("dmY")) {
                 echo "time_out";
                 exit;
             } elseif ($up_free && (isset(CGlobal::$UP_FREE_CAT[$up_top_cat]) && (int) (CGlobal::$UP_FREE_CAT[$up_top_cat] / 2) <= (int) $up_free['up'] || !isset(CGlobal::$UP_FREE_CAT[$up_top_cat]) && (int) (UP_FREE_MAX / 2) <= (int) $up_free['up'])) {
                 echo "time_out{$type_time}";
                 exit;
             }
             //else =>> còn lượt up trong ngày
         }
         $out_put = "";
         if (User::have_permit(ADMIN_ITEM) || User::have_cat_permit($item['category_id']) || $item['user_id'] == User::id()) {
             $main_cat = CGlobal::$allCategories[$up_top_cat];
             if ($main_cat && isset($main_cat['zones'])) {
                 foreach ($main_cat['zones'] as $zid) {
                     if ($zid && isset(CGlobal::$allZones[$zid])) {
                         $up_zone_id = $zid;
                         if ($main_cat['id'] != 100) {
                             break;
                         }
                     }
                 }
             }
             $out_put = "Còn lượt up tin trong ngày";
             $user_up_item = $user['up_item'];
             $up_order = "0";
             if (User::have_permit(ADMIN_ITEM) || User::have_cat_permit($item['category_id'])) {
                 $item_update['up_time'] = TIME_NOW;
                 $item_memcache['up_time'] = TIME_NOW;
                 $out_put = "up-0";
                 $up_log_sql = "INSERT INTO up_item_log \r\n\t\t\t\t\t\t\t\t\t(up_id, item_id, \t\tzone_id, \ttop_cat_id, \tcat_id, \t\titem_title, \t\tuser_id, \t\tuser_name, \t\t\t\tup_time, \t\ttype, \t\trun_order, \t\t\t\t\t\t\tup_remain, \t\tup_total, \t\t\tstatus) VALUES ";
                 $up_log_sql .= "\t(0,\t\t{$item['id']},\t{$up_zone_id},{$up_top_cat},\t{$up_cat_id},\t'{$item['name']}',\t{$user['id']},\t'{$user['user_name']}',\t" . TIME_NOW . ",\t{$up_type},\t'admin: (" . User::user_name() . ")',\t{$user_up_item},\t{$user['up_item']},\t1)";
                 DB::query($up_log_sql);
             } else {
                 $up_time = TIME_NOW;
                 $is_up = true;
                 $out_put = "up-1";
                 if (User::level() == 0) {
                     if ($user['up_item'] > 0) {
                         $up_type = 1;
                         //up tài khoản
                         //$re = DB::query("SELECT id,up_time FROM item WHERE user_id = ".$item['user_id']." AND id ORDER BY up_time DESC LIMIT 1");
                         $re = DB::query("SELECT id,up_time,category_id,level_1_catid FROM item WHERE user_id = " . $item['user_id'] . " AND level_1_catid = {$item['level_1_catid']} ORDER BY up_time DESC LIMIT 1");
                         if ($re) {
                             $old_item = mysql_fetch_assoc($re);
                             if ($old_item) {
                                 if ($old_item['up_time'] > TIME_NOW - 300 && $old_item['id'] != $item['id']) {
                                     $up_time = $old_item['up_time'] - 300;
                                 }
                             }
                         }
                         //End down time
                         $item_update['up_time'] = $up_time;
                         $item_memcache['up_time'] = $up_time;
                         //DB::query('UPDATE user SET up_item = '.(int)($user['up_item']-1).' WHERE id='.$item['user_id']);
                         DB::query('UPDATE user SET up_item = up_item-1 WHERE id=' . $item['user_id']);
                         User::getUser($item['user_id'], 0, 1);
                         $user_up_item--;
                         $up_order = "{$user_up_item}/" . $user['up_item'];
                     } else {
                         echo "no_perm_offical";
                         //echo "no_perm";
                         exit;
                     }
                 } else {
                     //Down time item nếu mới up hoặc đăng một tin nào đó chưa quá 5 phút
                     //$re = DB::query("SELECT id,up_time FROM item WHERE user_id = ".$item['user_id']." AND id ORDER BY up_time DESC LIMIT 1");
                     $re = DB::query("SELECT id,up_time,category_id,level_1_catid FROM item WHERE user_id = " . $item['user_id'] . " AND level_1_catid = {$item['level_1_catid']} ORDER BY up_time DESC LIMIT 1");
                     if ($re) {
                         $old_item = mysql_fetch_assoc($re);
                         if ($old_item) {
                             //if($old_item['up_time']>TIME_NOW-300 && $old_item['id']!=$item['id'] && ($old_item['category_id']==$item['category_id'] || $old_item['level_1_catid']==$item['level_1_catid']))
                             if ($old_item['up_time'] > TIME_NOW - 300 && $old_item['id'] != $item['id']) {
                                 $up_time = $old_item['up_time'] - 300;
                             }
                         }
                     }
                     //End down time
                     if ($up_tk) {
                         if ($user['up_item'] > 0) {
                             $up_type = 1;
                             //up tài khoản
                             $item_update['up_time'] = $up_time;
                             $item_memcache['up_time'] = $up_time;
                             //DB::query('UPDATE user SET up_item = '.(int)($user['up_item']-1).' WHERE id='.$item['user_id']);
                             DB::query('UPDATE user SET up_item = up_item-1 WHERE id=' . $item['user_id']);
                             User::getUser($item['user_id'], 0, 1);
                             $user_up_item--;
                             $up_order = "{$user_up_item}/" . $user['up_item'];
                         } else {
                             $out_put = "up_over";
                             $is_up = false;
                         }
                     } else {
                         $out_put = "Hết lượt up tin {$str_time}";
                         $is_up_free = true;
                         $item_update['up_time'] = $up_time;
                         $item_memcache['up_time'] = $up_time;
                         $up_order = "Up free";
                         if ($up_free) {
                             DB::query("UPDATE up_free SET time_up = " . TIME_NOW . ",up= up+ 1 WHERE id={$up_free['id']}");
                         } else {
                             DB::insert("up_free", array('user_id' => $user['id'], 'user_name' => $user['user_name'], 'time_f' => TIME_NOW, 'time_up' => TIME_NOW, 'catid' => $up_top_cat, 'date' => date("Ymd", TIME_NOW) . (TIME_NOW < $mid_noon ? "S" : "C"), 'up' => 1));
                         }
                     }
                 }
                 if ($is_up) {
                     $up_log_sql = "INSERT INTO up_item_log \r\n\t\t\t\t\t\t\t\t\t\t\t(up_id, \titem_id, \t\tzone_id, \t\ttop_cat_id, \tcat_id, \titem_title, \t\tuser_id, \t\tuser_name, \t\t\t\tup_time, \t\ttype, \t\trun_order, \t\t\t\tup_remain, \tup_total, \t\tstatus) VALUES ";
                     $up_log_sql .= "\t(0,\t\t\t{$item['id']},\t{$up_zone_id},\t{$up_top_cat},\t{$up_cat_id},\t'{$item['name']}',\t{$user['id']},\t'{$user['user_name']}',\t" . TIME_NOW . ",\t{$up_type},\t'{$up_order} (" . User::user_name() . ")',\t{$user_up_item},\t{$user['up_item']},\t1)";
                     DB::query($up_log_sql);
                 }
             }
         } else {
             $out_put = "no_perm";
         }
         //Up item
         if ($item_update) {
             DB::update('item', $item_update, "id={$item_id}");
             if (MEMCACHE_ON) {
                 AZMemcache::do_put("item:{$item_id}", $item_memcache);
             }
         }
         //return...
         echo $out_put;
         exit;
     }
 }
Example #11
0
 function check_register_service()
 {
     $json['error'] = "";
     $json['user_group'] = 0;
     $json['id'] = 0;
     $json['level'] = 0;
     if (!User::is_login()) {
         $json['error'] = "not_login";
         echo json_encode($json);
         exit;
     }
     if (User::is_block()) {
         $json['error'] = "no_permission";
         echo json_encode($json);
         exit;
     }
     $user_name = User::user_name();
     //kiểm tra xem user có thuộc nhóm premium hay không.
     if (User::isPremium()) {
         $json['user_group'] = 1;
     }
     //end
     //Kiểm tra user xem đã là thành viên chính thức hay chưa
     $json['level'] = User::level();
     $service_name = Url::get('service_name', '');
     $aryOrder = array();
     $aryOrder = DB::select_all('order_services', "user_use='" . $user_name . "' AND (active = 1 OR active = 0 OR active = -4)");
     if (count($aryOrder) > 0 && !User::is_root()) {
         foreach ($aryOrder as $val) {
             if ($service_name == $val['type_scs']) {
                 $json['error'] = "exist_service_order";
                 echo json_encode($json);
                 exit;
             }
             if ($val['payment_status'] == 1) {
                 $json['error'] = "over_reg_scs_payment";
             } else {
                 if ($val['active'] == 1) {
                     $json['error'] = "over_reg_scs_active";
                 } elseif ($val['active'] == -3 || $val['active'] == 0 || $val['active'] == -4) {
                     $json['error'] = "confirm_cancel_reg_scs";
                     $json['id'] = $val['id'];
                 }
             }
         }
         echo json_encode($json);
         exit;
     } else {
         $json['error'] = "success";
         echo json_encode($json);
         exit;
     }
 }