remove unmaintained chatbox / amazon_s3 exts

This commit is contained in:
Shish 2019-05-28 20:28:05 +01:00
parent 2396ae2ef9
commit 8a49b1e80e
43 changed files with 0 additions and 6733 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,79 +0,0 @@
<?php
/*
* Name: Amazon S3 Mirror
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Copy uploaded files to S3
* Documentation:
*/
require_once "ext/amazon_s3/lib/S3.php";
class UploadS3 extends Extension
{
public function onInitExt(InitExtEvent $event)
{
global $config;
$config->set_default_string("amazon_s3_access", "");
$config->set_default_string("amazon_s3_secret", "");
$config->set_default_string("amazon_s3_bucket", "");
}
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = new SetupBlock("Amazon S3");
$sb->add_text_option("amazon_s3_access", "Access key: ");
$sb->add_text_option("amazon_s3_secret", "<br>Secret key: ");
$sb->add_text_option("amazon_s3_bucket", "<br>Bucket: ");
$event->panel->add_block($sb);
}
public function onImageAddition(ImageAdditionEvent $event)
{
global $config;
$access = $config->get_string("amazon_s3_access");
$secret = $config->get_string("amazon_s3_secret");
$bucket = $config->get_string("amazon_s3_bucket");
if (!empty($bucket)) {
log_debug("amazon_s3", "Mirroring Image #".$event->image->id." to S3 #$bucket");
$s3 = new S3($access, $secret);
$s3->putBucket($bucket, S3::ACL_PUBLIC_READ);
$s3->putObjectFile(
warehouse_path("thumbs", $event->image->hash),
$bucket,
'thumbs/'.$event->image->hash,
S3::ACL_PUBLIC_READ,
[],
[
"Content-Type" => "image/jpeg",
"Content-Disposition" => "inline; filename=image-" . $event->image->id . ".jpg",
]
);
$s3->putObjectFile(
warehouse_path("images", $event->image->hash),
$bucket,
'images/'.$event->image->hash,
S3::ACL_PUBLIC_READ,
[],
[
"Content-Type" => $event->image->get_mime_type(),
"Content-Disposition" => "inline; filename=image-" . $event->image->id . "." . $event->image->ext,
]
);
}
}
public function onImageDeletion(ImageDeletionEvent $event)
{
global $config;
$access = $config->get_string("amazon_s3_access");
$secret = $config->get_string("amazon_s3_secret");
$bucket = $config->get_string("amazon_s3_bucket");
if (!empty($bucket)) {
log_debug("amazon_s3", "Deleting Image #".$event->image->id." from S3");
$s3 = new S3($access, $secret);
$s3->deleteObject($bucket, "images/" . $event->image->hash);
$s3->deleteObject($bucket, "thumbs/" . $event->image->hash);
}
}
}

View file

@ -1,486 +0,0 @@
<?php
error_reporting(E_ALL);
$kioskMode = false;
include '../php/filestorage.class.php';
include '../preferences.php';
include '../php/functions.php';
include '../php/yshout.class.php';
include '../php/ajaxcall.class.php';
if (isset($_POST['mode'])) {
switch ($_POST['mode']) {
case 'login':
doLogin();
break;
case 'logout':
doLogout();
break;
case 'unban':
doUnban();
break;
case 'unbanall':
doUnbanAll();
break;
case 'setpreference':
doSetPreference();
break;
case 'resetpreferences':
doResetPreferences();
break;
}
}
function doLogin()
{
global $kioskMode;
if ($kioskMode) {
logout();
$result = [
'error' => false,
'html' => cp()
];
echo json_encode($result);
return;
}
login(md5($_POST['password']));
$result = [];
if (loggedIn()) {
$result['error'] = false;
$result['html'] = cp();
} else {
$result['error'] = 'invalid';
}
echo json_encode($result);
}
function doLogout()
{
logout();
$result = [
'error' => false
];
echo json_encode($result);
}
function doUnban()
{
global $kioskMode;
if ($kioskMode) {
$result = [
'error' => false
];
echo json_encode($result);
return;
}
if (!loggedIn()) {
return;
}
$ys = ys();
$result = [];
$ip = $_POST['ip'];
if ($ys->banned($ip)) {
$ys->unban($ip);
$result['error'] = false;
} else {
$result['error'] = 'notbanned';
}
echo json_encode($result);
}
function doUnbanAll()
{
global $kioskMode;
if ($kioskMode) {
$result = [
'error' => false
];
echo json_encode($result);
return;
}
if (!loggedIn()) {
return;
}
$ys = ys();
$ys->unbanAll();
$result = [
'error' => false
];
echo json_encode($result);
}
function doSetPreference()
{
global $prefs, $kioskMode;
if ($kioskMode) {
$result = [
'error' => false
];
echo json_encode($result);
return;
}
if (!loggedIn()) {
return;
}
$pref = $_POST['preference'];
$value = magic($_POST['value']);
if ($value === 'true') {
$value = true;
}
if ($value === 'false') {
$value = false;
}
$prefs[$pref] = $value;
savePrefs($prefs);
if ($pref == 'password') {
login(md5($value));
}
$result = [
'error' => false
];
echo json_encode($result);
}
function doResetPreferences()
{
global $prefs, $kioskMode;
if ($kioskMode) {
$result = [
'error' => false
];
echo json_encode($result);
return;
}
if (!loggedIn()) {
return;
}
resetPrefs();
login(md5($prefs['password']));
// $prefs['password'] = 'lol no';
$result = [
'error' => false,
'prefs' => $prefs
];
echo json_encode($result);
}
/* CP Display */
function cp()
{
global $kioskMode;
if (!loggedIn() && !$kioskMode) {
return 'You\'re not logged in!';
}
return '
<div class="section" id="preferences">
<span style="display: none;" id="cp-loaded">true</span>
<div class="header">
<h1>YShout.Preferences</h1>
<a href="#" class="logout">Logout</a>
</div>
<ul class="subnav">
<li id="sn-administration"><a href="#">Administration</a></li>
<li id="sn-display"><a href="#">Display</a></li>
<li id="sn-resetall"><a href="#">Reset All</a></li>
<span class="sn-loading">Loading...</span>
</ul>
' . preferencesForm() . '
</div>
<div class="section" id="about">
<div class="header">
<h1>YShout.About</h1>
<a href="#" class="logout">Logout</a>
</div>
<ul class="subnav">
<li id="sn-about"><a href="#">About</a></li>
<li id="sn-contact"><a href="#">Contact</a></li>
<span class="sn-loading">Loading...</span>
</ul>
' . about() . '
</div>
<div class="section" id="bans">
<div class="header">
<h1>YShout.Bans</h1>
<a href="#" class="logout">Logout</a>
</div>
<ul class="subnav">
<li id="sn-unbanall"><a href="#">Unban All</a></li>
<span class="sn-loading">Loading...</span>
</ul>
' . bansList() . '
</div>';
}
function bansList()
{
global $kioskMode;
$ys = ys();
$bans = $ys->bans();
$html = '<ul id="bans-list">';
$hasBans = false;
foreach ($bans as $ban) {
$hasBans = true;
$html .= '
<li>
<span class="nickname">' . $ban['nickname']. '</span>
(<span class="ip">' . ($kioskMode ? '[No IP in Kiosk Mode]' : $ban['ip']) . '</span>)
<a title="Unban" class="unban-link" href="#" rel="' . $ban['timestamp'] . '">Unban</a>
</li>
';
}
if (!$hasBans) {
$html = '<p id="no-bans">No one is banned.</p>';
} else {
$html .= '</ul>';
}
return $html;
}
function preferencesForm()
{
global $prefs, $kioskMode;
return '
<form id="preferences-form">
<div id="cp-pane-administration" class="cp-pane">
<fieldset id="prefs-cat-cp">
<div class="legend">Control Panel</div class="legend">
<ol>
<li>
<label for="pref-password">Password</label>
<input rel="password" type="text" id="pref-password" value="' . ($kioskMode ? 'No password in Kiosk Mode.' : $prefs['password']) . '" />
</li>
</ol>
</fieldset>
<fieldset id="prefs-cat-flood">
<div class="legend">Flood Control</div class="legend">
<ol>
<li>
<label for="pref-flood">Use flood control</label>
<select rel="flood" id="pref-flood">
<option' . ($prefs['flood'] == true ? ' selected' : '') . ' rel="true">Yes</option>
<option' . ($prefs['flood'] == false ? ' selected' : '') . ' rel="false">No</option>
</select>
</li>
<li>
<label for="pref-flood-timeout">Flood timeout</label>
<input rel="floodTimeout" type="text" id="pref-flood-timeout" value="' . $prefs['floodTimeout'] . '" />
</li>
<li>
<label for="pref-flood-messages">Flood messages</label>
<input rel="floodMessages" type="text" id="pref-flood-messages" value="' . $prefs['floodMessages'] . '" />
</li>
<li>
<label for="pref-flood-length">Flood length</label>
<input rel="floodDisable" type="text" id="pref-flood-length" value="' . $prefs['floodDisable'] . '" />
</li>
<li>
<label for="pref-flood-autoban">Automatically ban after</label>
<select rel="autobanFlood" id="pref-flood-autoban">
<option' . ($prefs['autobanFlood'] == 1 ? ' selected' : '') . ' rel="1">One activation</option>
<option' . ($prefs['autobanFlood'] == 2 ? ' selected' : '') . ' rel="2">Two activations</option>
<option' . ($prefs['autobanFlood'] == 3 ? ' selected' : '') . ' rel="3">Three activations</option>
<option' . ($prefs['autobanFlood'] == 4 ? ' selected' : '') . ' rel="4">Four activations</option>
<option' . ($prefs['autobanFlood'] == 5 ? ' selected' : '') . ' rel="5">Five activations</option>
<option' . ($prefs['autobanFlood'] == 0 ? ' selected' : '') . ' rel="false">Never</option>
</select>
</li>
</ol>
</fieldset>
<fieldset id="prefs-cat-history">
<div class="legend">History</div class="legend">
<ol>
<li>
<label for="pref-max-logs">Max. amount of logs</label>
<input rel="logs" type="text" id="pref-max-logs" value="' . $prefs['logs'] . '" />
</li>
<li>
<label for="pref-history-shouts">Shouts to keep in history</label>
<input rel="history" type="text" id="pref-history-shouts" value="' . $prefs['history'] . '" />
</li>
</ol>
</fieldset>
<fieldset id="prefs-cat-misc">
<div class="legend">Miscellaneous</div class="legend">
<ol>
<li>
<label for="pref-refresh-rate">Refresh rate</label>
<input rel="refresh" type="text" id="pref-refresh-rate" value="' . $prefs['refresh'] . '" />
</li>
<li>
<label for="pref-censor-words">Censor words</label>
<input rel="censorWords" type="text" id="pref-censor-words" value="' . $prefs['censorWords'] . '" />
</li>
</ol>
</fieldset>
</div>
<div id="cp-pane-display" class="cp-pane">
<fieldset id="prefs-cat-form">
<div class="legend">Form</div class="legend">
<ol>
<li>
<label for="pref-form-position">Form position</label>
<select rel="inverse" id="pref-form-position">
<option' . ($prefs['inverse'] == true ? ' selected' : '') . ' rel="true">Top</option>
<option' . ($prefs['inverse'] == false ? ' selected' : '') . ' rel="false">Bottom</option>
</select>
</li>
<li>
<label for="pref-nickname-text">Default nickname text</label>
<input rel="defaultNickname" type="text" id="pref-nickname-text" value="' . $prefs['defaultNickname'] . '" />
</li>
<li>
<label for="pref-message-text">Default message text</label>
<input rel="defaultMessage" type="text" id="pref-message-text" value="' . $prefs['defaultMessage'] . '" />
</li>
<li>
<label for="pref-submit-text">Default submit text</label>
<input rel="defaultSubmit" type="text" id="pref-submit-text" value="' . $prefs['defaultSubmit'] . '" />
</li>
<li>
<label for="pref-nickname-length">Max. nickname length</label>
<input rel="nicknameLength" type="text" id="pref-nickname-length" value="' . $prefs['nicknameLength'] . '" />
</li>
<li>
<label for="pref-message-length">Max. message length</label>
<input rel="messageLength" type="text" id="pref-message-length" value="' . $prefs['messageLength'] . '" />
</li>
<li>
<label for="pref-show-submit">Show submit button</label>
<select rel="showSubmit" id="pref-show-submit">
<option' . ($prefs['showSubmit'] == true ? ' selected' : '') . ' rel="true">Yes</option>
<option' . ($prefs['showSubmit'] == false ? ' selected' : '') . ' rel="false">No</option>
</select>
</li>
<li>
<label for="pref-post-form-link">Show link</label>
<select rel="postFormLink" id="pref-post-form-link">
<option' . ($prefs['postFormLink'] == 'none' ? ' selected' : '') . ' rel="none">None</option>
<option' . ($prefs['postFormLink'] == 'history' ? ' selected' : '') . ' rel="history">History</option>
<option' . ($prefs['postFormLink'] == 'cp' ? ' selected' : '') . ' rel="cp">Control Panel</option>
</select>
</li>
</ol>
</fieldset>
<fieldset id="prefs-cat-shouts">
<div class="legend">Shouts</div class="legend">
<ol>
<li>
<label for="pref-timestamp-format">Timestamp format</label>
<select rel="timestamp" id="pref-timestamp-format">
<option' . ($prefs['timestamp'] == 12 ? ' selected' : '') . ' rel="12">12-hour</option>
<option' . ($prefs['timestamp'] == 24 ? ' selected' : '') . ' rel="24">24-hour</option>
<option' . ($prefs['timestamp'] == 0 ? ' selected' : '') . ' rel="false">No timestamps</option>
</select>
</li>
<li>
<label for="pref-truncate">Messages to show</label>
<input rel="truncate" type="text" id="pref-truncate" value="' . $prefs['truncate'] . '" />
</li>
<li>
<label for="pref-do-truncate">Truncate messages</label>
<select rel="doTruncate" id="pref-do-truncate">
<option' . ($prefs['doTruncate'] == true ? ' selected' : '') . ' rel="true">Yes</option>
<option' . ($prefs['doTruncate'] == false ? ' selected' : '') . ' rel="false">No</option>
</select>
</li>
<li>
<label for="pref-nickname-suffix">Nickname suffix</label>
<input rel="nicknameSeparator" type="text" id="pref-nickname-suffix" value="' . $prefs['nicknameSeparator'] . '" />
</li>
<li>
<label for="pref-info-view">Info view</label>
<select rel="info" id="pref-info-view">
<option' . ($prefs['info'] == 'inline' ? ' selected' : '') . ' rel="inline">Inline</option>
<option' . ($prefs['info'] == 'overlay' ? ' selected' : '') . ' rel="overlay">Overlay</option>
</select>
</li>
</ol>
</fieldset>
</div>
</form>
';
}
function about()
{
global $prefs;
$html = '
<div id="cp-pane-about" class="cp-pane">
<h2>About YShout</h2>
<p>YShout was created and developed by Yuri Vishnevsky. Version 5 is the first one with an about page, so you\'ll have to excuse the lack of appropriate information &mdash; I\'m not quite sure what it is that goes on "About" pages anyway.</p>
<p>Other than that obviously important tidbit of information, there\'s really nothing else that I can think of putting here... If anyone knows what a good and proper about page should contain, please contact me!
</div>
<div id="cp-pane-contact" class="cp-pane">
<h2>Contact Yuri</h2>
<p>If you have any questions or comments, you can contact me by email at <a href="mailto:yurivish@gmail.com">yurivish@gmail.com</a>, or on AIM at <a href="aim:goim?screnname=yurivish42">yurivish42</a>.</p>
<p>I hope you\'ve enjoyed using YShout!</p>
</div>
';
return $html;
}

