Commit 9489d4f7 authored by Benjamin Sonntag's avatar Benjamin Sonntag
Browse files

Merge branch 'master' of alternc.org:alternc

parents 566980a5 b2f5a132
...@@ -605,6 +605,7 @@ nightlybuild/READMEFIRST -text ...@@ -605,6 +605,7 @@ nightlybuild/READMEFIRST -text
nightlybuild/build.sh -text nightlybuild/build.sh -text
nightlybuild/mchroot.sh -text nightlybuild/mchroot.sh -text
nightlybuild/nightly.key -text nightlybuild/nightly.key -text
phpunit/tests/_datasets/domaines.yml -text
po/alternc-admintools.pot -text po/alternc-admintools.pot -text
po/fr/LC_MESSAGES/.svnignore -text po/fr/LC_MESSAGES/.svnignore -text
po/fr/LC_MESSAGES/alternc-admintools.po -text po/fr/LC_MESSAGES/alternc-admintools.po -text
...@@ -614,7 +615,6 @@ roundcube/class/m_roundcube.php -text ...@@ -614,7 +615,6 @@ roundcube/class/m_roundcube.php -text
roundcube/roundcube-install -text roundcube/roundcube-install -text
roundcube/roundcube_alternc_logo.png -text roundcube/roundcube_alternc_logo.png -text
roundcube/templates/apache2/roundcube.conf -text roundcube/templates/apache2/roundcube.conf -text
roundcube/templates/logrotate.d/roundcube-core -text
roundcube/templates/roundcube/main.inc.php -text roundcube/templates/roundcube/main.inc.php -text
roundcube/templates/roundcube/plugins/managesieve/config.inc.php -text roundcube/templates/roundcube/plugins/managesieve/config.inc.php -text
roundcube/templates/roundcube/plugins/password/config.inc.php -text roundcube/templates/roundcube/plugins/password/config.inc.php -text
...@@ -663,6 +663,7 @@ src/quota-warning.sh -text ...@@ -663,6 +663,7 @@ src/quota-warning.sh -text
src/quota_delete -text src/quota_delete -text
src/quota_edit -text src/quota_edit -text
src/quota_get -text src/quota_get -text
src/quota_get_all -text
src/quota_init -text src/quota_init -text
src/rebuild_all_webconf.sh -text src/rebuild_all_webconf.sh -text
src/sendmail -text src/sendmail -text
......
...@@ -35,24 +35,18 @@ if (!$admin->enabled) { ...@@ -35,24 +35,18 @@ if (!$admin->enabled) {
} }
$fields = array ( $fields = array (
"d" => array ("request", "array", array()), "accountList" => array ("request", "array", array()),
"del_confirm" => array("request", "string", ""), "del_confirm" => array("request", "string", ""),
); );
getFields($fields); getFields($fields);
if($del_confirm == "y"){ if($del_confirm == "y"){
if (!is_array($accountList)) { $error = "";
$accountList[] = $accountList; foreach ($accountList as $key => $val) {
}
reset($accountList);
while (list($key,$val)=each($accountList)) {
if (!$admin->checkcreator($val)) { if (!$admin->checkcreator($val)) {
__("This page is restricted to authorized staff"); __("This page is restricted to authorized staff");
exit(); exit();
} }
$error = "";
if (!($u=$admin->get($val)) || !$admin->del_mem($val)) { if (!($u=$admin->get($val)) || !$admin->del_mem($val)) {
$error .= sprintf(_("Member '%s' does not exist"),$val)."<br />"; $error .= sprintf(_("Member '%s' does not exist"),$val)."<br />";
} else { } else {
...@@ -77,12 +71,14 @@ if($del_confirm == "y"){ ...@@ -77,12 +71,14 @@ if($del_confirm == "y"){
<input type="hidden" name="del_confirm" value="y" /> <input type="hidden" name="del_confirm" value="y" />
<p class="alert alert-warning"><?php __("WARNING : Confirm the deletion of the users"); ?></p> <p class="alert alert-warning"><?php __("WARNING : Confirm the deletion of the users"); ?></p>
<p> <p>
<?php <ul>
foreach($accountList as $userid){ <?php
$membre = $admin->get($userid); foreach($accountList as $userid){
echo "<input type=\"hidden\" name=\"d[]\" value=\"$userid\" />".$membre['login']."<br/>"; $membre = $admin->get($userid);
} echo "<li><input type=\"hidden\" name=\"accountList[]\" value=\"$userid\" />".$membre['login']."</li>";
?> }
?>
</ul>
</p> </p>
<blockquote> <blockquote>
<input type="submit" class="inb ok" name="confirm" value="<?php __("Yes, delete those accounts"); ?>" />&nbsp;&nbsp; <input type="submit" class="inb ok" name="confirm" value="<?php __("Yes, delete those accounts"); ?>" />&nbsp;&nbsp;
......
...@@ -174,7 +174,7 @@ if (!is_array($accountList) || empty($accountList)) { ...@@ -174,7 +174,7 @@ if (!is_array($accountList) || empty($accountList)) {
<?php if ($val["su"]) { ?> <?php if ($val["su"]) { ?>
<td id="user_<?php echo $val["uid"]; ?>">&nbsp;</td> <td id="user_<?php echo $val["uid"]; ?>">&nbsp;</td>
<?php } else { ?> <?php } else { ?>
<td><input type="checkbox" class="inc" name="d[]" id="user_<?php echo $val["uid"]; ?>" value="<?php echo $val["uid"]; ?>" /></td> <td><input type="checkbox" class="inc" name="accountList[]" id="user_<?php echo $val["uid"]; ?>" value="<?php echo $val["uid"]; ?>" /></td>
<?php } // val['su'] ?> <?php } // val['su'] ?>
<td <?php if ($val["su"]) echo 'style="color: red"'; ?>><label for="user_<?php echo $val["uid"]; ?>"><b><?php echo $val["login"] ?></b></label></td> <td <?php if ($val["su"]) echo 'style="color: red"'; ?>><label for="user_<?php echo $val["uid"]; ?>"><b><?php echo $val["login"] ?></b></label></td>
<td><a title="<?php __("Send an email"); ?>" href="mailto:<?php echo $val["mail"]; ?>"><?php echo $val["nom"] . " " . $val["prenom"] ?></a>&nbsp;</td> <td><a title="<?php __("Send an email"); ?>" href="mailto:<?php echo $val["mail"]; ?>"><?php echo $val["nom"] . " " . $val["prenom"] ?></a>&nbsp;</td>
...@@ -250,7 +250,7 @@ if ($mem->user["admlist"] == 1) { // SHORT MODE ...@@ -250,7 +250,7 @@ if ($mem->user["admlist"] == 1) { // SHORT MODE
if ($val["su"]) { if ($val["su"]) {
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
} else { } else {
echo '<td align="center"><input type="checkbox" class="inc" name="d[]" value="' . $val["uid"] . '" id="id_c_' . $val["uid"] . '" /></td>'; echo '<td align="center"><input type="checkbox" class="inc" name="accountList[]" value="' . $val["uid"] . '" id="id_c_' . $val["uid"] . '" /></td>';
} // if $val["su"] } // if $val["su"]
?> ?>
<td align="center"> <td align="center">
......
...@@ -51,7 +51,7 @@ if ($newlogin) { ...@@ -51,7 +51,7 @@ if ($newlogin) {
// Add an account // Add an account
if ($mail->add_slave_account($newlogin,$newpass)) { if ($mail->add_slave_account($newlogin,$newpass)) {
$error=_("The requested account address has been created. It is now allowed."); $error=_("The requested account address has been created. It is now allowed.");
$newlogin=false;$newpass=false; $newlogin='';$newpass='';
} }
} }
......
...@@ -138,7 +138,7 @@ function var_input($infotype, $name, $value='') { ...@@ -138,7 +138,7 @@ function var_input($infotype, $name, $value='') {
break; break;
case "boolean": case "boolean":
echo "<input type='hidden' name='$name' value='0' />"; // This way, there is allways something send, even if checkbox is unchecked echo "<input type='hidden' name='$name' value='0' />"; // This way, there is allways something send, even if checkbox is unchecked
echo "<input type='checkbox' id='add_$id' name='$name' value='1' ";cbox($value);echo " />"; echo "<input type='checkbox' id='add_$id' name='$name' value='1' ";cbox((bool)$value);echo " />";
break; break;
default: default:
echo "WTF ? Dunno what to do with a ".$infotype['type']; echo "WTF ? Dunno what to do with a ".$infotype['type'];
...@@ -251,7 +251,7 @@ foreach ( $variables->strata_order as $strata) { ...@@ -251,7 +251,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['FQDN_CREATOR'] as $ttk => $ttv ) { foreach ($allvars['FQDN_CREATOR'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) { if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; "; echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>"; echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]); edit_var($ttv[$var]);
} }
echo "<br/>"; echo "<br/>";
...@@ -267,7 +267,7 @@ foreach ( $variables->strata_order as $strata) { ...@@ -267,7 +267,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['FQDN'] as $ttk => $ttv ) { foreach ($allvars['FQDN'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) { if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $panel_url[$ttk])." &rarr; "; echo sprintf(_("Overwritted by %s"), $panel_url[$ttk])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>"; echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]); edit_var($ttv[$var]);
} }
echo "<br/>"; echo "<br/>";
...@@ -283,7 +283,7 @@ foreach ( $variables->strata_order as $strata) { ...@@ -283,7 +283,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['CREATOR'] as $ttk => $ttv ) { foreach ($allvars['CREATOR'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) { if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; "; echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>"; echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]); edit_var($ttv[$var]);
} }
echo "<br/>"; echo "<br/>";
...@@ -299,7 +299,7 @@ foreach ( $variables->strata_order as $strata) { ...@@ -299,7 +299,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['MEMBER'] as $ttk => $ttv ) { foreach ($allvars['MEMBER'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) { if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; "; echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." &rarr; ";
echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>"; echo "<a href='javascript:edit_var(".$ttv[$var]['id'].");'>"; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "</a>";
edit_var($ttv[$var]); edit_var($ttv[$var]);
} }
echo "<br/>"; echo "<br/>";
......
...@@ -92,7 +92,7 @@ echo _("See the vars for the account")." "; ...@@ -92,7 +92,7 @@ echo _("See the vars for the account")." ";
echo "<select name='member_id'>";eoption($ml, $member_id);echo "</select>"; echo "<select name='member_id'>";eoption($ml, $member_id);echo "</select>";
echo " "._("logged via")." "; echo " "._("logged via")." ";
echo "<select name='fqdn_id'>";eoption($dom->get_panel_url_list(), $fqdn_id );echo "</select> "; echo "<select name='fqdn_id'>";eoption($dom->get_panel_url_list(), $fqdn_id );echo "</select> ";
echo "<input type='submit' class='ina' value=\""; echo ehe(_("View")); echo "\" />"; echo "<input type='submit' class='ina' value=\""; ehe(_("View")); echo "\" />";
?> ?>
</form> </form>
......
...@@ -37,14 +37,17 @@ if (!isset($charset) || ! $charset) $charset="UTF-8"; ...@@ -37,14 +37,17 @@ if (!isset($charset) || ! $charset) $charset="UTF-8";
if (file_exists("styles/style-custom.css") ) { if (file_exists("styles/style-custom.css") ) {
echo '<link rel="stylesheet" href="styles/style-custom.css" type="text/css" />'; echo '<link rel="stylesheet" href="styles/style-custom.css" type="text/css" />';
} }
$favicon = variable_get('favicon', 'favicon.ico' ,'You can specify a favicon, for example /images/my_logo.ico', array(array('desc'=>'URL','type'=>'string')));
?> ?>
<link rel="stylesheet" href="styles/style-empty.css" type="text/css" title="Default - Desktop TNG"/> <link rel="stylesheet" href="styles/style-empty.css" type="text/css" title="Default - Desktop TNG"/>
<link rel="alternate stylesheet" href="styles/style-bluedesktop10.css" type="text/css" title="Blue Desktop 1.0" /> <link rel="alternate stylesheet" href="styles/style-bluedesktop10.css" type="text/css" title="Blue Desktop 1.0" />
<link rel="alternate stylesheet" href="styles/style-hw.css" type="text/css" title="Halloween" /> <link rel="alternate stylesheet" href="styles/style-hw.css" type="text/css" title="Halloween" />
<link rel="Shortcut Icon" href="favicon.ico" type="image/ico" /> <link rel="Shortcut Icon" href="<?php echo $favicon;?>" type="image/ico" />
<link rel="icon" href="favicon.ico" type="image/ico" /> <link rel="icon" href="<?php echo $favicon;?>" type="image/ico" />
<script src="js/alternc.js" type="text/javascript" ></script> <script src="js/alternc.js" type="text/javascript" ></script>
<script src="js/jquery.min_embedded.js" type="text/javascript"></script> <script src="js/jquery.min_embedded.js" type="text/javascript"></script>
......
...@@ -35,11 +35,12 @@ reset($_POST); ...@@ -35,11 +35,12 @@ reset($_POST);
while (list($key,$val)=each($_POST)) { while (list($key,$val)=each($_POST)) {
if (substr($key,0,4)=="del_") { if (substr($key,0,4)=="del_") {
// Effacement du dossier $val // Effacement du dossier $val
$r=$hta->DelDir($val); // $r=$hta->DelDir($val);
if (!$r) { $return = $hta->DelDir($val);
$error.=$err->errstr()."<br />"; if (!$return) {
$error.= $err->errstr()."<br />";
} else { } else {
$error.=sprintf(_("The protected folder %s has been successfully unprotected"),$val)."<br />"; $error.= sprintf(_("The protected folder %s has been successfully unprotected"),$val)."<br />";
} }
} }
} }
......
...@@ -143,7 +143,7 @@ class system_bind { ...@@ -143,7 +143,7 @@ class system_bind {
* *
* @global m_dom $dom * @global m_dom $dom
* @param string $domain * @param string $domain
* @return string * @return array
*/ */
function get_domain_summary($domain=false) { function get_domain_summary($domain=false) {
global $dom; global $dom;
......
...@@ -44,7 +44,7 @@ function fl($str) { return str_replace("<","&lt;",str_replace("\"","&quot;",$str ...@@ -44,7 +44,7 @@ function fl($str) { return str_replace("<","&lt;",str_replace("\"","&quot;",$str
* @param struing $type * @param struing $type
* @return mixed * @return mixed
*/ */
function variable_get($name, $default = null, $createit_comment = null, $type=null) { function variable_get($name, $default = null, $createit_comment = null, $type = null) {
global $variables; global $variables;
return $variables->variable_get($name, $default, $createit_comment, $type); return $variables->variable_get($name, $default, $createit_comment, $type);
} }
...@@ -66,16 +66,16 @@ function variable_get($name, $default = null, $createit_comment = null, $type=nu ...@@ -66,16 +66,16 @@ function variable_get($name, $default = null, $createit_comment = null, $type=nu
*/ */
function checkhostallow($domain,$dns) { function checkhostallow($domain,$dns) {
global $L_NS1,$L_NS2,$db,$dom; global $L_NS1,$L_NS2,$db,$dom;
$sizefound=0; $sizefound = 0;
$found=""; $found = "";
$db->query("SELECT tld,mode FROM tld;"); $db->query("SELECT tld,mode FROM tld;");
while ($db->next_record()) { while ($db->next_record()) {
list($key,$val)=$db->Record; list($key,$val) = $db->Record;
if (substr($domain,-1-strlen($key))==".".$key) { if (substr($domain,-1-strlen($key))==".".$key) {
if ($sizefound<strlen($key)) { if ($sizefound<strlen($key)) {
$sizefound=strlen($key); $sizefound = strlen($key);
$found=$key; $found = $key;
$fmode=$val; $fmode = $val;
} }
} }
} }
...@@ -88,10 +88,10 @@ function checkhostallow($domain,$dns) { ...@@ -88,10 +88,10 @@ function checkhostallow($domain,$dns) {
return -2; return -2;
if ($fmode>2) // OK, in the case 3 4 5 if ($fmode>2) // OK, in the case 3 4 5
return $found; return $found;
$n1=false; $n2=false; $n1 = false; $n2 = false;
for ($i=0;$i<count($dns);$i++) { for ($i = 0;$i<count($dns);$i++) {
if (strtolower($dns[$i])==strtolower($L_NS1)) $n1=true; if (strtolower($dns[$i])==strtolower($L_NS1)) $n1 = true;
if (strtolower($dns[$i])==strtolower($L_NS2)) $n2=true; if (strtolower($dns[$i])==strtolower($L_NS2)) $n2 = true;
} }
if ($fmode==1 && $n1) // OK if ($fmode==1 && $n1) // OK
return $found; return $found;
...@@ -109,16 +109,16 @@ function checkhostallow($domain,$dns) { ...@@ -109,16 +109,16 @@ function checkhostallow($domain,$dns) {
*/ */
function checkhostallow_nodns($domain) { function checkhostallow_nodns($domain) {
global $db; global $db;
$sizefound=0; $sizefound = 0;
$found=""; $found = "";
$db->query("SELECT tld,mode FROM tld;"); $db->query("SELECT tld,mode FROM tld;");
while ($db->next_record()) { while ($db->next_record()) {
list($key,$val)=$db->Record; list($key,$val) = $db->Record;
if (substr($domain,-1-strlen($key))==".".$key) { if (substr($domain,-1-strlen($key))==".".$key) {
if ($sizefound<strlen($key)) { if ($sizefound<strlen($key)) {
$sizefound=strlen($key); $sizefound = strlen($key);
$found=$key; $found = $key;
$fmode=$val; $fmode = $val;
} }
} }
} }
...@@ -149,12 +149,12 @@ function get_remote_ip() { ...@@ -149,12 +149,12 @@ function get_remote_ip() {
function checkurl($url) { function checkurl($url) {
// TODO : add a path/file check // TODO : add a path/file check
if (substr($url,0,7)!="http://" && substr($url,0,8)!="https://" && substr($url,0,6)!="ftp://") return false; if (substr($url,0,7)!="http://" && substr($url,0,8)!="https://" && substr($url,0,6)!="ftp://") return false;
if (substr($url,0,7)=="http://" ) $fq=substr($url,7); if (substr($url,0,7)=="http://" ) $fq = substr($url,7);
if (substr($url,0,8)=="https://") $fq=substr($url,8); if (substr($url,0,8)=="https://") $fq = substr($url,8);
if (substr($url,0,6)=="ftp://" ) $fq=substr($url,6); if (substr($url,0,6)=="ftp://" ) $fq = substr($url,6);
$f=explode("/",$fq); $f = explode("/",$fq);
if (!is_array($f)) $f=array($f); if (!is_array($f)) $f = array($f);
$t=checkfqdn($f[0]); $t = checkfqdn($f[0]);
if ($t) return false; if ($t) return false;
return true; return true;
} }
...@@ -235,8 +235,8 @@ function checkfqdn($fqdn) { ...@@ -235,8 +235,8 @@ function checkfqdn($fqdn) {
// 4. Le fqdn ne fait qu'un seul membre (il n'est donc pas fq...) // 4. Le fqdn ne fait qu'un seul membre (il n'est donc pas fq...)
if (strlen($fqdn)>255) if (strlen($fqdn)>255)
return 1; return 1;
$members=explode(".", $fqdn); $members = explode(".", $fqdn);
if (count($members)>1) $ret=0; else $ret=4; if (count($members)>1) $ret = 0; else $ret = 4;
reset($members); reset($members);
while (list ($key, $val) = each ($members)) { while (list ($key, $val) = each ($members)) {
if (strlen($val)>63) if (strlen($val)>63)
...@@ -262,10 +262,10 @@ function checkfqdn($fqdn) { ...@@ -262,10 +262,10 @@ function checkfqdn($fqdn) {
*/ */
function checkuserpath($path) { function checkuserpath($path) {
global $mem; global $mem;
$user=$mem->user["login"]; $user = $mem->user["login"];
$usar=substr($user,0,1); $usar = substr($user,0,1);
if (substr($path,0,1)!="/") if (substr($path,0,1)!="/")
$path="/".$path; $path = "/".$path;
$rpath = realpath(ALTERNC_HTML."/$usar/$user$path"); $rpath = realpath(ALTERNC_HTML."/$usar/$user$path");
if (!$rpath) { // if file or directory does not exist if (!$rpath) { // if file or directory does not exist
...@@ -310,7 +310,7 @@ function cbox($test, $echo = TRUE) { ...@@ -310,7 +310,7 @@ function cbox($test, $echo = TRUE) {
if ($test) { if ($test) {
$return = " checked=\"checked\""; $return = " checked=\"checked\"";
} else { } else {
$return=''; $return = '';
} }
if( $echo ){ if( $echo ){
echo $return; echo $return;
...@@ -331,7 +331,7 @@ function selected($bool, $echo = TRUE) { ...@@ -331,7 +331,7 @@ function selected($bool, $echo = TRUE) {
if ($bool) { if ($bool) {
$return = " selected=\"selected\""; $return = " selected=\"selected\"";
} else { } else {
$return=''; $return = '';
} }
if( $echo ){ if( $echo ){
echo $return; echo $return;
...@@ -347,7 +347,7 @@ function selected($bool, $echo = TRUE) { ...@@ -347,7 +347,7 @@ function selected($bool, $echo = TRUE) {
* @param integer $affiche * @param integer $affiche
* @return string * @return string
*/ */
function ecif($test,$tr,$fa="",$affiche=1) { function ecif($test,$tr,$fa = "",$affiche = 1) {
if ($test){ if ($test){
$retour = $tr; $retour = $tr;
} }
...@@ -375,7 +375,7 @@ function __($str) { ...@@ -375,7 +375,7 @@ function __($str) {
* @param string $fa * @param string $fa
* @return string * @return string
*/ */
function ife($test,$tr,$fa="") { function ife($test,$tr,$fa = "") {
if ($test){ if ($test){
return $tr; return $tr;
} }
...@@ -388,33 +388,33 @@ function ife($test,$tr,$fa="") { ...@@ -388,33 +388,33 @@ function ife($test,$tr,$fa="") {
* @param integer $html * @param integer $html
* @return string * @return string
*/ */
function format_size($size,$html=0) { function format_size($size,$html = 0) {
// Retourne une taille formatt�e en Octets, Kilo-octets, M�ga-octets ou Giga-Octets, avec 2 d�cimales. // Retourne une taille formatt�e en Octets, Kilo-octets, M�ga-octets ou Giga-Octets, avec 2 d�cimales.
if ("-" == $size) { if ("-" == $size) {
return $size; return $size;
} }
$size=(float)$size; $size = (float)$size;
if ($size<1024) { if ($size<1024) {
$r=$size; $r = $size;
if ($size!=1) { if ($size!=1) {
$r.=" "._("Bytes"); $r.=" "._("Bytes");
} else { } else {
$r.=" "._("Byte"); $r.=" "._("Byte");
} }
} else { } else {
$size=$size/1024; $size = $size/1024;
if ($size<1024) { if ($size<1024) {
$r=round($size,2)." "._("Kb"); $r = round($size,2)." "._("Kb");
} else { } else {
$size=$size/1024; $size = $size/1024;
if ($size<1024) { if ($size<1024) {
$r=round($size,2)." "._("Mb"); $r = round($size,2)." "._("Mb");
} else { } else {
$size=$size/1024; $size = $size/1024;
if ($size<1024) { if ($size<1024) {
$r=round($size,2)." "._("Gb"); $r = round($size,2)." "._("Gb");
} else { } else {
$r=round($size/1024,2)." "._("Tb"); $r = round($size/1024,2)." "._("Tb");
} }
} }
} }
...@@ -448,17 +448,17 @@ function linkhelp($hid) { ...@@ -448,17 +448,17 @@ function linkhelp($hid) {
* @return string * @return string
*/ */
function format_date($format,$date) { function format_date($format,$date) {
$d=substr($date,8,2); $d = substr($date,8,2);
$m=substr($date,5,2); $m = substr($date,5,2);
$y=substr($date,0,4); $y = substr($date,0,4);
$h=substr($date,11,2); $h = substr($date,11,2);
$i=substr($date,14,2); $i = substr($date,14,2);
if ($h>12) { if ($h>12) {
$hh=$h-12; $hh = $h-12;
$am="pm"; $am = "pm";
} else { } else {
$hh=$h; $hh = $h;
$am="am"; $am = "am";
} }
return sprintf($format,$d,$m,$y,$h,$i,$hh,$am); return sprintf($format,$d,$m,$y,$h,$i,$hh,$am);
}