本文整理汇总了PHP中AZLib::ftp_check_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP AZLib::ftp_check_dir方法的具体用法?PHP AZLib::ftp_check_dir怎么用?PHP AZLib::ftp_check_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AZLib
的用法示例。
在下文中一共展示了AZLib::ftp_check_dir方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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!");
}
}
示例2: item_image_upload
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';
//.........这里部分代码省略.........
示例3: on_submit
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();
}
}
示例4: list
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'] = '';
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;
示例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'];
//.........这里部分代码省略.........
示例6: on_submit
//.........这里部分代码省略.........
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})";
}
}
}
if ($sql_inset) {
$sql_inset = "INSERT INTO category_zone_cat (zoneid, catid) VALUES " . $sql_inset;
DB::query($sql_inset);
示例7: edit_user
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;
}
}
示例8: 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', 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!");
}
}
示例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);
}
}
}
}