Пример #1
0
 public static function modify(array $args)
 {
     if (!empty($args["filename"])) {
         $args["filename"] = self::filename_check($args["id"], $args["filename"]);
     }
     CRUD::dataUpdate('seo', $args);
     if (!empty(DB::$error)) {
         self::$error = DB::$error;
         return false;
     } else {
         return true;
     }
 }
Пример #2
0
 private static function replace()
 {
     CHECK::is_array_exist($_POST["id"]);
     if (CHECK::is_pass()) {
         $fieldArray = array('origin', 'target', 'status', 'id');
         foreach ($_POST["id"] as $key => $ID) {
             unset($args);
             foreach ($fieldArray as $field) {
                 switch ($field) {
                     case "origin":
                         $var = preg_replace('/(http:\\/\\/|https:\\/\\/)([^\\/]+)(.*)/si', '$1' . CORE::$cfg['url'] . '$3', $_POST[$field][$key]);
                         break;
                     default:
                         $var = $_POST[$field][$key];
                         break;
                 }
                 $args[$field] = $var;
             }
             if (urlencode($args['origin']) == urlencode($args['target'])) {
                 continue;
             }
             if (empty($ID)) {
                 unset($args['id']);
                 CRUD::dataInsert('rewrite', $args);
             } else {
                 CRUD::dataUpdate('rewrite', $args);
             }
             if (!empty(DB::$error)) {
                 $msg = DB::$error;
             } else {
                 $msg = self::$lang["modify_done"];
             }
         }
     } else {
         $msg = CHECK::$alert;
     }
     CORE::msg($msg, CORE::$manage . 'rewrite/');
 }
Пример #3
0
 private static function new_member()
 {
     $args = array('account' => $_POST["account"], 'password' => md5($_POST["password"]), 'name' => $_POST["name"], 'address' => $_POST["address"], 'tel' => $_POST["tel"], 'cell' => $_POST["cell"], 'createdate' => date("Y-m-d H:i:s"));
     CRUD::dataInsert('member', $args);
     if (!empty(DB::$error)) {
         CORE::msg(DB::$error, CORE::$root);
         return false;
     } else {
         self::$id = DB::get_id();
         $verify_code = md5($args["account"] . $args["password"] . $args["createdate"] . self::$id);
         # 組合認證碼
         self::$verify = 'http://' . CORE::$cfg["url"] . CORE::$root . "member/verify/{$verify_code}/";
         # 組合認證路徑
         CRUD::dataUpdate('member', array('verify_code' => $verify_code, 'id' => self::$id));
         # 儲存認證碼
         return true;
     }
 }
Пример #4
0
 private static function modify()
 {
     CHECK::is_must($_POST["callback"], $_POST["id"], $_POST["subject"], $_POST["cateID"]);
     $check = CHECK::is_pass();
     $rsnum = CRUD::dataFetch('ad', array('id' => $_POST["id"]));
     if ($check && !empty($rsnum)) {
         CRUD::dataUpdate('ad', $_POST, false, true);
         if (!empty(DB::$error)) {
             $msg = DB::$error;
             $path = CORE::$manage . 'ad/';
         } else {
             $msg = self::$lang["modify_done"];
             $path = CORE::$manage . "ad/detail/{$_POST['id']}/";
         }
     } else {
         if (empty($rsnum)) {
             $msg = self::$lang["no_data"];
             $path = CORE::$manage . 'ad/';
         }
         if (!$check) {
             $msg = CHECK::$alert;
             $path = CORE::$manage . 'ad/';
         }
     }
     CORE::msg($msg, $path);
 }
Пример #5
0
 private static function del()
 {
     $id = array_shift(CORE::$args);
     CRUD::dataUpdate('order', array('del' => '1', 'id' => $id));
     if (!empty(DB::$error)) {
         CORE::msg(DB::$error, CORE::$manage . 'order/');
     } else {
         CORE::msg(self::$lang["del_done"], CORE::$manage . 'order/');
     }
 }
