Ejemplo n.º 1
0
 function on_submit()
 {
     if (!User::is_block()) {
         $file_name = strtolower($_FILES['avatar_url']['name']);
         $upload_path = AZLib::folderUpload(User::id(), 'avatar');
         $max_upload_file_size = 2 * 1024 * 1024;
         $file_ext = AZLib::getExtension(strtolower($file_name));
         $new_path = '';
         if ($file_name && in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png')) && filesize($_FILES['avatar_url']['tmp_name']) < $max_upload_file_size) {
             if (AZLib::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) {
                 if (User::$current->data['avatar_url'] != '') {
                     @AZLib::ftp_image_delete_file(User::$current->data['avatar_url'], User::$current->data['img_server']);
                 }
                 $new_path = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(AZLib::make_safe_name(basename($file_name, $file_ext)), 0, 36) . $file_ext;
                 @AZLib::ftp_image_put_file($new_path, $_FILES['avatar_url']['tmp_name'], IMAGE_SERVER_NO);
             }
         }
         $phone_verify = User::$current->data['phone_verify'];
         $this->update_user($new_path, $phone_verify, IMAGE_SERVER_NO);
         //đang làm dở
         User::getUser(User::id(), true);
         echo '<script>document.location.href="' . WEB_ROOT . AZRewrite::formatUrl('?page=personal&cmd=edit_user&action=success_edit_user') . '"</script>';
     } else {
         $this->setFormError('', "Tài khoản của bạn hiện đang bị khóa, bạn không thể thực hiện chức năng này!");
     }
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 function on_submit()
 {
     $status = (int) Url::get('status');
     $title = trim(AZLib::getParam('title', ''));
     $note = trim(AZLib::getParam('note', ''));
     if (!$title) {
         $this->setFormError('title', "Bạn chưa nhập vào tiêu đề!");
     }
     $h_start = Url::get('h_start', 0);
     $min_start = Url::get('min_start', 0);
     $date_start = Url::get('date_start', '');
     $h_end = Url::get('h_end', 0);
     $min_end = Url::get('min_end', 0);
     $date_end = Url::get('date_end', '');
     if ($h_start > 23 || $h_start < 0) {
         $this->setFormError('h_start', "Phút bắt đầu chạy sai định dạng!");
     }
     if ($min_start > 59 || $min_start < 0) {
         $this->setFormError('min_start', "Phút bắt đầu chạy sai định dạng!");
     }
     if ($h_end > 23 || $h_end < 0) {
         $this->setFormError('h_start', "Giờ kết thúc sai định dạng!");
     }
     if ($min_end > 59 || $min_end < 0) {
         $this->setFormError('min_end', "Phút kết thúc chạy sai định dạng!");
     }
     $arr = split('-', $date_start);
     if (count($arr) == 3 && $arr[0] > 1 && $arr[0] < 32 && $arr[1] > 1 && $arr[1] < 13 && $arr[2] >= date("Y", TIME_NOW) && $arr[2] <= date("Y", TIME_NOW) + 1) {
         $time_start = mktime($h_start, $min_start, 0, $arr[1], $arr[0], $arr[2]);
     } else {
         $this->setFormError('date_start', "Ngày bắt đầu sai định dạng!");
     }
     $arr = split('-', $date_end);
     if (count($arr) == 3 && $arr[0] > 1 && $arr[0] < 32 && $arr[1] > 1 && $arr[1] < 13 && $arr[2] >= date("Y", TIME_NOW) && $arr[2] <= date("Y", TIME_NOW) + 1) {
         $time_end = mktime($h_end, $min_end, 59, $arr[1], $arr[0], $arr[2]);
     } else {
         $this->setFormError('date_end', "Ngày kết thúc sai định dạng!");
     }
     echo $time_start, '<br />';
     echo $time_end;
     if ($time_end < TIME_NOW - 600) {
         $this->setFormError('date_end', "Thời gian kết thúc phải sau thời gian hiện tại ít nhất là 10 phút!");
     }
     if ($time_start > $time_end - 600) {
         $this->setFormError('date_end', "Thời gian bắt đầu phải trước thời gian kết thúc ít nhất là 10 phút!");
     }
     $img_url = '';
     $img_server = 0;
     if (isset($_FILES["img_url"]) && $_FILES["img_url"]['name']) {
         $upload_path = "event/" . date('Y/m/', TIME_NOW);
         if (AZLib::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) {
             $file_name = strtolower($_FILES["img_url"]['name']);
             $file_ext = AZLib::getExtension($file_name);
             if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) {
                 if (!$_FILES["img_url"]['error']) {
                     list($imagewidth, $imageheight, $imageType) = getimagesize($_FILES["img_url"]['tmp_name']);
                     if ($imagewidth && $imageheight && $_FILES["img_url"]['size'] <= Item::MAX_UPLOAD_SIZE) {
                         $img_url = $upload_path . date("YmdHis", TIME_NOW) . '_' . User::id() . "_" . substr(AZLib::make_safe_name(basename(strtolower($file_name), $file_ext)), 0, 36) . $file_ext;
                         $img_server = IMAGE_SERVER_NO;
                         if (!AZLib::ftp_image_put_file($img_url, $_FILES["img_url"]['tmp_name'], IMAGE_SERVER_NO)) {
                             $this->setFormError('img_url', "Không upload được ảnh!");
                         }
                     } else {
                         $json['error'] = 'over_max_size';
                         //Sai định dạng file hoặc upload dung lượng quá lớn
                     }
                 } elseif ($_FILES["img_url"]['error'] == 1) {
                     $json['error'] = 'over_max_size';
                 }
             } else {
                 $this->setFormError('img_url', "Sai định dạng ảnh, chỉ dùng file dạng .jpg, .jpeg, .gif, .png!");
             }
         }
     } else {
         $this->setFormError('img_url', "Ngày kết thúc sai định dạng!");
     }
     if (!$this->errNum) {
         $this->a_row = array('title' => $title, 'status' => $status, 'img_url' => $img_url, 'img_server' => $img_server, 'time_start' => $time_start, 'time_end' => $time_end, 'time_run' => 0, 'run_key' => '', 'user_c' => User::user_name(), 'time_c' => TIME_NOW, 'user_m' => User::user_name(), 'time_m' => TIME_NOW, 'note' => $note);
         DB::insert("event_product", $this->a_row);
         Url::redirect_current();
     }
 }
