include 'init.php'; //pre defined variables if (empty($_GET['action'])) { throw new Exception('empty action'); } $res = validateAccessToken($_REQUEST['access_token']); $return['uid'] = null; if (!empty($res)) { define('UID', $res['uid']); $return['uid'] = $res['uid']; } switch ($_GET['action']) { case 'saveReligion': ///religion/all ///religion/sections/id $DbTools = new DbTools(); $_REQUEST['path'] = '/religion/all'; $arr = $DbTools->add($tableName, $tableTag, $_REQUEST); if (empty($arr['id'])) { throw new Exception('could not create, please try again later'); } $id = $arr['id']; $d = array(); $d['path'] = '/religion/sections/' . $id; $d['title'] = 'General'; $d['appr'] = 1; $arr2 = $DbTools->add($tableName, $tableTag, $d); $arr['sections'] = $arr2; $return['data'] = $arr; break; default:
$data['results'][$k]['location'] = $res2; //$data['results'][$k]['user_info'] = $res3; //$data['results'][$k]['tags'] = $res4; } }*/ break; //getOne //getOne case 'getOne': //http://bootstrap.mkgalaxy.com/svnprojects/horo/records.php //Get Params //?action=getOne&id=15 if (empty($_REQUEST['id'])) { throw new Exception('missing id'); } $DbTools = new DbTools(); $data = $DbTools->getOne($tableName, $tableTag, $_REQUEST['id']); $return['data'] = $data; /*$q = 'select * from '.$tableName.' WHERE id = ?'; $res = $Models_General->fetchRow($q, array($_REQUEST['id']), TIMESMALL); $q = 'select * from locations WHERE location_id = ?'; $res2 = $Models_General->fetchRow($q, array($res['location_id']), TIMEBIG); $q = 'select * from users_info WHERE users_info_id = ?'; $res3 = $Models_General->fetchRow($q, array($res['users_info_id']), TIMEBIG); $res3['users_info_full'] = json_decode($res3['users_info'], 1); $q = 'select * from '.$tableTag.' WHERE id = ?'; $res4 = $Models_General->fetchAll($q, array($res['id']), TIMESMALL); $data = array(); $data = $res; $data['location'] = $res2; $data['user_info'] = $res3;
/** * * @global array $get * @global array $data * @param string $postAcc , valor de la variable POST accion * @return boolean * * pasa todos los $_POST a $data y todos los $_GET a $get y si se le pasa * una acción en $postAcc devuelve TRUE si $_POST["accion"]==$postAcc */ function getAndPost($postAcc = null) { global $get; global $data; foreach ($_GET as $key => $value) { $get[$key] = DbTools::filterData($value); } if (isset($_POST['accion']) && $_POST['accion'] == $postAcc) { foreach ($_POST as $key => $value) { $data[$key] = DbTools::filterData($value); } return TRUE; } else { return FALSE; } }