} if (!$error) { $save['last_update'] = $mmktime; if ($id == 0) { // ใหม่ $id = $db->add(DB_EMAIL_TEMPLATE, $save); } else { // แก้ไข $db->edit(DB_EMAIL_TEMPLATE, $id, $save); } $ret['lastupdate'] = gcms::mktime2date($mmktime); if (isset($_POST['email_copy_to'])) { $ret['email_copy_to'] = rawurlencode($save['copy_to']); } $ret['email_id'] = $id; $ret['error'] = 'SAVE_COMPLETE'; $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php', array('module' => 'mailtemplate')); } else { // คืนค่า input ตัวแรกที่ error if ($input) { $ret['input'] = $input; } $ret['error'] = $error; } } } } else { $ret['error'] = 'ACTION_ERROR'; } // คืนค่าเป็น JSON echo gcms::array2json($ret);
// อัปเดทหมวดหมู่ if ($save['category_id'] > 0) { // อัปเดทจำนวนเรื่อง และ ความคิดเห็น ในหมวด $sql1 = "SELECT COUNT(*) FROM `" . DB_INDEX . "` WHERE `category_id`=C.`category_id` AND `module_id`='{$index['module_id']}' AND `index`='0'"; $sql2 = "SELECT `id` FROM `" . DB_INDEX . "` WHERE `category_id`=C.`category_id` AND `module_id`='{$index['module_id']}' AND `index`='0'"; $sql2 = "SELECT COUNT(*) FROM `" . DB_COMMENT . "` WHERE `index_id` IN ({$sql2}) AND `module_id`='{$index['module_id']}'"; $sql = "UPDATE `" . DB_CATEGORY . "` AS C SET C.`c1`=({$sql1}),C.`c2`=({$sql2}) WHERE C.`module_id`='{$index['module_id']}'"; $db->query($sql); } if (is_file(ROOT_PATH . 'modules/document/news.php')) { // news include ROOT_PATH . 'modules/document/news.php'; } // return $ret['error'] = 'SAVE_COMPLETE'; $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php', array('module' => 'document-setup', 'id' => $index['module_id'])); } else { $ret['error'] = $error; if ($input) { $ret['input'] = $input; } if ($tab) { $ret['tab'] = $tab; } } } else { // ไม่สามารถเขียนหรือแก้ไขได้ $ret['error'] = 'NOT_ALLOWED'; } } }
} else { $save['width'] = $info['width']; $save['height'] = $info['height']; // ชื่อไฟล์ใหม่ $save['logo'] = "{$textlink['id']}.{$info['ext']}"; if (!@copy($logo['tmp_name'], DATA_PATH . 'image/' . $save['logo'])) { $ret['error'] = 'DO_NOT_UPLOAD'; $error = true; } } } if (!$error) { $save['text'] = preg_replace('/(<br[\\s\\/]+>)/iu', '<br>', $save['text']); if ($id == 0) { // ใหม่ $save['link_order'] = $textlink['link_order']; $save['published'] = 1; $id = $db->add(DB_TEXTLINK, $save); } else { // edit $db->edit(DB_TEXTLINK, $id, $save); } // คืนค่า $ret['error'] = 'SAVE_COMPLETE'; $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php', array('module' => 'textlink-setup', 'name' => $save['name'])); } } } // คืนค่า JSON echo gcms::array2json($ret); }
$save['config'] = implode("\n", $cfg); // save if ($id == 0) { // เพิ่มหมวดใหม่ $save['id'] = $index['id']; $save['module_id'] = $index['module_id']; $db->add(DB_CATEGORY, $save); // คืนค่า $ret['error'] = 'ADD_COMPLETE'; } else { // แก้ไข $db->edit(DB_CATEGORY, $index['id'], $save); // คืนค่า $ret['error'] = 'EDIT_SUCCESS'; } $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php', array('module' => 'board-category', 'id' => $index['module_id'])); // อัปเดทจำนวนกระทู้ และ ความคิดเห็น ในหมวด $sql1 = "SELECT COUNT(*) FROM `" . DB_BOARD_Q . "` WHERE `category_id`=C.`category_id` AND `module_id`='{$index['module_id']}'"; $sql2 = "SELECT `id` FROM `" . DB_BOARD_Q . "` WHERE `category_id`=C.`category_id` AND `module_id`='{$index['module_id']}'"; $sql2 = "SELECT COUNT(*) FROM `" . DB_BOARD_R . "` WHERE `index_id` IN ({$sql2}) AND `module_id`='{$index['module_id']}'"; $sql = "UPDATE `" . DB_CATEGORY . "` AS C SET C.`c1`=({$sql1}),C.`c2`=({$sql2}) WHERE C.`module_id`='{$index['module_id']}'"; $db->query($sql); } else { // error $ret['error'] = $error; if ($input) { $ret['input'] = $input; } } } else { $ret['error'] = 'ACTION_ERROR';
} else { $save[$lng] = $save2[$lng]['']; } } // save if ($id == 0) { $id = $db->add(DB_LANGUAGE, $save); $ret['error'] = 'SAVE_COMPLETE'; } else { $db->edit(DB_LANGUAGE, $id, $save); $ret['error'] = 'EDIT_SUCCESS'; } // อ่านไฟล์ภาษาใหม่ gcms::saveLanguage(); // back if (isset($_POST['next'])) { $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php?' . $_POST['next'], array()); } else { $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php', array('module' => 'language', 'js' => $save['js'])); } } } } else { $ret['error'] = 'ACTION_ERROR'; } } } else { $ret['error'] = 'ACTION_ERROR'; } // คืนค่าเป็น JSON echo gcms::array2json($ret);
foreach (explode(',', $save['reciever']) as $item) { if ($item != -1) { $reciever[$item] = $item; } } if (sizeof($reciever) > 0) { $sql = "SELECT `fname`,`lname`,`email` FROM `" . DB_USER . "` WHERE `status` IN (" . implode(',', $reciever) . ")"; foreach ($db->customQuery($sql) as $item) { // ส่งอีเมล์ $replace = array(); $replace['/%FNAME%/'] = $item['fname']; $replace['/%LNAME%/'] = $item['lname']; $replace['/%URL%/'] = WEB_URL . "/index.php?module={$index['module']}"; gcms::sendMail(1, 'edocument', $replace, $item['email']); } $ret['error'] = 'EDOCUMENT_SAVE_AND_SEND_SUCCESS'; } } // ส่งค่ากลับ $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php', array('module' => 'edocument-setup')); } else { $ret['error'] = $error; $ret['input'] = $input; } } } } else { $ret['error'] = 'ACTION_ERROR'; } // คืนค่าเป็น JSON echo gcms::array2json($ret);
$ret['input'] = 'download_file'; } else { $save['size'] = filesize($f); if ($save['name'] == '') { $info = pathinfo($save['file']); $save['name'] = $info['filename']; $save['ext'] = $info['extension']; } } } if (!isset($ret['error'])) { $save['last_update'] = $mmktime; if ($id == 0) { // ใหม่ $save['module_id'] = $index['module_id']; $save['create_date'] = $mmktime; $db->add(DB_DOWNLOAD, $save); } else { // แก้ไข $db->edit(DB_DOWNLOAD, $id, $save); } // คืนค่า $ret['error'] = 'SAVE_COMPLETE'; $ret['location'] = gcms::retURL(WEB_URL . '/admin/index.php', array('module' => 'download-setup')); } } } else { $ret['error'] = 'ACTION_ERROR'; } // คืนค่าเป็น JSON echo gcms::array2json($ret);