/** * @throws \Exception */ protected function init() { $this->setEnvironment(); // Load class aliases $aliases = Config::get('aliases'); foreach ($aliases as $orig => $new) { class_alias($orig, $new, true); } static::$container = new Container(); Session::init(); Request::init(); $this->initRouter(); $databaseConfig = Config::get('database'); if ($databaseConfig !== null && is_array($databaseConfig)) { $this->capsule = new Capsule(); foreach ($databaseConfig as $name => $conf) { if (array_key_exists('name', $conf) && strlen($conf['name']) > 0) { $name = $conf['name']; unset($conf['name']); } $this->capsule->addConnection($conf, $name); } $this->capsule->bootEloquent(); } $hookConfig = Config::get('hooks'); if (is_array($hookConfig)) { foreach ($hookConfig as $event => $callable) { EventHandler::addListener($event, $callable); } } EventHandler::triggerEvent('whirlpool-initialized', $this); }
public static function run() { if (!Site::init(!empty($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : '')) { @header('HTTP/1.1 404 Not Found'); exit; } $method = Core::getRequestMethod(); if (!in_array($method, array('get', 'put', 'delete', 'post'))) { @header("HTTP/1.1 501 Not Implemented"); exit; } $data = Core::getRequestData(); if (empty($data[$method]) && !in_array($_SERVER['REQUEST_URI'], array($_SERVER['SCRIPT_NAME'], "", "/"))) { $data[$method] = $_SERVER['REQUEST_URI']; } $resource = Core::getResource($data, $method); $staticFolders = array('/cache/', '/static/', '/uploads/', '/vendor/'); foreach ($staticFolders as $folder) { if (strncasecmp($resource, $folder, strlen($folder)) === 0) { @header('HTTP/1.1 404 Not Found'); exit; } } App::set(App::parse($resource)); Core::resource($resource); Module::init(); $response = Response\Factory::get($resource, $method); if (empty($response)) { @header('HTTP/1.1 406 Not Acceptable'); exit; } Request::init($response, $data); echo Request::run($resource, $method); }
public function dispatch(Request $request) { if (!$request->isInit()) { $request->init(); } $request->process(); return $this->lastResponse = $request->getResponse(); }
public function init() { if (!self::$init) { self::$get = WaxUrl::get_params(); self::$post = $_POST; self::$params = array_merge(self::$get, self::$post); self::$init = true; } }
public function __construct() { self::$root = rtrim(dirname($_SERVER['SCRIPT_FILENAME']), DIRECTORY_SEPARATOR); self::$base = rtrim(dirname($_SERVER['SCRIPT_NAME']), DIRECTORY_SEPARATOR); spl_autoload_register(array('TwCensus', 'loader')); Session::init(); Session::$prefix = 'TwCensus_'; Db::connect(self::$config['db']); Request::init(); if (Request::hasQuery('kml')) { $this->actionKML(); } else { $this->actionWebsite(); } }
/** * 直接 parse $_REQUEST * @param $_data * @return bool */ public function parse($_data) { $ctrlName = Config::getField('project', 'default_ctrl_name', 'main\\main'); $methodName = Config::getField('project', 'default_method_name', 'main'); $data = $_data; $apn = Config::getField('project', 'ctrl_name', 'a'); $mpn = Config::getField('project', 'method_name', 'm'); if (isset($data[$apn])) { $ctrlName = \str_replace('/', '\\', $data[$apn]); } if (isset($data[$mpn])) { $methodName = $data[$mpn]; } Request::init($ctrlName, $methodName, $data, Config::getField('project', 'view_mode', 'Rpc')); return true; }
public static function load() { // app is available static::available(); // load the app configs Config::init(); // initializing encryption Encryption::init(); // initializing the request infos Request::init(); // initializing sessions Session::init(); Session::start(); // handling the routes and response echo Route::response(); }
public static function poweron() { if (function_exists('ob_gzhandler')) { ob_start('ob_gzhandler'); } else { ob_start(); } import('system/share/exception/BaseException'); import('system/share/exception/DoesNotExistsException'); //set_exception_handler(array('BaseException', 'handler')); import('system/share/config/base'); BaseConfig::init(); self::BuildEnvironment(); import('system/share/pluggable/base'); import('system/share/network/request'); Request::init(); //echo "123"; self::runApplication(); self::output(); }
public function __construct() { Core::$curent_class = get_called_class(); // initialisation de la variable locale time limit Core::setTimeLimit(); // initialisation des constantes des chemins de l'application Core::setPathConst(); // initialisation des constantes issus du fichier de parametres Core::SetParameters(); // initialisation du DNS (PDO) Core::SetDns(); // initialisation de l'autoloader de classe spl_autoload_register(array(__CLASS__, 'setAutoload'), true, false); //tret // initialisation des requetes serveur Request::init(); /*Core::$abstract= new AbstractModel();*/ // initialisation de la session Session::start(); $_SESSION = array(); /*session_destroy(); exit;/**/ // initialisation de l'instance PDO Core::$pdo = new PdoControllers(new PdoInstance(DSN, DB_USER, DB_PASS)); // initialisation du filemanager //Core::$file_manager = new FileManager(); // initialisation de la base de données if (DB_RESET) { Core::setTimeLimit(0); DbInit::init(); Core::setTimeLimit(); } // initialisation Twig $path = Request::getController() != 'asset' ? View : Asset; Core::$twig = new Twig_Environment(new Twig_Loader_Filesystem($path), array('cache' => TWIG_CACHE == 1 ? CACHE : false, 'auto_reload' => TWIG_AUTO_RELOAD == 1 ? true : false)); Core::$twig->addExtension(new Project_Twig_Extension(Core::$curent_class)); // initialisation du header de la page header(Request::getHeader()); }
/** * run * * Run application * * @return null */ public static function run() { Request::init(); if (self::getConfig('main')->system->session_handler == 'database') { Storage::setDatabaseHandler(); } Storage::init(); Member::init(); Router::run(); }
/** * 1) Initialise the Request * 2) Grab the AssetType based on the request and initialise it * 3) Instantiate the Response class, set the headers, and then return the content * * Rap everything in a Try/Catch block for error handling * * @param Request $Request * @param array $options * * @return string * * @catch NotFoundException * @catch ErrorException */ public static function run(Request $Request, $options = array()) { try { /** * Merge in default options */ $options = array_merge(self::$defaultOptions, $options); /** * Set the header controller. Can be overwritten by the dispatcher options */ if (isset($options['headerController']) && $options['headerController'] instanceof Asset\HeaderSetter) { $headerController = $options['headerController']; } else { $headerController = new Asset\HeaderSetter(); } /** * Initialise the Request */ $Request->init(); /** * Grab the correct AssetType */ $AssetType = Asset\Registry::getClass($Request); /** * Initialise the AssetType */ $AssetType->init(); /** * Create a response */ $Response = new Response($AssetType); $Response->setHeaderController($headerController); /** * Set the headers if told to do so */ if ($options['setHeaders']) { /** * Set the headers. */ $Response->setHeaders($options['maxAge']); } /** * If the content hasn't been modified return null so only headers are sent * otherwise return the content */ return $Response->notModified ? null : $Response->render(); } catch (Asset\NotFoundException $e) { if (isset($headerController) && $headerController instanceof Asset\HeaderSetter) { $headerController->statusCode('HTTP/1.0', 404, 'Not Found'); $headerController->headerField('Status', '404 Not Found'); } return 'Not Found Error: ' . static::getErrors($e); } catch (Asset\Type\CompilationException $e) { if (isset($AssetType) && $AssetType instanceof Asset\Type) { $AssetType->cleanUpAfterError(); } return 'Compilation Error: ' . static::getErrors($e); } catch (ErrorException $e) { return 'Error: ' . static::getErrors($e); } }
// force integer define('TYPE_UINT', 3); // force unsigned integer define('TYPE_NUM', 4); // force number define('TYPE_UNUM', 5); // force unsigned number define('TYPE_UNIXTIME', 6); // force unix datestamp (unsigned integer) define('TYPE_STR', 7); // force trimmed string define('TYPE_NOTRIM', 8); // force string - no trim define('TYPE_NOHTML', 9); // force trimmed string with HTML made safe define('TYPE_ARRAY', 10); // force array define('TYPE_FILE', 11); // force file define('TYPE_ARRAY_BOOL', 101); define('TYPE_ARRAY_INT', 102); define('TYPE_ARRAY_UINT', 103); define('TYPE_ARRAY_NUM', 104); define('TYPE_ARRAY_UNUM', 105); define('TYPE_ARRAY_UNIXTIME', 106); define('TYPE_ARRAY_STR', 107); define('TYPE_ARRAY_NOTRIM', 108); define('TYPE_ARRAY_NOHTML', 109); define('TYPE_ARRAY_ARRAY', 110); Request::init();
require_once 'zee/core/Request.class.php'; require_once 'zee/core/Dispatch.class.php'; require_once 'zee/core/Controller.class.php'; require_once 'zee/core/Part.class.php'; require_once 'zee/core/FilterHelper.calss.php'; require_once 'zee/message/Errors.class.php'; require_once 'zee/message/Messages.class.php'; require_once 'zee/lang/Language.class.php'; require_once 'zee/lang/LanguageContentValue.class.php'; require_once 'zee/lang/LanguageValue.class.php'; require_once 'zee/lang/LanguageService.class.php'; require_once 'zee/lang/LanguageContentService.class.php'; //================== // Request //================== Request::init($_REQUEST); //================== // DB //================== Zee::register('DB', new DB()); //================== // Language //================== //================== // Exec Pre Filters //================== FilterHelper::execFilters(FilterHelper::PRE_FILTER); //================== // Do Module //================== $controller = Dispatch::getController(Request::getModule());
function testCustomHeader() { $value = "custom header value"; $r = Request::init()->withXCustomHeader($value); assert(!empty($r->headers['X-Custom-Header'])); assert($value == $r->headers['X-Custom-Header']); }
public static function initialize($onstart = null, $onfly = null) { Config::init(); if (Config::get('active') === 0) { return Bella::shutdown(); } $q = Config::get('settings'); if (is_dir($q->requires_dir)) { foreach (glob($q->requires_dir . '*.php') as $file) { include_once $file; } } if (is_dir($q->utils_dir)) { foreach (glob($q->utils_dir . '*.php') as $file) { include_once $file; } } Session::init(); Path::init(); Request::init(); if (isset($onstart) && is_callable($onstart)) { $onstart(); } $user = Session::get('user'); if (!$user) { $user = Session::get('manager'); } if (!!$user) { Context::set('user', $user); } $c = Path::get(0); if (!$c) { Bella::loadCoordinator('index'); } else { $dir = Config::get('settings')->controllers_dir; $f = $dir . $c . '.php'; if (file_exists($f)) { Bella::loadCoordinator($c); } else { if (isset($onfly) && is_callable($onfly)) { return $onfly($c); } } } }
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $output = curl_exec($ch); curl_close($ch); return $output; } public function create_album($album_name, $message) { $graph_url = "https://graph.facebook.com/Page-ID/albums"; $result = $this->do_request($graph_url, "is_default=false&name={$album_name}&message={$message}&access_token=" . $this->access_token); $encode = json_decode($result, TRUE); echo $encode["id"]; return $encode["id"]; } public function image_upload($album_id, $photo_url, $message) { $this->do_request("https://graph.facebook.com/{$album_id}/photos", "access_token=" . $this->access_token . "&url=" . $photo_url . "&name={$message}"); } } $req = new Request(); $req->init(); $gall_id = $req->create_album("경기도/서울 지역 날씨 정보", "경기도/서울 날씨 입니다."); $citys = array("경기도" => "Gyeonggi-1", "경기도" => "Gyeonggi-2", "경기도" => "Gyeonggi-3", "서울" => "Seoul"); foreach ($citys as $key => $value) { $req->image_upload($gall_id, "IMAGE_URL", $key . "지역 날씨"); }