Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> BB2Nuke
Author Message
tommyb
Hangin' Around



Joined: May 31, 2006
Posts: 49

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

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: 17088

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

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
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> BB2Nuke

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©