recache.php 1.1 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. $files = array_diff(scandir('.'), array('..', '.'));
  3. $channels = array();
  4. foreach ($files as $file) {
  5. if (substr_compare($file, ".html", -5, 5) === 0)
  6. array_push($channels, $file);
  7. }
  8. $cache = fopen("index-cache.txt", "w");
  9. $cache_data = array();
  10. foreach ($channels as $channel) {
  11. $html = new DOMDocument();
  12. $html->loadHTML(file_get_contents($channel));
  13. $name = explode(" @ ", $html->getElementsByTagName("title")->item(0)->textContent)[0];
  14. $date = "";
  15. $nicksCount = "";
  16. $temp = $html->getElementById("pagetitle2");
  17. if (!is_null($temp))
  18. $date = explode("on ", $temp->textContent)[1];
  19. $temp = $html->getElementById("pagetitle3");
  20. if (!is_null($temp))
  21. $usersCount = $temp->getElementsByTagName("b")->item(0)->textContent;
  22. $cache_data[$name] = array("file" => $channel, "date" => $date, "users" => $usersCount);
  23. }
  24. $cache_data["refresh_date"] = date('l jS \of F Y h:i:s A');
  25. fwrite($cache, json_encode($cache_data));
  26. ?>