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
35
commands/AppleController.php
Normal file
35
commands/AppleController.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\ApplePayment;
|
||||
use yii\console\Controller;
|
||||
|
||||
class AppleController extends Controller
|
||||
{
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$d = date("Ymd", strtotime("-2 days"));
|
||||
$s = $d."_V1_1";
|
||||
$data = `cd /home/nomer.io/reports && java -jar /home/nomer.io/reports/Reporter.jar p=Reporter.properties m=Robot.XML Sales.getReport 87428184, Subscriber, Detailed, Daily, $d, 1_1`;
|
||||
$result = `zcat /home/nomer.io/reports/Subscriber_87428184_$s.txt.gz`;
|
||||
$rows = explode("\n", $result);
|
||||
foreach ($rows as $i => $r) {
|
||||
if ($i == 0) continue;
|
||||
$items = explode("\t", $r);
|
||||
print_r($r);
|
||||
if (count($items) < 10) continue;
|
||||
|
||||
$payment = new ApplePayment();
|
||||
$payment->tm = $items[0];
|
||||
$payment->sum = $items[9];
|
||||
$payment->amount = $items[11];
|
||||
$payment->refund = $items[20] == "Yes" ? 1 : 0;
|
||||
if (!$payment->save()) {
|
||||
print_r($payment->getErrors());
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
40
commands/CallsController.php
Normal file
40
commands/CallsController.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\Call;
|
||||
use yii\console\Controller;
|
||||
|
||||
class CallsController extends Controller {
|
||||
|
||||
public function actionMan() {
|
||||
//select status, count(1) from calls where id < 35191 and id >9810 group by status order by count(1);
|
||||
|
||||
$calls = Call::find()
|
||||
->andWhere([">", "id", 9810])
|
||||
->andWhere(["<", "id", 35191])
|
||||
->andWhere(["status" => ["timeout", "hangup", "no-answer"]])
|
||||
->asArray()->all();
|
||||
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/man.txt', 'a+');
|
||||
foreach ($calls as $call) {
|
||||
fwrite($f, $call["phone"]."\n");
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
public function actionWoman() {
|
||||
//select status, count(1) from calls where id < 35191 and id >9810 group by status order by count(1);
|
||||
|
||||
$calls = Call::find()
|
||||
->andWhere([">", "id", 35191])
|
||||
->andWhere(["status" => ["timeout", "hangup", "no-answer"]])
|
||||
->asArray()->all();
|
||||
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/woman.txt', 'a+');
|
||||
foreach ($calls as $call) {
|
||||
fwrite($f, $call["phone"]."\n");
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
}
|
160
commands/CleanController.php
Normal file
160
commands/CleanController.php
Normal file
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\RequestResult;
|
||||
use app\models\ResultCache;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class CleanController extends Controller {
|
||||
|
||||
public function actionResults() {
|
||||
$pid = "/tmp/last.results.vk.log";
|
||||
$last = `cat $pid`;
|
||||
if(!$last) $last = 0;
|
||||
foreach (RequestResult::find()->where(["type_id" => [ResultCache::TYPE_VK_2012, ResultCache::TYPE_VK, ResultCache::TYPE_VK_OPEN]])->andWhere([">", "id", $last])->limit(1000)->orderBy(["id" => SORT_ASC])->batch(10) as $results) {
|
||||
foreach($results as $result) {
|
||||
/* @var $result \app\models\RequestResult */
|
||||
|
||||
$data = Json::decode($result->data);
|
||||
foreach($data as $vkId => $vkProfile) {
|
||||
if(isset($vkProfile["photo"])) {
|
||||
$tmp = "/tmp/vk-".$vkId.".jpg";
|
||||
$photo = $vkProfile["photo"];
|
||||
$this->base64_to_jpeg($photo, $tmp);
|
||||
|
||||
$file_path_str = '/vk/'.$vkId.'.jpg';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://q.apinomer.com/upload'.$file_path_str);
|
||||
|
||||
curl_setopt($ch, CURLOPT_PUT, 1);
|
||||
|
||||
$fh_res = fopen($tmp, 'r');
|
||||
|
||||
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
|
||||
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($tmp));
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
|
||||
$curl_response_res = curl_exec ($ch);
|
||||
fclose($fh_res);
|
||||
unlink($tmp);
|
||||
unset($data[$vkId]["photo"]);
|
||||
$data[$vkId]["photo"] = "https://q.apinomer.com'.$file_path_str";
|
||||
}
|
||||
if(isset($vkProfile["raw"])) {
|
||||
unset($data[$vkId]["raw"]);
|
||||
}
|
||||
}
|
||||
$result->data = Json::encode($data);
|
||||
$result->save();
|
||||
$last = $result->id;
|
||||
}
|
||||
`echo $last > $pid`;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionIndex() {
|
||||
$last = `cat /tmp/last.cache.log`;
|
||||
if(!$last) $last = 0;
|
||||
foreach (ResultCache::find()->where(["type_id" => ResultCache::TYPE_VK_2012])->andWhere([">", "id", $last])->limit(1000)->orderBy(["id" => SORT_ASC])->batch(10) as $results) {
|
||||
foreach($results as $result) {
|
||||
/* @var $result \app\models\ResultCache */
|
||||
$data = Json::decode($result->data);
|
||||
foreach($data as $vkId => $vkProfile) {
|
||||
if(isset($vkProfile["photo"])) {
|
||||
$tmp = "/tmp/".$vkId.".jpg";
|
||||
$photo = $vkProfile["photo"];
|
||||
$this->base64_to_jpeg($photo, $tmp);
|
||||
|
||||
$file_path_str = '/vk2012/'.$vkId.'.jpg';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://q.apinomer.com/upload'.$file_path_str);
|
||||
|
||||
curl_setopt($ch, CURLOPT_PUT, 1);
|
||||
|
||||
$fh_res = fopen($tmp, 'r');
|
||||
|
||||
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
|
||||
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($tmp));
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
|
||||
$curl_response_res = curl_exec ($ch);
|
||||
echo $curl_response_res;
|
||||
fclose($fh_res);
|
||||
unlink($tmp);
|
||||
unset($data[$vkId]["photo"]);
|
||||
$data[$vkId]["photo"] = "https://q.apinomer.com'.$file_path_str";
|
||||
}
|
||||
if(isset($vkProfile["raw"])) {
|
||||
unset($data[$vkId]["raw"]);
|
||||
}
|
||||
}
|
||||
$result->data = Json::encode($data);
|
||||
$result->save();
|
||||
$last = $result->id;
|
||||
}
|
||||
`echo $last > /tmp/last.cache.log`;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionFacebook() {
|
||||
$last = `cat /tmp/last.fb.cache.log`;
|
||||
if(!$last) $last = 0;
|
||||
foreach (ResultCache::find()->where(["type_id" => ResultCache::TYPE_FACEBOOK])->andWhere([">", "id", $last])->limit(1000)->orderBy(["id" => SORT_ASC])->batch(10) as $results) {
|
||||
foreach($results as $result) {
|
||||
/* @var $result \app\models\ResultCache */
|
||||
$data = Json::decode($result->data);
|
||||
foreach($data as $fbId => $fbProfile) {
|
||||
if(isset($fbProfile["photo"])) {
|
||||
$tmp = "/tmp/".$fbId.".jpg";
|
||||
$photo = $fbProfile["photo"];
|
||||
$this->base64_to_jpeg($photo, $tmp);
|
||||
|
||||
$file_path_str = '/fb/'.$fbId.'.jpg';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://q.apinomer.com/upload'.$file_path_str);
|
||||
|
||||
curl_setopt($ch, CURLOPT_PUT, 1);
|
||||
|
||||
$fh_res = fopen($tmp, 'r');
|
||||
|
||||
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
|
||||
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($tmp));
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
|
||||
$curl_response_res = curl_exec ($ch);
|
||||
echo $curl_response_res;
|
||||
fclose($fh_res);
|
||||
unlink($tmp);
|
||||
unset($data[$fbId]["photo"]);
|
||||
$data[$fbId]["photo"] = "https://q.apinomer.com".$file_path_str;
|
||||
}
|
||||
}
|
||||
|
||||
$result->data = Json::encode($data);
|
||||
$result->save();
|
||||
$last = $result->id;
|
||||
}
|
||||
`echo $last > /tmp/last.fb.cache.log`;
|
||||
}
|
||||
}
|
||||
|
||||
private function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode($base64_string));
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
}
|
86
commands/DaemonController.php
Normal file
86
commands/DaemonController.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace app\commands;
|
||||
|
||||
use yii\console\Controller;
|
||||
use app\models\Payment;
|
||||
use app\models\Retargeting;
|
||||
use app\models\User;
|
||||
use yii\db\Expression;
|
||||
|
||||
class DaemonController extends Controller
|
||||
{
|
||||
/**
|
||||
* создаём очередь на отправку
|
||||
*/
|
||||
public function actionQueueRetargeting()
|
||||
{
|
||||
$max_date = date("Y-m-d 00:00:00", strtotime("-1 day"));
|
||||
|
||||
$users = User::find()
|
||||
->select(['users.*', 'sum(payments.sum)', 'max(email_tokents.tm_create)'])
|
||||
->innerJoin('payments', 'payments.user_id=users.id')
|
||||
->join('LEFT JOIN', 'requests', 'requests.user_id=users.id')
|
||||
->join('LEFT JOIN', 'email_tokents', 'email_tokents.user_id=users.id')
|
||||
->orderBy(['requests.id' => SORT_DESC])
|
||||
->groupBy(['users.id', 'requests.id', 'email_tokents.tm_create'])
|
||||
->having('sum(sum) > 0')
|
||||
->having("max(email_tokents.tm_create) < '" . $max_date . "' OR COUNT(email_tokents.id) = 0")
|
||||
->limit(100)
|
||||
->all();
|
||||
|
||||
//var_dump($users);
|
||||
//exit;
|
||||
|
||||
if (!is_null($users)) {
|
||||
|
||||
foreach ($users as $user) {
|
||||
$date1 = date("Y-m-d") . '09:00';
|
||||
$date2 = date("Y-m-d") . '19:00';
|
||||
|
||||
$retargeting = new Retargeting();
|
||||
$retargeting->uuid = md5($user->id . time());
|
||||
$retargeting->status = 0;
|
||||
$retargeting->tm_create = new Expression('NOW()');
|
||||
$retargeting->tm_send = Retargeting::random_date_in_range($date1, $date2);
|
||||
$retargeting->user_id = $user->id;
|
||||
$retargeting->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* длеаем рассылку
|
||||
*/
|
||||
public function actionSendMsg()
|
||||
{
|
||||
$retargetings = Retargeting::find()->joinWith("user")
|
||||
->joinWith(['user'])
|
||||
->where(["email_tokents.status" => 0])
|
||||
->all();
|
||||
|
||||
if (!is_null($retargetings)) {
|
||||
foreach ($retargetings as $retargeting) {
|
||||
|
||||
$result = \Yii::$app->mailer->compose()
|
||||
->setTextBody(\Yii::t('email','msg'))
|
||||
->setFrom('noreply@' . \Yii::$app->name)
|
||||
->setTo($retargeting->user->email)
|
||||
->setSubject(\Yii::t('email','subject'))
|
||||
->send();
|
||||
|
||||
$retarg = Retargeting::find()->where(["uuid" => $retargeting->uuid, "user_id" => $retargeting->user_id, "status" => 0])->one();
|
||||
|
||||
if (!is_null($retarg)) {
|
||||
$retargeting->status = $result ? 1 : 4;
|
||||
$retargeting->tm_send = new Expression('NOW()');
|
||||
|
||||
if ($result === false) $retarg->descr = 'Ошибка при отправке письма';
|
||||
|
||||
$retarg->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
169
commands/NotifyController.php
Normal file
169
commands/NotifyController.php
Normal file
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\ResultCache;
|
||||
use app\models\Telegram;
|
||||
use yii\console\Controller;
|
||||
use yii\db\Expression;
|
||||
use yii\db\Query;
|
||||
|
||||
class NotifyController extends Controller
|
||||
{
|
||||
protected function notify($peerID, $text)
|
||||
{
|
||||
return `/home/alexander/tg/bin/telegram-cli -k /home/alexander/tg/tg-server.pub -WR -e 'msg ${peerID} "${text}"'`;
|
||||
}
|
||||
|
||||
public function actionQueue() {
|
||||
$jobCount = `/home/nomer.io/www/yii queue/info | grep waiting | grep -o '[0-9]*'`;
|
||||
if($jobCount > 15) {
|
||||
$this->notify('user#101209056', "В очереди ".$jobCount." запросов");
|
||||
}
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$todayResults = (new Query())
|
||||
->select(['request_results.type_id', '
|
||||
CASE
|
||||
WHEN (request_results.data = \'null\' OR request_results.data = \'[]\')
|
||||
THEN false
|
||||
ELSE true
|
||||
END as success
|
||||
', 'count(1)'])
|
||||
->from('requests')
|
||||
->leftJoin('request_results', ['requests.id' => new Expression('request_id')])
|
||||
->where(['>', 'requests.tm', date('Y-m-d H:i:s', strtotime('-24 hours'))])
|
||||
->groupBy(['type_id', 'success'])
|
||||
->orderBy(['type_id' => SORT_ASC, 'success' => SORT_ASC])
|
||||
->all();
|
||||
|
||||
$today = [];
|
||||
|
||||
foreach ($todayResults as $result) {
|
||||
if ($result['type_id'] === null) continue;
|
||||
if (!isset($today[$result['type_id']])) $today[$result['type_id']] = ['all' => 0, 'success' => 0];
|
||||
if ($result['success']) $today[$result['type_id']]['success'] += $result['count'];
|
||||
$today[$result['type_id']]['all'] += $result['count'];
|
||||
}
|
||||
|
||||
$yesterdayResults = (new Query())
|
||||
->select(['request_results.type_id', '
|
||||
CASE
|
||||
WHEN (request_results.data = \'null\' OR request_results.data = \'[]\')
|
||||
THEN false
|
||||
ELSE true
|
||||
END as success
|
||||
', 'count(1)'])
|
||||
->from('requests')
|
||||
->leftJoin('request_results', ['requests.id' => new Expression('request_id')])
|
||||
->where(['<=', 'requests.tm', date('Y-m-d H:i:s', strtotime('-24 hours'))])
|
||||
->where(['>=', 'requests.tm', date('Y-m-d H:i:s', strtotime('-48 hours'))])
|
||||
->groupBy(['type_id', 'success'])
|
||||
->orderBy(['type_id' => SORT_ASC, 'success' => SORT_ASC])
|
||||
->all();
|
||||
|
||||
$yesterday = [];
|
||||
|
||||
foreach ($yesterdayResults as $result) {
|
||||
if ($result['type_id'] === null) continue;
|
||||
if (!isset($yesterday[$result['type_id']])) $yesterday[$result['type_id']] = ['all' => 0, 'success' => 0];
|
||||
if ($result['success']) $yesterday[$result['type_id']]['success'] += $result['count'];
|
||||
$yesterday[$result['type_id']]['all'] += $result['count'];
|
||||
}
|
||||
|
||||
$types = array_unique(array_merge(array_keys($today), array_keys($yesterday)));
|
||||
|
||||
$text = '';
|
||||
|
||||
foreach ($types as $type) {
|
||||
if (!isset($today[$type]) || !isset($yesterday[$type])) continue;
|
||||
|
||||
$todayPercent = round($today[$type]['success'] / $today[$type]['all'] * 100, 2, PHP_ROUND_HALF_DOWN);
|
||||
$yesterdayPercent = round($yesterday[$type]['success'] / $yesterday[$type]['all'] * 100, 2, PHP_ROUND_HALF_DOWN);
|
||||
|
||||
if ($todayPercent < ($yesterdayPercent / 2)) {
|
||||
$text .= ResultCache::getTypeName($type) . ': ' . $todayPercent . '%, ' . $yesterdayPercent . "%\n";
|
||||
}
|
||||
}
|
||||
|
||||
$text = str_replace("\n", "\\n", trim($text));
|
||||
|
||||
if ($text) echo $this->notify('user#101209056', $text);
|
||||
}
|
||||
|
||||
public function actionViber()
|
||||
{
|
||||
$hours = date('H');
|
||||
|
||||
$time = null;
|
||||
$timeText = null;
|
||||
|
||||
if ($hours > 10 && $hours < 22) {
|
||||
$time = '-30 minutes';
|
||||
$timeText = 'последние 30 минут';
|
||||
} else {
|
||||
$time = '-1 hour';
|
||||
$timeText = 'последний час';
|
||||
}
|
||||
|
||||
$results = ResultCache::find()
|
||||
->where(['type_id' => ResultCache::TYPE_VIBER])
|
||||
->andWhere(['>', 'tm', date('Y-m-d H:i:s', strtotime($time))])
|
||||
->all();
|
||||
|
||||
if (!$results) return;
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['data'] != '[]' && $result['data'] != 'null') return;
|
||||
}
|
||||
|
||||
echo $this->notify('user#101209056', 'За ' . $timeText . ' не было ни одного успешного поиска в Viber.');
|
||||
}
|
||||
|
||||
public function actionTelegram()
|
||||
{
|
||||
$phones = [
|
||||
'79645552229',
|
||||
'79778979963',
|
||||
'79029111991'
|
||||
];
|
||||
|
||||
$instances = Telegram::find()->all();
|
||||
|
||||
foreach ($instances as $instance) {
|
||||
$phone = $phones[array_rand($phones)];
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://' . $instance->host . ':' . $instance->port . '/phone/' . $phone);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_exec($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$instance->tm_last = new Expression('NOW()');
|
||||
|
||||
switch ($code) {
|
||||
case 200: {
|
||||
$instance->status = Telegram::STATUS_ACTIVE;
|
||||
break;
|
||||
}
|
||||
case 404: {
|
||||
$instance->status = Telegram::STATUS_INACTIVE;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$instance->status = Telegram::STATUS_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($code != 200) {
|
||||
echo $this->notify('user#101209056', 'Telegram ' . $instance->host . ' ' . $code . ' (номер ' . $phone . ').');
|
||||
}
|
||||
|
||||
$instance->save();
|
||||
}
|
||||
}
|
||||
}
|
231
commands/ParseController.php
Normal file
231
commands/ParseController.php
Normal file
|
@ -0,0 +1,231 @@
|
|||
<?php
|
||||
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\Call;
|
||||
use app\models\Organization;
|
||||
use app\models\OrganizationEmail;
|
||||
use app\models\OrganizationPhone;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class ParseController extends Controller
|
||||
{
|
||||
public function actionPrepare() {
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/lists.txt', 'a+');
|
||||
$orgs = Organization::find()->all();
|
||||
foreach($orgs as $org) {
|
||||
foreach($org->emails as $email) {
|
||||
fwrite($f, $email->email.";".$org->name.";".$org->inn."\n");
|
||||
}
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
public function actionNew() {
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/new-calls.txt', 'a+');
|
||||
$calls = Call::find()->where(["status" => ["no-answer", "timeout"]])->all();
|
||||
foreach($calls as $call) {
|
||||
fwrite($f, $call->phone."\n");
|
||||
}
|
||||
}
|
||||
|
||||
public function actionCheck($file) {
|
||||
$fp = fopen(\Yii::getAlias('@runtime').'/new-phones.txt', 'a+');
|
||||
$fe = fopen(\Yii::getAlias('@runtime').'/new-emails.txt', 'a+');
|
||||
$data = file_get_contents($file);
|
||||
$rows = preg_split("/\n/", $data);
|
||||
foreach($rows as $phone) {
|
||||
$ch = curl_init("http://ssd.nomer.io/api/".$phone."?token=d131BpdeqbFJMasdfaVYJU6ydeyhgX");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode == 200) { // Все ок, берем данные
|
||||
$response = Json::decode($response);
|
||||
foreach ($response as $r) {
|
||||
if(isset($r["type"])) {
|
||||
switch ($r["type"]) {
|
||||
case "phone":
|
||||
fwrite($fp, $phone.";".$r["data"]."\n");
|
||||
break;
|
||||
case "email":
|
||||
if (strpos($r["data"], '@') !== false) {
|
||||
fwrite($fe, $phone.";".$r["data"]."\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($fe);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public function actionExportPhones() {
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/phones.txt', 'a+');
|
||||
$phones = OrganizationPhone::find()->all();
|
||||
foreach($phones as $phone) {
|
||||
fwrite($f, $phone->phone."\n");
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
public function actionExportEmails() {
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/emails.txt', 'a+');
|
||||
$emails = OrganizationEmail::find()->all();
|
||||
foreach($emails as $email) {
|
||||
fwrite($f, $email->email."\n");
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
protected function getOrgsPage($page)
|
||||
{
|
||||
$ch = curl_init('https://crmbg.su/actions.php');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Cookie: PHPSESSID=6mu3svdm2bgl3tpgr3oihc5k36'
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, [
|
||||
'action' => 'tender_search',
|
||||
'page' => $page,
|
||||
'protocol' => 'undefined',
|
||||
'sort' => 'id:DESC',
|
||||
'price' => 0,
|
||||
'online' => 0,
|
||||
'type' => 1,
|
||||
'first' => 'undefined',
|
||||
'onlyone' => 'undefined',
|
||||
'contact' => '30.06.2017'
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getCardPage($id)
|
||||
{
|
||||
$ch = curl_init('https://crmbg.su/actions.php');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Cookie: PHPSESSID=6mu3svdm2bgl3tpgr3oihc5k36'
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, [
|
||||
'action' => 'get_card_info',
|
||||
'id' => $id,
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function actionOrgs($from = 1, $to = 22)
|
||||
{
|
||||
for ($i = $from; $i <= $to; $i++) {
|
||||
echo 'Получаем организации со страницы ' . $i . PHP_EOL;
|
||||
|
||||
$response = $this->getOrgsPage($i);
|
||||
|
||||
preg_match('/(<table xmlns="http:\/\/www\.w3\.org\/1999\/xhtml" cellapdding="0" cellspacing="0" border="0" width="100%" class="table_result_tender">.*<\/table>)/s', $response, $matches);
|
||||
|
||||
$xml = simplexml_load_string($matches[1]);
|
||||
|
||||
$header = true;
|
||||
|
||||
foreach ($xml->tr as $row) {
|
||||
if ($header) {
|
||||
$header = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($row->td) != 10) continue;
|
||||
|
||||
$number = (string) $row->td[1]->a;
|
||||
$date = (string) $row->td[3];
|
||||
$sum = preg_replace('/[^\d.]/', '', (string) $row->td[4]->nobr);
|
||||
$inn = (string) $row->td[6];
|
||||
$name = (string) $row->td[7]['data-tip'];
|
||||
$region = (string) $row->td[9]['data-tip'];
|
||||
|
||||
$org = new Organization();
|
||||
$org->name = $name;
|
||||
$org->date = $date;
|
||||
$org->maximum_sum = $sum;
|
||||
$org->inn = $inn;
|
||||
$org->number = $number;
|
||||
$org->region = $region;
|
||||
|
||||
$org->save();
|
||||
|
||||
var_dump($number);
|
||||
var_dump($date);
|
||||
var_dump($sum);
|
||||
var_dump($inn);
|
||||
var_dump($name);
|
||||
var_dump($region);
|
||||
var_dump('----------------------------');
|
||||
|
||||
$response = $this->getCardPage($inn);
|
||||
|
||||
preg_match('/<td align="right">\s+Телефон\s+<\/td><td align="right">(.*?)<\/td>/s', $response, $mainPhone);
|
||||
$mainPhone = $mainPhone[1];
|
||||
|
||||
preg_match('/<td align="right">\s+Email\s+<\/td><td align="right">(.*?)<\/td>/s', $response, $mainEmail);
|
||||
$mainEmail = $mainEmail[1];
|
||||
|
||||
$orgPhone = new OrganizationPhone();
|
||||
$orgPhone->org_id = $org->id;
|
||||
$orgPhone->name = 'main';
|
||||
$orgPhone->phone = $mainPhone;
|
||||
$orgPhone->save();
|
||||
|
||||
$orgEmail = new OrganizationEmail();
|
||||
$orgEmail->org_id = $org->id;
|
||||
$orgEmail->name = 'main';
|
||||
$orgEmail->email = $mainEmail;
|
||||
$orgEmail->save();
|
||||
|
||||
preg_match_all('/(<table class="contacts" width="100%" cellpadding="0" cellspacing="0">.*?<\/table>)/s', $response, $matches);
|
||||
|
||||
$phones = simplexml_load_string($matches[1][1]);
|
||||
|
||||
foreach ($phones->tr as $phoneRow) {
|
||||
if (count($phoneRow->td) != 5) continue;
|
||||
|
||||
$phoneName = (string) $phoneRow->td[1]['data-tip'];
|
||||
$phoneValue = (string) $phoneRow->td[2]['data-tip'];
|
||||
|
||||
$orgAdditionalPhone = new OrganizationPhone();
|
||||
$orgAdditionalPhone->org_id = $org->id;
|
||||
$orgAdditionalPhone->name = $phoneName;
|
||||
$orgAdditionalPhone->phone = $phoneValue;
|
||||
$orgAdditionalPhone->save();
|
||||
}
|
||||
|
||||
$emails = simplexml_load_string($matches[1][0]);
|
||||
|
||||
foreach ($emails->tr as $emailRow) {
|
||||
if (count($emailRow->td) != 5) continue;
|
||||
|
||||
$emailName = (string) $emailRow->td[1]['data-tip'];
|
||||
$emailValue = (string) $emailRow->td[2]['data-tip'];
|
||||
|
||||
$orgAdditionalEmail = new OrganizationEmail();
|
||||
$orgAdditionalEmail->org_id = $org->id;
|
||||
$orgAdditionalEmail->name = $emailName;
|
||||
$orgAdditionalEmail->email = $emailValue;
|
||||
$orgAdditionalEmail->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
168
commands/QiwiController.php
Normal file
168
commands/QiwiController.php
Normal file
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\components\Curl;
|
||||
use app\models\BlockPhone;
|
||||
use app\models\Payment;
|
||||
use app\models\PhoneRequest;
|
||||
use app\models\Site;
|
||||
use app\models\Ticket;
|
||||
use app\models\User;
|
||||
use PHPHtmlParser\Dom;
|
||||
use app\components\Qiwi;
|
||||
use yii\console\Controller;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class QiwiController extends Controller {
|
||||
|
||||
private $Qiwi = null;
|
||||
|
||||
protected function getProxy()
|
||||
{
|
||||
$cachedProxy = \Yii::$app->getCache()->get('proxy');
|
||||
|
||||
try {
|
||||
$proxies = file_get_contents('http://nalevo.net/qiwiproxy.php');
|
||||
$proxies = Json::decode($proxies);
|
||||
if (count($proxies) == 0) throw new \Exception();
|
||||
} catch (\Exception $e) {
|
||||
if (!$cachedProxy) throw new \Exception('No proxy available');
|
||||
return $cachedProxy;
|
||||
}
|
||||
|
||||
$proxy = $proxies[array_rand($proxies)];
|
||||
\Yii::$app->getCache()->set('proxy', $proxy);
|
||||
return $proxy;
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
//$proxy = 'socks5://proxy:q2LVelfhoNbo@' . $this->getProxy();
|
||||
|
||||
//$proxy_ip = file_get_contents("https://awmproxy.com/getproxy.php?country=ru");
|
||||
//$proxy = 'socks5://'.trim($proxy_ip);
|
||||
$proxy = 'socks5://TG:tel.gg@proxy.rip:50000';
|
||||
|
||||
$ruCaptcha = [
|
||||
'proxyType' => 'SOCKS5',
|
||||
'apiKey' => '0d4004a0d4b7510706ca98dd09f3ec17',
|
||||
'googleToken' => '6LfjX_4SAAAAAFfINkDklY_r2Q5BRiEqmLjs4UAC'
|
||||
];
|
||||
|
||||
$sites = Site::find()->where(["!=", "phone", ""])->andWhere(["is not", "phone", null])->orderBy(["id" => SORT_ASC])->all();
|
||||
|
||||
foreach($sites as $s) {
|
||||
$this->Qiwi = new Qiwi(null, null, '', $proxy, $ruCaptcha);
|
||||
//$this->Qiwi->setCookieFile(\Yii::getAlias('@runtime').'/qiwi_cache0'.$s->id.'.php');
|
||||
$this->Qiwi->setCookieFile(\Yii::getAlias('@runtime').'/qiwi'.$s->phone.'.cookie');
|
||||
|
||||
echo $s->phone."\n";
|
||||
|
||||
$p = "Ag6K2oxG2";
|
||||
if($s->id == 23) {
|
||||
//$p = "Ag6K2oxGG";
|
||||
}
|
||||
|
||||
try {
|
||||
$this->Qiwi->login($s->phone, $p);
|
||||
} catch (\Exception $e) {
|
||||
print_r($e);
|
||||
}
|
||||
|
||||
try {
|
||||
$transactions = $this->Qiwi->transactions(TRUE, date("d.m.Y", (time()-86400*7)), date("d.m.Y", time()+86400));
|
||||
$this->process($transactions, $s->id);
|
||||
} catch (\Exception $e) {
|
||||
echo "error get transactions\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function process($transactions, $siteID) {
|
||||
|
||||
foreach($transactions as $t) {
|
||||
if(ArrayHelper::getValue($t, "incoming") !== true) continue;
|
||||
if(ArrayHelper::getValue($t, "status") != "SUCCESS") continue;
|
||||
$payment = Payment::find()->where(["operation_id" => ArrayHelper::getValue($t, "id"), "type_id" => [Payment::TYPE_QIWI_TERMINAL, Payment::TYPE_QIWI]])->one();
|
||||
if(!$payment) {
|
||||
$comment = ArrayHelper::getValue($t, 'comment');
|
||||
|
||||
$sum = ArrayHelper::getValue($t, 'cash');
|
||||
$operation_label = (string) ArrayHelper::getValue($t, 'opNumber');
|
||||
|
||||
$blockPayment = strlen($comment) == 11;
|
||||
|
||||
if ($blockPayment) {
|
||||
$blockedPhone = BlockPhone::find()->where(['phone' => $comment, 'status' => BlockPhone::STATUS_CONFIRMED])->one();
|
||||
|
||||
if (!$blockedPhone) continue;
|
||||
|
||||
if (preg_match('/\+(\d{11})/', $operation_label) && $sum < 299) {
|
||||
$sum = $sum + $sum * 0.07;
|
||||
}
|
||||
|
||||
if ($sum >= 299) {
|
||||
$blockedPhone->status = BlockPhone::STATUS_PAID;
|
||||
$blockedPhone->save();
|
||||
}
|
||||
|
||||
$user_id = null;
|
||||
} else {
|
||||
$user_id = (int) $comment;
|
||||
}
|
||||
|
||||
$balance = true;
|
||||
|
||||
$payment = new Payment();
|
||||
$payment->amount = $sum;
|
||||
$payment->sum = $sum;
|
||||
$payment->tm = date('Y-m-d H:i:s', strtotime('+3 hour'));
|
||||
$payment->operation_id = (string) ArrayHelper::getValue($t, 'id');
|
||||
$payment->operation_label = $operation_label;
|
||||
$payment->user_id = $user_id;
|
||||
$payment->site_id = $siteID;
|
||||
if (preg_match('/\+(\d{11})/', $operation_label)) {
|
||||
$payment->type_id = Payment::TYPE_QIWI;
|
||||
} else {
|
||||
$payment->type_id = Payment::TYPE_QIWI_TERMINAL;
|
||||
if ($sum < \Yii::$app->params['cost']) {
|
||||
$sum = $sum + $sum * 0.07;
|
||||
$balance = false;
|
||||
}
|
||||
}
|
||||
|
||||
$payment->save();
|
||||
|
||||
if($payment->user_id) {
|
||||
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 = $payment->user_id;
|
||||
$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 {
|
||||
$user = User::find()->where(['id' => $payment->user_id])->one();
|
||||
if(!$blockPayment) {
|
||||
$user->addBalance($sum, $sum, $balance, $payment->site_id);
|
||||
} else {
|
||||
$user->addBalance(0, $sum, true, $payment->site_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->Qiwi->paymentQiwi('+79269516206', $payment->sum, "RUB", "RUB");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64
commands/ReportsController.php
Normal file
64
commands/ReportsController.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\AppleSubscribeEvent;
|
||||
use yii\console\Controller;
|
||||
|
||||
class ReportsController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
for($i = 1; $i <= 15; $i++) {
|
||||
if($i < 10) $ii = '0'.$i;
|
||||
else $ii = $i;
|
||||
$f = fopen(\Yii::getAlias('@runtime').'/Subscription_Event_87428184_201801'.$ii.'_V1_1.txt', 'r');
|
||||
//$data = fgetcsv($f, 1024, "\t");
|
||||
$row = 0;
|
||||
while (($data = fgetcsv($f, 1000, "\t")) !== FALSE) {
|
||||
if($row == 0) { $row++; continue; }
|
||||
$e = new AppleSubscribeEvent();
|
||||
$e->event_date = $data[0];
|
||||
$e->event = $data[1];
|
||||
$e->app_name = $data[2];
|
||||
$e->app_id = (int)$data[3];
|
||||
$e->subscription_name = $data[4];
|
||||
$e->subscription_id = (int)$data[5];
|
||||
$e->subscription_group_id = (int)$data[6];
|
||||
$e->subscription_duration = $data[7];
|
||||
$e->introductory_price_type = $data[8];
|
||||
$e->introductory_price_duration = $data[9];
|
||||
$e->marketing_opt_in = $data[10];
|
||||
$e->marketing_opt_in_duration = $data[11];
|
||||
$e->preserved_pricing = $data[12];
|
||||
$e->proceeds_reason = $data[13];
|
||||
$e->consecutive_paid_periods = $data[14];
|
||||
$e->original_start_date = $data[15];
|
||||
$e->client = $data[16];
|
||||
$e->device = $data[17];
|
||||
$e->state = $data[18];
|
||||
$e->country = $data[19];
|
||||
$e->previous_subscription_name = $data[20];
|
||||
$e->previous_subscription_id = (int)$data[21];
|
||||
$e->days_before_canceling = (int)$data[22];
|
||||
$e->cancellation_reason = $data[23];
|
||||
$e->days_canceled = (int)$data[24];
|
||||
$e->quantity = (int)$data[25];
|
||||
if(!$e->save()) {
|
||||
print_r($e->getErrors()); die();
|
||||
}
|
||||
|
||||
$row++;
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
}
|
||||
}
|
||||
/*
|
||||
Array
|
||||
(
|
||||
[22] => Days Before Canceling
|
||||
[23] => Cancellation Reason
|
||||
[24] => Days Canceled
|
||||
[25] => Quantity
|
||||
)
|
||||
*/
|
||||
}
|
110
commands/RepostsController.php
Normal file
110
commands/RepostsController.php
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\Payment;
|
||||
use app\models\Repost;
|
||||
use app\models\ResultCache;
|
||||
use app\models\SearchRequest;
|
||||
use app\models\User;
|
||||
use yii\base\Exception;
|
||||
use yii\db\Expression;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Console;
|
||||
use yii\helpers\Json;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class RepostsController extends Controller {
|
||||
|
||||
public function actionIndex() {
|
||||
$reposts = Repost::find()->where(["status" => 1])->andWhere([">=", "tm", date("Y-m-d H:i:s", strtotime("-1 day"))])->all();
|
||||
foreach($reposts as $r) {
|
||||
$response = file_get_contents("https://api.vk.com/method/wall.get?owner_id=".$r->vk_id."&count=10&filter=owner&v=5.65&access_token=d585cf50d585cf50d585cf5077d5d94150dd585d585cf508cbd309b41310c9fdc6c13d7");
|
||||
|
||||
$response = Json::decode($response);
|
||||
|
||||
print_r($response);
|
||||
|
||||
$items = ArrayHelper::getValue($response, ["response", "items"], []);
|
||||
$hasRepost = false;
|
||||
foreach($items as $item) {
|
||||
$checkRepost = ArrayHelper::getValue($item, ["attachments", 0, "link", "url"], false);
|
||||
if($checkRepost && preg_match("/tels\.gg/", $checkRepost)) {
|
||||
$hasRepost = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$hasRepost) {
|
||||
$r->status = 0;
|
||||
$r->save();
|
||||
$user = User::find()->where(["id" => $r->user_id])->one();
|
||||
if($user->is_vip) continue;
|
||||
if($user->is_admin) continue;
|
||||
// if(!$user) continue;
|
||||
$payments = Payment::find()->where(["user_id" => $user->id])->count(1);
|
||||
if($payments > 0) return;
|
||||
$user->checks = 0;
|
||||
$user->save();
|
||||
$seaches = SearchRequest::find()->where(["user_id" => $user->id])->all();
|
||||
$phones = ArrayHelper::getColumn($seaches, "phone");
|
||||
$phones = array_unique($phones);
|
||||
|
||||
$r->sms_count = count($phones);
|
||||
$r->save();
|
||||
|
||||
try {
|
||||
$response = file_get_contents('https://api.vk.com/method/users.get?user_id=' . $r->vk_id . '&v=5.65&lang=ru&fields=photo_max_orig&access_token=d585cf50d585cf50d585cf5077d5d94150dd585d585cf508cbd309b41310c9fdc6c13d7');
|
||||
$response = Json::decode($response);
|
||||
$vkUser = ArrayHelper::getValue($response, ['response', 0]);
|
||||
|
||||
foreach($phones as $phone) {
|
||||
$name = null;
|
||||
$truecallerResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_TRUECALLER])->orderBy(["id" => SORT_DESC])->one();
|
||||
if($truecallerResult) {
|
||||
$truecallerResultData = Json::decode($truecallerResult->data);
|
||||
$name = ArrayHelper::getValue($truecallerResultData, [0, "name"], null);
|
||||
}
|
||||
if (is_null($name)) {
|
||||
$numbasterResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_NUMBUSTER])->orderBy(["id" => SORT_DESC])->one();
|
||||
if($numbasterResult) {
|
||||
$numbasterResultData = Json::decode($numbasterResult->data);
|
||||
$name = ArrayHelper::getValue($numbasterResultData, [0, "name"], null);
|
||||
}
|
||||
}
|
||||
if (is_null($name)) {
|
||||
$viberResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_VIBER])->orderBy(["id" => SORT_DESC])->one();
|
||||
if($viberResult) {
|
||||
$viberResultData = Json::decode($viberResult->data);
|
||||
$name = ArrayHelper::getValue($viberResultData, ["name"], null);
|
||||
}
|
||||
}
|
||||
if (is_null($name)) {
|
||||
$telegramResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_TELEGRAM])->orderBy(["id" => SORT_DESC])->one();
|
||||
if($telegramResult) {
|
||||
$telegramResultData = Json::decode($telegramResult->data);
|
||||
$name = ArrayHelper::getValue($telegramResultData, ["first_name"], null);
|
||||
$name .= " " . ArrayHelper::getValue($telegramResultData, ["last_name"], null);;
|
||||
}
|
||||
}
|
||||
|
||||
$url = "https://smsc.ru/sys/send.php?" . http_build_query([
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => ($name?$name."! ":'').'Ваш номер телефона пробивал "' . $vkUser['first_name'] . ' ' . $vkUser['last_name'] . '". Подробности на сайте ' . $user->generateLink(),
|
||||
'charset' => 'utf-8',
|
||||
'sender' => 'tels.gg',
|
||||
'translit' => 1
|
||||
]);
|
||||
|
||||
file_get_contents($url);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
Console::output("user ".$r->user_id." remove repost");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
100
commands/RetargetController.php
Normal file
100
commands/RetargetController.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\RequestResult;
|
||||
use app\models\SearchRequest;
|
||||
use app\models\User;
|
||||
use Swift_Attachment;
|
||||
use Yii;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
use yii\swiftmailer\Message;
|
||||
|
||||
class RetargetController extends Controller {
|
||||
|
||||
const USERID = 113168;
|
||||
|
||||
public function actionIndex() {
|
||||
$lastUserId = \Yii::$app->cache->get("lastUserId");
|
||||
if(!$lastUserId) $lastUserId = 0;
|
||||
foreach (User::find()->where(["IS NOT", "email", null])->andWhere([">", "id", $lastUserId])->with(["payments"])->orderBy(["id" => SORT_ASC])->batch(100) as $users) {
|
||||
foreach($users as $user) {
|
||||
\Yii::$app->cache->set("lastUserId", $user->id);
|
||||
if(!preg_match("/@/", $user->email)) continue;
|
||||
if(count($user->payments)) continue;
|
||||
|
||||
echo "\n\nUSERID: ".$user->id."\n";
|
||||
|
||||
$ch = curl_init('http://ssd.nomer.io/api/' . $user->email . '?token=NWBpdeqbbAFJMVYJU6XAfhyydeyhgX');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode == 200) { // Все ок, берем данные
|
||||
$response = Json::decode($response);
|
||||
$vkId = 0;
|
||||
foreach($response as $r) {
|
||||
if(ArrayHelper::getValue($r, "type") == "profile_id") {
|
||||
$vkId = ArrayHelper::getValue($r, "data");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($vkId) {
|
||||
$socData = file_get_contents("https://api.vk.com/method/users.get?user_ids=" . $vkId . "&fields=sex,bdate&lang=ru&access_token=8f95fab19fb8d3d41bdeeb28f0112cb2cd3c86a93fc66acbd29f327d1aa3f196540bfe10dcd4ca97baf37");
|
||||
$socData = Json::decode($socData);
|
||||
$socData = $socData["response"][0];
|
||||
|
||||
$bdate = ArrayHelper::getValue($socData, "bdate", null);
|
||||
$sex = ArrayHelper::getValue($socData, "sex", null);
|
||||
if(!$bdate) continue;
|
||||
if($sex != 2) continue;
|
||||
|
||||
$bdate = explode(".", $bdate);
|
||||
$year = ArrayHelper::getValue($bdate, 2);
|
||||
|
||||
if(date("Y") - $year >= 25) {
|
||||
$phones = [];
|
||||
$searches = SearchRequest::find()->where(["user_id" => $user->id])->asArray()->all();
|
||||
foreach($searches as $s) {
|
||||
if(!isset($phones[$s["phone"]])) {
|
||||
$phones[$s["phone"]] = 1;
|
||||
} else {
|
||||
$phones[$s["phone"]]++;
|
||||
}
|
||||
}
|
||||
arsort($phones);
|
||||
foreach($phones as $p => $c) {
|
||||
echo "Phone: ".$p."\n";
|
||||
$ch = curl_init('http://viber.apinomer.com:8999/' . preg_replace("/^7/", "8", $p));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$searchRequest = SearchRequest::find()->where(["user_id" => self::USERID, "phone" => $p])->orderBy(["id" => SORT_DESC])->asArray()->one();
|
||||
$requestResults = RequestResult::find()->select(["id", "index", "request_id"])->where(["request_id" => ArrayHelper::getValue($searchRequest, "id")])->all();
|
||||
$index = array_sum(ArrayHelper::getColumn($requestResults, "index"));
|
||||
echo "Index: ".$index."\n";
|
||||
if($index >= 50) {
|
||||
$mail = Yii::$app->mailer
|
||||
->compose("retarget", [
|
||||
"phone" => preg_replace("/^7/", "8", $p),
|
||||
"logo" => 'https://nomer.io/img/m/logo.png',
|
||||
"screenshot" => 'http://viber.apinomer.com:8999/static/' . preg_replace("/^7/", "8", $p).'.png'
|
||||
])
|
||||
->setFrom('no-reply@nomer.io')
|
||||
->setTo($user->email)
|
||||
->setSubject("Вы искали номер ". preg_replace("/^7/", "8", $p))
|
||||
->send();
|
||||
|
||||
//$mail->compose("retarget", ["phone" => preg_replace("/^7/", "8", $p)])
|
||||
var_dump($mail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
54
commands/TasksController.php
Normal file
54
commands/TasksController.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\Proxy;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class TasksController extends Controller
|
||||
{
|
||||
public function actionUpdateProxies()
|
||||
{
|
||||
$proxies = explode("\n", trim(file_get_contents('http://awmproxy.com/777proxy.txt')));
|
||||
|
||||
if (!$proxies) return;
|
||||
|
||||
Proxy::deleteAll();
|
||||
|
||||
foreach ($proxies as $proxy) {
|
||||
list($host, $port) = explode(':', $proxy);
|
||||
$model = new Proxy();
|
||||
$model->host = $host;
|
||||
$model->port = $port;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSms()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function actionCheckAvito()
|
||||
{
|
||||
$response = file_get_contents("http://rest-app.net/api/info?login=git@anyget.ru&token=a7548861db147975e7b3ad65c09c6398");
|
||||
$response = Json::decode($response);
|
||||
if($response["status"] == "ok") {
|
||||
\Yii::$app->cache->set("avito", ArrayHelper::getValue($response, "data"));
|
||||
}
|
||||
}
|
||||
|
||||
public function actionCheckAntiparkon()
|
||||
{
|
||||
//
|
||||
$response = file_get_contents("http://data.av100.ru/api.ashx?key=9f256387-5260-46b6-b9dc-8abdbfb877ee&phone=79299991975");
|
||||
$response = Json::decode($response);
|
||||
if(ArrayHelper::getValue($response, "error")) {
|
||||
\Yii::$app->cache->set("antiparkon", ArrayHelper::getValue($response, "error_msg"));
|
||||
} else {
|
||||
\Yii::$app->cache->delete("antiparkon");
|
||||
}
|
||||
}
|
||||
}
|
174
commands/TestController.php
Normal file
174
commands/TestController.php
Normal file
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\OrganizationPhone;
|
||||
use app\models\RequestResult;
|
||||
use app\models\ResultCache;
|
||||
use app\models\SearchRequest;
|
||||
use app\models\User;
|
||||
use yii\base\Exception;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class TestController extends Controller {
|
||||
|
||||
private $useragent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0';
|
||||
|
||||
public function actionRepost() {
|
||||
$user = User::find()->where(["id" => 1])->one();
|
||||
try {
|
||||
$response = file_get_contents('https://api.vk.com/method/users.get?user_id=' . $user->repost->vk_id . '&v=5.65&lang=ru&fields=photo_max_orig');
|
||||
$response = Json::decode($response);
|
||||
$vkUser = ArrayHelper::getValue($response, ['response', 0]);
|
||||
$phone = 79250379963;
|
||||
$name = null;
|
||||
$truecallerResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_TRUECALLER])->orderBy(["id" => SORT_DESC])->one();
|
||||
$truecallerResultData = Json::decode($truecallerResult->data);
|
||||
$name = ArrayHelper::getValue($truecallerResultData, [0, "name"], null);
|
||||
if(is_null($name)) {
|
||||
$numbasterResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_NUMBUSTER])->orderBy(["id" => SORT_DESC])->one();
|
||||
$numbasterResultData = Json::decode($numbasterResult->data);
|
||||
$name = ArrayHelper::getValue($numbasterResultData, [0, "name"], null);
|
||||
}
|
||||
if(is_null($name)) {
|
||||
$viberResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_VIBER])->orderBy(["id" => SORT_DESC])->one();
|
||||
$viberResultData = Json::decode($viberResult->data);
|
||||
$name = ArrayHelper::getValue($viberResultData, ["name"], null);
|
||||
}
|
||||
if(is_null($name)) {
|
||||
$telegramResult = ResultCache::find()->where(["phone" => $phone, "type_id" => ResultCache::TYPE_TELEGRAM])->orderBy(["id" => SORT_DESC])->one();
|
||||
$telegramResultData = Json::decode($telegramResult->data);
|
||||
$name = ArrayHelper::getValue($telegramResultData, ["first_name"], null);
|
||||
$name .= " ".ArrayHelper::getValue($telegramResultData, ["last_name"], null);;
|
||||
}
|
||||
|
||||
$url = "https://smsc.ru/sys/send.php?".http_build_query([
|
||||
'login' => 'admeo',
|
||||
'psw' => 'admeosmsc',
|
||||
'phones' => $phone,
|
||||
'mes' => $name.'! Ваш номер телефона пробивал "'.$vkUser['first_name'].' '.$vkUser['last_name'].'". Подробности на сайте '.$user->generateLink(),
|
||||
'charset' => 'utf-8',
|
||||
'sender' => 'tels.io'
|
||||
]);
|
||||
|
||||
file_get_contents($url);
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function actionRef() {
|
||||
$user = User::find()->where(["id" => 9437])->one();
|
||||
$user->addBalance(440);
|
||||
}
|
||||
|
||||
public function actionIndex($phone) {
|
||||
$ch = curl_init('https://www.truecaller.com/api/search?type=4&countryCode=RU&q='.$phone);
|
||||
// curl_setopt($ch, CURLOPT_INTERFACE, $ip);
|
||||
curl_setopt($ch, CURLOPT_PROXY, '95.141.193.84');
|
||||
curl_setopt($ch, CURLOPT_PROXYPORT, 777);
|
||||
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ErqH2RfLL_X2UubBtc_jt8VKF3cXtsic']);
|
||||
//curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||
$response = curl_exec($ch);
|
||||
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
print_r($response);
|
||||
}
|
||||
|
||||
private function getData() {
|
||||
$ch = curl_init('http://avinfo.co/info/?phone=9219312347');
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, "c.txt");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, "c.txt");
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
print_r($response);
|
||||
}
|
||||
|
||||
private function auth() {
|
||||
$ch = curl_init('http://avinfo.co/login');
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, "c.txt");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, "c.txt");
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
preg_match("%\<input\stype=\"hidden\"\sname=\"__VIEWSTATE\"\sid=\"__VIEWSTATE\"\svalue=\"(.+?)\"%", $response, $m);
|
||||
$viewState = $m[1];
|
||||
|
||||
preg_match("%\<input\stype=\"hidden\"\sname=\"__VIEWSTATEGENERATOR\"\sid=\"__VIEWSTATEGENERATOR\"\svalue=\"(.+?)\"%", $response, $m);
|
||||
$viewStateGenerator = $m[1];
|
||||
|
||||
preg_match("%\<input\stype=\"hidden\"\sname=\"__EVENTVALIDATION\"\sid=\"__EVENTVALIDATION\"\svalue=\"(.+?)\"%", $response, $m);
|
||||
$eventValidatrion = $m[1];
|
||||
|
||||
// set post fields
|
||||
$post = [
|
||||
'__EVENTTARGET' => '',
|
||||
'__EVENTARGUMENT' => '',
|
||||
'__VIEWSTATE' => $viewState,
|
||||
'__VIEWSTATEGENERATOR' => $viewStateGenerator,
|
||||
'__EVENTVALIDATION' => $eventValidatrion,
|
||||
'ctl00$MainContent$txtLogin' => '9660098505',
|
||||
'ctl00$MainContent$txtPassword' => '7801462364',
|
||||
'ctl00$MainContent$btnLogIn' => 'Войти',
|
||||
'ctl00$MainContent$txtRegPhone' => '',
|
||||
'ctl00$MainContent$txtCapchaVal' => '',
|
||||
];
|
||||
|
||||
$ch = curl_init('http://avinfo.co/login');
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, "c.txt");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, "c.txt");
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
public function actionUserRegions()
|
||||
{
|
||||
$reader = new Reader(\Yii::getAlias('@runtime') . '/GeoLite2-City.mmdb');
|
||||
|
||||
$users = User::find()
|
||||
->where(['is not', 'ip', null])
|
||||
->andWhere(['geo_id' => null])
|
||||
->all();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$data = $reader->get($user->ip);
|
||||
if (!isset($data['subdivisions']) || count($data['subdivisions']) == 0) continue;
|
||||
//var_dump($user->id, $data['subdivisions'][0]['geoname_id'], $data['subdivisions'][0]['names']['ru']);
|
||||
$user->geo_id = $data['subdivisions'][0]['geoname_id'];
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionPhone()
|
||||
{
|
||||
foreach (OrganizationPhone::find()->all() as $phone) {
|
||||
$formattedPhone = preg_replace('/#\d+/', '', $phone->phone);
|
||||
$formattedPhone = preg_replace('/[^\d]/', '', $formattedPhone);
|
||||
$formattedPhone = preg_replace('/^8/', '7', $formattedPhone);
|
||||
|
||||
if (preg_match('/^[^7]/', $formattedPhone)) continue;
|
||||
if (strlen($formattedPhone) != 11) continue;
|
||||
|
||||
$phone->phone2 = $formattedPhone;
|
||||
$phone->save();
|
||||
}
|
||||
}
|
||||
}
|
84
commands/VkController.php
Normal file
84
commands/VkController.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\models\Site;
|
||||
use app\models\Vk;
|
||||
use app\models\VkComment;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class VkController extends Controller {
|
||||
|
||||
public function actionComments() {
|
||||
foreach (Site::find()->where(["NOT IN", "id", [14]])->all() as $s) {
|
||||
$appID = $s->vk_id;
|
||||
$siteID = $s->id;
|
||||
$response = @file_get_contents("https://api.vk.com/method/widgets.getComments?widget_api_id=".$appID."&page_id=777&fields=replies&order=date&count=100&v=5.65");
|
||||
if($response) {
|
||||
$response = Json::decode($response);
|
||||
$posts = ArrayHelper::getValue($response, ["response", "posts"], []);
|
||||
if(count($posts)) foreach($posts as $post) {
|
||||
$vkPost = VkComment::find()->where(["id" => ArrayHelper::getValue($post, "id"), "site_id" => $siteID])->one();
|
||||
$vkID = ArrayHelper::getValue($post, "from_id");
|
||||
if(!$vkPost) {
|
||||
$responseVkUser = file_get_contents('https://api.vk.com/method/users.get?user_id=' . $vkID . '&v=5.65&lang=ru&fields=photo_50&access_token=8f95fab19fb8d3d41bdeeb28f0112cb2cd3c86a93fc66acbd29f327d1aa3f196540bfe10dcd4ca97baf37');
|
||||
$responseVkUser = Json::decode($responseVkUser);
|
||||
$vkUser = ArrayHelper::getValue($responseVkUser, ['response', 0]);
|
||||
$vkUserPhoto = @file_get_contents(ArrayHelper::getValue($vkUser, "photo_50"));
|
||||
if($vkUserPhoto) {
|
||||
$vkUserPhoto = base64_encode($vkUserPhoto);
|
||||
}
|
||||
|
||||
$vkPost = new VkComment();
|
||||
$vkPost->id = ArrayHelper::getValue($post, "id");
|
||||
$vkPost->site_id = $siteID;
|
||||
$vkPost->comment = ArrayHelper::getValue($post, "text");
|
||||
$vkPost->tm = \Yii::$app->formatter->asDatetime(ArrayHelper::getValue($post, "date"), "yyyy-MM-dd HH:mm:ss");
|
||||
$vkPost->vk_id = (string)ArrayHelper::getValue($post, "from_id");
|
||||
if($vkUserPhoto) {
|
||||
$vkPost->photo = $vkUserPhoto;
|
||||
}
|
||||
$vkPost->name = join(" ", [ArrayHelper::getValue($vkUser, "first_name"), ArrayHelper::getValue($vkUser, "last_name")]);
|
||||
if(!$vkPost->save()) {
|
||||
print_r($vkPost->getErrors()); die();
|
||||
}
|
||||
}
|
||||
$comments = ArrayHelper::getValue($post, "comments.replies", []);
|
||||
if(count($comments)) {
|
||||
foreach ($comments as $c) {
|
||||
$vkID = ArrayHelper::getValue($c, "uid");
|
||||
$vkComment = VkComment::find()->where(["id" => ArrayHelper::getValue($c, "cid"), "site_id" => $siteID])->one();
|
||||
if(!$vkComment) {
|
||||
$responseVkUser = file_get_contents('https://api.vk.com/method/users.get?user_id=' . $vkID . '&v=5.65&lang=ru&fields=photo_50&access_token=8f95fab19fb8d3d41bdeeb28f0112cb2cd3c86a93fc66acbd29f327d1aa3f196540bfe10dcd4ca97baf37');
|
||||
$responseVkUser = Json::decode($responseVkUser);
|
||||
$vkUser = ArrayHelper::getValue($responseVkUser, ['response', 0]);
|
||||
$vkUserPhoto = @file_get_contents(ArrayHelper::getValue($vkUser, "photo_50"));
|
||||
if($vkUserPhoto) {
|
||||
$vkUserPhoto = base64_encode($vkUserPhoto);
|
||||
}
|
||||
|
||||
$vkComment = new VkComment();
|
||||
$vkComment->id = ArrayHelper::getValue($c, "cid");
|
||||
$vkComment->site_id = $siteID;
|
||||
$vkComment->pid = ArrayHelper::getValue($vkPost, "id");
|
||||
$vkComment->comment = ArrayHelper::getValue($c, "text");
|
||||
$vkComment->tm = \Yii::$app->formatter->asDatetime(ArrayHelper::getValue($c, "date"), "yyyy-MM-dd HH:mm:ss");
|
||||
$vkComment->vk_id = (string)ArrayHelper::getValue($c, "uid");
|
||||
if($vkUserPhoto) {
|
||||
$vkComment->photo = $vkUserPhoto;
|
||||
}
|
||||
$vkComment->name = join(" ", [ArrayHelper::getValue($vkUser, "first_name"), ArrayHelper::getValue($vkUser, "last_name")]);
|
||||
if(!$vkComment->save()) {
|
||||
print_r($vkComment->getErrors()); die();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
196
commands/WalletsController.php
Normal file
196
commands/WalletsController.php
Normal file
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use app\components\Qiwi;
|
||||
use app\models\Site;
|
||||
use app\models\Wallet;
|
||||
use yii\base\Exception;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\db\Expression;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Console;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class WalletsController extends Controller {
|
||||
protected function getProxy()
|
||||
{
|
||||
$cachedProxy = \Yii::$app->getCache()->get('proxy');
|
||||
|
||||
try {
|
||||
$proxies = file_get_contents('http://nalevo.net/qiwiproxy.php');
|
||||
$proxies = Json::decode($proxies);
|
||||
if (count($proxies) == 0) throw new \Exception();
|
||||
} catch (\Exception $e) {
|
||||
if (!$cachedProxy) throw new \Exception('No proxy available');
|
||||
return $cachedProxy;
|
||||
}
|
||||
|
||||
$proxy = $proxies[array_rand($proxies)];
|
||||
\Yii::$app->getCache()->set('proxy', $proxy);
|
||||
return $proxy;
|
||||
}
|
||||
|
||||
public function actionIndex() {
|
||||
$wallets = Wallet::find()->where(["type_id" => Wallet::TYPE_YANDEX])->orderBy(["id" => SORT_ASC])->all();
|
||||
|
||||
foreach($wallets as $w) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://passport.yandex.ru/auth');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, 'login='.urlencode($w->login).'&passwd='.urlencode($w->password)."&retpath=".urlencode("https://money.yandex.ru/new")."&from=money&origin×tamp");
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, \Yii::getAlias('@runtime')."/yandex.".$w->wallet_id.".cookie");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, \Yii::getAlias('@runtime')."/yandex.".$w->wallet_id.".cookie");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0");
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if(preg_match("#<span class=\"price__whole-amount\">(.+?)</span>#", $response, $m)) {
|
||||
$balance = preg_replace("/\&\#160\;/", "", $m[1]);
|
||||
$w->balance = $balance;
|
||||
$w->tm_last_balance = new Expression('NOW()');
|
||||
$w->save();
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://money.yandex.ru/ajax/history/partly?history_shortcut=history_all&search=&start-record=0&record-count=100');
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, \Yii::getAlias('@runtime')."/yandex.".$w->wallet_id.".cookie");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, \Yii::getAlias('@runtime')."/yandex.".$w->wallet_id.".cookie");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0");
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
$data = Json::decode($response);
|
||||
foreach($data["history"] as $item) {
|
||||
if((int)$item["type"] == 1 || (int)$item["type"] == 4) {
|
||||
$w->tm_last_transaction = date("Y-m-d H:i:s", strtotime(\Yii::$app->formatter->asDatetime($item["date"], "yyyy-MM-dd HH:mm:ss")) + 60 * 60 * 3);
|
||||
$w->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($data["history"] as $item) {
|
||||
if((int)$item["type"] == 2 || $item["sum"] < 0) {
|
||||
$w->tm_last_transaction_out = date("Y-m-d H:i:s", strtotime(\Yii::$app->formatter->asDatetime($item["date"], "yyyy-MM-dd HH:mm:ss")) + 60 * 60 * 3);
|
||||
$w->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $proxy = 'socks5://proxy:q2LVelfhoNbo@' . $this->getProxy();
|
||||
//$proxy_ip = file_get_contents("https://awmproxy.com/getproxy.php?country=ru");
|
||||
//$proxy = 'socks5://'.trim($proxy_ip);
|
||||
/*
|
||||
$proxy = 'socks5://TG:tel.gg@proxy.rip:50000';
|
||||
$ruCaptcha = [
|
||||
'proxyType' => 'SOCKS5',
|
||||
'apiKey' => '0d4004a0d4b7510706ca98dd09f3ec17',
|
||||
'googleToken' => '6LfjX_4SAAAAAFfINkDklY_r2Q5BRiEqmLjs4UAC'
|
||||
];
|
||||
|
||||
$wallets = Wallet::find()->where(["type_id" => Wallet::TYPE_QIWI])->andWhere(["NOT IN", "login", ["79295595495", "79295044638"]])->orderBy(["id" => SORT_ASC])->all();
|
||||
foreach($wallets as $w) {
|
||||
Console::output("get data for ".$w->login);
|
||||
$Qiwi = new Qiwi(null, null, '', $proxy, $ruCaptcha);
|
||||
$Qiwi->setCookieFile(\Yii::getAlias('@runtime').'/qiwi'.$w->login.'.cookie');
|
||||
|
||||
$p = "";
|
||||
if($w->login == "79269516206") {
|
||||
$p = "Admeo!31337";
|
||||
} else {
|
||||
$p = "Ag6K2oxG2";
|
||||
}
|
||||
|
||||
try {
|
||||
$Qiwi->login($w->login, $p);
|
||||
} catch (\Exception $e) {
|
||||
print_r($e->getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$balances = $Qiwi->wallets();
|
||||
if($balances) {
|
||||
$w->balance = $balances["RUB"];
|
||||
$w->tm_last_balance = new Expression('NOW()');
|
||||
$w->save();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Console::output("Не получили баланс у ".$w->login);
|
||||
continue;
|
||||
}
|
||||
|
||||
$transactions = $Qiwi->transactions(TRUE, date("d.m.Y", (time()-86400*7)), date("d.m.Y", time()+86400));
|
||||
foreach($transactions as $t) {
|
||||
if((!(int)$t["incoming"]) && $t["status"] == "SUCCESS") {
|
||||
$w->tm_last_transaction_out = preg_replace("/(\d\d)\.(\d\d).(\d\d\d\d)/", "$3-$2-$1", $t["date"])." ".$t["time"];
|
||||
$w->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach($transactions as $t) {
|
||||
if(((int)$t["incoming"]) && $t["status"] == "SUCCESS") {
|
||||
$w->tm_last_transaction = preg_replace("/(\d\d)\.(\d\d).(\d\d\d\d)/", "$3-$2-$1", $t["date"])." ".$t["time"];
|
||||
$w->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function actionSites()
|
||||
{
|
||||
foreach (Site::find()->all() as $site) {
|
||||
/* @var $site Site */
|
||||
|
||||
echo $site->name . PHP_EOL;
|
||||
|
||||
if ($site->yandex_money_account) {
|
||||
echo 'Yandex Money ' . $site->yandex_money_account . PHP_EOL;
|
||||
|
||||
$wallet = Wallet::find()
|
||||
->where(['type_id' => Wallet::TYPE_YANDEX])
|
||||
->andWhere(['wallet_id' => $site->yandex_money_account])
|
||||
->one();
|
||||
|
||||
if ($wallet) {
|
||||
echo 'Кошелёк ' . $wallet->id . PHP_EOL;
|
||||
$wallet->site_id = $site->id;
|
||||
$wallet->save();
|
||||
} else {
|
||||
echo 'Кошелёк не найден' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
if ($site->phone) {
|
||||
echo 'Qiwi ' . $site->phone . PHP_EOL;
|
||||
|
||||
$wallet = Wallet::find()
|
||||
->where(['type_id' => Wallet::TYPE_QIWI])
|
||||
->andWhere(['wallet_id' => '+' . $site->phone])
|
||||
->one();
|
||||
|
||||
if ($wallet) {
|
||||
echo 'Кошелёк ' . $wallet->id . PHP_EOL;
|
||||
$wallet->site_id = $site->id;
|
||||
$wallet->save();
|
||||
} else {
|
||||
echo 'Кошелёк не найден' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
103
commands/YandexController.php
Normal file
103
commands/YandexController.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
namespace app\commands;
|
||||
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\Json;
|
||||
|
||||
class YandexController extends Controller{
|
||||
|
||||
public function actionIndex() {
|
||||
$login = 'mezhevikina.masha@yandex.ru';
|
||||
$password = 'Ag6K2oxG';
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://passport.yandex.ru/auth');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, 'login='.urlencode($login).'&passwd='.urlencode($password)."&retpath=".urlencode("https://money.yandex.ru/new")."&from=money&origin×tamp");
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
|
||||
$response = curl_exec($ch);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://money.yandex.ru/ajax/history/partly?history_shortcut=history_all&search=&start-record=0&record-count=10');
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
echo $response;
|
||||
|
||||
die();
|
||||
|
||||
if(preg_match_all('/\<form(.+?)action=\"(.+?)\"\>/u', $response, $m) && preg_match_all('/\"sk\"\:\"(.+?)\"/u', $response, $m2)) {
|
||||
$requestURL = $m[2][1];
|
||||
$sk = $m2[1][0];
|
||||
|
||||
/*
|
||||
* protection-period:7
|
||||
protection-code:0962
|
||||
receiver:410014057045840
|
||||
comment:
|
||||
sum_k:10
|
||||
sum:10.05
|
||||
pay-money-source:yamoney-account-410011204915798
|
||||
sk:ud50ce5e2d22b9fe711537a23f95bf18b
|
||||
*/
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $requestURL);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, 'receiver='.urlencode("410014057045840")."&sum=10.05&sum_k=10&protection-period=7&protection-code=0962&pay-money-source=yamoney-account-410011204915798&sk=".$sk);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_REFERER, "https://money.yandex.ru/transfer");
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
|
||||
$response = curl_exec($ch);
|
||||
|
||||
$result = Json::decode($response);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, preg_replace("/contract/", "process", $result["url"])."/PC/sign");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "pay-money-source=yamoney-account-410011204915798&sk=".$sk);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
curl_setopt($ch, CURLOPT_REFERER, $result["url"]);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, \Yii::getAlias('@runtime')."/ya.cookie");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
|
||||
$response = curl_exec($ch);
|
||||
|
||||
print_r($response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue