<?php

include './includes/page-header.php';
include './includes/functions.php';
$host_url = host_url();
if ($_POST) {
    if (isset($_SESSION['verifycode']) and $_POST['verifycode'] == $_SESSION['verifycode']['code'] and time() - $_SESSION['verifycode']['time'] < 5 * 60) {
        $database_config = (require __DIR__ . '/config/database.php');
        require_once __DIR__ . '/lib/Medoo.class.php';
        $medoo = @new Medoo($database_config);
        //连接数据库
        $medoo->query('set names utf8');
        $email = handle_user_post_string($_POST['email']);
        $password = trim($_POST['password']);
        $password_again = trim($_POST['password_again']);
        $has_error = FALSE;
        $errors = [];
        //check email
        $check_user_email_result = check_user_email_exist($email, $medoo);
        if ($check_user_email_result[0]) {
            $has_error = TRUE;
            array_push($errors, $check_user_email_result[1]);
        }
        //check password
        $check_user_password_result = check_user_password($password, $password_again);
        if ($check_user_password_result[0]) {
            $has_error = TRUE;
            array_push($errors, $check_user_password_result[1]);
        }
        if (!$has_error) {
            $insert_result = $medoo->update('users', ['password' => md5($password)], ['email' => $email]);
示例#2
0
<?php

include './includes/page-header.php';
include './includes/functions.php';
$host_url = host_url();
$database_config = (require __DIR__ . '/config/database.php');
require_once __DIR__ . '/lib/Medoo.class.php';
$medoo = @new Medoo($database_config);
$medoo->query('set names utf8');
if ($_GET['aid']) {
    $select_result = $medoo->select('article', ['[>]users' => ['user_id' => 'id'], '[>]class' => ['class_id' => 'id']], ['article.id', 'article.title', 'article.user_id', 'users.name', 'class.sort', 'article.class_id', 'article.content', 'article.created_at'], ['article.id' => $_GET['aid']])[0];
    var_dump($select_result);
    if ($_POST) {
        $title = handle_user_post_string($_POST['title']);
        $content = handle_user_post_string($_POST['content']);
        $Sort = $_POST['Sort'];
        $pass = isset($_POST['pass']) ? $_POST['pass'] : '******';
        $class = $medoo->select('class', '*', ['sort' => $Sort]);
        if (count($class)) {
            $_SESSION['class'] = $class[0];
        } else {
            echo "类型不存在";
        }
        if (!$medoo->has('article', ['title' => $title]) and strlen($content) > 10) {
            if ($update_result = $medoo->update('article', ['title' => $title, 'content' => $content, 'class_id' => $_SESSION['class']['id'], 'pass' => $pass], ['id' => $_GET['aid']])) {
                $_SESSION['errors']['state'] = 'am-alert-success';
                $_SESSION['errors']['details'] = ['修改帖子成功啦!'];
                header('Location:' . $host_url . 'read_article.php?aid=' . $_SESSION['article']['id']);
                exit;
            } else {
                $_SESSION['post']['title'] = $_POST['title'];
示例#3
0
<?php

include './includes/page-header.php';
include './includes/functions.php';
$host_url = host_url();
if ($_POST) {
    $database_config = (require __DIR__ . '/config/database.php');
    require_once __DIR__ . '/lib/Medoo.class.php';
    $medoo = @new Medoo($database_config);
    $medoo->query('set names utf8');
    $name = handle_user_post_string($_POST['name']);
    $insert_sort = $medoo->insert('class', ['sort' => $name]);
    if ($insert_sort) {
        $_SESSION['errors']['state'] = 'am-alert-success';
        $_SESSION['errors']['details'] = ['恭喜您,sort插入成功!'];
        header("Location:{$host_url}post_article.php");
    } else {
        $_SESSION['errors']['state'] = 'am-alert-warning';
        $_SESSION['errors']['details'] = ['Sorry,@~_~@,我们的数据库出问题啦,稍后再试'];
    }
}
?>
<body>
	<?php 
include './includes/nav.php';
?>
		<div class="am-g am-container php-bg-white  php-box-shadow">
			<?php 
include './includes/error.php';
?>
			<div class="am-u-lg-offset-2 am-u-md-offset-2 am-u-md-8 am-u-lg-8 am-u-sm-12  am-padding-top am-margin-top-xl ">