google.php 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418
  1. <?php
  2. class google{
  3. private const is_class = ".";
  4. private const is_id = "#";
  5. public function __construct(){
  6. include "lib/fuckhtml.php";
  7. $this->fuckhtml = new fuckhtml();
  8. include "lib/nextpage.php";
  9. $this->nextpage = new nextpage("google");
  10. }
  11. public function getfilters($page){
  12. switch($page){
  13. case "web":
  14. case "videos":
  15. case "news":
  16. return [
  17. "country" => [ // gl=<country>
  18. "display" => "Country",
  19. "option" => [
  20. "any" => "Instance's country",
  21. "af" => "Afghanistan",
  22. "al" => "Albania",
  23. "dz" => "Algeria",
  24. "as" => "American Samoa",
  25. "ad" => "Andorra",
  26. "ao" => "Angola",
  27. "ai" => "Anguilla",
  28. "aq" => "Antarctica",
  29. "ag" => "Antigua and Barbuda",
  30. "ar" => "Argentina",
  31. "am" => "Armenia",
  32. "aw" => "Aruba",
  33. "au" => "Australia",
  34. "at" => "Austria",
  35. "az" => "Azerbaijan",
  36. "bs" => "Bahamas",
  37. "bh" => "Bahrain",
  38. "bd" => "Bangladesh",
  39. "bb" => "Barbados",
  40. "by" => "Belarus",
  41. "be" => "Belgium",
  42. "bz" => "Belize",
  43. "bj" => "Benin",
  44. "bm" => "Bermuda",
  45. "bt" => "Bhutan",
  46. "bo" => "Bolivia",
  47. "ba" => "Bosnia and Herzegovina",
  48. "bw" => "Botswana",
  49. "bv" => "Bouvet Island",
  50. "br" => "Brazil",
  51. "io" => "British Indian Ocean Territory",
  52. "bn" => "Brunei Darussalam",
  53. "bg" => "Bulgaria",
  54. "bf" => "Burkina Faso",
  55. "bi" => "Burundi",
  56. "kh" => "Cambodia",
  57. "cm" => "Cameroon",
  58. "ca" => "Canada",
  59. "cv" => "Cape Verde",
  60. "ky" => "Cayman Islands",
  61. "cf" => "Central African Republic",
  62. "td" => "Chad",
  63. "cl" => "Chile",
  64. "cn" => "China",
  65. "cx" => "Christmas Island",
  66. "cc" => "Cocos (Keeling) Islands",
  67. "co" => "Colombia",
  68. "km" => "Comoros",
  69. "cg" => "Congo",
  70. "cd" => "Congo, the Democratic Republic",
  71. "ck" => "Cook Islands",
  72. "cr" => "Costa Rica",
  73. "ci" => "Cote D'ivoire",
  74. "hr" => "Croatia",
  75. "cu" => "Cuba",
  76. "cy" => "Cyprus",
  77. "cz" => "Czech Republic",
  78. "dk" => "Denmark",
  79. "dj" => "Djibouti",
  80. "dm" => "Dominica",
  81. "do" => "Dominican Republic",
  82. "ec" => "Ecuador",
  83. "eg" => "Egypt",
  84. "sv" => "El Salvador",
  85. "gq" => "Equatorial Guinea",
  86. "er" => "Eritrea",
  87. "ee" => "Estonia",
  88. "et" => "Ethiopia",
  89. "fk" => "Falkland Islands (Malvinas)",
  90. "fo" => "Faroe Islands",
  91. "fj" => "Fiji",
  92. "fi" => "Finland",
  93. "fr" => "France",
  94. "gf" => "French Guiana",
  95. "pf" => "French Polynesia",
  96. "tf" => "French Southern Territories",
  97. "ga" => "Gabon",
  98. "gm" => "Gambia",
  99. "ge" => "Georgia",
  100. "de" => "Germany",
  101. "gh" => "Ghana",
  102. "gi" => "Gibraltar",
  103. "gr" => "Greece",
  104. "gl" => "Greenland",
  105. "gd" => "Grenada",
  106. "gp" => "Guadeloupe",
  107. "gu" => "Guam",
  108. "gt" => "Guatemala",
  109. "gn" => "Guinea",
  110. "gw" => "Guinea-Bissau",
  111. "gy" => "Guyana",
  112. "ht" => "Haiti",
  113. "hm" => "Heard Island and Mcdonald Islands",
  114. "va" => "Holy See (Vatican City State)",
  115. "hn" => "Honduras",
  116. "hk" => "Hong Kong",
  117. "hu" => "Hungary",
  118. "is" => "Iceland",
  119. "in" => "India",
  120. "id" => "Indonesia",
  121. "ir" => "Iran, Islamic Republic",
  122. "iq" => "Iraq",
  123. "ie" => "Ireland",
  124. "il" => "Israel",
  125. "it" => "Italy",
  126. "jm" => "Jamaica",
  127. "jp" => "Japan",
  128. "jo" => "Jordan",
  129. "kz" => "Kazakhstan",
  130. "ke" => "Kenya",
  131. "ki" => "Kiribati",
  132. "kp" => "Korea, Democratic People's Republic",
  133. "kr" => "Korea, Republic",
  134. "kw" => "Kuwait",
  135. "kg" => "Kyrgyzstan",
  136. "la" => "Lao People's Democratic Republic",
  137. "lv" => "Latvia",
  138. "lb" => "Lebanon",
  139. "ls" => "Lesotho",
  140. "lr" => "Liberia",
  141. "ly" => "Libyan Arab Jamahiriya",
  142. "li" => "Liechtenstein",
  143. "lt" => "Lithuania",
  144. "lu" => "Luxembourg",
  145. "mo" => "Macao",
  146. "mk" => "Macedonia, the Former Yugosalv Republic",
  147. "mg" => "Madagascar",
  148. "mw" => "Malawi",
  149. "my" => "Malaysia",
  150. "mv" => "Maldives",
  151. "ml" => "Mali",
  152. "mt" => "Malta",
  153. "mh" => "Marshall Islands",
  154. "mq" => "Martinique",
  155. "mr" => "Mauritania",
  156. "mu" => "Mauritius",
  157. "yt" => "Mayotte",
  158. "mx" => "Mexico",
  159. "fm" => "Micronesia, Federated States",
  160. "md" => "Moldova, Republic",
  161. "mc" => "Monaco",
  162. "mn" => "Mongolia",
  163. "ms" => "Montserrat",
  164. "ma" => "Morocco",
  165. "mz" => "Mozambique",
  166. "mm" => "Myanmar",
  167. "na" => "Namibia",
  168. "nr" => "Nauru",
  169. "np" => "Nepal",
  170. "nl" => "Netherlands",
  171. "an" => "Netherlands Antilles",
  172. "nc" => "New Caledonia",
  173. "nz" => "New Zealand",
  174. "ni" => "Nicaragua",
  175. "ne" => "Niger",
  176. "ng" => "Nigeria",
  177. "nu" => "Niue",
  178. "nf" => "Norfolk Island",
  179. "mp" => "Northern Mariana Islands",
  180. "no" => "Norway",
  181. "om" => "Oman",
  182. "pk" => "Pakistan",
  183. "pw" => "Palau",
  184. "ps" => "Palestinian Territory, Occupied",
  185. "pa" => "Panama",
  186. "pg" => "Papua New Guinea",
  187. "py" => "Paraguay",
  188. "pe" => "Peru",
  189. "ph" => "Philippines",
  190. "pn" => "Pitcairn",
  191. "pl" => "Poland",
  192. "pt" => "Portugal",
  193. "pr" => "Puerto Rico",
  194. "qa" => "Qatar",
  195. "re" => "Reunion",
  196. "ro" => "Romania",
  197. "ru" => "Russian Federation",
  198. "rw" => "Rwanda",
  199. "sh" => "Saint Helena",
  200. "kn" => "Saint Kitts and Nevis",
  201. "lc" => "Saint Lucia",
  202. "pm" => "Saint Pierre and Miquelon",
  203. "vc" => "Saint Vincent and the Grenadines",
  204. "ws" => "Samoa",
  205. "sm" => "San Marino",
  206. "st" => "Sao Tome and Principe",
  207. "sa" => "Saudi Arabia",
  208. "sn" => "Senegal",
  209. "cs" => "Serbia and Montenegro",
  210. "sc" => "Seychelles",
  211. "sl" => "Sierra Leone",
  212. "sg" => "Singapore",
  213. "sk" => "Slovakia",
  214. "si" => "Slovenia",
  215. "sb" => "Solomon Islands",
  216. "so" => "Somalia",
  217. "za" => "South Africa",
  218. "gs" => "South Georgia and the South Sandwich Islands",
  219. "es" => "Spain",
  220. "lk" => "Sri Lanka",
  221. "sd" => "Sudan",
  222. "sr" => "Suriname",
  223. "sj" => "Svalbard and Jan Mayen",
  224. "sz" => "Swaziland",
  225. "se" => "Sweden",
  226. "ch" => "Switzerland",
  227. "sy" => "Syrian Arab Republic",
  228. "tw" => "Taiwan, Province of China",
  229. "tj" => "Tajikistan",
  230. "tz" => "Tanzania, United Republic",
  231. "th" => "Thailand",
  232. "tl" => "Timor-Leste",
  233. "tg" => "Togo",
  234. "tk" => "Tokelau",
  235. "to" => "Tonga",
  236. "tt" => "Trinidad and Tobago",
  237. "tn" => "Tunisia",
  238. "tr" => "Turkey",
  239. "tm" => "Turkmenistan",
  240. "tc" => "Turks and Caicos Islands",
  241. "tv" => "Tuvalu",
  242. "ug" => "Uganda",
  243. "ua" => "Ukraine",
  244. "ae" => "United Arab Emirates",
  245. "uk" => "United Kingdom",
  246. "us" => "United States",
  247. "um" => "United States Minor Outlying Islands",
  248. "uy" => "Uruguay",
  249. "uz" => "Uzbekistan",
  250. "vu" => "Vanuatu",
  251. "ve" => "Venezuela",
  252. "vn" => "Viet Nam",
  253. "vg" => "Virgin Islands, British",
  254. "vi" => "Virgin Islands, U.S.",
  255. "wf" => "Wallis and Futuna",
  256. "eh" => "Western Sahara",
  257. "ye" => "Yemen",
  258. "zm" => "Zambia",
  259. "zw" => "Zimbabwe"
  260. ]
  261. ],
  262. "nsfw" => [
  263. "display" => "NSFW",
  264. "option" => [
  265. "yes" => "Yes", // safe=active
  266. "no" => "No" // safe=off
  267. ]
  268. ],
  269. "lang" => [ // lr=<lang> (prefix lang with "lang_")
  270. "display" => "Language",
  271. "option" => [
  272. "any" => "Any language",
  273. "ar" => "Arabic",
  274. "bg" => "Bulgarian",
  275. "ca" => "Catalan",
  276. "cs" => "Czech",
  277. "da" => "Danish",
  278. "de" => "German",
  279. "el" => "Greek",
  280. "en" => "English",
  281. "es" => "Spanish",
  282. "et" => "Estonian",
  283. "fi" => "Finnish",
  284. "fr" => "French",
  285. "hr" => "Croatian",
  286. "hu" => "Hungarian",
  287. "id" => "Indonesian",
  288. "is" => "Icelandic",
  289. "it" => "Italian",
  290. "iw" => "Hebrew",
  291. "ja" => "Japanese",
  292. "ko" => "Korean",
  293. "lt" => "Lithuanian",
  294. "lv" => "Latvian",
  295. "nl" => "Dutch",
  296. "no" => "Norwegian",
  297. "pl" => "Polish",
  298. "pt" => "Portuguese",
  299. "ro" => "Romanian",
  300. "ru" => "Russian",
  301. "sk" => "Slovak",
  302. "sl" => "Slovenian",
  303. "sr" => "Serbian",
  304. "sv" => "Swedish",
  305. "tr" => "Turkish",
  306. "zh-CN" => "Chinese (Simplified)",
  307. "zh-TW" => "Chinese (Traditional)"
  308. ]
  309. ],
  310. "newer" => [ // &sort=review-date:r:20090301:20090430
  311. "display" => "Newer than",
  312. "option" => "_DATE"
  313. ],
  314. "older" => [
  315. "display" => "Older than",
  316. "option" => "_DATE"
  317. ]
  318. ];
  319. break;
  320. case "images":
  321. return [
  322. "country" => [ // gl=<country>
  323. "display" => "Country",
  324. "option" => [
  325. "any" => "Instance's country",
  326. "af" => "Afghanistan",
  327. "al" => "Albania",
  328. "dz" => "Algeria",
  329. "as" => "American Samoa",
  330. "ad" => "Andorra",
  331. "ao" => "Angola",
  332. "ai" => "Anguilla",
  333. "aq" => "Antarctica",
  334. "ag" => "Antigua and Barbuda",
  335. "ar" => "Argentina",
  336. "am" => "Armenia",
  337. "aw" => "Aruba",
  338. "au" => "Australia",
  339. "at" => "Austria",
  340. "az" => "Azerbaijan",
  341. "bs" => "Bahamas",
  342. "bh" => "Bahrain",
  343. "bd" => "Bangladesh",
  344. "bb" => "Barbados",
  345. "by" => "Belarus",
  346. "be" => "Belgium",
  347. "bz" => "Belize",
  348. "bj" => "Benin",
  349. "bm" => "Bermuda",
  350. "bt" => "Bhutan",
  351. "bo" => "Bolivia",
  352. "ba" => "Bosnia and Herzegovina",
  353. "bw" => "Botswana",
  354. "bv" => "Bouvet Island",
  355. "br" => "Brazil",
  356. "io" => "British Indian Ocean Territory",
  357. "bn" => "Brunei Darussalam",
  358. "bg" => "Bulgaria",
  359. "bf" => "Burkina Faso",
  360. "bi" => "Burundi",
  361. "kh" => "Cambodia",
  362. "cm" => "Cameroon",
  363. "ca" => "Canada",
  364. "cv" => "Cape Verde",
  365. "ky" => "Cayman Islands",
  366. "cf" => "Central African Republic",
  367. "td" => "Chad",
  368. "cl" => "Chile",
  369. "cn" => "China",
  370. "cx" => "Christmas Island",
  371. "cc" => "Cocos (Keeling) Islands",
  372. "co" => "Colombia",
  373. "km" => "Comoros",
  374. "cg" => "Congo",
  375. "cd" => "Congo, the Democratic Republic",
  376. "ck" => "Cook Islands",
  377. "cr" => "Costa Rica",
  378. "ci" => "Cote D'ivoire",
  379. "hr" => "Croatia",
  380. "cu" => "Cuba",
  381. "cy" => "Cyprus",
  382. "cz" => "Czech Republic",
  383. "dk" => "Denmark",
  384. "dj" => "Djibouti",
  385. "dm" => "Dominica",
  386. "do" => "Dominican Republic",
  387. "ec" => "Ecuador",
  388. "eg" => "Egypt",
  389. "sv" => "El Salvador",
  390. "gq" => "Equatorial Guinea",
  391. "er" => "Eritrea",
  392. "ee" => "Estonia",
  393. "et" => "Ethiopia",
  394. "fk" => "Falkland Islands (Malvinas)",
  395. "fo" => "Faroe Islands",
  396. "fj" => "Fiji",
  397. "fi" => "Finland",
  398. "fr" => "France",
  399. "gf" => "French Guiana",
  400. "pf" => "French Polynesia",
  401. "tf" => "French Southern Territories",
  402. "ga" => "Gabon",
  403. "gm" => "Gambia",
  404. "ge" => "Georgia",
  405. "de" => "Germany",
  406. "gh" => "Ghana",
  407. "gi" => "Gibraltar",
  408. "gr" => "Greece",
  409. "gl" => "Greenland",
  410. "gd" => "Grenada",
  411. "gp" => "Guadeloupe",
  412. "gu" => "Guam",
  413. "gt" => "Guatemala",
  414. "gn" => "Guinea",
  415. "gw" => "Guinea-Bissau",
  416. "gy" => "Guyana",
  417. "ht" => "Haiti",
  418. "hm" => "Heard Island and Mcdonald Islands",
  419. "va" => "Holy See (Vatican City State)",
  420. "hn" => "Honduras",
  421. "hk" => "Hong Kong",
  422. "hu" => "Hungary",
  423. "is" => "Iceland",
  424. "in" => "India",
  425. "id" => "Indonesia",
  426. "ir" => "Iran, Islamic Republic",
  427. "iq" => "Iraq",
  428. "ie" => "Ireland",
  429. "il" => "Israel",
  430. "it" => "Italy",
  431. "jm" => "Jamaica",
  432. "jp" => "Japan",
  433. "jo" => "Jordan",
  434. "kz" => "Kazakhstan",
  435. "ke" => "Kenya",
  436. "ki" => "Kiribati",
  437. "kp" => "Korea, Democratic People's Republic",
  438. "kr" => "Korea, Republic",
  439. "kw" => "Kuwait",
  440. "kg" => "Kyrgyzstan",
  441. "la" => "Lao People's Democratic Republic",
  442. "lv" => "Latvia",
  443. "lb" => "Lebanon",
  444. "ls" => "Lesotho",
  445. "lr" => "Liberia",
  446. "ly" => "Libyan Arab Jamahiriya",
  447. "li" => "Liechtenstein",
  448. "lt" => "Lithuania",
  449. "lu" => "Luxembourg",
  450. "mo" => "Macao",
  451. "mk" => "Macedonia, the Former Yugosalv Republic",
  452. "mg" => "Madagascar",
  453. "mw" => "Malawi",
  454. "my" => "Malaysia",
  455. "mv" => "Maldives",
  456. "ml" => "Mali",
  457. "mt" => "Malta",
  458. "mh" => "Marshall Islands",
  459. "mq" => "Martinique",
  460. "mr" => "Mauritania",
  461. "mu" => "Mauritius",
  462. "yt" => "Mayotte",
  463. "mx" => "Mexico",
  464. "fm" => "Micronesia, Federated States",
  465. "md" => "Moldova, Republic",
  466. "mc" => "Monaco",
  467. "mn" => "Mongolia",
  468. "ms" => "Montserrat",
  469. "ma" => "Morocco",
  470. "mz" => "Mozambique",
  471. "mm" => "Myanmar",
  472. "na" => "Namibia",
  473. "nr" => "Nauru",
  474. "np" => "Nepal",
  475. "nl" => "Netherlands",
  476. "an" => "Netherlands Antilles",
  477. "nc" => "New Caledonia",
  478. "nz" => "New Zealand",
  479. "ni" => "Nicaragua",
  480. "ne" => "Niger",
  481. "ng" => "Nigeria",
  482. "nu" => "Niue",
  483. "nf" => "Norfolk Island",
  484. "mp" => "Northern Mariana Islands",
  485. "no" => "Norway",
  486. "om" => "Oman",
  487. "pk" => "Pakistan",
  488. "pw" => "Palau",
  489. "ps" => "Palestinian Territory, Occupied",
  490. "pa" => "Panama",
  491. "pg" => "Papua New Guinea",
  492. "py" => "Paraguay",
  493. "pe" => "Peru",
  494. "ph" => "Philippines",
  495. "pn" => "Pitcairn",
  496. "pl" => "Poland",
  497. "pt" => "Portugal",
  498. "pr" => "Puerto Rico",
  499. "qa" => "Qatar",
  500. "re" => "Reunion",
  501. "ro" => "Romania",
  502. "ru" => "Russian Federation",
  503. "rw" => "Rwanda",
  504. "sh" => "Saint Helena",
  505. "kn" => "Saint Kitts and Nevis",
  506. "lc" => "Saint Lucia",
  507. "pm" => "Saint Pierre and Miquelon",
  508. "vc" => "Saint Vincent and the Grenadines",
  509. "ws" => "Samoa",
  510. "sm" => "San Marino",
  511. "st" => "Sao Tome and Principe",
  512. "sa" => "Saudi Arabia",
  513. "sn" => "Senegal",
  514. "cs" => "Serbia and Montenegro",
  515. "sc" => "Seychelles",
  516. "sl" => "Sierra Leone",
  517. "sg" => "Singapore",
  518. "sk" => "Slovakia",
  519. "si" => "Slovenia",
  520. "sb" => "Solomon Islands",
  521. "so" => "Somalia",
  522. "za" => "South Africa",
  523. "gs" => "South Georgia and the South Sandwich Islands",
  524. "es" => "Spain",
  525. "lk" => "Sri Lanka",
  526. "sd" => "Sudan",
  527. "sr" => "Suriname",
  528. "sj" => "Svalbard and Jan Mayen",
  529. "sz" => "Swaziland",
  530. "se" => "Sweden",
  531. "ch" => "Switzerland",
  532. "sy" => "Syrian Arab Republic",
  533. "tw" => "Taiwan, Province of China",
  534. "tj" => "Tajikistan",
  535. "tz" => "Tanzania, United Republic",
  536. "th" => "Thailand",
  537. "tl" => "Timor-Leste",
  538. "tg" => "Togo",
  539. "tk" => "Tokelau",
  540. "to" => "Tonga",
  541. "tt" => "Trinidad and Tobago",
  542. "tn" => "Tunisia",
  543. "tr" => "Turkey",
  544. "tm" => "Turkmenistan",
  545. "tc" => "Turks and Caicos Islands",
  546. "tv" => "Tuvalu",
  547. "ug" => "Uganda",
  548. "ua" => "Ukraine",
  549. "ae" => "United Arab Emirates",
  550. "uk" => "United Kingdom",
  551. "us" => "United States",
  552. "um" => "United States Minor Outlying Islands",
  553. "uy" => "Uruguay",
  554. "uz" => "Uzbekistan",
  555. "vu" => "Vanuatu",
  556. "ve" => "Venezuela",
  557. "vn" => "Viet Nam",
  558. "vg" => "Virgin Islands, British",
  559. "vi" => "Virgin Islands, U.S.",
  560. "wf" => "Wallis and Futuna",
  561. "eh" => "Western Sahara",
  562. "ye" => "Yemen",
  563. "zm" => "Zambia",
  564. "zw" => "Zimbabwe"
  565. ]
  566. ],
  567. "nsfw" => [
  568. "display" => "NSFW",
  569. "option" => [
  570. "yes" => "Yes", // safe=active
  571. "no" => "No" // safe=off
  572. ]
  573. ],
  574. "lang" => [ // lr=<lang> (prefix lang with "lang_")
  575. "display" => "Language",
  576. "option" => [
  577. "any" => "Any language",
  578. "ar" => "Arabic",
  579. "bg" => "Bulgarian",
  580. "ca" => "Catalan",
  581. "cs" => "Czech",
  582. "da" => "Danish",
  583. "de" => "German",
  584. "el" => "Greek",
  585. "en" => "English",
  586. "es" => "Spanish",
  587. "et" => "Estonian",
  588. "fi" => "Finnish",
  589. "fr" => "French",
  590. "hr" => "Croatian",
  591. "hu" => "Hungarian",
  592. "id" => "Indonesian",
  593. "is" => "Icelandic",
  594. "it" => "Italian",
  595. "iw" => "Hebrew",
  596. "ja" => "Japanese",
  597. "ko" => "Korean",
  598. "lt" => "Lithuanian",
  599. "lv" => "Latvian",
  600. "nl" => "Dutch",
  601. "no" => "Norwegian",
  602. "pl" => "Polish",
  603. "pt" => "Portuguese",
  604. "ro" => "Romanian",
  605. "ru" => "Russian",
  606. "sk" => "Slovak",
  607. "sl" => "Slovenian",
  608. "sr" => "Serbian",
  609. "sv" => "Swedish",
  610. "tr" => "Turkish",
  611. "zh-CN" => "Chinese (Simplified)",
  612. "zh-TW" => "Chinese (Traditional)"
  613. ]
  614. ],
  615. "time" => [ // tbs=qrd:<size>
  616. "display" => "Time posted",
  617. "option" => [
  618. "any" => "Any time",
  619. "d" => "Past 24 hours",
  620. "w" => "Past week",
  621. "m" => "Past month",
  622. "y" => "Past year"
  623. ]
  624. ],
  625. "size" => [
  626. "display" => "Size",
  627. "option" => [
  628. // tbs=isz:<size>
  629. "any" => "Any size",
  630. "l" => "Large",
  631. "m" => "Medium",
  632. "i" => "Icon",
  633. // from here
  634. // tbz:lt,islt:<size>
  635. "qsvga" => "Larger than 400x300",
  636. "vga" => "Larger than 640x480",
  637. "qsvga" => "Larger than 800x600",
  638. "xga" => "Larger than 1024x768",
  639. "2mp" => "Larger than 2MP",
  640. "4mp" => "Larger than 4MP",
  641. "6mp" => "Larger than 6MP",
  642. "8mp" => "Larger than 8MP",
  643. "10mp" => "Larger than 10MP",
  644. "12mp" => "Larger than 12MP",
  645. "15mp" => "Larger than 15MP",
  646. "20mp" => "Larger than 20MP",
  647. "40mp" => "Larger than 40MP",
  648. "70mp" => "Larger than 70MP"
  649. ]
  650. ],
  651. "ratio" => [ // tbs=iar:<size>
  652. "display" => "Aspect ratio",
  653. "option" => [
  654. "any" => "Any ratio",
  655. "t" => "Tall",
  656. "s" => "Square",
  657. "w" => "Wide",
  658. "xw" => "Panoramic"
  659. ]
  660. ],
  661. "color" => [ // tbs=ic:<color>
  662. "display" => "Color",
  663. "option" => [
  664. "any" => "Any color",
  665. "color" => "Full color",
  666. "gray" => "Black & white",
  667. "trans" => "Transparent",
  668. // from there, its ic:specific,isc:<color>
  669. "red" => "Red",
  670. "orange" => "Orange",
  671. "yellow" => "Yellow",
  672. "green" => "Green",
  673. "teal" => "Teal",
  674. "blue" => "Blue",
  675. "purple" => "Purple",
  676. "pink" => "Pink",
  677. "white" => "White",
  678. "gray" => "Gray",
  679. "black" => "Black",
  680. "brown" => "Brown"
  681. ]
  682. ],
  683. "type" => [ // tbs=itp:<type>
  684. "display" => "Type",
  685. "option" => [
  686. "any" => "Any type",
  687. "face" => "Faces",
  688. "clipart" => "Clip Art",
  689. "lineart" => "Line Drawing",
  690. "stock" => "Stock",
  691. "animated" => "Animated"
  692. ]
  693. ],
  694. "format" => [ // tbs=ift:<format>
  695. "display" => "Format",
  696. "option" => [
  697. "any" => "Any format",
  698. "jpg" => "JPG",
  699. "gif" => "GIF",
  700. "png" => "PNG",
  701. "bmp" => "BMP",
  702. "svg" => "SVG",
  703. "webp" => "WEBP",
  704. "ico" => "ICO",
  705. "craw" => "RAW"
  706. ]
  707. ],
  708. "rights" => [ // tbs=il:<rights>
  709. "display" => "Usage rights",
  710. "option" => [
  711. "any" => "Any license",
  712. "cl" => "Creative Commons licenses",
  713. "ol" => "Commercial & other licenses"
  714. ]
  715. ]
  716. ];
  717. break;
  718. }
  719. }
  720. private function get($url, $get = []){
  721. $headers = [
  722. "User-Agent: Mozilla/5.0 (Linux; U; Android 2.3.3; pt-pt; LG-P500h-parrot Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MMS/LG-Android-MMS-V1.0/1.2",
  723. "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
  724. "Accept-Language: en-US,en;q=0.5",
  725. "Accept-Encoding: gzip",
  726. "DNT: 1",
  727. "Connection: keep-alive",
  728. "Upgrade-Insecure-Requests: 1",
  729. "Sec-Fetch-Dest: document",
  730. "Sec-Fetch-Mode: navigate",
  731. "Sec-Fetch-Site: none",
  732. "Sec-Fetch-User: ?1"
  733. ];
  734. $curlproc = curl_init();
  735. if($get !== []){
  736. $get = http_build_query($get);
  737. $url .= "?" . $get;
  738. }
  739. curl_setopt($curlproc, CURLOPT_URL, $url);
  740. curl_setopt($curlproc, CURLOPT_ENCODING, ""); // default encoding
  741. curl_setopt($curlproc, CURLOPT_HTTPHEADER, $headers);
  742. curl_setopt($curlproc, CURLOPT_RETURNTRANSFER, true);
  743. curl_setopt($curlproc, CURLOPT_SSL_VERIFYHOST, 2);
  744. curl_setopt($curlproc, CURLOPT_SSL_VERIFYPEER, true);
  745. curl_setopt($curlproc, CURLOPT_CONNECTTIMEOUT, 30);
  746. curl_setopt($curlproc, CURLOPT_TIMEOUT, 30);
  747. $data = curl_exec($curlproc);
  748. if(curl_errno($curlproc)){
  749. throw new Exception(curl_error($curlproc));
  750. }
  751. curl_close($curlproc);
  752. return $data;
  753. }
  754. public function web($get){
  755. $search = $get["s"];
  756. $country = $get["country"];
  757. $nsfw = $get["nsfw"];
  758. $lang = $get["lang"];
  759. $older = $get["older"];
  760. $newer = $get["newer"];
  761. $params = [
  762. "num" => 20 // get 20 results
  763. ];
  764. // country
  765. if($country != "any"){
  766. $params["gl"] = $country;
  767. }
  768. // nsfw
  769. $params["safe"] = $nsfw == "yes" ? "off" : "active";
  770. // language
  771. if($lang != "any"){
  772. $params["lr"] = "lang_" . $lang;
  773. }
  774. // &sort=review-date:r:20090301:20090430
  775. $older = $older === false ? false : date("Ymd", $older);
  776. $newer = $newer === false ? false : date("Ymd", $newer);
  777. if(
  778. $older !== false &&
  779. $newer === false
  780. ){
  781. $newer = date("Ymd", time());
  782. }
  783. if(
  784. $older !== false ||
  785. $newer !== false
  786. ){
  787. $params["sort"] = "review-date:r:" . $older . ":" . $newer;
  788. }
  789. $handle = fopen("scraper/google.html", "r");
  790. $html = fread($handle, filesize("scraper/google.html"));
  791. fclose($handle);
  792. $this->fuckhtml->load($html);
  793. $out = [
  794. "status" => "ok",
  795. "spelling" => [
  796. "type" => "no_correction",
  797. "using" => null,
  798. "correction" => null
  799. ],
  800. "npt" => null,
  801. "answer" => [],
  802. "web" => [],
  803. "image" => [],
  804. "video" => [],
  805. "news" => [],
  806. "related" => []
  807. ];
  808. }
  809. public function image($get){
  810. // generate parameters
  811. if($get["npt"]){
  812. $params =
  813. json_decode(
  814. $this->nextpage->get(
  815. $get["npt"],
  816. "images"
  817. ),
  818. true
  819. );
  820. }else{
  821. $search = $get["s"];
  822. $country = $get["country"];
  823. $nsfw = $get["nsfw"];
  824. $lang = $get["lang"];
  825. $time = $get["time"];
  826. $size = $get["size"];
  827. $ratio = $get["ratio"];
  828. $color = $get["color"];
  829. $type = $get["type"];
  830. $format = $get["format"];
  831. $rights = $get["rights"];
  832. $params = [
  833. "q" => $search,
  834. "tbm" => "isch"
  835. ];
  836. // country
  837. if($country != "any"){
  838. $params["gl"] = $country;
  839. }
  840. // nsfw
  841. $params["safe"] = $nsfw == "yes" ? "off" : "active";
  842. // language
  843. if($lang != "any"){
  844. $params["lr"] = "lang_" . $lang;
  845. }
  846. $tbs = [];
  847. // time
  848. if($time != "any"){
  849. $tbs[] = "qrd:" . $time;
  850. }
  851. // size
  852. if($size != "any"){
  853. if(
  854. in_array(
  855. $size,
  856. ["l", "s", "i"]
  857. )
  858. ){
  859. $tbs[] = "isz:" . $size;
  860. }else{
  861. $tbs[] = "tbz:lt";
  862. $tbs[] = "islt:" . $size;
  863. }
  864. }
  865. // ratio
  866. if($ratio != "any"){
  867. $tbs[] = "iar:" . $ratio;
  868. }
  869. // color
  870. if($color != "any"){
  871. if(
  872. in_array(
  873. $color,
  874. ["color", "gray", "trans"]
  875. )
  876. ){
  877. $tbs[] = "ic:" . $color;
  878. }else{
  879. $tbs[] = "ic:specific";
  880. $tbs[] = "isc:" . $color;
  881. }
  882. }
  883. // type
  884. if($type != "any"){
  885. $tbs[] = "itp:" . $type;
  886. }
  887. // format
  888. if($format != "any"){
  889. $tbs[] = "ift:" . $format;
  890. }
  891. // rights
  892. if($rights != "any"){
  893. $tbs[] = "il:" . $rights;
  894. }
  895. // append tbs
  896. if(count($tbs) !== 0){
  897. $params["tbs"] =
  898. implode(",", $tbs);
  899. }
  900. }
  901. /*
  902. $handle = fopen("scraper/google-img.html", "r");
  903. $html = fread($handle, filesize("scraper/google-img.html"));
  904. fclose($handle);*/
  905. // scrape images
  906. try{
  907. $html =
  908. $this->get(
  909. "https://www.google.com/search",
  910. $params
  911. );
  912. }catch(Exception $error){
  913. throw new Exception("Failed to get search page");
  914. }
  915. $this->fuckhtml->load($html);
  916. $out = [
  917. "status" => "ok",
  918. "npt" => null,
  919. "image" => []
  920. ];
  921. $images =
  922. $this->fuckhtml
  923. ->getElementsByClassName(
  924. "islrtb isv-r",
  925. "div"
  926. );
  927. foreach($images as $image){
  928. $this->fuckhtml->load($image);
  929. $img =
  930. $this->fuckhtml
  931. ->getElementsByTagName("img")[0];
  932. $og_width = (int)$image["attributes"]["data-ow"];
  933. $og_height = (int)$image["attributes"]["data-oh"];
  934. $thumb_width = (int)$image["attributes"]["data-tw"];
  935. $ratio = $og_width / $og_height;
  936. if(isset($img["attributes"]["data-src"])){
  937. $src = &$img["attributes"]["data-src"];
  938. }else{
  939. $src = &$img["attributes"]["src"];
  940. }
  941. $thumb_height = floor($thumb_width / $ratio);
  942. $out["image"][] = [
  943. "title" =>
  944. $this->titledots(
  945. $this->fuckhtml
  946. ->getTextContent(
  947. $image["attributes"]["data-pt"]
  948. )
  949. ),
  950. "source" => [
  951. [
  952. "url" =>
  953. $this->fuckhtml
  954. ->getTextContent(
  955. $image["attributes"]["data-ou"]
  956. ),
  957. "width" => $og_width,
  958. "height" => $og_height
  959. ],
  960. [
  961. "url" =>
  962. $this->fuckhtml
  963. ->getTextContent(
  964. $src
  965. ),
  966. "width" => $thumb_width,
  967. "height" => $thumb_height
  968. ]
  969. ],
  970. "url" =>
  971. $this->fuckhtml
  972. ->getTextContent(
  973. $image["attributes"]["data-ru"]
  974. )
  975. ];
  976. }
  977. // get next page
  978. // https://www.google.com/search
  979. // ?q=higurashi
  980. // &tbm=isch
  981. // &async=_id%3Aislrg_c%2C_fmt%3Ahtml
  982. // &asearch=ichunklite
  983. // &ved=0ahUKEwidjYXJqJSAAxWrElkFHZ07CDwQtDIIQygA
  984. if(count($out["image"]) !== 100){
  985. // no more results
  986. return $out;
  987. }
  988. if($get["npt"]){
  989. // update nextpage information
  990. $params["start"] = (int)$params["start"] + count($out["image"]);
  991. $params["ijn"] = (int)$params["ijn"] + 1;
  992. $out["npt"] =
  993. $this->nextpage->store(
  994. json_encode($params),
  995. "images"
  996. );
  997. }else{
  998. // scrape nextpage information
  999. $this->fuckhtml->load($html);
  1000. $ved =
  1001. $this->fuckhtml
  1002. ->getElementById("islrg", "div");
  1003. if($ved){
  1004. $ved =
  1005. $this->fuckhtml
  1006. ->getTextContent(
  1007. $ved["attributes"]["data-ved"]
  1008. );
  1009. // &vet=1{$ved}..i (10ahUKEwidjYXJqJSAAxWrElkFHZ07CDwQtDIIQygA..i)
  1010. /*
  1011. These 2 are handled by us
  1012. start = start + number of results
  1013. ijn = current page number
  1014. */
  1015. // &start=100
  1016. // &ijn=1
  1017. // &imgvl=CAEY7gQgBSj3Aji8VTjXVUC4AUC3AUgAYNdV
  1018. preg_match(
  1019. '/var e=\'([A-z0-9]+)\';/',
  1020. $html,
  1021. $imgvl
  1022. );
  1023. $imgvl = $imgvl[1];
  1024. $params["async"] = "_id:islrg_c,_fmt:html";
  1025. $params["asearch"] = "ichunklite";
  1026. $params["ved"] = $ved;
  1027. $params["vet"] = "1" . $ved . "..i";
  1028. $params["start"] = 100;
  1029. $params["ijn"] = 1;
  1030. $params["imgvl"] = $imgvl;
  1031. $out["npt"] =
  1032. $this->nextpage->store(
  1033. json_encode($params),
  1034. "images"
  1035. );
  1036. }
  1037. }
  1038. return $out;
  1039. }
  1040. private function hms2int($time){
  1041. $parts = explode(":", $time, 3);
  1042. $time = 0;
  1043. if(count($parts) === 3){
  1044. // hours
  1045. $time = $time + ((int)$parts[0] * 3600);
  1046. array_shift($parts);
  1047. }
  1048. if(count($parts) === 2){
  1049. // minutes
  1050. $time = $time + ((int)$parts[0] * 60);
  1051. array_shift($parts);
  1052. }
  1053. // seconds
  1054. $time = $time + (int)$parts[0];
  1055. return $time;
  1056. }
  1057. private function loadjavascriptcrap($html){
  1058. $this->fuckhtml->load($html);
  1059. $styles =
  1060. $this->fuckhtml
  1061. ->getElementsByTagName("style");
  1062. $this->computedstyle = [];
  1063. $this->ask = [];
  1064. foreach($styles as $style){
  1065. $this->computedstyle =
  1066. array_merge(
  1067. $this->computedstyle,
  1068. $this->parsestyles($style["innerHTML"])
  1069. );
  1070. }
  1071. // get images in javascript var
  1072. preg_match(
  1073. '/google\.ldi=({[^}]+})/',
  1074. $html,
  1075. $this->js_image
  1076. );
  1077. if(count($this->js_image) !== 0){
  1078. $this->js_image = json_decode($this->js_image[1], true);
  1079. }else{
  1080. $this->js_image = [];
  1081. }
  1082. // additional js_images present in <script> tags
  1083. // ugh i fucking hate you
  1084. $scripts =
  1085. $this->fuckhtml
  1086. ->getElementsByTagName("script");
  1087. foreach($scripts as $script){
  1088. if(!isset($script["innerHTML"])){
  1089. continue;
  1090. }
  1091. preg_match_all(
  1092. '/var s=\'(data:image[^\']+)\';var i=\[\'([^\']+)\'];/',
  1093. $script["innerHTML"],
  1094. $image_grep
  1095. );
  1096. if(count($image_grep[0]) !== 0){
  1097. $this->js_image[trim($image_grep[2][0])] =
  1098. $this->fuckhtml
  1099. ->getTextContent(
  1100. $image_grep[1][0]
  1101. );
  1102. }
  1103. // even more javascript crap
  1104. // "People also ask" node is loaded trough javascript
  1105. preg_match_all(
  1106. '/window\.jsl\.dh\(\'([^\']+)\',\'(.+)\'\);/',
  1107. $script["innerHTML"],
  1108. $ask_grep
  1109. );
  1110. for($i=0; $i<count($ask_grep[0]); $i++){
  1111. $this->ask[trim($ask_grep[1][$i])] =
  1112. stripcslashes(
  1113. $ask_grep[2][$i]
  1114. );
  1115. }
  1116. }
  1117. }
  1118. private function findstyles($rules, $is){
  1119. ksort($rules);
  1120. foreach($this->computedstyle as $stylename => $styles){
  1121. if($styles == $rules){
  1122. preg_match(
  1123. '/\\' . $is . '([^ .]+)/',
  1124. $stylename,
  1125. $out
  1126. );
  1127. if(count($out) === 2){
  1128. return $out[1];
  1129. }
  1130. return false;
  1131. }
  1132. }
  1133. return false;
  1134. }
  1135. private function parsestyles($style){
  1136. // get style tags
  1137. preg_match_all(
  1138. '/([^{]+){([^}]+)}/',
  1139. $style,
  1140. $tags_regex
  1141. );
  1142. $tags = [];
  1143. for($i=0; $i<count($tags_regex[0]); $i++){
  1144. $tagnames = explode(",", trim($tags_regex[1][$i]));
  1145. foreach($tagnames as $tagname){
  1146. $tagname = trim($tagname);
  1147. if(!isset($tags[$tagname])){
  1148. $tags[$tagname] = [];
  1149. }
  1150. $values = explode(";", $tags_regex[2][$i]);
  1151. foreach($values as $value){
  1152. $value = explode(":", $value, 2);
  1153. if(count($value) !== 2){
  1154. continue;
  1155. }
  1156. $tags[$tagname][trim($value[0])] =
  1157. trim($value[1]);
  1158. }
  1159. }
  1160. }
  1161. foreach($tags as &$value){
  1162. ksort($value);
  1163. }
  1164. return $tags;
  1165. }
  1166. private function getimage($id){
  1167. if(
  1168. isset($this->js_image[$id]) &&
  1169. $this->js_image[$id] != "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABAUlEQVR4AWMYesChoYElLjkzPj4lY3d8csZjIL4MxPNjUzPcSTYsISFLAqj5NBD/h+LPQPwbiT87NCuLh2gDgRr2QzXuT0jNMoBYksARn5zuHJ+UcR0kB6RXE2VYXHJGOlTDZmzyIJcB5e+D1CSkZDgQNBAaZv+jU1JkcKpJygiGeZ0I76a/Byq8jU9NZFqaCNTA48SE33/iDcw8TIyBt0GKQTFN0Msp6f2EIyUpo57YSIlLSrMhIg0WCIBcCfXSdlzJBsheTHQ6jEnOUgEFOLaEDbMIlhZBOYrorAdJk+nroVnvPsSgdGdoOF7HZyhZ2XPoGQoqjbCpIbt0AiejIQMArVLI7k/DXFkAAAAASUVORK5CYII="
  1170. ){
  1171. if(stripos($this->js_image[$id], "data:image") !== false){
  1172. return
  1173. explode(
  1174. "\\x3d",
  1175. $this->js_image[$id],
  1176. 2
  1177. )[0];
  1178. }
  1179. return $this->js_image[$id];
  1180. }
  1181. return null;
  1182. }
  1183. private function decodeurl($url){
  1184. preg_match(
  1185. '/^\/url\?q=([^&]+)|^\/interstitial\?url=([^&]+)/',
  1186. $this->fuckhtml
  1187. ->getTextContent($url),
  1188. $match
  1189. );
  1190. if(count($match) === 0){
  1191. return null;
  1192. }
  1193. $url = empty($match[1]) ? urldecode($match[2]) : urldecode($match[1]);
  1194. $domain = parse_url($url, PHP_URL_HOST);
  1195. if(
  1196. preg_match(
  1197. '/wikipedia.org$/',
  1198. $domain
  1199. )
  1200. ){
  1201. // rewrite wikipedia mobile URLs to desktop
  1202. $url =
  1203. $this->replacedomain(
  1204. $url,
  1205. preg_replace(
  1206. '/([a-z0-9]+)(\.m\.)/',
  1207. '$1.',
  1208. $domain
  1209. )
  1210. );
  1211. }
  1212. if(
  1213. preg_match(
  1214. '/imdb\.com$|youtube\.[^.]+$/',
  1215. $domain
  1216. )
  1217. ){
  1218. // rewrite imdb and youtube mobile URLs too
  1219. $url =
  1220. $this->replacedomain(
  1221. $url,
  1222. preg_replace(
  1223. '/^m\./',
  1224. "",
  1225. $domain
  1226. )
  1227. );
  1228. }
  1229. return $url;
  1230. }
  1231. private function replacedomain($url, $domain){
  1232. return
  1233. preg_replace(
  1234. '/(https?:\/\/)([^\/]+)/',
  1235. '$1' . $domain,
  1236. $url
  1237. );
  1238. }
  1239. private function titledots($title){
  1240. return rtrim($title, ".… \t\n\r\0\x0B");
  1241. }
  1242. }