Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Job
- {
- private $db;
- public $account;
- private $proc_pid;
- private $likes_count;
- private $comments_count;
- private $follows_count;
- private $unfollows_count;
- private $uploads_count;
- private $follow_cycle;
- private $unfollow_cycle;
- private $start_time;
- private $time_used;
- private $purchased_time;
- private $last_proc_time;
- public $instagram;
- function __construct()
- {
- $this->db = MyDb::getInstance()->getConnection();
- }
- public function setAccount($acc)
- {
- $this->account = $acc;
- }
- private function setStatus($md5id)
- {
- $status_row = $this->db->queryFirstRow("select activity_status,likes,comments,follows,unfollows,uploads,time_used,last_proc_time,reg_days as purchased_time from accounts where md5id = %s", $md5id);
- $this->activity_status = $status_row['activity_status'];
- $this->likes_count = $status_row['likes'];
- $this->comments_count = $status_row['comments'];
- $this->follows_count = $status_row['follows'];
- $this->unfollows_count = $status_row['unfollows'];
- $this->uploads_count = $status_row['uploads'];
- $this->start_time = time();
- $this->time_used = $status_row['time_used'];
- $this->purchased_time = $status_row['purchased_time'];
- $this->last_proc_time = strtotime($status_row['last_proc_time']);
- }
- private function verifyJob() //-> check for AutoStop
- {
- //helper::manageInstagramResponse('checkpoint_required',$this);
- $verify['activityStatusNotRunning']['value'] = $this->account->getSettings()->getActivityStatus();
- $verify['activityStatusNotRunning']['limit'] = '1';
- $verify['activityStatusNotRunning']['condition'] = '!=';
- $verify['activityStatusNotRunning']['message'] = '';
- $verify['activityStatusNotRunning']['messageType'] = '';
- $verify['activityStatusPauseMode']['value'] = $this->account->getSettings()->getActivityStatus();
- $verify['activityStatusPauseMode']['limit'] = '2';
- $verify['activityStatusPauseMode']['condition'] = '==';
- $verify['activityStatusPauseMode']['message'] = '';
- $verify['activityStatusPauseMode']['messageType'] = '';
- $verify['noPurchasedTime']['value'] = $this->getPurchasedTime();
- $verify['noPurchasedTime']['limit'] = $this->getTimeUsed();
- $verify['noPurchasedTime']['condition'] = '<=';
- $verify['noPurchasedTime']['message'] = 'Activity has been stopped : No more time avalable in your activity account';
- $verify['noPurchasedTime']['messageType'] = 'purchasMoreTime';
- $verify['noActivity']['value'] = time();
- $verify['noActivity']['limit'] = @strtotime("+" . $this->account->getSettings()->getAutostopNoActivity(), $this->getLastProcTime());
- $verify['noActivity']['condition'] = '>=';
- $verify['noActivity']['message'] = 'Activity has been stopped , No activity since :' . $this->account->getSettings()->getAutostopNoActivity();
- $verify['noActivity']['messageType'] = 'autostop';
- $verify['activitySchedule']['value'] = helper::isScheduleOff($this->account);
- $verify['activitySchedule']['limit'] = false;
- $verify['activitySchedule']['condition'] = '==';
- $verify['activitySchedule']['message'] = "Activity in (Pause Mode) due your schedule setting";
- $verify['activitySchedule']['messageType'] = 'autostop';
- $verify['likesCount']['value'] = $this->getLikesCount();
- $verify['likesCount']['limit'] = $this->account->getSettings()->getAutostopLikesCount();
- $verify['likesCount']['condition'] = '>=';
- $verify['likesCount']['message'] = 'Activity has been stopped , Likes limit reached :' . $this->account->getSettings()->getAutostopLikesCount() . ' likes';
- $verify['likesCount']['messageType'] = 'autostop';
- $verify['commentsCount']['value'] = $this->getCommentsCount();
- $verify['commentsCount']['limit'] = $this->account->getSettings()->getAutostopCommentsCount();
- $verify['commentsCount']['condition'] = '>=';
- $verify['commentsCount']['message'] = 'Activity has been stopped ,Comments limit reached :' . $this->account->getSettings()->getAutostopLikesCount() . ' comments';
- $verify['commentsCount']['messageType'] = 'autostop';
- $verify['followsCount']['value'] = $this->getFollowersCount();
- $verify['followsCount']['limit'] = $this->account->getSettings()->getAutostopFollowCount();
- $verify['followsCount']['condition'] = '>=';
- $verify['followsCount']['message'] = 'Activity has been stopped ,Follow limit reached :' . $this->account->getSettings()->getAutostopFollowCount() . ' follow';
- $verify['followsCount']['messageType'] = 'autostop';
- $verify['unfollowsCount']['value'] = $this->getUnFollowersCount();
- $verify['unfollowsCount']['limit'] = $this->account->getSettings()->getAutostopFollowCount();
- $verify['unfollowsCount']['condition'] = '>=';
- $verify['unfollowsCount']['message'] = 'Activity has been stopped , Unfollow limit reached :' . $this->account->getSettings()->getAutostopFollowCount() . ' unfollow';
- $verify['unfollowsCount']['messageType'] = 'autostop';
- $verify['autoStopTimer']['value'] = time();
- $verify['autoStopTimer']['limit'] = @strtotime("+" . @explode(":", $this->account->getSettings()->getAutostopTimer())[0] . " hours " . @explode(":", $this->account->getSettings()->getAutostopTimer())[1] .
- " minutes", $this->getStartTime());
- $verify['autoStopTimer']['condition'] = '>=';
- $verify['autoStopTimer']['message'] = 'Activity has been stopped , Time limit reached :<b>' . @explode(":", $this->account->getSettings()->getAutostopTimer())[0] . " hours " . @explode(":", $this->account->getSettings
- ()->getAutostopTimer())[1] . " minutes</b>";
- $verify['autoStopTimer']['messageType'] = 'autostop';
- foreach ($verify as $key => $val)
- {
- if ($verify[$key]['limit'] && helper::evaluate($verify[$key]['value'], $verify[$key]['condition'], $verify[$key]['limit']))
- {
- if ($verify[$key]['message'])
- {
- print $message = helper::getMessageTxt($verify[$key]['messageType'], $verify[$key]['message'], $this->account->getUserName(), $this->account->getSettings()->getInstagramUsername());
- //helper::sendEmail($this->account()->getEmail(),$message);
- //helper::stopActivity($this->db, $verify[$key]['message'], $this->account->getSettings()->getmd5id(), $key);
- }
- return false;
- break;
- }
- }
- return true;
- }
- public function startJob()
- {
- $this->setProcPid();
- $this->setStatus($this->account->getSettings()->getmd5id());
- $verifyJob = $this->verifyJob();
- if ($verifyJob == false) return true;
- // Search for Syria Tag
- $this->instagramLogin();
- foreach($this->SearchByUser("1010315471") as $item)
- {
- $media = new media($item);
- $media->setInstagram($this->instagram);
- $media->setAccount($this->account);
- $media->setSearchType('tag');
- foreach($media->getCommenters() as $user){
- var_dump($user->getPk());
- exit();
- }
- //$media->setDontVerifyMediaAge();
- //$media->likeMedia();
- exit();
- }
- }
- private function setProcPid()
- {
- $this->proc_pid = getmypid();
- $this->db->update('accounts', array('pid' => getmypid()), "md5id=%s", $this->account->getSettings()->getmd5id());
- }
- private function getProcPid()
- {
- return $this->proc_pid;
- }
- public function SearchByTags($tag)
- {
- try
- {
- $helper = null;
- do
- {
- if (is_null($helper))
- {
- $helper = $this->instagram->getHashtagFeed($tag);
- }
- else
- {
- $helper = $this->instagram->getHashtagFeed($tag, $helper->getNextMaxId());
- }
- foreach ($helper->getItems() as $item)
- {
- yield $item;
- }
- } while (!is_null($helper->getNextMaxId()));
- }
- catch (exception $e)
- {
- helper::manageInstagramResponse($e->getMessage());
- }
- }
- public function SearchByUser($user_id)
- {
- try
- {
- $helper = null;
- do
- {
- if (is_null($helper))
- {
- $helper = $this->instagram->getUserFeed($user_id);
- }
- else
- {
- $helper = $this->instagram->getUserFeed($user_id, $helper->getNextMaxId());
- }
- foreach ($helper->getItems() as $item)
- {
- yield $item;
- }
- } while (!is_null($helper->getNextMaxId()));
- }
- catch (exception $e)
- {
- helper::manageInstagramResponse($e->getMessage());
- }
- }
- public function SearchByLocation($location_id)
- {
- try
- {
- $helper = null;
- do
- {
- if (is_null($helper))
- {
- $helper = $this->instagram->getLocationFeed($location_id);
- }
- else
- {
- $helper = $this->instagram->getLocationFeed($location_id, $helper->getNextMaxId());
- }
- foreach ($helper->getItems() as $item)
- {
- yield $item;
- }
- } while (!is_null($helper->getNextMaxId()));
- }
- catch (exception $e)
- {
- helper::manageInstagramResponse($e->getMessage());
- }
- }
- private function getLikesCount()
- {
- return $this->likes_count;
- }
- private function setLikesCount()
- {
- $this->db->query('update accounts set likes=likes+1,tlikes=tlikes+1,last_proc_time=%s where md5id=%s', hleper::getDate(), $this->account->getSettings()->getmd5id());
- $this->likes_count += 1;
- }
- private function getCommentsCount()
- {
- return $this->comments_count;
- }
- private function setCommentsCount()
- {
- $this->db->query('update accounts set comments=comments+1,tcomments=tcomments+1,last_proc_time=%s where md5id=%s', helper::getDate(), $this->account->getSettings()->getmd5id());
- $this->comments_count += 1;
- }
- private function getUploadsCount()
- {
- return $this->uploads_count;
- }
- private function setUploadsCount()
- {
- $this->db->query('update accounts set uploads=uploads+1,tuploads=tuploads+1,last_proc_time=%s where md5id=%s', helper::getDate(), $this->account->getSettings()->getmd5id());
- $this->uploads_count += 1;
- }
- private function getFollowersCount()
- {
- return $this->follows_count;
- }
- private function setFollowersCount()
- {
- $this->db->query('update accounts set tfollows=tfollows+1,follows=follows+1,last_proc_time=%s where md5id=%s', helper::getDate(), $this->account->getSettings()->getmd5id());
- $this->follows_count += 1;
- }
- private function getUnFollowersCount()
- {
- return $this->unfollows_count;
- }
- private function setUnFollowersCount()
- {
- $this->db->query('update accounts set tunfollows=tunfollows+1,unfollows=unfollows+1,last_proc_time=%s where md5id=%s', helper::getDate(), $this->account->getSettings()->getmd5id());
- $this->unfollows_count += 1;
- }
- private function getStartTime()
- {
- return $this->start_time;
- }
- private function getTimeUsed()
- {
- return $this->time_used;
- }
- private function setTimeUsed($time)
- {
- $this->db->query('update accounts set time_used = time_used + %s ,a_time_used = a_time_used + %s where md5id=%s', $time, $time, $this->account->getSettings()->getmd5id());
- }
- private function getPurchasedTime()
- {
- return $this->purchased_time;
- }
- private function getLastProcTime()
- {
- return $this->last_proc_time;
- }
- private function instagramLogin($force = false)
- {
- $debug = false;
- $max_attempts = 4;
- $attempts = 0;
- $this->instagram = new \InstagramAPI\Instagram($debug);
- $this->instagram->setUser($this->account->getSettings()->getInstagramUsername(), $this->account->getSettings()->getInstagramPassword());
- $user_cookies_dir = str_replace('\\', '/', dirname(__file__)) . "/../vendor/mgp25/instagram-php/src/data/" . $this->account->getSettings()->getInstagramUsername();
- if (!file_exists($user_cookies_dir)) $force = true;
- if ($force)
- {
- do
- {
- try
- {
- $this->instagram->login($force);
- if ($this->instagram->settings->isLogged())
- {
- break;
- }
- }
- catch (exception $e)
- {
- $attempts++;
- $message = $e->getMessage();
- helper::manageInstagramResponse($message, $this);
- print "\n" . 'Login #' . $attempts . "\n" . $message;
- if ($attempts >= $max_attempts)
- {
- print $alert_tip = "Login 4 times with no luck , please contact support\n";
- helper::stopActivity($this->db, $alert_tip, $this->account->getSettings()->getmd5id(), 'login_4times');
- exit(0);
- }
- }
- } while ($attempts < $max_attempts);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement