示例#1
0
<?php

// items/update POST
include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("item_id", "title", "description", "image_ref"));
$item_id = $post_data['item_id']['value'];
$title = $post_data['title']['value'];
$description = $post_data['description']['value'];
$image_ref = $post_data['image_ref']['value'];
preg_match_all("/#(\\w+)/", $description, $tags);
$result = db_cud_function(items_update($item_id, $title, $description, $image_ref));
db_cud_function(hashtagories_clear($item_id));
//    var_dump($result);
//    var_dump($new_item);
// for each found hashtag in regex,
// create hashtag relationship
//var_dump($tags[1]);
foreach ($tags[1] as $t) {
    //echo hashtagories_tag_item($new_item, $t);
    //echo
    db_cud_function(hashtagories_tag_item($item_id, $t));
}
if ($result) {
    http_response_code(200);
    echo $result;
} else {
    echo '{data:false}';
}
示例#2
0
<?php

// auctions/close
include '../auth.php';
include '../sql_statements.php';
include '../helper.php';
$id = $_POST['auction_id'];
$result = db_cud_function(auctions_close($id));
if ($result) {
    http_response_code(200);
    echo $result;
} else {
    http_response_code(500);
    echo '{error:"no data returned"}';
}
示例#3
0
<?php

// watches/delete POST OK
include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("watch_user_id", "watch_auction_id"));
$watch_user_id = $post_data['watch_user_id']['value'];
$watch_auction_id = $post_data['watch_auction_id']['value'];
$result = db_cud_function(watches_delete($watch_user_id, $watch_auction_id));
if ($result) {
    http_response_code(200);
    echo $result;
} else {
    http_response_code(304);
    //Not modified
    echo '{data:false}';
}
示例#4
0
<?php

// bids/create POST OK
include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array('bidder_user_id', 'bid_auction_id', 'bid_price'));
$bidder_user_id = $post_data['bidder_user_id']['value'];
$bid_auction_id = $post_data['bid_auction_id']['value'];
$bid_price = $post_data['bid_price']['value'];
//    var_dump($post_data);
//echo bids_create($bidder_user_id, $bid_price, $bid_auction_id);
$result = db_cud_function(bids_create($bidder_user_id, $bid_price, $bid_auction_id));
if ($result) {
    http_response_code(200);
    echo '{"data": true}';
} else {
    echo '{data: false}';
}
示例#5
0
// items/create POST OK
//    include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("owner_user_id", "title", "description", "image_ref"));
$owner_user_id = $post_data['owner_user_id']['value'];
$title = $post_data['title']['value'];
$description = $post_data['description']['value'];
$image_ref = $post_data['image_ref']['value'];
preg_match_all("/#(\\w+)/", $description, $tags);
$result = db_r_function(items_create($owner_user_id, $title, $description, $image_ref));
$new_item = json_decode($result, true)[0]['last_insert_id()'];
//    var_dump($result);
//    var_dump($new_item);
// for each found hashtag in regex,
// create hashtag relationship
//var_dump($tags[1]);
foreach ($tags[1] as $t) {
    //echo hashtagories_tag_item($new_item, $t);
    //echo
    db_cud_function(hashtagories_tag_item($new_item, $t));
}
if ($result) {
    http_response_code(201);
    echo $result;
} else {
    http_response_code(304);
    //Not modified
    echo '{"data":false}';
}
示例#6
0
<?php

// items/delete POST OK
include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("item_id"));
$item_id = $post_data['item_id']['value'];
$result = db_cud_function(items_delete($item_id));
if ($result) {
    http_response_code(200);
    echo $result;
} else {
    //        http_response_code(500);
    echo '{data:false}';
}
示例#7
0
<?php

// users/change_password
include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("user_id", "password", "new_password"));
$user_id = $post_data['user_id']['value'];
$password = md5($post_data['password']['value']);
$new_password = md5($post_data['new_password']['value']);
//$new_password_confirm = $_POST['new_password_confirm'];
//echo $password;
//echo users_change_password($user_id, $password, $new_password);
$result = db_cud_function(users_change_password($user_id, $password, $new_password));
if ($result === TRUE) {
    http_response_code(200);
    echo '{"data":true}';
} else {
    http_response_code(200);
    //Not modified
    echo '{"error":"' . $result . '"}';
}
示例#8
0
<?php

// users/update POST
include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("user_id", "first_name", "last_name", "email"));
$user_id = $post_data['user_id']['value'];
//$username = $_POST['username'];
$firstname = $post_data['first_name']['value'];
$lastname = $post_data['last_name']['value'];
$email = $post_data['email']['value'];
//$password = $_POST['password'];
$result = db_cud_function(users_update($user_id, $username, $firstname, $lastname, $email));
if ($result) {
    http_response_code(201);
    echo $result;
} else {
    http_response_code(304);
    //Not modified
    echo '{data:false}';
}
示例#9
0
<?php

// users/create POST
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("username", "first_name", "last_name", "email", "password"));
$username = $post_data['username']['value'];
$firstname = $post_data['first_name']['value'];
$lastname = $post_data['last_name']['value'];
$email = $post_data['email']['value'];
$password = md5($post_data['password']['value']);
$result = db_cud_function(users_create($username, $firstname, $lastname, $email, $password));
if ($result) {
    http_response_code(201);
    echo $result;
} else {
    http_response_code(304);
    //Not modified
    echo '{data:false}';
}
示例#10
0
<?php

// auctions/create POST
include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("auction_item_id", "start_time", "end_time", "reserve_price"));
$auction_item_id = $post_data['auction_item_id']['value'];
$start_time = $post_data['start_time']['value'];
$end_time = $post_data['end_time']['value'];
$reserve_price = $post_data['reserve_price']['value'];
$result = db_cud_function(auctions_create($auction_item_id, $start_time, $end_time, $reserve_price));
$data = json_decode($result);
db_cud_function(watches_create($data['owner_user_id'], $data['auction_id']));
if ($result) {
    http_response_code(200);
    echo '{"data": true}';
} else {
    echo '{"data": false}';
}
示例#11
0
<?php

// feedback/update POST
//include '../../auth.php';
include '../../sql_statements.php';
include '../../helper.php';
include '../../post_header.php';
$post_data = validate_data("POST", array("feedback_text", "feedback_rating", "user_id", "feedback_auction_id"));
$feedback_text = $post_data['feedback_text']['value'];
$feedback_rating = $post_data['feedback_rating']['value'];
$user_id = $post_data['user_id']['value'];
$feedback_auction_id = $post_data['feedback_auction_id']['value'];
$result = db_cud_function(feedback_update($feedback_text, $feedback_rating, $user_id, $feedback_auction_id));
if ($result) {
    http_response_code(201);
    echo $result;
} else {
    http_response_code(304);
    //Not modified
    echo '{data:false}';
}