Uname:Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64

403WebShell
403Webshell
Server IP : 188.114.96.2  /  Your IP : 104.23.243.200
Web Server : Apache/2.4.59 (Debian)
System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : edlftp ( 1002)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/nicolasj/www/sms.formationlangues.be/application/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/nicolasj/www/sms.formationlangues.be/application/core/NS_Controller.php
<?php

class NS_Controller extends CI_Controller
{
    // Whitelist classes and methodes for account without fullfilled
    public const LIMITED_PROFILE_ROUTES = [
        'Profile' => '*',
        'Teacher' => ['generate_contracts'],
        'Super_Admin' => '*',
        'Login' => '*'
    ];

    public function __construct($config = array())
    {
        parent::__construct();
        if (!defined('NS_BASE_URL')) {
            define('NS_BASE_URL', $this->config->slash_item('base_url'));
        }
        if (!defined('MAIN_TIMESTAMP')) {
            define('MAIN_TIMESTAMP', time());
        }
        $this->load->database();
        $this->load->library('Session');

        $this->reply = array('status' => 'success','errors' => array(),'error_fields' => array(),'logs' => array(),'data' => array(),'config' => array(),'request' => array('get' => $_GET,'post' => $_POST));
        $this->reply['queries'] = &$this->db->queries;
        $this->reply['session'] = &$_SESSION;
        $this->template = array('layout' => '','folder' => '','view' => '');

        $this->checkUser();
        $this->continueIfAllowed(array('ignore' => array('','Login','login','customers','payment_process','Payment','Payment/index','login/forgot_password','login/reset_password','Promotion/check_rules','login/validate_login','login/logout','login','login/?callback=cart','Glogin','Candidate','Hello','hello_student','hello_student/index','hello_teacher','hello_teacher/index','hello_teacher/submit','hello_teacher/submit_pdf','forms','forms/submit','pdf','status','Admin_Archive/archive','Admin_Users/cron_check_rules','Shop','shop'),'authorized' => 'any'));
    }

    public function getOrCreateID($table, $lookup, $dataSet, $update = false)
    {
        $existingEntry = $this->db->get_where($table, $lookup, 1)->row_array();
        if (!$existingEntry) {
            $this->db->insert($table, $dataSet);
            return $this->db->insert_id();
        } else {
            if ($update) {
                $this->db->where($lookup)->update($table, $dataSet);
            }
            if (!empty($existingEntry[$table.'_id'])) {
                return $existingEntry[$table.'_id'];
            }
        }
    }

    public function log($message)
    {
        $this->logs[] = $message;
    }

    public function getStatusList($objectCode)
    {
        $data = $this->db->select('s.*')
          ->join('status AS s', 's.status_target_object_id=sto.status_target_object_id', 'inner')
          ->get_where('status_target_object AS sto', array('sto.code' => $objectCode))->result_array();
        foreach($data as $e) {
            $labelToID = strtoupper($objectCode.'_status_'.$e['code']);
            $labelToCode = strtoupper('status_'.$e['status_id']);
            if (!defined($labelToID)) {
                define($labelToID, $e['status_id']);
                define($labelToCode, $e['code']);
            }
        }
        return $data;
    }

    public function getStatusOption($objectCode, $statusCode)
    {
        $label = strtoupper($objectCode.'_status_'.$statusCode);
        if (defined($label)) {
            return constant($label);
        } else {
            $this->getStatusList($objectCode);
            $label = strtoupper($objectCode.'_status_'.$statusCode);
            if (defined($label)) {
                return constant($label);
            }
        }
        return false;
    }

    public function loadTranslationCodes()
    {
        if (!defined('TRANSLATION_CODES')) {
            $list = $this->db->select('tof.translation_target_object_id AS oi,to.code AS o, tof.code AS f,tof.translation_target_object_field_id AS i')
              ->join('translation_target_object AS to', 'to.translation_target_object_id=tof.translation_target_object_id', 'inner')
              ->get('translation_target_object_field AS tof')->result_array();
            $objects = array();
            foreach ($list as $e) {
                define(strtoupper($e['o'].'_TRANSLATION_'.$e['f']), $e['i']);
                if (empty($objects[$e['oi']])) {
                    define(strtoupper($e['o'].'_TRANSLATION'), $e['oi']);
                    $objects[$e['oi']] = 1;
                }
            }
            define('TRANSLATION_CODES', true);
        }
    }

    public function checkUser()
    {
        $userID = (int) $this->session->userdata('userID');
        if (!empty($userID)) {
            $this->userInfo = $this->db
            ->select('u.user_id, u.email, u.first_name, u.last_name, u.phone, CONCAT(u.first_name,\' \',u.last_name) AS name, r.code AS role', false)
            ->from('user AS u')->join('role AS r', 'r.role_id=u.role_id', 'left')
            ->where('u.user_id', $userID)->limit(1)->get()->row_array();
        } else {
            $this->userInfo = null;
        }
        $this->reply['userInfo'] = $this->userInfo;

        // Check if user have fullfilled account
        if (!empty($this->userInfo)) {
            $this->load->model('users_model');
            $class = $this->router->fetch_class();
            $method = $this->router->fetch_method();

            if ($this->users_model->fullfilled_user($this->userInfo) === false) {
                $this->session->set_flashdata('error', 'Votre profil est incomplet. Remplissez les champs ci-dessous.');
            }
            if ($this->userInfo['role'] == 'teacher') {
                $this->load->model('teacher_model');
                $teacher = $this->teacher_model->get_entry((int) $this->userInfo['user_id']);
                if ($this->teacher_model->fullfilled_teacher($this->userInfo['user_id']) === false) {
                    $this->session->set_flashdata('error', '<a href="/profile">Votre profil est incomplet</a>, merci de le compléter pour être éligible au paiement de vos prestations');
                } else if ($this->teacher_model->teacher_available_to_sign_contract((int) $this->userInfo['user_id'])) {
                    $this->session->set_flashdata('warning', 'Votre profil est incomplet, merci de le compléter pour être éligible au paiement de vos prestations');
                }
            }
        }
    }

    public function notAllowed($message = null)
    {
        $this->reply['status'] = 'not_allowed';
        if (empty($message)) {
            $message = $this->lang->phrase('action_not_allowed');
        } 
        return $this->error($message, false, true);
    }

    public function continueIfAllowed($config)
    {
        $act_link_can = "$_SERVER[REQUEST_URI]";
        $valuescheck = rtrim($act_link_can, "/");
        $ver = explode("/", $valuescheck);

        $frontController = include("front_controller.php");

        if(in_array($ver['0'], $frontControllers) || in_array($ver['1'], $frontControllers)) {
            return true;
        }
        $loginRoles = array();

        if (!empty($config['ignore'])) {
            foreach($config['ignore'] as $s) {
                if ($this->uri->uri_string == $s) {
                    return true;
                }
            }
        }
        if (!empty($config['authorized'])) {
            if (!empty($this->userInfo['user_id'])) {
                if ($config['authorized'] == 'any') {
                    return true;
                } elseif (is_array($config['authorized'])) {
                    foreach($config['authorized'] as $s) {
                        if ($this->uri->uri_string == $s) {
                            return true;
                        }
                    }
                }
            }
        }
        if (!empty($config['allowed'])) {
            foreach($config['allowed'] as $key => $value) {
                if (is_numeric($key)) {
                    if ($value == $this->userInfo['role']) {
                        return true;
                    }
                    $loginRoles[] = $value;
                } else {
                    if ($key == $this->userInfo['role']) {
                        foreach($value as $s) {
                            if ($this->uri->uri_string == $s) {
                                return true;
                            }
                        }
                    }
                    $loginRoles[] = $key;
                }
            }
        }
        $this->redirect(NS_BASE_URL);
        die();
        return $this->notAllowed();
    }


    public function success($message)
    {
        $this->reply['success_message'] = $message;
    }


    public function error($message, $field = false, $return = false)
    {
        if ($this->reply['status'] == 'success') {
            $this->reply['status'] = 'fail';
        }
        if ($field) {
            $this->reply['error_fields'][$field] = $message;
        } else {
            $this->reply['errors'][] = $message;
        }
        if ($return) {
            $this->returnReply();
        }
        return false;
    }

    public function setErrors($errors)
    {
        $this->reply['errors'] = array_merge($this->reply['errors'], $errors);
        $this->reply['status'] = 'fail';
    }

    public function hasErrors()
    {
        switch($this->reply['status']) {
            case 'not_allowed':
            case 'fail':
                return true;
                break;
        }
        return isset($this->reply['errors'][0]);
    }
    public function includeLocalJS($path)
    {
        echo '<script type="text/javascript">';
        include(APPPATH.'../js/'.$path);
        echo '</script>';
    }

