Location: PHPKode > projects > MyPhpMoney > myphpmoney_2.0/public_html/inc/xhtml.inc
<?php
/**
 * $Id: xhtml.inc 417 2007-05-08 17:55:39Z hpfn $
 *
 * Author     : courou&#64;users.sourceforge.net
 * Website    : http://allreponse.ath.cx
 *
 * Support    : http://sourceforge.net/projects/myphpmoney/
 * CVS        : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/myphpmoney/
 */

// include the template file and display the template
// @param $number  = the number of template
// @param $tab     = The tab of different value for template
// @param $parse   = Parse la Template
function XHTML_SetFile($number,$tab,$parse) {
 Global $_MPM,$tpl; $_MPM['Serial'][] = "XHTML_SetFile($number,$tab,$parse)";

     if (isset($number)) {
          if (isset($parse) && $parse != 3 && $parse != 4) {
          $tpl->set_file(array('FILE_'.$number => $number));
          }
     }
     ## Disable the three parameter (because Problem with BELOW)
     if (isset($tab) && is_array($tab))  $tpl->set_var($tab,'',false);

     ## Active the three parameter of function set_var('','',$append)
     if (isset($number) && isset($parse)) {
       ## Idem  ->parse('EXECUTE','FILE') and ->get('EXECUTE')
       if ($parse == 1 || $parse == 3) return $tpl->parse('EXECUTE_'.$number,'FILE_'.$number,false);
       if ($parse == 2 || $parse == 4) $tpl->pparse('EXECUTE_'.$number,'FILE_'.$number,false);
     }
} ## end of XHTML_SetFile

// Contruit le header en appelant les differents elements
// qui lui sont necessaire
// @param $nojs        = display or no the noscript         (0 -> OFF * 1 -> ON)
// @param $js          = include the js file                (0 -> OFF * 1 -> ON)
// @param $sid         = verif is account exist             (0 -> OFF * 1 -> ON)
// @param $logo        = include the logo and menu          (0 -> OFF * 1 -> ON)
// @param $left        = include the left menu              (0 -> OFF * 1 -> ON)
// @param $calend      = include the calendar menu          (0 -> OFF * 1 -> ON)
//                     = include menu for doc               (2 -> DOCUMENTATION)
// @param $close       = include the close table for menu   (0 -> OFF * 1 -> ON)
// @param $top         = include the $top                   (0 -> OFF * 1 -> ON)
function XHTML_header($nojs,$js,$sid,$logo,$left,$calend,$close,$top) {
  Global $_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_header($nojs,$js,$sid,$logo,$left,$calend,$close,$top)";

     XHTML_MetaHeader();                                                      ## HEADER
     if (isset($js) && $js == 1)         MPM_DynamiqueJs();                   ## JAVASCRIPT
     if (isset($sid) && $sid == 1)       XHTML_VerifAccount();                ## VERIF IF ACCOUNT EXIST
     if (isset($logo) && $logo == 1)     XHTML_logo();                        ## LOGO AND MENU TOP
     if (isset($left) && $left == 1)     XHTML_SetFile('left_menu.tpl','',2); ## BEGIN TABLE LEFT MENU
     if (isset($calend) && $calend == 1) XHTML_calendar();                    ## LEFT MENU WIDTH CALENDAR

     ## LEFT MENU FOR DOCUMENTATION
     if (isset($calend) && $calend == 2) {
           $_MPM['BeginMixed'] = array
           (
             'DOC_MAILING'            => $_MPM['translate_mail'],
             'DOC_EMAILING'           => $_MPM['translate_email'],
             'URL_FAQ'                => $_MPM['external_faq'],
             'URL_SUPPORT'            => $_MPM['external_support'],
             'URL_CONTRIB'            => $_MPM['external_contrib'],
             'URL_CVS'                => $_MPM['external_cvs'],
             'URL_BUGS'               => $_MPM['external_bugs'],
             'URL_FORUM'              => $_MPM['external_forum'],
             'LAST_MODIF'             => $_MPM['date_modif'],
             'DOC_APROPOS'            => $_VAR['DOC_APROPOS'],
             'DOC_DOWNLOAD'           => $_VAR['DOC_DOWNLOAD'],
             'MODIF_DOC'              => $_VAR['MODIF_DOC'],
             'DOC_OS_WIN'             => $_VAR['DOC_OS_WIN'],
             'DOC_OS_UNIX'            => $_VAR['DOC_OS_UNIX'],
             'DOC_FORUM'              => $_VAR['DOC_FORUM'],
             'DOC_BUGS'               => $_VAR['DOC_BUGS'],
             'DOC_SUPPORT'            => $_VAR['DOC_SUPPORT'],
             'DOC_CONTRIB'            => $_VAR['DOC_LANG_CONTRIB'],
             'DOC_LICENCE'            => $_VAR['DOC_LICENCE'],
             'DOC_README'             => $_VAR['DOC_README'],
             'DOC_CHANGELOG'          => $_VAR['DOC_CHANGELOG'],
             'DOC_CREDITS'            => $_VAR['DOC_CREDITS'],
             'DOC_OPEN_SOURCE'        => $_VAR['DOC_OPEN_SOURCE'],
             'DOC_GRAB'               => $_VAR['DOC_GRAB'],
             'DOC_SETUP'              => $_VAR['DOC_SETUP'],
             'DIRECTORY_FAQ'          => basename($_MPM['dir_faq'])
          );
          XHTML_SetFile('menu_doc_left.tpl',$_MPM['BeginMixed'],2);
     }

     ## CLOSE TABLE LEFT MENU
     if (isset($close) && $close == 1) XHTML_SetFile('left_menu_end.tpl','',2);

     ## DISPLAY THE TOP
     if (isset($top) && $top == 1)  {
          $_MPM['BeginMixed'] = array
          (
                'VERSION'       => $_MPM['header_VERSION'],
                'BELOW'         => $_VAR['BELOW'],
                'ALT_DEC_BAS'   => $_VAR['ALT_DEC_BAS']
          );
          XHTML_SetFile('below.tpl',$_MPM['BeginMixed'],2);
     }

     ## NOSCRIPT FOR JAVASCRIPT
     if (isset($nojs) && $nojs == 1)   XHTML_SetFile('noscript.tpl',array('NOSCRIPT' => $_VAR['DOC_LANG_PHPDOC_5']),2);

     ## ERROR CHMOD
     if (isset($_MPM['chmod']) && $_MPM['chmod'] != '') echo sprintf("<p class=\"center\">%s</p><br />\n",$_MPM["chmod"]);
} ## end of XHTML_header

