public function __construct()
 {
     //error_reporting(E_ALL);
     log_message('debug', "Weixinapi Class Initialized.");
     $this->CI =& get_instance();
     $this->valid();
 }
Example #2
0
 function __construct()
 {
     parent::__construct();
     // Load language relations file
     $this->config->load('languages');
     $this->lang_path = APPPATH . '../lang';
     $this->langname = $this->config->item('default_language');
     if (!is_dir($this->lang_path)) {
         log_message('ERROR', 'Language path is not a directory');
         die;
     }
     // Defined language?
     $lang_rels = $this->config->item('lang_rels');
     if (!isset($lang_rels[$this->langname])) {
         log_message('ERROR', 'Language ' . $this->langname . ' not registered');
         $this->langname = 'en';
     }
     $this->lang_relations = $lang_rels[$this->langname];
     if (FALSE === ($this->lang_contents = $this->parse_language($this->langname))) {
         $this->extended_logs->message('ERROR', 'Language ' . $this->langname . ' not found');
         $this->langname = 'en';
         $this->lang_contents = $this->parse_language($this->langname);
     }
     // Locale
     $this->setlocale();
     // Set CodeIgniter language
     $this->set_ci_language();
 }
Example #3
0
 /**
  * Class constructor
  * @return    void
  */
 public function __construct()
 {
     $CFG =& load_class('Config', 'core');
     log_message('info', 'Hooks Class Initialized');
     if ($CFG->item('enable_hooks') === FALSE) {
         return;
     }
     if (file_exists(COMMONPATH . 'config/hooks.php')) {
         include COMMONPATH . 'config/hooks.php';
     }
     if (file_exists(COMMONPATH . 'config/' . ENVIRONMENT . '/hooks.php')) {
         include COMMONPATH . 'config/' . ENVIRONMENT . '/hooks.php';
     }
     if (file_exists(APPPATH . 'config/hooks.php')) {
         include APPPATH . 'config/hooks.php';
     }
     if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/hooks.php')) {
         include APPPATH . 'config/' . ENVIRONMENT . '/hooks.php';
     }
     if (!isset($hook) || !is_array($hook)) {
         return;
     }
     $this->hooks =& $hook;
     $this->enabled = TRUE;
 }
Example #4
0
 /**
  * Non-persistent database connection
  *
  * @param	bool	$persistent
  * @return	resource
  */
 public function db_connect($persistent = FALSE)
 {
     $error = NULL;
     $conn_id = $persistent === TRUE ? sqlite_popen($this->database, 0666, $error) : sqlite_open($this->database, 0666, $error);
     isset($error) && log_message('error', $error);
     return $conn_id;
 }
Example #5
0
 /**
  * Load Extension
  *
  * This function loads the specified extension.
  *
  * @access	public
  * @param	array	$extensions	specified extension
  * @return	void
  */
 public function extension($extensions = array())
 {
     if (!is_array($extensions)) {
         $extensions = array($extensions);
     }
     foreach ($extensions as $extension) {
         $plugin = strtolower(str_replace('.php', '', $extension));
         // If the extension is already loaded, continue on.
         if (isset($this->_ci_extensions[$extension])) {
             continue;
         }
         // Attempt to load the extension.
         if (file_exists($extension_path = sprintf(APPPATH . 'extend/%s/main.php', $extension))) {
             include $extension_path;
         } else {
             if (file_exists($extension_path = sprintf(BASEPATH . 'extend/%s/main.php', $extension))) {
                 include $extension_path;
             } else {
                 show_error(sprintf('Unable to load the requested file: extend/%s/main.php', $extension));
             }
         }
         // Initialize the plugin and log it.
         $this->_ci_extensions[$extension] = new $plugin();
         log_message('debug', sprintf('Extension loaded: %s', $plugin));
     }
 }
Example #6
0
 /**
  * Constructor - Sets Preferences
  *
  * The constructor can be passed an array of config values
  */
 public function __construct($config = array())
 {
     if (count($config) > 0) {
         $this->initialize($config);
     }
     log_message('debug', "FTP Class Initialized");
 }
Example #7
0
 /**
  * Constructor
  *
  * @access	public
  * @param	array	initialization parameters
  */
 function CI_Pagination($params = array())
 {
     if (count($params) > 0) {
         $this->initialize($params);
     }
     log_message('debug', "Pagination Class Initialized");
 }
Example #8
0
 /**
  * Load a language file
  *
  * @access	public
  * @param	mixed	the name of the language file to be loaded. Can be an array
  * @param	string	the language (english, etc.)
  * @return	mixed
  */
 function load($langfile = '', $idiom = '', $return = FALSE)
 {
     $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)) . '_lang' . EXT;
     if (in_array($langfile, $this->is_loaded, TRUE)) {
         return;
     }
     if ($idiom == '') {
         $CI =& get_instance();
         $deft_lang = $CI->config->item('language');
         $idiom = $deft_lang == '' ? 'english' : $deft_lang;
     }
     // Determine where the language file is and load it
     if (file_exists(APPPATH . 'language/' . $idiom . '/' . $langfile)) {
         include APPPATH . 'language/' . $idiom . '/' . $langfile;
     } else {
         if (file_exists(BASEPATH . 'language/' . $idiom . '/' . $langfile)) {
             include BASEPATH . 'language/' . $idiom . '/' . $langfile;
         } else {
             show_error('Unable to load the requested language file: language/' . $idiom . '/' . $langfile);
         }
     }
     if (!isset($lang)) {
         log_message('error', 'Language file contains no data: language/' . $idiom . '/' . $langfile);
         return;
     }
     if ($return == TRUE) {
         return $lang;
     }
     $this->is_loaded[] = $langfile;
     $this->language = array_merge($this->language, $lang);
     unset($lang);
     log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile);
     return TRUE;
 }
Example #9
0
 public function info_post()
 {
     //{{{
     $this->load->library('user_auth');
     $this->load->model('Follow', 'follow_m', TRUE);
     try {
         if (!$this->user_auth->is_user_login()) {
             $this->response(array('error' => 'user did not login yet.'), 500);
         } else {
             $object_user_id = $this->session->userdata('user_id');
             $user_id = $this->post('user_id', TRUE);
             $has_follow = $this->post('has_follow', TRUE);
             switch ($has_follow) {
                 case false:
                     $func_name = 'do_follow';
                     break;
                 case true:
                     $func_name = 'do_follow';
                     break;
             }
             $this->follow_m->{$func_name}($user_id, $object_user_id);
             $this->response(array(), 200);
         }
     } catch (Exception $e) {
         log_message('error', $e->getMessage());
         $this->response(array('error' => ''), 500);
     }
 }
Example #10
0
 /**
  * ๆž„้€ ๅ‡ฝๆ•ฐ
  * 
  * @access public
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     /** ไธป้ข˜็šฎ่‚คๆ‰€ๅœจ่ทฏๅพ„ */
     $this->themes_dir = FCPATH . ST_THEMES_DIR . DIRECTORY_SEPARATOR;
     log_message('debug', "STBLOG: Themes Model Class Initialized");
 }
Example #11
0
 public function get_access_token($provider, $grant = 'authorization_code', $code){
   if (! $provider) {
     log_message('error', __FILE__.' '.__LINE__.' Provider details not provided by the client for fetching Acess Token.');
     return FALSE;
   }
   
   $params = [
     'grant_type'    => $grant,
     'client_id'     => self::$SOCIAL_MEDIA_CREDENTIALS[$provider]['client_id'],
     'client_secret' => self::$SOCIAL_MEDIA_CREDENTIALS[$provider]['client_secret'],
     'redirect_uri'  => $this->redirect_url,
     'code'          => $code
   ];
   $params_string = http_build_query($params,'','&');
   
   $access_token_url = self::$SOCIAL_MEDIA_CREDENTIALS[$provider]['graph_url'].'oauth/access_token';
   
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $access_token_url);
   curl_setopt($ch, CURLOPT_POST, count($params));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
   curl_setopt($ch, CURLOPT_FAILONERROR, FALSE);
   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
   $output = curl_exec($ch);
   curl_close($ch);
   
   parse_str($output, $output_arr); 
   
   return $output_arr;
 }
Example #12
0
 public function buy_product($id, $amount, $product, $user_id, $user_money)
 {
     //Market Update
     $this->db->set('amount', 'amount -' . $amount, FALSE);
     $this->db->where('id', $id);
     $this->db->update('market');
     //Company Update
     $this->db->select('money');
     $query = $this->db->get_where('companies', array('id' => $product->company_id), 1);
     if ($query->num_rows() === 1) {
         foreach ($query->result() as $company) {
         }
     } else {
         $return = NULL;
         log_message('error', 'function buy_product() in /megapublik/models/market_m.php has received bad data for $product->company_id.');
     }
     $company_money = unserialize($company->money);
     $currency_money = money($company_money, $product->currency);
     $new_money[$product->currency] = round($currency_money + $amount * $product->price, 2);
     $company_money = array_merge($company_money, $new_money);
     $this->db->set('money', serialize($company_money));
     $this->db->where('id', $product->company_id);
     $this->db->update('companies');
     //User Update
     $currency_money = money($user_money, $product->currency);
     $new_money[$product->currency] = round($currency_money - $amount * $product->price, 2);
     $user_money = array_merge($user_money, $new_money);
     $this->db->set('money', serialize($user_money));
     $this->db->where('id', $user_id);
     $this->db->update('users');
     log_message('debug', number_format($amount, 0, '.', ',') . ' products bought with type "' . $product->type . '" and price "' . number_format($product->price, 2, '.', ',') . ' ' . $product->currency . '" by user with ID "' . $user_id . '"');
     return TRUE;
 }
Example #13
0
 public function index()
 {
     // Setup Spark
     $vrs = '0.0.1';
     // Update to your spark version
     $this->load->spark("codeigniter-payments/{$vrs}");
     $gateway = 'bluepay';
     // Change to reflect the identifier (Transaction ID from previous transaction)
     // Required for CAPTURE, REFUND, and VOID
     $identifier = '100000000000';
     // Only used for AUTH and ONEOFF
     $info = array('cc_number' => '4111111111111111', 'cc_code' => '203', 'cc_exp' => '022016', 'amt' => '25.00', 'email' => '*****@*****.**', 'first_name' => 'Bill', 'last_name' => 'Testing', 'street' => '181 Something Street', 'city' => 'Tompkinsville', 'state' => 'KY', 'country' => 'US', 'postal_code' => '42167');
     /**
      * INSTRUCTIONS: Uncomment the line below that you want to test out.
      */
     $response = 'Uncomment the line you want to test.';
     // One Off Payment Example
     // $response = $this->payments->oneoff_payment($gateway, $info);
     // Auth
     // $response = $this->payments->authorize_payment($gateway, $info);
     // Capture
     //$response = $this->payments->capture_payment($gateway, array('identifier' => $identifier));
     // Refund
     // $response = $this->payments->refund_payment($gateway, array('identifier' => $identifier));
     // Void Payment Example
     // $response = $this->payments->void_payment($gateway, array('identifier' => $identifier));
     // Display the Outcome
     echo "<pre>";
     print_r($response);
     echo "</pre>";
     // Just so you can check it out later
     // Probably want to store some of this information in a database
     log_message('error', 'GATEWAY RESPONSE!!');
     log_message('error', json_encode($response));
 }
Example #14
0
 function authentication_user($password)
 {
     try {
         log_message('debug', "AUTHENTICATION");
         $this->load->model('dto/DtoUser');
         $this->load->model('dao/DaoUser');
         $user = new DtoUser();
         $userDao = new DaoUser();
         $user->setUsername($this->input->post('username', TRUE));
         $user->setPassword(md5($this->input->post('password', TRUE)));
         $result = $userDao->login($user);
         if ($result) {
             foreach ($result as $row) {
                 $user->setUsername($row->username);
                 $user->setUserid($row->userid);
                 $user->setUsertype($row->usertype);
                 $this->session->set_userdata('logged_in', $user);
                 $this->session->set_userdata('username', $this->encryption->encrypt($user->getUsername()));
                 $this->session->set_userdata('userid', $this->encryption->encrypt($user->getUserid()));
                 $this->session->set_userdata('usertype', $user->getUsertype());
                 return TRUE;
             }
         } else {
             $this->form_validation->set_message('authentication_user', 'Invalid username or password. Please try again.');
             return false;
         }
     } catch (Exception $ex) {
         log_message('debug', $ex->getMessage());
     }
 }
