/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_regions(&$Form)
{
    load_class('regional/model/_country.class.php', 'Country');
    $CountryCache =& get_CountryCache(NT_('All'));
    $Form->select_country('c', get_param('c'), $CountryCache, T_('Country'), array('allow_none' => true));
    $Form->text('s', get_param('s'), 30, T_('Search'), '', 255);
}
Example #2
0
 public function cache_select()
 {
     $uid = $_SESSION['uid'];
     if (isset($GLOBALS['setcache'])) {
         $ids = get_cache('cache_all-' . $uid);
     } else {
         if (!isset($GLOBALS['ids']) || empty($GLOBALS['ids'])) {
             $where = array('keyid' => 'cache_all');
             $result = $this->db->get_list('setting', $where, '*', 0, 100);
             $ids = array();
             foreach ($result as $r) {
                 $ids[] = $r['id'];
             }
         } else {
             $ids = array_map('intval', $GLOBALS['ids']);
         }
         set_cache('cache_all-' . $uid, $ids);
     }
     if (empty($ids)) {
         MSG('缓存更新完成', '?m=core&f=cache_all&v=index' . $this->su(), 2000);
     }
     $id = array_shift($ids);
     $r = $this->db->get_one('setting', array('id' => $id));
     $caches = load_class($r['f'], $r['m']);
     if ($caches->{$r}['v']()) {
         set_cache('cache_all-' . $uid, $ids);
         MSG($r['data'] . L('update success'), '?m=core&f=cache_all&v=cache_select&setcache=1&' . $this->su(), 200);
     } else {
         MSG(L('operation failure'));
     }
 }
Example #3
0
 /**
  * Base loader method, uses a directive, unlike the global loader function
  * @param string Class directive as `[class].[type]`
  * @return class object
  **/
 protected function load_class($class)
 {
     $class = strtolower($class);
     $type = null;
     $_pieces = explode(self::DIRECTIVE_DELIMITER, $class);
     switch (count($_pieces)) {
         case 1:
             $class = $_pieces[0];
             $type = $class;
             break;
         case 2:
             $class = $_pieces[1];
             $type = $_pieces[0];
             break;
         case 0:
             throw new RuntimeException('class to load not specified');
             break;
         default:
             throw new RuntimeException('class directive not supported');
             break;
     }
     if (!isset($this->{$class})) {
         $this->{$class} =& load_class($class, true, $type);
     }
     $this->is_loaded[] = $class;
     return $this->{$class};
 }
Example #4
0
 function _initialize()
 {
     $CFG =& load_class('Config', 'core');
     // If hooks are not enabled in the config file
     // there is nothing else to do
     if ($CFG->item('enable_hooks') == FALSE) {
         return;
     }
     // Grab the "hooks" definition file.
     // If there are no hooks, we're done.
     if (defined('ENVIRONMENT') and is_file(ARCHPATH . 'config/' . ENVIRONMENT . '/hooks.php')) {
         include ARCHPATH . 'config/' . ENVIRONMENT . '/hooks.php';
     } elseif (is_file(ARCHPATH . 'config/hooks.php')) {
         include ARCHPATH . 'config/hooks.php';
     }
     if (defined('ENVIRONMENT') and is_file(APPPATH . 'config/' . ENVIRONMENT . '/hooks.php')) {
         include APPPATH . 'config/' . ENVIRONMENT . '/hooks.php';
     } elseif (is_file(APPPATH . 'config/hooks.php')) {
         include APPPATH . 'config/hooks.php';
     }
     if (!isset($hook) or !is_array($hook)) {
         return;
     }
     $this->hooks =& $hook;
     $this->enabled = TRUE;
 }
Example #5
0
 /**
  * 做一个login
  */
 public function login()
 {
     if (IS_AJAX && 'submit' == I('post.submit')) {
         //login 操作
         $username = I('post.username');
         $userpass = I('post.userpass');
         //表单令牌
         if (token_check() == false) {
             printJson(array('tk' => form_token()), 1, '请求超时,请重试');
         }
         $mod = Factory::getModel('bt_user');
         $where = sprintf("username='******' AND deleted=0", $username);
         $row = $mod->field('id,userpass,salt')->where($where)->find();
         if (empty($row)) {
             printJson(array('tk' => form_token()), 1, '账号不存在');
         }
         if ($row['userpass'] != md5($userpass . $row['salt'])) {
             printJson(array('tk' => form_token()), 1, '账号或者密码不正确');
         }
         $row['username'] = $username;
         session_regenerate_id();
         $user_cls = load_class('UserModel');
         $user_cls->setSessionUser($row);
         printJson(1);
     }
     $turl = urldecode(I('get.url', url('DiskTop', 'index')));
     $this->assign('turl', $turl);
     $this->display();
 }
