/**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // รายการที่ต้องการ
         $index = \Index\Mailwrite\Model::getIndex(self::$request->get('id')->toInt());
         // สร้างหรือแก้ไข
         $title = Language::get(empty($index->id) ? 'Create' : 'Edit');
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-settings">{LNG_Site settings}</span></li>');
         $ul->appendChild('<li><a href="{BACKURL?module=mailtemplate&id=0}">{LNG_Email template}</a></li>');
         $ul->appendChild('<li><span>' . $title . '</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-write">' . $title . ' ' . $index->name . '</h1>'));
         if ($index) {
             // แสดงฟอร์ม
             $section->appendChild(createClass('Index\\Mailwrite\\View')->render($index));
             return $section->render();
         }
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * แสดงผล
  */
 public function render($login)
 {
     // send email form
     $form = Html::create('form', array('id' => 'write_frm', 'class' => 'setup_frm', 'action' => 'index.php/index/model/sendmail/save', 'onsubmit' => 'doFormSubmit', 'token' => true, 'ajax' => true));
     $fieldset = $form->add('fieldset', array('title' => '{LNG_Details of} {LNG_Email}'));
     // reciever
     $reciever = self::$request->get('to')->topic();
     $fieldset->add('text', array('id' => 'reciever', 'itemClass' => 'item', 'labelClass' => 'g-input icon-email-sent', 'label' => '{LNG_Reciever}', 'comment' => '{LNG_Recipient&#39;s Email Address Many can be found Each separated by, (comma).}', 'autofocus', 'value' => $reciever));
     // email_from
     $datas = array($login['email'] => $login['email']);
     if (Login::isAdmin() && empty($login['fb'])) {
         $datas[self::$cfg->noreply_email] = self::$cfg->noreply_email;
         foreach (\Index\Sendmail\Model::findAdmin(self::$request) as $item) {
             $datas[$item] = $item;
         }
     }
     $fieldset->add('select', array('id' => 'from', 'itemClass' => 'item', 'labelClass' => 'g-input icon-email', 'label' => '{LNG_Sender}', 'options' => $datas));
     // subject
     $fieldset->add('text', array('id' => 'subject', 'itemClass' => 'item', 'labelClass' => 'g-input icon-edit', 'label' => '{LNG_Subject}', 'comment' => '' . '{LNG_Please fill in} {LNG_Subject}'));
     // detail
     $fieldset->add('ckeditor', array('id' => 'detail', 'itemClass' => 'item', 'height' => 300, 'language' => Language::name(), 'toolbar' => 'Email', 'label' => '{LNG_Detail}', 'value' => Template::load('', '', 'mailtemplate')));
     $fieldset = $form->add('fieldset', array('class' => 'submit'));
     // submit
     $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Send message}'));
     return $form->render();
 }
示例#3
0
 /**
  * ฟังก์ชั่นจัดการ debug อ่าน,ลบ
  */
 public function action()
 {
     // referer, session, admin
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] != 'demo' && empty($login['fb'])) {
             // action
             $action = self::$request->post('action')->toString();
             // file debug
             $debug = ROOT_PATH . DATA_FOLDER . 'logs/error_log.php';
             if (is_file($debug)) {
                 if ($action == 'get') {
                     // อ่าน debug
                     $t = self::$request->post('t')->toString();
                     foreach (file($debug) as $i => $row) {
                         if (preg_match('/^\\[([0-9\\-:\\s]+)\\][\\s]+([A-Z]+):[\\s]+(.*)/', trim($row), $match)) {
                             if ($match[1] > $t) {
                                 echo "{$match['1']}\t{$match['2']}\t{$match['3']}\n";
                             }
                         }
                     }
                 } elseif ($action == 'clear') {
                     // ลบไฟล์ debug
                     unlink($debug);
                 }
             }
         }
     }
 }
