Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.54 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.9.0
  8. * @ Author : DeZender
  9. * @ Release on : 08.08.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace Plugins\MassVoting;
  15.  
  16. require_once PLUGINS_PATH . '/' . IDNAME . '/vendor/autoload.php';
  17. require_once PLUGINS_PATH . '/' . IDNAME . '/models/LogModel.php';
  18. require_once PLUGINS_PATH . '/' . IDNAME . '/models/StatModel.php';
  19. require_once PLUGINS_PATH . '/' . IDNAME . '/models/ScheduleModel.php';
  20.  
  21. if (!defined('APP_VERSION')) {
  22. exit('Yo, what\'s up?');
  23. }
  24.  
  25. class HypervoteController extends \Controller
  26. {
  27. public function process()
  28. {
  29. set_time_limit(0);
  30. ini_set('memory_limit', '-1');
  31. $Route = $this->getVariable('Route');
  32. if (isset($Route->params->account_id) && isset($Route->params->user_id)) {
  33. $account_id = $Route->params->account_id;
  34. $user_id = $Route->params->user_id;
  35. }
  36. else {
  37. exit();
  38. }
  39.  
  40. error_log('Process Starting for Account ID:' . $account_id . ' & User ID:' . $user_id);
  41. $this->run($account_id, $user_id);
  42. }
  43.  
  44. private function run($account_id, $user_id)
  45. {
  46. ignore_user_abort(true);
  47. set_time_limit(0);
  48. $Log = new LogModel();
  49. $Account = \Controller::model('Account', $account_id);
  50. $User = \Controller::model('User', $user_id);
  51. $sC = new ScheduleModel(['account_id' => $account_id, 'user_id' => $user_id]);
  52.  
  53. if ($sC->get('is_executed')) {
  54. echo 'Hypervote loop already started.';
  55. exit();
  56. }
  57. else {
  58. $sC->set('is_executed', 1)->save();
  59. }
  60.  
  61. $pid = $sC->get('process_id');
  62.  
  63. if ($pid) {
  64. $process = \dgr\nohup\Process::loadFromPid($pid);
  65.  
  66. if ($process->isRunning()) {
  67. $process->stop();
  68. }
  69.  
  70. error_log('PID Check Complete');
  71. }
  72.  
  73. $pid = getmypid();
  74. $sC->set('process_id', $pid)->save();
  75. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error');
  76. $targets = json_decode($sC->get('target'), true);
  77.  
  78. if (is_null($targets)) {
  79. $sC->set('is_active', 0)->set('process_id', 0)->set('is_running', 0)->set('is_executed', 0)->save();
  80. exit();
  81. }
  82.  
  83. if (count($targets) < 1) {
  84. $Log->set('data.error.msg', 'Couldn\'t find any target to view story media')->save();
  85. $sC->set('process_id', 0)->set('is_running', 0)->set('is_executed', 0)->save();
  86. exit();
  87. }
  88.  
  89. try {
  90. $ig = \InstagramController::login($Account);
  91. }
  92. catch (\InstagramAPI\Exception\NetworkException $e) {
  93. $sC->set('schedule_date', date('Y-m-d H:i:s', time() + 7))->save();
  94. $sC->set('process_id', 0)->set('is_running', 0)->set('is_executed', 0)->save();
  95. exit();
  96. }
  97. catch (\InstagramAPI\Exception\EmptyResponseException $e) {
  98. $sC->set('schedule_date', date('Y-m-d H:i:s', time() + 7))->save();
  99. $sC->set('process_id', 0)->set('is_running', 0)->set('is_executed', 0)->save();
  100. exit();
  101. }
  102. catch (\Exception $e) {
  103. if ($Account->get('login_required')) {
  104. $sC->set('is_active', 0)->set('process_id', 0)->set('is_running', 0)->set('is_executed', 0)->save();
  105. $Log->set('data.error.msg', __('Hypervote has been stopped'));
  106. }
  107. else {
  108. $sC->set('process_id', 0)->set('is_running', 0)->set('is_executed', 0)->save();
  109. $sC->set('schedule_date', date('Y-m-d H:i:s', time() + 15))->save();
  110. $Log->set('data.error.msg', __('Hypervote re-scheduled'));
  111. }
  112.  
  113. $Log->set('data.error.details', $e->getMessage())->save();
  114. exit();
  115. }
  116.  
  117. $data = [];
  118.  
  119. for ($i = 0; $i < count($targets); $i++) {
  120. $data[$i] = ['type' => $targets[$i]['type'], 'id' => $targets[$i]['id'], 'value' => $targets[$i]['value']];
  121. }
  122.  
  123. $Settings = settings();
  124. $license = $Settings->get('data.license');
  125.  
  126. if ($license == 'invalid') {
  127. $Log = new LogModel();
  128. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', __('Hypervote has been stopped'))->set('data.error.details', __('Module license is not valid.'))->set('data.pid', $sC->get('process_id'))->save();
  129. $Log = NULL;
  130. unset($Log);
  131. $sC->set('is_active', 0)->set('is_running', 0)->set('process_id', 0)->set('is_executed', 0)->save();
  132. exit();
  133. }
  134.  
  135. $this->hypervote($Account, $User, $data, $ig);
  136. }
  137.  
  138. private function hypervote($Account, $User, $data, $ig)
  139. {
  140. ini_set('memory_limit', '-1');
  141. set_time_limit(0);
  142. $begin = $begin_f = $begin_login = $begin_ms = $begin_ms2 = $last_throttled_poll = $last_throttled_quiz = $last_throttled_slider = $last_throttled_question = $last_throttled_countdown = $last_throttled_mass_view = $now_ms = $last_throttled_type = $disabled_view = $activated_view = time();
  143. $st_count = $st_count_seen = $stats_count = $speed = $delitel = $counter1 = $counter2 = $counter3 = $counter4 = $counter5 = $delta = $stories = $action_count = $likers_list = $votePollStory_counter = $voteSliderStory_counter = $answerStoryQuestion_counter = $voteQuizStory_counter = $mass_story_view_counter = $follow_c_count = $sC = $Log = $get_from_follow = $mediaFeed = $followers = $mediaId = $action_stats_count = $actions_count = $response = $reel = $countdown_counter = $vote = $story = NULL;
  144. $stories = $likers_list = $targets_array = $follower_ids = [];
  145. $poll_throttled = $mass_act = $quiz_throttled = $slider_throttled = $question_throttled = $mass_view_throttled = $countdown_throttled = $get_from_likers = false;
  146. $fresh_stories_range = $fresh_stories = $index_new = $index_old = 0;
  147. $usfile = PLUGINS_PATH . '/' . IDNAME . '/temp/' . $Account->get('id') . '-user-exclude.txt';
  148. $Log = new LogModel();
  149. $sC = new ScheduleModel(['account_id' => $Account->get('id'), 'user_id' => $User->get('id')]);
  150. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', __('Hypervote started'))->set('data.error.details', __('We successfully started stories hypervote loop.'))->set('data.pid', $sC->get('process_id'))->save();
  151. $Log = NULL;
  152. unset($Log);
  153. $targets_array = $data;
  154. shuffle($targets_array);
  155.  
  156. for ($i = 0; $i < count($targets_array); $i++) {
  157. $data[$i] += ['rank_token' => \InstagramAPI\Signatures::generateUUID(), 'users_count' => 0, 'max_id' => NULL, 'begin_gf' => NULL];
  158. }
  159.  
  160. $poll_answer_option = $sC->get('poll_answer_option');
  161.  
  162. if ($sC->get('speed')) {
  163. $settings = settings();
  164. $maximum_speed = $settings->get('data.maximum_speed');
  165.  
  166. if (empty($maximum_speed)) {
  167. $maximum_speed = 'maximum';
  168. }
  169.  
  170. $speed_max_delay = 13;
  171. $package_modules = $User->get('settings.modules');
  172. $is_high_speed_enabled = (in_array('hypervote-high-speed', $package_modules) ? true : false);
  173.  
  174. if ($is_high_speed_enabled) {
  175. $speed_max_delay = 13;
  176. }
  177.  
  178. $speed == 'maximum' ? $delay = $speed_max_delay : $del = (int) $sC->get('speed');
  179. $delay = 13;
  180. }
  181. else {
  182. $Log = new LogModel();
  183. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', __('Speed for hypervote not defined'))->set('data.pid', $sC->get('process_id'))->save();
  184. $Log = NULL;
  185. unset($Log);
  186. $sC->set('is_active', 0)->set('process_id', 0)->set('is_running', 0)->set('is_executed', 0)->set('data.estimated_speed', 0)->save();
  187. exit();
  188. }
  189.  
  190. do {
  191. foreach ($data as $key => $d) {
  192. try {
  193. if ($d['max_id'] == NULL) {
  194. $is_gf_first = 1;
  195. }
  196.  
  197. sleep(1);
  198.  
  199. if (!empty($d['begin_gf'])) {
  200. $current_time = time();
  201.  
  202. if (($current_time - $d['begin_gf']) < 5) {
  203. $sleep_time = (5 - $current_time - $d['begin_gf']) + mt_rand(1, 3);
  204. }
  205.  
  206. sleep(3);
  207. }
  208.  
  209. if ($Account->get('login_required')) {
  210. $Log = new LogModel();
  211. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', __('Hypervote has been stopped'))->set('data.error.details', __('Re-login is required for the account.'))->set('data.pid', $sC->get('process_id'))->save();
  212. $Log = NULL;
  213. unset($Log);
  214. $sC->set('is_active', 0)->set('is_running', 0)->set('process_id', 0)->set('is_executed', 0)->save();
  215. exit();
  216. }
  217. if (!$User->isAvailable() || !$User->get('is_active') || $User->isExpired()) {
  218. $Log = new LogModel();
  219. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', __('Hypervote has been stopped'))->set('data.error.details', __('User account is either disabled or expired.'))->set('data.pid', $sC->get('process_id'))->save();
  220. $Log = NULL;
  221. unset($Log);
  222. $sC->set('is_active', 0)->set('is_running', 0)->set('process_id', 0)->set('is_executed', 0)->save();
  223. exit();
  224. }
  225.  
  226. if ($User->get('id') != $Account->get('user_id')) {
  227. $sC->set('is_active', 0)->set('is_running', 0)->set('process_id', 0)->set('is_executed', 0)->save();
  228. exit();
  229. }
  230.  
  231. $user_modules = $User->get('settings.modules');
  232. if (!is_array($user_modules) || !in_array(IDNAME, $user_modules)) {
  233. $Log = new LogModel();
  234. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', __('Massvoting has been stopped'))->set('data.error.details', __('Module is not accessible for your account.'))->set('data.pid', $sC->get('process_id'))->save();
  235. $Log = NULL;
  236. unset($Log);
  237. $sC->set('is_active', 0)->set('is_running', 0)->set('process_id', 0)->set('is_executed', 0)->save();
  238. exit();
  239. }
  240.  
  241. if ($d['type'] == 'people_getliker') {
  242. if (!$get_from_follow) {
  243. try {
  244. $data[$key]['begin_gf'] = time();
  245. unset($mediaFeed);
  246. $mediaFeed = NULL;
  247. $mediaFeed = $ig->timeline->getUserFeed($d['id'], $d['max_id']);
  248. }
  249. catch (\InstagramAPI\Exception\NotFoundException $e) {
  250. $Log = new LogModel();
  251. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', '@' . $d['value'] . ' ' . __('not found'))->set('data.error.details', __('Username is incorrect or maybe user blocked you (login to Instagram website or mobile app and check that).'))->set('data.debug.message', $e->getMessage())->set('data.pid', $sC->get('process_id'))->save();
  252. $Log = NULL;
  253. unset($Log);
  254. $data[$key] = NULL;
  255. unset($data[$key]);
  256. continue;
  257. }
  258. catch (\InstagramAPI\Exception\RequestException $e) {
  259. $Log = new LogModel();
  260. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', '@' . $d['value'] . ' ' . __('not found'))->set('data.error.details', __('Username is incorrect or maybe user blocked you (login to Instagram website or mobile app and check that).'))->set('data.pid', $sC->get('process_id'))->save();
  261. $Log = NULL;
  262. unset($Log);
  263. $data[$key] = NULL;
  264. unset($data[$key]);
  265. continue;
  266. }
  267. catch (\InstagramAPI\Exception\ThrottledException $e) {
  268. $followers = NULL;
  269. unset($followers);
  270. $data[$key]['begin_gf'] = time();
  271. $followers = $ig->people->getFollowers($d['id'], $d['rank_token'], NULL, $d['max_id']);
  272. $counter3 += 1;
  273. sleep(1);
  274. $get_from_user = true;
  275. }
  276. catch (Exception $e) {
  277. throw $e;
  278. }
  279.  
  280. sleep(1);
  281. $counter3 += 1;
  282. unset($items);
  283. $items = NULL;
  284. $items = $mediaFeed->getItems();
  285.  
  286. if (empty($items)) {
  287. $Log = new LogModel();
  288. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', '@' . $d['value'] . ' ' . __('don\'t have any data in his/her profile...'))->set('data.error.details', __('We skip this target and goes to the next one.'))->set('data.pid', $sC->get('process_id'))->save();
  289. $Log = NULL;
  290. unset($Log);
  291. $mediaFeed = NULL;
  292. unset($mediaFeed);
  293. $data[$key] = NULL;
  294. unset($data[$key]);
  295. continue;
  296. }
  297.  
  298. $counter3 += 1;
  299. sleep(1);
  300. $liker_list = NULL;
  301. unset($likers_list);
  302. $likers_list = [];
  303. $data[$key]['max_id'] = $mediaFeed->getNextMaxId();
  304.  
  305. foreach ($items as $item) {
  306. try {
  307. $mediaId = $item->getId();
  308. $likers_list[] = $ig->media->getLikersChrono($mediaId);
  309.  
  310. if (empty($likers_list)) {
  311. $Log = new LogModel();
  312. $Log->set('user_id', $User->get('id'))->set('account_id', $Account->get('id'))->set('status', 'error')->set('data.error.msg', '@' . $d['value'] . ' ' . __('don\'t have any data in his/her profile...'))->set('data.error.details', __('We skip this target and goes to the next one.'))->set('data.pid', $sc->get('process_id'))->save();
  313. $Log = NULL;
  314. unset($Log);
  315. $data[$key] = NULL;
  316. unset($data[$key]);
  317. unset($liker_list);
  318. $likers_list = NULL;
  319. $likers_list = [];
  320. continue;
  321. }
  322. }
  323. catch (\InstagramAPI\Exception\ThrottledException $e) {
  324. $get_from_follow = true;
  325. sleep(1);
  326. }
  327. }
  328. }
  329.  
  330. if ($get_from_follow) {
  331. try {
  332. $data[$key]['begin_gf'] = time();
  333. $followers = $ig->people->getFollowers($d['pk'], $d['rank_token'], NULL, $d['max_id']);
  334. ....................................................................................................
  335. ......................................................
  336. .......................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement