function _initialize()
 {
     CheckLogin();
     //检查用户是否登录
     $this->Message = D('message');
     $this->myenid = session('user_en_id');
     //自己用户表的id
 }
Exemple #2
0
 //open connection
 $ch = curl_init();
 //set the url, number of POST vars, POST data
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_POST, count($fields));
 curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 //execute post
 $result = curl_exec($ch);
 $json = json_decode($result, true);
 if ($json["success"] != "true") {
     $err .= "Jūs kļūdījāties ar reCaptcha ievadu!\n";
 }
 //
 $passwords = array("parole" => $ar["parole"], "parole_test" => $ar["parole-test"]);
 $err .= CheckLogin($ar["niks"], "text");
 $err .= Test($passwords, "password");
 // if ($ar["parole"] != $ar["parole-test"])
 //     $err .= "Paroles nesakrīt. Pārbaudiet savu paroli!";
 $err .= Test($ar["vards"], "text") . "\n";
 $err .= Test($ar["uzvards"], "text") . "\n";
 $err .= Test($ar["epasts"], "email") . "\n";
 $err .= Test($ar["talrunis"], "tel") . "\n";
 if (strlen($err) > 0) {
     exit($err . "\nPārbaudiet, vai visi lauki ir pareizi aizpildīti!\n");
 } else {
     $link = DBConnect::GetConnection();
     $stmt = mysqli_prepare($link, "INSERT INTO users (login, password, vards, uzvards, epasts, talrunis) VALUES (?, ?, ?, ?, ?, ?)");
     mysqli_stmt_bind_param($stmt, 'sssssi', $ar["niks"], md5($ar["parole"]), $ar["vards"], $ar["uzvards"], $ar["epasts"], $ar["talrunis"]);
     if (mysqli_stmt_execute($stmt)) {
         echo "success";
    exit;
}
/*=========================================*/
/* パスワード認証(BASIC)                   */
/*=========================================*/
if ($userauth_flg == "1") {
    if (!isset($_SERVER[PHP_AUTH_USER]) || $_SERVER[PHP_AUTH_USER] != $userauth_id || $_SERVER[PHP_AUTH_PW] != $userauth_pwd) {
        header('WWW-Authenticate: Basic realm="w3Analyzer"');
        header('HTTP/1.0 401 Unauthorized');
        echo "Login Failed.";
        exit;
    }
} elseif ($userauth_flg == "2") {
    //セッション開始
    session_start();
    //ログアウト
    if (isset($_GET["logout"])) {
        $_SESSION['login'] = false;
        loginform('ログアウトしました。');
    }
    //ログイン
    if (!$_SESSION['login'] && !CheckLogin($_POST["username"], $_POST["password"])) {
        //ユーザー名のチェック
        if (isset($_POST["username"])) {
            loginform('ユーザー名またはパスワードが違います。');
        } else {
            loginform();
        }
    }
    $_SESSION['login'] = true;
}
Exemple #4
0
<?php

session_start();
include_once "functions.php";
$uid = CheckLogin();
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
include "defs.php3";
$optargs = OptionalPageArguments("confirmed", PAGEARG_BOOLEAN, "description", PAGEARG_STRING, "referrer", PAGEARG_STRING);
$this_user = CheckLogin($check_status);
$referrer = isset($referrer) ? $referrer : $_SERVER['HTTP_REFERER'];
$referrer = urlencode($referrer);
#
# Standard Testbed Header
#
PAGEHEADER("Page Not Working Properly!");
if ($this_user) {
    if (!isset($confirmed)) {
        echo "<center>";
        echo "Are you sure you want to report a problem with:<br>\n              <b>{$referrer}</b><br><br>";
        echo "<form action='pagenotworking.php' method=get>";
        echo "<b>Please tell us briefly what is wrong ...</b>\n";
        echo "<br>\n";
        echo "<textarea name=description rows=10 cols=80></textarea><br>\n";
        echo "<b><input type=hidden name=confirmed value=1></b>";
Exemple #6
0
<?php

if (isset($_GET['username'])) {
    $errors = array();
    $groupid = -1;
    $username = $_GET['username'];
    if (empty($username)) {
        $errors[] = "Please enter the password";
    } else {
        $groupid = CheckLogin($username);
        if ($groupid < 0) {
            switch ($groupid) {
                case -1:
                    $errors[] = "Don't exists";
                    break;
                case -2:
                    $errors[] = "Not printed";
                    break;
                case -3:
                    $errors[] = "Password already used";
                    break;
                case -4:
                    $errors[] = "Shut e";
                    break;
                case -5:
                    $errors[] = "Ush e";
                    break;
                default:
                    $errors[] = "Wrong password";
                    break;
            }
/**
 * Сохраняет данные формы сгенерированной фукцией AdminUserEditor
 *
 * @param  $back_link
 * @param string $a
 * @param int $id
 * @param bool $IsAdmin
 * @return void
 */
function AdminUserEditSave($back_link, $a = 'insert', $id = 0, $IsAdmin = false)
{
    $SystemAdmin = System::user()->isSuperUser();
    $edit = $a == 'update';
    $editProfile = $edit && !$SystemAdmin && $id == System::user()->Get('u_id');
    // Администратор редактирует свой профиль
    $editStatus = false;
    // Разрешено редактирование статуса
    $editType = false;
    // Разрешено редактировать тип пользователя
    // Загружаем данные пользователя из БД
    if ($edit) {
        $user = System::database()->SelectOne('users', "`id`='{$id}'" . ($IsAdmin ? " and `type`='1'" : " and `type`='2'"));
        if (!$user) {
            AddTextBox('Ошибка', '<p align="center">Пользователь не найден, либо у вас не достаточно прав для редактирования администраторов.</p>');
            return;
        }
    }
    // Устанавливаем ограничения доступа
    if ($IsAdmin) {
        // Редактируем администратора
        if ($SystemAdmin) {
            // Только системные администраторы могут редактировать статус и тип администраторов
            if (!$edit) {
                $editStatus = true;
            } elseif (!(groupIsSystem(SafeEnv($user['access'], 11, int)) && GetSystemAdminsCount() <= 1)) {
                // Если он не системный или системных больше 1
                $editStatus = true;
            }
            $editType = $editStatus;
        }
    } else {
        // Если пользователь
        $editStatus = true;
        // Все администраторы с доступом могут редактировать статус пользователя
        $editType = $SystemAdmin;
        // Только системные администраторы могут создавать администраторов
    }
    // Обрабатываем данные
    $errors = array();
    // Логин
    if (isset($_POST['login']) && CheckLogin($_POST['login'], $errors, !$edit)) {
        $login = SafeEnv($_POST['login'], 30, str);
    } else {
        $login = '';
    }
    // Пароль
    $pass = '';
    if (!$edit || $_POST['pass'] != '') {
        $pass_generate_message = '';
        if (isset($_POST['pass']) && CheckPass($_POST['pass'], $errors)) {
            $pass = SafeEnv($_POST['pass'], 30, str);
            if (!isset($_POST['rpass']) || SafeEnv($_POST['rpass'], 30, str) != $pass) {
                $errors[] = 'Пароли не совпадают.';
            }
        } else {
            $pass = '';
        }
        if (isset($_POST['pass']) && $_POST['pass'] == '') {
            srand(time());
            $pass = GenBPass(rand(System::config('user/pass_min_length'), 15));
            $pass_generate_message = '<br />Так как вы не указали пароль, он был сгенерирован автоматически и выслан на указанный E-mail пользователя.';
        }
        $pass2 = md5($pass);
    }
    // e-mail
    if (isset($_POST['email']) && $_POST['email'] != '') {
        if (!CheckEmail($_POST['email'])) {
            $errors[] = 'Не правильный формат E-mail. Он должен быть вида: <b>domain@host.ru</b> .';
        }
        $email = SafeEnv($_POST['email'], 50, str, true);
    } else {
        $email = '';
        $errors[] = 'Вы не ввели E-mail.';
    }
    // Скрыть e-mail
    if (isset($_POST['hideemail'])) {
        $hide_email = '1';
    } else {
        $hide_email = '0';
    }
    // Имя пользователя на сайте
    if (isset($_POST['nikname']) && CheckNikname($_POST['nikname'], $errors, !$edit)) {
        $nik_name = SafeEnv($_POST['nikname'], 50, str, true);
    } else {
        $nik_name = '';
    }
    // Полное имя
    if (isset($_POST['realname'])) {
        $real_name = SafeEnv($_POST['realname'], 250, str, true);
    } else {
        $real_name = '';
    }
    // Возраст
    if (isset($_POST['age'])) {
        if ($_POST['age'] == '' || is_numeric($_POST['age'])) {
            $age = SafeEnv($_POST['age'], 3, int);
        } else {
            $errors[] = 'Ваш возраст должен быть числом!';
        }
    } else {
        $age = '';
    }
    // Домашняя страница
    if (isset($_POST['homepage'])) {
        if ($_POST['homepage'] != '' && substr($_POST['homepage'], 0, 7) == 'http://') {
            $_POST['homepage'] = substr($_POST['homepage'], 7);
        }
        $homepage = SafeEnv($_POST['homepage'], 250, str, true);
    } else {
        $homepage = '';
    }
    // Номер ICQ
    if (isset($_POST['icq'])) {
        if ($_POST['icq'] == '' || is_numeric($_POST['icq'])) {
            $icq = SafeEnv($_POST['icq'], 15, str, true);
        } else {
            $errors[] = 'Номер ICQ должен содержать только числа!';
        }
    } else {
        $icq = '';
    }
    // Город
    if (isset($_POST['city'])) {
        $city = SafeEnv($_POST['city'], 100, str, true);
    } else {
        $city = '';
    }
    // Часовой пояс
    if (isset($_POST['gmt'])) {
        $gmt = SafeEnv($_POST['gmt'], 255, str);
    } else {
        $gmt = System::config('general/default_timezone');
    }
    // О себе
    if (isset($_POST['about'])) {
        $about = SafeEnv($_POST['about'], System::config('user/about_max_length'), str, true);
    } else {
        $about = '';
    }
    // Подписка на новости
    if (isset($_POST['snews'])) {
        $server_news = '1';
    } else {
        $server_news = '0';
    }
    //Обрабатываем аватар
    $updateAvatar = true;
    if (isset($_POST['avatar'])) {
        if (System::config('user/avatar_transfer') == '1' && isset($_FILES['upavatar']) && file_exists($_FILES['upavatar']['tmp_name'])) {
            if ($edit) {
                $avatar = $user['avatar'];
                $a_personal = $user['a_personal'];
            } else {
                $avatar = '';
                $a_personal = '0';
            }
            UserLoadAvatar($errors, $avatar, $a_personal, $avatar, $a_personal, $edit);
        } elseif ($_POST['avatar'] == '') {
            $updateAvatar = false;
        } elseif (file_exists(RealPath2(System::config('general/avatars_dir') . $_POST['avatar']))) {
            if ($edit) {
                if ($user['a_personal'] == '1') {
                    UnlinkUserAvatarFiles($user['avatar']);
                }
            }
            $a_personal = '0';
            $avatar = $_POST['avatar'];
        } else {
            $avatar = '';
            $a_personal = '0';
        }
    } else {
        $avatar = '';
        $a_personal = '0';
    }
    $SendActivation = false;
    if ($edit) {
        $active = SafeEnv($user['active'], 11, int);
        $code = SafeEnv($user['activate'], 11, int);
    } else {
        $active = '1';
        $code = '';
    }
    if ($editStatus) {
        $activate = $_POST['activate'];
        $lastactivate = 'manual';
        if ($active == '0' && $code != '') {
            $lastactivate = 'mail';
        } elseif ($active == '1' && $code == '') {
            $lastactivate = 'auto';
        }
        if ($activate != $lastactivate) {
            switch ($activate) {
                case 'manual':
                    $active = '0';
                    $code = '';
                    $SendActivation = false;
                    break;
                case 'auto':
                    $active = '1';
                    $code = '';
                    $SendActivation = false;
                    break;
                case 'mail':
                    $active = '0';
                    $code = GenRandomString(8, 'qwertyuiopasdfghjklzxcvbnm');
                    $SendActivation = true;
                    break;
            }
        }
    }
    if ($edit) {
        $access = SafeEnv($user['type'], 11, int);
        $user_type = SafeEnv($user['access'], 11, int);
    } else {
        $access = '2';
        $user_type = '-1';
    }
    if ($editType && $_POST['status'] != 'member') {
        $access = '1';
        $user_type = SafeEnv($_POST['status'], 11, int);
    }
    $reg_date = time();
    $last_visit = time();
    $ip = getip();
    $points = 0;
    $visits = 0;
    if ($SendActivation) {
        UserSendActivationMail($nik_name, $email, $login, $pass, $code, $reg_date);
    } elseif (!$edit) {
        UserSendEndRegMail($email, $nik_name, $login, $pass, $reg_date);
    }
    if (!$edit) {
        $values = Values('', $login, $pass2, $nik_name, $real_name, $age, $email, $hide_email, $city, $icq, $homepage, $gmt, $avatar, $about, $server_news, $reg_date, $last_visit, $ip, $points, $visits, $active, $code, $access, $user_type, $a_personal, serialize(array()));
        System::database()->Insert('users', $values);
    } else {
        $set = "`login`='{$login}',`email`='{$email}',`hideemail`='{$hide_email}',`name`='{$nik_name}'," . "`truename`='{$real_name}',`age`='{$age}',`url`='{$homepage}',`icq`='{$icq}',`city`='{$city}'," . "`timezone`='{$gmt}'" . ($updateAvatar == true ? ",`avatar`='{$avatar}',`a_personal`='{$a_personal}'" : '') . "," . "`about`='{$about}',`servernews`='{$server_news}'" . ($pass != '' ? ",`pass`='{$pass2}'" : '') . ",`type`='{$access}'," . "`access`='{$user_type}',`active`='{$active}',`activate`='{$code}'";
        System::database()->Update('users', $set, "`id`='" . $id . "'");
        System::user()->UpdateMemberSession();
        UpdateUserComments($id, $id, $nik_name, $email, $hide_email, $homepage);
    }
    if (count($errors) > 0) {
        $text = 'Аккаунт сохранен, но имели место следующие ошибки:<br /><ul>';
        foreach ($errors as $error) {
            $text .= '<li>' . $error;
        }
        $text .= '</ul>';
        AddTextBox('Внимание', $text);
    } else {
        // Очищаем кэш пользователей
        System::cache()->Delete(system_cache, 'users');
        if (!$editProfile) {
            GO(ADMIN_FILE . '?exe=' . $back_link);
        } else {
            System::admin()->AddCenterBox('Редактирование профиля');
            System::admin()->Highlight('Ваш профиль сохранён, обновите страницу.');
        }
    }
}
Exemple #8
0
//Create request variables that have no default
$request = explode(',', 'cmd,sc,ssc,update,update2,id,pid,isid,inid,mail,note');
foreach ($request as $r) {
    #${$r} = $_REQUEST[$r] ?: '';
    isset($_REQUEST[$r]) ? ${$r} = $_REQUEST[$r] : (${$r} = '');
}
$content = '';
//Logout
if ($cmd == '[LOGOUT]') {
    session_unset();
    session_destroy();
    header("location:?", true, 301);
    exit;
}
//Displays login box when not logged in
if (!CheckLogin()) {
    include 'inc/login-box.htm';
}
#var_dump($_SESSION);
//If no page number selected set page number to 1
isset($_REQUEST['page']) ? $page = $_REQUEST['page'] : ($page = 1);
//Row to start from
$start_from = ($page - 1) * 30;
//If no order by set, order by due back date
isset($_REQUEST['order_by']) ? $order_by = $_REQUEST['order_by'] : ($order_by = 'due_back_date');
//Login conditional
if (isset($_SESSION['login'])) {
    //These are to make login info to variables
    $currentuser = unserialize($_SESSION['login']);
    $first_name = $currentuser['first_name'];
    $user_id = $currentuser['id'];
Exemple #9
0
/* ----- setup variables ----- */
$action = GetVariable("action");
/* edit variables */
$username = GetVariable("username");
$password = GetVariable("password");
//$persistent = GetVariable("persistent");
/* database connection */
$link = mysql_connect($GLOBALS['cfg']['mysqlhost'], $GLOBALS['cfg']['mysqluser'], $GLOBALS['cfg']['mysqlpassword']) or die("Could not connect: " . mysql_error());
mysql_select_db($GLOBALS['cfg']['mysqldatabase']) or die("Could not select database<br>");
/* connect to CAS if enabled */
if ($GLOBALS['cfg']['enablecas']) {
    phpCAS::client(CAS_VERSION_2_0, $GLOBALS['cfg']['casserver'], intval($GLOBALS['cfg']['casport']), $GLOBALS['cfg']['cascontext']);
}
/* ----- determine which action to take ----- */
if ($action == "login") {
    if (!CheckLogin($username, $password)) {
        DisplayLogin("Incorrect login. Make sure Caps Lock is not on");
    } else {
        header("Location: index.php");
    }
} elseif ($action == "logout") {
    DoLogout();
} else {
    if ($GLOBALS['cfg']['enablecas']) {
        $username = AuthenticateCASUser();
        if ($username == "") {
            DisplayLogin("Invalid CAS login");
        } else {
            echo "Created the client (session already exists)...<br>";
            phpCAS::setNoCasServerValidation();
            if (phpCAS::checkAuthentication()) {
Exemple #10
0
<?php

session_start();
include_once "Accounts.php";
include "SiteBanner.php";
echo "<div class='LoginBox'>";
if (CheckLogin()) {
    echo "Successfully Logged In";
    $loginValues = ['Username', 'Password'];
    $login = GetList($loginValues);
    $User = GetUser($login[0]);
    $_SESSION['Username'] = $login[0];
    $_SESSION['Role'] = $User['Role'];
    header('Location: Loading.php?Action=Login');
} else {
    if (!empty($_GET['Username'])) {
        echo '<h1>Invalid Login</h1>';
    }
}
?>
		
			<h1>Welcome, Please Login</h1>
			<form action="Login.php" method="get">
				<div class="InputLine"><label>Username</label>  <input name="Username" type="text"></input></div>
				<div class="InputLine"><label>Password</label>  <input name="Password" type="password"></input></div>
				<button type="submit">Login</button>
			</form>
		</div>
	</Body>
</HTML>
Exemple #11
0
 } else {
     if ($cmd == "checklogin") {
         if (strlen($req->data) < 4) {
             SendDataAndDie(4, "");
         }
         $res = CheckLogin($req->data);
         if ($res === false) {
             SendDataAndDie(666, "");
         }
         SendDataAndDie(200, $res);
     } else {
         if ($cmd == "registration") {
             if (!isset($req->data->login) || !isset($req->data->password) || !isset($req->data->soctype)) {
                 SendDataAndDie(4, "");
             }
             $res = CheckLogin($req->data->login);
             if ($res === 1) {
                 SendDataAndDie(666, "");
             }
             $res = Registration($req->data->login, $req->data->password, $req->data->soctype);
             if ($res === false) {
                 SendDataAndDie(666, "");
             }
             SendDataAndDie(200, "");
         } else {
             if ($cmd == "getsoctypes") {
                 $res = GetSocTypes();
                 if ($res === false) {
                     SendDataAndDie(666, "");
                 }
                 SendDataAndDie(200, $res);
			<p>Запишите или запомните введённые данные!</p>
		');
        $this->SetContent($text);
        $this->AddSubmitButton('Сохранить');
        break;
    case 2:
        $errors = array();
        $admin_login = $_POST['login'];
        $admin_pass = $_POST['pass'];
        $admin_email = $_POST['email'];
        // Сохраняем данные в сессии
        System::user()->Session('admin_login', $admin_login);
        System::user()->Session('admin_pass', $admin_pass);
        System::user()->Session('admin_email', $admin_email);
        // Проверки
        CheckLogin($admin_login, $errors, false, 0);
        CheckPass($admin_pass, $errors);
        // Email
        if ($admin_email == '') {
            $errors[] = 'Вы не ввели E-mail.';
        } elseif (!CheckEmail($admin_email)) {
            $errors[] = 'Формат E-mail не правильный. Он должен быть вида: <b>domain@host.ru</b> .';
        }
        if (count($errors) > 0) {
            $this->SetTitle("Создание учетной записи Главного администратора");
            $text = 'Ошибки:<br /><ul>';
            foreach ($errors as $error) {
                $text .= '<li>' . $error;
            }
            $text .= '</ul>';
            $this->SetContent($text);
Exemple #13
0
/**
 * Initialise some things when the pivot interface must be shown:
 *
 * - Check if user is trying to register him/herself
 * - Check if user is logged in
 * - Load languages
 * - Convert encoding
 * - Load allowed functions for 'normal users' and 'admins'
 * - depending on userlevel, display the screen for normal or admin users
 *
 * @see CheckSanity(), CheckLogin(), LoadUserLanguage(), mainFunctions(), adminFunctions(), startAdmin(), startNormal()
 */
function Load()
{
    global $Pivot_Vars, $Cfg, $Users, $ThisUser;
    CheckSanity();
    if ($Cfg['installed'] == 0) {
        require_once 'setup.php';
    } else {
        CheckLogin();
        // Redirecting to page requested after log in (if needed)
        if (!empty($Pivot_Vars['login_query_string'])) {
            SaveSettings();
            redirect("index.php?" . urldecode($Pivot_Vars['login_query_string']) . "&session=" . $Pivot_Vars['session']);
        }
        LoadUserLanguage();
        // convert encoding to UTF-8
        i18n_array_to_utf8($Pivot_Vars, $dummy_variable);
        $ThisUser = $Users[$Pivot_Vars['user']];
        require_once 'pv_data.php';
        mainFunctions();
        if ($Users[$Pivot_Vars['user']]['userlevel'] >= 3) {
            adminFunctions();
        }
        if (isset($Pivot_Vars['menu']) && $Pivot_Vars['menu'] == 'admin') {
            require_once 'pv_admin.php';
            startAdmin();
        } else {
            startNormal();
        }
    }
    SaveSettings();
}
function IndexUserRegistrationOk()
{
    System::site()->SetTitle('Регистрация на сайте');
    if (isset($_POST['usersave']) && $_POST['usersave'] == 'update') {
        $edit = true;
        $user_id = System::user()->Get('u_id');
        System::database()->Select('users', "`id`='" . $user_id . "'");
        $user = System::database()->FetchRow();
    } else {
        $edit = false;
    }
    if (!$edit) {
        System::user()->UnLogin(false);
    } else {
        if (!System::user()->Auth) {
            GO(Ufu('index.php'));
        }
    }
    if (System::config('user/registration') == 'off' && !$edit) {
        System::site()->AddTextBox('Ошибка', '<p align="center">Извините, регистрация временно приостановлена.</p>');
        return;
    }
    //Обрабатываем данные
    $errors = array();
    // Логин
    $login = '';
    $sendlogin = '';
    if (isset($_POST['login']) && CheckLogin(SafeEnv($_POST['login'], 30, str), $errors, true, $edit ? $user_id : 0)) {
        $login = SafeEnv($_POST['login'], 30, str);
        $sendlogin = $_POST['login'];
    }
    // Пароль
    $pass = '';
    $sendpass = '';
    $pass_generate_message = '';
    if (!System::user()->isAdmin() && $_POST['pass'] != '') {
        $pass = SafeEnv($_POST['pass'], 255, str);
        $rpass = SafeEnv($_POST['rpass'], 255, str);
        $sendpass = $_POST['pass'];
        if ($edit) {
            if ($rpass != '') {
                if (!CheckPass(SafeEnv($_POST['pass'], 255, str), $errors)) {
                    $pass = '';
                } elseif ($rpass != $pass) {
                    $errors[] = 'Пароли не совпадают.';
                    $pass = '';
                }
            } else {
                $pass = '';
            }
        } else {
            if ($_POST['pass'] == '') {
                srand(time());
                $pass = GenBPass(rand(System::config('user/pass_min_length'), 15));
                $sendpass = $pass;
                $pass_generate_message = '<br>Так как Вы не указали пароль, он был сгенерирован автоматически и выслан Вам на E-mail.';
            } else {
                if (CheckPass(SafeEnv($_POST['pass'], 255, str), $errors)) {
                    if ($rpass != $pass) {
                        $errors[] = 'Пароли не совпадают.';
                    }
                }
            }
        }
        $pass2 = md5($pass);
    }
    // E-mail
    if (!System::user()->isAdmin() && isset($_POST['email']) && CheckUserEmail(SafeEnv($_POST['email'], 50, str, true), $errors, true, $edit ? $user_id : 0)) {
        $email = SafeEnv($_POST['email'], 50, str, true);
    } else {
        $email = '';
    }
    // Скрыть E-mail
    if (isset($_POST['hideemail'])) {
        $hide_email = '1';
    } else {
        $hide_email = '0';
    }
    // Имя пользователя
    if (isset($_POST['nikname']) && CheckNikname(SafeEnv($_POST['nikname'], 50, str, true), $errors, true, $edit ? $user_id : 0)) {
        $nik_name = SafeEnv($_POST['nikname'], 50, str, true);
    } else {
        $nik_name = '';
    }
    // Настоящее имя
    if (isset($_POST['realname'])) {
        $real_name = SafeEnv($_POST['realname'], 250, str, true);
    } else {
        $real_name = '';
    }
    // Возраст лет
    if (isset($_POST['age'])) {
        if ($_POST['age'] == '' || is_numeric($_POST['age'])) {
            $age = SafeEnv($_POST['age'], 3, int);
        } else {
            $errors[] = 'Ваш возраст должен быть числом!';
        }
    } else {
        $age = '';
    }
    // Адрес домашней страницы
    if (isset($_POST['homepage'])) {
        $homepage = SafeEnv(Url($_POST['homepage']), 250, str, true);
    } else {
        $homepage = '';
    }
    // Номер ICQ
    if (isset($_POST['icq'])) {
        if ($_POST['icq'] == '' || is_numeric($_POST['icq'])) {
            $icq = SafeEnv($_POST['icq'], 15, str, true);
        } else {
            $errors[] = 'Номер ICQ должен содержать только числа!';
        }
    } else {
        $icq = '';
    }
    // Город
    if (isset($_POST['city'])) {
        $city = SafeEnv($_POST['city'], 100, str, true);
    } else {
        $city = '';
    }
    // Часовой пояс
    if (isset($_POST['gmt'])) {
        $gmt = SafeEnv($_POST['gmt'], 255, str);
    } else {
        $gmt = System::config('general/default_timezone');
    }
    // О себе
    if (isset($_POST['about'])) {
        $about = SafeEnv($_POST['about'], System::config('user/about_max_length'), str, true);
    } else {
        $about = '';
    }
    // Подписка на рассылку
    if (isset($_POST['snews'])) {
        $server_news = '1';
    } else {
        $server_news = '0';
    }
    if (!$edit && (!System::user()->Auth && !System::user()->isDef('captcha_keystring') || System::user()->Get('captcha_keystring') != $_POST['keystr'])) {
        $errors[] = 'Вы ошиблись при вводе кода с картинки.';
    }
    // Аватар
    $updateAvatar = true;
    if (isset($_POST['avatar'])) {
        if (System::config('user/avatar_transfer') == '1' && isset($_FILES['upavatar']) && file_exists($_FILES['upavatar']['tmp_name'])) {
            UserLoadAvatar($errors, $avatar, $a_personal, $user['avatar'], $user['a_personal'] == '1', $edit);
        } elseif ($_POST['avatar'] == '') {
            $updateAvatar = false;
        } elseif (file_exists(RealPath2(System::config('general/avatars_dir') . $_POST['avatar']))) {
            if ($edit) {
                if ($user['a_personal'] == '1') {
                    UnlinkUserAvatarFiles($user['avatar']);
                }
            }
            $a_personal = '0';
            $avatar = $_POST['avatar'];
        } else {
            $avatar = 'noavatar.gif';
            $a_personal = '0';
        }
    } else {
        $avatar = 'noavatar.gif';
        $a_personal = '0';
    }
    // Активация аккаунта
    $active = '1';
    $code = '';
    $SendActivation = false;
    $activate = '';
    if (!$edit) {
        $activate = System::config('user/activate_type');
        switch ($activate) {
            case 'manual':
                $active = '0';
                $code = '';
                $SendActivation = false;
                break;
            case 'auto':
                $active = '1';
                $code = '';
                $SendActivation = false;
                break;
            case 'mail':
                $active = '0';
                $code = GenRandomString(32);
                $SendActivation = true;
                break;
        }
    }
    $status = 2;
    $access = -1;
    $reg_date = time();
    $last_visit = time();
    $ip = getip();
    $points = 0;
    $visits = 0;
    // Сохранение
    if (count($errors) == 0) {
        if ($SendActivation) {
            UserSendActivationMail($nik_name, $email, $sendlogin, $sendpass, $code, $reg_date);
            $finish_message = Indent('
				<br>
				На указанный Вами E-Mail отправлено письмо,
				содержащее ссылку для подтверждения регистрации.
				Для активации Вашего аккаунта перейдите по данной ссылке
				и подтвердите регистрацию!
			');
        } elseif (!$edit) {
            UserSendEndRegMail($email, $nik_name, $sendlogin, $sendpass, $reg_date);
            $finish_message = '<br>На ваш E-mail отправлено письмо с данными о регистрации.';
        }
        if (!$edit) {
            // Добавление нового пользователя
            $values = Values('', $login, $pass2, $nik_name, $real_name, $age, $email, $hide_email, $city, $icq, $homepage, $gmt, $avatar, $about, $server_news, $reg_date, $last_visit, $ip, $points, $visits, $active, $code, $status, $access, $a_personal, serialize(array()));
            System::database()->Insert('users', $values);
            // Очищаем кэш пользователей
            System::cache()->Delete(system_cache, 'users');
            // Автоматический вход
            if ($activate == 'auto') {
                System::user()->Login($login, $pass, true, false);
                System::site()->InitVars();
            } elseif ($activate == 'mail') {
                System::user()->Def('activate_ps', base64_encode($pass));
            }
            System::site()->AddTextBox('Регистрация', '<p align="center">Поздравляем! Вы успешно зарегистрированы на сайте.' . $pass_generate_message . $finish_message . '<br>С уважением, администрация сайта <strong>' . System::config('general/site_name') . '.</strong></p>');
        } else {
            // Сохранение изменений
            $set = "`login`='{$login}',`hideemail`='{$hide_email}',`name`='{$nik_name}'," . "`truename`='{$real_name}',`age`='{$age}',`url`='{$homepage}',`icq`='{$icq}',`city`='{$city}',`timezone`='{$gmt}'" . ($updateAvatar == true ? ",`avatar`='{$avatar}',`a_personal`='{$a_personal}'" : '') . ",`about`='{$about}'," . "`servernews`='{$server_news}'" . ($pass != '' ? ",`pass`='{$pass2}'" : '') . ($email != '' ? ",`email`='{$email}'" : '');
            System::database()->Update('users', $set, "`id`='" . System::user()->Get('u_id') . "'");
            System::user()->UpdateMemberSession();
            UpdateUserComments(System::user()->Get('u_id'), System::user()->Get('u_id'), $nik_name, $email, $hide_email, $homepage, getip());
            // Очищаем кэш пользователей
            System::cache()->Delete(system_cache, 'users');
            GO(GetSiteUrl() . Ufu('index.php?name=user&op=userinfo', 'user/{op}/'));
        }
    } else {
        // Ошибка
        $text = 'Ваш аккаунт не ' . ($edit ? 'сохранен' : 'добавлен') . ', произошли следующие ошибки:<br><ul>';
        foreach ($errors as $error) {
            $text .= '<li>' . $error;
        }
        $text .= '</ul>';
        // Удаляем аватар
        if ($a_personal == '1' && !$edit) {
            unlink(System::config('general/personal_avatars_dir') . $avatar);
        }
        System::site()->AddTextBox('Ошибка', $text);
        IndexUserRegistration(true, $edit);
    }
}
Exemple #15
0
<?php

require_once __DIR__ . '/includes/includes.php';
if (isset($_GET['login'])) {
    if (CheckLogin($_POST['username'], $_POST['password'])) {
        set_loggedin(true);
    }
}
?>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>PhantomBot</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />

        <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/sandstone/bootstrap.min.css" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.min.css" />
        <link rel="stylesheet" type="text/css" href="css/main.css" />

        <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
        <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
    </head>

    <body>
        <div class="container" style="margin-top:5%">
            <div class="col-md-3 col-md-offset-4">
                <div class="panel member_signin">
                    <div class="panel-body">
                        <div class="fa_user">
Exemple #16
0
        } else {
            // Sinon affiche une erreur
            $error = '<span id="helpBlock" class="help-block">The password are not the same.</span>';
        }
    } else {
        // Sinon affiche une erreur
        $error = '<span id="helpBlock" class="help-block">Some field are empty.</span>';
    }
}
// Si le formulaire de connexion est envoyé
if (isset($_REQUEST["btnSubmit"])) {
    // Initialisation
    $UserName = filter_input(INPUT_POST, 'UserName', FILTER_SANITIZE_SPECIAL_CHARS);
    $UserPassword = filter_input(INPUT_POST, 'UserPassword', FILTER_SANITIZE_SPECIAL_CHARS);
    // Si le login est juste
    if (CheckLogin($UserName, $UserPassword)) {
        // Initialise une variable dans $_SESSION à true
        $_SESSION['user_logged'] = $UserName;
        $_SESSION["user"] = getUserByName($UserName);
        // Redirige vers l'index
        header('Location: index.php');
    } else {
        $error = '<span id="helpBlock" class="help-block">The login has failed.</span>';
    }
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
Exemple #17
0
<?php

require 'function.php';
CheckLogin();
header("Content-type: text/xml;charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<list>\n";
$sql = "select a.*,b.userpower from userconfig a inner join user b on a.userid = b.userid where a.userid=" . $_SESSION["userid"];
$oRs = $DB->getOne($sql);
if ($oRs) {
    echo "<item>\n";
    OutNode("DisType", $oRs["distype"]);
    OutNode("OrderType", $oRs["ordertype"]);
    OutNode("ChatSide", $oRs["chatside"]);
    OutNode("MsgSendKey", $oRs["msgsendkey"]);
    OutNode("MsgShowTime", $oRs["msgshowtime"]);
    OutNode("UserPower", $oRs["userpower"]);
    echo "</item>\n";
}
echo "</list>";
$DB->Close();
Exemple #18
0
<?php

include 'core.php';
include 'libs/rpclib.php';
//DB_DataObject::debugLevel(5);
var_dump(CheckLogin('kayomani', '2dbf2c8b82421856957e4469a7834d86'));