/**
  * แสดงผล
  */
 public function render(Request $request)
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // รายการที่ต้องการ
         $index = \Index\Pagewrite\Model::getIndex($request->get('id')->toInt(), $request->get('owner', 'index')->topic());
         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_Web pages}</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\\Pagewrite\\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();
 }
Example #3
0
 /**
  * แสดงผล
  *
  * @param Request $request
  */
 public function index(Request $request)
 {
     // เริ่มต้นการใช้งาน Template
     Template::init(self::$cfg->skin);
     // ถ้าไม่มีโมดูลเลือกหน้า home
     $module = $request->get('module', 'home')->toString();
     // สร้าง View
     $view = new \Kotchasan\View();
     // template default
     $view->setContents(array('/{MENU}/' => createClass('Index\\Menu\\Controller')->render($module), '/{TITLE}/' => self::$cfg->web_title, '/{CONTENT}/' => Template::load('', '', $module), '/{TIME}/' => Date::format()));
     // ส่งออกเป็น HTML
     echo $view->renderHTML();
 }
 public function view(Request $request)
 {
     $topic = Language::get('Personal information') . ' ' . self::$cfg->web_title;
     $user = \Index\Member\Model::getUserById($request->get('id')->toInt());
     if ($user) {
         $template = Template::create('member', 'member', 'view');
         $template->add(array('/{ID}/' => $user->id, '/{EMAIL}/' => $user->email, '/{FNAME}/' => $user->fname, '/{LNAME}/' => $user->lname, '/{SEX}/' => $user->sex === 'f' || $user->sex === 'm' ? $user->sex : 'u', '/{DATE}/' => Date::format($user->create_date), '/{WEBSITE}/' => $user->website, '/{VISITED}/' => $user->visited, '/{LASTVISITED}/' => Date::format($user->lastvisited), '/{POST}/' => number_format($user->post), '/{REPLY}/' => number_format($user->reply), '/{STATUS}/' => isset(self::$cfg->member_status[$user->status]) ? self::$cfg->member_status[$user->status] : 'Unknow', '/{COLOR}/' => $user->status, '/{SOCIAL}/' => $user->fb == 1 ? 'icon-facebook' : '', '/{TOPIC}/' => $topic));
         // breadcrumbs
         $canonical = WEB_URL . 'index.php?module=member&amp;id=' . $user->id;
         Gcms::$view->addBreadcrumb($canonical, $topic);
         // คืนค่า
         return (object) array('detail' => $template->render(), 'keywords' => self::$cfg->web_title, 'description' => self::$cfg->web_description, 'topic' => $topic, 'canonical' => $canonical);
     } else {
         // ไม่พบสมาชิก
         return createClass('Index\\PageNotFound\\Controller')->init($request, 'index');
     }
 }
