Example #1
0
function setup_database()
{
    $mysql_conn = mysqli_connection();
    $create_table_directory_sql = "CREATE TABLE Directories (object_id INT NOT NULL AUTO_INCREMENT,\n                                PRIMARY KEY (object_id),\n                                name VARCHAR(128),\n                                parent_id INT NOT NULL,\n                                category INT,\n                                info VARCHAR(256))";
    if (mysqli_query($mysql_conn, $create_table_directory_sql)) {
        echo "Table Directories created successfully";
    } else {
        echo "Error creating table Directories: " . mysqli_error($con);
    }
    $create_table_room_sql = "CREATE TABLE Rooms (object_id INT NOT NULL AUTO_INCREMENT,\n                                PRIMARY KEY (object_id),\n                                name VARCHAR(128),\n                                parent_id INT NOT NULL,\n                                category INT,\n                                room_no VARCHAR(16),\n                                info VARCHAR(256))";
    if (mysqli_query($mysql_conn, $create_table_room_sql)) {
        echo "Table Rooms created successfully";
    } else {
        echo "Error creating table Rooms: " . mysqli_error($con);
    }
    $create_table_person_sql = "CREATE TABLE Persons (object_id INT NOT NULL AUTO_INCREMENT,\n                                PRIMARY KEY (object_id),\n                                first_name VARCHAR(32),\n                                last_name VARCHAR(32),\n                                title VARCHAR(64),\n                                email VARCHAR(64)\n                                password VARCHAR(32),\n                                directory_id INT,\n                                phone VARCHAR(32))";
    if (mysqli_query($mysql_conn, $create_table_person_sql)) {
        echo "Table Persons created successfully";
    } else {
        echo "Error creating table Persons: " . mysqli_error($con);
    }
    $create_admin_table_sql = "CREATE TABLE Admins (object_id INT NOT NULL AUTO_INCREMENT,\n                                PRIMARY KEY (object_id),\n                                person_id INT NOT NULL,\n                                access_level ENUM ('SU', 'Building Admin'),\n                                directory_id INT)";
    if (mysqli_query($mysql_conn, $create_admin_table_sql)) {
        echo "Table Admins Created successfully";
    } else {
        echo "Error creating table Admins: " . mysqli_error($con);
    }
    $create_table_person_room_map_sql = "CREATE TABLE PersonRoomMap (object_id INT NOT NULL AUTO_INCREMENT,\n                                PRIMARY KEY (object_id),\n                                person_id INT NOT NULL,\n                                room_id INT NOT NULL)";
    if (mysqli_query($mysql_conn, $create_table_person_room_map_sql)) {
        echo "Table PersonRoomMap created successfully";
    } else {
        echo "Error creating table PersonRoomMap: " . mysqli_error($con);
    }
    $create_category_sql = "CREATE TABLE Categories (object_id INT NOT NULL AUTO_INCREMENT,\n                                PRIMARY KEY (object_id),\n                                name VARCHAR(32))";
    if (mysqli_query($mysql_conn, $create_category_sql)) {
        echo "Table Categories created successfully";
    } else {
        echo "Error creating table Categories: " . mysqli_error($con);
    }
    $create_table_meeting_sql = "CREATE TABLE Meeting (object_id INT NOT NULL AUTO_INCREMENT,\n                                PRIMARY KEY (object_id),\n                                name VARCHAR(256),\n                                description TEXT,\n                                start_time DATETIME,\n                                end_time DATETIME,\n                                host_id INT NOT NULL,\n                                room_id INT NOT NULL)";
    if (mysqli_query($mysql_conn, $create_table_meeting_sql)) {
        echo "Table Meeting created successfully";
    } else {
        echo "Error creating table Meeting: " . mysqli_error($mysql_conn);
    }
    $create_table_meeting_person_map_sql = "CREATE TABLE MeetingPersons (meeting_id INT NOT NULL,\n                                person_id INT NOT NULL,\n                                PRIMARY KEY (meeting_id, person_id))";
    if (mysqli_query($mysql_conn, $create_table_meeting_person_map_sql)) {
        echo "Table MeetingPersons created successfully";
    } else {
        echo "Error creating table MeetingPersons: " . mysqli_error($mysql_conn);
    }
}
Example #2
0
function getSecurityQuestions()
{
    $sql_conn = mysqli_connection();
    $sql = sprintf("SELECT  * FROM  SecurityQuestions ORDER BY `sl_no`");
    $result = mysqli_query($sql_conn, $sql);
    $res = array();
    while ($row = mysqli_fetch_array($result)) {
        $question = new SecurityQuestion();
        $question->populateQuestion($row);
        $res[] = $question;
    }
    mysqli_close($sql_conn);
    $r = json_encode($res);
    return $r;
}
Example #3
0
 public static function escapeObject($obj)
 {
     $sql_conn = mysqli_connection();
     if (is_object($obj)) {
         $vars = get_object_vars($obj);
         foreach ($vars as &$v) {
             if ($v != NULL) {
                 $v = $sql_conn->escape_string($v);
             }
         }
     } else {
         if (is_string($obj)) {
             if ($v != NULL) {
                 $obj = $sql_conn->escape_string($v);
             }
         }
     }
     mysqli_close($sql_conn);
     return $obj;
 }
Example #4
0
<?php

