';
echo 'The data file ('.$filename.') is not writeable. ';
echo 'Run
chmod 666 '.$filename.'
to make it writeable on linux.
';
echo 'People cannot shout!
';
}
/************* SAVE SUBMITTED SHOUT *****************/
if($_POST['act']=='shout') { // This executes the script once submit is clicked.
$ipaddr = $_SERVER['REMOTE_ADDR'];
$name = trim($_POST['name']);
$shout = trim($_POST['shout']);
if (!is_writable($filename)) {
$errorMsg .= $error_cantshout;
} else if(($_SESSION['lastip']==$ipaddr)&&(time()-$_SESSION['lasttime']<$delayshout)) {
// flooding control here
$errorMsg .= $error_wait;
} else {
if(!$name || $name=='' || $name=='Name') $errorMsg .= $error_noname;
elseif(!$isAdmin && strcasecmp($name, $adminname)==0) $errorMsg .= $error_namereserved;
elseif(!$shout || $shout=='' || $shout=='Message') $errorMsg .= $error_noshout;
// Good, now the essentials are taken care of!
// Let's make the name display a link if there is a site specified.
else {
$name = str_replace('|', '|',$name);
$shout = str_replace('|', '|',$shout);
// Now we should open the file, or make it if it's not there!
$handle = fopen($filename,'a');
$yourtimezone = floor($yourtimezone);
if ($yourtimezone<-12 || $yourtimezone>12) $yourtimezone = 0;
// Date...
$date = gmdate('d/m/Y', time() + 3600*($yourtimezone+(date('I')==1?0:1)));
$time = gmdate('H:i:s', time() + 3600*($yourtimezone+(date('I')==1?0:1)));
removeBadWords($name, '***');
removeBadWords($shout, '***');
// Let's make all of the data one string now!
$data = "$name | $date | $time | $ipaddr | $shout\n";
fwrite($handle, $data);
fclose($handle);
$_SESSION['lastip'] = $ipaddr;
$_SESSION['lasttime'] = time();
}
}
}
// This makes an array with each line in the file
$shouts = file($filename);
$rowColor = 0;
$count = 0;
$totalshouts = count($shouts)-1;
/************* DELETE SELECTED SHOUT *****************/
if($_GET['act']=='del' && !empty($_GET['k'])) { // delete a shout
if (!is_writable($filename)) {
$errorMsg .= $error_cantdelete;
} else if ($isAdmin) {
for ($count = 0; $count<=$totalshouts; $count++) {
if (md5($shouts[$count])==$_GET['k']) unset($shouts[$count]);
}
$handle = fopen($filename,'w');
fwrite($handle, implode('', $shouts));
fclose($handle);
$shouts = file($filename);
$totalshouts = count($shouts)-1;
}
}
$pages = ceil($totalshouts / $shoutsperpage);
if ($pages<1) $pages=1;
$page = $_GET['page'];
if (!$page) $page=1;
if ($page<0) $page = 1;
if ($page>$pages) $page = $pages;
/************* SHOW FORM *****************/
echo '';
echo '
';
// smileys list
echo '
';
echo '
';
if ($smileydir=='' || !is_dir($smileydir))
array_walk ($smileys, 'show_smiley2', $smileydir);
else
array_walk ($smileys, 'show_smiley', $smileydir);
echo ' |
';
// ends smileys list
// search form
if ($_POST['q']!='' && $_POST['q']!='Search for...') {
echo '
';
echo '';
if ($errorMsg!='') echo '
'.$errorMsg.'
';
/************* DISPLAY SHOUTS *****************/
if ($smileydir=='' || !is_dir($smileydir))
array_walk ($smileys, 'alter_smiley2', $smileydir);
else
array_walk ($smileys, 'alter_smiley', $smileydir);
// invert order of the shouts, last shout will go first
arsort($shouts);
$link_search = array('/\',
'/\>/',
'#([\n ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i',
'#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i',
'/(?\s]+)/i');
if ($usemask)
$link_replace = array('<',
'>',
'\\1
'.$email_mask.'',
'\\1
'.$link_mask.'',
'
'.$link_mask.'');
else
$link_replace = array('<',
'>',
'\\1
\\2@\\3',
'\\1
www.\\2.\\3\\4',
'
\\0');
$delbutton = '';
if ($_POST['act']=='search') {
if($_POST['q']!='' && $_POST['q']!=$str_searchfor) {
$found = 0;
$str = '';
for ($count = 0; $count<=$totalshouts; $count++) {
list($auth,$date,$time,$ipaddr,$shout) = explode(' | ', $shouts[$totalshouts-$count]);
if (!(stristr($shouts[$totalshouts-$count], $_POST['q'])===false)) {
if ($isAdmin) $delbutton = '
xip';
$shout = strip_tags($shout);
$shout = stripslashes($shout);
$shout = preg_replace($link_search, $link_replace, $shout);
$shout = strtr($shout, $smileys);
if (strlen($auth)>$shouternamelen) {
$str .= '
'.$delbutton.substr($auth,0,$shouternamelen-3).'…
';
} else {
$str .= '
'.$delbutton.$auth.'
';
}
$str .= '
'.$shout.'
';
$rowColor=($rowColor==0)?1:0;
$found++;
}
}
if ($found>0) {
$str_found = str_replace('{#}', $found, $str_found);
echo '
'.str_replace('{Q}', $_GET['q'], $str_found).'
';
echo '
';
echo $str;
die;
} else {
echo '
'.str_replace('{Q}', $_GET['q'], $str_nofound).'
';
}
} else {
echo '
'.$str_noquery.'
';
}
}
echo '
CShout
';
for ($count = $shoutsperpage*($page-1); $count<($shoutsperpage*$page) && $count<=$totalshouts; $count++) {
list($auth,$date,$time,$ipaddr,$shout) = explode(' | ', $shouts[$totalshouts-$count]);
if ($isAdmin) $delbutton = '
xip';
$shout = strip_tags($shout);
$shout = stripslashes($shout);
$shout = preg_replace($link_search, $link_replace, $shout);
$shout = strtr($shout, $smileys);
if (strlen($auth)>$shouternamelen) {
echo '
'.$delbutton.substr($auth,0,$shouternamelen-3).'…
';
} else {
echo '
'.$delbutton.$auth.'
';
}
echo '
'.$shout.'
';
$rowColor=($rowColor==0)?1:0;
}
?>