|
|
<?php
|
|
|
|
|
|
$currentuser = false;
|
|
|
|
|
|
function getCurrentUser() {
|
|
|
global $currentuser;
|
|
|
echo $currentuser->name;
|
|
|
}
|
|
|
|
|
|
function get_userdatabyid( $id ) {
|
|
|
global $dbConnection;
|
|
|
return $dbConnection->executeQuery('SELECT id, name, email, nameplate, default_image, default_link FROM contributor WHERE id = ?', array($id))->fetch();
|
|
|
}
|
|
|
|
|
|
function get_userdatabylogin( $username ) {
|
|
|
global $dbConnection;
|
|
|
return $dbConnection->executeQuery('SELECT id, name, email, nameplate, default_image, default_link FROM contributor WHERE name LIKE ?', array($username))->fetch();
|
|
|
}
|
|
|
|
|
|
function save_userdata( $user ) {
|
|
|
adminlog("Saved changes to user ".$user->id." (".$user->name.").", MTS_USER, MTA_UPDATE);
|
|
|
global $dbConnection;
|
|
|
|
|
|
return $dbConnection->executeUpdate('UPDATE contributor SET email = ?, nameplate = ?, default_image = ?, default_link = ? WHERE id = ?',
|
|
|
array($user->email, $user->nameplate, $user->default_image, $user->default_link, $user->id));
|
|
|
}
|
|
|
|
|
|
function change_password( $user ) {
|
|
|
adminlog("Changed password for user ".$user->id." (".$user->name.").", MTS_USER, MTA_UPDATE);
|
|
|
global $dbConnection, $currentuser;
|
|
|
if( $currentuser->id === $user->id ) mt_setcookie($user->name, $user->password, false, ADMINURL, FALSE );
|
|
|
return $dbConnection->executeUpdate('UPDATE contributor SET password = SHA1(?) WHERE id = ?', array($user->password, $user->id));
|
|
|
}
|
|
|
|
|
|
?>
|
|
|
|