echo mainFuncs::push_response(23); $run_cron = false; } else { if ($cron->get_cron_state('follow') == 1) { echo mainFuncs::push_response(24); $run_cron = false; } } if ($run_cron == true) { /* New to 0.3 - Some people on super cheap hosting seem to get SQL errors - output them if they occur */ $db->output_error = 1; //Set cron status $cron->set_cron_state('follow', 1); //Get credentials $ap_creds = $db->get_ap_creds(); //Loop through all accounts $q1 = $db->query("SELECT * FROM " . DB_PREFIX . "authed_users ORDER BY (followers_count + friends_count) ASC"); while ($q1a = $db->fetch_array($q1)) { //Defines $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $q1a['oauth_token'], $q1a['oauth_token_secret']); $cron->set_user_id($q1a['id']); $cron->set_first_pass_done($q1a['fr_fw_fp']); $cron->set_log($q1a['log_data']); $cron->set_throttle_time(0, 'fr'); $cron->set_throttle_time(0, 'fw'); $cron->set_fr_fw_issue(0); //Refresh details $content = $connection->get('account/verify_credentials');
} else { if ($cron->get_cron_state('bot_tweets') == 1) { echo mainFuncs::push_response(24); $run_cron = false; } } if ($run_cron != true) { exit; } if (!is_connected()) { //internet connection seems broken exit; } $db->output_error = 1; //Set cron status $cron->set_cron_state('bot_tweets', 1); $cron->set_log(1); $ap_creds = $db->get_ap_creds(); $configs = $db->query("\n SELECT *\n FROM " . DB_PREFIX . "users_config\n WHERE tweet_bot_status=1;\n"); while ($userConfig = mysql_fetch_array($configs, MYSQL_ASSOC)) { $cron->set_user_id($userConfig['user_id']); $tweetRate = $userConfig['tweeting_rate']; $authUserData = $db->get_user_data($userConfig['user_id']); $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $authUserData['oauth_token'], $authUserData['oauth_token_secret']); $tweetsToSend = $db->query("\n SELECT id, tweet_content\n FROM " . DB_PREFIX . "tweets_queue\n WHERE datetime_tweeted IS NULL\n AND user_id='{$userConfig['user_id']}'\n LIMIT {$tweetRate};\n "); while ($tweet = mysql_fetch_array($tweetsToSend, MYSQL_ASSOC)) { $connection->post('statuses/update', array('status' => $tweet['tweet_content'])); //Log result - reasons for a non 200 include duplicate tweets, too many tweets //posted in a period of time, etc etc. if ($connection->http_code == 200) { $cron->store_cron_log(7, $cron_txts[18] . $tweet['tweet_content'] . $cron_txts[19], '');
//Check crpn key and if running if ($argv[1] != CRON_KEY and $_GET['cron_key'] != CRON_KEY) { echo mainFuncs::push_response(23); $run_cron = false; } else { if ($cron->get_cron_state('upd_info') == 1 || $cron->get_cron_state('follow') == 1) { echo mainFuncs::push_response(24); $run_cron = false; } } if ($run_cron != true) { exit; } $db->output_error = 1; //Set cron status $cron->set_cron_state('upd_info', 1); $cron->set_log(1); $cron->set_user_id(CRON_SEARCH_AUTH_ID); //Get credentials $ap_creds = $db->get_ap_creds(); $authUserData = $db->get_user_data(CRON_SEARCH_AUTH_ID); $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $authUserData['oauth_token'], $authUserData['oauth_token_secret']); $rate_con = $cron->get_remaining_hits(); $usersRequestsRemaining = intval($rate_con['ul_remaining']); while ($usersRequestsRemaining > 10) { $result = getIds($db); $user_ids = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $user_ids[] = $row['user_id']; } if (empty($user_ids)) {
//Check crpn key and if running if ($argv[1] != CRON_KEY and $_GET['cron_key'] != CRON_KEY) { echo mainFuncs::push_response(23); $run_cron = false; } else { if ($cron->get_cron_state('gen_tweets') == 1) { echo mainFuncs::push_response(24); $run_cron = false; } } if ($run_cron != true) { exit; } $db->output_error = 1; //Set cron status $cron->set_cron_state('gen_tweets', 1); $cron->set_log(1); $configs = $db->query("\n SELECT *\n FROM " . DB_PREFIX . "users_config\n WHERE tweet_bot_status=1;\n"); while ($userConfig = mysql_fetch_array($configs, MYSQL_ASSOC)) { $cron->set_user_id($userConfig['user_id']); $queryLimit = $userConfig['tweet_generation_rate'] ? $userConfig['tweet_generation_rate'] : 0; $queryOffset = $userConfig['tweet_generation_offset'] ? $userConfig['tweet_generation_offset'] : 0; $tweetsCount = 0; if (!empty($userConfig['tweet_template']) && !empty($userConfig['tweet_query'])) { $tweetsData = $db->query($userConfig['tweet_query'] . " LIMIT {$queryLimit} OFFSET {$queryOffset};"); while ($data = mysql_fetch_array($tweetsData, MYSQL_ASSOC)) { $tweet_content = bind_to_template($data, $userConfig['tweet_template']); addTweetToQueue($tweet_content, $userConfig['user_id']); $tweetsCount++; } }
//Check crpn key and if running if ($argv[1] != CRON_KEY and $_GET['cron_key'] != CRON_KEY) { echo mainFuncs::push_response(23); $run_cron = false; } else { if ($cron->get_cron_state('search') == 1 || $cron->get_cron_state('follow') == 1) { echo mainFuncs::push_response(24); $run_cron = false; } } if ($run_cron != true) { exit; } $db->output_error = 1; //Set cron status $cron->set_cron_state('search', 1); $cron->set_log(1); $cron->set_user_id(CRON_SEARCH_AUTH_ID); //Get credentials $ap_creds = $db->get_ap_creds(); $authUserData = $db->get_user_data(CRON_SEARCH_AUTH_ID); $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $authUserData['oauth_token'], $authUserData['oauth_token_secret']); $rate_con = $cron->get_remaining_hits(); $followersReqLimit = intval($rate_con['fw_limit']); $followersRequestsRemaining = intval($rate_con['fw_remaining']); $tweetsRequestsRemaining = intval($rate_con['tw_remaining']); while ($followersRequestsRemaining > 3 && $tweetsRequestsRemaining > 3) { $search_queue_record = getSearchQueueRecord(); if (empty($search_queue_record)) { $cron->set_cron_state('search', 0); exit;
echo mainFuncs::push_response(23); $run_cron = false; } else { if ($cron->get_cron_state('tweet') == 1) { echo mainFuncs::push_response(24); $run_cron = false; } } if ($run_cron == true) { /* New to 0.3 - Some people on super cheap hosting seem to get SQL errors - output them if they occur */ $db->output_error = 1; //Set cron status $cron->set_cron_state('tweet', 1); //Get credentials $ap_creds = $db->get_ap_creds(); //Loop through all accounts $q1 = $db->query("SELECT * FROM " . DB_PREFIX . "authed_users ORDER BY (followers_count + friends_count) ASC"); while ($q1a = $db->fetch_array($q1)) { //Defines $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $q1a['oauth_token'], $q1a['oauth_token_secret']); $cron->set_user_id($q1a['id']); $cron->set_log($q1a['log_data']); //Time can vary between PHP and server if server timezone doesn't match PHP timezone. //All scripts use PHP time rather than NOW() to avoid issues. $current_time = date("Y-m-d H:i:s"); //Get scheduled tweets for this user older than or equal to current time $q2 = $db->query("SELECT * FROM " . DB_PREFIX . "scheduled_tweets WHERE owner_id = '" . $db->prep($q1a['id']) . "' AND time_to_post != '0000-00-00 00:00:00' AND time_to_post <= '" . $db->prep($current_time) . "' ORDER BY time_to_post ASC"); while ($q2a = $db->fetch_array($q2)) {
//Check crpn key and if running if ($argv[1] != CRON_KEY and $_GET['cron_key'] != CRON_KEY) { echo mainFuncs::push_response(23); $run_cron = false; } else { if ($cron->get_cron_state('robot_fw') == 1) { echo mainFuncs::push_response(24); $run_cron = false; } } if ($run_cron != true) { exit; } if (!is_connected()) { //internet connection seems broken $cron->set_cron_state('robot_fw', 0); exit; } $db->output_error = 1; //Set cron status $cron->set_cron_state('robot_fw', 1); $cron->set_log(1); //Get credentials $ap_creds = $db->get_ap_creds(); $configs = $db->query("\n SELECT *\n FROM " . DB_PREFIX . "users_config\n WHERE follow_bot_status=1;\n"); while ($userConfig = mysql_fetch_array($configs, MYSQL_ASSOC)) { $counter = $userConfig['follow_rate']; $cron->set_user_id($userConfig['user_id']); $result = $db->query("\n SELECT user_id, related_user_id, screen_name\n FROM " . DB_PREFIX . "extracted_user_data\n WHERE datetime_robot_follow_{$userConfig['user_id']} IS NULL\n AND datetime_updated IS NOT NULL\n {$userConfig['follow_rule']}\n LIMIT {$counter}\n "); $friendshipCounter = array(); $protected_accs = 0;