示例#4
0
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // ภาษาที่ต้องการ
         $language = self::$request->get('language', Language::name())->toString();
         if (preg_match('/^[a-z]{2,2}$/', $language)) {
             // intro detail
             $template = ROOT_PATH . DATA_FOLDER . 'intro.' . $language . '.php';
             if (is_file($template)) {
                 $template = trim(preg_replace('/<\\?php exit([\\(\\);])?\\?>/', '', file_get_contents($template)));
             } else {
                 $template = '<p style="padding: 20px; text-align: center; font-weight: bold;"><a href="index.php">Welcome<br>ยินดีต้อนรับ</a></p>';
             }
             // แสดงผล
             $section = Html::create('section');
             // breadcrumbs
             $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
             $ul = $breadcrumbs->add('ul');
             $ul->appendChild('<li><span class="icon-settings">{LNG_Site settings}</span></li>');
             $ul->appendChild('<li><span>{LNG_Intro Page}</span></li>');
             $section->add('header', array('innerHTML' => '<h1 class="icon-write">' . $this->title() . '</h1>'));
             // แสดงฟอร์ม
             $section->appendChild(createClass('Index\\Intro\\View')->render($language, $template));
             return $section->render();
         }
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * action
  */
 public static function action()
 {
     $ret = array();
     // referer, session, admin
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             if (self::$request->post('action')->toString() === 'delete') {
                 $id = self::$request->post('action')->toInt();
                 $rs = Recordset::create(get_called_class());
                 $index = $rs->find($id);
                 if ($index) {
                     $index->delete();
                 }
                 // คืนค่า
                 $ret['delete_id'] = self::$request->post('src')->toString() . '_' . $id;
                 $ret['alert'] = Language::get('Deleted successfully');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
 /**
  * แสดงผล
  */
 public function render(Request $request)
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // รายการที่ต้องการ
         $index = \Index\Menuwrite\Model::getMenu(self::$request->get('id')->toInt());
         if ($index) {
             // สร้างหรือแก้ไข
             // แสดงผล
             $section = Html::create('section');
             // breadcrumbs
             $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
             $ul = $breadcrumbs->add('ul');
             $ul->appendChild('<li><span class="icon-modules">{LNG_Menus} &amp; {LNG_Web pages}</span></li>');
             $ul->appendChild('<li><a href="{BACKURL?module=pages&id=0}">{LNG_Menus}</a></li>');
             $ul->appendChild('<li><span>{LNG_' . (empty($index->id) ? 'Create' : 'Edit') . '}</span></li>');
             $section->add('header', array('innerHTML' => '<h1 class="icon-write">' . $this->title() . '</h1>'));
             if ($index) {
                 // แสดงฟอร์ม
                 $section->appendChild(createClass('Index\\Menuwrite\\View')->render($index));
                 return $section->render();
             }
         }
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * แสดงผล
  */
 public function render(Request $request)
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // โมดูลที่ต้องการติดตั้ง
         $module = $request->get('m')->filter('a-z');
         $widget = $request->get('w')->filter('a-z');
         $this->module = $module !== '' ? $module : $widget;
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         if ($module !== '') {
             $ul->appendChild('<li><span class="icon-modules">{LNG_Module}</span></li>');
             $type = 'module';
         } elseif ($widget !== '') {
             $ul->appendChild('<li><span class="icon-widgets">{LNG_Widgets}</span></li>');
             $type = 'widget';
         } else {
             // 404.html
             return \Index\Error\Controller::page404();
         }
         $ul->appendChild('<li><span>{LNG_Install}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-inbox">' . $this->title() . '</h1>'));
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Install\\View')->render($type, $this->module));
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * รับค่าจาก action
  */
 public function action()
 {
     $ret = array();
     // referer, session, admin
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if (empty($login['fb'])) {
             // ค่าที่ส่งมา
             $type = self::$request->post('type')->toString();
             $type = $type == 'js' ? 'js' : 'php';
             $id = self::$request->post('id')->toString();
             $action = self::$request->post('action')->toString();
             if ($action == 'delete') {
                 // โหลดภาษา
                 $datas = Language::installed($type);
                 // ลบรายการที่ส่งมา
                 $datas = ArrayTool::delete($datas, $id);
                 // save
                 $error = Language::save($datas, $type);
                 if (empty($error)) {
                     $ret['location'] = 'reload';
                 } else {
                     $ret['alert'] = $error;
                 }
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     echo json_encode($ret);
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-modules">{LNG_Menus} &amp; {LNG_Web pages}</span></li>');
         $ul->appendChild('<li><a href="{BACKURL?module=mods&id=0}">{LNG_installed module}</a></li>');
         $ul->appendChild('<li><span>{LNG_Create}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-new">' . $this->title() . '</h1>'));
         // owner
         $modules = array();
         foreach (Gcms::$install_owners as $owner => $item) {
             if (file_exists(ROOT_PATH . 'modules/' . $owner . '/controllers/admin/init.php')) {
                 $class = ucfirst($owner) . '\\Admin\\Init\\Controller';
                 if (method_exists($class, 'description')) {
                     // get module description
                     $description = $class::description();
                     if (!empty($description)) {
                         $modules[$owner] = $description . ' [' . $owner . ']';
                     }
                 }
             }
         }
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Addmodule\\View')->render($modules));
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // ภาษาที่ต้องการ
         $language = self::$request->get('language', Language::name())->toString();
         if (preg_match('/^[a-z]{2,2}$/', $language)) {
             // maintenance detail
             $template = ROOT_PATH . DATA_FOLDER . 'maintenance.' . $language . '.php';
             if (is_file($template)) {
                 $template = trim(preg_replace('/<\\?php exit([\\(\\);])?\\?>/', '', file_get_contents($template)));
             } else {
                 $template = '<p style="padding: 20px; text-align: center; font-weight: bold;">Website Temporarily Closed for Maintenance, Please try again in a few minutes.<br>ปิดปรับปรุงเว็บไซต์ชั่วคราวเพื่อบำรุงรักษา กรุณาลองใหม่ในอีกสักครู่</p>';
             }
             // แสดงผล
             $section = Html::create('section');
             // breadcrumbs
             $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
             $ul = $breadcrumbs->add('ul');
             $ul->appendChild('<li><span class="icon-settings">{LNG_Site settings}</span></li>');
             $ul->appendChild('<li><span>{LNG_Maintenance Mode}</span></li>');
             $section->add('header', array('innerHTML' => '<h1 class="icon-write">' . $this->title() . '</h1>'));
             // แสดงฟอร์ม
             $section->appendChild(createClass('Index\\Maintenance\\View')->render($language, $template));
             return $section->render();
         }
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
示例#11
0
 /**
  * form submit
  */
 public function save()
 {
     $ret = array();
     // referer, session, member
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             // โหลด config
             $config = Config::load(ROOT_PATH . 'settings/config.php');
             $config->member_reserv = array();
             foreach (explode("\n", self::$request->post('member_reserv')->text()) as $item) {
                 $config->member_reserv[] = trim($item);
             }
             $config->wordrude = array();
             foreach (explode("\n", self::$request->post('wordrude')->text()) as $item) {
                 $config->wordrude[] = trim($item);
             }
             $config->wordrude_replace = self::$request->post('wordrude_replace', 'xxx')->toString();
             $config->counter_digit = max(4, self::$request->post('counter_digit')->toInt());
             // save config
             if (Config::save($config, ROOT_PATH . 'settings/config.php')) {
                 $ret['alert'] = Language::get('Saved successfully');
                 $ret['location'] = 'reload';
             } else {
                 $ret['alert'] = sprintf(Language::get('File %s cannot be created or is read-only.'), 'settings/config.php');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // สมาชิก
     if ($login = Login::isMember()) {
         // id ที่ต้องการ ถ้าไม่มีใช้คนที่ login
         $id = self::$request->get('id', $login['id'])->toInt();
         // อ่านข้อมูลสมาชิก
         $user = \Index\Editprofile\Model::getUser($id);
         if ($user && ($login['status'] == 1 || $login['id'] == $user->id)) {
             $template = Template::create('', '', 'editprofile');
             $contents = array();
             foreach ($user as $key => $value) {
                 if ($key === 'provinceID' || $key === 'country' || $key === 'sex' || $key === 'status') {
                     // select
                     if ($key == 'provinceID') {
                         $source = Province::all();
                     } elseif ($key == 'country') {
                         $source = Country::all();
                     } elseif ($key == 'sex') {
                         $source = Language::get('SEXES');
                     } elseif ($key == 'status') {
                         $source = self::$cfg->member_status;
                     }
                     $datas = array();
                     foreach ($source as $k => $v) {
                         $sel = $k == $value ? ' selected' : '';
                         $datas[] = '<option value="' . $k . '"' . $sel . '>' . $v . '</option>';
                     }
                     $contents['/{' . strtoupper($key) . '}/'] = implode('', $datas);
                 } elseif ($key === 'admin_access' || $key === 'subscrib') {
                     $contents['/{' . strtoupper($key) . '}/'] = $value == 1 ? 'checked' : '';
                 } elseif ($key === 'icon') {
                     if (is_file(ROOT_PATH . self::$cfg->usericon_folder . $value)) {
                         $icon = WEB_URL . self::$cfg->usericon_folder . $value;
                     } else {
                         $icon = WEB_URL . 'skin/img/noicon.jpg';
                     }
                     $contents['/{ICON}/'] = $icon;
                 } else {
                     $contents['/{' . strtoupper($key) . '}/'] = $value;
                 }
             }
             $contents['/{ADMIN}/'] = Login::isAdmin() && $user->fb == 0 ? '' : 'readonly';
             $contents['/{HIDDEN}/'] = implode("\n", Form::get2Input());
             $contents['/{ACCEPT}/'] = Mime::getEccept(self::$cfg->user_icon_typies);
             $template->add($contents);
             Gcms::$view->setContents(array('/:type/' => implode(', ', self::$cfg->user_icon_typies)), false);
             return $template->render();
         } else {
             // 404.html
             return \Index\Error\Controller::page404();
         }
     } else {
         // 404.html
         return \Index\Error\Controller::page404();
     }
 }
示例#13
0
 /**
  * ฟังก์ชั่น แปลงเป็นรายการเมนู
  *
  * @param array $item แอเรย์ข้อมูลเมนู
  * @param string $select (optional) เมนูที่ถูกเลือก
  * @param boolean $arrow (optional) true=แสดงลูกศรสำหรับเมนูที่มีเมนูย่อย (default false)
  * @return string คืนค่า HTML ของเมนู
  */
 public function getItem($item, $select = null, $arrow = false)
 {
     $c = array();
     if ($item->alias != '') {
         $c[] = $item->alias;
         if ($select === $item->alias) {
             $c[] = 'select';
         }
     } elseif ($item->module != '') {
         $c[] = $item->module;
         if ($select === $item->module) {
             $c[] = 'select';
         }
     }
     if (isset($item->published)) {
         if ($item->published != 1) {
             if (Login::isMember()) {
                 if ($item->published == '3') {
                     $c[] = 'hidden';
                 }
             } else {
                 if ($item->published == '2') {
                     $c[] = 'hidden';
                 }
             }
         }
     }
     $c = sizeof($c) == 0 ? '' : ' class="' . implode(' ', $c) . '"';
     if ($item->index_id > 0 || $item->menu_url != '') {
         $a = $item->menu_target == '' ? '' : ' target=' . $item->menu_target;
         $a .= $item->accesskey == '' ? '' : ' accesskey=' . $item->accesskey;
         if ($item->index_id > 0) {
             $a .= ' href="' . Gcms::createUrl($item->module) . '"';
         } elseif ($item->menu_url != '') {
             $a .= ' href="' . $item->menu_url . '"';
         } else {
             $a .= ' tabindex=0';
         }
     } else {
         $a = ' tabindex=0';
     }
     $menu_text = $item->menu_text;
     $b = $item->menu_tooltip == '' ? $menu_text : $item->menu_tooltip;
     if ($b != '') {
         $a .= ' title="' . $b . '"';
     }
     if ($arrow) {
         return '<li' . $c . '><a class=menu-arrow' . $a . '><span>' . (empty($menu_text) ? '&nbsp;' : htmlspecialchars_decode($menu_text)) . '</span></a>';
     } else {
         return '<li' . $c . '><a' . $a . '><span>' . (empty($menu_text) ? '&nbsp;' : htmlspecialchars_decode($menu_text)) . '</span></a>';
     }
 }
示例#14
0
 /**
  * รับค่าจาก action ของ table
  */
 public function action()
 {
     $ret = array();
     // referer, session, admin
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             // ค่าที่ส่งมา
             $action = self::$request->post('action')->toString();
             $id = self::$request->post('id')->toInt();
             // Model
             $model = new \Kotchasan\Model();
             if ($action === 'published') {
                 // เผยแพร่
                 $index = $model->db()->first($model->getFullTableName('index'), $id);
                 if ($index) {
                     $published = $index->published == 1 ? 0 : 1;
                     $model->db()->update($model->getFullTableName('index'), $index->id, array('published' => $published));
                     // คืนค่า
                     $ret['elem'] = 'published_' . $index->id;
                     $lng = Language::get('PUBLISHEDS');
                     $ret['title'] = $lng[$published];
                     $ret['class'] = 'icon-published' . $published;
                 }
             } elseif ($action === 'delete') {
                 // ลบโมดูลและหน้าเพจ ไม่ลบข้อมูลของโมดูล
                 $query = $model->db()->createQuery()->select('id', 'module_id')->from('index')->where(array(array('index', 1), array('module_id', $model->db()->createQuery()->select('module_id')->from('index')->where(array('id', $id)))));
                 $count = 0;
                 foreach ($query->execute() as $field) {
                     $count++;
                     if ($field->id == $id) {
                         $model->db()->delete($model->getFullTableName('index'), $id);
                         $model->db()->delete($model->getFullTableName('index_detail'), $id);
                     }
                 }
                 // ลบโมดูล ถ้าไม่มีรายการในภาษาอื่น
                 if ($count < 2) {
                     $model->db()->delete($model->getFullTableName('modules'), $field->module_id);
                 }
                 // คืนค่า
                 $ret['delete_id'] = self::$request->post('src')->toString() . '_' . $id;
                 $ret['alert'] = Language::get('Deleted successfully');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
 /**
  * Useronline
  *
  * @param array $query_string
  */
 public function index(Request $request)
 {
     // ตรวจสอบ Referer
     if ($request->initSession() && $request->isReferer()) {
         // ตัวแปรป้องกันการเรียกหน้าเพจโดยตรง
         define('MAIN_INIT', __FILE__);
         // เวลาปัจจุบัน
         $time = time();
         // sesssion ปัจจุบัน
         $session_id = session_id();
         // เวลาหมดอายุ
         $validtime = $time - self::$cfg->counter_gap;
         // ตาราง useronline
         $useronline = $this->getFullTableName('useronline');
         // ลบคนที่หมดเวลาและตัวเอง
         $this->db()->delete($useronline, array(array('time', '<', $validtime), array('session', $session_id)), 0, 'OR');
         // เพิ่มตัวเอง
         $save = array('time' => $time, 'session' => $session_id, 'ip' => $request->getClientIp());
         $login = Login::isMember();
         if ($login) {
             $save['member_id'] = (int) $login['id'];
             $save['displayname'] = $login['displayname'] == '' ? $login['email'] : $login['displayname'];
         }
         $this->db()->insert($useronline, $save);
         // คืนค่า user online
         $ret = array('time' => $time);
         // โหลด useronline ของ module
         $dir = ROOT_PATH . 'modules/';
         $f = @opendir($dir);
         if ($f) {
             while (false !== ($text = readdir($f))) {
                 if ($text != "." && $text != "..") {
                     if (is_dir($dir . $text)) {
                         if (is_file($dir . $text . '/controllers/useronline.php')) {
                             include $dir . $text . '/controllers/useronline.php';
                             $class = ucfirst($text) . '\\Useronline\\Controller';
                             if (method_exists($class, 'index')) {
                                 $ret = createClass($class)->index($ret);
                             }
                         }
                     }
                 }
             }
             closedir($f);
         }
         // คืนค่า JSON
         echo json_encode($ret);
     }
 }
 /**
  * หน้าแก้ไขข้อมูลส่วนตัว
  *
  * @param Request $request
  * @return object
  */
 public function render(Request $request)
 {
     if ($login = Login::isMember()) {
         // tab ที่เลือก
         $tab = $request->request('tab')->toString();
         $member_tabs = array_keys(Gcms::$member_tabs);
         $tab = in_array($tab, $member_tabs) ? $tab : reset($member_tabs);
         $index = (object) array('description' => self::$cfg->web_description);
         // รายการ tabs
         $tabs = array();
         if (!empty($login['fb'])) {
             unset(Gcms::$member_tabs['password']);
         }
         foreach (Gcms::$member_tabs as $key => $values) {
             if ($values[0] != '') {
                 if ($key == $tab) {
                     $class = "tab select {$key}";
                     $index->topic = Language::get($values[0]);
                     $className = $values[1];
                 } else {
                     $class = "tab {$key}";
                 }
                 if (preg_match('/^http:\\/\\/.*/', $values[1])) {
                     $tabs[] = '<li class="' . $class . '"><a href="' . $values[1] . '">' . Language::get($values[0]) . '</a></li>';
                 } else {
                     $tabs[] = '<li class="' . $class . '"><a href="{WEBURL}index.php?module=editprofile&amp;tab=' . $key . '">' . Language::get($values[0]) . '</a></li>';
                 }
             }
         }
         if (empty($className)) {
             // FB และแก้ไขรหัสผ่าน
             return createClass('Index\\PageNotFound\\Controller')->init($request, 'index');
         } else {
             $template = Template::create('member', 'member', 'main');
             $template->add(array('/{TAB}/' => implode('', $tabs), '/{DETAIL}/' => createClass($className)->render($request)));
             $index->detail = $template->render();
             $index->keywords = $index->topic;
             // menu
             $index->menu = 'member';
             return $index;
         }
     } else {
         // ไม่ได้ login
         return createClass('Index\\PageNotFound\\Controller')->init($request, 'index');
     }
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if ($login = Login::isAdmin()) {
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-email">{LNG_Mailbox}</span></li>');
         $ul->appendChild('<li><span>{LNG_Email send}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-email-sent">' . $this->title() . '</h1>'));
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Sendmail\\View')->render($login));
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
示例#18
0
 /**
  * แสดงผล
  *
  * @param Request $request
  */
 public function index(Request $request)
 {
     // session cookie
     $request->initSession();
     // ตรวจสอบการ login
     Login::create();
     if (Login::isMember()) {
         echo '<a href="?action=logout">Logout</a><br>';
         var_dump($_SESSION);
     } else {
         // forgot or login
         if ($request->get('action')->toString() == 'forgot') {
             $main = new \Index\Forgot\View();
         } else {
             $main = new \Index\Login\View();
         }
         echo $main->render();
     }
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><a class="icon-user" href="index.php?module=member">{LNG_Users}</a></li>');
         $ul->appendChild('<li><span>{LNG_Register}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-register">' . $this->title() . '</h1>'));
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Register\\View')->render());
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-home">{LNG_Home}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-dashboard">' . $this->title() . '</h1>'));
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Dashboard\\View')->render());
         return $section->render();
     } else {
         // 404.html
         return \Index\Error\Controller::page404();
     }
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-tools">{LNG_Tools}</span></li>');
         $ul->appendChild('<li><span>{LNG_Language}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-language">' . $this->title() . '</h1>'));
         // แสดงตาราง
         $section->appendChild(createClass('Index\\Language\\View')->render());
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
示例#22
0
 /**
  * แสดงผล
  */
 public function render(Request $request)
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-modules">{LNG_Menus} &amp; {LNG_Web pages}</span></li>');
         $ul->appendChild('<li><span>{LNG_installed module}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-modules">' . $this->title() . '</h1>'));
         // แสดงตาราง
         $section->appendChild(createClass('Index\\Mods\\View')->render());
         return $section->render();
     } else {
         // 404.html
         return \Index\Error\Controller::page404();
     }
 }
示例#23
0
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-settings">{LNG_Site settings}</span></li>');
         $ul->appendChild('<li><span>{LNG_Other}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-config">' . $this->title() . '</h1>'));
         // โหลด config
         $config = Config::load(ROOT_PATH . 'settings/config.php');
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Other\\View')->render($config));
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
示例#24
0
 /**
  * บันทึก
  */
 public function save()
 {
     $ret = array();
     // referer, session, member
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             // รับค่าจากการ POST
             $save = array('show_intro' => self::$request->post('show_intro')->toBoolean(), 'language' => self::$request->post('language')->toString(), 'detail' => self::$request->post('detail')->detail());
             if (!empty($save['language']) && preg_match('/^[a-z]{2,2}$/', $save['language'])) {
                 // save
                 $template = ROOT_PATH . DATA_FOLDER . 'intro.' . $save['language'] . '.php';
                 $f = @fopen($template, 'wb');
                 if ($f) {
                     fwrite($f, "<?php exit;?>\n" . $save['detail']);
                     fclose($f);
                     // โหลด config
                     $config = Config::load(ROOT_PATH . 'settings/config.php');
                     $config->show_intro = $save['show_intro'];
                     // save config
                     if (Config::save($config, ROOT_PATH . 'settings/config.php')) {
                         $ret['alert'] = Language::get('Saved successfully');
                         $ret['location'] = 'reload';
                     } else {
                         $ret['alert'] = sprintf(Language::get('File %s cannot be created or is read-only.'), 'settings/config.php');
                     }
                 } else {
                     $ret['alert'] = sprintf(Language::get('File %s cannot be created or is read-only.'), DATA_FOLDER . 'intro.' . $save['language'] . '.php');
                 }
             } else {
                 $ret['alert'] = Language::get('Unable to complete the transaction');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-tools">{LNG_Tools}</span></li>');
         $ul->appendChild('<li><span>{LNG_Database}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-database">' . $this->title() . '</h1>'));
         $div = $section->add('div', array('class' => 'setup_frm'));
         // แสดงฟอร์ม
         $view = new \Index\Database\View();
         $div->appendChild($view->export());
         $div->appendChild($view->import());
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
示例#26
0
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-tools">{LNG_Tools}</span></li>');
         $ul->appendChild('<li><span>' . $this->title() . '</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-world">' . $this->title() . '</h1>'));
         $div = $section->add('div', array('class' => 'setup_frm'));
         $div = $div->add('div', array('class' => 'item'));
         $div->appendChild('<div id="debug_layer"></div>');
         $div->appendChild('<div class="submit right"><a id="debug_clear" class="button large red">{LNG_Clear}</a></div>');
         $section->script('showDebug();');
         return $section->render();
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * หน้าส่งอีเมล์
  * สมาชิกส่งจดหมายถึงสมาชิก และ แอดมิน
  *
  * @param Request $request
  * @return object
  */
 public function render(Request $request)
 {
     // สมาชิก
     if ($login = Login::isMember()) {
         // ค่าที่ส่งมา
         $to = strtolower($request->get('to')->filter('0-9a-zA-Z'));
         if (preg_match('/^[0-9]+$/', $to)) {
             $reciever = \Index\Sendmail\Model::getUser($to);
             $to = '';
             foreach ($reciever as $id => $item) {
                 $to_msg = empty($item['name']) ? $item['email'] : $item['name'];
                 $to = $id;
             }
         } elseif ($to == 'admin') {
             $to_msg = self::$cfg->member_status[1];
         } else {
             $to = '';
         }
         if ($to != '') {
             // antispam
             $antispam = new Antispam();
             // ข้อมูลส่งกลับ
             $index = (object) array('topic' => Language::replace('Send a message to the :name', array(':name' => $to_msg)), 'keywords' => self::$cfg->web_title, 'description' => self::$cfg->web_description, 'module' => 'sendmail');
             $template = Template::create('member', 'member', 'sendmail');
             $template->add(array('/{TOPIC}/' => $index->topic, '/{ANTISPAM}/' => $antispam->getId(), '/{ANTISPAMVAL}/' => Login::isAdmin() ? $antispam->getValue() : '', '/{RECIEVER}/' => $to_msg, '/{SENDER}/' => $login['email'], '/{RECIEVERID}/' => $to));
             $index->detail = $template->render();
             // breadcrumbs
             $index->canonical = WEB_URL . 'index.php?module=sendmail&to=' . $to;
             Gcms::$view->addBreadcrumb($index->canonical, $index->topic);
             return $index;
         }
     }
     // ไม่สามารถส่งอีเมล์ได้
     $message = Language::get('Unable to send e-mail, Because you can not send e-mail to yourself or can not find the email address of the recipient.');
     return createClass('Index\\PageNotFound\\Controller')->init($request, 'member', $message);
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // รายการที่ต้องการ
         $id = self::$request->get('id')->toString();
         $title = Language::get(empty($id) ? 'Create' : 'Edit');
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-settings">{LNG_Site settings}</span></li>');
         $ul->appendChild('<li><a href="{BACKURL?module=languages&id=0}">{LNG_Language}</a></li>');
         $ul->appendChild('<li><span>' . $title . '</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-language">' . $title . ' {LNG_Language} ' . $id . '</h1>'));
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Languageadd\\View')->render($id));
         return $section->render();
     } else {
         // 404.html
         return \Index\Error\Controller::page404();
     }
 }
