Beispiel #1
0
 /**
 * Class constructor
 *
 * @param string File path location
 * @return void
 */
 public function __construct($file_path)
 {
     $arr = explode('/', $file_path);
     $file_name = end($arr);
     $file_path = APPLICATION . $file_path . '.php';
     $prefix = $arr[0];
     if (!file_exists($file_path)) {
         Library_error::_500('<b>Error:</b> No <b>' . $file_name . '</b> file in ' . $arr[0] . ' folder.');
     }
     $class = ucwords($prefix) . '_' . $file_name;
     include_once $file_path;
     if (!class_exists($class)) {
         Library_error::_500('<b>Error:</b> No class <b>' . $class . '</b> exists in file ' . $file_name . '.');
     }
     $this->class_inctance = new $class();
 }
Beispiel #2
0
 /**
  * Print the error at least to PHP error log file
  *
  * @return string
  */
 private function print_error()
 {
     if ($caller = Library_error::get_caller(2)) {
         $error_str = sprintf('Database error %1$s for query %2$s made by %3$s', $this->last_error, $this->last_query, $caller);
     } else {
         $error_str = sprintf('Database error %1$s for query %2$s', $this->last_error, $this->last_query);
     }
     //write the error to log
     @error_log($error_str, 0);
     //Is error output turned on or not..
     if (error_reporting() == 0) {
         return false;
     }
     $str = htmlspecialchars($this->last_error, ENT_QUOTES);
     $query = htmlspecialchars($this->last_query, ENT_QUOTES);
     // If there is an error then take note of it
     Library_error::database($str . '<br /><b>Query</b>: ' . $query . '<br /><b>Backtrace</b>: ' . $caller);
 }
Beispiel #3
0
 * Panada APC API.
 *
 * @package	Panada
 * @subpackage	Library
 * @author	Iskandar Soesman
 * @since	Version 0.2
 *
 * Install APC on Ubuntu: aptitude install libpcre3-dev;
 * pecl install apc
 */
/**
 * ID: Pastikan ekstensi APC telah terinstall
 * EN: Makesure APC extension is enabled
 */
if (!extension_loaded('apc')) {
    Library_error::_500('APC extension that required by Library_apc is not available.');
}
class Library_apc
{
    public function __construct()
    {
    }
    public function __call($name, $arguments)
    {
        return call_user_func_array($name, $arguments);
    }
    public static function __callStatic($name, $arguments)
    {
        return call_user_func_array($name, $arguments);
    }
}
Beispiel #4
0
defined('THISPATH') or die('Can\'t access directly!');
/**
 * Panada MongoDB API.
 *
 * @package	Panada
 * @subpackage	Library
 * @author	Iskandar Soesman
 * @since	Version 0.2
 */
/**
 * ID: Pastikan ektensi Mongo telah terinstall
 * EN: Makesure Memcache extension is enabled
 */
if (!extension_loaded('mongo')) {
    Library_error::_500('Mongo extension that required by Library_mongodb is not available.');
}
class Library_mongodb extends Mongo
{
    public $database;
    public function __construct($connection = 'default')
    {
        $this->config = new Library_config();
        $this->database = $this->config->mongodb->{$connection}->database;
        $host = $this->config->mongodb->{$connection}->host;
        /**
         * EN: This is the mongodb connection option. Eg: array('replicaSet' => true, 'connect' => false)
         */
        $connection_options = array();
        parent::__construct($host, $connection_options);
    }
Beispiel #5
0
 public function output($file_path, $data = array())
 {
     $file_path = APPLICATION . 'view/' . $file_path;
     if (!file_exists($view_file = $file_path . '.php')) {
         Library_error::_500('<b>Error:</b> No <b>' . $view_file . '</b> file in view folder.');
     }
     if (!empty($data)) {
         $this->view = $data;
     }
     if (!empty($this->view)) {
         extract($this->view, EXTR_SKIP);
     }
     include_once $view_file;
 }
Beispiel #6
0
defined('THISPATH') or die('Can\'t access directly!');
/**
 * Panada Restful class.
 *
 * @package	Panada
 * @subpackage	Library
 * @author	Iskandar Soesman
 * @since	Version 0.1
 */
/**
 * ID: Pastikan ektensi Curl telah terinstall
 * EN: Makesure Curl extension is enabled
 */
if (!function_exists('curl_init')) {
    Library_error::_500('cUrl extension that required by Library_rest is not available.');
}
class Library_rest
{
    public $request_method;
    public $request_data = array();
    public $set_request_headers = array();
    public $response_status;
    public $response_output_header = false;
    public $timeout = 30;
    public function get_request()
    {
        $this->request_method = strtoupper($_SERVER['REQUEST_METHOD']);
        switch ($this->request_method) {
            case 'GET':
                $this->request_data = $_GET;
Beispiel #7
0
 /**
  * EN: Class constructor
  */
 public function __construct()
 {
     if (!function_exists('imagecopyresampled')) {
         Library_error::costume(500, 'Image resizing function that required by Library_images Class is not available.');
     }
 }
Beispiel #8
0
defined('THISPATH') or die('Can\'t access directly!');
/**
 * Panada Memcached API.
 *
 * @package	Panada
 * @subpackage	Library
 * @author	Iskandar Soesman
 * @since	Version 0.1
 */
/**
 * ID: Pastikan ektensi Memcache telah terinstall
 * EN: Makesure Memcache extension is enabled
 */
if (!extension_loaded('memcache')) {
    Library_error::_500('Memcache extension that required by Library_memcached is not available.');
}
class Library_memcached extends Memcache
{
    /**
     * EN: Load configuration from config file.
     * @return void
     */
    public function __construct()
    {
        $this->config = new Library_config();
        foreach ($this->config->memcached_host as $host) {
            $this->addServer($host, $this->config->memcached_port);
        }
        /**
         * EN: If you need compression Threshold, you can uncomment this
Beispiel #9
0
 /**
  * Initiate contoller within contoller
  *
  * @return void
  * @param string $controller Controller's name
  * @param array $params The parameters for it controller
  * @param string $alias_method a method name for alias call
  */
 public static function sub_controller($class_file, $params = array(), $alias_method = false)
 {
     $requsts = array();
     if (!empty($params[1])) {
         $requsts = array_slice($params, 1);
     }
     if (!($class_file = self::is_controller_exists($class_file))) {
         Library_error::_404();
     }
     include_once $class_file;
     $controller = str_replace('.php', '', end(explode('/', $class_file)));
     $controller = 'Controller_' . $controller;
     $controller = new $controller();
     // Initiate Default Method
     $method = 'index';
     if (!empty($params[0])) {
         $method = $params[0];
     }
     if (!method_exists($controller, $method)) {
         if (!$alias_method) {
             Library_error::_404();
         }
         $requsts = $requsts ? array_merge(array($method), $requsts) : array($method);
         $method = $alias_method;
     }
     call_user_func_array(array($controller, $method), $requsts);
 }