## easymod compliant
############################################################## 
## MOD Title:    SpellingCow Spell Check
## MOD Author:   Nuttzy99 < nospam@blizzhackers.com > (Craig Nuttall) http://www.spellingcow.com
##
## MOD Description:  Once you have the free spellingcow.com service
##    working on your board, use this MOD to give your users the
##    option to automatically spell check before submitting posts.
## MOD Version:  1.0.2
## 
## Installation Level:  EASY
## Installation Time:   5 minutes
## Files To Edit:       posting.php
##                      privmsg.php
##                      includes/usercp_register.php
##                      templates/subSilver/posting_body.tpl
##                      templates/subSilver/profile_add_body.tpl
##                      language/lang_english/lang_main.php
## Included Files:      spell-gw.php
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/
############################################################## 
##
## Author Notes:
##     + As terms of service, SpellingCow.com does require appropriate link backs (this is
##         a condition of the SpellingCow service, not this GPL'd MOD.
##     + If you don't want the auto checking feature to be on by default, follow the instructions
##         in the SQL command
##     + Don't forget to follow the directions at the end of the MOD to set yourself as
##         admin and establish your site-wide dictionary!
##     + Should work with all versions phpBB
##     + installable with EasyMOD
##
############################################################## 
##
## MOD History:
##    2004-07-05 - Version 1.0.2
##         + fixes some auto checker issues
##         + first wide-scale release after MUCH testing ;-)
##    2004-06-21 - Version 1.0.0
##         + initial release
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 


#
#-----[ SQL ]---------------------------------
#
# NOTE: if you don't want the checker to be on by default, change "DEFAULT '1';" to "DEFAULT '0';"
#
ALTER TABLE `phpbb_users` ADD `user_autospell` TINYINT( 1 ) DEFAULT '1';


#
#-----[ COPY ]---------------------------------
#
# NOTE: this means place the spell-gw.php file in your phpBB root directory
#
copy spell-gw.php to spell-gw.php


#
#-----[ OPEN ]---------------------------------
#
posting.php


#
#-----[ FIND ]---------------------------------
#
	'SMILIES_STATUS' => $smilies_status,


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
	'AUTO_SPELL' => $userdata['user_autospell'],
// SPELLINGCOW - end

#
#-----[ OPEN ]---------------------------------
#
privmsg.php


#
#-----[ FIND ]---------------------------------
#
	'SMILIES_STATUS' => $smilies_status,


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
	'AUTO_SPELL' => $userdata['user_autospell'],
// SPELLINGCOW - end

#
#-----[ OPEN ]---------------------------------
#
includes/usercp_register.php


