remove not used update mode

This commit is contained in:
jelhan 2014-01-28 02:06:37 +01:00
parent 61e3fcad67
commit ff3ef88585
2 changed files with 0 additions and 57 deletions

37
api.php
View file

@ -59,43 +59,6 @@ switch ($_SERVER['REQUEST_METHOD']) {
}
break;
// update data
case 'PUT':
// get requested id from query parameter
if (!isset($requested_id)) {
throw new Exception("Requested data but there is no ID in URI");
}
// get data send with request
$data = file_get_contents('php://input');
// write new data
$result = $datahandler->update($requested_id, $data);
if ($result === false) {
header("HTTP/1.0 500 Internal Server Error");
}
else {
// set http header
header("HTTP/1.0 200 OK");
// forbidde browser to lead javascript from an external location
header("Content-Security-Policy: script-src 'self'");
// set content-type and charset
header('Content-Type: application/x-json-encrypted; charset=utf-8');
// extend given data with newId
// this point has to be fixed at it would not work with encrypted json
$newData = json_decode($data);
$newData->poll->id = $requested_id;
// send back data
echo json_encode($newData);
}
break;
// write data
case 'POST':

View file

@ -139,26 +139,6 @@ class datahandler {
return $highest_id + 1;
}
/*
* update existing data
* returns true on success or false on error
*/
public function update($id, $data) {
$file = self::DATA_FOLDER . $id;
// check if file is writeable
if (!is_writeable($file)) {
return false;
}
// write data
if (file_put_contents($file, $data, LOCK_EX) === false) {
return false;
}
return true;
}
/*
* store poll data
* returns new id or false on error