示例#1
0
 /**
  * 实现Session接口
  *
  * @return bool
  */
 function open()
 {
     $memcache = KISS_Framework_Config::getValue('/application/memcache');
     if (!isset($memcache['host']) || !isset($memcache['port'])) {
         die('没有配置 memcache 参数!');
     }
     self::$memcache_obj = new Memcache();
     return self::$memcache_obj->connect($memcache['host'], $memcache['port']);
 }
示例#2
0
 /**
  * 取得当前应用的唯一标示串
  *
  * @return string
  */
 public static function getUniqueAppName()
 {
     if ('' == self::$appName) {
         $root_path = KISS_Framework_Config::getSystemPath('root');
         return 'A' . strtoupper(substr(md5($root_path), 0, 7));
     } else {
         return self::$appName;
     }
 }
示例#3
0
 public static function getUniqueAppName()
 {
     if (xcache_isset('app_name')) {
         return xcache_get('app_name');
     }
     $app_name = 'A' . strtoupper(substr(md5(KISS_Framework_Config::getSystemPath('root')), 0, 7));
     if (!xcache_set('app_name', $app_name)) {
     }
     return $app_name;
 }
示例#4
0
 /**
  * 构造函数
  *
  */
 function __construct()
 {
     if ('cli' == php_sapi_name()) {
         $this->_innerController = new KISS_Controller_Cli();
     } else {
         $application = KISS_Framework_Config::getValue('//application');
         session_name(strtoupper(substr(MD5(KISS_Framework_Config::getSystemPath('root')), 0, 8)));
         if (isset($application['session'])) {
             switch ($application['session']) {
                 case 'disable':
                     break;
                 case 'memcache':
                     $memcache = KISS_Framework_Config::getValue('/application/memcache');
                     if (!isset($memcache['host']) || !isset($memcache['port'])) {
                         die('没有配置 memcache 参数!');
                     }
                     session_save_path("tcp://{$memcache['host']}:{$memcache['port']}?persistent=1&weight=1&timeout=1&retry_interval=5");
                     session_module_name('memcache');
                     KISS_Application::sessionStart();
                     break;
                 case 'redis':
                     $server = KISS_Framework_Config::getValue('/application/session_redis');
                     if (!isset($server['host']) || !isset($server['port'])) {
                         die('没有配置 memcache 参数!');
                     }
                     session_save_path("tcp://{$server['host']}:{$server['port']}?persistent=1&weight=1&timeout=1&database={$server['database']}");
                     session_module_name('redis');
                     KISS_Application::sessionStart();
                     break;
                 default:
                     KISS_Application::sessionStart();
                     break;
             }
         } else {
             KISS_Application::sessionStart();
         }
         if (isset($_SERVER['HTTP_KISS_RPC']) && in_array($_SERVER['HTTP_KISS_RPC'], array('JSON')) && class_exists('KISS_Controller_' . $_SERVER['HTTP_KISS_RPC'])) {
             $Controller = 'KISS_Controller_' . $_SERVER['HTTP_KISS_RPC'];
         }
         if (strpos($_SERVER['PHP_SELF'], '/WEB-INF/') !== false) {
             $_SERVER['PHP_SELF'] = $_SERVER['DOCUMENT_URI'];
         }
         preg_match("/^(_([^_]+)_){0,1}([^\\/]*?)(\\.|\$)/i", basename($_SERVER['PHP_SELF']), $matches);
         if (!isset($Controller)) {
             $Controller = "KISS_Controller_{$matches[2]}";
         }
         if ($Controller == 'KISS_Controller_' || !class_exists($Controller)) {
             $Controller = "KISS_Controller_Brower";
         }
         $class_name = implode('_', array_map('ucfirst', explode('_', $matches[3])));
         $this->_innerController = new $Controller($class_name);
     }
     $this->_innerController->run();
 }
示例#5
0
 function run()
 {
     $cache_file = KISS_Framework_Config::getSystemPath('root') . '/annotation.serialize';
     @unlink($cache_file);
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(KISS_Framework_Config::getSystemPath('class'))) as $file) {
         $filename = $file->getPathname();
         if (substr($filename, -4) == '.php') {
             new KISS_Parse(realpath($file->getPathname()));
         }
     }
     file_put_contents($cache_file, serialize(KISS_Framework_Config::$annotation));
     if (file_exists($cache_file)) {
         echo '成功!';
     } else {
         echo '失败!';
     }
 }
示例#6
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"));
             }
         }
     }
 }
