Здравствуйте. В ходе разработки в основном файле будущем системы постоянно висит ошибка "unexpected 'URI' (T_STRING) in <...>".
Удалял вообще всю эту строку - ругается на следующую. Точки с запятыми, вроде, не забыл.
Кто сталкивался?
Привожу код самого файла и код функции.
<?php
defined("BASEPATH") OR exit("Access denied.');
class App extends CI_Model {
public $user = FALSE;
public $mainfile = 'default';
function __construct(){
parent::__construct();
$this->define_core_data();
$this->check_auth();
}
function get_user($params, $column = NULL){
return $this->get_db('users', $params, $column);
}
function get_db($table, $params, $column = NULL){
if($column != NULL){
$params = [$column=>$params];
}
$sql = $this->db->get_where($table, $params)->result_array();
if($sql) return $sql[0];
else return FALSE;
}
function define_core_data(){
define("URI", $this->config->item("base_url"));
define("IS_AJAX", $this->input->is_ajax_request());
define("IS_MOBILE", $this->agent->is_mobile());
define("IP_ADDRESS", $this->input->ip_address());
define("USER_AGENT", $this->agent->agent_string());
define("CONTROLLER", $this->router->fetch_class());
define("METHOD", $this->router->fetch_method());
define("SERVER_TIME", time());
define("SERVER_TIME_MASK", "d.m.Y в H:i");
define("SERVER_PREP_TIME", date(SERVER_TIME_MASK, SERVER_TIME));
define("TEMPLATE_PATH", "templates/");
define("MAIN_TEMPLATES_PATH", "main/");
}
function check_auth(){
$phone = $this->security->xss_clean($this->session->phone);
$password = $this->security->xss_clean($this->session->password);
if(!empty($phone) && !empty($password)){
$sql = $this->get_user(['password'=>md5($password), 'phone'=>$phone]);
if($sql){
$this->user = $sql;
$this->db->where('id', $sql['id'])->update('users', ['last_online'=>SERVER_TIME, 'ip_address'=>IP_ADDRESS, 'user_agent'=>USER_AGENT]);
$is_blocked = $this->get_db('blocks', ['end_time >'=>SERVER_TIME]);
if($is_blocked && !in_array(CONTROLLER, ['logout','static'])){
header("Location: ".URI."static/ban_details/".$is_blocked['id']."");
exit;
}
}
}
$non_auth_urls = ['signin','signup','remind','welcome','static'];
$auth_non_urls = ['signin','signup','remind','welcome'];
if($this->user == FALSE && !in_array(CONTROLLER, $non_auth_urls)){
header("Location: ".URI."welcome");
exit;
}
if($this->user != FALSE && in_array(CONTROLLER, $auth_non_urls)){
header("Location: ".URI."ads/my");
exit;
}
}
function page($title, $document, $vars = [], $template_mode = 1){
$data = [
'title'=>$title,
'user'=>$this->user,
'uri'=>URI,
'is_ajax'=>IS_AJAX,
'is_mobile'=>IS_MOBILE,
];
$data = array_merge($data, $vars);
$data['content'] = $this->parser->parse(TEMPLATE_PATH.$document, $data, TRUE);
if(IS_AJAX == FALSE && $mode == 1) return $this->parser->parse(TEMPLATE_PATH.MAIN_TEMPLATES_PATH.$this->mainfile, $data, TRUE);
else return $data['content'];
}
}
Код функции:
function define_core_data(){
define("URI", $this->config->item("base_url"));
define("IS_AJAX", $this->input->is_ajax_request());
define("IS_MOBILE", $this->agent->is_mobile());
define("IP_ADDRESS", $this->input->ip_address());
define("USER_AGENT", $this->agent->agent_string());
define("CONTROLLER", $this->router->fetch_class());
define("METHOD", $this->router->fetch_method());
define("SERVER_TIME", time());
define("SERVER_TIME_MASK", "d.m.Y в H:i");
define("SERVER_PREP_TIME", date(SERVER_TIME_MASK, SERVER_TIME));
define("TEMPLATE_PATH", "templates/");
define("MAIN_TEMPLATES_PATH", "main/");
}