Пример #6
0
 private static function modify()
 {
     CHECK::is_must($_POST["callback"], $_POST["id"], $_POST["subject"], $_POST["dirpath"], $_POST["parent"]);
     $check = CHECK::is_pass();
     $rsnum = CRUD::dataFetch('gallery', array('id' => $_POST["id"]));
     if ($check && !empty($rsnum)) {
         if (is_array($_POST['related'])) {
             $_POST['related'] = json_encode($_POST['related']);
         } else {
             $_POST['related'] = '';
         }
         CRUD::dataUpdate('gallery', $_POST, true, true);
         if (!empty(DB::$error)) {
             $msg = DB::$error;
             $path = CORE::$manage . 'gallery/';
         } else {
             $msg = self::$lang["modify_done"];
             $path = CORE::$manage . "gallery/detail/{$_POST['id']}/";
         }
     } else {
         if (empty($rsnum)) {
             $msg = self::$lang["no_data"];
             $path = CORE::$manage . 'gallery/';
         }
         if (!$check) {
             $msg = CHECK::$alert;
             $path = CORE::$manage . 'gallery/';
         }
     }
     CORE::msg($msg, $path);
 }
Пример #7
0
 private static function replace()
 {
     CHECK::is_array_exist($_POST["id"]);
     if (CHECK::is_pass()) {
         $sql = DB::field(CORE::$prefix . '_stock_bind');
         while ($row = DB::fetch($sql)) {
             $field_array[] = $row["Field"];
         }
         foreach ($_POST["id"] as $key => $id) {
             $rsnum = CRUD::dataFetch('stock_cate');
             # 取得規格類別數量
             foreach ($field_array as $field) {
                 switch ($field) {
                     case "item":
                         for ($i = 0; $i < $rsnum; $i++) {
                             if ($_POST['item_' . $i][$key] !== 'null') {
                                 $item[$i] = $_POST['item_' . $i][$key];
                             }
                             if (empty($_POST["name"][$key])) {
                                 CRUD::dataFetch('stock_item', array('id' => $item[$i]));
                                 # 取得規格項目名稱
                                 if (!empty(CRUD::$data[0]["name"])) {
                                     $name[$i] = CRUD::$data[0]["name"];
                                 }
                             }
                         }
                         $args["item"] = json_encode($item);
                         $args["name"] = empty($_POST["name"][$key]) ? implode(" / ", $name) : $_POST["name"][$key];
                         break;
                     default:
                         $args[$field] = $_POST[$field][$key];
                         break;
                 }
             }
             $args["sort"] = $key;
             if (empty($id)) {
                 CRUD::dataInsert('stock_bind', $args);
             } else {
                 CRUD::dataUpdate('stock_bind', $args);
             }
             if (empty($key)) {
                 $p_id = $args["p_id"];
             }
             if (!empty(DB::$error)) {
                 CORE::msg(DB::$error, CORE::$manage . "stock/{$p_id}");
             }
         }
         CORE::msg(self::$lang["modify_done"], CORE::$manage . "stock/{$p_id}");
     } else {
         CORE::msg(self::$lang["no_args"], CORE::$manage . "stock/{$p_id}");
     }
 }
Пример #8
0
 private static function ban($id)
 {
     CRUD::dataUpdate('manager', array('id' => $id, 'ban' => '1'));
     if (!empty(DB::$error)) {
         $msg = DB::$error;
         $path = CORE::$manage . 'manager/';
     } else {
         $msg = self::$lang["modify_done"];
         $path = CORE::$manage . 'manager/';
     }
     CORE::msg($msg, $path);
 }
