Пример #1
0
 public static function connection()
 {
     if (empty(self::$connection)) {
         $parameters = ["tcp://" . Config::get('database.redis.default.host') . ':' . Config::get('database.redis.default.port')];
         $options = ['cluster' => 'redis'];
         self::$connection = new Client($parameters, $options);
     }
     return self::$connection;
 }
Пример #2
0
 public static function connection()
 {
     if (empty(self::$connection)) {
         $parameters = ["tcp://" . env('REDIS_HOST_CLUSTER', '127.0.0.1')];
         $options = ['cluster' => 'redis'];
         self::$connection = new Predis\Client($parameters, $options);
     }
     return self::$connection;
 }
Пример #3
0
$sign = trim($_REQUEST['sign']);
if (empty($transdata) || empty($sign)) {
    error_log(FormatLogStr('lenovo', 'callback', ERROR_PARAM, 'sign,transdata param is NULL '));
    die('FAILTURE');
}
$result = verify($transdata, $appKey, $sign);
if ($result) {
    $param = json_decode($transdata, true);
    $shopid = @$shopMap[$param['waresid']];
    if (!$shopid) {
        error_log(FormatLogStr('lenovo', 'callback', ERROR_PARAM, 'get shopid faile for waresid ' . $param['waresid']));
        die('FAILTURE');
    }
    $orderId = $param["exorderno"];
    //updat redis
    $redis = new RedisHelper($config);
    $data = $redis->HGet("recharge_order", $orderId);
    if ($data === false) {
        error_log(FormatLogStr('lenovo', 'callback', ERROR_NEXIST, "order : {$orderId} is not exist"));
        die('FAILTURE');
    }
    $cache = json_decode($data, true);
    $cache["ExtOrderId"] = $param["transid"];
    $cache['PayTime'] = strtotime($param["transtime"]);
    $cache['Uin'] = intval($param["cpprivate"]);
    $url = $config['center'] . $centerPath . '?uin=' . $param["cpprivate"] . '&orderId=' . $orderId . "&shopId=" . $shopid;
    $res = https_get($url);
    if ($res === 'callback success') {
        error_log(FormatLogStr('lenovo', 'callback', ERROR_0, $transdata . "&sign={$sign}"));
        $log = GetLogger($config['logger']);
        $log->writeFile(FormatLogStr('lenovo', 'callback', ERROR_0, $url . ' ExtOrderId : ' . $cache['ExtOrderId']));
Пример #4
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
$config = (require dirname(__FILE__) . "/../utils/config.php");
require dirname(__FILE__) . "/../utils/redis.php";
require dirname(__FILE__) . "/../utils/util.php";
//有错误状态码一定要非200!!!
$orderId = trim($_REQUEST['exorderno']);
if (empty($orderId)) {
    error_log(FormatLogStr('lenovo', 'query', ERROR_PARAM, "exorderno : {$orderId} param is null"));
    http_response_code(400);
    die('{"error":3}');
} else {
    $redis = new RedisHelper($config);
    $data = $redis->HGet("recharge_order", $orderId);
    if ($data) {
        $dtls = json_decode($data, true);
        if ($dtls["Status"] === "success") {
            return;
        } else {
            error_log(FormatLogStr('lenovo', 'query', ERROR_STATUS, "exorderno : {$orderId} status is failed"));
            http_response_code(400);
            die('{"error":"2"}');
        }
    } else {
        error_log(FormatLogStr('lenovo', 'query', ERROR_NEXIST, "order : {$orderId} is not exist"));
        http_response_code(400);
        die('{"error":1}');
    }
}
Пример #5
0
 /**
  * to do hash
  */
 public function destroy($sessionId)
 {
     list($hashKey, $key) = RedisHelper::hashKey($this->prefix, $sessionId);
     return $this->redis->hDel($hashKey, $key);
 }
Пример #6
0
});
Validator::extend('variable', function ($field, $value, $parameters) {
    if (!empty($value)) {
        foreach ($value as $item) {
            if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $item)) {
                return false;
            }
        }
    }
    return true;
});
Route::get('mDelKey', function () {
    set_time_limit(0);
    $keys = Input::get('key');
    if (!empty($keys)) {
        RedisHelper::delMKey($keys);
    }
    pr('complete');
});
Route::get('reportAudience', function () {
    $tracking = new RawTrackingAudience();
    $data = $tracking->reportAudience();
    pr($data);
});
Route::get('get-adrequest-hourly', function () {
    $tracking = new RawTrackingAdRequest();
    if ($rows = $tracking->reportScheduleHourly()) {
        pr($rows);
        echo "Report Success";
    } else {
        echo "No Report Complete";
Пример #7
0
    $param = $_GET;
} elseif ($method == "POST") {
    $param = $_POST;
} else {
    error_log(FormatLogStr('midas', 'callback', ERROR_PARAM, 'invalidate request method : ' . $method));
    return;
}
$appkey = $appkey . '&';
if (SnsSigCheck::verifySig($method, $url_path, $param, $appkey, $param['sig'])) {
    //获取前台附加参数uin#shopid
    $shopData = explode('*', $param['appmeta']);
    if (count($shopData) < 2) {
        error_log(FormatLogStr('midas', 'callback', ERROR_PARAM, json_encode($param)));
        die('result=FAIL&resultMsg=附加参数个数不正确');
    }
    $redis = new RedisHelper($config);
    if ($redis->CheckOrder('recharge_order', $_REQUEST['billno'])) {
        error_log(FormatLogStr('midas', 'callback', ERROR_EXIST, json_encode($param)));
        die('{"ret":4,"msg": "订单已经存在"}');
    }
    $cache['Money'] = intval($param['amt']);
    $cache['Status'] = 'success';
    $cache['ExtOrderId'] = $param['billno'];
    $cache['PayTime'] = time();
    $cache['Time'] = time();
    $cache['Uin'] = intval($shopData[0]);
    $cache['ShopId'] = intval($shopData[1]);
    $url = $config['center'] . $centerPath . '?uin=' . $shopData[0] . '&shopId=' . $shopData[1] . '&orderId=' . $cache['ExtOrderId'];
    $res = https_get($url);
    if ($res === "success") {
        $log = GetLogger($config['logger']);
Пример #8
0
 public function setChecksumTrackingEvent($checksum, $event)
 {
     if ($event == Delivery::RESPONSE_TYPE_ADS_SUCCESS) {
         //custom đối với event ads_success do 2 event impression và start thứ tự call random theo từng request . P/S: f*****g jwplayer
         RedisHelper::set("Checksum:{$checksum}:beforeImpression", true, 10);
         RedisHelper::set("Checksum:{$checksum}:beforeStart", true, 10);
     }
     $cacheKey = "Checksum:{$checksum}:{$event}";
     return RedisHelper::set($cacheKey, true, 10);
 }
Пример #9
0
<Error>
<Code>USS-0540</Code>
<Timestamp>2015-12-18T18:07:23+08:00</Timestamp>
</Error>
success:
<IdentityInfo>
<AccountID>10064330519</AccountID>
<Username>13424208619</Username>
<DeviceID>866048029139310</DeviceID>
<verified>1</verified>
</IdentityInfo>
*/
$url = $authUrl . 'lpsust=' . $lpsust . '&realm=' . $appid;
$res = https_get($url);
if (strchr($res, '<Error>')) {
    error_log(FormatLogStr('lenovo', 'createorder', ERROR_THIRD, 'auth failed ' . str_replace("\n", "", $res)));
    die('{"error":"3"}');
}
//todo 验证是否有权限
$shopid = @$shopMap[$waresid];
if (!$shopid) {
    error_log(FormatLogStr('lenovo', 'createorder', ERROR_PARAM, 'get shopid faile for waresid ' . $waresid));
    die('{"error":"3"}');
}
$orderId = GenOrderId('_lenovo');
$data = array('waresid' => $waresid, 'Money' => $money, 'Time' => time(), 'Status' => "fail", 'ShopId' => $shopid, 'OrderId' => $orderId);
$redis = new RedisHelper($config);
$redis->HSet("recharge_order", $orderId, $data);
//保证redis是连接的
error_log(FormatLogStr('lenovo', 'createorder', ERROR_0, $orderId));
die('{"orderId": "' . $orderId . '"}');
Пример #10
0
 public function retargeting()
 {
     $adv = Input::get("adv");
     if ($adv <= 0) {
         return "";
     }
     $referer_url = "";
     if (isset($_SERVER['HTTP_REFERER'])) {
         $referer_url = $_SERVER['HTTP_REFERER'];
     }
     if ($referer_url != "") {
         $tracking = new Tracking();
         $key = "Retargeting:{$adv}:{$tracking->getVisitorId()}";
         $key_referer_url = $referer_url;
         $cache = RedisHelper::get($key);
         if ($cache == null) {
             $array = new stdClass();
             $array->{$referer_url} = $referer_url;
             RedisHelper::set($key, $array);
         } else {
             $array = $cache;
             $array->{$referer_url} = $referer_url;
             RedisHelper::set($key, $array);
         }
     }
 }