Example #6
0
 /**
  * Initialize the Hooks Preferences
  *
  * @access	private
  * @return	void
  */
 function _initialize()
 {
     $CFG =& load_class('Config', 'core');
     // If hooks are not enabled in the config file
     // there is nothing else to do
     if ($CFG->item('enable_hooks') == FALSE) {
         return;
     }
     $look_in_dirs = $CFG->look_in_dirs();
     // Grab the "hooks" definition file.
     // If there are no hooks, we're done.
     if (defined('ENVIRONMENT') and is_file(APPPATH . 'config/' . ENVIRONMENT . '/hooks.php')) {
         include APPPATH . 'config/' . ENVIRONMENT . '/hooks.php';
     } else {
         $hook_files = array(NTS_SYSTEM_APPPATH . 'config/hooks.php', APPPATH . 'config/hooks.php');
         reset($look_in_dirs);
         foreach ($look_in_dirs as $dir) {
             $hf = $dir . '/config/hooks.php';
             if (file_exists($hf)) {
                 require $hf;
             }
         }
     }
     if (!isset($hook) or !is_array($hook)) {
         return;
     }
     $this->hooks =& $hook;
     $this->enabled = TRUE;
 }
Example #7
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 #8
0
 public function __construct()
 {
     self::$obj =& $this;
     foreach (is_load() as $key => $value) {
         $this->{$key} =& load_class($value);
     }
 }
Example #9
0
 /**
  * осуществление платежа 
  * 
  * @param array $fields массив с полями формы
  * @return ничего не возвращает
  */
 public function deposit($fields)
 {
     $CI =& get_instance();
     $CI->load->model('payment_gateways', '', TRUE);
     $data = $CI->payment_gateways->data('paypal');
     if ($fields['amount'] < $data->minimal_payment) {
         return _('Payment amount can\'t be less then ') . type_to_str($data->minimal_payment, 'money') . ".";
     }
     // Деньги для зачисления
     $value = number_format(type_cast($fields['amount'], 'float'), 2, '.', '');
     // Общая сумма
     $amount = $value + $value * $data->fund_comm / 100;
     $amount = number_format(type_cast((string) $amount, 'float'), 2, '.', '');
     $sitename = $CI->global_variables->get('SiteName');
     $time = time();
     $email_from = $CI->get_email();
     $email_to = $data->account_id_1;
     $site_url = $CI->get_siteurl();
     $trans_id = $this->save_transaction($email_from, $time, $amount, $value);
     $data = array('AMOUNT' => $amount, 'EMAIL' => $email_to, 'ITEMNAME' => $sitename . ': Deposit from ' . $email_from . ' ($' . type_to_str($amount, 'float') . ')', 'TIME' => $time, 'RETURN' => $site_url . 'advertiser/add_funds/success', 'CANCEL' => $site_url . 'advertiser/add_funds', 'NOTIFY' => $site_url . 'common/paypal_notify', 'TRANSID' => $trans_id);
     $html = $this->parser->parse('common/payments/paypal.html', $data, TRUE);
     $LOG =& load_class('Log');
     $LOG->write_log('ERROR', 'Request: ' . $html);
     echo $html;
     exit;
 }
 public static function parse_bbcode($text)
 {
     if (!$text) {
         return false;
     }
     return self::parse_links(load_class('Services_BBCode')->parse($text));
 }
