function __construct() { if (!kernel::is_online()) { die('error'); } cacheobject::init(); self::$is_start = true; }
function __construct() { if (!kernel::is_online()) { die('error'); } else { @(include APP_DIR . '/base/defined.php'); } cachemgr::init(); cacheobject::init(); self::$is_start = true; }
function __construct() { if (!kernel::is_online()) { die('error'); } else { require ROOT_DIR . '/config/config.php'; @(include APP_DIR . '/base/defined.php'); } cachemgr::init(); cacheobject::init(); }
function __construct() { if (!kernel::is_online()) { die('error'); } else { @(include APP_DIR . '/base/defined.php'); } cachemgr::init(); cacheobject::init(); self::$is_start = true; //@file_put_contents(ROOT_DIR.'/api_post_log.txt', json_encode($_POST)); }
public function process($path) { if (!kernel::is_online()) { die('error'); } else { require ROOT_DIR . '/config/config.php'; @(include APP_DIR . '/base/defined.php'); } if ($path == '/api') { $this->process_rpc(); } else { $args = explode('/', substr($path, 5)); $service_name = 'api.' . array_shift($args); $method = array_shift($args); foreach ($args as $i => $v) { if ($i % 2) { $params[$k] = str_replace('%2F', '/', $v); } else { $k = $v; } } kernel::service($service_name)->{$method}($params); } }
public function has_conflict_apps($apps, &$conflict_apps) { if (!kernel::is_online()) { return false; } if (is_string($apps)) { $apps = array($apps); } $queue = array(); $installed_queue = array(); $install_apps = array(); $installed_apps = array(); foreach ($apps as $app_id) { $install_apps[$app_id] = array(); $this->check_conflicts_install($app_id, $queue); } $rows = kernel::database()->select('select app_id from sdb_base_apps where status != "uninstalled"'); foreach ($rows as $row) { $installed_apps[$row['app_id']] = array(); $this->check_conflicts_install($row['app_id'], $installed_queue); } $conflict_one = array_intersect_key($queue, $installed_apps); $conflict_two = array_intersect_key($installed_queue, $install_apps); $conflict_apps = array_merge($conflict_one, $conflict_two); return count($conflict_apps) ? true : false; }
function input_element($type, $params = false) { if (!base_component_ui::$inputer) { if (kernel::is_online()) { base_component_ui::$inputer = kernel::servicelist('html_input'); } else { base_component_ui::$inputer = array('base_view_input' => new base_view_input()); } } if ($params === false) { foreach (base_component_ui::$inputer as $inputer) { $inputer->app = $this->app; if (method_exists($inputer, 'input_' . $type)) { return true; } } } else { foreach (base_component_ui::$inputer as $inputer) { $inputer->app = $this->app; if (method_exists($inputer, 'input_' . $type)) { $html = $inputer->{'input_' . $type}($params); } } return $html; } return false; }
function &load($check_lastmodified = true) { $real_table_name = $this->real_table_name(); if ($this->_define[$real_table_name]) { return $this->_define[$real_table_name]; } if (kernel::is_online() && !($this->target_app->app_id == 'base' && $this->key() == 'kvstore')) { if (defined('CUSTOM_CORE_DIR') && file_exists(CUSTOM_CORE_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php')) { $define_lastmodified = $check_lastmodified ? filemtime(CUSTOM_CORE_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php') : null; } else { $define_lastmodified = $check_lastmodified ? filemtime($this->target_app->app_dir . '/dbschema/' . $this->key . '.php') : null; } $define_flag = base_kvstore::instance('tbdefine')->fetch($this->target_app->app_id . $this->key, $define, $define_lastmodified); } else { $define_flag = false; } if ($define_flag === false) { if (defined('CUSTOM_CORE_DIR') && file_exists(CUSTOM_CORE_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php')) { require CUSTOM_CORE_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php'; } else { require $this->target_app->app_dir . '/dbschema/' . $this->key . '.php'; } $define =& $db[$this->key()]; $this->_define[$real_table_name] =& $define; foreach ($define['columns'] as $k => $v) { if ($v['pkey']) { $define['idColumn'][$k] = $k; } if ($v['is_title']) { $define['textColumn'][$k] = $k; } if ($v['in_list']) { $define['in_list'][] = $k; if ($v['default_in_list']) { $define['default_in_list'][] = $k; } } $define['columns'][$k] = $this->_prepare_column($k, $v); if (isset($v['pkey']) && $v['pkey']) { $define['pkeys'][$k] = $k; } } if (!$define['idColumn']) { $define['idColumn'] = key($define['columns']); } elseif (count($define['idColumn']) == 1) { $define['idColumn'] = current($define['idColumn']); } if (!$define['textColumn']) { $keys = array_keys($define['columns']); $define['textColumn'] = $keys[1]; } elseif (count($define['idColumn']) == 1) { $define['textColumn'] = current($define['textColumn']); } if (kernel::is_online() && !($this->target_app->app_id == 'base' && $this->key() == 'kvstore')) { base_kvstore::instance('tbdefine')->store($this->target_app->app_id . $this->key, $define); } } return $define; }
function status() { if (kernel::is_online()) { if ($this->app_id == 'base') { if (!kernel::database()->select('SHOW TABLES LIKE "' . kernel::database()->prefix . 'base_apps"')) { return 'uninstalled'; } } $row = @kernel::database()->selectrow('select status from sdb_base_apps where app_id="' . $this->app_id . '"'); return $row ? $row['status'] : 'uninstalled'; } else { return 'uninstalled'; } }
public function store($key, $value, $ttl = 0) { self::$__store_count++; if (!(defined('WITHOUT_KVSTORE_PERSISTENT') && constant('WITHOUT_KVSTORE_PERSISTENT')) && self::$__persistent && get_class($this->get_controller()) != 'base_kvstore_mysql' && kernel::is_online()) { $this->persistent($key, $value, $ttl); } logger::debug('kvstore:' . self::$__fetch_count . '.' . ' instance:' . $this->get_prefix() . ' store key:' . $key); return $this->get_controller()->store($key, $value, $ttl); }
public function &load($check_lastmodified = true) { $real_table_name = $this->real_table_name(); if (!static::$_define[$real_table_name]) { if (defined('CUSTOM_CORE_DIR')) { $customSchemaPath = CUSTOM_CORE_DIR . '/' . $this->target_app->app_id . '/dbschema/' . $this->key . '.php'; if (file_exists($customSchemaPath)) { $path = $customSchemaPath; } } if (!$path) { $path = $this->target_app->app_dir . '/dbschema/' . $this->key . '.php'; } $lastModified = $check_lastmodified ? filemtime($path) : null; // 当未安装时 或者 涉及到base kvstore 或者取不到数据 if (!kernel::is_online() || $this->target_app->app_id == 'base' && $this->key() == 'kvstore') { $define = $this->loadDefine($path); } else { if (!base_kvstore::instance('tbdefine')->fetch($this->target_app->app_id . $this->key, $define, $lastModified)) { $define = $this->loadDefine($path); base_kvstore::instance('tbdefine')->store($this->target_app->app_id . $this->key, $define); } } static::$_define[$real_table_name] = $define; } return static::$_define[$real_table_name]; }
public function store($key, $value, $ttl = 0) { self::$__store_count++; $persistent = config::get('kvstore.persistent', true); if ($persistent && self::$__persistent && get_class($this->get_controller()) != 'base_kvstore_mysql' && kernel::is_online()) { $this->persistent($key, $value, $ttl); } logger::debug('kvstore:' . self::$__fetch_count . '.' . ' instance:' . $this->get_prefix() . ' store key:' . $key); return $this->get_controller()->store($key, $value, $ttl); }
public function store($key, $value, $ttl = 0) { self::$__store_count++; if (!(defined('WITHOUT_KVSTORE_PERSISTENT') && constant('WITHOUT_KVSTORE_PERSISTENT')) && self::$__persistent && get_class($this->get_controller()) != 'base_kvstore_mysql' && kernel::is_online()) { $this->persistent($key, $value, $ttl); } return $this->get_controller()->store($key, $value, $ttl); }
function status() { if (kernel::is_online()) { try { $row = app::get('base')->database()->executeQuery('select status from base_apps where app_id = ?', [$this->app_id])->fetch(); return $row['status'] ? $row['status'] : 'uninstalled'; } catch (Exception $e) { return 'uninstalled'; } } else { return 'uninstalled'; } }
public function has_conflict_apps($apps, &$conflict_apps) { if (!kernel::is_online()) { return false; } if (is_string($apps)) { $apps = array($apps); } $queue = array(); $installed_queue = array(); $install_apps = array(); $installed_apps = array(); foreach ($apps as $app_id) { $install_apps[$app_id] = array(); $this->check_conflicts_install($app_id, $queue); } try { $rows = app::get('base')->database()->executeQuery('select app_id from base_apps where status <> "uninstalled"')->fetchAll(); } catch (Exception $e) { $rows = array(); } foreach ($rows as $row) { $installed_apps[$row['app_id']] = array(); $this->check_conflicts_install($row['app_id'], $installed_queue); } $conflict_one = array_intersect_key($queue, $installed_apps); $conflict_two = array_intersect_key($installed_queue, $install_apps); $conflict_apps = array_merge($conflict_one, $conflict_two); return count($conflict_apps) ? true : false; }
public function persistent($key, $value, $ttl = 0) { if (get_class($this->get_controller()) != 'base_kvstore_mysql' && kernel::is_online()) { kernel::single('base_kvstore_mysql', $this->get_prefix())->store($key, $value, $ttl); //todo: 持久化 } }
protected function _connect($host, $user, $passwd, $dbname) { if (defined('DB_PCONNECT') && constant('DB_PCONNECT')) { $lnk = mysql_pconnect($host, $user, $passwd); } else { $lnk = mysql_connect($host, $user, $passwd); } if (!$lnk && kernel::is_online()) { trigger_error(app::get('base')->_('无法连接数据库:') . mysql_error(), E_USER_ERROR); } mysql_select_db($dbname, $lnk); if (preg_match('/[0-9\\.]+/is', mysql_get_server_info($lnk), $match)) { $dbver = $match[0]; if (version_compare($dbver, '4.1.1', '<')) { define('DB_OLDVERSION', 1); $this->dbver = 3; } else { if (defined('DB_CHARSET') && constant('DB_CHARSET')) { mysql_query('SET NAMES \'' . DB_CHARSET . '\'', $lnk); } if (!version_compare($dbver, '6', '<')) { $this->dbver = 6; } } } return $lnk; }