示例#7
0
文件: JS.php 项目: iwater/kissphp
 private static function getFileContents($pPackName)
 {
     //CClass_Tools_Util::writeLog(time()."js.log", $pPackName."  load");
     $package_file_name = $pPackName . ".js";
     $js_lib = array();
     $js_lib[] = dirname(KISS_Framework_Config::getRootPath()) . "/scripts";
     $js_lib[] = dirname(dirname(dirname(__FILE__))) . '/NonPHP/kiss/libs';
     $config_dir = KISS_Framework_Config::getParam("jslib");
     if ($config_dir != "") {
         $tmp = explode(";", $config_dir);
         $js_lib = array_merge($js_lib, $tmp);
     }
     foreach ($js_lib as $lib) {
         $file_name = $lib . "/" . $package_file_name;
         if (file_exists($file_name)) {
             //CClass_Tools_Util::writeLog("js.log", $file_name);
             $content = file_get_contents($file_name);
             $pattern = "#^\\s*import\\s+([a-zA-Z_0-9]+);\\s*\$#ms";
             if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) {
                 $result = print_r($matches, true);
                 //CClass_Tools_Util::writeLog("js.log", $result);
                 foreach ($matches as $match) {
                     //CClass_Tools_Util::writeLog("{$match[1]}.log", self::getFileContents( self::getPackFileName($match[1]) ));
                     $content = str_replace($match[0], self::getFileContents(self::getPackFileName($match[1])), $content);
                     //CClass_Tools_Util::writeLog("tmp2.log", $match[0]);
                     //break;
                 }
             }
             $content = self::zipJs($content);
             //
             $content .= sprintf("\n_kiss_js._load_pack_push('%s');\n", str_replace('/', '_', $pPackName));
             //    echo sprintf("\n_kiss_js._load_pack.push('%s');\n", str_replace('/','_',$pPackName));;
             //CClass_Tools_Util::writeLog("tmp444.log", $content);
             return self::str2utf8($content);
         }
     }
     //CClass_Tools_Util::writeLog("js.log", $pPackName." not founded!");
     return "";
 }
示例#8
0
 /**
  * 执行SQL查询
  *
  * @param string $pQuery
  * @return mix
  */
 function ExecuteQuery($pQuery)
 {
     $this->connectDB();
     if (KISS_Framework_Config::getMode() == 'debug') {
         KISS_Util_Debug::setDebugInfo(array($this->UniqueObjectID, get_class($this), 'SQLQuery', $pQuery));
     }
     return $this->db_query($pQuery);
 }
示例#9
0
文件: SVN.php 项目: iwater/kissphp
 function _bytes()
 {
     $config = @parse_ini_file('config.ini', true);
     $class_code_path = dirname(KISS_Framework_Config::getSystemPath('class'));
     $command = "cd {$class_code_path};find . -name \\*.php|xargs ls -l|awk '{print \$5,\$NF}'|sort -n";
     echo '<pre>' . `{$command}` . '</pre>';
 }
示例#10
0
文件: Cache.php 项目: iwater/kissphp
 /**
  * 删除SQL结果缓存
  *
  * @param string $pSql SQL
  *
  * @return void
  */
 function removeSqlCache($pSql)
 {
     $files = glob(KISS_Framework_Config::getSystemPath('temp') . "/cache/cache." . md5($pSql) . ".*.serialize");
     if (is_array($files) && count($files) > 0) {
         foreach ($files as $filename) {
             unlink($filename);
         }
     }
 }
示例#11
0
 /**
  * 取得缓存文件名
  *
  * @return string
  */
 private function _getCacheFileName()
 {
     //var_dump(KISS_Framework_Config::getSystemPath('temp') );
     //exit();
     return KISS_Framework_Config::getSystemPath('temp') . "/cache/kiss_cache_" . $this->_mCacheKey;
 }
示例#12
0
文件: Page.php 项目: iwater/kissphp
 /**
  * Smarty 初始化
  *
  * @return void
  */
 private function _initSmarty()
 {
     if (is_null($this->mSmarty)) {
         $template_path = KISS_Framework_Config::getSystemPath('template');
         $template_c_path = KISS_Framework_Config::getSystemPath('temp') . '/template_c';
         $this->mSmarty = new Smarty();
         $this->mSmarty->template_dir = $template_path;
         $this->mSmarty->compile_dir = $template_c_path;
         $this->mSmarty->config_dir = $template_c_path;
         $this->mSmarty->cache_dir = $template_c_path;
     }
 }