Example #11
0
 function index()
 {
     $form = load_class('form');
     echo '<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>Plupload - Events example</title>';
     echo $form->upload('insert_file_callback');
     //include T('attachment','upload','default');
 }
 /**
  * Get Route including 404 check
  *
  * @see core/CodeIgniter.php
  *
  * @return array   [class, method, pararms]
  */
 public function getRoute()
 {
     $RTR =& load_class('Router', 'core');
     $URI =& load_class('URI', 'core');
     $e404 = FALSE;
     $class = ucfirst($RTR->class);
     $method = $RTR->method;
     if (empty($class) or !file_exists(APPPATH . 'controllers/' . $RTR->directory . $class . '.php')) {
         $e404 = TRUE;
     } else {
         require_once APPPATH . 'controllers/' . $RTR->directory . $class . '.php';
         if (!class_exists($class, FALSE) or $method[0] === '_' or method_exists('CI_Controller', $method)) {
             $e404 = TRUE;
         } elseif (method_exists($class, '_remap')) {
             $params = array($method, array_slice($URI->rsegments, 2));
             $method = '_remap';
         } elseif (!in_array(strtolower($method), array_map('strtolower', get_class_methods($class)), TRUE)) {
             $e404 = TRUE;
         }
     }
     if ($e404) {
         // If 404, CodeIgniter instance is not created yet. So create it here.
         // Because we need CI->output->_status
         $CI =& get_instance();
         if ($CI instanceof CIPHPUnitTestNullCodeIgniter) {
             CIPHPUnitTest::createCodeIgniterInstance();
         }
         show_404($RTR->directory . $class . '/' . $method . ' is not found');
     }
     if ($method !== '_remap') {
         $params = array_slice($URI->rsegments, 2);
     }
     return [$class, $method, $params];
 }
Example #13
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 #14
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 #15
0
 public function __construct()
 {
     $this->config =& load_class('Config', 'core');
     $this->config->load('triggers', TRUE);
     $this->uri =& load_class('URI', 'core');
     log_message('debug', "Router Class Initialized");
 }
Example #16
0
 public function createTrace($type = null, $message = null, $file = null, $line = null, $custom_data = array())
 {
     if (empty($type)) {
         $e = error_get_last();
         if (!empty($e)) {
             $message = $e['message'];
             $file = $e['file'];
             $type = $e['type'];
             $line = $e['line'];
         }
     }
     if (!empty($type)) {
         $levels = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice');
         // Set error type
         $type = isset($levels[$type]) ? $levels[$type] : 'Unknown';
         // Fetch router
         $router =& load_class('Router', 'core');
         // Set up the trace file (1 level is better than none)
         $trace = array();
         $trace[0] = array();
         $trace[0]['function'] = $router->fetch_method();
         $trace[0]['class'] = $router->fetch_class();
         $trace[0]['type'] = $type;
         $trace[0]['args'] = array();
         $trace[0]['file'] = $file;
         $trace[0]['line'] = $line;
         // Send to airbrake
         self::sendToTracker($type . ': ' . $message, $type, $trace, $custom_data);
     }
 }
Example #17
0
 function __construct()
 {
     //allow mongo to use 64bit ints
     ini_set('mongo.native_long', 1);
     // Fetch CodeIgniter instance
     $ci = get_instance();
     // Load Mongo configuration file
     $ci->load->config('mongo');
     // Fetch Mongo server and database configuration
     $server = $ci->config->item('mongo_server');
     $username = $ci->config->item('mongo_username');
     $password = $ci->config->item('mongo_password');
     $dbname = $ci->config->item('mongo_dbname');
     try {
         if ($ci->config->item('mongo_auth') === FALSE) {
             parent::__construct("mongodb://" . $server . "/" . $dbname);
         } else {
             parent::__construct("mongodb://{$username}:{$password}@{$server}/{$dbname}");
         }
         $this->db = $this->{$dbname};
     } catch (MongoConnectionException $e) {
         //Don't show Mongo Exceptions as they can contain authentication info
         $_error =& load_class('Exceptions', 'core');
         exit($_error->show_error('MongoDB Connection Error', 'A MongoDB error occured while trying to connect to the database!', 'error_db'));
     } catch (Exception $e) {
         $_error =& load_class('Exceptions', 'core');
         exit($_error->show_error('MongoDB Error', $e->getMessage(), 'error_db'));
     }
 }
