From 20705a550df5b13a544dc0865c6aef16e64c99d9 Mon Sep 17 00:00:00 2001 From: ShevAbam Date: Wed, 18 Jun 2014 10:11:11 +0200 Subject: + First commit (version 2.0) --- libs/Utils/Misc.class.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 libs/Utils/Misc.class.php (limited to 'libs/Utils/Misc.class.php') diff --git a/libs/Utils/Misc.class.php b/libs/Utils/Misc.class.php new file mode 100644 index 0000000..3fcfedb --- /dev/null +++ b/libs/Utils/Misc.class.php @@ -0,0 +1,57 @@ + $unit) + { + if ($filesize > 1024) + $filesize /= 1024; + else + break; + } + + return round($filesize, $precision).' '.$units[$idUnit].'o'; + } + + + /** + * Returns hostname + */ + public static function getHostname() + { + return php_uname('n'); + } + + + /** + * Returns server IP + */ + public static function getLanIp() + { + return $_SERVER['SERVER_ADDR']; + } + + /** + * Allows to pluralize a word based on a number + * Ex : echo 'mot'.Misc::pluralize(5); ==> prints mots + * Ex : echo 'cheva'.Misc::pluralize(5, 'ux', 'l'); ==> prints chevaux + * Ex : echo 'cheva'.Misc::pluralize(1, 'ux', 'l'); ==> prints cheval + * + * @param int $nb + * @param string $plural + * @param string $singular + * + * @return string + */ + public static function pluralize($nb, $plural = 's', $singular = '') + { + return $nb > 1 ? $plural : $singular; + } +} \ No newline at end of file -- cgit v1.3