Example #1
0
 static function identifyCountry()
 {
     $country = Session::getSessionVariable('country');
     if ($country !== null) {
         return $country;
     }
     $clientIP = self::getClientIP();
     $url = "http://api.ipinfodb.com/v3/ip-country/?key=7be18449bab1128e1f8c507b927112f34c634ba095c360842c536e49ddbddc56&ip={$clientIP}&format=json";
     $jsonResponse = file_get_contents($url);
     $response = json_decode($jsonResponse, true);
     if ($response['countryCode']) {
         $country = $response['countryCode'];
     } else {
         $country = 'RU';
     }
     Session::setSessionVariable('country', $country);
     return $country;
 }
 public static function YM_transaction_submit()
 {
     $usr = usr::getCurrentUser(1);
     if ($usr == null) {
         header('Location: /');
         exit;
     }
     if ($usr->getId() != 2) {
         header('Location: /');
         exit;
     }
     if (!isset($_GET['code'])) {
         $to = self::getVar('wallet');
         $UID = self::getVar('UID');
         Session::setSessionVariable('currentUIDTransaction', $UID);
         $scope = "account-info " . "operation-history " . "operation-details " . "payment.to-account(\"" . $to . "\",\"account\") ";
         $authUri = YandexMoney::authorizeUri(YM_OUT_ACCESSTOKEN, YM_OUT_REDIRECTPAGE, $scope);
         header('Location: ' . $authUri);
         exit;
     }
     $UID = Session::getSessionVariable('currentUIDTransaction');
     $code = $_GET['code'];
     $ym = new YandexMoney(YM_OUT_ACCESSTOKEN);
     $receiveTokenResp = $ym->receiveOAuthTokenOut($code, YM_OUT_REDIRECTPAGE, YM_OUT_SECRETTOKEN);
     if (!$receiveTokenResp->isSuccess()) {
         header('Location: /');
         exit;
     }
     $token = $receiveTokenResp->getAccessToken();
     $purseList = Purse::findBy(array('UID' => $UID, 'CurId' => 1));
     if (empty($purseList)) {
         header('Location: /admin/ym');
         exit;
     }
     $purse = $purseList[0];
     $prs = new Purse();
     $prs->findById($purse['id']);
     $prs->update(array('out_id' => $token));
     $at = new AtYm();
     $at->findBy(array('UID' => $UID));
     $at->delete();
     header('Location: /admin/ym');
     exit;
 }
Example #3
0
 public function getLastNewsByLocation()
 {
     $language = Session::getSessionVariable('lang');
     if ($language === null) {
         return;
     }
     $sql = "SELECT * FROM `news` WHERE `lang` =  '" . $language . "' ORDER BY `news_id` DESC LIMIT 1";
     $result = self::query($sql);
     if ($result && $language != 'EN') {
         $result['title'] = urldecode($result['title']);
         $result['full'] = urldecode($result['full']);
     }
     return $result;
 }
 public static function submitFeedback()
 {
     $captcha = Core::validate(self::getVar('captcha'));
     $right_code = Session::getSessionVariable('security_code');
     Session::unsetSessionVariable('security_code');
     if ($captcha != $right_code) {
         Core::printErrorJson('Incorrect captcha');
         exit;
     }
     $usr = self::getCurrentUser(1);
     if (!isset($usr)) {
         header('Location: /');
         exit;
     }
     $feedback = array();
     $feedback['type'] = Core::validate(self::getVar('trouble-type'));
     $feedback['message'] = Core::validate(self::getVar('trouble'));
     $feedback['email'] = Core::validate(self::getVar('email'));
     $fbModel = new Feedback();
     $fbModel->setUID($usr->getId());
     $fbModel->setType($feedback['type']);
     $fbModel->setMessage($feedback['message']);
     $fbModel->setEmail($feedback['email']);
     $fbModel->insert();
     Core::printSuccessJson('Your ticket is active now!');
 }