Example #18
0
	/**
	 * Initialize the Hooks Preferences
	 *
	 * @access	private
	 * @return	void
	 */
	function _initialize()
	{
		$CFG =& load_class('Config', 'core');

		// If hooks are not enabled in the config file
		// there is nothing else to do

		if ($CFG->item('enable_hooks') == FALSE)
		{
			return;
		}

		// Grab the "hooks" definition file.
		// If there are no hooks, we're done.

		@include(APPPATH.'config/hooks'.EXT);

		if ( ! isset($hook) OR ! is_array($hook))
		{
			return;
		}

		$this->hooks =& $hook;
		$this->enabled = TRUE;
	}
 /**
  * Called just after each controller instanciation
  * Displays or not the full page cache
  *
  */
 function post_controller_constructor_cache()
 {
     $CI =& get_instance();
     $CFG =& load_class('Config');
     $URI =& load_class('URI');
     $OUT =& load_class('Output');
     // No cache if :
     // - If some POST data are sent
     // - Admin URL
     // - User logged in
     if (!empty($_POST) or Connect()->logged_in() != FALSE or $URI->segments[1] == config_item('admin_url')) {
         // Regenerate the page
         return FALSE;
     }
     // Retrieve the complete URI with language code
     $URI->_fetch_uri_string();
     /*
      * HERE : 	Outputs the Cache()->get_page_cache()
      * 			If cache file not found returns false, but do not write the cache file
      *			Writin gof the cache file is done by Base_Controller()->render() depending on the page settings.
      *
      */
     /*
     		if ($OUT->_display_cache($CFG, $URI) == TRUE)
     			exit;
     */
 }
Example #20
0
 function pay_callback()
 {
     $api = load_class('pay_callback', 'order');
     if ($api->update('20150120237490658')) {
         echo 'ok';
     }
 }
Example #21
0
 function check()
 {
     session_start();
     $CI =& get_instance();
     $this->uri =& load_class('URI');
     $CI->load->library('session');
     $url = $this->uri->uri_string();
     log_message("info", $url);
     if (substr_count($url, "/page/") > 0) {
         $start = strpos($url, "/page");
         $url = str_replace("/page/", "/", $url);
     }
     if ("/admin/admin/norole" == $url || "/admin/admin" == $url || "/admin/admin/login" == $url) {
     } else {
         if ($CI->session->userdata("email") == "admin") {
             log_message("info", "email: " . $CI->session->userdata("email"));
         } else {
             $res_array = split(",", $CI->session->userdata('resources'));
             $flag = FALSE;
             foreach ($res_array as $res) {
                 log_message("error", $res);
                 if ($res != null && $res != "" && substr_count($url, $res) > 0) {
                     $flag = TRUE;
                     break;
                 }
             }
             log_message("error", "55555555" . $flag);
             if (!$flag) {
                 redirect("/admin/norole");
                 //echo ("<script>window.location='".base_url()."index.php/admin/admin/norole'</script>");
             }
         }
     }
 }
Example #22
0
 public function __construct($emulator, $driver, $char, $world)
 {
     // Load the loader class
     $this->load = load_class('Loader');
     // First, we must load the driver config!
     $file = path(WOWLIB_ROOT, 'drivers', strtolower($emulator), strtolower($driver), 'Driver.php');
     // If extension doesnt exist, return false
     if (!file_exists($file)) {
         throw new \Exception('Config file for driver ' . $driver . ' not found');
     }
     require $file;
     // Load the config variables into a local variable
     $this->config = $config;
     $this->CDB = false;
     $this->WDB = false;
     // Load the character DB
     if (is_array($char)) {
         try {
             $this->CDB = $this->load->database($char, false, true);
         } catch (\Exception $e) {
             $this->CDB = false;
         }
     }
     // Load world DB
     if (is_array($world)) {
         try {
             $this->WDB = $this->load->database($world, false, true);
         } catch (\Exception $e) {
             $this->WDB = false;
         }
     }
     // Finally set our emulator and driver variables
     $this->emulator = $emulator;
     $this->driver = $driver;
 }
Example #23
0
/**
 * Reset CodeIgniter instance
 */
