/**
  * 注册
  */
 public function register()
 {
     if (IS_POST) {
         $data = array();
         $smscode = trim($_POST['smscode']);
         if (empty($smscode)) {
             $this->error('验证码为空');
         }
         $data['mobile'] = str_rp(trim($_POST['mobile']));
         if ($smscode == session('smscode') && session('codetype') == 'register' && session('mobile') == $data['mobile']) {
             $spread = '';
             $data['pwd'] = re_md5($_POST['pwd']);
             $inviter = str_rp(trimall($_POST['inviter']));
             if ($inviter) {
                 $inviter = explode('_', $inviter);
                 if (is_array($inviter)) {
                     $data['inviter_type'] = intval($inviter[0]);
                     $data['inviter_id'] = intval($inviter[1]);
                     $spread['inviter_id'] = $data['inviter_id'];
                     $spread['inviter_type'] = $data['inviter_type'];
                     $spread['invited_type'] = 1;
                     $spread['spread_stage'] = 0;
                     $spread['spread_time'] = NOW_TIME;
                     $spread['spread_reward'] = 2;
                 }
             }
             $data['register_time'] = NOW_TIME;
             $api = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php';
             $ipparam['format'] = 'js';
             $ipparam['ip'] = get_client_ip();
             $res = get_api($api, $ipparam, 'array');
             if (!empty($res['city'])) {
                 $data['city'] = $res['city'];
             }
             $seller_id = $this->model->add($data);
             if ($seller_id) {
                 unset($data);
                 //推广赏金
                 if (is_array($spread) && !empty($spread)) {
                     $spread['invited_id'] = $seller_id;
                     M('SpreadLog')->add($spread);
                 }
                 session(null);
                 session('seller_id', $seller_id);
                 $this->success("注册成功!", U('Member/index'));
                 exit;
             }
         } else {
             $this->error('验证码错误');
         }
     } elseif (IS_GET) {
         $this->check_login();
         $this->display();
     }
 }
Example #2
0
function notification()
{
    /* Sanity check, all notifications will be delivered via POST, so accept 
     * nothing else here */
    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        return;
    }
    /* Read all of the POST data in the incoming request */
    $post_data = file_get_contents('php://input');
    if (!$post_data) {
        return;
    }
    $api = get_api();
    if (isset($api)) {
        try {
            /* This will process the input data and return a proper 
             * notification object (Trustly_Data_JSONRPCNotificationRequest) if 
             * the input data is valid. Never process a notification if you get 
             * an exception during this stage and never attempt to process it 
             * by not calling handleNotifiction() as you might process a forged 
             * request.
             *
             * This can fail in more then one way:
             * Trustly_SignatureException: 
             *  The incoming request is not properly cryptographically signed. 
             *  This can be a sign of either a fraud attempt (somebody other 
             *  then Trustly is sending you notifications for Trustly orders in 
             *  an attempt to aquire funds) or that Trustly has changed it's 
             *  crpytographic keys (should be an _extremely_ rare occasion). 
             *
             * Trustly_JSONRPCVersionException:
             *  The incoming request is formatted according to a different 
             *  JSONRPC version then this library was written for. This is 
             *  fatal as we do not know how to handle the incoming request in 
             *  this format.
             * */
            $notification = $api->handleNotification($post_data);
        } catch (Trustly_SignatureException $e) {
            error_log('Got incoming notification with bad signature');
            return;
        } catch (Trustly_JSONRPCVersionException $e) {
            error_log('Got incoming notification with bad JSONRPC version');
            return;
        }
        if (isset($notification)) {
            /* The method will reveal what type of incoming notification this 
             * is. Depending on the type of notification the contents will 
             * differ. Read more of the different notifications and exakt 
             * contents at https://trustly.com/en/developer/api */
            $method = $notification->getMethod();
            /* The orderid will always be present in the notifications. This 
             * and the 'messageid' parameter is used to connect the order to 
             * your call. OrderID being the Trustly identifier and the 
             * messageid being your identifier */
            $orderid = $notification->getData('orderid');
            /* This contains all the data of the notification. For most 
             * notitications the "interesting" data is within an 
             * "attributes" object in the data. */
            $data = $notification->getData();
            $data['datestamp'] = @strftime('%F %T');
            save_order_data($orderid, array($method => $data));
            /* Once you have acted upon the data in the notification you should 
             * respond in the same HTTP request that you have received it and 
             * processed it. If you processed the request successfully (by 
             * successfully we mean in such a way that you processed the 
             * contents correctly, regardless if the data within the 
             * notification was to your liking or not) then you should respond 
             * to the request.
             *
             * The ONLY case where you should not respond to 
             * the request is when you failed to process the data. If you are 
             * unable to process the notification then either do not respond 
             * with anything or set the success parameter to FALSE in the call 
             * to notificationResponse();
             *
             * Trustly will continue to attempt to deliver this notification 
             * until you respond to it.
             * */
            $response = $api->notificationResponse($notification, TRUE);
            print $response->json();
        }
    }
}
 /**
  * 注册
  */
 public function register()
 {
     if (IS_POST) {
         $data = array();
         $smscode = strtolower(trim($_POST['smscode']));
         if (empty($smscode)) {
             $this->error('验证码为空');
         }
         if ($_POST['s_class'] == 'mobile') {
             $data['mobile'] = str_rp(trim($_POST['mobile']));
             if ($smscode == session('smscode') && session('codetype') == 'register' && session('mobile') == $data['mobile'] && !empty($data['mobile'])) {
                 $data['pwd'] = re_md5($_POST['pwd']);
                 $data['register_time'] = NOW_TIME;
                 $data['member_status'] = 1;
                 $api = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php';
                 $ipparam['format'] = 'js';
                 $ipparam['ip'] = get_client_ip();
                 $res = get_api($api, $ipparam, 'array');
                 if (!empty($res['city'])) {
                     $data['city'] = $res['city'];
                 }
                 $member_id = $this->model->add($data);
                 if ($member_id) {
                     M('Order')->where(array('mobile' => $data['mobile']))->setField('member_id', $member_id);
                     saveContact($data['mobile'], 'mobile', '注册');
                     unset($data);
                     session(null);
                     session('member_id', $member_id);
                     $this->success("注册成功!", U('Member/index'));
                     exit;
                 }
             } else {
                 $this->error('验证码错误');
             }
         } elseif ($_POST['s_class'] == 'email') {
             $data['email'] = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
             if ($smscode == session('smscode') && session('codetype') == 'register' && session('email') == $data['email'] && !empty($data['email'])) {
                 $data['pwd'] = re_md5($_POST['pwd']);
                 $data['register_time'] = NOW_TIME;
                 $data['member_status'] = 1;
                 $api = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php';
                 $ipparam['format'] = 'js';
                 $ipparam['ip'] = get_client_ip();
                 $res = get_api($api, $ipparam, 'array');
                 if (!empty($res['city'])) {
                     $data['city'] = $res['city'];
                 }
                 $member_id = $this->model->add($data);
                 if ($member_id) {
                     M('Order')->where(array('email' => $data['email']))->setField('member_id', $member_id);
                     saveContact($data['email'], 'email', '注册');
                     unset($data);
                     session(null);
                     session('member_id', $member_id);
                     $this->success("注册成功!", U('Member/index'));
                     exit;
                 }
             } else {
                 $this->error('验证码错误');
             }
         }
     } elseif (IS_GET) {
         $this->check_login();
         $this->display();
     }
 }