// Contruit le header
function XHTML_MetaHeader() {
  Global $tpl,$langs,$_VAR; $_MPM['Serial'][] = 'XHTML_MetaHeader';
    Global $_MPM,$sess,$sess_user,$sess_pid,$Number_of_Days,$jour,$mois,$annee;

    $sess_pid  = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
    $sess_user = isset($sess_user) && is_object($sess) && $sess->is_registered('sess_user') ? $sess_user : '';

    $scriptname = $GLOBALS['_SERVER']['REQUEST_URI'];

    $FormDate = '';
    if (stripos($scriptname,$_MPM['http'][1]) !== false || stripos($scriptname,$_MPM['file_account']) !== false) {
     $FormDate = $_MPM['DATE_DAYS'];
    }

    $Seach_title = array(
        $_MPM['http'][0]      => $sess_user !='' && $sess_pid != '' ? $_VAR['WELCOME'].' '.$sess_user : $_VAR['LANG_BOOK_11'],                           ## INDEX
        $_MPM['http'][1]      => isset($GLOBALS['_GET']['opt']) && $GLOBALS['_GET']['opt'] == 'new' ? $_VAR['WELCOME'].' '.$sess_user : $FormDate,       ## GOOD BOOK
        $_MPM['http'][2]      => $_VAR['LANG_CALEND_DIS_2']." $Number_of_Days ".$_VAR['THIS_MONTH'][$mois - 1]." $annee ",                               ## CALENDAR
        $_MPM['http'][3]      => $_VAR['MESS_THIRD_PART_TITLE'],                                                                                         ## THIRD_PART
        $_MPM['http'][4]      => $_VAR['SIMUL_TITLE'][0],                                                                                                ## SIMULATION
        $_MPM['http'][5]      => $_VAR['SAVE_HOME'],                                                                                                     ## SAVE
        $_MPM['http'][6]      => $_VAR['TITLE_DOC'],                                                                                                     ## DOC
        $_MPM['http'][7]      => sprintf($_VAR['OPTION_HOME'],$sess_user),                                                                               ## OPTION
        $_MPM['http'][8]      => $_VAR['IMG_ALT'][8],                                                                                                    ## SIGNUP
        $_MPM['http'][9]      => $_VAR['IMG_ALT'][9],                                                                                                    ## LOGOUT
        $_MPM['http'][10]     => $_VAR['IMG_ALT'][10],                                                                                                   ## QUOTE
        $_MPM['http'][11]     => $_VAR['IMG_ALT'][11],                                                                                                   ## BALANCE
        $_MPM['file_account'] => $FormDate,                                                                                                              ## ACCOUNT
        $_MPM['file_phpdoc']  => $_MPM['translate_phpdoc'],                                                                                              ## PHPDOC
        $_MPM['file_listing'] => $_VAR['SIMUL_TITLE'][1],                                                                                                ## LISTING
    );

     ## CHOICE FOR META TAG ROBOTS
     if (stripos($scriptname,$_MPM['file_phpdoc']) !== false || stripos($scriptname,$_MPM['http'][6]) !== false ) {
       $bot   = $_MPM['header_ROBOTS_D'];
     } else {
       $bot   = $_MPM['header_ROBOTS'];
     }

    foreach ($Seach_title as $key => $val) if (stripos($scriptname,$key) !== false) $title = $val;

    ## THE META FOR HEADER
          $_MPM['BeginMixed'] = array
          (
              'PRAGMA'             => $_MPM['header_PRAGMA'],
              'CACHE'              => $_MPM['header_CACHE'],
              'AUTHOR'             => $_MPM['header_AUTHOR'],
              'MAIL'               => $_MPM['header_MAIL'],
              'VERSION'            => $_MPM['header_VERSION'],
              'DEBUG_JS'           => __HALT_JS_ERROR__ ? '' : '//',
              'ROBOTS'             => $bot,
              'EXPIRES'            => $_MPM['date_expire'],
              'STYLES'             => $_MPM['dir_style'],
              'CSS_STYLE'          => $_MPM['file_css'],
              'JS_SCRIPT'          => $_MPM['file_common'],
              'JS_LANG'            => $_MPM['file_stylang'],
              'TOP'                => $_VAR['TOP'],
              'CHARSET'            => $langs->Charset_need($_MPM['lang_verif_id'],1),
              'LANGUAGE'           => $langs->Charset_need($_MPM['lang_verif_id'],2),
              'BODY'               => MPM_JsBody($GLOBALS['_SERVER']['REQUEST_URI']),
              'TITLE_OPTION'       => isset($title) ? $title : $_VAR['TITLE_OPTION'],
              'COPYLEFT'           => sprintf($_MPM['header_COPYLEFT'],$_MPM['date_gettime']['year'])
          );
          XHTML_SetFile('header.tpl',$_MPM['BeginMixed'],2);
} ## end of XHTML_MetaHeader

// Contruit le footer
function XHTML_footer() {
  Global $sess,$sess_pid,$sess_user,$_MPM,$_VAR,$_below,$debugs,$tools; $_MPM['Serial'][] = 'XHTML_footer()';

     $sess_pid  = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
     $sess_user = isset($sess_user) && is_object($sess) && $sess->is_registered('sess_user') ? $sess_user : '';

     ## DISPLAY RESULT FOR PROCESS SQL AND ALL
     $z = '';
     $chaine1 = '';
     $chaine2 = '';

     if (__PROCESS_ACTIVE__ || __PROCESS_OPTION__) {
       $_MPM['proc_start'] = $tools->getmicrotime() - $_MPM['proc_start'];
       $SqlPercent   = number_format($_MPM['proc_sql'] * 100 / $_MPM['proc_start'],__PROCESS_PERCENT__);
       $StartPercent = 100 - $SqlPercent;

       $chaine1 = ($_MPM['proc_sql'] * 100) / 100;
       $chaine2 = ($_MPM['proc_start'] * 100) / 100;

       ## THE PROCESS TIME SLQ AND TOTAL
       $_MPM['BoucleMixed'] = array
       (
         'NBFUNCTION' => __PROCESS_OPTION__ ? sprintf("Number of Function : %s ---",sizeof($_MPM['Serial'])) : '',
         'NBSQL'      => __PROCESS_OPTION__ ? sprintf(" Number of SQL Request : %s ---",$_MPM['proc_nb']) : '',
         'SQLTIME'    => sprintf("Processed Sql in : %s sec (%s) ---",$chaine1 != 0 ? number_format($chaine1,__PROCESS_LENGHT__) : '0',$SqlPercent." %"),
         'STARTIME'   => sprintf("Processed Total in : %s sec (%s)",$chaine2 != 0 ? number_format($chaine2,__PROCESS_LENGHT__) : '0',$StartPercent." %")
       );
     }

     ## THE BELOW (Necessary for Opera and Xhtml)
     $_MPM['BeginMixed'] = array
     (
          'BELOW'               => isset($_below) && $_below == 1 ? 'Null' : $_VAR['BELOW'],
          'ALT_DEC_HAUT'        => $_VAR['ALT_DEC_HAUT'],
          'PROCESS'             => __PROCESS_ACTIVE__ || __PROCESS_OPTION__ ? 'Process_show();' : 'Process_hidden();'
     );
     $_MPM['BeginMixed'] = array_merge($_MPM['BeginMixed'],$_MPM['BoucleMixed']);
     XHTML_SetFile('top.tpl',$_MPM['BeginMixed'],2);

     ## THE COPYRIGHT
     if (__DISPLAY_COPYRIGHT__) {
          if (stripos($GLOBALS['_SERVER']['REQUEST_URI'],$_MPM['file_phpdoc']) === false) {
            $_MPM['BeginMixed'] = array
            (
               'CALCUL_WIDTH'   => __CALCUL_WIDTH__,
               'CALCUL_HEIGHT'  => __CALCUL_HEIGHT__,
               'CALCUL_IMG_ALT' => $_VAR['CALCUL_IMG_ALT'],
               'MAIL'           => $_MPM['header_MAIL'],
               'DUMP_DEVELOPER' => $_VAR['DUMP_DEVELOPER'],
	       'URI_MYPHPMONEY'    => $_MPM['external_support'],
	       'HTTP_HOME_PAGE_8'	=> $_MPM['http'][8], //signup
	       'IMG_ALT_8'        => $_VAR['IMG_ALT_NAV'][8],//singup
	       'TITLE_ALT_8'      => $_VAR['IMG_ALT'][8],
	       'TITLE_IMP'         => $_VAR['DOC_LANG_SETUP_11'],
	       'HTTP_HOME_PAGE_5'	=> $_MPM['http'][5], //save
	       'IMG_ALT_5'        => $_VAR['IMG_ALT_NAV'][5],//save
	       'TITLE_ALT_5'      => $_VAR['IMG_ALT'][5],
	       'HTTP_HOME_PAGE_9'	=> $_MPM['http'][9], //deconnection
	       'IMG_ALT_9'        => $_VAR['IMG_ALT_NAV'][9],//deconnection
	       'TITLE_ALT_9'      => $_VAR['IMG_ALT'][9],
	       'HELPER_CLOSE'   => $_VAR['HELPER_CLOSE'],
	       'COPYLEFT'       => sprintf($_MPM['header_COPYLEFT'],$_MPM['date_gettime']['year'])
            );
            XHTML_SetFile('copyright.tpl',$_MPM['BeginMixed'],2);
          }
     }

     ## THE XHTML LOGO
     if (__DISPLAY_XHTML__) {

       ## DEFINE OF PATH
       $begin_path = str_replace(basename($_MPM['dir_doc'])."/","",htmlspecialchars($_MPM['URI_MPM']));
       $chemin_css = basename($_MPM['dir_style']).'/'.$_MPM['file_css'];

       $_MPM['BeginMixed'] = array
       (
         'URL_CSS'      => sprintf($_MPM['external_css'],htmlspecialchars($begin_path.''.$chemin_css)),
         'URL_XHTML'    => sprintf($_MPM['external_xhtml'],htmlspecialchars("http://".$GLOBALS['_SERVER']['HTTP_HOST']."".$GLOBALS['_SERVER']['REQUEST_URI']))
       );
       XHTML_SetFile('xhtml.tpl',$_MPM['BeginMixed'],2);
     }

     ##  END TABLE (DON'T TOUCH PARENTHESE)
     if (($sess_pid != '' && $sess_user != '') &&
	     (stripos($GLOBALS['_SERVER']['REQUEST_URI'],$_MPM['file_account'] !== false)
	     || stripos($GLOBALS['_SERVER']['REQUEST_URI'],$_MPM['file_listing']) !== false) ) {
          ## Nothing
     }
     else {
          XHTML_SetFile('footer_end.tpl','',2);
     }

     ## DEBUG MODE
     $debugs->Debug_mode();

     ## CLOSE THE SESSION
     page_close();

     ## END XHTML
     XHTML_SetFile('footer.tpl','',2);

     ## End Etag and ob_._.()
     $m = '"MPM-'.md5(ob_get_contents()).'"';
     header("ETag: $m");
     $inm = isset($GLOBALS['_SERVER']['HTTP_IF_NONE_MATCH']) ? stripslashes($GLOBALS['_SERVER']['HTTP_IF_NONE_MATCH']) : '';
     if (strpos($inm,$m) !== false) {
       ob_end_clean();
          if (stripos($GLOBALS['_SERVER']['SERVER_SOFTWARE'],'Win32') !== false) {
               ## IIS has already sent a HTTP/1.1 200 by this stage for some strange reason
               header("Status: 304 Not Modified");
          } else {
               ## ETag hasn't changed, return "304 Not Modified"
               header("HTTP/1.0 304");
          }
     } else {
          ob_end_flush();
     }
} ## end of XHTML_footer

// Contruc the calendar and the links for left menu
function XHTML_calendar() {
  Global $sess,$sess_pid,$sess_user,$_MPM; $_MPM['Serial'][] = 'XHTML_calendar';
   Global $shuffle,$tpl,$_VAR,$jour,$mois,$annee;

    $sess_pid  = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
    $sess_user = isset($sess_user) && is_object($sess) && $sess->is_registered('sess_user') ? $sess_user : '';

     $Seach_link =
     array
     (
     ## INDEX
          $_MPM['http'][0] =>
          array
          (
            0  => $sess_user != '' && $sess_pid != '' ? $_VAR['IMG_ALT'][1] : $_VAR['IMG_ALT'][8],
            1  => $sess_user != '' && $sess_pid != '' ? $_MPM['http'][1] : $_MPM['http'][8],
            2  => $sess_user != '' && $sess_pid != '' ? 'INDEX_LOGIN' : 'INDEX_LOGOUT'
          ),
     ## GOOD BOOK
          $_MPM['http'][1] =>
          array
          (
            0  => isset($GLOBALS['_GET']['opt']) && $GLOBALS['_GET']['opt'] == 'new'
                     ? $_VAR['IMG_ALT'][1] : $_VAR['IMAGE_ADD_ALT'],
            1  => isset($GLOBALS['_GET']['opt']) && $GLOBALS['_GET']['opt'] == 'new'
                     ? $_MPM['http'][1] : $GLOBALS['_SERVER']['PHP_SELF']."?opt=new",
            2  => $sess_user != '' && $sess_pid != '' ? 'BOOK' : 'INDEX_LOGOUT'
          ),
     ## CALENDAR
          $_MPM['http'][2] =>
          array
          (
            0  => $_VAR['MESS_CALENDAR_NEW'],
            1  => $_MPM['http'][2]."?NewsChoice=YES#".$_VAR['BELOW'],
            2  => $sess_user != '' && $sess_pid != '' ? 'CALENDAR' : 'INDEX_LOGOUT'
          ),
     ## OPERATE
          $_MPM['http'][3] => array(2 => $sess_user !='' && $sess_pid != '' ? 'OPERATE' : 'INDEX_LOGOUT'),
     ## SIMULATE
          $_MPM['http'][4] => array(2 => $sess_user !='' && $sess_pid != '' ? 'SIMULATE' : 'INDEX_LOGOUT'),
     ## SAVE
          $_MPM['http'][5] =>
          array
          (
            0  => $_VAR['IMG_ALT'][7],
            1  => $_MPM['http'][7],
            2 => $sess_user != '' && $sess_pid != '' ? 'SAVE' : 'INDEX_LOGOUT'
          ),
     ## OPTION
          $_MPM['http'][7] =>
          array
          (
            0  => $_VAR['IMG_ALT'][5],
            1  => $_MPM['http'][5],
            2 => $sess_user != '' && $sess_pid != '' ? 'OPTION' : 'INDEX_LOGOUT'
          ),
     ## SIGNUP
          $_MPM['http'][8] =>
          array
          (
            0  => $_VAR['LANG_BOOK_11'],
            1  => $_MPM['http'][0],
            2  => 'SIGNUP'
          ),
     ## LOGOUT
          $_MPM['http'][9] =>
          array
          (
            0  => $_VAR['LANG_BOOK_11'],
            1  => $_MPM['http'][0],
            2  => 'LOGOUT'
          ),
     ## PORTFOLIO
          $_MPM['http'][10] => array(2 => $sess_user != '' && $sess_pid != '' ? 'PORTFOLIO' : 'INDEX_LOGOUT'),
     ## BALANCE
          $_MPM['http'][11] => array(2 => $sess_user != '' && $sess_pid != '' ? 'BALANCE' : 'INDEX_LOGOUT')
     );

    foreach ($Seach_link as $key => $val) {
       if (stripos($GLOBALS['_SERVER']['REQUEST_URI'],$key) !== false) {
          foreach ($val as $key => $val) {
               if ($key == 0) $new_user_account = $val;
               if ($key == 1) $url_user_account = $val;
               if ($key == 2) $display_help     = $val;
          }
       }
    }
     $help = isset($display_help) ? $display_help : 'INDEX_LOGOUT';

     ## CONTRUCT CALENDAR AND LINK
     $_MPM['BeginMixed'] = array
     (
       'THE_CALENDAR'     => !isset($GLOBALS['_GET']['T_MOIS'])
                                 ? $shuffle->getMonthView($mois,$annee) : $shuffle->getJustYear($mois,$annee),
        'NEW_USER_ACCOUNT' => isset($new_user_account) ? $new_user_account : $_VAR['IMG_ALT'][1],
        'URL_USER_ACCOUNT' => isset($url_user_account) ? $url_user_account : $_MPM['http'][1],
        'JS_HELPER'        => __HELPER_MENU__ ? XHTML_Helper($help) : ''
     );
     XHTML_SetFile('menu_calendar_left.tpl',$_MPM['BeginMixed'],2);
} ## end of of XHTML_calendar

// Contruit la fonction pour le menu d'aide
// @param $page = la page ou l'on se trouve et l'aide a afficher
function XHTML_Helper($page) {
  Global $_MPM,$_VAR,$tpl; $_MPM['Serial'][] = "XHTML_Helper($page)";

     $_MPM['BeginMixed'] = array
     (
      'HELPER_HOME'        => $_VAR['HELPER_HOME'],
      'HELPER_CLOSE'       => $_VAR['HELPER_CLOSE'],
      'HELPER_NEXT'        => $_VAR['HELPER_NEXT'],
      'HELPER_PREV'        => $_VAR['HELPER_PREV'],
      'HELPER_OPEN'        => $_VAR['HELPER_OPEN'],
      'HELPER_SMALL'       => $_VAR['HELPER_SMALL'],
      'HELPER_IMG_REDUIT'  => $_MPM['help_reduit'],
      'HELPER_IMG_OPEN'    => $_MPM['help_open'],
      'HELPER_IMG_CLOSE'   => $_MPM['help_close'],
      'SPEED_MOUV'         => __HELPER_MOUV__ ? 0 : 2,
      'SPEED_HELPER'       => __HELPER_TIMER__,
      'MENU_HELPER'        => __HELPER_MENU__ ? 'helper_display();' : ''
      );
      XHTML_SetFile('menu_helper.tpl',$_MPM['BeginMixed'],1);

      $tpl->set_block('FILE_menu_helper.tpl', 'BOUCLE_HELPER', 'BLOCK_menu_helper.tpl');
      $s = sizeof($_VAR['HELPER_MESSAGE'][$page]);
      for ($i=0; $i < $s; $i++) {
          $tpl->set_var(array(
              'COUNT'           => $i,
              'MESSAGE_COUNT'   => str_replace("'","\\'",$_VAR['HELPER_MESSAGE'][$page][$i])
          ));
      $tpl->parse('BLOCK_menu_helper.tpl','BOUCLE_HELPER',true);
      }
return XHTML_SetFile('menu_helper.tpl','',3);
} ## end of of XHTML_Helper

