Example #1
0
function matchTrip($tripId)
{
    if (!isLoggedIn()) {
        $response = array("status" => 1, "error" => "Invalid session");
        echo json_encode($response);
        return;
    }
    include "config.php";
    $myTripQuery = "SELECT * FROM " . $db_mysql_table_name . " WHERE id='" . $tripId . "'";
    $tripQuerySuccess = mysqli_query($link, $myTripQuery);
    if ($tripQuerySuccess) {
        if (mysqli_num_rows($tripQuerySuccess) == 1) {
            $matchTrip = mysqli_fetch_assoc($tripQuerySuccess);
        } else {
            $response = array("status" => 1, "error" => "Duplicate id in DB ");
            echo json_encode($response);
        }
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
    $query = "SELECT * FROM " . $db_mysql_table_name . " WHERE state=0" . " AND id!='" . $tripId . "'" . " AND date='" . getTripDate($matchTrip) . "'";
    // Ensures rides are on the same day.
    $success = mysqli_query($link, $query);
    $rows = array();
    if ($success) {
        while ($row = mysqli_fetch_assoc($success)) {
            if (timeCoincides($row, $matchTrip)) {
                // Ensures that they start at around the same time.
                if (getDistance(getDestAddr($row), getDestAddr($matchTrip)) <= 3000) {
                    if (getDistance(getSourceAddr($row), getSourceAddr($matchTrip)) <= 3000) {
                        $rows[] = $row;
                    }
                }
            }
        }
        $response = array("status" => 0, "data" => $rows);
        $response = json_encode($response);
        foreach ($rows as $match) {
            send_email(getUserId($match), $response);
        }
        if (!empty($playerlist)) {
            // Do not send email if no match found
            send_email(getMailId(), $response);
        } else {
            // Send email of no match if needed.
        }
        echo json_encode($response);
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
}
Example #2
0
<link rel="shortcut icon" href="./favicon.png" type="image/x-icon">
<link rel="icon" href="./favicon.png" type="image/x-icon">
</head>
<body>
<?php 
require_once 'header.php';
?>

<div class="container">
<div id="page_title">
	Create a new trip
</div>
<div id="page_content">
	<form id="form_table" onsubmit="return false;">
		<input type="hidden" name="email" value="<?php 
echo getMailId();
?>
" />
		<input type="hidden" name="username" value="<?php 
echo getName();
?>
" />
		<table width="100%">
			

			<tr>
				<td width="30%">
				</td>
				<td width="30%">
				</td>
				<td valign="top" rowspan="9" width="40%" style="vertical-align: top; padding-left: 15px; text-align: center;">
Example #3
0
<?php

require_once "ldap.php";
require_once "userhelper.php";
login("test.13", "abcde");
print_r($_SESSION['ldapstuff'][0]);
print "<br>";
print getUid();
print "<br>";
print "\n";
if (isAdmin()) {
    print "#t\n";
} else {
    print "#f\n";
}
print "<br>";
print getMailId() . "\n";
print "<br>";
print getName() . "\n";
print "<br>";