Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {return;}
- if (empty($_POST['action'])) {return;}
- $result = '';
- switch ($_POST['action']) {
- case 'read':
- $sql = 'SELECT * FROM `items` WHERE status=1 LIMIT 100';
- $query = $modx->query($sql);
- if ($query) {
- while ($i= $query->fetch(PDO::FETCH_ASSOC)) {
- $result .= $i['id'];
- }
- }
- break;
- case 'insert':
- $item_name = (int)$_POST['item_name'];
- $item_text=mysql_real_escape_string($_POST['item_text']);
- $status = 1;
- $sql ="insert into `items` (item_name,item_text,status) values ('".$item_name."','".$item_text."','".$status."')";
- $stmt = $modx->prepare($sql);
- $stmt->execute();
- $res = 'ok';
- break;
- }
- if (!empty($res)) {
- die($res);
- }
Add Comment
Please, Sign In to add comment