Example #1
0
 /**
  *
  * @access private
  */
 function prepareMapHash()
 {
     $file_cache = new KISS_Util_FileCache('0' . $this->mTableHash['name']);
     if ($file_cache->checkCacheStatus()) {
         $this->mTableFieldHash = unserialize($file_cache->getCacheContent());
     } else {
         $this->mTableFieldHash = $this->SqlCommand->getTableFieldHash($this->mTableHash['name']);
         if (count($this->mTableFieldHash) > 0) {
             if (KISS_Framework_Config::getMode() == "online") {
                 //如果系统运行在online模式下,则记录缓存,默认是online模式
                 $file_cache->putCacheContent(serialize($this->mTableFieldHash));
             }
         } else {
             die('数据库访问错误!');
         }
     }
     $keys = array_keys($this->mTableFieldHash);
     for ($i = 0; $i < count($this->mTableFieldHash); $i++) {
         $member_name = "m" . KISS_Util_Util::magicName($keys[$i]);
         $this->mMapHash[$keys[$i]] =& $this->{$member_name};
     }
     $file_cache = new KISS_Util_FileCache('1' . $this->mTableHash['name']);
     if ($file_cache->checkCacheStatus()) {
         $this->mTableHash['key'] = unserialize($file_cache->getCacheContent());
     } else {
         $this->mTableHash['key'] = $this->SqlCommand->getTablePrimeKey($this->mTableHash['name']);
         if (KISS_Framework_Config::getMode() == "online") {
             //如果系统运行在online模式下,则记录缓存,默认是online模式
             $file_cache->putCacheContent(serialize($this->mTableHash['key']));
         }
     }
 }
Example #2
0
 /**
  * 构造函数
  *
  * @param string $pTableName 表名
  * @param int    $pDBConfig  数据库配置偏移量
  */
 function __construct($pTableName, $pDBConfig = 0)
 {
     parent::__construct();
     $this->mTableName = $pTableName;
     $this->mDBConfig = $pDBConfig;
     if (empty($this->mMappingTableObject) || !is_object($this->mMappingTableObject)) {
         $class_name = KISS_Util_Util::magicName($pTableName);
         if (class_exists($class_name)) {
             $this->mMappingTableObject = new KISS_ORM_BaseTableObjectProxy(new $class_name(), $this->mCurrentUser);
         } else {
             $this->mMappingTableObject = new KISS_ORM_BaseTableObjectProxy(new KISS_ORM_BaseTableObject($pTableName, $pDBConfig), $this->mCurrentUser);
         }
     }
     $this->_pageInit();
     $this->_appInit();
 }
Example #3
0
 /**
  * 构造函数
  *
  */
 public function __construct()
 {
     set_time_limit(0);
     array_shift($_SERVER['argv']);
     if (count($_SERVER['argv']) > 0) {
         $class_name = array_shift($_SERVER['argv']);
         $class_name = KISS_Util_Util::magicName($class_name, '_');
         if (class_exists($class_name)) {
             try {
                 parse_str(implode('&', $_SERVER['argv']), $parameters);
                 $_GET = $parameters;
                 $_REQUEST = $parameters;
                 $this->_instance = new $class_name($parameters);
             } catch (Exception $error) {
                 $this->showMessage($error->getMessage());
             }
         } else {
             $this->showMessage('缺少类!' . $class_name);
         }
     } else {
         $this->showMessage('缺少参数!');
     }
 }
Example #4
0
 /**
  * 设置cookie
  *
  * @param string $str 需要存储的内容
  *
  * @return void
  */
 private function _setPartCookie($str)
 {
     static $count = 0;
     $cookie_name = $this->_mCookieName . '_' . $count++;
     setcookie($cookie_name, KISS_Util_Util::encrypt($str));
 }
Example #5
0
 private function generate()
 {
     $this->config_path = $this->mRoot . $this->mPath['config'];
     $registry =& KISS_Framework_Registry::instance();
     $db_configs = $registry->getEntry('database_connections');
     for ($i = 0; $i < count($db_configs); $i++) {
         $SqlCommand =& KISS_KDO_SqlCommand::getInstance($i);
         $tables = $SqlCommand->ExecuteArrayQuery('SHOW TABLE STATUS FROM ' . $db_configs[$i]['DatabaseName'], 0, 0, 'num');
         foreach ($tables as $row) {
             if (is_array($_POST['tables']) && count($_POST['tables']) > 0 && in_array($row[0], $_POST['tables'])) {
                 print "DB_{$i}: <input type='checkbox'><a href='Admin_" . KISS_Util_Util::magicName($row[0]) . ".php' target='_blank'>{$row[0]}</a> <a href='?action=config&table={$row[0]}&config={$i}'>初始化</a><br>\n";
                 $this->mSmarty->assign('class_name', KISS_Util_Util::magicName($row[0]));
                 $this->mSmarty->assign('table_name', $row[0]);
                 $this->mSmarty->assign('db_offset', $i);
                 $this->mSmarty->assign('date', date("Y/m/d"));
                 if (!file_exists(KISS_Framework_Config::getSystemPath('class') . "/" . KISS_Util_Util::magicName($row[0]) . "2.php")) {
                     $ConfigFile = $this->config_path . "/{$i}_{$row[0]}.serialize";
                     $table_config = array();
                     $keys = array();
                     if (file_exists($ConfigFile)) {
                         $table_config = unserialize(file_get_contents($ConfigFile));
                     }
                     $SqlCommand =& KISS_KDO_SqlCommand::getInstance();
                     $results = $SqlCommand->ExecuteAssocArrayQuery("show full fields from `{$row['0']}`");
                     foreach ($results as &$field) {
                         $field['PHPType'] = $this->getPhpType($field['Type']);
                         $field['PHPMember'] = implode("", array_map('ucfirst', explode('_', $field['Field'])));
                     }
                     $this->mSmarty->assign('keys', $results);
                     if (empty($row[1])) {
                         $this->generate_file(KISS_Framework_Config::getSystemPath('class') . "/DB/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.view.mapping.htm"));
                     } else {
                         $this->generate_file(KISS_Framework_Config::getSystemPath('class') . "/DB/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.mapping.htm"));
                     }
                 }
                 $this->generate_file($this->mRoot . $this->mPath['class'] . "/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.manager.htm"));
             }
         }
     }
 }
Example #6
0
 /**
  * 检查用户访问类是否存在
  *
  * @param string $class_name 类名
  *
  * @return string
  */
 private function _checkClass($class_name)
 {
     $u_name = APP_NAME . 'class_' . $class_name;
     if (apc_exists($u_name)) {
         return apc_fetch($u_name);
     }
     $class_names = array('Page_User_' . $class_name, 'Page_' . $class_name, $class_name);
     foreach ($class_names as $class_name) {
         $interfaces = @class_implements($class_name);
         if (is_array($interfaces) && in_array('KISS_Interface_Runnable', $interfaces)) {
             apc_store($u_name, $class_name);
             return $class_name;
         }
     }
     //file_put_contents('/tmp/x.log', var_export($_SERVER, true), FILE_APPEND);
     var_dump($class_name);
     var_dump(KISS_Framework_Config::getSystemPath('root'));
     var_dump(KISS_Framework_Config::getSystemPath('class'));
     exit;
     file_put_contents(KISS_Framework_Config::getSystemPath('root') . '/error.log', "Class {$class_name} Not Found\r\n", FILE_APPEND);
     file_put_contents(KISS_Framework_Config::getSystemPath('root') . '/error.log', "SERVER:{$_SERVER['REQUEST_URI']}\r\n", FILE_APPEND);
     KISS_Util_Util::directGoToUrl("/");
 }