-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dignajar/master
New pull request
- Loading branch information
Showing
19 changed files
with
442 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php defined('BLUDIT') or die('Bludit CMS.'); | ||
|
||
// ============================================================================ | ||
// Functions | ||
// ============================================================================ | ||
|
||
function setPassword($username, $new_password, $confirm_password) | ||
{ | ||
global $dbUsers; | ||
global $Language; | ||
|
||
// Password length | ||
if( strlen($new_password) < 6 ) | ||
{ | ||
Alert::set($Language->g('Password must be at least 6 characters long'), ALERT_STATUS_FAIL); | ||
return false; | ||
} | ||
|
||
if($new_password===$confirm_password) | ||
{ | ||
if( $dbUsers->setPassword($username, $new_password) ) { | ||
Alert::set($Language->g('The changes have been saved'), ALERT_STATUS_OK); | ||
return true; | ||
} | ||
else { | ||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to change the user password.'); | ||
return false; | ||
} | ||
} | ||
else { | ||
Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL); | ||
return false; | ||
} | ||
} | ||
|
||
// ============================================================================ | ||
// Main before POST | ||
// ============================================================================ | ||
|
||
// ============================================================================ | ||
// POST Method | ||
// ============================================================================ | ||
|
||
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) | ||
{ | ||
// Prevent editors to administrate other users. | ||
if($Login->role()!=='admin') | ||
{ | ||
$_POST['username'] = $Login->username(); | ||
unset($_POST['role']); | ||
} | ||
|
||
if( setPassword($_POST['username'], $_POST['new_password'], $_POST['confirm_password']) ) { | ||
Redirect::page('admin', 'users'); | ||
} | ||
} | ||
|
||
// ============================================================================ | ||
// Main after POST | ||
// ============================================================================ | ||
|
||
if($Login->role()!=='admin') { | ||
$layout['parameters'] = $Login->username(); | ||
} | ||
|
||
$_user = $dbUsers->getDb($layout['parameters']); | ||
|
||
// If the user doesn't exist, redirect to the users list. | ||
if($_user===false) { | ||
Redirect::page('admin', 'users'); | ||
} | ||
|
||
$_user['username'] = $layout['parameters']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.