Пример #1
0
function thanks_for_RT($message, $where)
{
    global $consumerKey, $consumerSecret, $OAuthToken, $OAuthSecret;
    // create new instance
    $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $OAuthToken, $OAuthSecret);
    $thanks_tweet = $message;
    // get
    $retweets = $tweet->get('statuses/retweets_of_me');
    $retweets_id = array();
    foreach ($retweets as $user) {
        $retweets_id[] = array('tweet_id' => $user->id_str, 'created_at' => $user->created_at, 'text' => $user->text);
    }
    $screen_names = array();
    // for each retweet, get the last user who retweeded.
    foreach ($retweets_id as $current_retweet) {
        $method = 'statuses/' . $current_retweet['tweet_id'] . '/retweeted_by';
        $retweet = $tweet->get($method, array('count' => '1'));
        if (!isset($retweet)) {
            continue;
        }
        $screen_name = $retweet[0]->screen_name;
        $screen_names[] = $screen_name;
    }
    // delete doublon
    $screen_names = array_unique($screen_names);
    if (sizeof($screen_names) == 0) {
        return;
    }
    foreach ($screen_names as $screen_name) {
        $more_140 = create_tweet($thanks_tweet, $screen_name, $where);
        if ($more_140 == false) {
            break;
        }
    }
    echo $thanks_tweet . "\n";
    send_tweet($thanks_tweet);
}
Пример #2
0
        //}
    } elseif ($panel_type == 'shizzow_panel') {
        $tweets = get_shizzow_shouts($tw_user, $tw_pass);
    }
    echo $tweets;
} elseif ($func == 'send_tweet') {
    $panel_id = $_REQUEST['panel'];
    $tw_user = $_SESSION['panels'][$panel_id]->user;
    $tw_pass = $_SESSION['panels'][$panel_id]->pass;
    $reply_to = $_REQUEST['reply_to'];
    $reply_to_name = $_REQUEST['reply_to_name'];
    $dm = $_REQUEST['direct_message'];
    $tweet = stripslashes($_REQUEST['tweet_data']);
    header("Content-type: text/javascript");
    if ($dm == "false") {
        $rsp = send_tweet($tw_user, $tw_pass, $tweet, $reply_to);
        echo $rsp;
    } else {
        //send a direct message
        $rsp = send_dm($tw_user, $tw_pass, $tweet, $reply_to_name);
        echo $rsp;
    }
} elseif ($func == 'get_last_update') {
    $panel_id = $_REQUEST['panel'];
    $tw_user = $_SESSION['panels'][$panel_id]->user;
    $tw_pass = $_SESSION['panels'][$panel_id]->pass;
    header("Content-type: text/javascript");
    echo get_last_update($tw_user, $tw_pass);
} elseif ($func == 'get_user_tweets') {
    $user = $_REQUEST['user'];
    header("Content-type: text/javascript");
Пример #3
0
 if (get_config('cancelcourse', 'sendtweet')) {
     //is the tweeting option selected?
     if (get_config('cancelcourse', 'ckey') && get_config('cancelcourse', 'csecret') && get_config('cancelcourse', 'utoken') && get_config('cancelcourse', 'usecret')) {
         //setup the message body and shorten the strings as needed
         if (get_config('cancelcourse', 'includeshortname')) {
             $shortname = ' : ' . short_string($COURSE->shortname, 10);
         }
         if (get_config('cancelcourse', 'includefullname')) {
             $fullname = ' ' . short_string($COURSE->fullname, 69);
         }
         if (get_config('cancelcourse', 'includeprofname') && $profname != 'none') {
             $name = ' (' . short_string($profname, 25) . ')';
         }
         $subjecttwitter = short_string(short_string($subject, 130 - strlen($shortname . $fullname . $name)), 75);
         //send the tweet and report results
         if (send_tweet(get_config('cancelcourse', 'ckey'), get_config('cancelcourse', 'csecret'), get_config('cancelcourse', 'utoken'), get_config('cancelcourse', 'usecret'), $subjecttwitter . $shortname . $fullname . $name)) {
             echo '<div class="box generalbox" style="background-color: #73c376; font-weight: bold;"><p>' . get_string('tweetsuccess', 'block_cancelcourse') . '</p></div>';
             $tweet_success = true;
         } else {
             $tweet_success = false;
             echo print_error('tweetfailed', 'block_cancelcourse');
             //either the configuration is wrong, or the twitter API is returning an error.
         }
     } else {
         //error!
         echo print_error('twittermessage_configerror', 'block_cancelcourse');
     }
 } else {
     $tweet_success = true;
     //if tweet is NOT selected, set the success as true.
 }
Пример #4
0
        case 'attack':
        case 'move':
            preg_match('/^([^\\s]+)[\\s]+from[\\s]+([^\\s]+)[\\s]+with[\\s]+([\\d]+)[\\s]+([^\\s]+)$/', trim($data), $data);
            var_dump($data);
            if (!count($data)) {
                $reply = 'I do not understand your troop movement request.';
            } else {
                foreach ($user->getValue('cities') as $city) {
                    if ($city->getValue('id') == $data || @preg_match('/^' . $data[2] . '$/i', $city->getValue('name'))) {
                        //							$message = $city->initiate_transaction(UNITID, intval($data[3]), intval(DESTID));
                        break;
                    }
                }
                //end foreach
            }
            break;
        default:
            $reply = 'I do not understand "' . $verb . ' ' . $data . '"';
    }
    //end switch
    if ($reply) {
        echo send_tweet($message->sender_id, $reply);
    }
    //end if reply
}
//end
/* /TWITTER */
file_put_contents('transaction_lock', 0);
?>
DONE
Пример #5
0
 static function subvert($transaction, $city, $db)
 {
     $defense = $city->getValue('defense') + 1;
     foreach ($city->getKeys() as $key) {
         $key2 = explode('_', $key);
         if ($key2[0] != 'unit' || !is_numeric($key2[1])) {
             continue;
         }
         $udefense = mysql_query("SELECT value FROM units_data WHERE unit_id=" . $key2[1] . " AND `key`='defense'") or die(mysql_error());
         $udefense = mysql_fetch_assoc($udefense);
         $defense += $udefense['value'] * $city->getValue($key);
     }
     //end foreach keys
     $random_bound = $defense / rand(2, 6);
     $randomness = rand($random_bound * -1, $random_bound);
     $skill = mysql_query("SELECT value FROM units_data WHERE unit_id=" . $transaction['unit_id'] . " AND `key`='skill'") or die(mysql_error());
     $skill = mysql_fetch_assoc($skill);
     $skill = $skill['value'] * $transaction['unit_count'];
     $results = $defense + $randomness - $skill;
     $pop = 0;
     $user = new user($transaction['user_id'], new server($transaction['server_id']));
     if ($results < 0) {
         //only do something if successful
         $has_pop = intval($city->getValue('population'));
         $pop = $results * -1 * 4;
         $pop = $pop < $has_pop ? $pop : $has_pop;
         $city->setValue('population', $has_pop - $pop);
         $cities = $user->getValue('cities');
         $cities[0]->setValue('population', $cities[0]->getValue('population') + $pop);
     }
     //end if results < 0
     $class = $results < 0 ? 'succeeded' : 'failed';
     $city_link .= $city->getValue('name') ? mysql_real_escape_string($city->getValue('name'), $db) : 'City at ' . $city->getValue('id');
     mysql_query("INSERT INTO messages (server_id,user_id,time,message) VALUES (" . $transaction['server_id'] . "," . $transaction['user_id'] . "," . time() . ",'<span class=\"{$class}\">Subverting {$city_link} {$class} ({$pop} people turned)</span>')", $db) or die(mysql_error());
     if ($user->getValue('twitter')) {
         send_tweet($user->getValue('twitter'), strip_tags("Subverting {$city_link} {$class} ({$pop} people turned)"));
     }
     $other_class = $class == 'succeeded' ? 'failed' : 'succeeded';
     $user_link .= '<a href="/server/' . $transaction['server_id'] . '/user/' . $user->getValue('userid') . '">' . ($user->getValue('nickname') ? mysql_real_escape_string($user->getValue('nickname'), $db) : 'User #' . $user->getValue('userid')) . '</a>';
     mysql_query("INSERT INTO messages (server_id,user_id,time,message) VALUES (" . $transaction['server_id'] . "," . $city->getValue('user')->getValue('userid') . "," . time() . ",'<span class=\"{$other_class}\">{$user_link} tried subverting {$city_link} and {$class} ({$pop} people turned)</span>')", $db) or die(mysql_error());
     if ($city->getValue('user')->getValue('twitter')) {
         send_tweet($city->getValue('user')->getValue('twitter'), strip_tags("{$user_link} tried subverting {$city_link} and {$class} ({$pop} people turned)"));
     }
 }
