BMLT Root Server
comdef_utilityclasses.inc.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************************/
3 /** \file comdef_utilityclasses.inc.php
4  \brief Some basic utility classes and functions to be used
5  throughout the CoMDEF system.
6 
7  These classes and functions describe some basic functionality that is
8  used throughout the system.
9 */
10 defined('BMLT_EXEC') or die('Cannot Execute Directly'); // Makes sure that this file is in the correct context.
11 
12 require_once(dirname(dirname(__FILE__))."/spanish_metaphone.php");
13 require_once(dirname(dirname(dirname(__FILE__)))."/c_comdef_server.class.php");
14 
15 /*******************************************************************/
16 /** \brief Returns a URL (HTTP) to the main_server directory (or renamed).
17 
18  \returns an HTTP URL, with the port (if necessary) and HTTPS (If necessary).
19 */
21  $inAllowHTTPS = true ///< If TRUE (default), then the URI will be allowed to use HTTPS. If FALSE, then we explicitly disallow HTTPS.
22 ) {
23  global $g_do_not_force_port;
24 
25  $from_proxy = array_key_exists("HTTP_X_FORWARDED_PROTO", $_SERVER);
26  if ($from_proxy) {
27  $https = $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
28  if (array_key_exists("HTTP_X_FORWARDED_PORT", $_SERVER)) {
29  $port = intval($_SERVER['HTTP_X_FORWARDED_PORT']);
30  } elseif ($https) {
31  $port = 443;
32  } else {
33  $port = 80;
34  }
35  } else {
36  $port = intval($_SERVER['SERVER_PORT']);
37  $https = $inAllowHTTPS && (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off' || $port == 443)) ? true : false;
38  }
39 
40  $url_path = $_SERVER['SERVER_NAME'];
41  $file_path = str_replace('\\', '/', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
42  $my_path = str_replace('\\', '/', dirname($_SERVER['PHP_SELF']));
43  $subsequent_path = str_replace($file_path, '', $my_path);
44 
45  // See if we need to add an explicit port to the URI.
46  if (!isset($g_do_not_force_port) || !$g_do_not_force_port) {
47  if (!$https && ($port != 80)) {
48  $url_path .= ":$port";
49  } elseif ($https && ($port != 443)) {
50  $url_path .= ":$port";
51  }
52  }
53 
54  $url_path .= '/'.trim($subsequent_path, '/').'/';
55  $url_path = 'http'.($https ? 's' : '').'://'.$url_path;
56  return $url_path;
57 }
58 
59 /*******************************************************************/
60 /** \brief Converts a string into an array of metaphone entities.
61 
62  This breaks up the given string into metaphone keys, and returns
63  them in an array, so they can be easily compared.
64 
65  http://us2.php.net/manual/en/function.metaphone.php
66 
67  \returns An associative array of metaphone keys. Null if none given.
68  The value will be the metaphone key, and the key will be the original
69  string, converted to lowercase.
70 */
72  $in_string, ///< The string to split up.
73  $in_lang_enum = null, ///< This is the code for the desired language. If not given, the server localization will be used.
74  $in_literal = false ///< If this is set to true (default is false), then metaphone will not be used.
75 ) {
76  $ret = null;
77 
78  $in_string = mb_strtolower(trim($in_string), 'UTF-8');
79 
80  /// If no language is given, we use the server's native language.
81  if (null == $in_lang_enum) {
82  $in_lang_enum = c_comdef_server::GetServer()->GetLocalLang();
83  }
84 
85  if (("en" == $in_lang_enum) || ("es" == $in_lang_enum)) {
86  $ar = explode(" ", $in_string);
87 
88  if (is_array($ar) && count($ar)) {
89  foreach ($ar as &$string) {
90  $string = mb_strtolower(trim($string), 'UTF-8');
91 
92  if ($string) {
93  $mp = $string;
94 
95  if (!$in_literal && ("en" == $in_lang_enum)) {
96  $mp = metaphone($mp);
97  } elseif (!$in_literal && ("es" == $in_lang_enum)) {
98  /// We also have a Spanish version of metaphone() available.
99  $mp = spanish_metaphone($mp);
100  }
101 
102  $ret[] = $mp;
103  }
104  }
105  }
106  } else {
107  $ret = array ( $in_string );
108  }
109 
110  return $ret;
111 }
112 
113 /*******************************************************************/
114 /** \brief Encrypts a string, using the most effective encryption.
115 
116  This function will encrypt a string, using the standard PHP
117  crypt() function, and, if asked, will use the most secure algorithm
118  available on the server. This is a one-way encryption.
119 
120  NOTE: If you use this in "secure" mode (other than CRYPT_DES), it may
121  deliver passwords in a format that cannot be ported to other servers.
122 
123  **UPDATE** This now uses the PHP password_hash() function. Much better. This also means that you need to check with hash_equals() and password_verify().
124 
125  \returns a string, which is the given string, encrypted. Use this to compare
126  with other strings, or as a salt for future encryptions.
127 */
128 function FullCrypt(
129  $in_string, ///< The string to be encrypted
130  $in_salt = null, ///< IGNORED
131  &$crypt_method = null ///< IGNORED
132 ) {
133  return password_hash($in_string, PASSWORD_DEFAULT);
134 }
135 
136 /*******************************************************************/
137 /** \brief This function accepts an array of data (or a single element),
138  and "cleans it up" in preparation for use as a JSON string.
139 
140  \returns a string, containing the "cleaned" array
141 */
142 function json_prepare($data, $escapeSpecialChars = false)
143 {
144  if (is_object($data)) {
145  throw new Exception(__FUNCTION__ . '() objects are not supported by this function');
146  }
147 
148  if (is_array($data)) {
149  $temp = array();
150 
151  reset($data);
152  foreach ($data as $key => $value) {
153  $temp[json_prepare($key, $escapeSpecialChars)] = json_prepare($value, $escapeSpecialChars);
154  }
155 
156  $data = $temp;
157  } else {
158  if (!is_null($data)) {
159  $data = preg_replace("|\"|", "\\\"", $data);
160  if ($escapeSpecialChars) {
161  $data = utf8_encode(c_comdef_htmlspecialchars($data, ENT_QUOTES));
162  } else {
163  $data = utf8_encode($data);
164  }
165  }
166  }
167 
168  return $data;
169 }
170 
171 /**
172  \brief This is a function that returns the results of an HTTP call to a URI.
173  It is a lot more secure than file_get_contents, but does the same thing.
174 
175  \returns a string, containing the response. Null if the call fails to get any data.
176 
177  \throws an exception if the call fails.
178 */
179 function call_curl(
180  $in_uri, ///< A string. The URI to call.
181  $in_post = true, ///< If false, the transaction is a GET, not a POST. Default is true.
182  &$http_status = null ///< Optional reference to a string. Returns the HTTP call status.
183 ) {
184  $ret = null;
185 
186  // If the curl extension isn't loaded, we try one backdoor thing. Maybe we can use file_get_contents.
187  if (!extension_loaded('curl')) {
188  if (ini_get('allow_url_fopen')) {
189  $ret = file_get_contents($in_uri);
190  }
191  } else {
192  // This gets the session as a cookie.
193  if (isset($_COOKIE['PHPSESSID']) && $_COOKIE['PHPSESSID']) {
194  $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
195 
196  session_write_close();
197  }
198 
199  // Create a new cURL resource.
200  $resource = curl_init();
201 
202  if (isset($strCookie)) {
203  curl_setopt($resource, CURLOPT_COOKIE, $strCookie);
204  }
205 
206  // If we will be POSTing this transaction, we split up the URI.
207  if ($in_post) {
208  $spli = explode("?", $in_uri, 2);
209 
210  if (is_array($spli) && count($spli)) {
211  $in_uri = $spli[0];
212  $in_params = $spli[1];
213  // Convert query string into an array using parse_str(). parse_str() will decode values along the way.
214  parse_str($in_params, $temp);
215 
216  // Now rebuild the query string using http_build_query(). It will re-encode values along the way.
217  // It will also take original query string params that have no value and appends a "=" to them
218  // thus giving them and empty value.
219  $in_params = http_build_query($temp);
220 
221  curl_setopt($resource, CURLOPT_POST, true);
222  curl_setopt($resource, CURLOPT_POSTFIELDS, $in_params);
223  }
224  }
225 
226  // Set url to call.
227  curl_setopt($resource, CURLOPT_URL, $in_uri);
228 
229  // Make curl_exec() function (see below) return requested content as a string (unless call fails).
230  curl_setopt($resource, CURLOPT_RETURNTRANSFER, true);
231 
232  // By default, cURL prepends response headers to string returned from call to curl_exec().
233  // You can control this with the below setting.
234  // Setting it to false will remove headers from beginning of string.
235  // If you WANT the headers, see the Yahoo documentation on how to parse with them from the string.
236  curl_setopt($resource, CURLOPT_HEADER, false);
237 
238  // Allow cURL to follow any 'location:' headers (redirection) sent by server (if needed set to true, else false- defaults to false anyway).
239  // Disabled, because some servers disable this for security reasons.
240 // curl_setopt ( $resource, CURLOPT_FOLLOWLOCATION, true );
241 
242  // Set maximum times to allow redirection (use only if needed as per above setting. 3 is sort of arbitrary here).
243  curl_setopt($resource, CURLOPT_MAXREDIRS, 3);
244 
245  // Set connection timeout in seconds (very good idea).
246  curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, 10);
247 
248  // Direct cURL to send request header to server allowing compressed content to be returned and decompressed automatically (use only if needed).
249  curl_setopt($resource, CURLOPT_ENCODING, 'gzip,deflate');
250 
251  // Pretend we're a browser, so that anti-cURL settings don't pooch us.
252  curl_setopt($resource, CURLOPT_USERAGENT, "cURL Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20130401 Firefox/21.0");
253 
254  // Trust meeeee...
255  curl_setopt($resource, CURLOPT_SSL_VERIFYPEER, false);
256 
257  // Execute cURL call and return results in $content variable.
258  $content = curl_exec($resource);
259 
260  // Check if curl_exec() call failed (returns false on failure) and handle failure.
261  if ($content === false) {
262  // Cram as much info into the exception as possible.
263  throw new Exception("curl failure calling $in_uri, ".curl_error($resource).", ".curl_errno($resource));
264  } else {
265  // Do what you want with returned content (e.g. HTML, XML, etc) here or AFTER curl_close() call below as it is stored in the $content variable.
266 
267  // You MIGHT want to get the HTTP status code returned by server (e.g. 200, 400, 500).
268  // If that is the case then this is how to do it.
269  $http_status = curl_getinfo($resource, CURLINFO_HTTP_CODE);
270  }
271 
272  // Close cURL and free resource.
273  curl_close($resource);
274 
275  // Maybe echo $contents of $content variable here.
276  if ($content !== false) {
277  $ret = $content;
278  }
279  }
280 
281  return $ret;
282 }
283 
284 /*******************************************************************/
285 /** \brief Returns the HTML for an "Admin Bar" along the top of the page.
286  \returns the HTML for the bar.
287 */
288 function c_comdef_admin_bar( $in_http_vars ///< The aggregation of the $_GET and $_POST superglobals, as an associative array.
289  )
290 {
291  $x_file = $_SERVER ['SCRIPT_NAME'];
292  require_once(dirname(__FILE__).'/../../../server/c_comdef_server.class.php');
293  $ret = '';
295  if ($server instanceof c_comdef_server) {
296  $localized_strings = c_comdef_server::GetLocalStrings();
297  include(dirname(__FILE__).'/../../../server/config/get-config.php');
298 
299  $user_obj = $server->GetCurrentUserObj();
300  if (($user_obj instanceof c_comdef_user) && ($user_obj->GetUserLevel() != _USER_LEVEL_DISABLED) && ($user_obj->GetUserLevel() != _USER_LEVEL_OBSERVER)) {
301  $left_link = '&nbsp;';
302  $middle_link = '&nbsp;';
303 
304  if (isset($in_http_vars['edit_cp'])
305  || (isset($in_http_vars['do_search']) && $in_http_vars['do_search'])
306  || (isset($in_http_vars['single_meeting_id']) && $in_http_vars['single_meeting_id']) ) {
307  $left_link = '<a href="'.$x_file.'?supports_ajax=yes&amp;lang_enum='.htmlspecialchars($lang_enum).'">';
308  $left_link .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['meeting_search']);
309  $left_link .= '</a>';
310  }
311 
312  if (!isset($in_http_vars['edit_cp'])) {
313  $link = '<a href="'.$x_file.'?edit_cp&amp;supports_ajax=yes&amp;lang_enum='.htmlspecialchars($lang_enum).'">';
314  $link .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['edit_link']);
315  $link .= '</a>';
316  if ($left_link == '&nbsp;') {
317  $left_link = $link;
318  } else {
319  $middle_link = $link;
320  }
321  }
322 
323  $right_link = '<a href="'.$x_file.'?logout&amp;supports_ajax=yes&amp;lang_enum='.htmlspecialchars($lang_enum).'">';
324  $right_link .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['logout']);
325  $right_link .= '</a>';
326 
327  $info_string = '<div class="bmlt_admin_info_div">';
328  $info_string .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['logged_in']);
329  $info_string .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Edit_Users'][$user_obj->GetUserLevel()]);
330  $info_string .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['login_name']);
331  $info_string .= c_comdef_htmlspecialchars($user_obj->GetLogin());
332  $info_string .= '</div>';
333 
334  $admin_links = '<div class="bmlt_admin_links_div">';
335  $admin_links .= '<div class="bmlt_admin_one_link_div">'.$left_link.'</div>';
336  $admin_links .= '<div class="bmlt_admin_one_link_div">'.$middle_link.'</div>';
337  $admin_links .= '<div class="bmlt_admin_one_link_div">'.$right_link.'</div>';
338  $admin_links .= '</div>';
339  } elseif (($user_obj instanceof c_comdef_user) && ($user_obj->GetUserLevel() == _USER_LEVEL_OBSERVER)) {
340  $info_string = '<div class="bmlt_admin_info_div">';
341  $info_string .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['logged_in']);
342  $info_string .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Edit_Users'][$user_obj->GetUserLevel()]);
343  $info_string .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['login_name']);
344  $info_string .= c_comdef_htmlspecialchars($user_obj->GetLogin());
345  $info_string .= '</div>';
346 
347  $admin_links = '<div class="bmlt_admin_links_div">';
348  if (isset($in_http_vars['edit_cp'])
349  || (isset($in_http_vars['do_search']) && $in_http_vars['do_search'])
350  || (isset($in_http_vars['single_meeting_id']) && $in_http_vars['single_meeting_id']) ) {
351  $admin_links .= '<div class="bmlt_admin_one_link_div">';
352  $admin_links .= '<a href="'.$x_file.'?supports_ajax=yes&amp;lang_enum='.htmlspecialchars($lang_enum).'">';
353  $admin_links .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['meeting_search']);
354  $admin_links .= '</a>';
355  $admin_links .= '</div>';
356  $admin_links .= '<div class="bmlt_admin_one_link_div">&nbsp;</div>';
357  $admin_links .= '<div class="bmlt_admin_one_link_div">';
358  $admin_links .= '<a href="'.$x_file.'?logout&amp;supports_ajax=yes&amp;lang_enum='.htmlspecialchars($lang_enum).'">';
359  $admin_links .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['logout']);
360  $admin_links .= '</a>';
361  $admin_links .= '</div>';
362  } else {
363  $admin_links .= '<div class="bmlt_admin_one_link_div">&nbsp;</div>';
364  $admin_links .= '<div class="bmlt_admin_one_link_div">';
365  $admin_links .= '<a href="'.$x_file.'?logout&amp;supports_ajax=yes&amp;lang_enum='.htmlspecialchars($lang_enum).'">';
366  $admin_links .= c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['logout']);
367  $admin_links .= '</a>';
368  $admin_links .= '</div>';
369  $admin_links .= '<div class="bmlt_admin_one_link_div">&nbsp;</div>';
370  }
371 
372  $admin_links .= '</div>';
373  } else {
374  $info_string = '<div class="bmlt_admin_info_div">&nbsp;</div>';
375  $admin_links = '<div class="bmlt_admin_links_div">';
376  $admin_links .= '<div class="bmlt_admin_one_link_div">&nbsp;</div>';
377  $admin_links .= '<div class="bmlt_admin_one_link_div"><a class="login_div" href="'.$_SERVER['SCRIPT_NAME'].'?login&amp;supports_ajax=yes&amp;lang_enum='.htmlspecialchars($lang_enum).'">'.c_comdef_htmlspecialchars($localized_strings['comdef_search_admin_strings']['Admin_Bar']['login']).'</a></div>';
378  $admin_links .= '<div class="bmlt_admin_one_link_div">&nbsp;</div>';
379  $admin_links .= '</div>';
380  }
381 
382  if (!isset($http_vars['login']) && !isset($_POST['login'])) {
383  $ret = '<div class="bmlt_admin_strip no_print" id ="bmlt_admin_strip">'.$info_string.$admin_links.'<div class="clear_both"></div></div>';
384  }
385  }
386 
387  return $ret;
388 }
389 
390 /*******************************************************************/
391 /** \brief This function creates a displayable string.
392 
393  \returns The "cleaned" string
394 */
395 function c_comdef_htmlspecialchars($in_string)
396 {
398  $ret = htmlspecialchars($in_string, null, $local_strings['charset']);
399 
400  return $ret;
401 }
402 
403 /*******************************************************************/
404 /** \brief This function vets the email address for proper form.
405 
406  \returns true if the email address has a valid format.
407 */
408 function c_comdef_vet_email_address($in_address)
409 {
410  $ret = false;
411  if (isset($in_address) && is_string($in_address) && trim($in_address) && preg_match('#^(?:[a-zA-Z0-9_\'^&amp;/+-])+(?:\.(?:[a-zA-Z0-9_\'^&amp;/+-])+)*@(?:(?:\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)|(?:[a-zA-Z0-9-]+\.)+(?:[a-zA-Z]){2,}\.?)$#', $in_address)) {
412  $ret = true;
413  }
414 
415  return $ret;
416 }
417 
418 /*******************************************************************/
419 /** \brief This function can be called to terminate the session.
420 */
422 {
423  if (!isset($_SESSION)) {
424  session_start();
425  }
426 
427  // Wipe out the session variables
428  $_SESSION = array();
429 
430  // Eat the session cookie.
431  if (isset($_COOKIE[session_name()])) {
432  setcookie(session_name(), '', time() - 42000, '/');
433  }
434 
435  // Bye, now...
436  session_write_close(); // Close the session.
437 }
438 
439 /*******************************************************************/
440 /**
441  * \class bdfProfiler
442  * \brief Execution time/memory profiling class
443  *
444  * This is a modification of <a href="http://solarphp.com">the Solar_Debug_Timer class</a>
445  * \author Paul M. Jones <pmjones@solarphp.com>
446  *
447  * Singleton class accessed via static methods
448  *
449  * Example:
450  * \code
451  * bdfProfiler::mark('Start');
452  * bdfProfiler::mark('End');
453  * echo bdfProfiler::html_output();
454  * \endcode
455  */
456 // phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
457 // phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
459 // phpcs:enable PSR1.Classes.ClassDeclaration.MissingNamespace
460 // phpcs:enable Squiz.Classes.ValidClassName.NotCamelCaps
461 {
462  private static $marks = array(); ///< This is an array that holds the markers.
463 
464  /**
465  * \brief Private constructor prevents direct creation of object
466  */
467  private function __construct()
468  {
469  }
470 
471  /**
472  * \brief Marks a time
473  */
474  public static function mark( $msg = null ///< Optional string. A message to be displayed for this marker.
475  )
476  {
477  // If possible, we see how the memory is being used.
478  if (function_exists('memory_get_usage')) {
479  $mem = memory_get_usage();
480  } else {
481  $mem = '-';
482  }
483  array_push(self::$marks, array('time' => microtime(true), 'memory' => $mem, 'msg' => $msg));
484  }
485 
486  /**
487  * \brief Returns profiling information as an array
488  *
489  * \returns an array of associative arrays that contain the profiling information. Each sub-array represents the information from one marker.
490  * - 'num' An integer. The marker ID number
491  * - 'diff' A floating-point number. The number of seconds (at a millisecond resolution) between the last marker and this one.
492  * - 'total' A floating-point number. The total number of seconds (at a millisecond resolution) since the start marker.
493  * - 'memory' If possible, the memory consumption at the marker's point in execution.
494  * - 'msg' Any text message that was associated with the marker.
495  */
496  public static function profile()
497  {
498  $diff = 0;
499  $prev = 0;
500  $total = 0;
501  $result = array();
502 
503  foreach (self::$marks as $k => $v) {
504  if ($prev > 0) {
505  $diff = $v['time'] - $prev;
506  }
507 
508  $total = $total + $diff;
509 
510  $result[] = array ( 'num' => $k, 'diff' => $diff, 'total' => $total, 'memory' => $v['memory'], 'msg' => $v['msg'] );
511 
512  $prev = $v['time'];
513  }
514 
515  return $result;
516  }
517 
518  /**
519  * \brief Return formatted profile information
520  *
521  * \returns a string, with a series of tab-delimited lines; each containing the profile information for a marker.
522  */
523  public static function output( $in_html = false ///< If true, the output is html. Default is false.
524  )
525  {
526  if ($in_html) {
527  $output = self::html_output();
528  } else {
529  $output = sprintf("%-3.3s\t%10.10s\t%10.10s\t%10.10s\t%-500.500s\n", 'Num', 'Diff/sec', 'Total/sec', 'Memory', 'Msg');
530  $output .= sprintf("%-'-3.3s\t%'-10.10s\t%'-10.10s\t%'-10.10s\t%-'-500.500s\n", '', '', '', '', '');
531 
532  $profile = self::profile();
533 
534  foreach ($profile as $value) {
535  $output .= sprintf("%3.3s\t%10F\t%10F\t%10d\t%-500.500s\n", $value['num'], $value['diff'], $value['total'], $value['memory'], $value['msg']);
536  }
537  }
538 
539  return $output;
540  }
541 
542  /**
543  * \brief Return formatted profile information in HTML form
544  *
545  * \returns a string, containing an HTML table element with a series of rows; each containing the profile information for a marker. The table's class is "bdfProfiler_table".
546  */
547  // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
548  public static function html_output()
549  {
550  //phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
551  $output = '<table class="bdfProfiler_table" cellpadding="0" cellspacing="0" summary="Profiling Information Report">';
552  $output .= '<thead><tr><td>Num</td><td>Diff/sec</td><td>Total/sec</td><td>Memory</td><td>Msg</td></tr></thead><tbody>';
553 
554  $profile = self::profile();
555 
556  foreach ($profile as $value) {
557  $output .= sprintf("<tr><td>%3.3s</td><td>%10F</td><td>%10F</td><td>%10d</td><td>%-500.500s</td></tr>", $value['num'], $value['diff'], $value['total'], $value['memory'], $value['msg']);
558  }
559 
560  $output .= '</tbody></table>';
561 
562  return $output;
563  }
564 }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
static output($in_html=false)
Return formatted profile information.
$local_strings
Definition: index.php:6
call_curl($in_uri, $in_post=true, &$http_status=null)
This is a function that returns the results of an HTTP call to a URI. It is a lot more secure than fi...
if(file_exists($config_file_path)) $url_path
Definition: index.php:64
spanish_metaphone($string)
This is a Spanish version of the standard double metaphone tokenizer.
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
function sprintf()
Definition: installer.js:873
static mark($msg=null)
Marks a time.
c_comdef_vet_email_address($in_address)
This function vets the email address for proper form.
const _USER_LEVEL_OBSERVER
__construct()
Private constructor prevents direct creation of object.
FullCrypt($in_string, $in_salt=null, &$crypt_method=null)
Encrypts a string, using the most effective encryption.
const _USER_LEVEL_DISABLED
c_comdef_LogoutUser()
This function can be called to terminate the session.
c_comdef_admin_bar($in_http_vars)
Returns the HTML for an "Admin Bar" along the top of the page.
$lang_enum
Definition: index.php:23
static profile()
Returns profiling information as an array.
global $http_vars
Definition: index.php:21
c_comdef_htmlspecialchars($in_string)
This function creates a displayable string.
SplitIntoMetaphone($in_string, $in_lang_enum=null, $in_literal=false)
Converts a string into an array of metaphone entities.
$server
Definition: GetLangs.php:25
GetURLToMainServerDirectory($inAllowHTTPS=true)
Returns a URL (HTTP) to the main_server directory (or renamed).
static MakeServer()
This is the factory for the server instantiation. It makes sure that only one instance exists...
Execution time/memory profiling class.
This class is the main server class. It instantiates a PDO database object, and is the starting point...
defined('BMLT_EXEC') or define('BMLT_EXEC'
Definition: index.php:3
static $marks
This is an array that holds the markers.
static html_output()
Return formatted profile information in HTML form.
$user_obj
Definition: index.php:7
$https
Definition: installer.php:72
defined('BMLT_EXEC') or define('BMLT_EXEC' true
Definition: index.php:29
json_prepare($data, $escapeSpecialChars=false)
This function accepts an array of data (or a single element), and "cleans it up" in preparation for u...