Пример #1
0
 function ImportExcel($row)
 {
     if (User::have_permit(array(ADMIN_ITEM))) {
         Module::Module($row);
         $cmd = Url::get('cmd');
         switch ($cmd) {
             case 'download':
                 $file_src = DATA_PATH . "AzNet.xls";
                 if (file_exists(ROOT_PATH . $file_src)) {
                     $ext = AZLib::getExtension($file_src);
                     if ($ext && strlen($ext) <= 5) {
                         $ext_app = substr($ext, 1);
                         header("Content-type: application/{$ext_app}");
                         header("Content-Disposition: attachment; filename=" . date("Y.m.d-H\\hi", TIME_NOW) . "_ANS_Products{$ext}");
                         readfile(ROOT_PATH . $file_src);
                         exit;
                     }
                 }
                 header("HTTP/1.0 404 Not Found");
                 echo "<h1>404 - Not Found!<br />Return to <a href='" . WEB_ROOT . "'>" . WEB_NAME . "</a></h1>";
                 exit;
                 break;
             default:
                 require_once 'forms/ImportExcel.php';
                 $this->add_form(new ImportExcelForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
Пример #2
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!");
     }
 }
Пример #3
0
 function on_submit()
 {
     if (User::have_permit(ADMIN_ADV)) {
         $status = (int) Url::get('status', 0);
         $url_detail = Url::get('url');
         $type = (int) Url::get('type', 0);
         $config_arr = array('status' => (int) $status, 'url_detail' => $url_detail, 'type' => (int) $type);
         if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
             $banner_file = ROOT_PATH . 'promotion/popup';
             //$file_ext=strtolower(substr($_FILES['banner']['name'],strlen($_FILES['banner']['name'])-4,4));
             $file_ext = AZLib::getExtension($_FILES['banner']['name']);
             if ($type == 0) {
                 if (in_array($file_ext, array('.jpg', '.gif'))) {
                     if (getimagesize($_FILES['banner']['tmp_name'])) {
                         if (!move_uploaded_file($_FILES['banner']['tmp_name'], $banner_file . '.gif')) {
                             $this->setFormError('banner', 'Không up load được Banner!');
                             return;
                         }
                     } else {
                         $this->setFormError('banner', 'Sai định dạng ảnh!');
                         return;
                     }
                 } else {
                     $this->setFormError('banner', 'Chỉ chấp nhận các định dạng file .jpg , .gif !');
                     return;
                 }
             } else {
                 if (in_array($file_ext, array('.swf'))) {
                     if (!move_uploaded_file($_FILES['banner']['tmp_name'], $banner_file . $file_ext)) {
                         $this->setFormError('banner', 'Không up load được Banner!');
                         return;
                     }
                 } else {
                     $this->setFormError('banner', 'Flash đại diện chỉ chấp nhận các định dạng file .swf');
                     return;
                 }
             }
         }
         $_SESSION['adv_cover_top'] = 0;
         if (isset(CGlobal::$configs['AdvCover'])) {
             DB::update('configs', array("conf_val" => addslashes(serialize($config_arr))), "conf_key='AdvCover'");
         } else {
             DB::insert('configs', array("conf_key" => 'AdvCover', "conf_val" => addslashes(serialize($config_arr))));
         }
         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);
 }
Пример #4
0
 function on_submit()
 {
     if (isset($_FILES['zipfile']) && $_FILES['zipfile']['error'] == 0) {
         //$fileEXT=strtolower(substr($_FILES['zipfile']['name'],strlen($_FILES['zipfile']['name'])-4,4));
         $fileEXT = AZLib::getExtension($_FILES['zipfile']['name']);
         if ($fileEXT == '.zip') {
             $uploadPath = ROOT_PATH . 'promotion/';
             @chmod($uploadPath, 0777);
             $zipFilePath = $uploadPath . time() . $fileEXT;
             @chmod($zipFilePath, 0777);
             if (!move_uploaded_file($_FILES['zipfile']['tmp_name'], $zipFilePath)) {
                 $this->setFormError('zipfile', "Không Upload được file Zip !");
                 return;
             } else {
                 @chmod($zipFilePath, 0777);
                 require_once "includes/unzip.ncl.php";
                 if (file_exists($zipFilePath)) {
                     $txt = '';
                     //unzipping...
                     $zip = new PclZip($zipFilePath);
                     if (($list = $zip->listContent()) == 0) {
                         $this->setFormError('zipfile', "File Zip trống!");
                         @unlink($zipFilePath);
                         return;
                     }
                     //calculate statistics...
                     for ($i = 0; $i < sizeof($list); $i++) {
                         if ($list[$i]['folder'] == '1') {
                             $fold++;
                             $dirs[$fold] = $list[$i]['stored_filename'];
                             $dirname = $list[$i]['stored_filename'];
                             $dirname = substr($dirname, 0, strlen($dirname) - 1);
                             @mkdir($basedir . '/' . $dirname);
                             @chmod($basedir . '/' . $dirname, 0777);
                         }
                     }
                     if ($zip->extract('promotion/')) {
                         unset($zip);
                         @unlink($zipFilePath);
                     } else {
                         $this->setFormError('zipfile', "Không giải nén được!");
                         return;
                     }
                 }
             }
         } else {
             $this->setFormError('zipfile', "File Upload phải là file nén dạng .zip !");
             return;
         }
     }
     $this->setFormError('zipfile', "Bạn chưa chọn file up lên!");
     //Url::redirect_current();
 }
Пример #5
0
 static function sendEBEmail($to, $subject, $content, $FromNameMail = '', $images = array())
 {
     $FromNameMail = WEB_NAME;
     require_once 'includes/mailer/PHPMailer_v5.1/class.phpmailer.php';
     $mail = new PHPMailer();
     //$mail->CharSet 		= 'utf-8';
     $mail->IsSMTP();
     //$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
     //$mail->SetLanguage("vn",ROOT_PATH.'includes/mailer/PHPMailer_v5.1/');
     $mail->Host = SMTP_HOST;
     $mail->SMTPSecure = SMTP_SECURE;
     //For PHPMailer_v5.1
     $mail->Port = SMTP_PORT;
     $mail->SMTPAuth = SMTP_AUTH;
     $mail->SMTPSecure = SMTP_SECURE;
     $mail->Username = SMTP_USER;
     // SMTP username
     $mail->Password = SMTP_PASS;
     // SMTP password
     $mail->From = SMTP_FROM_EMAIL;
     // Email duoc gui tu???
     $mail->FromName = WEB_NAME;
     // Ten hom email duoc gui
     //$mail->SetFrom(SMTP_FROM_EMAIL, WEB_NAME);
     $mail->AddReplyTo(SMTP_FROM_EMAIL, WEB_NAME);
     $mail->AddAddress($to, "");
     // Dia chi email va ten nhan
     $mail->Subject = $subject;
     // Chu de email
     $mail->IsHTML(true);
     // Gui theo dang HTML
     $mail->Body = $content;
     // Noi dung html
     $mail->AltBody = 'Để xem được nội dung Email này, hãy sử dụng một trình duyệt Email tương thích với mã HTML! (To view the message, please use an HTML compatible email viewer!)';
     //optional - MsgHTML will create an alternate automatically
     if (!empty($images)) {
         $mail->message_type = 'attachments';
         foreach ($images as $img) {
             if (!empty($img)) {
                 $ext = AZLib::getExtension($img['src']);
                 $img['mime'] = 'image/' . substr(strtolower($ext), 1, strlen($ext));
                 $mail->AddEmbeddedImage($img['src'], $img['id'], $img['title'], 'base64', $img['mime']);
             }
         }
         //cau hinh nhu sau <img src="cid:ubzsed" />
     }
     if (!$mail->Send()) {
         return false;
     } else {
         return true;
     }
 }
Пример #6
0
 function Document($row)
 {
     Module::Module($row);
     $cmd = Url::get('cmd');
     require_once "forms/DocumentList.php";
     switch ($cmd) {
         case 'delete':
             $this->add_form(new Deletedocument());
             break;
         case 'change':
             $this->add_form(new PublicdocumentForm());
             break;
         default:
             $id = (int) Url::get('id');
             $azname = trim(URL::get("azname", ''));
             if ($id || $azname != '') {
                 if ($id && $azname != '') {
                     $document = DB::select("document", "id={$id}");
                     if ($document && $azname == AZLib::safe_title($document['title']) && $document['file_path']) {
                         $file_src = DATA_PATH . "document/{$document['file_path']}";
                         if (file_exists(ROOT_PATH . $file_src)) {
                             $ext = AZLib::getExtension($file_src);
                             if ($ext && strlen($ext) <= 5) {
                                 $ext_app = substr($ext, 1);
                                 if ($document['status'] == 1 || User::haveAnyPermission(ADMIN_DOCUMENT)) {
                                     DB::query("UPDATE document SET down_num=down_num+1, time_last=" . TIME_NOW . " WHERE id={$id}");
                                     DB::close();
                                     header("Content-type: application/{$ext_app}");
                                     header("Content-Disposition: attachment; filename=" . date("Y.m.d-H\\hi", $document['time_m']) . "-{$id}-{$azname}{$ext}");
                                     readfile(ROOT_PATH . $file_src);
                                     exit;
                                 }
                             }
                         }
                     }
                 }
                 header("HTTP/1.0 404 Not Found");
                 echo "<h1>404 - Not Found!<br />Return to <a href='" . WEB_ROOT . "'>" . WEB_NAME . "</a></h1>";
                 exit;
             }
             $this->add_form(new ListdocumentForm());
             break;
     }
 }
Пример #7
0
 function get_all_layouts()
 {
     //Code mới: TuấnNK ( 20080606 15h36
     $layouts = array('' => '-- Chọn layout --');
     $dir = opendir(ROOT_PATH . 'layouts');
     while ($file = readdir($dir)) {
         if ($file != '.' and $file != '..' and is_file('layouts/' . $file)) {
             $layouts['layouts/' . $file] = basename($file, AZLib::getExtension($file));
         }
     }
     closedir($dir);
     return $layouts;
 }
Пример #8
0
 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'];
                     AZLib::ftp_image_put_file($file_name, $sourceName, IMAGE_SERVER_NO);
                     $logo['image'] = $file_name;
                 }
             }
             if (!$this->errNum && isset($logo['image']) && $logo['image']) {
                 if ($cmd == 'edit') {
                     DB::update('website_logo', $logo, 'id=' . $id);
                 } else {
                     $id = DB::insert('website_logo', $logo);
                 }
                 AZLib::getWebsiteLogo(1);
             }
         }
     }
 }
