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
				
			
		
							
								
								
									
										3
									
								
								.bowerrc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.bowerrc
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| { | ||||
|     "directory" : "vendor/bower" | ||||
| } | ||||
							
								
								
									
										36
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| # phpstorm project files | ||||
| .idea | ||||
| 
 | ||||
| # netbeans project files | ||||
| nbproject | ||||
| 
 | ||||
| # zend studio for eclipse project files | ||||
| .buildpath | ||||
| .project | ||||
| .settings | ||||
| 
 | ||||
| # windows thumbnail cache | ||||
| Thumbs.db | ||||
| 
 | ||||
| # composer vendor dir | ||||
| /vendor | ||||
| 
 | ||||
| # composer itself is not needed | ||||
| composer.phar | ||||
| 
 | ||||
| composer.lock | ||||
| 
 | ||||
| # Mac DS_Store Files | ||||
| .DS_Store | ||||
| 
 | ||||
| # phpunit itself is not needed | ||||
| phpunit.phar | ||||
| # local phpunit config | ||||
| /phpunit.xml | ||||
| 
 | ||||
| tests/_output/* | ||||
| tests/_support/_generated | ||||
| 
 | ||||
| config/db.php | ||||
| 
 | ||||
| web/index.php | ||||
							
								
								
									
										5
									
								
								CHANGELOG
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								CHANGELOG
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | |||
| 2017-03-02 | ||||
| + Блокировка своего номера | ||||
| 
 | ||||
| 2017-03-01 | ||||
| + Вывод RAW информации | ||||
							
								
								
									
										32
									
								
								LICENSE.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								LICENSE.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| The Yii framework is free software. It is released under the terms of | ||||
| the following BSD License. | ||||
| 
 | ||||
| Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) | ||||
| All rights reserved. | ||||
| 
 | ||||
| Redistribution and use in source and binary forms, with or without | ||||
| modification, are permitted provided that the following conditions | ||||
| are met: | ||||
| 
 | ||||
|  * Redistributions of source code must retain the above copyright | ||||
|    notice, this list of conditions and the following disclaimer. | ||||
|  * Redistributions in binary form must reproduce the above copyright | ||||
|    notice, this list of conditions and the following disclaimer in | ||||
|    the documentation and/or other materials provided with the | ||||
|    distribution. | ||||
|  * Neither the name of Yii Software LLC nor the names of its | ||||
|    contributors may be used to endorse or promote products derived | ||||
|    from this software without specific prior written permission. | ||||
| 
 | ||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||||
| FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||||
| COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
| INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||||
| BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||||
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||
| POSSIBILITY OF SUCH DAMAGE. | ||||
							
								
								
									
										0
									
								
								README.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								README.md
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										45
									
								
								assets/AppAsset.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								assets/AppAsset.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| <?php | ||||
| /** | ||||
|  * @link http://www.yiiframework.com/ | ||||
|  * @copyright Copyright (c) 2008 Yii Software LLC | ||||
|  * @license http://www.yiiframework.com/license/ | ||||
|  */ | ||||
| 
 | ||||
| namespace app\assets; | ||||
| 
 | ||||
| use yii\web\AssetBundle; | ||||
| 
 | ||||
| /** | ||||
|  * @author Qiang Xue <qiang.xue@gmail.com> | ||||
|  * @since 2.0 | ||||
|  */ | ||||
| class AppAsset extends AssetBundle | ||||
| { | ||||
|     public $basePath = '@webroot'; | ||||
|     public $baseUrl = '@web'; | ||||
|     public $css = [ | ||||
|         '//fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,300italic,600,600italic,700,700italic,800italic,800&subset=latin,cyrillic-ext,cyrillic,latin-ext', | ||||
|         'css/site.css', | ||||
|         'css/swipebox.min.css', | ||||
|         'css/a.css', | ||||
|         'css/jquery-confirm.min.css' | ||||
|     ]; | ||||
|     public $js = [ | ||||
|         'https://vk.com/js/api/openapi.js?146', | ||||
|         'js/swfobject-2.2.min.js', | ||||
|         'js/socket.io.min.js', | ||||
|         'js/jquery.swipebox.min.js', | ||||
|         'js/masonry.pkgd.min.js', | ||||
|         'js/jquery-confirm.min.js', | ||||
|         'js/app.js', | ||||
| 
 | ||||
|     ]; | ||||
|     public $depends = [ | ||||
|         'yii\web\YiiAsset', | ||||
|         'yii\web\JqueryAsset', | ||||
| //        'yii\bootstrap\BootstrapAsset',
 | ||||
| //        'yii\bootstrap\BootstrapPluginAsset',
 | ||||
|         'yii\authclient\widgets\AuthChoiceAsset', | ||||
|         'yii\widgets\MaskedInputAsset' | ||||
|     ]; | ||||
| } | ||||
							
								
								
									
										39
									
								
								assets/ZAsset.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								assets/ZAsset.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| <?php | ||||
| /** | ||||
|  * @link http://www.yiiframework.com/ | ||||
|  * @copyright Copyright (c) 2008 Yii Software LLC | ||||
|  * @license http://www.yiiframework.com/license/ | ||||
|  */ | ||||
| 
 | ||||
| namespace app\assets; | ||||
| 
 | ||||
| use yii\web\AssetBundle; | ||||
| 
 | ||||
| /** | ||||
|  * @author Qiang Xue <qiang.xue@gmail.com> | ||||
|  * @since 2.0 | ||||
|  */ | ||||
| class ZAsset extends AssetBundle | ||||
| { | ||||
|     public $basePath = '@webroot'; | ||||
|     public $baseUrl = 'http://z.fcheck.ru'; | ||||
|     public $css = [ | ||||
|         '//fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,300italic,600,600italic,700,700italic,800italic,800&subset=latin,cyrillic-ext,cyrillic,latin-ext', | ||||
|         'css/frame.css', | ||||
|         'css/jquery.fancybox.min.css', | ||||
|     ]; | ||||
|     public $js = [ | ||||
|         'https://cdnjs.cloudflare.com/ajax/libs/fingerprintjs2/1.5.0/fingerprint2.min.js', | ||||
|         'js/swfobject-2.2.min.js', | ||||
|         'js/evercookie.js', | ||||
|         'js/socket.io.min.js', | ||||
|         'js/jquery.fancybox.min.js', | ||||
|         'js/app.js' | ||||
|     ]; | ||||
|     public $depends = [ | ||||
|         'yii\web\YiiAsset', | ||||
|         'yii\bootstrap\BootstrapAsset', | ||||
|         'yii\bootstrap\BootstrapPluginAsset', | ||||
|         'yii\authclient\widgets\AuthChoiceAsset' | ||||
|     ]; | ||||
| } | ||||
							
								
								
									
										37
									
								
								codeception.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								codeception.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| actor: Tester | ||||
| paths: | ||||
|     tests: tests | ||||
|     log: tests/_output | ||||
|     data: tests/_data | ||||
|     helpers: tests/_support | ||||
| settings: | ||||
|     bootstrap: _bootstrap.php | ||||
|     memory_limit: 1024M | ||||
|     colors: true | ||||
| modules: | ||||
|     config: | ||||
|         Yii2: | ||||
|             configFile: 'config/test.php' | ||||
|             cleanup: false | ||||
| 
 | ||||
| # To enable code coverage: | ||||
| #coverage: | ||||
| #    #c3_url: http://localhost:8080/index-test.php/ | ||||
| #    enabled: true | ||||
| #    #remote: true | ||||
| #    #remote_config: '../tests/codeception.yml' | ||||
| #    whitelist: | ||||
| #        include: | ||||
| #            - models/* | ||||
| #            - controllers/* | ||||
| #            - commands/* | ||||
| #            - mail/* | ||||
| #    blacklist: | ||||
| #        include: | ||||
| #            - assets/* | ||||
| #            - config/* | ||||
| #            - runtime/* | ||||
| #            - vendor/* | ||||
| #            - views/* | ||||
| #            - web/* | ||||
| #            - tests/* | ||||
							
								
								
									
										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); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| } | ||||
							
								
								
									
										65
									
								
								composer.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								composer.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,65 @@ | |||
