コード例 #1
0
ファイル: user.php プロジェクト: sbenning42/42
function is_admin($user)
{
    if (!file_exists("private/user")) {
        return FALSE;
    }
    if (!($table_user = unserialize_get_content("private/user"))) {
        return FALSE;
    }
    return $table_user[$user]['right'];
}
コード例 #2
0
ファイル: create.php プロジェクト: sbenning42/42
}
include "product_table_handle.php";
$_SESSION['cre_error'] = 0;
if ($_POST['login'] === "" or $_POST['passwd'] === "" or $_POST['submit'] !== "OK") {
    header("Location: index.php");
    exit;
} else {
    if (!file_exists("private")) {
        mkdir("private", 0777);
    } else {
        if (file_exists("private/passwd")) {
            $data = unserialize(file_get_contents("private/passwd"));
        }
    }
    if ($data !== NULL and is_exists($_POST['login'], $data) === TRUE) {
        $_SESSION['cre_error'] = 1;
        header("Location: index.php");
        exit;
    }
    $data[] = array('login' => $_POST['login'], 'passwd' => hash("whirlpool", $_POST['passwd']));
    $serial = serialize($data);
    file_put_contents("private/passwd", $serial);
    if (file_exists("private/user")) {
        $table_user = unserialize_get_content("private/user");
    }
    $user['id'] = $_POST['login'];
    $user['right'] = "no-right";
    $table_user[$_POST['login']] = $user;
    serialize_put_content("private/user", $table_user);
    header("Location: index.php");
}
コード例 #3
0
function category_id_modif($old_id, $new_id)
{
    if (!file_exists("resources/category") or !file_exists("resources/join")) {
        return FALSE;
    }
    $table_category = unserialize_get_content("resources/category");
    if ($table_category[$old_id]['exist'] !== 1 or $table_category[$new_id]['exist'] === 1) {
        return FALSE;
    }
    $table_category[$new_id] = $table_category[$old_id];
    $table_category[$new_id]['id'] = $new_id;
    unset($table_category[$old_id]);
    $table_join = unserialize_get_content("resources/join");
    $tmp = $table_join;
    foreach ($tmp as $key => $join) {
        if (preg_match("/^" . $old_id . "<:>(.*)\$/", $key, $match) === 1) {
            $table_join[$new_id . "<:>" . $match[1]] = $table_join[$key];
            unset($table_join[$key]);
        }
    }
    serialize_put_content("resources/category", $table_category);
    serialize_put_content("resources/join", $table_join);
}