// Contruit le menu du haut et affiche les logo
function XHTML_logo() {
  Global $sess,$sess_user,$sess_pid,$_MPM; $_MPM['Serial'][] = 'XHTML_logo';
  Global $langs,$_VAR;

     $sess_pid  = isset($sess_pid)  && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid  : '';
     $sess_user = isset($sess_user) && is_object($sess) && $sess->is_registered('sess_user') ? $sess_user : '';

     $_MPM['BeginMixed'] = array
     (
         'URI_MYPHPMONEY'    => $_MPM['external_support'],
         //'LIST_LANGUAGE'     => XHTML_Select(2,$_MPM['lang_verif_id'],$langs->Get_List_file()),
         'IMAGE_LOGO'        => $_MPM['img_logo'],
         'IMAGES_LOGOS'      => $_MPM['img_menu'],
         'CALCUL_WIDTH'      => __CALCUL_WIDTH__,
         'CALCUL_HEIGHT'     => __CALCUL_HEIGHT__,
         'CALCUL_IMG_ALT'    => $_VAR['CALCUL_IMG_ALT'],
         'TITLE_IMP'         => $_VAR['DOC_LANG_SETUP_11'],
         'DISPLAY_LOGOUT_1'  => $sess_user != '' && $sess_pid != '' ? 'ViewLogout_show();' : 'ViewLogout_hidden();',
         'DISPLAY_LOGOUT_2'  => $sess_user != '' && $sess_pid != '' ? 'CopyLogout_show();' : 'CopyLogout_hidden();'
     );

   for ($d=0; $d<=11; $d++) {

      if ($sess_user != '' && $sess_pid != '') $this_ok = $_MPM['http'][$d];
      else if ($_MPM['http'][$d] == $_MPM['http'][6]) $this_ok = $_MPM['http'][$d];
      else if ($_MPM['http'][$d] == $_MPM['http'][8]) $this_ok = $_MPM['http'][$d];
      else if ($_MPM['http'][$d] == $_MPM['http'][9]) $this_ok = $_MPM['http'][$d];
      else  $this_ok = $_MPM['http'][0];

      $_MPM['BoucleMixed'] = array
      (
         "IMG_ALT_$d"        => $_VAR['IMG_ALT_NAV'][$d],
         "TITLE_ALT_$d"      => $d == 0 ? sprintf($_VAR['IMG_ALT'][0],$_MPM['name']) : $_VAR['IMG_ALT'][$d],
         "HTTP_HOME_PAGE_$d" => $this_ok
      );
      $_MPM['BeginMixed'] = array_merge($_MPM['BeginMixed'],$_MPM['BoucleMixed']);

   }
   XHTML_SetFile('logo.tpl',$_MPM['BeginMixed'],2);
} ## end of  of XHTML_logo

// Affiche l'image du graphique
// @param $this_graph = le choix du graphique
function XHTML_DisplayGraph($this_graph='default') {
  Global $_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_DisplayGraph($this_graph)";

          switch($this_graph) {
                 default:     $im  = $_MPM['dir_image'].''.$_MPM['img_concept'];
           break; case 1:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=1';
           break; case 100:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=2';
           break; case 2:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=3';
           break; case 200:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=4';
           break; case 3:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=5';
           break; case 300:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=6';
           break; case 4:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=7';
           break; case 400:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=8';
           break; case 5:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=9';
           break; case 500:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=10';
           break; case 6:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=11';
           break; case 600:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=12';
           break; case 7:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=13';
           break; case 700:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=14';
           break; case 8:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=15';
           break; case 800:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=16';
           break; case 9:     $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=17';
           break; case 900:   $im  = $_MPM['dir_graph'].''.$_MPM['file_all'].'?option=18';
           break;
          }

      $_MPM['BeginMixed'] = array
      (
           'IMG_ALT_GRAPH'          => $_VAR['IMG_ALT_GRAPH'],
           'DIRECTORIE_IMAGES'      => $im,
           'DIRECTORIE_HEIGHT'      => $this_graph == 'default' ? '240' : __IMG_GRAPH_H_HEIGHT__,
           'DIRECTORIE_WIDTH'       => $this_graph == 'default' ? '250' : __IMG_GRAPH_W_WIDTH__
      );
 return XHTML_SetFile('select_graph.tpl',$_MPM['BeginMixed'],1);
} ## end of XHTML_DisplayGraph

// permet d'afficher la template de langue pour option
// @param $id_lang = id de langue mais apres verif
function XHTML_DisplayLanguage($id_lang) {
  Global $_MPM,$langs,$tpl,$_VAR; $_MPM['Serial'][] = "XHTML_DisplayLanguage($id_lang)";

     $_MPM['BeginMixed'] = array
     (
          'SELF_OP'                  => $_MPM['http'][7],
          'LANG_OPTION_MODIF_1'      => $_VAR['LANG_OPTION_MODIF_1'],
          'LANG_OPTION_MODIF_2'      => $_VAR['LANG_OPTION_MODIF_2']
     );
     XHTML_SetFile('form_opt_lang.tpl','',0);

     $tpl->set_block('FILE_form_opt_lang.tpl','BOUCLE_OPTION_LANG','BLOCK_form_opt_lang.tpl');
     $news_array = $langs->Get_List_Lang(2);
     if (is_array($news_array)) {
         foreach($news_array as $f) {
           $f = explode('|',$f);

            $tpl->set_var(array(
                     'LANG_XX'      => $_VAR['LANG_OPTION_MODIF_3'],
                     'L_FIELD_1'    => $f[1],
                     'L_FIELD_2'    => $_VAR['THIS_LANG'][$f[1]],
                     'L_FIELD_3'    => $f[0],
                     'L_FIELD_4'    => $_VAR['ACTION_END']['P_FILE_DOWN']
            ));
            $tpl->parse('BLOCK_form_opt_lang.tpl','BOUCLE_OPTION_LANG',true);
         } ## end of foreach
     } ## end of is_array
return XHTML_SetFile('form_opt_lang.tpl',$_MPM['BeginMixed'],3);
} ## end of XHTML_DisplayLanguage

// test si le fichier exist avant de la proposer aux telechargeement
// @param $name_file = le nom du fichier lang
function XHTML_VerifAddLanguage($name_file) {
  Global $_MPM,$tools,$_VAR; $_MPM['Serial'][] = "XHTML_VerifAddLanguage($name_file)";

   if (strpos($name_file,'inc.php') !== false) {

        $file_url = str_replace('inc.php','zip',$name_file);
        $url = $_MPM['external_lang'].''.$file_url;

        ## 1 .verifie existance dans rep lang
        if (file_exists($_MPM['dir_lang'].''.$name_file)) {
          XHTML_DisplayJs(sprintf($_VAR['JS_DYNAMIQUE_52'],$name_file,$_MPM['name']));
        }
        ## 2. verifie the connection
        else if (!$tools->verif_connect()) {
          if (defined('PHP_HOSTCONNECT') && PHP_HOSTCONNECT == 1) {
             XHTML_DisplayJs(sprintf($_VAR['JS_PHP_HOSTCONNECT'],$_MPM['name'],$_VAR['LANG_OPTION_ADD_1']));
          } else {
             XHTML_DisplayJs($_VAR['LANG_OPTION_ADD_1']."\\n".$_VAR['LANG_OPTION_TAUX']);
          }
        }
        ## 3. verifier si la traduction existe
        else if (!MPM_fopen($url)) {
         XHTML_DisplayJs(sprintf($_VAR['JS_DYNAMIQUE_53'],$name_file));
        }
        ## 4. ok pour le dll
        else {
          $_MPM['BeginMixed'] = array
          (
            'MESSAGE'      => sprintf($_VAR['JS_DYNAMIQUE_54'],$name_file,$file_url,$_MPM['name']),
            'LOCATION_URL' => $url
          );
        XHTML_SetFile('js_add_lang.tpl',$_MPM['BeginMixed'],2);
        }
   }
   ## 5. erreur sur le fichier en entrer
   else {
     XHTML_DisplayJs(sprintf($_VAR['JS_DYNAMIQUE_55'],$name_file));
   } ## end of (strstr($name_file,'inc.php'))
} ## end of XHTML_VerifAddLanguage

