当前位置: 首页>>代码示例>>PHP>>正文


PHP AZLib::ftp_image_delete_file方法代码示例

本文整理汇总了PHP中AZLib::ftp_image_delete_file方法的典型用法代码示例。如果您正苦于以下问题:PHP AZLib::ftp_image_delete_file方法的具体用法?PHP AZLib::ftp_image_delete_file怎么用?PHP AZLib::ftp_image_delete_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AZLib的用法示例。


在下文中一共展示了AZLib::ftp_image_delete_file方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete_images

 static function delete_images($id)
 {
     $row = DB::select('item_image', 'id=' . $id);
     if ($row) {
         if ($row['root_id']) {
             //Ảnh gốc
             DB::delete('item_image', 'root_id=' . $row['root_id']);
         } else {
             DB::delete('item_image', 'id=' . $id);
         }
         //update memcache IMG
         $sql = "SELECT item_id FROM item_image WHERE (id = {$id} OR root_id = {$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);
             }
         }
         //update memcache IMG
         if ($row['img_url']) {
             if (DB::query("UPDATE item SET img_url='' WHERE img_url='" . $row['img_url'] . "'") && MEMCACHE_ON) {
                 $sql = "SELECT * FROM item WHERE img_url = '{$row['img_url']}'";
                 $re = DB::query($sql);
                 while ($item_memcache = mysql_fetch_assoc($re)) {
                     $item_memcache['img_server'] = 0;
                     $item_memcache['img_url'] = '';
                     AZMemcache::do_put("item:" . $item_memcache['id'], $item_memcache);
                 }
             }
             AZLib::ftp_image_delete_file($row['img_url'], $row['img_server']);
         }
     }
 }
开发者ID:duynhan07,项目名称:elink,代码行数:35,代码来源:ManageImage.php

示例2: on_submit

 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!");
     }
 }
开发者ID:duynhan07,项目名称:elink,代码行数:26,代码来源:EditUser.php

示例3: gallery_bulk_delete

 function gallery_bulk_delete()
 {
     //Xoá nhiều ảnh
     $arrIDs = explode(',', Url::get('ids'));
     $return = 'fail';
     if (count($arrIDs)) {
         foreach ($arrIDs as $imgID) {
             $image = DB::select('item_image', 'id=' . $imgID . (User::have_permit(ADMIN_IMAGE) ? '' : ' AND user_id=' . User::id()));
             if ($image) {
                 if ($image['img_url']) {
                     AZLib::ftp_image_delete_file($image['img_url'], $image['img_server']);
                     //Xoá ảnh gốc
                     //DB::query("UPDATE item SET img_url='' WHERE img_url='{$image['img_url']}' AND status IN(1,2) " . (User::have_permit(ADMIN_IMAGE) ? '' : ' AND user_id=' . User::id()));
                 }
                 //get Item_id
                 $sql = "SELECT item_id FROM item_image WHERE (id = {$imgID} OR root_id = {$imgID}) " . (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);
                     }
                 }
                 DB::delete('item_image', '(id=' . $imgID . ' OR root_id=' . $imgID . ')' . (User::have_permit(ADMIN_IMAGE) ? '' : ' AND user_id=' . User::id()));
                 $return = 'success';
             }
         }
     }
     echo $return;
     exit;
 }
开发者ID:duynhan07,项目名称:elink,代码行数:32,代码来源:ajax_upload.ajax.php

示例4: UserAdmin

 function UserAdmin($row)
 {
     define('BAN_NICK_DATE', 7);
     CGlobal::$website_title = 'Quản lý thành viên';
     Module::Module($row);
     if (User::have_permit(ADMIN_USER)) {
         switch (Url::get('cmd')) {
             case 'lockdie':
                 //Khoá vĩnh viễn
                 $id = (int) Url::get('id', 0);
                 if ($id) {
                     $user = User::getUser($id);
                     if ($user) {
                         DB::update('user', array('block_time' => -1), 'id=' . $id);
                         DB::insert('user_lock', array('time' => TIME_NOW, 'user_id' => $id, 'user_name' => $user['user_name'], 'type' => 3, 'admin_id' => User::id(), 'admin_name' => User::user_name()));
                         User::getUser($id, 0, 1);
                     }
                 }
                 Url::redirect_url(Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac')));
                 break;
             case 'delete':
                 Item::delete_item(Url::get('id'));
                 Url::redirect_url(Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac'), "cmd=item_list"));
                 break;
             case 'del_cache':
                 $id = (int) Url::get('id', 0);
                 if ($id) {
                     User::getUser($id, 0, 1);
                 }
                 Url::redirect_url(Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac')));
                 break;
             case 'del_avatar':
                 $user = DB::select('user', (int) Url::get('id'));
                 if ($user) {
                     if ($user['avatar_url']) {
                         AZLib::ftp_image_delete_file($user['avatar_url'], $user['img_server']);
                         DB::update('user', array('avatar_url' => '', 'img_server' => 0), 'id=' . $user['id']);
                         User::getUser($user['id'], 0, 1);
                     }
                 }
                 Url::redirect_url(Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac')));
                 break;
             case 'item_list':
                 require_once 'forms/item_list.php';
                 $this->add_form(new ItemListForm());
                 break;
             case 'user_log':
                 require_once 'forms/user_log.php';
                 $this->add_form(new UserLogForm());
                 break;
             case 'detail':
                 require_once 'forms/UserDetail.php';
                 $this->add_form(new UserDetailForm());
                 break;
             case 'add':
                 require_once 'forms/UserAdd.php';
                 $this->add_form(new UserAddForm());
                 break;
             case 'edit':
                 require_once 'forms/UserEdit.php';
                 $this->add_form(new UserEditForm());
                 break;
             default:
                 require_once 'forms/UserAdmin.php';
                 $this->add_form(new ListUserAdminForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
开发者ID:duynhan07,项目名称:elink,代码行数:71,代码来源:class.php

示例5: on_submit

 function on_submit()
 {
     $submit = Url::get('submit');
     $submitLogo = Url::get('submitLogo');
     if ($submit == 'Cập nhật') {
         if (User::is_admin()) {
             $status = (int) Url::get('status', 0);
             $b_background_file = DATA_PATH . "b_background.gif";
             if (isset($_FILES['b_background']) && $_FILES['b_background']['error'] == 0) {
                 $file_ext = strtolower(AZLib::getExtension($_FILES['b_background']['name']));
                 if (in_array($file_ext, array('.jpg', '.jpeg', '.png', '.gif'))) {
                     if (getimagesize($_FILES['b_background']['tmp_name'])) {
                         if (!move_uploaded_file($_FILES['b_background']['tmp_name'], $b_background_file)) {
                             $this->setFormError('b_background', 'Không up load được Body Background!');
                             return;
                         }
                     } else {
                         $this->setFormError('b_background', 'Sai định dạng Body Background!');
                         return;
                     }
                 } else {
                     $this->setFormError('b_background', 'Body Background chỉ chấp nhận các định dạng file .jpg, .jpeg, .gif, .png!');
                     return;
                 }
             }
             if (isset(CGlobal::$configs['event_on'])) {
                 DB::update('configs', array("conf_val" => $status), "conf_key='event_on'");
             } else {
                 DB::insert('configs', array("conf_key" => 'event_on', "conf_val" => $status));
             }
             AZLib::get_config(0, 1);
         }
         if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) {
             $referer = $_SERVER['HTTP_REFERER'];
         } else {
             $referer = $_SERVER['REQUEST_URI'];
         }
         Url::redirect_url($referer);
     }
     if (User::have_permit(ADMIN_LOGO) && $submitLogo) {
         $id = (int) Url::get('logoID', 0);
         $cmd = Url::get('logoCmd');
         if ($cmd == 'delete') {
             if ($id) {
                 $record = DB::select('website_logo', 'id=' . $id);
             }
             AZLib::ftp_image_delete_file($record['image'], $record['img_server']);
             $sql = 'delete FROM website_logo WHERE id = ' . $id;
             DB::query($sql);
             AZLib::getWebsiteLogo(1);
         } else {
             $logo = array();
             $start_date = Url::get('logoStartDate', 0);
             $end_date = Url::get('logoEndDate', 0);
             if ($id) {
                 $logo = DB::fetch("SELECT * FROM website_logo WHERE id = {$id}");
             }
             $logo['title'] = Url::get('logoTitle');
             if (!isset($logo['img_server'])) {
                 $logo['img_server'] = IMAGE_SERVER_NO;
             }
             if (!$cmd) {
                 $logo['username'] = User::$current->data['user_name'];
             }
             if ($start_date) {
                 $date_arr = explode("-", $start_date);
                 if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
                     $logo['start_date'] = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
                 }
             } else {
                 $logo['start_date'] = 0;
             }
             if ($end_date) {
                 $date_arr = explode("-", $end_date);
                 if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
                     $logo['end_date'] = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
                 }
             } else {
                 $logo['end_date'] = 0;
             }
             if (Url::get('logoActive', 0)) {
                 DB::query("UPDATE website_logo SET status = 0");
                 $logo['status'] = 1;
             } else {
                 $logo['status'] = 0;
             }
             //Gen image unique name
             $img = $_FILES['uploadLogo']['name'];
             $img = explode('.', $img);
             $img = array_pop($img);
             $mini = microtime(TRUE);
             $img = $mini . '.' . $img;
             if ($_FILES['uploadLogo']['tmp_name']) {
                 if ($cmd == 'edit') {
                     //sửa
                     AZLib::ftp_image_delete_file('logo/' . $img, $logo['img_server']);
                 }
                 if (AZLib::ftp_check_dir('logo/', TRUE, IMAGE_SERVER_NO)) {
                     $file_name = 'logo/' . $img;
                     $sourceName = $_FILES['uploadLogo']['tmp_name'];
//.........这里部分代码省略.........
开发者ID:duynhan07,项目名称:elink,代码行数:101,代码来源:header.php

示例6: on_submit


//.........这里部分代码省略.........
     $this->checkFormInput('Tên vắn tắt', 'brief_name', $brief_name, 'str', false, '', 1, 255);
     //$this->checkFormInput('Từ khoá','keywords',$keywords,'str',false,'',0,20);
     $this->checkFormInput('Mô tả', 'description', $description, 'str', false, '', 0, 250);
     if (Url::get('cmd') == 'edit' && $this->cat['parent_id'] == 0 && $parent_id && DB::select("category", 'parent_id=' . $this->cat['id'])) {
         $this->setFormError("parent_id", 'Không thể chuyển "Danh mục có danh mục con" thành một "Danh mục con" của "Danh mục khác" được!');
     }
     if (!$this->errNum) {
         $new_row = array('name' => $name, 'brief_name' => $brief_name ? $brief_name : $name, 'keywords' => AZLib::word_limit($keywords, 20, ''), 'description' => $description, 'parent_id' => $parent_id, 'ref_id' => $ref_id, 'status' => $status, 'tag_search' => $tag_search, 'img_server' => IMAGE_SERVER_NO, 'price_str' => $price_str, 'recomend' => $recomend);
         if (Url::get('cmd') == 'edit') {
             if ($position > 0 && $position != $this->cat['position']) {
                 $max_pos = (int) DB::fetch("SELECT max(position) AS max_pos FROM category WHERE parent_id=" . $parent_id, 'max_pos');
                 if ($position > $max_pos) {
                     $position = $max_pos + 1;
                 }
                 $new_row['position'] = $position;
             } else {
                 $position = $this->cat['position'];
             }
             $id = $this->cat['id'];
             DB::update('category', $new_row, 'id=' . $this->cat['id']);
             /*if($this->cat['parent_id']==0 && $parent_id){
             			DB::update('category', array('parent_id'=>0),'parent_id='.$this->cat['parent_id']);
             		}*/
         } else {
             $max_pos = (int) DB::fetch("SELECT max(position) AS max_pos FROM category WHERE parent_id=" . $parent_id, 'max_pos');
             if ($position > $max_pos || $position == 0) {
                 $position = $max_pos + 1;
             }
             $new_row['position'] = $position;
             $id = DB::insert('category', $new_row);
         }
         if ($_FILES['cat_image']['tmp_name']) {
             if (Url::get('cmd') == 'edit') {
                 AZLib::ftp_image_delete_file('category/' . $this->cat['id'] . '.gif', $this->cat['img_server']);
             }
             /*if(AZLib::ftp_image_connect(IMAGE_SERVER_NO)){
             			if(!AZLib::ftp_check_dir('category/',true,IMAGE_SERVER_NO)){
             				break ;
             			}
             				
             			$file_name	='category/'.$id.'.gif';
             			$sourceName =$_FILES['cat_image']['tmp_name'];
             			AZLib::ftp_image_put_file($file_name,$sourceName,IMAGE_SERVER_NO);
             			//@fopen('http://'.IMAGE_PATH.'?del_cat=1',"r");
             		}*/
             if (AZLib::ftp_check_dir('category/', true, IMAGE_SERVER_NO)) {
                 $file_name = 'category/' . $id . '.gif';
                 $sourceName = $_FILES['cat_image']['tmp_name'];
                 AZLib::ftp_image_put_file($file_name, $sourceName, IMAGE_SERVER_NO);
                 //@fopen('http://'.IMAGE_PATH.'?del_cat=1',"r");
             }
         }
         if ($id && DB::select('category', 'position="' . $position . '" AND id!="' . $id . '" AND parent_id="' . $parent_id . '"')) {
             DB::query('UPDATE category SET position=position+1 WHERE position>=' . $position . ' AND position<=' . $this->cat['position'] . ' AND parent_id="' . $parent_id . '" AND id!=' . $id);
         }
         $all_zones = $this->zones;
         $sql_inset = "";
         if ($zoneids) {
             foreach ($zoneids as $zoneid) {
                 if (isset($all_zones[$zoneid])) {
                     unset($all_zones[$zoneid]);
                 } else {
                     $sql_inset .= ($sql_inset != '' ? ',' : '') . "({$zoneid},{$id})";
                 }
             }
         }
开发者ID:duynhan07,项目名称:elink,代码行数:67,代码来源:CategoryEdit.php

示例7: fn_get_avatar_ya

 function fn_get_avatar_ya()
 {
     $avatar_id = Url::get('yahoo_id');
     if (!User::is_login()) {
         echo 'not_login';
         exit;
     } elseif ($avatar_id == '') {
         echo "empty";
         exit;
     } else {
         if (User::is_block()) {
             echo "unsuccess";
             exit;
         }
         if (User::$current->data['avatar_url'] != '') {
             @AZLib::ftp_image_delete_file(User::$current->data['avatar_url']);
         }
         $avatar_url = AZLib::get_yahoo_avatar($avatar_id, User::id(), IMAGE_SERVER_NO);
         if (DB::query('UPDATE user SET avatar_url="' . $avatar_url . '", img_server=' . IMAGE_SERVER_NO . ' WHERE id="' . User::id() . '"')) {
             User::updateUserCache(User::id());
             echo '<img src="' . AZLib::getImageThumb($avatar_url, 100, 100, 0, IMAGE_SERVER_NO) . '" />';
             exit;
         } else {
             echo "unsuccess";
             exit;
         }
     }
 }
开发者ID:duynhan07,项目名称:elink,代码行数:28,代码来源:ajax_personal.ajax.php

示例8: Category


//.........这里部分代码省略.........
                         Url::redirect_current(array("mod"));
                         break;
                     case 'show':
                     case 'hide':
                         //AZLib::del_cache_zone_cat();
                         $id = (int) Url::get('id', 0);
                         if ($id) {
                             $cat_zone = DB::select('category_zone', 'id=' . $id);
                             if ($cat_zone) {
                                 if ($cmd == 'hide') {
                                     $status = 0;
                                 } else {
                                     $status = 1;
                                 }
                                 DB::update('category_zone', array('status' => $status), "id={$id}");
                                 AZLib::getCats(0, 1);
                             }
                         }
                         Url::redirect_current(array("mod"));
                         break;
                     default:
                         require_once 'forms/Zone.php';
                         $this->add_form(new ZoneForm());
                 }
                 break;
             default:
                 switch ($cmd) {
                     case 'del_image':
                         $id = (int) Url::get('id', 0);
                         //Xoá file ảnh
                         if ($id) {
                             $cat = DB::select('category', "id={$id}");
                             if ($cat) {
                                 AZLib::ftp_image_delete_file('category/' . $id . '.gif', $cat['img_server']);
                                 //@fopen('http://'.IMAGE_PATH.'?del_cat=1',"r");//Xoá cache file ảnh
                             }
                             Url::redirect_current();
                         }
                         break;
                     case 'delete':
                         $selected_ids = Url::get('selected_ids');
                         if ($selected_ids) {
                             $ids = implode(',', $selected_ids);
                             if ($ids != '') {
                                 //									AZLib::del_cache_zone_cat();
                                 DB::delete('category', 'id IN(' . $ids . ')');
                             }
                             AZLib::getCats(0, 1);
                         }
                         Url::redirect_current();
                         break;
                     case 'del_cache':
                         //							AZLib::del_cache_zone_cat();
                         AZLib::getCats(0, 1);
                         Url::redirect_current();
                         break;
                     case 'add':
                     case 'edit':
                         require_once 'forms/CategoryEdit.php';
                         $this->add_form(new EditCategoryForm());
                         break;
                     case 'move_up':
                     case 'move_down':
                         $id = (int) Url::get('id', 0);
                         if ($id) {
                             $cat = DB::select('category', 'id=' . $id);
开发者ID:duynhan07,项目名称:elink,代码行数:67,代码来源:class.php

示例9: on_submit

 function on_submit()
 {
     if (User::is_admin()) {
         if (Url::get('cmd') == 'delete') {
             $id = (int) Url::get('id', 0);
             if ($id) {
                 $record = DB::select('adv_banner', 'id=' . $id);
             }
             AZLib::ftp_image_delete_file($record['img'], $record['img_server']);
             $sql = 'delete FROM adv_banner WHERE id = ' . $id;
             DB::query($sql);
             AZLib::getAdvBanners(1);
         } else {
             $this->banner['title'] = Url::get('title');
             $this->banner['link'] = Url::get('link');
             $zones = Url::get('zones');
             $blank = Url::get('blank');
             $is_home = Url::get('is_home');
             $this->banner['is_home'] = $is_home;
             $this->banner['blank'] = $blank;
             $start_date = Url::get('advStartDate', 0);
             $end_date = Url::get('advEndDate', 0);
             if ($start_date) {
                 $date_arr = explode("-", $start_date);
                 if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
                     $this->banner['start_date'] = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
                 }
             } else {
                 $this->banner['start_date'] = 0;
             }
             if ($end_date) {
                 $date_arr = explode("-", $end_date);
                 if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
                     $this->banner['end_date'] = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
                 }
             } else {
                 $this->banner['end_date'] = 0;
             }
             if ($zones) {
                 if (is_array($zones)) {
                     $this->banner['zones'] = implode(',', $zones);
                 }
             }
             /* $catids = Url::get('catids');
                if($catids)
                {
                if(is_array($catids)) $this->banner['catids']	= implode(',',$catids);
                } */
             if (Url::get('cmd') == '') {
                 $this->banner['username'] = User::$current->data['user_name'];
                 $this->banner['c_time'] = strtotime("now");
             }
             $this->banner['m_username'] = User::$current->data['user_name'];
             $this->banner['m_time'] = strtotime("now");
             //Gen image unique name
             $img = $_FILES['img']['name'];
             $img = explode('.', $img);
             $img = array_pop($img);
             $mini = microtime(true);
             $img = $mini . '.' . $img;
             if ($_FILES['img']['tmp_name']) {
                 if (Url::get('cmd') == 'edit') {
                     //sửa
                     AZLib::ftp_image_delete_file('items/adv_banner/' . $img, $this->banner['img_server']);
                 }
                 if (AZLib::ftp_check_dir('items/adv_banner/', true, IMAGE_SERVER_NO)) {
                     $file_name = 'items/adv_banner/' . $img;
                     $sourceName = $_FILES['img']['tmp_name'];
                     AZLib::ftp_image_put_file($file_name, $sourceName, IMAGE_SERVER_NO);
                     $this->banner['img'] = $file_name;
                 }
             }
             if (!$this->errNum) {
                 if (Url::get('cmd') == 'edit') {
                     $id = (int) Url::get('id', 0);
                     DB::update('adv_banner', $this->banner, 'id=' . $id);
                 } else {
                     $id = DB::insert('adv_banner', $this->banner);
                 }
                 AZLib::getAdvBanners(1);
             }
         }
     }
 }
开发者ID:duynhan07,项目名称:elink,代码行数:84,代码来源:AdvBanner.php

示例10: on_submit

 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', 0);
     $image_title = Url::get('image_title');
     /*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" => $this->news['image'], "img_server" => $this->news['img_server'], "title" => addslashes($image_title));
         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) {
                         $news_image = array("name" => $this->news['image'], "img_server" => $this->news['img_server'], "title" => addslashes($image_title), 'time_create' => TIME_NOW, 'news_id' => $this->news['id'], 'username' => User::user_name());
                         $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;
                             $news_image['img_server'] = IMAGE_SERVER_NO;
                             $image_id = DB::insert('news_image', $news_image);
                             if ($image_id) {
                                 if ($this->news['image'] != '') {
                                     AZLib::ftp_image_delete_file($this->news['name'], $this->news['img_server']);
                                     DB::delete("news_image", "news_id = " . $this->news['id'] . " AND 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);
         }
         if (DB::update('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_modify' => TIME_NOW, 'user_modify' => User::user_name(), 'hot' => $hot, 'focus' => $focus), "id=" . $this->news['id'], __LINE__ . __FILE__)) {
             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!");
     }
 }
开发者ID:duynhan07,项目名称:elink,代码行数:84,代码来源:NewsAdminEdit.php


注:本文中的AZLib::ftp_image_delete_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。