PHP Web Host - Quality Web Hosting For All PHP Applications Just Great Software
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
tommyb
Hangin' Around


Joined: May 31, 2006
Posts: 49

PostPosted: Mon Jun 18, 2007 10:07 am Reply with quote Back to top

Hi all,

I've been working on using pspell within the forums to accomodate a spell check in forum preview (pspell must be an activated module). The file I edited to do this was
modules/Forums/posting.php
but this was with a futurenuke version of nuke (so lines maybe different)
on line 1006 of my posting.php I have
Code:


$preview_message = stripslashes(prepare_message(addslashes(unprepare_message($message)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid));


and i commented this out and underneath i wrote :
Code:


//SPELL CHECK
         $dic = pspell_new("en");
            $preview_message = eregi_replace("\[.\]","\\0 ",$message);
            $preview_message = eregi_replace("\[/.\]"," \\0",$preview_message);
             $t = explode(" ",$preview_message);
            
            foreach($t as $s){
            $skip = FALSE;
            
            if(eregi("\[.\]",$s) || eregi("\[/.\]",$s)){
            $skip = TRUE;
            }
            else{
            $skip = FALSE;
            }
            
            if($skip == FALSE){
             $c = pspell_check($dic,$s);
             if(!$c){
              $suggestions = pspell_suggest($dic, $s);
             $w .="[color=red]$s [/color] ";
               // echo "<b style=\"color:red\">$s </b> ";
                   //foreach ($suggestions as $suggestion)
                   //{
                  $w .= "[color=#f74be1][".$suggestions[0]."][/color] ";
                  // echo "<font style=\"color:red\">[".$suggestions[0]."]</font> ";
                   }
                  //}
                  else{
                  $w .= "$s ";
               //echo "$s ";
                  }   
               } //end if $skip
         $preview_message = $w;
         $preview_message = stripslashes(prepare_message(addslashes(unprepare_message($w)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid));
         //end  spell check

How I have the code at the moment only displays the 1st spelling replacement but the foreach loop can be uncommented and the line
Code:

$w .= "[color=#f74be1][".$suggestions[0]."][/color] ";

removed to display all the suggestions. The font colors can also be changed easily enough to how you want the errors to display.

Now there are a couple of things I am aware of with this.
The spell checking does have some problems with punctuation still and this seems to throw it out. Also I know that preg_replace is a lot qiucker to use then eregi_replace (I am trying to figure out how to convert it to preg_replace to make it quicker and also look at moving redundant code and code that could be made quicker as i'm still learning after all). What I was wondering was if any of the more experienced developers could take this code I have made and improve upon it themselves or at least help me improve upon it as well as looking for any obvious vunerabilities.

As always make a backup of original files before editing though I'm sure you guys now to do that Wink

thanks

ps. Wasn't too sure where to post this but it is module specific.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 15057
Location: Kansas

PostPosted: Wed Jun 20, 2007 11:48 am Reply with quote Back to top

You might want to try adding a post in For Hire and rather than reproducing this post in its entirety just reference this post.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2008 by Raven
Proud to be listed at Lobo Links Web Directory

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::

:: fisubice Theme Recoded To 100% W3C CSS & HTML 4.01 Transitional Compliance by Raven and 64bitguy ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum