User:SoxBot/Source/Signpost

The following post was automatically generated by Cyberbot I.

&lt;?php

/*while( $vol == &quot;&quot; ) { echo &quot;What volume is this issue in?\n&quot;; $vol = trim(fgets(STDIN)); }

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

define('PILLAR','PILLAR'); require_once('/home/cyberpower678/pillar/trunk/class.pillar.php');

$pillar = Pillar::ini_launch('/home/cyberpower678/configs/afd-calc.cfg'); $site = $pillar-&gt;cursite;

$enablepage = &quot;User:Cyberbot I/Run/Newsletter&quot;; try { $run = new Page($site,$enablepage); $run = $run-&gt;get_text; } catch (PillarException $e) { die( &quot;Got an error when getting the enable page.\n&quot; ); } if( !preg_match( '/(enable|yes|run|go|start)/i', $run ) ) { die( &quot;Bot is disabled.\n&quot; ); }

if( $argv[2] != &quot;--nosource&quot; || 1 == 1 ) { try { $page = new Page($pillar-&gt;cursite,'User:SoxBot/Source/Signpost'); } catch (PillarException $e) { continue; }	try { $page-&gt;put('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)'); } catch (PillarException $e) { continue; } }

$delivery['page'] = 'Wikipedia:Wikipedia_Signpost/Tools/Spamlist'; $delivery['text'] = &quot;\n\n \n\r&lt;small&gt;Delivered by  at &lt;/small&gt;&quot;; $delivery['sum']  = &quot;Delivering Wikipedia Signpost (BOT)&quot;; $errors = array;

try { $deliverypage = new Page($pillar-&gt;cursite,$delivery['page']); $deliverytext = $deliverypage-&gt;get_text; } catch (PillarException $e) { continue; }

if( $argv[1] != &quot;--continue&quot; ) { preg_match_all('/[^\&gt;]\[\[(User|User_talk|User talk):.+\]\]/Si',$deliverytext,$pages); foreach ($pages[0] as $i =&gt; $p) { $temp = explode('|',$p); $p = preg_replace(array('/.*\[\[(User|User_talk|User talk):/Si','/\]\].*/i'),'',$temp[0]); deliver($p); } } else { $p = unserialize(file_get_contents('signpost.errors.log')); foreach( $p as $page ) { $p = $p[0]; $p = preg_replace('/(User|User_talk|User talk):/Si','',$page); deliver($p); } }

print_r($pages);die;

function deliver($page) { //Delivers the newsletter to $page global $wpi, $wpapi, $wpq, $delivery, $errors, $pillar, $argv; $page = &quot;User_talk:&quot;.trim($page);

try { $page_instance = new Page($pillar-&gt;cursite,$page); $content = $page_instance-&gt;get_text; } catch (PillarException $e) { $errors[] = array($page,$e); }

if (preg_match('/#REDIRECT \[\[.+\]\]/Si',$content,$new_page)) { $page = str_replace(array('#REDIRECT ',),,$new_page[0]); try { unset($page_instance); $page_instance = new Page($pillar-&gt;cursite,$page); $content = $page_instance-&gt;get_text; } catch (PillarException $e) { $errors[] = array($page,$e); }		if( !preg_match('/(User|User_talk|User talk):/Si', $page) ) return; }  	echo &quot;Sending to $page\n&quot;; preg_match('/--start=(.*)/',$argv[1],$m); $tmparr = array(  		$page,   		@$m[1]   	); sort($tmparr); print_r($tmparr); if( $tmparr[0] == $page ) { echo &quot;Already sent, skipping.\n&quot;; }		  	else { if( $page_instance-&gt;checkexcluded ) continue; if ($content != ''){ try { $page_instance-&gt;put($content.$delivery['text'],$delivery['sum'],false); } catch (PillarException $e) { $errors[] = array($page,$e); }	  	}   	} }

print_r($errors);

file_put_contents('signpost.errors.log',serialize($errors));