function edit_account_informations($email, $civility, $firstname, $lastname, $adress, $country, $postal_code, $city, $phone_fixe, $phone_mobile)
{
    $error_message = array();
    $error_message['email_invalid'] = $error_message['email_already_used'] = $error_message['emails_dont_match'] = $error_message['civility'] = $error_message['firstname'] = $error_message['firstname'] = $error_message['lastname'] = $error_message['adress'] = $error_message['postal_code'] = $error_message['city'] = $error_message['phone_fixe'] = $error_message['phone_mobile'] = $error_message['password_invalid'] = $error_message['passwords_dont_match'] = '';
    require $_SERVER['DOCUMENT_ROOT'] . '/e_commerce/register/register_action_functions.php';
    if ($civility != 'M' && $civility != 'Mlle' && $civility != 'Mme') {
        $error_message['civility'] = '- Civilité incorrecte.';
    }
    if (!is_name_valid($firstname)) {
        $error_message['firstname'] = '- Prénom incorrect.';
    }
    if (!is_name_valid($lastname)) {
        $error_message['lastname'] = '- Nom incorrect.';
    }
    if (!is_adress_valid($adress)) {
        $error_message['adress'] = '- Adresse incorrecte.';
    }
    if (!is_postal_code_valid($postal_code)) {
        $error_message['postal_code'] = '- Code postal incorrect.';
    }
    if (!is_city_valid($city)) {
        $error_message['city'] = '- Ville incorrecte.';
    }
    if (!is_phone_number_valid($phone_fixe)) {
        $error_message['phone_fixe'] = '- Téléphone fixe incorrect.';
    }
    if (!is_phone_number_valid($phone_mobile)) {
        $error_message['phone_mobile'] = '- Téléphone mobile incorrect.';
    }
    // If no error is raised, we update the account.
    if (!check_if_error($error_message)) {
        edit_account_informations_in_db($email, $civility, $firstname, $lastname, $adress, $country, $postal_code, $city, $phone_fixe, $phone_mobile);
    }
    $_SESSION['error_message'] = $error_message;
    redirect('vos_informations.php');
}
示例#2
0
function reset_pwd($username, $auth_key, $new_pwd)
{
    if (is_name_valid($username) != '') {
        return '用户不存在';
    }
    if (strlen($new_pwd) != 32) {
        return '无效的密码';
    }
    if (strlen($auth_key) != 32) {
        return '链接已失效';
    }
    $profile = get_user_information($username);
    if ($profile == null) {
        return '用户不存在';
    }
    if (process_auth_key($profile['auth_key'], $profile['last_time']) != $auth_key) {
        return '链接已经失效';
    }
    $new_salt = rand_string();
    $new_pwd = crypt_pwd($new_pwd, $new_salt);
    $new_auth_key = rand_string(32);
    $sql = 'UPDATE `ewu_account` SET `auth_key`= ?, `pwd`=?, `salt`=? WHERE username= ? LIMIT 1';
    $a_params = array($new_auth_key, $new_pwd, $new_salt, $username);
    $count = (new MysqlPDO())->execute($sql, $a_params);
    if ($count == 1) {
        return '1';
    } else {
        return '服务器繁忙,操作失败';
    }
}
示例#3
0
if ($_SESSION['id_session'] !== "admin") {
    session_destroy();
    header('Location: ../index.php');
    exit;
}
if ($_POST["submit"] == "Add") {
    if ($_POST["cat"] == "Categories" && !$_POST["new_cat"]) {
        alert("Chose Category");
    } else {
        if ($_POST["new_cat"] && ctype_alnum($_POST["new_cat"]) == FALSE) {
            alert("Only alphanumeric characters in category name");
        } else {
            if (!$_POST["name"]) {
                alert("No name");
            } else {
                if (is_name_valid($_POST["name"]) == FALSE) {
                    alert("Alphanumeric characters or _ in product's name");
                } else {
                    if (is_img_name_valid($_FILES["imgToUp"]["name"]) == FALSE) {
                        alert("Alphanumeric characters only and only .jpeg is supported");
                    } else {
                        $products = unserialize(file_get_contents("../products/prods.db"));
                        if (array_search($_POST["name"], array_column($products, "name")) == TRUE) {
                            alert("There is already a product named" . $_POST["name"] . ". Change product name");
                        } else {
                            if (array_search($_POST["imgToUp"], array_column($products, "name")) == TRUE) {
                                alert("There is already an image named" . $_POST["name"] . ". Change image name");
                            } else {
                                if (move_uploaded_file($_FILES["imgToUp"]["tmp_name"], "../img/" . $_FILES["imgToUp"]["name"])) {
                                    alert("Image uploaded");
                                } else {
示例#4
0
<?php

include "name_tests.php";
include "alert.php";
include "../config.php";
if ($_SESSION['id_session'] !== "admin") {
    session_destroy();
    header('Location: ../index.php');
    exit;
}
if ($_POST["submit"] == "change") {
    if (!$_POST["name"] || is_name_valid($_POST["name"]) == FALSE) {
        alert("Only Alphanumeric characters in name");
    } else {
        $products = unserialize(file_get_contents("../products/prods.db"));
        if (array_search($_POST["name"], array_column($products, "name")) == TRUE) {
            alert("There is already a product names" . $_POST["name"] . ". Change name.");
        } else {
            foreach ($products as $key => $product) {
                if ($product["name"] == $_GET["name"]) {
                    $products[$key]["name"] = $_POST["name"];
                    file_put_contents("../products/prods.db", serialize($products));
                    if ($_POST["name"]) {
                        $_GET["name"] = $_POST["name"];
                    }
                    header("Location: modify_product.php?name=" . $_GET['name'] . "&submit=OK");
                }
            }
        }
    }
} else {
function register_account($email, $email_confirmation, $civility, $firstname, $lastname, $adress, $country, $postal_code, $city, $phone_fixe, $phone_mobile, $password, $password_confirmation)
{
    if (!is_email_valid($email) || check_if_email_already_taken($email) || !do_passwords_match($email, $email_confirmation) || $civility != 'M' && $civility != 'Mlle' && $civility != 'Mme' || !is_name_valid($firstname) || !is_name_valid($lastname) || !is_adress_valid($adress) || !is_postal_code_valid($postal_code) || !is_city_valid($city) || !is_phone_number_valid($phone_fixe) || !is_phone_number_valid($phone_mobile) || !is_password_valid($password) || !do_passwords_match($password, $password_confirmation)) {
        redirect('register.php');
    } else {
        insert_account_in_db($email, $civility, $firstname, $lastname, $adress, $country, $postal_code, $city, $phone_fixe, $phone_mobile, $password);
        $_SESSION['email'] = $email;
        redirect('../index.php');
    }
}