Example #1
0
 /**
  * สร้าง Application สามารถเรียกใช้ได้ครั้งเดียวเท่านั้น
  *
  * @return \static
  */
 public static function &createWebApplication()
 {
     if (null === self::$instance) {
         self::$instance = new static();
     }
     return self::$instance;
 }
Example #2
0
 /**
  * สร้าง Application สามารถเรียกใช้ได้ครั้งเดียวเท่านั้น
  *
  * @param Config $cfg ถ้าไม่กำหนดมาจะใช้ค่าเริ่มต้นของคชสาร
  * @return \static
  */
 public static function createWebApplication(Config $cfg = null)
 {
     if (null === self::$instance) {
         self::$instance = new static($cfg);
     }
     return self::$instance;
 }
Example #3
0
<?php

// ลบไฟล์
session_start();
// header
header("content-type: text/html; charset=UTF-8");
// ตัวแปรที่จำเป็นสำหรับ Framework ใช้ระบุ root folder
define('APP_PATH', str_replace(array('\\', 'ckeditor/filemanager/browser/default'), array('/', ''), dirname(__FILE__)));
// load Kotchasan
include APP_PATH . 'core/load.php';
// inint Kotchasan Framework
Kotchasan::createWebApplication();
if (\Input::isReferer() && \Login::isAdmin()) {
    if (isset($_POST['did'])) {
        \File::removeDirectory(ROOT_PATH . $_POST['did']);
    } elseif (isset($_POST['fid'])) {
        @unlink(ROOT_PATH . $_POST['fid']);
    }
} else {
    echo 'Do not delete!';
}
<?php

/*
 * loader.php
 * หน้าเพจสำหรับให้ GLoader เรียกมา
 *
 * @author Goragod Wiriya <*****@*****.**>
 * @link http://www.kotchasan.com/
 * @copyright 2016 Goragod.com
 * @license http://www.kotchasan.com/license/
 */
// load Kotchasan
include 'load.php';
// Initial Kotchasan Framework
$app = Kotchasan::createWebApplication(Gcms\Config::create());
$app->defaultController = 'Index\\Loader\\Controller';
$app->run();
Example #5
0
 /**
  * บันทึก cache เมื่อบันทึกแล้วจะปิดการใช้งาน cache อัตโนมัติ
  * จะใช้คำสั่งนี้เมื่อมีการเรียกใช้แคชด้วยคำสั่ง cacheOn(false) เท่านั้น
  * query ครั้งต่อไปถ้าจะใช้ cache ต้อง เปิดการใช้งาน cache ก่อนทุกครั้ง
  *
  * @param array $datas ข้อมูลที่จะบันทึก
  */
 public function save($datas)
 {
     if ($this->cache_dir && !empty($this->cache_expire) && !empty($this->action) && is_array($datas)) {
         $f = @fopen($this->file, 'wb');
         if ($f) {
             fwrite($f, '<?php exit?>' . serialize($datas));
             fclose($f);
         } else {
             log_message('Warning', str_replace('%s', 'cache/', \Kotchasan::trans('The directory %s cannot be written')), __FILE__, __LINE__);
         }
     }
     $this->action = 0;
 }