User:SoxBot II/Source/Wikivoices

The following post was automatically generated by SoxBot II.

&lt;?php

while( $episode == &quot;&quot; ) { echo &quot;What episode is this?\n&quot;; $episode = trim(fgets(STDIN)); }

include(&quot;../svnbots/wikibot.classes.php&quot;);

$user = 'SoxBot II'; $pass = file_get_contents('../.password'); //Setup the classes $wpapi = new wikipediaapi; $wpq   = new wikipediaquery; $wpi   = new wikipediaindex; $wpapi-&gt;login($user,$pass);

if( $argv[2] != &quot;--nosource&quot; ) { $wpi-&gt;forcepost(		'User:'.$user.'/Source/Wikivoices',		'The following post was automatically generated by '.$user.&quot;.\n\n&lt;pre&gt;&quot; .		htmlentities(file_get_contents(__FILE__)) . 		&quot;&lt;/pre&gt;&quot;,		'Automatic source code upload (BOT)'	); }

$delivery['page'] = 'Wikipedia:Wikivoices/Subscribe'; $delivery['text'] = &quot;\n\n \n\r&lt;small&gt;Delievered by  at &lt;/small&gt;&quot;; $delivery['sum']  = &quot;Delivering episode $episode of Wikivoices (BOT)&quot;;

//preg_match_all('/[^\&gt;]\[\[(User|User_talk|User talk):.+\]\]/Si',$wpq-&gt;getpage($delivery['page']),$pages); preg_match_all('/\{\{user\|(.*?)\}\}/i',$wpq-&gt;getpage($delivery['page']),$pages); print_r($pages[1]); die; foreach ($pages[1] as $p) { echo &quot;Delivering to $p...\n&quot;; //deliver($p); }

function deliver($page) { //Delivers the newsletter to $page global $wpi, $wpapi, $wpq, $delivery; $page = &quot;User_talk:&quot;.trim($page); $content = $wpq-&gt;getpage($page); if (preg_match('/#REDIRECT \[\[.+\]\]/Si',$content,$new_page)) { $page = str_replace(array('#REDIRECT ',),,$new_page[0]); }	$content = $wpq-&gt;getpage($page); echo &quot;Sending to $page\n&quot;; $wpi-&gt;post($page,$content.$delivery['text'],$delivery['sum'],$minor = false,$rv = null,$bot = false); }