html.inc.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. // -------------------------------------------------------------------------------
  3. // | net2ftp: a web based FTP client |
  4. // | Copyright (c) 2003-2013 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('#Chrome/([0-9]{1,2}.[0-9]{1,4}.[0-9]{1,4}.[0-9]{1,4})#', $http_user_agent, $regs)) {
  92. $BROWSER_VERSION = $regs[1];
  93. $BROWSER_AGENT = 'Chrome';
  94. }
  95. elseif (preg_match('#Safari/([0-9].[0-9]{1,2})#', $http_user_agent, $regs)) {
  96. $BROWSER_VERSION = $regs[1];
  97. $BROWSER_AGENT = 'Safari';
  98. }
  99. elseif (preg_match('#Opera ([0-9].[0-9]{1,2})#', $http_user_agent, $regs)) {
  100. $BROWSER_VERSION = $regs[1];
  101. $BROWSER_AGENT = 'Opera';
  102. }
  103. elseif (preg_match('#Mozilla/([0-9].[0-9]{1,2})#', $http_user_agent, $regs)) {
  104. $BROWSER_VERSION = $regs[1];
  105. $BROWSER_AGENT = 'Mozilla';
  106. }
  107. else {
  108. $BROWSER_VERSION = 0;
  109. $BROWSER_AGENT = 'Other';
  110. }
  111. if ($what == "version") { return $BROWSER_VERSION; }
  112. elseif ($what == "agent") { return $BROWSER_AGENT; }
  113. } // end if
  114. // -------------------------------------------------------------------------
  115. // Determine platform
  116. // -------------------------------------------------------------------------
  117. elseif ($what == "platform") {
  118. if ( strstr($http_user_agent, 'BlackBerry') ||
  119. strstr($http_user_agent, 'DoCoMo') ||
  120. strstr($http_user_agent, 'Nokia') ||
  121. strstr($http_user_agent, 'Palm') ||
  122. strstr($http_user_agent, 'SonyEricsson') ||
  123. strstr($http_user_agent, 'SymbianOS') ||
  124. strstr($http_user_agent, 'Windows CE')) {
  125. $BROWSER_PLATFORM = 'Mobile';
  126. }
  127. /*elseif (strstr($http_user_agent, 'iPhone') || strstr($http_user_agent, 'iPod')) {
  128. $BROWSER_PLATFORM = 'iPhone';
  129. }*/
  130. elseif (strstr($http_user_agent, 'Win')) {
  131. $BROWSER_PLATFORM = 'Win';
  132. }
  133. else if (strstr($http_user_agent, 'Mac')) {
  134. $BROWSER_PLATFORM = 'Mac';
  135. }
  136. else if (strstr($http_user_agent, 'Linux')) {
  137. $BROWSER_PLATFORM = 'Linux';
  138. }
  139. else if (strstr($http_user_agent, 'Unix')) {
  140. $BROWSER_PLATFORM = 'Unix';
  141. }
  142. else {
  143. $BROWSER_PLATFORM = 'Other';
  144. }
  145. return $BROWSER_PLATFORM;
  146. } // end if elseif
  147. } // End function getBrowser
  148. // ** **
  149. // ** **
  150. // **************************************************************************************
  151. // **************************************************************************************
  152. ?>