예제 #1
0
function checkCookie()
{
    $uid = getUid();
    //获取Cookie对应用户数据,如果key不符合,退出
    $result = NULL;
    $count = safe_query('SELECT * FROM `user` WHERE `uid` = ?;', &$result, array('i', $uid));
    if ($count != 1) {
        die(json_err('cookie_invalid', -1, 'Error: Invalid Cookie'));
    }
    //返回空
    //!= == >= 代表作为数字比较
    if ($result[0]['key'] != intval($_COOKIE['key'])) {
        die(json_err('cookie_wrongkey', -1, 'Error: Cookie with Wrong Key'));
    }
    //key不符合
    if ($result[0]['status'] == 0) {
        die(json_err('cookie_deleted', -1, 'Error: Deleted Cookie'));
    }
    //status禁用
    if ($result[0]['time'] >= time()) {
        die(json_err('cookie_inactive', -1, 'Error: Not Yet Active'));
    }
    //time还在硬直中
    return true;
}
예제 #2
0
function addNewMember($thisEmail, $name)
{
    $thisId = rand(106, 5245);
    $thisUid = getUid($thisEmail, $thisId);
    $sqlQuery = "INSERT INTO mailing_list (email,uid,full_name ) VALUES ('{$thisEmail}','{$thisUid}','{$name}')";
    $result = MYSQL_QUERY($sqlQuery);
    if (!$result) {
        return false;
    }
    return true;
}
예제 #3
0
function addTripToDb($source, $destination, $date, $start_time, $end_time, $phone, $travellers, $comment, $private)
{
    if (!isLoggedIn()) {
        $response = array("status" => 1, "error" => "Invalid session");
        echo json_encode($response);
        return;
    }
    include "config.php";
    $query = "INSERT INTO new_cab_share (userid, source_addr, dest_addr, date, start_time, end_time, phone, travellers, comment, private, state, username) VALUES ('" . getUid() . "', '" . $source . "', '" . $destination . "', '" . $date . "', '" . $start_time . "', '" . $end_time . "', '" . $phone . "', '" . $travellers . "', '" . $comment . "',  '" . $private . "', 0, '" . getName() . "')";
    $success = mysqli_query($link, $query);
    if ($success) {
        $tripId = mysqli_insert_id($link);
        $data = array("message" => "Added new trip", "tripId" => $tripId);
        $response = array("status" => 0, "data" => $data);
        matchTrip($tripId);
        echo json_encode($response);
    } else {
        $response = array("status" => 1, "error" => "Unable to insert into DB");
        echo json_encode($response);
    }
}
예제 #4
0
function getLatestTrip()
{
    if (!isLoggedIn()) {
        $response = array("status" => 1, "error" => "Invalid session");
        echo json_encode($response);
        return;
    }
    include "config.php";
    $query = "SELECT * FROM " . $db_mysql_table_name . " WHERE userid='" . getUid() . "' ORDER BY -id LIMIT 1 ";
    $success = mysqli_query($link, $query);
    if ($success) {
        if (mysqli_num_rows($success) == 1) {
            $row = mysqli_fetch_assoc($success);
            $response = array("status" => 0, "data" => $row);
        }
        echo json_encode($response);
    } else {
        $response = array("status" => 1, "error" => "Unable to run select in DB");
        echo json_encode($response);
    }
}
예제 #5
0
function getAllTrips()
{
    if (!isLoggedIn()) {
        $response = array("status" => 1, "error" => "Invalid session");
        echo json_encode($response);
        return;
    }
    include "config.php";
    $query = "SELECT * FROM " . $db_mysql_table_name . " WHERE userid='" . getUid() . "' ORDER BY id DESC";
    $success = mysqli_query($link, $query);
    if ($success) {
        $rows = array();
        while ($row = mysqli_fetch_assoc($success)) {
            $rows[] = $row;
        }
        $response = array("status" => 0, "data" => $rows);
        echo json_encode($response);
    } else {
        $response = array("status" => 1, "error" => "Unable to run select in DB");
        echo json_encode($response);
    }
}
예제 #6
0
파일: index.php 프로젝트: 117n-n711/pjmgmt
<?php

$base = "../../../";
require_once $base . "functions.php";
require_once $base . "loginCheck.php";
header('Content-type: text/html; charset=UTF-8');
$uid = getUid();
$hash = getCookieHash();
checkCookieHash($uid, $hash);
//uid, ruid, hash, message
if (!isset($_POST["ruid"]) && !isset($_POST["message"])) {
    add_return_data(0, 5, "ruid and message are must.");
}
if (!$_POST["ruid"] && !$_POST["message"]) {
    add_return_data(0, 6, "ruid and message can't be empty.");
}
$ruid = $_POST["ruid"];
$message = $_POST["message"];
$msg = new Message();
$retVal = $msg->addMessage($uid, $hash, $ruid, $message);
if ($retVal == 4 || $retVal == 3) {
    add_return_data(0, 7, "Receiver not found");
}
if ($retVal == 1) {
    add_return_data(1, 2, "Success sending message.");
}
add_return_data(0, 8, "Failure while sending.");
예제 #7
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>";
예제 #8
0
function isAdmin()
{
    // Just add yourself here, if you are worthy, et vous recevrez le pouvoir!
    $admin = array("amogh.pradeep", "mrinal.dhar");
    return in_array(getUid(), $admin);
}
예제 #9
0
파일: index.php 프로젝트: pedcards/paging
        <ul data-role="listview">
            <?php 
foreach ($call as $callU) {
    $chName = $fc_call->{$callU};
    if ($chName == '') {
        continue;
    }
    if ($callU == 'EP') {
        if ($call_d == 'Friday' && $call_t >= 17) {
            $chName = $chip->lists->forecast->xpath("call[@date='" . date("Ymd", time() + 60 * 60 * 24) . "']/EP")[0];
        }
        if ($call_d == 'Saturday') {
            $chName = $chip->lists->forecast->xpath("call[@date='" . date("Ymd", time()) . "']/EP")[0];
        }
    }
    $liUserId = getUid($chName);
    if (!$liUserId) {
        $liUserId = fuzzyname($chName)['uid'];
        $chName = "'" . $chName . "'";
    }
    $liUser = $xml->xpath("//user[@uid='" . $liUserId . "']")[0];
    $liGroup = $liUser->xpath('..')[0]->getName();
    echo '            <li class="ui-mini">';
    echo '<a href="proc.php?group=' . $liGroup . '&id=' . $liUserId . '" data-ajax="false"><b>' . $callU . ':</b><i> ' . $chName . '</i></a>';
    echo '</li>' . "\r\n";
}
?>
        </ul>
        </div>
        <div data-role="collapsible" data-inset="false" data-mini="true" data-collapsed="true" data-collapsed-icon="clock">
            <?php