| { | ||||
|     "name": "yiisoft/yii2-app-basic", | ||||
|     "description": "Yii 2 Basic Project Template", | ||||
|     "keywords": ["yii2", "framework", "basic", "project template"], | ||||
|     "homepage": "http://www.yiiframework.com/", | ||||
|     "type": "project", | ||||
|     "license": "BSD-3-Clause", | ||||
|     "support": { | ||||
|         "issues": "https://github.com/yiisoft/yii2/issues?state=open", | ||||
|         "forum": "http://www.yiiframework.com/forum/", | ||||
|         "wiki": "http://www.yiiframework.com/wiki/", | ||||
|         "irc": "irc://irc.freenode.net/yii", | ||||
|         "source": "https://github.com/yiisoft/yii2" | ||||
|     }, | ||||
|     "minimum-stability": "dev", | ||||
|     "require": { | ||||
|         "php": ">=5.4.0", | ||||
|         "yiisoft/yii2": "*", | ||||
|         "yiisoft/yii2-bootstrap": "~2.0.0", | ||||
|         "yiisoft/yii2-swiftmailer": "^2.0", | ||||
|         "yiisoft/yii2-authclient": "~2.1.0", | ||||
|         "paquettg/php-html-parser": "^1.7", | ||||
|         "yiisoft/yii2-jui": "^2.0", | ||||
|         "nizsheanez/yii2-asset-converter": "1.*", | ||||
|         "mobiledetect/mobiledetectlib": "^2.8", | ||||
|         "alexandernst/yii2-device-detect": "0.0.11", | ||||
|         "geoip2/geoip2": "~2.0", | ||||
|         "airani/yii2-telegram-log": "*", | ||||
|         "aporat/store-receipt-validator": "dev-master", | ||||
|         "himiklab/yii2-recaptcha-widget" : "*", | ||||
|         "zhuravljov/yii2-queue": "^1.0", | ||||
|         "google/apiclient": "^2.0" | ||||
|     }, | ||||
|     "require-dev": { | ||||
|         "yiisoft/yii2-debug": "~2.0.0", | ||||
|         "yiisoft/yii2-gii": "~2.0.0", | ||||
|         "yiisoft/yii2-faker": "~2.0.0" | ||||
|     }, | ||||
|     "config": { | ||||
|         "process-timeout": 1800 | ||||
|     }, | ||||
|     "scripts": { | ||||
|         "post-create-project-cmd": [ | ||||
|             "yii\\composer\\Installer::postCreateProject" | ||||
|         ] | ||||
|     }, | ||||
|     "extra": { | ||||
|         "yii\\composer\\Installer::postCreateProject": { | ||||
|             "setPermission": [ | ||||
|                 { | ||||
|                     "runtime": "0777", | ||||
|                     "web/assets": "0777", | ||||
|                     "yii": "0755" | ||||
|                 } | ||||
|             ], | ||||
|             "generateCookieValidationKey": [ | ||||
|                 "config/web.php" | ||||
|             ] | ||||
|         }, | ||||
|         "asset-installer-paths": { | ||||
|             "npm-asset-library": "vendor/npm", | ||||
|             "bower-asset-library": "vendor/bower" | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										18
									
								
								config/assets.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								config/assets.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| <?php | ||||
| return [ | ||||
|     'app' => [ | ||||
|         'basePath' => '@webroot', | ||||
|         'baseUrl' => '@web', | ||||
|         'css' => [ | ||||
|             'css/source/fonts.css', | ||||
|             'css/source/reset.css', | ||||
|             'css/source/style.sass', | ||||
|         ], | ||||
|         'js' => [ | ||||
| 
 | ||||
|         ], | ||||
|         'depends' => [ | ||||
|             'yii', | ||||
|         ], | ||||
|     ], | ||||
| ]; | ||||
							
								
								
									
										52
									
								
								config/console.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								config/console.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,52 @@ | |||
| <?php | ||||
| 
 | ||||
| $params = require(__DIR__ . '/params.php'); | ||||
| $db = require(__DIR__ . '/db.php'); | ||||
| 
 | ||||
| $config = [ | ||||
|     'id' => 'basic-console', | ||||
|     'basePath' => dirname(__DIR__), | ||||
|     'bootstrap' => ['log', 'queue'], | ||||
|     'controllerNamespace' => 'app\commands', | ||||
|     'components' => [ | ||||
|         'queue' => [ | ||||
|             'class' => \zhuravljov\yii\queue\file\Queue::class, | ||||
|             'path' => '@runtime/queue', | ||||
|         ], | ||||
|         'cache' => [ | ||||
|             'class' => 'yii\caching\MemCache', | ||||
|             'useMemcached' => true | ||||
|         ], | ||||
|         'log' => [ | ||||
|             'targets' => [ | ||||
|                 [ | ||||
|                     'class' => 'yii\log\FileTarget', | ||||
|                     'levels' => ['error', 'warning'], | ||||
|                 ], | ||||
|             ], | ||||
|         ], | ||||
|         'db' => $db, | ||||
|         'urlManager' => [ | ||||
|             'scriptUrl' => '', | ||||
|             'hostInfo' => '' | ||||
|         ] | ||||
|     ], | ||||
|     'params' => $params, | ||||
|     /* | ||||
|     'controllerMap' => [ | ||||
|         'fixture' => [ // Fixture generation command line.
 | ||||
|             'class' => 'yii\faker\FixtureController', | ||||
|         ], | ||||
|     ], | ||||
|     */ | ||||
| ]; | ||||
| 
 | ||||
| if (YII_ENV_DEV) { | ||||
|     // configuration adjustments for 'dev' environment
 | ||||
|     $config['bootstrap'][] = 'gii'; | ||||
|     $config['modules']['gii'] = [ | ||||
|         'class' => 'yii\gii\Module', | ||||
|     ]; | ||||
| } | ||||
| 
 | ||||
| return $config; | ||||
							
								
								
									
										13
									
								
								config/params.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								config/params.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| <?php | ||||
| 
 | ||||
| return [ | ||||
|     'adminEmail' => 'firedemonru@gmail.com', | ||||
|     'user.remembermeduration' => 3600 * 24 * 30, | ||||
|     'files' => '/home/nomer.io/files', | ||||
|     'cost' => 98, | ||||
|     'user.passwordResetTokenExpire' => 3600, | ||||
|     'payModel' => true, | ||||
|     'storage' => 'http://storage.apinomer.com', | ||||
|     'storageUpload' => 'https://u158288:N46HNp0xUrzVCgSW@u158288.your-storagebox.de/apinomer/' | ||||
|     //'yandexMoney' => \app\components\ConfigHelper::getInstance()->getYandexMoney()
 | ||||
| ]; | ||||
							
								
								
									
										220
									
								
								config/web.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										220
									
								
								config/web.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,220 @@ | |||
| <?php | ||||
| 
 | ||||
| use app\components\AuthClientCollection; | ||||
| 
 | ||||
| $params = require(__DIR__ . '/params.php'); | ||||
| 
 | ||||
| $config = [ | ||||
|     'id' => $_SERVER["HTTP_HOST"], | ||||
|     'name' => preg_replace("/dev\-alexander\./", "", $_SERVER["HTTP_HOST"]), | ||||
|     'basePath' => dirname(__DIR__), | ||||
|     'charset' => 'utf-8', | ||||
|     'bootstrap' => ['log', 'queue'], | ||||
|     'language' => 'ru', | ||||
|     'sourceLanguage' => 'ru', | ||||
|     'timezone' => 'Europe/Moscow', | ||||
|     'modules' => [ | ||||
|         'admin' => [ | ||||
|             'class' => 'app\modules\admin\AdminModule', | ||||
|         ], | ||||
|         'api' => [ | ||||
|             'class' => 'app\modules\api\ApiModule', | ||||
|         ], | ||||
|     ], | ||||
|     'components' => [ | ||||
|         'queue' => [ | ||||
|             'class' => \zhuravljov\yii\queue\file\Queue::class, | ||||
|             'as log' => \zhuravljov\yii\queue\LogBehavior::class, | ||||
|             'path' => '@runtime/queue' | ||||
|             // Other driver options
 | ||||
|         ], | ||||
|         'reCaptcha' => [ | ||||
|             'name' => 'reCaptcha', | ||||
|             'class' => 'himiklab\yii2\recaptcha\ReCaptcha', | ||||
|             'siteKey' => '6LdpNCMUAAAAAIcP8mBuH3JhDl8zP2QADGoFtVYw', | ||||
|             'secret' => '6LdpNCMUAAAAABTYWw_Eaca7iGlbXaCWWe0fqqp7', | ||||
|         ], | ||||
|         'formatter' => [ | ||||
|             'class' => 'app\components\Formatter', | ||||
|             'numberFormatterOptions' => [ | ||||
|                 NumberFormatter::MIN_FRACTION_DIGITS => 0, | ||||
|                 NumberFormatter::MAX_FRACTION_DIGITS => 2, | ||||
|             ], | ||||
|             'defaultTimeZone' => 'Europe/Moscow', | ||||
|             'nullDisplay' => '' | ||||
|         ], | ||||
|         'devicedetect' => [ | ||||
|             'class' => 'alexandernst\devicedetect\DeviceDetect' | ||||
|         ], | ||||
|         'authClientCollection' => [ | ||||
|             'class' => AuthClientCollection::class, | ||||
|         ], | ||||
|         'assetManager' => [ | ||||
|             'appendTimestamp' => true, | ||||
|         ], | ||||
|         'request' => [ | ||||
|             // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
 | ||||
|             'cookieValidationKey' => 'HZ5DgjL?LqV~VcVq?EtdmrIWBsz{%WHl*ceiTJvV?*{PlEha|7b~6kv1bF~acxWG', | ||||
|         ], | ||||
|         'cache' => [ | ||||
|             'class' => 'yii\caching\MemCache', | ||||
|             'useMemcached' => true | ||||
|         ], | ||||
|         'mailer' => [ | ||||
|             'class' => 'yii\swiftmailer\Mailer', | ||||
|             'transport' => [ | ||||
|                 'class' => 'Swift_SmtpTransport', | ||||
|                 'host' => 'smtp.gmail.com', | ||||
|                 'username' => 'no-reply@nomer.io', | ||||
|                 'password' => 'cJqLmVysMr2C', | ||||
|                 'port' => 465, | ||||
|                 'encryption' => 'ssl', | ||||
|             ], | ||||
|         ], | ||||
|         'session' => [ | ||||
|             'cookieParams' => [ | ||||
|                 'domain' => $_SERVER["HTTP_HOST"], | ||||
|                 'httpOnly' => true, | ||||
|             ], | ||||
|         ], | ||||
|         'user' => [ | ||||
|             'identityClass' => 'app\models\User', | ||||
|             'enableAutoLogin' => true, | ||||
|         ], | ||||
|         'errorHandler' => [ | ||||
|             'errorAction' => 'site/error', | ||||
|         ], | ||||
|         'log' => [ | ||||
|             'traceLevel' => YII_DEBUG ? 3 : 0, | ||||
|             'targets' => [ | ||||
|                 [ | ||||
|                     'class' => 'yii\log\FileTarget', | ||||
|                     'levels' => ['error', 'warning'], | ||||
|                     'except' => ['yii\web\HttpException:404', 'yii\web\HttpException:400', 'yii\web\HttpException:403'] | ||||
|                 ], | ||||
|                 [ | ||||
|                     'enabled' => (YII_ENV != 'dev'?true:false), | ||||
|                     'class' => 'airani\log\TelegramTarget', | ||||
|                     'levels' => ['error'], | ||||
|                     'botToken' => '377062288:AAEs1S7OPwRym49su6624iITRzmPddr_A4E', // bot token secret key
 | ||||
|                     'chatId' => '-1001076571212', // chat id or channel username with @ like 12345 or @channel
 | ||||
|                     'except' => ['yii\web\HttpException:404', 'yii\web\HttpException:400', 'yii\web\HttpException:403'] | ||||
|                 ], | ||||
|             ], | ||||
|         ], | ||||
|         'db' => require(__DIR__ . '/db.php'), | ||||
|         'urlManager' => [ | ||||
|             'enablePrettyUrl' => true, | ||||
|             'showScriptName' => false, | ||||
|             //'cache' => false,
 | ||||
|             'rules' => [ | ||||
|                 'https://apinomer.com/contact'                                     => 'api/contact/index', | ||||
|                 'https://apinomer.com/status'                                      => 'api/buy/status', | ||||
|                 'https://apinomer.com/buy'                                      => 'api/buy/index', | ||||
|                 'https://apinomer.com/free'                                      => 'api/free/index', | ||||
| 
 | ||||
|                 'https://apinomer.com/ponomeru'                             => 'api/ponomeru/index', | ||||
| 
 | ||||
|                 'https://apinomer.com/check/<phone:\d+>'                             => 'api/check/index', | ||||
| 
 | ||||
| 
 | ||||
|                 'https://apinomer.com/results/<id:\d+>'                             => 'api/result/index', | ||||
|                 'https://apinomer.com/search/'                                       => 'api/search/index', | ||||
|                 'https://apinomer.com/telegram/<phone:\d+>'                          => 'api/telegram/index', | ||||
|                 'https://apinomer.com/plans/'                                        => 'api/plans/index', | ||||
|                 'https://apinomer.com/info/'                                         => 'api/info/index', | ||||
|                 'https://apinomer.com/search'                                       => 'api/search/index', | ||||
|                 'https://apinomer.com/plans'                                        => 'api/plans/index', | ||||
|                 'https://apinomer.com/info'                                         => 'api/info/index', | ||||
|                 'https://apinomer.com/call'                                         => 'api/call/index', | ||||
|                 'https://apinomer.com/notify/<token:>'                                         => 'api/notify/index', | ||||
|                 'https://apinomer.com/history'                                         => 'api/history/index', | ||||
| 
 | ||||
|                 'https://apinomer.com/exit'                                       => 'api/signin/exit', | ||||
|                 'https://apinomer.com/signin/gg'                                       => 'api/signin/google', | ||||
|                 'https://apinomer.com/signin/fb'                                       => 'api/signin/facebook', | ||||
|                 'https://apinomer.com/signin/vk'                                       => 'api/signin/vk', | ||||
|                 'https://apinomer.com/signin'                                       => 'api/signin/index', | ||||
|                 'https://apinomer.com/signup'                                       => 'api/signin/reg', | ||||
| 
 | ||||
|                 'https://apinomer.com/'                                       => 'site/api', | ||||
| 
 | ||||
|                 'https://tels.gg/c/<code:\w+>' => 'site/code', | ||||
|                 'https://tels.io/c/<code:\w+>' => 'site/code', | ||||
| 
 | ||||
|                 'https://wcaller.com' => 'wcaller/index', | ||||
|                 'https://wcaller.ru' => 'wcaller/index', | ||||
| 
 | ||||
| 
 | ||||
|                 'ios_coming_soon' => 'site/ios', | ||||
|                 'find-phone'                                    => 'site/find-phone', | ||||
|                 'signup'                                        => 'site/signup', | ||||
|                 'signin'                                        => 'site/signin', | ||||
|                 'remind'                                        => 'site/remind', | ||||
|                 'logout'                                        => 'site/logout', | ||||
|                 'auth'                                          => 'site/auth', | ||||
|                 'confirm'                                       => 'site/confirm', | ||||
|                 'contact'                                      => 'site/contacts', | ||||
|                 'remind/<token:>'                               => 'site/remind', | ||||
| 
 | ||||
|                 'ref<id:\d+>' => 'referrals/new', | ||||
| 
 | ||||
|                 'fp/<hash>.gif' => 'site/fingerprint', | ||||
|                 'ec/<hash>.gif' => 'site/evercookie', | ||||
| 
 | ||||
|                 'images/<uuid>.jpg' => 'site/image', | ||||
| 
 | ||||
|                 'retargeting/<uuid>.gif'                    => 'retargeting/pic', | ||||
|                 'get/<uuid>'                                => 'retargeting/redirect', | ||||
| 
 | ||||
|                 'http://z.fcheck.ru/<phone:8[\d]{10}>'                             => 'frame/index', | ||||
|                 'http://z.fcheck.ru/<phone:8[\d]{10}>/<action>/<id:\d+>'           => 'frame/<action>', | ||||
|                 'http://z.fcheck.ru/<phone:8[\d]{10}>/<action>'                    => 'frame/<action>', | ||||
| 
 | ||||
| 
 | ||||
|                 '<phone:8[\d]{10}>'                             => 'result/index', | ||||
|                 '<phone:8[\d]{10}>/<action>/<id:\d+>'           => 'result/<action>', | ||||
|                 '<phone:8[\d]{10}>/<action>'                    => 'result/<action>', | ||||
| 
 | ||||
|                 '<module:(admin)>'                                  => 'admin/dashboard/index', | ||||
|                 '<module:(admin)>/<controller:\w+>'                     => 'admin/<controller>/index', | ||||
|                 '<module:(admin)>/<controller:\w+>/<action>/<id:\d+>'   => 'admin/<controller>/<action>', | ||||
|                 '<module:(admin)>/<controller:\w+>/<action>'            => 'admin/<controller>/<action>', | ||||
| 
 | ||||
|                 '<controller:[A-Za-z]+>'                              => '<controller>/index', | ||||
|                 '<controller:[A-Za-z]+>/<action>/<id:\d+>'            => '<controller>/<action>', | ||||
|                 '<controller:[A-Za-z]+>/<action>'                     => '<controller>/<action>', | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|                 [ | ||||
|                     'pattern' => '<phone>', | ||||
|                     'route' => 'site/redirect', | ||||
|                     'mode' => \yii\web\UrlRule::PARSING_ONLY | ||||
|                 ], | ||||
|             ], | ||||
|         ], | ||||
|     ], | ||||
|     'params' => $params, | ||||
| ]; | ||||
| 
 | ||||
| if (YII_ENV_DEV && in_array($_SERVER["REMOTE_ADDR"], ['81.88.218.82', '82.204.203.174', '127.0.0.1'])) { | ||||
|     // configuration adjustments for 'dev' environment
 | ||||
|     //$config['bootstrap'][] = 'debug';
 | ||||
|     $config['modules']['debug'] = [ | ||||
|         'class' => 'yii\debug\Module', | ||||
|         // uncomment the following to add your IP if you are not connecting from localhost.
 | ||||
|         'allowedIPs' => ['81.88.218.82', '82.204.203.174', '127.0.0.1'], | ||||
|     ]; | ||||
| 
 | ||||
|     $config['bootstrap'][] = 'gii'; | ||||
|     $config['modules']['gii'] = [ | ||||
|         'class' => 'yii\gii\Module', | ||||
|         // uncomment the following to add your IP if you are not connecting from localhost.
 | ||||
|         //'allowedIPs' => ['127.0.0.1', '::1'],
 | ||||
|     ]; | ||||
| } | ||||
| 
 | ||||
| return $config; | ||||
| 
 | ||||
							
								
								
									
										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"); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										9
									
								
								env/alexander/config/db.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								env/alexander/config/db.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| <?php | ||||
| 
 | ||||
| return [ | ||||
|     'class' => 'yii\db\Connection', | ||||
|     'dsn' => 'pgsql:host=localhost;dbname=soc2phone', | ||||
|     'username' => 'soc2phone', | ||||
|     'password' => 'soc2phone', | ||||
|     'charset' => 'utf8', | ||||
| ]; | ||||
							
								
								
									
										11
									
								
								env/alexander/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								env/alexander/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| <?php | ||||
| // comment out the following two lines when deployed to production
 | ||||
| defined('YII_DEBUG') or define('YII_DEBUG', true); | ||||
| defined('YII_ENV') or define('YII_ENV', 'dev'); | ||||
| 
 | ||||
| require(__DIR__ . '/../vendor/autoload.php'); | ||||
| require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); | ||||
| 
 | ||||
| $config = require(__DIR__ . '/../config/web.php'); | ||||
| 
 | ||||
| (new yii\web\Application($config))->run(); | ||||
							
								
								
									
										50
									
								
								env/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								env/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,50 @@ | |||
| <?php | ||||
| /** | ||||
|  * The manifest of files that are local to specific environment. | ||||
|  * This file returns a list of environments that the application | ||||
|  * may be installed under. The returned data must be in the following | ||||
|  * format: | ||||
|  * | ||||
|  * ```php | ||||
|  * return [ | ||||
|  *     'environment name' => [ | ||||
|  *         'path' => 'directory storing the local files', | ||||
|  *         'writable' => [ | ||||
|  *             // list of directories that should be set writable
 | ||||
|  *         ], | ||||
|  *     ], | ||||
|  * ]; | ||||
|  * ``` | ||||
|  */ | ||||
| return [ | ||||
|     'alexander' => [ | ||||
|         'path' => 'alexander', | ||||
|         'writable' => [ | ||||
|             'runtime', | ||||
|             'assets', | ||||
|         ], | ||||
|         'executable' => [ | ||||
|             'yii', | ||||
|         ], | ||||
|     ], | ||||
|     'vladimir' => [ | ||||
|         'path' => 'vladimir', | ||||
|         'writable' => [ | ||||
|             'runtime', | ||||
|             'assets', | ||||
|         ], | ||||
|         'executable' => [ | ||||
|             'yii', | ||||
|         ], | ||||
|     ], | ||||
|     'production' => [ | ||||
|         'path' => 'production', | ||||
|         'writable' => [ | ||||
|             'runtime', | ||||
|             'assets', | ||||
|         ], | ||||
|         'executable' => [ | ||||
|             'yii', | ||||
|         ], | ||||
|     ], | ||||
| ]; | ||||
							
								
								
									
										9
									
								
								env/production/config/db.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								env/production/config/db.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| <?php | ||||
| 
 | ||||
| return [ | ||||
|     'class' => 'yii\db\Connection', | ||||
|     'dsn' => 'pgsql:host=localhost;dbname=soc2phone', | ||||
|     'username' => 'soc2phone', | ||||
|     'password' => 'soc2phone', | ||||
|     'charset' => 'utf8', | ||||
| ]; | ||||
							
								
								
									
										11
									
								
								env/production/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								env/production/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| <?php | ||||
| // comment out the following two lines when deployed to production
 | ||||
| defined('YII_DEBUG') or define('YII_DEBUG', false); | ||||
| defined('YII_ENV') or define('YII_ENV', 'production'); | ||||
| 
 | ||||
| require(__DIR__ . '/../vendor/autoload.php'); | ||||
| require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); | ||||
| 
 | ||||
| $config = require(__DIR__ . '/../config/web.php'); | ||||
| 
 | ||||
| (new yii\web\Application($config))->run(); | ||||
							
								
								
									
										9
									
								
								env/vladimir/config/db.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								env/vladimir/config/db.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| <?php | ||||
| 
 | ||||
| return [ | ||||
|     'class' => 'yii\db\Connection', | ||||
|     'dsn' => 'pgsql:host=localhost;dbname=soc2phone', | ||||
|     'username' => 'soc2phone', | ||||
|     'password' => 'soc2phone', | ||||
|     'charset' => 'utf8', | ||||
| ]; | ||||
							
								
								
									
										11
									
								
								env/vladimir/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								env/vladimir/index.php
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| <?php | ||||
| // comment out the following two lines when deployed to production
 | ||||
| defined('YII_DEBUG') or define('YII_DEBUG', true); | ||||
| defined('YII_ENV') or define('YII_ENV', 'dev'); | ||||
| 
 | ||||
| require(__DIR__ . '/../vendor/autoload.php'); | ||||
| require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); | ||||
| 
 | ||||
