<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.occupyboston.org/wiki/index.php?action=history&amp;feed=atom&amp;title=User%3AMcktimo%2Fscripts%2Fdiscussgrab2.php</id>
	<title>User:Mcktimo/scripts/discussgrab2.php - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.occupyboston.org/wiki/index.php?action=history&amp;feed=atom&amp;title=User%3AMcktimo%2Fscripts%2Fdiscussgrab2.php"/>
	<link rel="alternate" type="text/html" href="https://wiki.occupyboston.org/wiki/index.php?title=User:Mcktimo/scripts/discussgrab2.php&amp;action=history"/>
	<updated>2026-04-28T14:01:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.occupyboston.org/wiki/index.php?title=User:Mcktimo/scripts/discussgrab2.php&amp;diff=881&amp;oldid=prev</id>
		<title>Mcktimo: Created page with &quot;&lt;pre&gt; &lt;?php header('Content-Type: text/xml'); include_once('simple_html_dom.php');  $dir  = &quot;obout/&quot;; //directory of all pages $urllist = whichPagesHaveDiscussion($dir);  //print...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.occupyboston.org/wiki/index.php?title=User:Mcktimo/scripts/discussgrab2.php&amp;diff=881&amp;oldid=prev"/>
		<updated>2011-10-22T02:53:50Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;pre&amp;gt; &amp;lt;?php header(&amp;#039;Content-Type: text/xml&amp;#039;); include_once(&amp;#039;simple_html_dom.php&amp;#039;);  $dir  = &amp;quot;obout/&amp;quot;; //directory of all pages $urllist = whichPagesHaveDiscussion($dir);  //print...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
header('Content-Type: text/xml');&lt;br /&gt;
include_once('simple_html_dom.php');&lt;br /&gt;
&lt;br /&gt;
$dir  = &amp;quot;obout/&amp;quot;; //directory of all pages&lt;br /&gt;
$urllist = whichPagesHaveDiscussion($dir);&lt;br /&gt;
&lt;br /&gt;
//print_r($urllist);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;mediawiki xml:lang=&amp;quot;en&amp;quot; xmlns=&amp;quot;http://www.mediawiki.org/xml/export-0.5/&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot; xsi:schemaLocation=&amp;quot;http://www.mediawiki.org/xml/export-0.5/ http://www.mediawiki.org/xml/export-0.5.xsd&amp;quot; version=&amp;quot;0.5&amp;quot; &amp;gt;&lt;br /&gt;
&amp;lt;?&lt;br /&gt;
$theXML = createDiscussionXML($urllist);&lt;br /&gt;
&lt;br /&gt;
//echo $theXML;&lt;br /&gt;
&lt;br /&gt;
function whichPagesHaveDiscussion($dir){&lt;br /&gt;
	// open a known directory, and proceed to read its contents&lt;br /&gt;
	$farr=array();&lt;br /&gt;
	if (is_dir($dir)) {&lt;br /&gt;
		if ($dh = opendir($dir)) {&lt;br /&gt;
			while (($file = readdir($dh)) !== false) {&lt;br /&gt;
				if (filetype($dir . $file)=='file'){&lt;br /&gt;
					$farr[]=$file; //mak a list of just the files in the directory&lt;br /&gt;
				}&lt;br /&gt;
				//echo &amp;quot;filename: $file : filetype: &amp;quot; . filetype($dir . $file) . &amp;quot;\n&amp;quot;;&lt;br /&gt;
			}&lt;br /&gt;
			closedir($dh);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	// print_r($farr); //a list of all files in dir&lt;br /&gt;
	$urll=array();&lt;br /&gt;
	foreach ($farr as $pah){&lt;br /&gt;
		$url=&amp;quot;http://occupyboston.wikispaces.com/message/list/&amp;quot;.$pah;&lt;br /&gt;
		$html = file_get_html($url);&lt;br /&gt;
		$d = $html-&amp;gt;find('th[class=&amp;quot;pagination&amp;quot;] ');&lt;br /&gt;
		foreach ($d as $dd){ &lt;br /&gt;
			if (strlen($dd) &amp;gt;5 ) { //if this tag is found then there is discussion&lt;br /&gt;
				$urll[]=$url; //this page has a discussion, add it to list&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return $urll; //a list of web pages with discussions&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function createDiscussionXML($urllist){	&lt;br /&gt;
	&lt;br /&gt;
	foreach ($urllist as $url){&lt;br /&gt;
		$pgtitle = str_replace(&amp;quot; &amp;quot;, &amp;quot;_&amp;quot;, substr($url,48));&lt;br /&gt;
		$html = file_get_html($url);&lt;br /&gt;
		$dl=array(); //declares an array&lt;br /&gt;
		foreach($html-&amp;gt;find('td[class=&amp;quot;w_subject&amp;quot;] a') as $d)&lt;br /&gt;
		{&lt;br /&gt;
			$path = $d-&amp;gt;href;&lt;br /&gt;
			$dl[] = strip_tags($path); //adds to the end of the array&lt;br /&gt;
		}&lt;br /&gt;
		//print_r($dl);&lt;br /&gt;
		$d=$dl[0];&lt;br /&gt;
		$pg = 'This is my page, its not much anyway so what';&lt;br /&gt;
		$pg = createDiscussionPage($dl);&lt;br /&gt;
		?&amp;gt;&lt;br /&gt;
		&amp;lt;page&amp;gt;&lt;br /&gt;
			&amp;lt;title&amp;gt;User_talk:Mcktimo/take1/&amp;lt;?echo $pgtitle;?&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
		  &amp;lt;revision&amp;gt;&lt;br /&gt;
	        &amp;lt;timestamp&amp;gt;2011-10-19T01:01:00Z&amp;lt;/timestamp&amp;gt;&lt;br /&gt;
	      &amp;lt;contributor&amp;gt;&lt;br /&gt;
	        &amp;lt;username&amp;gt;Mcktimo&amp;lt;/username&amp;gt;&lt;br /&gt;
	        &amp;lt;id&amp;gt;3&amp;lt;/id&amp;gt;&lt;br /&gt;
	      &amp;lt;/contributor&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	        &amp;lt;text xml:space=&amp;quot;preserve&amp;quot;&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;?&lt;br /&gt;
echo $pg;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/text&amp;gt;&lt;br /&gt;
      &amp;lt;/revision&amp;gt;&lt;br /&gt;
&amp;lt;/page&amp;gt;&lt;br /&gt;
&amp;lt;?		&lt;br /&gt;
		$xmlf.= $pg;&lt;br /&gt;
	}&lt;br /&gt;
	return $xmlf;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function createDiscussionPage($dlist) {&lt;br /&gt;
&lt;br /&gt;
	$pg=&amp;quot;&amp;quot;;&lt;br /&gt;
	foreach($dlist as $d){&lt;br /&gt;
		$url= &amp;quot;http://occupyboston.wikispaces.com&amp;quot; . $d;&lt;br /&gt;
		$html = file_get_html($url);&lt;br /&gt;
		//echo $url.&amp;quot;\n\n&amp;quot;;&lt;br /&gt;
		$dti = $html-&amp;gt;find('h1[class=&amp;quot;noSpacing&amp;quot;] ');&lt;br /&gt;
		$dtit = strip_tags($dti[0]);&lt;br /&gt;
		//echo $dtit.&amp;quot;\n&amp;quot;;&lt;br /&gt;
		$uid=array(); //declares an array	&lt;br /&gt;
		$dat=array(); //declares an array	&lt;br /&gt;
		foreach($html-&amp;gt;find('td[class=&amp;quot;w_body&amp;quot;] strong' ) as $ut)&lt;br /&gt;
		{&lt;br /&gt;
&lt;br /&gt;
			$dat[]= strip_tags($ut);&lt;br /&gt;
			//$dat[] = strip_tags($ut[1]); //adds to the end of the array&lt;br /&gt;
		}&lt;br /&gt;
		foreach($html-&amp;gt;find('td[class=&amp;quot;w_body&amp;quot;] a' ) as $ut)&lt;br /&gt;
		{&lt;br /&gt;
&lt;br /&gt;
			$uid[]= strip_tags($ut);&lt;br /&gt;
			//$dat[] = strip_tags($ut[1]); //adds to the end of the array&lt;br /&gt;
		}	&lt;br /&gt;
		$raw=array(); //declares an array	&lt;br /&gt;
		foreach($html-&amp;gt;find('div[class=&amp;quot;wiki&amp;quot;] ') as $rt)&lt;br /&gt;
		{&lt;br /&gt;
			$raw[] = strip_tags($rt); //adds to the end of the array&lt;br /&gt;
			$raa = array_slice($raw,1,-2);&lt;br /&gt;
		}&lt;br /&gt;
		//echo count($uid);&lt;br /&gt;
		$ui=array();&lt;br /&gt;
		$di=array();&lt;br /&gt;
		for($i=0; $i&amp;lt; count($uid); $i++){&lt;br /&gt;
			if(($i+3) % 3){&lt;br /&gt;
				//do nothing&lt;br /&gt;
			} else {&lt;br /&gt;
				$ui[]=$uid[$i];&lt;br /&gt;
			}&lt;br /&gt;
			if(($i+2) % 3){&lt;br /&gt;
				//do nothing&lt;br /&gt;
			} else {&lt;br /&gt;
				$di[]=$uid[$i];&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		//print_r($dat);	&lt;br /&gt;
		//print_r($di);	&lt;br /&gt;
		//print_r($ui);	&lt;br /&gt;
		//print_r($raa);	&lt;br /&gt;
		$topic=&amp;quot;\n&amp;quot;;&lt;br /&gt;
		$topic.=&amp;quot;==&amp;quot;.$dtit.&amp;quot;==\n&amp;quot;;&lt;br /&gt;
		$topic.=&amp;quot;:[[user:&amp;quot;.$ui[0].&amp;quot;]] &amp;quot;.$di[0].&amp;quot;\n&amp;quot;;&lt;br /&gt;
		$topic.=$raa[0].&amp;quot;\n&amp;quot;;&lt;br /&gt;
		for ($i=1; $i &amp;lt; count($raa); $i++){&lt;br /&gt;
			$topic.=&amp;quot;====&amp;quot;.$dat[$i-1].&amp;quot;====\n&amp;quot;;&lt;br /&gt;
			$topic.=&amp;quot;::[[user:&amp;quot;.$ui[$i].&amp;quot;]] &amp;quot;.$di[$i].&amp;quot;\n&amp;quot;;&lt;br /&gt;
			$topic.=$raa[$i].&amp;quot;\n&amp;quot;;	&lt;br /&gt;
		}&lt;br /&gt;
		$pg.= $topic;&lt;br /&gt;
	}&lt;br /&gt;
	return $pg;&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/mediawiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mcktimo</name></author>
	</entry>
</feed>