Location: PHPKode > projects > MyPhpMoney > myphpmoney_2.0/public_html/config/setup.inc.php
<?php
/**
 * $Id: setup.inc.php 409 2007-04-07 13:47:50Z 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/
 */

 # ------------------ POSSIBILITY USAGE _POST _GET _SERVER _ENV _REQUEST -- ----------------------

   if (isset($_SERVER) === TRUE) {
      $HTTP_SERVER_VARS  = $_SERVER;
      $HTTP_GET_VARS     = $_GET;
      $HTTP_POST_VARS    = $_POST;
      $HTTP_COOKIE_VARS  = $_COOKIE;
      $HTTP_POST_FILES   = $_FILES;
      $HTTP_ENV_VARS     = $_ENV;
   } else {
      $_SERVER           = $HTTP_SERVER_VARS;
      $_GET              = $HTTP_GET_VARS;
      $_POST             = $HTTP_POST_VARS;
      $_COOKIE           = $HTTP_COOKIE_VARS;
      $_FILES            = $HTTP_POST_FILES;
      $_ENV              = $HTTP_ENV_VARS;
   }
   ## Remove $_SESSION (no usage -> phplib)
   ## Becareful $_SESSION return notice with IIS
   $mpm = array($_SERVER,$_GET,$_POST,$_COOKIE,$_FILES,$_ENV);
   $num = count($mpm);
   for ($i = 0; $i < $num; $i++) {
      if (isset($mpm[$i]) && is_array($mpm[$i]) === TRUE) {
         reset($mpm[$i]);
         ## the ; is important (before - after)
         for (;list($key,$value) = each($mpm[$i]);) {
            $$key = $value;
         }
      }
   }

 # --------------------------- No REQUEST_URI (IIS example) ---------------------------------------

    if (!isset($_SERVER['REQUEST_URI'])) {
       $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
       if (!strpos($_SERVER['REQUEST_URI'], '?') && isset($_SERVER['QUERY_STRING']))
          $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
    }

 # ----------------------------------- CHECK THE CONFIG -------------------------------------------

   ## VERIFIED THE VERSION OF PHP
   if (version_compare(MPM_version_test(phpversion()),__VERSION_PHP__) < 0) {
          $_MPM['message'] = 4;
   $sess->unregister('sess_pid'); $sess->unregister('sess_user');
   }
   ## LOGIN
   else if (isset($sess_pid) && $sess_pid != '' && isset($sess_user) && $sess_user != '') {

       ## TIME OUT SESSION
       if ((isset($sess_time) && $sess_time != '') && ($sess_time < $_MPM['date_unix'])) {
               $_MPM['message'] = 3;
       $sess->unregister('sess_pid'); $sess->unregister('sess_user');
       }

       ## UPDATE THE COUNTRY
       if (isset($_POST['CHANGE_COUNTRY']) && $_POST['CHANGE_COUNTRY'] != '') {
            SQL_UpdateUser(2,SQL_Clean($_POST['CHANGE_COUNTRY']),$langs->Get_Lang($_POST['CHANGE_COUNTRY']),$sess_pid);
       }

       ## LANG IN OPTION
       if (isset($_POST['CHECK_LANG']) && is_array($_POST['CHECK_LANG'])) {
            $_MPM['lang_cle'] =  key($_POST['CHECK_LANG']);
       }

       ## MODIF LANG
       if (isset($_POST['MODIF_CLE_LANG']) && $_POST['MODIF_CLE_LANG'] != '') {
            SQL_UpdateUser(4,SQL_Clean($_POST['MODIF_CLE_LANG']),'',$sess_pid);
       }
   }
   ## LOGOUT
   else {
       ## FOR THE DOC USAGE
       if (isset($_POST['MODIF_CLE_LANG']) && $_POST['MODIF_CLE_LANG'] != '') {
           $sess_no_enter = $_POST['MODIF_CLE_LANG'];
       $sess->register('sess_no_enter');
       }
   }

  # ----------------------- SEARCH THE LANGUAGE AND INCLUDE GOOD FILE ------------------------------
   ## USER (LOGIN)
   if (isset($sess_user) && $sess_user != '') {

      $db->query (
            "SELECT GRAPH,COUNTRY_VAL,LANG_VAL
            FROM ".$_MPM['table'][3]."
            WHERE LOGIN_NAME='$sess_user'"
      );
      $db->next_record();

      ## ENTER
      if ($db->num_rows() == 1) {
         $_MPM['lang_graph']       = $db->f('GRAPH');
         $_MPM['lang_id']          = $db->f('LANG_VAL');
         $_MPM['lang_country_id']  = $db->f('COUNTRY_VAL');
      } else {
      ## LOGOUT
         $_MPM['lang_id']          = $langs->Get_File_Verif($langs->detected_browser_languages,$langs->detected_browser_country);
         $_MPM['lang_country_id']  = $langs->Default_Country($_MPM['lang_id']);
      $sess->unregister('sess_pid'); $sess->unregister('sess_user');
      }
   } else if (isset($sess_no_enter) && $sess_no_enter != '') {
   ## LOGOUT AND LANG CHANGED
       $_MPM['lang_id']            = $langs->Get_File_Verif($sess_no_enter,$langs->Default_Country($sess_no_enter));
       $_MPM['lang_country_id']    = $langs->Default_Country($_MPM['lang_id']);
   } else {
   ## LOGOUT
       $_MPM['lang_id']            = $langs->Get_File_Verif($langs->detected_browser_languages,$langs->detected_browser_country);
       $_MPM['lang_country_id']    = $langs->Default_Country($_MPM['lang_id']);
   }

   ## INCLUDE THE FILE
   if ($_MPM['lang_id'] != $langs->default_id_lang && $_MPM['lang_country_id'] != $langs->default_id_Countries) {
   $langs->Include_File($langs->default_id_lang,$langs->default_id_Countries);
   $VAR_EN = $_VAR;
   }
   $langs->Include_File($_MPM['lang_id'],$_MPM['lang_country_id']);
   if (isset($VAR_EN)) {
      foreach ($_VAR as $cle => $value) {
         if ($value == '') { $_VAR[$cle] = $VAR_EN[$cle]; }
         else if (is_array($value)) {
            foreach ($value as $cle2 => $value2) {
               if ($value2 == '') { $_VAR[$cle][$cle2] = $VAR_EN[$cle][$cle2]; }
               else if (is_array($value2)) {
                  foreach ($value2 as $cle3 => $value3) {
                     if ($value3 == '') { $_VAR[$cle][$cle2][$cle3] = $VAR_EN[$cle][$cle2][$cle3]; }
                  }
               }
            }
         }
      }
   }

  # ------------------------ CHECK TAUX OF MONEY (LOGGING OR CALCULATE PAGE) ---------------------

   $_MPM['LocalRate']          = XML_GetRate($_MPM['export_local']);
   $_MPM['lang_euro']          = $_MPM['LocalRate'][2][$_MPM['lang_country_id']];

  # --------------------------------- NECESSARY VARIABLE FOR LANGUAGE -----------------------------

   $_MPM['lang_money_country'] = $langs->Translate_Money($_MPM['lang_country_id']);
   $_MPM['lang_verif_id']      = $langs->Get_File_Verif($_MPM['lang_id'],$_MPM['lang_country_id']);
   $_MPM['lang_file_name']     = $langs->Get_File($_MPM['lang_verif_id']);

 # --------------------------------- CHOICE FOR DISPLAY MONEY TYPE --------------------------------

   if (__DISPLAY_MODE__ == 5) {
      if (in_array($_MPM['lang_country_id'],$_MPM['zone_euro'])) define('__DISPLAY_EURO__',1);
      else if (in_array(221,$_MPM['zone_euro'])) define('__DISPLAY_EURO__',0);
      else define('__DISPLAY_EURO__',2);
   } else {
      define('__DISPLAY_EURO__',__DISPLAY_MODE__);
   }

 # --------------------------------- CHECK THE PERSONNAL CONFIG FILE ------------------------------

   ## ONLY IF LOGIN (BECAREFUL MUST BE AFTER THE INCLUDE LANG)
   if (isset($sess_user) && $sess_user != '') {

      ## ALTER THE TABLE MPM_acct
      if (isset($sess_pid) && $sess_pid != '') SQL_AlterOpen();

      if (!isset($_MPM['DirUser'])) $_MPM['DirUser'] = MPM_is_dir(__NIV__.'/'.$_MPM['dir_dump'],md5($sess_pid));
      $path_dump = dirname(dirname(__FILE__)).'/'.$_MPM['dir_dump'].''.md5($sess_pid);

      if (!isset($_POST['USER_DEL'])) {
           if ($_MPM['DirUser']) {
                 if (!file_exists($path_dump.'/'.md5($sess_pid).'.php')) {
                      $_MPM['chmod'] .= XHTML_CreateFileUser(0,0,1);
                 } else {
                     require_once $path_dump.'/'.md5($sess_pid).'.php';
                 }
           } else {
              $_MPM['chmod'] .= XHTML_CreateFileUser(0,0,1);
           }
       }
   }

 # ------------------------------------- AFFECT THE GLOBALS VALUE ---------------------------------

   $_MPM['URI_MPM']              = MPM_SearchUri();                              ## RECUP THE DYNAMIQUE URI
   $_MPM['DATE_DAYS']            = MPM_FormatDates($_MPM['date_days']);          ## RECUP THE ACTUEL DATE

 # --------------------------------- VARIABLE FOR GENERAL TEMPLATE --------------------------------

   $tpl->set_var(array(
         'IMG_ALT_OTHER'         => $langs->Translate_Country($_MPM['lang_country_id']),
         '_MONNAIE'              => __DISPLAY_EURO__ == 2 ? $_VAR['IMG_TXT_EUROS'] : $_MPM['lang_money_country'],
         'IMG_EUROS'             => __DISPLAY_EURO__ == 2 ? $_MPM['lang_country_id'] : '221',
         'IMG_TXT_EUROS'         => __DISPLAY_EURO__ == 2 ? $_MPM['lang_money_country'] : $_VAR['IMG_TXT_EUROS'],
         'IMG_ALT_EUROS'         => __DISPLAY_EURO__ == 2 ? $_MPM['lang_money_country'] : $_VAR['IMG_ALT_EUROS'],
         'LANG_BOOK_13'          => sprintf($_VAR['LANG_BOOK_13'],$_VAR['IMG_TXT_EUROS'],$_MPM['lang_money_country']),
         'LANG_BOOK_14'          => sprintf($_VAR['LANG_BOOK_14'],__DISPLAY_EURO__ == 2 ? $_MPM['lang_money_country'] : $_VAR['IMG_TXT_EUROS']),
         '_ID_PAYS'              => $_MPM['lang_country_id'],
         'IMAGES'                => $_MPM['dir_image'],
         'IMAGE_CONCEPT'         => $_MPM['img_concept'],
         'DOC_PHPDOC'            => $_MPM['translate_phpdoc'],
         'HTTP_CALCULATE'        => $_MPM['file_calculate'],
         'V.S'                   => $_MPM['version'],
         'URL_DOWNLOAD'          => $_MPM['external_down'],
         'TITLE'                 => $_MPM['name'],
         'IMG_MOUSE'             => $_MPM['img_mouse'],
         'ANOTHER_ABC'           => __ANOTHER_ACCOUNT__,
         'COLOR_DISPLAY_1'       => __COLOR_DISPLAY_1__,
         'COLOR_DISPLAY_2'       => __COLOR_DISPLAY_2__,
         'COLOR_SETPOINTER_1'    => __COLOR_SETPOINTER_1__,
         'COLOR_SETPOINTER_2'    => __COLOR_SETPOINTER_2__,
         'COLOR_SETPOINTER_3'    => __COLOR_SETPOINTER_3__,
         'COLOR_DESIGN_0'        => __COLOR_DESIGN_0__,
         'COLOR_DESIGN_1'        => __COLOR_DESIGN_1__,
         'COLOR_DESIGN_2'        => __COLOR_DESIGN_2__,
         'COLOR_DESIGN_3'        => __COLOR_DESIGN_3__,
         'COLOR_DESIGN_4'        => __COLOR_DESIGN_4__,
         'COLOR_DESIGN_5'        => __COLOR_DESIGN_5__,
         'COLOR_DESIGN_6'        => __COLOR_DESIGN_6__,
         'COLOR_DESIGN_7'        => __COLOR_DESIGN_7__,
         'COLOR_DESIGN_8'        => __COLOR_DESIGN_8__,
         'COLOR_DESIGN_9'        => __COLOR_DESIGN_9__,
         'COLOR_PHPDOC_1'        => __COLOR_PHPDOC_1__,
         'COLOR_PHPDOC_2'        => __COLOR_PHPDOC_2__,
         'COLOR_PHPDOC_3'        => __COLOR_PHPDOC_3__,
         'COLOR_PHPDOC_4'        => __COLOR_PHPDOC_4__,
         'COLOR_PHPDOC_5'        => __COLOR_PHPDOC_5__,
         'COLOR_PHPDOC_6'        => __COLOR_PHPDOC_6__,
         'COLOR_PHPDOC_7'        => __COLOR_PHPDOC_7__,
         'POPUP_NAME'            => __POPUP_NAME__,
         'POPUP_WIDTH'           => __POPUP_WIDTH__,
         'POPUP_HEIGHT'          => __POPUP_HEIGHT__,
         'ANNULER'               => $_VAR['ANNULER'],
         'CONFIRMER'             => $_VAR['CONFIRMER'],
         'LANG_ACCOUNT_1'        => $_VAR['LANG_ACCOUNT_1'],
         'LANG_ACCOUNT_2'        => $_VAR['LANG_ACCOUNT_2'],
         'LANG_ACCOUNT_3'        => $_VAR['LANG_ACCOUNT_3'],
         'LANG_ACCOUNT_4'        => $_VAR['LANG_ACCOUNT_4'],
         'LANG_ACCOUNT_5'        => $_VAR['LANG_ACCOUNT_5'],
         'LANG_ACCOUNT_6'        => $_VAR['LANG_ACCOUNT_6'],
         'LANG_ACCOUNT_7'        => $_VAR['LANG_ACCOUNT_7'],
         'LANG_ACCOUNT_8'        => $_VAR['LANG_ACCOUNT_8'],
         'SELF'                  => $_SERVER['PHP_SELF'],
         'NIVEAU'                => __NIV__ == '..' ? ''.__NIV__.'/' : '',
         'URI'                   => htmlspecialchars($_MPM['URI_MPM']),
         '_REQUEST_URI'          => (isset($_GET['op']) && $_GET['op'] == 'Logout')
                                       ? preg_replace('/\?op=Logout(.*)/i','',htmlspecialchars($_SERVER['REQUEST_URI']))
                                       : htmlspecialchars($_SERVER['REQUEST_URI'])
   ));

 # --------------------- DISPLAY THE YEAR - MONTH - DAY (IN THE GOOD LANGUAGE) --------------------

   $shuffle = new MPM_Calendar;                                                  ## INSTANCE THE CALENDAR
   $shuffle->setMonthNames($_VAR['THIS_MONTH']);
   $shuffle->setDayNames($_VAR['THIS_DAYS']);

    if (isset($_POST['S_date'])) {
     $s = explode('-',$_POST['S_date']);
       $annee = $s[2];
       $mois  = $s[1];
       $jour  = $s[0];
    } else if (isset($_GET['T_MOIS']) && $_GET['T_MOIS'] == 'ON') {
       $annee = $_GET['annee'];
       $jour  = $_MPM['date_gettime']['mday'];
       $mois  = isset($_GET['mois']) && $_GET['mois'] != ''
                    ? $_GET['mois']
                    : $_MPM['date_gettime']['mon'];
    } else if (isset($_GET['annee']) && isset($_GET['mois']) || isset($_GET['annee']) && isset($_GET['mois']) && isset($_GET['jour'])) {
       $annee = $_GET['annee'];
       $mois  = $_GET['mois'];
       $jour  = isset($_GET['jour']) && $_GET['jour'] != ''
                    ? $_GET['jour']
                    : $_MPM['date_gettime']['mday'];
    } else if (isset($_POST['annee']) && isset($_POST['mois']) && isset($_POST['jour'])) {
       $annee = $_POST['annee'];
       $mois  = $_POST['mois'];
       $jour  = $_POST['jour'];
    } else {
       $annee = $_MPM['date_gettime']['year'];
       $mois  = $_MPM['date_gettime']['mon'];
       $jour  = $_MPM['date_gettime']['mday'];
    }

   ## If date >= 2038
   if ($shuffle->getFirstDaysInMonth($mois,$annee) == -1) {
       $annee = $_MPM['date_gettime']['year'];
       $mois  = $_MPM['date_gettime']['mon'];
       $jour  = $_MPM['date_gettime']['mday'];
   }

   ## Put Zero before the month and days
   $jour = preg_replace('/^([1-9]){1}$/', '0\1', $jour);
   $mois = preg_replace('/^([1-9]){1}$/', '0\1', $mois);

   ## Number of days/month
   $Number_of_Days      = $shuffle->getDaysInMonth($mois,$annee);
Return current item: MyPhpMoney