// Fonction pour afficher les fonctions et class (xml et xhtml)
// @param $tnbr                    = number of the template name
// @param $b                       = number of row
// @param $choice_class_function   = choice between function or class
// @param $xml_html                = xml or html
function XHTML_PhpDoc($tnbr,$b,$choice_class_function,$xml_html) {
 Global $_MPM,$tpl; $_MPM['Serial'][] = "XHTML_PhpDoc($tnbr,$b,$choice_class_function,$xml_html)";

    $tpl->set_block('FILE_'.$tnbr, 'BOUCLE_PHPDOC_LIST_'.$b, 'BLOCK_'.$tnbr.'_'.$b);
    $s = sizeof($choice_class_function);		
    for ($i=0; $i < $s ; $i++) {
      $tpl->set_var(array('PHPDOC_LIST_'.$b.'' => $choice_class_function[$i]->$xml_html()));
    $tpl->parse('BLOCK_'.$tnbr.'_'.$b.'','BOUCLE_PHPDOC_LIST_'.$b.'',true);
    } ## end of for ($i=0; $i<sizeof($choice_class_function); $i++)
} ## end of XHTML_PhpDoc

// Redirige la page en cours
// @param $page = destination
function XHTML_Exit($page) {
  Global $_MPM; $_MPM['Serial'][] = "XHTML_Exit($page)";

     XHTML_SetFile('js_redirect.tpl',array('PAGE' => $page),2);
     XHTML_footer(); exit;
} ## end of XHTML_Exit

// Construit la liste des comptes
function XHTML_AccountList() {
  Global $_MPM,$tpl,$_VAR; $_MPM['Serial'][] = 'XHTML_AccountList';

     $_MPM['BeginMixed'] = array
     (
          'ACCOUNT_ANOTHER'   => $_VAR['ACCOUNT_ANOTHER'],
          'LANG_ACCOUNT_11'   => $_VAR['LANG_ACCOUNT_11'],
          'LANG_ACCOUNT_12'   => $_VAR['LANG_ACCOUNT_12'],
          'LANG_ACCOUNT_13'   => $_VAR['LANG_ACCOUNT_13'],
          'LANG_ACCOUNT_14'   => $_VAR['LANG_ACCOUNT_14'],
          'LANG_ACCOUNT_22'   => $_VAR['LANG_ACCOUNT_22']
    );
    XHTML_SetFile('form_book_add_account.tpl','',0);

    $tpl->set_block('FILE_form_book_add_account.tpl', 'BOUCLE_SELECT_BOOK', 'BLOCK_form_book_add_account.tpl');
        sort($_VAR['ACCOUNT_NAME']);
        while(list($key,$val)=each($_VAR['ACCOUNT_NAME'])) {

        $tpl->set_var(array(
          'VALUE_COMPTE'   => $val,
          'NAME_COMPTE'    => $val,
          'SELECTED'       => isset($GLOBALS['_POST']['detail_compte']) && $GLOBALS['_POST']['detail_compte'] == $val
                                     ? $select = ' selected="selected"' : $select = ''
        ));
        $tpl->parse('BLOCK_form_book_add_account.tpl','BOUCLE_SELECT_BOOK',true);
        }

   $_MPM['BoucleMixed'] = array
   (
     'CONTINUE'  => $_VAR['CONTINUE'],
     'SELECTED'  => isset($GLOBALS['_POST']['detail_compte']) && $GLOBALS['_POST']['detail_compte'] == $_VAR['ACCOUNT_ANOTHER']
                        ? $selected = ' selected="selected"' : $select = ''
   );
   $_MPM['BeginMixed'] = array_merge($_MPM['BeginMixed'],$_MPM['BoucleMixed']);
return XHTML_SetFile('form_book_add_account.tpl',$_MPM['BeginMixed'],3);
} ## end of XHTML_AccountList

// Affiche un message javascript avec deux choix possibles
// en terme de redirection
// @param $message       = the message to display
// @param $location1     = url if ok
// @param $location2     = url if false
function XHTML_RedirectJs($message,$location1,$location2) {
  Global $_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_RedirectJs($message,$location1,$location2)";
     $_MPM['BeginMixed'] = array
     (
        'MESSAGE_JS_CONFIRM' => $message,
        'LOCATION_1'         => $location1,
        'LOCATION_2'         => $location2
     );
     XHTML_SetFile('js_confirm.tpl',$_MPM['BeginMixed'],2);
} ## end of XHTML_RedirectJs

// Recherche Si un compte existe deja
// premiere utilisation et redirige en consequence
function XHTML_VerifAccount() {
  Global $_MPM,$_VAR; $_MPM['Serial'][] = 'XHTML_VerifAccount';
  if (!SQL_IdAccount('')) {
    XHTML_RedirectJs
    (
      sprintf($_VAR['MESSAGE_JS']['JS_VERIF_ENTER'],$_MPM['name'].' '.$_MPM['header_VERSION'].' '.$_MPM['version'],$_MPM['name'].' '.$_MPM['header_VERSION'].' '.$_MPM['version']),
      $_MPM['http'][1].'?opt=new',
      $_MPM['http'][0]
    );
  }
} ## end of XHTML_VerifAccount

// construit le menu de la home et des nouveaux utilisateurs
function XHTML_DisplayLogin() {
   Global $sess,$sess_challenge,$_MPM,$_VAR; $_MPM['Serial'][] = 'XHTML_DisplayLogin';

     ## CHALLENGE FOR PASSWORD
     $sess_challenge = isset($sess_challenge) && is_object($sess) && $sess->is_registered('sess_challenge') ? $sess_challenge : '';
     if ($sess_challenge == '') {
       $sess_challenge = md5(uniqid($_MPM['magic']));
     $sess->register("sess_challenge");
     }

     ## Build header
     XHTML_header(1,0,0,0,0,0,1,1);
//     XHTML_header(1,0,0,1,1,1,1,1);

     ## for the message error
     $error = '';
     if (isset($_MPM['message'])) {
          if ($_MPM['message'] == 1) $error = $_VAR['ACCUEIL'];
          if ($_MPM['message'] == 2) $error = $_VAR['OPTION_HOME_ENTER'];
          if ($_MPM['message'] == 3) $error = $_VAR['SESSION_TIMER'];
          if ($_MPM['message'] == 4) $error = str_replace("\\n",'<br />',sprintf($_VAR['JS_DYNAMIQUE_51'],__VERSION_PHP__));
     }

         $_MPM['BeginMixed'] = array
         (
          'MESSAGE'         => $error,
          'ACCES'           => $_MPM['translate_acces'],
          'URL_LOGIN'       => $_MPM['file_login'],
          'JS_MD5'          => $_MPM['file_md5'],
          'DOC_OPEN_SOURCE' => $_VAR['DOC_OPEN_SOURCE'],
          'MAGIC'           => $sess_challenge
         );

     if (isset($GLOBALS['_GET']['op']) && $GLOBALS['_GET']['op'] == 'Signup') {
         $_MPM['BoucleMixed'] = array
         (
          'CHOIX_LOGIN'     => $_VAR['CHOIX_LOGIN'],
          'CHOIX_FIRST_NAME'=> $_VAR['CHOIX_FIRST_NAME'],
          'CHOIX_LAST_NAME' => $_VAR['CHOIX_LAST_NAME'],
          'CHOIX_EMAIL'     => $_VAR['CHOIX_EMAIL'],
          'CHOIX_PASS_1'    => $_VAR['CHOIX_PASS_1'],
          'CHOIX_PASS_2'    => $_VAR['CHOIX_PASS_2'],
          'HTTP_REFERER'    => isset($GLOBALS['_SERVER']['HTTP_REFERER']) ? $GLOBALS['_SERVER']['HTTP_REFERER'] : ''
         );
     $_MPM['BeginMixed'] = array_merge($_MPM['BeginMixed'],$_MPM['BoucleMixed']);
     XHTML_SetFile('form_new_user.tpl',$_MPM['BeginMixed'],2);
     } else {
         $_MPM['BoucleMixed'] = array
         (
          'PASSWORD'        => $_VAR['PASSWORD'],
          'LOGIN'           => $_VAR['LOGIN'],
          'ENTER'           => $_VAR['ENTER']
         );
     $_MPM['BeginMixed'] = array_merge($_MPM['BeginMixed'],$_MPM['BoucleMixed']);
     XHTML_SetFile('form_login.tpl',$_MPM['BeginMixed'],2);
     }
} ## end of XHTML_DisplayLogin

