From 32c27924f5b1b4fb809107df3d4d0a2498f8d449 Mon Sep 17 00:00:00 2001 From: Arnan de Gans Date: Thu, 16 May 2024 19:12:14 -0600 Subject: [PATCH] Version 1.4 - NOTICE: config.default.php has changed, re-create your config.php!! - [fix] Footer no longer overlaps results - [fix] Search navigation no longer bunched up on smaller displays - [fix] Double search type when searching from start page - [new] Filter for additional/different headers per cURL request - [new] Image search via Openverse API (Access token and cronjob required, see installation instructions) - [new] Image search via Qwant API - [new] Web (recent news) search via Qwant API - [tweak] Merged 'cache' option into 'cache-type', see config.default.php for details - [tweak] Better filtering for duplicate web results - [tweak] File size formatting for images more uniform - [tweak] Optimized curl_multi_exec handling - [tweak] Improved SEO headers - [tweak] Layout tweaks and optimizations for search results, header and footer - [tweak] Removed redundant HTML, CSS and some PHP - [tweak] MagnetDL search disabled by default because of Cloudflare (Will probably be removed in future version) - [tweak] Removed non-functional magnet trackers - [tweak] Added 15 extra public magnet trackers - [change] Removed Ecosia support - [change] Removed Reddit support - [change] Removed 1337x support - [change] Removed MagnetDL support --- assets/css/styles.css | 299 ++++++++++++++-------------- assets/images/goosle.webp | Bin 0 -> 1476 bytes config.default.php | 191 ++++++++---------- engines/image/openverse.php | 111 +++++++++++ engines/image/qwant.php | 106 ++++++++++ engines/image/yahoo.php | 44 ++-- engines/magnet/1337x.php | 147 -------------- engines/magnet/eztv.php | 16 +- engines/magnet/lime.php | 10 +- engines/magnet/magnetdl.php | 64 ------ engines/magnet/magnetize_1337x.php | 29 --- engines/magnet/nyaa.php | 10 +- engines/magnet/thepiratebay.php | 36 ++-- engines/magnet/yts.php | 17 +- engines/search-image.php | 55 +++-- engines/search-magnet.php | 29 +-- engines/search.php | 42 ++-- engines/search/duckduckgo.php | 24 ++- engines/search/ecosia.php | 51 ----- engines/search/google.php | 24 ++- engines/search/qwantnews.php | 84 ++++++++ engines/search/reddit.php | 60 ------ engines/search/wikipedia.php | 21 +- engines/special/currency.php | 12 ++ engines/special/definition.php | 12 ++ engines/special/eztv_highlights.php | 12 ++ engines/special/php.php | 6 + engines/special/yts_highlights.php | 16 +- functions/oauth-functions.php | 59 ++++++ functions/oauth.php | 123 ++++++++++++ functions/search_engine.php | 102 +++++----- functions/tools.php | 109 +++++----- goosle-cron.php | 46 +++-- help.php | 196 +++++++++--------- index.php | 78 ++++---- readme.md | 96 +++++++-- results.php | 116 +++++++---- 37 files changed, 1400 insertions(+), 1053 deletions(-) create mode 100644 assets/images/goosle.webp create mode 100644 engines/image/openverse.php create mode 100644 engines/image/qwant.php delete mode 100644 engines/magnet/1337x.php delete mode 100644 engines/magnet/magnetdl.php delete mode 100644 engines/magnet/magnetize_1337x.php delete mode 100644 engines/search/ecosia.php create mode 100644 engines/search/qwantnews.php delete mode 100644 engines/search/reddit.php create mode 100644 functions/oauth-functions.php create mode 100644 functions/oauth.php diff --git a/assets/css/styles.css b/assets/css/styles.css index 4e77d07..987197c 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -9,8 +9,7 @@ * liability that might arise from its use. ------------------------------------------------------------------------------------ */ -html { font-size: 16px; } -body { position: relative; margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; color: #222; background-color: #ffffff; line-height: 1.2; } +body { margin: 0; padding: 0; background-color: #fff; font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #222; line-height: 1.2; } div { margin: 0; padding: 0; border: 0; vertical-align: baseline; } article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; } h2, h3, h4, h5, h6 { font-weight: normal; } @@ -22,110 +21,108 @@ p { font-size: 18px; color: #494949; } a { text-decoration: none; color: #4495d4; } small, sub, sup { padding: 5px 0; color: #666; font-size: 12px; } sub, sup { font-style: italic; } +pre, code { word-wrap: break-word; overflow-wrap: break-word; } a:hover { text-decoration: underline; } -input[type="text"]:invalid ~ input[type="submit"] { opacity: 0.5; pointer-events: none; } -input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; -webkit-mask-image: url("data:image/svg+xml;utf8,"); } +input[type="text"]: invalid ~ input[type="submit"] { opacity: 0.5; pointer-events: none; } +input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; -webkit-mask-image: url("data: image/svg+xml;utf8,"); } /* Page structure */ -.wrap { min-height: 100vh; overflow: hidden; } -.header-wrap { display: block; padding-top: 16px; width: 100%; } -.results-wrap { position: relative; display: flex; margin: 0 158px 50px 158px; } -.footer-wrap { position: absolute; bottom: 0; display: block; margin-top: 15px; padding: 0; width: 100%; } - -/* Main page */ -body.main { background-color: #1f242b; color: #f0f6fc; } -.search-box-main, .password-generator { text-align: center; margin-top: 10%; } -.search-box-main h1 { font-size: 4rem; } -.search-box-main .search, .password-generator .password { padding: 10px 20px; width: 600px; color: #f0f6fc; background-color: #333333; font-size: 2rem; font-family: sans-serif; border: 1px solid #3C4043; border-radius: 10px; } -.search-box-main .search[type="search"]::-webkit-search-cancel-button { background-size: 28px 28px; height: 28px; width: 28px; background-color: #f0f6fc; } -.search-box-buttons button { margin: 30px 20px 10px 20px; padding: 13px 10px 13px 10px; min-width: 130px; color: #f0f6fc; background-color: #333333; font-size: 0.8rem; border: 1px solid #3C4043; border-radius: 6px; } -.search-box-buttons button:hover { border: 1px solid #5f6368; } +body { min-height: 100vh; display: flex; flex-direction: column; } +.header { padding-top: 16px; width: 100%; } +.content { margin: 0 158px; padding: 15px 0; } +.footer { bottom: 0; margin-top: auto; padding: 0; width: 100%; } + +/* Start page */ +.startpage { background-color: #1f242b; color: #f0f6fc; } +.startpage-search, .password-generator { text-align: center; margin-top: 10%; } +.startpage-search h1 { font-size: 4rem; } +.startpage-search .search, .password-generator .password { padding: 10px 20px; width: 600px; color: #f0f6fc; background-color: #333333; font-size: 2rem; font-family: sans-serif; border: 1px solid #3C4043; border-radius: 10px; } +.startpage-search .search[type="search"]::-webkit-search-cancel-button { background-size: 28px 28px; height: 28px; width: 28px; background-color: #f0f6fc; } +.search-buttons button { margin: 30px 20px 10px 20px; padding: 13px 10px 13px 10px; min-width: 130px; color: #f0f6fc; background-color: #333333; font-size: 1rem; border: 1px solid #3C4043; border-radius: 6px; } +.startpage-search .search:focus, .password-generator .password:focus, .search-buttons button:hover { border: 1px solid #5f6368; } .password-generator { margin: 30px auto; padding: 0; } .password-generator .password { margin: 10px auto; width: 300px; text-align: center; font-size: 0.8rem; } -/* Search Results - Header */ -.header-wrap { background-color: #1f242b; color: #f0f6fc; border-bottom: 2px solid #1fa4d1; } -.header-wrap .search, .header-wrap .button { position: relative; height: 40px; color: #f0f6fc; font-size: 1rem; font-weight: 400; } -.header-wrap .search { margin: 28px 0 28px 158px; padding: 5px 5px 5px 15px; width: 580px; background-color: #1f242b; border: 1px solid #303842; border-radius: 10px 0 0 10px; } -.header-wrap .search[type="search"]::-webkit-search-cancel-button { background-size: 20px 20px; height: 20px; width: 20px; background-color: #f0f6fc; } -.header-wrap .button { margin: 28px 10px 28px 0; padding: 5px 20px 5px 15px; background-color: #1fa4d1; border: none; border-radius: 0 10px 10px 0; } - -/* Search results - Header Navigation */ -.navigation-header { margin-left: 165px; margin-bottom: 10px; } -.navigation-header img { margin-right: 5px; height: 16px; vertical-align: middle; } -.navigation-header a { margin-right: 20px; border: none; font-size: 1rem; cursor: pointer; text-decoration: none; } -.navigation-header a:hover { color: #ebf3fa; } -.navigation-header a:visited { color: #1fa4d1; } -.navigation-header .active { padding-bottom: 8px; border-bottom: 4px #1fa4d1 solid; } - -/* Search results */ -.main-column { width: 100%; } -.main-column ol .meta { margin: .75rem 0 .05rem 0; padding: .5rem 10px 0 10px; } -.main-column ol .sources { margin: .05rem 0 .75rem 0; padding: 0 10px .5rem 10px; font-size: 0.75rem; color: #666; } - -.main-column ol .special-result { margin: .75rem 0 .25rem 0; padding: .5rem 10px; } -.main-column ol .result { margin: .50rem 0 .50rem 0; padding: 0; } - -.main-column ol li article { padding: .5rem 10px; border: 1px solid #fefefe; border-radius: 8px; } -.main-column ol li article div.url:first-child, .main-column ol li.special-result article div.source:first-child { flex-grow: 0; } -.main-column ol li article div.url { display: inline-block; margin: 0; max-width: 100%; color: #666; font-size: 1rem; line-height: 1.6; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } -.main-column ol li article div.url a { margin: 0; color: #3f6e35; cursor: pointer; text-decoration: none; } -.main-column ol li article div.title, .main-column ol li.special-result article div.title { margin-bottom: .29rem; } -.main-column ol li article div.title h2 { margin: 0; padding: 0; position: relative; font-size: 1.46rem; letter-spacing: -.01px; } -.main-column ol li article div.title h2:hover { text-decoration: underline; } -.main-column ol li article div.title a { margin: 0; display: block; cursor: pointer; } -.main-column ol li article div.title a:visited { color: #6d59a3; } -.main-column ol li article div.description { margin: 0; line-height: 1.4; font-size: 1rem; color: #494949; } -.main-column ol li article div.engine { padding: 2px 0; font: 12px italic; color: #666; } -.main-column ol li article div.description .seeders { color: #518257; } -.main-column ol li article div.description .leechers { color: #c00; } - -/* Image results */ -.main-column .image-wrapper { width: 100%; margin: .75rem 0 .75rem 0; } -@supports not (display: grid) { - .image-grid > * { max-width: 8rem; margin-left: auto; margin-right: auto; } - .image-grid li.result { display: inline-block; margin: .75rem; width: 12.5%; } - .image-grid > * + * { margin-top: 1rem; } -} +/* oAUTH page*/ +.oauthpage { background-color: #1f242b; color: #f0f6fc; } +.oauth-form { text-align: center; margin-top: 20px; } +.oauth-form h1 { font-size: 4rem; } +.oauth-form p, .oauth-form small { margin-bottom: 15px; color: #f0f6fc; } +.oauth-form .field { padding: 5px 10px; width: 300px; color: #f0f6fc; background-color: #333333; font-size: 1rem; font-family: sans-serif; border: 1px solid #3C4043; border-radius: 10px; } +.oauth-buttons button { margin: 30px 20px 10px 20px; padding: 13px 10px 13px 10px; min-width: 130px; color: #f0f6fc; background-color: #333333; font-size: 1rem; border: 1px solid #3C4043; border-radius: 6px; } +.oauth-buttons button:hover { border: 1px solid #5f6368; } + +/* Results page header */ +.header { background-color: #1f242b; color: #f0f6fc; border-bottom: 2px solid #1fa4d1; } +.header .search, .header .button { position: relative; height: 40px; color: #f0f6fc; font-size: 1rem; font-weight: 400; } +.header .search { margin: 28px 0 28px 158px; padding: 5px 5px 5px 15px; width: 580px; background-color: #1f242b; border: 1px solid #5f6368; border-radius: 10px 0 0 10px; } +.header .search[type="search"]::-webkit-search-cancel-button { background-size: 20px 20px; height: 20px; width: 20px; background-color: #f0f6fc; } +.header .button { margin: 28px 10px 28px 0; padding: 5px 20px 5px 15px; background-color: #1fa4d1; border: none; border-radius: 0 10px 10px 0; } + +.navigation { margin-left: 158px; margin-bottom: 10px; } +.navigation img { margin-right: 5px; height: 16px; vertical-align: middle; } +.navigation a { margin-right: 20px; border: none; font-size: 1rem; cursor: pointer; text-decoration: none; } +.navigation a:hover { color: #ebf3fa; } +.navigation a: visited { color: #1fa4d1; } +.navigation .active { padding-bottom: 8px; border-bottom: 4px solid #1fa4d1; } + +/* Search results spacing */ +.content .meta { padding: 10px 0 0 0; } +.content .sources { padding: 0 0 10px 0; font-size: 0.75rem; color: #666; } +.content .suggestion { padding: 15px 0; } +.content .result { margin: 0 0 25px 0; } +.content .result-special { margin: 15px 0 25px 0; padding: 10px; } +.content .result.image { margin: 0; } + +/* Search results (web, image and magnet) */ +.content .result { border: 1px solid #fefefe; border-radius: 8px; } +.content .result div.url, .content .result-special div.source { max-width: 100%; font-size: 1rem; line-height: 1.6; letter-spacing: .2px; white-space: nowrap; overflow: hidden; } +.content .result div.url a, .content .result-special div.source a { color: #3f6e35; cursor: pointer; text-decoration: none; } +.content .result div.title, .content .result-special div.title { margin-bottom: 5px; } +.content .result div.title h2 { padding: 0; position: relative; font-size: 1.46rem; letter-spacing: -.01px; } +.content .result div.title h2:hover { text-decoration: underline; } +.content .result div.title a { display: block; cursor: pointer; } +.content .result div.title a: visited { color: #6d59a3; } +.content .result div.description { line-height: 1.4; font-size: 1rem; color: #494949; } +.content .result div.engine { padding: 2px 0; font: 12px italic; color: #666; } +.content .result div.description .seeders { color: #518257; } +.content .result div.description .leechers { color: #c00; } + +.content .result-special { position: relative; background-color: #fefefe; overflow: hidden; border: 1px solid #aeaeae; border-radius: 8px; color: #222; } +.content .result-special div.title h2 { padding: 0; font-size: 1.5rem; font-weight: 600; word-wrap: break-word; color: #222; } +.content .result-special div.title h2:hover { text-decoration: none; } +.content .result-special div.title a { display: block; color: #6c00a2; cursor: pointer; } +.content .result-special div.title a: visited { color: #6d59a3; } +.content .result-special div.text, .content .result-special div.source { position: relative; font-style: normal; } + +/* Grids (image and magnet highlights) */ @supports (display: grid) { - .main-column ol.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); grid-gap: 1rem; } + .image-grid ol, .magnet-grid ol { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); grid-gap: 1rem; } } -.main-column ol.image-grid .result .image-box { position: relative; } -.main-column ol.image-grid .result .image-box::after { display: block; padding-bottom: 100%; content: ""; } -.main-column ol.image-grid .result .image-box img { position: absolute; object-fit: cover; width: 100%; height: 100%; border-radius: 10px; } -.main-column ol.image-grid .result .image-box img:hover { outline: none; border-color: #3C4043; box-shadow: 0 0 10px #3C4043; } -.main-column ol.image-grid .result span { padding: 5px 0 0 0; color: #666; font-size: 0.75rem; } - -/* Special results - Main column */ -.main-column ol .special-result { background-color: #fefefe; } -.main-column ol li.special-result article { padding: .5rem 10px; position: relative; overflow: hidden; border: 1px solid #aeaeae; border-radius: 8px; color: #222; } -.main-column ol li.special-result article div.title h2 { margin: 0; padding: 0; font-size: 1.5rem; font-weight: 600; word-wrap: break-word; color: #222; } -.main-column ol li.special-result article div.title h2:hover { text-decoration: none; } -.main-column ol li.special-result article div.title a { margin: 0; display: block; color: #6c00a2; cursor: pointer; } -.main-column ol li.special-result article div.title a:visited { color: #6d59a3; } -.main-column ol li.special-result article div.text, .main-column ol li article div.source { position: relative; font-style: normal; } -.main-column ol li.special-result article div.text img { padding: 0 0 10px 10px; } -.main-column ol li.special-result article div.source { display: inline-block; margin: 0; max-width: 100%; color: #666; font-size: 1rem; line-height: 1.6; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: inherit; } -.main-column ol li.special-result article div.source a { margin: 0; color: #3f6e35; text-decoration: none; } - -/* Magnet highlights */ -.main-column .magnet-wrapper { width: 100%; margin: .75rem 0 .75rem 0; } @supports not (display: grid) { - .magnet-grid > * { max-width: 8rem; margin-left: auto; margin-right: auto; } - .magnet-grid li.result { display: inline-block; margin: .75rem; width: 12.5%; } - .magnet-grid > * + * { margin-top: 1rem; } -} -@supports (display: grid) { - .main-column ol.magnet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); grid-gap: 1rem; padding: .5rem 10px; } + .image-grid ol > *, .magnet-grid ol > * { max-width: 8rem; margin-left: auto; margin-right: auto; } + .image-grid ol .result, .magnet-grid ol .result { display: inline-block; margin: .75rem; width: 12.5%; } + .image-grid ol > * + *, .magnet-grid ol > * + * { margin-top: 1rem; } } -.main-column ol.magnet-grid .result .magnet-box { position: relative; } -.main-column ol.magnet-grid .result .magnet-box::after { display: block; content: ""; } -.main-column ol.magnet-grid .result .magnet-box img { width: 100%; height: 100%; border-radius: 10px; } -.main-column ol.magnet-grid .result .magnet-box p { visibility: hidden; opacity: 0; position: absolute; top: 0; bottom: 0; left: 0; right: 0; background: #1f242b; transition: opacity .1s, visibility .1s; padding: 10px; line-height: 1.4; text-align: center; font-size: 0.8rem; color: #f0f6fc; } -.main-column ol.magnet-grid .result .magnet-box a { display: block; position: relative; margin: 5px 0 5px 0; padding: 5px 20px; background-color: #1fa4d1; border: 1px solid #466f82; border-radius: 10px; color: #f0f6fc; font-weight: 800; text-align: center; } -.main-column ol.magnet-grid .result .magnet-box a:hover { text-decoration: none; } -.main-column ol.magnet-grid .result .magnet-box:hover p { visibility: visible; opacity: .90; outline: none; border-color: #3C4043; border-radius: 10px; box-shadow: 0 0 10px #3C4043; } + +/* Image results */ +.image-grid { width: 100%; margin: 25px 0; } +.image-grid ol .result .image-box { position: relative; } +.image-grid ol .result .image-box::after { display: block; padding-bottom: 100%; content: ""; } +.image-grid ol .result .image-box img { position: absolute; object-fit: cover; width: 100%; height: 100%; border-radius: 10px; } +.image-grid ol .result .image-box img:hover { outline: none; border-color: #3C4043; box-shadow: 0 0 10px #3C4043; } +.image-grid ol .result span { padding: 5px 0 0 0; color: #666; font-size: 0.75rem; } + +/* Magnet highlights */ +.magnet-grid { width: 100%; margin: 25px 0; } +.magnet-grid ol .result .magnet-box { position: relative; } +.magnet-grid ol .result .magnet-box::after { display: block; content: ""; } +.magnet-grid ol .result .magnet-box img { width: 100%; height: 100%; border-radius: 10px; } +.magnet-grid ol .result .magnet-box p { visibility: hidden; opacity: 0; position: absolute; top: 0; bottom: 0; left: 0; right: 0; background: #1f242b; transition: opacity .1s, visibility .1s; padding: 10px; line-height: 1.4; text-align: center; font-size: 0.8rem; color: #f0f6fc; } +.magnet-grid ol .result .magnet-box a { display: block; position: relative; margin: 5px 0 5px 0; padding: 5px 20px; background-color: #1fa4d1; border: 1px solid #466f82; border-radius: 10px; color: #f0f6fc; font-weight: 800; text-align: center; } +.magnet-grid ol .result .magnet-box a:hover { text-decoration: none; } +.magnet-grid ol .result .magnet-box:hover p { visibility: visible; opacity: .90; outline: none; border-color: #3C4043; border-radius: 10px; box-shadow: 0 0 10px #3C4043; } /* Misc */ .logo { position: absolute; margin: 28px 18px; } @@ -133,104 +130,104 @@ body.main { background-color: #1f242b; color: #f0f6fc; } .no-decoration, .no-decoration:hover { text-decoration: none; } .hide { display: none; } .G { color: #1fa4d1; } -.warning { position: relative; overflow: hidden; margin: 1rem 0 1rem 0; padding: .5rem 10px; color: #db9900; background-color: #ffffe0; border: 1px solid #e6db55; border-radius: 10px; } -.error { position: relative; overflow: hidden; margin: 1rem 0 1rem 0; padding: .5rem 10px; color: #c00; background-color: #ffebe8; border: 1px solid #c00; border-radius: 10px; } -.auth-error { margin-top: 15%; font-size: 2rem; text-align: center; color: #eaeaea; } +.warning { position: relative; overflow: hidden; margin: 20px 0; padding: 10px; color: #db9900; background-color: #ffffe0; border: 1px solid #e6db55; border-radius: 10px; } +.error { position: relative; overflow: hidden; margin: 20px 0; padding: 10px; color: #c00; background-color: #ffebe8; border: 1px solid #c00; border-radius: 10px; } +.auth-success { margin-top: 15%; font-size: 1rem; text-align: center; color: #f0f6fc; } +.auth-error { margin-top: 15%; font-size: 2rem; text-align: center; color: #f0f6fc; } +a.update { color: #c90; font-weight: bold; } -/* Footer bar */ -.footer-wrap { background-color: #161616; color: #f0f6fc; border-top: 2px solid #303134; } -.footer { padding: 10px; } +/* Footer */ +.footer { background-color: #161616; color: #f0f6fc; border-top: 1px solid #1fa4d1; } .footer a { color: #f0f6fc; } -a.update { color: #c90; font-weight: bold; } +.footer-left, .footer-right { display: inline-block; padding: 10px; } +.footer-right { float: right; } -@media only screen and (max-width:960px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ +@media only screen and (max-width: 960px) { /* tablet, landscape iPad, lo-res/smaller laptops */ /* Page structure */ - .results-wrap { position: relative; display: flex; margin: 0 48px 20px 48px; } + .content { position: relative; margin: 0 48px; } + .footer-left, .footer-right { display: block; padding: 5px 5px 0 5px; text-align: center; } + .footer-right { float: none; padding: 0px 5px 5px 5px; } - /* Main page */ - .search-box-main { margin-top: 10%; } - .search-box-main input { width: 80%; } - .search-box-buttons button { display: table-row; margin: 30px 0px 0px 0px; width: 80%; } + /* Start page */ + .startpage-search { margin-top: 10%; } + .startpage-search .search { width: 80%; } + .search-buttons button { display: table-row; margin: 30px 0px 0px 0px; width: 80%; } /* Search Results - Header */ - .header-wrap { margin-left: auto; margin-right: auto; text-align: center; } - .header-wrap .search { margin: 10px 0px 28px 48px; width: 400px; } - .header-wrap .search, .header-wrap .button { margin: 10px 0px 28px 0px; } + .header { margin-left: auto; margin-right: auto; text-align: center; } + .header .search { margin: 10px 0px 28px 48px; width: 400px; } + .header .search, .header .button { margin: 10px 0px 28px 0px; } /* Search results - Header Navigation */ - .navigation-header { display: flex; margin: 0; padding: 0; align-items: baseline; } - .navigation-header a { margin: 0 auto; padding: 0; } + .navigation { margin: 0 auto 10px auto; padding: 0; align-items: baseline; } /* Misc */ .logo { position: relative; display: block;margin: 0 auto; float: none; padding: 10px; font-size: 1.75rem; } } -@media only screen and (max-width:640px) { /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */ +@media only screen and (max-width: 640px) { /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */ /* Page structure */ - .results-wrap { position: relative; display: flex; margin: 0 10px 10px 10px; } + .content { position: relative; margin: 0 10px; } + .footer-left, .footer-right { display: block; padding: 5px 5px 0 5px; text-align: center; } + .footer-right { float: none; padding: 0px 5px 5px 5px; } - /* Main page */ - .search-box-main { margin-top: 10%; } - .search-box-main input { width: 80%; } - .search-box-buttons button { display: table-row; margin: 30px 0px 0px 0px; width: 80%; } + /* Start page */ + .startpage-search { margin-top: 10%; } + .startpage-search .search { width: 80%; } + .search-buttons button { display: table-row; margin: 30px 0px 0px 0px; width: 80%; } /* Search Results - Header */ - .header-wrap { margin-left: auto; margin-right: auto; text-align: center; } - .header-wrap .search, .header-wrap .button { margin: 0px 0px 10px 0px; width: 80%; border-radius: 25px; } + .header { margin-left: auto; margin-right: auto; text-align: center; } + .header .search, .header .button { margin: 0px 0px 10px 0px; width: 80%; border-radius: 25px; } /* Search results - Header Navigation */ - .navigation-header { display: flex; margin: 0; padding: 0; align-items: baseline; } - .navigation-header a { margin: 0 auto; padding: 0; } + .navigation { margin: 0 auto 10px auto; padding: 0; align-items: baseline; } /* Misc */ .logo { position: relative; display: block; float: none; margin: 0 auto; padding: 10px; font-size: 1.75rem; } } -@media only screen and (max-width:480px) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ +@media only screen and (max-width: 480px) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ /* Page structure */ - .results-wrap { position: relative; display: flex; margin: 0 10px 10px 10px; } + .content { position: relative; margin: 0 10px; } + .footer-left, .footer-right { display: block; padding: 5px 5px 0 5px; text-align: center; } + .footer-right { float: none; padding: 0px 5px 5px 5px; } - /* Main page */ - .search-box-main { margin-top: 10%; } - .search-box-main input { width: 80%; } - .search-box-main h1 { font-size: 2.5rem; } - .search-box-buttons button { display: table-row; margin: 30px 0px 0px 0px; width: 80%; } + /* Start page */ + .startpage-search { margin-top: 10%; } + .startpage-search h1 { font-size: 2.5rem; } + .startpage-search .search { width: 80%; } + .search-buttons button { display: table-row; margin: 30px 0px 0px 0px; width: 80%; } /* Search Results - Header */ - .header-wrap { margin-left: auto; margin-right: auto; text-align: center; } - .header-wrap .search, .header-wrap .button { margin: 0px 0px 10px 0px; width: 80%; border-radius: 25px; } + .header { margin-left: auto; margin-right: auto; text-align: center; } + .header .search, .header .button { margin: 0px 0px 10px 0px; width: 80%; border-radius: 25px; } /* Search results - Header Navigation */ - .navigation-header { display: flex; margin: 0; padding: 0; align-items: baseline; } - .navigation-header a { margin: 0 auto; padding: 0; } - - /* Magnet highlights */ - .main-column .magnet-wrapper { display: none; } + .navigation { margin: 0 auto 10px auto; padding: 0; align-items: baseline; } /* Misc */ .logo { position: relative; display: block; float: none; margin: 0 auto; padding: 10px; font-size: 1.75rem; } } -@media only screen and (max-width:320px) { /* smartphones, iPhone, portrait 480x320 phones */ +@media only screen and (max-width: 320px) { /* smartphones, iPhone, portrait 480x320 phones, split screen devices */ /* Page structure */ - .results-wrap { position: relative; display: flex; margin: 0 10px 10px 10px; } + .content { position: relative; margin: 0 10px; } + .footer-left, .footer-right { display: block; padding: 5px 5px 0 5px; text-align: center; } + .footer-right { float: none; padding: 0px 5px 5px 5px; } - /* Main page */ - .search-box-main { margin-top: 40px; } - .search-box-main input { width: 80%; } - .search-box-main h1 { font-size: 2.5rem; } - .search-box-buttons button { display: table-row; margin: 20px 0px 0px 0px; width: 80%; } + /* Start page */ + .startpage-search { margin-top: 40px; } + .startpage-search h1 { font-size: 2.5rem; } + .startpage-search .search { width: 80%; } + .search-buttons button { display: table-row; margin: 20px 0px 0px 0px; width: 80%; } /* Search Results - Header */ - .header-wrap { margin-left: auto; margin-right: auto; text-align: center; } - .header-wrap .search, .header-wrap .button { margin: 0px 0px 10px 0px; width: 80%; border-radius: 25px; } + .header { margin-left: auto; margin-right: auto; text-align: center; } + .header .search, .header .button { margin: 0px 0px 10px 0px; width: 80%; border-radius: 25px; } /* Search results - Header Navigation */ - .navigation-header { display: flex; margin: 0; padding: 0; align-items: baseline; } - .navigation-header a { margin: 0 auto; padding: 0; } - - /* Magnet highlights */ - .main-column .magnet-wrapper { display: none; } + .navigation { margin: 0 auto 10px auto; padding: 0; align-items: baseline; } /* Misc */ .logo { position: relative; float: none; display: block; margin: 0 auto; padding: 10px; font-size: 1.75rem; } diff --git a/assets/images/goosle.webp b/assets/images/goosle.webp new file mode 100644 index 0000000000000000000000000000000000000000..28aeef9d2c28f96ae3a56234315e6a84428692d4 GIT binary patch literal 1476 zcmV;#1v~muNk&Gz1pok7MM6+kP&il$0000G000300093006|PpNZkPd00EF)+qNo2 z``vf3ud4pWAqlzy!lNiU03-poOiBZQ0Nh>9xo5W){GIj}5fgw8Ljd|J^Xtu{N25#a z@u;~rU+Duvz{CnWUTrOm0r}fPhM|=^lA>mQF;gLVw>*w4ydei>j!9Lcdrg(R zm;v&RBFbB&7@cfF?v)Wch!|>96CItD?LovJ`i)_|T%z-LGtw5x&W= zL!rZkd&mGp%uwlaOw3d0c;VbS)pN?VCX?q9>qj)t84n-m{Co4BvG9N4|HA);{|o;Y{xAGr_`mRf z;s3(_h5rlx|6S0$XAj=HKcacgc-Ua_Tw-mV>N(}=JjHXuxr);KW|WD(7S(UcMh~jK zTL8xHXkIhkjv`>0;x*wSLcs6|lg|>51`!Z3P4$^_5)nX#9g4?y@n% z!Z*k;X;P&gpC0{{RJBmkWODgXfh0X~sPp-d&DBO)X8s6en131@EMbfE|wdU8)(dcpJ1 z-rt^kzeped@+|#Uzu5GEfB$$Y?5qf|Nr-PhPRN2e%VB0xw8{11$vpzC@{YC(bf!ekE3fIdgno0x#}`93^? zAOa_3wL_kB7Qi1P>dnkRb-foRHvM#}$!*lY>;$uPun;cG7a`)_RZ2|9?n#%vr(5WN z{*HGtVHNAYGfYc5F}p0RC|A zFqgDtEo0;-=Mv=^jb9L&&Pq)d0nA8WIp=9HLC?+^m-3Eecj_TDbSHp#X&+lp(}BS& zP&pIV!(?j!000ZD&UmD`+XWC!euTFIIk0w{$R=rr=u($IrZy&BL|e`{(uKQpsDm$g zFn5+O%it&p@NwNdaW%fX)#))-0Zz+Y4*hJ3L50ypK!)6qt1Qq1M;CfKl`qpQS zX0(GfQKJEFQL7wh~MNey@hI^`fsE(S=}eXM4vuj8fu zIn~`4A}Yo+D9PF{<+Xh4vS}$1MiYa((l!VAIo|cMyZE)_w89VdU3pp!&&;iJIo9$b z9UakK6N~l!3nX`^&&X7yIp;E1X;&dBn_br;Bm}cCAxnt*Y?aRQ7ahXBW~T0I;^|y| zo_)i<7uob)LfMdj;xokgo@qvP$BjOPsCF8j*?Mb=LC_pJ5}qrk7wG0^2RVJ#Y+t1! znjBsJCz=F?B>f$a98sl#q92d2KWS^3!$#)~aWjyTl*b1!DQPN`FL*z7B!}Y$`4c?i zUjYsUw`vXMXX!RQ%vxK_U7Y2=DXxMhzgmilZkbif5)1~b8rr4}jnz!@GuhI&i0vi} z>9YYP5_v0E!^a1{7@VB%tk=cLFf2S8rT0zadk4TA%PrArjVg~LgVHRgm2<^`l-XUY z_T3l^eF$D__Z7iYAVCk%kq$Dj00001xP?lZNko|9K`A2b2I#ZECYnH1;8G0Bgjss6 emP|&Vu@|~OMl}D}40ryR0tmnlcF1SGzyJWcQ?)<< literal 0 HcmV?d00001 diff --git a/config.default.php b/config.default.php index 2c1c920..ace119d 100644 --- a/config.default.php +++ b/config.default.php @@ -11,154 +11,106 @@ ------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------ +SITEURL: + Set the base domain name for your Goosle setup (ex. example.com, something.example.com, example.com/something/) so that internal links will work correctly. + HASH: - A simple lowercase passphrase (something simple like: j9fg-i2du-er6m or 1846) used for caching results. This helps to differentiate between instances on the same server. - You can also add it to your url/bookmark as a simple passphrase to keep unwanted users out. + A simple lowercase passphrase, something simple like: j9fg-i2du-er6m or 1846. + Used for caching results and optionally for accessing Goosle (See HASH_AUTH option). -HASH AUTH: +HASH_AUTH: Use the above hash as a simple passphrase. - Using it as a passphrase lets you host Goosle on a public server without providing a public service. + Using it as a passphrase lets you host Goosle on a public facing server without providing a public service. + This is useful for if just you and some friends or family should be able to use Goosle from anywhere. + + "off" Don't use the hash as a password. + "on" Use the hash as a password. Usage: https://example.com/?a=1234567890 - Disclaimer: This is not meant to 'hack proof' or truly secure the setup. Just a simple token to keep surface level prying eyes out. - -CACHE: - It is highly recommended to enable caching as it'll speed up repeat searches by a lot. + Disclaimer: This is not meant to 'hack proof' or truly secure the setup. Just a simple token to keep surface level prying eyes out. CACHE_TYPE: - Choose how to cache results. The cache is NOT unique per user but shared between all users. Different users searching for the exact same thing get the same results. - Default caching method is APCu. Alternatively, you can store the results in text files in the /cache/ folder. - Ignored if above 'cache' option is set to off. - "apcu" (Recommended) faster, utilize memory. - "file" Store results in text files. + It is highly recommended to enable caching as it will speed up repeat searches by a lot. + The cache is NOT unique per user but shared between all users. Different users searching for the exact same thing get the same results. + + Caching can be done in memory with APCu or as temporary files in the /cache/ folder. + + "off" No caching. + "file" Store results in text files (Default). + "apcu" Faster, utilizes memory. CACHE_TIME: Minutes the result should be cached. Accepts a numeric value between 1 and 720. - APCu stores in memory, using a longer time takes up more of it. It is recommended to not exceed 30 minutes for it. + APCu stores in memory, using a longer time takes up more of it. It is recommended to not exceed 30 minutes for APCu. The file cache is only limited by your hosting storage space and can safely be much much longer if you want. To not show outdated results the 'limit' is 720 minutes, which equals 12 hours. - Ignored if above 'cache' option is set to off. - - - -ENABLE IMAGE SEARCH: - Enable or disable image searches - Search results are provided by Yahoo! Images. - -ENABLE MAGNET SEARCH: - Enable or disable searching for magnet links on torrent websites. - -ENABLE SEARCH ENGINES: - Enable or disable search engines. - -ENABLE MAGNET CRAWLERS: - Enable or disable crawlers to pull magnet links from. - - - + Ignored if above 'CACHE_TYPE' option is set to off. +/* ------------------------------------------------------------------------------------ LANGUAGE: - DuckDuckGo, Google and Ecosia are language agnostic. But they DO profile you for your locale. - For example: Me searching with english terms has me seeing Spanish results because I live in Mexico. This setting should minimize that for supported engines. - - DuckDuckGo uses language regions as opposed to a simpler language choice. See if your region is available - https://duckduckgo.com/duckduckgo-help-pages/settings/params/. - Google's language option breaks reasonable results and other options like verbatim mode and some other settings. So you'll have to rely on Google picking up on the query language. + DuckDuckGo and Google are mostly language agnostic. + + To not fit the USA mold, Goosle defaults to the United Kingdom for english results. + + Google has no language setting because as soon as you specify it all 'anonymous' settings stop working. + DuckDuckGo uses language regions and defaults to the United Kingdom. To change it see if your region is available - https://duckduckgo.com/duckduckgo-help-pages/settings/params/. Wikipedia needs to be told which language you want. This changes the search url. Use any of their supported languages (en, es, fr, nl, etc.) + Qwant uses a locale similar to DuckDuckGo. Available locales are: bg_bg, br_fr, ca_ad, ca_es, ca_fr, co_fr, cs_cz, cy_gb, da_dk, de_at, de_ch, de_de, ec_ca, el_gr, en_au, en_ca, en_gb, en_ie, en_my, en_nz, en_us, es_ad, es_ar, es_cl, es_co, es_es, es_mx, es_pe, et_ee, eu_es, eu_fr, fc_ca, fi_fi, fr_ad, fr_be, fr_ca, fr_ch, fr_fr, gd_gb, he_il, hu_hu, it_ch, it_it, ko_kr, nb_no, nl_be, nl_nl, pl_pl, pt_ad, pt_pt, ro_ro, sv_se, th_th, zh_cn, zh_hk. SOCIAL MEDIA RELEVANCE: Show social media results lower in the combined results if you don't value such results. - Downranked results include: Facebook, Instagram, Twitter, Snapchat, TikTok, LinkedIn and Reddit. - !!CAREFUL!! This is a blanket setting, if what you're searching for primarily has social media links then less relevant results may show first. - Accepts a numeric value between 1 and 10. With 10 having *NO* effect on the rank, and 0 not ranking the link at all (shows very very low in the results) - -SHOW SEARCH SOURCE: - Show which search engine(s) came up with the result. - -SHOW SEARCH RANK: - When search source is enabled, show the rank Goosle gave the result. - -IMDB ID SEARCH: - Highlight imdb results if it's a tv-show or movie. - Handy for finding better results for specific tv-shows through EZTV and The Pirate Bay. - -PASSWORD GENERATOR - Show a password generator on the Goosle home page. - - - -SPECIAL: - Enable or disable special searches that show up before search results. - - - -SHOW ZERO SEEDERS: - Set to "on" to include results with 0 seeders (slow or stale downloads). Off to exclude these results. - -YTS HIGHLIGHT: - If you've enabled the YTS special search, you can also choose what it should show. The 8 most [insert choice] movies. - "date_added" = Newest movies (Default). - "rating" = Highest rated movies as per imdb. - "download_count" = Most downloaded movies. - -BLOCK 1337x CATEGORIES: - Add category IDs of 1337x categories, check /engines/magnet/1337x.php for a list of known categories. - Accepts a basic numeric array, comma separated. - -BLOCK PIRATEBAY CATEGORIES: - Add category IDs of Pirate Bay categories, check /engines/magnet/thepiratebay.php for a list of known categories. - Accepts a basic numeric array, comma separated. - -BLOCK YTS CATEGORIES: - Add category names as keywords, eg; "thriller", "war". - Movies can be in multiple categories, if a movie is in 5 categories it only has to match one to be filtered out. - Accepts a basic array of keywords, comma separated. - - - + Downranked results include websites like Facebook, Instagram, Twitter, Snapchat, TikTok, LinkedIn and Reddit. + !! CAREFUL !! This is a blanket setting, if what (or who) you're searching for primarily has social media links then less relevant results may show first. + Accepts a numeric value between 1 and 10. With 10 having *NO* effect on the rank, and 0 not ranking the link at all (shows very very low in the results). +/* ------------------------------------------------------------------------------------ USER AGENTS: - Add more or less user agents to the list. Keep at least one! + Add more or less user agents to the list but keep at least one! On every search Goosle picks one at random to identify as. Keep them generic to prevent profiling, but also so that the request comes off as a generic boring browser and not as a server/crawler. - Safari, Firefox and Internet Explorer/Edge should be safe to use. + Safari, Firefox and Internet Explorer (Yes that's old!) should be safe to use. Chrome may attract attention because of the lack of Chrome information (tracking) aside from the user agent. The search engine may know something is 'weird'. Opera/Edge/Brave and many others use Chrome under the hood and are not a good pick for that reason. - Mobile agents may work, but some services like Wikipedia are a bit picky when it comes to answering API calls. Mobile users generally do not use APIs, so they may block your search. + Mobile user agents may work, but some services like Wikipedia are a bit picky when it comes to answering API calls. + Mobile users generally do not use APIs, so they may block your search or show a trimmed version of results. MAGNET TRACKERS: - Only used for The Pirate Bay, LimeTorrents and YTS. + These are added to the magnet links Goosle creates by itself. Generally you do not need to change these. - These are added to the magnet links Goosle creates. You can add more or replace the existing ones if you know what you're doing. - Accepts a basic array of strings (tracker urls), comma separated. + Currently only The Pirate Bay, LimeTorrents and YTS use generated magnet links. + + You can add more or replace the existing ones if you know what you're doing. But keep at least one, preferably 3-5+. ------------------------------------------------------------------------------------ */ return (object) array( - "hash" => "j9fg-i2du-er6m", + // ALL OPTIONS ARE REQUIRED, EVEN IF YOU DO NOT USE THE FEATURE. EMPTY VALUES OR MISSING SETTINGS CAUSE ISSUES!!! + "siteurl" => "example.com", // Make sure this is accurate + "hash" => "j9fg-i2du-er6m", // Some kind of alphanumeric password-like string, used for caching and optionally for access to Goosle "hash_auth" => "off", // Default: off - "cache" => "off", // Default: off - "cache_type" => "apcu", // Default: apcu + "cache_type" => "file", // Default: file "cache_time" => 30, // Default: 30 (Minutes) - "enable_image_search" => "on", // Default: on - "enable_magnet_search" => "on", // Default: on "enable_duckduckgo" => "on", // Default: on "enable_google" => "on", // Default: on - "enable_reddit" => "on", // Default: on + "enable_qwantnews" => "on", // Default: on "enable_wikipedia" => "on", // Default: on - "enable_ecosia" => "off", // Default: on - // Site uses some kind of bot detector preventing crawler from working reliably since Feb 1, 2024, remove support in future release?) + "enable_image_search" => "on", // Default: on (Disables all image search regardless of settings for individual engines) + "enable_yahooimages" => "on", // Default: on + "enable_openverse" => "off", // Default: off (Requires API token, see readme for details) + "enable_qwant" => "on", // Default: on + + "enable_magnet_search" => "on", // Default: on (Disables all image search regardless of settings for individual engines) + "enable_eztv" => "on", // Default: on "enable_limetorrents" => "on", // Default: on + "enable_nyaa" => "on", // Default: on "enable_piratebay" => "on", // Default: on "enable_yts" => "on", // Default: on - "enable_magnetdl" => "on", // Default: on - "enable_nyaa" => "on", // Default: on - "enable_eztv" => "on", // Default: on - "enable_l33tx" => "off", // Default: off - // Site now uses cloudflare preventing crawler from working since Jan 20, 2024, remove support in future release?) "duckduckgo_language" => "uk-en", // Default: uk-en (United Kingdom) "wikipedia_language" => "en", // Default: en (English) + "qwant_language" => "en_gb", // Default: en_gb (United Kingdom) + "social_media_relevance" => 8, // Default: 8 - "show_reddit_nsfw" => "on", // Default: on "show_search_source" => "on", // Default: on "show_search_rank" => "off", // Default: off "imdb_id_search" => "off", // Default: off @@ -174,11 +126,15 @@ "show_zero_seeders" => "on", // Default: on "yts_highlight" => "date_added", // Default: "date_added" - "leetx_categories_blocked" => array(3, 7, 47), // Default: 3, 7, 47 "piratebay_categories_blocked" => array(206, 210), // Default: 206, 210 "yts_categories_blocked" => array("horror"), // Default: "horror" "user_agents" => array( + "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1", // Linux, Lynx browser 2.8.5 + "Lynx/2.8.9rel.1 libwww-FM/2.14 SSL-MM/1.4.1", // Linux, Lynx browser 2.8.9 + "Lynx/2.8.6rel.4 libwww-FM/2.14 SSL-MM/1.4.1", // Linux, Lynx browser 2.8.6 + "TinyBrowser/2.0 (TinyBrowser Comment; rv:1.9.1a2pre) Gecko/20201231", // Linux, Tinybrowser 2 + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) DuckDuckGo/7 Safari/605.1.15", // macOS 10.15, DuckDuckGo 7 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15) Gecko/20100101 Firefox/119.0", // macOS 10.15, Firefox 119 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Gecko/20100101 Firefox/116.0", // Windows 10, Firefox 116 "Mozilla/5.0 (X11; Ubuntu; Linux x86_64) Gecko/20100101 Firefox/83.0", // Linux Ubuntu, Firefox 83 @@ -187,11 +143,26 @@ "magnet_trackers" => array( "http://nyaa.tracker.wf:7777/announce", - "http://tracker.openbittorrent.com:80/announce", - "udp://tracker.opentrackr.org:1337/announce", - "udp://exodus.desync.com:6969/announce", + "udp://tracker.opentrackr.org:1337/announce", + "udp://exodus.desync.com:6969/announce", "udp://tracker.torrent.eu.org:451/announce", "udp://opentracker.i2p.rocks:6969/announce", + "udp://open.demonii.com:1337/announce", + "udp://open.stealth.si:80/announce", + "udp://tracker.moeking.me:6969/announce", + "udp://explodie.org:6969/announce", + "udp://tracker1.bt.moack.co.kr:80/announce", + "udp://tracker.theoks.net:6969/announce", + "udp://tracker-udp.gbitt.info:80/announce", + "https://tracker.tamersunion.org:443/announce", + "https://tracker.gbitt.info:443/announce", + "udp://tracker.tiny-vps.com:6969/announce", + "udp://tracker.dump.cl:6969/announce", + "udp://tamas3.ynh.fr:6969/announce", + "udp://retracker01-msk-virt.corbina.net:80/announce", + "udp://open.free-tracker.ga:6969/announce", + "udp://epider.me:6969/announce", + "udp://bt2.archive.org:6969/announce", ) ); -?> +?> \ No newline at end of file diff --git a/engines/image/openverse.php b/engines/image/openverse.php new file mode 100644 index 0000000..6f5eb2f --- /dev/null +++ b/engines/image/openverse.php @@ -0,0 +1,111 @@ +query, 0, 200); + + // Safe search override + $safe = "0"; // No mature results + if(strpos($query_terms[0], "safe") !== false) { + $switch = explode(":", $query_terms[0]); + + if(!is_numeric($switch[1])) { + $safe = (strtolower($switch[1]) == "off") ? "1" : "0"; + $this->query = implode(" ", array_slice($query_terms, 1)); + } + } + + // q = query + // format = json + // mature = 1 / 0 + // page_size = 80 (int) + + $args = array("q" => $query_terms, "format" => "json", "mature" => $safe, "page_size" => 50); + $url = "https://api.openverse.org/v1/images/?".http_build_query($args); + + unset($query_terms, $switch, $safe, $max_results, $args); + + return $url; + } + + public function get_request_headers() { + $token_file = ABSPATH.'cache/token.data'; + $token = unserialize(file_get_contents($token_file)); + + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Content-type' => 'application/x-www-form-urlencoded', + 'Authorization' => 'Bearer '.$token['openverse']['access_token'], + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + + public function parse_results($response) { + $results = array(); + $json_response = json_decode($response, true); + + // No response + if(empty($json_response)) return $results; + + // Set base rank and result amound + $rank = $results['amount'] = count($json_response['results']); + + // Nothing found + if($results['amount'] == 0) return $results; + + // Use API result + foreach ($json_response['results'] as $result) { + // Deal with optional or missing data + $dimensions_w = (!empty($result['width'])) ? sanitize($result['width']) : ""; + $dimensions_h = (!empty($result['height'])) ? sanitize($result['height']) : ""; + $filesize = (!empty($result['filesize'])) ? sanitize($result['filesize']) : ""; + $link = (!empty($result['url'])) ? sanitize($result['url']) : ""; + + $image_full = (!empty($result['foreign_landing_url'])) ? sanitize($result['foreign_landing_url']) : ""; + $image_thumb = (!empty($result['thumbnail'])) ? sanitize($result['thumbnail']) : $image_full; + $alt = (!empty($result['title'])) ? sanitize($result['title']) : ""; + + // Add attribution to alt text? + $creator = (!empty($result['creator'])) ? " by ".sanitize($result['creator']) : ""; + $alt = (!empty($creator)) ? $alt.$creator : $alt; + + // Process result + $filesize = intval(preg_replace('/[^0-9]/', '', $filesize)); + + // filter duplicate IMAGE urls/results + if(!empty($results['search'])) { + if(in_array($image_full, array_column($results['search'], "image_full"))) continue; + } + + $results['search'][] = array ("id" => uniqid(rand(0, 9999)), "source" => "Openverse", "image_thumb" => $image_thumb, "alt" => $alt, "image_full" => $image_full, "width" => $dimensions_w, "height" => $dimensions_h, "filesize" => $filesize, "webpage_url" => $link, "engine_rank" => $rank); + $rank -= 1; + unset($url_data, $usable_data, $dimensions_w, $dimensions_h, $filesize, $link, $image_full, $alt, $image_thumb); + } + unset($json_response, $rank); + + // Add error if there are no search results + if(empty($results['search'])) { + $results['error'] = array( + "message" => "No results found. Please try with less or different keywords!" + ); + } + + return $results; + } +} +?> diff --git a/engines/image/qwant.php b/engines/image/qwant.php new file mode 100644 index 0000000..01c730e --- /dev/null +++ b/engines/image/qwant.php @@ -0,0 +1,106 @@ +query)); + + // Safe search override + $safe = "1"; // Moderate results + if(strpos($query_terms[0], "safe") !== false) { + $switch = explode(":", $query_terms[0]); + + if(!is_numeric($switch[1])) { + $safe = (strtolower($switch[1]) == "off") ? "0" : "2"; + $this->query = implode(" ", array_slice($query_terms, 1)); + } + } + + $language = (strlen($this->opts->qwant_language) > 0 && strlen($this->opts->qwant_language < 6)) ? $this->opts->qwant_language : "en_gb"; + + // q = query + // t = Type of search, Images + // count = Up-to how many images to return (Max 50) + // locale = In which language should the search be done + // device = What kind of device are we searching from? + // safesearch = Safe search filter (0 = off, 1 = normal, 2 = strict) + + $args = array("q" => $this->query, "t" => 'images', 'count' => 50, 'locale' => $language, 'device' => 'desktop', 'safesearch' => $safe); + $url = "https://api.qwant.com/v3/search/images?".http_build_query($args); + + unset($query_terms, $switch, $safe, $language, $args); + + return $url; + } + + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + + public function parse_results($response) { + $results = array(); + $json_response = json_decode($response, true); + + // No response + if(empty($json_response)) return $results; + + // Nothing found + if($json_response["status"] != "success") return $results; + + // Set base rank and result amound + $rank = $results['amount'] = $json_response["data"]["result"]["total"]; + + // Use API result + foreach ($json_response["data"]["result"]["items"] as $result) { + // Deal with optional or missing data + $dimensions_w = (!empty($result['width'])) ? sanitize($result['width']) : ""; + $dimensions_h = (!empty($result['height'])) ? sanitize($result['height']) : ""; + $filesize = (!empty($result['size'])) ? sanitize($result['size']) : ""; + $link = (!empty($result['url'])) ? sanitize($result['url']) : ""; + + $image_full = (!empty($result['media'])) ? sanitize($result['media']) : ""; + $image_thumb = (!empty($result['thumbnail'])) ? sanitize($result['thumbnail']) : $image_full; + $alt = (!empty($result['title'])) ? sanitize($result['title']) : ""; + + // Process result + $filesize = intval(preg_replace('/[^0-9]/', '', $filesize)); + + // filter duplicate IMAGE urls/results + if(!empty($results['search'])) { + if(in_array($image_full, array_column($results['search'], "image_full"))) continue; + } + + $results['search'][] = array ("id" => uniqid(rand(0, 9999)), "source" => "Qwant", "image_thumb" => $image_thumb, "alt" => $alt, "image_full" => $image_full, "width" => $dimensions_w, "height" => $dimensions_h, "filesize" => $filesize, "webpage_url" => $link, "engine_rank" => $rank); + $rank -= 1; + unset($url_data, $usable_data, $dimensions_w, $dimensions_h, $filesize, $link, $image_full, $alt, $image_thumb); + } + unset($json_response, $rank); + + // Add error if there are no search results + if(empty($results['search'])) { + $results['error'] = array( + "message" => "No results found. Please try with less or different keywords!" + ); + } + + return $results; + } +} +?> \ No newline at end of file diff --git a/engines/image/yahoo.php b/engines/image/yahoo.php index 64a43b8..3628fd9 100644 --- a/engines/image/yahoo.php +++ b/engines/image/yahoo.php @@ -38,11 +38,17 @@ public function get_request_url() { $args = array("p" => $this->query, "imgsz" => $size); $url = "https://images.search.yahoo.com/search/images?".http_build_query($args); - unset($query_terms, $switch, $args, $size); + unset($query_terms, $switch, $size, $args); return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'text/html, application/xhtml+xml, application/xml;q=0.8, */*;q=0.7', + ); + } + public function parse_results($response) { $results = array(); $xpath = get_xpath($response); @@ -62,15 +68,19 @@ public function parse_results($response) { // Scrape the results // $scrape = $xpath->query("//li[contains(@class, 'ld') and not(contains(@class, 'slotting'))][position() < 101]"); $scrape = $xpath->query("//li[contains(@class, 'ld') and not(contains(@class, 'ignore'))][position() < 101]"); + + // Set base rank and result amound $rank = $results['amount'] = count($scrape); + // Nothing found + if($results['amount'] == 0) return $results; foreach($scrape as $result) { - $image = $xpath->evaluate(".//img/@src", $result)[0]; - if($image == null) continue; + $image_thumb = $xpath->evaluate(".//img/@src", $result)[0]; + if(is_null($image_thumb)) continue; $url_data = $xpath->evaluate(".//a/@href", $result)[0]; - if($url_data == null) continue; + if(is_null($url_data)) continue; // Get and prepare meta data // -- Relevant $url_data (there is more, but unused by Goosle) @@ -92,27 +102,25 @@ public function parse_results($response) { } // Deal with optional or missing data - $dimensions_w = (!array_key_exists('w', $usable_data)) ? "" : htmlspecialchars($usable_data['w']); - $dimensions_h = (!array_key_exists('h', $usable_data)) ? "" : htmlspecialchars($usable_data['h']); - $link = (!array_key_exists('imgurl', $usable_data)) ? "" : "//".htmlspecialchars($usable_data['imgurl']); - $url = (!array_key_exists('rurl', $usable_data)) ? "" : htmlspecialchars($usable_data['rurl']); - $filesize = (!array_key_exists('size', $usable_data)) ? "" : htmlspecialchars($usable_data['size']); - $alt = (!array_key_exists('tt', $usable_data)) ? "" : htmlspecialchars($usable_data['tt']); + $dimensions_w = (!array_key_exists('w', $usable_data)) ? "" : sanitize($usable_data['w']); + $dimensions_h = (!array_key_exists('h', $usable_data)) ? "" : sanitize($usable_data['h']); + $image_full = (!array_key_exists('imgurl', $usable_data)) ? "" : "//".sanitize($usable_data['imgurl']); + $link = (!array_key_exists('rurl', $usable_data)) ? "" : sanitize($usable_data['rurl']); + $filesize = (!array_key_exists('size', $usable_data)) ? "" : sanitize($usable_data['size']); + $alt = (!array_key_exists('tt', $usable_data)) ? "" : sanitize($usable_data['tt']); // Process result - $image = htmlspecialchars($image->textContent); + $image_thumb = sanitize($image_thumb->textContent); + $filesize = intval(preg_replace('/[^0-9.]/', '', $filesize) * 1000); - // filter duplicate urls/results + // filter duplicate IMAGE urls/results if(!empty($results['search'])) { - $result_urls = array_column($results['search'], "direct_link"); - if(in_array($link, $result_urls)) continue; + if(in_array($image_full, array_column($results['search'], "image_full"))) continue; } - $id = uniqid(rand(0, 9999)); - - $results['search'][] = array ("id" => $id, "source" => "Yahoo! Images", "image" => $image, "alt" => $alt, "url" => $url, "width" => $dimensions_w, "height" => $dimensions_h, "filesize" => $filesize, "direct_link" => $link, "engine_rank" => $rank); + $results['search'][] = array ("id" => uniqid(rand(0, 9999)), "source" => "Yahoo! Images", "image_thumb" => $image_thumb, "alt" => $alt, "image_full" => $image_full, "width" => $dimensions_w, "height" => $dimensions_h, "filesize" => $filesize, "webpage_url" => $link, "engine_rank" => $rank); $rank -= 1; - unset($url_data, $usable_data, $dimensions_w, $dimensions_h, $filesize, $link, $url, $alt, $image); + unset($url_data, $usable_data, $dimensions_w, $dimensions_h, $filesize, $link, $image_full, $alt, $image_thumb); } unset($response, $xpath, $scrape, $rank); diff --git a/engines/magnet/1337x.php b/engines/magnet/1337x.php deleted file mode 100644 index 1eebc8b..0000000 --- a/engines/magnet/1337x.php +++ /dev/null @@ -1,147 +0,0 @@ -query)."/1/"; - - return $url; - - } - - public function parse_results($response) { - $results = array(); - $xpath = get_xpath($response); - - // Failed to load page - if(!$xpath) return $results; - - $categories = array( - 1 => "DVD", - 2 => "Divx/Xvid", - 3 => "SVCD/VCD", - 4 => "Dubs/Dual Audio", - 5 => "DVD", - 6 => "Divx/Xvid", - 7 => "SVCD/VCD", - 9 => "Documentary", - - 10 => "PC Game", - 11 => "PS2", - 12 => "PSP", - 13 => "Xbox", - 14 => "Xbox360", - 15 => "PS1", - 16 => "Dreamcast", - 17 => "Other (Gaming)", - 18 => "PC Software", - 19 => "Mac Software", - - 20 => "Linux Software", - 21 => "Other (Software)", - 22 => "MP3", - 23 => "Lossless Audio", - 24 => "DVD (Music)", - 25 => "Music Video", - 26 => "Radio", - 27 => "Other (Audio)", - 28 => "Anime", - - 33 => "Emulation", - 34 => "Tutorials", - 35 => "Sounds", - 36 => "E-Books", - 37 => "Images", - 38 => "Mobile Phone", - 39 => "Comics", - - 40 => "Other", - 41 => "HD (Video)", - 42 => "HD (Video)", - 43 => "PS3", - 44 => "Wii", - 45 => "DS", - 46 => "GameCube", - 47 => "Nulled Script", - 48 => "Video", - 49 => "Picture", - - 50 => "Magazine", - 51 => "Hentai", - 52 => "Audiobook", - 53 => "Album (Music)", - 54 => "h.264/x264", - 55 => "Mp4", - 56 => "Android", - 57 => "iOS", - 58 => "Box Set (Music)", - 59 => "Discography", - - 60 => "Single (Music)", - 66 => "3D", - 67 => "Games", - 68 => "Concerts", - 69 => "AAC (Music)", - - 70 => "HEVC/x265", - 71 => "HEVC/x265", - 72 => "3DS", - 73 => "Bollywood", - 74 => "Cartoon", - 75 => "SD (Video)", - 76 => "UHD", - 77 => "PS4", - 78 => "Dual Audio (Video)", - 79 => "Dubbed (Video)", - - 80 => "Subbed", - 81 => "Raw", - 82 => "Switch", - ); - - // Scrape the page - foreach($xpath->query("//table/tbody/tr") as $result) { - $name = sanitize($xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent); - $url = "https://1337x.to".sanitize($xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent); - $magnet = "./engines/magnet/magnetize_1337x.php?url=".$url; - $seeders = sanitize($xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent); - $leechers = sanitize($xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent); - $size_unformatted = explode(" ", sanitize($xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent)); - $size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]); - - // Ignore results with 0 seeders? - if($this->opts->show_zero_seeders == "off" AND $seeders == 0) continue; - - // Get extra data - $category = explode("/", sanitize($xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[0]->textContent)); - $category = $category[2]; - - // Block these categories - if(in_array($category, $this->opts->leetx_categories_blocked)) continue; - - // Filter episodes - if(!is_season_or_episode($this->query, $name)) continue; - - $id = uniqid(rand(0, 9999)); - - $results[] = array ( - // Required - "id" => $id, "source" => "1337x.to", "name" => $name, "magnet" => $magnet, "hash" => null, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, - // Extra - "category" => $categories[$category], "url" => $url - ); - } - unset($response, $xpath); - - return $results; - } -} -?> \ No newline at end of file diff --git a/engines/magnet/eztv.php b/engines/magnet/eztv.php index 8ffe588..3546d79 100644 --- a/engines/magnet/eztv.php +++ b/engines/magnet/eztv.php @@ -23,6 +23,18 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $results = array(); $json_response = json_decode($response, true); @@ -61,11 +73,9 @@ public function parse_results($response) { } } - $id = uniqid(rand(0, 9999)); - $results[] = array ( // Required - "id" => $id, "source" => "EZTV", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => human_filesize($size), + "id" => uniqid(rand(0, 9999)), "source" => "EZTV", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => human_filesize($size), // Extra "quality" => $quality, "codec" => $codec, "date_added" => $date_added ); diff --git a/engines/magnet/lime.php b/engines/magnet/lime.php index 9ff49c6..73d636c 100644 --- a/engines/magnet/lime.php +++ b/engines/magnet/lime.php @@ -17,6 +17,12 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'text/html, application/xhtml+xml, application/xml;q=0.8, */*;q=0.7', + ); + } + public function parse_results($response) { $results = array(); $xpath = get_xpath($response); @@ -46,11 +52,9 @@ public function parse_results($response) { // Filter episodes if(!is_season_or_episode($this->query, $name)) continue; - $id = uniqid(rand(0, 9999)); - $results[] = array ( // Required - "id" => $id, "source" => "limetorrents.lol", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, + "id" => uniqid(rand(0, 9999)), "source" => "limetorrents.lol", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, // Extra "category" => $category, "url" => $url ); diff --git a/engines/magnet/magnetdl.php b/engines/magnet/magnetdl.php deleted file mode 100644 index 18da7d2..0000000 --- a/engines/magnet/magnetdl.php +++ /dev/null @@ -1,64 +0,0 @@ -query, 0, 1)."/".str_replace(' ', '-', $this->query); - - return $url; - } - - public function parse_results($response) { - $results = array(); - $xpath = get_xpath($response); - - // Failed to load page - if(!$xpath) return $results; - - // Scrape the page - foreach($xpath->query("//table[@class='download']/tbody/tr") as $result) { - // Skip page navigation and incompatible rows - if(is_null($xpath->evaluate(".//td[2]", $result)[0])) continue; - - $name = sanitize($xpath->evaluate(".//td[2]/a/@title", $result)[0]->textContent); - $magnet = sanitize($xpath->evaluate(".//td[1]/a/@href", $result)[0]->textContent); - $hash = parse_url($magnet, PHP_URL_QUERY); - parse_str($hash, $hash_parameters); - $hash = strtolower(str_replace("urn:btih:", "", $hash_parameters['xt'])); - $seeders = sanitize($xpath->evaluate(".//td[7]", $result)[0]->textContent); - $leechers = sanitize($xpath->evaluate(".//td[8]", $result)[0]->textContent); - $size = sanitize($xpath->evaluate(".//td[6]", $result)[0]->textContent); - - // Ignore results with 0 seeders? - if($this->opts->show_zero_seeders == "off" AND $seeders == 0) continue; - - // Get extra data - $category = sanitize($xpath->evaluate(".//td[4]", $result)[0]->textContent); - $url = "https://www.magnetdl.com".sanitize($xpath->evaluate(".//td[2]//a/@href", $result)[0]->textContent); - - // Filter episodes - if(!is_season_or_episode($this->query, $name)) continue; - - $id = uniqid(rand(0, 9999)); - - $results[] = array ( - // Required - "id" => $id, "source" => "magnetdl.com", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, - // Extra - "category" => $category, "url" => $url - ); - } - unset($response, $xpath); - - return $results; - } -} -?> diff --git a/engines/magnet/magnetize_1337x.php b/engines/magnet/magnetize_1337x.php deleted file mode 100644 index 89a5a6e..0000000 --- a/engines/magnet/magnetize_1337x.php +++ /dev/null @@ -1,29 +0,0 @@ -user_agents); -$response = curl_exec($ch); -curl_close($ch); - -$xpath = get_xpath($response); - -// No results -if(!$xpath) die(); - -$magnet = trim($xpath->query("//main/div/div/div/div/div/ul/li/a/@href")[0]->textContent); - -header("Location: $magnet") -?> diff --git a/engines/magnet/nyaa.php b/engines/magnet/nyaa.php index dc1fd05..b2ff269 100644 --- a/engines/magnet/nyaa.php +++ b/engines/magnet/nyaa.php @@ -19,6 +19,12 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'text/html, application/xhtml+xml, application/xml;q=0.8, */*;q=0.7', + ); + } + public function parse_results($response) { $results = array(); $xpath = get_xpath($response); @@ -53,11 +59,9 @@ public function parse_results($response) { // Filter episodes if(!is_season_or_episode($this->query, $name)) continue; - $id = uniqid(rand(0, 9999)); - $results[] = array ( // Required - "id" => $id, "source" => "nyaa.si", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, + "id" => uniqid(rand(0, 9999)), "source" => "nyaa.si", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, // Extra "category" => $category, "url" => $url, "date_added" => $date_added ); diff --git a/engines/magnet/thepiratebay.php b/engines/magnet/thepiratebay.php index f064bb6..caff731 100644 --- a/engines/magnet/thepiratebay.php +++ b/engines/magnet/thepiratebay.php @@ -19,6 +19,18 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $results = array(); $json_response = json_decode($response, true); @@ -89,24 +101,24 @@ public function parse_results($response) { ); // Use API result - foreach($json_response as $response) { + foreach($json_response as $result) { // Nothing found - if($response['name'] == "No results returned") break; + if($result['name'] == "No results returned") break; - $name = sanitize($response['name']); - $hash = strtolower(sanitize($response['info_hash'])); + $name = sanitize($result['name']); + $hash = strtolower(sanitize($result['info_hash'])); $magnet = "magnet:?xt=urn:btih:".$hash."&dn=".urlencode($name)."&tr=".implode("&tr=", $this->opts->magnet_trackers); - $seeders = sanitize($response['seeders']); - $leechers = sanitize($response['leechers']); - $size = sanitize($response['size']); + $seeders = sanitize($result['seeders']); + $leechers = sanitize($result['leechers']); + $size = sanitize($result['size']); // Ignore results with 0 seeders? if($this->opts->show_zero_seeders == "off" AND $seeders == 0) continue; // Get extra data - $category = sanitize($response['category']); - $url = "https://thepiratebay.org/description.php?id=".sanitize($response['id']); - $date_added = sanitize($response['added']); + $category = sanitize($result['category']); + $url = "https://thepiratebay.org/description.php?id=".sanitize($result['id']); + $date_added = sanitize($result['added']); // Block these categories if(in_array($category, $this->opts->piratebay_categories_blocked)) continue; @@ -114,11 +126,9 @@ public function parse_results($response) { // Filter episodes if(!is_season_or_episode($this->query, $name)) continue; - $id = uniqid(rand(0, 9999)); - $results[] = array( // Required - "id" => $id, "source" => "thepiratebay.org", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => human_filesize($size), + "id" => uniqid(rand(0, 9999)), "source" => "thepiratebay.org", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => human_filesize($size), // Extra "category" => $categories[$category], "url" => $url, "date_added" => $date_added, ); diff --git a/engines/magnet/yts.php b/engines/magnet/yts.php index 39adb3d..9657d61 100644 --- a/engines/magnet/yts.php +++ b/engines/magnet/yts.php @@ -16,9 +16,21 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $results = array(); - $response = curl_multi_getcontent($this->ch); +// $response = curl_multi_getcontent($this->ch); $json_response = json_decode($response, true); // No response @@ -60,11 +72,10 @@ public function parse_results($response) { // Get extra data $quality = sanitize($download['quality']); $codec = sanitize($download['video_codec']); - $id = uniqid(rand(0, 9999)); $results[] = array ( // Required - "id" => $id, "source" => "yts.mx", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, + "id" => uniqid(rand(0, 9999)), "source" => "yts.mx", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => $size, // Extra "quality" => $quality, "codec" => $codec, "year" => $year, "category" => $category, "runtime" => $runtime, "url" => $url, "date_added" => $date_added ); diff --git a/engines/search-image.php b/engines/search-image.php index 576ebc0..b85fb6c 100644 --- a/engines/search-image.php +++ b/engines/search-image.php @@ -13,17 +13,27 @@ class ImageSearch extends EngineRequest { protected $requests; public function __construct($opts, $mh) { - require ABSPATH."engines/image/yahoo.php"; + $this->requests = array(); - $this->requests = array( - new YahooImageRequest($opts, $mh), - ); + if($opts->enable_yahooimages == "on") { + require ABSPATH."engines/image/yahoo.php"; + $this->requests[] = new YahooImageRequest($opts, $mh); + } + + if($opts->enable_openverse == "on") { + require ABSPATH."engines/image/openverse.php"; + $this->requests[] = new OpenverseRequest($opts, $mh); + } + + if($opts->enable_qwant == "on") { + require ABSPATH."engines/image/qwant.php"; + $this->requests[] = new QwantImageRequest($opts, $mh); + } } public function parse_results($response) { $results = array(); - // Merge all results together foreach($this->requests as $request) { if($request->request_successful()) { $engine_result = $request->get_results(); @@ -41,26 +51,28 @@ public function parse_results($response) { // Merge duplicates and apply relevance scoring foreach($engine_result['search'] as $result) { if(array_key_exists('search', $results)) { - $result_urls = array_column($results['search'], "direct_link", "id"); - $found_key = array_search($result['direct_link'], $result_urls); + $result_urls = array_column($results['search'], "webpage_url", "id"); + $found_id = array_search($result['webpage_url'], $result_urls); } else { - $found_key = false; + $found_id = false; } - if($found_key !== false) { + if($found_id !== false) { // Duplicate result from another source, merge and rank accordingly - $results['search'][$found_key]['goosle_rank'] += $result['engine_rank']; + $results['search'][$found_id]['goosle_rank'] += $result['engine_rank']; } else { // First find, rank and add to results $query_terms = explode(" ", preg_replace("/[^a-z0-9 ]+/", "", strtolower($request->query))); $match_rank = match_count($result['alt'], $query_terms); +// $match_rank += match_count($result['url'], $query_terms); + $match_rank += match_count($result['webpage_url'], $query_terms); $result['goosle_rank'] = $result['engine_rank'] + $match_rank; $results['search'][$result['id']] = $result; } - unset($result, $result_urls, $found_key, $social_media_multiplier, $goosle_rank, $match_rank); + unset($result, $result_urls, $found_id, $social_media_multiplier, $goosle_rank, $match_rank); } } } @@ -115,35 +127,38 @@ public static function print_results($results, $opts) { echo "
  • Fetched ".$number_of_results." results in ".$results['time']." seconds.
  • "; // Format sources - search_sources($results['sources']); + echo "
  • Includes ".search_sources($results['sources'])."
  • "; // Did you mean/Search suggestion - search_suggestion($opts, $results); + if(array_key_exists("did_you_mean", $results)) { + echo "
  • Did you mean type."&a=".$opts->hash."\">".$results['did_you_mean']."?".search_suggestion($opts, $results)."
  • "; + } echo ""; // Search results - echo "
    "; - echo "
      "; + echo "
      "; + echo "
        "; foreach($results['search'] as $result) { // Extra data $meta = $links = array(); if(!empty($result['height']) && !empty($result['width'])) $meta[] = $result['width']."×".$result['height']; - if(!empty($result['filesize'])) $meta[] = $result['filesize']; + if(!empty($result['filesize'])) $meta[] = human_filesize($result['filesize']); - $links[] = "Website"; - if(!empty($result['direct_link'])) $links[] = "Image"; + $links[] = "Website"; + if(!empty($result['image_full'])) $links[] = "Image"; // Put result together - echo "
      1. "; - echo "\"".$result['alt']."\""; + echo "
      2. "; + echo "\"".$result['alt']."\""; echo "
        ".implode(" - ", $meta)."
        ".implode(" - ", $links)."
        "; echo "
      3. "; } echo "
      "; echo "
      "; + echo "
      Goosle does not store or distribute image files.
      "; } // No results found diff --git a/engines/search-magnet.php b/engines/search-magnet.php index 8d982be..e7ddb87 100644 --- a/engines/search-magnet.php +++ b/engines/search-magnet.php @@ -30,11 +30,6 @@ public function __construct($opts, $mh) { $this->requests[] = new YTSRequest($opts, $mh); } - if($opts->enable_magnetdl == "on") { - require ABSPATH."engines/magnet/magnetdl.php"; - $this->requests[] = new MagnetDLRequest($opts, $mh); - } - if($opts->enable_nyaa == "on") { require ABSPATH."engines/magnet/nyaa.php"; $this->requests[] = new NyaaRequest($opts, $mh); @@ -46,11 +41,6 @@ public function __construct($opts, $mh) { $this->requests[] = new EZTVRequest($opts, $mh); } } - - if($opts->enable_l33tx == "on") { - require ABSPATH."engines/magnet/1337x.php"; - $this->requests[] = new LeetxRequest($opts, $mh); - } // Special search $this->special_request = special_magnet_request($opts, $mh); @@ -81,7 +71,7 @@ public function parse_results($response) { $results_temp[$found_id]['combo_source'][] = $result['source']; } else { - // First find - rank and add to results + // First find - rank (by combo_seeders instead of internal ranking) and add to results $result['combo_seeders'] = intval($result['seeders']); $result['combo_leechers'] = intval($result['leechers']); $result['combo_source'][] = $result['source']; @@ -121,8 +111,7 @@ public function parse_results($response) { $results['search'] = array_slice($results_temp, 0, 50); // Count results per source - $sources = array_count_values(array_column($results['search'], 'source')); - if(count($sources) > 0) $results['sources'] = $sources; + $results['sources'] = array_count_values(array_column($results['search'], 'source')); unset($sources); } else { @@ -150,13 +139,13 @@ public static function print_results($results, $opts) { // Special results if(array_key_exists("special", $results)) { - echo "
      "; + echo "
      "; if(array_key_exists("yts", $results['special'])) { if($opts->yts_highlight == "date_added") echo "

      Latest releases from YTS

      "; if($opts->yts_highlight == "rating") echo "

      Highest rated on YTS

      "; if($opts->yts_highlight == "download_count") echo "

      Most downloaded from YTS

      "; if($opts->yts_highlight == "seeds") echo "

      Most seeded on YTS

      "; - echo "
        "; + echo "
          "; foreach($results['special']['yts'] as $highlight) { echo "
        1. "; @@ -181,7 +170,7 @@ public static function print_results($results, $opts) { if(array_key_exists("eztv", $results['special'])) { echo "

          Latest releases from EZTV

          "; - echo "
            "; + echo "
              "; foreach($results['special']['eztv'] as $highlight) { echo "
            1. "; @@ -213,7 +202,7 @@ public static function print_results($results, $opts) { echo "
            2. Fetched ".$number_of_results." results in ".$results['time']." seconds.
            3. "; // Format sources - search_sources($results['sources']); + echo "
            4. Includes ".search_sources($results['sources'])."
            5. "; // Search results foreach($results['search'] as $result) { @@ -230,11 +219,11 @@ public static function print_results($results, $opts) { $url = (array_key_exists('url', $result)) ? " - torrent page" : ""; // Put result together - echo "
            6. "; + echo "
            7. "; echo ""; echo "
              Seeds: ".$result['combo_seeders']." - Peers: ".$result['combo_leechers']." - Size: ".$result['size']."
              ".implode(" - ", $meta)."
              "; - if($opts->show_search_source == "on") echo "
              Found on: ".replace_last_comma(implode(", ", $result['combo_source'])).$url."
              "; - echo "
            8. "; + if($opts->show_search_source == "on") echo "
              Found on: ".replace_last_comma(implode(", ", $result['combo_source'])).'.'.$url."
              "; + echo ""; unset($result, $meta, $url); } diff --git a/engines/search.php b/engines/search.php index 346ed4c..7f669e9 100644 --- a/engines/search.php +++ b/engines/search.php @@ -25,20 +25,15 @@ public function __construct($opts, $mh) { $this->requests[] = new GoogleRequest($opts, $mh); } - if($opts->enable_reddit == "on") { - require ABSPATH."engines/search/reddit.php"; - $this->requests[] = new RedditRequest($opts, $mh); + if($opts->enable_qwantnews == "on") { + require ABSPATH."engines/search/qwantnews.php"; + $this->requests[] = new QwantNewsRequest($opts, $mh); } - + if($opts->enable_wikipedia == "on") { require ABSPATH."engines/search/wikipedia.php"; $this->requests[] = new WikiRequest($opts, $mh); } - - if($opts->enable_ecosia == "on") { - require ABSPATH."engines/search/ecosia.php"; - $this->requests[] = new EcosiaRequest($opts, $mh); - } // Special search $this->special_request = special_search_request($opts); @@ -65,18 +60,18 @@ public function parse_results($response) { foreach($engine_result['search'] as $result) { if(array_key_exists('search', $results)) { $result_urls = array_column($results['search'], "url", "id"); - $found_key = array_search($result['url'], $result_urls); + $found_id = array_search($result['url'], $result_urls); } else { - $found_key = false; + $found_id = false; } $social_media_multiplier = (is_social_media($result['url'])) ? ($request->opts->social_media_relevance / 10) : 1; $goosle_rank = floor($result['engine_rank'] * floatval($social_media_multiplier)); - if($found_key !== false) { + if($found_id !== false) { // Duplicate result from another source, merge and rank accordingly - $results['search'][$found_key]['goosle_rank'] += $goosle_rank; - $results['search'][$found_key]['combo_source'][] = $result['source']; + $results['search'][$found_id]['goosle_rank'] += $goosle_rank; + $results['search'][$found_id]['combo_source'][] = $result['source']; } else { // First find, rank and add to results $query_terms = explode(" ", preg_replace("/[^a-z0-9 ]+/", "", strtolower($request->query))); @@ -90,7 +85,7 @@ public function parse_results($response) { $results['search'][$result['id']] = $result; } - unset($result, $result_urls, $found_key, $social_media_multiplier, $goosle_rank, $match_rank); + unset($result, $result_urls, $found_id, $social_media_multiplier, $goosle_rank, $match_rank); } } } @@ -124,8 +119,7 @@ public function parse_results($response) { array_multisort($keys, SORT_DESC, $results['search']); // Count results per source - $sources = array_count_values(array_column($results['search'], 'source')); - if(count($sources) > 0) $results['sources'] = $sources; + $results['sources'] = array_count_values(array_column($results['search'], 'source')); unset($keys); } else { @@ -157,20 +151,22 @@ public static function print_results($results, $opts) { echo "
            9. Fetched ".$number_of_results." results in ".$results['time']." seconds.
            10. "; // Format sources - search_sources($results['sources']); + echo "
            11. Includes ".search_sources($results['sources'])."
            12. "; // Did you mean/Search suggestion - search_suggestion($opts, $results); + if(array_key_exists("did_you_mean", $results)) { + echo "
            13. Did you mean type."&a=".$opts->hash."\">".$results['did_you_mean']."?".search_suggestion($opts, $results)."
            14. "; + } // Special results if(array_key_exists("special", $results)) { - echo "
            15. "; + echo "
            16. "; echo "

              ".$results['special']['title']."

              "; echo "
              ".$results['special']['text']."
              "; if(array_key_exists("source", $results['special'])) { echo ""; } - echo "
            17. "; + echo ""; } // Search results @@ -181,7 +177,7 @@ public static function print_results($results, $opts) { } } - echo "
      "; } - echo ""; + echo ""; } echo "
    "; diff --git a/engines/search/duckduckgo.php b/engines/search/duckduckgo.php index be4fa76..ebae52b 100644 --- a/engines/search/duckduckgo.php +++ b/engines/search/duckduckgo.php @@ -49,6 +49,12 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'text/html, application/xhtml+xml, application/xml;q=0.8, */*;q=0.7', + ); + } + public function parse_results($response) { $results = array(); $xpath = get_xpath($response); @@ -70,19 +76,23 @@ public function parse_results($response) { $rank = $results['amount'] = count($scrape); foreach($scrape as $result) { $url = $xpath->evaluate(".//h2[@class='result__title']//a/@href", $result)[0]; - if($url == null) continue; + if(is_null($url)) continue; $title = $xpath->evaluate(".//h2[@class='result__title']", $result)[0]; - if($title == null) continue; + if(is_null($title)) continue; $description = $xpath->evaluate(".//a[@class='result__snippet']", $result)[0]; - $description = ($description == null) ? "No description was provided for this site." : htmlspecialchars(trim($description->textContent)); + $description = (is_null($description)) ? "No description was provided for this site." : sanitize($description->textContent); - $url = htmlspecialchars(trim($url->textContent)); - $title = htmlspecialchars(trim($title->textContent)); - $id = uniqid(rand(0, 9999)); + $url = sanitize($url->textContent); + $title = sanitize($title->textContent); - $results['search'][] = array ("id" => $id, "source" => "DuckDuckGo", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); + // filter duplicate urls/results + if(!empty($results['search'])) { + if(in_array($url, array_column($results['search'], "url"))) continue; + } + + $results['search'][] = array("id" => uniqid(rand(0, 9999)), "source" => "DuckDuckGo", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); $rank -= 1; } unset($response, $xpath, $scrape, $rank); diff --git a/engines/search/ecosia.php b/engines/search/ecosia.php deleted file mode 100644 index e471cd1..0000000 --- a/engines/search/ecosia.php +++ /dev/null @@ -1,51 +0,0 @@ - $this->query, "method" => "index", "addon" => "opensearch"); - $url = "https://www.ecosia.org/search/?".http_build_query($args); - - return $url; - } - - public function parse_results($response) { - $results = array(); - $xpath = get_xpath($response); - - if(!$xpath) return $results; - - // Scrape the results - $scrape = $xpath->query("//article[@class='result web-result mainline__result']"); - $rank = $results['amount'] = count($scrape); - foreach($scrape as $result) { - $url = $xpath->evaluate(".//a[@class='result__link']/@href", $result)[0]; - if($url == null) continue; - - $title = $xpath->evaluate(".//h2[@class='result-title__heading']", $result)[0]; - if($title == null) continue; - - $description = $xpath->evaluate(".//p[@class='web-result__description']", $result)[0]; - $description = ($description == null) ? "No description was provided for this site." : htmlspecialchars(trim($description->textContent)); - - $url = htmlspecialchars(trim($url->textContent)); - $title = htmlspecialchars(trim($title->textContent)); - $id = uniqid(rand(0, 9999)); - - $results['search'][] = array ("id" => $id, "source" => "Ecosia", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); - $rank -= 1; - } - unset($response, $xpath, $scrape, $rank); - - return $results; - } -} -?> diff --git a/engines/search/google.php b/engines/search/google.php index 2432424..6021039 100644 --- a/engines/search/google.php +++ b/engines/search/google.php @@ -44,6 +44,12 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'text/html, application/xhtml+xml, application/xml;q=0.8, */*;q=0.7', + ); + } + public function parse_results($response) { $results = array(); $xpath = get_xpath($response); @@ -66,19 +72,23 @@ public function parse_results($response) { $rank = $results['amount'] = count($scrape); foreach($scrape as $result) { $url = $xpath->evaluate(".//div[@class='yuRUbf']//a/@href", $result)[0]; - if($url == null) continue; + if(is_null($url)) continue; $title = $xpath->evaluate(".//h3", $result)[0]; - if($title == null) continue; + if(is_null($title)) continue; $description = $xpath->evaluate(".//div[contains(@class, 'VwiC3b')]", $result)[0]; - $description = ($description == null) ? "No description was provided for this site." : htmlspecialchars(trim($description->textContent)); + $description = (is_null($description)) ? "No description was provided for this site." : sanitize($description->textContent); - $url = htmlspecialchars(trim($url->textContent)); - $title = htmlspecialchars(trim($title->textContent)); - $id = uniqid(rand(0, 9999)); + $url = sanitize($url->textContent); + $title = sanitize($title->textContent); - $results['search'][] = array("id" => $id, "source" => "Google", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); + // filter duplicate urls/results + if(!empty($results['search'])) { + if(in_array($url, array_column($results['search'], "url"))) continue; + } + + $results['search'][] = array("id" => uniqid(rand(0, 9999)), "source" => "Google", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); $rank -= 1; } unset($response, $xpath, $scrape, $rank); diff --git a/engines/search/qwantnews.php b/engines/search/qwantnews.php new file mode 100644 index 0000000..84fe19b --- /dev/null +++ b/engines/search/qwantnews.php @@ -0,0 +1,84 @@ +query)); + + // Safe search override + $safe = "1"; // Moderate results + if(strpos($query_terms[0], "safe") !== false) { + $switch = explode(":", $query_terms[0]); + + if(!is_numeric($switch[1])) { + $safe = (strtolower($switch[1]) == "off") ? "0" : "2"; + $this->query = implode(" ", array_slice($query_terms, 1)); + } + } + + $language = (strlen($this->opts->qwant_language) > 0 && strlen($this->opts->qwant_language < 6)) ? $this->opts->qwant_language : "en_gb"; + + // q = query + // t = Type of search, Images + // locale = In which language should the search be done + // source = Where to get the news from (All) + // freshness = How old may the article be? (1 month) + // device = What kind of device are we searching from? + // safesearch = Safe search filter (0 = off, 1 = normal, 2 = strict) + + $args = array("q" => $this->query, "t" => 'news', 'locale' => $language, 'source' => 'all', 'freshness' => 'month', 'device' => 'desktop', 'safesearch' => $safe); + $url = "https://api.qwant.com/v3/search/news?".http_build_query($args); + + unset($query_terms, $switch, $safe, $language, $args); + + return $url; + } + + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + + public function parse_results($response) { + $results = array(); + $json_response = json_decode($response, true); + + // No response + if(empty($json_response)) return $results; + + // Nothing found + if($json_response["status"] != "success") return $results; + + // Set base rank and result amound + $rank = $results['amount'] = $json_response["data"]["result"]["total"]; + + foreach ($json_response["data"]["result"]["items"] as $result) { + $title = sanitize($result['title']); + $url = sanitize($result['url']); + $description = date('M d, Y H:i', sanitize($result['date']))." ⋅ ".sanitize($result['desc']); + + $results['search'][] = array ("id" => uniqid(rand(0, 9999)), "source" => "Qwant News", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); + $rank -= 1; + } + unset($response, $json_response, $rank); + + return $results; + } +} +?> diff --git a/engines/search/reddit.php b/engines/search/reddit.php deleted file mode 100644 index 6bdd26f..0000000 --- a/engines/search/reddit.php +++ /dev/null @@ -1,60 +0,0 @@ - $this->query, "type" => "link", "sort" => "top", "t" => "year"); - $url = "https://www.reddit.com/search.json?".http_build_query($args); - - return $url; - } - - public function parse_results($response) { - $results = array(); - $json_response = json_decode($response, true); - - if(empty($json_response)) return $results; - - // No results - if($json_response['data']['dist'] == 0) return $results; - - $rank = $results['amount'] = count($json_response['data']['children']); - foreach($json_response['data']['children'] as $result) { - $result = $result['data']; - - $nsfw = sanitize($result['over_18']); - - // Ignore NSFW results - if($this->opts->show_reddit_nsfw == "off" && $nsfw === 1) continue; - - $title = trim($result['title']); - $url = "https://www.reddit.com".sanitize($result['permalink']); - - $postdate = date('M d, Y', sanitize($result['created'])); - $author = sanitize($result['author']); - $reddit = sanitize($result['subreddit']); - $votes = sanitize($result['score']); - $comments = sanitize($result['num_comments']); - $nsfw = ($nsfw === 1) ? "[NSFW 18+] Caution, this result contains mature content!
    " : ""; - - $description = $nsfw."In r/".$reddit." ⋅ ".$postdate." ⋅ ".$author." ⋅ ".$votes." votes ⋅ ".$comments." comments"; - - $id = uniqid(rand(0, 9999)); - - $results['search'][] = array ("id" => $id, "source" => "Reddit", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); - $rank -= 1; - } - unset($response, $json_response, $rank); - - return $results; - } -} -?> diff --git a/engines/search/wikipedia.php b/engines/search/wikipedia.php index 09478a3..c61a70b 100644 --- a/engines/search/wikipedia.php +++ b/engines/search/wikipedia.php @@ -17,6 +17,18 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $results = array(); $json_response = json_decode($response, true); @@ -28,12 +40,11 @@ public function parse_results($response) { $rank = $results['amount'] = count($json_response['query']['search']); foreach($json_response['query']['search'] as $result) { - $title = htmlspecialchars(trim($result['title'])); - $url = "https://".$this->opts->wikipedia_language.".wikipedia.org/wiki/".htmlspecialchars(str_replace(" ", "_", trim($result['title']))); - $description = htmlspecialchars(strip_tags(trim($result['snippet']))); - $id = uniqid(rand(0, 9999)); + $title = sanitize($result['title']); + $url = "https://".$this->opts->wikipedia_language.".wikipedia.org/wiki/".sanitize(str_replace(" ", "_", $result['title'])); + $description = sanitize(strip_tags($result['snippet'])); - $results['search'][] = array ("id" => $id, "source" => "Wikipedia", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); + $results['search'][] = array ("id" => uniqid(rand(0, 9999)), "source" => "Wikipedia", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank); $rank -= 1; } unset($response, $json_response, $rank); diff --git a/engines/special/currency.php b/engines/special/currency.php index db19aaf..1d9ff10 100644 --- a/engines/special/currency.php +++ b/engines/special/currency.php @@ -14,6 +14,18 @@ public function get_request_url() { return "https://cdn.moneyconvert.net/api/latest.json"; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $json_response = json_decode($response, true); diff --git a/engines/special/definition.php b/engines/special/definition.php index 9eba34f..f9a5417 100644 --- a/engines/special/definition.php +++ b/engines/special/definition.php @@ -19,6 +19,18 @@ public function get_request_url() { return "https://api.dictionaryapi.dev/api/v2/entries/en/".$query_terms[1]; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $json_response = json_decode($response, true); diff --git a/engines/special/eztv_highlights.php b/engines/special/eztv_highlights.php index 2c3404c..c168e0a 100644 --- a/engines/special/eztv_highlights.php +++ b/engines/special/eztv_highlights.php @@ -15,6 +15,18 @@ public function get_request_url() { return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $results = array(); $json_response = json_decode($response, true); diff --git a/engines/special/php.php b/engines/special/php.php index 9057dd8..b84897d 100644 --- a/engines/special/php.php +++ b/engines/special/php.php @@ -16,6 +16,12 @@ public function get_request_url() { return "https://www.php.net/manual/function.".urlencode($this->query); } + public function get_request_headers() { + return array( + 'Accept' => 'text/html, application/xhtml+xml, application/xml;q=0.8, */*;q=0.7', + ); + } + public function parse_results($response) { $results = array(); $xpath = get_xpath($response); diff --git a/engines/special/yts_highlights.php b/engines/special/yts_highlights.php index 85591e2..1143a3d 100644 --- a/engines/special/yts_highlights.php +++ b/engines/special/yts_highlights.php @@ -11,13 +11,25 @@ ------------------------------------------------------------------------------------ */ class ytshighlights extends EngineRequest { public function get_request_url() { - $url = "https://yts.mx/api/v2/list_movies.json?".http_build_query(array("limit" => "20", "sort_by" => $this->opts->yts_highlight)); + $url = "https://yts.mx/api/v2/list_movies.json?".http_build_query(array("limit" => "16", "sort_by" => $this->opts->yts_highlight)); return $url; } + public function get_request_headers() { + return array( + 'Accept' => 'application/json, */*;q=0.8', + 'Accept-Language' => null, + 'Accept-Encoding' => null, + 'Connection' => null, + 'Sec-Fetch-Dest' => null, + 'Sec-Fetch-Mode' => null, + 'Sec-Fetch-Site' => null + ); + } + public function parse_results($response) { $results = array(); - $response = curl_multi_getcontent($this->ch); +// $response = curl_multi_getcontent($this->ch); $json_response = json_decode($response, true); // No response diff --git a/functions/oauth-functions.php b/functions/oauth-functions.php new file mode 100644 index 0000000..edc32ce --- /dev/null +++ b/functions/oauth-functions.php @@ -0,0 +1,59 @@ + $token))); + } else { + // Update token file + $tokens = unserialize(file_get_contents($token_file)); + $tokens[$connect] = $token; + file_put_contents($token_file, serialize($tokens)); + } +} + +?> \ No newline at end of file diff --git a/functions/oauth.php b/functions/oauth.php new file mode 100644 index 0000000..4360744 --- /dev/null +++ b/functions/oauth.php @@ -0,0 +1,123 @@ +user_auth; +/* ------------------------------------------------------------------------------------ +* Goosle - A meta search engine for private and fast internet fun. +* +* COPYRIGHT NOTICE +* Copyright 2023-2024 Arnan de Gans. All Rights Reserved. +* +* COPYRIGHT NOTICES AND ALL THE COMMENTS SHOULD REMAIN INTACT. +* By using this code you agree to indemnify Arnan de Gans from any +* liability that might arise from its use. +------------------------------------------------------------------------------------ */ +?> + + + + Goosle Search oAUTH + + + + + + + + + + + + + + + + + +
    +

    Goosle

    +

    Use this page to set up an authorization token for Openverse.
    + Fill in the relevant fields and click the button at the bottom to continue.

    + +
    +

    (re)New registration

    +

    Email address:

    (Required for verification)

    + +

    Recovering a previous registration?

    +

    Client ID:

    +

    Client Secret:

    + + + +
    + +
    +
    +
    + +user_agents[0], // Who? + 'post', // post/get + array(), // Additional headers + array('name' => 'Goosle Meta Search '.md5(get_base_url($opts->siteurl)), 'description' => 'Goosle Meta Search for '.get_base_url($opts->siteurl), 'email' => $email) // Payload + ); + + // Site already exists, get new token + if(stristr($registration['name'][0], 'this name already exists')) { + if(is_file($token_file)) { + $tokens = unserialize(file_get_contents($token_file)); + $registration = $tokens['openverse']; + } else { + echo "
    Error - Token file is missing. Please recover your registration with the Client ID and Client Secret.
    hash."\">Try again
    "; + exit; + } + } + } else { + $registration = array('client_id' => $client_id, 'client_secret' => $client_secret); + } + + $new_token = oath_curl_request( + 'https://api.openverse.org/v1/auth_tokens/token/', // Where? + $opts->user_agents[0], // Who? + 'post', // post/get + array('Authorization: Bearer'.$registration['client_id']), // Additional headers + 'grant_type=client_credentials&client_id='.$registration['client_id'].'&client_secret='.$registration['client_secret'] // Payload + ); + + $new_token['expires_in'] = time() + ($new_token['expires_in'] - 3600); + + oath_store_token($token_file, $connect, array("client_id" => $registration['client_id'], "client_secret" => $registration['client_secret'], "access_token" => $new_token['access_token'], "expires" => $new_token['expires_in'])); + + echo "
    SUCCESS!
    Goosle is now authorized and you can enable Openverse in your config.php if you haven't already!
    If this is your first time authorizing with this email address you'll get an email from Openverse in a few moments with a verification link that you need to click.

    To be able to recover your registration save these values:
    Used Email Address: ".$email."
    Client ID: ".$registration['client_id']."
    Client Secret: ".$registration['client_secret']."

    hash."&q=goose&t=1\">Continue to Goosle
    "; + + unset($registration, $new_token); +} +?> + +Goosle
    "; +} +?> + + \ No newline at end of file diff --git a/functions/search_engine.php b/functions/search_engine.php index bc031c0..be75366 100644 --- a/functions/search_engine.php +++ b/functions/search_engine.php @@ -10,7 +10,7 @@ * liability that might arise from its use. ------------------------------------------------------------------------------------ */ abstract class EngineRequest { - protected $url, $query, $opts, $mh, $ch; + protected $query, $ch, $mh, $opts, $url, $headers; function __construct($opts, $mh) { $this->query = $opts->query; @@ -23,11 +23,52 @@ function __construct($opts, $mh) { if(!$this->url) return; // Skip if there is a cached result (from earlier search) - if($this->opts->cache == "on" && has_cached_results($this->opts->cache_type, $this->opts->hash, $this->url, (intval($this->opts->cache_time) * 60))) return; + if($this->opts->cache_type !== "off" && has_cached_results($this->opts->cache_type, $this->opts->hash, $this->url, (intval($this->opts->cache_time) * 60))) return; + + // Default headers for the curl request + $default_headers = array( + 'Accept' => 'text/html, application/xhtml+xml, application/json;q=0.9, application/xml;q=0.8, */*;q=0.7', + 'Accept-Language' => 'en-US,en;q=0.5', + 'Accept-Encoding' => 'gzip, deflate', +// 'Connection' => 'keep-alive', + 'Upgrade-Insecure-Requests' => '1', + 'User-Agent' => $this->opts->user_agents[array_rand($this->opts->user_agents)], + 'Sec-Fetch-Dest' => 'document', + 'Sec-Fetch-Mode' => 'navigate', + 'Sec-Fetch-Site' => 'none' + ); + + // Override or remove headers per curl request + $extra_headers = $this->get_request_headers(); + if(count($extra_headers) > 0) { + $headers = array_filter(array_replace($default_headers, $extra_headers)); + + foreach($headers as $key => $value) { + $this->headers[] = $key.': '.$value; + } + + unset($key, $value); + } else { + $this->headers = $default_headers; + } + + unset($default_headers, $extra_headers, $key, $value); // Curl $this->ch = curl_init(); - set_curl_options($this->ch, $this->url, $this->opts->user_agents); + + curl_setopt($this->ch, CURLOPT_URL, $this->url); + curl_setopt($this->ch, CURLOPT_HTTPGET, 1); // Redundant? Probably... + curl_setopt($this->ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); + curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($this->ch, CURLOPT_ENCODING, "gzip,deflate"); + curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->headers); + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($this->ch, CURLOPT_MAXREDIRS, 5); + curl_setopt($this->ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); + curl_setopt($this->ch, CURLOPT_TIMEOUT, 3); + curl_setopt($this->ch, CURLOPT_VERBOSE, false); if($mh) curl_multi_add_handle($mh, $this->ch); } @@ -63,7 +104,7 @@ public function get_results() { $ttl = intval($this->opts->cache_time) * 60; // If there is a cached result from an earlier search use that instead - if($this->opts->cache == "on" && has_cached_results($this->opts->cache_type, $this->opts->hash, $this->url, $ttl)) { + if($this->opts->cache_type !== "off" && has_cached_results($this->opts->cache_type, $this->opts->hash, $this->url, $ttl)) { return fetch_cached_results($this->opts->cache_type, $this->opts->hash, $this->url); } @@ -75,10 +116,12 @@ public function get_results() { $response = ($this->mh) ? curl_multi_getcontent($this->ch) : curl_exec($this->ch); $results = $this->parse_results($response) ?? array(); - + // Cache last request - if($this->opts->cache == "on") { + if($this->opts->cache_type !== "off") { if(!empty($results)) store_cached_results($this->opts->cache_type, $this->opts->hash, $this->url, $results, $ttl); + + // Maybe delete old file cache if($this->opts->cache_type == "file") delete_cached_results($ttl); } @@ -88,52 +131,6 @@ public function get_results() { public static function print_results($results, $opts) {} } -/*-------------------------------------- -// Try to get some search results ---------------------------------------*/ -function fetch_search_results($opts) { - $start_time = microtime(true); - - echo "
    "; - - if(!empty($opts->query)) { - // Curl - $mh = curl_multi_init(); - - // Load search script - if($opts->type == 0) { - require ABSPATH."engines/search.php"; - $search = new Search($opts, $mh); - } else if($opts->type == 1) { - require ABSPATH."engines/search-image.php"; - $search = new ImageSearch($opts, $mh); - } else if($opts->type == 9) { - require ABSPATH."engines/search-magnet.php"; - $search = new MagnetSearch($opts, $mh); - } - - $running = null; - - do { - curl_multi_exec($mh, $running); - } while ($running); - - $results = $search->get_results(); - - curl_multi_close($mh); - - // Add elapsed time to results - $results['time'] = number_format(microtime(true) - $start_time, 5, '.', ''); - - // Echoes results and special searches - $search->print_results($results, $opts); - } else { - echo ""; - } - - echo "
    "; -} - /*-------------------------------------- // Process special searches --------------------------------------*/ @@ -176,6 +173,7 @@ function special_magnet_request($opts, $mh) { $special_request['yts'] = new ytshighlights($opts, $mh); } + // Latest additions to eztv if($opts->special['eztv'] == "on") { require ABSPATH."engines/special/eztv_highlights.php"; $special_request['eztv'] = new eztvhighlights($opts, $mh); diff --git a/functions/tools.php b/functions/tools.php index dbf99f1..b6024fc 100644 --- a/functions/tools.php +++ b/functions/tools.php @@ -31,8 +31,8 @@ function load_opts() { $opts->user_auth = (isset($_REQUEST['a'])) ? sanitize($_REQUEST['a']) : ""; // Force a few defaults and safeguards - if($opts->cache_type == "file" && !is_dir(ABSPATH.'cache/')) $opts->cache = "off"; - if($opts->cache_type == "apcu" && !function_exists("apcu_exists")) $opts->cache = "off"; + if($opts->cache_type == "file" && !is_dir(ABSPATH.'cache/')) $opts->cache_type = "off"; + if($opts->cache_type == "apcu" && !function_exists("apcu_exists")) $opts->cache_type = "off"; if($opts->enable_image_search == "off" && $opts->type == 1) $opts->type = 0; if($opts->enable_magnet_search == "off" && $opts->type == 9) $opts->type = 0; if(!is_numeric($opts->cache_time) || ($opts->cache_time > 720 || $opts->cache_time < 1)) $opts->cache_time = 30; @@ -44,34 +44,6 @@ function load_opts() { return $opts; } -/*-------------------------------------- -// Set curl options ---------------------------------------*/ -function set_curl_options($curl, $url, $user_agents) { - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_HTTPGET, 1); // Redundant? Probably... - curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_USERAGENT, $user_agents[array_rand($user_agents)]); - curl_setopt($curl, CURLOPT_ENCODING, "gzip,deflate"); - curl_setopt($curl, CURLOPT_HTTPHEADER, array( - 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'Accept-Language: en-US,en;q=0.5', - 'Accept-Encoding: gzip, deflate', - 'Connection: keep-alive', - 'Upgrade-Insecure-Requests: 1', - 'Sec-Fetch-Dest: document', - 'Sec-Fetch-Mode: navigate', - 'Sec-Fetch-Site: none' - )); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($curl, CURLOPT_MAXREDIRS, 5); - curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); - curl_setopt($curl, CURLOPT_TIMEOUT, 3); - curl_setopt($curl, CURLOPT_VERBOSE, false); -} - /*-------------------------------------- // Load pages into a DOM --------------------------------------*/ @@ -97,6 +69,16 @@ function get_formatted_url($url) { return $formatted_url; } +/*-------------------------------------- +// Get websites url/page +--------------------------------------*/ +function get_base_url($siteurl) { + // Figure out server protocol + $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https'; + + return $protocol.'://'.$siteurl; +} + /*-------------------------------------- // Result Caching --------------------------------------*/ @@ -106,7 +88,7 @@ function has_cached_results($cache_type, $hash, $url, $ttl) { } if($cache_type == "file") { - $cache_file = ABSPATH.'cache/'.md5("$hash:$url").'.data'; + $cache_file = ABSPATH.'cache/'.md5("$hash:$url").'.result'; if(is_file($cache_file)) { if(filemtime($cache_file) >= (time() - $ttl)) { return true; @@ -123,7 +105,7 @@ function store_cached_results($cache_type, $hash, $url, $results, $ttl) { } if($cache_type == "file") { - $cache_file = ABSPATH.'cache/'.md5("$hash:$url").'.data'; + $cache_file = ABSPATH.'cache/'.md5("$hash:$url").'.result'; file_put_contents($cache_file, serialize($results)); } } @@ -134,7 +116,7 @@ function fetch_cached_results($cache_type, $hash, $url) { } if($cache_type == "file") { - $cache_file = ABSPATH.'cache/'.md5("$hash:$url").'.data'; + $cache_file = ABSPATH.'cache/'.md5("$hash:$url").'.result'; if(is_file($cache_file)) { return unserialize(file_get_contents($cache_file)); } @@ -147,7 +129,7 @@ function delete_cached_results($ttl) { $folder = opendir(ABSPATH.'cache/'); while($file_name = readdir($folder)) { $extension = pathinfo($file_name, PATHINFO_EXTENSION); - if($file_name == "." OR $file_name == ".." OR $extension != "data") continue; + if($file_name == "." OR $file_name == ".." OR $extension != "result") continue; if(is_file($folder.$file_name)) { if(filemtime($folder.$file_name) < (time() - $ttl)) { @@ -230,6 +212,7 @@ function is_social_media($string) { // Borrowed from https://github.com/lorey/social-media-profiles-regexs if(preg_match("/(?:https?:)?\/\/(?:www\.)?(?:facebook|fb)\.com\/(?P(?![A-z]+\.php)(?!marketplace|gaming|watch|me|messages|help|search|groups)[A-z0-9_\-\.]+)\/?/", $string) + || preg_match("/(?:https?:)?\/\/(?:www\.)facebook.com\/(?:profile.php\?id=)?(?P[0-9]+)/", $string) || preg_match("/(?:https?:)?\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/(?P[A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)/", $string) || preg_match("/(?:https?:)?\/\/(?:[A-z]+\.)?twitter\.com\/@?(?P[A-z0-9_]+)\/status\/(?P[0-9]+)\/?/", $string) || preg_match("/(?:https?:)?\/\/(?:[A-z]+\.)?twitter\.com\/@?(?!home|share|privacy|tos)(?P[A-z0-9_]+)\/?/", $string) @@ -239,6 +222,9 @@ function is_social_media($string) { || preg_match("/(?:https?:)?\/\/(?:[\w]+\.)?linkedin\.com\/(?P(company)|(school))\/(?P[A-z0-9-À-ÿ\.]+)\/?/", $string) || preg_match("/(?:https?:)?\/\/(?:[\w]+\.)?linkedin\.com\/feed\/update\/urn:li:activity:(?P[0-9]+)\/?/", $string) || preg_match("/(?:https?:)?\/\/(?:[\w]+\.)?linkedin\.com\/in\/(?P[\w\-\_À-ÿ%]+)\/?/", $string) +// || preg_match("/(?:https?:)?\/\/(?:[A-z]+\.)?youtube.com\/(?:c(?:hannel)?)\/(?P[A-z0-9-\_]+)\/?/", $string) + || preg_match("/(?:https?:)?\/\/(?:[A-z]+\.)?youtube.com\/(?:u(?:ser)?)\/(?P[A-z0-9]+)\/?/", $string) +// || preg_match("/(?:https?:)?\/\/(?:(?:www\.)?youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)(?P[A-z0-9\-\_]+)/", $string) ) return true; return false; @@ -248,29 +234,23 @@ function is_social_media($string) { // Search suggestions --------------------------------------*/ function search_suggestion($opts, $results) { - if(array_key_exists("did_you_mean", $results)) { - $specific_result = $specific_result2 = ""; - - if(array_key_exists("search_specific", $results)) { - if($opts->type == 3 && count($results['search_specific']) > 1) { - // Format query url - $search_specific_url2 = "./results.php?q=".urlencode($results['search_specific'][1])."&t=".$opts->type."&a=".$opts->hash; - $specific_result2 = " or ".$results['search_specific'][1].""; - } - - // Format query url - $search_specific_url = "./results.php?q=".urlencode($results['search_specific'][0])."&t=".$opts->type."&a=".$opts->hash; - $specific_result = "
    Or instead search for ".$results['search_specific'][0]."".$specific_result2."."; + $specific_result = $specific_result2 = ""; - unset($search_specific, $search_specific_url, $search_specific2, $search_specific_url2); + if(array_key_exists("search_specific", $results)) { + if($opts->type == 3 && count($results['search_specific']) > 1) { + // Format query url + $search_specific_url2 = "./results.php?q=".urlencode($results['search_specific'][1])."&t=".$opts->type."&a=".$opts->hash; + $specific_result2 = " or ".$results['search_specific'][1].""; } - $didyoumean_url = "./results.php?q=".urlencode($results['did_you_mean'])."&t=".$opts->type."&a=".$opts->hash; + // Format query url + $search_specific_url = "./results.php?q=".urlencode($results['search_specific'][0])."&t=".$opts->type."&a=".$opts->hash; + $specific_result = "
    Or instead search for ".$results['search_specific'][0]."".$specific_result2."."; - echo "
  • Did you mean ".$results['did_you_mean']."?".$specific_result."
  • "; - - unset($didyoumean_url, $specific_result, $specific_result2); + unset($search_specific, $search_specific_url, $search_specific2, $search_specific_url2, $specific_result2); } + + return $specific_result; } /*-------------------------------------- @@ -283,11 +263,7 @@ function search_sources($results) { $sources[] = $amount." ".$plural." from ".$source; } - $sources = replace_last_comma(implode(', ', $sources)); - - echo "
  • Includes ".$sources.".
  • "; - - unset($sources); + return $sources = replace_last_comma(implode(', ', $sources)).'.'; } /*-------------------------------------- @@ -336,10 +312,10 @@ function string_generator() { // Show version in footer and do periodic update check --------------------------------------*/ function show_version() { - $cache_file = dirname(__DIR__).'/version.data'; + $cache_file = ABSPATH.'cache/version.data'; // Currently installed version - $current_version = "1.3"; + $current_version = "1.4b3"; // Format current version for footer $show_version = "Goosle ".$current_version."."; @@ -356,7 +332,20 @@ function show_version() { // Update check, every week if($version['checked'] < time() - 604800) { $ch = curl_init(); - set_curl_options($ch, "https://api.github.com/repos/adegans/goosle/releases/latest", array("goosle/".$current_version.";")); + + curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/adegans/goosle/releases/latest'); + curl_setopt($ch, CURLOPT_HTTPGET, 1); // Redundant? Probably... + curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json, */*;q=0.7', 'User-Agent: goosle/'.$current_version.';')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_MAXREDIRS, 5); + curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP); + curl_setopt($ch, CURLOPT_TIMEOUT, 3); + curl_setopt($ch, CURLOPT_VERBOSE, false); + $response = curl_exec($ch); curl_close($ch); diff --git a/goosle-cron.php b/goosle-cron.php index 2c25c0a..8d86f77 100644 --- a/goosle-cron.php +++ b/goosle-cron.php @@ -1,5 +1,5 @@ cache == "on" && $opts->cache_type == "file") { + if($opts->cache_type == "file") { $ttl = intval($opts->cache_time) * 60; + delete_cached_results($ttl); + + echo "Cache deleted!
    "; } - echo "Done!"; + // Possibly renew the Openverse access token + if($opts->enable_image_search == "on" && $opts->enable_openverse == "on") { + require ABSPATH."functions/oauth-functions.php"; + + $token_file = ABSPATH.'cache/token.data'; + + if(is_file($token_file)) { + $tokens = unserialize(file_get_contents($token_file)); + $registration = $tokens['openverse']; + + if($registration['expires'] < time()) { + // Is the token expired? + $new_token = oath_curl_request( + 'https://api.openverse.org/v1/auth_tokens/token/', // Where? + $opts->user_agents[0], // Who? + 'post', // post/get + array('Authorization: Bearer'.$registration['client_id']), // Additional headers + 'grant_type=client_credentials&client_id='.$registration['client_id'].'&client_secret='.$registration['client_secret'] // Payload + ); + + $new_token['expires_in'] = time() + ($new_token['expires_in'] - 3600); + + oath_store_token($token_file, 'openverse', array("client_id" => $registration['client_id'], "client_secret" => $registration['client_secret'], "access_token" => $new_token['access_token'], "expires" => $new_token['expires_in'])); + + echo "New Openverse token stored!
    "; + } + } + } } else { echo "Unauthorized!"; } diff --git a/help.php b/help.php index 06675b1..fe5de0d 100644 --- a/help.php +++ b/help.php @@ -1,8 +1,7 @@ user_auth; @@ -20,116 +19,119 @@ - - - + Goosle Search Help + + + + - - + + + + + + - Goosle Search Help + -
    - +
    +
    +

    Goosle

    + " name="q" /> -
    -
    -

    How to use Goosle

    -

    DuckDuckGo, Google and Ecosia are mostly language agnostic and will try to figure out on their own what language to use based on your search query.

    -

    Searching defaults to Moderate Safe mode. To override the safe mode, prefix your search with safe:on or safe:off.
    On will use 'Strict' mode, while off will disable safe searching, this may yield results that are unsuitable for work or minors.

    - enable_google == "on") { ?> -

    Google results are not personalized by default, using Google's own option for it.

    - - enable_duckduckgo == "on") { ?> -

    DuckDuckGo search bangs are not supported and the ! to trigger them is stripped out to prevent issues.

    - - enable_reddit == "on") { ?> -

    Reddit results will find 'Top Posts' in any subreddit posted in the last year. NSFW or mature content will be visibly marked. Alternatively Goosle has an option to ignore Reddit content labelled as NSFW.

    - - enable_wikipedia == "on") { ?> -

    Goosle can search directly on Wikipedia. This will yield results linking to Wikipedia pages in the language of your choice. Configure your language in config.php or have it default to english.

    - + + + + + +
    + +
    +

    How to use Goosle

    +

    DuckDuckGo and Google are mostly language agnostic and will try to figure out on their own what language to use based on your search query.

    +

    Searching defaults to Moderate Safe mode. To override the safe mode, prefix your search with safe:on or safe:off.
    On will use 'Strict' mode, while off will disable safe searching, this may yield results that are unsuitable for work or minors.

    + enable_google == "on") { ?> +

    Google results are not personalized by default, using Google's own option for it.

    + + enable_duckduckgo == "on") { ?> +

    DuckDuckGo search bangs are not supported and the ! to trigger them is stripped out to prevent issues.

    + + enable_wikipedia == "on") { ?> +

    Goosle can search directly on Wikipedia. This will yield results linking to Wikipedia pages in the language of your choice. Configure your language in config.php or have it default to english.

    + + +

    Result ranking

    +

    To try and provide the best results first, if a website is found through multiple search engines it will show higher in the results on Goosle. Also the amount of matching words in the title and SEO description is considered. A better match will show higher in the results.

    +

    Result ranking is applied to web search and image search.

    + + enable_image_search == "on") { ?> +

    Image Search

    +

    The number of results is not limited but typically yields about 60 to 80 images. If you've enabled Openverse you can set a limit for Openverse images of up to 200 images per search.

    +

    Contrary to regular image search such as Google Image Search which opens a popup/slider with more information. Goosle Image Search links directly to the page where the image is displayed, but also to the actual image itself. You'll see the links for it below each image.

    +

    You can search for images in a general size by adding size:small, size:medium or size:large to your search query.

    + + +

    Special Searches

    + special['currency'] == "on") { ?> +

    Currency converter

    +

    Convert currency with a simple query.
    + For example: Search for 20 EUR in HKD or 14 USD to MXN and Goosle will search for it, but also a local conversion is done in a highlighted result.

    + + + special['phpnet'] == "on") { ?> +

    PHP.net Search

    +

    Prefix your search with php to search on php.net for a PHP function.
    + For example: Searching for php in_array or php trim will show you a brief description, compatible PHP versions and the basic syntax for that function.

    + + + special['definition'] == "on") { ?> +

    Word Definition

    +

    You can easily look up the meaning of single words. Prefix the word you want to look up with any of the following keywords; d, define, mean or meaning.
    + For example: Searching for define search will search for that as normal, but also show the dictionary definition highlighted above the search results.

    +

    Note: Special Searches do not work for image and magnet search.

    + + + enable_magnet_search == "on") { ?> +

    Magnet Search

    +

    Search for anything torrent sites have on offer the direct search result should give you the magnet link.
    Results are gathered from 1337x, Nyaa, The Pirate Bay, EZTV and YTS and are ranked by most seeders. The number of results is limited to 50.

    +

    The search scripts will try to provide useful data which may include; Seeders/Leechers, A link to the torrent page, Download Category, Release year, Movie quality (720p, 4K etc.), Movie Runtime and the Download Size. Not every website makes this available and all results take a best effort approach.

    + imdb_id_search == "on") { ?> +

    Searching TV Shows

    +

    To do a specific search on The Pirate Bay and EZTV you can search for IMDb Title IDs. These are numeric IDs prefixed with tt. This kind of search is useful when you're looking for a tv show that doesn't have a unique name, or simply if you want to use a specialized tracker for tv shows.

    +

    If you already know the Title ID you can enter it directly in the Magnet Link search as your search query.
    + If you don't know the Title ID you can do a regular search for imdb [tv show name], for example imdb Jack Ryan.
    + Goosle will detect the IMDb ID from the search results and include a highlight in the result that offers you to search for downloads through a magnet link search.

    - enable_magnet_search == "on") { ?> -

    Magnet Search

    -

    Search for anything torrent sites have on offer the direct search result should give you the magnet link.
    Results are gathered from 1337x, Nyaa, The Pirate Bay, EZTV and YTS and are ranked by most seeders. The number of results is limited to 50.

    -

    The search scripts will try to provide useful data which may include; Seeders/Leechers, A link to the torrent page, Download Category, Release year, Movie quality (720p, 4K etc.), Movie Runtime and the Download Size. Not every website makes this available and all results take a best effort approach.

    - imdb_id_search == "on") { ?> -

    Searching TV Shows

    -

    To do a specific search on The Pirate Bay and EZTV you can search for IMDb Title IDs. These are numeric IDs prefixed with tt. This kind of search is useful when you're looking for a tv show that doesn't have a unique name, or simply if you want to use a specialized tracker for tv shows.

    -

    If you already know the Title ID you can enter it directly in the Magnet Link search as your search query.
    - If you don't know the Title ID you can do a regular search for imdb [tv show name], for example imdb Jack Ryan.
    - Goosle will detect the IMDb ID from the search results and include a highlight in the result that offers you to search for downloads through a magnet link search.

    - - -

    Filtering TV Show episodes

    -

    To help you narrow down results you can search for specific seasons and episodes. For example: If you search for tt5057054 S02 or Jack Ryan S02 you'll get filtered results for Jack Ryan Season 2. Searching for tt5057054 S02E03 or Jack Ryan S02E03 should find Season 2 Episode 3 and so on.

    -

    Likewise if you want a specific quality of a movie or tv show you can add that directly in your search. For example: If you search for Arrietty 720p you should primarily find that movie in 720p quality if it's available. Common screensizes are 480p, 720p, 1080p, 2160p (4K) and terms like HD-DVD, FULLHD, etc..

    -

    Note: If you like, or found a use for, what you downloaded, you should buy a legal copy of it.

    - + +

    Filtering TV Show episodes

    +

    To help you narrow down results you can search for specific seasons and episodes. For example: If you search for tt5057054 S02 or Jack Ryan S02 you'll get filtered results for Jack Ryan Season 2. Searching for tt5057054 S02E03 or Jack Ryan S02E03 should find Season 2 Episode 3 and so on.

    +

    Likewise if you want a specific quality of a movie or tv show you can add that directly in your search. For example: If you search for Arrietty 720p you should primarily find that movie in 720p quality if it's available. Common screensizes are 480p, 720p, 1080p, 2160p (4K) and terms like HD-DVD, FULLHD, etc..

    +

    Note: If you like, or found a use for, what you downloaded, you should buy a legal copy of it.

    + -

    Acknowledgements:
    Goosle started as a fork of LibreY, and takes some design cues from DuckDuckGo.com. Goosle is created by Arnan de Gans with the intent to make search fun and productive.

    - -
    +

    Acknowledgements:
    Goosle started as a fork of LibreY, and takes some design cues from DuckDuckGo.com. Goosle is created by Arnan de Gans with the intent to make search fun and productive.

    -