/** * Constructor * * @param string $uri The URI to route * @param string $domain The domain to route * @param bool $secure True if connection made via SSL */ public function __construct($buri = '/') { if (isset($_SERVER['REQUEST_URI'])) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = $buri; } if (isset($_SERVER['HTTP_HOST'])) { $domain = strtolower($_SERVER['HTTP_HOST']); } else { if (isset($_SERVER['SERVER_NAME'])) { $domain = strtolower($_SERVER['SERVER_NAME']); } else { $domain = 'localhost'; } } $secure = true; // Parse query string if (strpos($uri, '?')) { $base = substr($uri, 0, strpos($uri, '?')); $rest = substr($uri, strpos($uri, '?') + 1); // Apache mod_rewrite workaround for existing folders - requests // are routed as /uri/?/uri if the folder exists. if ($base != '/' && file_exists('.' . $base) && substr($rest, 0, strlen($base) - 1) . '/' == $base) { // folder match, reroute the $rest. // TODO: Query string arguments should be passed on if (strpos($rest, '&') > 0) { $params = substr($rest, strpos($rest, '&') + 1); } response::redirect($base . '?' . $params); } else { // Parse the querystring $qsl = explode('&', $rest); foreach ($qsl as $qsi) { if (preg_match('/^(.*)=(.*)$/', $qsi, $keys)) { $_GET[$keys[1]] = urldecode($keys[2]); $_REQUEST[$keys[1]] = urldecode($keys[2]); } } $uri = $base; } } // Quick fix for first index being '/index_php' when invoked via // apache - hopefully sorts bug with php oauth. if (arr::hasKey($_GET, '/index_php')) { array_shift($_GET); array_shift($_GET); } // Assign the URI and start parsing $this->_uri = $uri; $this->_domain = $domain; $this->_secure = request::isSecure(); foreach (explode('/', $this->_uri) as $segment) { if ($segment != '') { $this->_urisegments[] = $segment; } } }
function login() { $user = request::post('username')->toString(); $pass = request::post('password')->toString(); if (User::authenticate(new PasswordAuthentication($user, $pass))) { session::set('username', $user); response::redirect('/ppp/confirm'); } }
/** * Форма фхода в админку * @access protected */ public function admin() { $args = request::get(array('user', 'secret')); $data = array('LC' => LC::get()); try { if (!empty($args)) { authenticate::login(); } } catch (Exception $e) { dbg::write($e->getMessage(), LOG_PATH . 'adm_access.log'); $data['errors'] = $e->getMessage(); } if (!authenticate::is_logged()) { $tmpl = new tmpl($this->pwd() . 'login.html'); response::send($tmpl->parse($data), 'html'); } else { response::redirect('/xxx/'); } }
/** * Redirect with HTTP 303 "See Other" code * This is a recommended method to redirect after POST * @param string $message */ public function redirect($url) { response::redirect($url); }
public function run() { //echo 'Filename: '.$this->_filename.'<br />'; // echo 'Base path: '.$this->_basePath.'<br />'; // echo 'Base url: '.$this->_baseUrl.'<br />'; // echo 'Relative: '.$this->_rel.'<br />'; //var_dump($this); $tmFilename = $this->_basePath . '/' . dirname($this->_rel) . '/.thumb/' . $this->_filename; if (is_file($tmFilename)) { /* * IMPORTANT: Workaround for open_file_cache of nginx */ $this->readFile($tmFilename); } if (strpos($this->_filename, '_') !== false) { if (basename($this->_rel) == '.thumb') { if (($filename = $this->getSourcePath()) || ($filename = $this->getSourcePath('l_'))) { // Check path $path = $this->_basePath . '/' . $this->_rel; if (!is_dir($path)) { mkdir($path, 0777, true); } if (is_dir($path)) { if ($thumb = $this->makeThumbnail($filename)) { // FOUND $this->prepareShutdown($path); if (is_file($tmFilename)) { //response::notFound(); $this->optimizePng($tmFilename); // Finally, throw away redirects $this->readFile($tmFilename); response::redirect($_SERVER['REQUEST_URI']); } else { //echo $tmFilename; throw new Exception('thumbnail was created but not found 0_o'); //response::notFound(); } } } else { throw new Exception('can\'t create directory'); } } else { throw new Exception('source file not found in directory'); } } else { var_dump($this); throw new Exception('basename is not correct (' . $this->_rel . ')'); } } $this->notFound(); }
function doRenderGet($chart) { $url = $this->getPooledUrl($chart); response::redirect($url); }
/** * Public site initialization * * @author Litvinenko S. Anthon <*****@*****.**> * @access public * @package SBIN DIESEL */ try { $uri = empty($_SERVER['REDIRECT_URL']) ? '/' : $_SERVER['REDIRECT_URL']; $diStrc = data_interface::get_instance(SITE_DI); $page = $diStrc->get_page_by_uri($uri); define(PAGE_URI, $page['uri']); define(SRCH_URI, str_replace($page['uri'], "", $uri)); define(PAGE_ID, $page['id']); if (!empty($page['redirect'])) { response::redirect($page['redirect']); } else { $uiStrc = user_interface::get_instance(SITE_UI); $uiStrc->set_args(request::get()); $uiStrc->process_page($page); } } catch (Exception $e) { dbg::write('Error: ' . $e->getMessage()); //response::header('404'); //9* 28102010 try { $out = user_interface::get_instance('action_page'); $out->set_args(array('action_msg' => $e->getMessage())); return $out->render(); } catch (Exception $e) { dbg::write('Error: ' . $e->getMessage());
<?php // NOTE: Инициализация базовой части административного интерфейса. include_once 'adm_base.php'; try { if (request::get('cll') == 'logout') { authenticate::logout(); response::redirect('/xxx/'); } else { $ui = user_interface::get_instance('login'); $ui->admin(); } } catch (Exception $e) { dbg::write($e->getMessage(), LOG_PATH . 'ui_errors.log'); response::header('404'); }
<?php /** * The user interface initialization code * * @author Litvinenko S. Anthon <*****@*****.**> * @version 2.0 * @access public * @package CFsCMS2(PE) */ try { // NOTE: If defined authentication data interface and user not logged in if (defined('AUTH_DI') && !authenticate::is_logged()) { // Then redicrect to login form response::redirect('login/'); } // Call user interface $ui = user_interface::get_instance(request::get('ui', UI_DEFAULT)); if (($content = $ui->call(request::get('cll', UI_CLL_DEFAULT), request::get())) === FALSE) { response::header('404'); } else { response::send($content, 'html'); } } catch (Exception $e) { dbg::write($e->getMessage() . "\n" . $e->getTraceAsString(), LOG_PATH . 'ui_errors.log'); response::header('404'); }