<?php
### WHO THE FUCK DO YOU WANT THIS FUCKING SCRIPT TO NOT VOTE FOR? ###
$donotvote = "@mileycyrus @davedays @mileyrusfanclub @ddlovato @jonasbrothers @miley_fan_net @canardpcredac @selenagomez @seiji092 @billyraycyrus @thebrandicyrus @mommytish @respectmileyc @taylorswift13 @mandyyjirouxx @tracecyrus @ashika789 @davidefanmiley @shanedawson @mileyfashion @wesupportniley @mileycyrusru @teamcyrus @mileyunlimited @missnoiecyrus @mileys_lover @mileybrcom @believeinniley @mileycombr @weheartmileyc @jb_cyrus_lovato @mileyc_rox @jb_x3 @buckhollywood @unitedformiley @siimplesongx @bts_niley @mileycyrusbr @mileycyruschile @alwaysmileyus @mileyamazed @teammiley @jazjess @xxteamdisneyxx @mileyforever969 @xmileysupport @justinmgaston @nickela_ @therealjordin @henriquehora @lorano13 @gottaloveniley @gottaloveselena @teammcyrus @franniie23xo @peaceformiley @missmileysfan1 @teammileycyrusx @demiley_twi12 @dedicatdtomiley";

### URL OF THE PAGE WITH THE FUCKING PEOPLE THAT YOU WANT TO VOTE FOR ###
$urlo = "http://tweeterwall.mallplace.com/tw/fan-series/miley-cyrus-fans";


### USER AGENT? YEAH BITCHES ###
$user_k = array("http://www.useragentstring.com/pages/Firefox/", "http://www.useragentstring.com/pages/Internet%20Explorer/", "http://www.useragentstring.com/pages/Opera/", "http://www.useragentstring.com/pages/Chrome/", "http://www.useragentstring.com/pages/Safari/");
$useragents = array();
### I WOULDNT TOUCH THE SHIT BELOW HERE ###
$a = $b = $to = $tr = $uac = 0;
$banned = explode(" ",$donotvote);
echo "  [ ! ] TweeterWall autovoter by e\n";
echo "  [ ! ] irc.888chan.org #invasion\n";
echo "  [ ~ ] Starting Script!\n";
echo "  [ ~ ] Populating Fake User-Agents -- This might take a while...\n";
foreach($user_k as $ugs) {
$x0 = file_get_contents($ugs);
preg_match_all("/<li>(.*?)<\/li>/", $x0, $ua);
foreach($ua[1] as $uas) {
$useragents[] = strip_tags($uas);
}
}
echo "  [ ! ] Found ".count($useragents)." User-Agents!\n";
echo "  [ ~ ] Randomizing...\n";
shuffle($useragents);
echo "  [ ! ] Done! User-agent spoofing -- ACTIVE!\n";
#die;
$basestart = time();
while(1) {
if($tr == 0) {
echo "  [ ! ] First run, the time is ".date('l jS \of F Y h:i:s A')."\n";
} else {
echo "  [ ! ] Waking up! $tr run! the time is ".date('l jS \of F Y h:i:s A')."\n";
}
$tr++;
$next = time() + (21*60);
$started = time();
$pgs = 32;
$pxx = 0;
for($px = $pxx; $px <= $pgs; $px++) {
	if($px > 0) {
		$url = $urlo."?page=".$px;
	} else $url = $urlo;
$useragent = $useragents[$uac];
$uac++;
echo "  [ ~ ] Spoofing User-Agent to $useragent\n";
echo "  [ ! ] Loading Page: $px/$pgs\n";
echo "  [ ~ ] Fetching Token\n";
$ch = curl_init();
$cookies = "cookie.txt";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
#curl_setopt($ch, CURLOPT_REFERER, "refererAddress");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$wall = curl_exec($ch);
curl_close($ch);
unset($ch);

preg_match('/id="edit-auto-submit-token" value="(.*?)"/', $wall, $tokens);
if (!isset($tokens[1])) {
	echo "  [ x ] TOKEN NOT FOUND -- INVALID PAGE?? !!!\n";
	echo "  [ x ] DIEING !!!\n";
	unlink($cookies);
	exit;
}
echo "  [ + ] Token Found: $tokens[1]\n";
preg_match('/id="users-country" rel="([0-9]+)"/', $wall, $cid);
echo "  [ ~ ] Fetching Country ID\n";
if (!isset($cid[1])) {
	echo "  [ x ] COUNTRY ID NOT FOUND -- INVALID PAGE?? !!!\n";
	echo "  [ x ] DIEING !!!\n";
	unlink($cookies);
	exit;
}
$z = array();

echo "  [ + ] Country ID Found: $cid[1]\n";
$votefor = split(" ", $vote);
$cv = count($votefor);
echo "  [ ~ ] Finding UIDs for all the people.\n";
    preg_match_all('/title="@([A-z0-9_-]+)"(.*?)id="twitter-pic([0-9]+)"/', $wall, $p);
    $i=0;
    foreach($p[1] as $x) {
	if(in_array("@".$x, $banned)) {
	echo "  [ ^ ] @$x is on the banned list, and will not be voted for.\n";
} else {
    	$z['@'.$x] = $p[3][$i];
    	echo "  [ % ] Found UID for @$x: ".$p[3][$i]."\n";
    	   	$i++;
}
    }
  #  print_r($p);
sleep(1);
$cz = count($z);
if($cz == 0) {
echo "  [ x ] No one to vote for!\n";
} else {
echo "  [ ~ ] Voting for ".$cz." people.\n";
$oc = 1;
foreach ($z as $y => $x) {
    echo "  [ ~ ] ($oc/$cz)  ".round($oc/$cz*100)."%	[Voting]: $y\n";
$oc++;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://tweeterwall.mallplace.com/tw/vote");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'country_id='.$cid[1].'&token='.$tokens[1].'&uid='.$x);
    $s = curl_exec($ch);
    curl_close($ch);
    unset($ch);
    if ($js = json_decode($s, 1)) {
        echo "  [ % ]             Vote on $y was successful!\n";
        echo "  [ + ]                   $y is now at {$js['vote_count']} votes!\n";
        $a++;
    } else {
        echo "  [ x ]             Failed to vote for $y!\n";
        $b++;
        }
} ## THE GAME ##

}
$to = $cz + $to;
unlink($cookies);
}
echo "  [ ! ] SO FAR! \n";
echo "  [ % ]      Success: 		$a	".round($a/$to*100)."%\n";
echo "  [ % ]      Failure: 		$b	".round($b/$to*100)."%\n";
#echo "  [ % ]      Total Missing:	".($cv-$cz)."	".round(($cz-$cv)/$cz*100)."%\n";
echo "  [ % ]      Total		$to \n";
#echo "  [ % ]      Total Input:	$cv\n";
echo "  [ ! ] This script has been running since ".$basestart." and took ".(time()-$started)." seconds to upvote everyone.\n";
echo "  [ z ] Going to sleep! I'll wake up in ".($next - time())." seconds!\n";
sleep($next - time());
}
#echo "  [ ! ] REMEMBER! Run this again in 20 minutes\n";
?>