Beispiel #1
0
 public function dbAAA2()
 {
     Doo::loadCore('db/DooSqlMagic');
     $dbAAA = new DooSqlMagic();
     $dbAAA->setDb(Doo::conf()->db_aaa2, Doo::conf()->APP_MODE);
     $dbAAA->connect();
     return $dbAAA;
 }
Beispiel #2
0
 public function dbW()
 {
     Doo::loadCore('db/DooSqlMagic');
     $dbW = new DooSqlMagic();
     $dbW->setDb(Doo::conf()->db_write, Doo::conf()->APP_MODE);
     $dbW->connect();
     return $dbW;
 }
Beispiel #3
0
 function agregarRespuesta()
 {
     session_start();
     if (Session::siExisteSesion()) {
         $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Doo::conf()->APP_URL . 'ionadmin/index';
         $referer = strtok($referer, '?');
         $this->data['idpregunta'] = intval($this->params['idpregunta']);
         if (isset($_POST['respuesta']) && !empty($_POST['respuesta'])) {
             Doo::loadModel('CtRespuesta');
             Doo::loadCore('db/DooDbExpression');
             $r = new CtRespuesta();
             $r->respuesta = strip_tags(addslashes($_POST['respuesta']));
             $r->id_pregunta = $this->data['idpregunta'];
             $r->insert();
             header('location:' . $referer . '?success=1');
         } else {
             header('location:' . $referer . '?error=1');
         }
     } else {
         header('location:' . Doo::conf()->APP_URL . 'ionadmin/login?error=1');
     }
 }
Beispiel #4
0
<?php

