Skip to content

Commit

Permalink
FIX #360
Browse files Browse the repository at this point in the history
  • Loading branch information
haruka-7 committed Jan 7, 2020
1 parent 5c8b5a3 commit 1d6c952
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/lib/class.plx.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ public function editUsers($content, $action=false) {
$this->aUsers[$user_id]['lang'] = (isset($this->aUsers[$user_id]['lang'])?$this->aUsers[$user_id]['lang']:$this->aConf['default_lang']);
$this->aUsers[$user_id]['infos'] = (isset($this->aUsers[$user_id]['infos'])?$this->aUsers[$user_id]['infos']:'');

$this->aUsers[$user_id]['password_token'] = trim($content[$user_id.'_password_token']);
$this->aUsers[$user_id]['password_token_expiry'] = trim($content[$user_id.'_password_token_expiry']);
$this->aUsers[$user_id]['password_token'] = (isset($this->aUsers[$user_id]['_password_token'])?$this->aUsers[$user_id]['_password_token']:'');
$this->aUsers[$user_id]['password_token_expiry'] = (isset($this->aUsers[$user_id]['_password_token_expiry'])?$this->aUsers[$user_id]['_password_token_expiry']:'');
# Hook plugins
eval($this->plxPlugins->callHook('plxAdminEditUsersUpdate'));
$action = true;
Expand Down
23 changes: 23 additions & 0 deletions update/update_5.8.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,27 @@ public function step1() {
}
return true;
}

/**
* Update users file with new fields password_token, password_token_expiry
* @return boolean
*/
public function step2() {
echo L_UPDATE_FILE." (".path('XMLFILE_USERS').")<br />";
$data = file_get_contents(path('XMLFILE_USERS'));
$tag = 'user';
if(preg_match_all('{<'.$tag.'[^>]*>(.*?)</'.$tag.'>}', $data, $matches, PREG_PATTERN_ORDER)) {
foreach($matches[0] as $match) {
if(!preg_match('/<password_token>/', $match)) {
$str = str_replace('</'.$tag.'>', '<password_token><![CDATA[]]></password_token><password_token_expiry><![CDATA[]]></password_token_expiry></'.$tag.'>', $match);
$data = str_replace($match, $str, $data);
}
}
if(!plxUtils::write($data, path('XMLFILE_CATEGORIES'))) {
echo '<p class="error">'.L_UPDATE_ERR_FILE.'</p>';
return false;
}
}
return true;
}
}

0 comments on commit 1d6c952

Please sign in to comment.