예제 #1
0
파일: index.php 프로젝트: neequole/sp2
** E.g. LOGIN, VIEW ALL BLOG, VIEW BLOG and subchild, HOME
*/
include "config.php";
session_start();
//get action var: action|''
$action = isset($_GET['action']) ? $_GET['action'] : "";
//controls what to show in the front page
switch ($action) {
    case 'viewBlog':
        viewBlog();
        break;
    case 'blogHomepage':
        blogHomepage();
        break;
    case 'createBlog':
        createBlog();
        break;
    case 'myBlog':
        myBlog();
        break;
    case 'getComment':
        getComment();
        break;
    case 'aboutus':
        aboutUs();
        break;
    case 'adminCreateBlog':
        adminCreateBlog();
        break;
    default:
        homepage();
예제 #2
0
require 'authCheck.php';
if (!isset($USER->id)) {
    return;
}
require 'queries/blogQueries.php';
$PAGE->id = 'blogCreate';
$fields = array('name', 'desc', 'title');
$inputs = array();
//check POST object for variables from front end
foreach ($fields as $postKey) {
    if (isset($_POST[$postKey]) && !empty($_POST[$postKey])) {
        $inputs[$postKey] = $_POST[$postKey];
    } else {
        return errorHandler("missing {$postKey}", 503);
    }
}
//print debug statement
if ($SERVERDEBUG) {
    echo "\r\n inputs:";
    echo json_encode($inputs);
}
//setup for query
$stmt = createBlog($DB, $inputs['name'], $inputs['desc'], $inputs['title']);
if (!$stmt) {
    return;
}
// createNewList already send error.
if (!$stmt->execute()) {
    return errorHandler("failed to create this user {$stmt->errno}: {$stmt->error}");
}
echo '{"id":"' . $stmt->insert_id . '"}';