#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete line to find is:
# $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $board_config['allow_smilies'];
#
isset($HTTP_POST_VARS['allowsmilies']


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
		$spellcheck = ( isset($HTTP_POST_VARS['spellcheck']) ) ? ( ($HTTP_POST_VARS['spellcheck']) ? TRUE : 0 ) : TRUE ;
// SPELLINGCOW - end

#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete line to find is:
# $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $userdata['user_allowsmile'];
#
isset($HTTP_POST_VARS['allowsmilies']


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
		$spellcheck = ( isset($HTTP_POST_VARS['spellcheck']) ) ? ( ($HTTP_POST_VARS['spellcheck']) ? TRUE : 0 ) : $userdata['user_autospell'];
// SPELLINGCOW - end

#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete lines to find are:
# $sql = "UPDATE " . USERS_TABLE . "
# 	SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popup_pm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . "
#
$sql = "UPDATE " . USERS_TABLE
	SET


#
#-----[ IN-LINE FIND ]---------------------------------
#
user_allowsmile = $allowsmilies,


#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
 user_autospell = $spellcheck,


#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete lines to find are:
# $sql = "INSERT INTO " . USERS_TABLE . "	(user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
# 	VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popup_pm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";
#
$sql = "INSERT INTO " . USERS_TABLE
	VALUES

#
#-----[ IN-LINE FIND ]---------------------------------
#
user_allowsmile,


#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
 user_autospell,


#
#-----[ IN-LINE FIND ]---------------------------------
#
$allowsmilies,


#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
 $spellcheck,


#
#-----[ FIND ]---------------------------------
#
	$allowsmilies = $userdata['user_allowsmile'];


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
	$spellcheck = $userdata['user_autospell'];
// SPELLINGCOW - end

#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete line to find is:
#		'ALWAYS_ALLOW_SMILIES_NO' => ( !$allowsmilies ) ? 'checked="checked"' : '',
#
'ALWAYS_ALLOW_SMILIES_NO' =>


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
		'ALWAYS_SPELL_CHECK_YES' => ( $spellcheck ) ? 'checked="checked"' : '',
		'ALWAYS_SPELL_CHECK_NO' => ( !$spellcheck ) ? 'checked="checked"' : '',
// SPELLINGCOW - end

#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete line to find is:
#		'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'],
#
		'L_ALWAYS_ALLOW_SMILIES' =>


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
		'L_ALWAYS_SPELL_CHECK' => $lang['Always_spellcheck'],
// SPELLINGCOW - end

#
#-----[ OPEN ]---------------------------------
#
language/lang_english/lang_main.php


#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete line to find is:
# $lang['Always_smile'] = 'Always enable Smilies';
#
$lang['Always_smile']


#
#-----[ AFTER, ADD ]---------------------------------
#
// SPELLINGCOW - begin
$lang['Always_spellcheck'] = 'Always check Spelling before posting';
// SPELLINGCOW - end

#
#-----[ OPEN ]---------------------------------
#
templates/subSilver/posting_body.tpl


#
#-----[ FIND ]---------------------------------
#
function checkForm() {
	formErrors = false;    


#
#-----[ BEFORE, ADD ]---------------------------------
#

// SPELLINGCOW - begin
function auto_check_spelling()
{
	// if we are auto checking, set value to 2 so the submit from checkForm will fail; open the checker window
	if (document.post.auto_spell_check.value == 1)
	{
		document.post.auto_spell_check.value = 2 ;
		window.open('spell-gw.php?mode=load&form=post&auto=check&source=message&button=post&type=phpBB', '_spellcheck', 'HEIGHT=484,resizable=yes,scrollbars=yes,WIDTH=595');
	}
}
// SPELLINGCOW - end


#
#-----[ AFTER, ADD ]---------------------------------
#

// SPELLINGCOW - begin
	// if we set value to 2, then that means we are auto spell checking, so fail
	if (document.post.auto_spell_check.value == 2)
	{
		// reset our value
		document.post.auto_spell_check.value = 1 ;
		return false;
	}
// SPELLINGCOW - end

#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete lines to find are:
#		  <tr>
#			<td colspan="9"><span class="gen">
#			  <textarea name="message" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3" class="post" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">{MESSAGE}</textarea>
#			  </span></td>
#		  </tr>
#
{MESSAGE}
</td>
</tr>


#
#-----[ AFTER, ADD ]---------------------------------
#
# NOTE: for a standard install, you won't need to modify these lines at all
#

		<!-- =======================================================================
			Adjust the spellcheck_data line to use SpellingCow with ANY form and 
			ANY textarea or textbox.  Simply adjust the "value" data as follows:
				form:   Enter the form name to check.  Enter only one form name.
				source: Enter the form item to be checked.  Later versions will
						allow more than one item to be checked!
				button: Enter the name of the submit button for the form
				type:   phpBB, vB, IPB, or other - not used yet, but perhaps
						will be in the near future

			The following is optimized for a standard phpBB install but you can
				make any changes desired regarding style or to accommodate MODs
		     =======================================================================  -->
<!-- SPELL CHECKER -->
		  <tr align="center">
			<td colspan="4">
				<input type="hidden" name="auto_spell_check" value="{AUTO_SPELL}">
				<input type="button" name="spellcheck" class="liteoption" value="Spell Check" 
					onClick="window.open('spell-gw.php?mode=load&form=post&source=message&button=post&type=phpBB', '_spellcheck', 'HEIGHT=484,resizable=yes,scrollbars=yes,WIDTH=595');"><br>

				<style type="text/css"><!-- .spellcow, a.spellcow { font-size : 8px; color : #FFFFFF; } --></style>
				<!-- Removal of the following line may result in suspension of the service by SpellingCow.  Come on, linking back to us is not asking much but means a lot to us.  Thanks! ;-) -->
				<span class="spellcow">by <a href="http://www.spellingcow.com" target="_blank" class="spellcow">SpellingCow.com</a><a href="spell-gw.php" target="_blank" class="spellcow">.</a><br>
			</td>
		  </tr>
<!-- SPELL CHECKER -->

#
#-----[ FIND ]---------------------------------
#
#   NOTE - the complete line to find is:
# <td class="catBottom" colspan="2" align="center" height="28"> {S_HIDDEN_FORM_FIELDS}<input type="submit" tabindex="5" name="preview" class="mainoption" value="{L_PREVIEW}" onclick="javascript:preview_press()" />&nbsp;<input type="submit" accesskey="s" tabindex="6" name="post" class="mainoption" value="{L_SUBMIT}" /></td>
#
value="{L_SUBMIT}"


#
#-----[ IN-LINE FIND ]---------------------------------
#
value="{L_SUBMIT}"


#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
 onclick="javascript:auto_check_spelling()"


#
#-----[ OPEN ]---------------------------------
#
templates/subSilver/profile_add_body.tpl


#
#-----[ FIND ]---------------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_BOARD_LANGUAGE}:</span></td>


#
#-----[ BEFORE, ADD ]---------------------------------
#
<!-- SPELLINGCOW begin -->
	<tr> 
	  <td class="row1"><span class="gen">{L_ALWAYS_SPELL_CHECK}:</span></td>
	  <td class="row2"> 
		<input type="radio" name="spellcheck" value="1" {ALWAYS_SPELL_CHECK_YES} />
		<span class="gen">{L_YES}</span>&nbsp;&nbsp; 
		<input type="radio" name="spellcheck" value="0" {ALWAYS_SPELL_CHECK_NO} />
		<span class="gen">{L_NO}</span></td>
	</tr>
<!-- SPELLINGCOW end -->

#
# The follow is optional, but would be very much appreciated.  It would really help support the project, thanks!
#

#
#-----[ OPEN ]---------------------------------
#
templates/subSilver/overall_footer.tpl


#
#-----[ FIND ]---------------------------------
#
#   adding this is optional but would be appreciated by SpellingCow ;-)
#   NOTE - the complete line to find is:
# Powered by <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB</a> {PHPBB_VERSION} &copy; 2001, 2002 phpBB Group<br />{TRANSLATION_INFO}</span></div>
#
{PHPBB_VERSION} &copy


#
#-----[ IN-LINE FIND ]---------------------------------
#
phpBB Group


#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
 :: Spelling by <a href="http://www.spellingcow.com/" target="_phpbb" class="copyright">SpellingCow</a><a href="spell-gw.php" target="_phpbb" class="copyright">.</a>


#
# All installed!  Now go ahead and set yourself as Admin so that you can setup your site-wide dictionary!  The site-wide
#   dictionary will prevent your users from being bothered with the lingo common to your site.
#
# To control the site-wide dictionary, a SpellingCow.com account must be set as the designated admin account. Once you have
#   registered a SpellingCow.com account, edit the spell-gw.php file you installed on your site. Find the line that reads
#   "define('ADMIN_USERNAME', 'insert-admin-username') ;" and change "insert-admin-username" to whatever your
#   SpellingCow.com account name is. After logging in, you will then be known as the admin for your site. You may also 
#   modify this entry at any time to designate a different account to act as admin.  Enjoy!
#


#
#-----[ SAVE/CLOSE ALL FILES ]---------------------------------
#
# EoM