function reset_instance()
{
    // Reset loaded classes
    load_class('', '', NULL, TRUE);
    is_loaded('', TRUE);
    // Close db connection
    $CI =& get_instance();
    if (isset($CI->db)) {
        if ($CI->db->dsn !== 'sqlite::memory:' && $CI->db->database !== ':memory:') {
            $CI->db->close();
            $CI->db = null;
        } else {
            // Don't close if SQLite in-memory database
            // If we close it, all tables and stored data will be gone
            load_class_instance('db', $CI->db);
        }
    }
    // Load core classes
    load_class('Benchmark', 'core');
    load_class('Hooks', 'core');
    load_class('Config', 'core');
    //	load_class('Utf8', 'core');
    load_class('URI', 'core');
    load_class('Router', 'core');
    load_class('Output', 'core');
    load_class('Security', 'core');
    load_class('Input', 'core');
    load_class('Lang', 'core');
    CIPHPUnitTest::loadLoader();
    // Remove CodeIgniter instance
    $CI = new CIPHPUnitTestNullCodeIgniter();
}
function execute_command($command, $capability, $db, $request)
{
    if (!empty($command) && ($action = load_class($command))) {
        try {
            if (!authorize_command($command, $capability)) {
                log_message('error', sprintf("insufficient privileges for operation %s", $command));
                header("Content-Type: application/json", true);
                echo '{"Message":"Insufficient privileges"}';
            } else {
                // this is really ugly and should be done by passing
                // the capability separately into the function
                // $request['_Capability'] = $capability;
                $action->Execute($db, $request);
            }
        } catch (Exception $ex) {
            log_message('error', "Service {$command} threw an exception: " . print_r($ex, true));
            header("Content-Type: application/json", true);
            echo '{"Message":"Unhandled error"}';
        }
    } else {
        log_message('warn', 'An empty or unrecognized command was requested: ' . $command);
        header("Content-Type: application/json", true);
        echo '{"Message":"Unsupported or missing RequestMethod"}';
    }
}
Example #25
0
 /**
  * Constructor
  *
  * Runs the route mapping function.
  */
 function Router()
 {
     $this->config =& load_class('Config');
     $this->uri =& load_class('URI');
     $this->_set_routing();
     log_message('debug', "Router Class Initialized");
 }
 /**
  * CSRF Verify
  *
  * @return	CI_Security
  */
 public function csrf_verify()
 {
     // If it's not a POST request we will set the CSRF cookie
     if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') {
         return $this->csrf_set_cookie();
     }
     // Check if URI has been whitelisted from CSRF checks
     if ($exclude_uris = config_item('csrf_exclude_uris')) {
         $uri = load_class('URI', 'core');
         foreach ($exclude_uris as $excluded) {
             if (preg_match('#^' . $excluded . '$#i' . (UTF8_ENABLED ? 'u' : ''), $uri->uri_string())) {
                 return $this;
             }
         }
     }
     // Do the tokens exist in both the _POST and _COOKIE arrays?
     if (!isset($_POST[$this->_csrf_token_name], $_COOKIE[$this->_csrf_cookie_name]) or $_POST[$this->_csrf_token_name] !== $_COOKIE[$this->_csrf_cookie_name]) {
         $this->csrf_show_error();
     }
     // We kill this since we're done and we don't want to polute the _POST array
     unset($_POST[$this->_csrf_token_name]);
     // Regenerate on every submission?
     if (config_item('csrf_regenerate')) {
         // Nothing should last forever
         unset($_COOKIE[$this->_csrf_cookie_name]);
         $this->_csrf_hash = NULL;
     }
     $this->_csrf_set_hash();
     $this->csrf_set_cookie();
     log_message('info', 'CSRF token verified');
     return $this;
 }
Example #27
-1
 public static function parse_markdown($text)
 {
     if (!$text) {
         return false;
     }
     return load_class('Services_Markdown')->transform($text);
 }
Example #28
-1
 public function index($params)
 {
     require_once 'permissions.php';
     $baseURL = $GLOBALS['CFG']->config['base_url'];
     $routing =& load_class('Router');
     $class = $routing->fetch_class();
     //$method = $routing->fetch_method();
     if (!empty($doesNotRequireLogin[$class])) {
         return true;
     } else {
         if (!$_SESSION['userType']) {
             //checking authentication
             header("location: {$baseURL}logout/");
             exit;
         } else {
             if (empty($permissions[$_SESSION['userType']][$class]) || $permissions[$_SESSION['userType']][$class] != true) {
                 //return true;
                 //exit();
                 //header("location: {$baseURL}");
                 echo $_SESSION['userType'];
                 exit;
             } else {
                 return true;
             }
         }
     }
 }
Example #29
-1
 function __construct()
 {
     $this->member = load_class('member', M);
     load_function('common', M);
     $this->setting = get_cache('setting', M);
     parent::__construct();
 }
Example #30
-8
 /**
  * Check & Set URI resource to determine the side of application
  *
  */
 public function __construct()
 {
     parent::__construct();
     $uri =& load_class('URI', 'core');
     $admin = $uri->segment(1);
     $this->is_admin = $admin == 'administrator' || $admin == 'admin' ? true : false;
 }