Пример #9
0
 private static function seo()
 {
     CHECK::is_array_exist($_POST["id"]);
     CHECK::is_must($_POST["callback"]);
     if (CHECK::is_pass()) {
         $field_rs = DB::field(CORE::$prefix . '_seo');
         while ($field_row = DB::fetch($field_rs)) {
             if ($field_row["Field"] != "langtag" && $field_row["Field"] != "name") {
                 $field_array[] = $field_row["Field"];
             }
         }
         foreach ($_POST["id"] as $key => $id) {
             foreach ($field_array as $field) {
                 $args[$field] = $_POST[$field][$key];
             }
             CRUD::dataUpdate('seo', $args);
             if (!empty(DB::$error)) {
                 $msg = array(DB::$error, CORE::$manage . 'system/seo/');
                 CORE::msg($msg);
                 return false;
             }
         }
         $msg = array(self::$lang["modify_done"], CORE::$manage . 'system/seo/');
     } else {
         $msg = array(CHECK::$alert, CORE::$manage . 'system/seo/');
     }
     CORE::msg($msg);
 }
Пример #10
0
 public static function multi($tb_name = false, $path = false)
 {
     list($func, $action, $args) = CORE::$args;
     CHECK::is_array_exist($_POST["id"]);
     CHECK::is_must($action);
     if (CHECK::is_pass() && $tb_name !== false) {
         # 依照排序要求更改陣列排序, 以符合自動排序邏輯
         if ($action == "sort") {
             asort($_POST["sort"]);
             foreach ($_POST["sort"] as $id => $sort) {
                 if (isset($_POST["id"][$id]) && !empty($_POST["id"][$id])) {
                     $new_args[] = $_POST["id"][$id];
                 }
             }
         } else {
             $new_args = $_POST["id"];
         }
         foreach ($new_args as $key => $id) {
             switch ($action) {
                 case "sort":
                     CRUD::dataUpdate($tb_name, array('id' => $id, 'sort' => $_POST["sort"][$id]));
                     if (!empty(DB::$error)) {
                         $msg = DB::$error;
                     }
                     break;
                 case "status":
                     CRUD::dataUpdate($tb_name, array('id' => $id, 'status' => $args));
                     if (!empty(DB::$error)) {
                         $msg = DB::$error;
                     }
                     break;
                 case "clone":
                     /*
                     $rsnum = CRUD::dataFetch($tb_name,array('id' => $id));
                     if(!empty($rsnum)){
                     	list($row) = CRUD::$data;
                     	unset($row["id"]);
                     
                     	CRUD::dataInsert($tb_name,$row);
                     	if(!empty(DB::$error)){
                     		$msg = DB::$error;
                     	}
                     }else{
                     	$msg = self::$lang["no_args"];
                     }
                     */
                     break;
                 case "del":
                     $rs = CRUD::dataDel($tb_name, array('id' => $id));
                     if (!empty(DB::$error)) {
                         $msg = DB::$error;
                     }
                     if (!$rs) {
                         $msg = self::$lang["del_error"];
                     }
                     break;
             }
             if (!empty($msg)) {
                 break;
             }
         }
     } else {
         $msg = self::$lang["no_args"];
     }
     if (empty($msg)) {
         $msg = self::$lang["modify_done"];
     } else {
         $path = self::$temp_option["MSG"];
     }
     CORE::msg($msg, $path);
 }
