S
S
Sergey Grigorov2018-03-24 18:33:45
PHP
Sergey Grigorov, 2018-03-24 18:33:45

What is the weird error?

Hello. During development, the error "unexpected 'URI' (T_STRING) in <...>" constantly hangs in the main file of the future system.
Deleted this whole line in general - swears at the next one. I didn't forget the semicolons.
Who faced?
I give the code of the file itself and the code of the function.

<?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 code:
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/");
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Grigorov, 2018-03-24
@Serjio-Grig Asker

Oops... Looked from the interface of the toaster... I'm sorry, I'm just an idiot.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question