Пример #1
0
<?php

import('libs/plugins/array.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // ワンタイムトークン
    if (!token('check')) {
        error('不正なアクセスです。');
    }
    // 入力データを整理
    $post = array('user' => normalize_users(array('id' => $_SESSION['auth']['user']['id'], 'username' => isset($_POST['username']) ? $_POST['username'] : '', 'password' => isset($_POST['password']) ? $_POST['password'] : '', 'password_confirm' => isset($_POST['password_confirm']) ? $_POST['password_confirm'] : '', 'email' => isset($_POST['email']) ? $_POST['email'] : '')), 'profile' => normalize_profiles(array('user_id' => $_SESSION['auth']['user']['id'], 'name' => isset($_POST['profile_name']) ? $_POST['profile_name'] : '', 'text' => isset($_POST['profile_text']) ? $_POST['profile_text'] : '')));
    // 入力データを検証&登録
    $warnings = validate_users($post['user']);
    $warnings += array_key_prefix(validate_profiles($post['profile']), 'profile_');
    if (isset($_POST['_type']) && $_POST['_type'] === 'json') {
        if (empty($warnings)) {
            ok();
        } else {
            warning($warnings);
        }
    } else {
        if (empty($warnings)) {
            $_SESSION['post']['user'] = $post['user'];
            $_SESSION['post']['profile'] = $post['profile'];
            // リダイレクト
            redirect('/user/modify_preview');
        } else {
            $_view['user'] = $post['user'];
            $_view['profile'] = $post['profile'];
            $_view['warnings'] = $warnings;
        }
    }
Пример #2
0
<?php

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // ワンタイムトークン
    if ((empty($_POST['view']) || $_POST['view'] !== 'preview') && !token('check')) {
        error('不正なアクセスです。');
    }
    // 入力データを整理
    $post = array('profile' => normalize_profiles(array('id' => isset($_POST['id']) ? $_POST['id'] : '', 'name' => isset($_POST['name']) ? $_POST['name'] : '', 'text' => isset($_POST['text']) ? $_POST['text'] : '', 'memo' => isset($_POST['memo']) ? $_POST['memo'] : '')));
    if (isset($_POST['view']) && $_POST['view'] === 'preview') {
        // プレビュー
        $_view['profile'] = $post['profile'];
    } else {
        // 入力データを検証&登録
        $warnings = validate_profiles($post['profile']);
        if (isset($_POST['_type']) && $_POST['_type'] === 'json') {
            if (empty($warnings)) {
                ok();
            } else {
                warning($warnings);
            }
        } else {
            if (empty($warnings)) {
                $_SESSION['post']['profile'] = $post['profile'];
                // フォワード
                forward('/admin/profile_post');
            } else {
                $_view['profile'] = $post['profile'];
                $_view['warnings'] = $warnings;
            }
        }