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
56
modules/api/controllers/CallController.php
Normal file
56
modules/api/controllers/CallController.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
namespace app\modules\api\controllers;
|
||||
|
||||
use app\models\Call;
|
||||
use app\models\User;
|
||||
use Yii;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
use yii\helpers\Url;
|
||||
use yii\rest\Controller;
|
||||
|
||||
class CallController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
$body = \Yii::$app->request->getRawBody();
|
||||
$body = Json::decode($body);
|
||||
|
||||
$call = new Call();
|
||||
$call->cuid = ArrayHelper::getValue($body, 'cuid');
|
||||
$call->status = ArrayHelper::getValue($body, 'status');
|
||||
$call->duration = ArrayHelper::getValue($body, 'duration');
|
||||
$call->phone = ArrayHelper::getValue($body, 'number');
|
||||
$call->tm = new Expression('NOW()');
|
||||
$call->save();
|
||||
|
||||
if($call->status == "dtmf-1") {
|
||||
$user = User::find()->where(["email" => $call->phone])->one();
|
||||
if(!$user) {
|
||||
$code = sprintf("%'.04d", rand(0, 9999));
|
||||
|
||||
$user = new User();
|
||||
$user->email = $call->phone;
|
||||
$user->password = $code;
|
||||
$user->auth_key = \Yii::$app->getSecurity()->generateRandomString();
|
||||
$user->checks = 3;
|
||||
|
||||
if($user->save()) {
|
||||
$user->checks = 3;
|
||||
$user->save();
|
||||
$url = Url::to(['https://smsc.ru/sys/send.php',
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $call->phone,
|
||||
'mes' => "Probiv nomera telefona(3 besplatnye proverki):\nhttps://num.gg\nlogin:".$user->email."\npass:".$user->password,
|
||||
'charset' => 'utf-8',
|
||||
'sender' => 'num.gg'
|
||||
], 'https');
|
||||
file_get_contents($url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue