Example #1
0
 /**
  * @param array $parameters
  * @param null $parent
  * @return string|null
  */
 public function getMobileDeviceType($parameters, $parent = NULL)
 {
     /** @var \Detection\MobileDetect $mobileDetection */
     $mobileDetection = new \Detection\MobileDetect();
     $mobileDetection->setUserAgent($parameters['userAgent']);
     $type = NULL;
     if ($mobileDetection->isTablet()) {
         $type = 'tablet';
     } elseif ($mobileDetection->isMobile()) {
         $type = 'smartPhone';
     } else {
         $parameters['returnResult'] = FALSE;
     }
     return $type;
 }
 /**
  * SetUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Request::addDetector('mobile', function ($request) {
         $detector = new \Detection\MobileDetect();
         return $detector->isMobile();
     });
     Request::addDetector('tablet', function ($request) {
         $detector = new \Detection\MobileDetect();
         return $detector->isTablet();
     });
     $this->event = new Event('Controller.beforeFilter');
     $this->Controller = new MobileComponentTestController(new Request());
     //$this->Controller->constructClasses();
     $this->Controller->request->session()->delete('User');
     Configure::delete('User');
 }
Example #3
0
 function alipay($order_id)
 {
     $this->load->model('order/Orders_model');
     $this->load->model('activities/Activities_model');
     $order = $this->Orders_model->getOne(array('order_id' => $order_id));
     $activity = $this->Activities_model->getOne(array('id' => $order_id['activity_id']));
     $pay_config = $this->config->item('alipay');
     $detector = new Detection\MobileDetect();
     $is_mobile = $detector->isMobile();
     $alipay = new \mytharcher\sdk\alipay\Alipay($pay_config, $is_mobile);
     if ($is_mobile) {
         $params = $alipay->prepareMobileTradeData(array('out_trade_no' => $order['order_id'], 'subject' => 'PaintMore 绘陌-订单', 'total_fee' => $order['price'], 'body' => $activity['title'], 'merchant_url' => 'http://' . $_SERVER['HTTP_HOST'], 'req_id' => date('Ymdhis-', time())));
         echo $alipay->buildRequestFormHTML($params, 'get');
     } else {
         echo $alipay->buildRequestFormHTML(array("service" => "create_direct_pay_by_user", "partner" => trim($pay_config['partner']), "payment_type" => $pay_config['payment_type'], "notify_url" => $pay_config['notify_url'], "return_url" => $pay_config['return_url'], "seller_id" => $pay_config['partner'], 'out_trade_no' => $order['order_id'], 'subject' => $this->config->item('subject'), 'total_fee' => $order['price'], 'body' => $activity['title'], "show_url" => site_url('activity') . '?activity_id=' . $activity['id'], "anti_phishing_key" => '', "exter_invoke_ip" => '', "_input_charset" => $pay_config['input_charset']), "post");
     }
 }
Example #4
0
Security::salt(Configure::consume('Security.salt'));
/**
 * The default crypto extension in 3.0 is OpenSSL.
 * If you are migrating from 2.x uncomment this code to
 * use a more compatible Mcrypt based implementation
 */
// Security::engine(new \Cake\Utility\Crypto\Mcrypt());
/**
 * Setup detectors for mobile and tablet.
 */
Request::addDetector('mobile', function ($request) {
    $detector = new \Detection\MobileDetect();
    return $detector->isMobile();
});
Request::addDetector('tablet', function ($request) {
    $detector = new \Detection\MobileDetect();
    return $detector->isTablet();
});
/**
 * Custom Inflector rules, can be set to correctly pluralize or singularize
 * table, model, controller names or whatever other string is passed to the
 * inflection functions.
 *
 * Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
 * Inflector::rules('irregular', ['red' => 'redlings']);
 * Inflector::rules('uninflected', ['dontinflectme']);
 * Inflector::rules('transliteration', ['/å/' => 'aa']);
 */
/**
 * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
 * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
 /**
  * @return boolean whether the user browser is a tablet browser
  */
 public static function isTablet()
 {
     $detector = new Detection\MobileDetect();
     return $detector->isTablet();
 }
Example #6
0
 /**
  * Function for detecting tablet client with useragent
  * 
  * @return bool client is tablet device
  */
 function isTablet()
 {
     $md = new \Detection\MobileDetect($this->_request->headers->all(), $this->_request->headers->get('User-Agent'));
     return $md->isTablet();
 }
Example #7
0
 */
require __DIR__ . '/vendor/autoload.php';
require_once "config.php";
// require_once("lib/Alipay.class.php");
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>支付宝即时到账交易接口</title>
</head>
<body>
<?php 
//计算得出通知验证结果
$detector = new Detection\MobileDetect();
$is_mobile = $detector->isMobile();
$alipay = new mytharcher\sdk\alipay\Alipay($alipay_config, $is_mobile);
$verify_result = $alipay->verifyCallback();
if ($verify_result) {
    //验证成功
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //请在这里加上商户的业务逻辑程序代码
    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
    //商户订单号
    $out_trade_no = $_GET['out_trade_no'];
    //支付宝交易号
    $trade_no = $_GET['trade_no'];
    //交易状态
    $trade_status = $_GET['trade_status'];
Example #8
0
<?php

$detect = new \Detection\MobileDetect();
define('MOBILE', $detect->isMobile());
define('TABLET', $detect->isTablet());