vote api include
This commit is contained in:
parent
e92f67e0c1
commit
99612ce729
3
api.php
3
api.php
@ -4,7 +4,8 @@ require_once '../system/autoload.inc.php';
|
||||
require_once 'uVote/autoload.inc.php'; //Project Classes
|
||||
require_once '../system/log/register_exception_shortcut.php'; //allow ERROR() instead of \SYSTEM\LOG\ERROR()
|
||||
require_once '../system/log/register_errorhandler_jsonoutput.php'; //print errors as json to caller
|
||||
|
||||
require_once '../system/log/register_result_shortcut.php';
|
||||
|
||||
SYSTEM\system::start(array( array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_ERRORREPORTING, E_ALL | E_STRICT),
|
||||
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL, 'http://www.mojotrollz.eu/web/uVote/'),
|
||||
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEPATH, '/home/web/webdir/uVote/'),
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ApiClass extends \SYSTEM\API\apiloginclass {
|
||||
|
||||
public static function call_vote_action_vote($poll_ID, $vote) {
|
||||
return votes::write_vote($poll_ID, $vote);
|
||||
}
|
||||
}
|
||||
@ -12,4 +12,19 @@ class votes {
|
||||
|
||||
return $result;
|
||||
}
|
||||
public static function write_vote($poll_ID, $vote){
|
||||
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
|
||||
$res = $con->prepare( 'selVote',
|
||||
'SELECT * FROM `uvote_data` WHERE `poll_ID` = ?;',
|
||||
array($poll_ID));
|
||||
// print_r($res->next());
|
||||
// die();
|
||||
if ($res->next()){
|
||||
throw new ERROR('You already voted!'); }
|
||||
$res = $con->prepare( 'insertVote',
|
||||
'INSERT INTO uvote_data
|
||||
VALUES (?, ?, ?);',
|
||||
array($poll_ID, NULL, $vote));
|
||||
return JsonResult::ok();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user