/gui/tools/filemanager/includes/html.inc.php

https://github.com/BenBE/ispCP · PHP · 201 lines · 78 code · 53 blank · 70 comment · 27 complexity · 8002085a1802526b2dfc3cf1129197b7 MD5 · raw file

  1. <?php
  2. // -------------------------------------------------------------------------------
  3. // | net2ftp: a web based FTP client |
  4. // | Copyright (c) 2003-2009 by David Gartner |
  5. // | |
  6. // | This program is free software; you can redistribute it and/or |
  7. // | modify it under the terms of the GNU General Public License |
  8. // | as published by the Free Software Foundation; either version 2 |
  9. // | of the License, or (at your option) any later version. |
  10. // | |
  11. // -------------------------------------------------------------------------------
  12. // **************************************************************************************
  13. // **************************************************************************************
  14. // ** **
  15. // ** **
  16. function timer() {
  17. // --------------
  18. // This function calculates the time between starttime and endtime in milliseconds
  19. // --------------
  20. global $net2ftp_globals;
  21. list($start_usec, $start_sec) = explode(' ', $net2ftp_globals["starttime"]);
  22. $starttime = ((float)$start_usec + (float)$start_sec);
  23. list($end_usec, $end_sec) = explode(' ', $net2ftp_globals["endtime"]);
  24. $endtime = ((float)$end_usec + (float)$end_sec);
  25. $time_taken = ($endtime - $starttime); // to convert from microsec to sec
  26. $time_taken = number_format($time_taken, 2); // optional
  27. return $time_taken;
  28. } // End function timer
  29. // ** **
  30. // ** **
  31. // **************************************************************************************
  32. // **************************************************************************************
  33. // **************************************************************************************
  34. // **************************************************************************************
  35. // ** **
  36. // ** **
  37. function mytime() {
  38. $datetime = date("Y-m-d H:i:s");
  39. return $datetime;
  40. }
  41. // ** **
  42. // ** **
  43. // **************************************************************************************
  44. // **************************************************************************************
  45. // **************************************************************************************
  46. // **************************************************************************************
  47. // ** **
  48. // ** **
  49. function mytime_short() {
  50. $datetime = date("H:i");
  51. return $datetime;
  52. }
  53. // ** **
  54. // ** **
  55. // **************************************************************************************
  56. // **************************************************************************************
  57. // **************************************************************************************
  58. // **************************************************************************************
  59. // ** **
  60. // ** **
  61. function getBrowser($what) {
  62. // --------------
  63. // This function returns the browser name, version and platform using the http_user_agent string
  64. // --------------
  65. // Original code comes from http://www.phpbuilder.com/columns/tim20000821.php3?print_mode=1
  66. // Written by Tim Perdue, and released under the GPL license
  67. //
  68. // SourceForge: Breaking Down the Barriers to Open Source Development
  69. // Copyright 1999-2000 (c) The SourceForge Crew
  70. // http://sourceforge.net
  71. //
  72. // $Id: tim20000821.php3,v 1.2 2001/05/22 19:22:47 tim Exp $
  73. // -------------------------------------------------------------------------
  74. // If no information is available, return ""
  75. // -------------------------------------------------------------------------
  76. if (isset($_SERVER["HTTP_USER_AGENT"]) == false) { return ""; }
  77. // -------------------------------------------------------------------------
  78. // Remove XSS code
  79. // -------------------------------------------------------------------------
  80. $http_user_agent = validateGenericInput($_SERVER["HTTP_USER_AGENT"]);
  81. // -------------------------------------------------------------------------
  82. // Determine browser and version
  83. // -------------------------------------------------------------------------
  84. if ($what == "version" || $what == "agent") {
  85. // !!! If a new browser is added, add is also in the plugin properties
  86. // Else, functionality will be broken when loading the plugin in printTextareaSelect().
  87. if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $http_user_agent, $regs)) {
  88. $BROWSER_VERSION = $regs[1];
  89. $BROWSER_AGENT = 'IE';
  90. }
  91. elseif (preg_match('/Safari\/([0-9].[0-9]{1,2})/', $http_user_agent, $regs)) {
  92. $BROWSER_VERSION = $regs[1];
  93. $BROWSER_AGENT = 'Safari';
  94. }
  95. elseif (preg_match('/Opera ([0-9].[0-9]{1,2})/', $http_user_agent, $regs)) {
  96. $BROWSER_VERSION = $regs[1];
  97. $BROWSER_AGENT = 'Opera';
  98. }
  99. elseif (preg_match('/Mozilla\/([0-9].[0-9]{1,2})/', $http_user_agent, $regs)) {
  100. $BROWSER_VERSION = $regs[1];
  101. $BROWSER_AGENT = 'Mozilla';
  102. }
  103. else {
  104. $BROWSER_VERSION = 0;
  105. $BROWSER_AGENT = 'Other';
  106. }
  107. if ($what == "version") { return $BROWSER_VERSION; }
  108. elseif ($what == "agent") { return $BROWSER_AGENT; }
  109. } // end if
  110. // -------------------------------------------------------------------------
  111. // Determine platform
  112. // -------------------------------------------------------------------------
  113. elseif ($what == "platform") {
  114. if ( strstr($http_user_agent, 'BlackBerry') ||
  115. strstr($http_user_agent, 'DoCoMo') ||
  116. strstr($http_user_agent, 'Nokia') ||
  117. strstr($http_user_agent, 'Palm') ||
  118. strstr($http_user_agent, 'SonyEricsson') ||
  119. strstr($http_user_agent, 'SymbianOS') ||
  120. strstr($http_user_agent, 'Windows CE')) {
  121. $BROWSER_PLATFORM = 'Mobile';
  122. }
  123. elseif (strstr($http_user_agent, 'iPhone') || strstr($http_user_agent, 'iPod')) {
  124. $BROWSER_PLATFORM = 'iPhone';
  125. }
  126. elseif (strstr($http_user_agent, 'Win')) {
  127. $BROWSER_PLATFORM = 'Win';
  128. }
  129. else if (strstr($http_user_agent, 'Mac')) {
  130. $BROWSER_PLATFORM = 'Mac';
  131. }
  132. else if (strstr($http_user_agent, 'Linux')) {
  133. $BROWSER_PLATFORM = 'Linux';
  134. }
  135. else if (strstr($http_user_agent, 'Unix')) {
  136. $BROWSER_PLATFORM = 'Unix';
  137. }
  138. else {
  139. $BROWSER_PLATFORM = 'Other';
  140. }
  141. return $BROWSER_PLATFORM;
  142. } // end if elseif
  143. } // End function getBrowser
  144. // ** **
  145. // ** **
  146. // **************************************************************************************
  147. // **************************************************************************************
  148. ?>