This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0b01ced
Showing
153 changed files
with
11,697 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory" : "vendor/bower-asset" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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 | ||
|
||
# Mac DS_Store Files | ||
.DS_Store | ||
|
||
# phpunit itself is not needed | ||
phpunit.phar | ||
# local phpunit config | ||
/phpunit.xml | ||
|
||
tests/_output/* | ||
tests/_support/_generated | ||
|
||
config/authClientCollection.php | ||
config/db.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## IG Monitoring | ||
|
||
# Version | ||
Early dev stage. **Use at your own risk.** | ||
|
||
# Install | ||
- composer install | ||
|
||
# Config | ||
- create database: mysql, utf8mb4 | ||
- copy config/db.dist => config/db.dist | ||
- register google project for Google Sign-In | ||
- copy config/authClientCollection.php.dist => config/authClientCollection.php | ||
- [configure worker](https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/worker.md) | ||
- create cron hourly for: `./yii stats/update-accounts` and `./yii stats/update-tags` | ||
|
||
# Manual | ||
Everything should be added from the command line. | ||
|
||
- `./yii proxy/create` | ||
- `./yii monitoring/account` | ||
- `./yii monitoring/tag` | ||
- `./yii help monitoring/account` - displays help for the command | ||
|
||
See `./yii` for more commands. | ||
|
||
|
||
# Limitations | ||
You need at least one, **WORKING proxy** for accounts and one for tags. | ||
|
||
# Legal | ||
This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Instagram or any of its affiliates or subsidiaries. | ||
This is an independent tool. **Use at your own risk.** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?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; | ||
|
||
/** | ||
* Main application asset bundle. | ||
* | ||
* @author Qiang Xue <qiang.xue@gmail.com> | ||
* @since 2.0 | ||
*/ | ||
class AppAsset extends AssetBundle | ||
{ | ||
public $basePath = '@webroot'; | ||
public $baseUrl = '@web'; | ||
public $css = [ | ||
'css/site.css', | ||
]; | ||
public $js = [ | ||
]; | ||
public $depends = [ | ||
'yii\web\YiiAsset', | ||
'yii\bootstrap\BootstrapAsset', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '../codeception.yml' | ||
# whitelist: | ||
# include: | ||
# - models/* | ||
# - controllers/* | ||
# - commands/* | ||
# - mail/* | ||
# blacklist: | ||
# include: | ||
# - assets/* | ||
# - config/* | ||
# - runtime/* | ||
# - vendor/* | ||
# - views/* | ||
# - web/* | ||
# - tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Created for IG Monitoring. | ||
* User: jakim <pawel@jakimowski.info> | ||
* Date: 13.01.2018 | ||
*/ | ||
|
||
namespace app\commands; | ||
|
||
|
||
use app\models\Account; | ||
use app\models\Tag; | ||
use yii\console\Controller; | ||
use yii\helpers\Console; | ||
|
||
class AccountController extends Controller | ||
{ | ||
/** | ||
* Tag accounts. | ||
* | ||
* @param array $usernames | ||
* @param array $tags | ||
*/ | ||
public function actionTag(array $usernames, array $tags) | ||
{ | ||
$accounts = Account::findAll(['username' => $usernames]); | ||
$tags = Tag::findAll(['name' => $tags]); | ||
|
||
$this->stdout(sprintf("Valid accounts: %d, valid tags: %d\n", count($accounts), count($tags))); | ||
|
||
foreach ($accounts as $account) { | ||
foreach ($tags as $tag) { | ||
$account->link('tags', $tag); | ||
} | ||
$this->stdout("Account '{$account->username}' done!\n", Console::FG_GREEN); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
/** | ||
* Created for IG Monitoring. | ||
* User: jakim <pawel@jakimowski.info> | ||
* Date: 11.01.2018 | ||
*/ | ||
|
||
namespace app\commands; | ||
|
||
|
||
use app\dictionaries\ProxyType; | ||
use app\models\Account; | ||
use app\models\Proxy; | ||
use app\models\Tag; | ||
use yii\console\Controller; | ||
use yii\console\ExitCode; | ||
use yii\console\widgets\Table; | ||
use yii\helpers\Console; | ||
use yii\helpers\Inflector; | ||
|
||
class MonitoringController extends Controller | ||
{ | ||
public function actionIndex() | ||
{ | ||
$this->actionAccounts(); | ||
$this->actionTags(); | ||
} | ||
|
||
public function actionAccount($username, $proxy_id = null) | ||
{ | ||
$account = Account::findOne(['username' => $username]); | ||
if ($account === null) { | ||
$account = new Account(['username' => $username]); | ||
} | ||
|
||
$proxy = Proxy::findOne(['id' => $proxy_id, 'type' => ProxyType::ACCOUNT]); | ||
if ($proxy) { | ||
$account->proxy_id = $proxy->id; | ||
|
||
} elseif ($proxy === null && $proxy_id) { | ||
$this->stdout("ERR: Proxy '$proxy_id' not found.\n", Console::FG_RED); | ||
|
||
return ExitCode::UNSPECIFIED_ERROR; | ||
} elseif (!$proxy_id && !Proxy::find()->andWhere(['type' => ProxyType::ACCOUNT])->exists()) { | ||
$this->stdout("ERR: There MUST be at least one proxy for accounts.\n", Console::FG_RED); | ||
|
||
return ExitCode::UNSPECIFIED_ERROR; | ||
} | ||
|
||
$account->monitoring = 1; | ||
if (!$account->save()) { | ||
print_r($account->errors); | ||
|
||
return ExitCode::UNSPECIFIED_ERROR; | ||
} | ||
$this->stdout("OK!\n"); | ||
|
||
return ExitCode::OK; | ||
} | ||
|
||
public function actionAccounts() | ||
{ | ||
echo Table::widget([ | ||
'headers' => [ | ||
'ID', | ||
'Username', | ||
], | ||
'rows' => Account::find() | ||
->select([ | ||
'id', | ||
'username', | ||
]) | ||
->monitoring() | ||
->asArray() | ||
->all(), | ||
]); | ||
} | ||
|
||
public function actionTag($name, $proxy_id = null) | ||
{ | ||
$tag = Tag::findOne(['name' => $name]); | ||
if ($tag === null) { | ||
$tag = new Tag(['name' => $name]); | ||
$mainTag = Tag::findOne(['slug' => Inflector::slug($name)]); | ||
if ($mainTag) { | ||
$tag->main_tag_id = $mainTag->id; | ||
} | ||
} | ||
$proxy = Proxy::findOne(['id' => $proxy_id, 'type' => ProxyType::TAG]); | ||
if ($proxy) { | ||
$tag->proxy_id = $proxy->id; | ||
} elseif ($proxy === null && $proxy_id) { | ||
$this->stdout("ERR: Proxy '$proxy_id' not found.\n", Console::FG_RED); | ||
|
||
return ExitCode::UNSPECIFIED_ERROR; | ||
} elseif (!$proxy_id && !Proxy::find()->andWhere(['type' => ProxyType::TAG])->exists()) { | ||
$this->stdout("ERR: There MUST be at least one proxy for accounts.\n", Console::FG_RED); | ||
|
||
return ExitCode::UNSPECIFIED_ERROR; | ||
} | ||
|
||
$tag->monitoring = 1; | ||
if (!$tag->save()) { | ||
print_r($tag->errors); | ||
|
||
return ExitCode::UNSPECIFIED_ERROR; | ||
} | ||
$this->stdout("OK!\n"); | ||
|
||
return ExitCode::OK; | ||
} | ||
|
||
public function actionTags() | ||
{ | ||
echo Table::widget([ | ||
'headers' => [ | ||
'ID', | ||
'Tag', | ||
], | ||
'rows' => Tag::find() | ||
->select([ | ||
'id', | ||
'name', | ||
]) | ||
->monitoring() | ||
->asArray() | ||
->all(), | ||
]); | ||
} | ||
} |
Oops, something went wrong.