Location: PHPKode > projects > MyPhpMoney > myphpmoney_2.0/public_html/option.php
<?php
/**
 * $Id: option.php 410 2007-04-19 18:37:58Z 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/
 */

if (!defined('__OPTION_CONFIG__')) {
    define('__OPTION_CONFIG__', 'YES');

/**
 * INCLUDE FILE
 */
     require 'config/settings.inc.php';

/**
 * ENTER IN THE SESSION OR BUILD THE LOGIN FORM
 */
   if (SQL_VerifSession()) {

/**
 * DEFINE THE PATH
 */
     if (!isset($_MPM['DirUser'])) $_MPM['DirUser'] = MPM_is_dir($_MPM['dir_dump'],md5($sess_pid));
     $chemin = dirname(__FILE__).'/'.$_MPM['dir_dump'].''.md5($sess_pid);

/**
 * DELETE THE USER AND ALL THE ACCOUNT (OPTION DELETE)
 */
     if (isset($_POST['USER_DEL']) && $_POST['USER_DEL'] == 'on') {
         SQL_Record(0);
          MPM_DelDump($chemin);

        if ($_MPM['DirUser'] && file_exists($chemin.'/'.md5($sess_pid).'.php')) {
            unlink($chemin.'/'.md5($sess_pid).'.php');
            rmdir($chemin);
        }
     $sess->unregister('sess_pid'); $sess->unregister('sess_user');
     } ## end of if (!isset($_POST['USER_DEL'])

/**
 * DOWNLOAD THE DUMP FILE
 */
     if (isset($_POST['valide_sauvegarde']) && $_POST['valide_sauvegarde'] != '' && isset($_POST['telecharger']) && $_POST['telecharger'] == 1) {
      $fichier = str_replace($_MPM['dir_dump'].''.md5($sess_pid).'/','',$_POST['valide_sauvegarde']);
          $tools->Construc_header($fichier);
          echo MPM_ReadFile($_POST['valide_sauvegarde']);
     exit;
     }
   } ## end First SQL_VerifSession (for USER_DEL)

/**
 * RE CHECK SESSION AND BUILD THE HEADER
 */
     if (SQL_VerifSession()) {

       XHTML_header(1,0,1,1,1,1,1,1);

 /**
 * MESSAGE FOR OPERA IMPOSSIBLE DISPLAY THE PAGE FOR THE MOMENT
 * BECAUSE OPERA PUT THE INCLUDE FILE IN THIS CACHE
 */
     if (stristr($_SERVER['HTTP_USER_AGENT'],'opera')) XHTML_DisplayJs($_VAR['MESSAGE_JS']['JS_OPERA']);

/**
 * FOR THE LANG OPTION IF ADD LANG (FILE OPTION.PHP)
 */
     if (isset($_MPM['lang_cle']))  XHTML_VerifAddLanguage($langs->Get_File($_MPM['lang_cle']));

/**
 * UPDATE THE TAUX MONETAIRE
 */
     if (isset($_POST['TAUX_MODIF']) && $_POST['TAUX_MODIF'] == 'on') XHTML_DisplayJs(XML_CheckUpdateXmlFiles());

/**
 * RECUP ACTION FOR THE LAYER DHTML -- COMMON.PHP
 */
 if (isset($_POST['CHAMPS_HIDDEN'])) {
     switch($_POST['CHAMPS_HIDDEN']) {
           case 1 : ## AUTOMATIQUE DUMP
              if ($_MPM['DirUser']) {
                MPM_DumpDays();
                    $OPTION_CONFIG = 1;
                    echo XHTML_CreateFileUser($OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI);
              }
      break;
           case 2 : ## STOP THE AUTOMATIQUE DUMP
                 MPM_DelDump($chemin);
              if ($_MPM['DirUser']) {
                    $OPTION_CONFIG = 0; $OPTION_SAUV_AUTO = 0;
                    echo XHTML_CreateFileUser($OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI);
              }
      break;
           case 3 : ## START DELETE AUTOMATIQUE
              if ($_MPM['DirUser']) {
                   $OPTION_SAUV_AUTO = 1;
                   echo XHTML_CreateFileUser($OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI);
              }
      break;
           case 4 : ## STOP DELETE AUTOMATIQUE
              if ($_MPM['DirUser']) {
                   $OPTION_SAUV_AUTO = 0;
                   echo XHTML_CreateFileUser($OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI);
              }
      break;
           case 5 : ## START CHECK APPLICATION
              if ($_MPM['DirUser']) {
                   $OPTION_NEW_APPLI = 1;
                   echo XHTML_CreateFileUser($OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI);
              if (!isset($sess_check)) XHTML_CheckAppli($_SERVER['PHP_SELF']);
              }
      break;
           case 6 : ## STOP CHECK APPLICATION
              if ($_MPM['DirUser']) {
                    $OPTION_NEW_APPLI = 0;
                    echo XHTML_CreateFileUser($OPTION_CONFIG,$OPTION_SAUV_AUTO,$OPTION_NEW_APPLI);
              }
      $sess->unregister('sess_check');
      break;
     }
  } ## end of of if (isset($_POST['CHAMPS_HIDDEN']))

/**
 * RECUP ACTION FOR THE TEMPLATE FORM
 */
if (isset($_POST['OPT'])) {
     switch($_POST['OPT']) {
           case 1 : ## MODIFIED THE PASSWORD
              SQL_VerifPass(md5($_POST['old_pass']),md5($_POST['News_Passe2']));
              unset($_POST['old_pass'],$_POST['News_Passe1'],$_POST['News_Passe2']);
      break;
           case 2 : ## INSERT INTO THE DUMP
              if ($_POST['valide_sauvegarde'] != '') SQL_InsertBackup($_POST['valide_sauvegarde']);
      break;
           case 3 : ## DELETE THE DUMP FILE
               if (isset($_POST['valide_sauvegarde']) && $_POST['valide_sauvegarde'] != '') {
                  if (is_array($_POST['valide_sauvegarde'])) {
                     while (list($keys,$vals) = each($_POST['valide_sauvegarde'])) {
                        if (MPM_is_dir($_MPM['dir_dump'],md5($sess_pid)) && file_exists($vals)) {
                          unlink($vals);
                        }
                     }
                  }
               }
      break;
     }
  } ## end of of if (isset($_POST['OPT']))

/**
 * INCLUDE DYNAMIQUE JAVASCRIPT (DON'T MOUVE - IMPORTANT)
 */
     MPM_DynamiqueJs();

/**
 * THE TEMPLATES -- BUILD THE FORM ACTION
 */
     $OPTION['CONFIG']        = $OPTION_CONFIG;
     $OPTION['SAUV_AUTO']     = $OPTION_SAUV_AUTO;
     $OPTION['NEW_APPLI']     = $OPTION_NEW_APPLI;

/**
 * THE TEMPLATES -- FIRST ELEMENT OF TEMPLATES FORM
 */

     $_MPM['BeginMixed'] = array
     (
     	     'LIST_LANGUAGE'     => XHTML_Select(2,$_MPM['lang_verif_id'],$langs->Get_List_file()),
             'SELF_OP'                => $_MPM['http'][7],
             'OPTION_MID_BEG'         => sprintf($_VAR['OPTION_MID_BEG'],$_MPM['name']),
             'LANG_BOOK_5'            => $_VAR['LANG_BOOK_5'],
             'LANG_BOOK_6'            => $_VAR['LANG_BOOK_6'],
             'LANG_BOOK_9'            => $_VAR['LANG_BOOK_9'],
             'LANG_BOOK_10'           => $_VAR['LANG_BOOK_10'],
             'OPTION_MID_BEG_1'       => sprintf($_VAR['OPTION_MID_BEG_1'],$sess_user),
             'UPDATES'                => $_VAR['UPDATES'],
             'LANG_OPTION_ADD_1'      => $_VAR['LANG_OPTION_ADD_1'],
             'LANG_OPTION_TAUX'       => $_VAR['LANG_OPTION_TAUX'],
             'MESSAGE_MIDDLE'         => $_VAR['MESSAGE_JS']['JS_BOOK_LISTING_1']
                                         .' '.$sess_user
                                         .' '.$_VAR['MESSAGE_JS']['JS_THIRD_BEGIN_DEL']
                                         .' : '.$_VAR['MESSAGE_JS']['JS_USER_DEL']
     );
     XHTML_SetFile('form_option_1.tpl',$_MPM['BeginMixed'],0);

     $tpl->set_block('FILE_form_option_1.tpl','BOUCLE_OPTION','BOUCLE');
     $j=0;
     while(list($name,$value)=each($_VAR['OPTION_BEGIN'])) {

        if ($name == 'SAUV_AUTO')      $descript = sprintf($_VAR['OPTION_BEGIN'][$name],__BACK_DAYS__);
        else if ($name == 'NEW_APPLI') $descript = $_VAR['OPTION_BEGIN'][$name].' ('.$_VAR['LANG_OPTION_TAUX'].')';
        else                           $descript = $_VAR['OPTION_BEGIN'][$name];

        $tpl->set_var(array(
                  'CHECKBOX_1'        => $name,
                  'MESSAGE_1'         => $_VAR['ACTION_BEGIN'][0],
                  'MESSAGE_2'         => $_VAR['ACTION_BEGIN'][1],
                  'DESCRIPTION'       => $descript,
                  'CHECKED_0'         => $OPTION[$name] == 1 ? ' checked="checked"' : '',
                  'CHECKED_1'         => $OPTION[$name] == 1 ? '' : ' checked="checked"',
                  'LAYER_BEGIN'       => $j,
                  'LAYER_BEGIN_PLUS'  => bcadd($j,1)
        ));
        $tpl->parse('BOUCLE','BOUCLE_OPTION',true);
     $j = 2 + $j++;
     }

/**
 * THE TEMPLATES -- END ELEMENT OF TEMPLATES FORM
 */
    XHTML_SetFile('form_option_2.tpl','',0);
    $tpl->set_block('FILE_form_option_2.tpl','BOUCLE_OPTION_PLUS','BOUCLE_PLUS');

         if (MPM_is_dir($_MPM['dir_dump'],md5($sess_pid)) && $OPTION_CONFIG != 0) {
             $i = 0;
             while(list($name_plus,$value_plus)=each($_VAR['OPTION_END'])) {

            $tpl->set_var(array(
                      'DESCRIPTION_PLUS'  => $_VAR['OPTION_END'][$name_plus],
                      'MESSAGE_PLUS'      => $_VAR['ACTION_END'][$name_plus],
                      'LAYER_BOUCLE'      => bcadd($i,100),
                      'NUMBER_CASE'       => $i
            ));
            $tpl->parse('BOUCLE_PLUS','BOUCLE_OPTION_PLUS',true);
            $i++;
            }
         $_MPM['BeginMixed'] = array('CONDITION_FORM' => XHTML_SetFile('form_option_2.tpl','',1));
         } else {
         $_MPM['BeginMixed'] = array('CONDITION_FORM' => '');
         }
     XHTML_SetFile('form_option_1.tpl',$_MPM['BeginMixed'],4);
     } else {
          XHTML_DisplayLogin();
     } ## end Second SQL_VerifSession

/**
 * BUILD THE FOOTER
 */
     XHTML_footer();
}
Return current item: MyPhpMoney