Example #5
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();
     }
 }
 /**
  * แสดงข้อมูลสมาชิก
  *
  * @param Request $request
  * @return object
  */
 public function render(Request $request)
 {
     // ตรวจสอบข้อมูล
     $user = \Index\Member\Model::getUserByActivateCode($request->get('id')->topic());
     if ($user) {
         // activate
         \Index\Member\Model::activateUser($user);
         // ข้อมูลแสดงผล (สำเร็จ)
         $details = array('/{DETAIL}/' => Language::get('<b>Congratulations!</b> your members have already confirmed. You can use your email address and password sent with the email address used to login.'), '/{CLASS}/' => 'message');
     } else {
         // ข้อมูลแสดงผล (ไม่สำเร็จ)
         $details = array('/{DETAIL}/' => Language::get('<b>Sorry!</b> can not find it registered. Information of registration may have expired or your registration may be confirmed.'), '/{CLASS}/' => 'error');
     }
     // template
     $template = Template::create('member', 'member', 'activate');
     $template->add($details);
     // คืนค่า
     return (object) array('detail' => $template->render(), 'keywords' => self::$cfg->web_title, 'description' => self::$cfg->web_description, 'topic' => Language::get('Activate') . ' ' . self::$cfg->web_title, 'menu' => 'member');
 }
 public function index(Request $request)
 {
     if ($request->initSession() && $request->isReferer()) {
         $user = $this->db()->createQuery()->from('user')->where($request->get('id')->toInt())->cacheOn()->toArray()->first('icon');
         if ($user) {
             if (!empty($user['icon']) && is_file(ROOT_PATH . self::$cfg->usericon_folder . $user['icon'])) {
                 $icon = ROOT_PATH . self::$cfg->usericon_folder . $user['icon'];
             }
         }
         if (empty($icon)) {
             $icon = is_file(ROOT_PATH . 'skin/' . self::$cfg->skin . '/img/noicon.jpg') ? ROOT_PATH . 'skin/' . self::$cfg->skin . '/img/noicon.jpg' : ROOT_PATH . 'skin/img/noicon.jpg';
         }
         // ตรวจสอบรูป
         $info = getImageSize($icon);
         if (empty($info['error'])) {
             $response = new Response();
             $response->withHeaders(array('Pragma' => 'public', 'Cache-Control' => 'max-age=86400', 'Expires' => gmdate('D, d M Y H:i:s GMT', time() + 86400), 'Content-type' => $info['mime']))->withContent(file_get_contents($icon))->send();
         }
     }
 }
 /**
  * แสดงผล
  */
 public function render(Request $request)
 {
     // แอดมิน
     if (Login::isAdmin()) {
         $this->date = $request->get('date', date('Y-m-d'))->date();
         // แสดงผล
         $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>');
         $ul->appendChild('<li><span>{LNG_Report}</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-stats">' . $this->title() . '</h1>'));
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Report\\View')->render($this->date));
         return $section->render();
     } else {
         // 404.html
         return \Index\Error\Controller::page404();
     }
 }
 /**
  * แสดงผลหน้าหลักเว็บไซต์
  *
  * @param Request $request
  */
 public function index(Request $request)
 {
     // ตัวแปรป้องกันการเรียกหน้าเพจโดยตรง
     define('MAIN_INIT', __FILE__);
     // session cookie
     $request->initSession();
     // ตรวจสอบการ login
     Login::create();
     // กำหนด skin ให้กับ template
     Template::init($request->get('skin', self::$cfg->skin)->toString());
     // backend
     Gcms::$view = new \Kotchasan\View();
     if ($login = Login::adminAccess()) {
         // โหลดโมดูลที่ติดตั้งแล้ว
         \Index\Index\Model::installedmodules();
         // Controller หลัก
         $main = new \Index\Main\Controller();
     } else {
         // forgot or login
         if ($request->request('action')->toString() === 'forgot') {
             $main = new \Index\Forgot\Controller();
         } else {
             $main = new \Index\Login\Controller();
         }
     }
     $languages = array();
     $uri = $request->getUri();
     foreach (array_merge(self::$cfg->languages, Language::installedLanguage()) as $i => $item) {
         $languages[$item] = '<a id=lang_' . $item . ' href="' . $uri->withParams(array('lang' => $item), true) . '" title="{LNG_Language} ' . strtoupper($item) . '" style="background-image:url(' . WEB_URL . 'language/' . $item . '.gif)" tabindex=1>&nbsp;</a>';
     }
     // เนื้อหา
     Gcms::$view->setContents(array('/{MAIN}/' => $main->execute($request), '/{VERSION}/' => self::$cfg->version, '/{LANGUAGES}/' => implode('', $languages), '/{TITLE}/' => $main->title() . ' (Admin)', '/{BACKURL(\\?([a-zA-Z0-9=&\\-_@\\.]+))?}/e' => '\\Kotchasan\\View::back'));
     if ($login) {
         $name = trim($login['fname'] . ' ' . $login['lname']);
         Gcms::$view->setContents(array('/{LOGINID}/' => $login['id'], '/{LOGINNAME}/' => empty($name) ? $login['email'] : $name, '/{STATUS}/' => $login['status'], '/{MENUS}/' => \Index\Menu\View::render()));
     }
     // ส่งออก เป็น HTML
     $response = new Response();
     $response->withContent(Gcms::$view->renderHTML())->send();
 }
