diff options
| author | lolcat <will@lolcat.ca> | 2026-04-25 22:58:28 -0400 |
|---|---|---|
| committer | lolcat <will@lolcat.ca> | 2026-04-25 22:58:28 -0400 |
| commit | e63a17d6dbc474a8220b651f61353d871b2f9674 (patch) | |
| tree | 8d1c37dad8de68855abf035154aceca6bd9575e3 /lib/frontend.php | |
| parent | 4349bf232d93fa1f868668f50b948bd9b90dff47 (diff) | |
added google api image scraper
Diffstat (limited to 'lib/frontend.php')
| -rw-r--r-- | lib/frontend.php | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/lib/frontend.php b/lib/frontend.php index 7cf4e24..d3ff0c3 100644 --- a/lib/frontend.php +++ b/lib/frontend.php @@ -2,6 +2,52 @@ class frontend{ + public function validateurl($url, $net_validate = false){ + + $url_parts = parse_url($url); + + // check if required parts are there + if( + !isset($url_parts["scheme"]) || + !( + $url_parts["scheme"] == "http" || + $url_parts["scheme"] == "https" + ) || + !isset($url_parts["host"]) + ){ + return false; + } + + if($net_validate){ + $ip = + str_replace( + ["[", "]"], // handle ipv6 + "", + $url_parts["host"] + ); + + // if its not an IP + if(!filter_var($ip, FILTER_VALIDATE_IP)){ + + // resolve domain's IP + $ip = gethostbyname($url_parts["host"] . "."); + } + + // check if its localhost + if( + filter_var( + $ip, + FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE + ) === false + ){ + + return false; + } + } + + return true; + } + public function load($template, $replacements = []){ $replacements["server_name"] = htmlspecialchars(config::SERVER_NAME); @@ -622,6 +668,7 @@ class frontend{ "yandex" => "Yandex", "brave" => "Brave", "google" => "Google", + "google_api" => "Google API", "google_cse" => "Google CSE", "yahoo_japan" => "Yahoo! JAPAN", "startpage" => "Startpage", @@ -638,8 +685,7 @@ class frontend{ "fivehpx" => "500px", "vsco" => "VSCO", "imgur" => "Imgur", - "ftm" => "FindThatMeme", - //"sankakucomplex" => "SankakuComplex" + "ftm" => "FindThatMeme" ] ]; break; @@ -695,6 +741,22 @@ class frontend{ ] ]; break; + + case "booru": + $filters["scraper"] = [ + "display" => "Scraper", + "option" => [ + "safebooru" => "Safebooru", + "konachan" => "Konachan", + "tbib" => "The Big Imageboard", + "gelbooru" => "Gelbooru", + "yandere" => "Yande.re", + "tbib" => "The Big Imageboard", + "sankakucomplex" => "SankakuComplex", + "soybooru" => "SoyBooru" + ] + ]; + break; } // get scraper name from user input, or default out to preferred scraper @@ -871,6 +933,7 @@ class frontend{ $html = null; + //foreach(["web", "images", "videos", "news", "music", "booru"] as $type){ foreach(["web", "images", "videos", "news", "music"] as $type){ $html .= '<a href="/' . $type . '?s=' . urlencode($query); |
