Source for file lib_common.php
Documentation is available at lib_common.php 
 * @author linea21 <info@linea21.com>  
 * @license http://opensource.org/licenses/gpl-3.0.html  
 * implode avec clefs associées renvoyées  
 * sous forme de chaîne de caractères  
  foreach( $array as $key =>  $item )  
  $output[] =  $key .  "=" .  $item;  
 * Renvoie les paramètres HTTP  
 * sous forme de chaîne de caractères  
 * Remove PHP and HTML code  
 * @param string $exceptions   
  if(defined('RICH_TEXT_EDITOR') &&  RICH_TEXT_EDITOR != (string)  0) {  
 * Include SIMILE Timeline JS code  
  if(defined('TIMELINE_DISPLAY') &&  TIMELINE_DISPLAY ==  1) {  
    if(isset ($_REQUEST['rub']) &&  $_REQUEST['rub']== "project" &&  (!isset ($_REQUEST['todo']) ||  $_REQUEST['todo'] ==  'list')) {  
      echo  '<script src="' . SITE_ROOT_URL.  'lib/js/timeline/timeline_ajax/simile-ajax-api.js" type="text/javascript"></script>'. END_LINE; 
      echo  '<script type="text/javascript"> 
             Timeline_urlPrefix=\'' . SITE_ROOT_URL.  'lib/js/timeline/timeline_js/\';  
             Timeline_parameters=\'bundle=true\';  
             $("#content").prepend(\'<div id="my-timeline" style="height: 250px; border-bottom: 1px solid #aaa"></div>\');  
      echo  '<script src="' . SITE_ROOT_URL.  'lib/js/timeline/timeline_js/timeline-api.js" type="text/javascript"></script>'. END_LINE; 
      echo  '<script type="text/javascript" src="../lib/js/timeline.js"></script>'.  END_LINE; 
 * Include jQuery text-resizer plugin  
 * if no js wysiwyg are enabled  
  if(!defined('RICH_TEXT_EDITOR') ||  RICH_TEXT_EDITOR == (string)  0 )  
    echo  '<script type="text/javascript" src="../lib/js/jquery.textarearesizer.compressed.js"></script>'; 
    echo  '<script type="text/javascript"> 
              $(document).ready(function() {  
                $(\'textarea.largetextfield:not(.processed)\').TextAreaResizer();  
 * Include Js & css for PHP_DEBUG  
  if(defined('MOD_DEBUG') &&  MOD_DEBUG ==  true) {  
    echo  '<script type="text/javascript" src="../lib/vendor/PHP_Debug/js/html_div.js"></script>'. END_LINE; 
    echo  '<link type="text/css" rel="stylesheet" href="../lib/vendor/PHP_Debug/css/html_div.css" />'. END_LINE; 
 * Include jQuery tooltip plugin  
 * @param string $selector   
    $str .=  '$("'. $selector. '").tooltip({ effect: "slide", opacity: 0.8});';  
    foreach($selector as $sel) {  
      $str .=  '$("'. $sel. '").tooltip({ effect: "slide", opacity: 0.8});';  
  echo  '<script type="text/javascript" src="../lib/js/jquery.tools.min.js"></script>'. END_LINE; 
  echo  '<script type="text/javascript"> 
          $(document).ready(function() {  
 * Transform a list given in the form "jpg,png,gif"  
 * into "(jpg)|(png)|(gif)" format  
 * Include jQuery Fancy Upload  
  $rub = isset ($_REQUEST['rub']) ?  $_REQUEST['rub'] :  '';  
  $a =  $GLOBALS['fancyUpload_includes'];  
  // security check here because uploadify is not able to handle cookie  
    echo  '<script type="text/javascript"> 
              var rooturl = "' .  SITE_ROOT_URL.  '";  
              var upbutton = "' .  _t('divers', 'up'). '";  
              var delbutton = "'.  _t('divers', 'delqueue'). '";  
              var addfiles = "' .  _t('upload', 'addfiles'). '";  
              var succeed = "' .  _t('upload', 'confirmed'). '";  
              var error = "' .  _t('upload', 'error'). '";  
              var notallowed_msg = "'. sprintf(_t('upload', 'wrong_ext'), $fileDesc). '";  
              var maxsize = "' .  MEDIA_ALLOWED_SIZE. '";  
              var regexpattern = "' .  extRegex(MEDIA_ALLOWED_EXT). '";  
              var fileReplace = "' .  _t('divers', 'replace_file'). '";  
              var cbText = "'. _t('workshop', 'share_files'). '";  
           <link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/base/jquery-ui.css" id="theme" />  
           <link type="text/css" rel="stylesheet" href="../lib/vendor/jQuery-File-Upload/jquery.fileupload-ui-l21.css" media="screen" />  
           <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>  
          <script type="text/javascript" src="../lib/vendor/jQuery-File-Upload/jquery.fileupload.js"></script>  
          <script type="text/javascript" src="../lib/vendor/jQuery-File-Upload/jquery.fileupload-ui.js"></script>  
          <script type="text/javascript" src="../lib/vendor/jQuery-File-Upload/public-settings.js"></script>'. END_LINE;  
 * Include jQuery text-corner plugin  
  echo  '<script type="text/javascript" src="../lib/js/jquery.corner.js"></script>'. END_LINE; 
  echo  '<script type="text/javascript" src="../lib/js/jquery.corner.config.js"></script>'. END_LINE; 
 * Include jQuery tree plugin  
  $str =  '<ul id="cMenu" class="contextMenu"><li class="edit"><a href="#edit">'.  _t('divers','modify'). '<\/a><\/li><li class="delete separator"><a href="#delete">'.  _t('divers','delete'). '<\/a><\/li><\/ul>';  
  echo  '<script type="text/javascript" src="../lib/js/jquery.contextMenu/jquery.contextMenu.js"></script>'. END_LINE; 
  echo  '<link type="text/css" rel="stylesheet" href="../lib/js/jquery.contextMenu/jquery.contextMenu-l21.css" media="screen" />'. END_LINE; 
  echo  '<script type="text/javascript" src="../lib/js/jquery.treeview/jquery.treeview.js"></script>'. END_LINE; 
  echo  '<link type="text/css" rel="stylesheet" href="../lib/js/jquery.treeview/jquery.treeview.css" media="screen" />'. END_LINE; 
  echo  '<script type="text/javascript"> 
          $(document).ready(function(){  
              $("#tree").after(\''. $str. '\');  
            $("#tree ul li").contextMenu({  
                }, function(action, el, pos) {  
                        if(typeof $(el).children("a.ico_mod").attr("href") == "undefined") {  
                            document.location.href = $(el).children("a.ico_mod").attr("href");  
                        if(typeof $(el).children("a.ico_sup").attr("href") == "undefined") {  
                            //$("cMenu").disableContextMenuItems("delete");  
                            //$("ul.contextMenu li.delete").attr("disabled", true);  
                            document.location.href = $(el).children("a.ico_sup").attr("href");  
            $("#tree li a.ico_mod, #tree li a.ico_sup").css("display", "none");  
 * IncludeRichTextEditor()  
 * Include RichTextEditor if enabled  
  if(defined('RICH_TEXT_EDITOR') &&  RICH_TEXT_EDITOR != (string)  0 )  {  
      include('../lib/js/ckeditor/ckeditor.php');  
      $CKEditor =  new CKEditor();  
      $CKEditor->basePath =  SITE_ROOT_URL. 'lib/js/ckeditor/';  
      $CKEditor->config['customConfig'] =  'l21_config.js';  
      if(defined('CKFINDER_ENABLED') &&  CKFINDER_ENABLED ==  true) {  
        require_once '../lib/vendor/ckfinder/ckfinder.php';  
        CKFinder::SetupCKEditor( $CKEditor, '../lib/vendor/ckfinder/' ) ;  
        $CKEditor->config['filebrowserBrowseUrl'] =  '../library/access.php';  
        $CKEditor->config['filebrowserImageBrowseUrl'] =  '../library/access.php?type=images';  
        $CKEditor->config['filebrowserUploadUrl'] =  '../library/access.php';  
        $CKEditor->config['filebrowserImageUploadUrl'] =  '../library/access.php?type=images';  
        $CKEditor->config['filebrowserWindowWidth'] =  '100%';  
        $CKEditor->config['filebrowserWindowHeight'] =  '100%';  
      $CKEditor->replaceAll('largetextfield');  
 * Include Lightbox jQuery plugin  
 * @param string £selector  
    $str .=  '$("'. $selector. '").lightBox();'. END_LINE;  
    foreach($selector as $sel) {  
      $str .=  '$("'. $sel. '").lightBox();'. END_LINE;  
  echo  '<script type="text/javascript" src="../lib/js/jquery.lightbox-0.5.pack.js"></script>'. END_LINE; 
        <script type="text/javascript">  
        $(document).ready(function() {  
 * Include jQuery TextBoxList plugin  
  $rub = isset ($_REQUEST['rub']) ?  $_REQUEST['rub'] :  '';  
  $todo = isset ($_REQUEST['todo']) ?  $_REQUEST['todo'] :  '';  
  $a =  $GLOBALS['textboxList_includes'];  
    echo  '<link type="text/css" rel="stylesheet" href="'. THEME_ADMIN_PATH. 'css/TextboxList.css" media="screen" />'. END_LINE; 
    echo  '<link type="text/css" rel="stylesheet" href="'. THEME_ADMIN_PATH. 'css/TextboxList.Autocomplete.css" media="screen" />'. END_LINE; 
    echo  '<script type="text/javascript" src="../lib/js/jquery.textboxList/GrowingInput.js"></script>'. END_LINE; 
    echo  '<script type="text/javascript" src="../lib/js/jquery.textboxList/TextboxList.js"></script>'. END_LINE; 
    echo  '<script type="text/javascript" src="../lib/js/jquery.textboxList/TextboxList.Autocomplete.js"></script>'. END_LINE; 
 * Include jQuery multiSelect plugin  
  $rub = isset ($_REQUEST['rub']) ?  $_REQUEST['rub'] :  '';  
  $todo = isset ($_REQUEST['todo']) ?  $_REQUEST['todo'] :  '';  
  $a =  $GLOBALS['multiSelect_includes'];  
    echo  '<script type="text/javascript" src="../lib/js/jquery.multiSelect/jquery.multiSelect.js"></script>'. END_LINE; 
    echo  '<script type="text/javascript" src="../lib/js/jquery.multiSelect/jquery.bgiframe.min.js"></script>'. END_LINE; 
 * Include jQuery date Picker  
  $rub = isset ($_REQUEST['rub']) ?  $_REQUEST['rub'] :  '';  
  $todo = isset ($_REQUEST['todo']) ?  $_REQUEST['todo'] :  '';  
  $a =  $GLOBALS['datePicker_includes'];  
    echo  '<script type="text/javascript" src="../lib/js/jquery.datePicker.js"></script>'. END_LINE; 
    echo  '<script type="text/javascript" src="../lib/js/date.js"></script>'. END_LINE; 
 * Créer un dossier s'il n'existe pas.  
 * @param string $pathname   
 * @return integer $ver_num  
    return mkdir ($pathname, $perms, true);  
 * Supprime le contenu d'un dossier et le dossier lui-même si précisé.  
 * @return integer $ver_num  
    if($obj== '.' ||  $obj== '..') continue;  
 * Retourne un entier comme numéro de version PHP  
 * @return integer $ver_num  
  $ver_num =  $ver[0] .  $ver[1] .  $ver[2];  
 * Découpe un texte à une longeur donnée.  
function cutText($content, $length, $abbr =  0, $end =  '...')  
  else  $substr =  substr($content, 0, $length);  
  if (strlen($content) >  $length) {  
    if ($abbr ==  1) $content_light =  "<abbr title=\"" .  $content .  "\">" .  $substr .  $end .  "</abbr>\n";  
    else $content_light =  $substr .  $end;  
  } else $content_light =  $content;  
 * Renvoie un texte en 2 parties dans un tableau  
  $middle =  (strlen($text) /  2);  
  $body[0] =  substr($text, 0, $middle);  
  $body[1] =  substr($text, $middle, $end);  
  $chaine =  preg_split("/(\.(<br \/>| ))/", $body[1], 2);  
  $body[0] .=  $chaine[0] .  ".";  
  $body[1] =  @trim($chaine[1]);  
 * Miniatures; agrandissement onclick  
 * @param string $alt_desc   
 * @return string $img_link  
  $img_link =  '<a href="' .  $uri .  '" title="' .  _t('divers','enlarge_photo') .  '">' .  END_LINE;  
  $img_link .=  '<img src="' .  get_min_name($uri) .  '" alt="' .  _t('divers','enlarge_photo') .  ' ' .  $alt_desc .  '"' .  $style .  ' />' .  END_LINE;  
 * Formatage des titres ( interface admin )  
 * @return string $content  
  $content =  cutText($content, 70, 1);  
 * Formatage des listes ( interface admin )  
 * @return string $content  
  $content =  cutText($content, 65, 1);  
 * Formatage des titres h2 ( interface admin )  
 * @return string $content  
 * check if raw text or html text  
 * Formatage de texte pour affichage  
 * @return string $content  
      if(RICH_TEXT_EDITOR ===  0 ||  isRawText($content)) $content =  nl2br($content);  
      //$content = addslashes(trim($content));  
 * Remplacement des caractères invalides  par leurs entités HTML  
 * @return string $valid_string  
  $htmlentities_chars =  array('å' =>  'Œ', 'ú' =>  'œ',  
        'ä' =>  'Š', 'ö' =>  'š',  
        'ü' =>  'Ÿ', 'à' =>  'ˆ',  
        'ò' =>  '˜', 'ñ' =>  '–',  
        'ó' =>  '—', 'ë' =>  '‘',  
        'í' =>  '’', 'Ç' =>  '‚',  
        'ì' =>  '“', 'î' =>  '”',  
        'Ñ' =>  '„', 'Ü' =>  '†',  
        'á' =>  '‡', 'Ö' =>  '…',  
        'â' =>  '‰', 'É' =>  'ƒ',  
        'ã' =>  '‹', 'õ' =>  '›',  
        'Ä' =>  '€', 'ô' =>  '™',  
        'ï' =>  '•', 'ò' =>  '˜',  
  //$valid_string = str_replace(array_keys($htmlentities_chars), array_values($htmlentities_chars), $str);  
  $search =  explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u");  
  $replace =  explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u");  
  // strip all non word chars  
  // replace all white space sections with a dash  
 * Renvoie la date au format SQL  
                          'mysql' =>  array('short'=>  '%d-%m-%Y', 'long'=>   
  array('12' =>  '%d-%m-%Y  %r', '24' =>  '%d-%m-%Y  %T')),  
                        'pgsql' =>  array('short'=>  'DD-MM-YYYY', 'long'=>   
  array('12' =>  'DD-MM-YYYY HH12:MI:SS', '24' =>  'DD-MM-YYYY HH24:MI:SS'))),  
                          'mysql' =>  array('short'=>  '%Y-%m-%d', 'long'=>   
  array('12' =>  '%Y-%m-%d  %r', '24' =>  '%Y-%m-%d  %T')),  
                        'pgsql' =>  array('short'=>  'YYYY-MM-DD', 'long'=>   
  array('12' =>  'YYYY-MM-DD HH12:MI:SS', '24' =>  'YYYY-MM-DD HH24:MI:SS'))),  
  if($format ==  'long') $s =  $date_format[DATE_FORMAT][SQL][$format][TIME_FORMAT];  
  else $s =  $date_format[DATE_FORMAT][SQL][$format];  
 * Compare 2 dates with a given operator.  
      if($date1 >  $date2) return true;  
      if($date1 <  $date2) return true;  
      if($date1 >=  $date2) return true;  
      if($date1 <=  $date2) return true;  
      if($date1 ==  $date2) return true;  
 * Build a localized filename  
 * according to the cuurent language  
  $total =  count($tmp) -  1;  
 * Include the required file  
 * if no user file is found,  
 * includes the dist/ version file.  
 * Localized files have the priority  
  $file_dist_default =   $default_dist. 'dist/'. basename($file);  
  $l10n_file_dist_default =  $default_dist. 'dist/'. basename($l10n_file);  
    _debug('distInclude() file Inclusion : '. $l10n_file);  
    include_once($l10n_file);  
    _debug('distInclude() file Inclusion : '. $l10n_file_dist);  
    include_once($l10n_file_dist);  
    _debug('distInclude() file Inclusion : '. $file);  
    _debug('distInclude() file Inclusion : '. $l10n_file_dist_default);  
    include_once($l10n_file_dist_default);  
    _debug('distInclude() file Inclusion : '. $file_dist_default);  
    include_once($file_dist_default);  
 * check if a template file version exists or not  
 * if no user file is found in theme,  
 * return the default module version file.  
  $theme_file =  $path. 'override/'. str_replace('../', '', $file);  
    _debug('themePath() returned value : '. $theme_file);  
    _debug('themePath() returned value : '. $file);  
 * Renvoie la date aux formats yyyy-mm-dd ou dd-mm-yyyy suivant le cas de départ  
 * Si $db == true renvoie toujours la date au format yyyy-mm-dd  
 * @return string $new_date  
  @list ($part1, $part2, $part3) =  explode('-', $date);  
    $new_date =  $part3 .  '-' .  $part2 .  '-' .  $part1;  
    $new_date =  $part1 .  '-' .  $part2 .  '-' .  $part3;  
    // always return yyyy-mm-dd format  
      $new_date =  $part3 .  '-' .  $part2 .  '-' .  $part1;  
      $new_date =  $part1 .  '-' .  $part2 .  '-' .  $part3;  
 * Format date to RFC 2822 date format  
 * @return string (exemple : Thu, 21 Dec 2000 16:01:07 +0200)  
    @list ($y, $m, $d) =  explode('-', $tmp_date);  
  if($date ==  '0001-01-01' ||  $date ==  '01-01-0001') {  
 * retourne le contenu ou N.C  
 * @return string $content  
  $content =  trim($content);  
  if (empty($content) ||  isNullDate($content)) $content =  _t('divers','nc');  
 * retourne le contenu ou 'aucun'  
 * @return string $content  
  $content =  trim($content);  
  if (empty($content)) $content =  _t('divers','none');  
 * retourne le contenu ou 0  
 * @return string $content  
  $content =  trim($content);  
  if (empty($content)) $content =  0;  
 * Vérifie la validité d'une date  
 * @param string $msg (optionnal)  
 * @return boolean true or error message (string)  
  @list ($year, $month, $day) =  explode('-', $date);  
    $msg .=  _t('date','not_valid');  
  if (!@checkdate($month , $day , $year)) return $msg .  _t('date','date_do_not_exist');  
 * Affichage d'un message d'erreur utilisateur  
  $display_it =  "<div class=\"error\">\n";  
  $display_it .=  "</div>\n";  
 * Affichage d'un message d'erreur syst�me  
  $display_it =  "<div class=\"systemerror\">\n";  
  $display_it .=  "</div>\n";  
 * obtenir le nom temporaire d'un fichier  
 * @return string $temp_path  
  $temp_path =  $short_path .  "/temp_" .  $filename;  
 * obtenir le nom de la miniature d'un fichier  
 * @return string $min_path  
  $min_path =  $short_path .  "/min_" .  $filename;  
 * Teste si une image dépasse ou non la taille autorisée (en pixels)  
 * @param integer $width_max   
  if ($width >  $width_max ||  $height >  $width_max) return true;  
 * renvoie les paths des photos dans un tableau  
  if (empty($path)) return false;  
    if ($opt ==  'min') array_walk($tab, 'get_min_name');  
 * génére un bouton de retour  
  return '<input name="annuler" type="button" value="' .  _t('btn','annul') .  '" class="button" id="annuler" onclick="window.location=\'' .  $back_uri .  '\';" />';  
 * renvoie les droits d'un utilisateur  
  if ($indice ==  'U') return _t('user','norights');  
  if ($indice ==  'A') return _t('user','adminrights');  
  if ($indice ==  'O' &&  $module ==  'dashboard') return _t('user','managerrights');  
  if ($indice ==  'O' &&  $module ==  'workshop') return _t('user','animatorrights');  
  if ($indice ==  'O' &&  ($module !=  'workshop' &&  $module !=  'dashboard')) return _t('user','redactorrights');  
 * @param array $table_link   
  $result =  ceil($total /  $pas);  
  if ($result <=  1) return ' ';  
    $link =  '<div class="lienliste">'. END_LINE;  
    for($i =  0; $i <  $result; $i++ ) {  
      $current_pos =  ($pas *  $i);  
      if ($debut ==  $current_pos) $link .=  $sep. "<span>" .  ($i +  1) .  "</span> \n";  
        $array_pos =  array ('debut' =>  $current_pos);  
        $new_table_link =  array_merge ($table_link, $array_pos);  
        $link .=  $sep. '<a href="'.  HrefMaker($new_table_link) .  '">' .  ($i +  1) .  '</a>'. END_LINE;  
 * création d'un navigateur de pages numérotées  
 * @param string $string_uri   
function linkin_page($string_uri, $total, $debut, $pas =  SELECT_LIMIT)  
  $result =  ceil($total /  $pas);  
  if ($result <=  1) return ' ';  
    if (strpos($string_uri, '?') ===  false) $string_uri .=  '?';  
    else $string_uri .=  '&';  
    $link =  '<div class="lienliste">';  
    for($i =  0; $i <  $result; $i++ ) {  
      $current_pos =  ($pas *  $i);  
      if ($debut ==  $current_pos) $link .=  "<span>" .  ($i +  1) .  "</span> \n";  
      else $link .=  "<a href=\"" .  $string_uri .  "debut=" .  $current_pos .  "\">" .  ($i +  1) .  "</a> \n";  
 * renvoie le statut en pleines lettres  
      $result =  _t('statut','public');  
      $result =  _t('statut','draft');  
      $result =  _t('statut','E');  
      $result =  _t('statut','AA');  
      $result =  _t('statut','PA');  
      $result =  _t('statut','C');  
      $result =  _t('statut','U');  
      $result =  _t('statut','O');  
      $result =  _t('statut','A');  
      $result =  _t('statut','W');  
      $result =  _t('statut','public');  
 * Cherche les liens et emails dans du contenu -> linkage  
 * @return string $content  
  if(defined('AUTO_LINK') &&  AUTO_LINK ==  1)  
    if(defined('RICH_TEXT_EDITOR') &&  RICH_TEXT_EDITOR == (string)  0) {  
      if ($option ==  'ALL' ||  $option ==  'MAIL') {  
        $content =  eregi_replace("( |<br />)+([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)", '\\1<a href="mailto:\\2">\\2</a>', $content);  
      if ($option ==  'ALL' ||  $option ==  'LINK') {  
        $content =  eregi_replace("(http|https|ftp|ftps)://([-a-z0-9#?/&=:,_;@%.{}]*)([a-z0-9=]{2,4})", '<a href="\\1://\\2\\3" class="out">\\1://\\2\\3</a>', $content);  
 * Génération de la quickbox  
 * @param string $suffixclass   
 * @return string $quickbox  
function QuickBoxNow($module, $h1, $liste, $suffixclass =  '')  
  $quickbox =  "<div class=\"entete\">\n<div class=\"qb_ico\" id=\"qbico" .  $suffixclass .  "\" title=\"" .  $module .  "\"></div>\n";  
  $quickbox .=  "<div class=\"quickbox\" id=\"qbbg" .  $suffixclass .  "\">\n";  
  $quickbox .=  "<h1>" .  $h1 .  "</h1>\n";  
 * Chargement de l'index après destruction de sessions  
      return header("Location: ../public/index.php");  
      return header("Location: ../admin/logout.php");  
 * renvoie le temps en microsecondes  
  return ((float) $usec + (float) $sec);  
 * Return available plugins  
  if ($handle =  opendir('../plugins/')) {  
    while (false !==  ($file =  readdir($handle))) {  
      if (substr($file, 0, 4) ==  'l21_' ) {  
 * @link http://fr2.php.net/manual/fr/function.mysql-query.php  
  $handle =  @fopen($url, "r");  
  if($a == - 1) $a =  array();  
    $sql_line =  fgets($handle);  
    if (trim($sql_line) !=  "" &&  strpos($sql_line, "--") ===  false &&  strpos($sql_line, "#") ===  false) {  
  foreach ($input as $key =>  $value)  
 * @param unknown $redirect   
  $page  =  '<?xml version="1.0" encoding="' .  CHARSET .  '" xml:lang="' .  U_L .  '"?>' .  END_LINE;  
  $page .=  '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' .  END_LINE;  
  $page .=  '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .  U_L .  '">' .  END_LINE;  
  $page .=  '<meta http-equiv="content-type" content="text/html;charset=' .  CHARSET .  '" />' .  END_LINE;  
  $page .=  '<meta http-equiv="content-langage" content="' .  CHARSET .  '" />' .  END_LINE;  
  $page .=  '<meta http-equiv="refresh" content="' .  $time .  ';url=' .  $redirect .  '">' .  END_LINE;  
  $page .=  '<title>'. SITE_NAME. '</title>' .  END_LINE;  
  $page .=  '<div class="info" style="margin-top:10em">'. $string. END_LINE;  
  $page .=  sprintf( _t('divers','redirect_string'), $redirect, $time);  
 * Display a debug message  
  if(isset ($GLOBALS['Dbg']))  
  $str =  '<link type="text/css" rel="stylesheet" href="../'. $path. '" />'. END_LINE;  
  if(isset ($GLOBALS['CSSheader']))  
      $GLOBALS['CSSheader'] =  $str .  $GLOBALS['CSSheader'];  
      $GLOBALS['CSSheader'] .=  $str .  END_LINE ;  
    $GLOBALS['CSSheader'] =  $str;  
  _debug('Loading <b>CSS file</b> : '. $path .  ' (position: '. $pos. ')');  
    _debug('<b>Problem loading JS file</b> : '. $path .  ' (position: '. $pos. ')');  
  $str=  '<script type="text/javascript" src="../'. $path . '"></script>'. END_LINE;  
  if(isset ($GLOBALS['JSheader']))  
      $GLOBALS['JSheader'] =  $str .  $GLOBALS['JSheader'];  
      $GLOBALS['JSheader'] .=  $str .  END_LINE ;  
    $GLOBALS['JSheader'] =  $str;  
  _debug('Loading <b>JS file</b> : '. $path .  ' (position: '. $pos. ')');  
    _debug('<b>Problem loading JS file</b> : '. $path .  ' (position: '. $pos. ')');  
  $str=  '<script type="text/javascript" src="../'. $path . '"></script>'. END_LINE;  
  if(isset ($GLOBALS['JSfooter']))  
      $GLOBALS['JSfooter'] =  $str .  $GLOBALS['JSheader'];  
      $GLOBALS['JSfooter'] .=  $str .  END_LINE ;  
    $GLOBALS['JSfooter'] =  $str;  
  _debug('Loading <b>JS file</b> : '. $path .  ' (position: '. $pos. ')');  
 * Display JS and CSS header  
  if(isset ($GLOBALS['JSheader'])) echo  $GLOBALS['JSheader'];  
  if(isset ($GLOBALS['CSSheader']))  echo  $GLOBALS['CSSheader'];  
  if(isset ($GLOBALS['JSfooter'])) echo  $GLOBALS['JSfooter'];  
 * Display a link to download new version if available  
      throw  new Exception('Version : xml file was not found'); 
    $current_version =  preg_replace("/([a-z])/i",'', LINEA_VERSION); // remove letter (if dev version)  
    if((integer) $latest_version > (integer) $current_version) {  
      $update =  '<div id="version-check">'. _t('check_update','search'). ' : <a href="'.(string) $rss->link. '">'. sprintf(_t('check_update','dl'), $rss->num). '</a></div>';  
      $update =  '<div id="version-check">'. _t('check_update','search'). ' : '. _t('check_update','ok'). '</div>';  
    $update =  $e->getMessage();  
      throw  new Exception($name. ' plugin : xml file was not found'); 
    $a['name'] =  $flow->themename;  
    $a['description'] =  $flow->description;  
    $a['version'] =  $flow->version;  
    $a['date'] =  $flow->date;  
    $a['compatibility'] =  $flow->compatibility;  
    $a['author'] =  $flow->author;  
    $a['homepage'] =  $flow->homepage;  
 * For compatibility with PHP < 5.2  
    require_once __DIR__ . '/vendor/JSON/JSON.php';  
    return $json->decode($content);  
 * For compatibility with PHP < 5.2  
    require_once __DIR__ . '/vendor/JSON/JSON.php';  
    return $json->encode($content);  
 Validate an email address.  
 Provide email address (raw input)  
 Returns true if the email address has the email  
 address format and the domain exists.  
 @link http://www.linuxjournal.com/article/9585  
  if (is_bool($atIndex) &&  !$atIndex)  
    $domain =  substr($email, $atIndex+ 1);  
    $local =  substr($email, 0, $atIndex);  
    if ($localLen <  1 ||  $localLen >  64)  
      // local part length exceeded  
    else if ($domainLen <  1 ||  $domainLen >  255)  
      // domain part length exceeded  
    else if ($local[0] ==  '.' ||  $local[$localLen- 1] ==  '.')  
      // local part starts or ends with '.'  
      // local part has two consecutive dots  
    else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))  
      // character not valid in domain part  
      // domain part has two consecutive dots  
    (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',  
      // character not valid in local part unless  
        // domain not found in DNS  
  if(!isset ($GLOBALS['breadcrumb'])) $GLOBALS['breadcrumb']=  array();  
  $GLOBALS['breadcrumb'] =  array_merge($GLOBALS['breadcrumb'], $array);  
 * get the Breadcrumb for displaying  
 * @param string (optional)  
  $str =  '<div id="breadcrumb">'. END_LINE;  
  $str.=  '<li>'. $sep. ' <a href="'. SITE_ROOT_URL. 'public/">Accueil</a></li>'. END_LINE;  
  foreach($GLOBALS['breadcrumb'] as $key =>  $value) {  
    // echo "$key => $value";  
    if($value!= false) $str.=  '<li>'. $sep. ' <a href="'. $value. '">'. $key. '</a></li>'. END_LINE;  
    else $str.=  '<li>'. $sep. ' '. $key. '</li>'. END_LINE;  
 * Return an HTML list for a given folder  
function ListDir($dir_handle,$path, $url) {  
  while (false !==  ($file =  readdir($dir_handle))) {  
    if(is_dir($dir) &&  $file !=  '.' &&  $file != '..' ) {  
      $handle =  @opendir($dir) or die("Unable to open file $file");  
    } elseif($file !=  '.' &&  $file != '..' &&  $file != '.htaccess') {  
      $class =  ($i++  & 1) ?  '' :  'class="odd"';  
      echo  '<li '. $class. '><a href="'.  $url .  $dir . '">'. $file. '</a> <em>('. $size. ')</em> <a  class="dlfile" href="'.  $url . 'library/dl.php?file='.  $dir . '" title="'. _t('divers','dl').  ' ' .  $file. '"><span>' . _t('divers','dl').  '</span></a></li>'; 
  if($i== 0) echo  '<li>'. _t('divers','no_files'). '</li>';  
 * Make File size readable  
  $units =  array('o', 'Ko', 'Mo', 'Go', 'To');  
  $bytes /=  pow(1024, $pow);  
  return round($bytes, $precision) .  ' ' .  $units[$pow];  
 * Return installed themes  
  if ($handle =  opendir('../templates/'. $f)) {  
    while (false !==  ($file =  readdir($handle))) {  
      if ($file !=  "." &&  $file !=  ".." &&  $file !=  ".svn") {  
 * Remove exotic characters form string  
 * same as used in filemanager  
    foreach ($allowed as $value) {  
        'Š'=> 'S', 'š'=> 's', 'Đ'=> 'Dj', 'đ'=> 'dj', 'Ž'=> 'Z', 'ž'=> 'z', 'Č'=> 'C', 'č'=> 'c', 'Ć'=> 'C', 'ć'=> 'c',  
        'À'=> 'A', 'Á'=> 'A', 'Â'=> 'A', 'Ã'=> 'A', 'Ä'=> 'A', 'Å'=> 'A', 'Æ'=> 'A', 'Ç'=> 'C', 'È'=> 'E', 'É'=> 'E',  
        'Ê'=> 'E', 'Ë'=> 'E', 'Ì'=> 'I', 'Í'=> 'I', 'Î'=> 'I', 'Ï'=> 'I', 'Ñ'=> 'N', 'Ò'=> 'O', 'Ó'=> 'O', 'Ô'=> 'O',  
        'Õ'=> 'O', 'Ö'=> 'O', 'Ő'=> 'O', 'Ø'=> 'O', 'Ù'=> 'U', 'Ú'=> 'U', 'Û'=> 'U', 'Ü'=> 'U', 'Ű'=> 'U', 'Ý'=> 'Y',  
        'Þ'=> 'B', 'ß'=> 'Ss','à'=> 'a', 'á'=> 'a', 'â'=> 'a', 'ã'=> 'a', 'ä'=> 'a', 'å'=> 'a', 'æ'=> 'a', 'ç'=> 'c',  
        'è'=> 'e', 'é'=> 'e', 'ê'=> 'e', 'ë'=> 'e', 'ì'=> 'i', 'í'=> 'i', 'î'=> 'i', 'ï'=> 'i', 'ð'=> 'o', 'ñ'=> 'n',  
        'ò'=> 'o', 'ó'=> 'o', 'ô'=> 'o', 'õ'=> 'o', 'ö'=> 'o', 'ő'=> 'o', 'ø'=> 'o', 'ù'=> 'u', 'ú'=> 'u', 'ű'=> 'u',  
        'û'=> 'u', 'ý'=> 'y', 'ý'=> 'y', 'þ'=> 'b', 'ÿ'=> 'y', 'Ŕ'=> 'R', 'ŕ'=> 'r', ' '=> '_', "'"=> '_', '/'=> ''  
          foreach ($string as $key =>  $clean) {  
            $clean =  strtr($clean, $mapping);  
            $clean =  preg_replace("/[^{$allow}_a-zA-Z0-9]/", '', $clean);  
            $cleaned[$key] =  preg_replace('/[_]+/', '_', $clean); // remove double underscore  
          $string =  strtr($string, $mapping);  
          $string =  preg_replace("/[^{$allow}_a-zA-Z0-9]/", '', $string);  
          $cleaned =  preg_replace('/[_]+/', '_', $string); // remove double underscore  
 * Test and sanitize user input  
  // we first sanitize vars  
  if(isset ($_REQUEST['rub']))  
  if(isset ($_REQUEST['name']))  
  if(isset ($_REQUEST['id']) &&  preg_match('/[^0-9A-Za-z]/',$_REQUEST['id']))  
  if(isset ($_REQUEST['parentid']) &&  !is_numeric($_REQUEST['parentid']))  
  if(isset ($_REQUEST['parentparentid']) &&  !is_numeric($_REQUEST['parentparentid']))  
  if(isset ($_REQUEST['debut']) &&  !is_numeric($_REQUEST['debut']))  
  if($passed ==  false) die('no way!');  
 
 
        
       |