Пример #1
0
<?php

require_once "praveen.php";
$app = new praveen();
$keys = array("phone", "email");
$app->checkPOST($keys);
$phone = $app->escapedPost($keys[0]);
$email = $app->escapedPost($keys[0]);
if (is_numeric($phone)) {
    $sql = "select (id) from registered_users where phone='{$phone}' or email='{$email}' limit 1";
    $result = $app->query($sql);
    $userCount = $result->num_rows;
    if ($userCount == 0) {
        $password = $app->generateRandomString(8);
        if ($phone == "") {
            $sql = "insert into registered_users(email, password) values ('{$email}','{$password}')";
        } else {
            if ($email == "") {
                $sql = "insert into registered_users(email,password) values ('{$phone}','{$password}')";
            } else {
                $sql = "insert into registered_users(phone, email, password) values ('{$phone}','{$email}','{$password}')";
            }
        }
        $result = $app->query($sql);
        $resp[error] = 0;
        if (debug) {
            $resp['status'] = "success";
        }
    } else {
        if (debug) {
            $resp["status"] = "Already registered";
Пример #2
0
<?php

require_once "praveen.php";
$app = new praveen();
$keys = array("username", "password");
$app->checkPOST($keys);
$username = $app->escapedPost($keys[0]);
$password = $app->escapedPost($keys[1]);
$sql = "select id from registered_users WHERE( phone='{$username}' or email ='{$username}') and (password='******' )limit 1";
$result = $app->query($sql);
$usercount = $result->num_rows;
if ($usercount == 1) {
    $row = $result->fetch_array();
    $resp['userid'] = $row['id'];
    $resp[error] = 0;
    if (debug) {
        $resp['status'] = "success";
    }
} else {
    $resp[error] = 5;
    if (debug) {
        $resp['status'] = "Authentication Failure";
    }
}
echo json_encode($resp);
Пример #3
0
<?php

require_once "praveen.php";
$respjson = array("status" => "unprocessed", error => 1);
$keys = array("userid", "password", "repassword");
$prn = new praveen();
$password = $prn->safePost("password");
$repassword = $prn->safePost("repassword");
if ($prn->checkPOST($keys)) {
    if (strcmp($password, $repassword) == 0) {
        $con = $prn->getConnection();
        if ($con) {
            $userid = $prn->safePost("userid");
            $sql = "select password from registered_users where id='{$userid}' limit 1";
            if ($result = $prn->query($sql)) {
                $usercount = $result->num_rows;
                if ($usercount == 1) {
                    $sql = "update  hawabaaz.registered_users set password='******' where id='{$userid}'";
                    $prn->query($sql);
                    $respjson[error] = 0;
                    $respjson['status'] = "success";
                } else {
                    $respjson["status"] = "Authentication Failure";
                    $respjson[error] = 5;
                }
            } else {
                $respjson["status"] = "SQL querry error";
                $respjson["SqlError"] = $conn->error;
                $respjson[error] = 4;
            }
        } else {
Пример #4
0
<?php

require_once "praveen.php";
$app = new praveen();
$keys = array("locationid");
$app->checkPOST($keys);
$locationid = $app->escapedPost($keys[0]);
$sql = "select id,name from available_recipies where location='{$locationid}'";
$result = $app->query($sql);
$resp["list"] = array();
while ($row = $result->fetch_array()) {
    $entry = array($row['id'], $row['name']);
    $resp["list"][] = $entry;
}
$resp[error] = 0;
if (debug) {
    $resp['status'] = "success";
}
echo json_encode($resp);
Пример #5
0
<?php

require_once "praveen.php";
$app = new praveen();
$keys = array("orderid");
$app->checkPOST($keys);
$orderid = $app->escapedPost($keys[0]);
$sql = "insert into cancel_request (order_id) values ('{$orderid}')";
$app->query($sql);
$resp[error] = 0;
if (debug) {
    $resp['status'] = "success";
}
echo json_encode($resp);
Пример #6
0
<?php

require_once "praveen.php";
$resp = array("status" => "unprocessed", error => 1);
$keys = array("OTP", "userId", "password", "rePassword");
$prn = new praveen();
if ($prn->checkPOST($keys)) {
    $userId = $prn->safePost("userId");
    $otp = $prn->safePost("OTP");
    $password = $prn->safePost("password");
    $rePassword = $prn->safePost("rePassword");
    if ($password == $rePassword) {
        $con = $prn->getConnection();
        if ($con) {
            $sql = "select verified from registered_users where id='{$userId}' and temporary_password ='******' limit 1";
            if ($result = $prn->query($sql)) {
                $usercount = $result->num_rows;
                if ($usercount == 1) {
                    $row = $result->fetch_array();
                    if ($row['verified'] == 0) {
                        $sql = "update  hawabaaz.registered_users set password='******', temporary_password='', verified=1  where id='{$userId}' ";
                        if ($prn->query($sql)) {
                            $resp[error] = 0;
                            if ($prn->debug) {
                                $resp['status'] = "success";
                            }
                        } else {
                            $resp[error] = 4;
                        }
                    } else {
                        $resp[error] = 105;
Пример #7
0
<?php

require_once "praveen.php";
$app = new praveen();
$keys = array("userid");
$app->checkPOST($keys);
$userid = $app->escapedPost($keys[0]);
$sql = "select id,order_status from orders where user='******'";
$result = $app->query($sql);
$resp["list"] = array();
while ($row = $result->fetch_array()) {
    $entry = array($row['id'], $row['order_status']);
    $resp["list"][] = $entry;
}
$resp[error] = 0;
if (debug) {
    $resp['status'] = "success";
}
echo json_encode($resp);
Пример #8
0
<?php

require_once "praveen.php";
$app = new praveen();
$sql = "select id,name from available_locations";
$result = $app->query($sql);
$resp["list"] = array();
while ($row = $result->fetch_array()) {
    $entry = array($row['id'], $row['name']);
    $resp["list"][] = $entry;
}
$resp[error] = 0;
if (debug) {
    $resp['status'] = "success";
}
echo json_encode($resp);
Пример #9
0
<?php

require_once "praveen.php";
$app = new praveen();
$keys = array("recipeid", "rating", "userid", "comment");
$app->checkPOST($keys);
$recipeid = $app->escapedPost($keys[0]);
$rating = $app->escapedPost($keys[1]);
$userid = $app->escapedPost($keys[2]);
$comment = $app->escapedPost("{$keys['3']}");
$sql = "insert into ratings (recipe_id,rating,user,comment) VALUES ({$recipeid},{$rating},{$userid},'{$comment}')";
$app->query($sql);
$resp[error] = 0;
if (debug) {
    $resp['status'] = "success";
}
echo json_encode($resp);
Пример #10
0
<?php

require_once "praveen.php";
$keys = array("userId", "orders");
$app = new praveen();
$conn = $app->getConnection();
$app->checkPOST($keys);
$userId = $app->escapedPost($keys[0]);
$json = $app->escapedPost($keys[1]);
$sql = "insert into orders(user) value ({$userId})";
$result = $app->query($sql);
$orderId = $conn->insert_id;
if ($orders = json_decode($json, true)) {
    $sql = "";
    foreach ($orders as $order) {
        $sql .= "insert into ordered_items(order_id, item_id, item_count) VALUES ({$orderId},{$order['0']},{$order['1']});";
    }
    $app->multiQuery($sql);
    $resp[error] = 0;
    if (debug) {
        $resp[status] = "success";
    }
} else {
    $resp[error] = 6;
    if (debug) {
        $resp['status'] = "Json decode error";
        $resp['json'] = $json;
        $resp[line] = __LINE__;
    }
}
echo json_encode($resp);