// construit le menu gauche et droit et les graphiques
// @param $id_pays       = l'id du pays
// @param $this_pays     = l'id pays modifier
// @param $this_graph    = le choix du graphique
// @param $change_graph  = le nouveau choix de graphique
function XHTML_ConstMiddle($id_pays,$this_pays,$this_graph,$change_graph) {
  Global $sess,$sess_pid,$langs,$_VAR,$_MPM; $_MPM['Serial'][] = "XHTML_ConstMiddle($id_pays,$this_pays,$this_graph,$change_graph)";

  $sess_pid = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
  if ($sess_pid != '') {
      if ($change_graph != '' && $this_graph != $change_graph) SQL_UpdateUser(1,SQL_Clean($change_graph),'',$sess_pid);
      if ($this_pays != '')    $id_pays    = $this_pays;
      if ($change_graph != '') $this_graph = $change_graph;
  return XHTML_SetFile('menu_home.tpl',array('GRAPHIQUE' => SQL_HomeGraph(SQL_Clean($id_pays),SQL_Clean($this_graph))),1);
  }
} ## end of XHTML_ConstMiddle

// Verifie si une nouvelle version existe
// @param $redirect_url = la page courante
function XHTML_CheckAppli($redirect_url) {
Global $sess,$sess_check,$_MPM,$tools,$_VAR; $_MPM['Serial'][] = "XHTML_CheckAppli($redirect_url)";
Global $OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI;

   $url     = $_MPM['external_check'];
   $no_sess = 0;
   $open    = MPM_fopen($url);

    ## 1. verifie the connection
    if (!$tools->verif_connect()) {
      if (defined('PHP_HOSTCONNECT') && PHP_HOSTCONNECT == 1) {
         $OPTION_CONFIG       = isset($OPTION_CONFIG) ? $OPTION_CONFIG : 0;
         $OPTION_SAUV_AUTO    = isset($OPTION_SAUV_AUTO) ? $OPTION_SAUV_AUTO : 0;
         $OPTION_NEW_APPLI    = 0;
      XHTML_DisplayJs(sprintf($_VAR['JS_PHP_HOSTCONNECT'],$_MPM['name'],$_VAR['OPTION_BEGIN']['NEW_APPLI']));
      echo XHTML_CreateFileUser($OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI);
      $no_sess = 1;
      } else {
        XHTML_DisplayJs($_VAR['OPTION_BEGIN']['NEW_APPLI']."\\n".$_VAR['LANG_OPTION_TAUX']);
      }
    }
    ## 2. verifier si le fichier existe
    else if (!$open) {
     XHTML_DisplayJs(sprintf($_VAR['JS_PARSER_XML_5'],basename($url)));
    }
    ## 3. OK verif here
    else if ($open) {
       $fps = fopen($url,'r');
       if($fps) {
         $vs = fgets($fps,4096);
          ## Message because new version
          if ($_MPM['version'] != 'cvs-version' && $vs != '' && $_MPM['version'] != $vs) {
              XHTML_RedirectJs
              (
                 sprintf($_VAR['JS_DYNAMIQUE_57'],$_MPM['name']),
                 $_MPM['external_down'],
                 $redirect_url
              );
          } ## end of if ($_MPM['version'] != $version_checked)
       fclose($fps);
       } ## end if $fps
    } ## end of else if (MPM_fopen($url))
 if ($no_sess == 0) { $sess_check = 1; $sess->register('sess_check'); }
} ## end of XHTML_CheckAppli

// Création du fichier de configuration personnel
// @param $option1 = Permet d'avoir une sauvegarde en automatique (0 = OFF , 1 = ON)
// @param $option2 = Permet de supprimer les vieilles sauvegardes (0 = OFF , 1 = ON)
// @param $option3 = Permet de vérifier les nouvelles versions    (0 = OFF , 1 = ON)
function XHTML_CreateFileUser($option1,$option2,$option3) {
  Global $sess,$sess_pid,$_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_CreateFileUser($option1,$option2,$option3)";

   $sess_pid = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
   if ($sess_pid != '') {
        $_MPM['BeginMixed'] = array
        (
           'BEGIN_PHP'                => '<?php',
           'LANG_OPTION_CONFIG'       => $_VAR['LANG_OPTION_CONFIG'],
           'LANG_OPTION_SAUV_AUTO'    => $_VAR['LANG_OPTION_SAUV_AUTO'],
           'LANG_OPTION_NEW_APPLI'    => $_VAR['LANG_OPTION_NEW_APPLI'],
           'OPTION_CONFIG'            => $option1 == '' ? 0 : $option1,
           'OPTION_SAUV_AUTO'         => $option2 == '' ? 0 : $option2,
           'OPTION_NEW_APPLI'         => $option3 == '' ? 0 : $option3
         );

         ## Ajout de is_writable afin de verifier avant le mkdir
         ## evite le warning sur mkdir
         $exist = MPM_is_dir(__NIV__.'/'.$_MPM['dir_dump'],md5($sess_pid));

         if (!$exist && is_writable(__NIV__.'/'.$_MPM['dir_dump'])) {
              mkdir($_MPM['dir_dump'].''.md5($sess_pid), 0755);
         $exist = true;
         }

         if ($exist) {
            $fichier = $_MPM['dir_dump'].''.md5($sess_pid).'/'.md5($sess_pid).'.php';

              if (!($fc = fopen($fichier, 'w'))) {
                   return XHTML_ChmodError();
              } else {
                   $w = fwrite($fc,XHTML_SetFile('user_config.tpl',$_MPM['BeginMixed'],1));
                   fclose($fc);
              }
         } else {
              return XHTML_ChmodError();
         }
     }
} ## end of XHTML_CreateFileUser

# --------------------------*- MENU SELECT (NO TEMPLATE BECAUSE MORE SPEED) -*---------------------

// construit les menu select
// non utilisation des template car vraiment trop long
// @param $choice        = This choice for select
// @param $cle           = l'id a chercher (country,lang,day)
// @param $tab           = le tableau ou l'on recherche
function XHTML_Select($choice,$cle,$tab) {
  Global $_MPM,$langs,$_VAR; $_MPM['Serial'][] = "XHTML_Select($choice,$cle,$tab)";

     if (isset($choice) && $choice == 1) {
          $_class   = 'Graphique';
          $_name1   = 'CHANGE_COUNTRY';
          $_js      = 'this.form.submit();';
          $_name2   = $_VAR['LANG_HOME_GRAPH_1'];
     } else if (isset($choice) && $choice == 2) {
          $_class   = 'Language';
          $_name1   = 'MODIF_CLE_LANG';
          $_js      = 'return Verif_MOUV_LANG(this.form);';
          $_name2   = $_VAR['LANG_OPTION_ADD'];
     } else if (isset($choice) && $choice == 3) {
          $_class   = 'iewidthMoins';
          $_name1   = 'The_mois';
          $_js      = 'return Verif_MOUV_DATE(this.form);';
          $_name2   = $_VAR['LANG_CRITERIAS'];
          $_name3   = $_VAR['LANG_OPERATE_PENDING'];
     }

    $selt  = "\r\n";
    $selt .= "\t\t<select class=\"".$_class."\" size=\"1\" name=\"".$_name1."\" onchange=\"".$_js."\">\n";
    $selt .= "\t\t<option value=\"\">".$_name2."</option>\n";

    if (isset($choice) && $choice == 3) {
      $_value3 = 'CRITERIAS';
      $_s = $_value3 == $cle ? ' selected="selected"' : '';
    $selt .= "\t\t<option value=\"".$_value3."\"".$_s.">".$_name3."</option>\n";
    }

    if (isset($choice)) {
      if (is_array($tab)) {
         foreach($tab as $f) {
         $f = explode("|",$f);

             ## SELECT THE MENU FOR CHOICE THE MONEY COMPARAISON
             if ($choice == 1) {
                  $v = $f[0];
                  $n = "".$f[1]." (1 ".$_VAR['IMG_TXT_EUROS']." = ".$f[2]." ".$f[3].")";
                  $s = $f[0] == $cle ? ' selected="selected"' : '';
             }
             ## SELECT THE MENU FOR CHOICE THE LANGUAGE
             else if ($choice == 2) {
                  $v = $f[2];
                  $n = !file_exists($_MPM['dir_lang'].''.$f[1])
                             ? $_VAR['THIS_LANG'][$f[2]].' ['.$langs->Charset_need($f[2],2).'] ('.$_VAR['DOC_LANG_PHPDOC_8'].')'
                             : $_VAR['THIS_LANG'][$f[2]].' ['.$langs->Charset_need($f[2],2).']';
                  $s = $f[2] == $cle ? ' selected="selected"' : '';
             }
             ## SELECT THE MENU FOR DISPLAY THE DAY FOR ACCOUNT
             else if ($choice == 3) {
                  $v = "$f[0]-$f[1]";
                  $n = $_VAR['LANG_ACCOUNT_29']." : ".$_VAR['THIS_MONTH'][$f[0] - 1]." $f[1]";
                  $s = $v == $cle ? ' selected="selected"' : '';
             }
         $selt .= "\t\t<option value=\"".$v."\"".$s.">".$n."</option>\n";
         } ## end of foreach
       } ## end of is_array()
    } ## end of if isset
  $selt .= "\t\t</select>\r";
return $selt;
} ## end of XHTML_Select

// construit les menu select des annees et des mois
// non utilisation des template car vraiment trop long
// @param $choice        = This choice for select
// @param $cle           = l'id a chercher (country,lang,day)
// @param $tab           = le tableau ou l'on recherche
// @param $_name1        = le nom qui sera envoyer
function XHTML_SelectYearMonth($choice,$cle,$tab,$_name1) {
  Global $_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_SelectYearMonth($choice,$cle,$tab,$_name1)";

    if (isset($choice) && $choice == 1) {
      $_name2 = $_VAR['LANG_ACCOUNT_28'];
      $_class = 'ChoixYear';
      $_js    = '';
    }
    else if (isset($choice) && $choice == 2) {
      $_name2 = $_VAR['LANG_CALEND_DIS_0'];
      $_class = 'ChoixYear';
      $_js    = '';
    }
    else if (isset($choice) && $choice == 3) {
      $_name2 = '';
      $_class = 'Days';
      $_js    = '';
    }
    else if (isset($choice) && $choice == 4) {
      $_name2 = $_VAR['LANG_CALEND_DIS_0'];
      $_class = 'ChoixYearPlus';
      $_js    = ' onchange="return Verif_Year();"';
    }

    $selt  = "\r\n";
    $selt .= "\t\t\t<select class=\"".$_class."\" size=\"1\" name=\"".$_name1."\"".$_js.">\n";
    if (isset($choice) && $choice != 3) {
    $selt .= "\t\t\t<option value=\"\">".$_name2."</option>\n";
    }

    if (isset($choice)) {
      if (is_array($tab)) {
         foreach($tab as $f) {
             // SELECT THE MONTH FOR BALANCE
             if ($choice == 1) {
                  $v = $f;
                  $n = $_VAR['THIS_MONTH'][$f-1];
                  $s = $f == $cle ? ' selected="selected"' : '';
             }
             // SELECT THE YEAR FOR BALANCE
             else if ($choice == 2) {
                  $v = $f;
                  $n = $f;
                  $s = $f == $cle ? ' selected="selected"' : '';
             }
             // SELECT THE DAYS FOR BALANCE
             else if ($choice == 3) {
                  $v = $f;
                  $n = $f;
                  $s = $f == $cle ? ' selected="selected"' : '';
             }
             // SELECT THE YEAR FOR OPERATE
             else if ($choice == 4) {
                  $v = $f;
                  $n = $f;
                  $s = $f == $cle ? ' selected="selected"' : '';
             }
           if (isset($choice) && $choice == 4) {
             $selt .= "\t\t\t<option value=\"".$v."\"".$s."> + --- ".$n."</option>\n";
           } else {
             $selt .= "\t\t\t<option value=\"".$v."\"".$s.">".$n."</option>\n";
           }
         } ## end of foreach

         if (isset($choice) && $choice == 4) {
           $selt .= "\t\t\t<option value=\"".$_VAR['SIMUL_FORM_9']."\"> + --- ".$_VAR['SIMUL_FORM_9']."</option>\n";
         }

       } ## end of is_array()

    } ## end of if isset
  $selt .= "\t\t\t</select>\r";
return $selt;
} ## end of XHTML_SelectYearMonth

// construit le menu select des graphiques de la home
// non utilisation des template car vraiment trop long
// @param $this_graph = le choix du graphique
// @param $id_pays    = l'id pays selectionner
function XHTML_ConstrucGraph($id_pays,$this_graph) {
  Global $sess,$sess_pid,$_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_ConstrucGraph($id_pays,$this_graph)";

   $sess_pid = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
   if ($sess_pid != '') {
       $_class   = 'Graphique';
       $_name1   = 'CHANGE_GRAPHIQUE';
       $_js      = 'this.form.submit();';
       $_value   = 'default';
       $_name2   = "...................... ".$_VAR["LANG_HOME_GRAPH_6"]." ......................";

       $sel = "\r\n";
       $sel .= "\t\t<select class=\"".$_class."\" size=\"1\" name=\"".$_name1."\" onchange=\"".$_js."\">\n";
       $sel .= "\t\t<option value=\"".$_value."\">".$_name2."</option>\n";

       if (__DISPLAY_EURO__ == 0 || __DISPLAY_EURO__ == 1) {

       $sel .= "\t\t<option value=\"\"> </option>\n";
       $sel .= "\t\t<option value=\"\">--------------------- ".$_VAR["IMG_TXT_EUROS"]." ------------------------</option>\n";
       $sel .= "\t\t<option value=\"\"> </option>\n";

            $s = sizeof($_VAR["SELECT_GRAPHIQUE"]);       
            for ($i=1; $i < $s; $i++) {
              $name   = "+--- ".$_VAR["SELECT_GRAPHIQUE"][$i];
              $selec  = $this_graph == $i ? ' selected="selected"' : '';
              $sel   .= "\t\t<option value=\"$i\"".$selec.">".$name."</option>\n";
            }

       } ## end __DISPLAY_EURO__

       if (__DISPLAY_EURO__ == 1 || __DISPLAY_EURO__ == 2) {

       $sel .= "\t\t<option value=\"\"> </option>\n";
       $sel .= "\t\t<option value=\"\">--------------------- ".$_VAR["THIS_COUNTRY"][$id_pays]["MONEY"]." ------------------------</option>\n";
       $sel .= "\t\t<option value=\"\"> </option>\n";

            $s = sizeof($_VAR["SELECT_GRAPHIQUE"]); 
            for ($j=1; $j < $s; $j++) {
              $name   = "+--- ".$_VAR["SELECT_GRAPHIQUE"][$j];
              $selec  = ($this_graph == "".$j."00") ? ' selected="selected"' : '';
              $sel   .= "\t\t<option value=\"".$j."00\"".$selec.">".$name."</option>\n";
            }
       } ## end __DISPLAY_EURO__
       $sel .= "\t\t<option value=\"\"> </option>\n";
       $sel .= "\t\t</select>\r";
   return $sel;
   }
} ## end of XHTML_ConstrucGraph

