nilsteampassnet /
TeamPass
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * |
||
| 4 | * @package index.php |
||
| 5 | * @author Nils Laumaillé <[email protected]> |
||
| 6 | * @version 2.1.27 |
||
| 7 | * @copyright 2009-2018 Nils Laumaillé |
||
| 8 | * @license GNU GPL-3.0 |
||
| 9 | * @link https://www.teampass.net |
||
| 10 | * |
||
| 11 | * This library is distributed in the hope that it will be useful, |
||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 14 | */ |
||
| 15 | |||
| 16 | require_once './sources/SecureHandler.php'; |
||
| 17 | session_start(); |
||
| 18 | if (isset($_SESSION['CPM']) === false || $_SESSION['CPM'] != 1 |
||
| 19 | || isset($_SESSION['user_id']) === false || empty($_SESSION['user_id']) === true |
||
| 20 | || isset($_SESSION['key']) === false || empty($_SESSION['key']) === true |
||
| 21 | ) { |
||
| 22 | die('Hacking attempt...'); |
||
| 23 | } |
||
| 24 | |||
| 25 | // Load config |
||
| 26 | if (file_exists('../includes/config/tp.config.php')) { |
||
| 27 | include_once '../includes/config/tp.config.php'; |
||
| 28 | } elseif (file_exists('./includes/config/tp.config.php')) { |
||
| 29 | include_once './includes/config/tp.config.php'; |
||
| 30 | } else { |
||
| 31 | throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1); |
||
| 32 | } |
||
| 33 | |||
| 34 | /* do checks */ |
||
| 35 | require_once $SETTINGS['cpassman_dir'].'/includes/config/include.php'; |
||
| 36 | require_once $SETTINGS['cpassman_dir'].'/sources/checks.php'; |
||
| 37 | if (checkUser($_SESSION['user_id'], $_SESSION['key'], "home") === false) { |
||
| 38 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 39 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 40 | exit(); |
||
| 41 | } |
||
| 42 | |||
| 43 | require $SETTINGS['cpassman_dir'].'/includes/language/'.$_SESSION['user_language'].'.php'; |
||
| 44 | require $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
||
| 45 | require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
||
| 46 | header("Content-type: text/html; charset=utf-8"); |
||
| 47 | header("Cache-Control: no-cache, no-store, must-revalidate"); |
||
| 48 | |||
| 49 | // reload user avatar |
||
| 50 | $userData = DB::queryFirstRow( |
||
|
0 ignored issues
–
show
|
|||
| 51 | "SELECT avatar, avatar_thumb |
||
| 52 | FROM ".prefix_table("users")." |
||
| 53 | WHERE id=%i", |
||
| 54 | $_SESSION['user_id'] |
||
| 55 | ); |
||
| 56 | $_SESSION['user_avatar'] = $userData['avatar']; |
||
| 57 | $_SESSION['user_avatar_thumb'] = $userData['avatar_thumb']; |
||
| 58 | |||
| 59 | // prepare avatar |
||
| 60 | if (isset($userData['avatar']) && !empty($userData['avatar'])) { |
||
| 61 | if (file_exists('includes/avatars/'.$userData['avatar'])) { |
||
| 62 | $avatar = $SETTINGS['cpassman_url'].'/includes/avatars/'.$userData['avatar']; |
||
| 63 | } else { |
||
| 64 | $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg'; |
||
| 65 | } |
||
| 66 | } else { |
||
| 67 | $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg'; |
||
| 68 | } |
||
| 69 | |||
| 70 | // user type |
||
| 71 | if (isset($LANG) === true) { |
||
| 72 | if ($_SESSION['user_admin'] === '1') { |
||
| 73 | $_SESSION['user_privilege'] = $LANG['god']; |
||
| 74 | } elseif ($_SESSION['user_manager'] === '1') { |
||
| 75 | $_SESSION['user_privilege'] = $LANG['gestionnaire']; |
||
| 76 | } elseif ($_SESSION['user_read_only'] === '1') { |
||
| 77 | $_SESSION['user_privilege'] = $LANG['read_only_account']; |
||
| 78 | } elseif ($_SESSION['user_can_manage_all_users'] === '1') { |
||
| 79 | $_SESSION['user_privilege'] = $LANG['human_resources']; |
||
| 80 | } else { |
||
| 81 | $_SESSION['user_privilege'] = $LANG['user']; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | // prepare list of timezones |
||
| 86 | foreach (timezone_identifiers_list() as $zone) { |
||
| 87 | $arrayTimezones[$zone] = $zone; |
||
| 88 | } |
||
| 89 | |||
| 90 | // prepare lsit of flags |
||
| 91 | $rows = DB::query("SELECT label FROM ".prefix_table("languages")." ORDER BY label ASC"); |
||
| 92 | foreach ($rows as $record) { |
||
| 93 | $arraFlags[$record['label']] = $record['label']; |
||
| 94 | } |
||
| 95 | |||
| 96 | header("access-control-allow-origin: *"); |
||
| 97 | echo ' |
||
| 98 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||
| 99 | <html> |
||
| 100 | <head> |
||
| 101 | <title>User Profile</title> |
||
| 102 | </head> |
||
| 103 | <body>'; |
||
| 104 | |||
| 105 | echo ' |
||
| 106 | <input type="hidden" id="profile_user_token" value="" />'; |
||
| 107 | |||
| 108 | // Get info about personal_saltkey_security_level |
||
| 109 | if (isset($SETTINGS['personal_saltkey_security_level']) === true && empty($SETTINGS['personal_saltkey_security_level']) === false) { |
||
| 110 | echo ' |
||
| 111 | <input type="hidden" id="input_personal_saltkey_security_level" value="'.$SETTINGS['personal_saltkey_security_level'].'" />'; |
||
| 112 | } else { |
||
| 113 | echo ' |
||
| 114 | <input type="hidden" id="input_personal_saltkey_security_level" value="" />'; |
||
| 115 | } |
||
| 116 | |||
| 117 | echo ' |
||
| 118 | <table style="margin-left:7px;"> |
||
| 119 | <tr> |
||
| 120 | <td rowspan="4" style="width:94px"> |
||
| 121 | <div id="profile_photo" class="ui-widget ui-state-highlight tip" style="padding:2px; text-align:center; cursor:pointer;" title="'.$LANG['upload_new_avatar'].'"><img src="'.$avatar.'" /></div> |
||
| 122 | </td> |
||
| 123 | <td style="width:70px;"> '.$LANG['name'].':</td> |
||
| 124 | <td><b>', isset($_SESSION['name']) && !empty($_SESSION['name']) ? $_SESSION['name'].' '.$_SESSION['lastname'] : $_SESSION['login'], '</b></td> |
||
| 125 | </tr> |
||
| 126 | <tr> |
||
| 127 | <td style="width:70px;"> '.$LANG['user_login'].':</td> |
||
| 128 | <td><span style="">'.$_SESSION['login'].'</span></td> |
||
| 129 | </tr> |
||
| 130 | <tr> |
||
| 131 | <td style="width:70px;"> '.$LANG['email'].':</td> |
||
| 132 | <td title="'.$LANG['click_to_change'].'"><span style="cursor:pointer;" class="editable_textarea" id="email_'.$_SESSION['user_id'].'">'.$_SESSION['user_email'].'</span> <i class="fa fa-pencil fa-fw jeditable-activate" style="cursor:pointer;"></i></td> |
||
| 133 | </tr> |
||
| 134 | <tr> |
||
| 135 | <td style="width:70px;"> '.$LANG['role'].':</td> |
||
| 136 | <td>'.$_SESSION['user_privilege'].'</td> |
||
| 137 | </tr> |
||
| 138 | </table> |
||
| 139 | |||
| 140 | <div style="float:left; margin-left:10px;"> |
||
| 141 | <ul class="menu" style=""> |
||
| 142 | <li class="menu_150" style="padding:4px; text-align:left;"><i class="fa fa-bars fa-fw"></i> '.$LANG['admin_actions_title'].' |
||
| 143 | <ul class="menu_250" style="text-align:left;">'; |
||
| 144 | if (!isset($SETTINGS['duo']) || $SETTINGS['duo'] == 0) { |
||
| 145 | echo ' |
||
| 146 | <li id="but_change_password"><i class="fa fa-key fa-fw"></i> '.$LANG['index_change_pw'].'</li>'; |
||
| 147 | } |
||
| 148 | echo ' |
||
| 149 | <li id="but_change_psk"><i class="fa fa-lock fa-fw"></i> '.$LANG['menu_title_new_personal_saltkey'].'</li> |
||
| 150 | <li id="but_reset_psk"><i class="fa fa-eraser fa-fw"></i> '.$LANG['personal_saltkey_lost'].'</li> |
||
| 151 | </ul> |
||
| 152 | </li> |
||
| 153 | </ul> |
||
| 154 | </div> |
||
| 155 | |||
| 156 | <div style="float:left;width:95%;margin:10px 0 5px 10px;"> |
||
| 157 | <hr> |
||
| 158 | <div style="margin-bottom:6px;"> |
||
| 159 | <i class="fa fa-child fa-fw fa-lg"></i> |
||
| 160 | '.$LANG['index_last_seen'].' ', isset($SETTINGS['date_format']) ? date($SETTINGS['date_format'], $_SESSION['derniere_connexion']) : date("d/m/Y", $_SESSION['derniere_connexion']), ' '.$LANG['at'].' ', isset($SETTINGS['time_format']) ? date($SETTINGS['time_format'], $_SESSION['derniere_connexion']) : date("H:i:s", $_SESSION['derniere_connexion']), ' |
||
| 161 | </div>'; |
||
| 162 | if (isset($_SESSION['unsuccessfull_login_attempts']) === true |
||
| 163 | && $_SESSION['unsuccessfull_login_attempts']['nb'] !== 0 |
||
| 164 | ) { |
||
| 165 | echo ' |
||
| 166 | <div style="margin-bottom:6px;" class="', |
||
| 167 | $_SESSION['unsuccessfull_login_attempts']['shown'] === false ? |
||
| 168 | 'ui-widget-content ui-state-error ui-corner-all' |
||
| 169 | : |
||
| 170 | '' |
||
| 171 | ,'"> |
||
| 172 | <i class="fa fa-history fa-fw fa-lg"></i> |
||
| 173 | '.$LANG['login_attempts'].': |
||
| 174 | <div style="margin:1px 0 0 36px;">'; |
||
| 175 | foreach ($_SESSION['unsuccessfull_login_attempts']['attempts'] as $entry) { |
||
| 176 | echo '<span class="fa fa-caret-right"></span> '.$entry.'<br/>'; |
||
| 177 | } |
||
| 178 | echo ' |
||
| 179 | </div> |
||
| 180 | </div>'; |
||
| 181 | $_SESSION['unsuccessfull_login_attempts']['shown'] = true; |
||
| 182 | } |
||
| 183 | if (isset($_SESSION['last_pw_change']) && !empty($_SESSION['last_pw_change'])) { |
||
| 184 | // Handle last password change string |
||
| 185 | if (isset($_SESSION['last_pw_change']) === true) { |
||
| 186 | if (isset($SETTINGS['date_format']) === true) { |
||
| 187 | $last_pw_change = date($SETTINGS['date_format'], $_SESSION['last_pw_change']); |
||
| 188 | } else { |
||
| 189 | $last_pw_change = date("d/m/Y", $_SESSION['last_pw_change']); |
||
| 190 | } |
||
| 191 | } else { |
||
| 192 | $last_pw_change = "-"; |
||
| 193 | } |
||
| 194 | |||
| 195 | // Handle expiration for pw |
||
| 196 | if (isset($_SESSION['numDaysBeforePwExpiration']) === false || |
||
| 197 | $_SESSION['numDaysBeforePwExpiration'] === '' || |
||
| 198 | $_SESSION['numDaysBeforePwExpiration'] === 'infinite' |
||
| 199 | ) { |
||
| 200 | $numDaysBeforePwExpiration = ''; |
||
| 201 | } else { |
||
| 202 | $numDaysBeforePwExpiration = $LANG['index_pw_expiration'].' '.$_SESSION['numDaysBeforePwExpiration'].' '.$LANG['days'].'.'; |
||
| 203 | } |
||
| 204 | echo ' |
||
| 205 | <div style="margin-bottom:6px;"> |
||
| 206 | <i class="fa fa-calendar fa-fw fa-lg"></i> '.$LANG['index_last_pw_change'].' '.$last_pw_change.'. '.$numDaysBeforePwExpiration.' |
||
| 207 | </div>'; |
||
| 208 | } |
||
| 209 | echo ' |
||
| 210 | <div style="margin-bottom:6px;margin-top:6px;"> |
||
| 211 | <i class="fa fa-cloud-upload fa-fw fa-lg"></i> |
||
| 212 | <span id="plupload_runtime2" class="ui-state-error ui-corner-all" style="width:350px;">'.$LANG['error_upload_runtime_not_found'].'</span> |
||
| 213 | <input type="hidden" id="upload_enabled2" value="" /> |
||
| 214 | </div> |
||
| 215 | <hr> |
||
| 216 | <div style="margin-bottom:6px;"> |
||
| 217 | <i class="fa fa-code-fork fa-fw fa-lg"></i> '. $LANG['tree_load_strategy'].': <span style="cursor:pointer; font-weight:bold;" class="editable_select" id="treeloadstrategy_'.$_SESSION['user_id'].'" title="'.$LANG['click_to_change'].'">'.$_SESSION['user_settings']['treeloadstrategy'].'</span> <i class="fa fa-pencil fa-fw jeditable-activate" style="cursor:pointer;"></i> |
||
| 218 | </div>'; |
||
| 219 | |||
| 220 | if ((isset($_SESSION['user_settings']['usertimezone']) === true && $_SESSION['user_settings']['usertimezone'] !== "not_defined") || isset($SETTINGS['timezone']) === true) { |
||
| 221 | echo ' |
||
| 222 | <div style="margin-bottom:6px;"> |
||
| 223 | <i class="fa fa-clock-o fa-fw fa-lg"></i> '. $LANG['timezone_selection'].': <span style="cursor:pointer; font-weight:bold;" class="editable_timezone" id="usertimezone_'.$_SESSION['user_id'].'" title="'.$LANG['click_to_change'].'">', (isset($_SESSION['user_settings']['usertimezone']) && $_SESSION['user_settings']['usertimezone'] !== "not_defined") ? $_SESSION['user_settings']['usertimezone'] : $SETTINGS['timezone'], '</span> <i class="fa fa-pencil fa-fw jeditable-activate" style="cursor:pointer;"></i> |
||
| 224 | </div>'; |
||
| 225 | } |
||
| 226 | |||
| 227 | echo ' |
||
| 228 | <div style="margin-bottom:6px;"> |
||
| 229 | <i class="fa fa-language fa-fw fa-lg"></i> '. $LANG['user_language'].': <span style="cursor:pointer; font-weight:bold;" class="editable_language" id="userlanguage_'.$_SESSION['user_id'].'" title="'.$LANG['click_to_change'].'">', isset($_SESSION['user_language']) ? $_SESSION['user_language'] : $SETTINGS['default_language'], '</span> <i class="fa fa-pencil fa-fw jeditable-activate" style="cursor:pointer;"></i> |
||
| 230 | </div>'; |
||
| 231 | |||
| 232 | |||
| 233 | if (isset($SETTINGS['api']) && $SETTINGS['api'] === '1') { |
||
| 234 | echo ' |
||
| 235 | <div style="margin-bottom:6px;"> |
||
| 236 | <i class="fa fa-paper-plane fa-lg"></i> '. $LANG['user_profile_api_key'].': <span style="font-weight:bold;" id="user_api_key" title="">', isset($_SESSION['user_settings']['api-key']) === true ? $_SESSION['user_settings']['api-key'] : '', '</span> <i class="fa fa-refresh fa-fw" style="cursor:pointer;" id="but_new_api"></i> |
||
| 237 | </div>'; |
||
| 238 | } |
||
| 239 | |||
| 240 | if (isset($SETTINGS['agses_authentication_enabled']) && $SETTINGS['agses_authentication_enabled'] == 1) { |
||
| 241 | echo ' |
||
| 242 | <hr> |
||
| 243 | |||
| 244 | <div style="margin-bottom:6px;"> |
||
| 245 | <i class="fa fa-id-card-o fa-lg"></i> '. $LANG['user_profile_agses_card_id'].': <span style="cursor:pointer; font-weight:bold;" class="editable_textarea" id="agses-usercardid_'.$_SESSION['user_id'].'" title="'.$LANG['click_to_change'].'">', isset($_SESSION['user_settings']['agses-usercardid']) ? $_SESSION['user_settings']['agses-usercardid'] : '', '</span> <i class="fa fa-pencil fa-fw jeditable-activate" style="cursor:pointer;"></i> |
||
| 246 | </div>'; |
||
| 247 | } |
||
| 248 | |||
| 249 | echo ' |
||
| 250 | </div> |
||
| 251 | |||
| 252 | <hr> |
||
| 253 | |||
| 254 | <div style="display:none;margin:3px 0 10px 0;text-align:center;padding:4px;" id="field_warning" class="ui-widget-content ui-state-error ui-corner-all"></div> |
||
| 255 | |||
| 256 | <div style="float:left;width:100%;margin-top:3px;"> |
||
| 257 | <div style="text-align:center;margin:5px;padding:3px;display:none;" id="profile_info_box" class="ui-widget ui-state-highlight ui-corner-all"></div> |
||
| 258 | <div style="height:20px;text-align:center;margin:2px;" id="change_pwd_error" class=""></div> |
||
| 259 | <div id="upload_container_photo" style="display:none;"></div> |
||
| 260 | <div id="filelist_photo" style="display:none;"></div>'; |
||
| 261 | |||
| 262 | // if DUOSecurity enabled then changing PWD is not allowed |
||
| 263 | if (isset($SETTINGS['duo']) === false || $SETTINGS['duo'] == 0) { |
||
| 264 | echo ' |
||
| 265 | <div id="div_change_password" style="display:none; padding:5px;" class="ui-widget ui-state-default"> |
||
| 266 | <div style="text-align:center;margin:5px;padding:3px;" id="change_pwd_complexPw" class="ui-widget ui-state-active ui-corner-all"></div> |
||
| 267 | <label for="new_pw" class="form_label">'.$LANG['index_new_pw'].' :</label> |
||
| 268 | <input type="password" size="15" name="new_pw" id="new_pw" /> |
||
| 269 | <br /> |
||
| 270 | <label for="new_pw2" class="form_label">'.$LANG['index_change_pw_confirmation'].' :</label> |
||
| 271 | <input type="password" size="15" name="new_pw2" id="new_pw2" /> |
||
| 272 | |||
| 273 | <div id="pw_strength" style="margin:10px 0 10px 120px;text-align:center;"></div> |
||
| 274 | <input type="hidden" id="pw_strength_value" /> |
||
| 275 | |||
| 276 | <span class="button" id="button_change_pw">'.$LANG['index_change_pw_button'].'</span> |
||
| 277 | <span id="password_change_wait" style="display:none;"><i class="fa fa-cog fa-spin"></i> '.$LANG['please_wait'].'</span> |
||
| 278 | </div>'; |
||
| 279 | } |
||
| 280 | |||
| 281 | //change the saltkey dialogbox |
||
| 282 | echo ' |
||
| 283 | <div id="div_change_psk" style="display:none;padding:5px;" class="ui-widget ui-state-default"> |
||
| 284 | <div style="text-align:center;margin:5px;padding:3px;" id="change_psk_complexPw" class="ui-widget ui-state-active ui-corner-all hidden"></div> |
||
| 285 | <div style="margin-bottom:4px; padding:6px;" class="ui-state-highlight"> |
||
| 286 | <i class="fa fa-exclamation-triangle fa-fw mi-red"></i> '.$LANG['new_saltkey_warning'].' |
||
| 287 | </div> |
||
| 288 | <table border="0"> |
||
| 289 | <tr> |
||
| 290 | <td> |
||
| 291 | <label for="new_personal_saltkey" class="form_label">'.$LANG['new_saltkey'].' :</label> |
||
| 292 | </td> |
||
| 293 | <td> |
||
| 294 | <input type="password" size="30" id="new_personal_saltkey" class="text_without_symbols tip" title="'.$LANG['text_without_symbols'].'" /> |
||
| 295 | </td> |
||
| 296 | </tr> |
||
| 297 | <tr> |
||
| 298 | <td> |
||
| 299 | <label for="new_personal_saltkey_confirm" class="form_label">'.$LANG['confirm'].' :</label> |
||
| 300 | </td> |
||
| 301 | <td> |
||
| 302 | <input type="password" size="30" id="new_personal_saltkey_confirm" value="" class="text_without_symbols" /> |
||
| 303 | </td> |
||
| 304 | </tr> |
||
| 305 | <tr> |
||
| 306 | <td></td> |
||
| 307 | <td> |
||
| 308 | <div id="new_psk_strength" style="margin:3px 0 3px"></div> |
||
| 309 | <input type="hidden" id="new_psk_strength_value" /> |
||
| 310 | </td> |
||
| 311 | </tr> |
||
| 312 | <tr> |
||
| 313 | <td> |
||
| 314 | <label for="old_personal_saltkey" class="form_label" style="margin-top:5px;">'.$LANG['old_saltkey'].' :</label> |
||
| 315 | </td> |
||
| 316 | <td> |
||
| 317 | <input type="text" size="30" name="old_personal_saltkey" id="old_personal_saltkey" value="" class="text_without_symbols" /> |
||
| 318 | </td> |
||
| 319 | </tr> |
||
| 320 | </table> |
||
| 321 | <div style="margin-top:4px;"> |
||
| 322 | <span class="button" id="button_change_psk">'.$LANG['index_change_pw_button'].'</span> |
||
| 323 | <span id="psk_change_wait" style="display:none;"><i class="fa fa-cog fa-spin"></i> <span id="psk_change_wait_info">'.$LANG['please_wait'].'</span></span> |
||
| 324 | </div> |
||
| 325 | </div>'; |
||
| 326 | |||
| 327 | |||
| 328 | //saltkey LOST dialogbox |
||
| 329 | echo ' |
||
| 330 | <div id="div_reset_psk" style="display:none;padding:5px;" class="ui-widget ui-state-default"> |
||
| 331 | <div style="margin-bottom:4px; padding:6px;" class="ui-state-highlight"> |
||
| 332 | <i class="fa fa-exclamation-triangle fa-fw mi-red"></i> '.$LANG['new_saltkey_warning_lost'].' |
||
| 333 | </div> |
||
| 334 | |||
| 335 | <div style="margin-top:4px;"> |
||
| 336 | <input type="checkbox" id="reset_psk_confirm" /> <label for="reset_psk_confirm">'.$LANG['please_confirm_operation'].'</label> |
||
| 337 | </div> |
||
| 338 | |||
| 339 | <div style="margin-top:4px;"> |
||
| 340 | <span class="button" id="button_reset_psk">'.$LANG['continue'].'</span> |
||
| 341 | <span id="psk_reset_wait" style="display:none;"><i class="fa fa-cog fa-spin"></i> <span id="psk_reset_wait_info">'.$LANG['please_wait'].'</span></span> |
||
| 342 | </div> |
||
| 343 | </div>'; |
||
| 344 | echo ' |
||
| 345 | </div>'; |
||
| 346 | |||
| 347 | // Pw complexity levels |
||
| 348 | if (isset($_SESSION['user_language']) && $_SESSION['user_language'] !== "0") { |
||
| 349 | require_once $SETTINGS['cpassman_dir'].'/includes/language/'.$_SESSION['user_language'].'.php'; |
||
| 350 | $SETTINGS_EXT['pwComplexity'] = array( |
||
| 351 | 0=>array(0, $LANG['complex_level0']), |
||
| 352 | 25=>array(25, $LANG['complex_level1']), |
||
| 353 | 50=>array(50, $LANG['complex_level2']), |
||
| 354 | 60=>array(60, $LANG['complex_level3']), |
||
| 355 | 70=>array(70, $LANG['complex_level4']), |
||
| 356 | 80=>array(80, $LANG['complex_level5']), |
||
| 357 | 90=>array(90, $LANG['complex_level6']) |
||
| 358 | ); |
||
| 359 | } |
||
| 360 | ?> |
||
| 361 | <script type="text/javascript" src="includes/js/functions.js"></script> |
||
| 362 | <script type="text/javascript"> |
||
| 363 | $(function() { |
||
| 364 | $(".tip").tooltipster({multiple: true}); |
||
| 365 | // password |
||
| 366 | $("#but_change_password").click(function() { |
||
| 367 | $("#change_pwd_complexPw").html("<?php echo $LANG['complex_asked']; ?> : <?php echo $SETTINGS_EXT['pwComplexity'][$_SESSION['user_pw_complexity']][1]; ?>"); |
||
| 368 | $("#change_pwd_error").hide(); |
||
| 369 | $("#div_change_psk, #div_reset_psk").hide(); |
||
| 370 | |||
| 371 | if ($("#div_change_password").not(":visible")) { |
||
| 372 | $("#div_change_password").show(); |
||
| 373 | $("#dialog_user_profil").dialog("option", "height", 580); |
||
| 374 | } |
||
| 375 | }); |
||
| 376 | |||
| 377 | //Password meter |
||
| 378 | $("#new_pw").simplePassMeter({ |
||
| 379 | "requirements": {}, |
||
| 380 | "container": "#pw_strength", |
||
| 381 | "defaultText" : "<?php echo $LANG['index_pw_level_txt']; ?>", |
||
| 382 | "ratings": [ |
||
| 383 | {"minScore": 0, |
||
| 384 | "className": "meterFail", |
||
| 385 | "text": "<?php echo $LANG['complex_level0']; ?>" |
||
| 386 | }, |
||
| 387 | {"minScore": 25, |
||
| 388 | "className": "meterWarn", |
||
| 389 | "text": "<?php echo $LANG['complex_level1']; ?>" |
||
| 390 | }, |
||
| 391 | {"minScore": 50, |
||
| 392 | "className": "meterWarn", |
||
| 393 | "text": "<?php echo $LANG['complex_level2']; ?>" |
||
| 394 | }, |
||
| 395 | {"minScore": 60, |
||
| 396 | "className": "meterGood", |
||
| 397 | "text": "<?php echo $LANG['complex_level3']; ?>" |
||
| 398 | }, |
||
| 399 | {"minScore": 70, |
||
| 400 | "className": "meterGood", |
||
| 401 | "text": "<?php echo $LANG['complex_level4']; ?>" |
||
| 402 | }, |
||
| 403 | {"minScore": 80, |
||
| 404 | "className": "meterExcel", |
||
| 405 | "text": "<?php echo $LANG['complex_level5']; ?>" |
||
| 406 | }, |
||
| 407 | {"minScore": 90, |
||
| 408 | "className": "meterExcel", |
||
| 409 | "text": "<?php echo $LANG['complex_level6']; ?>" |
||
| 410 | } |
||
| 411 | ] |
||
| 412 | }); |
||
| 413 | $("#new_pw").bind({ |
||
| 414 | "score.simplePassMeter": function(jQEvent, score) { |
||
| 415 | $("#pw_strength_value").val(score); |
||
| 416 | } |
||
| 417 | }); |
||
| 418 | |||
| 419 | // For Personal Saltkey |
||
| 420 | $("#new_personal_saltkey").simplePassMeter({ |
||
| 421 | "requirements": {}, |
||
| 422 | "container": "#new_psk_strength", |
||
| 423 | "defaultText" : "<?php echo $LANG['index_pw_level_txt']; ?>", |
||
| 424 | "ratings": [ |
||
| 425 | {"minScore": 0, |
||
| 426 | "className": "meterFail", |
||
| 427 | "text": "<?php echo $LANG['complex_level0']; ?>" |
||
| 428 | }, |
||
| 429 | {"minScore": 25, |
||
| 430 | "className": "meterWarn", |
||
| 431 | "text": "<?php echo $LANG['complex_level1']; ?>" |
||
| 432 | }, |
||
| 433 | {"minScore": 50, |
||
| 434 | "className": "meterWarn", |
||
| 435 | "text": "<?php echo $LANG['complex_level2']; ?>" |
||
| 436 | }, |
||
| 437 | {"minScore": 60, |
||
| 438 | "className": "meterGood", |
||
| 439 | "text": "<?php echo $LANG['complex_level3']; ?>" |
||
| 440 | }, |
||
| 441 | {"minScore": 70, |
||
| 442 | "className": "meterGood", |
||
| 443 | "text": "<?php echo $LANG['complex_level4']; ?>" |
||
| 444 | }, |
||
| 445 | {"minScore": 80, |
||
| 446 | "className": "meterExcel", |
||
| 447 | "text": "<?php echo $LANG['complex_level5']; ?>" |
||
| 448 | }, |
||
| 449 | {"minScore": 90, |
||
| 450 | "className": "meterExcel", |
||
| 451 | "text": "<?php echo $LANG['complex_level6']; ?>" |
||
| 452 | } |
||
| 453 | ] |
||
| 454 | }); |
||
| 455 | $("#new_personal_saltkey").bind({ |
||
| 456 | "score.simplePassMeter": function(jQEvent, score) { |
||
| 457 | $("#new_psk_strength_value").val(score); |
||
| 458 | } |
||
| 459 | }); |
||
| 460 | |||
| 461 | // launch password change |
||
| 462 | $("#button_change_pw").click(function() { |
||
| 463 | $("#change_pwd_error").addClass("ui-state-error ui-corner-all").hide(); |
||
| 464 | if ($("#new_pw").val() != "" && $("#new_pw").val() == $("#new_pw2").val()) { |
||
| 465 | if (parseInt($("#pw_strength_value").val()) >= parseInt($("#user_pw_complexity").val())) { |
||
| 466 | $("#password_change_wait").show(); |
||
| 467 | var data = '{"new_pw":"'+sanitizeString($("#new_pw").val())+'"}'; |
||
| 468 | $.post( |
||
| 469 | "sources/main.queries.php", |
||
| 470 | { |
||
| 471 | type : "change_pw", |
||
| 472 | change_pw_origine : "user_change", |
||
| 473 | complexity : $("#pw_strength_value").val(), |
||
| 474 | data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key']; ?>") |
||
| 475 | }, |
||
| 476 | function(data) { |
||
| 477 | if (data[0].error == "already_used") { |
||
| 478 | $("#new_pw, #new_pw2").val(""); |
||
| 479 | $("#change_pwd_error").addClass("ui-state-error ui-corner-all").show().html("<span><?php echo $LANG['pw_used']; ?></span>"); |
||
| 480 | } else if (data[0].error == "complexity_level_not_reached") { |
||
| 481 | $("#new_pw, #new_pw2").val(""); |
||
| 482 | $("#change_pwd_error").addClass("ui-state-error ui-corner-all").show().html("<span><?php echo $LANG['error_complex_not_enought']; ?></span>"); |
||
| 483 | } else if (data[0].error == "pwd_hash_not_correct") { |
||
| 484 | $("#new_pw, #new_pw2").val(""); |
||
| 485 | $("#change_pwd_error").addClass("ui-state-error ui-corner-all").show().html("<span><?php echo $LANG['error_not_allowed_to']; ?></span>"); |
||
| 486 | } else { |
||
| 487 | $("#div_change_password").hide(); |
||
| 488 | $("#dialog_user_profil").dialog("option", "height", 450); |
||
| 489 | $("#new_pw, #new_pw2").val(""); |
||
| 490 | } |
||
| 491 | $("#password_change_wait").hide(); |
||
| 492 | $("#profile_info_box").html("<?php echo $LANG['alert_message_done']; ?>").show(); |
||
| 493 | |||
| 494 | $(this).delay(2000).queue(function() { |
||
| 495 | $("#profile_info_box").effect( "fade", "slow" ); |
||
| 496 | $(this).dequeue(); |
||
| 497 | }); |
||
| 498 | }, |
||
| 499 | "json" |
||
| 500 | ); |
||
| 501 | } else { |
||
| 502 | $("#change_pwd_error").addClass("ui-state-error ui-corner-all").show().html("<?php echo $LANG['error_complex_not_enought']; ?>"); |
||
| 503 | $(this).delay(1000).queue(function() { |
||
| 504 | $("#change_pwd_error").effect( "fade", "slow" ); |
||
| 505 | $(this).dequeue(); |
||
| 506 | }); |
||
| 507 | } |
||
| 508 | } else { |
||
| 509 | $("#change_pwd_error").addClass("ui-state-error ui-corner-all").show().html("<?php echo $LANG['index_pw_error_identical']; ?>"); |
||
| 510 | $(this).delay(1000).queue(function() { |
||
| 511 | $("#change_pwd_error").effect( "fade", "slow" ); |
||
| 512 | $(this).dequeue(); |
||
| 513 | }); |
||
| 514 | } |
||
| 515 | }); |
||
| 516 | |||
| 517 | // AVATAR IMPORT |
||
| 518 | var uploader_photo = new plupload.Uploader({ |
||
| 519 | runtimes : "gears,html5,flash,silverlight,browserplus", |
||
| 520 | browse_button : "profile_photo", |
||
| 521 | container : "upload_container_photo", |
||
| 522 | max_file_size : "2mb", |
||
| 523 | chunk_size : "1mb", |
||
| 524 | unique_names : true, |
||
| 525 | dragdrop : true, |
||
| 526 | multiple_queues : false, |
||
| 527 | multi_selection : false, |
||
| 528 | max_file_count : 1, |
||
| 529 | filters : [ |
||
| 530 | {title : "PNG files", extensions : "png"} |
||
| 531 | ], |
||
| 532 | resize : { |
||
| 533 | width : "90", |
||
| 534 | height : "90", |
||
| 535 | quality : "90" |
||
| 536 | }, |
||
| 537 | url : "sources/upload/upload.files.php", |
||
| 538 | flash_swf_url : "includes/libraries/Plupload/plupload.flash.swf", |
||
| 539 | silverlight_xap_url : "includes/libraries/Plupload/plupload.silverlight.xap", |
||
| 540 | init: { |
||
| 541 | FilesAdded: function(up, files) { |
||
| 542 | // generate and save token |
||
| 543 | $.post( |
||
| 544 | "sources/main.queries.php", |
||
| 545 | { |
||
| 546 | type : "save_token", |
||
| 547 | size : 25, |
||
| 548 | capital: true, |
||
| 549 | numeric: true, |
||
| 550 | ambiguous: true, |
||
| 551 | reason: "avatar_profile_upload", |
||
| 552 | duration: 10 |
||
| 553 | }, |
||
| 554 | function(data) { |
||
| 555 | $("#profile_user_token").val(data[0].token); |
||
| 556 | up.start(); |
||
| 557 | }, |
||
| 558 | "json" |
||
| 559 | ); |
||
| 560 | }, |
||
| 561 | BeforeUpload: function (up, file) { |
||
| 562 | var tmp = Math.random().toString(36).substring(7); |
||
| 563 | |||
| 564 | up.settings.multipart_params = { |
||
| 565 | "PHPSESSID":"<?php echo $_SESSION['user_id']; ?>", |
||
| 566 | "type_upload":"upload_profile_photo", |
||
| 567 | "user_token": $("#profile_user_token").val() |
||
| 568 | }; |
||
| 569 | } |
||
| 570 | } |
||
| 571 | }); |
||
| 572 | |||
| 573 | // Show runtime status |
||
| 574 | uploader_photo.bind("Init", function(up, params) { |
||
| 575 | $("#plupload_runtime2").html("<?php echo $LANG['runtime_upload']; ?> " + params.runtime).removeClass('ui-state-error'); |
||
| 576 | $("#upload_enabled2").val("1"); |
||
| 577 | }); |
||
| 578 | |||
| 579 | // get error |
||
| 580 | uploader_photo.bind("Error", function(up, err) { |
||
| 581 | $("#filelist_photo").html("<div class='ui-state-error ui-corner-all'>Error: " + err.code + |
||
| 582 | ", Message: " + err.message + |
||
| 583 | (err.file ? ", File: " + err.file.name : "") + |
||
| 584 | "</div>" |
||
| 585 | ); |
||
| 586 | up.refresh(); // Reposition Flash/Silverlight |
||
| 587 | }); |
||
| 588 | |||
| 589 | // get response |
||
| 590 | uploader_photo.bind("FileUploaded", function(up, file, object) { |
||
| 591 | // Decode returned data |
||
| 592 | var myData = prepareExchangedData(object.response, "decode", "<?php echo $_SESSION['key']; ?>"); |
||
| 593 | |||
| 594 | // update form |
||
| 595 | $("#profile_photo").html('<img src="includes/avatars/'+myData.filename+'" />'); |
||
| 596 | $("#user_avatar_thumb").attr('src', 'includes/avatars/'+myData.filename_thumb); |
||
| 597 | $("#filelist_photo").html('').hide(); |
||
| 598 | }); |
||
| 599 | |||
| 600 | uploader_photo.init(); |
||
| 601 | |||
| 602 | $("#profile_photo").click(function() { |
||
| 603 | $("#div_change_psk, #div_reset_psk, #div_change_password").hide(); |
||
| 604 | $("#dialog_user_profil").dialog("option", "height", 450); |
||
| 605 | }); |
||
| 606 | |||
| 607 | //inline editing |
||
| 608 | $(".editable_textarea").editable("sources/users.queries.php", { |
||
| 609 | onsubmit: function(settings, value) { |
||
| 610 | console.log(value); |
||
| 611 | }, |
||
| 612 | indicator : "<img src=\'includes/images/loading.gif\' />", |
||
| 613 | type : "text", |
||
| 614 | submit : "<i class=\'fa fa-check mi-green\'></i> ", |
||
| 615 | cancel : "<i class=\'fa fa-remove mi-red\'></i> ", |
||
| 616 | name : "newValue", |
||
| 617 | width : 220 |
||
| 618 | }); |
||
| 619 | $(".editable_select").editable("sources/users.queries.php", { |
||
| 620 | indicator : "<img src=\'includes/images/loading.gif\' />", |
||
| 621 | data : " {'full':'<?php echo $LANG['full']; ?>','sequential':'<?php echo $LANG['sequential']; ?>', 'selected':'<?php echo $_SESSION['user_settings']['treeloadstrategy']; ?>'}", |
||
| 622 | type : 'select', |
||
| 623 | select : true, |
||
| 624 | onblur : "cancel", |
||
| 625 | submit : "<i class=\'fa fa-check mi-green\'></i> ", |
||
| 626 | cancel : "<i class=\'fa fa-remove mi-red\'></i> ", |
||
| 627 | name : "newValue" |
||
| 628 | }); |
||
| 629 | $(".editable_language").editable("sources/users.queries.php", { |
||
| 630 | indicator : "<img src=\'includes/images/loading.gif\' />", |
||
| 631 | data : '<?php print json_encode($arraFlags); ?>', |
||
| 632 | type : 'select', |
||
| 633 | select : true, |
||
| 634 | onblur : "cancel", |
||
| 635 | submit : "<i class=\'fa fa-check mi-green\'></i> ", |
||
| 636 | cancel : "<i class=\'fa fa-remove mi-red\'></i> ", |
||
| 637 | name : "newValue" |
||
| 638 | }); |
||
| 639 | $(".editable_timezone").editable("sources/users.queries.php", { |
||
| 640 | indicator : "<img src=\'includes/images/loading.gif\' />", |
||
| 641 | data : '<?php print json_encode($arrayTimezones); ?>', |
||
| 642 | type : 'select', |
||
| 643 | select : true, |
||
| 644 | onblur : "cancel", |
||
| 645 | submit : "<i class=\'fa fa-check mi-green\'></i> ", |
||
| 646 | cancel : "<i class=\'fa fa-remove mi-red\'></i> ", |
||
| 647 | name : "newValue" |
||
| 648 | }); |
||
| 649 | $(".editable_yesno").editable("sources/users.queries.php", { |
||
| 650 | indicator : "<img src=\'includes/images/loading.gif\' />", |
||
| 651 | data : '{"O":"<?php echo $LANG['no']; ?>","1":"<?php echo $LANG['yes']; ?>"}', |
||
| 652 | type : 'select', |
||
| 653 | select : true, |
||
| 654 | onblur : "cancel", |
||
| 655 | submit : "<i class=\'fa fa-check mi-green\'></i> ", |
||
| 656 | cancel : "<i class=\'fa fa-remove mi-red\'></i> ", |
||
| 657 | name : "newValue" |
||
| 658 | }); |
||
| 659 | |||
| 660 | $('.jeditable-activate').click(function() { |
||
| 661 | $(this).prev().click(); |
||
| 662 | }); |
||
| 663 | |||
| 664 | |||
| 665 | // PSK |
||
| 666 | $("#but_change_psk").click(function() { |
||
| 667 | // hide other divs |
||
| 668 | $("#div_change_password, #div_reset_psk").hide(); |
||
| 669 | |||
| 670 | // prepare fields |
||
| 671 | $("#new_personal_saltkey").val(""); |
||
| 672 | $("#old_personal_saltkey").val("<?php echo addslashes(str_replace(""", '"', @$_SESSION['user_settings']['clear_psk'])); ?>"); |
||
| 673 | |||
| 674 | // Get personal_saltkey_security_level |
||
| 675 | if ($("#input_personal_saltkey_security_level").val() !== "") { |
||
| 676 | $("#change_psk_complexPw") |
||
| 677 | .html("<?php echo $LANG['complex_asked']; ?> : <?php echo $SETTINGS_EXT['pwComplexity'][$SETTINGS['personal_saltkey_security_level']][1]; ?>") |
||
| 678 | .removeClass("hidden"); |
||
| 679 | } else { |
||
| 680 | $("#change_psk_complexPw").addClass("hidden"); |
||
| 681 | } |
||
| 682 | |||
| 683 | $("#div_change_psk").show(); |
||
| 684 | $("#dialog_user_profil").dialog("option", "height", 690); |
||
| 685 | }); |
||
| 686 | |||
| 687 | // manage CHANGE OF PERSONAL SALTKEY |
||
| 688 | $("#button_change_psk").click(function() { |
||
| 689 | // Check if all fields are filled in |
||
| 690 | if ($("#new_personal_saltkey").val() === "" || $("#new_personal_saltkey_confirm").val() === "" || $("#old_personal_saltkey").val() === "") { |
||
| 691 | $("#psk_change_wait").hide(); |
||
| 692 | $("#div_change_psk").before('<div id="tmp_msg" class="ui-widget ui-state-error ui-corner-all" style="margin-bottom:3px; padding:3px;"><?php echo addslashes($LANG['home_personal_saltkey_label']); ?></div>'); |
||
| 693 | |||
| 694 | $(this).delay(1000).queue(function() { |
||
| 695 | $("#tmp_msg").effect( "fade", "slow" ); |
||
| 696 | $("#tmp_msg").remove(); |
||
| 697 | $(this).dequeue(); |
||
| 698 | }); |
||
| 699 | return false; |
||
| 700 | } |
||
| 701 | |||
| 702 | // Check if psk are similar |
||
| 703 | if ($("#new_personal_saltkey").val() !== $("#new_personal_saltkey_confirm").val()) { |
||
| 704 | $("#psk_change_wait").hide(); |
||
| 705 | $("#div_change_psk").before('<div id="tmp_msg" class="ui-widget ui-state-error ui-corner-all" style="margin-bottom:3px; padding:3px;"><?php echo addslashes($LANG['bad_psk_confirmation']); ?></div>'); |
||
| 706 | |||
| 707 | $(this).delay(1000).queue(function() { |
||
| 708 | $("#tmp_msg").effect( "fade", "slow" ); |
||
| 709 | $("#tmp_msg").remove(); |
||
| 710 | $(this).dequeue(); |
||
| 711 | }); |
||
| 712 | return false; |
||
| 713 | } |
||
| 714 | |||
| 715 | // Check if minimum security level is reched |
||
| 716 | if ($("#input_personal_saltkey_security_level").val() !== "") { |
||
| 717 | if (parseInt($("#new_psk_strength_value").val()) < parseInt($("#input_personal_saltkey_security_level").val())) { |
||
| 718 | $("#change_pwd_error").addClass("ui-state-error ui-corner-all").show().html("<?php echo $LANG['error_complex_not_enought']; ?>"); |
||
| 719 | $(this).delay(1000).queue(function() { |
||
| 720 | $("#change_pwd_error").effect( "fade", "slow" ); |
||
| 721 | $(this).dequeue(); |
||
| 722 | }); |
||
| 723 | return false; |
||
| 724 | } |
||
| 725 | } |
||
| 726 | |||
| 727 | // Show pspinner to user |
||
| 728 | $("#psk_change_wait").show(); |
||
| 729 | |||
| 730 | var data_to_share = "{\"sk\":\"" + sanitizeString($("#new_personal_saltkey").val()) + "\", \"old_sk\":\"" + sanitizeString($("#old_personal_saltkey").val()) + "\"}"; |
||
| 731 | |||
| 732 | $("#psk_change_wait_info").html("... 0%"); |
||
| 733 | |||
| 734 | //Send query |
||
| 735 | $.post( |
||
| 736 | "sources/main.queries.php", |
||
| 737 | { |
||
| 738 | type : "change_personal_saltkey", |
||
| 739 | data_to_share : prepareExchangedData(data_to_share, "encode", "<?php echo $_SESSION['key']; ?>"), |
||
| 740 | key : "<?php echo $_SESSION['key']; ?>" |
||
| 741 | }, |
||
| 742 | function(data) { |
||
| 743 | data = prepareExchangedData(data , "decode", "<?php echo $_SESSION['key']; ?>"); |
||
| 744 | if (data.error === "no") { |
||
| 745 | changePersonalSaltKey(data_to_share, data.list, data.nb_total); |
||
| 746 | } else { |
||
| 747 | $("#psk_change_wait").hide(); |
||
| 748 | $("#div_change_psk").before('<div id="tmp_msg" class="ui-widget ui-state-error ui-corner-all" style="margin-bottom:3px; padding:3px;">' + data.error + '</div>'); |
||
| 749 | |||
| 750 | $(this).delay(3000).queue(function() { |
||
| 751 | $("#tmp_msg").effect( "fade", "slow" ); |
||
| 752 | $("#tmp_msg").remove(); |
||
| 753 | $(this).dequeue(); |
||
| 754 | }); |
||
| 755 | return false; |
||
| 756 | } |
||
| 757 | } |
||
| 758 | ); |
||
| 759 | }); |
||
| 760 | |||
| 761 | |||
| 762 | // RESET PSK |
||
| 763 | $("#but_reset_psk").click(function() { |
||
| 764 | // hide other divs |
||
| 765 | $("#div_change_password, #div_change_psk").hide(); |
||
| 766 | |||
| 767 | // prepare fields |
||
| 768 | $("#new_reset_psk").val(""); |
||
| 769 | |||
| 770 | $("#div_reset_psk").show(); |
||
| 771 | $("#dialog_user_profil").dialog("option", "height", 600); |
||
| 772 | }); |
||
| 773 | $("#button_reset_psk").click(function() { |
||
| 774 | if ($("#reset_psk_confirm").is(":checked")) { |
||
| 775 | $("#psk_reset_wait").show(); |
||
| 776 | |||
| 777 | $.post( |
||
| 778 | "sources/main.queries.php", |
||
| 779 | { |
||
| 780 | type : "reset_personal_saltkey", |
||
| 781 | key : "<?php echo $_SESSION['key']; ?>" |
||
| 782 | }, |
||
| 783 | function(data) { |
||
| 784 | $("#psk_reset_wait").hide(); |
||
| 785 | $("#button_reset_psk").after('<div id="reset_temp"><?php echo $LANG['alert_message_done']; ?></div>'); |
||
| 786 | |||
| 787 | $(this).delay(1500).queue(function() { |
||
| 788 | $("#div_reset_psk").effect( "fade", "slow" ); |
||
| 789 | $("#reset_temp").remove(); |
||
| 790 | $(this).dequeue(); |
||
| 791 | }); |
||
| 792 | |||
| 793 | $("#psk_change_wait_info").html("<?php echo $LANG['alert_message_done']; ?>"); |
||
| 794 | location.reload(); |
||
| 795 | } |
||
| 796 | ); |
||
| 797 | } |
||
| 798 | }); |
||
| 799 | |||
| 800 | $( ".button" ).button(); |
||
| 801 | |||
| 802 | $(".menu").menu({ |
||
| 803 | icon: {}, |
||
| 804 | position: { my: "left top", at: "right top" } |
||
| 805 | }); |
||
| 806 | |||
| 807 | // prevent usage of symbols in Personal saltkey |
||
| 808 | $(".text_without_symbols").bind("keydown", function (event) { |
||
| 809 | switch (event.keyCode) { |
||
| 810 | case 8: // Backspace |
||
| 811 | case 9: // Tab |
||
| 812 | case 13: // Enter |
||
| 813 | case 37: // Left |
||
| 814 | case 38: // Up |
||
| 815 | case 39: // Right |
||
| 816 | case 40: // Down |
||
| 817 | break; |
||
| 818 | default: |
||
| 819 | var regex = new RegExp("^[a-zA-Z0-9.,/#&$@()%*]+$"); |
||
| 820 | var key = event.key; |
||
| 821 | if (!regex.test(key)) { |
||
| 822 | $("#field_warning").html("<?php echo addslashes($LANG['character_not_allowed']); ?>").stop(true,true).show().fadeOut(1000); |
||
| 823 | event.preventDefault(); |
||
| 824 | return false; |
||
| 825 | } |
||
| 826 | break; |
||
| 827 | } |
||
| 828 | }).bind("paste",function(e){ |
||
| 829 | $("#field_warning").html("<?php echo addslashes($LANG['error_not_allowed_to']); ?>").stop(true,true).show().fadeOut(1000); |
||
| 830 | e.preventDefault(); |
||
| 831 | }); |
||
| 832 | |||
| 833 | // If user api is empty then generate one |
||
| 834 | if ($("#user_api_key").text() === "none") { |
||
| 835 | generateNewUserApiKey(); |
||
| 836 | } |
||
| 837 | |||
| 838 | $("#but_new_api").click(function() { |
||
| 839 | generateNewUserApiKey(); |
||
| 840 | }); |
||
| 841 | }); |
||
| 842 | |||
| 843 | |||
| 844 | function changePersonalSaltKey(credentials, ids, nb_total) |
||
| 845 | { |
||
| 846 | // extract current id and adapt list |
||
| 847 | var aIds = ids.split(","); |
||
| 848 | var currentID = aIds[0]; |
||
| 849 | aIds.shift(); |
||
| 850 | var nb = aIds.length; |
||
| 851 | aIds = aIds.toString(); |
||
| 852 | |||
| 853 | if (nb == 0) |
||
| 854 | $("#psk_change_wait_info").html(" ... "+"100%"); |
||
| 855 | else |
||
| 856 | $("#psk_change_wait_info").html(" ... "+Math.floor(((nb_total-nb) / nb_total) * 100)+"%"); |
||
| 857 | |||
| 858 | var data = "{\"psk\":\""+sanitizeString($("#new_personal_saltkey").val())+"\"}"; |
||
| 859 | $.post( |
||
| 860 | "sources/main.queries.php", |
||
| 861 | { |
||
| 862 | type : "store_personal_saltkey", |
||
| 863 | data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key']; ?>"), |
||
| 864 | debug : true, |
||
| 865 | key : "<?php echo $_SESSION['key']; ?>" |
||
| 866 | }, |
||
| 867 | function(data){ |
||
| 868 | if (data[0].error !== "") { |
||
| 869 | // display error |
||
| 870 | $("#psk_change_wait_info").html(data[0].error); |
||
| 871 | $(this).delay(4000).queue(function() { |
||
| 872 | $("#main_info_box").effect( "fade", "slow" ); |
||
| 873 | $(this).dequeue(); |
||
| 874 | }); |
||
| 875 | } else { |
||
| 876 | $.post( |
||
| 877 | "sources/utils.queries.php", |
||
| 878 | { |
||
| 879 | type : "reencrypt_personal_pwd", |
||
| 880 | data_to_share : prepareExchangedData(credentials, "encode", "<?php echo $_SESSION['key']; ?>"), |
||
| 881 | currentId : currentID, |
||
| 882 | key : "<?php echo $_SESSION['key']; ?>" |
||
| 883 | }, |
||
| 884 | function(data){ |
||
| 885 | if (currentID === "") { |
||
| 886 | $("#psk_change_wait_info").html("<?php echo $LANG['alert_message_done']; ?>"); |
||
| 887 | location.reload(); |
||
| 888 | } else { |
||
| 889 | if (data[0].error === "") { |
||
| 890 | changePersonalSaltKey(credentials, aIds, nb_total); |
||
| 891 | } else { |
||
| 892 | $("#psk_change_wait_info").html(data[0].error); |
||
| 893 | } |
||
| 894 | } |
||
| 895 | }, |
||
| 896 | "json" |
||
| 897 | ); |
||
| 898 | } |
||
| 899 | }, |
||
| 900 | "json" |
||
| 901 | ); |
||
| 902 | } |
||
| 903 | |||
| 904 | /* |
||
| 905 | ** |
||
| 906 | */ |
||
| 907 | function generateNewUserApiKey() { |
||
| 908 | var newApiKey = ""; |
||
| 909 | |||
| 910 | // Generate key |
||
| 911 | $.post( |
||
| 912 | "sources/main.queries.php", |
||
| 913 | { |
||
| 914 | type : "generate_a_password", |
||
| 915 | size : "39", |
||
| 916 | lowercase : "true", |
||
| 917 | numerals : "true", |
||
| 918 | capitalize : "true", |
||
| 919 | symbols : "false", |
||
| 920 | secure : "false" |
||
| 921 | }, |
||
| 922 | function(data) { |
||
| 923 | data = prepareExchangedData(data, "decode", "<?php echo $_SESSION['key']; ?>"); |
||
| 924 | if (data.key !== "") { |
||
| 925 | newApiKey = data.key; |
||
| 926 | |||
| 927 | // Save key in session and database |
||
| 928 | var data = "{\"field\":\"user_api_key\" ,\"new_value\":\""+newApiKey+"\" ,\"user_id\":\"<?php echo $_SESSION['user_id']; ?>\"}"; |
||
| 929 | |||
| 930 | $.post( |
||
| 931 | "sources/main.queries.php", |
||
| 932 | { |
||
| 933 | type : "update_user_field", |
||
| 934 | data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key']; ?>"), |
||
| 935 | key : "<?php echo $_SESSION['key']; ?>" |
||
| 936 | }, |
||
| 937 | function(data){ |
||
| 938 | $("#user_api_key").text(newApiKey); |
||
| 939 | } |
||
| 940 | ); |
||
| 941 | } |
||
| 942 | } |
||
| 943 | ); |
||
| 944 | } |
||
| 945 | </script> |
||
| 946 | </body> |
||
| 947 | </html> |
||
| 948 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths