<?php
header("Content-Type: application/json"); //Set header for outputing the JSON information
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/vars/constants.php';
$request = file_get_contents('php://input');
$data = json_decode($request);
$user_id = $data->user_id;
$begin_datetime = $data->begin_datetime;
$datename = ($data->datename) ? $data->datename : DEFAULT_BADMINTON_DATE_NAME;
$end_datetime = $data->end_datetime;
$visibility = $data->visibility;
$summary = $data->summary;
$group_id = $data->group_id;
$user = User::get_current_user();
$max_attendants = $data->max_attendants;
/*$begin_datetime = '2015-09-06 12:00:00';
$end_datetime = '2015-09-06 13:00:00';*/
/*$begin_datetime = '2015-09-21 00:00:00';
$end_datetime = '2015-09-22 00:00:00';*/
try {
	if (($user instanceof CurrentUser) && $end_datetime && $begin_datetime) {
		//Attempt to create a new badminton date
		list($datetime, $datename, $summary) = Database::sanitize(array($datetime, $datename, $summary));
		if (!is_numeric($group_id))  {
			//The date is a public date
			$badminton_date = new PublicProposedDate(array(
				'summary' => $summary,
				'datename' => $datename,
				'begin_datetime' =>  $begin_datetime,
				'end_datetime' =>  $end_datetime,
				'creator' => $user,
<?php
header("Content-Type: application/json"); //Set header for outputing the JSON information
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/autoload.php';
try {
    $mysqli = Database::connection();
    $user = User::get_current_user(); //To check if the user has joined in on this date
    $sql = "SELECT t1.date_id, t1.datename, t1.begin_datetime, t1.end_datetime, t1.confirmed, t1.bool_group, t2.username, t2.email, t2.reputation, t2.avatar, t3.status, t1.creator_id as `user_id`
    FROM `badminton_dates` as t1 
    LEFT JOIN users as t2
    ON t2.user_id = t1.creator_id
    LEFT JOIN `joins` as t3 
    ON t3.date_id = t1.date_id
    WHERE t1.confirmed = '" . BadmintonDate::CONFIRMED . "'";
    $result = $mysqli->query($sql)
    or die ($mysqli->error);
    $dates = array();
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $row['creator'] = new ProfileUser($row);
        $badminton_date = new ConfirmedBadmintonDate($row);
        $badminton_date->get_attendees();
        array_push($dates, $badminton_date);
    }
    http_response_code(200);
    echo json_encode($dates, JSON_PRETTY_PRINT);
}
catch (Exception $e) {
    http_response_code(400);
    Database::print_exception($e);
}
?>
<?php

ob_start();
// This is buffer area where cookies and session are set and again set to expire them
session_start();
require_once 'class.user.php';
$email = $_SESSION["login_user"];
$user = new User($email);
$current_user = $user->get_current_user();
function validateForm($__initialized_user, $email_param, $password_param, $confirm_password_param)
{
    $errors = array();
    if ($email_param == "") {
        array_push($errors, "Email is required");
    }
    if ($password_param == "") {
        array_push($errors, "Password is required");
    }
    // Validating Uniqueness
    $current_user_email = $_SESSION["login_user"];
    $result = $__initialized_user->validate_uniqueness($current_user_email, "on_update");
    if ($result->num_rows > 0) {
        array_push($errors, "This Email has already been taken");
    }
    if ($password_param != $confirm_password_param) {
        array_push($errors, "Password Confiramtion is not matched with password");
    }
    $password_length = strlen($password_param);
    if ($password_length <= 8) {
        array_push($errors, "Password must be of at least 8 characters");
    }
<?php

ob_start();
// If Session Variable is present on the page?
session_start();
require_once 'class.user.php';
if (isset($_SESSION["login_user"])) {
    $email = $_SESSION["login_user"];
    $user = new User($email);
    $user_field = $user->get_current_user();
    $user_events = $user->user_events($user_field["id"]);
}
?>
<div class="page-header">
	<h1>My Events</h1>
</div>
<?php 
if ($user_events->num_rows > 0) {
    ?>
  <table class="table table-striped table-hover">
    <thead>
      <tr>
        <th>Name</th>
        <th>Theme</th>
        <th>Price</th>
        <th>Description</th>
        <th></th>
        <th colspan="2"></th>
      </tr>
    </thead>
    <tbody>
Example #5
0
$request = file_get_contents('php://input');
$data = json_decode($request);
$level = $data->level;
$program = $data->program;
$commuter = $data->commuter;
$accolades = $data->accolades;
$bio = $data->bio;
// $commuter = 2;
// $level = 'AngularJS Level';
// $program = 'Object Oriented';   
// $level = 1;
// $playingLevel = $data->playingLevel;
// $commuter = 1;
// $bio = 'hey there';
// $playingLevel = 1;  
$user = User::get_current_user(); //The user to edit on
try {
    if ($user instanceof CurrentUser) {
        if (is_numeric($level) && is_numeric($commuter)) {
            list($program, $accolades, $bio) = Database::sanitize(array($program, $accolades, $bio));
            $edit = new ProfileUser(array(
                'level' => $level,
                'program' => $program,
                'commuter' => $commuter,
                'bio' => $bio,
                'accolades' => $accolades)
            );
            $result = $user->edit_self($edit);
            if ($result) {
                http_response_code(200);
            }