Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $pages = Array();
- /*
- $data = file_get_contents("http://www.rouming.cz/roumingKiwiList.php");
- $links = get_links($data);
- foreach($links as $page){
- $html = file_get_contents("http://www.rouming.cz/roumingKiwi.php?page=".$page);
- $pages[$page] = get_links($html);
- }
- file_put_contents("out.json",json_encode($pages));
- */
- $pages = json_decode(file_get_contents("out.json"), true);
- $exist = array_map("slug", array_keys($pages));
- $pagelist = Array();
- $missing = Array();
- foreach($pages as $key => $list){
- $pagelist[] = slug($key);
- foreach($list as $page){
- $pagelist[] = slug($page);
- }
- }
- $pagelist = array_unique($pagelist);
- $missing = array_unique($missing);
- $out = Array();
- foreach($pages as $page => $to){
- foreach($to as $t){
- $dest = array_search(slug($t), $pagelist);
- if($dest === false){
- $out[] = "# missing $t \n";
- }
- $out[] = " x".array_search(slug($page), $pagelist)." -> x".$dest."[color=\"#000000aa\"];\n";
- }
- }
- $out = array_unique($out);
- echo "digraph G {\n";
- echo "overlap = false\n";
- echo "truecolor = true\n";
- foreach($pagelist as $i=>$key){
- echo "x$i [label=\"$key\"";
- if(array_search(slug($key), $exist) === false){
- echo ", fillcolor=red, fontcolor=white, style=filled";
- }
- echo "]";
- echo "\n";
- }
- echo implode("", $out);
- echo "}\n";
- function get_links($data){
- $match = Array();
- preg_match_all('/\?page=(.+?)(?=")/', $data, $match);
- return $match[1];
- }
- function slug($x){
- return strtolower($x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement