本文整理汇总了PHP中deliver_response函数的典型用法代码示例。如果您正苦于以下问题:PHP deliver_response函数的具体用法?PHP deliver_response怎么用?PHP deliver_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deliver_response函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mysql_connect
$conn = mysql_connect('localhost', 'webmaster', '');
mysql_select_db('edison', $conn);
$query = "SELECT *\n FROM control\n WHERE mac_address = '{$mac_address}'";
$result = mysql_query($query);
$result_array = mysql_fetch_array($result);
$control_type = $result_array[control_type];
$auto_control_command = $result_array[auto_control_command];
$manual_control_command = $result_array[manual_control_command];
$suspend_pwm1 = $result_array[suspend_pwm1];
$suspend_pwm2 = $result_array[suspend_pwm2];
$suspend_pwm3 = $result_array[suspend_pwm3];
$suspend_pwm4 = $result_array[suspend_pwm4];
$update_time = $result_array[update_time];
$response['control_type'] = $control_type;
$response['auto_control_command'] = $auto_control_command;
$response['manual_control_command'] = $manual_control_command;
$response['suspend_pwm1'] = $suspend_pwm1;
$response['suspend_pwm2'] = $suspend_pwm2;
$response['suspend_pwm3'] = $suspend_pwm3;
$response['suspend_pwm4'] = $suspend_pwm4;
$response['update_time'] = $update_time;
deliver_response(200, "The control commands have been got", $response);
function deliver_response($status, $status_message, $data)
{
header("HTTP/1.1 {$status} {$status_message}");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response);
echo $json_response;
}
示例2: add_new_user
function add_new_user()
{
$conn = new mysqli($GLOBALS['db'], $GLOBALS['login'], $GLOBALS['pass'], $GLOBALS['dbname']);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$query = "INSERT INTO GS_USER (NICKNAME, PASSWORD, EMAIL) VALUES (\n '" . $_POST['name'] . "',\n '" . sha1($_POST['password']) . "',\n '" . $_POST['email'] . "'\n )";
if (mysqli_query($conn, $query)) {
deliver_response(201, "Success", 2);
} else {
deliver_response(400, "Query error", 232);
}
}
示例3: authenticate
function authenticate()
{
if (empty($_POST['email'])) {
return false;
}
if (empty($_POST['password'])) {
return false;
}
$conn = new mysqli($GLOBALS['db'], $GLOBALS['login'], $GLOBALS['pass'], $GLOBALS['dbname']);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$query = "SELECT NICKNAME FROM GS_USER WHERE EMAIL='" . $_POST['email'] . "' AND PASSWORD='" . sha1($_POST['password']) . "'";
$result = $conn->query($query);
if ($result->num_rows == 1) {
$row = mysqli_fetch_assoc($result);
deliver_response(201, $query, $row['NICKNAME']);
return true;
} else {
return false;
}
}
示例4: deliver_response
if ($sqlQ1 and $sqlQ2) {
$response['success'] = true;
$response['status'] = 200;
$response['data'] = 'deleted';
} else {
$response['success'] = false;
$response['status'] = 404;
}
} else {
$response['status'] = 404;
$response['success'] = false;
}
}
} else {
$response['status'] = 404;
$response['success'] = false;
}
}
}
}
}
}
}
}
}
}
}
deliver_response('json', $response);
?>
示例5: deliver_response
die;
}
}
}
} else {
$res["status"] = false;
$res["message"] = "No File Present";
deliver_response(200, 'Okay', $res);
die;
}
$sql = "DELETE FROM frontcarouselgallery where ID = {$delid}";
$result = mysqli_query($conn, $sql);
$res = array();
if ($conn->query($sql) === TRUE) {
$res["status"] = true;
$res["message"] = "okay";
} else {
$res["status"] = false;
$res["message"] = $conn->error;
}
deliver_response(200, 'Okay', $res);
function deliver_response($status, $status_message, $data)
{
header("Content-Type:application/json");
header("HTTP/1.1 " . $status . " " . $status_message);
$response["status"] = $status;
$response["status_message"] = $status_message;
$response["data"] = $data;
$json_response = json_encode($data);
echo $json_response;
}
示例6: setArciereStampato
$response['data'] = setArciereStampato($tessera);
}
}
// Method q: Restituisce informazioni sulla foto;
if (strcasecmp($apiMethod, 'fotoinfo') == 0) {
if (isset($_GET['file'])) {
$file = $_GET['file'];
} else {
$file = null;
}
if (isset($_GET['tipo'])) {
$tipo = $_GET['tipo'];
} else {
$tipo = null;
}
if ($file == null || $tipo == null) {
$response['code'] = 0;
$response['status'] = $api_response_code[$response['code']]['HTTP Response'];
$response['data'] = "'Parametri obbligatori: file, il nome senza il percorso. Tipo: nonabbinate, abbinate";
} else {
$response['code'] = 1;
$response['status'] = $api_response_code[$response['code']]['HTTP Response'];
$response['data'] = getFotoInfo($file, $tipo);
}
}
// --- Step 4: Deliver Response
// Return Response to browser
deliver_response($apiFormat, $response);
//echo json_encode($response);
?>
示例7: mysqli
<?php
include '../../session.php';
include '../response.php';
include '../db.php';
$conn = new mysqli($GLOBALS['db'], $GLOBALS['login'], $GLOBALS['pass'], $GLOBALS['dbname']);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$query = "SELECT * FROM GS_MATCH WHERE ID=" . $_GET['id'];
$result = $conn->query($query);
if ($result->num_rows == 0) {
deliver_response(400, "No Match Found", NULL);
} else {
$query = "SELECT * FROM GS_HISTORY WHERE MATCH_ID =" . $_GET['id'] . " ORDER BY TURN";
$result = $conn->query($query);
$array = array();
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
array_push($array, array('turn' => $row['TURN'], 'user' => $row['USER_ID'], 'date' => $row['DATESTAMP'], 'description' => $row['DESCRIPTION']));
}
}
deliver_response(200, 'Games', $array);
}
示例8: deliver_response
{
echo $n;
echo $find;
echo $row['runtime'];
return $row['runtime'];
}
else
{
echo " Error:".mysql_error();
}
*/
function deliver_response($status, $status_message, $data)
{
header("HTTP/1.1 {$status} {$status_message}");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response);
echo $json_response;
}
if (!empty($_GET['name'])) {
$name = $_GET['name'];
$price = get_price($name);
if (empty($price)) {
deliver_response(200, "Movie NOT found!", NULL);
} else {
deliver_response(200, "Movie found!", $price);
}
} else {
deliver_response(404, "Invalid Request!", NULL);
}
示例9: header
header("Content-Type:application/json");
// start the session
session_start();
// close the session
session_write_close();
$conn = mysql_connect('localhost', 'webmaster', '');
mysql_select_db('edison', $conn);
$query = "SELECT *\n FROM camera\n WHERE id = '1'";
$result = mysql_query($query);
$result_array = mysql_fetch_array($result);
$image = $result_array[image];
$video = $result_array[video];
$latitude = $result_array[latitude];
$longitude = $result_array[longitude];
$update_time = $result_array[update_time];
$response['image'] = $image;
$response['video'] = $video;
$response['latitude'] = $latitude;
$response['longitude'] = $longitude;
$response['update_time'] = $update_time;
deliver_response(200, "The camera commands have been got", $response);
function deliver_response($status, $status_message, $data)
{
header("HTTP/1.1 {$status} {$status_message}");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response);
echo $json_response;
}
示例10: header
header("Content-Type:application/json");
// start the session
session_start();
$status = $_POST['status'];
$is_pwm_change = $_POST['is_pwm_change'];
$conn = mysql_connect('localhost', 'webmaster', '');
mysql_select_db('edison', $conn);
$query = "UPDATE `general`\n SET status = '{$status}', is_pwm_change = '{$is_pwm_change}', update_time = now()\n WHERE id = '1'";
$result = mysql_query($query);
// close the session
session_write_close();
$query = "SELECT id, status, is_pwm_change, update_time\n FROM `general`\n WHERE id=1";
$result = mysql_query($query);
$result_array = mysql_fetch_array($result);
$status = $result_array[status];
$is_pwm_change = $result_array[is_pwm_change];
$update_time = $result_array[update_time];
$response['status'] = $status;
$response['is_pwm_change'] = $is_pwm_change;
$response['update_time'] = $update_time;
deliver_response(200, "The general info has been updated", $response);
function deliver_response($status, $status_message, $data)
{
header("HTTP/1.1 {$status} {$status_message}");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response);
echo $json_response;
}
示例11: mysql_query
$result = mysql_query($query);
$result_array = mysql_fetch_array($result);
$last_time_image = $result_array[image];
$last_time_video = $result_array[video];
if ($image == NULL) {
$image = $last_time_image;
}
if ($video == NULL) {
$video = $last_time_video;
}
$query = "UPDATE camera\n SET image = '{$image}', video = '{$video}', update_time = now()\n WHERE id = '1'";
$result = mysql_query($query);
$query = "SELECT *\n FROM camera\n WHERE id = '1'";
$result = mysql_query($query);
$result_array = mysql_fetch_array($result);
$image = $result_array[image];
$video = $result_array[video];
$update_time = $result_array[update_time];
$response['image'] = $image;
$response['video'] = $video;
$response['update_time'] = $update_time;
deliver_response(200, "The camera commands have been updated", $response);
function deliver_response($status, $status_message, $data)
{
header("HTTP/1.1 {$status} {$status_message}");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response);
echo $json_response;
}
示例12: mysqli_query
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$msg[] = array("title" => $row['title'], "price" => $row['price'], "year" => $row['year'], "category" => $row['category']);
}
$json = $msg;
deliver_response(200, "Book Found", $json);
} else {
deliver_response(404, "Invalid Request", NULL);
}
mysqli_close($con);
} else {
$sql = "SELECT title from book";
$result = mysqli_query($con, $sql);
while ($row = mysqli_fetch_array($result)) {
$msg[] = $row['title'];
}
$json = $msg;
deliver_response(200, "List of Books", $json);
mysqli_close($con);
}
@mysql_close($conn);
function deliver_response($status, $status_message, $data)
{
header("HTTP/1.1 {$status} {$status_message}");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response);
echo $json_response;
}
示例13: mysql_query
$selectVisitorQuery1 = "select * from visitor where mobileNo='{$mobileNo}'";
$selectVisitor1 = mysql_query($selectVisitorQuery1, $conn) or die(mysql_error());
$selectVisitorRows1 = mysql_num_rows($selectVisitor1);
if ($selectVisitorRows1 > 0) {
deliver_response(203, "An Account With This Mobile Number Already Exists", "otp", $jsonresponse);
} else {
//Check if Email Id exists
$selectVisitorQuery2 = "select * from visitor where emailId='{$email}'";
$selectVisitor2 = mysql_query($selectVisitorQuery2, $conn) or die(mysql_error());
$selectVisitorRows2 = mysql_num_rows($selectVisitor2);
if ($selectVisitorRows2 > 0) {
deliver_response(203, "An Account With This Email Id Already Exists", "otp", $jsonresponse);
} else {
//Create OTP
/*$digits_needed=4;
$random_number=''; // set up a blank string
$count=0;
while ($count < $digits_needed )
{
$random_digit = mt_rand(0, 3);
$random_number .= $random_digit;
$count++;
}*/
//$jsonresponse=$random_number;
$jsonresponse = "1234";
//Hardcoded for Testing, Remove Later
json_encode($jsonresponse);
deliver_response(200, "OTP Created", "otp", $jsonresponse);
}
}
}
示例14: mysqli_query
<?php
require_once "connection.php";
$sql = "SELECT * FROM frontcarouselgallery order by ID desc";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
$retarray = array();
$objects = array();
while ($row = mysqli_fetch_assoc($result)) {
$retarray["id"] = $row["ID"];
$retarray["path"] = $row["Image"];
$retarray["title"] = $row["Title"];
$retarray["caption"] = $row["Caption"];
array_push($objects, $retarray);
}
}
deliver_response(200, 'Okay', $objects);
function deliver_response($status, $status_message, $data)
{
header("Content-Type:application/json");
header("HTTP/1.1 " . $status . " " . $status_message);
$response["status"] = $status;
$response["status_message"] = $status_message;
$response["data"] = $data;
$json_response = json_encode($data);
echo $json_response;
}
示例15: error_reporting
// Turn the error reporting on while debugging
error_reporting(0);
// Instance of the Connection class is used to perform the database related operations. For any database related error check $root/models/connection.php
$db = new Connection();
if (!$db || !$db->checkConnection()) {
// Database connection error
deliver_response(500, "Internal Server Error", null);
} else {
// Validate the URL before passing it to the database
if (filter_var($_GET['url'], FILTER_VALIDATE_URL)) {
// Get the token for the particular URL and call deliver_response() with the status code, the status message and the data accordingly
$result = $db->getToken($_GET['url']);
if (!$result) {
deliver_response(404, "Not Found", null);
} else {
deliver_response(201, "Created", $result);
}
} else {
deliver_response(400, "Bad Request", null);
}
}
// This function is used to prepare the response and deliver it in the JSON format
function deliver_response($status, $status_message, $data)
{
header("HTTP/1.1 {$status} {$status_message}");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['token'] = $data;
$json_response = json_encode($response);
echo $json_response;
}