Example #10
0
 /**
  * หน้าหลักแอดมิน
  *
  * @param Request $request
  * @return string
  */
 public function execute(Request $request)
 {
     // โมดูลจาก URL ถ้าไม่มีใช้ default (dashboard)
     $module = $request->get('module', 'dashboard')->toString();
     if (preg_match('/^([a-z]+)([\\/\\-]([a-z]+))?$/i', $module, $match)) {
         if (empty($match[3])) {
             $owner = 'index';
             $module = $match[1];
         } else {
             $owner = $match[1];
             $module = $match[3];
         }
     } else {
         $owner = 'index';
         $module = 'dashboard';
     }
     // ตรวจสอบหน้าที่เรียก
     if (is_file(APP_PATH . 'modules/' . $owner . '/controllers/' . $module . '.php')) {
         // หน้าที่เรียก (Admin)
         include APP_PATH . 'modules/' . $owner . '/controllers/' . $module . '.php';
         $controller = ucfirst($owner) . '\\' . ucfirst($module) . '\\Controller';
     } elseif (is_file(ROOT_PATH . 'modules/' . $owner . '/controllers/admin/' . $module . '.php')) {
         // เรียกโมดูลที่ติดตั้ง
         include ROOT_PATH . 'modules/' . $owner . '/controllers/admin/' . $module . '.php';
         $controller = ucfirst($owner) . '\\Admin\\' . ucfirst($module) . '\\Controller';
     } elseif (is_file(ROOT_PATH . 'Widgets/' . ucfirst($owner) . '/Controllers/' . ucfirst($module) . '.php')) {
         // เรียก Widgets ที่ติดตั้ง
         include ROOT_PATH . 'Widgets/' . ucfirst($owner) . '/Controllers/' . ucfirst($module) . '.php';
         $controller = 'Widgets\\' . ucfirst($owner) . '\\Controllers\\' . ucfirst($module);
     } else {
         // หน้า default ของ backend
         include APP_PATH . 'modules/index/controllers/dashboard.php';
         $controller = 'Index\\Dashboard\\Controller';
     }
     $this->controller = new $controller();
     // tempalate
     $template = Template::create('', '', 'main');
     $template->add(array('/{CONTENT}/' => $this->controller->render($request)));
     return $template->render();
 }
 /**
  * GLoader
  *
  * @param Request $request
  */
 public function index(Request $request)
 {
     // session cookie
     $request->initSession();
     // กำหนด skin ให้กับ template
     Template::init(self::$cfg->skin);
     // ตรวจสอบโมดูลที่เรียก
     $index = \Index\Export\Model::module($request->get('module')->toString());
     if ($index) {
         $className = ucfirst($index->owner) . '\\Export\\Controller';
         if (method_exists($className, 'init')) {
             $detail = createClass($className)->init($request, $index);
         }
         if ($detail != '') {
             $view = new \Kotchasan\View();
             $view->setContents(array('/{CONTENT}/' => $detail));
             echo $view->renderHTML(Template::load('', '', 'print'));
             exit;
         }
     }
     // ไม่พบโมดูลหรือไม่มีสิทธิ
     new \Kotchasan\Http\NotFound();
 }
 /**
  * หน้าส่งอีเมล์
  * สมาชิกส่งจดหมายถึงสมาชิก และ แอดมิน
  *
  * @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);
 }
Example #13
0
 /**
  * แสดงผล index.html
  *
  * @param Request $request
  */
 public function index(Request $request)
 {
     // ตัวแปรป้องกันการเรียกหน้าเพจโดยตรง
     define('MAIN_INIT', __FILE__);
     // session cookie
     $request->initSession();
     // ตรวจสอบการ login
     Login::create();
     // กำหนด skin ให้กับ template
     self::$cfg->skin = $request->get('skin', self::$request->session('skin', self::$cfg->skin)->toString())->toString();
     self::$cfg->skin = is_file(ROOT_PATH . 'skin/' . self::$cfg->skin . '/style.css') ? self::$cfg->skin : 'bighead';
     $_SESSION['skin'] = self::$cfg->skin;
     Template::init(self::$cfg->skin);
     // ตรวจสอบหน้าที่จะแสดง
     if (!empty(self::$cfg->maintenance_mode) && !Login::isAdmin()) {
         Gcms::$view = new \Index\Maintenance\View();
     } elseif (!empty(self::$cfg->show_intro) && str_replace(array(BASE_PATH, '/'), '', $request->getUri()->getPath()) == '') {
         Gcms::$view = new \Index\Intro\View();
     } else {
         // counter และ useronline
         $new_day = \Index\Counter\Model::init();
         // View
         Gcms::$view = new \Gcms\View();
         // โมดูลที่ติดตั้ง
         $dir = ROOT_PATH . 'modules/';
         // โหลดโมดูลทั้งหมด
         foreach (\Index\Module\Model::getInstalledModule() as $owner) {
             if (is_file($dir . $owner . '/controllers/init.php')) {
                 include $dir . $owner . '/controllers/init.php';
                 $class = ucfirst($owner) . '\\Init\\Controller';
                 if (method_exists($class, 'init')) {
                     createClass($class)->init();
                 }
             }
             if ($new_day && is_file($dir . $owner . '/controllers/cron.php')) {
                 include $dir . $owner . '/controllers/cron.php';
                 $class = ucfirst($owner) . '\\Cron\\Controller';
                 if (method_exists($class, 'init')) {
                     createClass($class)->init();
                 }
             }
         }
         // โหลด Init ของ Widgets
         $dir = ROOT_PATH . 'Widgets/';
         $f = @opendir($dir);
         if ($f) {
             while (false !== ($text = readdir($f))) {
                 if ($text != "." && $text != "..") {
                     if (is_dir($dir . $text)) {
                         if (is_file($dir . $text . '/Controllers/Init.php')) {
                             include $dir . $text . '/Controllers/Init.php';
                             $class = 'Widgets\\' . ucfirst($text) . '\\Controllers\\Init';
                             if (method_exists($class, 'init')) {
                                 createClass($class)->init();
                             }
                         }
                     }
                 }
             }
             closedir($f);
         }
         // หน้า home มาจากเมนูรายการแรก
         $home = Gcms::$menu->homeMenu();
         if ($home) {
             $home->canonical = WEB_URL . 'index.php';
             // breadcrumb หน้า home
             Gcms::$view->addBreadcrumb($home->canonical, $home->menu_text, $home->menu_tooltip, 'icon-home');
         }
         // ตรวจสอบโมดูลที่เรียก
         $modules = \Index\Module\Controller::get($request->getQueryParams());
         if (!empty($modules)) {
             // โหลดโมดูลที่เรียก
             $page = createClass($modules->className)->{$modules->method}($request, $modules->module);
         }
         if (empty($page)) {
             // ไม่พบหน้าที่เรียก (index)
             $page = createClass('Index\\PageNotFound\\Controller')->init($request, 'index');
         }
         // title ของเว็บไซต์
         $web_title = strip_tags($page->topic);
         // meta tag
         $meta = array('generator' => '<meta name=generator content="GCMS AJAX CMS design by http://gcms.in.th">', 'og:title' => '<meta property="og:title" content="' . $web_title . '">', 'description' => '<meta name=description content="' . $page->description . '">', 'keywords' => '<meta name=keywords content="' . $page->keywords . '">', 'og:site_name' => '<meta property="og:site_name" content="' . $web_title . '">', 'og:type' => '<meta property="og:type" content="article">');
         // โมดูลแรกสุด ใส่ลงใน Javascript
         $module_list = array_keys(Gcms::$install_modules);
         $script = array('var FIRST_MODULE = "' . reset($module_list) . '";');
         // logo
         $image_logo = '';
         if (!empty(self::$cfg->logo) && is_file(ROOT_PATH . DATA_FOLDER . 'image/' . self::$cfg->logo)) {
             $image_src = WEB_URL . DATA_FOLDER . 'image/' . self::$cfg->logo;
             $info = getImageSize(ROOT_PATH . DATA_FOLDER . 'image/' . self::$cfg->logo);
             if ($info[0] > 0 || $info[1] > 0) {
                 $ext = explode('.', self::$cfg->logo);
                 if (strtolower(end($ext)) == 'swf') {
                     $script[] = '$G(window).Ready(function(){';
                     $script[] = 'if ($E("logo")) {';
                     $script[] = "new GMedia('logo_swf', '" . $image_src . "', {$info['0']}, {$info['1']}).write('logo');";
                     $script[] = '}';
                     $script[] = '});';
                 } else {
                     $image_logo = '<img src="' . $image_src . '" alt="{WEBTITLE}">';
                 }
             }
         }
         if (empty($page->image_src)) {
             if (is_file(ROOT_PATH . DATA_FOLDER . 'image/facebook_photo.jpg')) {
                 $page->image_src = WEB_URL . DATA_FOLDER . 'image/facebook_photo.jpg';
             }
         } elseif (!empty($image_src)) {
             $page->image_src = $image_src;
         }
         if (!empty($page->image_src)) {
             $meta['image_src'] = '<link rel=image_src href="' . $page->image_src . '">';
             $meta['og:image'] = '<meta property="og:image" content="' . $page->image_src . '">';
         }
         if (!empty(self::$cfg->facebook_appId)) {
             $meta['og:app_id'] = '<meta property="fb:app_id" content="' . self::$cfg->facebook_appId . '">';
         }
         if (isset($page->canonical)) {
             $meta['canonical'] = '<meta name=canonical content="' . $page->canonical . '">';
             $meta['og:url'] = '<meta property="og:url" content="' . $page->canonical . '">';
         }
         $meta['script'] = "<script>\n" . implode("\n", $script) . "\n</script>";
         Gcms::$view->setMetas($meta);
         // ภาษาที่ติดตั้ง
         $languages = Template::create('', '', 'language');
         foreach (self::$cfg->languages as $lng) {
             $languages->add(array('/{LNG}/' => $lng));
         }
         // เมนูหลัก
         Gcms::$view->setContents(Gcms::$menu->render(isset($page->menu) ? $page->menu : $page->module));
         // เนื้อหา
         Gcms::$view->setContents(array('/{CONTENT}/' => $page->detail, '/{TITLE}/' => $web_title, '/{LANGUAGES}/' => $languages->render(), '/{LOGO}/' => $image_logo));
     }
     // ส่งออก เป็น HTML
     $response = new Response();
     $response->withContent(Gcms::$view->renderHTML())->send();
 }
 public function index(Request $request)
 {
     $request->initSession();
     // Antispam Image
     Antispam::createImage($request->get('id')->toString());
 }
Example #15
0
 /**
  * แสดงผล
  *
  * @param Request $request
  */
 public function index(Request $request)
 {
     $action = $request->get('action', 'hello')->username();
     $this->{$action}();
 }