public function login($username = null, $password = null, $remember = false) { if (!$username && !$password && $this->exists()) { Session::put($this->_sessionName, $this->data()->ID); } else { $user = $this->find($username); if ($user) { Hash::make($password, $this->data()->salt); if ($this->data()->Password === Hash::make($password, $this->data()->salt)) { Session::put($this->_sessionName, $this->data()->ID); if ($remember) { $hash = Hash::unique(); $hashCheck = $this->_db->get('users_session', array('user_id', '=', $this->data()->ID)); if (!$hashCheck->count()) { $this->_db->insert('user_session', array('user_id' => $this - data()->ID, 'hash' => $hash)); } else { $hash = $hashCheck->first()->hash; } Cookie::put($this->_cookieName, $hash, Config::get('remember/cookie_expiry')); } return true; } } } return false; }
function view($OrderID) { $Order = new mOrder($OrderID); $this->load->helper('date'); data('Order', $Order); $this->display('orders/view'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!jwt()->check()) { return data()->sendErr(['token' => '未登录或未授权的请求。'], 401); } return $next($request); }
static function init() { self::$page = data('page') ?: self::$page; self::$limit = data('limit') ?: self::$limit; self::$order = data('order') ?: self::$order; self::$where = data('where') ?: self::$where; }
private function models() { $class = $this; $fields = array('status' => array('default' => 'active')); $conf = array('functions' => array('relations' => function ($obj) use($class) { return $class->dbr->where('entity_name = ' . $class->entity)->fetch(); }, 'fetchCollection' => function ($obj) use($class) { return $class->fetchValues(); }, 'attributes' => function ($obj) use($class) { $collection = array(); $tuples = array(); $relations = $class->dbr->where('entity = ' . $obj->getId())->fetch(); foreach ($relations as $relation) { $att = $relation->getAttribute(); if (!Arrays::in($att, $tuples)) { array_push($tuples, $att); array_push($collection, $class->dba->find($att)); } } return $collection; })); data($this->entity . '_eav', $fields, $conf); $fields = array('name' => array('cantBeNull' => true)); $conf = array('checkTuple' => 'name', 'functions' => array('data' => function ($obj) use($class) { return $class->data($obj); })); data('attributes_eav', $fields, $conf); $fields = array('entity_name' => array('default' => $this->entity), 'entity' => array('cantBeNull' => true), 'attribute' => array('cantBeNull' => true), 'value' => array('cantBeNull' => true)); $conf = array('functions' => array('entity' => function ($obj) use($class) { return $class->dbe->find($obj->getEntity()); }, 'attribute' => function ($obj) use($class) { return $class->dba->find($obj->getAttribute()); })); data('relations_eav', $fields, $conf); }
private function models() { $fields = array('name' => array(), 'firstname' => array(), 'email' => array(), 'public_key' => array(), 'private_key' => array(), 'token' => array('canBeNull' => true), 'expire' => array('canBeNull' => true)); $conf = array('checkTuple' => 'email', 'functions' => array('findRights' => function ($obj) { $userId = $obj->getId(); $db = new Store('apistore_right'); return $db->where("user = {$userId}")->fetch(); })); data('apistore_user', $fields, $conf); $fields = array('user' => array(), 'table' => array(), 'can_add' => array('default' => false), 'can_edit' => array('default' => false), 'can_duplicate' => array('default' => false), 'can_delete' => array('default' => false), 'can_search' => array('default' => false)); $conf = array('checkTuple' => array('user', 'table'), 'functions' => array('findUser' => function ($obj) { $userId = $obj->getUser(); $db = new Store('apistore_user'); return $db->find($userId); }, 'findTable' => function ($obj) { $tableId = $obj->getYable(); $db = new Store('apistore_table'); return $db->find($tableId); })); data('apistore_right', $fields, $conf); $fields = array('name' => array(), 'model' => array()); $conf = array('checkTuple' => 'name', 'functions' => array('findRights' => function ($obj) { $tableId = $obj->getId(); $db = new Store('apistore_right'); return $db->where("table = {$tableId}")->fetch(); })); data('apistore_table', $fields, $conf); }
/** * Add an event to the log * * @param string $message */ public function add(array $data) { $line = '[' . data('r', $data['datetime']) . '] ' . $data['message'] . ' User: '******'user'] . PHP_EOL; $config = Registry::get('site-config'); if (!file_put_contents($config['location'], $line, FILE_APPEND)) { throw new Exception("An error occurred writing to file."); } }
function variants($ForOptionID) { $Option = new mOption($ForOptionID); $Variants = $Option->variants; data('Option', $Option); data('Variants', $Variants); $this->display('custom/variants'); }
function privacy() { $this->output->cache(30); //We need to retreive the page content from the DB and parse it $Content = new ifx_PageData(); data('Content', $Content->get(PD_PRIVACY)); $this->display('page'); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function signup(Request $request) { $validation = $this->validator($request->all()); if ($validation->fails()) { return data([$validation->errors()]); } $user = User::create(['first_name' => $request->first_name, 'last_name' => $request->last_name, 'email' => $request->email, 'password' => bcrypt($request->password)]); return data(compact('user')); }
public function __construct() { $this->rawPost = isset($_POST) ? $_POST : data(); $this->rawGet = isset($_GET) ? $_GET : data(); $this->rawRequest = isset($_REQUEST) ? $_REQUEST : data(); $this->post = $this->process($this->rawPost); $this->get = $this->process($this->rawGet); $this->request = array_merge($this->get, $this->post); }
function index() { $this->output->cache(30); $this->config->set_item('class_as_root', false, 'ifx'); data('scrollHeader', true); $LatestPosts = new mBlogPost(); data('Posts', $LatestPosts->list_all(TRUE, 3)->get()); $this->display('homepage'); }
public function __construct() { /* MODEL */ $fields = array('partner' => array('cantBeNull' => true), 'partner_id' => array('cantBeNull' => true), 'address' => array('canBeNull' => true), 'bedroom' => array('canBeNull' => true), 'type' => array('canBeNull' => true), 'price' => array('canBeNull' => true), 'city' => array('canBeNull' => true), 'thumb' => array('canBeNull' => true)); $conf = array('db' => 'lite', 'instanceModel' => $this, 'checkId' => 'partner_id', 'checkTuple' => 'partner_id'); data('propriete', $fields, $conf); $this->db = Data::lite('propriete'); Data::prepareDbLite('propriete'); }
public function __construct() { /* MODEL */ $fields = array('longitude' => array('canBeNull' => true), 'latitude' => array('canBeNull' => true), 'partner' => array('cantBeNull' => true), 'partner_id' => array('cantBeNull' => true), 'address' => array('canBeNull' => true), 'description' => array('canBeNull' => true), 'type' => array('canBeNull' => true), 'price' => array('canBeNull' => true), 'caracteristics' => array('canBeNull' => true), 'city' => array('canBeNull' => true), 'province' => array('canBeNull' => true), 'num_bedroom' => array('canBeNull' => true), 'price_category' => array('canBeNull' => true), 'pics' => array('canBeNull' => true), 'caracteristics' => array('canBeNull' => true), 'name' => array('canBeNull' => true), 'firstname' => array('canBeNull' => true), 'email' => array('canBeNull' => true), 'home_phone' => array('canBeNull' => true), 'cell_phone' => array('canBeNull' => true), 'work_phone' => array('canBeNull' => true), 'fax' => array('canBeNull' => true)); $conf = array('checkTuple' => array('longitude', 'latitude')); $conf = array('checkTuple' => 'partner_id'); data('property', $fields, array()); $this->dwn(); }
/** * Identifier * * @param string $id * * @return string */ function filter_id(string $id) : string { static $data, $keys; if ($data === null) { $data = data('filter', 'id'); $keys = array_keys($data); } return trim(preg_replace($keys, $data, strtolower($id)), '-'); }
function order($OrderID) { $Order = new mOrder($OrderID); if ($Order->is_loaded()) { data('Order', $Order); data('Customer', $Order->customer); } $this->index(); }
function view($ItemID) { $StoreItem = new mStoreItem($ItemID); if ($StoreItem->is_loaded()) { data('Item', $StoreItem); $this->display('item'); } else { $this->display('notfound'); } }
function display_image($ImageID) { if (!is_a($ImageID, static::$model)) { $ImageID = new static::$model($ImageID); } $StoreImage = new mStoreItemImage(); $StoreImage->load($ImageID); data('Image', $ImageID); data('StoreImage', $StoreImage); display_view('store/image'); }
function display_image($ImageID) { if (!is_a($ImageID, static::$model)) { $ImageID = new static::$model($ImageID); } $Carousel = new mCarouselImage(); $Carousel->load($ImageID); data('Image', $ImageID); data('Carousel', $Carousel); display_view('carousel/image'); }
function view() { $Order = new mOrder(); $Order->__fromMemory(); if (!$Order->id()) { redirect('/trackorder/'); } data('Order', $Order); data('Customer', $Order->customer); $this->display('view'); }
function display_image($ImageID) { if (!is_a($ImageID, static::$model)) { $ImageID = new static::$model($ImageID); } $Box = new mHomepageImage(); $Box->load($ImageID); data('Image', $ImageID); data('Box', $Box); display_view('homepage/image'); }
function extractLogDates($site) { $d = HTTP_DIR . '/' . $site . '/code'; $h = opendir($d) or die("Couldn't open {$d}"); $datalist = data($site); $fs = array(); while ($each = readdir($h)) { if (preg_match('/\\.log$/i', $each) && $datalist[$each]) { $fs[] = $d . '/' . $each; } } $sitelist = includes($site); $freq = array(); $sum = 0.0; foreach ($fs as $each) { $parts = explode(".", $each); $lang = $parts[2]; if (isset($sitelist[$lang])) { $fp = @fopen($each, "r") or die("Couldn't open {$each}"); while ($line = fgets($fp, 128)) { if ($found = preg_match('/([A-Z][a-z]{2})[0-9A-Z\\s\\:]+(\\d{4})/', $line, $match)) { break; } } if ($found) { $sum++; $mth = month($match[1]); $yr = intval($match[2]); if (!isset($freq[$yr][$mth][$site])) { $freq[$yr][$mth][$site] = 1; } else { $freq[$yr][$mth][$site] += 1; } } fclose($fp) or die("Couldn't close {$each}"); } } closedir($h); $a = array(); foreach ($freq as $yr => $mths) { foreach ($mths as $mth => $counts) { if (isset($counts[$site]) && $counts[$site] > 0) { $a[] = array($yr, $mth, $site, $counts[$site] / $sum); } } } usort($a, 'CompareYearMonth'); $cumulative = 0.0; for ($k = 0; $k < sizeof($a); $k++) { $cumulative += $a[$k][3]; $a[$k][3] = $cumulative; } return $a; }
function index() { if (isset($_POST['username'])) { $this->User->__post(); if ($Result = $this->User->login()) { redirect('/site-admin/'); } else { data('login_error', 'The username or password is invalid'); } } $this->display('login'); }
/** * 新增用户 * @return id 获取id * @author 蒋文书 <*****@*****.**> */ public function addUser() { //获取用户信息 $role = array(); $data = array('username' => I('username'), 'password' => I('password', '', 'md5'), 'reg_time' => data(), 'reg_ip' => get_client_ip(), 'role' => I('role')); $user_id = $this->add($data); if ($user_id) { $role = array('role_id' => I('role'), 'user_id' => $user_id); M('role_user')->add($role); } return true; }
public static function withEmail() { // 验证请求 $validator = Validator::make(request()->all(), ['email' => 'required|email|max:255|unique:users', 'name' => 'required|min:2|max:255|regex:/^[\\x{4e00}-\\x{9fa5}A-Za-z0-9_]+$/u|unique:users', 'password' => 'required|confirmed|min:6'], $messages = ['required' => '字段不存在。']); if ($validator->fails()) { // 转化错误为数组并追加到data() data()->setErr(collect($validator->errors())->toArray()); return null; } // 创建用户 $user = model('User')->create(['name' => request()->name, 'email' => request()->email, 'password' => request()->password]); auth()->loginUsingId($user->id); return auth()->user(); }
function edit($Key) { $PageData = new ifx_PageData(); if (isset($_POST['value'])) { if ($PageData->set($Key, $_POST['value'])) { data('info_success', 'Updated'); } else { data('info_errors', 'Couldn\'t save that'); } $this->output->delete_cache('/'); } data('key', $Key); data('value', $PageData->get($Key)); $this->display('pagedata/edit'); }
public function deleteAllCategory() { $category = meta('company_category'); $cats = $category->loadQuery(); if ($cats) { foreach ($cats as $cat) { $id = $cat->getRecord('id'); $file = data()->load(" gid='company-category' AND code='{$id}' "); if ($file) { $file->delete(); } $cat->delete(); } } }
function &set($container, $key, $val, $update = false) { $data =& data(); if (!isset($data[$container])) { load($container); } if ($key !== false) { $data[$container][$key] = $val; } else { $data[$container][] = $val; } if ($update) { update($container); } return $data[$container]; }
/** * Output the current view **/ public function display($view, $data = NULL, $doNotWrap = false) { if (_config('class_as_root') == true) { $view = strtolower(get_class($this)) . '/' . $view; } if (is_null($data)) { $data = data(); } if ($doNotWrap == false) { $this->_load_views(_config('include_before'), $data); } $this->load->view($view, $data); if ($doNotWrap == false) { $this->_load_views(_config('include_after'), $data); } }
function step($step = 1, $editonly = false) { if (is_numeric($step)) { $stepdata = new mStep($step); } switch ($step) { case 1: $stepdata->isFirst = true; break; } data('basket', $this->_fetchBasket()); if (isset($stepdata)) { data('step', $stepdata); } $this->display('step'); }