From b644536fbc30305d6006551c61737ba88bb5b0ae Mon Sep 17 00:00:00 2001 From: 7trey <7trey@noreply.codeberg.org> Date: Thu, 1 Apr 2021 06:39:30 +0200 Subject: [PATCH 1/6] Add 'tool/mastodonfind' --- tool/mastodonfind | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tool/mastodonfind diff --git a/tool/mastodonfind b/tool/mastodonfind new file mode 100644 index 000000000..4ddd282e7 --- /dev/null +++ b/tool/mastodonfind @@ -0,0 +1,14 @@ +### Find Mastodon Toots & Accounts + +- Cloudflare filtered out by default (enable from Advanced menu) +- JSON for developers + + +### Code + +- [index.php](index.php): Main website to show the result + + +## Related + +- [Mastodon Watch](../mastodonwch/) From d5664b48259bcc3d09e5719b0e2b12580bbfee93 Mon Sep 17 00:00:00 2001 From: 7trey <7trey@noreply.codeberg.org> Date: Thu, 1 Apr 2021 06:40:33 +0200 Subject: [PATCH 2/6] Update 'tool/mastodonfinder/README.md' --- tool/{mastodonfind => mastodonfinder/README.md} | 6 ++++++ 1 file changed, 6 insertions(+) rename tool/{mastodonfind => mastodonfinder/README.md} (68%) diff --git a/tool/mastodonfind b/tool/mastodonfinder/README.md similarity index 68% rename from tool/mastodonfind rename to tool/mastodonfinder/README.md index 4ddd282e7..6137d2886 100644 --- a/tool/mastodonfind +++ b/tool/mastodonfinder/README.md @@ -4,6 +4,12 @@ - JSON for developers +### Live example + +- [Tor](http://qyo4hcmvxiysc6zrxdn6rhofgkroyoygszkljw5izwdqklxfantseiyd.onion/) +- Clearnet + + ### Code - [index.php](index.php): Main website to show the result From ba265b7b8c1acbdc24e8442981bcf51c958ee98e Mon Sep 17 00:00:00 2001 From: 7trey <7trey@noreply.codeberg.org> Date: Thu, 1 Apr 2021 06:40:50 +0200 Subject: [PATCH 3/6] Update 'tool/mastodonfind/README.md' --- tool/{mastodonfinder => mastodonfind}/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tool/{mastodonfinder => mastodonfind}/README.md (100%) diff --git a/tool/mastodonfinder/README.md b/tool/mastodonfind/README.md similarity index 100% rename from tool/mastodonfinder/README.md rename to tool/mastodonfind/README.md From 048892d2499aaad75ad9b958b88cba22bfdc8edd Mon Sep 17 00:00:00 2001 From: 7trey <7trey@noreply.codeberg.org> Date: Thu, 1 Apr 2021 06:42:30 +0200 Subject: [PATCH 4/6] Add 'tool/mastodonfind/index.php' --- tool/mastodonfind/index.php | 179 ++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 tool/mastodonfind/index.php diff --git a/tool/mastodonfind/index.php b/tool/mastodonfind/index.php new file mode 100644 index 000000000..8de02e8c3 --- /dev/null +++ b/tool/mastodonfind/index.php @@ -0,0 +1,179 @@ + +$vi_opt_timeB = $_GET['tib']??$_POST['tib']; +if (!preg_match("/^2([0-9]{3})\-([0-9]{2})\-([0-9]{2})$/", $vi_opt_timeB)) { + $vi_opt_timeB = ''; +} //<-B +$vi_internal_tia = $vi_internal_tib = ''; +if ($vi_opt_timeA != '') { + $vi_internal_tia = gmdate('U', strtotime($vi_opt_timeA . ' 00:00:00')); + if ($vi_internal_tia > NOWTIME_U) { + $vi_internal_tia = NOWTIME_U; + } +} +if ($vi_opt_timeB != '') { + $vi_internal_tib = gmdate('U', strtotime($vi_opt_timeB . ' 23:59:59')); + if ($vi_internal_tib > NOWTIME_U) { + $vi_internal_tib = NOWTIME_U; + } +} +if (isset($vi_query)) { + $vi_query = cleanse_str($vi_query); + if (is_attackable_str($vi_query)) { + $vi_query = ''; + } +} +$vi_showquery = htmlspecialchars($vi_query, ENT_QUOTES); +$sql_Result = []; +if (strlen($vi_query) >= 2) { + $sqlme = @new mysqli('localhost', 'REDACTED', 'REDACTED', 'REDACTED'); + if ($sqlme->connect_errno) { + echo ('DB ERROR TRY AGAIN LATER'); + exit; + } + $sql_Query = 'SELECT * FROM REDACTED WHERE '; + $sql_Pcs = []; + $sql_smt = ($vi_opt_sm == 'a') ? 'who' : 'body'; + if (!$vi_opt_inclcf) { + $sql_Pcs[] = "iscf = '0' "; + } + if ($vi_opt_limitlg != '') { + $sql_Pcs[] = "lang = '{$vi_opt_limitlg}' "; + } + if ($vi_internal_tia != '') { + $sql_Pcs[] = "`when` >= '{$vi_internal_tia}' "; + } + if ($vi_internal_tib != '') { + $sql_Pcs[] = "`when` <= '{$vi_internal_tib}' "; + } + foreach (explode(' ', $vi_query) as $w) { + if (strlen($w) <= 1) { + continue; + } + if (strpos($w, 'author:') === 0) { + $w = str_replace('author:', '', $w); + if (strlen($w) < 2) { + continue; + } + $sql_Pcs[] = "who LIKE '%{$w}%' "; + continue; + } + if (strpos($w, '-author:') === 0) { + $w = str_replace('-author:', '', $w); + if (strlen($w) < 2) { + continue; + } + $sql_Pcs[] = "who NOT LIKE '%{$w}%' "; + continue; + } + if (strpos($w, '-') === 0) { + $w = str_replace('-', '', $w); + if (strlen($w) < 2) { + continue; + } + $sql_Pcs[] = "{$sql_smt} NOT LIKE '%{$w}%' "; + continue; + } + $sql_Pcs[] = "{$sql_smt} LIKE '%{$w}%' "; + } + if ($result = $sqlme->query($sql_Query . implode('AND ', $sql_Pcs) . ' ORDER BY `when` DESC LIMIT 500;')) { + while ($g = $result->fetch_array()) { + $sql_Result[] = $g; + } + } + $sqlme->close(); +} +if (isset($vi_json)) { + header('Content-Type: application/json; charset=utf-8'); + $finalRESP = []; + if ($vi_showquery == '') { + $finalRESP = ['method' => ['POST', 'GET'], 'accept_param' => ['q' => ['type' => 'string', 'value' => 'any', 'note' => 'Required'], 'sm' => ['type' => 'string', 'value' => ['a' => 'Account', 't' => 'Toot'], 'note' => 'default is t'], 'cf' => ['type' => 'existence', 'value' => 'any'], 'lg' => ['type' => 'string', 'value' => '2 letter'], 'tia' => ['type' => 'date', 'value' => 'Y-m-d'], 'tib' => ['type' => 'date', 'value' => 'Y-m-d']], 'example' => ['GET' => ['/?json&q=friend', '/?json&cf&lg=en&q=news']]]; + } else { + foreach ($sql_Result as $g) { + $finalRESP[] = ['url' => $g['url'], 'who' => $g['who'], 'when' => $g['when'], 'iscf' => $g['iscf'], 'lang' => $g['lang'], 'body' => str_replace(' ', ' ', $g['body']) ]; + } + } + echo (json_encode($finalRESP)); + exit; +} else { + header('Content-Type: text/html; charset=UTF-8'); + $finalRESP = ''; + foreach ($sql_Result as $g) { + $finalRESP.= '