darklight Posted September 3, 2007 Share Posted September 3, 2007 OK, I'm messing around with PHP. I am trying to stop it from writing bad words to a file. Can anyone help? <? $request = strip_tags($_POST['textfield3']); $engine = $_POST['engine']; //$image = $_POST['Image']; $IP = $_SERVER['REMOTE_ADDR']; $file=fopen("IPs/$IP".".htm","a+"); fwrite($file,"$IP Searched: $request<br><hr><br>"); fclose($file); if ($engine == 'Google') { if($request != 'porn' || $request != 'sex' || $request != 'fuck' || $request != 'shit') { $file=fopen("searches.txt","a+"); fwrite($file,' '."<a href=http://www.google.com/search?q=$request>$request - $engine</a>\n"); fclose($file); } header("Location: http://www.google.com/search?q=$request"); } /* if ($engine == 'Google' && $image == '0' ) { $file=fopen("searches.txt","a+"); fwrite($file,' '."<a href=http://images.google.com/images?hl=en&q=$request&btnG=Search+Images&gbv=2>$request - $engine (Images)</a>\n"); fclose($file); header("Location: http://images.google.com/images?hl=en&q=$request&btnG=Search+Images&gbv=2"); } */ elseif ($engine == 'Yahoo') { if($request != 'porn' || $request != 'sex' || $request != 'fuck' || $request != 'shit') { $file=fopen("searches.txt","a+"); fwrite($file,' '."<a href=http://search.yahoo.com/search?p=$request>$request - $engine</a>\n"); fclose($file); } header("Location: http://search.yahoo.com/search?p=$request&fr=yfp-t-471&toggle=1&cop=mss&ei=UTF-8"); } elseif ($engine == 'Ask') { if($request != 'porn' || $request != 'sex' || $request != 'fuck' || $request != 'shit') { $file=fopen("searches.txt","a+"); fwrite($file,' '."<a href=http://www.ask.com/web?q=$request&search=search&qsrc=0&o=0&l=dir>$request - $engine</a>\n"); fclose($file); } header("Location: http://www.ask.com/web?q=$request&search=search&qsrc=0&o=0&l=dir"); } elseif ($engine == 'Youtube') { if($request != 'porn' || $request != 'sex' || $request != 'fuck' || $request != 'shit') { $file=fopen("searches.txt","a+"); fwrite($file,' '."<a href=http://youtube.com/results?search_query=$request&search=Search>$request - $engine</a>\n"); fclose($file); } header("Location: http://youtube.com/results?search_query=$request&search=Search"); } elseif ($engine == 'Live') { if($request != 'porn' || $request != 'sex' || $request != 'fuck' || $request != 'shit') { $file=fopen("searches.txt","a+"); fwrite($file,' '."<a href=http://search.live.com/results.aspx?q=$request&mkt=en-us&FORM=LIVSOP&go.x=0&go.y=0&go=Search>$request - $engine</a>\n"); fclose($file); } header("Location: http://search.live.com/results.aspx?q=$request&mkt=en-us&FORM=LIVSOP&go.x=0&go.y=0&go=Search"); } elseif ($engine == 'Blockland') { if($request != 'porn' || $request != 'sex' || $request != 'fuck' || $request != 'shit') { $file=fopen("searches.txt","a+"); fwrite($file,' '."<a href=http://www.google.com/search?q=site%3Ablockland.us+$request&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a>$request - $engine</a>\n"); fclose($file); } header("Location: http://www.google.com/search?q=site%3Ablockland.us+$request&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a"); } elseif ($engine != 'Google' || $engine != 'Yahoo' || $engine != 'Ask'|| $engine != 'Youtube' || $engine != 'Live' || $engine != 'Blockland') { echo "<center>There was an error getting the engine to search. Please retry your search.</center>"; echo "<hr color = red><br>Debug: $engine<br>Debug User IP: " . $_SERVER['REMOTE_ADDR']; } ?> Link to comment https://forums.phpfreaks.com/topic/67798-noob-needs-help-with-php-d/ Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Share Posted September 3, 2007 set a words file with one pword per line and say foreach line (with fget i think) if the request equals that (preq_match or str_replace) then echo they searched soemthgin abd and die the script. Link to comment https://forums.phpfreaks.com/topic/67798-noob-needs-help-with-php-d/#findComment-340689 Share on other sites More sharing options...
Daniel0 Posted September 3, 2007 Share Posted September 3, 2007 Please use tags and not [quote] tags for code. Link to comment https://forums.phpfreaks.com/topic/67798-noob-needs-help-with-php-d/#findComment-340693 Share on other sites More sharing options...
darklight Posted September 3, 2007 Author Share Posted September 3, 2007 Now I get: Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in C:\xampp\htdocs\test\result.php on line 14 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\result.php:14) in C:\xampp\htdocs\test\result.php on line 19 Link to comment https://forums.phpfreaks.com/topic/67798-noob-needs-help-with-php-d/#findComment-340726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.