Пример #6
0
    if ($rows_number <= 0) {
        insert_feeds();
        // calcul row number again
        // Find the number of rows in the table using SELECT COUNT(*) FROM your_table
        $rows_number = $bdd->query('SELECT count(*) from list_of_feeds')->fetchColumn();
        $rows_number = intval($rows_number) - 1;
    }
    //Use PHP's math functions to find a random number between 0 and the number of rows
    $rand_number = rand(0, $rows_number);
    echo 'random number : ' . $rand_number . "\n";
    //Get the actual data you want using SELECT * FROM your_table LIMIT 200, 1, where 200 is the random number you calculated in step 2.
    $select = 'SELECT * FROM list_of_feeds LIMIT ' . $rand_number . ', 1';
    $request = $bdd->query($select);
    if ($request->rowCount() == 1) {
        $response = $request->fetch();
        $tweet = $response['tweet'];
        $tweet_to_send = mb_convert_encoding($tweet, 'UTF-8', 'HTML-ENTITIES');
        send_tweet($tweet_to_send);
        echo $tweet_to_send;
        // ... delete
        $tweet = addslashes($tweet);
        $delete = 'DELETE FROM list_of_feeds WHERE tweet=\'' . $tweet . '\'';
        $request = $bdd->query($delete);
        $request->closeCursor();
        // Termine le traitement de la requête
    }
    // and now we're done; close it
    $bdd = null;
} catch (Exception $e) {
    die('Erreur : ' . $e->getMessage());
}
Пример #7
0
$rand_id = rand(0, 11);
$post = $rand_posts[$rand_id];
if (isset($post)) {
    $title = __($post->post_title);
    $punchline = __($post->post_content);
    $category = get_the_category($post->ID);
    $image = get_image_url($post->ID);
    $author = "";
    foreach ($category as $cat) {
        $author .= " " . $cat->cat_name;
    }
    $url = make_bitly_url('http://www.universetee.com/fr/' . $post->post_name);
    // 140
    $tweet = 'Tshirt' . $author . ' - ' . $title . ' : ' . $url;
    //send_tweet_image($tweet,$image);
    send_tweet($tweet);
    echo $tweet;
}
/* make a URL small */
function make_bitly_url($url)
{
    //create the URL
    return file_get_contents("http://tinyurl.com/api-create.php?url=" . $url);
}
/* split_to_chunks by John Hamelink 2010. This code is in the PUBLIC DOMAIN. */
function split_to_chunks($to, $text)
{
    $total_length = 140 - strlen($to);
    $text_arr = explode(" ", $text);
    $i = 0;
    $message[0] = "";