Example #15
0
 public function __construct()
 {
     // Assign the main database object to $this->db
     $CI =& get_instance();
     $this->db =& $CI->db;
     log_message('debug', 'Database Forge Class Initialized');
 }
Example #16
0
 public function do_menu()
 {
     // start the unordered list
     $output = '<ul>';
     // get an array of enabled desklets from the database
     $enabled_desklets = $this->Database->get_enabled_desklets();
     // load the launcher.json config file for each enabled desklet and
     // then decode it into an array
     foreach ($enabled_desklets as $desklet => $array) {
         $launcher_json = 'assets/desktop/desklets/' . $desklet . '/launcher.json';
         if (file_exists($launcher_json)) {
             $handle = fopen($launcher_json, 'r');
             $json = fread($handle, filesize($launcher_json));
             fclose($handle);
             $desklets[$desklet] = json_decode($json, true);
         } else {
             log_message('error', 'The desklet "' . $desklet . '" was marked as enabled, but its launcher.json could not be found in ' . $launcher_json);
         }
     }
     // make a list item for each installed desklet
     foreach ($desklets as $desklet) {
         $output .= '<li><a href="' . site_url('assets/desktop/desklets/') . '/' . $desklet['name'] . '/" alt="' . $desklet['name'] . '" ><img src="' . site_url('assets/desktop/desklets') . '/' . $desklet['name'] . '/' . $desklet['icon'] . '" alt="' . $desklet['title'] . '" title="' . $desklet['title'] . '"></a></li>';
     }
     // if no desklets are found/installed, tell the user
     if (empty($desklets)) {
         $output .= '<li>No desklets could be found.</li>';
     }
     // end the unordered list
     $output .= '</ul>';
     // echo the output
     echo $output;
 }
Example #17
0
 /**
  * Constructor
  *
  * Calls the initialize() function
  */
 function Controller()
 {
     parent::CI_Base();
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     // In PHP 5 the Loader class is run as a discreet
     // class.  In PHP 4 it extends the Controller @PHP4
     if (is_php('5.0.0') == TRUE) {
         $this->load =& load_class('Loader', 'core');
         $this->load->_base_classes =& is_loaded();
         $this->load->_ci_autoloader();
     } else {
         $this->_ci_autoloader();
         // sync up the objects since PHP4 was working from a copy
         foreach (array_keys(get_object_vars($this)) as $attribute) {
             if (is_object($this->{$attribute})) {
                 $this->load->{$attribute} =& $this->{$attribute};
             }
         }
     }
     log_message('debug', "Controller Class Initialized");
 }
Example #18
0
 public function purge_cache($method, $cache_pages, $post_id = null, $user_id = null)
 {
     log_message('error', 'Invoked method: ' . $method);
     $caches = $this->CI->config->item('cacher');
     foreach ($caches[$method] as $cache) {
         if ($cache['paged'] != 0) {
             for ($i = 0; $i <= $cache_pages; $i++) {
                 $key = $cache['method'] . $i;
                 if (!$this->CI->cache->memcached->delete(sha1($key))) {
                     log_message('error', 'cache key: ' . $key);
                 }
             }
         } else {
             if ($cache['post_id'] == 1) {
                 $key = $cache['method'] . $post_id;
             } elseif ($cache['user_id'] == 1) {
                 $key = $cache['method'] . $user_id;
             } else {
                 $key = $cache['method'];
             }
             if ($this->CI->cache->memcached->delete(sha1($key))) {
                 log_message('error', 'cache key: ' . $key);
             }
         }
     }
 }
Example #19
0
 public function up()
 {
     $this->load->helper('date');
     $is_datetime = strtolower(Model::TIMESTAMP_FORMAT) == 'datetime';
     foreach ($this->tables() as $name => $prop) {
         $keys = [];
         $is_auto_timestamp = element(self::FLAG_AUTOTIMESTAMP, $prop, true);
         if ($schemas = element(self::DB_SCHEMAS, $prop, [])) {
             if (true === $is_auto_timestamp) {
                 $this->_auto_timestamp = true;
                 $creator = ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'default' => null];
                 if ($is_datetime) {
                     $timestamp = ['type' => 'datetime', 'default' => '0000-00-00 00:00:00'];
                 } else {
                     $timestamp = ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'default' => 0];
                 }
                 $schemas[Model::CREATION_KEY . '_by'] = $creator;
                 $schemas[Model::CREATION_KEY . '_at'] = $timestamp;
                 $schemas[Model::MODIFICATION_KEY . '_by'] = $creator;
                 $schemas[Model::MODIFICATION_KEY . '_at'] = $timestamp;
             }
             if (false === element(self::FLAG_DESTRUCTIVE, $prop, false)) {
                 $schemas[Model::DELETION_KEY] = ['type' => 'tinyint', 'constraint' => 1, 'unsigned' => true, 'DEFAULT' => 0];
             }
             foreach ($schemas as $column => $schema) {
                 if (isset($schema['key'])) {
                     $keys[$column] = $schema['key'];
                     unset($schema['key']);
                 }
             }
             if (true === element(self::FLAG_OVERRIDE, $prop, true)) {
                 $this->dbforge->drop_table($name, true);
             }
             $this->dbforge->add_field($schemas);
             if (!empty($keys)) {
                 foreach ($keys as $key => $value) {
                     $this->dbforge->add_key($key, $value);
                 }
             }
             if (false === element(self::FLAG_ALTERTABLE, $prop, false)) {
                 if ($this->dbforge->create_table($name, true, ['engine' => 'InnoDB'])) {
                     log_message('info', 'Migration successfully create table ' . $name);
                 } else {
                     log_message('error', 'Migration failed to create table ' . $name);
                 }
             }
         }
         if ($data = element(self::DB_DATA, $prop, [])) {
             if (true === $is_auto_timestamp) {
                 $now = $is_datetime ? date('Y-m-d H:i:s') : time();
                 for ($d = 0; $d < count($data); $d++) {
                     $data[$d] += [Model::CREATION_KEY . '_by' => null, Model::CREATION_KEY . '_at' => $now, Model::MODIFICATION_KEY . '_by' => null, Model::MODIFICATION_KEY . '_at' => $now];
                 }
             }
             if ($this->db->insert_batch($name, $data)) {
                 log_message('info', 'Migration successfully insert data to table ' . $name);
             }
         }
     }
 }
Example #20
0
function wpci_template($default)
{
    log_message('debug', "Default template is {$default}");
    $template = $default;
    if (is_codeigniter()) {
        global $RTR;
        // application/class/action template
        if ($path = template_exists($RTR->fetch_app() . '/' . $RTR->fetch_class() . '/' . $RTR->fetch_method() . EXT)) {
            $template = $path;
        } else {
            if ($path = template_exists($RTR->fetch_app() . '/' . $RTR->fetch_class() . EXT)) {
                $template = $path;
            } else {
                if ($path = template_exists($RTR->fetch_class() . '/' . $RTR->fetch_method() . EXT)) {
                    $template = $path;
                } else {
                    if ($path = template_exists($RTR->fetch_class() . EXT)) {
                        $template = $path;
                    } else {
                        if ($path = template_exists($RTR->fetch_app() . EXT)) {
                            $template = $path;
                        } else {
                            if ($path = template_exists('codeigniter' . EXT)) {
                                $template = $path;
                            }
                        }
                    }
                }
            }
        }
    }
    log_message('debug', "Loading template {$template}");
    return $template;
}
 /**
  * Class constructor
  *
  * Setup Memcache(d)
  *
  * @return    void
  */
 public function __construct()
 {
     // Try to load memcached server info from the config file.
     $CI =& get_instance();
     $defaults = $this->_config['default'];
     if ($CI->config->load('memcached', TRUE, TRUE)) {
         $this->_config = $CI->config->config['memcached'];
     }
     if (class_exists('Memcached', FALSE)) {
         $this->_memcached = new Memcached();
     } elseif (class_exists('Memcache', FALSE)) {
         $this->_memcached = new Memcache();
     } else {
         log_message('error', 'Cache: Failed to create Memcache(d) object; extension not loaded?');
         return;
     }
     foreach ($this->_config as $cache_server) {
         isset($cache_server['hostname']) or $cache_server['hostname'] = $defaults['host'];
         isset($cache_server['port']) or $cache_server['port'] = $defaults['port'];
         isset($cache_server['weight']) or $cache_server['weight'] = $defaults['weight'];
         if ($this->_memcached instanceof Memcache) {
             // Third parameter is persistance and defaults to TRUE.
             $this->_memcached->addServer($cache_server['hostname'], $cache_server['port'], TRUE, $cache_server['weight']);
         } elseif ($this->_memcached instanceof Memcached) {
             $this->_memcached->addServer($cache_server['hostname'], $cache_server['port'], $cache_server['weight']);
         }
     }
 }
