public static function render($app, $ref_id, $title = 'Comments') { if (!isset($app)) { throw new \FuelException('Petro_Comment : Invalid $app = ' . $app); } $query = \DB::query('SELECT ' . static::$_table . '.*, users.username FROM ' . static::$_table . ', users' . ' WHERE ' . static::$_table . '.user_id = users.id' . ' AND ' . static::$_table . '.app = "' . $app . '"' . ' AND ' . static::$_table . '.ref_id = ' . $ref_id . ' ORDER BY ' . static::$_table . '.created_at asc')->execute(); $data['title'] = $title; $data['app'] = $app; $data['ref_id'] = $ref_id; $data['total_comments'] = count($query); if ($data['total_comments'] <= 0) { $data['comments'] = str_replace('{text}', 'No comments yet.', \Config::get('petro.template.comment.empty')); } else { $t = \Config::get('petro.template.comment.item'); $out = ''; foreach ($query as $item) { $author = isset($item['username']) ? $item['username'] : '******'; $date = empty($item['created_at']) ? '' : \Date::forge($item['created_at'])->format(\Config::get('petro.date_format', '%Y-%m-%d %H:%M')); $cost = empty($item['cost']) ? '' : number_format($item['cost']); $out .= str_replace(array('{comment_id}', '{comment_author}', '{comment_date}', '{comment_text}', '{comment_cost}'), array($item['id'], $author, $date, nl2br($item['text']), $cost), $t); } $data['comments'] = $out; } $data['last_url'] = \Uri::current(); return \View::forge('petro/comments/_form', $data, false)->render(); }
public function action_usercp() { if (!$this->current_user->logged_in()) { Session::set_flash('error', 'You need to be logged in to access is page'); Session::set_flash('login_redirect', Uri::current()); Response::redirect('login'); } $this->title('UserCP'); $this->view = $this->theme->view('users/usercp'); if (Input::param() != array()) { // Set name and email $this->current_user->name = Input::param('name'); $this->current_user->email = Input::param('email'); // Set new password if (Input::param('new_password')) { $this->current_user->password = Input::param('new_password'); } // Check if the current password is valid... $auth = Model_User::authenticate_login($this->current_user->username, Input::param('current_password')); if ($this->current_user->is_valid() and $auth) { $this->current_user->save(); Session::set_flash('success', 'Details saved'); Response::redirect('usercp'); } else { $errors = $this->current_user->errors(); if (!$auth) { $errors = array('Current password is invalid.') + $errors; } } $this->view->set('errors', isset($errors) ? $errors : array()); } }
public static function require_auth() { if (!empty(static::$user)) { return true; } \Config::load('facebook::facebook', 'facebook'); $login_url = static::$instance->getLoginUrl(array('redirect_uri' => \Uri::current(), 'client_id' => \Config::get('facebook.app_id'))); \Uri::redirect($login_url); }
public function action_recover($hash = null) { if (Input::Method() === "POST") { if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) { // generate a recovery hash $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id; // and store it in the user profile \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username); // send an email out with a reset link \Package::load('email'); $email = \Email::forge(); $html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>'; // use a view file to generate the email message $email->html_body($html); // give it a subject $email->subject(\Settings::Get('site_name') . ' Password Recovery'); // GET ADMIN EMAIL FROM SETTINGS? $admin_email = Settings::get('admin_email'); if (empty($admin_email) === false) { $from = $admin_email; } else { $from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false))); } $email->from($from); $email->to($user->email, $user->fullname); // and off it goes (if all goes well)! try { // send the email $email->send(); Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!'); } catch (\Exception $e) { Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email); \Response::redirect_back(); } } else { Session::Set('error', 'Sorry there is not a matching email!'); } } elseif (empty($hash) === false) { $hash = str_replace(Uri::Create('login/recover/'), '', Uri::current()); $user = substr($hash, 44); if ($user = \Model\Auth_User::find_by_id($user)) { // do we have this hash for this user, and hasn't it expired yet , must be within 24 hours if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) { // invalidate the hash \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username); // log the user in and go to the profile to change the password if (\Auth::instance()->force_login($user->id)) { Session::Set('current_password', Auth::reset_password($user->username)); Response::Redirect(Uri::Create('user/settings')); } } } Session::Set('error', 'Invalid Hash!'); } $this->template->content = View::forge('login/recover'); }
public function action_index() { $this->dataGlobal['pageTitle'] = __('backend.category.manage'); // Pagination $config = array('pagination_url' => \Uri::current(), 'total_items' => \Model_User::count(), 'per_page' => floor(\Model_User::count() / 2), 'uri_segment' => 'page'); $this->data['pagination'] = $pagination = \Pagination::forge('authors_pagination', $config); // Get categories $this->data['authors'] = \Model_User::query()->offset($pagination->offset)->limit($pagination->per_page)->order_by('created_at', 'DESC')->get(); return \Response::forge(\View::forge('backend/author/index')->set($this->data, null, false)); }
public function action_index() { $this->dataGlobal['pageTitle'] = __('backend.post.manage'); // Pagination $config = array('pagination_url' => \Uri::current(), 'total_items' => Model_Post::count(), 'per_page' => \Config::get('application.pagination.per_page'), 'uri_segment' => 'page'); $this->data['pagination'] = $pagination = \Pagination::forge('post_pagination', $config); // Get posts $this->data['posts'] = \Model_Post::query()->offset($pagination->offset)->limit($pagination->per_page)->order_by('created_at', 'DESC')->get(); $this->theme->set_partial('content', 'backend/post/index')->set($this->data, null, false); }
public function action_index() { $export = \Input::get('export', false); //set cookie order \Fuel\Core\Cookie::set('person_url', Uri::base() . 'job/orders'); $this->template->title = 'UOS求人システム'; //get search value $search_arr = \Input::get(); //set return url after edit $pagination_url = \Uri::base() . 'job/orders/index'; $return_url = \Uri::current(); if (\Input::get('flag') != null) { $pagination_url = \Uri::base() . 'job/orders/index' . '?' . http_build_query($_GET); $return_url = \Uri::current() . '?' . http_build_query($_GET); } //config pagination $config = array('pagination_url' => $pagination_url, 'total_items' => count(\Model_Orders::get_all_order_list(null, null, $search_arr)), 'per_page' => \Constants::$default_limit_pagination, 'uri_segment' => 'page', 'num_links' => \Constants::$default_num_links, 'show_last' => true); if ($export) { $config['per_page'] = 100000; } else { //setcookie \Cookie::set('return_url_search', $return_url, 60 * 60 * 24); } //setup pagination $pagination = \Uospagination::forge('orders-pagination', $config); $model_group = new \Model_Mgroups(); $data['listgroup'] = $model_group->get_type(1); $model_partner = new \Model_Mpartner(); $data['listpartner'] = $model_partner->get_filter_partner(array('type' => 1)); //get list media $model_media = new \Model_Mmedia(); $data['listmedias'] = $model_media->get_list_all_media(); if (is_array($data['listmedias']) == false) { $data['listmedias'] = array(); } //get list post $model_post = new \Model_Mpost(); $data['listpost'] = $model_post->get_list_all(); //get list ss $model_ss = new \Model_Mss(); $data['list_all_ss'] = $model_ss->get_list_all_ss(); //get all orders $model_order = new \Model_Orders(); $data['listorders'] = \Model_Orders::get_all_order_list($pagination->per_page, $pagination->offset, $search_arr); if ($export) { $csv_data = $model_order->csv_process($data['listorders']); \Model_Orders::export($csv_data); } foreach ($data['listorders'] as $key => $value) { $data['listorders'][$key]['image_content'] = base64_encode($data['listorders'][$key]['image_content']); $data['listorders'][$key]['price'] = \Model_Orders::cost_of_order($value); } $this->template->content = \View::forge('orders/index', $data); }
/** * return just the segments of the uri as an array * * @param num mixed[string|int] The segment number to be returned * * @return array */ static function segments($num = null) { //get the current url $url = parse_url(trim(Uri::current(), '/')); //explode it into segments seperated by the / $segments = array_filter(explode('/', $url['path'])); //if num is given, use non-zero indexed if (!is_null($num)) { return $segments[$num - 1]; } //return either the segments of an array containing / for the root - this means we can always loop return $segments ?: array('/'); }
/** * Redirects back to the previous page, if that page is within the current * application. If not, it will redirect to the given url, and if none is * given, back to the application root * * @param string $url The url * @param string $method The redirect method * @param int $code The redirect status code * * @return void */ public static function redirect_back($url = '', $method = 'location', $code = 302) { // do we have a referrer? if ($referrer = \Input::referrer()) { // is it within our website? And not equal to the current url? if (strpos($referrer, \Uri::base()) === 0 and $referrer != \Uri::current()) { // redirect back to where we came from static::redirect($referrer, $method, $code); } } // no referrer or an external link, do a normal redirect static::redirect($url, $method, $code); }
/** * Overloads default class properties from the options. * * Any of the provider options can be set here, such as app_id or secret. * * @param array provider options * @return void */ public function __construct(array $options = array()) { if (!$this->name) { // Attempt to guess the name from the class name $this->name = strtolower(substr(get_class($this), strlen('OAuth2\\Provider_'))); } if (!($this->client_id = \Arr::get($options, 'id'))) { throw new Exception(array('message' => 'Required option not provided: id')); } $this->callback = \Arr::get($options, 'callback'); $this->client_secret = \Arr::get($options, 'secret'); $this->scope = \Arr::get($options, 'scope'); $this->redirect_uri = \Uri::current(); }
/** * Get all categorys from author * @param string $author username */ public function action_show_by_author($author = false) { $author = $this->data['author'] = \Model_User::query()->where('username', $author)->get_one(); if (!$author) { \Messages::error(__('frontend.author.not-found')); \Response::redirect_back(\Router::get('homepage')); } else { // Pagination $config = array('pagination_url' => \Uri::current(), 'total_items' => count($author->posts), 'per_page' => \Config::get('application.pagination.per_page'), 'uri_segment' => 'page'); $this->data['pagination'] = $pagination = \Pagination::forge('category_pagination', $config); // Get categorys $this->data['categories'] = Model_Category::query()->where('user_id', $author->id)->order_by('created_at', 'DESC')->offset($pagination->offset)->limit($pagination->per_page)->get(); return \Response::forge(\View::forge('frontend/category/author')->set($this->data, null, false)); } }
/** * Set an item on breadcrumb static property * * @param string $title Display Link * @param string $link Relative Link * @param intenger $index Index to replace itens * @return void */ public static function set($title, $link = "", $index = null, $overwrite = true) { // trim the bastard $title = trim($title); // if link is empty user the current $link = $link === '' ? \Uri::current() : $link; if (is_null($index)) { static::$breadcrumb[] = array('title' => $title, 'link' => $link); } else { if ($overwrite === true) { static::$breadcrumb[$index] = array('title' => $title, 'link' => $link); } else { static::append($title, $link, $index); } } }
function body_class() { $classes = array(); // Get the URL slug $parts = explode('/', Uri::current()); $classes[] = count($parts) ? trim(current($parts)) : 'index'; // Is it a posts page? if (is_postspage()) { $classes[] = 'posts'; } // Is it the homepage? if (is_homepage()) { $classes[] = 'home'; } return implode(' ', array_unique($classes)); }
public function action_index() { if (!$this->current_user->group->is_admin) { return $this->no_permission(); } $this->title('Settings'); $this->view = $this->theme->view('admin/settings/index'); if (Input::param() != array()) { foreach (Input::param('settings') as $setting => $value) { $s = Model_Setting::find('first', array('where' => array('setting' => $setting))); $s->value = $value; $s->save(); } Session::set_flash('success', 'Settings saved'); Response::redirect(Uri::current()); } }
/** * Load every call to the API with this method. * * @return void * @access public */ public function action_index() { // Profile the loader \Profiler::mark('Start of loader\'s action_index() function'); \Profiler::mark_memory($this, 'Start of loader\'s action_index() function'); // Make sure we aren't processing crap. if (in_array($this->format, array('csv', 'php', 'serialize'))) { $this->format = 'json'; } // For some reason this value is quoted when set to html. if (\Input::post('format') === '"html"') { $this->format = 'html'; } // Cleanse the session to keep things stable. \Session::destroy(); // For error handling \Session::set('response_format', $this->format); // External error processing through Apache if (\Uri::segment(1) === 'error' && is_numeric(\Uri::segment(2)) && strlen(\Uri::segment(2)) === 3) { return $this->response(\Utility::format_error(\Uri::segment(2))); } // /loader/index/error/404 style (Due to routing) if (substr_count(\Uri::current(), 'loader/index/error') === 1 && is_numeric(\Uri::segment(4)) && strlen(\Uri::segment(4)) === 3) { return $this->response(\Utility::format_error(\Uri::segment(4))); } // We need a version number if (empty(\Uri::segment(1)) || \Module::exists(\Uri::segment(1)) === false) { $error_data = \Utility::format_error(400, \Err::BAD_OR_NO_VERSION, \Lang::get('errors.bad_version')); return $this->response($error_data, 400); } // We need a request. if (empty(\Input::post()) || \Input::method() !== 'POST') { $error_data = \Utility::format_error(405, null, \Lang::get('errors.no_request')); return $this->response($error_data, 405); } // Pass the request to the proper API version request handler. (Module) if (!empty(\Input::post())) { \Module::load(\Uri::segment(1)); $response = \Request::forge(\Uri::segment(1) . '/index', false)->execute()->response->body; // HTML only Data Calls if (is_string($response)) { return $this->response($response, 200); } return $this->response($response[0], $response[1]); } }
public function action_index() { $this->template->title = 'UOS求人システム'; $data = array(); //get search value if ($search_arr = \Input::get()) { Session::set('url_filter_concierges', http_build_query(\Input::get())); } //set return url after edit $pagination_url = \Uri::base() . 'support/concierges/index'; $return_url = \Uri::current(); if (\Input::get()) { $pagination_url = \Uri::base() . 'support/concierges/index' . '?' . http_build_query($_GET); $return_url = \Uri::current() . '?' . http_build_query($_GET); } //setcookie \Cookie::set('register_url_search', $return_url, 60 * 60 * 24); //config pagination $config = array('pagination_url' => $pagination_url, 'total_items' => count(\Model_Concierges::get_register_list(null, null, $search_arr)), 'per_page' => \Constants::$default_limit_pagination, 'uri_segment' => 'page', 'num_links' => \Constants::$default_num_links, 'show_last' => true); //setup pagination $pagination = \Uospagination::forge('concierges-pagination', $config); $data['listall'] = \Model_Concierges::get_register_list($pagination->per_page, $pagination->offset, $search_arr); $this->template->content = \View::forge('concierges/index', $data); }
public function get_articles() { // Pagination $config = array('pagination_url' => \Uri::current(), 'total_items' => Model_Post::count(), 'per_page' => 3, 'uri_segment' => 'page'); $this->data['pagination'] = $pagination = \Pagination::forge('post_pagination', $config); // Get posts return $this->response = Model_Post::query()->offset($pagination->offset)->limit($pagination->per_page)->order_by('created_at', 'DESC')->get(); }
<ul> <li class="logo"> <a href="<?php echo Uri::to('admin/posts'); ?> ">Anchor CMS</a> </li> <?php $menu = array('posts', 'comments', 'pages', 'categories', 'users', 'extend'); ?> <?php foreach ($menu as $url) { ?> <li <?php if (strpos(Uri::current(), $url) !== false) { echo 'class="active"'; } ?> > <a href="<?php echo Uri::to('admin/' . $url); ?> "> <?php echo ucfirst(__($url . '.' . $url)); ?> </a> </li> <?php }
function is_admin() { return strpos(Uri::current(), 'admin') === 0; }
foreach ($articles as $article) { if ($article->commentOf != 0) { continue; } ?> <?php echo '<a href=\'/bbs/thread/' . $shortName . DS . $article->id . '\'>' . $count . ':' . '</a>'; echo '<a href=\'/bbs/thread/' . $shortName . DS . $article->id . '\'>' . $article->title . '(' . ($article->commentCount + 1) . ')</a>'; echo ' '; $count++; } if (isset($mode)) { if ($mode != 'all') { echo '<BR>'; echo '<BR>'; echo '<a href =\'' . Uri::current() . '?mode=all' . '\'>全スレッド表示</a>'; } } ?> </DIV> </font> <?php if (isset($pagination)) { echo $pagination->render(); } if (isset($systemAd2)) { echo $systemAd2 . '<BR>'; } if (isset($msg)) { echo $msg; }
/** * Create a form open tag * * @param string|array action string or array with more tag attribute settings * @return string */ public static function open($attributes = array(), array $hidden = array()) { $attributes = !is_array($attributes) ? array('action' => (string) $attributes) : $attributes; // If there is still no action set, Form-post if (!array_key_exists('action', $attributes)) { $attributes['action'] = \Uri::current(); } elseif (!strpos($attributes['action'], '://')) { $attributes['action'] = \Uri::create($attributes['action']); } if (empty($attributes['accept-charset'])) { $attributes['accept-charset'] = strtolower(\Fuel::$encoding); } // If method is empty, use POST !empty($attributes['method']) || ($attributes['method'] = static::get_class_config('form_method', 'post')); $form = '<form'; foreach ($attributes as $prop => $value) { $form .= ' ' . $prop . '="' . $value . '"'; } $form .= '>'; // Add hidden fields when given foreach ($hidden as $field => $value) { $form .= PHP_EOL . static::hidden($field, $value); } return $form; }
<div class="app-content"> <div class="container"> <div class="row"> <div class="label-heading"> <h3 class="label-title">Forgot Password</h3> </div> <div class="col-sm-6"> <div class="app-content"> <div class="form-group"> <p>Please enter your registered email address. You will then receive an email to reset your password.</p> </div> <!-- Forgot Password Form --> <?php echo \Form::open(array('action' => \Uri::current(), 'data-validate' => 'parsley'), array('forgot' => 1)); ?> <div class="form-group"> <label for="" class="form-label">Email Address</label> <?php echo \Form::input('identity', \Input::post('identity'), array("class" => "required form-control", 'data-type' => 'email', 'data-trigger' => 'change')); ?> </div> <button type="submit" class="btn btn-green">Submit</button> <a href="<?php echo \Uri::front_create('user/login'); ?> " class="link-default pull-right">Back to login?</a> <?php echo \Form::close(); ?>
<?php if (!isset($article)) { echo 'パラメータ異常'; return; } if (Auth::check()) { if ($board->userId == Auth::get('id')) { echo '<div><div id=\'redBox\'> <a href = \'' . Uri::current() . '?mode=delete\'>削除</a></div>'; echo '<div id=\'shortBox\'> <a href = \'' . $backURL . '\'>キャンセル</a></div>'; echo '</div><BR><BR>'; echo '<div>管理者権限で下記の投稿を削除しますか?<BR>'; echo '(スレッド元書き込みの場合、投稿の添付画像、レス等も全て削除されます。)'; echo '</div><BR>'; echo '<BR>'; } } ?> <div id ='article'> <div id ='threadNum'> スレッドNo: <?php echo $article->id; ?> </DIV> <BR> <HR> <div id ='postDate'> 投稿日時: <?php
private function _checkLogin() { if (isset($_GET['oauth_token'])) { $this->_setAccessKey($_GET['oauth_token']); $token = $this->_getAccessToken(); $token = $token->_result; $token = is_bool($token) ? $token : (object) $token; if (!empty($token->oauth_token) && !empty($token->oauth_token_secret)) { $this->_setAccessKey($token->oauth_token); $this->_setAccessSecret($token->oauth_token_secret); } \Response::redirect(\Uri::current()); return NULL; } }
<!-- - Unfortunately, Microsoft has added a clever new - "feature" to Internet Explorer. If the text of - an error's message is "too small", specifically - less than 512 bytes, Internet Explorer returns - its own error message. You can turn that off, - but it's pretty tricky to find switch called - "smart error messages". That means, of course, - that short error messages are censored by default. - IIS always returns error messages that are long - enough to make Internet Explorer happy. The - workaround is pretty simple: pad the error - message with a big comment like this to push it - over the five hundred and twelve bytes minimum. - Of course, that's exactly what you're reading - right now. --> </head> <body> <h1>404</h1> <p>The page <code><?php echo htmlspecialchars(Uri::current()); ?> </code> was not found.</p> <p>Try the <a href="/">homepage</a></p> </body> </html>
<article> <h2><?php echo Uri::current() == Uri::create($article->href()) ? $article->title : Html::anchor($article->href(), $article->title); ?> </h2> <div class="article_content"> <?php echo \Formatting\Textile::format($article->body); ?> </div> <div class="article_meta"> <?php echo Date::time_ago($article->created_at); ?> by <?php echo $article->user->username; ?> </div> </article>
echo $product->title; ?> "><?php echo $product->title; ?> </h3> <span class="product-price">$<?php echo number_format($product_data['price'], 2); ?> </span> </span> <?php if ($product->attributes[0]->stock_quantity > 0 || $allow_buy_out_of_stock) { ?> <?php echo \Form::open(array('action' => \Uri::current(), 'method' => 'post', 'id' => 'cart_form')); ?> <?php echo \Form::hidden('product_id', $product->id); ?> <?php echo \Form::hidden('attributeid', '', array('class' => 'attributeid')); ?> <?php if (isset($attr_obj)) { echo \Form::hidden('product_attribute_id', $attr_obj->id, array('class' => 'product_attribute_id')); } ?> <?php echo \Form::hidden(\Config::get('security.csrf_token_key'), \Security::fetch_token()); ?>
<nav> <img src="<?php echo asset('views/assets/img/logo.png'); ?> "> <ul> <?php if (!isset($installed)) { ?> <li class="start database metadata account complete">Language and timezone</li> <li class="database metadata account complete">Database setup</li> <li class="metadata account complete">Site metadata</li> <li class="account complete">Your account</li> <?php } ?> <li class="complete">All done!</li> </ul> </nav> <script> (function(w, d, u) { var parts = "<?php echo Uri::current(); ?> ".split('/'), url = parts.pop(), li = d.getElementsByClassName(url); if(url == 'complete') d.body.parentNode.className += 'small'; for(var i = 0; i < li.length; i++) li[i].className += ' elapsed'; }(window, document)); </script>
/** * Tests Uri::current() * * @test */ public function test_current() { $output = Uri::current(); $expected = Uri::create(); $this->assertEquals($expected, $output); }
function comment_form_url() { return Uri::to(Uri::current()); }