    public function setTemplate($layout, $view = false, $config = array())
    {

        switch(REQUEST_TYPE) {
            case 'JSON':
                $this->returnJSON();
                break;
            case 'AJAX':
                if ($this->reply['status'] == 'not_allowed') {
                    $view = 'login.php';
                }
                $this->load->view($view, $config);
                break;
            default:
                switch($this->reply['status']) {
                    case 'not_allowed':
                        if (is_file(APPPATH.'/views/forbidden.php')) {
                            $view = 'forbidden.php';
                        } else {
                            $view = 'basic.php';
                        }
                        break;
                    case 'fail':
                        $view = 'basic.php';
                        break;
                }
                $config['view'] = $view;

                $this->load->view($layout, $config);
                break;
        }
    }

    public function returnJSON()
    {
        if ($this->reply['status'] == 'success' && !empty($this->reply['errors'][0])) {
            $this->reply['status'] = 'fail';
        }
        echo json_encode($this->reply);
        die();
    }

    public function returnReply()
    {
        switch(REQUEST_TYPE) {
            case 'JSON':
                $this->returnJSON();
                break;
            default:
                switch($this->reply['status']) {
                    case 'not_allowed':
                        $this->session->set_flashdata('login_error', 'Action is not allowed, please login with correct permissions');
                        $this->redirect(NS_BASE_URL);
                        die();
                        break;
                    case 'fail':
                        $view = 'basic.php';
                        break;
                }
                echo $this->load->view($view, false, true);
                break;
        }
        die();
    }


    public function redirect($URI, $method = 'auto', $code = null)
    {
        if (REQUEST_TYPE == 'JSON') {

            $this->reply['status'] = 'redirect';
            $this->reply['redirect_url'] = $URI;

            return $this->returnJSON();
        }

        redirect($URI, $method, $code);
    }

    public function translate($message)
    {
        if (function_exists('get_phrase')) {
            return get_phrase($message);
        } else {
            return $this->lang->phrase($message);
        }
    }

    public function loadStoreSource($storeID = 0)
    {
        $storeID *= 1;
        if ($storeID == 0) {
            return $this->error($this->translate('store_not_set'));
        }

        $storeData = $this->db->select('at.controller,as.config_code,s.store_id,s.api_source_id,at.api_type_id'
          .',IFNULL(s.remote_config,\'{}\') AS remote_config,IFNULL(s.local_config,\'{}\') AS local_config')
          ->join('api_source AS as', 'as.api_source_id=s.api_source_id', 'left')
          ->join('api_type AS at', 'at.api_type_id=as.api_type_id', 'left')
          ->get_where('store AS s', array('s.store_id' => $storeID), 1)->row_array();

        if (empty($storeData)) {
            return $this->error($this->translate('store_source_not_found'));
        }

        require_once(APPPATH.'libraries/APIs/'.$storeData['controller'].'/config/'.$storeData['config_code'].'.php');
        if (empty($appConfig)) {
            $appConfig = array();
        }

        $remoteConfig = json_decode(trim($storeData['remote_config']), true);
        $localConfig = json_decode(trim($storeData['local_config']), true);

        $this->storeSourceRemoteConfig = &$remoteConfig;
        $localConfig['instance'] = &$this;
        $localConfig['storeID'] = $storeData['store_id'];
        $localConfig['APITypeID'] = $storeData['api_type_id'];
        $localConfig['APISourceID'] = $storeData['api_source_id'];
        $localConfig['configUpdater'] = 'updateStoreSourceRemoteConfig';
        $localConfig['errorLogger'] = 'error';
        $localConfig['requestLogger'] = 'updateStoreSourceLog';

        $config = array(
          'remote' => array_merge($appConfig, $remoteConfig)
          ,'local' => &$localConfig
        );

        $this->load->library('APIs/'.$storeData['controller'].'/'.$storeData['controller'], $config, 'storeSource');
    }

    public function updateStoreSourceRemoteConfig($dataSet)
    {
        foreach($dataSet as $k => $v) {
            $this->storeSourceRemoteConfig[$k] = $v;
        }
        $this->db->where('store_id', $this->storeSource->localConfig['storeID'])
          ->update('store', array('remote_config' => json_encode($this->storeSourceRemoteConfig)));
    }

    public function updateStoreSourceLog($logID, $storeID, $data)
    {
        $logID *= 1;
        if ($logID > 0) {
            $this->db->where('store_log_entry_id', $logID)->update('store_log', $data);
        } else {
            $this->db->insert('store_log', array_merge(array('store_id' => $storeID,'timestamp' => time()), $data));
            return $this->db->insert_id();
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit