本文整理汇总了PHP中Core::request方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::request方法的具体用法?PHP Core::request怎么用?PHP Core::request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_pay
/**
* [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)));
}
}
示例2: action_social
public function action_social()
{
$user = FALSE;
$provider_name = Core::request('social_network');
$identifier = Core::request('token');
$email = Core::request('email');
$name = Core::request('name');
$user = Auth::instance()->social_login($provider_name, $identifier);
//not found in database
if ($user == FALSE) {
//register the user in DB
Model_User::create_social($email, $name, $provider_name, $identifier);
//log him in
$user = Auth::instance()->social_login($provider_name, $identifier);
}
if ($user !== FALSE and $user->loaded()) {
//save device id only if its different
if (Core::request('device_id') !== NULL and $user->device_id != Core::request('device_id')) {
$user->device_id = Core::request('device_id');
try {
$user->save();
} catch (Kohana_HTTP_Exception $khe) {
}
}
$this->rest_output(array('user' => self::get_user_array($user)));
}
}
示例3: action_result
public function action_result()
{
$this->auto_render = FALSE;
$id_order = Core::request('id_order');
//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)));
}
//correct payment?
if (($result = paguelofacil::check_result()) === TRUE) {
//mark as paid
$order->confirm_payment('paguelofacil', Core::request('Oper'));
//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, __('Transaction not successful!'));
$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)));
}
}
示例4: action_login
/**
* Handle GET requests.
*/
public function action_login()
{
// If the passwords match, perform a login
if (($user = Auth::instance()->email_login(Core::request('email'), Core::request('password'))) !== FALSE) {
if ($user->loaded()) {
//save device id only if its different
if (Core::request('device_id') !== NULL and $user->device_id != Core::request('device_id')) {
$user->device_id = Core::request('device_id');
try {
$user->save();
} catch (Kohana_HTTP_Exception $khe) {
}
}
$res = $user->as_array();
$res['user_token'] = $user->api_token();
$res['image'] = $user->get_profile_image();
//I do not want to return this fields...
$hidden_fields = array('password', 'token', 'hybridauth_provider_uid', 'token_created', 'token_expires', 'user_agent');
//all fields
$this->_return_fields = array_keys($res);
//remove the hidden fields
foreach ($this->_return_fields as $key => $value) {
if (in_array($value, $hidden_fields)) {
unset($this->_return_fields[$key]);
}
}
$this->rest_output(array('user' => $res));
}
} else {
$this->_error(__('Wrong user name or password'), 401);
}
}
示例5: action_index
/**
* List all Advertisements (PUBLISHED)
*/
public function action_index()
{
//template header
$this->template->title = __('Advertisements');
$this->template->meta_description = __('Advertisements');
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
$this->template->scripts['footer'][] = 'js/jquery.toolbar.js';
$this->template->scripts['footer'][] = 'js/oc-panel/moderation.js';
$ads = new Model_Ad();
$fields = array('title', 'id_ad', 'published', 'created', 'id_category', 'id_location', 'status');
//filter ads by status
$status = is_numeric(Core::get('status')) ? Core::get('status') : Model_Ad::STATUS_PUBLISHED;
$ads = $ads->where('status', '=', $status);
// sort ads by search value
if ($q = $this->request->query('search')) {
$ads = $ads->where('title', 'like', '%' . $q . '%');
if (core::config('general.search_by_description') == TRUE) {
$ads = $ads->or_where('description', 'like', '%' . $q . '%');
}
}
if (is_numeric(Core::request('filter__id_user'))) {
$ads = $ads->where('id_user', '=', Core::request('filter__id_user'));
}
$ads_count = clone $ads;
$res_count = $ads_count->count_all();
if ($res_count > 0) {
$pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $res_count, 'items_per_page' => 50))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
$ads = $ads->order_by(core::get('order', 'published'), core::get('sort', 'desc'))->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
$this->template->content = View::factory('oc-panel/pages/ad', array('res' => $ads, 'pagination' => $pagination, 'fields' => $fields));
} else {
$this->template->content = View::factory('oc-panel/pages/ad', array('res' => NULL, 'fields' => $fields));
}
}
示例6: action_process
public function action_process()
{
$this->auto_render = FALSE;
$this->template = View::factory('js');
//finished?
if ($this->amount_ads_import() === 0) {
/*Alert::set(Alert::SUCCESS,__('All ads are processed! Congrats!'));
$this->redirect(Route::url('oc-panel',array('controller'=>'import','action'=>'index')));*/
$this->template->content = json_encode('OK');
} else {
//how many ads we process in each request? pass get/post
$limit_process = Core::request('limit', 5);
$ads_import = DB::select()->from('adsimport')->where('processed', '=', '0')->limit($limit_process)->as_object()->execute();
$i = 0;
foreach ($ads_import as $adi) {
if ($this->create_ad($adi) === TRUE) {
$i++;
}
}
$todo = $this->amount_ads_import();
$done = $this->amount_ads_import(1);
$total = $todo + $done;
$this->template->content = json_encode(round(100 - $todo * 100 / $total));
//$this->redirect(Route::url('oc-panel',array('controller'=>'import','action'=>'process')));
}
}
示例7: __construct
function __construct(Request $request, Response $response)
{
parent::__construct($request, $response);
//forcing a filter
if (Core::request('filter__id_forum') === NULL) {
$this->_filter_post['id_forum'] = 'NOT NULL';
}
}
示例8: before
public function before()
{
parent::before();
$key = Core::request('apikey');
//try normal api key not user
if ($key != Core::config('general.api_key')) {
$this->_error(__('Wrong Api Key'), 401);
}
}
示例9: before
public function before()
{
parent::before();
$key = Core::request('user_token');
//try authenticate the user
if ($key == NULL or ($this->user = Auth::instance()->api_login($key)) == FALSE) {
$this->_error(__('Wrong Api User Token'), 401);
}
}
示例10: before
public function before()
{
parent::before();
if (Theme::get('premium') != 1) {
$this->_error('You need a premium theme to use the API', 401);
}
$key = Core::request('user_token');
//try authenticate the user
if ($key == NULL or ($this->user = Auth::instance()->api_login($key)) == FALSE) {
$this->_error(__('Wrong Api User Token'), 401);
}
}
示例11: before
public function before()
{
parent::before();
if (Theme::get('premium') != 1) {
$this->_error('You need a premium theme to use the API', 401);
}
$key = Core::request('apikey');
//try normal api key not user
if ($key != Core::config('general.api_key')) {
$this->_error(__('Wrong Api Key'), 401);
}
}
示例12: validate_passback
/**
* validate the return
* see https://www.2checkout.com/documentation/checkout/
* @param Model_Order $order
* @return order number or FALSE if not match
*/
public static function validate_passback(Model_Order $order)
{
$hashSecretWord = Core::config('payment.twocheckout_secretword');
//2Checkout Secret Word
$hashSid = Core::config('payment.twocheckout_sid');
//2Checkout account number
$hashTotal = self::money_format($order->amount);
//Sale total to validate against
$hashOrder = Core::request('order_number');
//2Checkout Order Number
$StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal));
return $StringToHash == Core::request('key') ? $hashOrder : FALSE;
}
示例13: action_index
public function action_index()
{
$this->template->title = __('Stats');
$this->template->bind('content', $content);
$content = View::factory('oc-panel/pages/stats/dashboard');
$content->title = $this->template->title;
// Getting the dates and range
$from_date = Core::request('from_date', date('Y-m-d', strtotime('-1 month')));
$to_date = Core::request('to_date', date('Y-m-d', strtotime('+1 day')));
// We assure is a proper time stamp if not we transform it
if (is_string($from_date) === TRUE) {
$from_date = strtotime($from_date);
}
if (is_string($to_date) === TRUE) {
$to_date = strtotime($to_date);
}
$from_datetime = new DateTime();
$to_datetime = new DateTime();
// Dates displayed
$content->from_date = date('Y-m-d', $from_date);
$content->to_date = date('Y-m-d', $to_date);
$content->days_ago = $from_datetime->setTimestamp($from_date)->diff($to_datetime->setTimestamp($to_date))->format("%a");
// Ads
$content->ads = $this->ads_by_date($from_date, $to_date);
$content->ads_total = $this->ads_total($from_date, $to_date);
$content->ads_total_past = $this->ads_total($from_date, $to_date, TRUE);
// Users
$content->users = $this->users_by_date($from_date, $to_date);
$content->users_total = $this->users_total($from_date, $to_date);
$content->users_total_past = $this->users_total($from_date, $to_date, TRUE);
// Visits
$content->visits = $this->visits_by_date($from_date, $to_date);
$content->visits_total = $this->visits_total($from_date, $to_date);
$content->visits_total_past = $this->visits_total($from_date, $to_date, TRUE);
// Contacts
$content->contacts = $this->contacts_by_date($from_date, $to_date);
$content->contacts_total = $this->contacts_total($from_date, $to_date);
$content->contacts_total_past = $this->contacts_total($from_date, $to_date, TRUE);
// Paid Orders
$content->paid_orders = $this->paid_orders_by_date($from_date, $to_date);
$content->paid_orders_total = $this->paid_orders_total($from_date, $to_date);
$content->paid_orders_total_past = $this->paid_orders_total($from_date, $to_date, TRUE);
// Sales
$content->sales = $this->sales_by_date($from_date, $to_date);
$content->sales_total = $this->sales_total($from_date, $to_date);
$content->sales_total_past = $this->sales_total($from_date, $to_date, TRUE);
$content->chart_config = array('height' => 94, 'width' => 378, 'options' => array('responsive' => true, 'scales' => array('xAxes' => array(array('display' => false)), 'yAxes' => array(array('display' => false, 'ticks' => array('min' => 0)))), 'legend' => array('display' => false)));
$content->chart_colors = array(array('fill' => 'rgba(33,150,243,.1)', 'stroke' => 'rgba(33,150,243,.8)', 'point' => 'rgba(33,150,243,.8)', 'pointStroke' => 'rgba(33,150,243,.8)'));
}
示例14: action_index
/**
*
* Loads a basic list info
* @param string $view template to render
*/
public function action_index($view = NULL)
{
$this->template->title = __('Orders');
$this->template->styles = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen');
$this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/oc-panel/crud/index.js', 'js/oc-panel/stats/dashboard.js');
$orders = new Model_Order();
$orders = $orders->where('status', '=', Model_Order::STATUS_PAID);
//filter email
if (core::request('email') !== NULL) {
$user = new Model_User();
$user->where('email', '=', core::request('email'))->limit(1)->find();
if ($user->loaded()) {
$orders = $orders->where('id_user', '=', $user->id_user);
}
}
//filter date
if (!empty(Core::request('from_date')) and !empty(Core::request('to_date'))) {
//Getting the dates range
$from_date = Core::request('from_date', strtotime('-1 month'));
$to_date = Core::request('to_date', time());
$orders = $orders->where('pay_date', 'between', array($from_date, $to_date));
}
//filter coupon
if (is_numeric(core::request('id_coupon'))) {
$orders = $orders->where('id_coupon', '=', core::request('id_coupon'));
}
//filter product
if (is_numeric(core::request('id_product'))) {
$orders = $orders->where('id_product', '=', core::request('id_product'));
}
//filter status
if (is_numeric(core::request('status'))) {
$orders = $orders->where('status', '=', core::request('status'));
}
//order by paid if we are filtering paid....
if (core::request('status') == Model_Order::STATUS_PAID) {
$orders->order_by('pay_date', 'desc');
} else {
$orders->order_by('id_order', 'desc');
}
$items_per_page = core::request('items_per_page', 10);
$pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $orders->count_all(), 'items_per_page' => $items_per_page))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
$pagination->title($this->template->title);
$orders = $orders->limit($items_per_page)->offset($pagination->offset)->find_all();
$pagination = $pagination->render();
$products = new Model_Product();
$products = $products->find_all();
$this->render('oc-panel/pages/order/index', array('orders' => $orders, 'pagination' => $pagination, 'products' => $products));
}
示例15: action_device
/**
* Handle GET requests.
*/
public function action_device()
{
try {
$result = FALSE;
if (($license = $this->request->param('id')) != NULL) {
$device_id = Core::request('device_id');
if ($license != NULL and $device_id != NULL) {
$result = Model_License::verify_device($license, $device_id);
}
}
$this->rest_output(array('valid' => $result));
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
}
}