mirror of
https://github.com/janickiy/yii2-nomer
synced 2025-03-09 15:39:59 +00:00
add files to project
This commit is contained in:
commit
5cac498444
3729 changed files with 836998 additions and 0 deletions
11
controllers/AppsController.php
Normal file
11
controllers/AppsController.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use yii\web\Controller;
|
||||
|
||||
class AppsController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
return $this->render("index");
|
||||
}
|
||||
}
|
200
controllers/BlockController.php
Normal file
200
controllers/BlockController.php
Normal file
|
@ -0,0 +1,200 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\forms\BlockForm;
|
||||
use app\models\Site;
|
||||
use Yii;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\Json;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Controller;
|
||||
use app\models\BlockPhone;
|
||||
|
||||
class BlockController extends Controller
|
||||
{
|
||||
public function actionIndex()
|
||||
{
|
||||
|
||||
$phone = false;
|
||||
|
||||
$model = new BlockForm();
|
||||
if($model->load(\Yii::$app->request->post()) && $model->validate()) {
|
||||
$phone = preg_replace('/[^0-9]/', '', $model->phone);
|
||||
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "status" => [1, 2]])->one();
|
||||
if(!$block) {
|
||||
$code = sprintf("%'.03d", rand(0, 999));
|
||||
|
||||
$site = Site::find()->where(["name" => \Yii::$app->request->getHostName()])->one();
|
||||
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "site_id" => $site->id])->one();
|
||||
|
||||
if (is_null($block)) {
|
||||
$block = new BlockPhone();
|
||||
$block->phone = (string) $phone;
|
||||
$block->ip = Yii::$app->getRequest()->getUserIP();
|
||||
$block->ua = Yii::$app->getRequest()->getUserAgent();
|
||||
$block->tm = new Expression("NOW()");
|
||||
$block->code = (string) $code;
|
||||
$block->site_id = $site->id;
|
||||
|
||||
if ($block->save()) {
|
||||
/*
|
||||
$url = Url::to(['https://smsc.ru/sys/send.php',
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => 'Ваш код: ' . $code,
|
||||
'charset' => 'utf-8',
|
||||
'sender' => Yii::$app->name
|
||||
], 'https');
|
||||
*/
|
||||
|
||||
Yii::$app->session->set('lastBlockPhone', $phone);
|
||||
|
||||
$codeTxt = str_split($code, 1);
|
||||
$codeTxt = join(" ", $codeTxt);
|
||||
|
||||
|
||||
$request = curl_init("http://asterisk.apinomer.com:8101/call");
|
||||
curl_setopt_array($request, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => Json::encode(["phone" => $phone, "code" => $codeTxt]),
|
||||
CURLOPT_HTTPHEADER => ['Content-type: application/json'],
|
||||
]);
|
||||
|
||||
curl_exec($request);
|
||||
|
||||
//file_get_contents($url);
|
||||
//Yii::$app->session->set('lastBlockPhone', $phone);
|
||||
return $this->redirect(['block/confirm']);
|
||||
}
|
||||
} else {
|
||||
// $block = BlockPhone::find()->where(["phone" => $phone, "site_id" => $site->id])->one();
|
||||
// if(!$block) {
|
||||
$block = new BlockPhone();
|
||||
$block->phone = (string) $phone;
|
||||
$block->ip = Yii::$app->getRequest()->getUserIP();
|
||||
$block->ua = Yii::$app->getRequest()->getUserAgent();
|
||||
$block->tm = new Expression("NOW()");
|
||||
$block->site_id = $site->id;
|
||||
$block->save();
|
||||
// }
|
||||
Yii::$app->session->set('lastBlockPhone', $phone);
|
||||
return $this->redirect(['block/confirm']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('index', [
|
||||
"model" => $model,
|
||||
"phone" => $phone
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSms()
|
||||
{
|
||||
if(Yii::$app->session->get('smsBlockPhone')) {
|
||||
return $this->redirect(["block/confirm"]);
|
||||
};
|
||||
|
||||
$phone = Yii::$app->session->get('lastBlockPhone', null);
|
||||
|
||||
$site = Site::find()->where(["name" => \Yii::$app->request->getHostName()])->one();
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "site_id" => $site->id])->one();
|
||||
|
||||
Yii::$app->session->set('smsBlockPhone', true);
|
||||
|
||||
$url = Url::to(['https://smsc.ru/sys/send.php',
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => 'Ваш код: ' . $block->code,
|
||||
'charset' => 'utf-8',
|
||||
'sender' => Yii::$app->name
|
||||
], 'https');
|
||||
|
||||
file_get_contents($url);
|
||||
|
||||
return $this->redirect(["block/confirm"]);
|
||||
}
|
||||
|
||||
public function actionConfirm()
|
||||
{
|
||||
$phone = Yii::$app->session->get('lastBlockPhone', null);
|
||||
|
||||
if (is_null($phone)) {
|
||||
return $this->redirect(['block/index']);
|
||||
}
|
||||
|
||||
if (Yii::$app->request->isPost) {
|
||||
$code = Yii::$app->request->post('code');
|
||||
$code = preg_replace('/[^0-9]/', '', $code);
|
||||
|
||||
$site = Site::find()->where(["name" => \Yii::$app->request->getHostName()])->one();
|
||||
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "code" => $code, "site_id" => $site->id])->one();
|
||||
|
||||
if (!is_null($block)) {
|
||||
$block->status = 1;
|
||||
$block->save();
|
||||
// Yii::$app->session->remove('lastBlockPhone');
|
||||
// return $this->goHome();
|
||||
return $this->redirect(['block/pay']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('confirm', compact('phone'));
|
||||
}
|
||||
|
||||
public function actionRecall() {
|
||||
$phone = Yii::$app->session->get('lastBlockPhone', null);
|
||||
Yii::$app->session->set('recallBlockPhone', true);
|
||||
|
||||
$block = BlockPhone::find()->where(["phone" => $phone])->one();
|
||||
|
||||
if(!$block) {
|
||||
return $this->redirect(['block/confirm']);
|
||||
}
|
||||
|
||||
$request = curl_init("http://asterisk.apinomer.com:8101/call");
|
||||
curl_setopt_array($request, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => Json::encode(["phone" => $phone, "code" => $block->code]),
|
||||
CURLOPT_HTTPHEADER => ['Content-type: application/json'],
|
||||
]);
|
||||
|
||||
curl_exec($request);
|
||||
|
||||
//file_get_contents($url);
|
||||
return $this->redirect(['block/confirm']);
|
||||
}
|
||||
|
||||
public function actionPay()
|
||||
{
|
||||
$phone = Yii::$app->session->get('lastBlockPhone', null);
|
||||
|
||||
if (is_null($phone) || !BlockPhone::find()->where(['phone' => $phone, 'status' => BlockPhone::STATUS_CONFIRMED])->one()) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
$price = 299;
|
||||
|
||||
return $this->render('pay', compact('phone', 'price'));
|
||||
}
|
||||
|
||||
public function actionDeclinePay()
|
||||
{
|
||||
Yii::$app->session->remove('lastBlockPhone');
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
public function actionPaySuccess()
|
||||
{
|
||||
Yii::$app->session->remove('lastBlockPhone');
|
||||
return $this->render('success');
|
||||
}
|
||||
}
|
36
controllers/ContactsController.php
Normal file
36
controllers/ContactsController.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use app\models\search\UserContactSearch;
|
||||
|
||||
class ContactsController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'rules' => [
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@']
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex($pageSize = 20)
|
||||
{
|
||||
$searchModel = new UserContactSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->getRequest()->getQueryParams());
|
||||
$pageSize = (int) $pageSize == 0 ? 20 : $pageSize;
|
||||
$dataProvider->getPagination()->setPageSize($pageSize);
|
||||
return $this->render('index', compact('searchModel', 'dataProvider', 'pageSize'));
|
||||
}
|
||||
}
|
124
controllers/FeedbackController.php
Normal file
124
controllers/FeedbackController.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\Site;
|
||||
use app\models\Ticket;
|
||||
use app\models\TicketComment;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\db\Exception;
|
||||
use yii\db\Expression;
|
||||
use yii\web\Controller;
|
||||
use yii\web\ForbiddenHttpException;
|
||||
|
||||
class FeedbackController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
$model = new Ticket();
|
||||
|
||||
\Yii::$app->session->set("lastRef", \Yii::$app->request->referrer);
|
||||
|
||||
$ticketsDataProvider = null;
|
||||
$ticketsClosedDataProvider = null;
|
||||
|
||||
if(!\Yii::$app->getUser()->isGuest) {
|
||||
$ticketsDataProvider = new ActiveDataProvider([
|
||||
'query' => Ticket::find()->where(["is_deleted" => 0, "user_id" => \Yii::$app->getUser()->getId()])->andWhere(["<>", "status", 4])->orderBy(["id" => SORT_DESC])
|
||||
]);
|
||||
$ticketsClosedDataProvider = new ActiveDataProvider([
|
||||
'query' => Ticket::find()->where(["is_deleted" => 0, "user_id" => \Yii::$app->getUser()->getId(), "status" => 4])->orderBy(["id" => SORT_DESC])
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render("index", [
|
||||
"model" => $model,
|
||||
"ticketsDataProvider" => $ticketsDataProvider,
|
||||
"ticketsClosedDataProvider" => $ticketsClosedDataProvider
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew() {
|
||||
$ticket = new Ticket();
|
||||
|
||||
$site = Site::find()->where(["name" => $_SERVER["HTTP_HOST"]])->one();
|
||||
$ticket->site_id = $site->id;
|
||||
$ticket->url = \Yii::$app->session->get("lastRef", null);
|
||||
|
||||
if ($ticket->load(\Yii::$app->getRequest()->post()) && $ticket->save()) {
|
||||
return $this->redirect(['feedback/index']);
|
||||
}
|
||||
|
||||
return $this->render("new", [
|
||||
"ticket" => $ticket
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionView($id) {
|
||||
if(\Yii::$app->getUser()->isGuest) return $this->redirect(["site/index", "#" => "signin"]);
|
||||
$ticket = Ticket::find()->where(["id" => $id, "user_id" => \Yii::$app->getUser()->getId()])->one();
|
||||
if(!$ticket) {
|
||||
new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
|
||||
TicketComment::updateAll(["tm_read" => new Expression('NOW()')], "ticket_id = ".$ticket->id." AND tm_read is null AND user_id <> ".\Yii::$app->getUser()->id);
|
||||
|
||||
if($ticket->status == 2) {
|
||||
$ticket->status = 3;
|
||||
$ticket->save(false);
|
||||
}
|
||||
|
||||
$comments = TicketComment::find()->with("user")->where(["is_deleted" => 0, "ticket_id" => $ticket->id])->orderBy(["id" => SORT_ASC])->all();
|
||||
|
||||
$comment = new TicketComment();
|
||||
|
||||
return $this->render("view", [
|
||||
"ticket" => $ticket,
|
||||
"comments" => $comments,
|
||||
"comment" => $comment
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionComment($id) {
|
||||
$ticket = Ticket::find()->where(["id" => $id, "user_id" => \Yii::$app->getUser()->getId()])->one();
|
||||
if(!$ticket) {
|
||||
new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
|
||||
$comment = new TicketComment();
|
||||
$comment->load(\Yii::$app->request->post());
|
||||
$comment->ticket_id = $id;
|
||||
$comment->save();
|
||||
|
||||
if(!in_array($ticket->status, [6,7])) {
|
||||
$ticket->status = 0;
|
||||
}
|
||||
|
||||
$ticket->save(false);
|
||||
|
||||
return $this->redirect(["feedback/view", "id" => $id]);
|
||||
}
|
||||
|
||||
public function actionClose($id) {
|
||||
$model = Ticket::find()->where(["id" => $id])->one();
|
||||
if($model->user_id != \Yii::$app->getUser()->getId()) {
|
||||
throw new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
|
||||
$model->tm_close = new Expression('NOW()');
|
||||
$model->status = 4;
|
||||
$model->save(false);
|
||||
|
||||
return $this->redirect(['feedback/index']);
|
||||
}
|
||||
|
||||
public function actionReopen($id) {
|
||||
$model = Ticket::find()->where(["id" => $id])->one();
|
||||
if($model->user_id != \Yii::$app->getUser()->getId()) {
|
||||
throw new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
|
||||
$model->tm_reopen = new Expression('NOW()');
|
||||
$model->status = 5;
|
||||
$model->save(false);
|
||||
return $this->redirect(['feedback/index']);
|
||||
}
|
||||
}
|
143
controllers/FrameController.php
Normal file
143
controllers/FrameController.php
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\BlockPhone;
|
||||
use app\models\ResultCache;
|
||||
use app\models\SearchRequest;
|
||||
use app\models\UrlFilter;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class FrameController extends Controller {
|
||||
|
||||
public $layout = 'frame';
|
||||
|
||||
public function actionIndex($phone) {
|
||||
$phone = preg_replace("/^8/", "7", $phone);
|
||||
|
||||
$refresh = \Yii::$app->request->get("refresh", false);
|
||||
|
||||
$result = [];
|
||||
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "status" => 1])->one();
|
||||
if(!is_null($block)) {
|
||||
return $this->render("block", ["phone" => $phone]);
|
||||
}
|
||||
|
||||
$cache = ResultCache::find()->where(['phone' => $phone])->andWhere([">", "tm", date("Y-m-d H:i:s", strtotime("-1 month"))])->all();
|
||||
if(count($cache) && !$refresh) {
|
||||
$result["cache"] = true;
|
||||
}
|
||||
|
||||
if (preg_match("/79(\d{9})/", $phone)) {
|
||||
$operatorCache = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_OPERATOR])->one();
|
||||
if(is_null($operatorCache)) {
|
||||
$operator = @file_get_contents("https://moscow.megafon.ru/api/mfn/info?msisdn=" . $phone);
|
||||
if ($operator) {
|
||||
$operator = Json::decode($operator);
|
||||
|
||||
if (!is_null($operator) && !isset($operator["error"])) {
|
||||
$result["mobile"]["operator"] = $operator["operator"];
|
||||
$result["mobile"]["region"] = $operator["region"];
|
||||
$operatorCache = new ResultCache();
|
||||
$operatorCache->phone = $phone;
|
||||
$operatorCache->type_id = ResultCache::TYPE_OPERATOR;
|
||||
$operatorCache->data = Json::encode($result["mobile"]);
|
||||
$operatorCache->save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result["mobile"] = Json::decode($operatorCache->data);
|
||||
}
|
||||
}
|
||||
|
||||
$lastId = \Yii::$app->session->get("lastSearchId", null);
|
||||
$lastPhone = \Yii::$app->session->get("lastSearchPhone");
|
||||
if($phone !== $lastPhone) {
|
||||
$searchRequest = new SearchRequest();
|
||||
$searchRequest->ip = \Yii::$app->request->userIP;
|
||||
$searchRequest->ua = \Yii::$app->request->userAgent;
|
||||
$searchRequest->phone = $phone;
|
||||
$searchRequest->tm = new Expression("NOW()");
|
||||
$searchRequest->user_id = \Yii::$app->getUser()->isGuest?null:\Yii::$app->getUser()->getId();
|
||||
$searchRequest->refresh = (boolean)$refresh;
|
||||
$searchRequest->save();
|
||||
$lastId = $searchRequest->id;
|
||||
}
|
||||
|
||||
$log = SearchRequest::find()->where(["phone" => $phone])->andWhere(["<>", "id", $lastId])->orderBy(["id" => SORT_DESC])->all();
|
||||
|
||||
|
||||
return $this->render("index", [
|
||||
'id' => $lastId,
|
||||
'phone' => $phone,
|
||||
'result' => $result,
|
||||
'log' => $log
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionVk($phone) {
|
||||
$vkCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_VK])->one();
|
||||
if(is_null($vkCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
$vkCacheData = Json::decode($vkCache->data);
|
||||
|
||||
return $this->render("vk", [
|
||||
"phone" => $phone,
|
||||
"result" => $vkCacheData["result2012"]
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionGoogle($phone) {
|
||||
$googleCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_GOOGLE_PHONE])->one();
|
||||
if(is_null($googleCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
$urls = ArrayHelper::map(UrlFilter::find()->all(), "url", "type");
|
||||
|
||||
return $this->render("google", [
|
||||
"phone" => $phone,
|
||||
"result" => Json::decode($googleCache->data),
|
||||
"urls" => $urls
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionAvinfo($phone) {
|
||||
$avinfoCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_AVINFO])->one();
|
||||
if(is_null($avinfoCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
return $this->render("avinfo", [
|
||||
"phone" => $phone,
|
||||
"result" => Json::decode($avinfoCache->data)
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionAvito($phone, $id = null) {
|
||||
$avitoCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_AVITO])->one();
|
||||
if(is_null($avitoCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
if($id) {
|
||||
return $this->render("avito_item", [
|
||||
"id" => $id,
|
||||
"phone" => $phone,
|
||||
"result" => Json::decode($avitoCache->data)
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render("avito", [
|
||||
"phone" => $phone,
|
||||
"result" => Json::decode($avitoCache->data)
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
32
controllers/GoogleController.php
Normal file
32
controllers/GoogleController.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\SearchRequest;
|
||||
use app\models\User;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Controller;
|
||||
|
||||
class GoogleController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
$id = \Yii::$app->request->get("id");
|
||||
$uuid = \Yii::$app->request->get("uuid");
|
||||
$user = User::find()->where(["uuid" => $uuid])->one();
|
||||
|
||||
if(!$user) {
|
||||
throw new BadRequestHttpException("Пользователь с uuid: ".$uuid." не найден");
|
||||
}
|
||||
|
||||
$searchRequest = SearchRequest::getDb()->cache(function () use ($id, $user) {
|
||||
return SearchRequest::find()->where(["id" => $id, "user_id" => $user->id])->one();
|
||||
});
|
||||
|
||||
if(!$searchRequest) {
|
||||
throw new BadRequestHttpException("Запрос с ID: ".$id." не найден");
|
||||
}
|
||||
|
||||
return $this->render("index", [
|
||||
"searchRequest" => $searchRequest
|
||||
]);
|
||||
}
|
||||
}
|
40
controllers/HistoryController.php
Normal file
40
controllers/HistoryController.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\SearchRequest;
|
||||
use Yii;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
|
||||
class HistoryController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'rules' => [
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@']
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
/* @var $user \app\models\User */
|
||||
$user = Yii::$app->getUser()->getIdentity();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => SearchRequest::find()->where(['user_id' => $user->id])->with('results'),
|
||||
'sort' => ['defaultOrder' => ['id' => SORT_DESC]]
|
||||
]);
|
||||
|
||||
return $this->render('index', compact('dataProvider'));
|
||||
}
|
||||
}
|
48
controllers/MController.php
Normal file
48
controllers/MController.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\RequestResult;
|
||||
use app\models\ResultCache;
|
||||
use app\models\SearchRequest;
|
||||
use yii\helpers\Json;
|
||||
use yii\web\Controller;
|
||||
use yii\web\Response;
|
||||
|
||||
class MController extends Controller {
|
||||
|
||||
public function actionFacebook($id) {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
$result = RequestResult::find()->where(["request_id" => $id, "type_id" => ResultCache::TYPE_FACEBOOK])->one();
|
||||
if(is_null($result)) return [];
|
||||
|
||||
$data = Json::decode($result->data);
|
||||
sort($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function actionVk($id) {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
$result = RequestResult::find()->where(["request_id" => $id, "type_id" => ResultCache::TYPE_VK])->one();
|
||||
if(is_null($result)) return [];
|
||||
|
||||
$data = Json::decode($result->data);
|
||||
sort($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function actionAvito($id) {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
$result = RequestResult::find()->where(["request_id" => $id, "type_id" => ResultCache::TYPE_AVITO])->one();
|
||||
if(is_null($result)) return [];
|
||||
|
||||
$data = Json::decode($result->data);
|
||||
//sort($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
15
controllers/PackagesController.php
Normal file
15
controllers/PackagesController.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use yii\web\Controller;
|
||||
|
||||
class PackagesController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
return $this->render("index");
|
||||
}
|
||||
|
||||
public function actionBuy() {
|
||||
|
||||
}
|
||||
}
|
410
controllers/PayController.php
Normal file
410
controllers/PayController.php
Normal file
|
@ -0,0 +1,410 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\BlockPhone;
|
||||
use app\models\forms\WmForm;
|
||||
use app\models\Payment;
|
||||
use app\models\PhoneRequest;
|
||||
use app\models\Repost;
|
||||
use app\models\Site;
|
||||
use app\models\Ticket;
|
||||
use app\models\User;
|
||||
use app\models\WebmoneyOrder;
|
||||
use Imagick;
|
||||
use ImagickDraw;
|
||||
use ImagickPixel;
|
||||
use yii\db\Exception;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Controller;
|
||||
use yii\web\ForbiddenHttpException;
|
||||
use yii\web\Response;
|
||||
|
||||
class PayController extends Controller {
|
||||
|
||||
public $enableCsrfValidation = false;
|
||||
|
||||
public function actionIndex() {
|
||||
if(\Yii::$app->getUser()->isGuest) return $this->goHome();
|
||||
|
||||
$hasRepost = Repost::find()->where(["user_id" => \Yii::$app->getUser()->getId()])->count(1);
|
||||
|
||||
return $this->render("index", ["hasRepost" => $hasRepost]);
|
||||
}
|
||||
|
||||
public function actionSuccess() {
|
||||
return $this->render("success");
|
||||
}
|
||||
|
||||
public function actionFindPhoneSuccess() {
|
||||
return $this->render("find-phone-success");
|
||||
}
|
||||
|
||||
public function actionPaypal() {
|
||||
$f = fopen(\Yii::getAlias('@runtime')."/paypal.log", 'a+');
|
||||
fwrite($f, print_r(\Yii::$app->request->post(), true)."\n\n");
|
||||
fwrite($f, print_r(\Yii::$app->request->get(), true)."\n\n");
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
public function actionCouponCheck() {
|
||||
$uniquecode = \Yii::$app->request->get("uniquecode");
|
||||
|
||||
$data = [
|
||||
"id_seller" => "729622",
|
||||
"unique_code" => $uniquecode,
|
||||
"sign" => md5("729622:".$uniquecode.":F58F3834A6")
|
||||
];
|
||||
$data = Json::encode($data);
|
||||
|
||||
$ch = curl_init("https://www.oplata.info/xml/check_unique_code.asp");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$f = fopen(\Yii::getAlias('@runtime')."/ccc.log", "a+");
|
||||
fwrite($f, $response."\n\n");
|
||||
fclose($f);
|
||||
|
||||
$response = Json::decode($response);
|
||||
if(ArrayHelper::getValue($response, "retval") == 0) {
|
||||
$base64params = ArrayHelper::getValue($response, "query_string");
|
||||
$base64params = base64_decode($base64params);
|
||||
parse_str($base64params, $output);
|
||||
|
||||
$checks = ArrayHelper::getValue($response, "cnt_goods");
|
||||
|
||||
$sum = ArrayHelper::getValue($response, "amount");
|
||||
$sum = str_replace(",", ".", $sum);
|
||||
$amount = $sum - ($sum * 0.015);
|
||||
|
||||
$payment = Payment::find()->where(["type_id" => Payment::TYPE_COUPON, "operation_label" => $uniquecode])->one();
|
||||
if(!$payment) {
|
||||
$payment = new Payment();
|
||||
$payment->user_id = (int)$output["user_id"];
|
||||
$payment->sum = $sum;
|
||||
$payment->site_id = (int)ArrayHelper::getValue($output, "site_id", 1);
|
||||
$payment->amount = $amount;
|
||||
$payment->tm = date("Y-m-d H:i:s", strtotime(ArrayHelper::getValue($response, "date_pay")));
|
||||
$payment->operation_label = (string)ArrayHelper::getValue($response, "unique_code");
|
||||
$payment->operation_id = (string)ArrayHelper::getValue($response, "inv");
|
||||
$payment->type_id = Payment::TYPE_COUPON;
|
||||
$payment->save();
|
||||
|
||||
if ($payment->user_id) {
|
||||
/* @var $user \app\models\User */
|
||||
$user = User::find()->where(["id" => $payment->user_id])->one();
|
||||
$user->addBalance($sum, $amount, true, $payment->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->redirect(["pay/success"]);
|
||||
}
|
||||
|
||||
public function actionRepost() {
|
||||
if(\Yii::$app->getUser()->isGuest) return $this->goHome();
|
||||
$hasRepost = Repost::find()->where(["user_id" => \Yii::$app->getUser()->getId()])->count(1);
|
||||
|
||||
return $this->render("repost", [
|
||||
"hasRepost" => $hasRepost
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionCheckRepost() {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
$site = Site::find()->where(["name" => $_SERVER["HTTP_HOST"]])->one();
|
||||
|
||||
$response = file_get_contents("https://api.vk.com/method/likes.getList?type=sitepage&owner_id=".$site->vk_id."&item_id=".\Yii::$app->getUser()->getId()."&filter=copies&v=4.93");
|
||||
|
||||
$response = Json::decode($response);
|
||||
|
||||
$vkID = ArrayHelper::getValue($response, ["response", "items", 0], false);
|
||||
|
||||
$responseFriends = file_get_contents("https://api.vk.com/method/friends.get?user_id=".$vkID."&v=5.8");
|
||||
$responseFriends = Json::decode($responseFriends);
|
||||
$friends = ArrayHelper::getValue($responseFriends, ["response", "count"], 0);
|
||||
|
||||
if($vkID and $friends > 20) {
|
||||
$repost = Repost::find()->where(["vk_id" => $vkID])->one();
|
||||
if(!$repost) {
|
||||
$repost = new Repost();
|
||||
$repost->user_id = \Yii::$app->getUser()->getId();
|
||||
$repost->site_id = $site->id;
|
||||
$repost->vk_id = $vkID;
|
||||
$repost->tm = new Expression("NOW()");
|
||||
if($repost->save()) {
|
||||
$user = User::find()->where(["id" => $repost->user_id])->one();
|
||||
$user->checks += 2;
|
||||
$user->save();
|
||||
return ["success" => 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ["success" => 0];
|
||||
}
|
||||
|
||||
public function actionQiwi() {
|
||||
//if (\Yii::$app->getUser()->isGuest) return $this->goHome();
|
||||
return $this->render('qiwi');
|
||||
}
|
||||
|
||||
public function actionQiwiBlock()
|
||||
{
|
||||
return $this->render('qiwi_block');
|
||||
}
|
||||
|
||||
public function actionPaymentwallResult()
|
||||
{
|
||||
$f = fopen(\Yii::getAlias('@runtime') . '/paymentwall.txt', "a+");
|
||||
fwrite($f, Json::encode(\Yii::$app->request->post()));
|
||||
fwrite($f, Json::encode(\Yii::$app->request->get()));
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
public function actionWebmoneyResult() {
|
||||
$post = \Yii::$app->request->post();
|
||||
\Yii::$app->response->statusCode = 200;
|
||||
if(!count($post)) {
|
||||
echo "YES"; die();
|
||||
}
|
||||
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/wm.log', 'a+');
|
||||
fwrite($f, Json::encode(\Yii::$app->request->post())."\n\n");
|
||||
|
||||
|
||||
$wmForm = new WmForm;
|
||||
$wmForm->LMI_PAYEE_PURSE = \Yii::$app->request->post('LMI_PAYEE_PURSE');
|
||||
$wmForm->LMI_PAYMENT_AMOUNT = \Yii::$app->request->post('LMI_PAYMENT_AMOUNT');
|
||||
$wmForm->LMI_PAYMENT_NO = \Yii::$app->request->post('LMI_PAYMENT_NO');
|
||||
$wmForm->LMI_MODE = \Yii::$app->request->post('LMI_MODE');
|
||||
$wmForm->LMI_SYS_INVS_NO = \Yii::$app->request->post('LMI_SYS_INVS_NO');
|
||||
if(trim($wmForm->LMI_SYS_INVS_NO) == '') throw new BadRequestHttpException('Error');
|
||||
$wmForm->LMI_SYS_TRANS_NO = \Yii::$app->request->post('LMI_SYS_TRANS_NO');
|
||||
if(trim($wmForm->LMI_SYS_TRANS_NO) == '') throw new BadRequestHttpException('Error');
|
||||
$wmForm->LMI_SYS_TRANS_DATE = \Yii::$app->request->post('LMI_SYS_TRANS_DATE');
|
||||
$wmForm->LMI_SECRET_KEY = \Yii::$app->request->post('LMI_SECRET_KEY');
|
||||
$wmForm->LMI_PAYER_PURSE = \Yii::$app->request->post('LMI_PAYER_PURSE');
|
||||
$wmForm->LMI_PAYER_WM = \Yii::$app->request->post('LMI_PAYER_WM');
|
||||
$wmForm->LMI_HASH = \Yii::$app->request->post('LMI_HASH');
|
||||
|
||||
fwrite($f, "WMFORM BEFORE VALIDATE\n");
|
||||
|
||||
if($wmForm->validate()){
|
||||
fwrite($f, "WMFORM SUCCESS VALIDATE\n");
|
||||
$order = WebmoneyOrder::find()->where(["id" => (int)$wmForm->LMI_PAYMENT_NO, "status" => 0])->one();
|
||||
if(!$order) die();
|
||||
|
||||
if($order->user_id > 0) {
|
||||
$user = User::find()->where(["id" => $order->user_id])->one();
|
||||
} else {
|
||||
$findPhone = PhoneRequest::find()->where(["id" => -$order->user_id])->one();
|
||||
$user = User::find()->where(["id" => $findPhone->user_id])->one();
|
||||
|
||||
$ticket = new Ticket();
|
||||
$ticket->detachBehavior("user_id");
|
||||
$ticket->user_id = $user->id;
|
||||
$ticket->site_id = $order->site_id;
|
||||
$ticket->subject_id = 1;
|
||||
$ticket->text = $findPhone->data;
|
||||
$ticket->subject = "Запрос на поиск номера телефона";
|
||||
$ticket->status = 0;
|
||||
$ticket->is_payed = true;
|
||||
$ticket->tm_create = new Expression('NOW()');
|
||||
$ticket->save(false);
|
||||
}
|
||||
|
||||
|
||||
fwrite($f, "WMFORM ORDER ".$order->id."\n");
|
||||
|
||||
$sum = \Yii::$app->request->post('LMI_PAYMENT_AMOUNT');
|
||||
|
||||
$payment = new Payment();
|
||||
$payment->site_id = $order->site_id;
|
||||
$payment->user_id = $user->id;
|
||||
$payment->sum = $sum;
|
||||
$payment->amount = $sum;
|
||||
$payment->tm = new Expression('NOW()');
|
||||
$payment->operation_label = (string)\Yii::$app->request->post('LMI_SYS_INVS_NO');
|
||||
$payment->operation_id = (string)\Yii::$app->request->post('LMI_SYS_TRANS_NO');
|
||||
$payment->type_id = Payment::TYPE_WEBMONEY;
|
||||
if(!$payment->save()) {
|
||||
fwrite($f, Json::encode($payment->getErrors()));
|
||||
}
|
||||
|
||||
if ($payment->user_id) {
|
||||
/* @var $user \app\models\User */
|
||||
$user = User::find()->where(['id' => $payment->user_id])->one();
|
||||
$user->addBalance($sum, $sum, true, $payment->site_id);
|
||||
}
|
||||
|
||||
$order->status = 1;
|
||||
$order->save();
|
||||
|
||||
echo 'OK';
|
||||
} else {
|
||||
fwrite($f, "WMFORM FAIL VALIDATE\n");
|
||||
fwrite($f, Json::encode($wmForm->getErrors()));
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
die();
|
||||
}
|
||||
|
||||
public function actionResult() {
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/log.txt', "a+");
|
||||
fwrite($f, Json::encode(\Yii::$app->request->post())."\n\n");
|
||||
fwrite($f, Json::encode(\Yii::$app->request->get())."\n\n");
|
||||
fclose($f);
|
||||
|
||||
$post = \Yii::$app->request->post();
|
||||
|
||||
$label = explode('-', ArrayHelper::getValue($post, 'label'));
|
||||
|
||||
$blockPayment = $label[0] == 'block';
|
||||
|
||||
$sum = ArrayHelper::getValue($post, 'withdraw_amount');
|
||||
$notification_type = (string) ArrayHelper::getValue($post, 'notification_type');
|
||||
|
||||
if ($blockPayment) {
|
||||
$blockedPhone = BlockPhone::find()->where(['phone' => $label[1], 'status' => BlockPhone::STATUS_CONFIRMED])->one();
|
||||
|
||||
if ($sum >= 299 && $blockedPhone) {
|
||||
$blockedPhone->status = BlockPhone::STATUS_PAID;
|
||||
$blockedPhone->save();
|
||||
}
|
||||
|
||||
$payment = Payment::find()->where(["operation_id" => (string)ArrayHelper::getValue($post, "operation_id")])->one();
|
||||
if ($payment) return '';
|
||||
|
||||
$userID = $label[2] == 0 ? null : $label[2];
|
||||
$siteID = $label[3];
|
||||
} else {
|
||||
$payment = Payment::find()->where(["operation_id" => (string)ArrayHelper::getValue($post, "operation_id")])->one();
|
||||
if ($payment) return '';
|
||||
|
||||
$userID = (int)$label[0];
|
||||
$siteID = 0;
|
||||
|
||||
if (isset($label[1])) {
|
||||
$siteID = (int)$label[1];
|
||||
}
|
||||
}
|
||||
|
||||
$payment = new Payment();
|
||||
$payment->user_id = $userID;
|
||||
$payment->sum = $sum;
|
||||
$payment->site_id = $siteID;
|
||||
$payment->amount = ArrayHelper::getValue($post, "amount");
|
||||
$payment->tm = date("Y-m-d H:i:s", strtotime(ArrayHelper::getValue($post, "datetime")));
|
||||
$payment->operation_label = (string)ArrayHelper::getValue($post, "operation_label");
|
||||
$payment->operation_id = (string)ArrayHelper::getValue($post, "operation_id");
|
||||
$payment->type_id = $notification_type=="card-incoming"?Payment::TYPE_YANDEX:Payment::TYPE_YANDEX_WALLET;
|
||||
$payment->save();
|
||||
|
||||
if($payment->sum == 1000) {
|
||||
$findPhone = PhoneRequest::find()->where(["user_id" => $payment->user_id])->orderBy(["id" => SORT_DESC])->one();
|
||||
$ticket = new Ticket();
|
||||
$ticket->detachBehavior("user_id");
|
||||
$ticket->user_id = $userID;
|
||||
$ticket->site_id = $siteID;
|
||||
$ticket->subject_id = 1;
|
||||
$ticket->text = $findPhone->data;
|
||||
$ticket->subject = "Запрос на поиск номера телефона";
|
||||
$ticket->status = 0;
|
||||
$ticket->is_payed = true;
|
||||
$ticket->tm_create = new Expression('NOW()');
|
||||
$ticket->save(false);
|
||||
} else {
|
||||
if (!$blockPayment && $payment->user_id) {
|
||||
/* @var $user \app\models\User */
|
||||
$user = User::find()->where(['id' => $payment->user_id])->one();
|
||||
$user->addBalance($sum, $payment->amount, true, $payment->site_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function actionFindPhoneConfirm() {
|
||||
$id = \Yii::$app->request->get("id");
|
||||
$request = PhoneRequest::find()->where(["id" => $id, "user_id" => \Yii::$app->getUser()->getId()])->one();
|
||||
if(!$request) {
|
||||
throw new ForbiddenHttpException();
|
||||
}
|
||||
|
||||
return $this->render("find-phone-confirm", ["id" => $id]);
|
||||
}
|
||||
|
||||
public function actionFindPhone() {
|
||||
$id = \Yii::$app->request->get("id");
|
||||
$request = PhoneRequest::find()->where(["id" => $id, "user_id" => \Yii::$app->getUser()->getId()])->one();
|
||||
if(!$request) {
|
||||
throw new ForbiddenHttpException();
|
||||
}
|
||||
|
||||
$dataType = $data = null;
|
||||
if(preg_match('/@/', $request->data)) {
|
||||
$dataType = "email";
|
||||
$data = $request->data;
|
||||
} elseif(preg_match('/vk\.com\/(.+)/', $request->data, $m)) {
|
||||
$dataType = "vk";
|
||||
$vkResponse = @file_get_contents("https://api.vk.com/method/users.get?user_ids=".$m[1]."&fields=photo_max,photo_max_orig");
|
||||
$vkResponse = Json::decode($vkResponse);
|
||||
$data = ArrayHelper::getValue($vkResponse, ["response", 0]);
|
||||
} elseif(preg_match('/facebook\.com/', $request->data)) {
|
||||
$fbId = preg_replace('[\D]', '', $request->data);
|
||||
$dataType = "fb";
|
||||
$fbResponse = @file_get_contents("https://graph.facebook.com/".$fbId."?fields=first_name,last_name&access_token=223417934354442|uoEzUVtKfO6Y-txtcgT8i4bzRG8&locale=ru_RU");
|
||||
$fbResponse = Json::decode($fbResponse);
|
||||
$data = $fbResponse;
|
||||
$data["photo"] = "http://graph.facebook.com/".$fbId."/picture?width=400&height=400";
|
||||
} elseif(preg_match('/instagram/', $request->data)) {
|
||||
$dataType = "instagram";
|
||||
$data = $request->data;
|
||||
}
|
||||
|
||||
return $this->render("find-phone", [
|
||||
"id" => $id,
|
||||
"request" => $request,
|
||||
"dataType" => $dataType,
|
||||
"data" => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionQiwiCheck()
|
||||
{
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
$value = \Yii::$app->getRequest()->get('value');
|
||||
|
||||
$payment = Payment::find()
|
||||
->where(['type_id' => [Payment::TYPE_QIWI, Payment::TYPE_QIWI_TERMINAL]])
|
||||
->andWhere(['or', ['operation_id' => $value], ['operation_label' => $value]])
|
||||
->one();
|
||||
|
||||
if (!$payment) return ['code' => 0];
|
||||
if ($payment->user_id === null) return ['response' => 3];
|
||||
if ($payment->user_id != \Yii::$app->getUser()->getId()) return ['code' => 2];
|
||||
return ['code' => 1];
|
||||
}
|
||||
|
||||
public function actionMethods() {
|
||||
if(\Yii::$app->getUser()->isGuest) return $this->goHome();
|
||||
|
||||
return $this->render("methods");
|
||||
}
|
||||
|
||||
public function actionMethods2() {
|
||||
if(\Yii::$app->getUser()->isGuest) return $this->goHome();
|
||||
|
||||
return $this->render("methods2");
|
||||
}
|
||||
}
|
||||
?>
|
68
controllers/ReferralsController.php
Normal file
68
controllers/ReferralsController.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\Checkout;
|
||||
use app\models\User;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Controller;
|
||||
use yii\web\ForbiddenHttpException;
|
||||
|
||||
class ReferralsController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
if(\Yii::$app->getUser()->isGuest) return $this->goHome();
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => User::find()->where(["ref_id" => \Yii::$app->getUser()->getId()])
|
||||
]);
|
||||
|
||||
$todayUsers = User::find()->where(["ref_id" => \Yii::$app->getUser()->id])->andWhere([">=", "tm_create", date("Y-m-d 00:00:00")])->count(1);
|
||||
$totalUsers = User::find()->where(["ref_id" => \Yii::$app->getUser()->id])->count(1);
|
||||
|
||||
$users = User::find()->where(["ref_id" => \Yii::$app->getUser()->id])->with(["payments"])->all();
|
||||
$payments = ArrayHelper::getColumn($users, "payments.sum");
|
||||
$sum = array_sum($payments);
|
||||
|
||||
return $this->render("index", [
|
||||
"dataProvider" => $dataProvider,
|
||||
"todayUsers" => $todayUsers,
|
||||
"totalUsers" => $totalUsers,
|
||||
"sum" => $sum * 0.3
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionCheckout() {
|
||||
if(\Yii::$app->getUser()->isGuest) {
|
||||
return $this->goHome();
|
||||
}
|
||||
$wallet = \Yii::$app->request->get("wallet");
|
||||
|
||||
/* @var $user \app\models\User */
|
||||
$user = \Yii::$app->getUser()->getIdentity();
|
||||
if($user->ref_balance < 5000) {
|
||||
return $this->redirect(["referrals/index"]);
|
||||
}
|
||||
|
||||
$checkout = new Checkout();
|
||||
$checkout->user_id = $user->id;
|
||||
$checkout->wallet = $wallet;
|
||||
$checkout->sum = $user->ref_balance;
|
||||
$checkout->tm_create = new Expression('NOW()');
|
||||
if($checkout->save()) {
|
||||
$user->ref_balance = 0;
|
||||
$user->save();
|
||||
}
|
||||
return $this->redirect(["referrals/index"]);
|
||||
}
|
||||
|
||||
public function actionNew($id) {
|
||||
\Yii::$app->session->set("ref_id", join("~", [$id, time()]));
|
||||
if(!\Yii::$app->getUser()->isGuest) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
return $this->redirect(["/", '#' => 'signup']);
|
||||
}
|
||||
}
|
65
controllers/RegController.php
Normal file
65
controllers/RegController.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\User;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Response;
|
||||
|
||||
class RegController extends \yii\web\Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
return $this->render("index");
|
||||
}
|
||||
|
||||
public function actionSms() {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
$phone = \Yii::$app->request->get("phone");
|
||||
|
||||
$phone = preg_replace("/[^\d]/", "", $phone);
|
||||
$code = \Yii::$app->getSecurity()->generateRandomString(6);
|
||||
|
||||
$user = User::find()->where(["phone" => $phone])->one();
|
||||
if(is_null($user)) {
|
||||
$user = new User();
|
||||
$user->phone = $phone;
|
||||
$user->tm_create = new Expression("NOW()");
|
||||
} else {
|
||||
$user->tm_update = new Expression("NOW()");
|
||||
}
|
||||
|
||||
$user->auth_key = \Yii::$app->getSecurity()->generateRandomString();
|
||||
$user->code = $code;
|
||||
if($user->save()) {
|
||||
$url = Url::to(["https://smsc.ru/sys/send.php",
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => 'Ваш код: '.$code,
|
||||
'charset' => 'utf-8',
|
||||
'sender' => \Yii::$app->name
|
||||
], "https");
|
||||
|
||||
file_get_contents($url);
|
||||
} else {
|
||||
return ["error" => 1];
|
||||
}
|
||||
|
||||
return ["error" => 0];
|
||||
}
|
||||
|
||||
public function actionCheck() {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
$code = \Yii::$app->request->get("code");
|
||||
|
||||
$user = User::findByCode($code);
|
||||
if(!is_null($user)) {
|
||||
$user->tm_last_auth = new Expression("NOW()");
|
||||
$user->save();
|
||||
\Yii::$app->user->login($user, 3600 * 24 * 30);
|
||||
return ["error" => 0];
|
||||
}
|
||||
|
||||
return ["error" => 1];
|
||||
}
|
||||
}
|
440
controllers/ResultController.php
Normal file
440
controllers/ResultController.php
Normal file
|
@ -0,0 +1,440 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use app\components\SearchHelper;
|
||||
use app\models\RequestResult;
|
||||
use app\models\Settings;
|
||||
use app\models\Site;
|
||||
use app\models\User;
|
||||
use app\models\UserContact;
|
||||
use Yii;
|
||||
use app\models\BlockPhone;
|
||||
use app\models\ResultCache;
|
||||
use app\models\SearchRequest;
|
||||
use app\models\UrlFilter;
|
||||
use yii\base\Exception;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Controller;
|
||||
use yii\web\ForbiddenHttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class ResultController extends Controller {
|
||||
|
||||
private function guest($phone, $source) {
|
||||
|
||||
|
||||
$searchRequest = new SearchRequest();
|
||||
$searchRequest->ip = \Yii::$app->request->userIP;
|
||||
$searchRequest->ua = \Yii::$app->request->userAgent;
|
||||
$searchRequest->phone = $phone;
|
||||
$searchRequest->tm = new Expression("NOW()");
|
||||
$searchRequest->user_id = null;
|
||||
$searchRequest->refresh = false;
|
||||
$searchRequest->source_id = $source;
|
||||
$searchRequest->site_id = $this->siteId;
|
||||
if(ArrayHelper::getValue($this->site, "type_id") == 2) {
|
||||
$q = SearchRequest::find()->where(["ip" => \Yii::$app->request->userIP])->andWhere([">=", "tm", date("Y-m-d H:i:s", strtotime("-1 day"))])->count();
|
||||
if(!$q) {
|
||||
$searchRequest->is_payed = -1;
|
||||
}
|
||||
}
|
||||
$searchRequest->save();
|
||||
|
||||
$result = SearchHelper::Operator($phone);
|
||||
$requestResult = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_OPERATOR])->one();
|
||||
if (is_null($requestResult)) {
|
||||
$requestResult = new RequestResult();
|
||||
$requestResult->request_id = $searchRequest->id;
|
||||
$requestResult->type_id = ResultCache::TYPE_OPERATOR;
|
||||
$requestResult->data = Json::encode($result);
|
||||
$requestResult->index = $result ? Settings::get("search_index_operator", 5) : 0;
|
||||
|
||||
$requestResult->save();
|
||||
}
|
||||
|
||||
$jobCount = `/home/nomer.io/www/yii queue/info | grep waiting | grep -o '[0-9]*'`;
|
||||
|
||||
return $this->render("free", [
|
||||
'phone' => $phone,
|
||||
'searchRequest' => $searchRequest,
|
||||
'is_cache' => false,
|
||||
'jobCount' => $jobCount
|
||||
]);
|
||||
}
|
||||
|
||||
private $siteId = 0;
|
||||
|
||||
/* @var $site \app\models\Site */
|
||||
private $site;
|
||||
|
||||
public function actionIndex($phone, $token = "") {
|
||||
$phone = preg_replace("/\D/", "", $phone);
|
||||
$phone = preg_replace("/^8/", "7", $phone);
|
||||
if(mb_strlen($phone) != 11 || !preg_match('/79(\d{9})/', $phone)) {
|
||||
\Yii::$app->session->setFlash("error", "Номер $phone указан не корректно! Мы работаем только с мобильными номерами России.");
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
Yii::$app->user->returnUrl = Yii::$app->request->url;
|
||||
|
||||
/*
|
||||
$count = SearchRequest::find()->where(["ip" => \Yii::$app->request->getUserIP()])->count();
|
||||
if($count > 15 && \Yii::$app->getUser()->isGuest) {
|
||||
return $this->render('please');
|
||||
}
|
||||
*/
|
||||
|
||||
if($token != "" && \Yii::$app->getUser()->isGuest) {
|
||||
$user = User::findIdentityByAccessToken($token);
|
||||
if($user) {
|
||||
\Yii::$app->user->login($user, 3600 * 24 * 30);
|
||||
return $this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
$source = SearchRequest::SOURCE_WEB;
|
||||
if (isset($_SERVER["is_mobile"]) && $_SERVER["is_mobile"] == 1) {
|
||||
$source = SearchRequest::SOURCE_MOBILE;
|
||||
}
|
||||
|
||||
$site = Site::find()->where(["name" => $_SERVER["HTTP_HOST"]])->one();
|
||||
$this->site = $site;
|
||||
$this->siteId = ArrayHelper::getValue($site, "id", 0);
|
||||
if(ArrayHelper::getValue($site, 'is_demo', false)) {
|
||||
$operator = SearchHelper::Operator($phone);
|
||||
return $this->render('demo', [
|
||||
"phone" => $phone,
|
||||
"operator" => $operator
|
||||
]);
|
||||
}
|
||||
|
||||
if(\Yii::$app->getUser()->isGuest) {
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "site_id" => [ArrayHelper::getValue($site, 'id'), 0], "status" => [1, 2]])->one();
|
||||
if(!is_null($block) && $block->status == 1) {
|
||||
return $this->render("block", ["phone" => $phone]);
|
||||
} elseif(!is_null($block) && $block->status == 2) {
|
||||
$url = Url::to(['https://smsc.ru/sys/send.php',
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => 'Ваш номер пробивали анонимно с IP: ' .\Yii::$app->request->getUserIP(),
|
||||
'charset' => 'utf-8',
|
||||
'sender' => Yii::$app->name
|
||||
], 'https');
|
||||
@file_get_contents($url);
|
||||
}
|
||||
|
||||
$countSeaches = 0;
|
||||
$freePhones = [];
|
||||
$seaches = SearchRequest::find()->where(["ip" => \Yii::$app->request->getUserIP()])->andWhere(["<>", "ip", "82.204.203.174"])->andWhere(["<>", "ip", "81.88.218.82"])->andWhere([">", "tm", date("Y-m-d H:i:s", strtotime("-7 days"))])->all();
|
||||
foreach ($seaches as $s) {
|
||||
if($s->is_has_name && $s->is_has_photo && !in_array($s->phone, $freePhones)) {
|
||||
$countSeaches++;
|
||||
$freePhones[] = $s->phone;
|
||||
}
|
||||
if($countSeaches == 3) break;
|
||||
}
|
||||
if($countSeaches >= 3) return $this->render("please", ["phone" => $phone]);
|
||||
return $this->guest($phone, $source);
|
||||
}
|
||||
|
||||
$refresh = \Yii::$app->request->get("refresh", false);
|
||||
if($refresh == 1) $refresh = true;
|
||||
|
||||
if(in_array($phone, ["79999999988", "79645552229"])) $refresh = true;
|
||||
|
||||
$result = [];
|
||||
|
||||
$is_cache = false;
|
||||
|
||||
/* @var $user \app\models\User */
|
||||
$user = \Yii::$app->getUser()->getIdentity();
|
||||
|
||||
$searchRequest = null;
|
||||
|
||||
if(!$refresh) {
|
||||
$searchRequest = SearchRequest::find()->where([
|
||||
"user_id" => \Yii::$app->getUser()->getId(),
|
||||
"phone" => $phone,
|
||||
"is_payed" => [1, 2]
|
||||
|
||||
])->orderBy(["id" => SORT_DESC])->one();
|
||||
if($searchRequest) {
|
||||
$is_cache = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(!$user->is_vip && \Yii::$app->params["payModel"]) {
|
||||
if(!$user->checks && $user->balance < \Yii::$app->params["cost"]) {
|
||||
return $this->render("pay");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "site_id" => [ArrayHelper::getValue($site, "id", 0), 0], "status" => [1]])->one();
|
||||
if(!is_null($block) && !$user->is_vip) {
|
||||
return $this->render("block", ["phone" => $phone]);
|
||||
}
|
||||
|
||||
$block = BlockPhone::find()->where(["phone" => $phone, "site_id" => [ArrayHelper::getValue($site, "id", 0), 0], "status" => [2]])->one();
|
||||
if(!is_null($block) && !$user->is_admin) {
|
||||
$url = Url::to(['https://smsc.ru/sys/send.php',
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => 'Ваш номер пробивал '.$user->email.' с IP: ' . \Yii::$app->request->getUserIP(),
|
||||
'charset' => 'utf-8',
|
||||
'sender' => Yii::$app->name
|
||||
], 'https');
|
||||
@file_get_contents($url);
|
||||
}
|
||||
|
||||
if(!$searchRequest) {
|
||||
$searchRequest = new SearchRequest();
|
||||
$searchRequest->ip = \Yii::$app->request->userIP;
|
||||
$searchRequest->ua = \Yii::$app->request->userAgent;
|
||||
$searchRequest->phone = $phone;
|
||||
$searchRequest->tm = new Expression("NOW()");
|
||||
$searchRequest->user_id = $user->id;
|
||||
$searchRequest->refresh = (boolean)$refresh;
|
||||
$searchRequest->source_id = $source;
|
||||
$searchRequest->is_payed = 0;
|
||||
$searchRequest->site_id = $this->siteId;
|
||||
if(ArrayHelper::getValue($this->site, 'type_id', 1) == 2) {
|
||||
$q = SearchRequest::find()->where(["ip" => \Yii::$app->request->userIP])->andWhere([">=", "tm", date("Y-m-d H:i:s", strtotime("-1 day"))])->count();
|
||||
if(!$q) {
|
||||
$searchRequest->is_payed = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(\Yii::$app->params["payModel"]) {
|
||||
if($user->checks > 0) {
|
||||
$user->checks--;
|
||||
$searchRequest->is_payed = 1;
|
||||
} elseif($user->balance >= \Yii::$app->params["cost"]) {
|
||||
$user->balance -= \Yii::$app->params["cost"];
|
||||
$searchRequest->is_payed = 1;
|
||||
}/* elseif($user->is_vip) {
|
||||
$searchRequest->is_payed = 3;
|
||||
}*/
|
||||
$user->save();
|
||||
}
|
||||
|
||||
if(!$searchRequest->is_payed) {
|
||||
/*
|
||||
$countSeaches = 0;
|
||||
$seaches = SearchRequest::find()->where(["and", ["ip" => \Yii::$app->request->getUserIP()], ["<>", "ip", "82.204.203.174"], [">", "tm", date("Y-m-d H:i:s", strtotime("-12 hours"))]])->orWhere(["user_id" => \Yii::$app->getUser()->getId()])->all();
|
||||
foreach ($seaches as $s) {
|
||||
$caches = RequestResult::find()->where(["request_id" => $s->id])->andWhere(["<>", "type_id", ResultCache::TYPE_SPRUT])->all();
|
||||
$names = $photos = [];
|
||||
foreach ($caches as $c) {
|
||||
try {
|
||||
$data = Json::decode($c->data);
|
||||
if($data && is_array($data)) {
|
||||
$names = ArrayHelper::merge($names, ArrayHelper::getColumn($data, "name"));
|
||||
$photos = ArrayHelper::merge($photos, ArrayHelper::getColumn($data, "photo"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$names = array_filter($names);
|
||||
$photos = array_filter($photos);
|
||||
if($names || $photos) {
|
||||
$countSeaches++;
|
||||
}
|
||||
if($countSeaches == 3) break;
|
||||
}
|
||||
if($countSeaches >= 3) return $this->render("please");
|
||||
*/
|
||||
$countSeaches = 0;
|
||||
$freePhones = [];
|
||||
$seaches = SearchRequest::find()->where(["and", ["ip" => \Yii::$app->request->getUserIP()], ["<>", "ip", "82.204.203.174"], [">", "tm", date("Y-m-d H:i:s", strtotime("-7 days"))]])->andWhere(["user_id" => \Yii::$app->getUser()->getId()])->all();
|
||||
foreach ($seaches as $s) {
|
||||
if($s->is_has_name && $s->is_has_photo && !in_array($s->phone, $freePhones)) {
|
||||
$countSeaches++;
|
||||
$freePhones[] = $s->phone;
|
||||
}
|
||||
if($countSeaches == 3) break;
|
||||
}
|
||||
if($countSeaches >= 3) return $this->render("please", ["phone" => $phone]);
|
||||
}
|
||||
|
||||
$searchRequest->save();
|
||||
}
|
||||
|
||||
$checkBanPhone = SearchRequest::find()->where(["requests.phone" => $phone])->joinWith(["user" => function(\yii\db\ActiveQuery $q) {
|
||||
$q->andWhere(["status" => 0]);
|
||||
}])->andWhere(["<>", "user_id", $user->id])->all();
|
||||
|
||||
if(count($checkBanPhone) && $user->is_test) {
|
||||
$user->status = 0;
|
||||
$user->ban = User::BAN_PHONE;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/*
|
||||
if($user->status == 0 && !$user->is_vip) {
|
||||
if($user->phone) {
|
||||
$url = "https://smsc.ru/sys/send.php?login=admeo&psw=admeosmsc&phones=$phone&mes=".urlencode("Ваш номер пытался пробить владелец телефона +".$user->phone." на сайте ".\Yii::$app->name)."&charset=utf-8&sender=".\Yii::$app->name;
|
||||
file_get_contents($url);
|
||||
} else {
|
||||
$url = "https://smsc.ru/sys/send.php?login=admeo&psw=admeosmsc&phones=$phone&mes=".urlencode("Ваш номер пытался пробить владелец e-mail адреса ".$user->email." на сайте ".\Yii::$app->name)."&charset=utf-8&sender=".\Yii::$app->name;
|
||||
file_get_contents($url);
|
||||
}
|
||||
return $this->render("ban", ["phone" => $phone]);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (!Yii::$app->getUser()->isGuest) {
|
||||
UserContact::updateAll(['last_check' => $searchRequest->tm], ['phone' => $searchRequest->phone, 'user_id' => $searchRequest->user_id]);
|
||||
}
|
||||
|
||||
$log = [];
|
||||
if($user->is_admin) {
|
||||
$log = SearchRequest::find()->where(["phone" => $phone])->with("user")->asArray()->orderBy(["id" => SORT_DESC])->all();
|
||||
}
|
||||
|
||||
if($is_cache) {
|
||||
return $this->render("cache", [
|
||||
'searchRequest' => $searchRequest,
|
||||
'log' => $log
|
||||
]);
|
||||
}
|
||||
|
||||
if(!$searchRequest->is_payed) {
|
||||
$result = SearchHelper::Operator($phone);
|
||||
$requestResult = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_OPERATOR])->one();
|
||||
if(is_null($requestResult)) {
|
||||
$requestResult = new RequestResult();
|
||||
$requestResult->request_id = $searchRequest->id;
|
||||
$requestResult->type_id = ResultCache::TYPE_OPERATOR;
|
||||
$requestResult->data = Json::encode($result);
|
||||
$requestResult->index = $result?Settings::get("search_index_operator", 5):0;
|
||||
|
||||
$requestResult->save();
|
||||
}
|
||||
|
||||
return $this->render("free", [
|
||||
'searchRequest' => $searchRequest
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $this->render("index", [
|
||||
'searchRequest' => $searchRequest,
|
||||
'log' => $log
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionVk($phone) {
|
||||
$vkCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_VK])->one();
|
||||
if(is_null($vkCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
$vkCacheData = Json::decode($vkCache->data);
|
||||
|
||||
return $this->render("vk", [
|
||||
"phone" => $phone,
|
||||
"result" => $vkCacheData["result2012"]
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionGoogle($phone) {
|
||||
if(\Yii::$app->getUser()->isGuest) {
|
||||
throw new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
$googleCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_GOOGLE_PHONE])->orderBy(["id" => SORT_DESC])->one();
|
||||
if(is_null($googleCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
$urls = ArrayHelper::map(UrlFilter::find()->all(), "url", "type");
|
||||
|
||||
return $this->render("google", [
|
||||
"phone" => $phone,
|
||||
"result" => Json::decode($googleCache->data),
|
||||
"urls" => $urls
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionAvinfo($phone) {
|
||||
if(\Yii::$app->getUser()->isGuest) {
|
||||
throw new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
$avinfoCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_AVINFO])->one();
|
||||
$antiparkonCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_ANTIPARKON])->one();
|
||||
|
||||
if(is_null($avinfoCache) && is_null($antiparkonCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
return $this->render("avinfo", [
|
||||
"phone" => $phone,
|
||||
"result" => $avinfoCache?Json::decode($avinfoCache->data):[],
|
||||
'resultAntiparkon' => $antiparkonCache?Json::decode($antiparkonCache->data):[],
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionLog($phone) {
|
||||
if(\Yii::$app->getUser()->isGuest || !\Yii::$app->getUser()->getIdentity()->is_admin) {
|
||||
throw new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
|
||||
$log = SearchRequest::find()->where(["phone" => $phone])->with("user")->asArray()->orderBy(["id" => SORT_DESC])->all();
|
||||
|
||||
return $this->render('log', [
|
||||
'log' => $log,
|
||||
'phone' => $phone
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function actionAvito($phone, $id = null) {
|
||||
if(\Yii::$app->getUser()->isGuest) {
|
||||
throw new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
|
||||
$avitoCache = ResultCache::find()->where(['phone' => preg_replace('/^8/', '7', $phone), 'type_id' => ResultCache::TYPE_AVITO])->orderBy(["id" => SORT_DESC])->one();
|
||||
if(is_null($avitoCache)) {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
if($id) {
|
||||
return $this->render("avito_item", [
|
||||
"id" => $id,
|
||||
"phone" => $phone,
|
||||
"result" => Json::decode($avitoCache->data)
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render("avito", [
|
||||
"phone" => $phone,
|
||||
"result" => Json::decode($avitoCache->data)
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionScorista($phone)
|
||||
{
|
||||
if(\Yii::$app->getUser()->isGuest) {
|
||||
throw new ForbiddenHttpException("Нет доступа");
|
||||
}
|
||||
if (!ArrayHelper::getValue(Yii::$app->getUser()->getIdentity(), 'is_vip', false)) throw new ForbiddenHttpException('Нет доступа');
|
||||
/* @var $sprutCache ResultCache */
|
||||
|
||||
$searchRequest = SearchRequest::find()->where(["phone" => preg_replace('/^8/', '7', $phone)])->orderBy(["id" => SORT_DESC])->limit(1)->one();
|
||||
$result = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_SCORISTA])->one();
|
||||
|
||||
if (!$result) throw new NotFoundHttpException('Страница не найдена');
|
||||
return $this->render('sprut', ['result' => $result->data, 'phone' => $phone]);
|
||||
}
|
||||
}
|
79
controllers/RetargetingController.php
Normal file
79
controllers/RetargetingController.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\Retargeting;
|
||||
use app\models\User;
|
||||
use Yii;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use yii\web\Response;
|
||||
use yii\db\Expression;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\web\ForbiddenHttpException;
|
||||
|
||||
class RetargetingController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $uuid
|
||||
* @param $user_id
|
||||
* подсчитываем сколько пользователей открыло письмо
|
||||
*/
|
||||
public function actionPic($uuid)
|
||||
{
|
||||
//отмечаем письмо как прочитано
|
||||
if ($uuid) {
|
||||
$retargeting = Retargeting::find()->where(["uuid" => $uuid, "status" => 1])->one();
|
||||
|
||||
if (!is_null($retargeting)) {
|
||||
$retargeting->status = 2;
|
||||
$retargeting->tm_read = new Expression('NOW()');
|
||||
$retargeting->save();
|
||||
}
|
||||
}
|
||||
|
||||
//формируем прозрачную картинку gif размером 1 x 1 pix и выводи в браузер
|
||||
$img = ImageCreateTrueColor(1,1);
|
||||
|
||||
\Yii::$app->response->format = Response::FORMAT_RAW;
|
||||
\Yii::$app->response->headers->set('Content-Type', 'image/gif');
|
||||
|
||||
return imagegif($img);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
* @throws NotFoundHttpException
|
||||
* подсчитываем количество кликов по ссылке
|
||||
*/
|
||||
public function actionRedirect($uuid)
|
||||
{
|
||||
|
||||
if ($uuid) {
|
||||
$retargeting = Retargeting::find()->where(["uuid" => $uuid])->one();
|
||||
|
||||
if (!is_null($retargeting)) {
|
||||
|
||||
if ($retargeting->status != 2) throw new ForbiddenHttpException("Нет доступа");
|
||||
|
||||
$retargeting->status = 3;
|
||||
$retargeting->tm_click = new Expression('NOW()');
|
||||
$retargeting->save();
|
||||
|
||||
$user = User::find()->where(['id' => $retargeting->user_id])->one();
|
||||
$user->checks = $user->checks + 1;
|
||||
$user->save();
|
||||
|
||||
return $this->redirect('http://kto.lol/get/' . $uuid);
|
||||
|
||||
} else {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
} else {
|
||||
throw new NotFoundHttpException("Страница не найдена");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
controllers/ReviewController.php
Normal file
11
controllers/ReviewController.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use yii\web\Controller;
|
||||
|
||||
class ReviewController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
//return $this->render("index");
|
||||
}
|
||||
}
|
3364
controllers/SearchController.php
Normal file
3364
controllers/SearchController.php
Normal file
File diff suppressed because it is too large
Load diff
25
controllers/SettingsController.php
Normal file
25
controllers/SettingsController.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\SetPasswordForm;
|
||||
use yii\web\Controller;
|
||||
|
||||
class SettingsController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
/* @var $user \app\models\User */
|
||||
$user = \Yii::$app->getUser()->getIdentity();
|
||||
$model = new SetPasswordForm();
|
||||
if($model->load(\Yii::$app->request->post()) && $user->validatePassword($model->oldpassword) && $model->validate()) {
|
||||
$user->password = $model->password;
|
||||
if($user->save()) {
|
||||
\Yii::$app->session->setFlash("success", "Пароль успешно изменен!");
|
||||
return $this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('index', [
|
||||
"model" => $model
|
||||
]);
|
||||
}
|
||||
}
|
442
controllers/SiteController.php
Normal file
442
controllers/SiteController.php
Normal file
|
@ -0,0 +1,442 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\ContactForm;
|
||||
use app\models\Link;
|
||||
use app\models\NewPasswordForm;
|
||||
use app\models\PhoneRequest;
|
||||
use app\models\RemindForm;
|
||||
use app\models\SigninForm;
|
||||
use app\models\SignupForm;
|
||||
use app\models\Ticket;
|
||||
use app\models\User;
|
||||
use app\models\UserEvercookie;
|
||||
use app\models\UserFingerprint;
|
||||
use app\models\UserSetting;
|
||||
use app\models\UserTest;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\db\Expression;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Controller;
|
||||
use app\components\AuthHandler;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\web\Response;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'only' => ['signin', 'signup', 'logout'],
|
||||
'rules' => [
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['signin', 'signup'],
|
||||
'roles' => ['?'],
|
||||
],
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['logout'],
|
||||
'roles' => ['@'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionApi()
|
||||
{
|
||||
echo "Превед медвед! ;)";
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
'error' => [
|
||||
'class' => 'yii\web\ErrorAction',
|
||||
],
|
||||
'captcha' => [
|
||||
'class' => 'yii\captcha\CaptchaAction',
|
||||
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
|
||||
],
|
||||
'auth' => [
|
||||
'class' => 'yii\authclient\AuthAction',
|
||||
'successCallback' => [$this, 'onAuthSuccess'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays homepage.
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$model = new PhoneRequest();
|
||||
if(\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
return ActiveForm::validate($model);
|
||||
}
|
||||
if($model->load(\Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(["pay/find-phone", "id" => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('index', [
|
||||
"model" => $model
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionFindPhone()
|
||||
{
|
||||
$model = new PhoneRequest();
|
||||
if($model->load(\Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(["pay/find-phone", "id" => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('find-phone', [
|
||||
"model" => $model
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionIos()
|
||||
{
|
||||
return $this->render('ios');
|
||||
}
|
||||
|
||||
public function actionSignin()
|
||||
{
|
||||
$signinForm = new SigninForm();
|
||||
if(\Yii::$app->request->isAjax && $signinForm->load(\Yii::$app->request->post())) {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
return ActiveForm::validate($signinForm);
|
||||
}
|
||||
|
||||
if(\Yii::$app->request->isPost && $signinForm->load(\Yii::$app->request->post())) {
|
||||
if($signinForm->validate() && $signinForm->login()) {
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('signin', [
|
||||
"signinForm" => $signinForm
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSignup()
|
||||
{
|
||||
$signupForm = new SignupForm();
|
||||
if(\Yii::$app->request->isAjax && $signupForm->load(\Yii::$app->request->post())) {
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
return ActiveForm::validate($signupForm);
|
||||
}
|
||||
|
||||
if(\Yii::$app->request->isPost && $signupForm->load(\Yii::$app->request->post())) {
|
||||
if($signupForm->validate()) {
|
||||
$user = $signupForm->createUser();
|
||||
if(\Yii::$app->getUser()->login($user, 3600 * 24 * 30)) {
|
||||
$site = \app\models\Site::find()->where(["name" => $_SERVER["HTTP_HOST"]])->one();
|
||||
$log = new \app\models\UserAuthLog();
|
||||
$log->user_id = $user->id;
|
||||
$log->site_id = \yii\helpers\ArrayHelper::getValue($site, "id", 0);
|
||||
$log->ip = \Yii::$app->request->getUserIP();
|
||||
$log->tm = new \yii\db\Expression('NOW()');
|
||||
$log->save();
|
||||
}
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('signup', [
|
||||
"signupForm" => $signupForm,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSetPassword($token = "")
|
||||
{
|
||||
/*
|
||||
$password = \Yii::$app->request->post('password');
|
||||
$re_password = \Yii::$app->request->post('re-password');
|
||||
*/
|
||||
|
||||
if (empty($token)) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = User::findOne(['password_reset_token' => $token]);
|
||||
|
||||
if (empty($user)) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
/*
|
||||
if (!empty($password) && !empty($re_password)) {
|
||||
if ($password === $re_password) {
|
||||
$user->removePasswordResetToken();
|
||||
$user->setPassword($password);
|
||||
|
||||
$user->save();
|
||||
|
||||
\Yii::$app->user->login($user, 3600 * 24 * 30);
|
||||
|
||||
return $this->redirect(['/cabinet/stats/index']);
|
||||
}
|
||||
|
||||
return $this->render('new_password', ['error' => 'Пароли не совпадают']);
|
||||
}
|
||||
*/
|
||||
|
||||
$model = new NewPasswordForm();
|
||||
if($model->load(\Yii::$app->request->post()) && $model->validate()) {
|
||||
$user->password = $model->password;
|
||||
$user->password_reset_token = '';
|
||||
if($user->save()) {
|
||||
\Yii::$app->user->login($user, 3600 * 24 * 30);
|
||||
|
||||
return $this->goHome();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('new_password', [
|
||||
"model" => $model
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionRemind()
|
||||
{
|
||||
$remindForm = new RemindForm();
|
||||
if(\Yii::$app->request->isPost && $remindForm->load(\Yii::$app->request->post())) {
|
||||
if($remindForm->validate()) {
|
||||
$remindForm->remind();
|
||||
\Yii::$app->session->setFlash("remindMessage", "Ссылка для восстановления пароля отправлена на указанный E-mail");
|
||||
return $this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('remind', [
|
||||
"remindForm" => $remindForm,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionConfirm()
|
||||
{
|
||||
$user = false;
|
||||
$token = \Yii::$app->request->get("token", null);
|
||||
if($token) {
|
||||
$user = User::find()->where(new Expression("MD5('cc-' || id) = '".$token."'"))->one();
|
||||
if($user) {
|
||||
$user->is_confirm = true;
|
||||
$user->tm_confirm = new Expression("NOW()");
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
if(!$user) return "";
|
||||
|
||||
return $this->render("confirm", [
|
||||
"user" => $user
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionFree()
|
||||
{
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
/* @var $user \app\models\User */
|
||||
$user = \Yii::$app->getUser()->getIdentity();
|
||||
if($user->is_confirm && !$user->is_test) {
|
||||
$user->checks += 5;
|
||||
$user->is_test = true;
|
||||
if($user->save()) {
|
||||
$test = new UserTest();
|
||||
$test->user_id = $user->id;
|
||||
$test->tm = new Expression('NOW()');
|
||||
$test->ip = \Yii::$app->request->getUserIP();
|
||||
return ["success" => 1, "checks" => $user->checks];
|
||||
}
|
||||
}
|
||||
return ["success" => 0];
|
||||
}
|
||||
|
||||
public function actionSendConfirm()
|
||||
{
|
||||
\Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
/* @var $user \yii\web\View */
|
||||
$user = \Yii::$app->getUser()->getIdentity();
|
||||
|
||||
return \Yii::$app->mailer->compose()
|
||||
->setTextBody("Для подтверждения e-mail адреса перейдите по ссылке: ".Url::toRoute(['site/confirm', 'token' => md5("cc-".$user->id)], true))
|
||||
->setFrom('noreply@'.\Yii::$app->name)
|
||||
->setTo($user->email)
|
||||
->setSubject(\Yii::$app->name." - подтверждение e-mail адреса")
|
||||
->send();
|
||||
}
|
||||
|
||||
public function onAuthSuccess($client)
|
||||
{
|
||||
(new AuthHandler($client))->handle();
|
||||
}
|
||||
|
||||
public function actionLogout()
|
||||
{
|
||||
\Yii::$app->getUser()->logout();
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
public function actionRedirect($phone) {
|
||||
$phone = preg_replace('/\D/', '', $phone);
|
||||
if(mb_strlen($phone) == 10) {
|
||||
$phone = "8".$phone;
|
||||
} elseif(mb_strlen($phone) == 11 && $phone{0} == 7) {
|
||||
$phone = preg_replace('/^7/', '8', $phone);
|
||||
}
|
||||
if(preg_match('/^8(\d{10})$/', $phone)) {
|
||||
return $this->redirect(["result/index", "phone" => $phone]);
|
||||
} else {
|
||||
\Yii::$app->session->setFlash("error", "Номер $phone указан не корректно!");
|
||||
return $this->goHome();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionImage($uuid) {
|
||||
$response = \Yii::$app->getResponse();
|
||||
$response->headers->set('Content-Type', 'image/jpeg');
|
||||
$response->format = Response::FORMAT_RAW;
|
||||
|
||||
if ( !is_resource($response->stream = @fopen("http://storage.aprokat.com/nomerio/".$uuid, "r")) ) {
|
||||
//throw new \yii\web\ServerErrorHttpException('file access failed: permission deny');
|
||||
$response->stream = @fopen(\Yii::getAlias('@webroot').'/img/nophoto.png', "r");
|
||||
}
|
||||
$response->send();
|
||||
}
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
return $this->render("test");
|
||||
}
|
||||
|
||||
public function actionFingerprint($hash) {
|
||||
\Yii::$app->response->format = Response::FORMAT_RAW;
|
||||
if(!\Yii::$app->getUser()->isGuest) {
|
||||
$fp = UserFingerprint::find()->where(["user_id" => \Yii::$app->getUser()->getId(), "hash" => $hash, "ip" => \Yii::$app->request->getUserIP()])->one();
|
||||
if(is_null($fp)) {
|
||||
$fp = new UserFingerprint();
|
||||
$fp->user_id = \Yii::$app->getUser()->getId();
|
||||
$fp->hash = $hash;
|
||||
$fp->ip = \Yii::$app->request->getUserIP();
|
||||
$fp->tm = new Expression('NOW()');
|
||||
$fp->save();
|
||||
}
|
||||
|
||||
$user = \Yii::$app->getUser()->getIdentity();
|
||||
|
||||
$hashes = ArrayHelper::getColumn(UserFingerprint::find()->where(["user_id" => \Yii::$app->getUser()->getId()])->all(), "hash");
|
||||
$checks = UserFingerprint::find()->where(["<>", "user_id", \Yii::$app->getUser()->getId()])->andWhere(["hash" => $hashes])->all();
|
||||
/*
|
||||
if(count($checks)) {
|
||||
$user->status = 0;
|
||||
$user->ban = User::BAN_FINGERPRINT;
|
||||
$user->save();
|
||||
}
|
||||
*/
|
||||
}
|
||||
\Yii::$app->response->headers->add('Content-Type', 'image/gif');
|
||||
return "\x47\x49\x46\x38\x39\x61\x1\x0\x1\x0\x80\x0\x0\xff\xff\xff\xff\xff\xff\x21\xf9\x04\x1\x0a\x0\x1\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x4c\x1\x0\x3b";
|
||||
}
|
||||
|
||||
public function actionEvercookie($hash) {
|
||||
\Yii::$app->response->format = Response::FORMAT_RAW;
|
||||
if(!\Yii::$app->getUser()->isGuest) {
|
||||
$ec = UserEvercookie::find()->where(["user_id" => \Yii::$app->getUser()->getId(), "data" => $hash, "ip" => \Yii::$app->request->getUserIP()])->one();
|
||||
if(is_null($ec)) {
|
||||
$ec = new UserEvercookie();
|
||||
$ec->user_id = \Yii::$app->getUser()->getId();
|
||||
$ec->data = $hash;
|
||||
$ec->ip = \Yii::$app->request->getUserIP();
|
||||
$ec->tm = new Expression('NOW()');
|
||||
$ec->save();
|
||||
}
|
||||
$originalUser = User::find()->where(new Expression("MD5(CONCAT_WS('-', 'nomerio', id)) = '".$hash."'"))->one();
|
||||
if($originalUser && ($originalUser->id != \Yii::$app->getUser()->getId() && $originalUser->is_test)) {
|
||||
$user = User::find()->where(["id" => \Yii::$app->getUser()->getId()])->one();
|
||||
if($user->status == 1 && $user->is_test){
|
||||
$user->status = 0;
|
||||
$user->ban = User::BAN_EVERCOOKIE;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
\Yii::$app->response->headers->add('Content-Type', 'image/gif');
|
||||
return "\x47\x49\x46\x38\x39\x61\x1\x0\x1\x0\x80\x0\x0\xff\xff\xff\xff\xff\xff\x21\xf9\x04\x1\x0a\x0\x1\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x4c\x1\x0\x3b";
|
||||
}
|
||||
|
||||
public function actionSetSetting() {
|
||||
$param = \Yii::$app->request->get("param");
|
||||
$value = \Yii::$app->request->get("value");
|
||||
if(\Yii::$app->request->isAjax && !\Yii::$app->getUser()->isGuest) {
|
||||
$s = UserSetting::find()->where(["user_id" => \Yii::$app->getUser()->getId(), "param" => $param])->one();
|
||||
if(is_null($s)) {
|
||||
$s = new UserSetting();
|
||||
$s->user_id = \Yii::$app->getUser()->getId();
|
||||
$s->param = $param;
|
||||
}
|
||||
$s->value = $value;
|
||||
return $s->save();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function actionContacts() {
|
||||
/*
|
||||
$model = new Ticket();
|
||||
|
||||
if ($model->load(\Yii::$app->getRequest()->post()) && $model->save()) {
|
||||
//return $this->redirect(['site/contacts']);
|
||||
}
|
||||
|
||||
/*
|
||||
if((\Yii::$app->request->isAjax == false) && \Yii::$app->request->isPost && $model->load(\Yii::$app->request->post()) && $model->save()) {
|
||||
\Yii::$app->session->setFlash("success", "Запрос успешно создан!");
|
||||
return $this->redirect(['site/contacts']);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
$ticketsDataProvider = new ActiveDataProvider([
|
||||
'query' => Ticket::find()->where(["user_id" => \Yii::$app->getUser()->getId()])
|
||||
]);
|
||||
|
||||
return $this->render("contacts", [
|
||||
"model" => $model,
|
||||
"ticketsDataProvider" => $ticketsDataProvider
|
||||
]);
|
||||
*/
|
||||
}
|
||||
|
||||
public function actionCode($code)
|
||||
{
|
||||
$link = Link::find()->where(compact('code'))->one();
|
||||
|
||||
if (!$link || !$link->user || !$link->user->repost) throw new NotFoundHttpException();
|
||||
|
||||
if (strtotime($link->tm) < strtotime('-7 day')) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$response = file_get_contents('https://api.vk.com/method/users.get?user_id=' . $link->user->repost->vk_id . '&v=5.65&lang=ru&fields=photo_max_orig&access_token=8f95fab19fb8d3d41bdeeb28f0112cb2cd3c86a93fc66acbd29f327d1aa3f196540bfe10dcd4ca97baf37');
|
||||
$response = Json::decode($response);
|
||||
$user = ArrayHelper::getValue($response, ['response', 0]);
|
||||
|
||||
if (!$user) throw new NotFoundHttpException();
|
||||
|
||||
return $this->render('user', compact('user'));
|
||||
}
|
||||
}
|
94
controllers/TryController.php
Normal file
94
controllers/TryController.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\User;
|
||||
use app\models\UserFingerprint;
|
||||
use app\models\UserTest;
|
||||
use Yii;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Controller;
|
||||
|
||||
class TryController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
/*
|
||||
if(\Yii::$app->request->isPost) {
|
||||
$phone = \Yii::$app->request->post("phone");
|
||||
$phone = preg_replace('/[\D]/', '', $phone);
|
||||
|
||||
$code = rand(0, 9999);
|
||||
$code = sprintf("%'.04d", $code);
|
||||
|
||||
$user = User::find()->where(["id" => \Yii::$app->getUser()->getId()])->one();
|
||||
$user->phone = $phone;
|
||||
$user->code = $code;
|
||||
if($user->save()) {
|
||||
$url = "https://smsc.ru/sys/send.php?login=admeo&psw=admeosmsc&phones=$phone&mes=".urlencode("Ваш код: $code")."&charset=utf-8&sender=nomer.io";
|
||||
/*
|
||||
Url::to(["@smsc",
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => 'Ваш код: '.$code,
|
||||
'charset' => 'utf-8',
|
||||
'sender' => 'nomer.io'
|
||||
]);
|
||||
*
|
||||
|
||||
file_get_contents($url);
|
||||
}
|
||||
|
||||
|
||||
return $this->redirect(["try/check"]);
|
||||
}
|
||||
|
||||
if(\Yii::$app->getUser()->getIdentity()->is_test) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
return $this->render("index");
|
||||
*/
|
||||
}
|
||||
|
||||
public function actionCheck() {
|
||||
/*
|
||||
if(\Yii::$app->request->isPost) {
|
||||
$code = \Yii::$app->request->post("code");
|
||||
$code = preg_replace('/\D/', '', $code);
|
||||
$user = User::find()->where(["id" => \Yii::$app->getUser()->getId()])->one();
|
||||
|
||||
if($user->code == $code) {
|
||||
$test = UserTest::find()->where(["ip" => \Yii::$app->request->getUserIP()])->one();
|
||||
|
||||
if(!$user->is_test) {
|
||||
$user->is_test = true;
|
||||
$user->checks += 5;
|
||||
if($test) {
|
||||
$user->status = 0;
|
||||
$user->ban = User::BAN_IP;
|
||||
} else {
|
||||
$hashes = ArrayHelper::getColumn(UserFingerprint::find()->where(["user_id" => \Yii::$app->getUser()->getId()])->all(), "hash");
|
||||
$checks = UserFingerprint::find()->where(["<>", "user_id", \Yii::$app->getUser()->getId()])->andWhere(["hash" => $hashes])->all();
|
||||
if(count($checks)) {
|
||||
$user->status = 0;
|
||||
$user->ban = User::BAN_FINGERPRINT;
|
||||
}
|
||||
}
|
||||
if($user->save()) {
|
||||
$test = new UserTest();
|
||||
$test->user_id = $user->id;
|
||||
$test->tm = new Expression('NOW()');
|
||||
$test->ip = \Yii::$app->request->getUserIP();
|
||||
$test->save();
|
||||
}
|
||||
}
|
||||
return $this->goHome();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render("check");
|
||||
*/
|
||||
}
|
||||
}
|
26
controllers/UrlController.php
Normal file
26
controllers/UrlController.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\UrlFilter;
|
||||
use yii\web\Controller;
|
||||
|
||||
class UrlController extends Controller {
|
||||
|
||||
public $enableCsrfValidation = false;
|
||||
|
||||
public function actionIndex() {
|
||||
$url = \Yii::$app->request->post("url");
|
||||
$type = \Yii::$app->request->post("type");
|
||||
|
||||
$u = UrlFilter::find()->where(["url" => $url])->one();
|
||||
if(is_null($u)) {
|
||||
$u = new UrlFilter();
|
||||
$u->url = $url;
|
||||
}
|
||||
$u->type = $type;
|
||||
$u->save();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
12
controllers/WcallerController.php
Normal file
12
controllers/WcallerController.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
use yii\web\Controller;
|
||||
|
||||
class WcallerController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
return $this->render("index");
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue