public function install() { //ini_set('display_errors', 'On'); $name = self::trimSpace($_POST['name']); $pwd = self::trimSpace($_POST['pwd']); $file = self::trimSpace($_POST['file']); $dbuname = self::trimSpace($_POST['dbuname']); $dbpwd = self::trimSpace($_POST['dbpwd']); $dbname = self::trimSpace($_POST['dbname']); $host = self::trimSpace($_POST['host']); $port = $_POST['port'] ? (int) $_POST['port'] : 3306; if (!$name || !$pwd || !$file || !$dbuname || !$dbname || !$host) { return Response::json(FAIL, array('数据不能为空')); } $res = mkdir($file, 0777, true); if (!$res && !file_exists($file)) { return Response::json(FAIL, array('文件存储目录创建失败,请检查对应目录是否有写权限后重试')); } $mysqlConf = array(); $mysqlConf['slave'][0]['user'] = $mysqlConf['master']['user'] = $dbuname; $mysqlConf['slave'][0]['pwd'] = $mysqlConf['master']['pwd'] = $dbpwd; $mysqlConf['slave'][0]['host'] = $mysqlConf['master']['host'] = $host; $mysqlConf['slave'][0]['port'] = $mysqlConf['master']['port'] = $port; $mysqlConf['slave'][0]['dbname'] = $mysqlConf['master']['dbname'] = $dbname; if (!file_exists(CONFIG_PATH . 'mysql.php')) { $int = file_put_contents(CONFIG_PATH . 'mysql.php', '<?php return ' . var_export($mysqlConf, true) . '; ?>'); if (!$int) { return Response::json(FAIL, array('conf目录文件写入失败,请检查是否有写权限')); } } $cres = $this->check(); $check = json_decode($cres, true); if ($check['code'] != 1) { return $cres; } $this->executeSql(SQL_PATH . 'opendisk.sql'); $ures = Factory::getInstance('user')->regist($name, $pwd, 1); if ($ures <= 0) { return Response::json(FAIL, array('管理员账号创建失败,请重新安装')); } $handle = fopen(CONFIG_PATH . 'install.lock', 'w'); fclose($handle); $_SESSION['CLOUD_UID'] = $ures; setcookie('CLOUD_UID', $ures, time() + 3600 * 24); return Response::json(SUCC, array('安装成功')); }
/** * Return configuration of UI Styleguide components * * @requestParam Array $components list of component names */ public function getComponentsConfig() { wfProfileIn(__METHOD__); $componentNames = $this->request->getArray(self::PARAMETER_COMPONENTS, []); if (empty($componentNames) || $componentNames == [""]) { wfProfileOut(__METHOD__); throw new \MissingParameterApiException(self::PARAMETER_COMPONENTS); } // create the Component instances for names specified in request parameter $factory = Factory::getInstance(); $dependencies = []; try { $components = $factory->init($componentNames, false, $dependencies); if (!is_array($components)) { $components = [$components]; } } catch (\Exception $e) { wfProfileOut(__METHOD__); throw new \NotFoundApiException($e->getMessage()); } // build the response $result = []; foreach ($components as $component) { $result[] = $this->getComponentConfig($component, $factory); } $this->setVal('components', $result); // add the dependencies to the response $result = []; foreach ($dependencies as $component) { // @todo - do we want to include in the dependencies the components that are already returned in the 'components' array? /** @var $component \Wikia\UI\Component */ $result[$component->getName()] = $this->getComponentConfig($component, $factory); } $this->setVal('dependencies', $result); // set response caching $this->response->setCacheValidity(self::CLIENT_CACHE_VALIDITY); wfProfileOut(__METHOD__); }
public function offer() { $curPage = max($_REQUEST['curPage'], 1); $perPage = $_REQUEST['perPage'] ? (int) $_REQUEST['perPage'] : 100; $name = $_REQUEST['search']; $order = $_REQUEST['order']; $by = $_REQUEST['by'] == 'asc' ? 'asc' : 'desc'; $fac = Factory::getInstance(); $userinfo = Factory::getInstance('user')->getUserInfo($_REQUEST['uid']); $list = $fac->getOfferList($curPage, $perPage, $name, $order, $by); if ($list) { $fileIocn = json_decode(ICON, true); foreach ((array) $list as $k => $v) { $list[$k]['pwd'] = $v['pwd'] ? 1 : 0; $icon = $fileIocn[pathinfo($list[$k]['name'], PATHINFO_EXTENSION)]; if (!$list[$k]['isdir']) { $list[$k]['size'] = self::formatBytes($v['size']); $list[$k]['icon'] = $icon ? $icon : $fileIocn['default']; } else { $list[$k]['size'] = 0; $list[$k]['icon'] = $fileIocn['folder']; } $collecInfo = $fac->isCollect($_REQUEST['uid'], $v['id']); if ($collecInfo) { $list[$k]['collect'] = 1; } else { $list[$k]['collect'] = 0; } } } $num = $fac->getOfferNum($name); $page = ceil($num / $perPage); include VIEW_PATH . 'offer.php'; }
public function pwd() { $mapId = (int) $_REQUEST['mapId']; $pwd = $_REQUEST['pwd']; if (!$mapId || !$pwd) { echo Response::json(LACK, array(tip('参数不全'))); exit; } if (strlen($pwd) > 8) { echo Response::json(FAIL, array(tip('密码不能超过8位'))); exit; } $res = Factory::getInstance()->pwd($mapId, $pwd); if ($res) { $_SESSION['share'][self::getClientIp() . ':' . $mapId] = 1; echo Response::json(SUCC, array('urlkey' => base_convert($mapId, 10, 36))); } else { echo Response::json(FAIL, array(tip('验证失败'))); } }
//判断 if(is_file("../20140913/Core/$class.class.php")){ include_once "../20140913/Core/$class.class.php"; } } //4.3 加载模型类 public static function loadModel($class){ //判断 if(is_file("../20140913/Model/$class.class.php")){ include_once "../20140913/Model/$class.class.php"; } } //将所有的自动加载方法注册到自动加载机制中 private static function setAutoload(){ spl_autoload_register(array('Factory','loadCore')); spl_autoload_register(array('Factory','loadAction')); //系统会判断当前提供的参数是一个函数(字符串)还是一个数组 //如果是一个数组:1.找到数组的第一个参数,判断该参数,如果参数不是一个对象,系统会认为该字符串是一个类名,所以在拼凑访问的时候,会用范围解析操作符去访问第二个参数 //Application::loadCore(); spl_autoload_register(array('Factory','loadModel')); } } echo '<pre>'; echo '<pre>'; $first = Factory::getInstance('Captcha'); var_dump($first); $second = Factory::getInstance('Captcha'); var_dump($second);
/** * @covers Xoops\Core\Handler\FactorySpec::getFactory */ public function testGetFactory() { $factory = Factory::getInstance(); $this->assertSame($factory, $this->object->getFactory()); }
/** * Class constructor * * Determines whether to globally enable the XSS processing * and whether to allow the $_GET array. * * @return void */ public function __construct() { // First load the factory so contact can be made with everything in FuzeWorks $this->factory = Factory::getInstance(); $this->_allow_get_array = Config::get('routing')->allow_get_array === TRUE; $this->_enable_xss = Config::get('security')->global_xss_filtering === TRUE; $this->_enable_csrf = Config::get('security')->csrf_protection === TRUE; $this->_standardize_newlines = (bool) Config::get('security')->standardize_newlines; // Sanitize global arrays $this->_sanitize_globals(); // CSRF Protection check if ($this->_enable_csrf === TRUE && !$this->is_cli_request()) { $this->factory->security->csrf_verify(); } }
public function unCollectAll() { $uid = (int) $_REQUEST['uid']; if (!$uid) { echo Response::json(LACK, array(tip('参数不全'))); exit; } $res = Factory::getInstance()->unCollectAll($uid); if ($res) { echo Response::json(SUCC, array(tip('操作成功'))); } else { echo Response::json(FAIL, array(tip('操作失败'))); } }
/** * Class constructor * * @param object &$db Database object * @return void */ public function __construct(&$db) { $this->db =& $db; $this->factory = Factory::getInstance(); Logger::log('Database Utility Class Initialized'); }
function testGetInstance() { $instance = Factory::getInstance(); self::assertInstanceOf('Hirak\\Prestissimo\\Factory', $instance); }
public function getUserInfo() { $uid = (int) $_REQUEST['uid']; return Factory::getInstance('user')->getUserInfo($uid); }
public function __construct() { $this->request = Factory::getInstance(\App\Lib\Api\GooglePlace\Request::class); }
public function person() { $userinfo = Factory::getInstance('user')->getUserInfo($_REQUEST['uid']); include VIEW_PATH . 'person.php'; }
Tools::clean_gpc(); if (_DEBUG) { F::i('Benchmark')->addStep('init'); } try { if (!_DEBUG) { ob_start(); } // What the visitor want to do ? $action = isset($_GET['action']) && !empty($_GET['action']) ? $_GET['action'] : _DEFAULT_ACTION; // Initiate Cookies Factory::getInstance('Cookie', _COOKIE_NAME); // Initiate Session Factory::getInstance('Session'); // Initiate Lang Factory::getInstance('Lang'); // What Params ? Priority to the requested $params = $_GET + $_POST; try { // Control ! $output = Controller::check($action, $params); } catch (FileNotFoundException $e) { // 404 header('HTTP/1.1 404 File Not Found'); exit; } F::i('Session')->close(); $output = Tools::parseOutput($output); if (!_DEBUG) { ob_end_clean(); }
/** * @see Factory::getInstance */ public static function i($class, $params = array(), $superclass = NULL) { return Factory::getInstance($class, $params, $superclass); }
public function __construct() { $this->httpParameterList = Factory::getInstance(RequiredParamEntity::class); return parent::__construct(); }
/** * Display Output * * Processes and sends finalized output data to the browser along * with any server headers and profile data. It also stops benchmark * timers so the page rendering speed and memory usage can be shown. * * Note: All "view" data is automatically put into $this->final_output * by controller class. * * @uses Output::$final_output * @param string $output Output data override * @return void */ public function _display($output = '') { $router = Factory::getInstance()->router; // Grab the super object if we can. if ($router->getCallable() === null) { $use_cache = true; } else { $use_cache = false; } // -------------------------------------------------------------------- // Set the output data if ($output === '') { $output =& $this->final_output; } // -------------------------------------------------------------------- // Do we need to write a cache file? Only if the controller does not have its // own _output() method and we are not dealing with a cache file, which we // can determine by the existence of the $CI object above if ($this->cache_expiration > 0 && $use_cache === false) { $this->_write_cache($output); } // -------------------------------------------------------------------- if ($this->parse_exec_vars === TRUE) { $memory = round(memory_get_usage() / 1024 / 1024, 2) . 'MB'; $output = str_replace(array('{memory_usage}'), array($memory), $output); } // -------------------------------------------------------------------- // Is compression requested? if ($use_cache === false && $this->_compress_output === TRUE && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) { ob_start('ob_gzhandler'); } // -------------------------------------------------------------------- // Are there any server headers to send? if (count($this->headers) > 0) { foreach ($this->headers as $header) { @header($header[0], $header[1]); } } // -------------------------------------------------------------------- if ($use_cache === true) { if ($this->_compress_output === TRUE) { if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) { header('Content-Encoding: gzip'); header('Content-Length: ' . strlen($output)); } else { // User agent doesn't support gzip compression, // so we'll have to decompress our cache $output = gzinflate(substr($output, 10, -8)); } } echo $output; Logger::log('Final output sent to browser'); return; } // -------------------------------------------------------------------- // Do we need to generate profile data? // If so, load the Profile class and run it. if ($this->enable_profiler === TRUE) { Logger::logWarning("Profiler not yet implemented"); return; $CI->load->library('profiler'); if (!empty($this->_profiler_sections)) { $CI->profiler->set_sections($this->_profiler_sections); } // If the output data contains closing </body> and </html> tags // we will remove them and add them back after we insert the profile data $output = preg_replace('|</body>.*?</html>|is', '', $output, -1, $count) . $CI->profiler->run(); if ($count > 0) { $output .= '</body></html>'; } } echo $output; Logger::log('Output sent to browser'); }