Example #22
0
 function __construct()
 {
     parent::__construct();
     $this->load->helper('url');
     $this->CI =& get_instance();
     $this->CI->load->database("", FALSE, TRUE);
     $this->CI->load->library('pagination');
     // Turn off caching
     $this->CI->db->cache_off();
     $this->table_url = isset($_GET['table']) ? "?table={$_GET['table']}" : '';
     $this->tables_list = $this->db->list_tables();
     /**
      * If scaffolding disable is set to true, redirect to default controller
      */
     if ($this->config->item('scaffolding_disable')) {
         redirect($this->router->default_controller);
         exit;
     }
     /**
      * Set the current table name
      */
     $this->current_table = isset($_GET['table']) ? $_GET['table'] : ($this->config->item('scaffolding_table') ? $this->config->item('scaffolding_table') : $this->tables_list[0]);
     // Set the base URL
     $this->base_url = $this->CI->config->site_url() . '/' . $this->CI->uri->segment(1) . $this->CI->uri->slash_segment(2, 'both');
     $this->base_uri = $this->CI->uri->segment(1) . $this->CI->uri->slash_segment(2, 'leading');
     // Set a few globals
     $data = array('image_url' => $this->CI->config->system_url() . 'scaffolding/images/', 'base_uri' => $this->base_uri, 'base_url' => $this->base_url, 'title' => $this->current_table, 'table_url' => $this->table_url, 'tables' => $this->tables_list);
     $this->CI->load->vars($data);
     // Load the language file
     $this->lang->load('scaffolding');
     //  Load the helper files we plan to use
     $this->CI->load->helper(array('url', 'form'));
     log_message('debug', 'Scaffolding Class Initialized');
 }
Example #23
0
 /**
  * Constructor - Sets Preferences
  *
  * The constructor can be passed an array of config values
  */
 function CI_FTP($config = array())
 {
     if (count($config) > 0) {
         $this->initialize($config);
     }
     log_message('debug', "FTP Class Initialized");
 }
Example #24
0
	/**
	 * Class constructor
	 *
	 * @return	void
	 */
	public function __construct()
	{
		self::$instance =& $this;

		// Assign all the class objects that were instantiated by the
		// bootstrap file (CodeIgniter.php) to local class variables
		// so that CI can run as one big super object.
		foreach (is_loaded() as $var => $class)
		{
			$this->$var =& load_class($class);
		}

		$this->load =& load_class('Loader', 'core');
		$this->load->initialize();
		log_message('info', 'Controller Class Initialized');
                user_logged_in();
                //echo $user_type = $this->session->userdata['department'];
                $valid_method = get_restricted_department();
                $user_type = strtolower($this->session->userdata['department']);
                if(in_array($user_type, $valid_method)) {
					user_authentication($user_type);
                }
                
               
	}
Example #25
0
 function error($exception, $message = NULL)
 {
     if ($this->enable_logging === TRUE) {
         if (is_string($exception) && $message == NULL) {
             $message = $exception;
             $exception = NULL;
         }
         if (is_object($exception)) {
             $error_message = "Error on line " . $exception->getLine() . " in " . $exception->getFile();
         } else {
             if (is_string($exception)) {
                 $error_message = $exception;
             } else {
                 $error_message = '';
             }
         }
         if ($message == NULL) {
             $message = $error_message;
         } else {
             if ($error_message != '') {
                 $message = $error_message . ": " . $message;
             }
         }
         $message = $this->_prepend_class_name($message);
         log_message('error', $message);
     }
 }