View file

@ -1,386 +0,0 @@
* {
margin: 0;
padding: 0;
}
html, body {height: 100%;}
body {
background: #1a1a1a url(../images/bg.gif) center center no-repeat;
color: #a7a7a7;
font: 11px/1 Tahoma, Arial, sans-serif;
text-shadow: 0 0 0 #273541;
overflow: hidden;
}
a {
outline: none;
color: #fff;
text-decoration: none;
}
a:hover{
color: #fff;
}
input {
font-size: 11px;
background: #e5e5e5;
border: 1px solid #f5f5f5;
padding: 2px;
}
select {
font-size: 11px;
}
#cp {
height: 440px;
width: 620px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -220px;
margin-left: -310px;
}
#nav {
height: 65px;
width: 100%;
background: url(../images/bg-nav.gif) repeat-x;
position: absolute;
bottom: 0;
}
#nav ul {
display: none;
width: 240px;
height: 65px;
margin: 0 auto;
list-style: none;
}
#nav li {
width: 80px;
float: left;
text-align: center;
}
#nav a {
display: block;
height: 65px;
text-indent: -4200px;
outline: none;
}
#nav a:active {
background-position: 0 -65px;
}
#n-prefs a { background: 0 0 url("../images/n-prefs.gif") no-repeat; }
#n-bans a { background: 0 0 url("../images/n-bans.gif") no-repeat; }
#n-about a { background: 0 0 url("../images/n-about.gif") no-repeat; }
.subnav {
height: 25px;
background: url(../images/bg-subnav.gif) repeat-x;
list-style: none;
}
.subnav input {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.subnav li {
width: 85px;
float: left;
text-indent: -4200px;
}
.subnav a {
display: block;
height: 25px;
}
.subnav a:hover {
background-position: bottom left !important;
}
#sn-administration a { background: url(../images/sn-administration.gif) no-repeat; }
#sn-display a { background: url(../images/sn-display.gif) no-repeat; }
#sn-form a { background: url(../images/sn-form.gif) no-repeat; }
#sn-resetall a { background: url(../images/sn-resetall.gif) no-repeat; }
#sn-ban a { background: url(../images/sn-ban.gif) no-repeat; }
#sn-unbanall a { background: url(../images/sn-unbanall.gif) no-repeat; }
#sn-deleteall a { background: url(../images/sn-deleteall.gif) no-repeat; }
#sn-about a { background: url(../images/sn-about.gif) no-repeat; }
#sn-contact a { background: url(../images/sn-contact.gif) no-repeat; }
.sn-loading {
display: block;
height: 25px;
width: 25px;
float: right;
text-indent: -4200px;
background: url(../images/sn-spinny.gif) no-repeat;
_position: absolute;
_right: 20px;
_top: 50px;
}
@media { .sn-loading {
position: absolute;
right: 15px;
top: 41px;
}}
#content {
position: relative;
height: 375px;
overflow: hidden;
}
.header {
height: 33px;
padding-bottom: 2px;
border-bottom: 1px solid #444;
}
#login .header { border-bottom: 1px solid #4c657b; }
h1 {
float: left;
height: 32px;
width: 185px;
text-indent: -4200px;
}
#login h1 { background: url(../images/h-login.gif) no-repeat; }
#preferences h1 { background: url(../images/h-preferences.gif) no-repeat; }
#bans h1 { background: url(../images/h-bans.gif) no-repeat; }
#about h1 { background: url(../images/h-about.gif) no-repeat; }
.logout {
display: block;
height: 32px;
width: 45px;
float: right;
text-indent: -4200px;
background: url(../images/a-logout.gif) no-repeat;
}
.logout:hover {
background-position: bottom left;
}
.section {
clear: both;
width: 590px;
height: 355px;
padding: 15px;
padding-top: 5px;
position: absolute;
}
#login {
left: 0;
background: url(../images/bg-login.gif) repeat-x;
z-index: 5;
}
#login-form {
height: 45px;
width: 300px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -45px;
margin-left: -150px;
background: url(../images/bg-login-form.gif) no-repeat;
}
#login-form label {
display: none;
}
#login-form input {
position: absolute;
left: 127px;
top: 13px;
width: 153px;
z-index: 2;
border: 1px solid #d4e7fa;
background: #e7eef6;
}
#login-loading {
display: block;
position: absolute;
top: 12px;
right: 8px;
height: 25px;
width: 25px;
text-indent: -4200px;
background: url(../images/login-spinny.gif) no-repeat;
z-index: 1;
}
#preferences {
left: 0;
background: url(../images/bg-prefs.gif) repeat-x;
}
#preferences-form { }
#preferences-form fieldset {
margin-top: 10px;
width: 295px;
border: none;
}
#preferences-form fieldset.odd {
float: right;
}
#preferences-form fieldset.even {
float: left;
}
#preferences-form .legend {
display: block;
width: 265px;
color: #fff;
padding-bottom: 3px;
border-bottom: 1px solid #80a147;
}
/* IE7 */
@media {#preferences-form legend {
margin-left: -7px;
}}
#preferences-form ol {
list-style: none;
margin-top: 15px;
}
#preferences-form li {
width: 295px;
padding-bottom: 10px;
}
#preferences-form label {
display: block;
width: 130px;
float: left;
}
#preferences-form input {
width: 129px;
}
#preferences-form select {
width: 135px;
}
.cp-pane {
position: absolute;
width: 590px;
display: none;
}
#cp-pane-administration {
display: block;
}
#bans {
left: 0;
background: url(../images/bg-bans.gif) repeat-x;
line-height: 1.3;
}
#cp #bans-list a {
color: #d9d9d9;
border-bottom: 1px solid transparent;
_border-bottom: none;
}
#cp #bans-list a:hover {
color: #fff;
border-bottom: 1px solid #de4147;
}
#bans-list {
padding-top: 10px;
list-style: none;
height: 280px;
overflow: auto;
}
#bans-list li {
clear: both;
padding: 3px 5px;
}
#bans-list .nickname {
color: #fff;
font-size: 12px;
}
#bans-list .unban-link {
position: absolute;
right: 20px;
}
#no-bans {
margin-top: 100px;
text-align: center;
font-size: 22px;
color: #383838;
}
#about {
left: 0;
background: url(../images/bg-about.gif) repeat-x;
line-height: 1.6;
}
#about h2 {
color: #fff;
font: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
margin-bottom: 5px;
}
#about p {
margin-bottom: 5px;
}
#cp-pane-about {
margin-top: 10px;
display: block;
}
#cp-pane-contact {
margin-top: 10px;
}
#cp-pane-about a,
#cp-pane-contact a {
color: #d9d9d9;
padding-bottom: 2px;
}
#cp-pane-about a:hover,
#cp-pane-contact a:hover {
color: #fff;
border-bottom: 1px solid #f3982d;
}

View file

@ -1,45 +0,0 @@
<?php
include 'ajax.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>YShout: Admin CP</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="js/admincp.js"></script>
</head>
<body>
<div id="cp">
<div id="nav">
<ul>
<li id="n-prefs"><a href="#">Preferences</a></li>
<li id="n-bans"><a href="#">Bans</a></li>
<li id="n-about"><a href="#">About</a></li>
</ul>
</div>
<div id="content">
<div class="section" id="login">
<div class="header">
<h1>YShout.Preferences</h1>
</div>
<form id="login-form" action="index.php" method="post">
<label for="login-password">Password:</label>
<input type="password" id="login-password" name="loginPassword">
<span id="login-loading">Loading...</span>
</form>
</div>
<?php
if (loggedIn()) {
echo cp();
}
?>
</div>
</div>
</body>
</html>

View file

@ -1,388 +0,0 @@
/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
Array.prototype.inArray = function (value) {
for (var i = 0; i < this.length; i++) {
if (this[i] === value) {
return true;
}
}
return false;
};
var AdminCP = function() {
var self = this;
var args = arguments;
$(function(){
self.init.apply(self, args);
});
};
AdminCP.prototype = {
z: 5,
animSpeed: 'normal',
curSection: 'login',
curPrefPane: 'administration',
curAboutPane: 'about',
init: function(options) {
this.initializing = true;
this.loginForm();
this.initEvents();
if (this.loaded()) {
this.afterLogin();
} else {
$('#login-password')[0].focus();
}
this.initializing = false;
},
loginForm: function() {
$('#login-loading').fadeTo(1, 0);
},
initEvents: function() {
var self = this;
$('#login-form').submit(function() { self.login(); return false; });
$('#n-prefs').click(function() { self.show('preferences'); return false; });
$('#n-bans').click(function() { self.show('bans'); return false; });
$('#n-about').click(function() { self.show('about'); return false; });
},
afterLogin: function() {
var self = this;
// Login and logout
$('#login-password')[0].blur();
$('.logout').click(function() { self.logout(); return false; });
// Show the nav
if (this.initializing) {
$('#nav ul').css('display', 'block');
} else {
$('#nav ul').slideDown();
}
// Some css for betterlookingness
$('#preferences-form fieldset:odd').addClass('odd');
$('#preferences-form fieldset:even').addClass('even');
$('#bans-list li:odd').addClass('odd');
$('#bans-list li:even').addClass('even');
// Hide the loading thingie
$('.sn-loading').fadeTo(1, 0);
// Events after load
this.initEventsAfter();
// If they want to go directly to a section
var anchor = this.getAnchor();
if (anchor.length > 0 && ['preferences', 'bans', 'about'].inArray(anchor)) {
self.show(anchor);
} else {
self.show('preferences');
}
},
initEventsAfter: function() {
var self = this;
// Navigation
$('#sn-administration').click(function() { self.showPrefPane('administration'); return false; });
$('#sn-display').click(function() { self.showPrefPane('display'); return false; });
$('#sn-about').click(function() { self.showAboutPane('about'); return false; });
$('#sn-contact').click(function() { self.showAboutPane('contact'); return false; });
$('#sn-resetall').click(function() { self.resetPrefs(); return false; });
$('#sn-unbanall').click(function() { self.unbanAll(); return false; });
// Bans
$('.unban-link').click(function() {
self.unban($(this).parent().find('.ip').html(), $(this).parent());
return false;
});
// Preferences
$('#preferences-form input').keypress(function(e) {
var key = window.event ? e.keyCode : e.which;
if (key === 13 || key === 3) {
self.changePref.apply(self, [$(this).attr('rel'), this.value]);
return false;
}
}).focus(function() {
this.name = this.value;
}).blur(function() {
if (this.name !== this.value) {
self.changePref.apply(self, [$(this).attr('rel'), this.value]);
}
});
$('#preferences-form select').change(function() {
self.changePref.apply(self, [$(this).attr('rel'), $(this).find('option:selected').attr('rel')]);
});
},
changePref: function(pref, value) {
this.loading();
var pars = {
mode: 'setpreference',
preference: pref,
'value': value
};
this.ajax(function(json) {
if (!json.error) {
this.done();
} else {
alert(json.error);
}
}, pars);
},
resetPrefs: function() {
this.loading();
var pars = {
mode: 'resetpreferences'
};
this.ajax(function(json) {
this.done();
if (json.prefs) {
for (pref in json.prefs) {
var value = json.prefs[pref];
var el = $('#preferences-form input[@rel=' + pref + '], select[@rel=' + pref + ']')[0];
if (el.type === 'text') {
el.value = value;
} else {
if (value === true) { value = 'true'; }
if (value === false) { value = 'false'; }
$('#preferences-form select[@rel=' + pref + ']')
.find('option')
.removeAttr('selected')
.end()
.find('option[@rel=' + value + ']')
.attr('selected', 'yeah');
}
}
}
}, pars);
},
invalidPassword: function() {
// Shake the login form
$('#login-form')
.animate({ marginLeft: -145 }, 100)
.animate({ marginLeft: -155 }, 100)
.animate({ marginLeft: -145 }, 100)
.animate({ marginLeft: -155 }, 100)
.animate({ marginLeft: -150 }, 50);
$('#login-password').val('').focus();
},
login: function() {
if (this.loaded()) {
alert('Something _really_ weird has happened. Refresh and pretend nothing ever happened.');
return;
}
var self = this;
var pars = {
mode: 'login',
password: $('#login-password').val()
};
this.loginLoading();
this.ajax(function() {
this.ajax(function(json) {
self.loginDone();
if (json.error) {
self.invalidPassword();
return;
}
$('#content').append(json.html);
self.afterLogin.apply(self);
}, pars);
}, pars);
},
logout: function() {
var self = this;
var pars = {
mode: 'logout'
};
this.loading();
this.ajax(function() {
$('#login-password').val('');
$('#nav ul').slideUp();
self.show('login', function() {
$('#login-password')[0].focus();
$('.section').not('#login').remove();
self.done();
});
}, pars);
},
show: function(section, callback) {
// var sections = ['login', 'preferences', 'bans', 'about'];
// if (!sections.inArray(section)) section = 'preferences';
if ($.browser.msie) {
if (section === 'preferences') {
$('#preferences select').css('display', 'block');
} else {
$('#preferences select').css('display', 'none');
}
}
if (section === this.curSection) { return; }
this.curSection = section;
$('#' + section)[0].style.zIndex = ++this.z;
if (this.initializing) {
$('#' + section).css('display', 'block');
} else {
$('#' + section).fadeIn(this.animSpeed, callback);
}
},
showPrefPane: function(pane) {
var self = this;
if (pane === this.curPrefPane) { return; }
this.curPrefPane = pane;
$('#preferences .cp-pane').css('display', 'none');
$('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() {
if (self.curPrefPane === pane) {
$('#preferences .cp-pane').not('#cp-pane-' + pane).css('display', 'none');
} else {
$('#cp-pane-' + pane).css('display', 'none');
}
});
},
showAboutPane: function(pane) {
var self = this;
if (pane === this.curAboutPane) { return; }
this.curAboutPane = pane;
$('#about .cp-pane').css('display', 'none');
$('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() {
if (self.curAboutPane === pane) {
$('#about .cp-pane').not('#cp-pane-' + pane).css('display', 'none');
} else {
$('#cp-pane-' + pane).css('display', 'none');
}
});
},
ajax: function(callback, pars, html) {
var self = this;
$.post('ajax.php', pars, function(parse) {
// alert(parse);
if (parse) {
if (html) {
callback.apply(self, [parse]);
} else {
callback.apply(self, [self.json(parse)]);
}
} else {
callback.apply(self);
}
});
},
json: function(parse) {
var json = eval('(' + parse + ')');
return json;
},
loaded: function() {
return ($('#cp-loaded').length === 1);
},
loading: function() {
$('#' + this.curSection + ' .sn-loading').fadeTo(this.animSpeed, 1);
},
done: function() {
$('#' + this.curSection + ' .sn-loading').fadeTo(this.animSpeed, 0);
},
loginLoading: function() {
$('#login-password').animate({
width: 134
});
$('#login-loading').fadeTo(this.animSpeed, 1);
},
loginDone: function() {
$('#login-password').animate({
width: 157
});
$('#login-loading').fadeTo(this.animSpeed, 0);
},
getAnchor: function() {
var href = window.location.href;
if (href.indexOf('#') > -1 ) {
return href.substr(href.indexOf('#') + 1).toLowerCase();
}
return '';
},
unban: function(ip, el) {
var self = this;
this.loading();
var pars = {
mode: 'unban',
'ip': ip
};
this.ajax(function(json) {
if (!json.error) {
$(el).fadeOut(function() {
$(this).remove();
$('#bans-list li:odd').removeClass('even').addClass('odd');
$('#bans-list li:even').removeClass('odd').addClass('even');
}, this.animSpeed);
}
self.done();
}, pars);
},
unbanAll: function() {
this.loading();
var pars = {
mode: 'unbanall'
};
this.ajax(function(json) {
this.done();
$('#bans-list').fadeOut(this.animSpeed, function() {
$('#bans-list').children().remove();
$('#bans-list').fadeIn();
});
}, pars);
}
};
var cp = new AdminCP();

View file

@ -1,389 +0,0 @@
/*
YShout HTML Structure:
<div id="yshout">
<div id="ys-before-posts"></div>
<div id="ys-posts>
<div id="ys-post-1" class="ys-post ys-first [ys-admin-post] [ys-banned-post]">
<span class="ys-post-timestamp">12:56</span>
<span class="ys-post-nickname">Yurivish:<span>
<span class="ys-post-message">Hey!</span>
<span class="ys-post-info ys-info-[inline|overlay]">
<em>IP:</em> 127.0.0.1
<em>Posted:</em> Sunday Apr. 29, 2007 at 12:56.
</span>
<span class="ys-post-actions">
<a title="Show post information" class="ys-info-link" href="#">Info</a> |
<a title="Delete post" class="ys-delete-link" href="#">Delete</a> |
<a title="Ban Yurivish" class="ys-ban-link" href="#">Ban</a>
</span>
</div>
<div id="ys-post-2" class="ys-post [ys-admin-post] [ys-banned-post]">
<span class="ys-post-timestamp">12:57</span>
<span class="ys-post-nickname>Travis:<span>
<span class="ys-post-message>Hello.</span>
<span class="ys-post-info ys-info-[inline|overlay]">
<em>IP:</em> 127.0.0.2
<em>Posted:</em> Sunday Apr. 29, 2007 at 12:57.
</span>
<span class="ys-post-actions">
<a title="Show post information" class="ys-info-link" href="#">Info</a> |
<a title="Delete post" class="ys-delete-link" href="#">Delete</a> |
<a title="Ban Travis" class="ys-ban-link" href="#">Ban</a>
</span>
</div>
<div id="ys-post-3" class="ys-post ys-last [ys-admin-post] [ys-banned-post]">
<span class="ys-post-timestamp">12:57</span>
<span class="ys-post-nickname>Yurivish:<span>
<span class="ys-post-message>Yup...</span>
<span class="ys-post-info ys-info-[inline|overlay]">
<em>IP:</em> 127.0.0.1
<em>Posted:</em> Sunday Apr. 29, 2007 at 12:57.
</span>
<span class="ys-post-actions">
<a title="Show post information" class="ys-info-link" href="#">Info</a> |
<a title="Delete post" class="ys-delete-link" href="#">Delete</a> |
<a title="Ban Yurivish" class="ys-ban-link" href="#">Ban</a>
</span>
</div>
</div>
<div id="ys-after-posts"></div>
<div id="ys-before-post-form"></div>
<div id="ys-post-form">
<form id="ys-post-form>
<fieldset>
<input id="ys-input-nickname" value="Nickname" type="text" accesskey="N" maxlength="25" class="[ys-before-focus|ys-after-focus]" />
<input id="ys-input-message" value="Message Text" type="text" accesskey="M" maxlength="175" class="[ys-before-focus|ys-after-focus]" />
<input id="ys-input-submit" value="Shout!" accesskey="S" type="submit" />
<a title="[View YShout History|Open Admin CP]" class="ys-post-form-link" id="[ys-history-link|ys-cp-link]" href="[history/|cp/]">[View History|Admin CP]</a>
</fieldset>
</form>
</div>
<div id="ys-after-post-form"></div>
</div>
*/
#yshout * {
margin: 0;
padding: 0;
}
#yshout a {
text-decoration: none;
color: #989898;
}
#yshout a:hover {
color: #fff;
}
#yshout a:active {
color: #e5e5e5;
}
/* Adjust the width here
-------------------------- */
#yshout {
position: relative;
overflow: hidden;
font: 11px/1.4 Arial, Helvetica, sans-serif;
}
/* Posts
------------------------------------- */
#yshout #ys-posts {
position: relative;
background: #1a1a1a;
}
#yshout .ys-post {
border-bottom: 1px solid #212121;
margin: 0 5px;
padding: 5px;
position: relative;
overflow: hidden;
text-align: left;
}
#yshout .ys-admin-post .ys-post-nickname {
padding-left: 11px;
background: url(../images/star-dark.gif) 0 2px no-repeat;
}
#yshout .ys-post-timestamp {
color: #333;
}
#yshout .ys-post-nickname {
color: #e5e5e5;
}
#yshout .ys-post-message {
color: #595959;
}
/* Banned
------------------------------------- */
#yshout .ys-banned-post .ys-post-nickname,
#yshout .ys-banned-post .ys-post-message,
#yshout .ys-banned-post {
color: #b3b3b3 !important;
}
#yshout #ys-banned {
position: absolute;
z-index: 75;
height: 100%;
_height: 430px;
top: 0;
left: 0;
margin: 0 5px;
background: #1a1a1a;
}
#yshout #ys-banned span {
position: absolute;
display: block;
height: 20px;
margin-top: -10px;
top: 50%;
padding: 0 20px;
color: #666;
text-align: center;
font-size: 13px;
z-index: 80;
}
#yshout #ys-banned a {
color: #999;
}
#yshout #ys-banned a:hover {
color: #666;
}
/* Hover Controls
------------------------------------- */
#yshout .ys-post-actions {
display: none;
position: absolute;
top: 0;
right: 0;
padding: 5px;
font-size: 11px;
z-index: 50;
background: #1a1a1a;
color: #666;
}
#yshout .ys-post-actions a {
color: #989898;
}
#yshout .ys-post-actions a:hover {
color: #fff;
}
#yshout .ys-post:hover .ys-post-actions {
display: block;
}
#yshout .ys-post-info {
color: #595959;
}
#yshout .ys-post-info em {
font-style: normal;
color: #1a1a1a;
}
#yshout .ys-info-overlay {
display: none;
position: absolute;
z-index: 45;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #1a1a1a;
padding: 5px;
}
#yshout .ys-info-inline {
display: none;
margin-top: 2px;
padding-top: 3px;
border-top: 1px solid #f2f2f2;
}
/* Post Form
------------------------------------- */
#yshout #ys-post-form {
height: 40px;
line-height: 40px;
background: #262626;
text-align: left;
}
#yshout #ys-input-nickname,
#yshout #ys-input-message {
font-size: 11px;
padding: 2px;
background: #333;
border: 1px solid #404040;
}
#yshout #ys-post-form fieldset {
_position: absolute;
border: none;
padding: 0 10px;
_margin-top: 10px;
}
#yshout #ys-input-nickname {
width: 105px;
margin-left: 5px;
}
#yshout #ys-input-message {
margin-left: 5px;
width: 400px;
}
#yshout #ys-input-submit {
font-size: 11px;
width: 64px;
margin-left: 5px;
}
#yshout #ys-input-submit:hover {
cursor: pointer;
}
#yshout .ys-before-focus {
color: #4d4d4d;
}
#yshout .ys-after-focus {
color: #e5e5e5;
}
#yshout .ys-input-invalid {
}
#yshout .ys-post-form-link {
margin-left: 5px;
}
/* Overlays - This should go in all YShout styles
------------------------------------- */
#ys-overlay {
position: fixed;
_position: absolute;
z-index: 100;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #000;
filter: alpha(opacity=60);
-moz-opacity: 0.6;
opacity: 0.6;
}
* html body {
height: 100%;
width: 100%;
}
#ys-closeoverlay-link,
#ys-switchoverlay-link {
display: block;
font-weight: bold;
height: 13px;
font: 11px/1 Arial, Helvetica, sans-serif;
color: #fff;
text-decoration: none;
margin-bottom: 1px;
outline: none;
float: left;
}
#ys-switchoverlay-link {
float: right;
}
.ys-window {
z-index: 102;
position: fixed;
_position: absolute;
top: 50%;
left: 50%;
}
#ys-cp {
margin-top: -220px;
margin-left: -310px;
width: 620px;
}
#ys-yshout {
margin-top: -250px;
margin-left: -255px;
width: 500px;
}
#ys-history {
margin-top: -220px;
margin-left: -270px;
width: 540px;
}
#yshout .ys-browser {
border: none !important;
outline: none !important;
z-index: 102;
overflow: auto;
background: transparent !important;
}
#yshout-browser {
height: 580px;
width: 510px;
}
#cp-browser {
height: 440px;
width: 620px;
_height: 450px;
_width: 440px;
}
#history-browser {
height: 440px;
width: 540px;
border-top: 1px solid #545454;
border-left: 1px solid #545454;
border-bottom: 1px solid #444;
border-right: 1px solid #444;
}

View file

@ -1,93 +0,0 @@
/* Overlays - Use this stylesheet if you want to only use yLink.
------------------------------------- */
#ys-overlay {
position: fixed;
_position: absolute;
z-index: 100;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #000;
filter: alpha(opacity=60);
-moz-opacity: 0.6;
opacity: 0.6;
}
* html body {
height: 100%;
width: 100%;
}
#ys-closeoverlay-link,
#ys-switchoverlay-link {
display: block;
font-weight: bold;
height: 13px;
font: 11px/1 Arial, Helvetica, sans-serif;
color: #fff;
text-decoration: none;
margin-bottom: 1px;
outline: none;
float: left;
}
#ys-switchoverlay-link {
float: right;
}
.ys-window {
z-index: 102;
position: fixed;
_position: absolute;
top: 50%;
left: 50%;
}
#ys-cp {
margin-top: -220px;
margin-left: -310px;
width: 620px;
}
#ys-yshout {
margin-top: -250px;
margin-left: -255px;
width: 500px;
}
#ys-history {
margin-top: -220px;
margin-left: -270px;
width: 540px;
}
#yshout .ys-browser {
border: none !important;
outline: none !important;
z-index: 102;
overflow: auto;
background: transparent !important;
}
#yshout-browser {
height: 580px;
width: 510px;
}
#cp-browser {
height: 440px;
width: 620px;
_height: 450px;
_width: 440px;
}
#history-browser {
height: 440px;
width: 540px;
border-top: 1px solid #545454;
border-left: 1px solid #545454;
border-bottom: 1px solid #444;
border-right: 1px solid #444;
}

View file

@ -1,113 +0,0 @@
* {
margin: 0;
padding: 0;
}
body {
background: #182635 url(../images/bg.gif) fixed repeat-x;
font: 11px/1.6 Arial, Helvetica, sans-serif;
color: #92b5ce;
}
a {
color: #d5edff;
text-decoration: none;
}
a:hover {
color: #fff !important;
text-decoration: underline;
}
h2 {
font-weight: normal;
color: #fff;
font-size: 14px;
margin-bottom: 5px;
margin-top:10px;
}
p {
margin-bottom: 5px;
}
pre {
padding: 3px;
margin-top: 5px;
margin-bottom: 10px;
background: url(../images/bg-code.png);
_background: none;
color: #b4d4eb;
}
code {
color: #fff;
}
pre code {
padding: 0;
color: #b4d4eb;
}
ul {
list-style: none;
}
li {
margin-bottom: 5px;
}
em {
font-weight: normal;
font-style: normal;
color: #fff;
}
#container {
width: 510px;
margin: 0 auto;
}
#top {
width: 510px;
margin-top: 25px;
height: 20px;
border-bottom: 1px solid #567083;
font-size: 11px;
overflow: hidden;
}
h1 {
text-indent: -4200px;
height: 13px;
width: 120px;
background: url(../images/h-welcome.gif) no-repeat;
float: left;
}
#nav {
color: #93b3ca;
float: right;
line-height: 1.6;
}
#footer {
width: 510px;
margin: 20px auto 10px auto;
padding-top: 5px;
border-top: 1px solid #273e56;
color: #384858;
}
#footer:hover {
color: #92b5ce;
}
#footer:hover a {
color: #fff;
}
#footer a {
color: #425d7a;
}

View file

@ -1,85 +0,0 @@
* {
margin: 0;
padding: 0;
}
body {
background: #202020 url(../images/bg.gif) fixed repeat-x;
color: #5c5c5c;
font: 11px/1.6 Arial, Helvetica, sans-serif;
}
#top {
height: 25px;
width: 510px;
margin: 0 auto;
margin-top: 20px;
border-bottom: 1px solid #444;
overflow: none;
line-height: 1.0;
}
h1 {
text-indent: -4200px;
background: url(../images/h-history.gif) no-repeat;
width: 105px;
height: 17px;
margin-top: 5px;
float: left;
overflow: none;
_position: absolute;
}
#top a, #bottom a {
color: #7d7d7d;
text-decoration: none;
}
#top a {
line-height: 25px;
}
#top a:hover, #bottom a:hover {
color: #fff;
border-bottom-color: #5e5e5e;
}
#log {
font-size: 11px;
margin-left: 10px;
border: 1px solid #767676;
border-right: none;
width: 60px;
}
#controls {
float: right;
}
#yshout {
margin: 0 auto;
margin-top: 10px;
}
#bottom {
width:510px;
margin: 10px auto;
}
#bottom #to-top {
margin-left: 5px;
}
/* Inane IE Compatibility PNG fixes
------------------------------------- */
#yshout #ys-before-posts { _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src='../example/images/ys-bg-posts-top.png',sizingMethod='crop'); }
#yshout #ys-posts { _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src='../example/images/bg-posts.png',sizingMethod='scale'); }
#yshout #ys-after-posts { _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src='../example/images/ys-bg-posts-bottom.png',sizingMethod='crop'); }
#yshout #ys-banned { _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src='../example/images/bg-banned.png',sizingMethod='scale'); }
#yshout #ys-post-form { _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src='../example/images/bg-form.png',sizingMethod='crop'); }
#yshout .ys-post { _height: 1%; }

View file