Пример #9
0
 function upload()
 {
     $json['error'] = 'not_uploaded';
     $json['image_url'] = '';
     if (User::is_login()) {
         $upload_path = DIR_CACHE . 'ad_images/';
         AZLib::CheckDir($upload_path);
         $uploadFile = $_FILES["fast_upload"];
         if (isset($uploadFile) && $uploadFile['name']) {
             $file_name = TIME_NOW . strtolower($uploadFile['name']);
             $sourceName = $uploadFile['tmp_name'];
             $file_ext = AZLib::getExtension($file_name);
             if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) {
                 if (!$uploadFile['error']) {
                     $newFile = $upload_path . $file_name;
                     //$width = 300;
                     //$height = 255;
                     //$this->genImageFromSource($sourceName,$upload_path.$file_name,$width);
                     include_once ROOT_PATH . 'core/ThumbImage.php';
                     $ThumbImage = new ThumbImage();
                     $ThumbImage->ThumbImageWithBackground($sourceName, $file_name, 300);
                     // Tạo cache đã resize cho ảnh quảng cáo
                     // Upload lên server ảnh, fix lỗi không tìm thấy file cache với server load balancing
                     $img_path = 'upnew/cpc/';
                     AZLib::ftp_image_put_file($img_path . $file_name, $newFile, IMAGE_SERVER_NO);
                     $img_url = $img_path . $file_name;
                     $json['image_domain'] = 'http://' . CGlobal::$img_server[IMAGE_SERVER_NO];
                     $json['image_url'] = $img_url;
                     $json['error'] = 'success';
                 } elseif ($uploadFile['error'] == 1) {
                     $json['error'] = 'over_max_size';
                 }
             } else {
                 $json['error'] = 'ext_invalid';
                 //Sai định dạng file
             }
         } else {
             $json['error'] = 'destination_not_exist';
         }
     } else {
         $json['error'] = 'not_login';
     }
     echo json_encode($json);
     exit;
 }
