main.php 11 KB

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