4 http://php.net/manual/en/xmlreader.readstring.php
6 function read_string($reader) {
7 $node = $reader->expand();
8 return $node->textContent
;
12 $ledger_url = "../4Chan_Bans_Log-Ledger.txt";
13 $ledger_contents = explode("\n", fread(fopen($ledger_url, "r"), filesize($ledger_url)));
15 $number_of_files = intval($ledger_contents[1]);
18 while($number_of_files > 0){
19 array_push($ledger_string, "http://bans.verniy.xyz/Logs/4Chan_Bans_Log-Reverse_Chrono-".$number_of_files.".json");
20 array_push($ledger_string, "http://bans.verniy.xyz/pages?file=".($number_of_files +
1));
21 array_push($write_test, true);
22 array_push($write_test, true);
26 //cehcks sitemap for changes
27 $xml_reader = new XMLReader
;
28 $xml_reader->open("../sitemap.xml");
30 while($xml_reader->read()){
31 if($xml_reader->nodeType
== XMLReader
::ELEMENT
&& $xml_reader->name
== "loc"){
32 foreach($ledger_string as $index=>$ledger_item){
33 $file_point = ceil($index / 2 +
1);
34 if(strcmp($xml_reader->readString(), $ledger_string[$index]) == 0){
35 //echo $xml_reader->readString(). " Found $file_point \n";
36 $write_test[$index] = false;
45 $dom_sitemap = new DOMDocument
;
46 $dom_sitemap->formatOutput
= true;
47 $dom_sitemap->load("../sitemap.xml");
49 $head = $dom_sitemap->getElementsByTagName("urlset")->item(0);
51 foreach($write_test as $index=>$write){
53 $url = $dom_sitemap->createElement("url");
54 $head->appendChild($url);
56 $loc = $dom_sitemap->createElement("loc");
57 $loc_text = $dom_sitemap->createTextNode($ledger_string[$index]);
58 $loc->appendChild($loc_text);
59 $url->appendChild($loc);
61 $lastmod = $dom_sitemap->createElement("lastmod");
64 $filename = substr($ledger_string[$index], 27);
65 $file_mod_time = date ("Y-m-dTH:i:s", filemtime("../Logs/$filename")) . "+00:00";
66 $file_mod_time = str_replace("CST", "T", $file_mod_time);
69 $filename = substr($ledger_string[$index - 1], 27);
70 $file_mod_time = date ("Y-m-dTH:i:s", filemtime("../Logs/$filename")) . "+00:00";
72 $lastmod_text = $dom_sitemap->createTextNode($file_mod_time);
73 $lastmod->appendChild($lastmod_text);
74 $url->appendChild($lastmod);
76 $priority = $dom_sitemap->createElement("priority");
78 $priority = $dom_sitemap->createElement("priority");
79 $priority_text = $dom_sitemap->createTextNode("0.64");
80 $priority->appendChild($priority_text);
81 $url->appendChild($priority);
86 $contents = $dom_sitemap->saveHTML();
87 echo("<pre>$contents");
88 $sitemap = fopen("../sitemap.xml", "w");
89 fwrite($sitemap, $contents);