2013-10-09 13:40:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function mdp($username, $mdp)
|
|
|
|
{
|
2013-10-09 21:46:19 +00:00
|
|
|
return hash('whirlpool', strtoupper($username).'#'.$mdp);
|
2013-10-09 13:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ip()
|
|
|
|
{
|
|
|
|
return $_SERVER["REMOTE_ADDR"];
|
|
|
|
}
|
|
|
|
|
|
|
|
function send_mail($to, $subject, $body)
|
|
|
|
{
|
|
|
|
$mail = new Mailer();
|
|
|
|
$mail->AddAddress($to);
|
|
|
|
$mail->Subject = $subject;
|
|
|
|
$mail->Body = $body;
|
|
|
|
|
|
|
|
return $mail->Send();
|
|
|
|
}
|
|
|
|
|
2013-10-10 03:13:45 +00:00
|
|
|
function erreur($message, $color="danger")
|
2013-10-09 13:40:23 +00:00
|
|
|
{
|
|
|
|
global $template;
|
|
|
|
|
|
|
|
$template->assign('ERRmessage', $message);
|
|
|
|
$template->assign('ERRcolor', $color);
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_url($string)
|
|
|
|
{
|
|
|
|
$string = trim($string);
|
|
|
|
|
|
|
|
if ( ctype_digit($string) )
|
|
|
|
{
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// replace accented chars
|
|
|
|
$accents = '/&([A-Za-z]{1,2})(grave|acute|circ|cedil|uml|lig);/';
|
|
|
|
$string_encoded = htmlentities($string,ENT_NOQUOTES,'UTF-8');
|
|
|
|
|
|
|
|
$string = preg_replace($accents,'$1',$string_encoded);
|
|
|
|
|
|
|
|
// clean out the rest
|
|
|
|
$replace = array('([\40\'/])','([^a-zA-Z0-9-])','(-{2,})');
|
|
|
|
$with = array('-','','-');
|
|
|
|
$string = preg_replace($replace,$with,$string);
|
|
|
|
}
|
|
|
|
|
|
|
|
return strtolower($string);
|
|
|
|
}
|
|
|
|
|
|
|
|
function pagination($nbPages, $page, $link = "documents-recents-")
|
|
|
|
{
|
|
|
|
$nbPages++;
|
|
|
|
$cntPages = array();
|
|
|
|
if ($nbPages < 10)
|
|
|
|
{
|
|
|
|
for ($i = 1 ; $i <= $nbPages ; $i++)
|
|
|
|
$cntPages[] = $i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ($i = 1 ; $i <= 4 ; $i++)
|
|
|
|
$cntPages[] = $i;
|
|
|
|
if (6 != max(6, $page))
|
|
|
|
$cntPages[] = "...";
|
|
|
|
for ($i = max(6, $page) - 1 ; $i < min(max(6, $page) + 3, $nbPages - 2) ; $i++)
|
|
|
|
$cntPages[] = $i;
|
|
|
|
if ($nbPages - 2 != max(6, $page) + 3 && $nbPages - 2 != $i)
|
|
|
|
$cntPages[] = "...";
|
|
|
|
for ($i = $nbPages - 2 ; $i <= $nbPages ; $i++)
|
|
|
|
$cntPages[] = $i;
|
|
|
|
}
|
|
|
|
|
|
|
|
$out = "";
|
|
|
|
foreach($cntPages as $p)
|
|
|
|
{
|
|
|
|
if ($p == "...")
|
|
|
|
$out .= "<span class=\"etc\"><span> ... </span></span>";
|
|
|
|
else
|
|
|
|
$out .= ' <a href="'.$link.$p.'" class="page'.($p==$page+1?" hilight":"").'">'.$p.'</a> ';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<a href="'.$link.($page>1?$page:1).'" class="moins"><span><<</span></a>'.$out.'<a href="'.$link.($page+1<$nbPages?$page+2:$nbPages).'" class="plus"><span>>></span></a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
function eregmenu($pattern, $string)
|
|
|
|
{
|
|
|
|
return preg_match("#".$pattern."#ui", $string);
|
|
|
|
}
|
|
|
|
|
2013-10-09 21:46:19 +00:00
|
|
|
?>
|