| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-26 17:58:04 +01:00
										 |  |  | $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, "utf-8"); | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns TRUE if browser is Internet Explorer.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function isIE() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global $_SERVER; | 
					
						
							|  |  |  |     return strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'); | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function isKonq() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global $_SERVER; | 
					
						
							|  |  |  |     return strstr($_SERVER['HTTP_USER_AGENT'], 'Konqueror'); | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function isMoz() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global $_SERVER; | 
					
						
							|  |  |  |     return strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko'); | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Force upload of specified file to browser.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function upload($source, $destination, $content_type = "application/octet-stream") | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | 
					
						
							|  |  |  |     header("Expires: -1"); | 
					
						
							|  |  |  | #   header("Cache-Control: no-store, no-cache, must-revalidate");
 | 
					
						
							|  |  |  | #   header("Cache-Control: post-check=0, pre-check=0", false);
 | 
					
						
							|  |  |  | #   header("Pragma: no-cache");
 | 
					
						
							| 
									
										
										
										
											2020-02-27 18:01:17 +01:00
										 |  |  |     header("Content-Type: $content_type"); | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     if (is_array($source)) { | 
					
						
							|  |  |  |         $fsize = 0; | 
					
						
							|  |  |  |         foreach ($source as $f) { | 
					
						
							|  |  |  |             $fsize += filesize($f); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         $fsize = filesize($source); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     header("Content-length: " . $fsize); | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | #        header("Content-Disposition: attachment; filename=\"" . $destination ."\"");
 | 
					
						
							|  |  |  |         header("Content-Disposition: filename=\"" . $destination ."\""); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     if (is_array($source)) { | 
					
						
							|  |  |  |         foreach ($source as $f) { | 
					
						
							|  |  |  |             $ret = readfile($f); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         $ret=readfile($source); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #        $fd=fopen($source,'r');
 | 
					
						
							|  |  |  | #        fpassthru($fd);
 | 
					
						
							|  |  |  | #        fclose($fd);
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns a value from the GET/POST global array referenced
 | 
					
						
							|  |  |  | # by field name.  POST fields have precedence over GET fields.
 | 
					
						
							|  |  |  | # Quoting/Slashes are stripped if magic quotes gpc is on.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function gpvar($v) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global $_GET, $_POST; | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  |     $x = ""; | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     if (isset($_GET[$v])) { | 
					
						
							|  |  |  |         $x = $_GET[$v]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (isset($_POST[$v])) { | 
					
						
							|  |  |  |         $x = $_POST[$v]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (get_magic_quotes_gpc()) { | 
					
						
							|  |  |  |         $x = stripslashes($x); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return $x; | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Sort a two multidimensional array by one of it's columns
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function csort($array, $column, $ascdec = SORT_ASC) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     if (sizeof($array) == 0) { | 
					
						
							|  |  |  |         return $array; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-01 19:27:19 +02:00
										 |  |  |     // Sort by digital date rather than text date
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     if ($column == 'issued') { | 
					
						
							|  |  |  |         $column = "issuedSort"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ($column == 'expires') { | 
					
						
							|  |  |  |         $column = 'expiresSort'; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-01 19:27:19 +02:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2020-04-02 14:19:15 +02:00
										 |  |  |     if ($column == 'status') { | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |         foreach ($array as $x) { | 
					
						
							|  |  |  |             $sortarr[]=$x[$column]; | 
					
						
							|  |  |  |             $sortdate[] = $x['expiresSort']; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-04-02 14:19:15 +02:00
										 |  |  |         array_multisort($sortarr, $ascdec, $sortdate, SORT_ASC, $array); | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |         foreach ($array as $x) { | 
					
						
							|  |  |  |             $sortarr[]=$x[$column]; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-04-02 14:19:15 +02:00
										 |  |  |         array_multisort($sortarr, $ascdec, $array); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-01 19:27:19 +02:00
										 |  |  |     return $array; | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns a value suitable for display in the browser.
 | 
					
						
							|  |  |  | # Strips slashes if second argument is true.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function htvar($v, $strip = false) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ($strip) { | 
					
						
							|  |  |  |         return  htmlentities(stripslashes($v), 0, "UTF-8"); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return  htmlentities($v, 0, "UTF-8"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns a value suitable for use as a shell argument.
 | 
					
						
							|  |  |  | # Strips slashes if magic quotes is on, surrounds
 | 
					
						
							|  |  |  | # provided strings with single-quotes and quotes any
 | 
					
						
							|  |  |  | # other dangerous characters.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function escshellarg($v, $strip = false) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ($strip) { | 
					
						
							|  |  |  |         return escapeshellarg(stripslashes($v)); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return escapeshellarg($v); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Similar to escshellarg(), but doesn't surround provided
 | 
					
						
							|  |  |  | # string with single-quotes.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function escshellcmd($v, $strip = false) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ($strip) { | 
					
						
							|  |  |  |         return escapeshellcmd(stripslashes($v)); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return escapeshellarg($v); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | #
 | 
					
						
							|  |  |  | # Recursively strips slashes from a string or array.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function stripslashes_array(&$a) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (is_array($a)) { | 
					
						
							|  |  |  |         foreach ($a as $k => $v) { | 
					
						
							|  |  |  |             my_stripslashes($a[$k]); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         $a = stripslashes($a); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Don't use this.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function undo_magic_quotes(&$a) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (get_magic_quotes_gpc()) { | 
					
						
							|  |  |  |         global $HTTP_POST_VARS, $HTTP_GET_VARS; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         foreach ($HTTP_POST_VARS as $k => $v) { | 
					
						
							|  |  |  |             stripslashes_array($HTTP_POST_VARS[$k]); | 
					
						
							|  |  |  |             global $$k; | 
					
						
							|  |  |  |             stripslashes_array($$k); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         foreach ($HTTP_GET_VARS as $k => $v) { | 
					
						
							|  |  |  |             stripslashes_array($HTTP_GET_VARS[$k]); | 
					
						
							|  |  |  |             global $$k; | 
					
						
							|  |  |  |             stripslashes_array($$k); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns TRUE if argument contains only alphabetic characters.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function is_alpha($v) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     #return (eregi('[^A-Z]',$v) ? false : true) ;
 | 
					
						
							|  |  |  |     #return (preg_match('/[^A-Z]'.'/i',$v,PCRE_CASELESS) ? false : true) ; # Replaced eregi() with preg_match()
 | 
					
						
							|  |  |  |     return (preg_match('/[^A-Z]/i', $v) ? false : true) ; | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns TRUE if argument contains only numeric characters.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function is_num($v) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     #return (eregi('[^0-9]',$v) ? false : true) ;
 | 
					
						
							|  |  |  |     return (preg_match('/[^0-9]/', $v) ? false : true) ; # Replaced eregi() with preg_match()
 | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns TRUE if argument contains only alphanumeric characters.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function is_alnum($v) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     #return (eregi('[^A-Z0-9]',$v) ? false : true) ;
 | 
					
						
							|  |  |  |     return (preg_match('/[^A-Z0-9]/i', $v) ? false : true) ; # Replaced eregi() with preg_match()
 | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns TRUE if argument is in proper e-mail address format.
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function is_email($v) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     #return (eregi('^[^@ ]+\@[^@ ]+\.[A-Z]{2,4}$',$v) ? true : false);
 | 
					
						
							|  |  |  |     return (preg_match('/^[^@ ]+\@[^@ ]+\.[A-Z]{2,4}$'.'/i', $v) ? true : false); # Replaced eregi() with preg_match()
 | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-21 11:24:22 +02:00
										 |  |  | #
 | 
					
						
							|  |  |  | # Returns True if the given string is a IP address
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function is_ip($ip = null) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!$ip or strlen(trim($ip)) == 0) { | 
					
						
							| 
									
										
										
										
											2013-07-21 11:24:22 +02:00
										 |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     $ip=trim($ip); | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     if (preg_match("/^[0-9]{1,3}(.[0-9]{1,3}){3}$/", $ip)) { | 
					
						
							|  |  |  |         foreach (explode(".", $ip) as $block) { | 
					
						
							|  |  |  |             if ($block<0 || $block>255) { | 
					
						
							| 
									
										
										
										
											2013-07-21 11:24:22 +02:00
										 |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-21 11:24:22 +02:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Returns True if the given string is a valid FQDN
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function is_fqdn($FQDN) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-14 03:59:32 +06:00
										 |  |  |     // remove leading wildcard characters if exist
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     $FQDN = preg_replace('/^\*\./', '', $FQDN, 1); | 
					
						
							| 
									
										
										
										
											2015-03-01 20:29:47 +06:00
										 |  |  |     return (!empty($FQDN) && preg_match('/^(?=.{1,254}$)((?=[a-z0-9-]{1,63}\.)(xn--+)?[a-z0-9]+(-[a-z0-9]+)*\.)+(xn--+)?[a-z0-9]{2,63}$/i', $FQDN) > 0); | 
					
						
							| 
									
										
										
										
											2013-07-21 11:24:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | #
 | 
					
						
							|  |  |  | # Checks regexp in every element of an array, returns TRUE as soon
 | 
					
						
							|  |  |  | # as a match is found.
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 13:23:58 +01:00
										 |  |  | function preg_match_array($regexp, $arr) | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  |     foreach ($arr as $elem) { | 
					
						
							|  |  |  |         #if (eregi($regexp,$elem))
 | 
					
						
							|  |  |  |         if (! preg_match('/^\/.*\/$/', $regexp)) { # if it doesn't begin and end with '/'
 | 
					
						
							|  |  |  |             $regexp = '/'.$regexp.'/'; # pad the $regexp with '/' to prepare for preg_match()
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (preg_match($regexp.'i', $elem)) { # Replaced eregi() with preg_match()
 | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return false; | 
					
						
							| 
									
										
										
										
											2020-02-21 12:32:17 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | #
 | 
					
						
							|  |  |  | # Reads entire file into a string
 | 
					
						
							|  |  |  | # Same as file_get_contents in php >= 4.3.0
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function my_file_get_contents($f) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return implode('', file($f)); | 
					
						
							| 
									
										
										
										
											2012-02-28 08:23:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 17:15:01 +01:00
										 |  |  | function getOSInformation() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-02-27 16:18:12 +01:00
										 |  |  |     if (false == function_exists("shell_exec")) { | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     $os = shell_exec('cat /etc/redhat-release'); | 
					
						
							|  |  |  |     if (preg_match('/^SME Server/', $os)) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-03-18 12:55:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Used in setup
 | 
					
						
							|  |  |  | function flush_exec($command, $line_length = 200) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |         $handle = popen("$command 2>&1", 'r'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $line = ''; | 
					
						
							|  |  |  |     while (! feof($handle)) { | 
					
						
							|  |  |  |             $chr = fread($handle, 1); | 
					
						
							|  |  |  |             $line .= $chr; | 
					
						
							|  |  |  |         if ($chr == "\n") { | 
					
						
							|  |  |  |                 print str_replace("\n", "<br>\n", $line); | 
					
						
							|  |  |  |                 $line = ''; | 
					
						
							|  |  |  |                 flush(); | 
					
						
							|  |  |  |         } elseif (strlen($line) > $line_length) { | 
					
						
							|  |  |  |                 print $line."<br>\n"; | 
					
						
							|  |  |  |                 $line = ''; | 
					
						
							|  |  |  |                 flush(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |         print $line."<br>\n"; | 
					
						
							|  |  |  |     flush(); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | } |