$length) { $words = explode(' ', $str); $wCnt = count($words); if($wCnt == 1) { $str = substr($str, 0, $length) . '.'; } else { $str = ''; $cnt = 0; while($cnt < $wCnt && strlen($str) < $length) { $str .= trim($words[$cnt++]) . ' '; } if($cnt < $wCnt) $str .= '.'; } } return $str; } // Replace bad words with image // Arguments: text // function replaceWords($str) { global $badwords; $repl = ''; $c = '(\_|[^\d\w\r\n])*'; $cl = strlen($c); for($i = 0; $i < count($badwords); $i++) { $expr = chunk_split($badwords[$i], 1, $c); $str = preg_replace('/' . substr($expr, 0, strlen($expr) - $cl) . '/i', $repl, $str); } return $str; } /////////////////////////////////////////// function randomNumber($length) { $result = ''; for($i = 0; $i < $length; $i++) { $result .= mt_rand(0, 9); } return $result; } ////////////////////////////////////// function alphaNumSpacePeriod($c1) { $c1=trim(preg_replace('/(\s)\s+/', ' ', $c1)); return trim(preg_replace('/[^A-Za-z0-9\.]/', ' ',$c1)); // return trim(preg_replace('/[^A-Za-z0-9\s]/', '',$c1)); } //////////////////////////////////// function alphaNumOnly($c) { return trim(preg_replace('/[^A-Za-z0-9]/', '',$c)); } ////////////////////////////////// function oneSpace($str) { return trim(preg_replace('/(\s)\s+/', ' ', $str)); } ///////////////////////////////////// if(file_exists($dbfile)) { $files= file($dbfile); $size = filesize($dbfile); if($size > 0) { if($size > $entries){ $output = array_slice($files, 0,$entries);// returns lines set at line 30 file_put_contents($dbfile, $output, LOCK_EX); }else{ $output=$files; } $i=1; $cnt=count($output); //echo $cnt; $u=''; $n=''; $rt=''; foreach ($output as $line) { $users = explode('#', $line); $thename =$users[3]; $comment =stripslashes(smile($users[4])); //uncomment below 3 lines to decode for hyperlinks with link name used //if($links){ //$comment= html_entity_decode($comment, ENT_COMPAT | ENT_HTML5); //} $comment =wordwrap($comment, $wrap, "\n", 1); if (!empty($_SESSION['admin'])) { $comment="$comment
Delete"; } if (in_array($thename, $reserved)) { $u .= "$thename $users[2]
$comment
"; $rt='1'; } else{ $u .= "$thename $users[2]
$comment
"; } if(empty($comment)){ $u .= "No posts yet
$comment
"; } //$u .= "
"; //$n .= $users[1]; //$n .= "\n"; $i++; } } } if(empty($u)){ $u = 'No posts yet

'; } $admin_in=''; $errors=''; if (isset($_POST['postit'])){ if (isset($_POST['user']) and empty($_POST['user'])){ $errors='1'; }elseif(!empty($_POST['user'])){ $user = clean($_POST['user']); if (strlen($user) > 12){ $user = substr($user, 0, 11); } $user = alphaNumOnly($user); $user=strtolower($user); if(empty($_SESSION['admin'])){ if(in_array($user,$reserved)){ $rn=randomNumber('4'); $user="user".$rn; } } $_SESSION['user']=$user; }else{ $user=$_SESSION['user']; } //////////////////////////////////////////////////////// if(isset($_POST['box']) and empty($_POST['box'])){ $errors='1'; }else{ $str=str_replace(array('script','#'),'',$_POST['box']); $str=checkRepeats($str); $str=cutString($str, $textLength); $str=oneSpace($str); if(!$links){ $str = clean($str); $str =alphaNumSpacePeriod($str); }elseif($links){ $str=strip_tags($str,''); $str=htmlentities($str); }else{ $str=htmlentities($str); } $str=str_replace("\n","
",$str); $str=replaceWords($str); } /////////////////////////////////////// if ($captcha) { if(isset($_POST['m1']) and empty($_POST['m1'])){ $errors='1'; } if(isset($_POST['a1']) and empty($_POST['a1'])){ $errors='1'; } if(!empty($_POST['a1']) and !empty($_POST['m1']) and $_POST['a1'] != $_POST['m1']){ $errors='1'; } } /////////////////////////////////// if (!file_exists($dbfile)) touch($dbfile); if (!$errors){ $fh = fopen($dbfile, 'r'); $fcontent = fread($fh, filesize($dbfile)); if(isset($_SESSION['user'])){ $suser=$_SESSION['user']; }else{ $suser=$user; } $newcontent="$unixtime#$user_ip#$time#$suser#$str\n"; $_SESSION['posted']=$unixtime; $towrite = $newcontent.$fcontent; $fh2 = fopen($dbfile, 'w+'); fwrite($fh2, $towrite); fclose($fh); fclose($fh2); header("Location: $self"); }else{ echo '

Errors with your post.

'; } } ?> Try out the CMXads easy chat and shout box its a free and cool text DB php script
CMXads.com Flatfile Free Script
"; }else{ echo "Chat name: "; echo $_SESSION['user']; echo " "; } //////////////////////////////////////////////// if ($captcha) { function rand_pass_string($length) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; return substr(str_shuffle($chars),0,$length); } $rannum = rand_pass_string('9'); print " $rannum "; print ''; } ///////////////////////////// ?>
"; print " "; print " "; print " "; print " "; print " "; print " "; print " "; print " "; print " "; print " "; print " "; print " "; print "
"; print " "; print " "; print " "; print " "; print ""; print " "; print " "; print " "; print ""; print ""; print "
"; ?>

"; echo "password "; echo ''; } ?>