query("SELECT * FROM `cms` ORDER BY `type`,`name`"); while($r = $q->fetch_assoc()) { $cms_pages[$r['name']] = $r['head']; } $action = ''; if(array_key_exists('action', $_POST)) { $action = $_POST['action']; } switch($action) { case 'get': $name = $_POST['name']; if(!array_key_exists($name, $cms_pages)) { exit(); } $q = $mysqli->query("SELECT `text`,`desc`,`type` FROM cms WHERE name='$name'"); $r = $q->fetch_row(); $vals = array(); $vals['text'] = $r[0]; $vals['desc'] = $r[1]; form_ajax_response(array('status'=>0, 'val'=>$vals)); exit(); case 'save': $name = $_POST['name']; if(!array_key_exists($name, $cms_pages)) { exit(); } $text = ''; post_text($text,'text'); $text = $mysqli->real_escape_string($text); $mysqli->real_query("UPDATE cms SET `text`='$text', `language`='en', `use`='1' WHERE `name`='$name'"); form_ajax_response(0); exit(); } sfiab_page_begin($u, "Edit Page Text", $page_id); ?>