@ -1,142 +0,0 @@
<?php
error_reporting(E_ALL);
include '../php/filestorage.class.php';
include '../preferences.php';
include '../php/functions.php';
include '../php/yshout.class.php';
$html = '<div id="history-posts">';
$admin = loggedIn();
$log = 1;
if (isset($_GET['log'])) {
$log = $_GET['log'];
}
if (isset($_POST['log'])) {
$log = $_POST['log'];
}
if (filter_var($log, FILTER_VALIDATE_INT) === false) {
$log = 1;
}
$ys = ys($log);
$posts = $ys->posts();
if (sizeof($posts) === 0) {
$html .= '
<div id="ys-post-1" class="ys-post ys-first ys-admin-post">
<span class="ys-post-timestamp">13:37</span>
<span class="ys-post-nickname">Yurivish:<span>
<span class="ys-post-message">Hey, there aren\'t any posts in this log.</span>
</div>
';
}
$id = 0;
foreach ($posts as $post) {
$id++;
$banned = $ys->banned($post['adminInfo']['ip']);
$html .= '<div ' . ($admin ? 'rel="' . $post['adminInfo']['ip'] . '" ' : '') . 'id="ys-post-' . $id . '" class="ys-post' . ($post['admin'] ? ' ys-admin-post' : '') . ($banned ? ' ys-banned-post' : '') . '">' . "\n";
$ts = '';
switch ($prefs['timestamp']) {
case 12:
$ts = date('h:i', $post['timestamp']);
break;
case 24:
$ts = date('H:i', $post['timestamp']);
break;
case 0:
$ts = '';
break;
}
$html .= ' <span class="ys-post-timestamp">' . $ts . '</span> ' . "\n";
$html .= ' <span class="ys-post-nickname">' . $post['nickname'] . '</span>' . $prefs['nicknameSeparator'] . ' ' . "\n";
$html .= ' <span class="ys-post-message">' . $post['message'] . '</span>' . "\n";
$html .= ' <span class="ys-post-info' . ($prefs['info'] == 'overlay' ? ' ys-info-overlay' : ' ys-info-inline') . '">' . ($admin ? '<em>IP:</em> ' . $post['adminInfo']['ip'] . ', ' : '') . '<em>Posted:</em> ' . date('l M. j, Y \a\t ' . ($prefs['timestamp'] > 12 ? 'G:i' : 'g:i')) .'.</span>' . "\n";
$html .= ' <span class="ys-post-actions">' . "\n";
$html .= ' <a title="Show post information" class="ys-info-link" href="#">Info</a>' . ($admin ? ' | <a title="Delete post" class="ys-delete-link" href="#">Delete</a> | ' . ($banned ? '<a title="Unban ' . $post['nickname'] . '" class="ys-ban-link" href="#">Unban</a>' : '<a title="Ban ' . $post['nickname'] . '" class="ys-ban-link" href="#">Ban</a>') : '') . "\n";
$html .= ' </span>' . "\n";
if ($admin) {
$html .= '<div class="ys-history" style="display: none;">';
$html .= ' <span class="ys-h-ip">' . $post['adminInfo']['ip'] . '</span>';
$html .= ' <span class="ys-h-nickname">' . $post['nickname'] . '</span>';
$html .= ' <span class="ys-h-uid">' . $post['uid'] . '</span>';
$html .= '</div>';
}
$html .= '</div>' . "\n";
}
$html .= '</div>' . "\n";
if (isset($_POST['p'])) {
echo $html;
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>YShout: History</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="js/history.js"></script>
<link rel="stylesheet" href="../example/css/example.yshout.css" />
<link rel="stylesheet" href="css/style.css" />
<script type="text/javascript">
new History({
prefsInfo: '<?= $prefs['info'] ?>',
log: <?= $log ?>
});
</script>
</head>
<body>
<div id="top">
<h1>YShout.History</h1>
<div id="controls">
<?php if ($admin) : ?>
<a id="clear-log" href="#">Clear this log</a>, or
<a id="clear-logs" href="#">Clear all logs</a>.
<?php endif; ?>
<select id="log">
<?php
for ($i = 1; $i <= $prefs['logs']; $i++) {
echo '<option' . ($log == $i ? ' selected' : '') . ' rel="' . $i . '">Log ' . $i . '</option>' . "\n";
}
?>
</select>
</div>
</div>
<div id="yshout">
<div id="ys-before-posts"></div>
<div id="ys-posts">
<?= $html ?>
</div>
<div id="ys-after-posts"></div>
</div>
<div id="bottom">
<a id="to-top" href="#top">Back to top</a>
</div>
</body>
</html>

View file

@ -1,276 +0,0 @@
/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
var History = function() {
var self = this;
var args = arguments;
$(function(){
self.init.apply(self, args);
});
};
History.prototype = {
animSpeed: 'normal',
noPosts: '<div id="ys-post-1" class="ys-post ys-first ys-admin-post">\n<span class="ys-post-timestamp">13:37</span>\n<span class="ys-post-nickname">Yurivish:<span>\n<span class="ys-post-message">Hey, there aren\'t any posts in this log.</span>\n</div>',
init: function(options) {
this.prefsInfo = options.prefsInfo;
this.log = options.log;
this.initEvents();
$('body').ScrollToAnchors({ duration: 800 });
},
initEvents: function() {
var self = this;
this.initLogEvents();
// Select log
$('#log').change(function() {
var logIndex = $(this).find('option[@selected]').attr('rel');
var pars = {
p: 'yes',
log: logIndex
};
self.ajax(function(html) {
$('#ys-posts').html(html);
$('#yshout').fadeIn();
self.initLogEvents();
}, pars, true, 'index.php');
});
// Clear the log
$('#clear-log').click(function() {
var el = this;
var pars = {
reqType: 'clearlog'
};
self.ajax(function(json) {
if (json.error) {
switch(json.error) {
case 'admin':
self.error('You\'re not an admin. Log in through the admin CP to clear the log.');
el.innerHTML = 'Clear this log';
return;
}
}
$('#ys-posts').html(self.noPosts);
self.initLogEvents();
el.innerHTML = 'Clear this log';
}, pars);
this.innerHTML = 'Clearing...';
return false;
});
// Clear all logs
$('#clear-logs').click(function() {
var el = this;
var pars = {
reqType: 'clearlogs'
};
self.ajax(function(json) {
if (json.error) {
switch(json.error) {
case 'admin':
el.innerHTML = 'Clear all logs';
self.error('You\'re not an admin. Log in through the admin CP to clear logs.');
return;
}
}
$('#ys-posts').html(self.noPosts);
self.initLogEvents();
el.innerHTML = 'Clear all logs';
}, pars);
this.innerHTML = 'Clearing...';
return false;
});
},
initLogEvents: function() {
var self = this;
$('#yshout .ys-post')
.find('.ys-info-link').toggle(
function() { self.showInfo.apply(self, [$(this).parent().parent()[0].id, this]); return false; },
function() { self.hideInfo.apply(self, [$(this).parent().parent()[0].id, this]); return false; })
.end()
.find('.ys-ban-link').click(
function() { self.ban.apply(self, [$(this).parent().parent()[0]]); return false; })
.end()
.find('.ys-delete-link').click(
function() { self.del.apply(self, [$(this).parent().parent()[0]]); return false; });
},
showInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info');
if (jEl.length === 0) { return false; }
if (this.prefsInfo === 'overlay') {
jEl.css('display', 'block').fadeIn(this.animSpeed);
} else {
jEl.slideDown(this.animSpeed);
}
el.innerHTML ='Close Info';
return false;
},
hideInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info');
if (jEl.length === 0) { return false; }
if (this.prefsInfo === 'overlay') {
jEl.fadeOut(this.animSpeed);
} else {
jEl.slideUp(this.animSpeed);
}
el.innerHTML = 'Info';
return false;
},
ban: function(post) {
var self = this;
var link = $('#' + post.id).find('.ys-ban-link')[0];
switch(link.innerHTML)
{
case 'Ban':
var pIP = $(post).find('.ys-h-ip').html();
var pNickname = $(post).find('.ys-h-nickname').html();
var pars = {
log: self.log,
reqType: 'ban',
ip: pIP,
nickname: pNickname
};
this.ajax(function(json) {
if (json.error) {
switch (json.error) {
case 'admin':
self.error('You\'re not an admin. Log in through the admin CP to ban people.');
break;
}
return;
}
$('#yshout .ys-post[@rel="' + pars.ip + '"]')
.addClass('ys-banned-post')
.find('.ys-ban-link')
.html('Unban');
}, pars);
link.innerHTML = 'Banning...';
return false;
case 'Banning...':
return false;
case 'Unban':
var pIP = $(post).find('.ys-h-ip').html();
var pars = {
reqType: 'unban',
ip: pIP
};
this.ajax(function(json) {
if (json.error) {
switch(json.error) {
case 'admin':
self.error('You\'re not an admin. Log in through the admin CP to unban people.');
return;
}
}
$('#yshout .ys-post[@rel="' + pars.ip + '"]')
.removeClass('ys-banned-post')
.find('.ys-ban-link')
.html('Ban');
}, pars);
link.innerHTML = 'Unbanning...';
return false;
case 'Unbanning...':
return false;
}
},
del: function(post) {
var self = this;
var link = $('#' + post.id).find('.ys-delete-link')[0];
if (link.innerHTML === 'Deleting...') { return; }
var pUID = $(post).find('.ys-h-uid').html();
var pars = {
reqType: 'delete',
uid: pUID
};
self.ajax(function(json) {
if (json.error) {
switch(json.error) {
case 'admin':
self.error('You\'re not an admin. Log in through the admin CP to ban people.');
return;
}
}
$(post).slideUp(self.animSpeed);
}, pars);
link.innerHTML = 'Deleting...';
return false;
},
json: function(parse) {
var json = eval('(' + parse + ')');
return json;
},
ajax: function(callback, pars, html, page) {
pars = jQuery.extend({
reqFor: 'history',
log: this.log
}, pars);
var self = this;
if (page === null) { page = '../yshout.php'; }
$.post(page, pars, function(parse) {
if (parse) {
if (html) {
callback.apply(self, [parse]);
} else {
callback.apply(self, [self.json(parse)]);
}
} else {
callback.apply(self);
}
});
},
error: function(err) {
alert(err);
}
};

View file

@ -1,7 +0,0 @@
<?php
$null = null;
include 'php/filestorage.class.php';
include 'preferences.php';
include 'php/functions.php';
include 'php/yshout.class.php';
include 'php/ajaxcall.class.php';

View file

@ -1,810 +0,0 @@
/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
String.prototype.sReplace = function(find, replace) {
return this.split(find).join(replace);
};
String.prototype.repeat = function(times) {
var rep = new Array(times + 1);
return rep.join(this);
};
var YShout = function() {
var self = this;
var args = arguments;
$(document).ready(function() {
self.init.apply(self, args);
});
};
var yShout;
YShout.prototype = {
animSpeed: 300,
p: [],
init: function(options) {
yShout = this;
var self = this;
this.initializing = true;
var dOptions = {
yPath: 'yshout/',
log: 1
};
this.options = jQuery.extend(dOptions, options);
this.postNum = 0;
this.floodAttempt = 0;
// Correct for missing trailing /
if ((this.options.yPath.length > 0) && (this.options.yPath.charAt(this.options.yPath.length - 1) !== '/')) {
this.options.yPath += '/';
}
if (this.options.yLink) {
if (this.options.yLink.charAt(0) !== '#') {
this.options.yLink = '#' + this.options.yLink;
}
$(this.options.yLink).click(function() {
self.openYShout.apply(self);
return false;
});
}
// Load YShout from a link, in-page
if (this.options.h_loadlink) {
$(this.options.h_loadlink).click(function() {
$('#yshout').css('display', 'block');
$(this).unbind('click').click(function() { return false; });
return false;
});
this.load(true);
} else {
this.load();
}
},
load: function(hidden) {
if ($('#yshout').length === 0) { return; }
if (hidden) { $('#yshout').css('display', 'none'); }
this.ajax(this.initialLoad, {
reqType: 'init',
yPath: this.options.yPath,
log: this.options.log
});
},
initialLoad: function(updates) {
if (updates.yError) {
alert('There appears to be a problem: \n' + updates.yError + '\n\nIf you haven\'t already, try chmodding everything inside the YShout directory to 777.');
}
var self = this;
this.prefs = jQuery.extend(updates.prefs, this.options.prefs);
this.initForm();
this.initRefresh();
this.initLinks();
if (this.prefs.flood) { this.initFlood(); }
if (updates.nickname) {
$('#ys-input-nickname')
.removeClass('ys-before-focus')
.addClass( 'ys-after-focus')
.val(updates.nickname);
}
if (updates) {
this.updates(updates);
}
if (!this.prefs.doTruncate) {
$('#ys-posts').css('height', $('#ys-posts').height + 'px');
}
if (!this.prefs.inverse) {
var postsDiv = $('#ys-posts')[0];
postsDiv.scrollTop = postsDiv.scrollHeight;
}
this.markEnds();
this.initializing = false;
},
initForm: function() {
this.d('In initForm');
var postForm =
'<form id="ys-post-form"' + (this.prefs.inverse ? 'class="ys-inverse"' : '' ) + '><fieldset>' +
'<input id="ys-input-nickname" value="' + nickname + '" type="hidden" accesskey="N" maxlength="' + this.prefs.nicknameLength + '" class="ys-before-focus" />' +
'<input id="ys-input-message" value="' + this.prefs.defaultMessage + '" type="text" accesskey="M" maxlength="' + this.prefs.messageLength + '" class="ys-before-focus" />' +
(this.prefs.showSubmit ? '<input id="ys-input-submit" value="' + this.prefs.defaultSubmit + '" accesskey="S" type="submit" />' : '') +
(this.prefs.postFormLink === 'cp' ? '<a title="View YShout Control Panel" class="ys-post-form-link" id="ys-cp-link" href="' + this.options.yPath + 'cp/index.php">Admin CP</a>' : '') +
(this.prefs.postFormLink === 'history' ? '<a title="View YShout History" class="ys-post-form-link" id="ys-history-link" href="' + this.options.yPath + 'history/index.php?log=' + this.options.log + '">View History</a>' : '') +
'</fieldset></form>';
var postsDiv = '<div id="ys-posts"></div>';
if (this.prefs.inverse) { $('#yshout').html(postForm + postsDiv); }
else { $('#yshout').html(postsDiv + postForm); }
$('#ys-posts')
.before('<div id="ys-before-posts"></div>')
.after('<div id="ys-after-posts"></div>');
$('#ys-post-form')
.before('<div id="ys-before-post-form"></div>')
.after('<div id="ys-after-post-form"></div>');
var self = this;
var defaults = {
'ys-input-nickname': self.prefs.defaultNickname,
'ys-input-message': self.prefs.defaultMessage
};
var keypress = function(e) {
var key = window.event ? e.keyCode : e.which;
if (key === 13 || key === 3) {
self.send.apply(self);
return false;
}
};
var focus = function() {
if (this.value === defaults[this.id]) {
$(this).removeClass('ys-before-focus').addClass( 'ys-after-focus').val('');
}
};
var blur = function() {
if (this.value === '') {
$(this).removeClass('ys-after-focus').addClass('ys-before-focus').val(defaults[this.id]);
}
};
$('#ys-input-message').keypress(keypress).focus(focus).blur(blur);
$('#ys-input-nickname').keypress(keypress).focus(focus).blur(blur);
$('#ys-input-submit').click(function(){ self.send.apply(self); });
$('#ys-post-form').submit(function(){ return false; });
},
initRefresh: function() {
var self = this;
if (this.refreshTimer) { clearInterval(this.refreshTimer); }
this.refreshTimer = setInterval(function() {
self.ajax(self.updates, { reqType: 'refresh' });
}, this.prefs.refresh); // ! 3000..?
},
initFlood: function() {
this.d('in initFlood');
var self = this;
this.floodCount = 0;
this.floodControl = false;
this.floodTimer = setInterval(function() {
self.floodCount = 0;
}, this.prefs.floodTimeout);
},
initLinks: function() {
if ($.browser.msie) { return; }
var self = this;
$('#ys-cp-link').click(function() {
self.openCP.apply(self);
return false;
});
$('#ys-history-link').click(function() {
self.openHistory.apply(self);
return false;
});
},
openCP: function() {
var self = this;
if (this.cpOpen) { return; }
this.cpOpen = true;
var url = this.options.yPath + 'cp/index.php';
$('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-cp"><a title="Close Admin CP" href="#" id="ys-closeoverlay-link">Close</a><a title="View History" href="#" id="ys-switchoverlay-link">View History</a><object class="ys-browser" id="cp-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>');
$('#ys-overlay, #ys-closeoverlay-link').click(function() {
self.reload.apply(self, [true]);
self.closeCP.apply(self);
return false;
});
$('#ys-switchoverlay-link').click(function() {
self.closeCP.apply(self);
self.openHistory.apply(self);
return false;
});
},
closeCP: function() {
this.cpOpen = false;
$('#ys-overlay, #ys-cp').remove();
},
openHistory: function() {
var self = this;
if (this.hOpen) { return; }
this.hOpen = true;
var url = this.options.yPath + 'history/index.php?log='+ this.options.log;
$('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-history"><a title="Close history" href="#" id="ys-closeoverlay-link">Close</a><a title="View Admin CP" href="#" id="ys-switchoverlay-link">View Admin CP</a><object class="ys-browser" id="history-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>');
$('#ys-overlay, #ys-closeoverlay-link').click(function() {
self.reload.apply(self, [true]);
self.closeHistory.apply(self);
return false;
});
$('#ys-switchoverlay-link').click(function() {
self.closeHistory.apply(self);
self.openCP.apply(self);
return false;
});
},
closeHistory: function() {
this.hOpen = false;
$('#ys-overlay, #ys-history').remove();
},
openYShout: function() {
var self = this;
if (this.ysOpen) { return; }
this.ysOpen = true;
var url = this.options.yPath + 'example/yshout.html';
$('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-yshout"><a title="Close YShout" href="#" id="ys-closeoverlay-link">Close</a><object class="ys-browser" id="yshout-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>');
$('#ys-overlay, #ys-closeoverlay-link').click(function() {
self.reload.apply(self, [true]);
self.closeYShout.apply(self);
return false;
});
},
closeYShout: function() {
this.ysOpen = false;
$('#ys-overlay, #ys-yshout').remove();
},
send: function() {
if (!this.validate()) { return; }
if (this.prefs.flood && this.floodControl) { return; }
var postNickname = $('#ys-input-nickname').val(), postMessage = $('#ys-input-message').val();
if (postMessage === '/cp') {
this.openCP();
} else if (postMessage === '/history') {
this.openHistory();
} else {
this.ajax(this.updates, {
reqType: 'post',
nickname: postNickname,
message: postMessage
});
}
$('#ys-input-message').val('');
if (this.prefs.flood) { this.flood(); }
},
validate: function() {
var nickname = $('#ys-input-nickname').val(),
message = $('#ys-input-message').val(),
error = false;
var showInvalid = function(input) {
$(input).removeClass('ys-input-valid').addClass('ys-input-invalid')[0].focus();
error = true;
};
var showValid = function(input) {
$(input).removeClass('ys-input-invalid').addClass('ys-input-valid');
};
if (nickname === '' || nickname === this.prefs.defaultNickname) {
showInvalid('#ys-input-nickname');
} else {
showValid('#ys-input-nickname');
}
if (message === '' || message === this.prefs.defaultMessage) {
showInvalid('#ys-input-message');
} else {
showValid('#ys-input-message');
}
return !error;
},
flood: function() {
var self = this;
this.d('in flood');
if (this.floodCount < this.prefs.floodMessages) {
this.floodCount++;
return;
}
this.floodAttempt++;
this.disable();
if (this.floodAttempt === this.prefs.autobanFlood) {
this.banSelf('You have been banned for flooding the shoutbox!');
}
setTimeout(function() {
self.floodCount = 0;
self.enable.apply(self);
}, this.prefs.floodDisable);
},
disable: function () {
$('#ys-input-submit')[0].disabled = true;
this.floodControl = true;
},
enable: function () {
$('#ys-input-submit')[0].disabled = false;
this.floodControl = false;
},
findBySame: function(ip) {
if (!$.browser.safari) {return;}
var same = [];
for (var i = 0; i < this.p.length; i++) {
if (this.p[i].adminInfo.ip === ip) {
same.push(this.p[i]);
}
}
for (var j = 0; j < same.length; j++) {
$('#' + same[j].id).fadeTo(this.animSpeed, 0.8).fadeTo(this.animSpeed, 1);
}
},
updates: function(updates) {
if (!updates) {return;}
if (updates.prefs) {this.prefs = updates.prefs;}
if (updates.posts) {this.posts(updates.posts);}
if (updates.banned) {this.banned();}
},
banned: function() {
var self = this;
clearInterval(this.refreshTimer);
clearInterval(this.floodTimer);
if (this.initializing) {
$('#ys-post-form').css('display', 'none');
} else {
$('#ys-post-form').fadeOut(this.animSpeed);
}
if ($('#ys-banned').length === 0) {
$('#ys-input-message')[0].blur();
$('#ys-posts').append('<div id="ys-banned"><span>You\'re banned. Click <a href="#" id="ys-unban-self">here</a> to unban yourself if you\'re an admin. If you\'re not, go <a href="' + this.options.yPath + 'cp/index.php" id="ys-banned-cp-link">log in</a>!</span></div>');
$('#ys-banned-cp-link').click(function() {
self.openCP.apply(self);
return false;
});
$('#ys-unban-self').click(function() {
self.ajax(function(json) {
if (!json.error) {
self.unbanned();
} else if (json.error === 'admin') {
alert('You can only unban yourself if you\'re an admin.');
}
}, { reqType: 'unbanself' });
return false;
});
}
},
unbanned: function() {
var self = this;
$('#ys-banned').fadeOut(function() { $(this).remove(); });
this.initRefresh();
$('#ys-post-form').css('display', 'block').fadeIn(this.animSpeed, function(){
self.reload();
});
},
posts: function(p) {
for (var i = 0; i < p.length; i++) {
this.post(p[i]);
}
this.truncate();
if (!this.prefs.inverse) {
var postsDiv = $('#ys-posts')[0];
postsDiv.scrollTop = postsDiv.scrollHeight;
}
},
post: function(post) {
var self = this;
var pad = function(n) { return n > 9 ? n : '0' + n; };
var date = function(ts) { return new Date(ts * 1000); };
var time = function(ts) {
var d = date(ts);
var h = d.getHours(), m = d.getMinutes();
if (self.prefs.timestamp === 12) {
h = (h > 12 ? h - 12 : h);
if (h === 0) { h = 12; }
}
return pad(h) + ':' + pad(m);
};
var dateStr = function(ts) {
var t = date(ts);
var Y = t.getFullYear();
var M = t.getMonth();
var D = t.getDay();
var d = t.getDate();
var day = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][D];
var mon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][M];
return day + ' ' + mon + '. ' + d + ', ' + Y;
};
var self = this;
this.postNum++;
var id = 'ys-post-' + this.postNum;
post.id = id;
post.message = this.links(post.message);
post.message = this.smileys(post.message);
post.message = this.bbcode(post.message);
var html =
'<div id="' + id + '" class="ys-post' + (post.admin ? ' ys-admin-post' : '') + (post.banned ? ' ys-banned-post' : '') + '">' +
(this.prefs.timestamp> 0 ? '<span class="ys-post-timestamp">' + time(post.timestamp) + '</span> ' : '') +
'<span class="ys-post-nickname">' + post.nickname + this.prefs.nicknameSeparator + '</span> ' +
'<span class="ys-post-message">' + post.message + '</span> ' +
'<span class="ys-post-info' + (this.prefs.info === 'overlay' ? ' ys-info-overlay' : ' ys-info-inline') + '">' + (post.adminInfo ? '<em>IP:</em> ' + post.adminInfo.ip + ', ' : '') + '<em>Posted:</em> ' + dateStr(post.timestamp) + ' at ' + time(post.timestamp) + '.</span>' +
'<span class="ys-post-actions"><a title="Show post information" class="ys-info-link" href="#">Info</a>' + (post.adminInfo ? ' | <a title="Delete post" class="ys-delete-link" href="#">Delete</a> | ' + (post.banned ? '<a title="Unban user" class="ys-ban-link" href="#">Unban</a>' : '<a title="Ban user" class="ys-ban-link" href="#">Ban</a>') : '') + '</span>' +
'</div>';
if (this.prefs.inverse) { $('#ys-posts').prepend(html); }
else { $('#ys-posts').append(html); }
this.p.push(post);
$('#' + id)
.find('.ys-post-nickname').click(function() {
if (post.adminInfo) {
self.findBySame(post.adminInfo.ip);
}
}).end()
.find('.ys-info-link').toggle(
function() { self.showInfo.apply(self, [id, this]); return false; },
function() { self.hideInfo.apply(self, [id, this]); return false; })
.end()
.find('.ys-ban-link').click(
function() { self.ban.apply(self, [post, id]); return false; })
.end()
.find('.ys-delete-link').click(
function() { self.del.apply(self, [post, id]); return false; });
},
showInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info');
if (this.prefs.info === 'overlay') {
jEl.css('display', 'block').fadeIn(this.animSpeed);
} else {
jEl.slideDown(this.animSpeed);
}
el.innerHTML = 'Close Info';
return false;
},
hideInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info');
if (this.prefs.info === 'overlay') {
jEl.fadeOut(this.animSpeed);
} else {
jEl.slideUp(this.animSpeed);
}
el.innerHTML = 'Info';
return false;
},
ban: function(post, id) {
var self = this;
var link = $('#' + id).find('.ys-ban-link')[0];
switch(link.innerHTML) {
case 'Ban':
var pars = {
reqType: 'ban',
ip: post.adminInfo.ip,
nickname: post.nickname
};
this.ajax(function(json) {
if (json.error) {
switch (json.error) {
case 'admin':
self.error('You\'re not an admin. Log in through the Admin CP to ban people.');
break;
}
return;
}
//alert('p: ' + this.p + ' / ' + this.p.length);
if (json.bannedSelf) {
self.banned(); // ?
} else {
$.each(self.p, function(i) {
if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) {
$('#' + this.id)
.addClass('ys-banned-post')
.find('.ys-ban-link').html('Unban');
}
});
}
}, pars);
link.innerHTML = 'Banning...';
return false;
case 'Banning...':
return false;
case 'Unban':
var pars = {
reqType: 'unban',
ip: post.adminInfo.ip
};
this.ajax(function(json) {
if (json.error) {
switch(json.error) {
case 'admin':
self.error('You\'re not an admin. Log in through the Admin CP to unban people.');
return;
}
}
$.each(self.p, function(i) {
if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) {
$('#' + this.id)
.removeClass('ys-banned-post')
.find('.ys-ban-link').html('Ban');
}
});
}, pars);
link.innerHTML = 'Unbanning...';
return false;
case 'Unbanning...':
return false;
}
},
del: function(post, id) {
var self = this;
var link = $('#' + id).find('.ys-delete-link')[0];
if (link.innerHTML === 'Deleting...') { return; }
var pars = {
reqType: 'delete',
uid: post.uid
};
self.ajax(function(json) {
if (json.error) {
switch(json.error) {
case 'admin':
self.error('You\'re not an admin. Log in through the Admin CP to ban people.');
return;
}
}
self.reload();
}, pars);
link.innerHTML = 'Deleting...';
return false;
},
banSelf: function(reason) {
var self = this;
this.ajax(function(json) {
if (json.error === false) {
self.banned();
}
}, {
reqType: 'banself',
nickname: $('#ys-input-nickname').val()
});
},
bbcode: function(s) {
s = s.sReplace('[i]', '<i>');
s = s.sReplace('[/i]', '</i>');
s = s.sReplace('[I]', '<i>');
s = s.sReplace('[/I]', '</i>');
s = s.sReplace('[b]', '<b>');
s = s.sReplace('[/b]', '</b>');
s = s.sReplace('[B]', '<b>');
s = s.sReplace('[/B]', '</b>');
s = s.sReplace('[u]', '<u>');
s = s.sReplace('[/u]', '</u>');
s = s.sReplace('[U]', '<u>');
s = s.sReplace('[/U]', '</u>');
return s;
},
smileys: function(s) {
var yp = this.options.yPath;
var smile = function(str, smiley, image) {
return str.sReplace(smiley, '<img src="' + yp + 'smileys/' + image + '" />');
};
s = smile(s, ':twisted:', 'twisted.gif');
s = smile(s, ':cry:', 'cry.gif');
s = smile(s, ':\'(', 'cry.gif');
s = smile(s, ':shock:', 'eek.gif');
s = smile(s, ':evil:', 'evil.gif');
s = smile(s, ':lol:', 'lol.gif');
s = smile(s, ':mrgreen:', 'mrgreen.gif');
s = smile(s, ':oops:', 'redface.gif');
s = smile(s, ':roll:', 'rolleyes.gif');
s = smile(s, ':?', 'confused.gif');
s = smile(s, ':D', 'biggrin.gif');
s = smile(s, '8)', 'cool.gif');
s = smile(s, ':x', 'mad.gif');
s = smile(s, ':|', 'neutral.gif');
s = smile(s, ':P', 'razz.gif');
s = smile(s, ':(', 'sad.gif');
s = smile(s, ':)', 'smile.gif');
s = smile(s, ':o', 'surprised.gif');
s = smile(s, ';)', 'wink.gif');
return s;
},
links: function(s) {
return s.replace(/((https|http|ftp|ed2k):\/\/[\S]+)/gi, '<a href="$1" target="_blank">$1</a>');
},
truncate: function(clearAll) {
var truncateTo = clearAll ? 0 : this.prefs.truncate;
var posts = $('#ys-posts .ys-post').length;
if (posts <= truncateTo) { return; }
//alert(this.initializing);
if (this.prefs.doTruncate || this.initializing) {
var diff = posts - truncateTo;
for (var i = 0; i < diff; i++) {
this.p.shift();
}
// $('#ys-posts .ys-post:gt(' + truncateTo + ')').remove();
if (this.prefs.inverse) {
$('#ys-posts .ys-post:gt(' + (truncateTo - 1) + ')').remove();
} else {
$('#ys-posts .ys-post:lt(' + (posts - truncateTo) + ')').remove();
}
}
this.markEnds();
},
markEnds: function() {
$('#ys-posts')
.find('.ys-first').removeClass('ys-first').end()
.find('.ys-last').removeClass('ys-last');
$('#ys-posts .ys-post:first-child').addClass('ys-first');
$('#ys-posts .ys-post:last-child').addClass('ys-last');
},
reload: function(everything) {
var self = this;
this.initializing = true;
if (everything) {
this.ajax(function(json) {
$('#yshout').html('');
clearInterval(this.refreshTimer);
clearInterval(this.floodTimer);
this.initialLoad(json);
}, {
reqType: 'init',
yPath: this.options.yPath,
log: this.options.log
});
} else {
this.ajax(function(json) { this.truncate(true); this.updates(json); this.initializing = false; }, {
reqType: 'reload'
});
}
},
error: function(str) {
alert(str);
},
json: function(parse) {
this.d('In json: ' + parse);
var json = eval('(' + parse + ')');
if (!this.checkError(json)) { return json; }
},
checkError: function(json) {
if (!json.yError) { return false; }
this.d('Error: ' + json.yError);
return true;
},
ajax: function(callback, pars, html) {
pars = jQuery.extend({
reqFor: 'shout'
}, pars);
var self = this;
$.ajax({
type: 'POST',
url: this.options.yPath + 'yshout.php',
dataType: html ? 'text' : 'json',
data: pars,
success: function(parse) {
var arr = [parse];
callback.apply(self, arr);
}
});
},
d: function(message) {
// console.log(message);
$('#debug').css('display', 'block').prepend('<p>' + message + '</p>');
return message;
}
};

