Пример #1
0
{
    global $dbName;
    mysqli_select_db($con, $dbName);
}
$topics = array("gaming", "movies", "music", "hardware", "comics", "other");
//create tables if they dont exist
function createTables($con)
{
    $userTable = "CREATE TABLE users\n\t\t\t(\n\t\t\t\tuserID INT NOT NULL AUTO_INCREMENT,\n\t\t\t\tPRIMARY KEY(userID),\n\t\t\t\tusername CHAR(40) NOT NULL UNIQUE,\n\t\t\t\tname CHAR(40) NOT NULL,\n\t\t\t\temail CHAR(100),\n\t\t\t\tpassword CHAR(50) NOT NULL\n\t\t\t)";
    global $topics;
    foreach ($topics as $topic) {
        $topicTable = "CREATE TABLE " . $topic . "\n\t\t\t\t(\n\t\t\t\t\ttopicID INT NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tPRIMARY KEY(topicID),\n\t\t\t\t\tsubject CHAR(40) NOT NULL,\n\t\t\t\t\tuserID INT NOT NULL\n\t\t\t\t)";
        mysqli_query($con, $topicTable);
        if (mysqli_error($con)) {
            echo "error: " . mysqli_error($con);
        }
    }
    if (!mysqli_query($con, $userTable)) {
        //echo "error: " . mysqli_error($con);
    }
}
function addGuest($con)
{
    $query = "INSERT INTO users(username, name, email, password)\n\t\t\t\tVALUES('guest', 'guest', '*****@*****.**', 1234)";
    mysqli_query($con, $query);
}
createDatabase($connection);
connectToDB($connection);
createTables($connection);
addGuest($connection);
mysqli_close($connection);
Пример #2
0
} elseif ($act == "delPro") {
    $mes = delPro($id);
} elseif ($act == "addUser") {
    $mes = addUser();
} elseif ($act == "delUser") {
    $mes = delUser($id);
} elseif ($act == "delHostInfo") {
    $mes = delHostInfo($id);
} elseif ($act == "editUser") {
    $mes = editUser($id);
} elseif ($act == "waterText") {
    $mes = doWaterText($id);
} elseif ($act == "waterPic") {
    $mes = doWaterPic($id);
} elseif ($act == "addGuest") {
    $mes = addGuest();
} elseif ($act == "addGuestInfo") {
    $mes = addGuestInfo();
} elseif ($act == "editGuestInfo") {
    $mes = editGuestInfo($id);
} elseif ($act == "editGuestRequest") {
    $mes = editGuestRequest($id);
} elseif ($act == "delGuest") {
    $mes = delGuest($id);
} elseif ($act == "delImg") {
    $mes = delImg($album_id, $img_path);
} elseif ($act == "addImgs") {
    $mes = addImgs($album_id);
}
?>
Пример #3
0
	remember me functionality and logins. 
	This file is included from many different pages. */
include_once "class.User.php";
include_once "class.Topic.php";
include_once "class.Post.php";
include_once "class.Forum.php";
include_once "class.PM.php";
include_once "function.OnlineList.php";
include_once "outHtml.php";
session_start();
if (isset($_COOKIE['username']) && isset($_COOKIE['password']) && ($_SESSION['loggedIn'] == false || !isset($_SESSION['loggedIn']))) {
    $fileC = file("db/forumUsers.dat");
    foreach ($fileC as $item) {
        $temp = new User($item);
        if ($_COOKIE['username'] == $temp->getUserId() && $_COOKIE['password'] == $temp->getPassword()) {
            setcookie("username", $_COOKIE['username'], time() + 60 * 60 * 24 * 14);
            setcookie("password", $_COOKIE['password'], time() + 60 * 60 * 24 * 14);
            $_SESSION['loggedIn'] = true;
            $_SESSION['user'] = $temp;
        }
    }
}
if ($_SESSION['loggedIn'] == true) {
    addUser($_SESSION['user']->getUserId());
} else {
    addGuest($_SERVER['SERVER_ADDR']);
}
$boardname = trim(file_get_contents("db/boardname.dat"));
$boarddescription = trim(file_get_contents("db/boarddescription.dat"));
define(BOARDNAME, $boardname);
define(BOARDDESCRIPTION, $boarddescription);
Пример #4
0
<?php

require "api.php";
$action = $_GET['action'];
if ($action == "addguest") {
    $name = htmlspecialchars(@$_POST['name'], ENT_HTML5, 'utf-8');
    $age = htmlspecialchars(@$_POST['age'], ENT_HTML5, 'utf-8');
    $gender = htmlspecialchars(@$_POST['gender'], ENT_HTML5, 'utf-8');
    $email = htmlspecialchars(@$_POST['email'], ENT_HTML5, 'utf-8');
    $code = addGuest($mysqli, $name, $age, $gender, $email);
    if ($code != -1) {
        report($code, "OK");
    } else {
        report(-1, "Internal server error.");
    }
} else {
    if ($action == "delguest") {
        $gid_array = $_REQUEST['guests'];
        $flag = 0;
        foreach ($gid_array as $gid) {
            $code = delGuest($mysqli, $gid);
            if ($code == 1) {
                report(1, "One of the guests you have attempted to delete is not in the database. Please refresh your page. If this happens again, please contact Big Green Snake and report this incident.");
                $flag = 1;
                break;
            } else {
                if ($code == 2) {
                    report(2, "Internal server error.");
                    $flag = 1;
                    break;
                }