Пример #11
0
 public static function crop($id, $path = false, $width = false, $height = false, $width_m = false, $height_m = false, $crop = false, $crop_m = false)
 {
     if (empty($id)) {
         return false;
     }
     if (!empty($crop) || !empty($crop_m)) {
         self::delCrop($crop, $crop_m);
     }
     if (!empty($path) && $path != CORE::$cfg['noimg']) {
         $nowDate = strtotime(date('Y-m-d H:i:s'));
         $filePath = str_replace(CORE::$cfg['host'], ROOT_PATH, $path);
         $fileName = basename($filePath);
         $extension = pathinfo($filePath, PATHINFO_EXTENSION);
         $cropName = 'crop_' . $id . '_' . $nowDate . '.' . $extension;
         $cropDir = ROOT_PATH . "files/crop/";
         $cropDir_m = ROOT_PATH . "files/crop_m/";
         $cropHostPath = CORE::$cfg['host'] . 'files/crop/' . $cropName;
         $cropHost_mPath = CORE::$cfg['host'] . 'files/crop_m/' . $cropName;
         if (!is_dir($cropDir)) {
             mkdir($cropDir, 0777, true) || die("can't create dir in '{$cropDir}'");
             chmod($cropDir, 0777);
         }
         if (!is_dir($cropDir_m)) {
             mkdir($cropDir_m, 0777, true) || die("can't create dir in '{$cropDir_m}'");
             chmod($cropDir_m, 0777);
         }
         $cropPath = $cropDir . $cropName;
         $cropPath_m = $cropDir_m . $cropName;
         switch (true) {
             case !empty($width) && !empty($height):
                 self::resize($filePath, $width, $height, $cropPath);
                 break;
             case !empty($width) || !empty($height):
                 if (empty($width)) {
                     $width = 'auto';
                 }
                 if (empty($height)) {
                     $height = 'auto';
                 }
                 self::resize($filePath, $width, $height, $cropPath);
                 break;
             default:
                 $cropNone = true;
                 break;
         }
         switch (true) {
             case !empty($width_m) && !empty($height_m):
                 self::resize($filePath, $width_m, $height_m, $cropPath_m);
                 break;
             case !empty($width_m) || !empty($height_m):
                 if (empty($width_m)) {
                     $width_m = 'auto';
                 }
                 if (empty($height_m)) {
                     $height_m = 'auto';
                 }
                 self::resize($filePath, $width_m, $height_m, $cropPath_m);
                 break;
             default:
                 $cropNone = true;
                 break;
         }
     } else {
         $cropNone = true;
     }
     if (!$cropNone) {
         $cropArgs = array('crop' => $cropHostPath, 'crop_m' => $cropHost_mPath, 'id' => $id);
     } else {
         $cropArgs = array('crop' => 'null', 'crop_m' => 'null', 'id' => $id);
     }
     CRUD::dataUpdate('images', $cropArgs);
 }
Пример #12
0
 public static function dataDel($tb_name, array $args)
 {
     $rsnum = CRUD::dataFetch($tb_name, $args);
     if (!empty($rsnum)) {
         list($row) = CRUD::$data;
         DB::delete(CORE::$prefix . "_" . $tb_name, $args);
         # 去除語系連結
         if (isset($row["lang_id"]) && !empty($row["lang_id"])) {
             $lang_rsnum = CRUD::dataFetch("lang", array("id" => $row["lang_id"]));
             if (!empty($lang_rsnum)) {
                 list($lang_row) = CRUD::$data;
                 $lang_related = json_decode($lang_row["related"], true);
                 if (is_array($lang_related)) {
                     unset($lang_related[CORE::$langtag]);
                     if (count($lang_related) >= 1) {
                         $new_related = array('id' => $lang_row["id"], 'related' => json_encode($lang_related));
                         CRUD::dataUpdate("lang", $new_related);
                     } else {
                         $related_none = true;
                     }
                 } else {
                     $related_none = true;
                 }
                 # 沒有可連結資料,刪除整筆記錄
                 if ($related_none) {
                     DB::delete(CORE::$prefix . "_lang", array('id' => $row["lang_id"]));
                 }
             }
         }
         # 刪除 seo 紀錄
         if (isset($row["seo_id"]) && !empty($row["seo_id"])) {
             DB::delete(CORE::$prefix . "_seo", array('id' => $row["seo_id"]));
         }
         # 刪除圖片記錄
         IMAGES::del($tb_name, $row["id"]);
         return true;
     } else {
         return false;
     }
 }
Пример #13
0
 private static function replace()
 {
     CRUD::dataUpdate('member', $_POST);
     if (!empty(DB::$error)) {
         CORE::msg(DB::$error, CORE::$manage . 'member/detail/' . $_POST["id"]);
     } else {
         CORE::msg(self::$lang["modify_done"], CORE::$manage . 'member/detail/' . $_POST["id"]);
     }
 }
