main.php 11 KB

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