示例#13
0
 /**
  *
  * @access public
  */
 function _count($pSmartCode = 1, $pColumns = '*', $pGroupBy = '')
 {
     $this->generateSql('', $pSmartCode, $pColumns, $pGroupBy);
     if (KISS_Framework_Config::isCached()) {
         $return = $this->SqlCommand->ExecuteCacheArrayQuery($this->mLastCountSQLQuery, 0, 10, 'num', array($this->mTableHash['name']));
     } else {
         $return = $this->SqlCommand->ExecuteArrayQuery($this->mLastCountSQLQuery, 0, 10, 'num');
     }
     return $return[0][0];
 }
示例#14
0
文件: Clean.php 项目: iwater/kissphp
 function run()
 {
     $this->clear_xcache();
     $this->clear_cache_file(sys_get_temp_dir());
     $this->clear_cache_file(KISS_Framework_Config::getSystemPath('temp') . DIRECTORY_SEPARATOR . 'cache');
 }
示例#15
0
文件: Config.php 项目: iwater/kissphp
 static function setMode($pMode)
 {
     self::$_mode = $pMode;
 }
示例#16
0
文件: KISS.php 项目: iwater/kissphp
 /**
  * 析构函数
  *
  */
 public function __destruct()
 {
     if (self::$_new_class_found && !is_null($this->_auto_load_cache_file) && KISS_Framework_Config::getMode() == "online") {
         file_put_contents($this->_auto_load_cache_file, serialize(self::$_load_array));
     }
 }
示例#17
0
文件: Brower.php 项目: iwater/kissphp
 /**
  * 检查用户访问类是否存在
  *
  * @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("/");
 }
示例#18
0
 /**
  * 程序初始化,检测模板和配置文件
  *
  * @return void
  */
 private function _appInit()
 {
     $this->generateTemplate();
     if (!file_exists(KISS_Framework_Config::getSystemPath('template') . "/{$this->mTemplateFile}")) {
         $config_file = KISS_Framework_Config::getSystemPath('temp') . "/config/{$this->mDBConfig}_{$this->mTableName}.serialize";
         if (!file_exists($config_file)) {
             /*foreach ($this->mMappingTableObject as $key => $value) {
               $config[] = array (    'name' => $key, 'comment' => $key, 'type' => 'text', 'insert' => '1', 'update' => '1', 'select' => '1', 'list' => '1', 'search' => '1');
               }*/
             $SqlCommand =& KISS_KDO_SqlCommand::getInstance($this->mDBConfig);
             $fields = $SqlCommand->ExecuteArrayQuery("show full fields from `{$this->mTableName}`");
             foreach ($fields as $row) {
                 $config[] = array('name' => $row['Field'], 'comment' => $row['Comment'], 'type' => 'text', 'insert' => '1', 'update' => '1', 'select' => '1', 'list' => '1', 'search' => '1');
             }
             file_put_contents($config_file, serialize($config));
         }
         $table_config = unserialize(file_get_contents($config_file));
         $template_c_path = KISS_Framework_Config::getSystemPath('temp') . '/template_c';
         $smarty = new Smarty();
         $smarty->template_dir = dirname(dirname(__FILE__)) . '/Tools/Builder/template/';
         $smarty->compile_dir = $template_c_path;
         $smarty->config_dir = $template_c_path;
         $smarty->cache_dir = $template_c_path;
         foreach ($table_config as $config) {
             $config['file'] = "base/tpl.input.{$config['type']}.{$this->mAction}.htm";
             if (!file_exists(KISS_Framework_Config::getSystemPath('template') . "/{$config['file']}")) {
                 $config['file'] = "base/tpl.input.{$config['type']}.htm";
             }
             $table_configs[] = $config;
         }
         $smarty->assign('action_template', "base/tpl.base_{$this->mAction}.htm");
         $smarty->assign('config', $table_configs);
         $smarty->assign("_action", $this->mAction);
         $smarty->assign("_table", $this->mTableName);
         $smarty->assign('key', $this->mMappingTableObject->mTableHash['key']);
         $output = $smarty->fetch("base/tpl.BaseTableAdmin.htm");
         file_put_contents(KISS_Framework_Config::getSystemPath('template') . "/{$this->mTemplateFile}", $output);
     }
 }
示例#19
0
文件: Debug.php 项目: iwater/kissphp
 public function disableDebugInfoOutput()
 {
     KISS_Framework_Config::setMode('online');
 }