// Affichage du menu deroulant permettant de modifier le compte de destination
// @param $id       = numero de compte
function SQL_ChangeAccount($id) {
  Global $sess,$sess_pid,$_MPM,$tools,$db,$_VAR; $_MPM['Serial'][] = "SQL_ChangeAccount($id)";

    $sess_pid = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
    if ($sess_pid != '') {
         $db->query (
               "SELECT ACCOUNTID,ACCOUNT
               FROM ".$_MPM['table'][2]."
               WHERE USERID='$sess_pid'
               AND ACCOUNTID <> '$id'
               ORDER BY ACCOUNT ASC"
         );

         $_class  = 'Medium';
         $_name1  = 'MODIF_IF_ACCOUNT';
         $_name2  = $_VAR['LANG_CALEND_DIS_9'];

         $sel = "\r\n";
         $sel .= "\t\t<select class=\"".$_class."\" size=\"1\" name=\"".$_name1."\">\n";
         $sel .= "\t\t<option value=\"\">".$_name2."</option>\n";

         while ($db->next_record()) {
             $sel .= "\t\t<option value=\"".$db->f('ACCOUNTID')."\">". $tools->Reduit_chaine($db->f('ACCOUNT'),__LENGTH_ACCOUNT__,0)."</option>\n";
         }
         $sel .= "\t\t</select>\r";
       return $sel;
    } ## end of ($sess_pid != '')
} ## end of SQL_ChangeAccount

// liste les fichiers d'un repertoire necessaire pour option
// @param $direction = chemin d'installation
// @param $opt = champs hidden le name
// @param $val = champs hidden la value
// @param $nbr = la valeur du select (value)
// @param $multitle = multiple selection
// @param $multitle = change le nom du js pour le multiple
// @param $mulsize = la taille du select
// @param $multname = le nom du select
function XHTML_ListDir($directory,$opt,$val,$multitle,$jsmultiple,$mulsize,$multname) {
 Global $sess,$sess_pid,$_MPM,$tpl,$_VAR; $_MPM['Serial'][] = "XHTML_ListDir($directory,$opt,$val,$multitle,$jsmultiple,$mulsize,$multname) ";

    $sess_pid = isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid') ? $sess_pid : '';
    if ($sess_pid != '') {
         $sel  = '<form method="post" action="'.$_MPM['http'][7].'" id="option_file" onsubmit="return Verif_OP_FILE'.$jsmultiple.'(this);" enctype="multipart/form-data">';
         $sel .= '<div class="centered">';
         $sel .= '<input type="hidden" name="THIS_SCROLLING" value="YES" />';
         $sel .= '<input type="hidden" name="'.$opt.'" value="'.$val.'" />';
         $sel .= '<select class="Dates" name="valide_sauvegarde'.$multitle.'" size="'.$mulsize.'"'.$multname.'>';
         $sel .= '<option value="">'.$_VAR['OPTION_OPEN_FILE'].'</option>';

        ## Ajout de is_writable afin d'eviter le warning et la notice error
        $exist = MPM_is_dir($_MPM['dir_dump'],md5($sess_pid));
        if ($exist && is_writable("$directory".md5($sess_pid))) {
                $File = array();
                $Dir = opendir("$directory".md5($sess_pid));
                while($tmp = readdir($Dir)) $File[] = "$tmp";
                closedir($Dir);
                rsort($File); next($File); next($File);  reset($File);

           while($tmp = each($File))
           if (stripos($tmp[1],'_'.md5($sess_pid).'.sql') !== false) {

           $tmps = '';
           $tmps = str_replace('_'.md5($sess_pid).'.sql','',$tmp[1]);
           $sel .= '<option value="'.$directory.''.md5($sess_pid).'/'.$tmp[1].'"> +------ '.$tmps.' </option>';
           }
        } ## end of $exist

         $sel .= '</select>';
         $sel .= '&nbsp;<input class="Submit" type="submit" value="'.$_VAR['CONFIRMER'].'" />';
         $sel .= '&nbsp;<input class="Submit" type="button" value="'.$_VAR['ANNULER'].'" onclick="Change_objet_option(\\\'\\\',\\\'parent2\\\',\\\'here2\\\',\\\'\\\');Vide_option();" />';
         $sel .= '</div></form><br />';

    echo $sel;
    } ##end of $sess_pid
} ## end of XHTML_ListDir

// Affiche un message en javascript
// @param $message       = the message to display
function XHTML_DisplayJs($message) {
  Global $_MPM; $_MPM['Serial'][] = "XHTML_DisplayJs($message)";
    XHTML_SetFile('js_message.tpl',array('MESSAGE_JS_SIMPLE' => $message),2);
} ## end of XHTML_DisplayJs

// Affiche un message en hr2
// @param $message       = the message to display
function XHTML_DisplayHr($message) {
  Global $_MPM; $_MPM['Serial'][] = "XHTML_DisplayHr($message)";
     echo '<h2 class="center">'.$message.'</h2><br />';
} ## end of XHTML_DisplayJs

// Afficher les images croissant decroissant
// @param $name      = le nom de la variable
// @param $asc       = croissant (doit contenir un "_" ex: ASC_0)
// @param $desc      = decroissant (doit contenir un "_" ex: DESC_0)
// @param $multiple  = si besoin de differencier plusieurs box sur la meme page
function XHTML_ASC_DESC($name,$asc,$desc,$multiple) {
 Global $_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_ASC_DESC($name,$asc,$desc,$multiple)";

   if (isset($GLOBALS['_POST']['order'.$multiple.''][$name]) && stristr($GLOBALS['_POST']['order'.$multiple.''][$name], 'asc')) {
      $img = '<input type="image" name="orderby'.$multiple.'['.$name.'='.$desc.']" src="?flag=help_bas" alt="'.$_VAR['DESC_ORDER'].'" title="'.$_VAR['DESC_ORDER'].'" />';
   }
   else if (isset($GLOBALS['_POST']['order'.$multiple.''][$name]) && stristr($GLOBALS['_POST']['order'.$multiple.''][$name], 'des')) {
      $img = '<input type="image" name="orderby'.$multiple.'['.$name.'='.$asc.']" src="?flag=help_haut" alt="'.$_VAR['ASC_ORDER'].'" title="'.$_VAR['ASC_ORDER'].'" />';
   }
   else {
      $img = '<input type="image" name="orderby'.$multiple.'['.$name.'='.$desc.']" src="?flag=help_bas" alt="'.$_VAR['DESC_ORDER'].'" title="'.$_VAR['DESC_ORDER'].'" />';
   }
if (__ORDER_BY__) return $img;
} ## end of XHTML_ASC_DESC

// Afficher les images ouvrir fermer
function XHTML_OPEN_CLOSE() {
 Global $_MPM,$_VAR; $_MPM['Serial'][] = "XHTML_OPEN_CLOSE()";
   $lay  = '<a href="javascript:void(0)" onclick="table_hidden();return false;">';
   $lay .= '<img src="'.$_MPM['dir_image'].''.$_MPM['help_reduit'].'" height="11" width="11" alt="'.$_VAR['HELPER_SMALL'].'" title="'.$_VAR['HELPER_SMALL'].'" /></a>&nbsp;';
   $lay .= '<a href="javascript:void(0)" onclick="table_show();return false;">';
   $lay .= '<img src="'.$_MPM['dir_image'].''.$_MPM['help_open'].'" height="11" width="11" alt="'.$_VAR['HELPER_OPEN'].'" title="'.$_VAR['HELPER_OPEN'].'" /></a>&nbsp;';
   $lay .= '<a href="javascript:void(0)" onclick="table_close();return false;">';
   $lay .= '<img src="'.$_MPM['dir_image'].''.$_MPM['help_close'].'" height="11" width="11" alt="'.$_VAR['HELPER_CLOSE'].'" title="'.$_VAR['HELPER_CLOSE'].'" /></a>';
if (__OPEN_CLOSE__) return $lay;
} ## end of XHTML_OPEN_CLOSE

// Affiche un message si probleme de droit sur les repertoires
function XHTML_ChmodError() {
 Global $_MPM,$_VAR; $_MPM['Serial'][] = 'XHTML_ChmodError';

  $textes = sprintf("<h3 class=\"center\">".$_VAR['LANG_FUNCTION']."</h3>",basename($_MPM['dir_dump']));
  if (__DEBUG_CHMOD__ == 1) return $textes;
  else if (__DEBUG_CHMOD__ == 2) MPM_TestHandler($textes,"Error");
  else if (__DEBUG_CHMOD__ == 3) {
       return $textes;
   MPM_TestHandler($textes,'Error');
  }
} ## end of XHTML_ChmodError
Return current item: MyPhpMoney