Пример #10
0
 function on_submit()
 {
     $start_row = 6;
     //$start_row = 4;
     if (isset($_FILES['file_excel']) && $_FILES['file_excel']['error'] == 0) {
         $file_ext = AZLib::getExtension($_FILES['file_excel']['name']);
         if ($file_ext == '.xls') {
             require_once 'includes/excel/PHPExcel_1.7.6/PHPExcel/IOFactory.php';
             try {
                 $objPHPExcel = PHPExcel_IOFactory::load($_FILES['file_excel']['tmp_name']);
             } catch (Exception $e) {
                 $this->setFormError('', 'File bạn nhập không đúng định dạng');
             }
         } else {
             $this->setFormError('', 'File bạn nhập không đúng định dạng');
         }
     } else {
         $this->setFormError('', "Bạn chưa chọn file Excel!");
     }
     $sku_arr = array();
     //B Col 1
     $category_id_arr = array();
     //C Col 2
     $brand_arr = array();
     //D Col 3
     $name_arr = array();
     //E Col 4
     $quantity_arr = array();
     //F Col 5 - Số lượng
     $made_in_arr = array();
     //G Col 6
     $warranty_arr = array();
     //H Col 7
     $price_arr = array();
     //I Col 8
     $price_out_arr = array();
     //J Col 9
     $currency_id_arr = array();
     //Q Col 16
     $offer_arr = array();
     //R Col 17
     $status_arr = array();
     //S Col 18
     $list_brief_arr = array();
     //T Col 19
     $description_arr = array();
     //U Col 20
     $brief_arr = array();
     //V Col 21
     ##########################################################################################################
     #Check lỗi:
     $error = '';
     $worksheet = $objPHPExcel->getSheetByName('Sản phẩm');
     if (!$worksheet) {
         $this->setFormError('', 'Tên sheet gốc đã bị thay đổi, hãy đổi lại tên sheet thành "Sản phẩm"');
     }
     $brand_name_ars = array();
     $not_allow_update = array();
     $not_allow_insert = array();
     if (!$this->errNum) {
         if ($worksheet->getCell("Z1")->getValue() != 2) {
             $this->setFormError('', 'File excel không đúng phiên bản, đề nghị <a href="import_excel.html?cmd=download" style="color:#0000FF"><b>Tải về file Excel mẫu</b></a> mới nhất và cập nhật lại!');
             return;
         }
         $max_rows = $worksheet->getHighestRow();
         for ($i = $start_row; $i <= $max_rows; $i++) {
             $sku = trim(str_replace(array("'", "\""), '', $worksheet->getCell("B{$i}")->getValue()));
             if ($sku == '') {
                 //$error	.=	"<b>SKU</b> tại Cell <font color='#f00'>B$i</font> không được để trống<br/>";
                 $not_allow_update[$i] = $i;
                 //Không cho  update
                 $not_allow_insert[$i] = $i;
                 //Không cho insert
             } else {
                 $sku_arr[$i] = $sku;
                 $catid = trim($worksheet->getCell("C{$i}")->getValue());
                 if ($catid) {
                     if (!isset(CGlobal::$allCategories[$catid])) {
                         //$error	.=	"<b>ID Danh mục</b> tại Cell <font color='#f00'>C$i</font> không tồn tại<br/>";
                         $not_allow_update[$i] = $i;
                         //Không cho  update
                         $not_allow_insert[$i] = $i;
                         //Không cho insert
                     }
                 }
                 $category_id_arr[$i] = $catid;
                 $brand_arr[$i] = trim($worksheet->getCell("D{$i}")->getValue());
                 if ($brand_arr[$i] != '') {
                     $brand_name_ars[strtolower($brand_arr[$i])] = str_replace(array("'", "\""), '', $brand_arr[$i]);
                 }
                 $name_arr[$i] = trim($worksheet->getCell("E{$i}")->getValue());
                 if ($name_arr[$i] == '') {
                     //$error	.=	"<b>Tên sản phẩm</b> tại Cell <font color='#f00'>C$i</font> không được để trống<br/>";
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 } elseif (strlen($name_arr[$i]) < 2) {
                     //$error	.=	"<b>Tên sản phẩm</b> tại Cell <font color='#f00'>C$i</font> không được để trống<br/>";
                     $not_allow_update[$i] = $i;
                     //Không cho  update
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 }
                 $quantity_arr[$i] = abs($worksheet->getCell("F{$i}")->getValue());
                 $made_in_arr[$i] = $worksheet->getCell("G{$i}")->getValue();
                 $warranty_arr[$i] = $worksheet->getCell("H{$i}")->getValue();
                 $price_arr[$i] = abs($worksheet->getCell("I{$i}")->getValue());
                 $price_out_arr[$i] = abs($worksheet->getCell("J{$i}")->getValue());
                 if ($price_out_arr[$i] && $price_out_arr[$i] < $price_arr[$i]) {
                     //$error	.=	"<b>Giá thị trường</b> tại Cell <font color='#f00'>J$i</font> phải lớn hơn hoặc bằng <b>Giá niêm yết</b> tại Cell <font color='#f00'>I$i</font><br/>";
                     $not_allow_update[$i] = $i;
                     //Không cho  update
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 }
                 $currency_id_arr[$i] = strtolower($worksheet->getCell("Q{$i}")->getValue()) == 'usd' ? 2 : 1;
                 $offer_arr[$i] = $worksheet->getCell("R{$i}")->getValue();
                 /*$list_brief_arr[$i] 	= str_replace("/","<br />",$worksheet->getCell("S$i")->getValue());
                 		$brief_arr[$i] 			= str_replace("/","<br />",$worksheet->getCell("T$i")->getValue());
                 		$description_arr[$i] 	= str_replace("/","<br />",$worksheet->getCell("U$i")->getValue());
                 		*/
                 $list_brief_arr[$i] = trim($worksheet->getCell("T{$i}")->getValue());
                 $description_arr[$i] = trim($worksheet->getCell("U{$i}")->getValue());
                 $brief_arr[$i] = trim($worksheet->getCell("V{$i}")->getValue());
                 if ($list_brief_arr[$i] == '') {
                     //$error	.=	"<b>Thông số tóm tắt</b> tại Cell <font color='#f00'>S$i</font> không được để trống!<br/>";
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 } elseif (strlen($list_brief_arr[$i]) < 2) {
                     $not_allow_update[$i] = $i;
                     //Không cho  update
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 }
                 if ($description_arr[$i] == '') {
                     //$error	.=	"<b>Thông số tóm tắt</b> tại Cell <font color='#f00'>S$i</font> không được để trống!<br/>";
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 } elseif (strlen($description_arr[$i]) < 2) {
                     $not_allow_update[$i] = $i;
                     //Không cho  update
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 }
                 if ($brief_arr[$i] == '') {
                     //$error	.=	"<b>Thông số tóm tắt</b> tại Cell <font color='#f00'>S$i</font> không được để trống!<br/>";
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 } elseif (strlen($brief_arr[$i]) < 2) {
                     $not_allow_update[$i] = $i;
                     //Không cho  update
                     $not_allow_insert[$i] = $i;
                     //Không cho insert
                 }
                 /*
                 if($brief_arr[$i] == '')
                 {
                 	$brief_arr[$i] = $list_brief_arr[$i];
                 }
                 
                 if($description_arr[$i] == '')
                 {
                 	$description_arr[$i] = $brief_arr[$i];
                 }
                 */
                 $status_arr[$i] = trim($worksheet->getCell("S{$i}")->getValue());
                 if ($status_arr[$i] != '') {
                     if (in_array($status_arr[$i], array(-1, 1, 2))) {
                         $status_arr[$i] = 1;
                     }
                 }
             }
         }
         #Check lỗi
         ##########################################################################################################
         $success = '';
         if (!$name_arr) {
             $this->setFormError('', "Bạn chưa nhập thông tin sản phẩm nào!");
             return;
         }
         $all_sku_items = array();
         $sku_str = "'" . implode("','", $sku_arr) . "'";
         $re = DB::query("SELECT id, sku FROM item WHERE sku IN({$sku_str})");
         if ($re) {
             while ($item = mysql_fetch_assoc($re)) {
                 $all_sku_items[$item['sku']] = $item['id'];
             }
         }
         $all_rands = array();
         if ($brand_name_ars) {
             $brand_str = "'" . implode("','", $brand_name_ars) . "'";
             $re = DB::query("SELECT * FROM brand WHERE name IN({$brand_str})");
             if ($re) {
                 while ($brand = mysql_fetch_assoc($re)) {
                     $all_rands[strtolower(trim($brand['name']))] = $brand['id'];
                 }
             }
         }
         $total_update = 0;
         $total_add = 0;
         $total_skip = 0;
         foreach ($name_arr as $key => $nam) {
             if (!isset($not_allow_update[$key], $not_allow_insert[$key])) {
                 if (isset($all_sku_items[$sku_arr[$key]])) {
                     if (!isset($not_allow_update[$key])) {
                         $item_update_row = array('status' => 1, 'modify_time' => TIME_NOW, 'modify_user_name' => User::user_name());
                         if ($category_id_arr[$key] != '') {
                             $catid = $category_id_arr[$key];
                             $cattopid = $catid;
                             $catl2id = $catid;
                             $cat = CGlobal::$allCategories[$catid];
                             if ($cat) {
                                 if ($cat['parent_id'] && isset(CGlobal::$allCategories[$cat['parent_id']])) {
                                     $pcat = CGlobal::$allCategories[$cat['parent_id']];
                                     if ($pcat['parent_id'] && isset(CGlobal::$allCategories[$pcat['parent_id']])) {
                                         $cattopid = $pcat['parent_id'];
                                         $catl2id = $pcat['id'];
                                     } else {
                                         //Cấp 2
                                         $cattopid = $cat['parent_id'];
                                         $catl2id = $cat['id'];
                                     }
                                 } else {
                                     $cattopid = $catid;
                                     $catl2id = 0;
                                 }
                             }
                             $item_update_row['level_1_catid'] = $cattopid;
                             $item_update_row['level_2_catid'] = $catl2id;
                             $item_update_row['category_id'] = $catid;
                         }
                         if ($brand_arr[$key] != '') {
                             $brand_id = 0;
                             if (isset($all_rands[strtolower($brand_arr[$key])])) {
                                 $brand_id = $all_rands[strtolower($brand_arr[$key])];
                             } elseif ($brand_arr[$key] != '-') {
                                 $brand_id = DB::insert('brand', array('name' => $brand_arr[$key]));
                                 $all_rands[strtolower($brand_arr[$key])] = $brand_id;
                             }
                             $item_update_row['brand_id'] = $brand_id;
                         }
                         if ($name_arr[$key] != '') {
                             $item_update_row['name'] = $name_arr[$key];
                         }
                         if ($list_brief_arr[$key] != '') {
                             $item_update_row['list_brief'] = $list_brief_arr[$key];
                         }
                         if ($brief_arr[$key] != '') {
                             $item_update_row['brief'] = $brief_arr[$key];
                         }
                         if ($description_arr[$key] != '') {
                             $item_update_row['description'] = $description_arr[$key];
                         }
                         if ($quantity_arr[$key] != '') {
                             $item_update_row['quantity'] = (int) $quantity_arr[$key];
                         }
                         if ($made_in_arr[$key] != '') {
                             if ($made_in_arr[$key] == '-') {
                                 $item_update_row['made_in'] = '';
                             } else {
                                 $item_update_row['made_in'] = (int) $made_in_arr[$key];
                             }
                         }
                         if ($warranty_arr[$key] != '') {
                             if ($warranty_arr[$key] == '-') {
                                 $item_update_row['warranty'] = '';
                             } else {
                                 $item_update_row['warranty'] = (int) $warranty_arr[$key];
                             }
                         }
                         if ($price_arr[$key] != '') {
                             if ($price_arr[$key] == '-') {
                                 $item_update_row['price'] = 0;
                             } else {
                                 $item_update_row['price'] = (int) $price_arr[$key];
                             }
                         }
                         if ($price_out_arr[$key] != '') {
                             if ($price_out_arr[$key] == '-') {
                                 $item_update_row['price_out'] = 0;
                             } else {
                                 $item_update_row['price_out'] = (int) $price_out_arr[$key];
                             }
                         }
                         if ($currency_id_arr[$key] != '') {
                             if ($currency_id_arr[$key] == '-') {
                                 $item_update_row['currency_id'] = 1;
                             } else {
                                 $item_update_row['currency_id'] = (int) $currency_id_arr[$key];
                             }
                         }
                         if ($offer_arr[$key] != '') {
                             if ($offer_arr[$key] == '-') {
                                 $item_update_row['offer'] = '';
                             } else {
                                 $item_update_row['offer'] = $offer_arr[$key];
                             }
                         }
                         if ($status_arr[$key] != '') {
                             if ($status_arr[$key] == '-') {
                                 $item_update_row['status'] = 1;
                             } else {
                                 $item_update_row['status'] = (int) $status_arr[$key];
                             }
                         }
                         $id = $all_sku_items[$sku_arr[$key]];
                         DB::update('item', $item_update_row, "id={$id}");
                         Item::get_item($id, 1);
                         $total_update++;
                         $success .= "<a href='p{$id}.html' target='_blank'>[ ID: {$id} ]</a> Cập nhật thành công sp ở dòng thứ {$key}<br />";
                     } else {
                         $total_skip++;
                     }
                 } else {
                     if (!isset($not_allow_insert[$key])) {
                         $catid = $category_id_arr[$key];
                         $cattopid = $catid;
                         $catl2id = $catid;
                         $cat = CGlobal::$allCategories[$catid];
                         if ($cat) {
                             if ($cat['parent_id'] && isset(CGlobal::$allCategories[$cat['parent_id']])) {
                                 $pcat = CGlobal::$allCategories[$cat['parent_id']];
                                 if ($pcat['parent_id'] && isset(CGlobal::$allCategories[$pcat['parent_id']])) {
                                     $cattopid = $pcat['parent_id'];
                                     $catl2id = $pcat['id'];
                                 } else {
                                     //Cấp 2
                                     $cattopid = $cat['parent_id'];
                                     $catl2id = $cat['id'];
                                 }
                             } else {
                                 $cattopid = $catid;
                                 $catl2id = 0;
                             }
                         }
                         $brand_id = 0;
                         if ($brand_arr[$key] != '') {
                             if (isset($all_rands[strtolower($brand_arr[$key])])) {
                                 $brand_id = $all_rands[strtolower($brand_arr[$key])];
                             } elseif ($brand_arr[$key] != '-') {
                                 $brand_id = DB::insert('brand', array('name' => $brand_arr[$key]));
                                 $all_rands[strtolower($brand_arr[$key])] = $brand_id;
                             }
                         }
                         if ($status_arr[$key] == '') {
                             $status_arr[$key] = 1;
                         }
                         $item_insert_row = array('sku' => $sku_arr[$key], 'category_id' => $catid, 'level_1_catid' => $cattopid, 'level_2_catid' => $catl2id, 'brand_id' => $brand_id, 'name' => $name_arr[$key], 'list_brief' => $list_brief_arr[$key], 'brief' => $brief_arr[$key], 'description' => $description_arr[$key], 'quantity' => $quantity_arr[$key], 'made_in' => $made_in_arr[$key], 'warranty' => $warranty_arr[$key], 'price' => $price_arr[$key], 'price_out' => $price_out_arr[$key], 'currency_id' => $currency_id_arr[$key], 'offer' => $offer_arr[$key], 'offer' => $offer_arr[$key], 'status' => $status_arr[$key], 'created_time' => TIME_NOW, 'user_id' => ser::id(), 'user_name' => ser::user_name(), 'modify_time' => TIME_NOW, 'modify_user_name' => User::user_name());
                         $id = DB::insert('item', $item_insert_row);
                         $total_add++;
                         $success .= "<a href='p{$id}.html' target='_blank'><font color=red>[ ID: {$id} ]</font></a> Thêm mới thành công sp ở dòng thứ {$key}<br />";
                     } else {
                         $total_skip++;
                     }
                 }
             } else {
                 $total_skip++;
             }
         }
         if ($success != '') {
             $success = "Tạo mới: {$total_add}, Cập nhật: {$total_update}, Bỏ qua: {$total_skip}.<br /><br />" . $success;
             $this->setFormSucces('', $success);
         }
     }
 }
Пример #11
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();
     }
 }
Пример #12
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!");
     }
 }
Пример #13
0
 function on_submit()
 {
     $title = Url::get('title');
     $url = Url::get('url');
     $des = Url::get('des');
     if ($des == '<br>') {
         $des = $title;
     }
     $this->checkFormInput("Tên tài liệu", "title", $title, "str", true, '', 1);
     if (!$this->errNum) {
         $uploadPath = AZLib::uploadDocPath();
         //Insert to document
         $doc_id = DB::insert('document', array('title' => addslashes($title), 'des' => addslashes($des), 'status' => 1, 'time_c' => TIME_NOW, 'user_c' => User::user_name(), 'time_m' => TIME_NOW, 'user_m' => User::user_name(), 'file_path' => ''));
         if ($doc_id) {
             if ($url != '') {
                 DB::update('document', array('file_path' => '', 'url' => $url), "id={$doc_id}");
             } elseif (isset($_FILES['file_path']) && $_FILES['file_path']['error'] == 0) {
                 $ext = strtolower(AZLib::getExtension($_FILES['file_path']['name']));
                 $file_name = AZLib::safe_title(basename(strtolower($_FILES['file_path']['name']), $ext)) . $ext;
                 $up_file = $uploadPath . date('Y.m.d_H\\hi.s') . "-{$doc_id}-{$file_name}";
                 $file_path = str_replace(DATA_PATH . "document/", '', $up_file);
                 chmod($uploadPath, 0777);
                 if (!move_uploaded_file($_FILES['file_path']['tmp_name'], $up_file)) {
                     DB::delete('document', "id={$doc_id}");
                     $this->setFormError('file_path', "Không upload được file!");
                     return;
                 } else {
                     DB::update('document', array('file_path' => $file_path), "id={$doc_id}");
                 }
             }
             Url::redirect_current();
             //Url::redirect_current(array('cmd'=>'add'));
         } else {
             $this->setFormError('name', "Không thêm được tài liệu, hãy thử lại sau!");
         }
     }
 }
Пример #14
0
//System Config...
require_once ROOT_PATH . 'core/Init.php';
//System Init...
header("Content-Type:text/xml");
$configs = @CGlobal::$configs['home_banner']['conf_val'];
if ($configs) {
    $configs = unserialize(stripslashes($configs));
} else {
    $configs = array();
}
$dir = scandir(ROOT_PATH . DATA_PATH . "home_banner/");
$i = 1;
$list = '';
foreach ($dir as $fd) {
    if (is_file(ROOT_PATH . DATA_PATH . "home_banner/{$fd}")) {
        $ext = strtolower(AZLib::getExtension($fd));
        if (in_array($ext, array('.gif', '.jpg', '.jpeg', '.png'))) {
            $arr = array();
            $arr['stt'] = $i++;
            $arr['name'] = (int) basename($fd, $ext);
            $arr['path'] = DATA_PATH . "home_banner/{$fd}";
            if (isset($configs[$arr['name']])) {
                $h_banner[$arr['name']] = $configs[$arr['name']]['time'] . '000';
                $arr['time'] = $configs[$arr['name']]['time'];
                if ($configs[$arr['name']]['url'] != '') {
                    $arr['url'] = urldecode($configs[$arr['name']]['url']);
                } else {
                    $arr['url'] = '';
                }
            } else {
                $h_banner[$arr['name']] = 15000;
Пример #15
0
    $_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;
                                    $arrRet['image_url'] = $img_url;
                                    $arrRet['error'] = 'success';
                                }
                            }
                        } else {
Пример #16
0
 static function getImageThumbMax($imagePath, $title = '', $full_with_domain = true, $server_no = 0)
 {
     if ($imagePath && isset(CGlobal::$img_server[$server_no]) && CGlobal::$img_server[$server_no]) {
         if ($title != '') {
             $title = $title ? AZLib::base64_url_encode(str_replace(array('"', "'"), array('&quot;', '\\\''), stripslashes($title))) : '';
             $file_ext = AZLib::getExtension($imagePath);
             $imagePath = dirname($imagePath) . '/' . basename($imagePath, $file_ext) . ',' . $title . $file_ext;
         }
         //return ($full_with_domain?'http://'.IMAGE_PATH:'')."thumb_max/1200_800/$imagePath";
         return ($full_with_domain ? CGlobal::$img_server[$server_no] : '') . "thumb_max/{$imagePath}";
     }
     return '';
 }
Пример #17
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;
     }
 }
