--- FreeBSD/tinderbox/webui/core/functions.php 2007/11/02 20:56:34 1.1.1.1 +++ FreeBSD/tinderbox/webui/core/functions.php 2007/11/12 22:45:14 1.1.1.1.2.1 @@ -24,28 +24,27 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # +# $Paefchen$ # $MCom: portstools/tinderbox/webui/core/functions.php,v 1.5 2007/06/09 22:09:12 marcus Exp $ # function prettyEmail($input) { - return eregi_replace("@FreeBSD.org", "", $input); + return preg_replace('/@FreeBSD.org$/i', '', $input); } function prettyDatetime($input) { - if (ereg("[0-9]{14}", $input)) { + if (preg_match('/^[0-9]{14}$/', $input)) /* timstamp */ return substr($input,0,4)."-".substr($input,4,2)."-".substr($input,6,2)." ".substr($input,8,2).":".substr($input,10,2).":".substr($input,12,2); - } elseif (ereg("[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}", $input)) { + + elseif (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}', $input)) /* datetime */ - if ($input == "0000-00-00 00:00:00" || - $input == "0000-00-00 00:00:00.000000") { - return ""; - } else { - return substr($input,0,19); - } - } else { + return $input == '0000-00-00 00:00:00' + || $input == '0000-00-00 00:00:00.000000' + ? '' + : substr($input, 0, 19); + else return $input; - } } function cryptPassword($password) { @@ -55,9 +54,9 @@ function cryptPassword($password) { function build_query_string($url, $qs, $key, $value) { $qs[$key] = $value; $tmp = array(); - foreach ($qs as $k => $v) { + foreach ($qs as $k => $v) array_push($tmp, $k . '=' . $v); - } + return $url . '?' . implode('&', $tmp); } @@ -68,13 +67,15 @@ function time_difference_from_now($then) { } function time_elapsed($c) { - if ($c===0 || $c < 0 || $c=="") - return "-"; - if ($c>=3600) + if ($c === 0 || $c < 0 || $c == '') + return '-'; + + if ($c >= 3600) return sprintf("%0d:%02d:%02d", - floor($c/3600),floor(($c%3600)/60),floor($c%60)); - return sprintf("%02d:%02d", - floor(($c%3600)/60),floor($c%60)); + floor($c / 3600), floor(($c % 3600) / 60), floor($c % 60)); + + return sprintf('%02d:%02d', + floor(($c % 3600) / 60), floor($c % 60)); } ?>