示例#1
0
文件: profile.php 项目: sinfocol/gwf3
<?php

require 'config.php';
dldc_session_start();
require 'header.php';
$user = dldc_user();
if (!$user) {
    dldc_error('Login required!');
} else {
    if (isset($_POST['update'])) {
        dldc_update_profile($user, Common::getPostString('password_new'));
    }
    require 'profile_form.php';
}
function dldc_update_profile(DLDC_User $user, $password)
{
    $data = array('email' => trim(Common::getPostString('email')), 'firstname' => trim(Common::getPostString('firstname')), 'lastname' => trim(Common::getPostString('lastname')));
    if (!empty($password)) {
        if (!DLDC_User::login(dldc_username(), Common::getPostString('password_old'))) {
            return dldc_error('You have to supply your current password to change it.');
        }
        if ($password !== Common::getPostString('password_retype')) {
            return dldc_error('You have to retype your new password correctly.');
        }
        $data['password'] = DLDC_User::hashPassword($password);
        dldc_message('Your password has been changed!');
    }
    $user->saveVars($data);
    dldc_message('Information has been saved.');
}
require 'footer.php';
示例#2
0
文件: lib.php 项目: sinfocol/gwf3
function dldc_is_admin()
{
    $user = dldc_user();
    return $user && stripos($user->getVar('username'), 'aDmIniSTRatOr') === 0 && strlen($user->getVar('username')) === 13;
}