| $config = require(__DIR__ . '/../config/web.php'); | ||||
| 
 | ||||
| (new yii\web\Application($config))->run(); | ||||
							
								
								
									
										177
									
								
								init
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										177
									
								
								init
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,177 @@ | |||
| #!/usr/bin/env php | ||||
| <?php | ||||
| /** | ||||
|  * Yii Application Initialization Tool | ||||
|  * | ||||
|  * In order to run in non-interactive mode: | ||||
|  * | ||||
|  * init --env=Development --overwrite=n | ||||
|  * | ||||
|  * @author Alexander Makarov <sam@rmcreative.ru> | ||||
|  * | ||||
|  * @link http://www.yiiframework.com/ | ||||
|  * @copyright Copyright (c) 2008 Yii Software LLC | ||||
|  * @license http://www.yiiframework.com/license/ | ||||
|  */ | ||||
| 
 | ||||
| $params = getParams(); | ||||
| $root = str_replace('\\', '/', __DIR__); | ||||
| $envs = require("$root/env/index.php"); | ||||
| $envNames = array_keys($envs); | ||||
| 
 | ||||
| echo "Yii Application Initialization Tool v1.0\n\n"; | ||||
| 
 | ||||
| $envName = null; | ||||
| if (empty($params['env']) || $params['env'] === '1') { | ||||
| 	echo "Which environment do you want the application to be initialized in?\n\n"; | ||||
| 	foreach ($envNames as $i => $name) { | ||||
| 		echo "  [$i] $name\n"; | ||||
| 	} | ||||
| 	echo "\n  Your choice [0-" . (count($envs) - 1) . ', or "q" to quit] '; | ||||
| 	$answer = trim(fgets(STDIN)); | ||||
| 
 | ||||
| 	if (!ctype_digit($answer) || !in_array($answer, range(0, count($envs) - 1))) { | ||||
| 		echo "\n  Quit initialization.\n"; | ||||
| 		exit(0); | ||||
| 	} | ||||
| 
 | ||||
| 	if (isset($envNames[$answer])) { | ||||
| 		$envName = $envNames[$answer]; | ||||
| 	} | ||||
| } else { | ||||
| 	$envName = $params['env']; | ||||
| } | ||||
| 
 | ||||
