/** * Posts a message to the group with the current list. */ function listNames() { global $DIR; $meal = date("G") < 12 ? "Lunch" : "Dinner"; $message = $meal . " saveplates for " . date("l, jS \\of F") . ":\n\n"; $message = $message . file_get_contents($DIR . "list"); postMessage($message); }
function cleanUp() { global $admin; $msgLifeSpan = $admin['msgLifeSpan']; $chatSessionLifeSpan = $admin['chatSessionLifeSpan']; $chatIDLifeSpan = $admin['chatIDLifeSpan']; $now = time(); if (!$msgLifeSpan || !$chatSessionLifeSpan || !$chatIDLifeSpan) { echo 'Nope, something missing: ' . $msgLifeSpan . ', ' . $chatSessionLifeSpan . ', ' . $chatIDLifeSpan . '<br />'; } else { /* Clean up messages */ if ($dir = @opendir(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/msgs/')) { while (($file = readdir($dir)) !== false) { if (substr($file, -strlen('.message')) == '.message') { $info = @stat(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/msgs/' . $file); if ($now - $info['mtime'] > $msgLifeSpan) { unlink(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/msgs/' . $file); } } } } /* Clean up inactive users (doesn't delete the users, just logs them out) */ if ($dir = @opendir(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/users/')) { while (($file = readdir($dir)) !== false) { if (substr($file, -strlen('.prefs')) == '.prefs') { $chatName = substr($file, 0, -strlen('.prefs')); $la = getLastAccessed($chatName); if ($now - $la > $chatSessionLifeSpan && $la > 0) { postMessage('system', 'User ' . $chatName . ' has been logged out due to inactivity.', $topMsgNum, $bottomMsgNum); resetLastAccessed($chatName); } } } } } }
+-------------------------------------------------------------+ */ error_reporting(-1); // an ordinary if having 2 actions on TRUE and none on FALSE function processTransaction() { echo "Inside processTransaction\n"; } function postMessage() { echo "Inside postMessage\n"; } $count = 5; if ($count > 0) { processTransaction(); postMessage(); } // despite the indenting that suggests the true path has 2 statements, in the // absence of braces, the true path is the first statement only. The second statement // is always executed. if (0) { echo "Line 1\n"; } echo "Line 2\n"; // always executed // use if with all scalar types + array $colors = array("red", "white", "blue"); $scalarValueList = array(10, -100, 0, 1.234, 0.0, TRUE, FALSE, NULL, 'xx', "", $colors); foreach ($scalarValueList as $e) { if ($e) { echo ">{$e}< is TRUE\t";
/* Inclusive Design Institute */ /* http://atutor.ca */ /* */ /* This program 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. */ /****************************************************************/ define('AT_INCLUDE_PATH', '../../../include/'); require AT_INCLUDE_PATH . 'vitals.inc.php'; session_write_close(); //authenticate(USER_CLIENT, USER_ADMIN); require AT_INCLUDE_PATH . '../mods/_standard/chat/lib/chat.inc.php'; $myPrefs = getPrefs($_SESSION['login']); $topMsgNum = $bottomMsgNum = 0; howManyMessages($topMsgNum, $bottomMsgNum); postMessage(_AT('chat_system'), _AT('chat_logged_out', $_SESSION['login']), $topMsgNum, $bottomMsgNum); $myPrefs['lastAccessed'] = 0; writePrefs($myPrefs, $_SESSION['login']); Header('Location: index.php'); exit; //exit; require 'include/html/chat_header.inc.php'; ?> <table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr> <td align="left"><h4><?php echo $admin['chatName']; ?> : Logout</h4></td> </tr> </table>
<?php session_start(); require_once 'connection.php'; if ($_POST['action'] == 'message') { postMessage($connection, $_POST); } else { if ($_POST['action'] == 'comment') { postComment($connection, $_POST); } else { session_destroy(); header('Location: login.php'); } } function postMessage($connection, $post) { $_SESSION['message_errors'] = array(); if (empty($post['message'])) { header('Location: success.php'); } else { $message = mysqli_real_escape_string($connection, $post['message']); $query = "INSERT INTO messages (message, user_id, created_at, updated_at) VALUES ('{$message}', '{$_SESSION['user_id']}', NOW(), NOW())"; mysqli_query($connection, $query); header('Location: success.php'); } } function postComment($connection, $post) { $_SESSION['comment_errors'] = array(); if (empty($post['comment'])) { header('Location: success.php');
*/ $maxRows_rsView = 100; $pageNum_rsView = 0; if (isset($_GET['pageNum_rsView'])) { $pageNum_rsView = $_GET['pageNum_rsView']; } $startRow_rsView = $pageNum_rsView * $maxRows_rsView; $params = array($uid, $_SESSION['user']['id'], $_SESSION['user']['id'], $uid, $_GET['module_id']); $cacheTime = 30; $sql = "SELECT help_messages.*, gf.email, gf.gender, gf.name, gf.picture, gf.link , gt.email as to_email, gt.gender as to_gender, gt.name as to_name, gt.picture as to_picture, gt.link as to_link FROM help_messages LEFT JOIN google_auth as gf ON help_messages.uid = gf.uid LEFT JOIN google_auth as gt ON help_messages.to_uid = gt.uid WHERE 1 AND ((help_messages.uid = ? AND help_messages.to_uid = ?) OR (help_messages.uid = ? AND help_messages.to_uid = ?)) AND help_messages.module_id = ? AND help_messages.deleted = 0"; $sql .= sprintf(" AND help_messages.id = %s", $modelGeneral->qstr($colname_rsID)); $sql .= " ORDER BY message_date DESC"; $query_limit_rsView = sprintf("%s LIMIT %d, %d", $sql, $startRow_rsView, $maxRows_rsView); $details = $modelGeneral->fetchAll($query_limit_rsView, $params, $cacheTime); if (!empty($_POST['MM_Insert']) && $_POST['MM_Insert'] === 'formMessage' && !empty($uid)) { postMessage($approved); $cache = 0; $modelGeneral->clearCache($query_limit_rsView, $params); header("Location:" . $currentURL . "/auto/messages?uid=" . $uid . "&module_id=" . $colname_rsModule . "&id=" . $colname_rsID); exit; } //get points if (!empty($uid)) { $returnPoints = updatePoints($uid, $_SESSION['user']['id']); } //include(SITEDIR.'/libraries/addresses/nearby.php'); if (empty($users)) { throw new Exception('No messages available.'); } ?> <script language="javascript">
<?php include_once "procedures.php"; if (isActiveUser() && isset($_POST['submit'])) { if (postMessage($_POST['recevier'], $_POST['title'], $_POST['text'])) { echo "Сообщение успешно отправлено"; } else { echo "При отправке произошла ошибка"; } exit; } include "top.php"; ?> <div class="content container"> <script type="text/javascript"> function sendMessage() { text = CKEDITOR.instances.userMessage.getData(); $.post( 'userMessages.php', { 'recevier' : $("#recevier").val(), 'title' : $("#title").val(), 'text' : text, 'submit' : 'true' }, function (data) { showModalAlert(data); window.location.reload(); }
function shareAlreadyUploadedFile($id, $user) { $content = '{username|' . $user . '} {lang|' . "userUploadedFile" . '} {file|' . $id . '}.'; postMessage($content, 0); }
/* * This is the bot callback script. All messages from the group * post to this script. This script decides is the message is a * valid command, and does what's needed */ require_once 'name_lookup.php'; $data = json_decode(file_get_contents('php://input')); if ($data == null) { exit; } if ($data->sender_type == "bot" || $data->sender_type == "system") { exit; } $text = $data->text; if ($text == "meow" || $text == "Meow") { postMessage("stfu karma w***e"); exit; } preg_match('/snape,? ?(make a|add)? ?save ?plate for (.+)/i', $text, $matches); if ($matches != null) { addName($matches[count($matches) - 1]); exit; } preg_match('/snape,? ?(remove|cancel) ?save ?plate for (.+)/i', $text, $matches); if ($matches != null) { removeName($matches[count($matches) - 1]); exit; } preg_match('/(snape,?|!) ?(add|make)(\\s*)(save ?plate)?/i', $text, $matches); if ($matches != null) { $map = getNameMap();
$la = 0; } else { if ($now - $la < $admin['chatSessionLifeSpan']) { $colour = getChatIDColour($chatName, $myPrefs['colours']); if ($chatName == $_SESSION['login']) { echo '<li><a href="filterHistory.php?filterChatID=' . $chatName . '" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><span style="color:' . $colour . '">' . $chatName . '</span></a> (' . _AT('chat_you') . ')</li>'; } else { if ($chatName != '') { echo '<li><a href="filterHistory.php?filterChatID=' . $chatName . '" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><span style="color:' . $colour . '">' . $chatName . '</span></a></li>'; } } } else { resetLastAccessed($chatName); $topMsgNum = $bottomMsgNum = 0; howManyMessages($topMsgNum, $bottomMsgNum); postMessage(_AT('chat_system'), require AT_INCLUDE_PATH . '../mods/_standard/chat/lib/chat.inc.php', _AT('chat_user_logged_out', $chatName), $topMsgNum, $bottomMsgNum); } } } } closedir($dir); echo '</ul>'; echo '<table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr><td align="right"><a href="history.php" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . _AT('chat_full_history') . '</a> | <a href="options.php" target="options" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . _AT('chat_refresh_user_list') . '</a></td></tr></table>'; //if ($myPrefs['navigationAidFlag'] > 0) { echo '<br /><br />'; echo '<table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr><td align="left"><h4>' . _AT('chat_quick_keys') . '</h4></td></tr></table>'; echo '<ul><li>' . _AT('chat_altc') . '</li> <li>' . _AT('chat_post') . '</li> <li>' . _AT('chat_altr') . '</li>