示例#29
0
 /**
  * โหลดรายการเมนูทั้งหมด.
  *
  * @return array รายการเมนูทั้งหมด
  */
 public static function getMenus()
 {
     // menu section
     self::$menus['sections']['home'] = array('h', '<a href="index.php?module=dashboard" accesskey=h title="{LNG_Home}"><span>{LNG_Home}</span></a>');
     self::$menus['sections']['settings'] = array('1', '{LNG_Site settings}');
     self::$menus['sections']['index'] = array('2', '{LNG_Menus} &amp; {LNG_Web pages}');
     self::$menus['sections']['modules'] = array('3', '{LNG_Modules}');
     self::$menus['sections']['widgets'] = array('4', '{LNG_Widgets}');
     self::$menus['sections']['users'] = array('5', '{LNG_Users}');
     self::$menus['sections']['email'] = array('6', '{LNG_Mailbox}');
     self::$menus['sections']['tools'] = array('7', '{LNG_Tools}');
     // settings
     self::$menus['settings']['system'] = '<a href="index.php?module=system"><span>{LNG_General}</span></a>';
     self::$menus['settings']['mailserver'] = '<a href="index.php?module=mailserver"><span>{LNG_Email settings}</span></a>';
     self::$menus['settings']['mailtemplate'] = '<a href="index.php?module=mailtemplate"><span>{LNG_Email template}</span></a>';
     self::$menus['settings']['template'] = '<a href="index.php?module=template"><span>{LNG_Template}</span></a>';
     self::$menus['settings']['skin'] = '<a href="index.php?module=skin"><span>{LNG_Template settings}</span></a>';
     self::$menus['settings']['maintenance'] = '<a href="index.php?module=maintenance"><span>{LNG_Maintenance Mode}</span></a>';
     self::$menus['settings']['intro'] = '<a href="index.php?module=intro"><span>{LNG_Intro Page}</span></a>';
     self::$menus['settings']['languages'] = '<a href="index.php?module=languages"><span>{LNG_Language}</span></a>';
     self::$menus['settings']['other'] = '<a href="index.php?module=other"><span>{LNG_Other}</span></a>';
     self::$menus['settings']['meta'] = '<a href="index.php?module=meta"><span>{LNG_SEO &amp; Social}</span></a>';
     // email
     self::$menus['email']['sendmail'] = '<a href="index.php?module=sendmail"><span>{LNG_Email send}</span></a>';
     // เมนู
     self::$menus['index']['pages'] = '<a href="index.php?module=pages"><span>{LNG_Web pages}</span></a>';
     self::$menus['index']['insmod'] = '<a href="index.php?module=mods"><span>{LNG_installed module}</span></a>';
     self::$menus['index']['menu'] = '<a href="index.php?module=menus"><span>{LNG_Menus}</span></a>';
     // เมนูสมาชิก
     self::$menus['users']['memberstatus'] = '<a href="index.php?module=memberstatus"><span>{LNG_Member status}</span></a>';
     self::$menus['users']['member'] = '<a href="index.php?module=member"><span>{LNG_Member List}</span></a>';
     self::$menus['users']['register'] = '<a href="index.php?module=register"><span>{LNG_Register}</span></a>';
     // tools
     self::$menus['tools']['install'] = array();
     self::$menus['tools']['database'] = '<a href="index.php?module=database"><span>{LNG_Database}</span></a>';
     self::$menus['tools']['language'] = '<a href="index.php?module=language"><span>{LNG_Language}</span></a>';
     self::$menus['tools']['debug'] = '<a href="index.php?module=debug"><span>{LNG_Debug tool}</span></a>';
     self::$menus['modules'] = array();
     // โมดูลที่ติดตั้งแล้ว
     foreach (Gcms::$install_modules as $item) {
         // ตรวจสอบไฟล์ config
         if (is_file(ROOT_PATH . "modules/{$item['owner']}/controllers/settings.php")) {
             self::$menus['modules'][$item['module']]['config'] = '<a href="index.php?module=' . $item['owner'] . '-settings&amp;id=' . $item['id'] . '"><span>{LNG_Config}</span></a>';
         }
         // ตรวจสอบไฟล์ category
         if (is_file(ROOT_PATH . "modules/{$item['owner']}/controllers/category.php")) {
             self::$menus['modules'][$item['module']]['category'] = '<a href="index.php?module=' . $item['owner'] . '-category&amp;id=' . $item['id'] . '"><span>{LNG_Category}</span></a>';
         }
         // ตรวจสอบไฟล์ setup
         if (is_file(ROOT_PATH . "modules/{$item['owner']}/controllers/setup.php")) {
             self::$menus['modules'][$item['module']]['setup'] = '<a href="index.php?module=' . $item['owner'] . '-setup&amp;id=' . $item['id'] . '"><span>{LNG_Contents}</span></a>';
         }
     }
     if (!Login::isAdmin()) {
         unset(self::$menus['sections']['settings']);
         unset(self::$menus['sections']['index']);
         unset(self::$menus['sections']['menus']);
         unset(self::$menus['sections']['widgets']);
         unset(self::$menus['sections']['users']);
         unset(self::$menus['sections']['tools']);
     }
     if (sizeof(self::$menus['modules']) == 0) {
         unset(self::$menus['sections']['modules']);
     }
     if (isset(self::$menus['widgets']) && sizeof(self::$menus['widgets']) == 0) {
         unset(self::$menus['sections']['widgets']);
     }
     if (sizeof(self::$menus['tools']['install']) == 0) {
         unset(self::$menus['tools']['install']);
     }
 }
 /**
  * บันทึก
  */
 public function save(Request $request)
 {
     $ret = array();
     // referer, session, member
     if ($request->initSession() && $request->isReferer() && ($login = Login::isMember())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             // รับค่าจากการ POST
             $save = array();
             foreach ($request->getParsedBody() as $key => $value) {
                 $k = str_replace('register_', '', $key);
                 switch ($k) {
                     case 'phone1':
                     case 'phone2':
                     case 'provinceID':
                     case 'zipcode':
                         $save[$k] = $request->post($key)->number();
                         break;
                     case 'sex':
                         $save['sex'] = $request->post('register_sex')->topic();
                         $save['subscrib'] = $request->post('register_subscrib')->toBoolean();
                         break;
                     case 'displayname':
                     case 'fname':
                     case 'lname':
                     case 'address1':
                     case 'address2':
                     case 'province':
                     case 'country':
                         $save[$k] = $request->post($key)->topic();
                         break;
                     case 'website':
                         $save[$k] = str_replace(array('http://', 'https://', 'ftp://'), array('', '', ''), $request->post($key)->url());
                         break;
                     case 'subscrib':
                         $save[$k] = $request->post($key)->toBoolean();
                         break;
                     case 'birthday':
                         $save[$k] = $request->post($key)->date();
                         break;
                     case 'password':
                     case 'repassword':
                         ${$k} = $request->post($key)->text();
                         break;
                 }
             }
             // ชื่อตาราง user
             $user_table = $this->getFullTableName('user');
             // database connection
             $db = $this->db();
             // ตรวจสอบค่าที่ส่งมา
             $user = $db->first($user_table, $request->post('register_id')->toInt());
             if (!$user) {
                 // ไม่พบสมาชิกที่แก้ไข
                 $ret['alert'] = Language::get('not a registered user');
             } else {
                 $input = false;
                 // ชื่อเล่น
                 if (isset($save['displayname'])) {
                     if (mb_strlen($save['displayname']) < 2) {
                         $ret['ret_register_displayname'] = Language::get('Name for the show on the site at least 2 characters');
                         $input = !$input ? 'register_displayname' : $input;
                     } elseif (in_array($save['displayname'], self::$cfg->member_reserv)) {
                         $ret['ret_register_displayname'] = Language::get('Invalid name');
                         $input = !$input ? 'register_displayname' : $input;
                     } else {
                         // ตรวจสอบ displayname ซ้ำ
                         $search = $db->first($user_table, array('displayname', $save['displayname']));
                         if ($search !== false && $user->id != $search->id) {
                             $ret['ret_register_displayname'] = str_replace(':name', Language::get('Name'), Language::get('This :name is already registered'));
                             $input = !$input ? 'register_displayname' : $input;
                         } else {
                             $ret['ret_register_displayname'] = '';
                         }
                     }
                 }
                 // ชื่อ นามสกุล
                 if (!empty($save['fname']) || !empty($save['lname'])) {
                     $search = $db->first($user_table, array(array('fname', $save['fname']), array('lname', $save['lname'])));
                     if ($search !== false && $user->id != $search->id) {
                         $ret['ret_register_fname'] = str_replace(':name', Language::get('Name') . ' ' . Language::get('Surname'), Language::get('This :name is already registered'));
                         $input = !$input ? 'register_fname' : $input;
                     } else {
                         $ret['ret_register_fname'] = '';
                     }
                 }
                 // โทรศัพท์
                 if (!empty($save['phone1'])) {
                     if (!preg_match('/[0-9]{9,10}/', $save['phone1'])) {
                         $ret['ret_register_phone1'] = str_replace(':name', Language::get('phone number'), Language::get('Invalid :name'));
                         $input = !$input ? 'register_phone1' : $input;
                     } else {
                         // ตรวจสอบโทรศัพท์
                         $search = $db->first($user_table, array('phone1', $save['phone1']));
                         if ($search !== false && $user->id != $search->id) {
                             $ret['ret_register_phone1'] = str_replace(':name', Language::get('phone number'), Language::get('This :name is already registered'));
                             $input = !$input ? 'register_phone1' : $input;
                         } else {
                             $ret['ret_register_phone1'] = '';
                         }
                     }
                 }
                 // แก้ไขรหัสผ่าน
                 if ($user->fb == 0 && (!empty($password) || !empty($repassword))) {
                     if (mb_strlen($password) < 4) {
                         // รหัสผ่านต้องไม่น้อยกว่า 4 ตัวอักษร
                         $ret['ret_register_password'] = Language::get('Passwords must be at least four characters');
                         $input = !$input ? 'register_password' : $input;
                     } elseif ($repassword != $password) {
                         // ถ้าต้องการเปลี่ยนรหัสผ่าน กรุณากรอกรหัสผ่านสองช่องให้ตรงกัน
                         $ret['ret_register_repassword'] = Language::get('To change your password, enter your password to match the two inputs');
                         $input = !$input ? 'register_repassword' : $input;
                     } else {
                         // password ใหม่ถูกต้อง
                         $save['password'] = md5($password . $user->email);
                         $ret['ret_register_password'] = '';
                         $ret['ret_register_repassword'] = '';
                     }
                 }
                 // อัปโหลดไฟล์
                 foreach ($request->getUploadedFiles() as $item => $file) {
                     if ($file->hasUploadFile()) {
                         $item = str_replace('register_', '', $item);
                         if (!File::makeDirectory(ROOT_PATH . self::$cfg->usericon_folder)) {
                             // ไดเรคทอรี่ไม่สามารถสร้างได้
                             $ret['ret_register_' . $item] = sprintf(Language::get('Directory %s cannot be created or is read-only.'), self::$cfg->usericon_folder);
                             $input = !$input ? 'ret_register_' . $item : $input;
                         } else {
                             if (!empty($user->icon)) {
                                 // ลบไฟล์เดิม
                                 @unlink(ROOT_PATH . self::$cfg->usericon_folder . $user->icon);
                             }
                             try {
                                 // อัปโหลด thumbnail
                                 $save['icon'] = $user->id . '.jpg';
                                 $file->cropImage(self::$cfg->user_icon_typies, ROOT_PATH . self::$cfg->usericon_folder . $save['icon'], self::$cfg->user_icon_w, self::$cfg->user_icon_h);
                             } catch (\Exception $exc) {
                                 // ไม่สามารถอัปโหลดได้
                                 $ret['ret_register_' . $item] = Language::get($exc->getMessage());
                                 $input = !$input ? 'ret_register_' . $item : $input;
                             }
                         }
                     }
                 }
                 if (!empty($save)) {
                     if (!$input) {
                         // save
                         $db->update($user_table, $user->id, $save);
                         // เปลี่ยน password ที่ login ใหม่
                         if (!empty($save['password'])) {
                             $_SESSION['login']['password'] = $password;
                         }
                         // คืนค่า
                         $ret['alert'] = Language::get('Saved successfully');
                         $ret['location'] = 'index.php?module=editprofile&tab=' . $request->post('tab')->toString();
                     } else {
                         // error
                         $ret['input'] = $input;
                     }
                 }
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     if (!empty($ret)) {
         echo json_encode($ret);
     }
 }