| if (!in_array($envName, $envNames)) { | ||||
| 	$envsList = implode(', ', $envNames); | ||||
| 	echo "\n  $envName is not a valid environment. Try one of the following: $envsList. \n"; | ||||
| 	exit(2); | ||||
| } | ||||
| 
 | ||||
| $env = $envs[$envName]; | ||||
| 
 | ||||
| if (empty($params['env'])) { | ||||
| 	echo "\n  Initialize the application under '{$envNames[$answer]}' environment? [yes|no] "; | ||||
| 	$answer = trim(fgets(STDIN)); | ||||
| 	if (strncasecmp($answer, 'y', 1)) { | ||||
| 		echo "\n  Quit initialization.\n"; | ||||
| 		exit(0); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| echo "\n  Start initialization ...\n\n"; | ||||
| $files = getFileList("$root/env/{$env['path']}"); | ||||
| $all = false; | ||||
| foreach ($files as $file) { | ||||
|     //echo $file."\n"; | ||||
|     if($file == 'index.php') continue; | ||||
| 	if (!copyFile($root, "env/{$env['path']}/$file", $file, $all, $params)) { | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| if(file_exists("$root/env/{$env['path']}/index.php")) { | ||||
|     if (!copyFile($root, "env/{$env['path']}/index.php", "web/index.php", $all, $params)) { | ||||
|         echo "error copy index.php\n"; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| if (isset($env['writable'])) { | ||||
| 	foreach ($env['writable'] as $writable) { | ||||
| 		echo "      chmod 0777 $writable\n"; | ||||
| 		@chmod("$root/$writable", 0777); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| if (isset($env['executable'])) { | ||||
| 	foreach ($env['executable'] as $executable) { | ||||
| 		echo "      chmod 0755 $executable\n"; | ||||
| 		@chmod("$root/$executable", 0755); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| echo "\n  ... initialization completed.\n\n"; | ||||
| 
 | ||||
| function getFileList($root, $basePath = '') | ||||
| { | ||||
| 	$files = []; | ||||
| 	$handle = opendir($root); | ||||
| 	while (($path = readdir($handle)) !== false) { | ||||
| 		if ($path === '.svn' || $path === '.' || $path === '..') { | ||||
| 			continue; | ||||
| 		} | ||||
| 		$fullPath = "$root/$path"; | ||||
| 		$relativePath = $basePath === '' ? $path : "$basePath/$path"; | ||||
| 		if (is_dir($fullPath)) { | ||||
| 			$files = array_merge($files, getFileList($fullPath, $relativePath)); | ||||
| 		} else { | ||||
| 			$files[] = $relativePath; | ||||
| 		} | ||||
| 	} | ||||
| 	closedir($handle); | ||||
| 	return $files; | ||||
| } | ||||
| 
 | ||||
| function copyFile($root, $source, $target, &$all, $params) | ||||
| { | ||||
| 	if (!is_file($root . '/' . $source)) { | ||||
| 		echo "       skip $target ($source not exist)\n"; | ||||
| 		return true; | ||||
| 	} | ||||
| 	if (is_file($root . '/' . $target)) { | ||||
| 		if (file_get_contents($root . '/' . $source) === file_get_contents($root . '/' . $target)) { | ||||
| 			echo "  unchanged $target\n"; | ||||
| 			return true; | ||||
| 		} | ||||
| 		if ($all) { | ||||
| 			echo "  overwrite $target\n"; | ||||
| 		} else { | ||||
| 			echo "      exist $target\n"; | ||||
| 			echo "            ...overwrite? [Yes|No|All|Quit] "; | ||||
| 
 | ||||
| 
 | ||||
| 			$answer = !empty($params['overwrite']) ? $params['overwrite'] : trim(fgets(STDIN)); | ||||
| 			if (!strncasecmp($answer, 'q', 1)) { | ||||
| 				return false; | ||||
| 			} else { | ||||
| 				if (!strncasecmp($answer, 'y', 1)) { | ||||
| 					echo "  overwrite $target\n"; | ||||
| 				} else { | ||||
| 					if (!strncasecmp($answer, 'a', 1)) { | ||||
| 						echo "  overwrite $target\n"; | ||||
| 						$all = true; | ||||
| 					} else { | ||||
| 						echo "       skip $target\n"; | ||||
| 						return true; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); | ||||
| 		return true; | ||||
| 	} | ||||
| 	echo "   generate $target\n"; | ||||
| 	@mkdir(dirname($root . '/' . $target), 0777, true); | ||||
| 	file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| function getParams() | ||||
| { | ||||
| 	$rawParams = []; | ||||
| 	if (isset($_SERVER['argv'])) { | ||||
| 		$rawParams = $_SERVER['argv']; | ||||
| 		array_shift($rawParams); | ||||
| 	} | ||||
| 
 | ||||
| 	$params = []; | ||||
| 	foreach ($rawParams as $param) { | ||||
| 		if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) { | ||||
| 			$name = $matches[1]; | ||||
| 			$params[$name] = isset($matches[3]) ? $matches[3] : true; | ||||
| 		} else { | ||||
| 			$params[] = $param; | ||||
| 		} | ||||
| 	} | ||||
| 	return $params; | ||||
| } | ||||
							
								
								
									
										22
									
								
								mail/layouts/html.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								mail/layouts/html.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| <?php | ||||
| use yii\helpers\Html; | ||||
| 
 | ||||
| /* @var $this \yii\web\View view component instance */ | ||||
| /* @var $message \yii\mail\MessageInterface the message being composed */ | ||||
| /* @var $content string main view render result */ | ||||
| ?>
 | ||||
| <?php $this->beginPage() ?>
 | ||||
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||||
| <html xmlns="http://www.w3.org/1999/xhtml"> | ||||
| <head> | ||||
|     <meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" /> | ||||
|     <title><?= Html::encode($this->title) ?></title>
 | ||||
|     <?php $this->head() ?>
 | ||||
| </head> | ||||
| <body offset="0" class="body" style="padding:0; margin:0; display:block; background:#f7f7f7; -webkit-text-size-adjust:none" bgcolor="#f7f7f7"> | ||||
|     <?php $this->beginBody() ?>
 | ||||
|     <?= $content ?>
 | ||||
|     <?php $this->endBody() ?>
 | ||||
| </body> | ||||
| </html> | ||||
| <?php $this->endPage() ?>
 | ||||
							
								
								
									
										176
									
								
								mail/retarget.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								mail/retarget.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,176 @@ | |||
| <?php | ||||
| /* @var $this \yii\web\View */ | ||||
| 
 | ||||
| use yii\helpers\Html; | ||||
| 
 | ||||
| /* @var $site string */ | ||||
| /* @var $phone string */ | ||||
| $css = <<<CSS | ||||
|         img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic;} | ||||
|         a img { border: none; } | ||||
|         table { border-collapse: collapse !important; } | ||||
|         #outlook a { padding:0; }
 | ||||
|         .ReadMsgBody { width: 100%; } | ||||
|         .ExternalClass {width:100%;} | ||||
|         .backgroundTable {margin:0 auto; padding:0; width:100% !important;} | ||||
|         table td {border-collapse: collapse;} | ||||
|         .ExternalClass * {line-height: 115%;} | ||||
| 
 | ||||
|         /* General styling */ | ||||
|         td { | ||||
|             font-family: Arial, sans-serif; | ||||
|         } | ||||
|         body { | ||||
|             -webkit-font-smoothing:antialiased; | ||||
|             -webkit-text-size-adjust:none; | ||||
|             width: 100%; | ||||
|             height: 100%; | ||||
|             color: #6f6f6f;
 | ||||
|             font-weight: 400; | ||||
|             font-size: 18px; | ||||
|         } | ||||
|         h1 { | ||||
|             margin: 10px 0; | ||||
|         } | ||||
|         a { | ||||
|             color: #333333;
 | ||||
|             text-decoration: none; | ||||
|         } | ||||
|         .body-padding { | ||||
|             padding: 0 75px; | ||||
|         } | ||||
|         .force-full-width { | ||||
|             width: 100% !important; | ||||
|         } | ||||
| 
 | ||||
|         /* Mobile styles */ | ||||
|         @media only screen and (max-width: 1039px) { | ||||
|             table[class*="w1300"] { | ||||
|                 width: 600px !important; | ||||
|                 font-size: 24px !important; | ||||
|             } | ||||
|             td[class*="w1300"] { | ||||
|                 width: 560px !important; | ||||
|                 padding-left: 15px !important; | ||||
|                 padding-right: 15px !important; | ||||
|             } | ||||
|             td[class*="mobile-center"] { | ||||
|                 text-align: center !important; | ||||
|             } | ||||
|             td[class*="column-padding"] { | ||||
|                 padding: 20px 0px !important; | ||||
|             } | ||||
|             td[class*="bottom-padding"] { | ||||
|                 padding-bottom: 40px !important; | ||||
|             } | ||||
|             td[class*="top-padding"] { | ||||
|                 padding-top: 40px !important; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /* Mobile styles */ | ||||
|         @media only screen and (max-width: 599px) { | ||||
|             table[class*="w320"] { | ||||
|                 width: 320px !important; | ||||
|                 font-size: 18px !important; | ||||
|             } | ||||
|             td[class*="w320"] { | ||||
|                 width: 280px !important; | ||||
|                 padding-left: 15px !important; | ||||
|                 padding-right: 15px !important; | ||||
|             } | ||||
|             td[class*="mobile-spacing"] { | ||||
|                 padding-top: 10px !important; | ||||
|                 padding-bottom: 10px !important; | ||||
|             } | ||||
|             *[class*="mobile-hide"] { | ||||
|                 display: none !important; | ||||
|                 width: 0 !important; | ||||
|             } | ||||
|             *[class*="mobile-br"] { | ||||
|                 font-size: 12px !important; | ||||
|             } | ||||
|             td[class*="mobile-center"] { | ||||
|                 text-align: center !important; | ||||
|             } | ||||
|             table[class*="columns"] { | ||||
|                 width: 100% !important; | ||||
|             } | ||||
|             td[class*="column-padding"] { | ||||
|                 padding: 10px 0px !important; | ||||
|             } | ||||
|             td[class*="bottom-padding"] { | ||||
|                 padding-bottom: 30px !important; | ||||
|             } | ||||
|             td[class*="top-padding"] { | ||||
|                 padding-top: 30px !important; | ||||
|             } | ||||
|             td[class*="logo-block"] img { | ||||
| 				width: 180px !important; | ||||
| 				height: 180px !important; | ||||
|             } | ||||
|         } | ||||
| CSS; | ||||
| $this->registerCss($css); | ||||
| ?>
 | ||||
| 
 | ||||
| <table align="center" cellpadding="0" cellspacing="0" width="100%" height="100%"> | ||||
|     <tr> | ||||
|         <td align="center" valign="top" background="#f7f7f7" style="background-color: #f7f7f7;" width="100%"> | ||||
|             <!-- HEADER --> | ||||
|             <table align="center" cellpadding="0" cellspacing="0" width="100%" height="100%"> | ||||
|                 <tr> | ||||
|                     <td align="center" valign="top" width="100%"> | ||||
|                         <center> | ||||
|                             <table cellspacing="0" cellpadding="0" width="100%" class="w320 w1300" style="width: 100%; font-family: Arial, sans-serif; font-size: 2em; max-width: 1040px; padding-left: 10px; padding-right: 10px;"> | ||||
|                                 <tr> | ||||
|                                     <td align="center" valign="top" class="column-padding top-padding logo-block" style="text-align: center; padding-top: 100px; padding-bottom: 90px;"> | ||||
|                                         <a href="https://ktoti.me/" target="_blank"><img src="<?= $message->embed($logo); ?>" alt="logo" width="260px" height="260px"></a> | ||||
|                                     </td> | ||||
|                                 </tr> | ||||
|                                 <tr> | ||||
|                                     <td align="center" valign="top" class="column-padding" style="text-align: center; padding-top: 0px; padding-bottom: 45px; color: #333333; line-height: 1;"> | ||||
|                                         Вы на нашем сайте <a href="https://ktoti.me/" target="_blank" style="color: #f7a916; font-weight: bold;">nomer.io</a> как-то давно искали информацию по номеру: | ||||
|                                     </td> | ||||
|                                 </tr> | ||||
|                                 <tr> | ||||
|                                     <td align="center" valign="top" class="column-padding" style="text-align: center; padding-top: 0px; padding-bottom: 0px; font-weight: bold; text-decoration: underline; color: #333333; line-height: 1;"> | ||||
|                                         <a href="tel:<?=$phone;?>"><?=$phone;?></a>
 | ||||
|                                     </td> | ||||
|                                 </tr> | ||||
|                                 <tr> | ||||
|                                     <td align="center" valign="top" class="column-padding bottom-padding" style="text-align: center; padding-top: 45px; padding-bottom: 65px; color: #333333; line-height: 1; border-bottom: 3px solid #b3b3b3;"> | ||||
|                                         но так как не заплатили нам, то мы не показали результат. | ||||
|                                     </td> | ||||
|                                 </tr> | ||||
|                             </table> | ||||
|                         </center> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|             <!-- END HEADER --> | ||||
| 
 | ||||
|             <!-- FOOTER --> | ||||
|             <table align="center" cellpadding="0" cellspacing="0" width="100%" height="100%"> | ||||
|                 <tr> | ||||
|                     <td align="center" valign="top" width="100%"> | ||||
|                         <center> | ||||
|                             <table cellspacing="0" cellpadding="0" width="100%" class="w320 w1300" style="width: 100%; max-width: 1040px; padding-left: 10px; padding-right: 10px; font-family: Arial, sans-serif; font-size: 2em;"> | ||||
|                                 <tr> | ||||
|                                     <td align="center" valign="top" class="column-padding top-padding" style="text-align: center; padding-top: 45px; padding-bottom: 100px; color: #333333; line-height: 1;"> | ||||
|                                         Сейчас мы всё же решили показать вам, на что мы способны совершенно бесплатно и вы можете ознакомиться со всей добытой нами информацией по этому номеру ниже в скриншоте: | ||||
|                                     </td> | ||||
|                                 </tr> | ||||
|                                 <tr> | ||||
|                                     <td align="center" valign="top" class="column-padding" style="padding-top: 0px; padding-bottom: 100px; box-sizing: border-box;"> | ||||
|                                         <img src="<?= $message->embed($screenshot); ?>" alt="img" width="100%" style="border-radius: 10px; border: 2px solid #f7a916; max-width: 100%; width: 100%; box-sizing: border-box;"> | ||||
|                                     </td> | ||||
|                                 </tr> | ||||
|                             </table> | ||||
|                         </center> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|             <!-- END FOOTER --> | ||||
|         </td> | ||||
|     </tr> | ||||
							
								
								
									
										39
									
								
								migrations/M161119140200Queue.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								migrations/M161119140200Queue.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| <?php | ||||
| /** | ||||
|  * @link https://github.com/zhuravljov/yii2-queue | ||||
|  * @copyright Copyright (c) 2017 Roman Zhuravlev | ||||
|  * @license http://opensource.org/licenses/BSD-3-Clause | ||||
|  */ | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Example of migration for queue message storage | ||||
|  * | ||||
|  * @author Roman Zhuravlev <zhuravljov@gmail.com> | ||||
|  */ | ||||
| class M161119140200Queue extends Migration | ||||
| { | ||||
|     public $tableName = '{{%queue}}'; | ||||
|     public $tableOptions; | ||||
| 
 | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable($this->tableName, [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'channel' => $this->string()->notNull(), | ||||
|             'job' => $this->binary()->notNull(), | ||||
|             'created_at' => $this->integer()->notNull(), | ||||
|             'started_at' => $this->integer(), | ||||
|             'finished_at' => $this->integer(), | ||||
|         ], $this->tableOptions); | ||||
| 
 | ||||
|         $this->createIndex('channel', $this->tableName, 'channel'); | ||||
|         $this->createIndex('started_at', $this->tableName, 'started_at'); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable($this->tableName); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										28
									
								
								migrations/M170307170300Later.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								migrations/M170307170300Later.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| <?php | ||||
| /** | ||||
|  * @link https://github.com/zhuravljov/yii2-queue | ||||
|  * @copyright Copyright (c) 2017 Roman Zhuravlev | ||||
|  * @license http://opensource.org/licenses/BSD-3-Clause | ||||
|  */ | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Example of migration for queue message storage | ||||
|  * | ||||
|  * @author Roman Zhuravlev <zhuravljov@gmail.com> | ||||
|  */ | ||||
| class M170307170300Later extends Migration | ||||
| { | ||||
|     public $tableName = '{{%queue}}'; | ||||
| 
 | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn($this->tableName, 'timeout', $this->integer()->defaultValue(0)->notNull()->after('created_at')); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn($this->tableName, 'timeout'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										37
									
								
								migrations/m170210_085747_create_users_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								migrations/m170210_085747_create_users_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `users`. | ||||
|  */ | ||||
| class m170210_085747_create_users_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('users', [ | ||||
|             'id'            => $this->primaryKey(), | ||||
|             'email'         => $this->string(), | ||||
|             'password'      => $this->string(), | ||||
|             'nick'          => $this->string(), | ||||
|             'phone'         => $this->string(), | ||||
|             'code'          => $this->string(), | ||||
|             'auth_key'      => $this->string(), | ||||
|             'balance'       => $this->decimal(24, 4)->defaultValue(0), | ||||
|             'tm_create'     => $this->dateTime(), | ||||
|             'tm_update'     => $this->dateTime(), | ||||
|             'tm_last_auth'  => $this->dateTime() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('users'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										33
									
								
								migrations/m170210_085806_create_requests_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								migrations/m170210_085806_create_requests_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `requests`. | ||||
|  */ | ||||
| class m170210_085806_create_requests_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('requests', [ | ||||
|             'id'        => $this->primaryKey(), | ||||
|             'user_id'   => $this->integer(), | ||||
|             'phone'     => $this->string(), | ||||
|             'ip'        => $this->string(), | ||||
|             'ua'        => $this->string(), | ||||
|             'result'    => $this->text(), | ||||
|             'tm'        => $this->timestamp() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('requests'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										32
									
								
								migrations/m170210_113137_create_facebook_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								migrations/m170210_113137_create_facebook_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `facebook`. | ||||
|  */ | ||||
| class m170210_113137_create_facebook_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('facebook', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'tm' => $this->dateTime(), | ||||
|             'phone' => $this->string(), | ||||
|             'fb_id' => $this->string(), | ||||
|             'name' => $this->string(), | ||||
|             'photo' => $this->text() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('facebook'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										30
									
								
								migrations/m170213_115912_create_auth_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								migrations/m170213_115912_create_auth_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `auth`. | ||||
|  */ | ||||
| class m170213_115912_create_auth_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('auth', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'user_id' => $this->integer(), | ||||
|             'source' => $this->string(), | ||||
|             'source_id' => $this->string() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('auth'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										33
									
								
								migrations/m170214_121454_create_payments_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								migrations/m170214_121454_create_payments_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `payments`. | ||||
|  */ | ||||
| class m170214_121454_create_payments_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('payments', [ | ||||
|             'id'                => $this->primaryKey(), | ||||
|             'sum'               => $this->decimal(24, 4), | ||||
|             'amount'            => $this->decimal(24, 4), | ||||
|             'user_id'           => $this->integer(), | ||||
|             'tm'                => $this->timestamp(), | ||||
|             'operation_id'      => $this->string(), | ||||
|             'operation_label'   => $this->string() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('payments'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										34
									
								
								migrations/m170221_152736_create_cache_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								migrations/m170221_152736_create_cache_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `cache`. | ||||
|  */ | ||||
| class m170221_152736_create_cache_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('cache', [ | ||||
|             'id'        => $this->primaryKey(), | ||||
|             'phone'     => $this->string(), | ||||
|             'data'      => $this->text(), | ||||
|             'type_id'   => $this->smallInteger(2) | ||||
|         ]); | ||||
| 
 | ||||
|         $this->createIndex('idx_cache_phone', 'cache', 'phone'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropIndex('idx_cache_phone', 'cache'); | ||||
| 
 | ||||
|         $this->dropTable('cache'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170301_071147_add_tm_field_to_cache.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170301_071147_add_tm_field_to_cache.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170301_071147_add_tm_field_to_cache extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("cache", "tm", $this->timestamp()->defaultExpression('NOW()')); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("cache", "tm"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170301_110603_add_is_admin_field.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170301_110603_add_is_admin_field.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170301_110603_add_is_admin_field extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("users", "is_admin", $this->boolean()->defaultValue(false)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("users", "is_admin"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										33
									
								
								migrations/m170301_110655_create_block_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								migrations/m170301_110655_create_block_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `block`. | ||||
|  */ | ||||
| class m170301_110655_create_block_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('block', [ | ||||
|             'id'        => $this->primaryKey(), | ||||
|             'phone'     => $this->string(), | ||||
|             'ip'        => $this->string(), | ||||
|             'ua'        => $this->string(), | ||||
|             'tm'        => $this->timestamp(), | ||||
|             'code'      => $this->string(4), | ||||
|             'status'    => $this->smallInteger(1)->defaultValue(0) | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('block'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170307_084049_create_urls_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170307_084049_create_urls_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `urls`. | ||||
|  */ | ||||
| class m170307_084049_create_urls_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('urls', [ | ||||
|             'id'    => $this->primaryKey(), | ||||
|             'url'   => $this->string(), | ||||
|             'type'  => $this->smallInteger(2) | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('urls'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170307_123524_create_settings_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170307_123524_create_settings_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `settings`. | ||||
|  */ | ||||
| class m170307_123524_create_settings_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('settings', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'param' => $this->string(), | ||||
|             'value' => $this->string() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('settings'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										32
									
								
								migrations/m170309_080524_create_request_results_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								migrations/m170309_080524_create_request_results_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `request_results`. | ||||
|  */ | ||||
| class m170309_080524_create_request_results_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('request_results', [ | ||||
|             'id'            => $this->bigPrimaryKey(), | ||||
|             'request_id'    => $this->bigInteger(), | ||||
|             'type_id'       => $this->smallInteger(2), | ||||
|             'index'         => $this->smallInteger(2), | ||||
|             'data'          => $this->text(), | ||||
|             'cache_id'      => $this->bigInteger()->defaultValue(null) | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('request_results'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170309_130045_add_refresh_to_requests.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170309_130045_add_refresh_to_requests.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170309_130045_add_refresh_to_requests extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn(\app\models\SearchRequest::tableName(), "refresh", $this->boolean()->defaultValue(false)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn(\app\models\SearchRequest::tableName(), "refresh"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170310_122737_add_is_vip_to_users.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170310_122737_add_is_vip_to_users.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use app\models\User; | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170310_122737_add_is_vip_to_users extends Migration | ||||
| { | ||||
| 
 | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn(User::tableName(), "is_vip", $this->boolean()->defaultValue(false)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn(User::tableName(), "is_vip"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170313_101638_create_files_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170313_101638_create_files_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `files`. | ||||
|  */ | ||||
| class m170313_101638_create_files_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('files', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'uuid' => $this->string(), | ||||
|             'type' => $this->string(16) | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('files'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										31
									
								
								migrations/m170323_114223_create_user_fingerprints_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								migrations/m170323_114223_create_user_fingerprints_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `user_fingerprints`. | ||||
|  */ | ||||
| class m170323_114223_create_user_fingerprints_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('user_fingerprints', [ | ||||
|             'id'        => $this->primaryKey(), | ||||
|             'user_id'   => $this->bigInteger(), | ||||
|             'ip'        => $this->string(), | ||||
|             'hash'      => $this->string(), | ||||
|             'tm'        => $this->timestamp() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('user_fingerprints'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										30
									
								
								migrations/m170323_114243_create_user_ips_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								migrations/m170323_114243_create_user_ips_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `user_ips`. | ||||
|  */ | ||||
| class m170323_114243_create_user_ips_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('user_ips', [ | ||||
|             'id'        => $this->primaryKey(), | ||||
|             'user_id'   => $this->bigInteger(), | ||||
|             'ip'        => $this->string(), | ||||
|             'tm'        => $this->timestamp() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('user_ips'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										31
									
								
								migrations/m170323_115442_create_user_evercookies_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								migrations/m170323_115442_create_user_evercookies_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `user_evercookies`. | ||||
|  */ | ||||
| class m170323_115442_create_user_evercookies_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('user_evercookies', [ | ||||
|             'id'        => $this->primaryKey(), | ||||
|             'user_id'   => $this->bigInteger(), | ||||
|             'ip'        => $this->string(), | ||||
|             'data'      => $this->string(), | ||||
|             'tm'        => $this->timestamp() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('user_evercookies'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										31
									
								
								migrations/m170323_142901_add_user_fields.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								migrations/m170323_142901_add_user_fields.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170323_142901_add_user_fields extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("users", "is_test", $this->boolean()->defaultValue(false)); | ||||
|         $this->addColumn("users", "checks", $this->integer()->defaultValue(0)); | ||||
|         $this->addColumn("users", "plan", $this->smallInteger()->defaultValue(0)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("users", "plan"); | ||||
|         $this->dropColumn("users", "checks"); | ||||
|         $this->dropColumn("users", "is_test"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										28
									
								
								migrations/m170324_084758_add_source_id_to_requests.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								migrations/m170324_084758_add_source_id_to_requests.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| use app\models\SearchRequest; | ||||
| 
 | ||||
| class m170324_084758_add_source_id_to_requests extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn(SearchRequest::tableName(), 'source_id', $this->smallInteger()); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn(SearchRequest::tableName(), 'source_id'); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										49
									
								
								migrations/m170327_094510_create_plans_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								migrations/m170327_094510_create_plans_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,49 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `plans`. | ||||
|  */ | ||||
| class m170327_094510_create_plans_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('plans', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'cost'  => $this->integer(), | ||||
|             'count' => $this->integer(), | ||||
|             'title' => $this->string(), | ||||
|             'status' => $this->boolean()->defaultValue(true) | ||||
|         ]); | ||||
| 
 | ||||
|         $this->insert("plans", [ | ||||
|             "cost"  => 40, | ||||
|             "count" => 30, | ||||
|             "title" => "Предоплаченный-30" | ||||
|         ]); | ||||
| 
 | ||||
|         $this->insert("plans", [ | ||||
|             "cost"  => 30, | ||||
|             "count" => 50, | ||||
|             "title" => "Предоплаченный-50" | ||||
|         ]); | ||||
| 
 | ||||
|         $this->insert("plans", [ | ||||
|             "cost"  => 25, | ||||
|             "count" => 100, | ||||
|             "title" => "Предоплаченный-100" | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('plans'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170327_115426_add_status_to_user.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170327_115426_add_status_to_user.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170327_115426_add_status_to_user extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("users", "status", $this->smallInteger()->defaultValue(1)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("users", "status"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										36
									
								
								migrations/m170328_142237_create_vk_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								migrations/m170328_142237_create_vk_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `vk`. | ||||
|  */ | ||||
| class m170328_142237_create_vk_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('vk', [ | ||||
|             'id' => $this->primaryKey(), | ||||
| 		    'www' => $this->string(), | ||||
|             'skype' => $this->string(), | ||||
|             'instagram' => $this->string(), | ||||
|             'twitter' => $this->string(), | ||||
|             'facebook' => $this->string(), | ||||
|             'phone1' => $this->string(), | ||||
|             'phone2' => $this->string(), | ||||
|             'phone3' => $this->string(), | ||||
|             'phone4' => $this->string(), | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('vk'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170329_083421_create_indexes.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170329_083421_create_indexes.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170329_083421_create_indexes extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         echo "m170329_083421_create_indexes cannot be reverted.\n"; | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										32
									
								
								migrations/m170330_092131_add_indexes.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								migrations/m170330_092131_add_indexes.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170330_092131_add_indexes extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createIndex("idx_vk_phone1", "vk", "phone1"); | ||||
|         $this->createIndex("idx_vk_phone2", "vk", "phone2"); | ||||
| 
 | ||||
|         $this->createIndex("idx_requests", "requests", ["user_id", "phone"]); | ||||
|         $this->createIndex("idx_request_results_id", "request_results", "request_id"); | ||||
|         $this->createIndex("idx_cache", "cache", ["phone", "type_id"]); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         //$this->dropIndex("idx_cache", "cache");
 | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										34
									
								
								migrations/m170330_104926_crate_user_contacts_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								migrations/m170330_104926_crate_user_contacts_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170330_104926_crate_user_contacts_table extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('user_contacts', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'user_id' => $this->integer(), | ||||
|             'name' => $this->string(), | ||||
|             'phone' => $this->string(), | ||||
|             'tm' => $this->timestamp(), | ||||
|             'last_check' => $this->timestamp()->defaultValue(null) | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('user_contacts'); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170403_071249_add_password_reset_token.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170403_071249_add_password_reset_token.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170403_071249_add_password_reset_token extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("users", "password_reset_token", $this->string()); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         echo "m170403_071249_add_password_reset_token cannot be reverted.\n"; | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170404_123244_add_user_ip.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170404_123244_add_user_ip.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170404_123244_add_user_ip extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("users", "ip", $this->string()); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("users", "ip"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										30
									
								
								migrations/m170405_122703_create_tests_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								migrations/m170405_122703_create_tests_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `tests`. | ||||
|  */ | ||||
| class m170405_122703_create_tests_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('tests', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'user_id' => $this->integer(), | ||||
|             'tm' => $this->dateTime(), | ||||
|             'ip' => $this->string() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('tests'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170405_142656_add_ban_column.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170405_142656_add_ban_column.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170405_142656_add_ban_column extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("users", "ban", $this->smallInteger()->defaultValue(0)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("users", "ban"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										33
									
								
								migrations/m170412_083035_create_user_settings_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								migrations/m170412_083035_create_user_settings_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `user_settings`. | ||||
|  */ | ||||
| class m170412_083035_create_user_settings_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('user_settings', [ | ||||
|             'id' => $this->primaryKey(), | ||||
|             'user_id' => $this->integer(), | ||||
|             'param' => $this->string(), | ||||
|             'value' => $this->string() | ||||
|         ]); | ||||
| 
 | ||||
|         $this->createIndex("idx_user_settings_user_id", "user_settings", "user_id"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropIndex("idx_user_settings_user_id", "user_settings"); | ||||
|         $this->dropTable('user_settings'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170413_142306_add_payed_field.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170413_142306_add_payed_field.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170413_142306_add_payed_field extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("requests", "is_payed", $this->smallInteger()->defaultValue(0)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("requests", "is_payed"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170414_122946_add_result_index.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170414_122946_add_result_index.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170414_122946_add_result_index extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createIndex("idx_request_result_request_id", "request_results", "request_id"); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         echo "m170414_122946_add_result_index cannot be reverted.\n"; | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										28
									
								
								migrations/m170417_135938_create_vk_phones_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								migrations/m170417_135938_create_vk_phones_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `vk_phones`. | ||||
|  */ | ||||
| class m170417_135938_create_vk_phones_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('vk_phones', [ | ||||
|             'id' => $this->bigPrimaryKey(), | ||||
|             'phone' => $this->string() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('vk_phones'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										34
									
								
								migrations/m170425_095137_create_gibdd_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								migrations/m170425_095137_create_gibdd_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `gibdd`. | ||||
|  */ | ||||
| class m170425_095137_create_gibdd_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('gibdd', [ | ||||
|             'tm' => $this->string(10), | ||||
|             'number' => $this->string(10), | ||||
|             'model' => $this->string(64), | ||||
|             'year' => $this->string(4), | ||||
|             'lastname' => $this->string(32), | ||||
|             'firstname' => $this->string(32), | ||||
|             'middlename' => $this->string(32), | ||||
|             'phone' => $this->string(11), | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('gibdd'); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170425_120322_create_idx_gibdd.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170425_120322_create_idx_gibdd.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170425_120322_create_idx_gibdd extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createIndex("idx_gibdd_phone", "gibdd", "phone"); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropIndex("idx_gibdd_phone", "gibdd"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										29
									
								
								migrations/m170425_135720_add_confirm_field.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								migrations/m170425_135720_add_confirm_field.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170425_135720_add_confirm_field extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn("users", "is_confirm", $this->boolean()->defaultValue(false)); | ||||
|         $this->addColumn("users", "tm_confirm", $this->dateTime()); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn("users", "tm_confirm"); | ||||
|         $this->dropColumn("users", "is_confirm"); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										27
									
								
								migrations/m170512_120833_add_uuid_to_users.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								migrations/m170512_120833_add_uuid_to_users.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| class m170512_120833_add_uuid_to_users extends Migration | ||||
| { | ||||
|     public function up() | ||||
|     { | ||||
|         $this->addColumn('users', 'uuid', $this->string(64)); | ||||
|     } | ||||
| 
 | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropColumn('users', 'uuid'); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     // Use safeUp/safeDown to run migration code within a transaction
 | ||||
|     public function safeUp() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     public function safeDown() | ||||
|     { | ||||
|     } | ||||
|     */ | ||||
| } | ||||
							
								
								
									
										28
									
								
								migrations/m170512_124345_create_vk_raw_table.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								migrations/m170512_124345_create_vk_raw_table.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| <?php | ||||
| 
 | ||||
| use yii\db\Migration; | ||||
| 
 | ||||
| /** | ||||
|  * Handles the creation of table `vk_raw`. | ||||
|  */ | ||||
| class m170512_124345_create_vk_raw_table extends Migration | ||||
| { | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function up() | ||||
|     { | ||||
|         $this->createTable('vk_raw', [ | ||||
|             'id' => $this->bigInteger(), | ||||
|             'data' => $this->text() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     public function down() | ||||
|     { | ||||
|         $this->dropTable('vk_raw'); | ||||
|     } | ||||
| } | ||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue