27 list($usec, $sec) = explode(
' ', microtime());
28 mt_srand((
float) $sec + ((
float) $usec * 100000));
31 function fl($str) {
return str_replace(
"<",
"<",str_replace(
"\"",
""",$str)); }
33 function variable_get($name, $default = null, $createit_comment = null, $type=null) {
35 return $variables->variable_get($name, $default, $createit_comment, $type);
47 $db->query(
"SELECT tld,mode FROM tld;");
48 while ($db->next_record()) {
51 if ($sizefound<strlen(
$key)) {
52 $sizefound=strlen(
$key);
58 if ( $dom->tld_no_check_at_all )
63 if (($fmode!=4) && (!is_array($dns)))
68 for (
$i=0;
$i<count($dns);
$i++) {
69 if (strtolower($dns[
$i])==strtolower($L_NS1)) $n1=
true;
70 if (strtolower($dns[$i])==strtolower($L_NS2)) $n2=
true;
74 if ($fmode==2 && $n1 && $n2)
86 $db->query(
"SELECT tld,mode FROM tld;");
87 while ($db->next_record()) {
90 if ($sizefound<strlen(
$key)) {
91 $sizefound=strlen(
$key);
100 if (count(explode(
".",substr(
$domain,0,-$sizefound)))>2) {
109 return getenv(
'REMOTE_ADDR');
115 if (substr($url,0,7)!=
"http://" && substr($url,0,8)!=
"https://" && substr($url,0,6)!=
"ftp://")
return false;
116 if (substr($url,0,7)==
"http://" ) $fq=substr($url,7);
117 if (substr($url,0,8)==
"https://") $fq=substr($url,8);
118 if (substr($url,0,6)==
"ftp://" ) $fq=substr($url,6);
120 if (!is_array($f)) $f=array($f);
122 if (
$t)
return false;
138 return filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
144 return filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
156 if (filter_var($mail,FILTER_VALIDATE_EMAIL)) {
171 if (strlen($fqdn)>255)
174 if (count(
$members)>1) $ret=0;
else $ret=4;
182 if (!preg_match(
"#^[a-z0-9_]([a-z0-9-_]*[a-z0-9_])?$#i",
$val)) {
196 $user=$mem->user[
"login"];
197 $usar=substr(
$user,0,1);
198 if (substr($path,0,1)!=
"/")
206 if(strpos($rpath,$userpath) === 0){
225 if (is_null(
$user)) {
227 $user = $mem->user[
'login'];
236 if ($test) echo (
" checked=\"checked\"");
245 echo
" selected=\"selected\"";
249 function ecif($test,$tr,$fa=
"",$affiche=1) {
265 function ife($test,$tr,$fa=
"") {
288 $r=round($size,2).
" "._(
"Kb");
292 $r=round($size,2).
" "._(
"Mb");
296 $r=round($size,2).
" "._(
"Gb");
298 $r=round($size/1024,2).
" "._(
"Tb");
304 return str_replace(
" ",
" ",
$r);
311 return "(<a href=\"javascript:help($hid);\">?</a>)";
318 $d=substr($date,8,2);
319 $m=substr($date,5,2);
320 $y=substr($date,0,4);
321 $h=substr($date,11,2);
322 $i=substr($date,14,2);
330 return sprintf($format,
$d,$m,$y,$h,
$i,$hh,$am);
335 if (get_magic_quotes_gpc()) {
336 return stripslashes($str);
350 $chars=
"./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
352 $salt.=substr($chars,(mt_rand(0,strlen($chars))),1);
356 return crypt($pass,$salt);
364 $db_exploded_name = explode(
"_",$dbname);
365 return array($db_exploded_name[0],
366 implode(
"_", array_slice($db_exploded_name, 1)));
377 return str_replace(
"<",
"<",str_replace(
">",
">",str_replace(
"&",
"&",$string)));
387 if( $months % 12 == 0 && $months > 11) {
388 $years = $months / 12;
389 return "$years " . ($years > 1 ? _(
"years") : _(
"year"));
391 return "$months " . ($months > 1 ? _(
"months") : _(
"month"));
403 $res =
"<select name=\"$name\" id=\"$name\" class=\"inl\">";
405 foreach(array(0, 1, 2, 3, 4, 6, 12, 24) as $dur) {
406 $res .=
"<option value=\"$dur\"";
407 if($selected == $dur) {
408 $res .=
' selected="selected" ';
414 $res .= _(
'Not managed');
429 function eoption($values,$cur,$onedim=
false) {
430 if (is_array($values)) {
431 foreach ($values as $k=>$v) {
432 if ( $onedim ) $k=$v;
433 echo
"<option value=\"$k\"";
434 if ($k==$cur) echo
" selected=\"selected\"";
435 echo
">".$v.
"</option>";
446 function ehe($str,$affiche=1) {
448 $retour = htmlspecialchars($str,ENT_QUOTES,$charset);
461 $methodType = array (
"get",
"post",
"request",
"files",
"server");
464 if (in_array(strtolower(
$options[0]), $methodType) ===
false)
465 die (
"Unrecognized method type used for field " . $name .
" : " .
$options[0]);
467 if ($requestOnly ===
true)
468 $method =
"_REQUEST";
470 $method =
"_" . strtoupper($options[0]);
472 switch ($options[1]) {
474 $vars[$name] = (
isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? intval($GLOBALS[$method][$name]) : $options[2]);
477 $vars[$name] = (
isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? floatval($GLOBALS[$method][$name]) : $options[2]);
480 $vars[$name] = (
isset($GLOBALS[$method][$name]) ? trim($GLOBALS[$method][$name]) : $options[2]);
483 $vars[$name] = (
isset($GLOBALS[$method][$name]) && is_array($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
486 $vars[$name] = (
isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
489 $vars[$name] = (
isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
492 die (
"Illegal method type used for field " . $name .
" : " . $options[1]);
497 foreach ($vars AS $var =>
$value)
504 echo
"<pre style=\"border: 1px solid black; text-align: left; font-size: 9px\">\n";
509 if ( $a[
'label'] == $b[
'label']) {
512 return ($a[
'label']<$b[
'label'])?-1:1;
526 $offset=intval($offset);
527 $count=intval($count);
529 if ($offset<=0) $offset=
"0";
530 if ($count<=1) $count=
"1";
540 $o=max($offset-$count,0);
541 echo
"<a href=\"".str_replace(
"%%offset%%",$o,$url).
"\" alt=\"(Ctl/Alt-p)\" title=\"(Alt-p)\" accesskey=\"p\">"._(
"Previous Page").
"</a> ";
543 echo _(
"Previous Page").
" ";
554 echo
"<a href=\"".str_replace(
"%%offset%%",$o,$url).
"\">$i</a> ";
563 echo
"<a href=\"".str_replace(
"%%offset%%",$o,$url).
"\">$i</a> ";
566 if ($offset>=$count && $offset<(
$total-2*$count)) {
568 $start=max(3,intval($offset/$count)-2);
569 $end=min(intval($offset/$count)+3,intval(
$total/$count)-3);
570 if ($start!=3) echo
" ... ";
571 for(
$i=$start;
$i<$end;
$i++) {
576 echo
"<a href=\"".str_replace(
"%%offset%%",$o,$url).
"\">$i</a> ";
579 if ($end!=intval(
$total/$count)-3) echo
" ... ";
588 echo
"<a href=\"".str_replace(
"%%offset%%",$o,$url).
"\">$i</a> ";
595 if ($offset+$count<
$total) {
597 echo
"<a href=\"".str_replace(
"%%offset%%",$o,$url).
"\" alt=\"(Ctl/Alt-s)\" title=\"(Alt-s)\" accesskey=\"s\">"._(
"Next Page").
"</a> ";
599 echo _(
"Next Page").
" ";
605 $chars =
"1234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
608 while (
$i <= $length) {
609 $password .= @$chars{mt_rand(0,strlen($chars))};
615 define(
"DEFAULT_PASS_SIZE", 8);
620 echo
"<div id='z$id' style='display:none;'><a href=\"javascript:generate_password_html('$id',$pass_size,'$fields_to_fill1','$fields_to_fill2');\">";
621 __(
"Clic here to generate a password");
623 echo
"<script type='text/javascript'>$('#z$id').show();</script>";
630 $bid=
"b".rand(1,1000);
631 echo
"<script type=\"text/javascript\">
634 $( \"#".$bid.
"\" ).dialog({
641 $('.ui-widget-overlay').css('opacity', .70);
642 $('.ui-dialog-content').css('background-color', '#F0F0FA');
648 .attr(\"class\", \"ina\")
650 $( \"#".$bid.
"\" ).dialog( \"open\" );
656 document.write(' <input type=\"button\" id=\"bt".$bid.
"\" value=\""._(
"Choose a folder...").
"\" class=\"ina\">');
657 document.write('<div id=\"".$bid.
"\" title=\""._(
"Choose a folder...").
"\" style=\"display: none; bgcolor:red;\">');
658 document.write(' <iframe src=\"/browseforfolder2.php?caller=".$caller.
"&file=".
ehe($dir, 0).
"&bid=".$bid.
"\" width=\"".($width-40).
"\" height=\"".($height-64).
"\" frameborder=\"no\" id=\"browseiframe\"></iframe>');
659 document.write('</div>');
667 function auto_wrap($message=
"",$max=10,$wrap_string=
"<wbr/>") {
669 $mot = split(
" ",$message);
670 while (
isset($mot[$cpt]) && ($mot[$cpt] !=
"")){
671 if(@strlen($mot[$cpt]) > $max){
672 $nvmot = chunk_split ($mot[$cpt], $max, $wrap_string );
673 $message = str_replace($mot[$cpt], $nvmot, $message);
696 if($iH > 360) $iH = 360;
698 if($iS > 100) $iS = 100;
700 if($iV > 100) $iV = 100;
708 while($dT >= 2.0) $dT -= 2.0;
709 $dX = $dC*(1-abs($dT-1));
712 case($dH >= 0.0 && $dH < 1.0):
713 $dR = $dC; $dG = $dX; $dB = 0.0;
break;
714 case($dH >= 1.0 && $dH < 2.0):
715 $dR = $dX; $dG = $dC; $dB = 0.0;
break;
716 case($dH >= 2.0 && $dH < 3.0):
717 $dR = 0.0; $dG = $dC; $dB = $dX;
break;
718 case($dH >= 3.0 && $dH < 4.0):
719 $dR = 0.0; $dG = $dX; $dB = $dC;
break;
720 case($dH >= 4.0 && $dH < 5.0):
721 $dR = $dX; $dG = 0.0; $dB = $dC;
break;
722 case($dH >= 5.0 && $dH < 6.0):
723 $dR = $dC; $dG = 0.0; $dB = $dX;
break;
725 $dR = 0.0; $dG = 0.0; $dB = 0.0;
break;
729 $dR += $dM; $dG += $dM; $dB += $dM;
730 $dR *= 255; $dG *= 255; $dB *= 255;
732 return array(
'r'=>round($dR),
'g'=>round($dG),
'b'=>round($dB) );
738 return (strlen(
"$num") >= 2) ?
"$num" :
"0$num";
745 $h = 1+((100-
$p)*130/100);
748 $color =
"#".hexa($rvb[
'r']).hexa($rvb[
'g']).hexa($rvb[
'b']);
755 if ($cuid!=2000)
return false;
761 if ($cuid!=2000)
return false;