'; } function show_smiley2($item1, $key, $prefix) { $_key = str_replace('\'', '\\u0027', $key); $_key = str_replace('"', '\\u0022', $_key); echo ''.htmlspecialchars($key).' '; } function alter_smiley(&$item1, $key, $prefix) { $item1 = ' '.htmlspecialchars($key).''; } function alter_smiley2(&$item1, $key, $prefix) { $item1 = ' '.htmlspecialchars($key); } function removeBadWords(&$text, $replace = '[:)]') { global $badwords; // add bad words to your filter here for ($i=0;$i time()) { $errorMsg = $error_templock; } else if ($_POST['u']!=$adminname || $_POST['p']!=$adminpassword) { $errorMsg = $error_wrongup; $_SESSION['tries']++; if ($_SESSION['tries']>2) { $_SESSION['lasttry'] = time() + $failedbantime; $_SESSION['tries'] = 0; } } else { $_SESSION['lasttry'] = time(); $_SESSION['tries'] = 0; $_SESSION['u'] = sha1($_POST['u']); $_SESSION['p'] = sha1($_POST['p']); } } else if($_POST['act']=='logout') { $_SESSION['u'] = ''; $_SESSION['p'] = ''; } $isAdmin = isAdmin(); /************* WARNING ON DATA FILE PERMISSION *****************/ if (!file_exists($filename)) { if (!is_writable('./')) { echo '
'; echo 'The data file ('.$filename.') does not exist
'; echo 'Create one or provide write permission to the shoutbox\'s directory '; echo 'by running the following command in that directory:
'; echo 'chmod 777 .
'; echo 'This will allow it to create new data file automatically.
'; die; } else { $handle = fopen($filename, 'w') or die("Can't create file"); fclose($handle); } } if (!is_writable($filename)) { echo '
'; 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 '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo ''; if ($isAdmin) echo ''; else echo ''; echo ''; echo ''; echo ''; echo ''.$page.''; 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 '
'; } else { echo '
'; } echo ''; echo ''; echo '
'; // ends search form // login form echo '
'; echo '
'; if ($isAdmin) { echo ''; echo ''; } else { echo ''; echo ''; echo ''; echo ''; } echo '
'; // ends login form echo '
'; for ($count=1; $count<$pages+1; $count++) { if($count==$page) echo ''.$count.' '; else echo ''.$count.' '; } echo '
'; echo '
'; echo '
Make a shout
'; echo '
Enter your name in the first text box and your message in the second one then click .: Send :. button.
'; echo '
Insert emoticons
'; echo '
Place the cursor in the second text box where you want to insert an emoticon then click :) button and click on appropriate icon.
'; echo '
Search old messages
'; echo '
Click S button and enter your search query. You can search by date, time, shouter, message or even ip address.
'; echo '
Page navigation
'; echo '
Use or buttons to move to previous or next page respectively. Or click P button to jump to any page.
'; echo '
'; 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', '\\1www.\\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; } ?>