Ignore:
Timestamp:
Feb 6, 2013, 9:05:25 PM (11 years ago)
Author:
Eric
Message:

Next version is 2.41.4 ready for publication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/trunk/admin/UAM_admin.php

    r19234 r20591  
    8383if (function_exists('set_fckeditor_instance'))
    8484{
    85                 $fcke_config = unserialize($conf['FCKEditor']);
     85  $fcke_config = unserialize($conf['FCKEditor']);
    8686  foreach($areas as $area)
    8787  {
    88                                 if (!isset($fcke_config[$area]))
     88    if (!isset($fcke_config[$area]))
    8989    {
    9090      $fcke_config[$area] = false;
    9191    }
    9292  }
    93                 $conf['FCKEditor'] = serialize($fcke_config);
    94 
    95                 set_fckeditor_instance($areas, $toolbar, $width, $height);
     93  $conf['FCKEditor'] = serialize($fcke_config);
     94
     95  set_fckeditor_instance($areas, $toolbar, $width, $height);
    9696}
    9797
     
    108108// +-----------------------------------------------------------------------+
    109109// *************************************************************************
    110                 case 'global':
    111 
    112                 if (isset($_POST['submit']) and isset($_POST['UAM_Mail_Info']) and isset($_POST['UAM_Username_Char']) and isset($_POST['UAM_Confirm_Mail']) and isset($_POST['UAM_Password_Enforced']) and isset($_POST['UAM_AdminPassword_Enforced']) and isset($_POST['UAM_GhostUser_Tracker']) and isset($_POST['UAM_Admin_ConfMail']) and isset($_POST['UAM_RedirToProfile']) and isset($_POST['UAM_GTAuto']) and isset($_POST['UAM_GTAutoMail']) and isset($_POST['UAM_CustomPasswRetr']) and isset($_POST['UAM_USRAuto']) and isset($_POST['UAM_USRAutoMail']) and isset($_POST['UAM_Stuffs']) and isset($_POST['UAM_HidePassw']) and isset($_POST['UAM_PwdReset']) and isset($_POST['UAM_RejectConnexion']))
    113                 {
    114 
    115     // Render email contents fields
    116     // ----------------------------
    117                                 $_POST['UAM_MailInfo_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_MailInfo_Text'])));
    118 
    119                                 $_POST['UAM_ConfirmMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Text'])));
    120 
    121                                 $_POST['UAM_GhostTracker_ReminderText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GhostTracker_ReminderText'])));
    122 
    123                                 $_POST['UAM_GTAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText'])));
    124 
    125                                 $_POST['UAM_GTAutoMailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMailText'])));
    126 
    127                                 $_POST['UAM_AdminValidationMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Text'])));
    128 
    129                                 $_POST['UAM_CustomPasswRetr_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomPasswRetr_Text'])));
    130 
    131                                 $_POST['UAM_USRAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText'])));
    132 
    133                                 $_POST['UAM_CustomRejectConnexion_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomRejectConnexion_Text'])));
    134 
    135                                 // Render email subjects fields
    136     // ---------------------------
    137                                 $_POST['UAM_ConfirmMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Subject'])));
    138 
    139                                 $_POST['UAM_ConfirmMail_Remail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Remail_Subject'])));
    140 
    141                                 $_POST['UAM_InfoMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_InfoMail_Subject'])));
    142 
    143                                 $_POST['UAM_GTAutoMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMail_Subject'])));
    144 
    145                                 $_POST['UAM_GTReminder_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTReminder_Subject'])));
    146 
    147                                 $_POST['UAM_AdminValidationMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Subject'])));
    148 
    149 
    150                                 // Check if emails are mandatory for registrations (needed for email exclusion option)
    151                                 // -----------------------------------------------------------------------------------
    152                                 if ($conf['obligatory_user_mail_address'])
    153                                 {
    154           // Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them
    155           // --------------------------------------------------------------------------------------
    156                   if (preg_match('/^[\s]+/', $_POST['UAM_MailExclusion_List']))
    157                   {
    158                   array_push($page['errors'], l10n('UAM_mail_exclusionlist_error'));
    159                   $UAM_Exclusionlist_Error = true;
    160                   }
    161                   }
    162                   elseif (!$conf['obligatory_user_mail_address'])
    163                   {
    164                   $_POST['UAM_MailExclusion_List'] = '';
    165                   }
     110  case 'global':
     111
     112  if (isset($_POST['submit']) and isset($_POST['UAM_Mail_Info']) and isset($_POST['UAM_Username_Char']) and isset($_POST['UAM_Confirm_Mail']) and isset($_POST['UAM_Password_Enforced']) and isset($_POST['UAM_AdminPassword_Enforced']) and isset($_POST['UAM_GhostUser_Tracker']) and isset($_POST['UAM_Admin_ConfMail']) and isset($_POST['UAM_RedirToProfile']) and isset($_POST['UAM_GTAuto']) and isset($_POST['UAM_GTAutoMail']) and isset($_POST['UAM_CustomPasswRetr']) and isset($_POST['UAM_USRAuto']) and isset($_POST['UAM_USRAutoMail']) and isset($_POST['UAM_Stuffs']) and isset($_POST['UAM_HidePassw']) and isset($_POST['UAM_PwdReset']) and isset($_POST['UAM_RejectConnexion']))
     113  {
     114
     115  // Render email contents fields
     116  // ----------------------------
     117    $_POST['UAM_MailInfo_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_MailInfo_Text'])));
     118
     119    $_POST['UAM_ConfirmMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Text'])));
     120
     121    $_POST['UAM_GhostTracker_ReminderText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GhostTracker_ReminderText'])));
     122
     123    $_POST['UAM_GTAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText'])));
     124
     125    $_POST['UAM_GTAutoMailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMailText'])));
     126
     127    $_POST['UAM_AdminValidationMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Text'])));
     128
     129    $_POST['UAM_CustomPasswRetr_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomPasswRetr_Text'])));
     130
     131    $_POST['UAM_USRAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText'])));
     132
     133    $_POST['UAM_CustomRejectConnexion_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomRejectConnexion_Text'])));
     134
     135  // Render email subjects fields
     136  // ---------------------------
     137    $_POST['UAM_ConfirmMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Subject'])));
     138
     139    $_POST['UAM_ConfirmMail_Remail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Remail_Subject'])));
     140
     141    $_POST['UAM_InfoMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_InfoMail_Subject'])));
     142
     143    $_POST['UAM_GTAutoMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMail_Subject'])));
     144
     145    $_POST['UAM_GTReminder_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTReminder_Subject'])));
     146
     147    $_POST['UAM_AdminValidationMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Subject'])));
     148
     149
     150  // Check if emails are mandatory for registrations (needed for email exclusion option)
     151        // -----------------------------------------------------------------------------------
     152    if ($conf['obligatory_user_mail_address'])
     153    {
     154      // Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them
     155      // --------------------------------------------------------------------------------------
     156      if (preg_match('/^[\s]+/', $_POST['UAM_MailExclusion_List']))
     157      {
     158        array_push($page['errors'], l10n('UAM_mail_exclusionlist_error'));
     159        $UAM_Exclusionlist_Error = true;
     160      }
     161    }
     162    elseif (!$conf['obligatory_user_mail_address'])
     163    {
     164      $_POST['UAM_MailExclusion_List'] = '';
     165    }
    166166
    167167    // Consistency check between ConfirmMail and AutoMail - We cannot use GTAutoMail if ConfirmMail is disabled
     
    172172    if (((isset($conf_UAM['1']) and ($conf_UAM['1'] == 'false' or $conf_UAM['1'] == 'local')) or ($_POST['UAM_Confirm_Mail'] == 'false' or $_POST['UAM_Confirm_Mail'] == 'local')) and $_POST['UAM_GTAutoMail'] == 'true')
    173173    {
    174                 $newvalue = 'false';
     174      $newvalue = 'false';
    175175      $_POST['UAM_GTAutoMail'] = $newvalue;
    176176      array_push($page['errors'], l10n('UAM_Error_GTAutoMail_cannot_be_set_without_ConfirmMail'));
     
    187187    // Save global UAM configuration
    188188    // -----------------------------
    189                                 $newconf_UAM = array(
    190                 $_POST['UAM_Mail_Info'],
     189    $newconf_UAM = array(
     190      $_POST['UAM_Mail_Info'],
    191191      $_POST['UAM_Confirm_Mail'],
    192192      (isset($_POST['UAM_No_Confirm_Group'])?$_POST['UAM_No_Confirm_Group']:''),
     
    235235      $_POST['UAM_GTReminder_Subject'],
    236236      $_POST['UAM_AdminValidationMail_Subject'],
    237       );
     237    );
    238238
    239239    $conf['UserAdvManager'] = serialize($newconf_UAM);
     
    266266    // Save ConfirmMail settings
    267267    // -------------------------
    268                 $newconf_UAM_ConfirmMail = array (
     268    $newconf_UAM_ConfirmMail = array (
    269269      $_POST['UAM_ConfirmMail_TimeOut'],
    270270      $_POST['UAM_ConfirmMail_Delay'],
     
    273273      $_POST['UAM_ConfirmMail_ReMail_Txt2'],
    274274      $_POST['UAM_ConfirmMail_Custom_Txt1'],
    275       $_POST['UAM_ConfirmMail_Custom_Txt2']);
     275      $_POST['UAM_ConfirmMail_Custom_Txt2']
     276    );
    276277
    277278    $conf['UserAdvManager_ConfirmMail'] = serialize($newconf_UAM_ConfirmMail);
     
    279280    conf_update_param('UserAdvManager_ConfirmMail', pwg_db_real_escape_string($conf['UserAdvManager_ConfirmMail']));
    280281
    281                                 array_push($page['infos'], l10n('UAM_save_config'));
     282    array_push($page['infos'], l10n('UAM_save_config'));
    282283  }
    283284
     
    352353  $query = '
    353354SELECT id, name
    354                 FROM '.GROUPS_TABLE.'
     355FROM '.GROUPS_TABLE.'
    355356ORDER BY name ASC
    356357;';
     
    364365    if (isset($conf_UAM[2]) and $conf_UAM[2] == $row['id'])
    365366    {
    366                                 $No_Valid = $row['id'];
    367                                 }
     367      $No_Valid = $row['id'];
     368    }
    368369    //configuration value for validated users
    369370    if (isset($conf_UAM[3]) and $conf_UAM[3] == $row['id'])
    370                                 {
    371                                 $Valid = $row['id'];
    372                                 }
     371    {
     372      $Valid = $row['id'];
     373    }
    373374    //configuration value for downgrade users
    374375    if (isset($conf_UAM[25]) and $conf_UAM[25] == $row['id'])
    375                                 {
    376                                 $Downgrade = $row['id'];
    377                                 }
     376    {
     377      $Downgrade = $row['id'];
     378    }
    378379  }
    379380       
     
    381382  // ---------------------------------------------------
    382383  $template->assign(
    383                 'No_Confirm_Group',
    384                         array(
    385                                 'group_options'=> $groups,
    386                                 'group_selected' => $No_Valid
    387                                         )
    388                 );
     384    'No_Confirm_Group',
     385      array(
     386        'group_options'=> $groups,
     387        'group_selected' => $No_Valid
     388      )
     389    );
    389390
    390391  // Template initialization for validated users group
    391392  // -------------------------------------------------
    392393  $template->assign(
    393                 'Validated_Group',
    394                                                 array(
    395                 'group_options'=> $groups,
    396                 'group_selected' => $Valid
    397                                         )
    398         );
     394    'Validated_Group',
     395      array(
     396        'group_options'=> $groups,
     397        'group_selected' => $Valid
     398      )
     399    );
    399400
    400401  // Template initialization for downgrade group
     
    402403  $template->assign(
    403404    'Downgrade_Group',
    404                                                 array(
    405                 'group_options'=> $groups,
    406                 'group_selected' => $Downgrade
    407                                         )
     405      array(
     406        'group_options'=> $groups,
     407        'group_selected' => $Downgrade
     408      )
    408409        );
    409410       
     
    428429    // ----------------------------------------------------
    429430    $template->assign(
    430                 'No_Confirm_Status',
    431                                 array(
    432                         'Status_options' => $status_options,
    433                         'Status_selected' => $No_Valid_Status
    434                                                         )
    435                         );
     431      'No_Confirm_Status',
     432        array(
     433          'Status_options' => $status_options,
     434          'Status_selected' => $No_Valid_Status
     435        )
     436      );
    436437  }
    437438 
     
    439440  // --------------------------
    440441  foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
    441                 {
    442                                 $status_options[$status] = l10n('user_status_'.$status);
    443                                 if (isset($conf_UAM[4]) and $conf_UAM[4] == $status)
    444                                 {
    445                                 $Valid_Status = $status;
    446                                 }
     442  {
     443    $status_options[$status] = l10n('user_status_'.$status);
     444    if (isset($conf_UAM[4]) and $conf_UAM[4] == $status)
     445    {
     446      $Valid_Status = $status;
     447    }
    447448               
    448449    // Template initialization for validated users status
    449450    // --------------------------------------------------
    450451    $template->assign(
    451                                                 'Confirm_Status',
    452                                                 array(
    453                                                                 'Status_options' => $status_options,
    454                                                                 'Status_selected' => $Valid_Status
    455                                                 )
    456                                 );
    457                 }
     452      'Confirm_Status',
     453        array(
     454          'Status_options' => $status_options,
     455          'Status_selected' => $Valid_Status
     456        )
     457      );
     458  }
    458459
    459460  // Get downgrade status values
     
    461462  foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
    462463  {
    463                                 $status_options[$status] = l10n('user_status_'.$status);
    464                                 if (isset($conf_UAM[26]) and $conf_UAM[26] == $status)
    465                                 {
    466                                 $Downgrade_Status = $status;
    467                                 }
     464    $status_options[$status] = l10n('user_status_'.$status);
     465    if (isset($conf_UAM[26]) and $conf_UAM[26] == $status)
     466    {
     467      $Downgrade_Status = $status;
     468    }
    468469               
    469470    // Template initialization for validated users status
    470471    // --------------------------------------------------
    471472    $template->assign(
    472                                                 'Downgrade_Status',
    473                                                                 array(
    474                                                                                 'Status_options' => $status_options,
    475                                                                                 'Status_selected' => $Downgrade_Status
    476                                                                 )
    477                                 );
    478                 }
     473      'Downgrade_Status',
     474        array(
     475          'Status_options' => $status_options,
     476          'Status_selected' => $Downgrade_Status
     477        )
     478      );
     479  }
    479480
    480481
     
    490491  foreach ($conf['available_permission_levels'] as $level)
    491492  {
    492                                 $level_options[$level] = l10n(sprintf('Level %d', $level));
    493                                 if (isset($conf_UAM[35]) and $conf_UAM[35] == $level)
    494                                 {
    495                                                 $No_Valid_Level = $level;
    496                                 }
     493    $level_options[$level] = l10n(sprintf('Level %d', $level));
     494    if (isset($conf_UAM[35]) and $conf_UAM[35] == $level)
     495    {
     496      $No_Valid_Level = $level;
     497    }
    497498
    498499    // Template initialization for unvalidated users level
    499500    // ---------------------------------------------------
    500501    $template->assign(
    501                                                 'No_Valid_Level',
    502                                                                 array(
    503                                                                                 'Level_options' => $level_options,
    504                                                                                 'Level_selected' => $No_Valid_Level
    505                                                                 )
    506                                 );
     502      'No_Valid_Level',
     503        array(
     504          'Level_options' => $level_options,
     505          'Level_selected' => $No_Valid_Level
     506        )
     507      );
    507508  }
    508509
     
    511512  foreach ($conf['available_permission_levels'] as $level)
    512513  {
    513                                 $level_options[$level] = l10n(sprintf('Level %d', $level));
    514                                 if (isset($conf_UAM[36]) and $conf_UAM[36] == $level)
    515                                 {
    516                                                 $Valid_Level = $level;
    517                                 }
     514    $level_options[$level] = l10n(sprintf('Level %d', $level));
     515    if (isset($conf_UAM[36]) and $conf_UAM[36] == $level)
     516    {
     517      $Valid_Level = $level;
     518    }
    518519
    519520    // Template initialization for unvalidated users level
    520521    // ---------------------------------------------------
    521522    $template->assign(
    522                                                 'Valid_Level',
    523                                                                 array(
    524                                                                                 'Level_options' => $level_options,
    525                                                                                 'Level_selected' => $Valid_Level
    526                                                                 )
    527                                 );
     523      'Valid_Level',
     524        array(
     525          'Level_options' => $level_options,
     526          'Level_selected' => $Valid_Level
     527        )
     528      );
    528529  }
    529530
     
    532533  foreach ($conf['available_permission_levels'] as $level)
    533534  {
    534                                 $level_options[$level] = l10n(sprintf('Level %d', $level));
    535                                 if (isset($conf_UAM[37]) and $conf_UAM[37] == $level)
    536                                 {
    537                                                 $Downgrade_Level = $level;
    538                                 }
     535    $level_options[$level] = l10n(sprintf('Level %d', $level));
     536    if (isset($conf_UAM[37]) and $conf_UAM[37] == $level)
     537    {
     538      $Downgrade_Level = $level;
     539    }
    539540
    540541    // Template initialization for unvalidated users level
    541542    // ---------------------------------------------------
    542543    $template->assign(
    543                                                 'Downgrade_Level',
    544                                                                 array(
    545                                                                                 'Level_options' => $level_options,
    546                                                                                 'Level_selected' => $Downgrade_Level
    547                                                                 )
    548                                 );
     544      'Downgrade_Level',
     545        array(
     546          'Level_options' => $level_options,
     547          'Level_selected' => $Downgrade_Level
     548        )
     549      );
    549550  }
    550551
     
    570571
    571572  $template->assign(
    572                                 array(
     573    array(
    573574                                                'nb_para'                           => $nb_para,
    574                 'nb_para2'                          => $nb_para2,
    575                 'UAM_VERSION'                       => $version,
    576                 'UAM_PATH'                          => UAM_PATH,
    577                 'UAM_DUMP_DOWNLOAD'                 => $dump_download,
    578                 'UAM_THEME'                         => $UAM_theme,
     575            'nb_para2'                          => $nb_para2,
     576            'UAM_VERSION'                       => $version,
     577            'UAM_PATH'                          => UAM_PATH,
     578            'UAM_DUMP_DOWNLOAD'                 => $dump_download,
     579            'UAM_THEME'                         => $UAM_theme,
    579580                                                'UAM_MAIL_INFO_TRUE'                => $conf_UAM[0]=='true' ?  'checked="checked"' : '' ,
    580581                                                'UAM_MAIL_INFO_FALSE'               => $conf_UAM[0]=='false' ?  'checked="checked"' : '' ,
     
    585586                                                'UAM_CONFIRM_MAIL_TRUE'             => $conf_UAM[1]=='true' ?  'checked="checked"' : '' ,
    586587                                                'UAM_CONFIRM_MAIL_FALSE'            => $conf_UAM[1]=='false' ?  'checked="checked"' : '' ,
    587                         'UAM_CONFIRM_MAIL_LOCAL'            => $conf_UAM[1]=='local' ?  'checked="checked"' : '' ,
     588            'UAM_CONFIRM_MAIL_LOCAL'            => $conf_UAM[1]=='local' ?  'checked="checked"' : '' ,
    588589                                                'UAM_CONFIRMMAIL_TEXT'              => $conf_UAM[9],
    589590                                                'UAM_No_Confirm_Group'              => $conf_UAM[2],
     
    597598                                                'UAM_PASSWORDENF_FALSE'             => $conf_UAM[12]=='false' ?  'checked="checked"' : '' ,
    598599                                                'UAM_PASSWORD_SCORE'                => $conf_UAM[13],
    599                         'UAM_ADMINPASSWENF_TRUE'            => $conf_UAM[14]=='true' ?  'checked="checked"' : '' ,
     600            'UAM_ADMINPASSWENF_TRUE'            => $conf_UAM[14]=='true' ?  'checked="checked"' : '' ,
    600601                                                'UAM_ADMINPASSWENF_FALSE'           => $conf_UAM[14]=='false' ?  'checked="checked"' : '' ,
    601                 'UAM_GHOSTRACKER_TRUE'              => $conf_UAM[15]=='true' ?  'checked="checked"' : '' ,
     602            'UAM_GHOSTRACKER_TRUE'              => $conf_UAM[15]=='true' ?  'checked="checked"' : '' ,
    602603                                                'UAM_GHOSTRACKER_FALSE'             => $conf_UAM[15]=='false' ?  'checked="checked"' : '' ,
    603                 'UAM_GHOSTRACKER_DAYLIMIT'          => $conf_UAM[16],
    604                 'UAM_GHOSTRACKER_REMINDERTEXT'      => $conf_UAM[17],
    605                 'UAM_ADDLASTVISIT_TRUE'             => $conf_UAM[18]=='true' ?  'checked="checked"' : '' ,
    606                 'UAM_ADDLASTVISIT_FALSE'            => $conf_UAM[18]=='false' ?  'checked="checked"' : '' ,
    607                 'UAM_ADMINCONFMAIL_TRUE'            => $conf_UAM[19]=='true' ?  'checked="checked"' : '' ,
    608                 'UAM_ADMINCONFMAIL_FALSE'           => $conf_UAM[19]=='false' ?  'checked="checked"' : '' ,
    609                 'UAM_REDIRTOPROFILE_TRUE'           => $conf_UAM[20]=='true' ?  'checked="checked"' : '' ,
    610                 'UAM_REDIRTOPROFILE_FALSE'          => $conf_UAM[20]=='false' ?  'checked="checked"' : '' ,
    611                 'UAM_GTAUTO_TRUE'                   => $conf_UAM[21]=='true' ?  'checked="checked"' : '' ,
    612                 'UAM_GTAUTO_FALSE'                  => $conf_UAM[21]=='false' ?  'checked="checked"' : '' ,
    613                 'UAM_GTAUTOMAIL_TRUE'               => $conf_UAM[22]=='true' ?  'checked="checked"' : '' ,
    614                 'UAM_GTAUTOMAIL_FALSE'              => $conf_UAM[22]=='false' ?  'checked="checked"' : '' ,
    615                 'UAM_GTAUTODEL_TEXT'                => $conf_UAM[23],
    616                 'UAM_GTAUTOMAILTEXT'                => $conf_UAM[24],
     604            'UAM_GHOSTRACKER_DAYLIMIT'          => $conf_UAM[16],
     605            'UAM_GHOSTRACKER_REMINDERTEXT'      => $conf_UAM[17],
     606            'UAM_ADDLASTVISIT_TRUE'             => $conf_UAM[18]=='true' ?  'checked="checked"' : '' ,
     607            'UAM_ADDLASTVISIT_FALSE'            => $conf_UAM[18]=='false' ?  'checked="checked"' : '' ,
     608            'UAM_ADMINCONFMAIL_TRUE'            => $conf_UAM[19]=='true' ?  'checked="checked"' : '' ,
     609            'UAM_ADMINCONFMAIL_FALSE'           => $conf_UAM[19]=='false' ?  'checked="checked"' : '' ,
     610            'UAM_REDIRTOPROFILE_TRUE'           => $conf_UAM[20]=='true' ?  'checked="checked"' : '' ,
     611            'UAM_REDIRTOPROFILE_FALSE'          => $conf_UAM[20]=='false' ?  'checked="checked"' : '' ,
     612            'UAM_GTAUTO_TRUE'                   => $conf_UAM[21]=='true' ?  'checked="checked"' : '' ,
     613            'UAM_GTAUTO_FALSE'                  => $conf_UAM[21]=='false' ?  'checked="checked"' : '' ,
     614            'UAM_GTAUTOMAIL_TRUE'               => $conf_UAM[22]=='true' ?  'checked="checked"' : '' ,
     615            'UAM_GTAUTOMAIL_FALSE'              => $conf_UAM[22]=='false' ?  'checked="checked"' : '' ,
     616            'UAM_GTAUTODEL_TEXT'                => $conf_UAM[23],
     617            'UAM_GTAUTOMAILTEXT'                => $conf_UAM[24],
    617618                                                'UAM_Downgrade_Group'               => $conf_UAM[25],
    618619                                                'UAM_Downgrade_Status'              => $conf_UAM[26],
    619                 'UAM_ADMINVALIDATIONMAIL_TEXT'      => $conf_UAM[27],
    620                 'UAM_CUSTOMPASSWRETR_TRUE'          => $conf_UAM[28]=='true' ?  'checked="checked"' : '' ,
    621                 'UAM_CUSTOMPASSWRETR_FALSE'         => $conf_UAM[28]=='false' ?  'checked="checked"' : '' ,
    622                 'UAM_CUSTOMPASSWRETR_TEXT'          => $conf_UAM[29],
    623                 'UAM_USRAUTO_TRUE'                  => $conf_UAM[30]=='true' ?  'checked="checked"' : '' ,
    624                 'UAM_USRAUTO_FALSE'                 => $conf_UAM[30]=='false' ?  'checked="checked"' : '' ,
    625                 'UAM_USRAUTODEL_TEXT'               => $conf_UAM[31],
    626                 'UAM_USRAUTOMAIL_TRUE'              => $conf_UAM[32]=='true' ?  'checked="checked"' : '' ,
    627                 'UAM_USRAUTOMAIL_FALSE'             => $conf_UAM[32]=='false' ?  'checked="checked"' : '' ,
    628                 'UAM_STUFFS_TRUE'                   => $conf_UAM[33]=='true' ?  'checked="checked"' : '' ,
    629                 'UAM_STUFFS_FALSE'                  => $conf_UAM[33]=='false' ?  'checked="checked"' : '' ,
    630                 'UAM_HIDEPASSW_TRUE'                => $conf_UAM[34]=='true' ?  'checked="checked"' : '' ,
    631                 'UAM_HIDEPASSW_FALSE'               => $conf_UAM[34]=='false' ?  'checked="checked"' : '' ,
     620            'UAM_ADMINVALIDATIONMAIL_TEXT'      => $conf_UAM[27],
     621            'UAM_CUSTOMPASSWRETR_TRUE'          => $conf_UAM[28]=='true' ?  'checked="checked"' : '' ,
     622            'UAM_CUSTOMPASSWRETR_FALSE'         => $conf_UAM[28]=='false' ?  'checked="checked"' : '' ,
     623            'UAM_CUSTOMPASSWRETR_TEXT'          => $conf_UAM[29],
     624            'UAM_USRAUTO_TRUE'                  => $conf_UAM[30]=='true' ?  'checked="checked"' : '' ,
     625            'UAM_USRAUTO_FALSE'                 => $conf_UAM[30]=='false' ?  'checked="checked"' : '' ,
     626            'UAM_USRAUTODEL_TEXT'               => $conf_UAM[31],
     627            'UAM_USRAUTOMAIL_TRUE'              => $conf_UAM[32]=='true' ?  'checked="checked"' : '' ,
     628            'UAM_USRAUTOMAIL_FALSE'             => $conf_UAM[32]=='false' ?  'checked="checked"' : '' ,
     629            'UAM_STUFFS_TRUE'                   => $conf_UAM[33]=='true' ?  'checked="checked"' : '' ,
     630            'UAM_STUFFS_FALSE'                  => $conf_UAM[33]=='false' ?  'checked="checked"' : '' ,
     631            'UAM_HIDEPASSW_TRUE'                => $conf_UAM[34]=='true' ?  'checked="checked"' : '' ,
     632            'UAM_HIDEPASSW_FALSE'               => $conf_UAM[34]=='false' ?  'checked="checked"' : '' ,
    632633                                                'UAM_NO_VALID_LEVEL'                => $conf_UAM[35],
    633634                                                'UAM_VALID_LEVEL'                   => $conf_UAM[36],
    634                 'UAM_DOWNGRADE_LEVEL'               => $conf_UAM[37],
    635                 'UAM_PWDRESET_TRUE'                 => $conf_UAM[38]=='true' ?  'checked="checked"' : '' ,
    636                 'UAM_PWDRESET_FALSE'                => $conf_UAM[38]=='false' ?  'checked="checked"' : '' ,
    637                 'UAM_REJECTCONNECT_TRUE'            => $conf_UAM[39]=='true' ?  'checked="checked"' : '' ,
    638                 'UAM_REJECTCONNECT_FALSE'           => $conf_UAM[39]=='false' ?  'checked="checked"' : '' ,
    639                 'UAM_REJECTCONNECT_TEXT'            => $conf_UAM[40],
    640                 'UAM_CONFIRMMAIL_SUBJECT'           => $conf_UAM[41],
    641                 'UAM_CONFIRMMAIL_REMAIL_SUBJECT'    => $conf_UAM[42],
    642                 'UAM_INFOMAIL_SUBJECT'              => $conf_UAM[43],
    643                 'UAM_GTAUTOMAIL_SUBJECT'            => $conf_UAM[44],
    644                 'UAM_GTREMINDER_SUBJECT'            => $conf_UAM[45],
    645                 'UAM_ADMINVALIDATIONMAIL_SUBJECT'   => $conf_UAM[46],
     635            'UAM_DOWNGRADE_LEVEL'               => $conf_UAM[37],
     636            'UAM_PWDRESET_TRUE'                 => $conf_UAM[38]=='true' ?  'checked="checked"' : '' ,
     637            'UAM_PWDRESET_FALSE'                => $conf_UAM[38]=='false' ?  'checked="checked"' : '' ,
     638            'UAM_REJECTCONNECT_TRUE'            => $conf_UAM[39]=='true' ?  'checked="checked"' : '' ,
     639            'UAM_REJECTCONNECT_FALSE'           => $conf_UAM[39]=='false' ?  'checked="checked"' : '' ,
     640            'UAM_REJECTCONNECT_TEXT'            => $conf_UAM[40],
     641            'UAM_CONFIRMMAIL_SUBJECT'           => $conf_UAM[41],
     642            'UAM_CONFIRMMAIL_REMAIL_SUBJECT'    => $conf_UAM[42],
     643            'UAM_INFOMAIL_SUBJECT'              => $conf_UAM[43],
     644            'UAM_GTAUTOMAIL_SUBJECT'            => $conf_UAM[44],
     645            'UAM_GTREMINDER_SUBJECT'            => $conf_UAM[45],
     646            'UAM_ADMINVALIDATIONMAIL_SUBJECT'   => $conf_UAM[46],
    646647                                                'UAM_PASSWORD_TEST_SCORE'           => $UAM_Password_Test_Score,
    647                 'UAM_ERROR_REPORTS1'                => $UAM_Exclusionlist_Error,
    648                 'UAM_ERROR_REPORTS2'                => $UAM_Illegal_Flag_Error1,
    649                 'UAM_ERROR_REPORTS3'                => $UAM_Illegal_Flag_Error2,
    650                 'UAM_ERROR_REPORTS4'                => $UAM_Illegal_Flag_Error3,
    651                 'UAM_EMAIL_MANDATORY'               => $UAM_Email_Mandatory_Check,
    652                                                 'UAM_CONFIRMMAIL_TIMEOUT_TRUE'          => $conf_UAM_ConfirmMail[0]=='true' ?  'checked="checked"' : '' ,
     648            'UAM_ERROR_REPORTS1'                => $UAM_Exclusionlist_Error,
     649            'UAM_ERROR_REPORTS2'                => $UAM_Illegal_Flag_Error1,
     650            'UAM_ERROR_REPORTS3'                => $UAM_Illegal_Flag_Error2,
     651            'UAM_ERROR_REPORTS4'                => $UAM_Illegal_Flag_Error3,
     652            'UAM_EMAIL_MANDATORY'               => $UAM_Email_Mandatory_Check,
     653                                                'UAM_CONFIRMMAIL_TIMEOUT_TRUE'      => $conf_UAM_ConfirmMail[0]=='true' ?  'checked="checked"' : '' ,
    653654                                                'UAM_CONFIRMMAIL_TIMEOUT_FALSE'     => $conf_UAM_ConfirmMail[0]=='false' ?  'checked="checked"' : '' ,
    654                                                 'UAM_CONFIRMMAIL_DELAY'                                                                                                 => $conf_UAM_ConfirmMail[1],
    655                 'UAM_CONFIRMMAIL_REMAIL_TRUE'       => $conf_UAM_ConfirmMail[3]=='true' ? 'checked="checked"' : '',
    656                 'UAM_CONFIRMMAIL_REMAIL_FALSE'      => $conf_UAM_ConfirmMail[3]=='false' ? 'checked="checked"' : '',
    657                 'UAM_CONFIRMMAIL_REMAIL_TXT1'       => $conf_UAM_ConfirmMail[2],
    658                 'UAM_CONFIRMMAIL_REMAIL_TXT2'       => $conf_UAM_ConfirmMail[4],
    659                 'UAM_CONFIRMMAIL_CUSTOM_TXT1'       => $conf_UAM_ConfirmMail[5],
    660                 'UAM_CONFIRMMAIL_CUSTOM_TXT2'       => $conf_UAM_ConfirmMail[6],
     655                                                'UAM_CONFIRMMAIL_DELAY'             => $conf_UAM_ConfirmMail[1],
     656            'UAM_CONFIRMMAIL_REMAIL_TRUE'       => $conf_UAM_ConfirmMail[3]=='true' ? 'checked="checked"' : '',
     657            'UAM_CONFIRMMAIL_REMAIL_FALSE'      => $conf_UAM_ConfirmMail[3]=='false' ? 'checked="checked"' : '',
     658            'UAM_CONFIRMMAIL_REMAIL_TXT1'       => $conf_UAM_ConfirmMail[2],
     659            'UAM_CONFIRMMAIL_REMAIL_TXT2'       => $conf_UAM_ConfirmMail[4],
     660            'UAM_CONFIRMMAIL_CUSTOM_TXT1'       => $conf_UAM_ConfirmMail[5],
     661            'UAM_CONFIRMMAIL_CUSTOM_TXT2'       => $conf_UAM_ConfirmMail[6],
    661662    )
    662663  );
    663664
    664665  if (isset($_POST['audit']))
    665                 {
    666                                 $msg_error1 = '';
     666  {
     667    $msg_error1 = '';
    667668               
    668669    // Username without forbidden keys
    669670    // -------------------------------
    670671    if ( isset($conf_UAM[5]) and $conf_UAM[5] == 'true' )
    671                 {
    672                                                 $query = '
     672          {
     673      $query = '
    673674SELECT '.$conf['user_fields']['username'].', '.$conf['user_fields']['email'].'
    674                 FROM '.USERS_TABLE.'
     675FROM '.USERS_TABLE.'
    675676;';
    676                          
    677                                                 $result = pwg_query($query);
    678                        
    679                                                 while($row = pwg_db_fetch_assoc($result))
    680                                                 {
    681                                                                 if (!ValidateUsername(stripslashes($row['username'])))
    682                                                                                 $msg_error1 .= (($msg_error1 <> '') ? '<br>' : '').l10n('UAM_Err_audit_username_char').stripslashes($row['username']);
    683                                                 }
    684                                 }
    685 
    686                                 $msg_error2 = '';
     677
     678      $result = pwg_query($query);
     679
     680      while($row = pwg_db_fetch_assoc($result))
     681      {
     682        if (!ValidateUsername(stripslashes($row['username'])))
     683          $msg_error1 .= (($msg_error1 <> '') ? '<br>' : '').l10n('UAM_Err_audit_username_char').stripslashes($row['username']);
     684      }
     685    }
     686
     687    $msg_error2 = '';
    687688               
    688689    // Email without forbidden domain
    689690    // ------------------------------
    690691    if ( isset($conf_UAM[10]) and $conf_UAM[10] == 'true' )
    691                                                 {
    692                                                                 $query = '
     692    {
     693      $query = '
    693694SELECT '.$conf['user_fields']['username'].', '.$conf['user_fields']['email'].'
    694   FROM '.USERS_TABLE.'
     695FROM '.USERS_TABLE.'
    695696;';
    696                          
    697                                                 $result = pwg_query($query);
    698                        
    699                                                 while($row = pwg_db_fetch_assoc($result))
    700                                                 {
    701                                                                 $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[11]);
    702                                                                 for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++)
    703                                                                 {
    704                                                                                                 $pattern = '/'.$conf_MailExclusion[$i].'/';
    705                                                                                 if (preg_match($pattern, $row['mail_address']))
    706                                                                                 {
    707                                                                                                                 $msg_error2 .=  (($msg_error2 <> '') ? '<br>' : '').l10n('UAM_Err_audit_email_forbidden').stripslashes($row['username']).' ('.$row['mail_address'].')';
    708                                                                                                 }
    709                                                                                 }
    710                                                                 }
    711                                                 }
    712                
    713                 if ($msg_error1 <> '')
    714                                                                 $errors[] = $msg_error1.'<br><br>';
    715                
    716                                                 if ($msg_error2 <> '')
    717                                                                 $errors[] = $msg_error2.'<br><br>';
    718                
    719                                                 if ($msg_error1 <> '' or $msg_error2 <> '')
    720                                                 array_push($page['errors'], l10n('UAM_Err_audit_advise'));
    721                                                 else
    722                                 array_push($page['infos'], l10n('UAM_audit_ok'));
     697
     698      $result = pwg_query($query);
     699
     700      while($row = pwg_db_fetch_assoc($result))
     701      {
     702        $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[11]);
     703        for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++)
     704        {
     705          $pattern = '/'.$conf_MailExclusion[$i].'/';
     706          if (preg_match($pattern, $row['mail_address']))
     707          {
     708            $msg_error2 .=  (($msg_error2 <> '') ? '<br>' : '').l10n('UAM_Err_audit_email_forbidden').stripslashes($row['username']).' ('.$row['mail_address'].')';
     709          }
     710        }
     711      }
     712    }
     713
     714    if ($msg_error1 <> '')
     715    $errors[] = $msg_error1.'<br><br>';
     716
     717    if ($msg_error2 <> '')
     718      $errors[] = $msg_error2.'<br><br>';
     719
     720    if ($msg_error1 <> '' or $msg_error2 <> '')
     721      array_push($page['errors'], l10n('UAM_Err_audit_advise'));
     722    else
     723      array_push($page['infos'], l10n('UAM_audit_ok'));
    723724  }
    724725
     
    727728// |                             errors display                            |
    728729// +-----------------------------------------------------------------------+
    729                 if (isset ($errors) and count($errors) != 0)
    730   {
    731                                 $template->assign('errors',array());
    732                 foreach ($errors as $error)
    733                 {
    734                                 array_push($page['errors'], $error);
    735                                 }
    736                
     730  if (isset ($errors) and count($errors) != 0)
     731  {
     732    $template->assign('errors',array());
     733    foreach ($errors as $error)
     734    {
     735      array_push($page['errors'], $error);
     736    }
     737 
    737738
    738739// +-----------------------------------------------------------------------+
     
    760761// +-----------------------------------------------------------------------+
    761762
    762                                 if (!defined('PHPWG_ROOT_PATH'))
    763                 {
    764                                 die('Hacking attempt!');
    765                 }
     763    if (!defined('PHPWG_ROOT_PATH'))
     764    {
     765      die('Hacking attempt!');
     766    }
    766767         
    767                 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     768    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    768769
    769770// +-----------------------------------------------------------------------+
    770771// | Check Access and exit when user status is not ok                      |
    771772// +-----------------------------------------------------------------------+
    772                                 check_status(ACCESS_ADMINISTRATOR);
     773    check_status(ACCESS_ADMINISTRATOR);
    773774
    774775
     
    777778// +-----------------------------------------------------------------------+
    778779
    779                                 $page['filtered_users'] = get_user_list();
     780    $page['filtered_users'] = get_user_list();
    780781
    781782// +-----------------------------------------------------------------------+
     
    783784// +-----------------------------------------------------------------------+
    784785
    785                                 $visible_user_list = array();
     786      $visible_user_list = array();
    786787                foreach ($page['filtered_users'] as $num => $local_user)
    787788                {
    788                                 $visible_user_list[] = $local_user;
    789                                 }
    790 
    791                                 foreach ($visible_user_list as $local_user)
    792         {
    793                                 // dates formating and compare
     789        $visible_user_list[] = $local_user;
     790      }
     791
     792                        foreach ($visible_user_list as $local_user)
     793      {
     794        // dates formating and compare
    794795                // ---------------------------
    795796                $today = date("d-m-Y"); // Get today's date
     
    801802                $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
    802803
    803                                                 $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps     
     804        $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps     
    804805                $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
    805806 
    806                                                 if (isset($conf_UAM[15]) and $conf_UAM[15]=='true' and !empty($conf_UAM[16]))
     807        if (isset($conf_UAM[15]) and $conf_UAM[15]=='true' and !empty($conf_UAM[16]))
    807808                {
    808                                 if ($deltadays <= ($conf_UAM[16]/2))
     809          if ($deltadays <= ($conf_UAM[16]/2))
    809810                {
    810                                 $display = 'green';
     811            $display = 'green';
    811812                }
    812813
    813                                                                 if (($deltadays > ($conf_UAM[16]/2)) and ($deltadays < $conf_UAM[16]))
     814          if (($deltadays > ($conf_UAM[16]/2)) and ($deltadays < $conf_UAM[16]))
    814815                {
    815                                 $display = 'orange';
     816            $display = 'orange';
    816817                }
    817818
    818819                if ($deltadays >= $conf_UAM[16])
    819820                {
    820                                 $display = 'red';
     821            $display = 'red';
    821822                        }
    822                                                 }
     823        }
    823824                else $display = '';
    824825
     
    829830                                array(
    830831                                        'ID'          => $local_user['id'],
    831                                 'USERNAME'    => stripslashes($local_user['username']),
    832                                                                                                 'EMAIL'       => get_email_address_as_display_text($local_user['email']),
    833                         'LASTVISIT'   => $local_user['lastvisit'],
    834                         'DAYS'        => $deltadays,
    835                         'DISPLAY'     => $display,
    836                                                                                 )
    837                                                 );
    838                                 }
    839 
    840                                 // Plugin version inserted
     832                'USERNAME'    => stripslashes($local_user['username']),
     833                'EMAIL'       => get_email_address_as_display_text($local_user['email']),
     834                'LASTVISIT'   => $local_user['lastvisit'],
     835                'DAYS'        => $deltadays,
     836                'DISPLAY'     => $display,
     837              )
     838            );
     839      }
     840
     841      // Plugin version inserted
    841842                // -----------------------
    842843                $template->assign(
    843844                                array(
    844845                                'UAM_VERSION'  => $version,
    845                 'UAM_PATH'     => UAM_PATH,
    846                 )
    847                 );
    848    
     846                  'UAM_PATH'     => UAM_PATH,
     847          )
     848      );
     849
    849850// +-----------------------------------------------------------------------+
    850851// |                             errors display                            |
    851852// +-----------------------------------------------------------------------+
    852                                 if ( isset ($errors) and count($errors) != 0)
    853                                 {
    854                                                 $template->assign('errors',array());
    855                                                 foreach ($errors as $error)
    856                                 {
    857                                                                 array_push($page['errors'], $error);
    858                                 }
    859                                
     853      if ( isset ($errors) and count($errors) != 0)
     854      {
     855        $template->assign('errors',array());
     856        foreach ($errors as $error)
     857        {
     858          array_push($page['errors'], $error);
     859        }
     860     
    860861
    861862// +-----------------------------------------------------------------------+
    862863// |                           templates display                           |
    863864// +-----------------------------------------------------------------------+
    864                                 $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/userlist.tpl');
    865                 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');             
    866                 }
    867                 else
    868                 {
    869                                 array_push($page['errors'], l10n('UAM_Err_Userlist_Settings'));
    870                 }
     865    $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/userlist.tpl');
     866    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
     867  }
     868        else
     869        {
     870    array_push($page['errors'], l10n('UAM_Err_Userlist_Settings'));
     871  }
    871872
    872873break;
     
    890891// +-----------------------------------------------------------------------+
    891892
    892                                 if (!defined('PHPWG_ROOT_PATH'))
    893     {
    894                 die('Hacking attempt!');
     893    if (!defined('PHPWG_ROOT_PATH'))
     894    {
     895      die('Hacking attempt!');
    895896    }
    896897
     
    900901// | Check Access and exit when user status is not ok                      |
    901902// +-----------------------------------------------------------------------+
    902                                 check_status(ACCESS_ADMINISTRATOR);
     903    check_status(ACCESS_ADMINISTRATOR);
    903904
    904905// +-----------------------------------------------------------------------+
     
    906907// +-----------------------------------------------------------------------+
    907908
    908                                 $page['filtered_users'] = get_unvalid_user_list();
     909    $page['filtered_users'] = get_unvalid_user_list();
    909910
    910911// +-----------------------------------------------------------------------+
    911912// |                            selected users                             |
    912913// +-----------------------------------------------------------------------+
    913                                 if (isset($_POST['Del_Selected']))
    914                                 {
    915                                 $collection = array();
    916 
    917                                                 switch ($_POST['target'])
    918                                                 {
    919                                                 case 'all' :
    920                 {
    921                                         foreach($page['filtered_users'] as $local_user)
    922                         {
    923                                         array_push($collection, $local_user['id']);
    924                         }
    925                                                                 break;
    926                                                                 }
    927                 case 'selection' :
    928                 {
    929                                 if (isset($_POST['selection']))
    930                         {
    931                                         $collection = $_POST['selection'];
    932                         }
    933                 break;
    934                 }
    935                                                 }
    936 
    937                                                 if (count($collection) == 0)
    938                 {
    939                                 array_push($page['errors'], l10n('Select at least one user'));
    940                         }
    941                                 }
     914    if (isset($_POST['Del_Selected']))
     915    {
     916      $collection = array();
     917
     918      switch ($_POST['target'])
     919      {
     920        case 'all' :
     921        {
     922          foreach($page['filtered_users'] as $local_user)
     923          {
     924            array_push($collection, $local_user['id']);
     925          }
     926          break;
     927        }
     928        case 'selection' :
     929        {
     930          if (isset($_POST['selection']))
     931          {
     932            $collection = $_POST['selection'];
     933          }
     934          break;
     935        }
     936      }
     937
     938      if (count($collection) == 0)
     939      {
     940        array_push($page['errors'], l10n('Select at least one user'));
     941      }
     942    }
    942943
    943944// +-----------------------------------------------------------------------+
    944945// |                             delete users                              |
    945946// +-----------------------------------------------------------------------+
    946                                 if (isset($_POST['Del_Selected']) and count($collection) > 0)
    947                 {
    948                                         if (in_array($conf['guest_id'], $collection))
    949                         {
    950                                 array_push($page['errors'], l10n('Guest cannot be deleted'));
    951                 }
    952                         if (($conf['guest_id'] != $conf['default_user_id']) and
    953                                 in_array($conf['default_user_id'], $collection))
    954                 {
    955                                 array_push($page['errors'], l10n('Default user cannot be deleted'));
    956                 }
    957                 if (in_array($conf['webmaster_id'], $collection))
    958                 {
    959                                 array_push($page['errors'], l10n('Webmaster cannot be deleted'));
    960                 }
    961                 if (in_array($user['id'], $collection))
    962                 {
    963                                 array_push($page['errors'], l10n('You cannot delete your account'));
    964                 }
    965 
    966                                                 if (count($page['errors']) == 0)
    967                 {
    968                                         foreach ($collection as $user_id)
    969                 {
    970                                 delete_user($user_id);
    971                         }
    972                                                                 array_push(
    973                                 $page['infos'],
    974                         l10n_dec(
    975                                         '%d user deleted', '%d users deleted',
    976                         count($collection)
    977                         )
    978                 );
    979 
    980                 foreach ($page['filtered_users'] as $filter_key => $filter_user)
    981                 {
    982                                         if (in_array($filter_user['id'], $collection))
    983                         {
    984                                         unset($page['filtered_users'][$filter_key]);
    985                         }
    986                         }
    987                                                 }
    988                                 }
     947    if (isset($_POST['Del_Selected']) and count($collection) > 0)
     948    {
     949      if (in_array($conf['guest_id'], $collection))
     950      {
     951        array_push($page['errors'], l10n('Guest cannot be deleted'));
     952      }
     953      if (($conf['guest_id'] != $conf['default_user_id']) and
     954        in_array($conf['default_user_id'], $collection))
     955      {
     956        array_push($page['errors'], l10n('Default user cannot be deleted'));
     957      }
     958      if (in_array($conf['webmaster_id'], $collection))
     959      {
     960        array_push($page['errors'], l10n('Webmaster cannot be deleted'));
     961      }
     962      if (in_array($user['id'], $collection))
     963      {
     964        array_push($page['errors'], l10n('You cannot delete your account'));
     965      }
     966
     967      if (count($page['errors']) == 0)
     968      {
     969        foreach ($collection as $user_id)
     970        {
     971          delete_user($user_id);
     972        }
     973        array_push(
     974          $page['infos'],
     975            l10n_dec(
     976              '%d user deleted', '%d users deleted',
     977              count($collection)
     978            )
     979        );
     980
     981        foreach ($page['filtered_users'] as $filter_key => $filter_user)
     982        {
     983          if (in_array($filter_user['id'], $collection))
     984          {
     985            unset($page['filtered_users'][$filter_key]);
     986          }
     987        }
     988      }
     989    }
    989990
    990991// +-----------------------------------------------------------------------+
     
    994995// |                            selected users                             |
    995996// +-----------------------------------------------------------------------+
    996                                 if (isset($_POST['Mail_With_Key']))
    997                                 {
    998                                 $collection = array();
    999 
    1000                                                 switch ($_POST['target'])
    1001                 {
    1002                                 case 'all' :
    1003                 {
    1004                                 foreach($page['filtered_users'] as $local_user)
    1005                         {
    1006                                         array_push($collection, $local_user['id']);
    1007                         }
    1008                 break;
    1009                                                                 }
    1010                 case 'selection' :
    1011                 {
    1012                                 if (isset($_POST['selection']))
    1013                         {
    1014                                         $collection = $_POST['selection'];
    1015                         }
    1016         break;
    1017                 }
    1018                                                 }
    1019 
    1020                 if (count($collection) == 0)
    1021                 {
    1022                                 array_push($page['errors'], l10n('Select at least one user'));
    1023                 }
    1024                                 }
     997    if (isset($_POST['Mail_With_Key']))
     998    {
     999      $collection = array();
     1000
     1001      switch ($_POST['target'])
     1002      {
     1003        case 'all' :
     1004        {
     1005          foreach($page['filtered_users'] as $local_user)
     1006          {
     1007            array_push($collection, $local_user['id']);
     1008          }
     1009          break;
     1010        }
     1011        case 'selection' :
     1012        {
     1013          if (isset($_POST['selection']))
     1014          {
     1015            $collection = $_POST['selection'];
     1016          }
     1017          break;
     1018        }
     1019      }
     1020
     1021      if (count($collection) == 0)
     1022      {
     1023        array_push($page['errors'], l10n('Select at least one user'));
     1024      }
     1025    }
    10251026// +-----------------------------------------------------------------------+
    10261027// |                 Resend new validation key to users                    |
    10271028// +-----------------------------------------------------------------------+
    1028                                 if (isset($_POST['Mail_With_Key']) and count($collection) > 0)
    1029                                 {
    1030                                                 if (in_array($conf['guest_id'], $collection))
    1031                         {
    1032                                 array_push($page['errors'], l10n('UAM_No_validation_for_Guest'));
    1033                         }
    1034                 if (($conf['guest_id'] != $conf['default_user_id']) and
    1035                                 in_array($conf['default_user_id'], $collection))
    1036                 {
    1037                                 array_push($page['errors'], l10n('UAM_No_validation_for_default_user'));
    1038                         }
    1039                         if (in_array($conf['webmaster_id'], $collection))
    1040                 {
    1041                                 array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster'));
    1042                 }
    1043                 if (in_array($user['id'], $collection))
    1044                 {
    1045                                 array_push($page['errors'], l10n('UAM_No_validation_for_your_account'));
    1046                 }
    1047 
    1048                 if (count($page['errors']) == 0)
    1049                 {
    1050                                 foreach ($collection as $user_id)
    1051                 {       
    1052                                 $typemail = 1;
    1053                                                                 $query = '
     1029    if (isset($_POST['Mail_With_Key']) and count($collection) > 0)
     1030    {
     1031      if (in_array($conf['guest_id'], $collection))
     1032      {
     1033        array_push($page['errors'], l10n('UAM_No_validation_for_Guest'));
     1034      }
     1035      if (($conf['guest_id'] != $conf['default_user_id']) and
     1036        in_array($conf['default_user_id'], $collection))
     1037      {
     1038        array_push($page['errors'], l10n('UAM_No_validation_for_default_user'));
     1039      }
     1040      if (in_array($conf['webmaster_id'], $collection))
     1041      {
     1042        array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster'));
     1043      }
     1044      if (in_array($user['id'], $collection))
     1045      {
     1046        array_push($page['errors'], l10n('UAM_No_validation_for_your_account'));
     1047      }
     1048
     1049      if (count($page['errors']) == 0)
     1050      {
     1051        foreach ($collection as $user_id)
     1052        {
     1053          $typemail = 1;
     1054          $query = '
    10541055SELECT id, username, mail_address
    1055   FROM '.USERS_TABLE.'
     1056FROM '.USERS_TABLE.'
    10561057WHERE id = '.$user_id.'
    10571058;';
    1058                                                                                 $data = pwg_db_fetch_assoc(pwg_query($query));
    1059                                
    1060                                 ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],true);
    1061                 }
    1062                 array_push(
    1063                                 $page['infos'],
    1064                                         l10n_dec(
    1065                                         'UAM_%d_Mail_With_Key', 'UAM_%d_Mails_With_Key',
    1066                                         count($collection)
    1067                                         )
    1068                                 );
    1069        
    1070                                                                 $page['filtered_users'] = get_unvalid_user_list();
    1071                                                 }
    1072                                 }
     1059          $data = pwg_db_fetch_assoc(pwg_query($query));
     1060
     1061          ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],true);
     1062        }
     1063        array_push(
     1064          $page['infos'],
     1065          l10n_dec(
     1066            'UAM_%d_Mail_With_Key', 'UAM_%d_Mails_With_Key',
     1067            count($collection)
     1068          )
     1069        );
     1070
     1071        $page['filtered_users'] = get_unvalid_user_list();
     1072      }
     1073    }
    10731074
    10741075// +-----------------------------------------------------------------------+
     
    10781079// |                            selected users                             |
    10791080// +-----------------------------------------------------------------------+
    1080                                 if (isset($_POST['Mail_Without_Key']))
    1081                                 {
    1082                                 $collection = array();
    1083 
    1084                                                 switch ($_POST['target'])
    1085                 {
    1086                                 case 'all' :
    1087                 {
    1088                                 foreach($page['filtered_users'] as $local_user)
    1089                         {
    1090                                         array_push($collection, $local_user['id']);
    1091                         }
    1092         break;
    1093                                                                 }
    1094                 case 'selection' :
    1095                 {
    1096                                         if (isset($_POST['selection']))
    1097                         {
    1098                                         $collection = $_POST['selection'];
    1099                         }
    1100         break;
    1101                 }
    1102                                                 }
    1103 
    1104                 if (count($collection) == 0)
    1105                 {
    1106                                 array_push($page['errors'], l10n('Select at least one user'));
    1107                         }
    1108                                 }
     1081    if (isset($_POST['Mail_Without_Key']))
     1082    {
     1083      $collection = array();
     1084
     1085      switch ($_POST['target'])
     1086      {
     1087        case 'all' :
     1088        {
     1089          foreach($page['filtered_users'] as $local_user)
     1090          {
     1091            array_push($collection, $local_user['id']);
     1092          }
     1093          break;
     1094        }
     1095        case 'selection' :
     1096        {
     1097          if (isset($_POST['selection']))
     1098          {
     1099            $collection = $_POST['selection'];
     1100          }
     1101          break;
     1102        }
     1103      }
     1104
     1105      if (count($collection) == 0)
     1106      {
     1107        array_push($page['errors'], l10n('Select at least one user'));
     1108      }
     1109    }
    11091110// +-----------------------------------------------------------------------+
    11101111// |             Send reminder without new key to users                    |
    11111112// +-----------------------------------------------------------------------+
    1112                                 if (isset($_POST['Mail_Without_Key']) and count($collection) > 0)
    1113                                 {
    1114                                                 if (in_array($conf['guest_id'], $collection))
    1115                         {
    1116                                 array_push($page['errors'], l10n('UAM_No_validation_for_Guest'));
    1117                 }
    1118                 if (($conf['guest_id'] != $conf['default_user_id']) and
    1119                                 in_array($conf['default_user_id'], $collection))
    1120                 {
    1121                                 array_push($page['errors'], l10n('UAM_No_validation_for_default_user'));
    1122                 }
    1123                         if (in_array($conf['webmaster_id'], $collection))
    1124                 {
    1125                                 array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster'));
    1126                 }
    1127                 if (in_array($user['id'], $collection))
    1128                 {
    1129                                 array_push($page['errors'], l10n('UAM_No_validation_for_your_account'));
    1130                 }
    1131 
    1132                 if (count($page['errors']) == 0)
    1133                 {
    1134                                 foreach ($collection as $user_id)
    1135                 {
    1136                                 $typemail = 2;
    1137                                                                 $query = '
     1113    if (isset($_POST['Mail_Without_Key']) and count($collection) > 0)
     1114    {
     1115      if (in_array($conf['guest_id'], $collection))
     1116      {
     1117        array_push($page['errors'], l10n('UAM_No_validation_for_Guest'));
     1118      }
     1119      if (($conf['guest_id'] != $conf['default_user_id']) and
     1120        in_array($conf['default_user_id'], $collection))
     1121      {
     1122        array_push($page['errors'], l10n('UAM_No_validation_for_default_user'));
     1123      }
     1124      if (in_array($conf['webmaster_id'], $collection))
     1125      {
     1126        array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster'));
     1127      }
     1128      if (in_array($user['id'], $collection))
     1129      {
     1130        array_push($page['errors'], l10n('UAM_No_validation_for_your_account'));
     1131      }
     1132
     1133      if (count($page['errors']) == 0)
     1134      {
     1135        foreach ($collection as $user_id)
     1136        {
     1137          $typemail = 2;
     1138          $query = '
    11381139SELECT id, username, mail_address
    1139   FROM '.USERS_TABLE.'
     1140FROM '.USERS_TABLE.'
    11401141WHERE id = '.$user_id.'
    11411142;';
    11421143                                       
    1143                                                                                 $data = pwg_db_fetch_assoc(pwg_query($query));
    1144                                
    1145                                 ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],false);                               
    1146                 }
    1147                 array_push(
    1148                                 $page['infos'],
    1149                         l10n_dec(
    1150                         'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent',
     1144          $data = pwg_db_fetch_assoc(pwg_query($query));
     1145
     1146          ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],false);                             
     1147        }
     1148        array_push(
     1149          $page['infos'],
     1150          l10n_dec(
     1151            'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent',
    11511152                        count($collection)
    1152                         )
    1153                 );
    1154        
    1155                                                                 $page['filtered_users'] = get_unvalid_user_list();
    1156                                                 }
    1157                                 }
    1158 
    1159 // +-----------------------------------------------------------------------+
    1160 // |                                                                             Manual validation      by admins                                                |
     1153          )
     1154        );
     1155
     1156        $page['filtered_users'] = get_unvalid_user_list();
     1157      }
     1158    }
     1159
     1160// +-----------------------------------------------------------------------+
     1161// |                                                                             Manual validation      by admins              |
    11611162// +-----------------------------------------------------------------------+
    11621163// +-----------------------------------------------------------------------+
    11631164// |                            selected users                             |
    11641165// +-----------------------------------------------------------------------+
    1165                                 if (isset($_POST['Manual_Validation']))
    1166                                 {
    1167                                 $collection = array();
    1168 
    1169                                                 switch ($_POST['target'])
    1170                 {
    1171                                 case 'all' :
    1172                 {
    1173                                 foreach($page['filtered_users'] as $local_user)
    1174                         {
    1175                                         array_push($collection, $local_user['id']);
    1176                         }
    1177         break;
    1178                                                                 }
    1179                 case 'selection' :
    1180                 {
    1181                                 if (isset($_POST['selection']))
    1182                         {
    1183                                         $collection = $_POST['selection'];
    1184                         }
     1166    if (isset($_POST['Manual_Validation']))
     1167    {
     1168      $collection = array();
     1169
     1170      switch ($_POST['target'])
     1171      {
     1172        case 'all' :
     1173        {
     1174          foreach($page['filtered_users'] as $local_user)
     1175          {
     1176            array_push($collection, $local_user['id']);
     1177          }
     1178          break;
     1179        }
     1180        case 'selection' :
     1181        {
     1182          if (isset($_POST['selection']))
     1183          {
     1184            $collection = $_POST['selection'];
     1185          }
    11851186                break;
    1186                 }
    1187                                                 }
    1188 
    1189                                                 if (count($collection) == 0)
    1190                 {
    1191                                 array_push($page['errors'], l10n('Select at least one user'));
    1192                 }
    1193                                 }
     1187        }
     1188      }
     1189
     1190      if (count($collection) == 0)
     1191      {
     1192        array_push($page['errors'], l10n('Select at least one user'));
     1193      }
     1194    }
    11941195// +-----------------------------------------------------------------------+
    11951196// |                                                                            Force validation                                                         |
    11961197// +-----------------------------------------------------------------------+
    1197                                 if (isset($_POST['Manual_Validation']) and count($collection) > 0)
    1198                                 {
    1199                                                 if (in_array($conf['guest_id'], $collection))
    1200                         {
    1201                                 array_push($page['errors'], l10n('UAM_No_validation_for_Guest'));
    1202                 }
    1203                 if (($conf['guest_id'] != $conf['default_user_id']) and
    1204                                 in_array($conf['default_user_id'], $collection))
    1205                 {
    1206                                 array_push($page['errors'], l10n('UAM_No_validation_for_default_user'));
    1207                 }
    1208                                 if (in_array($conf['webmaster_id'], $collection))
    1209                 {
    1210                                 array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster'));
    1211                 }
    1212                 if (in_array($user['id'], $collection))
    1213                 {
    1214                                 array_push($page['errors'], l10n('UAM_No_validation_for_your_account'));
    1215                 }
    1216 
    1217                 if (count($page['errors']) == 0)
    1218                 {
    1219                                 foreach ($collection as $user_id)
    1220                 {
    1221                         ManualValidation($user_id);
     1198    if (isset($_POST['Manual_Validation']) and count($collection) > 0)
     1199    {
     1200      if (in_array($conf['guest_id'], $collection))
     1201      {
     1202        array_push($page['errors'], l10n('UAM_No_validation_for_Guest'));
     1203      }
     1204      if (($conf['guest_id'] != $conf['default_user_id']) and
     1205        in_array($conf['default_user_id'], $collection))
     1206      {
     1207        array_push($page['errors'], l10n('UAM_No_validation_for_default_user'));
     1208      }
     1209      if (in_array($conf['webmaster_id'], $collection))
     1210      {
     1211        array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster'));
     1212      }
     1213      if (in_array($user['id'], $collection))
     1214      {
     1215        array_push($page['errors'], l10n('UAM_No_validation_for_your_account'));
     1216      }
     1217
     1218      if (count($page['errors']) == 0)
     1219      {
     1220        foreach ($collection as $user_id)
     1221        {
     1222          ManualValidation($user_id);
    12221223          validation_mail($user_id);
    1223                 }
    1224                 array_push(
    1225                                 $page['infos'],
    1226                         l10n_dec(
    1227                         'UAM_%d_Validated_User', 'UAM_%d_Validated_Users',
     1224        }
     1225        array_push(
     1226          $page['infos'],
     1227          l10n_dec(
     1228            'UAM_%d_Validated_User', 'UAM_%d_Validated_Users',
    12281229                        count($collection)
    1229                         )
    1230                 );
    1231 
    1232                                                                 $page['filtered_users'] = get_unvalid_user_list();
    1233                                                 }
    1234                                 }
    1235                
     1230          )
     1231        );
     1232
     1233        $page['filtered_users'] = get_unvalid_user_list();
     1234      }
     1235    }
     1236
    12361237
    12371238// +-----------------------------------------------------------------------+
     
    12391240// +-----------------------------------------------------------------------+
    12401241
    1241                                 $groups[-1] = '------------';
     1242    $groups[-1] = '------------';
    12421243
    12431244    $query = '
    12441245SELECT id, name
    1245   FROM '.GROUPS_TABLE.'
     1246FROM '.GROUPS_TABLE.'
    12461247ORDER BY name ASC
    12471248;';
    12481249
    1249                                 $result = pwg_query($query);
    1250          
     1250    $result = pwg_query($query);
     1251     
    12511252    while ($row = pwg_db_fetch_assoc($result))
    12521253    {
    1253                 $groups[$row['id']] = $row['name'];
     1254      $groups[$row['id']] = $row['name'];
    12541255    }
    12551256
     
    12581259// +-----------------------------------------------------------------------+
    12591260
    1260                                 $profile_url = get_root_url().'admin.php?page=profile&amp;user_id=';
    1261                                 $perm_url = get_root_url().'admin.php?page=user_perm&amp;user_id=';
     1261    $profile_url = get_root_url().'admin.php?page=profile&amp;user_id=';
     1262    $perm_url = get_root_url().'admin.php?page=user_perm&amp;user_id=';
    12621263
    12631264    $visible_user_list = array();
    12641265    foreach ($page['filtered_users'] as $num => $local_user)
    12651266    {
    1266                 $visible_user_list[] = $local_user;
    1267                                 }
    1268 
    1269                                 foreach ($visible_user_list as $local_user)
    1270     {
    1271                 $groups_string = preg_replace(
    1272                 '/(\d+)/e',
     1267      $visible_user_list[] = $local_user;
     1268    }
     1269
     1270    foreach ($visible_user_list as $local_user)
     1271    {
     1272      $groups_string = preg_replace(
     1273        '/(\d+)/e',
    12731274        "\$groups['$1']",
    12741275        implode(
    1275                 ', ',
    1276             $local_user['groups']
    1277          )
    1278                                                 );
     1276          ', ',
     1277          $local_user['groups']
     1278        )
     1279      );
    12791280
    12801281      $query = '
     
    12971298
    12981299
    1299                                 if (isset($_POST['pref_submit'])
    1300                                 and isset($_POST['selection'])
    1301                         and in_array($local_user['id'], $_POST['selection']))
    1302                                 {
    1303                                                                 $checked = 'checked="checked"';
    1304                                 }
    1305                                                 else
    1306                 {
    1307                                 $checked = '';
    1308                         }
    1309 
    1310                 $properties = array();
    1311                 if ( $local_user['level'] != 0 )
    1312                                                 {
    1313                                 $properties[] = l10n( sprintf('Level %d', $local_user['level']) );
    1314                                                 }
    1315                 $properties[] =
    1316                                 (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true'))
    1317                                 ? l10n('is_high_enabled') : l10n('is_high_disabled');
    1318 
    1319                                                 $expiration = expiration($local_user['id']);
     1300      if (isset($_POST['pref_submit'])
     1301        and isset($_POST['selection'])
     1302        and in_array($local_user['id'], $_POST['selection']))
     1303      {
     1304        $checked = 'checked="checked"';
     1305      }
     1306      else
     1307      {
     1308        $checked = '';
     1309      }
     1310
     1311      $properties = array();
     1312
     1313      if ($local_user['level'] != 0)
     1314      {
     1315        $properties[] = l10n( sprintf('Level %d', $local_user['level']) );
     1316      }
     1317
     1318      $properties[] = (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true'))
     1319        ? l10n('is_high_enabled') : l10n('is_high_disabled');
     1320
     1321      $expiration = expiration($local_user['id']);
    13201322
    13211323      // Template initialization
    13221324      // -----------------------
    1323                         $template->append(
    1324                         'users',
    1325                         array(
    1326                                                 'ID'               => $local_user['id'],
    1327                                 'CHECKED'          => $checked,
    1328                                 'U_PROFILE'        => $profile_url.$local_user['id'],
    1329                                 'U_PERM'           => $perm_url.$local_user['id'],
    1330                                 'USERNAME'         => stripslashes($local_user['username'])
    1331                                   .($local_user['id'] == $conf['guest_id']
    1332                                   ? '<BR>['.l10n('is_the_guest').']' : '')
    1333                                   .($local_user['id'] == $conf['default_user_id']
    1334                                   ? '<BR>['.l10n('is_the_default').']' : ''),
    1335                                   'STATUS' => l10n('user_status_'
    1336                                   .$local_user['status']),
    1337                                                                                                 'EMAIL'            => get_email_address_as_display_text($local_user['email']),
    1338                                 'GROUPS'           => $groups_string,
    1339                                 'REGISTRATION'     => $local_user['registration_date'],
    1340                         'REMINDER'         => $reminder,   
    1341                                 'EXPIRATION'       => $expiration,
    1342                                                                                 )
    1343                                                 );
    1344                                 }   
     1325      $template->append(
     1326        'users',
     1327        array(
     1328          'ID'               => $local_user['id'],
     1329          'CHECKED'          => $checked,
     1330          'U_PROFILE'        => $profile_url.$local_user['id'],
     1331          'U_PERM'           => $perm_url.$local_user['id'],
     1332          'USERNAME'         => stripslashes($local_user['username'])
     1333                                .($local_user['id'] == $conf['guest_id']
     1334                                ? '<BR>['.l10n('is_the_guest').']' : '')
     1335                                .($local_user['id'] == $conf['default_user_id']
     1336                                ? '<BR>['.l10n('is_the_default').']' : ''),
     1337                                'STATUS' => l10n('user_status_'
     1338                                .$local_user['status']),
     1339          'EMAIL'            => get_email_address_as_display_text($local_user['email']),
     1340          'GROUPS'           => $groups_string,
     1341          'REGISTRATION'     => $local_user['registration_date'],
     1342          'REMINDER'         => $reminder,   
     1343          'EXPIRATION'       => $expiration,
     1344        )
     1345      );
     1346    }   
    13451347
    13461348    // Check if validation of register is made by admin or visitor
     
    13611363    // -----------------------
    13621364    $template->assign(
    1363                 array(
     1365      array(
    13641366        'CONFIRM_LOCAL'=> $Confirm_Local,
    13651367        'UAM_VERSION'  => $version,
     
    13711373// |                             errors display                            |
    13721374// +-----------------------------------------------------------------------+
    1373                                 if ( isset ($errors) and count($errors) != 0)
    1374                                 {
    1375                                 $template->assign('errors',array());
    1376                                                 foreach ($errors as $error)
    1377                                 {
    1378                                                                 array_push($page['errors'], $error);
    1379                                 }
    1380                                
     1375    if ( isset ($errors) and count($errors) != 0)
     1376    {
     1377      $template->assign('errors',array());
     1378      foreach ($errors as $error)
     1379      {
     1380        array_push($page['errors'], $error);
     1381      }
     1382   
    13811383
    13821384// +-----------------------------------------------------------------------+
    13831385// |                           templates display                           |
    13841386// +-----------------------------------------------------------------------+
    1385                                 $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/usermanager.tpl');
    1386                 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');             
    1387                 }
     1387    $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/usermanager.tpl');
     1388    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
     1389  }
    13881390  else
    13891391  {
    1390                                 array_push($page['errors'], l10n('UAM_Err_UserManager_Settings'));
     1392    array_push($page['errors'], l10n('UAM_Err_UserManager_Settings'));
    13911393  }
    13921394  break;
     
    13981400// +-----------------------------------------------------------------------+
    13991401// *************************************************************************
    1400                 case 'ghosttracker':
     1402  case 'ghosttracker':
    14011403
    14021404  $conf_UAM = unserialize($conf['UserAdvManager']);
     
    14081410// +-----------------------------------------------------------------------+
    14091411
    1410                                 if (!defined('PHPWG_ROOT_PATH'))
    1411                 {
    1412                                 die('Hacking attempt!');
    1413                 }
    1414          
    1415                 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     1412    if (!defined('PHPWG_ROOT_PATH'))
     1413    {
     1414      die('Hacking attempt!');
     1415    }
     1416     
     1417    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    14161418
    14171419// +-----------------------------------------------------------------------+
    14181420// | Check Access and exit when user status is not ok                      |
    14191421// +-----------------------------------------------------------------------+
    1420                                 check_status(ACCESS_ADMINISTRATOR);
     1422    check_status(ACCESS_ADMINISTRATOR);
    14211423
    14221424// +-----------------------------------------------------------------------+
     
    14241426// +-----------------------------------------------------------------------+
    14251427
    1426                                 $page['filtered_users'] = get_ghost_user_list();
     1428    $page['filtered_users'] = get_ghost_user_list();
    14271429
    14281430// +-----------------------------------------------------------------------+
    14291431// |                            selected users                             |
    14301432// +-----------------------------------------------------------------------+
    1431                                 if (isset($_POST['Del_Selected']))
    1432                                 {
    1433                                 $collection = array();
    1434 
    1435                                                 switch ($_POST['target'])
    1436                 {
    1437                                 case 'all' :
    1438                 {
    1439                                 foreach($page['filtered_users'] as $local_user)
    1440                                 {
    1441                                         array_push($collection, $local_user['id']);
    1442                         }
    1443                                                                 break;
    1444                                                                 }
    1445                 case 'selection' :
    1446                 {
    1447                                 if (isset($_POST['selection']))
    1448                         {
    1449                                         $collection = $_POST['selection'];
    1450                         }
     1433    if (isset($_POST['Del_Selected']))
     1434    {
     1435      $collection = array();
     1436
     1437      switch ($_POST['target'])
     1438      {
     1439        case 'all' :
     1440        {
     1441          foreach($page['filtered_users'] as $local_user)
     1442          {
     1443            array_push($collection, $local_user['id']);
     1444          }
     1445          break;
     1446        }
     1447        case 'selection' :
     1448        {
     1449          if (isset($_POST['selection']))
     1450          {
     1451            $collection = $_POST['selection'];
     1452          }
     1453          break;
     1454        }
     1455      }
     1456
     1457      if (count($collection) == 0)
     1458      {
     1459        array_push($page['errors'], l10n('Select at least one user'));
     1460      }
     1461    }
     1462
     1463// +-----------------------------------------------------------------------+
     1464// |                             delete users                              |
     1465// +-----------------------------------------------------------------------+
     1466    if (isset($_POST['Del_Selected']) and count($collection) > 0)
     1467    {
     1468      if (in_array($conf['guest_id'], $collection))
     1469      {
     1470        array_push($page['errors'], l10n('Guest cannot be deleted'));
     1471      }
     1472      if (($conf['guest_id'] != $conf['default_user_id']) and
     1473        in_array($conf['default_user_id'], $collection))
     1474      {
     1475        array_push($page['errors'], l10n('Default user cannot be deleted'));
     1476      }
     1477      if (in_array($conf['webmaster_id'], $collection))
     1478      {
     1479        array_push($page['errors'], l10n('Webmaster cannot be deleted'));
     1480      }
     1481      if (in_array($user['id'], $collection))
     1482      {
     1483        array_push($page['errors'], l10n('You cannot delete your account'));
     1484      }
     1485
     1486      if (count($page['errors']) == 0)
     1487      {
     1488        foreach ($collection as $user_id)
     1489        {
     1490          delete_user($user_id);
     1491        }
     1492        array_push(
     1493          $page['infos'],
     1494          l10n_dec(
     1495            '%d user deleted', '%d users deleted',
     1496                        count($collection)
     1497          )
     1498        );
     1499
     1500        foreach ($page['filtered_users'] as $filter_key => $filter_user)
     1501        {
     1502          if (in_array($filter_user['id'], $collection))
     1503          {
     1504            unset($page['filtered_users'][$filter_key]);
     1505          }
     1506        }
     1507      }
     1508    }
     1509
     1510// +-----------------------------------------------------------------------+
     1511// |                          Send ghost reminder                          |
     1512// +-----------------------------------------------------------------------+
     1513// +-----------------------------------------------------------------------+
     1514// |                            selected users                             |
     1515// +-----------------------------------------------------------------------+
     1516    if (isset($_POST['Reminder_Email']))
     1517    {
     1518      $collection = array();
     1519
     1520      switch ($_POST['target'])
     1521      {
     1522        case 'all' :
     1523        {
     1524          foreach($page['filtered_users'] as $local_user)
     1525          {
     1526            array_push($collection, $local_user['id']);
     1527          }
     1528          break;
     1529        }
     1530        case 'selection' :
     1531        {
     1532          if (isset($_POST['selection']))
     1533          {
     1534            $collection = $_POST['selection'];
     1535          }
    14511536                break;
    1452                 }
    1453                                                 }
    1454 
    1455                                                 if (count($collection) == 0)
    1456                 {
    1457                                 array_push($page['errors'], l10n('Select at least one user'));
    1458                         }
    1459                                 }
    1460 
    1461 // +-----------------------------------------------------------------------+
    1462 // |                             delete users                              |
    1463 // +-----------------------------------------------------------------------+
    1464                                 if (isset($_POST['Del_Selected']) and count($collection) > 0)
    1465                 {
    1466                                 if (in_array($conf['guest_id'], $collection))
    1467                         {
    1468                                 array_push($page['errors'], l10n('Guest cannot be deleted'));
    1469                 }
    1470                 if (($conf['guest_id'] != $conf['default_user_id']) and
    1471                                 in_array($conf['default_user_id'], $collection))
    1472                 {
    1473                                 array_push($page['errors'], l10n('Default user cannot be deleted'));
    1474                 }
    1475                 if (in_array($conf['webmaster_id'], $collection))
    1476                 {
    1477                                 array_push($page['errors'], l10n('Webmaster cannot be deleted'));
    1478                 }
    1479                 if (in_array($user['id'], $collection))
    1480                 {
    1481                                 array_push($page['errors'], l10n('You cannot delete your account'));
    1482                 }
    1483 
    1484                                                 if (count($page['errors']) == 0)
    1485                 {
    1486                                 foreach ($collection as $user_id)
    1487                 {
    1488                                 delete_user($user_id);
    1489                 }
    1490                         array_push(
    1491                                 $page['infos'],
    1492                         l10n_dec(
    1493                         '%d user deleted', '%d users deleted',
    1494                         count($collection)
    1495                         )
    1496                 );
    1497 
    1498                 foreach ($page['filtered_users'] as $filter_key => $filter_user)
    1499                 {
    1500                                 if (in_array($filter_user['id'], $collection))
    1501                         {
    1502                                         unset($page['filtered_users'][$filter_key]);
    1503                         }
    1504                         }
    1505                                                 }
    1506                                 }
    1507 
    1508 // +-----------------------------------------------------------------------+
    1509 // |                          Send ghost reminder                          |
    1510 // +-----------------------------------------------------------------------+
    1511 // +-----------------------------------------------------------------------+
    1512 // |                            selected users                             |
    1513 // +-----------------------------------------------------------------------+
    1514                                 if (isset($_POST['Reminder_Email']))
    1515                                 {
    1516                                 $collection = array();
    1517 
    1518                                                 switch ($_POST['target'])
    1519                 {
    1520                                 case 'all' :
    1521                 {
    1522                                 foreach($page['filtered_users'] as $local_user)
    1523                         {
    1524                                         array_push($collection, $local_user['id']);
    1525                         }
    1526         break;
    1527                                                                 }
    1528                 case 'selection' :
    1529                 {
    1530                                 if (isset($_POST['selection']))
    1531                         {
    1532                                         $collection = $_POST['selection'];
    1533                         }
    1534                 break;
    1535                 }
    1536                                                 }
    1537 
    1538                 if (count($collection) == 0)
    1539                 {
    1540                                 array_push($page['errors'], l10n('Select at least one user'));
    1541                 }
    1542                                 }
     1537        }
     1538      }
     1539
     1540      if (count($collection) == 0)
     1541      {
     1542        array_push($page['errors'], l10n('Select at least one user'));
     1543      }
     1544    }
    15431545// +-----------------------------------------------------------------------+
    15441546// |                         Send ghost reminder                           |
    15451547// +-----------------------------------------------------------------------+
    1546                                 if (isset($_POST['Reminder_Email']) and count($collection) > 0)
    1547                                 {
    1548                                                 if (in_array($conf['guest_id'], $collection))
    1549                         {
    1550                                 array_push($page['errors'], l10n('UAM_No_reminder_for_Guest'));
    1551                         }
    1552                 if (($conf['guest_id'] != $conf['default_user_id']) and
    1553                                 in_array($conf['default_user_id'], $collection))
    1554                 {
    1555                                 array_push($page['errors'], l10n('UAM_No_reminder_for_default_user'));
    1556                 }
    1557                         if (in_array($conf['webmaster_id'], $collection))
    1558                 {
    1559                                 array_push($page['errors'], l10n('UAM_No_reminder_for_Webmaster'));
    1560                 }
    1561                 if (in_array($user['id'], $collection))
    1562                 {
    1563                                 array_push($page['errors'], l10n('UAM_No_reminder_for_your_account'));
    1564                         }
    1565 
    1566                 if (count($page['errors']) == 0)
    1567                 {
    1568                                 foreach ($collection as $user_id)
    1569                 {
    1570                                                                 $query = '
     1548    if (isset($_POST['Reminder_Email']) and count($collection) > 0)
     1549    {
     1550      if (in_array($conf['guest_id'], $collection))
     1551      {
     1552        array_push($page['errors'], l10n('UAM_No_reminder_for_Guest'));
     1553      }
     1554      if (($conf['guest_id'] != $conf['default_user_id']) and
     1555        in_array($conf['default_user_id'], $collection))
     1556      {
     1557        array_push($page['errors'], l10n('UAM_No_reminder_for_default_user'));
     1558      }
     1559      if (in_array($conf['webmaster_id'], $collection))
     1560      {
     1561        array_push($page['errors'], l10n('UAM_No_reminder_for_Webmaster'));
     1562      }
     1563      if (in_array($user['id'], $collection))
     1564      {
     1565        array_push($page['errors'], l10n('UAM_No_reminder_for_your_account'));
     1566      }
     1567
     1568      if (count($page['errors']) == 0)
     1569      {
     1570        foreach ($collection as $user_id)
     1571        {
     1572          $query = '
    15711573SELECT id, username, mail_address
    1572   FROM '.USERS_TABLE.'
     1574FROM '.USERS_TABLE.'
    15731575WHERE id = '.$user_id.'
    15741576;';
    15751577                                       
    1576                                                                                 $data = pwg_db_fetch_assoc(pwg_query($query));
    1577                                
    1578                                 ghostreminder($user_id,stripslashes($data['username']),$data['mail_address']);                         
    1579                 }
    1580                 array_push(
    1581                                 $page['infos'],
    1582                         l10n_dec(
    1583                         'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent',
    1584                         count($collection)
    1585                         )
    1586                 );
    1587 
    1588                                                                 $page['filtered_users'] = get_ghost_user_list();
    1589                                                 }
    1590                                 }
    1591    
     1578          $data = pwg_db_fetch_assoc(pwg_query($query));
     1579
     1580          ghostreminder($user_id,stripslashes($data['username']),$data['mail_address']);                               
     1581        }
     1582
     1583        array_push(
     1584          $page['infos'],
     1585          l10n_dec(
     1586            'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent',
     1587            count($collection)
     1588          )
     1589        );
     1590
     1591        $page['filtered_users'] = get_ghost_user_list();
     1592      }
     1593    }
     1594
    15921595    if (isset($_POST['GhostTracker_Init']) and is_admin()) //Reset is only allowed for admins !
    15931596    {
    1594                 $query1 = '
     1597      $query1 = '
    15951598SELECT *
    1596   FROM '.USER_LASTVISIT_TABLE.';';
     1599FROM '.USER_LASTVISIT_TABLE.';';
    15971600
    15981601      $count = pwg_db_num_rows(pwg_query($query1));
     
    16001603      if ($count <> 0)
    16011604      {
    1602                 $query = '
     1605        $query = '
    16031606SELECT DISTINCT u.id,
    16041607                ui.status AS status
     
    16141617
    16151618        $result = pwg_query($query);
    1616          
     1619
    16171620        while ($row = pwg_db_fetch_assoc($result))
    16181621        {
     
    16421645
    16431646        $result = pwg_query($query);
    1644          
     1647
    16451648        while($row = pwg_db_fetch_assoc($result))
    16461649        {
    16471650          $dbnow = date("Y-m-d H:i:s");
    1648            
     1651
    16491652          $query = '
    16501653INSERT INTO '.USER_LASTVISIT_TABLE.'
     
    16551658        }
    16561659      }
    1657        
     1660
    16581661      array_push($page['infos'], l10n('UAM_GhostTracker_Init_OK'));
    16591662    }
     
    16671670    {
    16681671      $visible_user_list[] = $local_user;
    1669                                 }
    1670    
    1671                                 foreach ($visible_user_list as $local_user)
     1672    }
     1673
     1674    foreach ($visible_user_list as $local_user)
    16721675        {
    1673                 $reminder = '';
    1674    
     1676      $reminder = '';
     1677
    16751678      if (isset($local_user['reminder']) and $local_user['reminder'] == 'true')
    16761679      {
     
    16811684        $reminder = l10n('UAM_Reminder_Sent_NOK');
    16821685      }
    1683    
     1686
    16841687      if (isset($_POST['pref_submit']) and isset($_POST['selection']) and in_array($local_user['id'], $_POST['selection']))
    1685                                 {
    1686                                                                 $checked = 'checked="checked"';
    1687                                 }
    1688                                                 else
    1689                 {
    1690                                 $checked = '';
    1691                         }
     1688      {
     1689        $checked = 'checked="checked"';
     1690      }
     1691      else
     1692      {
     1693        $checked = '';
     1694      }
    16921695
    16931696      // Template initialization
     
    16961699          'users',
    16971700        array(
    1698                         'ID'          => $local_user['id'],
     1701          'ID'          => $local_user['id'],
    16991702                'CHECKED'     => $checked,
    17001703                'USERNAME'    => stripslashes($local_user['username']),
    1701                                                                                 'EMAIL'       => get_email_address_as_display_text($local_user['email']),
     1704          'EMAIL'       => get_email_address_as_display_text($local_user['email']),
    17021705          'LASTVISIT'   => $local_user['lastvisit'],
    17031706          'REMINDER'    => $reminder,
    1704                                                                 )
    1705                                                 );
    1706                                 }
     1707        )
     1708      );
     1709    }
    17071710
    17081711    // Plugin version inserted
     
    17181721// |                             errors display                            |
    17191722// +-----------------------------------------------------------------------+
    1720                                 if ( isset ($errors) and count($errors) != 0)
    1721                                 {
    1722                                 $template->assign('errors',array());
    1723                                                 foreach ($errors as $error)
    1724                                 {
    1725                                                                 array_push($page['errors'], $error);
    1726                                 }
    1727                                
     1723    if ( isset ($errors) and count($errors) != 0)
     1724    {
     1725      $template->assign('errors',array());
     1726      foreach ($errors as $error)
     1727      {
     1728        array_push($page['errors'], $error);
     1729      }
     1730   
    17281731
    17291732// +-----------------------------------------------------------------------+
    17301733// |                           templates display                           |
    17311734// +-----------------------------------------------------------------------+
    1732                                 $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/ghosttracker.tpl');
     1735    $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/ghosttracker.tpl');
    17331736    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
    1734                 }
     1737  }
    17351738  else
    17361739  {
    1737                                 array_push($page['errors'], l10n('UAM_Err_GhostTracker_Settings'));
     1740    array_push($page['errors'], l10n('UAM_Err_GhostTracker_Settings'));
    17381741  }
    17391742
Note: See TracChangeset for help on using the changeset viewer.