public static function matchURI($uri = null) { $path_info = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); $uri = !$uri ? $path_info : $uri; $uri = !$uri ? '/' : rtrim($uri, "\\/"); if (!empty(self::$request)) { $count = count(self::$request); for ($i = 0; $i < $count; ++$i) { foreach (self::$request[$i] as $k => $v) { if (is_array($v) and $k !== 'param') { self::$param = self::$request[$i]['param']; $v['request'] = preg_replace_callback("/\\<(?<key>[0-9a-z_]+)\\>/", 'Route::_replacer', str_replace(")", ")?", $v['request'])); $rulleTemp = array_merge((array) self::$request[$i], (array) $v); if ($t = self::_reportRulle($rulleTemp, $uri)) { return $t; } } } } } else { return array(); } }
<?php #1. LOGIC Auth::kickout('/pokecart/'); $comment = new Comment(); $comment->load(Route::param('id')); if ($comment->user_id == Auth::user_id()) { if (Input::posted()) { $comment->content = Input::get('message'); $comment->save(); URL::restore(); } } Sticky::set('message', $comment->content); #2. LOAD VIEWS include VIEWS . 'header.php'; include VIEWS . 'edit_comment.php'; include VIEWS . 'footer.php';
<?php # new_task.php # 1. logic $project = new Project(); $project->load(['slug' => Route::param('slug')]); if (Input::posted()) { $task = new Task(); $task->fill(Input::all()); $task->user_id = Auth::user_id(); $task->project_id = $project->id; if (Input::get('name') != "" || Input::get('description') != "") { $task->save(); } } URL::redirect('/' . $project->slug);
<?php # controllers/resetpw.php # Logic $token = new Token(); # load the token by the value in the url $token->load(['value' => Route::param('value')]); $today_dt = strtotime(date('Y-m-d H:i:s')); $token_dt = strtotime($token->expiration); if ($today_dt < $token_dt) { # create a new user $user = new User(); # load the user with the id found in the token $user->load($token->user_id); # if the form was posted if (Input::posted()) { # set the users password to the new hash $user->password = password_hash(Input::get('password'), PASSWORD_DEFAULT); # and save it $user->save(); # log that user in Auth::log_in($user->id, $user->is_admin); # hard delete the token $token->hard_delete(); # Redirect wherever you want to go after that. if (Auth::is_admin()) { URL::redirect('/admin'); } else { URL::redirect('/'); } }
<?php Auth::kickout('/pokecart/product/' . Route::param('id') . '/view'); $comment = new Comment(); $comment->content = Input::get('message'); $comment->product_id = Route::param('id'); $comment->user_id = Auth::user_id(); $comment->date_time = date('Y-m-d H:i:s'); $comment->save(); URL::redirect('/pokecart/product/' . Route::param('id') . '/view');
<?php #1. Auth::kickout_non_admin('/pokecart/'); $product = new Product(); $product->load(Route::param('id')); $product->delete(); #2. REDIRECT URL::redirect('/pokecart/admin');
<?php # progress.php # 1. Logic $project = new Project(); $project->load(['slug' => Route::param('slug')]); $task = new Task(); $task->load(Route::param('id')); $task->progress = $task->progress + 1; $task->save(); # 2. URL::redirect('/' . $project->slug);
<?php Cart::remove_product(Route::param('id')); URL::redirect('/pokecart/cart');
<?php # controllers/paybill.php # Logic $account = new Account(); $account->load(['bill_id' => Route::param('id'), 'user_id' => Auth::user()->id]); if ($account->id) { $account->paid = 1; $account->save(); } # Redirect URL::redirect('/');
<?php # controllers/deletebill.php # Logic Auth::kickout_non_admin('/'); $bill = new Bill(); $bill->load(Route::param('id')); $bill->delete(); $accounts = new Accounts_Collection(); $accounts->where('bill_id', $bill->id); $accounts->get(); foreach ($accounts->items as $account) { $account->delete(); } # Redirect URL::redirect('/admin');
<?php $product = new Product(); $product->load(Route::param('id')); #1. Cart::add_product(Route::param('id'), 1, $product->cart_max); #2. LOAD VIEWS if (AJAX) { echo json_encode(['success' => true, 'count' => Cart::get_total() + 1, 'name' => $product->name, 'image' => $product->image, 'id' => $product->id, 'price' => $product->price, 'sub' => Cart::get_subtotal() + $product->price, 'qty' => Cart::get_quantity($product->id)]); } else { URL::redirect('/pokecart/cart'); }
<?php $product = new Product(); $product->load(Route::param('id')); Cart::set_quantity(Route::param('id'), Cart::get_quantity(Route::param('id')) - 1, $product->cart_max); if (AJAX) { echo json_encode(['success' => true, 'count' => Cart::get_total() - 1, 'name' => $product->name, 'image' => $product->image, 'id' => $product->id, 'price' => $product->price, 'sub' => Cart::get_subtotal() - $product->price, 'qty' => Cart::get_quantity($product->id)]); } else { URL::redirect('/pokecart/'); }
<?php $products = new Products_Collection(); $products->where(['name LIKE' => '%' . Route::param('keywords') . '%', 'deleted' => '0']); // $products->order_by('name', 'desc'); $products->get(); include VIEWS . 'header.php'; include VIEWS . 'products_grid.php'; include VIEWS . 'footer.php';
<li><a href="/pokecart/logout"><i class="fa fa-reply"></i> Log out</a></li> <? else: ?> <li><a href="/pokecart/register"><i class="fa fa-user-plus"></i> Register</a></li> <li><a href="/pokecart/login"><i class="fa fa-share"></i> Login</a></li> <? endif ?> <li> <form class="navbar-form navbar-left" action="/pokecart/search.php"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search" name="keywords" value="<?php echo Route::param('keywords'); ?> "> </div> <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button> </form> </li> <li> <div class="notification "> <div class="notification-cart hide animated"> <h2 class="productName"></h2> <div class="flex flex-a-center flex-j-between"> <a href="" class="productLink"><img src="" alt="" height="94" width="94" class="productImg"></a>