Example #1
0
 function AdminHome($row)
 {
     if (User::is_foodnet_team()) {
         Module::Module($row);
         //Url::redirect_url("admin_order.html");
         require_once 'forms/AdminHome.php';
         $this->add_form(new AdminHomeForm());
     }
 }
Example #2
0
 function Navigation($row)
 {
     Module::Module($row);
     if (User::is_foodnet_team()) {
         CGlobal::$adminRegion = true;
         require_once 'forms/Navigation.php';
         $this->add_form(new NavigationForm());
     } else {
         Url::access_denied();
     }
 }
Example #3
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 #4
0
    function item_image_upload() {//
        if ((User::have_permit(ADMIN_ITEM) || User::is_mod_cat()) && (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_foodnet_team() || User::level() > 0) {
                $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']) && !$_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 = 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;
                                /* $json['error'] = EClassApi::ftp_image_put_file($original_image_url, $sourceName, IMAGE_SERVER_NO);
                                  echo json_encode($json);
                                  exit; */
                                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
                                            ));
                                    if ($image_id) {
                                        $json['id'] = $image_id;
                                        $json['img_server'] = IMAGE_SERVER_NO;
                                        $json['image_url'] = $original_image_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/';
                        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;
                                    //$json['error'] = EClassApi::ftp_image_put_file($original_image_url, $sourceName, IMAGE_SERVER_NO);
                                    //echo json_encode($json);
                                    //exit;
                                    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
                                                ));

                                        if ($image_id) {
                                            $json['id'] = $image_id;
                                            $json['img_server'] = IMAGE_SERVER_NO;
                                            $json['image_url'] = $original_image_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 #5
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_foodnet_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('account', "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']}/" . EClassApi::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;
 }