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; }
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; }
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); } }
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); } }
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); } }
<?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.");
<?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>";
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); }
<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