index.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. $sqlme = @new mysqli('localhost', 'sseeccrreett', 'sseeccrreett', 'sseeccrreett');
  3. if ($sqlme->connect_errno)
  4. {
  5. exit;
  6. }
  7. $count_all = - 1;
  8. if ($r = $sqlme->query("SELECT count(id) FROM toot_scanned;"))
  9. {
  10. $rr = mysqli_fetch_assoc($r);
  11. $r->free();
  12. $count_all = $rr['count(id)'];
  13. }
  14. $count_cf = - 1;
  15. if ($r = $sqlme->query("SELECT count(id) FROM toot_scanned WHERE iscf=1;"))
  16. {
  17. $rr = mysqli_fetch_assoc($r);
  18. $r->free();
  19. $count_cf = $rr['count(id)'];
  20. }
  21. if ($count_all == - 1 || $count_cf == - 1)
  22. {
  23. exit;
  24. }
  25. $count_acpct = round(($count_cf * 100) / $count_all, 2);
  26. $count_all = number_format($count_all);
  27. $count_cf = number_format($count_cf);
  28. $count_waitask = - 1;
  29. if ($r = $sqlme->query("SELECT count(fqdn) FROM toot_notcf_fqdn WHERE dl=0;"))
  30. {
  31. $rr = mysqli_fetch_assoc($r);
  32. $r->free();
  33. $count_waitask = $rr['count(fqdn)'];
  34. }
  35. $count_waitask = number_format($count_waitask);
  36. $lastuptime = humanTiming(filemtime('/onion/sseeccrreett/data/mastodon.toot.scan'));
  37. $var_who = htmlspecialchars($_GET['who'], ENT_QUOTES);
  38. $resultHTML = '';
  39. if (write_this_block_yourself)
  40. {
  41. $var_who = '';
  42. }
  43. if (preg_match("/write_this_block_yourself/", $var_who))
  44. {
  45. $resultHTML .= '<br><table border=1>';
  46. $person_a = 0;
  47. if ($r = $sqlme->query("SELECT count(id) FROM toot_scanned WHERE who='{$var_who}';"))
  48. {
  49. $rr = mysqli_fetch_assoc($r);
  50. $r->free();
  51. $person_a = $rr['count(id)'];
  52. }
  53. $person_b = 0;
  54. if ($r = $sqlme->query("SELECT count(id) FROM toot_scanned WHERE who='{$var_who}' AND iscf=1;"))
  55. {
  56. $rr = mysqli_fetch_assoc($r);
  57. $r->free();
  58. $person_b = $rr['count(id)'];
  59. }
  60. $person_c = round(($person_b * 100) / $person_a, 2);
  61. if (is_nan($person_c))
  62. {
  63. $person_c = 0;
  64. }
  65. $person_a = number_format($person_a);
  66. $person_b = number_format($person_b);
  67. $resultHTML .= "<tr><th>About</th><th>{$var_who}</th></tr>";
  68. $resultHTML .= "<tr><td>Toots has links</td><td>{$person_a}</td></tr>";
  69. $resultHTML .= "<tr><td>&#11169; Toots has Cloudflare link</td><td>{$person_b} [<i>{$person_c}</i>%]</td></tr>";
  70. $resultHTML .= "<tr><td> </td><td>Detected (LIMIT 100)</td></tr>";
  71. if ($r = $sqlme->query("SELECT url FROM toot_cfsaid WHERE who='{$var_who}' LIMIT 100;"))
  72. {
  73. while ($row = mysqli_fetch_assoc($r))
  74. {
  75. $vurl = htmlspecialchars($row['url'], ENT_QUOTES);
  76. $resultHTML .= "<tr><td></td><td><a href=\"{$vurl}\" target=\"_blank\">{$vurl}</a></td></tr>";
  77. }
  78. }
  79. $resultHTML .= '</table>';
  80. }
  81. elseif ($var_who == 'a')
  82. {
  83. $resultHTML .= '<br><table border=1><tr><th>Shared any links</th><th>Toots</th></tr>';
  84. if ($r = $sqlme->query("SELECT who,count(*) as count FROM toot_scanned GROUP BY who ORDER BY count DESC LIMIT 100;"))
  85. {
  86. while ($row = mysqli_fetch_assoc($r))
  87. {
  88. $rcount = number_format($row['count']);
  89. $resultHTML .= "<tr><td><a href=\"./?who={$row['who']}\">{$row['who']}</a></td><td>{$rcount}</td></tr>";
  90. }
  91. }
  92. $resultHTML .= '</table>';
  93. }
  94. elseif ($var_who == 'c')
  95. {
  96. $resultHTML .= '<br><table border=1><tr><th>Shared Cloudflare links</th><th>Toots</th></tr>';
  97. if ($r = $sqlme->query("SELECT who,count(*) as count FROM toot_scanned WHERE iscf=1 GROUP BY who ORDER BY count DESC LIMIT 100;"))
  98. {
  99. while ($row = mysqli_fetch_assoc($r))
  100. {
  101. $rcount = number_format($row['count']);
  102. $resultHTML .= "<tr><td><a href=\"./?who={$row['who']}\">{$row['who']}</a></td><td>{$rcount}</td></tr>";
  103. }
  104. }
  105. $resultHTML .= '</table>';
  106. }
  107. elseif ($var_who == 'f')
  108. {
  109. $resultHTML .= '<br><table border=1><tr><th>Shared FQDN</th><th>Cloudflare</th><th>Found in Toots</th></tr>';
  110. if ($r = $sqlme->query("SELECT fqdn,count(*) as count FROM toot_sharefqdn GROUP BY fqdn ORDER BY count DESC LIMIT 50;"))
  111. {
  112. while ($row = mysqli_fetch_assoc($r))
  113. {
  114. $rcount = number_format($row['count']);
  115. $riscf = is_known_cf(get_domainname($row['fqdn']) [1]) ? '<font color="red">Yes</font>' : 'No';
  116. $resultHTML .= "<tr><td>{$row['fqdn']}</td><td>{$riscf}</td><td>{$rcount}</td></tr>";
  117. }
  118. }
  119. $resultHTML .= '</table>';
  120. }
  121. else
  122. {
  123. $resultHTML .= '<ul><li> <a href="./?who=a">Show Top 100 (Shared any links)</a></li>';
  124. $resultHTML .= '<li> <a href="./?who=c">Show Top 100 (Shared Cloudflare links)</a></li>';
  125. $resultHTML .= '<li> <a href="./?who=f">Show Top 50 (Shared FQDN)</a></li>';
  126. $resultHTML .= '<li> <a href="#" onclick="location.href=\'./?who=\'+(prompt(\'user@example.com\')||\'\');">Search by Mastodon ID</a></li></ul>';
  127. }
  128. $finalpage = <<<HTMLRESULT
  129. <html><title>Shared on Mastodon</title><br><br><div>
  130. [ <a href="./">INDEX</a> ] Update <i>{$lastuptime} ago</i><br>
  131. <b>Toots has links</b>: {$count_all}<br>
  132. &#11169; <b>Toots has Cloudflare link</b>: {$count_cf} [<i>{$count_acpct}</i>%]<br>
  133. <b>Pending Investigation</b>: {$count_waitask}<br>
  134. <hr>{$resultHTML}</div></html>
  135. HTMLRESULT;
  136. echo (str_replace("\n", '', $finalpage));