示例#1
0
     $input = 'gallery_detail';
 } elseif ($file['tmp_name'] == '' && $id == 0) {
     // อัลบัมใหม่ ต้องมีรูปภาพเสมอ
     $ret['ret_gallery_pic'] = 'REQUIRE_PICTURE';
     $error = 'REQUIRE_PICTURE';
     $input = 'gallery_pic';
 } else {
     // อัปโหลดรูปภาw
     if ($file['tmp_name'] != '') {
         // ตรวจสอบไฟล์อัปโหลด
         $info = gcms::isValidImage($config['gallery_image_type'], $file);
         if (!$info) {
             $ret['ret_gallery_pic'] = 'INVALID_FILE_TYPE';
             $input = 'gallery_pic';
             $error = 'INVALID_FILE_TYPE';
         } elseif (!gcms::testDir(DATA_PATH . "gallery/{$index['id']}/")) {
             $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
             $input = 'gallery_pic';
             $error = 'DO_NOT_UPLOAD';
         } else {
             // อัปโหลดรูปภาพจริง
             $res = gcms::resizeImage($file['tmp_name'], DATA_PATH . "gallery/{$index['id']}/", "0.{$info['ext']}", $info, $config['gallery_image_w']);
             if (!$res) {
                 $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
                 $input = 'gallery_pic';
                 $error = 'DO_NOT_UPLOAD';
             } else {
                 $save2['image'] = $res['name'];
             }
             // อัปโหลด thumbnail
             if (!gcms::cropImage($file['tmp_name'], DATA_PATH . "gallery/{$index['id']}/thumb_{$save2['image']}", $info, $config['gallery_thumb_w'], $config['gallery_thumb_h'])) {
示例#2
0
文件: counter.php 项目: phannack/GCMS
     }
     $f = @opendir($counter_dir);
     if ($f) {
         while (false !== ($text = readdir($f))) {
             if ($text != '.' && $text != '..') {
                 if ($text != $y) {
                     gcms::rm_dir($counter_dir . "/{$text}");
                 }
             }
         }
         closedir($f);
     }
 }
 // ตรวจสอบ + สร้าง โฟลเดอร์
 gcms::testDir("{$counter_dir}/{$y}", 0755);
 gcms::testDir("{$counter_dir}/{$y}/{$m}", 0755);
 // ip ปัจจุบัน
 $counter_ip = gcms::getip();
 // session ปัจจุบัน
 $counter_ssid = session_id();
 // วันนี้
 $counter_day = date('Y-m-d', $mmktime);
 // อ่านข้อมูล counter ล่าสุด
 $sql = "SELECT * FROM `" . DB_COUNTER . "` ORDER BY `id` DESC LIMIT 1";
 $my_counter = $db->customQuery($sql);
 $my_counter = sizeof($my_counter) == 1 ? $my_counter[0] : array('date' => '', 'counter' => 0);
 if ($my_counter['date'] != $counter_day) {
     // วันใหม่
     $my_counter['visited'] = 0;
     $my_counter['pages_view'] = 0;
     $my_counter['date'] = $counter_day;
示例#3
0
 if (preg_match('/^(.*)\\.(.*)$/', $file['name'], $match)) {
     $file_name = $match[1];
     $save['ext'] = $match[2];
 }
 // ตรวจสอบไฟล์อัปโหลด
 if ($file_name == '' || !in_array($save['ext'], explode(',', $config['download_file_typies']))) {
     $ret['ret_download_upload'] = 'INVALID_FILE_TYPE';
     $ret['error'] = 'INVALID_FILE_TYPE';
     $ret['input'] = 'download_upload';
 } elseif ($file['size'] > $config['download_upload_size']) {
     $ret['ret_download_upload'] = 'FILE_TOO_BIG';
     $ret['error'] = 'FILE_TOO_BIG';
     $ret['input'] = 'download_upload';
 } else {
     // ตรวจสอบโฟลเดอร์
     gcms::testDir(DATA_PATH . 'download/');
     // อัปโหลด
     $save['file'] = DATA_FOLDER . "download/{$mmktime}.{$save['ext']}";
     while (file_exists(ROOT_PATH . $save['file'])) {
         $mmktime++;
         $save['file'] = DATA_FOLDER . "download/{$mmktime}.{$save['ext']}";
     }
     if (!@copy($file['tmp_name'], ROOT_PATH . $save['file'])) {
         $ret['ret_download_upload'] = 'DO_NOT_UPLOAD';
         $ret['error'] = 'DO_NOT_UPLOAD';
         $ret['input'] = 'download_upload';
     } else {
         if ($save['name'] == '') {
             $save['name'] = $file_name;
         }
         $save['size'] = $file['size'];
示例#4
0
 if (preg_match('/^(.*)\\.(.*)$/', $file['name'], $match)) {
     $file_name = $match[1];
     $save['ext'] = $match[2];
 }
 // ตรวจสอบไฟล์อัปโหลด
 if ($file_name == '' || !in_array($save['ext'], $config['edocument_file_typies'])) {
     $ret['ret_edocument_file'] = 'INVALID_FILE_TYPE';
     $input = !$input ? 'edocument_file' : $input;
     $error = !$error ? 'INVALID_FILE_TYPE' : $error;
 } elseif ($file['size'] > $config['edocument_upload_size']) {
     $ret['ret_edocument_file'] = 'FILE_TOO_BIG';
     $input = !$input ? 'edocument_file' : $input;
     $error = !$error ? 'FILE_TOO_BIG' : $error;
 } else {
     // ตรวจสอบโฟลเดอร์
     gcms::testDir(DATA_PATH . 'edocument/');
     // อัปโหลด
     $save['file'] = "{$mmktime}.{$save['ext']}";
     while (file_exists(DATA_PATH . "edocument/{$save['file']}")) {
         $mmktime++;
         $save['file'] = "{$mmktime}.{$save['ext']}";
     }
     if (!@copy($file['tmp_name'], DATA_PATH . "edocument/{$save['file']}")) {
         $ret['ret_edocument_file'] = 'DO_NOT_UPLOAD';
         $input = !$input ? 'edocument_file' : $input;
         $error = !$error ? 'DO_NOT_UPLOAD' : $error;
     } else {
         if ($save['topic'] == '') {
             $save['topic'] = $file_name;
         }
         $save['size'] = $file['size'];
示例#5
0
 // video thumbnail
 if (isset($item->{'thumbnails'}->{'standard'})) {
     $url = $item->{'thumbnails'}->{'standard'}->{'url'};
 } else {
     $url = $item->{'thumbnails'}->{'high'}->{'url'};
 }
 if (function_exists('curl_init') && ($ch = @curl_init())) {
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $thumbnail = curl_exec($ch);
     curl_close($ch);
 } else {
     $thumbnail = file_get_contents($url);
 }
 // ตรวจสอบโฟลเดอร์
 gcms::testDir(DATA_PATH . 'video/');
 $f = @fopen(DATA_PATH . "video/{$youtube}.jpg", 'w');
 if (!$f) {
     $ret['error'] = 'DO_NOT_UPLOAD';
 } else {
     fwrite($f, $thumbnail);
     fclose($f);
     $ret['imgIcon'] = rawurlencode(DATA_URL . "video/{$youtube}.jpg?{$mmktime}");
     $save['youtube'] = $youtube;
     $save['last_update'] = $mmktime;
     if ($id == 0) {
         $save['module_id'] = $index['module_id'];
         $id = $db->add(DB_VIDEO, $save);
     } else {
         $db->edit(DB_VIDEO, $index['id'], $save);
     }