Example #26
0
 public function reject($id)
 {
     $this->auth->checkIfOperationIsAllowed('reject_overtime');
     $this->load->model('users_model');
     $this->load->model('delegations_model');
     $extra = $this->overtime_model->getExtras($id);
     if (empty($extra)) {
         redirect('notfound');
     }
     $employee = $this->users_model->getUsers($extra['employee']);
     $is_delegate = $this->delegations_model->isDelegateOfManager($this->user_id, $employee['manager']);
     if ($this->user_id == $employee['manager'] || $this->is_hr || $is_delegate) {
         $this->overtime_model->rejectExtra($id);
         $this->sendMail($id);
         $this->session->set_flashdata('msg', lang('overtime_reject_flash_msg_success'));
         if (isset($_GET['source'])) {
             redirect($_GET['source']);
         } else {
             redirect('overtime');
         }
     } else {
         log_message('error', 'User #' . $this->user_id . ' illegally tried to reject extra #' . $id);
         $this->session->set_flashdata('msg', lang('overtime_reject_flash_msg_error'));
         redirect('leaves');
     }
 }
Example #27
0
 function auth()
 {
     if (!$this->common->isUserLogin()) {
         $dataheader['login'] = false;
         $dataheader['pageTitle'] = $this->common->getPageTitle($this->router->fetch_class());
         $this->load->view('layout/header', $dataheader);
     } else {
         $dataheader['user_id'] = $this->common->getUserId();
         $dataheader['pageTitle'] = $this->common->getPageTitle($this->router->fetch_class());
         if ($this->common->isAdmin()) {
             $dataheader['admin'] = true;
         }
         $dataheader['login'] = true;
         $dataheader['username'] = $this->common->getUserName();
         $product = $this->common->getCurrentProduct();
         if (isset($product) && $product != null) {
             $dataheader['product'] = $product;
             log_message("error", "HAS Product");
         }
         $productList = $this->product->getAllProducts($dataheader['user_id']);
         if ($productList != null && $productList->num_rows() > 0) {
             $dataheader["productList"] = $productList;
         }
         $this->load->model('pluginlistmodel');
         $userId = $this->common->getUserId();
         $userKeys = $this->pluginlistmodel->getUserKeys($userId);
         if ($userKeys) {
             $dataheader['key'] = $userKeys->user_key;
             $dataheader['secret'] = $userKeys->user_secret;
         }
         log_message("error", "Load Header 123");
         $this->load->view('layout/header', $dataheader);
     }
 }
 function Scaffolding($db_table)
 {
     $this->CI =& get_instance();
     $this->CI->load->database("", FALSE, TRUE);
     $this->CI->load->library('pagination');
     // Turn off caching
     $this->CI->db->cache_off();
     /**
      * Set the current table name
      * This is done when initializing scaffolding:
      * $this->load->scaffolding('table_name')
      *
      */
     $this->current_table = $db_table;
     /**
      * Set the path to the "view" files
      * We'll manually override the "view" path so that
      * the load->view function knows where to look.
      */
     $this->CI->load->_ci_view_path = BASEPATH . 'scaffolding/views/';
     // Set the base URL
     $this->base_url = $this->CI->config->site_url() . '/' . $this->CI->uri->segment(1) . $this->CI->uri->slash_segment(2, 'both');
     $this->base_uri = $this->CI->uri->segment(1) . $this->CI->uri->slash_segment(2, 'leading');
     // Set a few globals
     $data = array('image_url' => $this->CI->config->system_url() . 'scaffolding/images/', 'base_uri' => $this->base_uri, 'base_url' => $this->base_url, 'title' => $this->current_table);
     $this->CI->load->vars($data);
     // Load the language file and create variables
     $this->lang = $this->CI->load->scaffold_language('scaffolding', '', TRUE);
     $this->CI->load->vars($this->lang);
     //  Load the helper files we plan to use
     $this->CI->load->helper(array('url', 'form'));
     log_message('debug', 'Scaffolding Class Initialized');
 }
Example #29
0
 /**
  * Constructor
  *
  * Grabs the CI super object instance so we can access it.
  *
  */
 function CI_DB_utility()
 {
     // Assign the main database object to $this->db
     $CI =& get_instance();
     $this->db =& $CI->db;
     log_message('debug', "Database Utility Class Initialized");
 }
Example #30
0
 public function error_view($msg = '', $log = '', $ret = FALSE)
 {
     if ($log !== '') {
         log_message('error', $log);
     }
     echo $msg;
 }