View file

@ -1,4 +0,0 @@
<Files *>
order allow,deny
deny from all
</Files>

View file

@ -1 +0,0 @@
a:2:{s:4:"info";a:1:{s:15:"latestTimestamp";d:1365655195.8733589649200439453125;}s:5:"posts";a:1:{i:0;a:6:{s:8:"nickname";s:7:"YaoiFox";s:7:"message";s:42:"I hope enjoy this chatbox based on YShout!";s:9:"timestamp";d:1365655195.8733589649200439453125;s:5:"admin";b:0;s:3:"uid";s:32:"ee9e9a7a01909be8065571655dad044d";s:9:"adminInfo";a:1:{s:2:"ip";s:11:"84.193.78.8";}}}}

View file

@ -1 +0,0 @@
a:0:{}

View file

@ -1 +0,0 @@
a:23:{s:8:"password";s:8:"fortytwo";s:7:"refresh";i:6000;s:4:"logs";i:5;s:7:"history";i:200;s:7:"inverse";b:0;s:8:"truncate";i:15;s:10:"doTruncate";b:1;s:9:"timestamp";i:12;s:15:"defaultNickname";s:8:"Nickname";s:14:"defaultMessage";s:12:"Message Text";s:13:"defaultSubmit";s:6:"Shout!";s:10:"showSubmit";b:1;s:14:"nicknameLength";i:25;s:13:"messageLength";i:175;s:17:"nicknameSeparator";s:1:":";s:5:"flood";b:1;s:12:"floodTimeout";i:5000;s:13:"floodMessages";i:4;s:12:"floodDisable";i:8000;s:12:"autobanFlood";i:0;s:11:"censorWords";s:19:"fuck shit bitch ass";s:12:"postFormLink";s:7:"history";s:4:"info";s:6:"inline";}

View file

