Example #1
0
if (!$gValidLogin) {
    $gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
}
// check if the call of the page was allowed by settings
if ($gPreferences['enable_chat_module'] != 1) {
    // message if the Chat is not allowed
    $gMessage->show($gL10n->get('SYS_MODULE_DISABLED'));
}
$postFunction = admFuncVariableIsValid($_POST, 'function', 'string');
$postMessage = admFuncVariableIsValid($_POST, 'message', 'string');
$postLines = admFuncVariableIsValid($_POST, 'state', 'number');
$log = array();
// open some additonal functions for messages
$modulemessages = new ModuleMessages();
// find ID of the admidio Chat
$msg_id = $modulemessages->msgGetChatId();
$sql = "SELECT MAX(msc_part_id) as max_id\n          FROM " . TBL_MESSAGES_CONTENT . "\n          where msc_msg_id = '" . $msg_id . "'";
$statement = $gDb->query($sql);
$row = $statement->fetch();
$MsgId = $row['max_id'];
if (!$MsgId) {
    $MsgId = 0;
}
switch ($postFunction) {
    case 'update':
        if ($MsgId + 25 < $postLines) {
            $postLines = $postLines - 50;
        }
        if ($postLines >= 100) {
            $log['test'] = '100';
            $sql = "DELETE FROM " . TBL_MESSAGES_CONTENT . " WHERE msc_msg_id = '" . $msg_id . "' and msc_part_id <= 50";