4 http://php.net/manual/en/xmlreader.readstring.php
6 function read_string($reader) {
7 $node = $reader->expand();
8 return $node->textContent
;
11 //ledger files to check
12 $ledger_url = "../4Chan_Bans_Log-Ledger.txt";
13 $ledger_contents = explode("\n", fread(fopen($ledger_url, "r"), filesize($ledger_url)));
14 $ledger_contents[2] = $ledger_contents[1] - 1;
16 $ledger_string_A = "http://bans.verniy.xyz/Logs/4Chan_Bans_Log-Reverse_Chrono-".$ledger_contents[2].".json";
17 $ledger_string_B = "http://bans.verniy.xyz/Logs/4Chan_Bans_Log-Reverse_Chrono-$ledger_contents[1].json";
18 echo($ledger_string_A . " " . $ledger_string_B . "<br/>");
20 //cehcks sitemap for changes
21 $xml_reader = new XMLReader
;
22 $xml_reader->open("../sitemap.xml");
26 while($xml_reader->read()){
27 if($xml_reader->nodeType
== XMLReader
::ELEMENT
&& $xml_reader->name
== "loc"){
28 if(strcmp($xml_reader->readString(), $ledger_string_A) == 0){
29 echo $xml_reader->readString(). " == $ledger_string_A <br/> AAAA<br/><br/>";
32 else if(strcmp($xml_reader->readString(), $ledger_string_B) == 0){
33 echo $xml_reader->readString(). " == $ledger_string_B <br/> BBBB<br/><br/>";
36 else echo $xml_reader->readString() . " != $ledger_string_A && != $ledger_string_B<br/>";
43 $dom_sitemap = new DOMDocument
;
44 $dom_sitemap->load("../sitemap.xml");
46 $head = $dom_sitemap->getElementsByTagName("urlset")->item(0);
49 $url = $dom_sitemap->createElement("url");
50 $head->appendChild($url);
52 $loc = $dom_sitemap->createElement("loc");
53 $loc_text = $dom_sitemap->createTextNode($ledger_string_A);
54 $loc->appendChild($loc_text);
55 $url->appendChild($loc);
57 $lastmod = $dom_sitemap->createElement("lastmod");
58 $file_mod_time = date ("Y-m-dTH:i:s", filemtime("../Logs/4Chan_Bans_Log-Reverse_Chrono-" . $ledger_contents[2] . ".json")) . "+00:00";
59 $file_mod_time = str_replace("CST", "T", $file_mod_time);
60 $lastmod_text = $dom_sitemap->createTextNode($file_mod_time);
61 $lastmod->appendChild($lastmod_text);
62 $url->appendChild($lastmod);
63 $priority = $dom_sitemap->createElement("priority");
65 $priority = $dom_sitemap->createElement("priority");
66 $priority_text = $dom_sitemap->createTextNode("0.64");
67 $priority->appendChild($priority_text);
68 $url->appendChild($priority);
71 $url = $dom_sitemap->createElement("url");
72 $head->appendChild($url);
74 $loc = $dom_sitemap->createElement("loc");
75 $loc_text = $dom_sitemap->createTextNode($ledger_string_B);
76 $loc->appendChild($loc_text);
77 $url->appendChild($loc);
79 $lastmod = $dom_sitemap->createElement("lastmod");
80 $file_mod_time = date ("Y-m-dTH:i:s", filemtime("../Logs/4Chan_Bans_Log-Reverse_Chrono-" . $ledger_contents[1] . ".json")) . "+00:00";
81 $file_mod_time = str_replace("CST", "T", $file_mod_time);
82 $lastmod_text = $dom_sitemap->createTextNode($file_mod_time);
83 $lastmod->appendChild($lastmod_text);
84 $url->appendChild($lastmod);
85 $priority = $dom_sitemap->createElement("priority");
87 $priority = $dom_sitemap->createElement("priority");
88 $priority_text = $dom_sitemap->createTextNode("0.64");
89 $priority->appendChild($priority_text);
90 $url->appendChild($priority);
94 $contents = $dom_sitemap->saveHTML();
96 $sitemap = fopen("../sitemap.xml", "w");
97 fwrite($sitemap, $contents);