function run() { header("Content-type: text/html; charset=UTF-8"); @($referer = strtolower($_SERVER['HTTP_REFERER'])); $tmp = explode('?', $referer); $referer = $tmp[0]; $cache_path = KISS_Framework_Config::getSystemPath("temp"); if (file_exists($cache_path) && is_writable($cache_path)) { $this->js_cache_file = $cache_path . '/js.list.' . md5($referer); $this->js_cache_file_content = $cache_path . '/js.content.' . md5($referer) . ".js"; } if (!is_null($this->js_cache_file)) { if (file_exists($this->js_cache_file)) { $this->load_array = unserialize(file_get_contents($this->js_cache_file)); } $pack = self::getPackFileName($_GET["jspack"]); //$pack = $_GET["jspack"]; if (in_array($pack, $this->load_array)) { echo file_get_contents($this->js_cache_file_content); } else { $this->load_array[] = $pack; $this->new_class_found = true; echo self::getFileContents($pack); } } }
/** * 取得当前应用的唯一标示串 * * @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; } }
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; }
/** * 构造函数 * */ 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(); }
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 '失败!'; } }
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")); } } } }
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>'; }
/** * 删除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); } } }
/** * 取得缓存文件名 * * @return string */ private function _getCacheFileName() { //var_dump(KISS_Framework_Config::getSystemPath('temp') ); //exit(); return KISS_Framework_Config::getSystemPath('temp') . "/cache/kiss_cache_" . $this->_mCacheKey; }
/** * 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; } }
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'); }
/** * 检查用户访问类是否存在 * * @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("/"); }
/** * 程序初始化,检测模板和配置文件 * * @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); } }
public static function init($pConfigFile = null, $pRootPath = null) { if (isset($_COOKIE['kiss_debug']) && 1 == $_COOKIE['kiss_debug']) { self::$_mode = "debug"; } if (is_null($pConfigFile)) { $pConfigFile = realpath(dirname($_SERVER['SCRIPT_FILENAME']) . '/config.xml'); } if (is_null($pRootPath)) { $pRootPath = realpath(dirname($_SERVER['SCRIPT_FILENAME'])); } $registry =& KISS_Framework_Registry::instance(); if (file_exists(dirname(__FILE__) . "/config.xml")) { $default_config = simplexml_load_file(dirname(__FILE__) . "/config.xml"); $registry->setEntry('default', $default_config); } $registry->setEntry('root_path', $pRootPath); if (!empty($pConfigFile)) { if (!file_exists($pConfigFile)) { die('没有找到配置文件:' . $pConfigFile); } $user_config = simplexml_load_file($pConfigFile); foreach ($user_config->attributes() as $key => $value) { if (property_exists('KISS_Application', $key)) { KISS_Application::${$key} = $value; } } $registry->setEntry('user_defined', $user_config); $db_configs = array(); $db_count = 0; foreach ($user_config->databases->database as $database) { $db_configs[$db_count] = array('DatabaseType' => (string) $database['type'], 'DatabaseHost' => (string) $database['host'], 'DatabaseUsername' => (string) $database['username'], 'DatabasePassword' => (string) $database['password'], 'DatabaseName' => (string) $database['database'], 'DatabasePort' => (int) $database['port']); if (isset($database['name'])) { $db_configs[$db_count]['name'] = (string) $database['name']; $db_configs[(string) $database['name']] =& $db_configs[$db_count]; } $db_count++; } $registry->setEntry('database_connections', $db_configs); } KISS::addIncludePath(self::getSystemPath('class')); $key = APP_NAME . 'config_ini_array'; if (KISS::enableCache() && apc_exists($key)) { self::$_config_ini_array = apc_fetch($key); } else { $config_ini = self::getSystemPath('root') . '/config.ini'; if (file_exists($config_ini)) { self::$_config_ini_array = parse_ini_file($config_ini, true); if (KISS::enableCache()) { apc_store($key, self::$_config_ini_array); } } } $annotation_file = realpath(KISS_Framework_Config::getSystemPath('root') . '/annotation.serialize'); if (file_exists($annotation_file)) { self::$annotation = unserialize(file_get_contents($annotation_file)); } }