PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/website/community/de_timeconverter.php

https://gitlab.com/Drakons/Illarion-Website
PHP | 351 lines | 326 code | 25 blank | 0 comment | 14 complexity | 60e317685f8a588cde1336e247aa9268 MD5 | raw file
  1. <?php
  2. include $_SERVER['DOCUMENT_ROOT'] . '/shared/shared.php';
  3. Page::setTitle( 'Zeitumrechnung' );
  4. Page::setDescription( 'Mit dieser Seite ist es möglich die Illarion Zeit in die echte Zeit umzurechnen' );
  5. Page::setKeywords( array( 'Zeit', 'umrechnen', 'Zeitumrechner', 'Umrechner' ) );
  6. Page::setXHTML();
  7. Page::Init();
  8. $timekey = (isset( $_GET['timekey'] ) && ctype_xdigit($_GET['timekey']) ? hexdec( $_GET['timekey'] ) : false);
  9. $show_result = false;
  10. $show_input = true;
  11. if ($timekey)
  12. {
  13. $server_timestamp = $timekey;
  14. $local_timestamp = IllaDateTime::TimestampWithOffset( $server_timestamp );
  15. $illa_timestamp = IllaDateTime::RLTimeToIllaTime( $server_timestamp );
  16. $show_result = true;
  17. $show_input = false;
  18. }
  19. elseif ( isset($_POST['type']) && $_POST['type'] === 'rl' )
  20. {
  21. $local_timestamp = mktime( (int)$_POST['hour'], (int)$_POST['minute'], (int)$_POST['second'], (int)$_POST['month'], (int)$_POST['day'], (int)$_POST['year'] );
  22. $server_timestamp = IllaDateTime::TimestampWithoutOffset( $local_timestamp );
  23. $illa_timestamp = IllaDateTime::RLTimeToIllaTime( $server_timestamp );
  24. $show_result = true;
  25. $show_input = true;
  26. }
  27. elseif ( isset($_POST['type']) && $_POST['type'] === 'server' )
  28. {
  29. $server_timestamp = mktime( (int)$_POST['hour'], (int)$_POST['minute'], (int)$_POST['second'], (int)$_POST['month'], (int)$_POST['day'], (int)$_POST['year'] );
  30. $local_timestamp = IllaDateTime::TimestampWithOffset( $server_timestamp );
  31. $illa_timestamp = IllaDateTime::RLTimeToIllaTime( $server_timestamp );
  32. $show_result = true;
  33. $show_input = true;
  34. }
  35. elseif ( isset($_POST['type']) && $_POST['type'] === 'illa' )
  36. {
  37. $illa_timestamp = IllaDateTime::mkIllaTimestamp( (int)$_POST['hour'], (int)$_POST['minute'], (int)$_POST['second'], (int)$_POST['month'], (int)$_POST['day'], (int)$_POST['year'] );
  38. $server_timestamp = IllaDateTime::IllaTimeToRLTime( $illa_timestamp );
  39. $local_timestamp = IllaDateTime::TimestampWithOffset( $server_timestamp );
  40. $show_result = true;
  41. $show_input = true;
  42. }
  43. else
  44. {
  45. $server_timestamp = time();
  46. $local_timestamp = IllaDateTime::TimestampWithOffset( $server_timestamp );
  47. $illa_timestamp = IllaDateTime::RLTimeToIllaTime( $server_timestamp );
  48. $show_result = false;
  49. $show_input = true;
  50. }
  51. ?>
  52. <h1>Zeitumrechner</h1>
  53. <?php if ($show_result): ?>
  54. <h2>Resultat der Zeitumrechnung</h2>
  55. <table>
  56. <colgroup>
  57. <col style="width:210px;" />
  58. <col style="width:15px;" />
  59. <col style="width:150px;" />
  60. <col style="width:15px;" />
  61. <col style="width:100px;" />
  62. </colgroup>
  63. <tr>
  64. <th />
  65. <th />
  66. <th>Datum</th>
  67. <th />
  68. <th>Uhrzeit</th>
  69. </tr>
  70. <tr>
  71. <td colspan="5" style="height:10px" />
  72. </tr>
  73. <tr>
  74. <th style="text-align:right;">Lokale Zeit:</th>
  75. <td />
  76. <td style="text-align:center;font-weight:bold;"><?php echo strftime('%d. %B %Y', $local_timestamp); ?></td>
  77. <td />
  78. <td style="text-align:center;font-weight:bold;"><?php echo strftime('%T', $local_timestamp); ?></td>
  79. </tr>
  80. <tr>
  81. <td colspan="5" style="height:10px" />
  82. </tr>
  83. <tr>
  84. <th style="text-align:right;">Server Zeit:</th>
  85. <td />
  86. <td style="text-align:center;font-weight:bold;"><?php echo strftime('%d. %B %Y', $server_timestamp); ?></td>
  87. <td />
  88. <td style="text-align:center;font-weight:bold;"><?php echo strftime('%T', $server_timestamp); ?></td>
  89. </tr>
  90. <tr>
  91. <td colspan="5" style="height:10px" />
  92. </tr>
  93. <tr>
  94. <th style="text-align:right;">Illarion Zeit:</th>
  95. <td />
  96. <td style="text-align:center;font-weight:bold;"><?php echo IllaDateTime::IllaTimestampToTime('d. F Y', $illa_timestamp); ?></td>
  97. <td />
  98. <td style="text-align:center;font-weight:bold;"><?php echo IllaDateTime::IllaTimestampToTime('H:i:s', $illa_timestamp) ?></td>
  99. </tr>
  100. </table>
  101. <?php if ($show_input): ?>
  102. <table style="width:100%;">
  103. <tr>
  104. <td style="width:150px;">Link zu dieser Seite:</td>
  105. <td><input type="text" name="pagelink" readonly="readonly" onclick="this.select();" style="width:100%;" value="<?php echo Page::getURL(); ?>/community/un_timeconverter.php?timekey=<?php echo dechex( $server_timestamp ); ?>" /></td>
  106. </tr>
  107. <tr>
  108. <td style="width:150px;">BBCode:</td>
  109. <td><input type="text" name="pagelink" readonly="readonly" onclick="this.select();" style="width:100%;" value="[url=<?php echo Page::getURL(); ?>/community/un_timeconverter.php?timekey=<?php echo dechex( $server_timestamp ); ?>]<?php echo IllaDateTime::IllaTimestampToTime('d. F Y H:i', $illa_timestamp); ?>[/url]" /></td>
  110. </tr>
  111. </table>
  112. <?php endif; ?>
  113. <?php Page::insert_go_to_top_link(); ?>
  114. <?php endif; ?>
  115. <?php if ($show_input): ?>
  116. <h2>Aus der lokalen Zeit umrechnen</h2>
  117. <p>Die richtige Funktionalität dieser Umrechnung ist davon abhängig, dass deine Zeitzone in deinem Account eingestellt ist. Wird keine Umrechnung
  118. vorgenommen, so zeigt diese Seite die aktuelle Zeit. Hiermit kannst du auch überprüfen, ob
  119. deine lokale Zeitzone richtig eingestellt ist.</p>
  120. <form action="<?php echo Page::getURL(); ?>/community/de_timeconverter.php" method="post">
  121. <table style="width:100%;">
  122. <colgroup>
  123. <col style="width:90px;" />
  124. <col style="width:90px;" />
  125. <col style="width:90px;" />
  126. <col />
  127. <col style="width:90px;" />
  128. <col style="width:90px;" />
  129. <col style="width:90px;" />
  130. </colgroup>
  131. <thead>
  132. <tr>
  133. <th>Tag</th>
  134. <th>Monat</th>
  135. <th>Jahr</th>
  136. <th />
  137. <th>Stunde</th>
  138. <th>Minute</th>
  139. <th>Sekunde</th>
  140. </tr>
  141. </thead>
  142. <tfoot>
  143. <tr>
  144. <td colspan="3" style="text-align:right;">
  145. <input type="reset" name="reset" value="Zurücksetzen" style="width:120px;" />
  146. </td>
  147. <td />
  148. <td colspan="3">
  149. <input type="submit" name="submit" value="Umrechnen" style="width:120px;" />
  150. <input type="hidden" name="type" value="rl" />
  151. </td>
  152. </tr>
  153. </tfoot>
  154. <tbody>
  155. <tr>
  156. <td>
  157. <input style="width:100%" type="text" name="day" value="<?php echo date('d', $local_timestamp); ?>" />
  158. </td>
  159. <td>
  160. <select name="month" style="background-color:black;width:100%;">
  161. <?php $rl_month = date('m', $local_timestamp);
  162. for ( $i=1;$i<=12;$i++ ): ?>
  163. <option value="<?php echo $i; ?>"<?php echo ( (int)$rl_month == $i ? ' selected="selected"' : '' ); ?>><?php echo nl_langinfo( constant( 'MON_'.$i ) ) ?></option>
  164. <?php endfor; ?>
  165. </select>
  166. </td>
  167. <td>
  168. <input style="width:100%" type="text" name="year" value="<?php echo date('Y', $local_timestamp); ?>" />
  169. </td>
  170. <td />
  171. <td>
  172. <input style="width:100%" type="text" name="hour" value="<?php echo date('H', $local_timestamp); ?>" />
  173. </td>
  174. <td>
  175. <input style="width:100%" type="text" name="minute" value="<?php echo date('i', $local_timestamp); ?>" />
  176. </td>
  177. <td>
  178. <input style="width:100%" type="text" name="second" value="<?php echo date('s', $local_timestamp); ?>" />
  179. </td>
  180. </tr>
  181. <tr>
  182. <td colspan="7" style="height:10px" />
  183. </tr>
  184. </tbody>
  185. </table>
  186. </form>
  187. <?php Page::insert_go_to_top_link(); ?>
  188. <h2>Aus der Serverzeit umrechnen</h2>
  189. <p>Der Server befindet sich im Augenblick in der Zeitzone GMT+<?php echo ((int)date( 'O', time() ))/100; ?></p>
  190. <form action="<?php echo Page::getURL(); ?>/community/de_timeconverter.php" method="post">
  191. <table style="width:100%;">
  192. <colgroup>
  193. <col style="width:90px;" />
  194. <col style="width:90px;" />
  195. <col style="width:90px;" />
  196. <col />
  197. <col style="width:90px;" />
  198. <col style="width:90px;" />
  199. <col style="width:90px;" />
  200. </colgroup>
  201. <thead>
  202. <tr>
  203. <th>Tag</th>
  204. <th>Monat</th>
  205. <th>Jahr</th>
  206. <th />
  207. <th>Stunde</th>
  208. <th>Minute</th>
  209. <th>Sekunde</th>
  210. </tr>
  211. </thead>
  212. <tfoot>
  213. <tr>
  214. <td colspan="3" style="text-align:right;">
  215. <input type="reset" name="reset" value="Zurücksetzen" style="width:120px;" />
  216. </td>
  217. <td />
  218. <td colspan="3">
  219. <input type="submit" name="submit" value="Umrechnen" style="width:120px;" />
  220. <input type="hidden" name="type" value="server" />
  221. </td>
  222. </tr>
  223. </tfoot>
  224. <tbody>
  225. <tr>
  226. <td>
  227. <input style="width:100%" type="text" name="day" value="<?php echo date('d', $server_timestamp); ?>" />
  228. </td>
  229. <td>
  230. <select name="month" style="background-color:black;width:100%;">
  231. <?php $rl_month = date('m', $server_timestamp);
  232. for ( $i=1;$i<=12;$i++ ): ?>
  233. <option value="<?php echo $i; ?>"<?php echo ( (int)$rl_month == $i ? ' selected="selected"' : '' ); ?>><?php echo nl_langinfo( constant( 'MON_'.$i ) ) ?></option>
  234. <?php endfor; ?>
  235. </select>
  236. </td>
  237. <td>
  238. <input style="width:100%" type="text" name="year" value="<?php echo date('Y', $server_timestamp); ?>" />
  239. </td>
  240. <td />
  241. <td>
  242. <input style="width:100%" type="text" name="hour" value="<?php echo date('H', $server_timestamp); ?>" />
  243. </td>
  244. <td>
  245. <input style="width:100%" type="text" name="minute" value="<?php echo date('i', $server_timestamp); ?>" />
  246. </td>
  247. <td>
  248. <input style="width:100%" type="text" name="second" value="<?php echo date('s', $server_timestamp); ?>" />
  249. </td>
  250. </tr>
  251. <tr>
  252. <td colspan="7" style="height:10px" />
  253. </tr>
  254. </tbody>
  255. </table>
  256. </form>
  257. <?php Page::insert_go_to_top_link(); ?>
  258. <h2>Aus Illarionzeit umrechnen</h2>
  259. <form action="<?php echo $url; ?>/community/de_timeconverter.php" method="post">
  260. <table style="width:100%;">
  261. <colgroup>
  262. <col style="width:90px;" />
  263. <col style="width:90px;" />
  264. <col style="width:90px;" />
  265. <col />
  266. <col style="width:90px;" />
  267. <col style="width:90px;" />
  268. <col style="width:90px;" />
  269. </colgroup>
  270. <thead>
  271. <tr>
  272. <th>Tag</th>
  273. <th>Monat</th>
  274. <th>Jahr</th>
  275. <th />
  276. <th>Stunde</th>
  277. <th>Minute</th>
  278. <th>Sekunde</th>
  279. </tr>
  280. </thead>
  281. <tfoot>
  282. <tr>
  283. <td colspan="3" style="text-align:right;">
  284. <input type="reset" name="reset" value="Zurücksetzen" style="width:120px;" />
  285. </td>
  286. <td />
  287. <td colspan="3">
  288. <input type="submit" name="submit" value="Umrechnen" style="width:120px;" />
  289. <input type="hidden" name="type" value="illa" />
  290. </td>
  291. </tr>
  292. </tfoot>
  293. <tbody>
  294. <tr> <?php $illa_time = IllaDateTime::IllaTimestampToTime('array', $illa_timestamp); ?>
  295. <td>
  296. <input style="width:100%" type="text" name="day" value="<?php echo $illa_time['day']; ?>" />
  297. </td>
  298. <td>
  299. <select name="month" style="background-color:black;width:100%;">
  300. <?php for ( $i=1;$i<=16;$i++ ): ?>
  301. <option value="<?php echo $i; ?>"<?php echo ( (int)$illa_time['month'] == $i ? ' selected="selected"' : '' ); ?>><?php echo IllaDateTime::getMonthName( $i ); ?></option>
  302. <?php endfor; ?>
  303. </select>
  304. </td>
  305. <td>
  306. <input style="width:100%" type="text" name="year" value="<?php echo $illa_time['year']; ?>" />
  307. </td>
  308. <td />
  309. <td>
  310. <input style="width:100%" type="text" name="hour" value="<?php echo $illa_time['hour']; ?>" />
  311. </td>
  312. <td>
  313. <input style="width:100%" type="text" name="minute" value="<?php echo $illa_time['min']; ?>" />
  314. </td>
  315. <td>
  316. <input style="width:100%" type="text" name="second" value="<?php echo $illa_time['sec']; ?>" />
  317. </td>
  318. </tr>
  319. <tr>
  320. <td colspan="7" style="height:10px" />
  321. </tr>
  322. </tbody>
  323. </table>
  324. </form>
  325. <?php Page::insert_go_to_top_link(); ?>
  326. <?php endif; ?>