@ -1,38 +0,0 @@
<?php
/**
* Name: [Beta] Chatbox
* Author: Drudex Software <support@drudexsoftware.com>
* Link: http://www.drudexsoftware.com
* License: GPLv2
* Description: Places an ajax chatbox at the bottom of each page
* Documentation:
* This chatbox uses YShout 5 as core.
*/
class Chatbox extends Extension
{
public function onPageRequest(PageRequestEvent $event)
{
global $page, $user;
// Adds header to enable chatbox
$root = get_base_href();
$yPath = make_http($root . "/ext/chatbox/");
$page->add_html_header("
<script src=\"http://code.jquery.com/jquery-migrate-1.2.1.js\" type=\"text/javascript\"></script>
<script src=\"$root/ext/chatbox/js/yshout.js\" type=\"text/javascript\"></script>
<link rel=\"stylesheet\" href=\"$root/ext/chatbox/css/dark.yshout.css\" />
<script type=\"text/javascript\">
nickname = '{$user->name}';
new YShout({ yPath: '$yPath' });
</script>
", 500);
// loads the chatbox at the set location
$html = "<div id=\"yshout\"></div>";
$chatblock = new Block("Chatbox", $html, "main", 97);
$chatblock->is_content = false;
$page->add_block($chatblock);
}
}

View file

@ -1,314 +0,0 @@
<?php
class AjaxCall
{
public $reqType;
public $updates;
public function AjaxCall($log = null)
{
header('Content-type: application/json');
session_start();
if (isset($log)) {
$_SESSION['yLog'] = $log;
}
$this->reqType = $_POST['reqType'];
}
public function process()
{
switch ($this->reqType) {
case 'init':
$this->initSession();
$this->sendFirstUpdates();
break;
case 'post':
$nickname = $_POST['nickname'];
$message = $_POST['message'];
cookie('yNickname', $nickname);
$ys = ys($_SESSION['yLog']);
if ($ys->banned(ip())) {
$this->sendBanned();
break;
}
if ($post = $ys->post($nickname, $message)) {
// To use $post somewheres later
$this->sendUpdates();
}
break;
case 'refresh':
$ys = ys($_SESSION['yLog']);
if ($ys->banned(ip())) {
$this->sendBanned();
break;
}
$this->sendUpdates();
break;
case 'reload':
$this->reload();
break;
case 'ban':
$this->doBan();
break;
case 'unban':
$this->doUnban();
break;
case 'delete':
$this->doDelete();
break;
case 'banself':
$this->banSelf();
break;
case 'unbanself':
$this->unbanSelf();
break;
case 'clearlog':
$this->clearLog();
break;
case 'clearlogs':
$this->clearLogs();
break;
}
}
public function doBan()
{
$ip = $_POST['ip'];
$nickname = $_POST['nickname'];
$send = [];
$ys = ys($_SESSION['yLog']);
switch (true) {
case !loggedIn():
$send['error'] = 'admin';
break;
case $ys->banned($ip):
$send['error'] = 'already';
break;
default:
$ys->ban($ip, $nickname);
if ($ip == ip()) {
$send['bannedSelf'] = true;
}
$send['error'] = false;
}
echo json_encode($send);
}
public function doUnban()
{
$ip = $_POST['ip'];
$send = [];
$ys = ys($_SESSION['yLog']);
switch (true) {
case !loggedIn():
$send['error'] = 'admin';
break;
case !$ys->banned($ip):
$send['error'] = 'already';
break;
default:
$ys->unban($ip);
$send['error'] = false;
}
echo json_encode($send);
}
public function doDelete()
{
$uid = $_POST['uid'];
$send = [];
$ys = ys($_SESSION['yLog']);
switch (true) {
case !loggedIn():
$send['error'] = 'admin';
break;
default:
$ys->delete($uid);
$send['error'] = false;
}
echo json_encode($send);
}
public function banSelf()
{
$ys = ys($_SESSION['yLog']);
$nickname = $_POST['nickname'];
$ys->ban(ip(), $nickname);
$send = [];
$send['error'] = false;
echo json_encode($send);
}
public function unbanSelf()
{
if (loggedIn()) {
$ys = ys($_SESSION['yLog']);
$ys->unban(ip());
$send = [];
$send['error'] = false;
} else {
$send = [];
$send['error'] = 'admin';
}
echo json_encode($send);
}
public function reload()
{
global $prefs;
$ys = ys($_SESSION['yLog']);
$posts = $ys->latestPosts($prefs['truncate']);
$this->setSessTimestamp($posts);
$this->updates['posts'] = $posts;
echo json_encode($this->updates);
}
public function initSession()
{
$_SESSION['yLatestTimestamp'] = 0;
$_SESSION['yYPath'] = $_POST['yPath'];
$_SESSION['yLog'] = $_POST['log'];
$loginHash = cookieGet('yLoginHash') ;
if (isset($loginHash) && $loginHash != '') {
login($loginHash);
}
}
public function sendBanned()
{
$this->updates = [
'banned' => true
];
echo json_encode($this->updates);
}
public function sendUpdates()
{
global $prefs;
$ys = ys($_SESSION['yLog']);
if (!$ys->hasPostsAfter($_SESSION['yLatestTimestamp'])) {
return;
}
$posts = $ys->postsAfter($_SESSION['yLatestTimestamp']);
$this->setSessTimestamp($posts);
$this->updates['posts'] = $posts;
echo json_encode($this->updates);
}
public function setSessTimestamp(&$posts)
{
if (!$posts) {
return;
}
$latest = array_slice($posts, -1, 1);
$_SESSION['yLatestTimestamp'] = $latest[0]['timestamp'];
}
public function sendFirstUpdates()
{
global $prefs, $overrideNickname;
$this->updates = [];
$ys = ys($_SESSION['yLog']);
$posts = $ys->latestPosts($prefs['truncate']);
$this->setSessTimestamp($posts);
$this->updates['posts'] = $posts;
$this->updates['prefs'] = $this->cleanPrefs($prefs);
if ($nickname = cookieGet('yNickname')) {
$this->updates['nickname'] = $nickname;
}
if ($overrideNickname) {
$this->updates['nickname'] = $overrideNickname;
}
if ($ys->banned(ip())) {
$this->updates['banned'] = true;
}
echo json_encode($this->updates);
}
public function cleanPrefs($prefs)
{
unset($prefs['password']);
return $prefs;
}
public function clearLog()
{
//$log = $_POST['log'];
$send = [];
$ys = ys($_SESSION['yLog']);
switch (true) {
case !loggedIn():
$send['error'] = 'admin';
break;
default:
$ys->clear();
$send['error'] = false;
}
echo json_encode($send);
}
public function clearLogs()
{
global $prefs;
//$log = $_POST['log'];
$send = [];
//$ys = ys($_SESSION['yLog']);
switch (true) {
case !loggedIn():
$send['error'] = 'admin';
break;
default:
for ($i = 1; $i <= $prefs['logs']; $i++) {
$ys = ys($i);
$ys->clear();
}
$send['error'] = false;
}
echo json_encode($send);
}
}

View file

@ -1,106 +0,0 @@
<?php
class FileStorage
{
public $shoutLog;
public $path;
public $handle;
public function FileStorage($path, $shoutLog = false)
{
$this->shoutLog = $shoutLog;
$folder = 'logs';
if (!is_dir($folder)) {
$folder = '../' . $folder;
}
if (!is_dir($folder)) {
$folder = '../' . $folder;
}
$this->path = $folder . '/' . $path . '.txt';
}
public function open($lock = false)
{
$this->handle = fopen($this->path, 'a+');
if ($lock) {
$this->lock();
return $this->load();
}
}
public function close(&$array)
{
if (isset($array)) {
$this->save($array);
}
$this->unlock();
fclose($this->handle);
unset($this->handle);
}
public function load()
{
if (($contents = $this->read($this->path)) == null) {
return $this->resetArray();
}
return unserialize($contents);
}
public function save(&$array, $unlock = true)
{
$contents = serialize($array);
$this->write($contents);
if ($unlock) {
$this->unlock();
}
}
public function unlock()
{
if (isset($this->handle)) {
flock($this->handle, LOCK_UN);
}
}
public function lock()
{
if (isset($this->handle)) {
flock($this->handle, LOCK_EX);
}
}
public function read()
{
fseek($this->handle, 0);
//return stream_get_contents($this->handle);
return file_get_contents($this->path);
}
public function write($contents)
{
ftruncate($this->handle, 0);
fwrite($this->handle, $contents);
}
public function resetArray()
{
if ($this->shoutLog) {
$default = [
'info' => [
'latestTimestamp' => -1
],
'posts' => []
];
} else {
$default = [];
}
$this->save($default, false);
return $default;
}
}

View file

@ -1,174 +0,0 @@
<?php
function cookie($name, $data)
{
return setcookie($name, $data, time() + 60 * 60 * 24 * 30, '/');
}
function cookieGet($name, $default = null)
{
if (isset($_COOKIE[$name])) {
return $_COOKIE[$name];
} else {
return $default;
}
}
function cookieClear($name)
{
setcookie($name, false, time() - 42);
}
function getVar($name)
{
if (isset($_POST[$name])) {
return $_POST[$name];
}
if (isset($_GET[$name])) {
return $_GET[$name];
}
return null;
}
function clean($s)
{
$s = magic($s);
$s = htmlspecialchars($s);
return $s;
}
function magic($s)
{
if (get_magic_quotes_gpc()) {
$s = stripslashes($s);
}
return $s;
}
function ip()
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
return $_SERVER['REMOTE_ADDR'];
}
}
function ipValid($ip)
{
if ($ip == long2ip(ip2long($ip))) {
return true;
}
return false;
}
function validIP($ip)
{
if ($ip == long2ip(ip2long($ip))) {
return true;
}
return false;
}
function ts()
{
// return microtime(true);
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function len($string)
{
$i = 0;
$count = 0;
$len = strlen($string);
while ($i < $len) {
$chr = ord($string[$i]);
$count++;
$i++;
if ($i >= $len) {
break;
}
if ($chr & 0x80) {
$chr <<= 1;
while ($chr & 0x80) {
$i++;
$chr <<= 1;
}
}
}
return $count;
}
function error($err)
{
echo 'Error: ' . $err;
exit;
}
function ys($log = 1)
{
global $yShout, $prefs;
if ($yShout) {
return $yShout;
}
if (filter_var($log, FILTER_VALIDATE_INT, ["options" => ["min_range" => 0, "max_range" => $prefs['logs']]]) === false) {
$log = 1;
}
$log = 'log.' . $log;
return new YShout($log, loggedIn());
}
function dstart()
{
global $ts;
$ts = ts();
}
function dstop()
{
global $ts;
echo 'Time elapsed: ' . ((ts() - $ts) * 100000);
exit;
}
function login($hash)
{
// echo 'login: ' . $hash . "\n";
$_SESSION['yLoginHash'] = $hash;
cookie('yLoginHash', $hash);
// return loggedIn();
}
function logout()
{
$_SESSION['yLoginHash'] = '';
cookie('yLoginHash', '');
// cookieClear('yLoginHash');
}
function loggedIn()
{
global $prefs;
$loginHash = cookieGet('yLoginHash', false);
// echo 'loggedin: ' . $loginHash . "\n";
// echo 'pw: ' . $prefs['password'] . "\n";
if (isset($loginHash)) {
return $loginHash == md5($prefs['password']);
}
if (isset($_SESSION['yLoginHash'])) {
return $_SESSION['yLoginHash'] == md5($prefs['password']);
}
return false;
}

View file

@ -1,292 +0,0 @@
<?php
class YShout
{
public function YShout($path, $admin = false)
{
global $storage;
// Redo to check for folders or just not break, because nonexistent files should be allowed.
// if (!file_exists($path)) error('That file does not exist.');
$this->storage = new $storage($path, true);
$this->admin = $admin;
}
public function posts()
{
global $null;
$this->storage->open();
$s = $this->storage->load();
$this->storage->close($null);
if ($s) {
return $s['posts'];
}
}
public function info()
{
global $null;
$s = $this->storage->open(true);
$this->storage->close($null);
if ($s) {
return $s['info'];
}
}
public function postsAfter($ts)
{
$allPosts = $this->posts();
$posts = [];
/* for ($i = sizeof($allPosts) - 1; $i > -1; $i--) {
$post = $allPosts[$i];
if ($post['timestamp'] > $ts)
$posts[] = $post;
} */
foreach ($allPosts as $post) {
if ($post['timestamp'] > $ts) {
$posts[] = $post;
}
}
$this->postProcess($posts);
return $posts;
}
public function latestPosts($num)
{
$allPosts = $this->posts();
$posts = array_slice($allPosts, -$num, $num);
$this->postProcess($posts);
return array_values($posts);
}
public function hasPostsAfter($ts)
{
$info = $this->info();
$timestamp = $info['latestTimestamp'];
return $timestamp > $ts;
}
public function post($nickname, $message)
{
global $prefs;
if ($this->banned(ip()) /* && !$this->admin*/) {
return false;
}
if (!$this->validate($message, $prefs['messageLength'])) {
return false;
}
if (!$this->validate($nickname, $prefs['nicknameLength'])) {
return false;
}
$message = trim(clean($message));
$nickname = trim(clean($nickname));
if ($message == '') {
return false;
}
if ($nickname == '') {
return false;
}
$timestamp = ts();
$message = $this->censor($message);
$nickname = $this->censor($nickname);
$post = [
'nickname' => $nickname,
'message' => $message,
'timestamp' => $timestamp,
'admin' => $this->admin,
'uid' => md5($timestamp . ' ' . $nickname),
'adminInfo' => [
'ip' => ip()
]
];
$s = $this->storage->open(true);
$s['posts'][] = $post;
if (sizeof($s['posts']) > $prefs['history']) {
$this->truncate($s['posts']);
}
$s['info']['latestTimestamp'] = $post['timestamp'];
$this->storage->close($s);
$this->postProcess($post);
return $post;
}
public function truncate(&$array)
{
global $prefs;
$array = array_slice($array, -$prefs['history']);
$array = array_values($array);
}
public function clear()
{
global $null;
$this->storage->open(true);
$this->storage->resetArray();
// ? Scared to touch it... Misspelled though. Update: Touched! Used to be $nulls...
$this->storage->close($null);
}
public function bans()
{
global $storage, $null;
$s = new $storage('yshout.bans');
$s->open();
$bans = $s->load();
$s->close($null);
return $bans;
}
public function ban($ip, $nickname = '', $info = '')
{
global $storage;
$s = new $storage('yshout.bans');
$bans = $s->open(true);
$bans[] = [
'ip' => $ip,
'nickname' => $nickname,
'info' => $info,
'timestamp' => ts()
];
$s->close($bans);
}
public function banned($ip)
{
global $storage, $null;
$s = new $storage('yshout.bans');
$bans = $s->open(true);
$s->close($null);
foreach ($bans as $ban) {
if ($ban['ip'] == $ip) {
return true;
}
}
return false;
}
public function unban($ip)
{
global $storage;
$s = new $storage('yshout.bans');
$bans = $s->open(true);
foreach ($bans as $key=>$value) {
if ($value['ip'] == $ip) {
unset($bans[$key]);
}
}
$bans = array_values($bans);
$s->close($bans);
}
public function unbanAll()
{
global $storage, $null;
$s = new $storage('yshout.bans');
$s->open(true);
$s->resetArray();
$s->close($null);
}
public function delete($uid)
{
global $prefs, $storage;
$s = $this->storage->open(true);
$posts = $s['posts'];
foreach ($posts as $key=>$value) {
if (!isset($value['uid'])) {
unset($posts['key']);
} elseif ($value['uid'] == $uid) {
unset($posts[$key]);
}
}
$s['posts'] = array_values($posts);
$this->storage->close($s);
return true;
}
public function validate($str, $maxLen)
{
return len($str) <= $maxLen;
}
public function censor($str)
{
global $prefs;
$cWords = explode(' ', $prefs['censorWords']);
$words = explode(' ', $str);
$endings = '|ed|es|ing|s|er|ers';
$arrEndings = explode('|', $endings);
foreach ($cWords as $cWord) {
foreach ($words as $i=>$word) {
$pattern = '/^(' . $cWord . ')+(' . $endings . ')\W*$/i';
$words[$i] = preg_replace($pattern, str_repeat('*', strlen($word)), $word);
}
}
return implode(' ', $words);
}
public function postProcess(&$post)
{
if (isset($post['message'])) {
if ($this->banned($post['adminInfo']['ip'])) {
$post['banned'] = true;
}
if (!$this->admin) {
unset($post['adminInfo']);
}
} else {
foreach ($post as $key=>$value) {
if ($this->banned($value['adminInfo']['ip'])) {
$post[$key]['banned'] = true;
}
if (!$this->admin) {
unset($post[$key]['adminInfo']);
}
}
}
}
}

View file

@ -1,75 +0,0 @@
<?php
// If you want to change the nickname, the line below is the one to modify.
// Simply set $overrideNickname to whatever variable you want to appear as the nickname,
// or leave it null to use the set nicknames.
$overrideNickname = null;
$storage = 'FileStorage';
function loadPrefs()
{
global $prefs, $storage, $null;
$s = new $storage('yshout.prefs');
$s->open();
$prefs = $s->load();
$s->close($null);
}
function savePrefs($newPrefs)
{
global $prefs, $storage;
$s = new $storage('yshout.prefs');
$s->open(true);
$s->close($newPrefs);
$prefs = $newPrefs;
}
function resetPrefs()
{
$defaultPrefs = [
'password' => 'fortytwo', // The password for the CP
'refresh' => 6000, // Refresh rate
'logs' => 5, // Amount of different log files to allow
'history' => 200, // Shouts to keep in history
'inverse' => false, // Inverse shoutbox / form on top
'truncate' => 15, // Truncate messages client-side
'doTruncate' => true, // Truncate messages?
'timestamp' => 12, // Timestamp format 12- or 24-hour
'defaultNickname' => 'Nickname',
'defaultMessage' => 'Message Text',
'defaultSubmit' => 'Shout!',
'showSubmit' => true,
'nicknameLength' => 25,
'messageLength' => 175,
'nicknameSeparator' => ':',
'flood' => true,
'floodTimeout' => 5000,
'floodMessages' => 4,
'floodDisable' => 8000,
'floodDelete' => false,
'autobanFlood' => 0, // Autoban people for flooding after X messages
'censorWords' => 'fuck shit bitch ass',
'postFormLink' => 'history',
'info' => 'inline'
];
savePrefs($defaultPrefs);
}
resetPrefs();
//loadPrefs();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

View file

@ -1,39 +0,0 @@
<?php
error_reporting(E_ALL);
ob_start();
set_error_handler('errorOccurred');
include 'include.php';
if (isset($_POST['reqFor'])) {
switch ($_POST['reqFor']) {
case 'shout':
$ajax = new AjaxCall();
$ajax->process();
break;
case 'history':
// echo $_POST['log'];
$ajax = new AjaxCall($_POST['log']);
$ajax->process();
break;
default:
exit;
}
} else {
include 'example.html';
}
function errorOccurred($num, $str, $file, $line)
{
$err = [
'yError' => "$str. \n File: $file \n Line: $line"
];
echo json_encode($err);
exit;
}