Doo::loadCore('db/DooSmartModel');
class Food extends DooSmartModel
{
    public $id;
    public $name;
    public $description;
    public $location;
    public $food_type_id;
    public $_table = 'food';
    public $_primarykey = 'id';
    public $_fields = array('id', 'name', 'description', 'location', 'food_type_id');
    function __construct()
    {
        //parent::__construct( array('id'=>1, 'name'=>'Ban Mian', 'location'=>'Malaysia') );    //This is for you to set the properties with constructor
        //parent::$caseSensitive = true;
        parent::$className = __CLASS__;
        //a must if you are using static querying methods Food::_count(), Food::getById()
        //parent::setupModel(__CLASS__);
        //parent::setupModel(__CLASS__, true);
    }
    public function get_recipe()
    {
        return Doo::db()->relate('Recipe', __CLASS__, array('limit' => 'first'));
    }
    public function get_by_id()
    {
        if (intval($this->id) <= 0) {
            return null;
        }
<?php

/**
 * DooManageSqliteDb class file.
 *
 * @author Richard Myers <*****@*****.**>
 * @link http://www.doophp.com/
 * @copyright Copyright &copy; 2009 Leng Sheng Hong
 * @license http://www.doophp.com/license
 * @package doo.db.manage.adapters
 * @since 1.3
 */
Doo::loadCore('db/manage/DooManageDb');
class DooManageSqliteDb extends DooManageDb
{
    /**
     * A mapping of DooManageDb generic datatypes to RDBMS native datatypes for columns
     * These must be defined in each specific adapter
     *
     * The datatypes are
     * COL_TYPE_BOOL		: A true or false boolean
     * COL_TYPE_SMALLINT	: 2-byte integer (-32,767 to 32,768)
     * COL_TYPE_INT			: 4-byte integer (-2,147,483,648 to 2,147,483,647)
     * COL_TYPE_BIGINT		: 8-byte integer (about -9,000 trilllion to 9,000 trillion)
     * COL_TYPE_DECIMAL		: Fixed point decimal of specific size (total digits) and scope (num digits after decimal point)
     * COL_TYPE_FLOAT		: A double-percision floating point decimal number
     * COL_TYPE_CHAR		: A fixed length string of 1-255 characters
     * COL_TYPE_VARCHAR		: A variable length string of 1-255 characters
     * COL_TYPE_CLOB		: A large character object of up to about 2Gb
     * COL_TYPE_DATE		: an ISO 8601 date eg. 2009-09-27
     * COL_TYPE_TIME		: an ISO 8601 time eg. 18:38:49
 /**
  * Gets an instance of a Database Admin Adapter for the current DB's Engine
  * @param object $engine
  * @return
  */
 private function getDbEngineManager($engine)
 {
     if ($engine == 'mysql') {
         Doo::loadCore('db/manage/adapters/DooManageMySqlDb');
         return new DooManageMySqlDb();
     } else {
         if ($engine == 'pgsql') {
             Doo::loadCore('db/manage/adapters/DooManagePgSqlDb');
             return new DooManagePgSqlDb();
         } else {
             if ($engine == 'sqlite') {
                 Doo::loadCore('db/manage/adapters/DooManageSqliteDb');
                 return new DooManageSqliteDb();
             } else {
                 throw new DooDbUpdateException("Unsupported Database Engine : {$engine}");
             }
         }
     }
 }
 /**
  * Handles the routing process.
  * Auto routing, sub folder, subdomain, sub folder on subdomain are supported.
  * It can be used with or without the <i>index.php</i> in the URI
  * @return mixed HTTP status code such as 404 or URL for redirection
  */
 public function route_to()
 {
     Doo::loadCore('uri/DooUriRouter');
     $router = new DooUriRouter();
     $routeRs = $router->execute($this->route, Doo::conf()->SUBFOLDER);
     if ($routeRs[0] != NULL && $routeRs[1] != NULL) {
         //dispatch, call Controller class
         #echo "<h1>Dispatched!</h1>{$routeRs[0]}->{$routeRs[1]}<br>";
         require_once Doo::conf()->BASE_PATH . "controller/DooController.php";
         require_once Doo::conf()->SITE_PATH . "protected/controller/{$routeRs[0]}.php";
         if (strpos($routeRs[0], '/') !== FALSE) {
             $clsname = explode('/', $routeRs[0]);
             $routeRs[0] = $clsname[sizeof($clsname) - 1];
         }
         //if defined class name, use the class name to create the Controller object
         $clsnameDefined = sizeof($routeRs) === 4;
         if ($clsnameDefined) {
             $controller = new $routeRs[3]();
         } else {
             $controller = new $routeRs[0]();
         }
         $controller->params = $routeRs[2];
         if (isset($controller->params['__extension'])) {
             $controller->extension = $controller->params['__extension'];
             unset($controller->params['__extension']);
         }
         if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
             $controller->init_put_vars();
         }
         //before run, normally used for ACL auth
         if ($clsnameDefined) {
             if ($rs = $controller->beforeRun($routeRs[3], $routeRs[1])) {
                 return $rs;
             }
         } else {
             if ($rs = $controller->beforeRun($routeRs[0], $routeRs[1])) {
                 return $rs;
             }
         }
         return $controller->{$routeRs}[1]();
     } else {
         if (Doo::conf()->AUTOROUTE) {
             list($controller_name, $method_name, $params) = $router->auto_connect(Doo::conf()->SUBFOLDER);
             $controller_file = Doo::conf()->SITE_PATH . "protected/controller/{$controller_name}.php";
             if (file_exists($controller_file)) {
                 require_once Doo::conf()->BASE_PATH . "controller/DooController.php";
                 require_once $controller_file;
                 $controller = new $controller_name();
                 if (!$controller->autoroute) {
                     $this->throwHeader(404);
                 }
                 if ($params != NULL) {
                     $controller->params = $params;
                 }
                 if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
                     $controller->init_put_vars();
                 }
                 if (method_exists($controller, $method_name)) {
                     return $controller->{$method_name}();
                 } else {
                     $this->throwHeader(404);
                 }
             } else {
                 $this->throwHeader(404);
             }
         } else {
             $this->throwHeader(404);
         }
     }
 }
<?php

/**
* DooRbAcl class file.
*
* @author aligo <*****@*****.**>
* @link http://www.doophp.com/
* @copyright Copyright &copy; 2009 Leng Sheng Hong
* @license http://www.doophp.com/license
*
*/
Doo::loadCore('auth/DooAcl');
class DooRbAcl extends DooAcl
{
    /**
     * Check if the user Roles is allowed to access the resource or action list or both.
     *
     * <code>
     * //Check if members are allowed for BlogController->post
     * Doo::acl()->isAllowed(array('member','admin'), 'BlogController', 'post' );
     *
     * //Check if members are allowed for BlogController
     * Doo::acl()->isAllowed(array('anonymous','member'), 'BlogController');
     * </code>
     *
     * @param array $role Roles of a user, usually retrieve from user's login session
     * @param string $resource Resource name (use Controller class name)
     * @param string $action Action name (use Method name)
     * @return bool
     */
    public function isAllowed($roles, $resource, $action = '')
Beispiel #9
0
 /**
  * The view singleton, auto create if the singleton has not been created yet.
  * @return DooView|DooViewBasic
  */
 public function view()
 {
     if ($this->_view == NULL) {
         $engine = Doo::conf()->TEMPLATE_ENGINE;
         Doo::loadCore('view/' . $engine);
         $this->_view = new $engine();
     }
     return $this->_view;
 }
Beispiel #10
0
 *                   );
 * </code>
 *
 * <p>In the bootstrap index.php you would need to call the <b>useDbReplicate</b> method.</p>
 * <code>
 * Doo::useDbReplicate();
 * Doo::db()->setMap($dbmap);
 * Doo::db()->setDb($dbconfig, $config['APP_MODE']);
 * </code>
 *
 * @author Leng Sheng Hong <*****@*****.**>
 * @version $Id: DooMasterSlave.php 1000 2009-08-20 22:53:26
 * @package doo.db
 * @since 1.1
 */
Doo::loadCore('db/DooSqlMagic');
class DooMasterSlave extends DooSqlMagic
{
    const MASTER = 'master';
    const SLAVE = 'slave';
    /**
     * Stores the pdo connection for master & slave
     * @var array
     */
    protected $pdoList = array();
    protected $autoToggle = True;
    /**
     * Connects to the database with the default slaves configurations
     */
    public function connect()
    {
Beispiel #11
0
 public function gen_model()
 {
     Doo::loadCore('db/DooModelGen');
     global $dbconfig;
     foreach ($dbconfig as $key => $value) {
         $path = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . 'model/' . $key;
         if (!is_dir($path)) {
             mkdir($path);
         }
         $path .= '/';
         Doo::db()->setDb($dbconfig, $key);
         Doo::db()->reconnect($key);
         DooModelGen::genMySQL($comments = true, $vrules = true, $extends = 'DooModel', $createBase = true, $baseSuffix = 'Base', $useAutoload = false, $chmod = null, $path, $dbname = ucfirst($key));
         //exit;
     }
 }
 /**
  * The view singleton, auto create if the singleton has not been created yet.
  * @return DooView
  */
 public function view()
 {
     if ($this->_view == NULL) {
         Doo::loadCore('view/DooView');
         $this->_view = new DooView();
     }
     return $this->_view;
 }
/**
 * DooCliController class file.
 *
 * @author Richard Myers <*****@*****.**>
 * @link http://www.doophp.com/
 * @copyright Copyright &copy; 2011 Leng Sheng Hong
 * @license http://www.doophp.com/license
 */
/**
 * DooCliController is the controller for CLI application should be use with Doo::app('DooCliApp')->run();
 * @author Richard Myers <*****@*****.**>
 * @package doo.controller
 * @since 1.4 
 */
Doo::loadCore('app/DooCliApp');
class DooCliController
{
    const STREAM_STD_IN = "STD_IN";
    const STREAM_STD_OUT = "STD_OUT";
    /**
     * Arguments from the comment line
     */
    public $arguments = array();
    /**
     * Display a title in the consol
     * @param string $title The title to be displayed
     * @param bool $clearScreen Should the screen be cleared (so title sits at top of title)
     * @param int $width Title will be positioned in the middle of this width
     */
    protected function displayTitle($title, $clearScreen = true, $width = 80, $char = '=')
Beispiel #14
0
 /**
  * Handles the routing process.
  * Auto routing, sub folder, subdomain, sub folder on subdomain are supported.
  * It can be used with or without the <i>index.php</i> in the URI
  * @return mixed HTTP status code such as 404 or URL for redirection
  */
 public function routeTo()
 {
     Doo::loadCore('uri/DooUriRouter');
     $router = new DooUriRouter();
     $routeRs = $router->execute($this->route, Doo::conf()->SUBFOLDER);
     if ($routeRs[0] !== null && $routeRs[1] !== null) {
         //dispatch, call Controller class
         require_once Doo::conf()->BASE_PATH . "controller/DooController.php";
         if ($routeRs[0][0] !== '[') {
             if (strpos($routeRs[0], '\\') !== false) {
                 $nsClassFile = str_replace('\\', '/', $routeRs[0]);
                 $nsClassFile = explode(Doo::conf()->APP_NAMESPACE_ID . '/', $nsClassFile, 2);
                 $nsClassFile = $nsClassFile[1];
                 require_once Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . $nsClassFile . '.php';
             } else {
                 // by Lua
                 $_File = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . "controller/{$routeRs[0]}.php";
                 if (file_exists($_File)) {
                     require_once $_File;
                 } else {
                     require_once LUA_ROOT . ADMIN_ROOT . "/controller/{$routeRs[0]}.php";
                 }
             }
         } else {
             $moduleParts = explode(']', $routeRs[0]);
             $moduleName = substr($moduleParts[0], 1);
             if (isset(Doo::conf()->PROTECTED_FOLDER_ORI) === true) {
                 require_once Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER_ORI . 'module/' . $moduleName . '/controller/' . $moduleParts[1] . '.php';
             } else {
                 require_once Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . 'module/' . $moduleName . '/controller/' . $moduleParts[1] . '.php';
                 Doo::conf()->PROTECTED_FOLDER_ORI = Doo::conf()->PROTECTED_FOLDER;
             }
             //set class name
             $routeRs[0] = $moduleParts[1];
             Doo::conf()->PROTECTED_FOLDER = Doo::conf()->PROTECTED_FOLDER_ORI . 'module/' . $moduleName . '/';
         }
         if (strpos($routeRs[0], '/') !== false) {
             $clsname = explode('/', $routeRs[0]);
             $routeRs[0] = $clsname[sizeof($clsname) - 1];
         }
         //if defined class name, use the class name to create the Controller object
         $clsnameDefined = sizeof($routeRs) === 4;
         if ($clsnameDefined) {
             $controller = new $routeRs[3]();
         } else {
             $controller = new $routeRs[0]();
         }
         $controller->params = $routeRs[2];
         if (isset($controller->params['__extension']) === true) {
             $controller->extension = $controller->params['__extension'];
             unset($controller->params['__extension']);
         }
         if (isset($controller->params['__routematch']) === true) {
             $controller->routematch = $controller->params['__routematch'];
             unset($controller->params['__routematch']);
         }
         if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
             $controller->init_put_vars();
         }
         //before run, normally used for ACL auth
         if ($clsnameDefined) {
             if ($rs = $controller->beforeRun($routeRs[3], $routeRs[1])) {
                 return $rs;
             }
         } else {
             if ($rs = $controller->beforeRun($routeRs[0], $routeRs[1])) {
                 return $rs;
             }
         }
         $routeRs = $controller->{$routeRs}[1]();
         $controller->afterRun($routeRs);
         return $routeRs;
     } else {
         if (Doo::conf()->AUTOROUTE) {
             list($controller_name, $method_name, $method_name_ori, $params, $moduleName) = $router->auto_connect(Doo::conf()->SUBFOLDER, isset($this->route['autoroute_alias']) === true ? $this->route['autoroute_alias'] : null);
             if (empty($this->route['autoroute_force_dash']) === false) {
                 if ($method_name !== 'index' && $method_name === $method_name_ori && ctype_lower($method_name_ori) === false) {
                     $this->throwHeader(404);
                     return;
                 }
             }
             if (isset($moduleName) === true) {
                 Doo::conf()->PROTECTED_FOLDER_ORI = Doo::conf()->PROTECTED_FOLDER;
                 Doo::conf()->PROTECTED_FOLDER = Doo::conf()->PROTECTED_FOLDER_ORI . 'module/' . $moduleName . '/';
             }
             $controller_file = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . "controller/{$controller_name}.php";
             if (file_exists($controller_file)) {
                 require_once Doo::conf()->BASE_PATH . "controller/DooController.php";
                 require_once $controller_file;
                 $methodsArray = get_class_methods($controller_name);
                 //if the method not in controller class, check for a namespaced class with the same file name.
                 if ($methodsArray === null && isset(Doo::conf()->APP_NAMESPACE_ID) === true) {
                     if (isset($moduleName) === true) {
                         $controller_name = Doo::conf()->APP_NAMESPACE_ID . '\\module\\' . $moduleName . '\\controller\\' . $controller_name;
                     } else {
                         $controller_name = Doo::conf()->APP_NAMESPACE_ID . '\\controller\\' . $controller_name;
                     }
                     $methodsArray = get_class_methods($controller_name);
                 }
                 //if method not found in both both controller and namespaced controller, 404 error
                 if ($methodsArray === null) {
                     if (isset(Doo::conf()->PROTECTED_FOLDER_ORI) === true) {
                         Doo::conf()->PROTECTED_FOLDER = Doo::conf()->PROTECTED_FOLDER_ORI;
                     }
                     $this->throwHeader(404);
                     return;
                 }
             } else {
                 if (isset($moduleName) === true && isset(Doo::conf()->APP_NAMESPACE_ID) === true) {
                     if (isset(Doo::conf()->PROTECTED_FOLDER_ORI) === true) {
                         Doo::conf()->PROTECTED_FOLDER = Doo::conf()->PROTECTED_FOLDER_ORI;
                     }
                     $controller_file = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . '/controller/' . $moduleName . '/' . $controller_name . '.php';
                     if (file_exists($controller_file) === false) {
                         $this->throwHeader(404);
                         return;
                     }
                     $controller_name = Doo::conf()->APP_NAMESPACE_ID . '\\controller\\' . $moduleName . '\\' . $controller_name;
                     #echo 'module = '.$moduleName.'<br>';
                     #echo $controller_file.'<br>';
                     #echo $controller_name.'<br>';
                     $methodsArray = get_class_methods($controller_name);
                 } else {
                     if (isset(Doo::conf()->PROTECTED_FOLDER_ORI) === true) {
                         Doo::conf()->PROTECTED_FOLDER = Doo::conf()->PROTECTED_FOLDER_ORI;
                     }
                     $this->throwHeader(404);
                     return;
                 }
             }
             //check for REST request as well, utilized method_GET(), method_PUT(), method_POST, method_DELETE()
             $restMethod = $method_name . '_' . strtolower($_SERVER['REQUEST_METHOD']);
             $inRestMethod = in_array($restMethod, $methodsArray);
             //check if method() and method_GET() etc. doesn't exist in the controller, 404 error
             if (in_array($method_name, $methodsArray) === false && $inRestMethod === false) {
                 if (isset(Doo::conf()->PROTECTED_FOLDER_ORI) === true) {
                     Doo::conf()->PROTECTED_FOLDER = Doo::conf()->PROTECTED_FOLDER_ORI;
                 }
                 $this->throwHeader(404);
                 return;
             }
             //use method_GET() etc. if available
             if ($inRestMethod === true) {
                 $method_name = $restMethod;
             }
             $controller = new $controller_name();
             //if autoroute in this controller is disabled, 404 error
             if ($controller->autoroute === false) {
                 if (isset(Doo::conf()->PROTECTED_FOLDER_ORI) === true) {
                     Doo::conf()->PROTECTED_FOLDER = Doo::conf()->PROTECTED_FOLDER_ORI;
                 }
                 $this->throwHeader(404);
             }
             if ($params != null) {
                 $controller->params = $params;
             }
             if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
                 $controller->initPutVars();
             }
             //before run, normally used for ACL auth
             if ($rs = $controller->beforeRun($controller_name, $method_name)) {
                 return $rs;
             }
             $routeRs = $controller->{$method_name}();
             $controller->afterRun($routeRs);
             return $routeRs;
         } else {
             $this->throwHeader(404);
         }
     }
 }
Beispiel #15
0
 /**
  * 供子类使用执行mysql
  * @var array
  */
 protected function ProcessExecute($procedure, &$param = array())
 {
     $output = array();
     // 插入、变更数据必须进入下面的流程
     if (!empty($param) && $this->cacheStrict) {
         $res = self::get($this->_dbNameKey)->execute($procedure, $param, $this->_dimension, $this->_type);
         foreach ($this->_cacheProcedureList as $key => $val) {
             $vals = explode(',', $val);
             if (in_array($procedure, $vals)) {
                 Doo::loadCore('cache/DooPhpCache');
                 $cacheObj = new DooPhpCache($this->_dbNameKey);
                 // 删除缓存数据
                 $cacheObj->del($cacheKey, $res);
             }
         }
     } else {
         if (isset($this->_cacheProcedureList[$procedure])) {
             Doo::loadCore('cache/DooPhpCache');
             $cacheObj = new DooPhpCache($this->_dbNameKey);
             $cacheKey = empty($param) ? $procedure : $procedure . '_' . md5(var_export($param, true));
             $res = $cacheObj->get($cacheKey);
             if (empty($res)) {
                 $res = self::get($this->_dbNameKey)->execute($procedure, $param, $this->_dimension, $this->_type);
                 if (!empty($res)) {
                     // 写入缓存数据
                     $cacheObj->set($cacheKey, $res);
                 }
             }
         } else {
             $res = self::get($this->_dbNameKey)->execute($procedure, $param, $this->_dimension, $this->_type);
         }
     }
     // // 固定返回结果格式
     // if($this->_success) {
     // 	return array('success'=>$this->_success,'errors'=>$res);
     // } else {
     // 	return array('success'=>$this->_success,'errors'=>$this->_errors);
     // }
     $this->_dimension = 2;
     $this->_type = 1;
     return $res;
 }
Beispiel #16
0
 public function admin()
 {
     $users['admin'] = '1234';
     $users['doophp'] = '1234';
     $users['demo'] = 'demo';
     Doo::loadCore('auth/DooDigestAuth');
     $username = DooDigestAuth::http_auth('Food Api Admin', $users, 'Failed to login!');
     echo 'You are login now. Welcome, ' . $username;
 }
 /**
  * short hand of Doo::loadCore()
  * @param string $class_name
  */
 public function core($class_name)
 {
     Doo::loadCore($class_name);
 }
 *     public function run(){
 *         $this->executeTest();
 *         $this->showResult();
 *         $this->saveResult();
 *     }    
 * }
 * </code>
 *
 * @author Leng Sheng Hong <*****@*****.**>
 * @package doo.controller
 * @since 1.5
 */
Doo::loadCore('helper/DooFile');
Doo::loadCore('controller/DooController');
Doo::loadCore('ext/ArrBDD/ArrBDD');
Doo::loadCore('ext/ArrBDD/ArrBDDSpec');
class DooBDDController extends DooController
{
    /**
     * Result array
     * @var array
     */
    protected $result;
    /**
     * BDD instance
     * @var ArrBDD
     */
    protected $bdd;
    /**
     * To include subject in result, set to True.
     * @var bool
Beispiel #19
0
<?php

Doo::loadCore('db/DooModel');
class CtRespuestaBase extends DooModel
{
    /**
     * @var int Max length is 10.  unsigned.
     */
    public $id_respuesta;
    /**
     * @var int Max length is 10.  unsigned.
     */
    public $id_pregunta;
    /**
     * @var varchar Max length is 100.
     */
    public $respuesta;
    public $_table = 'ct_respuesta';
    public $_primarykey = 'id_respuesta';
    public $_fields = array('id_respuesta', 'id_pregunta', 'respuesta');
    public function getVRules()
    {
        return array('id_respuesta' => array(array('integer'), array('min', 0), array('maxlength', 10), array('optional')), 'id_pregunta' => array(array('integer'), array('min', 0), array('maxlength', 10), array('notnull')), 'respuesta' => array(array('maxlength', 100), array('notnull')));
    }
}
Beispiel #20
0
 /**
  * Main function to be called in order to parse the requested URI.
  *
  * <p>The returned parameter list can be accessed as an assoc array.</p>
  *
  * <code>
  * #Defined in routes.conf.php
  * $route['*']['/news/:year/:month'] = array('NewsController', 'show_news_by_year'
  * </code>
  *
  * @param array $routeArr Routes defined in <i>routes.conf.php</i>
  * @param string $subfolder Relative path of the sub directory where the app is located. eg. http://localhost/doophp, the value should be '/doophp/'
  * @return array returns an array consist of the Controller class, action method and parameters of the route
  */
 public function execute($routeArr, $subfolder = '/')
 {
     list($route, $params) = $this->connect($routeArr, $subfolder);
     if ($route[0] === 'redirect') {
         if (sizeof($route) === 2) {
             return array('redirect' => array($route[1], 302));
         } else {
             return array('redirect' => array($route[1], $route[2]));
         }
     }
     if (isset($route['auth']) === true) {
         $route['authFailURL'] = !isset($route['authFailURL']) ? null : $route['authFailURL'];
         $route['authFail'] = !isset($route['authFail']) ? null : $route['authFail'];
         Doo::loadCore('auth/DooDigestAuth');
         DooDigestAuth::http_auth($route['authName'], $route['auth'], $route['authFail'], $route['authFailURL']);
     }
     if (isset($route['params']) === true) {
         $params = array_merge((array) $params, $route['params']);
     }
     if (isset($route['className']) === true) {
         return array($route[0], $route[1], $params, $route['className']);
     }
     //return Controller class, method, parameters of the route
     return array($route[0], $route[1], $params);
 }
 public function gen_models()
 {
     Doo::loadCore('db/DooModelGen');
     DooModelGen::genMySQL();
 }
 *
 * If you have multiple servers for memcache, you would have to set it up in common.conf.php
 * <code>
 * // host, port, persistent, weight
 * $config['MEMCACHE'] = array(
 *                       array('192.168.1.31', '11211', true, 40),
 *                       array('192.168.1.23', '11211', true, 80)
 *                     );
 * </code>
 *
 * @author Leng Sheng Hong <*****@*****.**>
 * @version $Id: DooMemCache.php 1000 2009-08-22 19:36:10
 * @package doo.cache
 * @since 1.1
 */
Doo::loadCore('cache/DooCache');
class DooMemCache extends DooCache
{
    /**
     * Memcached connection
     * @var Memcache
     */
    protected $_memcache;
    /**
     * Configurations of the connections
     * @var array
     */
    protected $_config;
    public function __construct($conf = Null)
    {
        $this->_memcache = new Memcache();