Пример #18
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;
 }
Пример #19
0
 function draw()
 {
     global $display;
     $catid = Url::get('catid', 0);
     $max_name = 0;
     $baners = array();
     $h_banner = array();
     $configs = @CGlobal::$configs['home_banner']['conf_val'];
     if ($configs) {
         $configs = unserialize(stripslashes($configs));
     } else {
         $configs = array();
     }
     $dir = scandir(DATA_PATH . "home_banner/");
     $i = 1;
     foreach ($dir as $fd) {
         if (is_file(DATA_PATH . "home_banner/{$fd}")) {
             $ext = strtolower(AZLib::getExtension($fd));
             if (in_array($ext, array('.swf', '.gif', '.jpg', '.jpeg', '.png'))) {
                 $arr = array();
                 if ($ext == '.swf') {
                     $arr['type'] = 1;
                 } else {
                     $arr['type'] = 2;
                 }
                 $arr['stt'] = $i++;
                 $arr['name'] = (int) basename($fd, $ext);
                 if ($max_name < $arr['name']) {
                     $max_name = $arr['name'];
                 }
                 $arr['path'] = DATA_PATH . "home_banner/{$fd}";
                 $arr['del'] = "?cmd=del_hb&id={$arr['name']}";
                 if (isset($configs[$arr['name']])) {
                     $h_banner[$arr['name']] = $configs[$arr['name']]['time'] . '000';
                     $arr['time'] = $configs[$arr['name']]['time'];
                     if ($configs[$arr['name']]['url'] != '') {
                         $arr['url'] = urldecode($configs[$arr['name']]['url']);
                     } else {
                         $arr['url'] = '';
                     }
                 } else {
                     $h_banner[$arr['name']] = 15000;
                     $arr['time'] = 15;
                     $arr['url'] = '';
                 }
                 $baners[$arr['name']] = $arr;
             }
         }
     }
     $display->add("baners", $baners);
     $display->add("h_banner", json_encode($h_banner));
     $display->add("max", $i - 1);
     $arr = array(0 => "Up mới!");
     if ($max_name > 0) {
         for ($i = 1; $i <= $max_name; $i++) {
             $arr[$i] = "Thay banner {$i}";
         }
     }
     $display->add("hb_option", AZLib::getOption($arr, 0));
     if (User::is_admin()) {
         $display->add("is_admin", 1);
         $display->add("msg", $this->showFormErrorMessages(1));
         $display->add('begin_form', $this->beginForm(TRUE, 'post', FALSE, FALSE, 1));
         $display->add('end_form', $this->endForm(TRUE));
     }
     //ngannv settting   JW Image Rotator
     $display->add("jw_swf_file", STATIC_URL . FOLDER_JS . 'imagerotator/imagerotator.swf');
     $settingFile = DATA_PATH . 'banner_home.php';
     if (!file_exists(ROOT_PATH . $settingFile)) {
         $settingFile = DATA_PATH . 'banner_setting_default.xml';
         //không có file này nữa thì ^^
     }
     $display->add("jw_xml_file", $settingFile);
     //end   JW Image Rotator
     $display->output("IntroBanner");
 }