[9230] | 1 | <?php |
---|
| 2 | |
---|
| 3 | global $user, $lang, $conf, $errors; |
---|
| 4 | |
---|
| 5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | Check Access and exit when user status is not ok | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 10 | |
---|
| 11 | if (!defined('LCAS_PATH')) define('LCAS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
| 12 | |
---|
| 13 | //ini_set('error_reporting', E_ALL); |
---|
| 14 | //ini_set('display_errors', true); |
---|
| 15 | |
---|
| 16 | include_once(PHPWG_ROOT_PATH.'include/constants.php'); |
---|
| 17 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 18 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
| 19 | |
---|
| 20 | load_language('plugin.lang', LCAS_PATH); |
---|
| 21 | load_language('help/plugin.lang', LCAS_PATH); |
---|
| 22 | |
---|
| 23 | $error = array(); |
---|
| 24 | |
---|
[9326] | 25 | /* Not useful */ |
---|
| 26 | /*$t = pwg_db_fetch_row(pwg_query(' |
---|
[9230] | 27 | SELECT `value` |
---|
| 28 | FROM `'.CONFIG_TABLE.'` |
---|
| 29 | WHERE `param` = "LoginCaseAccentsSensitivity" |
---|
| 30 | LIMIT 1; |
---|
| 31 | ')); |
---|
| 32 | |
---|
[9326] | 33 | $conf['LoginCaseAccentsSensitivity'] = $t[0];*/ |
---|
[9230] | 34 | |
---|
| 35 | // +-----------------------------------------------------------------------+ |
---|
| 36 | // | Getting plugin version | |
---|
| 37 | // +-----------------------------------------------------------------------+ |
---|
| 38 | $plugin = LCAS_PluginInfos(LCAS_PATH); |
---|
| 39 | $version = $plugin['version']; |
---|
| 40 | |
---|
| 41 | if (isset($_POST['submit']) and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail'])) |
---|
| 42 | { |
---|
| 43 | |
---|
| 44 | /* General configuration settings */ |
---|
| 45 | $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText']))); |
---|
| 46 | |
---|
| 47 | $newconf_LCAS= array( |
---|
| 48 | $_POST['LCAS_Option'], |
---|
| 49 | $_POST['LCAS_Mail'], |
---|
| 50 | $_POST['LCAS_MailText']); |
---|
| 51 | |
---|
| 52 | $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS); |
---|
| 53 | |
---|
| 54 | $query = ' |
---|
| 55 | UPDATE '.CONFIG_TABLE.' |
---|
| 56 | SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'" |
---|
| 57 | WHERE param="LoginCaseAccentsSensitivity" |
---|
| 58 | LIMIT 1 |
---|
| 59 | ;'; |
---|
| 60 | |
---|
| 61 | pwg_query($query); |
---|
| 62 | |
---|
| 63 | array_push($page['infos'], l10n('LCAS_save_config')); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); |
---|
| 67 | |
---|
[9326] | 68 | if (isset($conf_LCAS[0])) |
---|
[9230] | 69 | { |
---|
[9326] | 70 | $case_ins = ($conf_LCAS[0] == '1' or $conf_LCAS[0] == '3'); |
---|
| 71 | $acc_ins = ($conf_LCAS[0] == '2' or $conf_LCAS[0] == '3'); |
---|
[9230] | 72 | |
---|
| 73 | if ($case_ins or $acc_ins) |
---|
| 74 | { |
---|
| 75 | // +-----------------------------------------------------------------------+ |
---|
| 76 | // | initialization | |
---|
| 77 | // +-----------------------------------------------------------------------+ |
---|
| 78 | |
---|
| 79 | $lcas_UserToUpdate = -1; |
---|
| 80 | if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) { |
---|
| 81 | $lcas_UserToUpdate = $_POST['UserToUpdate']; |
---|
| 82 | |
---|
| 83 | if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) { |
---|
[9388] | 84 | // Check if username already exists |
---|
[9230] | 85 | $query = ' |
---|
[9388] | 86 | SELECT username |
---|
| 87 | FROM '.USERS_TABLE.' |
---|
| 88 | WHERE username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'" |
---|
[9230] | 89 | ;'; |
---|
| 90 | |
---|
[9388] | 91 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
| 92 | |
---|
| 93 | if ($count != 0) |
---|
| 94 | { |
---|
| 95 | // Username update |
---|
| 96 | $query = ' |
---|
| 97 | UPDATE '.USERS_TABLE.' |
---|
| 98 | SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'" |
---|
| 99 | WHERE id='.$lcas_UserToUpdate.' |
---|
| 100 | LIMIT 1 |
---|
| 101 | ;'; |
---|
[9230] | 102 | |
---|
[9388] | 103 | pwg_query($query); |
---|
[9230] | 104 | |
---|
[9388] | 105 | if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true') |
---|
| 106 | { |
---|
| 107 | LCAS_SendMail($lcas_UserToUpdate, $_POST['user-'.$lcas_UserToUpdate]); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed')); |
---|
| 111 | } |
---|
| 112 | else |
---|
| 113 | { |
---|
| 114 | // Username already exists |
---|
| 115 | array_push($page['errors'], l10n('LCAS_Err_Userlist_New_Username_Exists')); |
---|
| 116 | } |
---|
[9230] | 117 | } |
---|
| 118 | else { |
---|
[9384] | 119 | // Username is empty |
---|
[9230] | 120 | array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username')); |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | // +-----------------------------------------------------------------------+ |
---|
| 126 | // | user list | |
---|
| 127 | // +-----------------------------------------------------------------------+ |
---|
| 128 | |
---|
[9326] | 129 | $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]); |
---|
[9230] | 130 | |
---|
| 131 | // +-----------------------------------------------------------------------+ |
---|
| 132 | // | user list | |
---|
| 133 | // +-----------------------------------------------------------------------+ |
---|
| 134 | |
---|
| 135 | $lcas_previous_compare_user = ''; |
---|
| 136 | $visible_user_list = array(); |
---|
| 137 | foreach ($page['all_users'] as $local_user) |
---|
| 138 | { |
---|
| 139 | if ($lcas_previous_compare_user != $local_user['transformed']) { |
---|
| 140 | $display = 'orange'; |
---|
| 141 | $lcas_previous_compare_user = $local_user['transformed']; |
---|
| 142 | } |
---|
| 143 | else { |
---|
| 144 | $display = ''; |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | $template->append( |
---|
| 148 | 'users', |
---|
| 149 | array( |
---|
| 150 | 'ID' => $local_user['id'], |
---|
| 151 | 'USERNAME' => stripslashes($local_user['username']), |
---|
| 152 | 'COMPARE' => stripslashes($local_user['transformed']), |
---|
| 153 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
| 154 | 'DISPLAY' => $display, |
---|
| 155 | ) |
---|
| 156 | ); |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | // +-----------------------------------------------------------------------+ |
---|
| 164 | // | templates init | |
---|
| 165 | // +-----------------------------------------------------------------------+ |
---|
| 166 | $template->assign( |
---|
| 167 | array( |
---|
| 168 | 'LCAS_VERSION' => $version, |
---|
| 169 | 'LCAS_PATH' => LCAS_PATH, |
---|
[9326] | 170 | 'LCAS_Option' => $conf_LCAS[0], |
---|
| 171 | 'LCAS_MAIL_TRUE' => $conf_LCAS[1] == 'true' ? 'checked = "checked"' : '' , |
---|
| 172 | 'LCAS_MAIL_FALSE' => $conf_LCAS[1] == 'false' ? 'checked = "checked"' : '' , |
---|
| 173 | 'LCAS_MAILTEXT' => $conf_LCAS[2] |
---|
[9230] | 174 | ) |
---|
| 175 | ); |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | // +-----------------------------------------------------------------------+ |
---|
| 179 | // | errors display | |
---|
| 180 | // +-----------------------------------------------------------------------+ |
---|
| 181 | if (isset ($errors) and count($errors) != 0) |
---|
| 182 | { |
---|
| 183 | $template->assign('errors',array()); |
---|
| 184 | foreach ($errors as $error) |
---|
| 185 | { |
---|
| 186 | array_push($page['errors'], $error); |
---|
| 187 | } |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | // +-----------------------------------------------------------------------+ |
---|
| 191 | // | templates display | |
---|
| 192 | // +-----------------------------------------------------------------------+ |
---|
| 193 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl'); |
---|
| 194 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 195 | |
---|
[8214] | 196 | ?> |
---|