initialize() public static method

This method also re-initializes all properties.
public static initialize ( array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], string | resource $content = null )
$query array The GET parameters
$request array The POST parameters
$attributes array The request attributes (parameters parsed from the PATH_INFO, ...)
$cookies array The COOKIE parameters
$files array The FILES parameters
$server array The SERVER parameters
$content string | resource The raw body data
 /**
  * Transform the form results before sending it to validation.
  *
  * @param array $query
  * @param array $request
  * @param array $attributes
  * @param array $cookies
  * @param array $files
  * @param array $server
  * @param null  $content
  */
 public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
 {
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     $input = Input::all();
     $input['timestamp'] = strtotime($input['timestamp']);
     if (!json_decode($input['information'])) {
         $input['information'] = json_encode(['report' => $input['information']]);
     }
     $this->getInputSource()->replace($input);
 }
Example #2
0
	function generateData() {
		Request::initialize(true);
		$requested_url = $_SERVER['REQUEST_URI'];
		$this->data['error'] = 'Такой страницы не существует';
		$this->data['error_code'] = 404;
		$this->data['error_description'] = 'Страницы ' . urldecode($requested_url) . ' не существует';
		
		$realPath = Request::getRealPath();
		if($realPath){
			$this->data['error_description'].='<br/>';
			$this->data['error_description'].='Но есть <a href="'.$realPath.'">страница</a>, на которую вы вероятно хотели попасть.';
			//$this->data['error_description'].='<br/>'.Request::$path_history;
		}
		
		
		header("HTTP/1.1 404 Not Found", null, 404);
	}
Example #3
0
 /**
  * Transform the form results before sending it to validation.
  *
  * @param array $query
  * @param array $request
  * @param array $attributes
  * @param array $cookies
  * @param array $files
  * @param array $server
  * @param null  $content
  */
 public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
 {
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     if (config('main.notes.show_abusedesk_names') === true) {
         $postingUser = '******' . Auth::user()->fullName() . ')';
     } else {
         $postingUser = '';
     }
     switch ($this->method()) {
         case 'POST':
             $this->getInputSource()->add(['submitter' => trans('ash.communication.abusedesk') . $postingUser, 'viewed' => true]);
             break;
         case 'PATCH':
             $this->getInputSource()->add(['submitter' => trans('ash.communication.abusedesk') . $postingUser]);
             break;
         default:
             break;
     }
 }
Example #4
0
Config::init($local_config);
require_once 'include.php';
//jQuery запросы
if (isset($_POST['jquery'])) {
    if (is_string($_POST['jquery'])) {
        $jModuleName = 'J' . $_POST['jquery'];
        $jModule = new $jModuleName();
        echo $jModule->getJson();
    }
    exit;
}
Log::timing('total');
try {
    ob_start();
    // разбираем запрос
    $pageName = Request::initialize();
    // авторизуем пользователя
    $current_user = new CurrentUser();
    // выполняем модули записи, если был соответствующий POST запрос
    if (Request::post('writemodule')) {
        PostWrite::process(Request::post('writemodule'));
    }
    // запускаем обработку страницы
    $page = new PageConstructor(Request::$pageName);
    @ob_end_clean();
    echo $page->process();
} catch (Exception $e) {
    if ($dev_mode) {
        $errorString = "<h3>" . $e->getMessage() . '</h3><br/>[' . $e->getFile() . ':' . $e->getLine() . '][' . $e->getCode() . ']';
        $errorString .= '<br/><pre>' . $e->getTraceAsString() . '</pre>';
        die($errorString);
Example #5
0
 /**
  * Transform the form results before sending it to validation
  *
  * @param array $query
  * @param array $request
  * @param array $attributes
  * @param array $cookies
  * @param array $files
  * @param array $server
  * @param null $content
  */
 public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
 {
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     $this->getInputSource()->add(['account_id' => (int) Auth::user()->account->id]);
 }
Example #6
0
 function isNicknameUnique()
 {
     global $current_user;
     $this->data['success'] = 1;
     if (!$current_user->authorized) {
         $this->error('Auth');
         return;
     }
     $nickname = isset($_POST['nickname']) ? $_POST['nickname'] : false;
     $mask = array('nickname' => array('type' => 'string', 'regexp' => '/^[A-Za-z][A-Za-z0-9_]+$/', 'min_length' => 3, 'max_length' => 26));
     Request::initialize();
     try {
         $params = Request::checkPostParameters($mask);
     } catch (Exception $e) {
         $this->error($e->getMessage());
         return;
     }
     $nickname = trim($params['nickname']);
     if ($nickname) {
         $query = 'SELECT COUNT(1) as cnt FROM `users` WHERE `nickname`=' . Database::escape($nickname) . ' AND `id` <> ' . $current_user->id;
         $cnt = Database::sql2single($query);
         if ($cnt) {
             $this->error('already_taken');
             return;
         } else {
             return true;
         }
     } else {
         $this->error('Illegal nickname ^[A-Za-z][A-Za-z0-9_]+$');
         return;
     }
 }
		
    WideImage is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.
		
    You should have received a copy of the GNU Lesser General Public License
    along with WideImage; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  **/
define('WI_DEMO_PATH', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR);
define('WI_IMG_PATH', WI_DEMO_PATH . 'images' . DIRECTORY_SEPARATOR);
require_once dirname(__FILE__) . '/../config.php';
require_once $wideimage_inc_path . '/WideImage.inc.php';
require_once WI_DEMO_PATH . 'helpers/Request.class.php';
Request::initialize();
require_once WI_DEMO_PATH . 'helpers/Registry.class.php';
// common
Registry::set('image formats', array('jpg', 'png', 'gif'));
Registry::set('images', array('rainbow.png', 'fgnl.jpg', 'color-hole.gif', 'bg03.jpg', 'blue-alpha.png', 'mask-smiley.gif'));
Registry::set('colors', array('16', '128', '256', 'truecolor'));
// resize
Registry::set('resize methods', array('inside', 'fill', 'outside'));
Registry::set('image dim regex', '/^[0-9]{1,}[\\%]?$/');
function img_header($format)
{
    header('Pragma: no-cache');
    if (Registry::get('debug') == 'text') {
        header('Content-type: text/plain');
    } elseif (Registry::get('debug') == 'html') {
        header('Content-type: text/html');
Example #8
0
 /**
  * Initialize this Request.
  *
  * @param Context A Context instance.
  * @param array   An associative array of initialization parameters.
  *
  * @return bool true, if initialization completes successfully, otherwise
  *			  false.
  *
  * @throws <b>InitializationException</b> If an error occurs while
  *										initializing this Request.
  */
 public function initialize($context, $parameters = null)
 {
     return parent::initialize($context, $parameters);
 }