function getDanhsachhoso($iddv) { $luongcoban = Core::config('cbcc/luong/luongcoban'); $bhxh = Core::config('cbcc/luong/phantrambhxh') / 100; $bhyt = Core::config('cbcc/luong/phantrambhyt') / 100; $db = JFactory::getDbo(); $query = 'select hosochinh_id, hoten, congtac_chucvu,congtac_donvi_id, congtac_donvi,congtac_phong_id, congtac_phong, luong_mangach, luong_heso, congtac_chucvu_heso ,luong_vuotkhung, luong_phucap_trachnhiem, hs.e_code , ht.name, ht.s_name from hosochinh_quatrinhhientai as hsht INNER JOIN hosochinh as hs ON hs.id = hsht.hosochinh_id INNER JOIN bc_hinhthuc as ht ON ht.id = hsht.bienche_hinhthuc_id WHERE hsht.hoso_trangthai = "00" and congtac_donvi_id = ' . $db->quote($iddv) . ' ORDER BY congtac_phong_id ASC, congtac_chucvutuongduong ASC'; // -- , luong_phucap_trachnhiem; $db->setQuery($query); $data = $db->loadAssocList(); // var_dump($data); exit; for ($i = 0; $i < count($data); $i++) { $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']] = $data[$i]; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['tongheso'] = $data[$i]['luong_heso'] + $data[$i]['congtac_chucvu_heso'] + $data[$i]['luong_phucap_trachnhiem'] + $data[$i]['luong_vuotkhung']; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['luong_tt'] = $data[$i]['luong_heso'] * $luongcoban; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['chucvu_tt'] = $data[$i]['congtac_chucvu_heso'] * $luongcoban; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['trachnhiem_tt'] = $data[$i]['luong_phucap_trachnhiem'] * $luongcoban; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['vuotkhung_tt'] = $data[$i]['luong_vuotkhung'] * $luongcoban * $data[$i]['luong_heso'] / 100; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['tongthanhtien'] = ($data[$i]['luong_heso'] + $data[$i]['congtac_chucvu_heso'] + $data[$i]['luong_phucap_trachnhiem']) * $luongcoban + $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['vuotkhung_tt']; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['bhxh'] = $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['tongthanhtien'] * $bhxh; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['bhyt'] = $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['tongthanhtien'] * $bhyt; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['cong_truluong'] = $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['bhxh'] + $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['bhyt']; $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['tongtienluongnhan'] = $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['tongthanhtien'] - $ar_data[$data[$i]['congtac_phong_id']]['data'][$data[$i]['hosochinh_id']]['cong_truluong']; $ar_data[$data[$i]['congtac_phong_id']]['name'] = $data[$i]['congtac_phong']; } // var_dump($ar_data); exit; return $ar_data; }
/** * [action_form] generates the form to pay at paypal */ public function action_form() { $this->auto_render = FALSE; $order_id = $this->request->param('id'); $order = new Model_Order(); $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { // dependant on product we have different names if ($order->id_product == Paypal::to_featured) { $item_name = __('Advertisement to featured'); } else { if ($order->id_product == Paypal::to_top) { $item_name = __('Advertisement to top'); } else { $item_name = $order->description . __(' category'); } } $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway; $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => core::config('payment.paypal_account'), 'paypal_currency' => core::config('payment.paypal_currency'), 'item_name' => $item_name); $this->template = View::factory('paypal', $paypal_data); $this->response->body($this->template->render()); } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->request->redirect(Route::url('default')); } }
/** * generates HTML for apy buton * @param Model_Order $order * @return string */ public static function button(Model_Order $order) { if (Core::config('payment.stripe_private') != '' and Core::config('payment.stripe_public') != '' and Theme::get('premium') == 1) { return View::factory('pages/stripe/button', array('order' => $order)); } return ''; }
public static function initialise() { self::$tplHandler = new TemplateLoader('db', 'default'); self::$preloadHandler = new PreloadFunctions('db'); include_once dirname(__FILE__) . '/config.php'; self::$config = $_CONFIG; }
private function __construct() { self::init(); self::$log = new Log(); self::log()->info = 'Starting, PID is '.getmypid(); if (VERBOSE > 5) { self::log()->info = ' (__) '; self::log()->info = ' (oo) '; self::log()->info = ' /------\/ '; self::log()->info = ' / | || '; self::log()->info = ' * /\---/\ '; self::log()->info = ' ~~ ~~ '; self::log()->info = '...."Have you mooed today?"...'; } self::$config = new Config(); self::$permission = new Permission(); self::$language = new Language(LANGUAGE); if (VERBOSE > 0) self::log()->info = 'Loaded Config'; self::$bot = new Bot(); $modules = self::config()->config['modules']; // load default modules if (VERBOSE > 0) self::log()->info = 'Loading Modules'; foreach ($modules as $module) { self::loadModule($module); } self::bot()->work(); }
/** * [action_form] generates the form to pay at paypal */ public function action_pay() { $this->auto_render = FALSE; $order_id = $this->request->param('id'); $order = new Model_Order(); $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { // case when selling advert if ($order->id_product == Model_Order::PRODUCT_AD_SELL) { $paypal_account = $order->ad->paypal_account(); $currency = i18n::get_intl_currency_symbol(); if (isset($order->ad->cf_shipping) and Valid::numeric($order->ad->cf_shipping) and $order->ad->cf_shipping > 0) { $order->amount = $order->amount + $order->ad->cf_shipping; } } else { $paypal_account = core::config('payment.paypal_account'); $currency = core::config('payment.paypal_currency'); } $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway; $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => $paypal_account, 'paypal_currency' => $currency, 'item_name' => $order->description); $this->template = View::factory('paypal', $paypal_data); $this->response->body($this->template->render()); } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->redirect(Route::url('default')); } }
/** * 创建Session * * @return void */ public function create() { session_name(Session::$config['name']); $this->destroy(); $cookie_config = Core::config('cookie'); # 这里对IP+非80端口的需要特殊处理下,经试验,当这种情况下,设置session id的cookie的话会失败 if (preg_match('#^([0-9]+.[0-9]+.[0-9]+.[0-9]+):[0-9]+$#', $cookie_config['domain'], $m)) { # IP:PORT 方式 $cookie_config['domain'] = $m[1]; } $s_name = session_name(); if (Session::$config['type'] == 'url') { $old_sid = HttpIO::COOKIE($s_name); } else { $old_sid = HttpIO::COOKIE($s_name); } if ($old_sid) { # 校验Session ID if (!Session::check_session_id($old_sid)) { # 如果检验的Session ID不合法,则重新生成一个 session_id(Session::create_session_id()); } } else { # 设置Session ID session_id(Session::create_session_id()); } # Session ID 通过uri传递 if (Session::$config['type'] == 'url') { @ini_set('session.use_cookies', 0); @ini_set('session.use_only_cookies', 0); } else { session_set_cookie_params($cookie_config['httponly'] ? 0 : Session::$config['expiration'], $cookie_config['path'], $cookie_config['domain'], $cookie_config['secure'], $cookie_config['httponly']); } session_start(); }
public static function start() { // Gets current time, next update, and expiration. // Note: i'm making the last two digits to zero. for rounding purposes. self::$_NOW = BMK; self::$_TTU = (int) substr((string) self::$_NOW + self::$_TTU, 0, -2) . '00'; self::$_EXP = (int) substr((string) self::$_NOW + self::$_EXP, 0, -2) . '00'; // set the session id with the IP, User-agent and the fingerkey // TODO: Add username for login based frameworks session_id(self::$_ID = md5($_SERVER['SERVER_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . Core::config('sess_finger'))); // set the XML dom document, or create it if non existent. if (file_exists(SESS . 'session')) { XML::load(SESS . 'session'); } else { XML::set(SESS . 'session'); } // if we can't find the ID set, create it in the index.. if (!($element = XML::get_id(self::$_ID))) { XML::append(array('tagname' => 'session', 'id' => self::$_ID, 'exp' => self::$_EXP)); } // remove all expired sessions self::gc(0); // start session session_start(); }
/** * 导出项目为独立项目,并优化加载速度 */ public function action_export() { $this->output('请选择你的项目:'); $i = 0; $arr = array(); foreach (Core::config('core.projects') as $item) { $i++; $arr[$i] = $item; $this->output($i . ':' . $item['name']); } $id = $this->input(); if (!isset($arr[$id])) { $this->output('指定的项目错误'); return; } $this->output('请输入待导出的路径'); $str = $this->input(); if (is_dir($str)) { $this->output('指定的路径已存在,是否将文件导出到此文件夹?yes or no'); $str = strtolower($this->input()); if ($str == 'no' || $str == 'n') { $this->output('操作已取消'); return; } } $this->output('now reading files...'); //TODO }
/** * 权限组列表 */ public function action_default() { $this->quick_menu = array('administrator/group/add' => '添加权限组', 'administrator/' => '管理员列表', 'administrator/add' => '添加管理员'); if (!$this->session()->member()->perm()->is_own('administrator.view_group_info')) { if ($this->session()->member()->perm()->is_own('administrator.can_edit_group')) { $groups = $this->session()->member()->groups(); } else { $this->message('抱歉,您无此权限'); } } $view = new View('admin/administrator/group_list'); if (isset($groups)) { $view->list = $groups; $view->group_manager = true; } else { if ($this->session()->member()->perm()->is_super_perm()) { # 超级管理员列出所有组 $project = null; } else { $project = Core::$project; } $model_administrator = new Model_Admin_Administrator(); $count = $model_administrator->total_group_count($project); if ($count) { $pageconfig = Core::config('admin/pagination'); $pageconfig['total_items'] = $count; $pagination = new Pagination($pageconfig); $list = $model_administrator->get_group_list($project, $pagination->get_offset(), $pagination->get_items_per_page()); $view->list = $list; $view->pagehtml = $pagination->render(); } } $view->render(); }
public function __construct($lang = null) { if (null === $lang) { $core_lang = Core::config('core.lang'); if ($core_lang == 'auto') { $core_lang = null; if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $accept = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']); foreach ($accept as $item) { if (false !== ($pos = strpos($item, ','))) { $item = substr($item, $pos + 1); } if (preg_match('#^[a-z\\-]+$#', $item)) { # 尝试寻找语言包 if (Core::find_file('i18n', $item, 'lang')) { $core_lang = $item; break; } } } } } if (!$core_lang) { $core_lang = Core_I18n::$default_lang; } $lang = $core_lang; } $this->lang = $lang; }
/** * [action_form] generates the form to pay at paypal */ public function action_pay() { $this->auto_render = FALSE; //sandobx doesnt do the x_receipt_link_url redirect so in sanbbox instead we put the order id $id_order = Core::config('payment.twocheckout_sandbox') == 1 ? Core::request('x_receipt_link_url') : $this->request->param('id'); //retrieve info for the item in DB $order = new Model_Order(); $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { //its a fraud...lets let him know if ($order->is_fraud() === TRUE) { Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } if (($order_id = twocheckout::validate_passback($order)) !== FALSE) { //mark as paid $order->confirm_payment('2checkout', $order_id); //redirect him to his ads Alert::set(Alert::SUCCESS, __('Thanks for your payment!')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))); } else { Alert::set(Alert::INFO, __('Please fill your card details.')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } }
public function __construct($request, $response) { ignore_user_abort(TRUE); parent::__construct($request, $response); self::$db_prefix = Database::instance('default')->table_prefix(); self::$db_charset = Core::config('database.default.charset'); }
public static final function _construct() { self::$_CHR = Core::config('charset'); self::$_VER = Core::config('xml_version'); self::$_PWS = Core::config('xml_white_spaces'); self::$_FOU = Core::config('xml_format_output'); }
/** * generates HTML for apy buton * @param Model_Order $order * @return string */ public static function button(Model_Order $order) { if (Core::config('payment.paymill_private') != '' and Core::config('payment.paymill_public') != '' and Theme::get('premium') == 1 and $order->loaded()) { return View::factory('pages/paymill/button', array('order' => $order)); } return ''; }
public function action_index() { //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; $this->template->meta_description = Core::config('general.site_description'); //setting main view/template and render pages // swith to decide on ads_in_home $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); switch (core::config('advertisement.ads_in_home')) { case 2: $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 1: $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc'); break; case 0: default: $ads->order_by('published', 'desc'); break; } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', DB::expr('NOW()')); } $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all(); $this->ads = $ads; $categs = Model_Category::get_category_count(); $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs)); }
/** * * Initializes configs for the APP to run */ public static function initialize() { /** * Load all the configs from DB */ //Change the default cache system, based on your config /config/cache.php Cache::$default = Core::config('cache.default'); //is not loaded yet in Kohana::$config Kohana::$config->attach(new ConfigDB(), FALSE); //overwrite default Kohana init configs. Kohana::$base_url = Core::config('general.base_url'); //enables friendly url @todo from config Kohana::$index_file = FALSE; //cookie salt for the app Cookie::$salt = Core::config('auth.cookie_salt'); // -- i18n Configuration and initialization ----------------------------------------- I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset')); //Loading the OC Routes // if (($init_routes = Kohana::find_file('config','routes'))) // require_once $init_routes[0];//returns array of files but we need only 1 file //faster loading require_once APPPATH . 'config/routes.php'; //getting the selected theme, and loading options Theme::initialize(); }
/** * expired featured ads * @return void */ public static function renew() { if (Core::config('general.subscriptions') == TRUE) { //get expired subscription that are active $subscriptions = new Model_Subscription(); $subscriptions = $subscriptions->where('status', '=', 1)->where('expire_date', '<=', Date::unix2mysql())->order_by('created', 'desc')->find_all(); foreach ($subscriptions as $s) { //disable the plan $s->status = 0; try { $s->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $plan = $s->plan; if ($plan->loaded() and $plan->status == 1) { //generate a new order $order = Model_Order::new_order(NULL, $s->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name); //free plan no checkout if ($plan->price == 0) { $order->confirm_payment('cash'); } else { $checkout_url = $s->user->ql('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order)); $s->user->email('plan-expired', array('[PLAN.NAME]' => $plan->name, '[URL.CHECKOUT]' => $checkout_url)); } } //if plan loaded } //end foreach } //if subscription active }
/** * Deletes a single record while ignoring relationships. * * @chainable * @throws Kohana_Exception * @return ORM */ public function delete() { if (!$this->_loaded) { throw new Kohana_Exception('Cannot delete :model model because it is not loaded.', array(':model' => $this->_object_name)); } //remove image $this->delete_image(); //remove ads, will remove reviews, images etc... $ads = new Model_Ad(); $ads = $ads->where('id_user', '=', $this->id_user)->find_all(); foreach ($ads as $ad) { $ad->delete(); } //bye profile pic $this->delete_image(); //delete favorites DB::delete('favorites')->where('id_user', '=', $this->id_user)->execute(); //delete reviews DB::delete('reviews')->where('id_user', '=', $this->id_user)->execute(); //delete orders DB::delete('orders')->where('id_user', '=', $this->id_user)->execute(); //delete subscribtions DB::delete('subscribers')->where('id_user', '=', $this->id_user)->execute(); //delete posts DB::delete('posts')->where('id_user', '=', $this->id_user)->execute(); //delete messages DB::delete('messages')->where('id_user_from', '=', $this->id_user)->or_where('id_user_to', '=', $this->id_user)->execute(); //unsusbcribe from elasticemail if (Core::config('email.elastic_listname') != '') { ElasticEmail::unsubscribe(Core::config('email.elastic_listname'), $this->email); } parent::delete(); }
/** * [action_buy] Pay for ad, and set new order * */ public function action_buy() { if (Core::config('general.subscriptions') == FALSE) { throw HTTP_Exception::factory(404, __('Page not found')); } //getting the user that wants to buy now if (!Auth::instance()->logged_in()) { Alert::set(Alert::INFO, __('To buy this product you need to register first.')); $this->redirect(Route::url('oc-panel')); } //check plan exists $plan = new Model_Plan(); $plan->where('seoname', '=', $this->request->param('id'))->where('status', '=', 1)->find(); //loaded published and with stock if we control the stock. if ($plan->loaded() and $plan->status == 1) { //free plan can not be renewed if ($plan->price == 0 and $this->user->subscription()->id_plan == $plan->id_plan) { Alert::set(Alert::WARNING, __('Free plan can not be renewed, before expired')); HTTP::redirect(Route::url('pricing')); } $order = Model_Order::new_order(NULL, $this->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name); //free plan no checkout if ($plan->price == 0) { $order->confirm_payment('cash'); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))); } else { $this->redirect(Route::url('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order))); } } else { throw HTTP_Exception::factory(404, __('Page not found')); } }
/** * 创建Session * * @return void */ public function create() { if (preg_match('#^(?=.*[a-z])[a-z0-9_]++$#iD', Session::$config['name'])) { session_name(Session::$config['name']); } $this->destroy(); $cookieconfig = Core::config('cookie'); # 这里对IP+非80端口的需要特殊处理下,经试验,当这种情况下,设置session id的cookie的话会失败 if (preg_match('#^([0-9]+.[0-9]+.[0-9]+.[0-9]+):[0-9]+$#', $cookieconfig['domain'], $m)) { # IP:PORT 方式 $cookieconfig['domain'] = $m[1]; } $sname = session_name(); if (isset($_COOKIE[$sname]) && $_COOKIE[$sname]) { $old_sid = $_COOKIE[$sname]; # 校验Session ID if (!Session::check_session_id($old_sid)) { # 如果检验的Session ID不合法,则重新生成一个 session_id(Session::create_session_id()); } } else { # 设置Session ID session_id(Session::create_session_id()); } session_set_cookie_params(Session::$config['expiration'], $cookieconfig['path'], $cookieconfig['domain'], $cookieconfig['secure'], $cookieconfig['httponly']); session_start(); }
/** * [action_form] generates the form to pay at paypal */ public function action_pay() { $this->auto_render = FALSE; $id_order = $this->request->param('id'); //retrieve info for the item in DB $order = new Model_Order(); $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { // include class vendor require Kohana::find_file('vendor/authorize/', 'autoload'); define('AUTHORIZENET_API_LOGIN_ID', Core::config('payment.authorize_login')); define('AUTHORIZENET_TRANSACTION_KEY', Core::config('payment.authorize_key')); define('AUTHORIZENET_SANDBOX', Core::config('payment.authorize_sandbox')); $sale = new AuthorizeNetAIM(); $sale->amount = $order->amount; $sale->card_num = Core::post('card-number'); $sale->exp_date = Core::post('expiry-month') . '/' . Core::post('expiry-year'); $response = $sale->authorizeAndCapture(); if ($response->approved) { $order->confirm_payment('authorize', $response->transaction_id); //redirect him to his ads Alert::set(Alert::SUCCESS, __('Thanks for your payment!') . ' ' . $response->transaction_id); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))); } else { Alert::set(Alert::INFO, $response->error_message); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } }
public function before() { $this->password = Core::config('core.debug_open_password'); if (!is_array($this->password) || !$this->password) { Core::show_404(); } }
public function __construct($config = null) { //Auto Class loader closure setting spl_autoload_register(function ($class) { // Set path. The location of where the file-to-read is. // Iterate over app/controllers, models, views, sys/core but NOT app/config. $paths = array(APPPATH . 'controllers', APPPATH . 'models', APPPATH . 'views', SYSPATH . 'core'); $found = false; // Iterate over the possible paths, and include if detected. foreach ($paths as $path) { $file = $path . DS . $class . '.php'; // If found, load it. if (file_exists($file)) { require_once $file; $found = true; } } // Error reporting. if (!$found) { echo "Could not find the {$class} object"; } }); if ($config) { $xml = simplexml_load_file($config); self::$config = $xml; //Core Class load if ($xml->route) { self::$instance["Router"] = new Router($xml->route); } if ($xml->database) { self::$instance["Database"] = new Database($xml->database); } } self::$instance["Core"] = $this; }
/** * Core constructor. * @param $file_config app/config.xml */ public function __construct($file_config) { // Set autoloader as closure inside the constructor. spl_autoload_register(function ($class) { // Set paths. The location of where the files-to-read are. // Paths include app/controllers, models, sys/core but NOT app/config. $paths = array(APPPATH . 'controllers', APPPATH . 'models', SYSPATH . 'core'); // Iterate over the paths set, and include if any file is detected. foreach ($paths as $path) { $file = $path . DS . $class . '.php'; if (file_exists($file)) { require_once $file; } } }); /** * Load Configuration. * This refers to an external config.xml file. */ if ($file_config) { $config = simplexml_load_file($file_config); self::$config = $config; // Create instances with information from config.xml. if ($config->Router) { self::$instance["Router"] = new Router($config->Router); } if ($config->Database) { self::$instance["Database"] = new Database($config->Database); } } // Also create a Core instance. self::$instance["Core"] = $this; }
public function __construct() { // load the field templates if (($this->field_template = Core::config('db_field_templates')) && count($this->field_template) > 0) { // we have to make sure all the templates have string keys defined since we'll use them as names foreach ($this->field_template as $key => $field) { if (!is_string($key)) { if (!isset($field['NAME'])) { Core::error('DBFDTM', 'LIBTIT', array(__CLASS__, $key)); } else { $this->field_template[$field['NAME']] =& $field; // remove old keys unset($this->field_template[$key], $this->field_template[$field['NAME']]['NAME']); } } } } else { $this->field_template = false; } // propagate database connection info to public vars if (is_array(DB::$INFO)) { foreach (DB::$INFO as $param => $value) { $this->{$param} = $value; } } // initialize the connection if the auto flag is set to true. if (DB::$AUTO === true) { $this->init(); } }
public function action_api() { if (substr($this->file, -strlen(EXT)) == EXT) { $classname = substr(str_replace('/', '_', $this->file), 0, strpos($this->file, '.')); if ($this->dir == 'controllers' || $this->dir == 'shell') { $is_class = true; $class_name = 'Controller_' . strtolower(str_replace('_', '__', $classname)); } elseif ($this->dir == 'models') { $is_class = true; $class_name = 'Model_' . $classname; } elseif ($this->dir == 'orm') { $is_class = true; $class_name = 'orm_' . $classname . '_Finder'; } elseif ($this->dir == 'config') { $is_class = false; $config_key = substr($this->file, 0, -11); $config = Core::config($config_key, $this->project); View::factory('docs/api/config_and_i18n')->set('file', $this->file)->set('config', $config)->set('dir', $this->dir)->render(); $this->filepath = true; } else { $is_class = true; $class_name = $classname; } if ($is_class) { if (class_exists($class_name, true)) { $doc = Docs::factory($class_name); $this->filepath = $doc->class->getFileName(); } if ($this->filepath) { $this->view->righthtml = View::factory('docs/api/classtoc')->set('doc', $doc)->render(false); # 输出结果 View::factory('docs/api/class')->set('doc', $doc)->set('dir', $this->dir)->set('route', Core::route())->render(true); } elseif (class_exists($class_name, false)) { # PHP 默认类 $this->redirect('http://www.php.net/manual/zh/class.' . strtolower($classname) . '.php'); } } } elseif (substr($this->file, -5) == '.lang') { # 语言包 foreach (self::$include_path as $path) { $tmpfile = $path . 'i18n' . DIRECTORY_SEPARATOR . $this->file; if (is_file($tmpfile)) { $found[] = $tmpfile; } } $config = array(); if ($found) { foreach ($found as $file) { $config = array_merge(@parse_ini_file($file), $config); } } View::factory('docs/api/config_and_i18n')->set('file', $this->file)->set('config', $config)->set('dir', $this->dir)->render(); $this->filepath = true; } if (!$this->filepath) { $this->dir_classes(); } $this->view->lefthtml = $this->file_tree(); }
/** * * Initializes the php-gettext * Remember to load first php-gettext * @param string $locale * @param string $charset * @param string $domain */ public static function initialize($locale = 'en_UK', $charset = 'utf-8', $domain = 'messages') { /** * setting the statics so later we can access them from anywhere */ //we allow to choose lang from the url if (Core::config('i18n.allow_query_language') == 1) { if (Core::get('language') !== NULL) { $locale = Core::get('language'); } elseif (Cookie::get('user_language') !== NULL) { $locale = Cookie::get('user_language'); } Cookie::set('user_language', $locale, Core::config('auth.lifetime')); } self::$lang = $locale; //used in i18n kohana self::$locale = $locale; self::$charset = $charset; self::$domain = $domain; //time zone set in the config date_default_timezone_set(Kohana::$config->load('i18n')->timezone); //Kohana core charset, used in the HTML templates as well Kohana::$charset = self::$charset; /** * In Windows LC_MESSAGES are not recognized by any reason. * So we check if LC_MESSAGES is defined to avoid bugs, * and force using gettext */ if (defined('LC_MESSAGES')) { $locale_res = setlocale(LC_MESSAGES, self::$locale); } else { $locale_res = FALSE; } // used with a function money_format setlocale(LC_MONETARY, self::$locale); /** * check if gettext exists if not uses gettext dropin */ if (!function_exists('_') or $locale_res === FALSE or empty($locale_res)) { /** * gettext override * v 1.0.11 * https://launchpad.net/php-gettext/ * We load php-gettext here since Kohana_I18n tries to create the function __() function when we extend it. * PHP-gettext already does this. */ require Kohana::find_file('vendor', 'php-gettext/gettext', 'inc'); T_setlocale(LC_MESSAGES, self::$locale); T_bindtextdomain(self::$domain, DOCROOT . 'languages'); T_bind_textdomain_codeset(self::$domain, self::$charset); T_textdomain(self::$domain); //force to use the gettext dropin self::$dropin = TRUE; } else { bindtextdomain(self::$domain, DOCROOT . 'languages'); bind_textdomain_codeset(self::$domain, self::$charset); textdomain(self::$domain); } }
public function __construct($config_name = null) { if (null === $config_name) { $config_name = Auth::DEFAULT_CONFIG_NAME; } $this->config_name = $config_name; $this->config = Core::config('auth.' . $config_name); }
public function __construct() { $tablename = Core::config('admin/administrator.tablename'); if ($tablename) { $this->tablename = $tablename; } parent::__construct(); }