Ejemplo n.º 4
0
$arrRet['img_server'] = -1;
$arrRet['image_url'] = '';
if (User::is_login()) {
    if (User::have_permit(ADMIN_ITEM)) {
        $upload_path = AZLib::folderUpload();
        if (AZLib::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 = AZLib::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) {
                            $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::user_name()));
                                if ($image_id) {
                                    $arrRet['id'] = $image_id;
                                    $arrRet['img_server'] = IMAGE_SERVER_NO;
                                    $arrRet['image_url'] = $img_url;
                                    $arrRet['error'] = 'success';
                                }
                            }
                        } else {
                            $arrRet['error'] = 'over_max_size';
                            //Sai định dạng file hoặc upload dung lượng quá lớn
                        }
                    } elseif ($_FILES['Filedata']['error'] == 1) {
                        $json['error'] = 'over_max_size';
Ejemplo n.º 5
0
 function edit_user()
 {
     $file_name = strtolower($_FILES['avatar_url']['name']);
     $upload_path = AZLib::folderUpload(User::id(), 'avatar');
     $max_upload_file_size = 2 * 1024 * 1024;
     $file_ext = AZLib::getExtension($file_name);
     $new_path = '';
     if ($file_name && in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png')) && filesize($_FILES['avatar_url']['tmp_name']) < $max_upload_file_size) {
         if (AZLib::ftp_check_dir($upload_path)) {
             $old_avatar_url = Url::get('old_avatar_url');
             if ($old_avatar_url != '') {
                 @AZLib::ftp_image_delete_file($old_avatar_url);
             }
             $new_path = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(AZLib::make_safe_name(basename($file_name, $file_ext)), 0, 36) . $file_ext;
             @AZLib::ftp_image_put_file($new_path, $_FILES['avatar_url']['tmp_name']);
         }
     }
     $show_email = Url::get('show_email');
     $email_alert = Url::get('email_alert');
     $new_blast = Url::get('blast');
     if (AZLib::checkBadWord($new_blast)) {
         $new_blast = '';
     }
     $new_sign = Url::get('sign');
     if (AZLib::checkBadWord($new_sign)) {
         $new_sign = '';
     }
     $full_name = Url::get('full_name');
     if (AZLib::checkBadWord($full_name)) {
         $full_name = '';
     }
     $address = Url::get('address');
     if (AZLib::checkBadWord($address)) {
         $address = '';
     }
     $home_phone = Url::get('home_phone');
     if (AZLib::checkBadWord($home_phone)) {
         $home_phone = '';
     }
     $fax = Url::get('fax');
     if (AZLib::checkBadWord($fax)) {
         $fax = '';
     }
     $mobile_phone = Url::get('mobile_phone');
     if (AZLib::checkBadWord($mobile_phone)) {
         $mobile_phone = '';
     }
     $website = Url::get('website');
     if (AZLib::checkBadWord($website)) {
         $website = '';
     }
     $yahoo_id = Url::get('yahoo_id');
     if (AZLib::checkBadWord($yahoo_id)) {
         $yahoo_id = '';
     }
     $skype_id = Url::get('skype_id');
     if (AZLib::checkBadWord($skype_id)) {
         $skype_id = '';
     }
     $arr = explode('-', Url::get('birth_day'));
     if (is_numeric($arr['0']) && is_numeric($arr['1']) && is_numeric($arr['2'])) {
         $strBirthDay = $arr['2'] . '-' . $arr['1'] . '-' . $arr['0'];
     } else {
         $strBirthDay = "";
     }
     $new_row = array('full_name' => $full_name, 'address' => $address, 'birth_day' => $strBirthDay, 'home_phone' => $home_phone, 'fax' => $fax, 'mobile_phone' => $mobile_phone, 'show_email' => $show_email, 'email_alert' => $email_alert, 'website' => $website, 'yahoo_id' => $yahoo_id, 'skype_id' => $skype_id, 'blast' => $new_blast, 'signature' => $new_sign, 'avatar_url' => $new_path);
     $id_new_row = DB::update('user', $new_row, 'id="' . User::id() . '"');
     @User::updateUserCache(User::id());
     if ($id_new_row) {
         echo "success";
         exit;
     } else {
         echo "unsuccess";
         exit;
     }
 }
Ejemplo n.º 6
0
 function on_submit()
 {
     $news_catid = Url::get('news_catid', 0);
     if (!$news_catid) {
         $this->setFormError('news_catid', "Bạn chưa chọn Danh mục cho Sản phẩm!");
     } else {
         $news_category = DB::select('news_categories', 'id=' . $news_catid);
         if (!$news_category) {
             $this->setFormError('news_catid', "Danh mục không tồn tại, mời bạn chọn Danh mục khác!");
         }
     }
     $title = Url::get('title');
     $brief = Url::get('brief', '');
     $content = Url::get('content', '');
     $hot = Url::get('hot', 0);
     $focus = Url::get('focus', 0);
     $status = Url::get('status', 2);
     //1:ẩn;2:hiện
     $image_title = Url::get('image_title');
     if ($status == 2) {
         $status = 1;
     } else {
         $status = 0;
     }
     /*if($image_title=='')
     		$image_title	=	AznetLib::convert_utf8_to_sms(AznetLib::subString($title,0,30,true));*/
     $pen_name = Url::get('pen_name');
     $source = Url::get('source', '');
     $get_source = Url::get('get_source', 0);
     $this->checkFormInput('Tiêu đề tin', "title", $title, 'str', true, '', 1, 255);
     $this->checkFormInput('Nội dung tóm tắt', "brief", $brief, 'str', true);
     $this->checkFormInput('Tiêu đề ảnh', "image_title", $image_title, 'str', false, '', 1, 100);
     $this->checkFormInput('Nội dung tin', "content", $content, 'str', true);
     if (!$this->errNum) {
         $news_image = array("name" => '', "img_server" => IMAGE_SERVER_NO, "title" => addslashes($image_title), 'time_create' => TIME_NOW, 'news_id' => 0, 'username' => User::user_name());
         if (isset($_FILES['main_image']) && $_FILES['main_image']['error'] == 0) {
             if ($_FILES['main_image']['name'] && getimagesize($_FILES['main_image']['tmp_name'])) {
                 $file_ext = AZLib::getExtension($_FILES['main_image']['name']);
                 if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) {
                     if ($_FILES['main_image']['size'] <= Item::MAX_UPLOAD_SIZE) {
                         $uploadPath = AZLib::folderUpload(User::id(), "news");
                         $file_name = $uploadPath . date("YmdHis", TIME_NOW) . '_' . substr(AZLib::make_safe_name(basename(strtolower($_FILES['main_image']['name']), $file_ext)), 0, 36) . $file_ext;
                         if (AZLib::ftp_check_dir($uploadPath) && AZLib::ftp_image_put_file($file_name, $_FILES['main_image']['tmp_name'], IMAGE_SERVER_NO)) {
                             $news_image['name'] = $file_name;
                             $image_id = DB::insert('news_image', $news_image);
                             if ($image_id) {
                                 $news_image['id'] = $image_id;
                             } else {
                                 $this->setFormError('image', "Không cập nhật được <b>Ảnh đại diện</b>!");
                                 return;
                             }
                         } else {
                             $this->setFormError('image', "Không upload được <b>Ảnh đại diện</b>!");
                             return;
                         }
                     } else {
                         $this->setFormError('image', "Dung lượng ảnh quá lớn, dung lượng ảnh phải < 1 MB!");
                         return;
                     }
                 } else {
                     $this->setFormError('image', "Ảnh không đúng định dạng, chỉ chấp nhận các file .jpg, .jpeg, .gif, .png !");
                     return;
                 }
             } else {
                 $this->setFormError('image', "Lỗi <b>Ảnh đại diện</b>!");
                 return;
             }
         }
         if ($get_source) {
             //require_once('includes/news.php');
             //$content=News::convertContent(addslashes($content),$this->news['id']);
         }
         if ($brief == '') {
             $brief = AznetLib::subString($content, 0, 300, true);
         }
         $news_id = DB::insert('news', array('news_catid' => $news_catid, 'title' => addslashes($title), 'brief' => addslashes($brief), 'content' => addslashes($content), 'image' => $news_image['name'], 'image_title' => $news_image['title'], 'img_server' => $news_image['img_server'], 'status' => $status, 'pen_name' => addslashes($pen_name), 'source' => addslashes($source), 'get_source' => $get_source, 'time_created' => TIME_NOW, 'username' => User::user_name(), 'time_modify' => TIME_NOW, 'user_modify' => User::user_name(), 'hot' => $hot, 'focus' => $focus));
         if ($news_id) {
             if ($news_image['name'] && $news_image['id']) {
                 DB::update("news_image", array("news_id" => $news_id), "id={$news_image['id']}");
             }
             if (Url::get('href')) {
                 Url::redirect_url(urldecode(Url::get('href')));
             } else {
                 Url::redirect_current();
             }
         }
         $this->setFormError('title', "Không sửa được tin, mời bạn thử lại!");
     }
 }