include_once "CUserSession.php";
include_once "CStandard.php";
include_once "CQuestion.php";
include_once "CUser.php";
if (isset($_POST['chapter'])) {
    $chapter = $_POST['chapter'];
    $chapter = mysqli_real_escape_string(mysqli_connection(), $chapter);
    print getStandards($chapter);
} else {
    if (isset($_POST['columns'])) {
        $columns = $_POST['columns'];
        if ($columns === "GOALS") {
            print getGoalColumnNames();
        } elseif ($columns === "PHASES") {
            print getPhaseColumnNames();
        }
    } else {
        if (isset($_POST['register'])) {
            $columns = $_POST['register'];
            if ($columns === "QUESTIONS") {
                print getSecurityQuestions();
            }
            if ($columns === "REGISTER") {
                $data = json_decode(stripslashes($_POST['data']), true);
                $recaptcha = $data['recaptcha'];
                // verify recaptcha
                $url = "https://www.google.com/recaptcha/api/siteverify";
                $fields = array('secret' => '6LcmTSATAAAAAFtJj2F9XlF6wl9gUmIX9Vu-4af7', 'response' => $recaptcha);
                //open connection
Example #5
0
function getAllUsers($public = true)
{
    $sql_conn = mysqli_connection();
    $clause = Util::escapeObject($clause);
    $s = "SELECT * FROM  `Users_temp`";
    if (!($stmt = $sql_conn->prepare($s))) {
        echo "Prepare failed: (" . $sql_conn->errno . ") " . $sql_conn->error . $s;
    }
    if (!$stmt->execute()) {
        echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
    }
    if (!($ret = $stmt->get_result())) {
        echo "Getting Result failed: (" . $stmt->errno . ") " . $stmt->error;
    }
    $user = new User();
    $res = array();
    while ($row = mysqli_fetch_array($ret)) {
        $user = new User();
        $user->populateFromDBRow($row);
        if ($public) {
            $user = getPublicUserData($user);
        }
        $res[] = $user;
    }
    $stmt->close();
    mysqli_close($sql_conn);
    $r = json_encode($res);
    //echo "hello : ". $r;
    return $r;
}
Example #6
0
<html>
<head>
<title>candidate registration</title>
</head>
<body>
<?php 
$username = "******";
$password = "";
$database = "evoting";
$server = "127.0.0.1";
$myconn = mysqli_connection($server, $username, $password, $database);
if ($myconn) {
    $candregid = $_GET['candreg_id'];
    //coming from page
    $fname = $_GET['fname'];
    $mame = $_GET['mname'];
    $lname = $_GET['lname'];
    $candfhname = $_GET['fhnamec'];
    $mon = $_GET['mon'];
    $gender = $_GET['gender'];
    $candcard = $_GET['card'];
    $candcardno = $_GET['cardno'];
    $candaddress = $_GET['txtaddress'];
    $country = $_GET['country'];
    $state = $_GET['state'];
    $city = $_GET['city'];
    $pcode = $_GET['pcode'];
    $candmobno = $_GET['mobileno'];
    $candemailid = $_GET['email_id'];
    $candpost = $_GET['candpost'];
    /*$candphotos=$_GET['candphoto'];
						';)',
						';(',
						':/',
						':|',
						'(:|'
					);
	$liste_smiley2 = array(
						'<div class="smiley-ico smile" style="background-image: url(\'/img/smileys/smile.png\')" alt="smile"></div>',
						'<div class="smiley-ico sadsmile" style="background-image: url(\'/img/smileys/sadsmile.png\')" alt="sadsmile"></div>',
						'<div class="smiley-ico bigsmile" style="background-image: url(\'/img/smileys/bigsmile.png\')" alt="bigsmile"></div>',
						'<div class="smiley-ico surprised" style="background-image: url(\'/img/smileys/surprised.png\')" alt="surprised"></div>',
						'<div class="smiley-ico wink" style="background-image: url(\'/img/smileys/wink.png\')" alt="wink"></div>',
						'<div class="smiley-ico crying" style="background-image: url(\'/img/smileys/crying.png\')" alt="crying"></div>',
						'<div class="smiley-ico speechless" style="background-image: url(\'/img/smileys/speechless.png\')" alt="speechless"></div>',
						'<div class="smiley-ico speechless" style="background-image: url(\'/img/smileys/speechless.png\')" alt="speechless"></div>',
						'<div class="smiley-ico sweating" style="background-image: url(\'/img/smileys/sweating.png\')" alt="sweating"></div>'
					);
	$msg = str_replace($liste_smiley1, $liste_smiley2, $msg);
	return $msg;
}*/
mysqli_connection();
function random($car)
{
    $string = "";
    $chaine = "abcdefghijklmnpqrstuvwxy0123456789-_";
    srand((double) microtime() * 1000000);
    for ($i = 0; $i < $car; $i++) {
        $string .= $chaine[rand() % strlen($chaine)];
    }
    return $string;
}
Example #8
0
function getGoalColumnNames()
{
    $sql_conn = mysqli_connection();
    $sql = 'SELECT `goal_text` FROM UD_S_Goals';
    $result = mysqli_query($sql_conn, $sql);
    $res = array();
    while ($row = mysqli_fetch_array($result)) {
        $res[] = $row["goal_text"];
    }
    mysqli_close($sql_conn);
    $r = json_encode($res);
    return $r;
}