Пример #14
0
 private static function forget()
 {
     CHECK::is_email($_POST["email"]);
     if (CHECK::is_pass()) {
         $rsnum = CRUD::dataFetch('manager', array('account' => $_POST["email"], 'status' => '1', 'ban' => '0'));
         if (!empty($rsnum)) {
             list($row) = CRUD::$data;
             $rand_password = CORE::rand_password();
             $forget_temp = 'ogs-mail-manager-forget-tpl.html';
             CRUD::dataUpdate('manager', array('password' => md5($rand_password), 'id' => $row["id"]));
             # 輸出取回密碼樣板
             VIEW::assignGlobal('VALUE_RAND_PASSWORD', $rand_password);
             new VIEW($forget_temp, false, true, 1);
             CORE::mail_handle(SYSTEM::$setting["email"], $row["account"], VIEW::$output, CORE::$lang["forget_recall"], SYSTEM::$setting["name"]);
             # 寄出認證信
             CORE::msg(CORE::$lang["forget_send"], CORE::$manage);
         } else {
             CORE::msg(CORE::$lang["account_none"], CORE::$manage);
         }
     } else {
         CORE::msg(CHECK::$alert, CORE::$manage);
     }
 }
Пример #15
0
 private static function reply()
 {
     $rsnum = CRUD::dataFetch('contact', array('id' => $_POST["id"]));
     $id = $_POST["id"];
     if (!empty($rsnum) && !empty($id)) {
         list($row) = CRUD::$data;
         CHECK::is_must($_POST["reply"]);
         CHECK::is_email($row["email"]);
         if (CHECK::is_pass()) {
             CRUD::dataUpdate('contact', array('id' => $id, 'reply' => $_POST["reply"]));
             $mail_temp = 'ogs-mail-contact-reply-tpl.html';
             VIEW::assignGlobal(array('VALUE_REPLY' => $_POST["reply"], "VALUE_CONTENT" => $row["content"]));
             new VIEW($mail_temp, false, true, 1);
             CORE::mail_handle(SYSTEM::$setting["email"], $row["email"], VIEW::$output, self::$lang["reply"], SYSTEM::$setting["name"]);
             # 寄出認證信
             $msg = self::$lang["reply_done"];
         } else {
             $msg = CHECK::$alert;
         }
     } else {
         $msg = self::$lang["no_args"];
     }
     CORE::msg($msg, CORE::$manage . "contact/detail/{$id}/");
 }
Пример #16
0
 private static function modify()
 {
     self::check();
     CHECK::is_email($_POST["account"]);
     CHECK::is_must($_POST["name"], $_POST["callback"]);
     if (!empty($_POST["old_password"]) && !empty($_POST["password"])) {
         CHECK::is_password($_POST["old_password"]);
         CHECK::is_password($_POST["password"]);
         CHECK::is_same($_POST["password"], $_POST["password_match"]);
         $pass = CHECK::is_pass();
         $rsnum = CRUD::dataFetch('member', array('status' => '1', 'verify' => '1', 'id' => self::$id, 'password' => md5($_POST["old_password"])));
         if (empty($rsnum)) {
             CORE::msg(CORE::$lang["args_error"], CORE::$root . 'member/profile/');
             return false;
         } else {
             $modify["password"] = md5($_POST["password"]);
         }
     } else {
         $pass = CHECK::is_pass();
         unset($_POST["password"]);
     }
     if ($pass) {
         $modify["id"] = self::$id;
         $modify = array_merge($_POST, $modify);
         CRUD::dataUpdate('member', $modify);
         if (!empty(DB::$error)) {
             CORE::msg(DB::$error, CORE::$root . 'member/profile/');
         } else {
             CORE::msg(CORE::$lang["modify_done"], CORE::$root . 'member/profile/');
         }
     } else {
         CORE::msg(CHECK::$alert, CORE::$root . 'member/profile/');
     }
 }