* @author Dave Lawson * @author Esther Brunner */ global $ID; global $REV; global $ACT; if (chat_plugin::isChatID($ID) && file_exists(wikiFN($ID))) { session_write_close(); if ($ACT == 'show') { print "Redirecting..."; exit(); } } class chat_plugin { /** * @author Esther Brunner * @author Pavel Vitis */ function chatHtml() { global $ID; global $ACT; global $conf; global $lang; $dID = chat_plugin::addChatNS($ID); // check mode and existing page if (($ACT !== 'show' && $ACT !== 'export_xhtml') || !file_exists(wikiFN($ID))) { return ''; } // check for existing chat page if automatic is disabled. if (!$conf['chat']['automatic'] && !file_exists(wikiFN($dID))) return ''; // check for existing chat page. if (!file_exists(wikiFN($dID))) { if ($conf['chat']['automatic']) { // automatic mode - don't try to recreate a deleted discussion page. $revs = getRevisions($dID); if (count($revs) != 0) return ''; } else { // manual mode - don't create non-existing discussion pages. return ''; } } $html = ''; if (!$_REQUEST['nosound'] && $conf['chat']['audio-notify']) { $html .= "". "\n"; } else { } $html .= '
'; // $html .= '

'.$lang['chat_title'].'

'; if ($conf['chat']['recentfirst']) { $html .= chat_plugin::chatFormHtml($dID); $html .= chat_plugin::chatPageHtml($dID); } else { $html .= chat_plugin::chatPageHtml($dID); $html .= chat_plugin::chatFormHtml($dID); } $html .= '
'; return $html; } /** * Is specified page ID in a chat namespace? * * @author Dave Lawson */ function isChatID($ID) { global $conf; $dNS = $conf['chat']['namespace']; $pID = noNS($ID); return strpos($ID, "$dNS:$pID") !== false; } /** * Convert a chat page ID to a normal page ID. * * @author Dave Lawson */ function stripChatNS($ID) { global $conf; $dNS = $conf['chat']['namespace']; return str_replace("$dNS:", '', $ID); } /** * Convert a normal page ID to a chat page ID. * * @author Dave Lawson */ function addChatNS($ID) { global $conf; $dNS = $conf['chat']['namespace']; if (chat_plugin::isChatID($ID)) { return $ID; } $dID = getNS($ID); if ($dID !== '') { $dID .= ':'; } $dID .= $dNS.':'.noNS($ID); return $dID; } /** * Display existing comments if availaible * * @author Esther Brunner */ function chatPageHtml($dID) { global $ID; $html = ''; $dFN = wikiFN($dID); if (file_exists($dFN)) { $html .= ''; $html .= '
'; $html .= 'Loading messages...'; // $html .= html_secedit(p_cached_xhtml($dFN), false); $html .= "
"; } return $html; } /** * @author Pavel Vitis */ function chatFormHtml($chatID) { global $DATE; global $INFO; global $USERINFO; global $PRE; global $SUF; global $SUM; global $lang; global $conf; global $auth; global $ID; global $commentId; $maxmsgsize = 1 * $conf['chat']['max-message-size']; if ($maxmsgsize <= 0) { $maxmsgsize = 256; } if ($masmsgsize > 2*1024) { $maxmsgsize = 2*1024; } if ($conf['useacl'] && $_SERVER['REMOTE_USER'] /*&& auth_quickaclcheck($dID) >= AUTH_EDIT*/) { $anonymous = false; } else { $anonymous = true; } // only if we are NOT in a comment page itself if (chat_plugin::isChatID($ID)) { $mainID = chat_plugin::stripChatNS($ID); echo '
'; echo '
'.html_wikilink($mainID,$lang['comments_back'].' '.$mainID).'
'; return true; } // guest comments must be allowed or you need to be logged in if (!$conf['chat']['allowguests'] && $_SERVER['REMOTE_USER'] == '') return ''; $refreshURL = wl(chat_plugin::stripChatNS($ID), 'rid='.time(), true).'#chat'; if ($anonymous) { $user = $_COOKIE['chatName']; if (empty($user)) { $user = "guest".date(time(),'hms'); } } else { $user = $INFO['userinfo']['name']; } $volume = (int)$_COOKIE['chatVolume']; if ($volume < 0) { $volume = 0; } if ($volume > 4) { $volume = 4; } //echo $_SERVER['REMOTE_USER']; $html = ''; $html .= '
'. '
'. ''; if ($conf['useacl'] && auth_quickaclcheck($chatID) >= AUTH_EDIT) { $html .= ($anonymous ? '' : '' ). ''; $html .= ''; } if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && auth_quickaclcheck($ID) >= AUTH_EDIT) { $html .= ''; } $html .= '
'; if (!$_REQUEST['nosound'] && $conf['chat']['audio-notify']) { $html .= '
'. '
'. ''. '
'. '
'; } else { $html .= "
"; } if ($conf['chat']['show-progress']) { $html .= '
'. ''. ''. ''. ''. ''. '
'; } $html .= '
'; return $html; } } //Setup VIM: ex: et ts=4 enc=utf-8 :