/** * @return string */ public function generateId() { return implode('-', str_split(strtoupper(Crypt::create(12)), 4)); }
protected function init() { $this->headers = getallheaders(); $this->script_name = basename($_SERVER['SCRIPT_NAME']); $this->ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? true : false; $this->server_name = $_SERVER['SERVER_NAME']; $tmp_base_url = array_filter(explode('/' . $this->script_name, $_SERVER['PHP_SELF'])); $this->base_url = count($tmp_base_url) > 1 ? $tmp_base_url[0] : str_replace('\\', '/', str_replace($this->script_name, '', pathinfo($_SERVER['PHP_SELF'])['dirname'])); $this->base_url = strlen($this->base_url) > 1 ? $this->base_url . '/' : $this->base_url; $this->port = $_SERVER['SERVER_PORT']; $this->home = $this->base_url . ($this->script_name != 'index.php' ? '/' . $this->script_name : ''); $this->absolute_url = ($this->ssl ? 'https' : 'http') . '://'; $this->absolute_url .= $this->server_name . ($this->port == 80 ? '' : ':' . $this->port) . $this->base_url; $this->csrf_id = $this->_session->get('request.csrf_id'); $this->csrf_value = $this->_session->get('request.csrf_value'); $this->salt = $this->_session->get('request.salt'); if ($this->_csrf) { if (!$this->csrf_id) { $this->csrf_id = Crypt::create(10); $this->_session->put('request.csrf_id', $this->csrf_id); } if (!$this->csrf_value) { $this->csrf_value = hash('sha256', Crypt::create(500)); $this->_session->put('request.csrf_value', $this->csrf_value); } if (!$this->salt) { $this->salt = Crypt::create(32); $this->_session->put('request.salt', $this->salt); } } }