* Mambo is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 of the License. */ /** ensure this file is being included by a parent file */ defined('_VALID_MOS') or die('Direct Access to this location is not allowed.'); require_once $mainframe->getPath('admin_html'); require_once $mainframe->getPath('class'); $task = trim(mosGetParam($_REQUEST, 'task', null)); $cid = mosGetParam($_REQUEST, 'cid', array(0)); if (!is_array($cid)) { $cid = array(0); } switch ($task) { case "view": viewMessage($cid[0], $option); break; case "new": newMessage($option, NULL, NULL); break; case "reply": newMessage($option, mosGetParam($_REQUEST, 'userid', 0), mosGetParam($_REQUEST, 'subject', '')); break; case "save": saveMessage($option); break; case "remove": removeMessage($cid, $option); break; case "config": editConfig($option);
<?php include 'dbconnect.php'; viewMessage(); function viewMessage() { if (isset($_GET['location_id'])) { $location_id = $_GET['location_id']; $db = connectToDB(); /* query the list of messages*/ $query = "SELECT comment from message where message.location_id = {$location_id} ORDER BY time ASC"; // $query = "SELECT comment,image from message join drawing where message.location_id = $location_id GROUP BY comment // ORDER BY message.time ASC"; $result = performQuery($db, $query); /* create array of messages */ $messages = array(); while ($message = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $messages[] = $message; } header('Content-type: application/json'); echo json_encode(array('messages' => $messages)); } }