* => controllers/app.php */ //dispatch('/app', 'apps'); //dispatch('/app/list', 'listApps'); //dispatch('/app/:operation/:app', 'operateApp'); //dispatch('/app/:operation/:app/ajax', 'operateAppAjax'); /** * => controllers/user.php */ dispatch('/user', 'user'); dispatch('/user/list', 'listUser'); dispatch('/user/details/:user', 'userDetails'); dispatch('/user/add', 'addUserForm'); dispatch_post('/user/add', 'addUser'); dispatch('/user/delete/:user', 'deleteUserForm'); dispatch_delete('/user/delete', 'deleteUser'); //dispatch('/user/update/:user', 'updateUserForm'); //dispatch_put('/user/update/:user', 'updateUser'); //dispatch('/user/mailaliases/:user', 'updateMailAliasesUserForm'); //dispatch_put('/user/mailaliases/:user', 'updateMailAliasesUser'); //dispatch('/user/password/:user', 'updatePasswordUserForm'); //dispatch_put('/user/password/:user', 'updatePasswordUser'); /** * => controllers/tools.php */ //dispatch('/tools', 'tools'); //dispatch('/tools/log/:service/:logFile', 'watchLog'); //dispatch('/tools/chat', 'getChat'); //dispatch('/tools/chat/enable', 'enableChat'); //dispatch('/tools/chat/disable', 'disableChat'); //dispatch('/tools/monitor', 'systemMonitor');
option('env', $env); option('dsn', $dsn); option('db_conn', $db); option('debug', true); } function after($output) { $time = number_format((double) substr(microtime(), 0, 10) - LIM_START_MICROTIME, 6); $output .= "<!-- page rendered in {$time} sec., on " . date(DATE_RFC822) . "-->"; return $output; } layout('layout/default.html.php'); // main controller dispatch('/', 'main_page'); // books controller dispatch_get('books', 'books_index'); dispatch_post('books', 'books_create'); dispatch_get('books/new', 'books_new'); dispatch_get('books/:id/edit', 'books_edit'); dispatch_get('books/:id', 'books_show'); dispatch_put('books/:id', 'books_update'); dispatch_delete('books/:id', 'books_destroy'); // authors controller dispatch_get('authors', 'authors_index'); dispatch_post('authors', 'authors_create'); dispatch_get('authors/new', 'authors_new'); dispatch_get('authors/:id/edit', 'authors_edit'); dispatch_get('authors/:id', 'authors_show'); dispatch_put('authors/:id', 'authors_update'); dispatch_delete('authors/:id', 'authors_destroy'); run();
<?php require_once "lib/limonade.php"; dispatch_get("/", "redirect_data"); dispatch_get("/data", "data"); dispatch_get("/data/extract", "data_extract"); dispatch_get("/document", "document"); dispatch_get("/promo", "promo"); dispatch_post("/document", "add_document"); dispatch_post("/promo", "add_promo"); dispatch_put("/data/:dataid", "alter_data"); dispatch_put("/document/:documentid", "alter_document"); dispatch_put("/promo/:promoid", "alter_promo"); dispatch_delete("/document/:fileid", "delete_document"); dispatch_delete("/promo/:promoid", "delete_promo"); try { run(); } catch (Exception $e) { error_log($e); }
$service_id = intval($_POST['service_id']); $connect = isset($_POST['connect']) ? true : false; $result = $db->insert("INSERT INTO {$cfg['tblAccess']}\n (rolle_id, dienst_id) VALUES\n ('{$role_id}', '{$service_id}')"); if (!$result) { halt(SERVER_ERROR); return; } if (isAjaxRequest() && $connect) { $arrRoles = fetchRolesServices("WHERE {$cfg['tblRole']}.id = {$role_id}"); return js('roles_services/role.js.php', null, array('role' => array_pop($arrRoles))); } else { halt(HTTP_NOT_IMPLEMENTED); } } # delete the link between role and a service dispatch_delete('/roles_services', 'roles_services_delete'); function roles_services_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $role_id = intval($_POST['role_id']); $service_id = intval($_POST['service_id']); $connect = isset($_POST['connect']) ? true : false; $result = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE rolle_id='{$role_id}'\n AND dienst_id='{$service_id}'\n LIMIT 1"); if (!$result) { halt(SERVER_ERROR); return; } if (isAjaxRequest() && $connect) { $arrRoles = fetchRolesServices("WHERE {$cfg['tblRole']}.id = {$role_id}"); return js('roles_services/role.js.php', null, array('role' => array_pop($arrRoles)));
$desc = $db->escape($_POST['desc']); $result = $db->update("UPDATE {$cfg['tblClient']}\n SET person_id='{$person_id}', type='{$type}', mac='{$mac}', `desc`='{$desc}'\n WHERE id={$id}\n LIMIT 1"); if ($result) { $arrClient = fetchClients("WHERE {$cfg['tblClient']}.id={$id}"); set('client', array_pop($arrClient)); if (isAjaxRequest()) { return js('clients/show.js.php', null, array('nested' => $nested)); } else { redirect_to('clients'); } } else { halt(SERVER_ERROR); } } # remove a client dispatch_delete('/clients/:id', 'clients_delete'); function clients_delete() { $id = intval(params('id')); $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $result = $db->delete("DELETE FROM {$cfg['tblClient']}\n WHERE id={$id}\n LIMIT 1"); if ($result) { set('client', array('id' => $id)); if (isAjaxRequest()) { return js('clients/delete.js.php', null); } else { redirect_to('clients'); } } else { halt(SERVER_ERROR);
function people_update() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval($_POST['id']); $vorname = $db->escape($_POST['vorname']); $nachname = $db->escape($_POST['nachname']); $result = $db->update("UPDATE {$cfg['tblPerson']}\n SET vorname='{$vorname}', nachname='{$nachname}'\n WHERE id={$id}\n LIMIT 1"); if ($result) { redirect_to('people'); } else { halt(SERVER_ERROR); } } # remove a person dispatch_delete('/people/:id', 'people_delete'); function people_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval(params('id')); $result = $db->delete("DELETE FROM {$cfg['tblPerson']}\n WHERE id={$id}\n LIMIT 1"); $resClientForeign = $db->delete("DELETE FROM {$cfg['tblClient']}\n WHERE person_id={$id}"); $resHasRolleForeign = $db->delete("DELETE FROM {$cfg['tblPersonHasRole']}\n WHERE person_id={$id}"); if ($result && $resClientForeign && $resHasRolleForeign) { set('person', array('id' => $id)); if (isAjaxRequest()) { return js('people/delete.js.php', null); } else { redirect_to('people'); }
(int) $id; return $id / $divider; } dispatch('/route9/*', 'MyController::staticMethod'); dispatch('/route9b/*', 'MyController::staticMethod', array('params' => array(10))); dispatch(array('/route10/*', array('id')), 'MyController::staticMethod'); dispatch(array('/route10b/*', array('id')), 'MyController::staticMethod', array('params' => array('id' => 10))); /* http methods dispatching */ dispatch_get('/route11', 'test_route11'); function test_route11() { header('X-LIM-CTL: route11'); return "GET"; } dispatch_post('/route11', 'test_route11post'); function test_route11post() { //header('Content-length: 4'); return "POST"; } dispatch_put('/route11', 'test_route11put'); function test_route11put() { return "PUT"; } dispatch_delete('/route11', 'test_route11delete'); function test_route11delete() { return "DELETE"; } run();
<?php require_once 'autoload.php'; //load app classes require_once 'lib/limonade.php'; dispatch('/css/:css', 'AssetController::css'); dispatch('/js/:js', 'AssetController::js'); //REST API dispatch_get('/api/users', 'UserController::index'); dispatch_get('/api/users/:id', 'UserController::get'); dispatch_post('/api/users', 'UserController::post'); dispatch_put('/api/users/:id', 'UserController::put'); dispatch_delete('/api/users/:id', 'UserController::remove'); dispatch_get('/api/users/search/:name', 'UserController::search'); //pages dispatch('/', 'MainController::index'); run();
$resultDocuments[$i]['fichier'] = $data['fichier']; $i++; } if (isset($resultDocuments)) { return $resultDocuments; } else { return null; } } /** * Delete document function. * * @author paul.michaud * @author loic.bothorel */ dispatch_delete('/deleteDocument', 'deleteDocument'); function deleteDocument() { $query = "SELECT id FROM document"; $result = mysql_query($query) or die(mysql_error()); while ($data = mysql_fetch_array($result)) { if ($data['id'] == $_POST['id']) { $query = 'DELETE FROM document WHERE id = "' . $_POST['id'] . '"'; $result = mysql_query($query) or die(mysql_error()); //On supprime également le fichier sur le serveur unlink('/var/www/html/rentree/user/pdf/' . $_POST['fichier']); } } return documents(); } /**
if ($data['id'] == $_POST['id']) { $query = 'UPDATE data SET identifiant = "' . $_POST['identifiant'] . '", nom_fils = "' . $_POST['nom'] . '", prenom_fils = "' . $_POST['prenom'] . '", ddn_fils = "' . $_POST['ddn'] . '", tel_mobile = "' . $_POST['tel'] . '", courriel = "' . $_POST['courriel'] . '" WHERE id = "' . $_POST['id'] . '"'; $result = mysql_query($query) or die(mysql_error()); } } return datas(); } /** * Delete class function. * * @author paul.michaud * @author loic.bothorel */ dispatch_delete('/deleteStudent', 'deleteStudent'); function deleteStudent() { $query = "SELECT id FROM data"; $result = mysql_query($query) or die(mysql_error()); while ($data = mysql_fetch_array($result)) { if ($data['id'] == $_POST['id']) { $query = 'DELETE FROM data WHERE id = "' . $_POST['id'] . '"'; $result = mysql_query($query) or die(mysql_error()); } } return datas(); } /** * Extract to .csv class function. *
} lemon_csrf_unset_token(); if (!$token_expired) { $auth = lemon_auth(option('auth_config')); // redirect to '/espace_client' if login successfuly $errors = array_merge(lemon_auth_login($_POST['username'], $_POST['password'], '/espace_client'), $errors); } // else unset($_SESSION['username']); flash('errors', $errors); flash('username', $_POST['username']); redirect_to('/espace_client/login'); } } # DELETE /espace_client/logout dispatch_delete('/espace_client/logout', 'helye_espace_client_logout'); function helye_espace_client_logout() { lemon_auth_logout(); redirect_to('/espace_client/login'); } # GET /espace_client/ # GET /espace_client/username/file.ext dispatch('/espace_client/**', 'helye_espace_client'); function helye_espace_client() { $auth = lemon_auth(option('auth_config')); if ($username = lemon_auth_logged_in()) { $is_admin = lemon_auth_is_admin($username); $path = params(0); $base_path = option('private_lemon_tree_root');
$arrDaemon = $db->select("SELECT *\n FROM {$cfg['tblDaemon']}\n WHERE id={$daemon_id}"); if (!$arrDaemon) { halt(SERVER_ERROR); return; } $arrDaemon[0]['d_desc'] = $desc; set('daemon', $arrDaemon[0]); set('server', array('id' => $server_id)); if (isAjaxRequest()) { return js('daemons_servers/show.js.php', null); } else { halt(HTTP_NOT_IMPLEMENTED); } } # delete the link between daemon and server dispatch_delete('/servers/:server_id/daemons/:daemon_id', 'daemons_servers_delete'); function daemons_servers_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $server_id = intval(params('server_id')); $daemon_id = intval(params('daemon_id')); $arrService = $db->select("SELECT id\n FROM {$cfg['tblService']}\n WHERE server_id='{$server_id}'\n AND daemon_id='{$daemon_id}'"); if (!$arrService) { halt(SERVER_ERROR); return; } $id = $arrService[0]['id']; $result = $db->delete("DELETE FROM {$cfg['tblService']}\n WHERE id='{$id}'\n LIMIT 1"); $resultForeign = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE dienst_id='{$id}'"); if (!$result || !$resultForeign) {
option('env', ENV_DEVELOPMENT); option('debug', true); option('session', 'Yummy_Plus3_Session_Cookie'); // true, false or the name of your session option('encoding', 'utf-8'); } // END function configure() # the index request dispatch('/', function () { return 'hello world'; }); dispatch('/phpinfo', function () { phpinfo(); return; }); $echo = function () { setcookie('example', 'test'); $response = array(); foreach ($GLOBALS as $key => $data) { if ($key != 'GLOBALS') { $response[$key] = $data; } } $response['_HEADERS'] = http_get_request_headers(); return json($response); }; dispatch_get('/echo', $echo); dispatch_post('/echo', $echo); dispatch_put('/echo', $echo); dispatch_delete('/echo', $echo); run();
$cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval($_POST['id']); $fqdn = $db->escape($_POST['fqdn']); $desc = $db->escape($_POST['desc']); $ip = $db->escape($_POST['ip']); $mac = $db->escape($_POST['mac']); $result = $db->update("UPDATE {$cfg['tblServer']}\n SET fqdn='{$fqdn}', `desc`='{$desc}', ip='{$ip}', mac='{$mac}'\n WHERE id={$id}\n LIMIT 1"); if (!$result) { halt(SERVER_ERROR); return; } redirect_to('servers'); } # delete a server dispatch_delete('/servers/:id', 'servers_delete'); function servers_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval(params('id')); $result = $db->delete("DELETE FROM {$cfg['tblServer']}\n WHERE id={$id}\n LIMIT 1"); $resForeign = $db->delete("DELETE {$cfg['tblService']}, {$cfg['tblAccess']}\n FROM {$cfg['tblService']}\n LEFT OUTER JOIN {$cfg['tblAccess']}\n ON {$cfg['tblService']}.id = {$cfg['tblAccess']}.dienst_id\n WHERE {$cfg['tblService']}.server_id={$id}"); if ($result && $resForeign) { set('server', array('id' => $id)); if (isAjaxRequest()) { return js('servers/delete.js.php', null); } else { redirect_to('servers'); } } else {
dispatch('/commissioner/challenge', 'AdminChallengeController::challenge'); dispatch_post('/commissioner/challenge', 'AdminChallengeController::challenge_add'); dispatch('/commissioner/challenge/edit', 'AdminChallengeController::challenge_show_edit'); dispatch_put('/commissioner/challenge/edit', 'AdminChallengeController::challenge_do_edit'); dispatch_delete('/commissioner/challenge/edit', 'AdminChallengeController::challenge_do_delete'); dispatch('/commissioner/challenge/check', 'AdminChallengeController::check'); // Player dispatch('/commissioner/player', 'AdminPlayerController::player'); dispatch('/commissioner/players', 'AdminPlayerController::player'); dispatch('/commissioner/player/new', 'AdminPlayerController::player_add'); dispatch_post('/commissioner/player/new', 'AdminPlayerController::player_do_add'); dispatch('/commissioner/player/:id', 'AdminPlayerController::player_show'); dispatch('/commissioner/player/:id/edit', 'AdminPlayerController::player_show_edit'); dispatch_put('/commissioner/player/:id/edit', 'AdminPlayerController::player_do_edit'); dispatch('/commissioner/player/:id/delete', 'AdminPlayerController::player_show_delete'); dispatch_delete('/commissioner/player/:id/delete', 'AdminPlayerController::player_do_delete'); // Player's Picks dispatch('/commissioner/players/picks', 'AdminPlayerPicksController::players'); dispatch('/commissioner/player/:uid/picks', 'AdminPlayerPicksController::player_picks'); dispatch('/commissioner/player/:uid/picks/:week', 'AdminPlayerPicksController::player_picks_week'); dispatch_post('/commissioner/player/:uid/picks/:week', 'AdminPlayerPicksController::save_player_picks_week'); /* * == UserController == * Method Path Controller * GET /login UserController::show_login * POST /login UserController::do_login * GET /logout UserController::do_logout * GET /my-account UserController::show_account * PUT /my-account UserController::edit_account */ dispatch('/login', 'UserController::show_login');
$result = $db->insert("INSERT INTO {$cfg['tblPort']}\n (number, proto, daemon_id) VALUES\n ('{$number}', '{$proto}', '{$daemon_id}')"); $id = $db->insertId(); if (!$result) { halt(SERVER_ERROR); return; } $arrPorts = fetchPorts("WHERE {$cfg['tblPort']}.id={$id}"); set('port', array_pop($arrPorts)); if (isAjaxRequest()) { return js('ports/show.js.php', null, array('nested' => $nesting)); } else { redirect_to('ports'); } } # delete a port dispatch_delete('/ports/:id', 'ports_delete'); function ports_delete() { $id = intval(params('id')); $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $result = $db->delete("DELETE FROM {$cfg['tblPort']}\n WHERE id={$id}\n LIMIT 1"); if (!$result) { halt(SERVER_ERROR); return; } set('port', array('id' => $id)); if (isAjaxRequest()) { return js('ports/delete.js.php', null); } else { halt(HTTP_NOT_IMPLEMENTED);
$arrPerson = $db->select("SELECT *\n FROM {$cfg['tblPerson']}\n WHERE id={$person_id}"); if (!$arrPerson) { halt(SERVER_ERROR); return; } set('person', $arrPerson[0]); set('role', array('id' => $role_id)); return js('people_roles/show.js.php', null); } } else { halt(HTTP_NOT_IMPLEMENTED); } } # delete the link between role and person dispatch_delete('/roles/:role_id/people/:person_id', 'people_roles_delete'); dispatch_delete('/people_roles', 'people_roles_delete'); function people_roles_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $role_id = intval(params('role_id')); $person_id = intval(params('person_id')); $connect = isset($_POST['connect']) ? true : false; if ($connect) { $role_id = intval($_POST['role_id']); $person_id = intval($_POST['person_id']); } $result = $db->delete("DELETE FROM {$cfg['tblPersonHasRole']}\n WHERE rolle_id='{$role_id}'\n AND person_id='{$person_id}'\n LIMIT 1"); if (!$result) { halt(SERVER_ERROR); return;
option('debug', true); $c = mysqli_connect(MYSQL_SERVER, MYSQL_USER, MYSQL_PASS, MYSQL_DATABASE); /******************************************************** * ROUTERS *******************************************************/ dispatch('/login/:pass', 'login'); dispatch('/logout', 'logout'); dispatch('/', 'home'); // People dispatch('/search/:q', 'search'); // Person dispatch('/get/:detail', 'get'); dispatch_post('/save', 'save'); dispatch_delete('/delete/:id', 'delete'); dispatch_post('/comment', 'comment'); dispatch_delete('/comment/:id', 'commentdelete'); // for API usage dispatch('/api/:pass/:action/:detail', 'api'); /******************************************************** * MODELS *******************************************************/ /** * login * Authenticate user * @param (string) User's password * @param (bool) Set as false to avoid redirect to the home page */ function login($pass, $redirect = true) { global $users, $form, $c; foreach ($users as $key => $user) {
$name = mysql_real_escape_string($_POST['addName']); $shortcut = mysql_real_escape_string($_POST['addShortcut']); $query = 'INSERT INTO promo (name, shortcut) VALUES("' . $name . '", "' . $shortcut . '")'; $result = mysql_query($query) or die(mysql_error()); return classes(); } /** * Delete class function. * * @param String shortcut * * @author paul.michaud * @author loic.bothorel */ //Retour 1: Supprimé 0: Le shortcut n'existe pas -> non supprimé dispatch_delete('/deleteClass', 'deletePromo'); function deletePromo() { //On commence par vérifier si le shortcut existe (clé primaire) $query = "SELECT shortcut FROM promo"; $result = mysql_query($query) or die(mysql_error()); while ($data = mysql_fetch_array($result)) { if ($data['shortcut'] == $_POST['shortcut']) { //Si le shortcut existe on le supprime $query = 'DELETE FROM promo WHERE shortcut = "' . $_POST['shortcut'] . '"'; $result = mysql_query($query) or die(mysql_error()); } } return classes(); } /**
} $arrService = $db->select("SELECT {$cfg['tblService']}.id as dienst_id,\n {$cfg['tblService']}.`desc` as dienst_desc,\n {$cfg['tblDaemon']}.name as daemon_name,\n {$cfg['tblServer']}.fqdn as fqdn\n FROM {$cfg['tblService']}\n LEFT OUTER JOIN {$cfg['tblServer']}\n ON {$cfg['tblServer']}.id = {$cfg['tblService']}.server_id\n LEFT OUTER JOIN {$cfg['tblDaemon']}\n ON {$cfg['tblDaemon']}.id = {$cfg['tblService']}.daemon_id\n WHERE {$cfg['tblService']}.id={$dienst_id}"); if (!$arrService) { halt(SERVER_ERROR); return; } set('service', $arrService[0]); set('role', array('id' => $role_id)); if (isAjaxRequest()) { return js('access/show.js.php', null); } else { halt(HTTP_NOT_IMPLEMENTED); } } # remove a role-service association dispatch_delete('/roles/:role_id/service/:service_id', 'access_delete'); function access_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $role_id = intval(params('role_id')); $dienst_id = intval(params('service_id')); $result = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE rolle_id='{$role_id}'\n AND dienst_id='{$dienst_id}'\n LIMIT 1"); if (!$result) { halt(SERVER_ERROR); return; } set('role', array('id' => $role_id)); set('service', array('id' => $dienst_id)); if (isAjaxRequest()) { return js('access/delete.js.php', null);
dispatch_put('/daemons', 'daemons_update'); function daemons_update() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval($_POST['id']); $name = $db->escape($_POST['name']); $result = $db->update("UPDATE {$cfg['tblDaemon']}\n SET name='{$name}'\n WHERE id={$id}\n LIMIT 1"); if (!$result) { halt(SERVER_ERROR); return; } redirect_to('daemons'); } # delete a daemon dispatch_delete('/daemons/:id', 'daemons_delete'); function daemons_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval(params('id')); $result = $db->delete("DELETE FROM {$cfg['tblDaemon']}\n WHERE id={$id}\n LIMIT 1"); $resPortsForeign = $db->delete("DELETE FROM {$cfg['tblPort']}\n WHERE daemon_id={$id}"); $resServiceForeign = $db->delete("DELETE {$cfg['tblService']}, {$cfg['tblAccess']}\n FROM {$cfg['tblService']}\n LEFT OUTER JOIN {$cfg['tblAccess']}\n ON {$cfg['tblService']}.id = {$cfg['tblAccess']}.dienst_id\n WHERE {$cfg['tblService']}.daemon_id={$id}"); if ($result && $resPortsForeign && $resServiceForeign) { set('daemon', array('id' => $id)); if (isAjaxRequest()) { return js('daemons/delete.js.php', null); } else { redirect_to('daemons'); }
# raises error / renders an error page } } # matches PUT /posts/1 dispatch_put('/posts/:id', 'blog_posts_update'); function blog_posts_update() { $post_id = params('id'); if (post_update($post_id, $_POST['post'])) { redirect_to('posts', $post_id); # redirects to this freshly just updated post } else { halt(SERVER_ERROR, "An error occured while trying to update post " . $post_id); # raises error / renders an error page } } # matches DELETE /posts/1 dispatch_delete('/posts/:id', 'blog_posts_destroy'); function blog_posts_destroy() { $post_id = params('id'); if ($post = post_destroy($post_id)) { redirect_to('posts'); # redirects to the index } else { halt(SERVER_ERROR, "An error occured while trying to destroy post " . $post_id); # raises error / renders an error page } } # 4. Running the limonade blog app run();
function fz_dispatch_delete($path_or_array, $controller, $action) { return dispatch_delete($path_or_array, 'fz_dispatcher', array('params' => array('controller' => $controller, 'action' => $action))); }
function roles_update() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval($_POST['id']); $name = $db->escape($_POST['name']); $desc = $db->escape($_POST['desc']); $result = $db->update("UPDATE {$cfg['tblRole']}\n SET name='{$name}', `desc`='{$desc}'\n WHERE id={$id}\n LIMIT 1"); if ($result) { redirect_to('roles'); } else { halt(SERVER_ERROR); } } #remove a role dispatch_delete('/roles/:id', 'roles_delete'); function roles_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $id = intval(params('id')); $result = $db->delete("DELETE FROM {$cfg['tblRole']}\n WHERE id={$id}\n LIMIT 1"); $resultPersonForeign = $db->delete("DELETE FROM {$cfg['tblPersonHasRole']}\n WHERE rolle_id={$id}"); $resultZugriffForeign = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE rolle_id={$id}"); if ($result && $resultPersonForeign && $resultZugriffForeign) { set('role', array('id' => $id)); if (isAjaxRequest()) { return js('roles/delete.js.php', null); } else { redirect_to('roles'); }