public function postUlogin() { $url_request = 'http://ulogin.ru/token.php?token=' . Input::get('token') . '&host=' . $_SERVER['HTTP_HOST']; $result = (new ApiController())->getCurl($url_request, FALSE); $_user = json_decode($result['curl_result'], true); $validate = Validator::make([], []); if (isset($_user['error'])) { return Redirect::to(URL::route('page', 'registering')); } $post['provider'] = $_user['network']; $post['identity'] = $_user['uid']; $api_social = (new ApiController())->social_logon($post); try { if (is_array($api_social)) { if (Ulogin::where('identity', '=', $_user['identity'])->exists() === FALSE) { $post = array(); $post['customerId'] = @$api_social['id']; $post['sessionKey'] = @$api_social['sessionKey']; $api = (new ApiController())->get_register($post); if (isset($api['email'])) { $password = Str::random(8); $post['remote_id'] = $post['customerId']; $post['email'] = $api['email']; $post['name'] = @$api['name']; $post['surname'] = @$api['surname']; $post['sex'] = @$api['sex'] == 'female' ? 0 : 1; $post['dd'] = @$api['dd']; $post['mm'] = @$api['mm']; $post['yyyy'] = @$api['yyyy']; $post['phone'] = @$api['phone']; $post['city'] = @$api['city']; $post['password'] = Hash::make($password); $post['code'] = Input::get('promo-code'); $user = (new RegisterController())->getRegisterAccount($post); (new RegisterController())->createULogin($user->id, $post); } } } else { /* if (Config::has('api.message')): Session::flash('message', Config::get('api.message')); else: Session::flash('message', 'Возникла ошибка при авторизации через социальную сеть.'); endif; return Redirect::to(pageurl('auth') . '#message'); */ } } catch (Exception $e) { Session::flash('message', 'Возникла ошибка при авторизации через социальную сеть.'); return Redirect::to(pageurl('auth') . '#message'); } if ($check = Ulogin::where('identity', '=', $_user['identity'])->first()) { Auth::loginUsingId($check->user_id, FALSE); if (is_array($api_social)) { Auth::user()->active = 1; Auth::user()->remote_id = @$api_social['id']; Auth::user()->sessionKey = @$api_social['sessionKey']; Auth::user()->save(); } if (isset($_COOKIE['firstCodeCookie']) && !empty($_COOKIE['firstCodeCookie'])) { $result = PromoController::registerPromoCode($_COOKIE['firstCodeCookie']); Session::flash('message', Config::get('api.message')); setcookie("firstCodeCookie", "", time() - 3600, '/'); return Redirect::to(AuthAccount::getGroupStartUrl() . '#message'); } return Redirect::to(AuthAccount::getGroupStartUrl()); } elseif (isset($_user['email']) && User::where('email', @$_user['email'])->exists()) { return Redirect::to(URL::route('page', 'registering'))->with('token', Input::get('token'))->with('email', @$_user['email'])->with('identity', @$_user['identity'])->with('profile', @$_user['profile'])->with('first_name', @$_user['first_name'])->with('last_name', @$_user['last_name'])->with('sex', @$_user['sex'] - 1)->with('bdate', @$_user['bdate'])->with('uid', @$_user['uid'])->with('photo_big', @$_user['photo_big'])->with('photo', @$_user['photo'])->with('network', @$_user['network'])->with('verified_email', @$_user['verified_email']); } else { $rules = array('network' => 'required|max:255', 'identity' => 'required|max:255|unique:ulogin', 'email' => 'required|unique:ulogin|unique:users'); $validate = Validator::make($_user, $rules); if ($validate->passes()) { return Redirect::to(URL::route('page', 'registering'))->with('token', Input::get('token'))->with('email', @$_user['email'])->with('identity', @$_user['identity'])->with('profile', @$_user['profile'])->with('first_name', @$_user['first_name'])->with('last_name', @$_user['last_name'])->with('sex', @$_user['sex'] - 1)->with('bdate', @$_user['bdate'])->with('uid', @$_user['uid'])->with('photo_big', @$_user['photo_big'])->with('photo', @$_user['photo'])->with('network', @$_user['network'])->with('verified_email', @$_user['verified_email']); } else { return Redirect::to(URL::route('page', 'registering')); } } }
public function signup() { $json_request = array('status' => FALSE, 'responseText' => '', 'valid_phone' => FALSE, 'redirectURL' => FALSE); if (Request::ajax()) { $validator = Validator::make(Input::all(), Accounts::$rules); if ($validator->passes()) { if (User::where('email', Input::get('email'))->exists() == FALSE) { $password = Str::random(8); $post = Input::all(); $post['password'] = $password; $api = (new ApiController())->send_register($post); if ($api === FALSE) { $json_request['responseText'] = Config::get('api.message'); return Response::json($json_request, 200); } elseif (is_array($api)) { $post['remote_id'] = @$api['id']; $post['sessionKey'] = @$api['sessionKey']; } $post['password'] = Hash::make($password); if ($account = self::getRegisterAccount($post)) { if (Config::get('directcrm.send_local_messages')) { Mail::send('emails.auth.signup', array('account' => $account, 'password' => $password, 'verified_email' => $post['verified_email']), function ($message) { $message->from(Config::get('mail.from.address'), Config::get('mail.from.name')); $message->to(Input::get('email'))->subject('Lipton - регистрация'); }); } self::createULogin($account->id, $post); Auth::loginUsingId($account->id, FALSE); $json_request['status'] = TRUE; $json_request['valid_phone'] = TRUE; $json_request['responseText'] = Lang::get('interface.SIGNUP.success'); if (isset($post['code']) && !empty($post['code'])) { $result = PromoController::registerPromoCode($post['code']); Session::flash('message', Config::get('api.message')); $json_request['redirectURL'] = URL::to(AuthAccount::getGroupStartUrl() . '#message'); setcookie("firstCodeCookie", "", time() - 3600, '/'); } } } else { $json_request['responseText'] = Lang::get('interface.SIGNUP.email_exist'); } } else { $json_request['responseText'] = Lang::get('interface.SIGNUP.fail'); } } else { return App::abort(404); } return Response::json($json_request, 200); }
/** * changepaymentstatus method * * This change the status of Payment from Admin Panel * @return void Description */ public function changepaymentstatus($token = null) { $tmp = explode(",", $token); $cId = $tmp[1]; $oId = $tmp[0]; $this->request->allowMethod('post', 'delete'); $order = $this->Order->find("first", array("conditions" => array("Order.id" => $oId))); if ($order['Order']['payment_status'] == "PENDING") { $this->Order->updateAll(array("Order.payment_status" => "'PAID'"), array("Order.sku" => $order['Order']['sku'])); App::uses("PromoController", "Controller"); $promo = new PromoController(); $promo->sendCashToReferal($order['Order']['customer_id']); } else { $this->Order->updateAll(array("Order.payment_status" => "'PENDING'"), array("Order.sku" => $order['Order']['sku'])); } return $this->redirect($this->request->referer()); }