main.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <?php
  2. include '../auth.php';
  3. ?>
  4. <html>
  5. <head>
  6. <?php
  7. //header("Content-Type: text/plain");
  8. $bg = array('1.jpeg','2.jpeg','3.jpeg','4.jpeg','5.jpeg','6.jpeg','7.jpeg','8.jpeg','9.jpeg'); // array of filenames
  9. $i = rand(0, count($bg)-1); // generate random number size of the array
  10. $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
  11. ?>
  12. <title>ArOZ Mirror</title>
  13. <link rel="stylesheet" href="../script/tocas/tocas.css">
  14. <script src="../script/tocas/tocas.js"></script>
  15. <script src="../script/jquery.min.js"></script>
  16. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons-wind.min.css">
  17. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.min.css">
  18. <style>
  19. h1 { margin:0 0 10px 0; }
  20. .wrapper { position: relative; height:200px; width:300px; margin:20px 0; overflow:hidden; }
  21. .content { position:absolute; bottom:0; width:100%; }
  22. .content div { padding:10px;}
  23. body{
  24. background: url(img/bg/<?php echo $selectedBg; ?>);
  25. background-size: auto 100%;
  26. background-repeat: no-repeat;
  27. background-attachment: fixed;
  28. background-position: center top;
  29. }
  30. </style>
  31. <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  32. <!-- style="background-color:black;color:white;" -->
  33. </head>
  34. <body style="color:white;height:100%;">
  35. <div id="time" align="right" style="position: fixed; top: 10%; right: 5%; width: auto; height: 300px;">
  36. <div id="dayOfWeek" style="font-size: 5vh;height:5vh;"></div>
  37. <div id="CurrentDate" style="font-size: 4vh;height:4vh;"></div>
  38. <div id="CurrentTime" style="font-size: 3vh;height:3vh;"></div>
  39. </div>
  40. <div id="weather" align="left" style="position: fixed; top: 10%; left: 5%; width: auto; height: 500px;">
  41. <div style="font-size: 4vh;height:4vh;" id="country" style="text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black !important;"></div>
  42. <div style="font-size: 2vh;height:2vh;">
  43. <div class="h1"></div>
  44. <p id="city" style="font-size: 3vh;"></p>
  45. <br>
  46. <P><i class="wi wi-night-sleet" style="font-size:80px" id="weathericon"></i></p>
  47. <div class="h2" id="temp" style="text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"></div>
  48. <p id="description" style="text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"></p>
  49. <!-- <br class="clear"> -->
  50. <p id="forecast_details" style="text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"></p>
  51. <p id="wind_details" style="text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"></p>
  52. </div>
  53. </div>
  54. </body>
  55. <script>
  56. $( document ).ready(function() {
  57. var t = setInterval(updateTime,1000);
  58. //show(22.302242, 114.174052);
  59. setTimeout(getLocation(),1500);
  60. });
  61. function updateTime(){
  62. var currentdate = new Date();
  63. $("#dayOfWeek").html(GetDay());
  64. $("#CurrentTime").html(zeroFill(currentdate.getHours(),2) + ":"+ zeroFill(currentdate.getMinutes(),2) + ":" + zeroFill(currentdate.getSeconds(),2));
  65. //$("#CurrentDate").html(currentdate.getDate() + "/" + (currentdate.getMonth()+1) + "/" + currentdate.getFullYear());
  66. $("#CurrentDate").html(GetMonthName() + " " + currentdate.getDate() +", " + currentdate.getFullYear());
  67. }
  68. function GetDay(){
  69. var d = new Date();
  70. var weekday = new Array(7);
  71. weekday[0] = "Sunday";
  72. weekday[1] = "Monday";
  73. weekday[2] = "Tuesday";
  74. weekday[3] = "Wednesday";
  75. weekday[4] = "Thursday";
  76. weekday[5] = "Friday";
  77. weekday[6] = "Saturday";
  78. var n = weekday[d.getDay()];
  79. return n;
  80. }
  81. function GetMonthName(){
  82. var monthNames = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"];
  83. var d = new Date();
  84. return(monthNames[d.getMonth()]);
  85. }
  86. function zeroFill( number, width )
  87. {
  88. width -= number.toString().length;
  89. if ( width > 0 )
  90. {
  91. return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;
  92. }
  93. return number + ""; // always return a string
  94. }
  95. </script>
  96. <script>
  97. function getLocation() {
  98. if (localStorage.getItem("MagicPanel-location") !== null && localStorage.getItem("MagicPanel-location") !== undefined ){
  99. var tmp = JSON.parse(localStorage.getItem("MagicPanel-location"));
  100. show(parseFloat(tmp[0]),parseFloat(tmp[1]));
  101. return;
  102. }
  103. if (confirm("Manual enter Latitude and Longitude?")){
  104. var lt = prompt("Latitude", "22.303797");
  105. var ln = prompt("Longitude", "114.179455");
  106. show(parseFloat(lt),parseFloat(ln));
  107. localStorage.setItem("MagicPanel-location",JSON.stringify([lt,ln]));
  108. }else{
  109. if (navigator.geolocation) {
  110. navigator.geolocation.getCurrentPosition(showPosition);
  111. } else {
  112. console.log("Geolocation is not supported by this browser.");}
  113. }
  114. }
  115. function showPosition(position) {
  116. console.log("Latitude: " + position.coords.latitude + "Longitude: " + position.coords.longitude);
  117. show(position.coords.latitude , position.coords.longitude);
  118. }
  119. function show(lt , ln){
  120. $.getJSON( "https://fcc-weather-api.glitch.me/api/current?lat=" + lt.toFixed(5) + "&lon=" + ln.toFixed(5), function( data ) {
  121. if(typeof data.sys.country !== "undefined"){
  122. $( "#country" ).text(ISO3166[data.sys.country]);
  123. }
  124. if(typeof data.name !== "undefined"){
  125. $( "#city" ).text(data.name);
  126. }
  127. if(typeof data.weather[0].id !== "undefined"){
  128. $( "#weathericon").attr('class',"wi wi-owm-" + data.weather[0].id);
  129. }
  130. if(typeof data.main.temp !== "undefined"){
  131. $( "#temp" ).text(data.main.temp + " °C");
  132. }
  133. if(typeof data.weather[0].main !== "undefined"){
  134. $( "#description" ).text(data.weather[0].main);
  135. }
  136. if(typeof data.main.temp_max !== "undefined" && typeof data.main.temp_min !== "undefined"){
  137. $( "#forecast_details" ).html('Forecast: ' + data.main.temp_max + ' / ' + data.main.temp_min + '&nbsp;°C');
  138. }
  139. if(typeof data.wind.speed !== "undefined"){
  140. $( "#wind_details" ).html('Wind: ' + data.wind.speed + ' km/h');
  141. }
  142. if(typeof data.wind.deg !== "undefined"){
  143. $( "#wind_details" ).append(' <span class="comp sa20" ><i class="wi wi-wind towards-' + data.wind.deg + '-deg"></i></span> from ' + data.wind.deg + 'degree');
  144. }
  145. });
  146. }
  147. var ISO3166 = {
  148. "AF": "Afghanistan",
  149. "AX": "land Islands",
  150. "AL": "Albania",
  151. "DZ": "Algeria",
  152. "AS": "American Samoa",
  153. "AD": "Andorra",
  154. "AO": "Angola",
  155. "AI": "Anguilla",
  156. "AQ": "Antarctica",
  157. "AG": "Antigua and Barbuda",
  158. "AR": "Argentina",
  159. "AM": "Armenia",
  160. "AW": "Aruba",
  161. "AU": "Australia",
  162. "AT": "Austria",
  163. "AZ": "Azerbaijan",
  164. "BS": "Bahamas",
  165. "BH": "Bahrain",
  166. "BD": "Bangladesh",
  167. "BB": "Barbados",
  168. "BY": "Belarus",
  169. "BE": "Belgium",
  170. "BZ": "Belize",
  171. "BJ": "Benin",
  172. "BM": "Bermuda",
  173. "BT": "Bhutan",
  174. "BO": "Bolivia",
  175. "BQ": "Bonaire",
  176. "BA": "Bosnia and Herzegovina",
  177. "BW": "Botswana",
  178. "BV": "Bouvet Island",
  179. "BR": "Brazil",
  180. "IO": "British Indian Ocean Territory",
  181. "BN": "Brunei Darussalam",
  182. "BG": "Bulgaria",
  183. "BF": "Burkina Faso",
  184. "BI": "Burundi",
  185. "KH": "Cambodia",
  186. "CM": "Cameroon",
  187. "CA": "Canada",
  188. "CV": "Cape Verde",
  189. "KY": "Cayman Islands",
  190. "CF": "Central African Republic",
  191. "TD": "Chad",
  192. "CL": "Chile",
  193. "CN": "China",
  194. "CX": "Christmas Island",
  195. "CC": "Cocos (Keeling) Islands",
  196. "CO": "Colombia",
  197. "KM": "Comoros",
  198. "CG": "Congo",
  199. "CD": "Congo",
  200. "CK": "Cook Islands",
  201. "CR": "Costa Rica",
  202. "CI": "Cte d'Ivoire",
  203. "HR": "Croatia",
  204. "CU": "Cuba",
  205. "CW": "Curaao",
  206. "CY": "Cyprus",
  207. "CZ": "Czech Republic",
  208. "DK": "Denmark",
  209. "DJ": "Djibouti",
  210. "DM": "Dominica",
  211. "DO": "Dominican Republic",
  212. "EC": "Ecuador",
  213. "EG": "Egypt",
  214. "SV": "El Salvador",
  215. "GQ": "Equatorial Guinea",
  216. "ER": "Eritrea",
  217. "EE": "Estonia",
  218. "ET": "Ethiopia",
  219. "FK": "Falkland Islands (Malvinas)",
  220. "FO": "Faroe Islands",
  221. "FJ": "Fiji",
  222. "FI": "Finland",
  223. "FR": "France",
  224. "GF": "French Guiana",
  225. "PF": "French Polynesia",
  226. "TF": "French Southern Territories",
  227. "GA": "Gabon",
  228. "GM": "Gambia",
  229. "GE": "Georgia",
  230. "DE": "Germany",
  231. "GH": "Ghana",
  232. "GI": "Gibraltar",
  233. "GR": "Greece",
  234. "GL": "Greenland",
  235. "GD": "Grenada",
  236. "GP": "Guadeloupe",
  237. "GU": "Guam",
  238. "GT": "Guatemala",
  239. "GG": "Guernsey",
  240. "GN": "Guinea",
  241. "GW": "Guinea-Bissau",
  242. "GY": "Guyana",
  243. "HT": "Haiti",
  244. "HM": "Heard Island and McDonald Islands",
  245. "VA": "Holy See (Vatican City State)",
  246. "HN": "Honduras",
  247. "HK": "Hong Kong",
  248. "HU": "Hungary",
  249. "IS": "Iceland",
  250. "IN": "India",
  251. "ID": "Indonesia",
  252. "IR": "Iran",
  253. "IQ": "Iraq",
  254. "IE": "Ireland",
  255. "IM": "Isle of Man",
  256. "IL": "Israel",
  257. "IT": "Italy",
  258. "JM": "Jamaica",
  259. "JP": "Japan",
  260. "JE": "Jersey",
  261. "JO": "Jordan",
  262. "KZ": "Kazakhstan",
  263. "KE": "Kenya",
  264. "KI": "Kiribati",
  265. "KP": "Korea",
  266. "KR": "Korea",
  267. "KW": "Kuwait",
  268. "KG": "Kyrgyzstan",
  269. "LA": "Lao People's Democratic Republic",
  270. "LV": "Latvia",
  271. "LB": "Lebanon",
  272. "LS": "Lesotho",
  273. "LR": "Liberia",
  274. "LY": "Libya",
  275. "LI": "Liechtenstein",
  276. "LT": "Lithuania",
  277. "LU": "Luxembourg",
  278. "MO": "Macao",
  279. "MK": "Macedonia",
  280. "MG": "Madagascar",
  281. "MW": "Malawi",
  282. "MY": "Malaysia",
  283. "MV": "Maldives",
  284. "ML": "Mali",
  285. "MT": "Malta",
  286. "MH": "Marshall Islands",
  287. "MQ": "Martinique",
  288. "MR": "Mauritania",
  289. "MU": "Mauritius",
  290. "YT": "Mayotte",
  291. "MX": "Mexico",
  292. "FM": "Micronesia",
  293. "MD": "Moldova",
  294. "MC": "Monaco",
  295. "MN": "Mongolia",
  296. "ME": "Montenegro",
  297. "MS": "Montserrat",
  298. "MA": "Morocco",
  299. "MZ": "Mozambique",
  300. "MM": "Myanmar",
  301. "NA": "Namibia",
  302. "NR": "Nauru",
  303. "NP": "Nepal",
  304. "NL": "Netherlands",
  305. "NC": "New Caledonia",
  306. "NZ": "New Zealand",
  307. "NI": "Nicaragua",
  308. "NE": "Niger",
  309. "NG": "Nigeria",
  310. "NU": "Niue",
  311. "NF": "Norfolk Island",
  312. "MP": "Northern Mariana Islands",
  313. "NO": "Norway",
  314. "OM": "Oman",
  315. "PK": "Pakistan",
  316. "PW": "Palau",
  317. "PS": "Palestine",
  318. "PA": "Panama",
  319. "PG": "Papua New Guinea",
  320. "PY": "Paraguay",
  321. "PE": "Peru",
  322. "PH": "Philippines",
  323. "PN": "Pitcairn",
  324. "PL": "Poland",
  325. "PT": "Portugal",
  326. "PR": "Puerto Rico",
  327. "QA": "Qatar",
  328. "RE": "Runion",
  329. "RO": "Romania",
  330. "RU": "Russian Federation",
  331. "RW": "Rwanda",
  332. "BL": "Saint Barthlemy",
  333. "SH": "Saint Helena",
  334. "KN": "Saint Kitts and Nevis",
  335. "LC": "Saint Lucia",
  336. "MF": "Saint Martin (French part)",
  337. "PM": "Saint Pierre and Miquelon",
  338. "VC": "Saint Vincent and the Grenadines",
  339. "WS": "Samoa",
  340. "SM": "San Marino",
  341. "ST": "Sao Tome and Principe",
  342. "SA": "Saudi Arabia",
  343. "SN": "Senegal",
  344. "RS": "Serbia",
  345. "SC": "Seychelles",
  346. "SL": "Sierra Leone",
  347. "SG": "Singapore",
  348. "SX": "Sint Maarten (Dutch part)",
  349. "SK": "Slovakia",
  350. "SI": "Slovenia",
  351. "SB": "Solomon Islands",
  352. "SO": "Somalia",
  353. "ZA": "South Africa",
  354. "GS": "South Georgia and the South Sandwich Islands",
  355. "SS": "South Sudan",
  356. "ES": "Spain",
  357. "LK": "Sri Lanka",
  358. "SD": "Sudan",
  359. "SR": "Suriname",
  360. "SJ": "Svalbard and Jan Mayen",
  361. "SZ": "Swaziland",
  362. "SE": "Sweden",
  363. "CH": "Switzerland",
  364. "SY": "Syrian Arab Republic",
  365. "TW": "Taiwan",
  366. "TJ": "Tajikistan",
  367. "TZ": "Tanzania",
  368. "TH": "Thailand",
  369. "TL": "Timor-Leste",
  370. "TG": "Togo",
  371. "TK": "Tokelau",
  372. "TO": "Tonga",
  373. "TT": "Trinidad and Tobago",
  374. "TN": "Tunisia",
  375. "TR": "Turkey",
  376. "TM": "Turkmenistan",
  377. "TC": "Turks and Caicos Islands",
  378. "TV": "Tuvalu",
  379. "UG": "Uganda",
  380. "UA": "Ukraine",
  381. "AE": "United Arab Emirates",
  382. "GB": "United Kingdom",
  383. "US": "United States",
  384. "UM": "United States Minor Outlying Islands",
  385. "UY": "Uruguay",
  386. "UZ": "Uzbekistan",
  387. "VU": "Vanuatu",
  388. "VE": "Venezuela",
  389. "VN": "Viet Nam",
  390. "VG": "Virgin Islands",
  391. "VI": "Virgin Islands",
  392. "WF": "Wallis and Futuna",
  393. "EH": "Western Sahara",
  394. "YE": "Yemen",
  395. "ZM": "Zambia",
  396. "ZW": "Zimbabwe"
  397. }
  398. </script>
  399. </html>