+ // bump up version number
+ setPref($data_dir,$username,'sqspell_version','0.5');
+ }
+}
+
+/** Internal functions **/
+
+/**
+ * This function is the GUI wrapper for the options page. SquirrelSpell
+ * uses it for creating all Options pages.
+ *
+ * @param string $title The title of the page to display
+ * @param string $scriptsrc This is used to link a file.js into the
+ * <script src="file.js"></script> format. This
+ * allows to separate javascript from the rest of the
+ * plugin and place it into the js/ directory.
+ * @param string $body The body of the message to display.
+ * @return void
+ */
+function sqspell_makePage($title, $scriptsrc, $body){
+ global $color, $SQSPELL_VERSION;
+
+ if (! sqgetGlobalVar('MOD', $MOD, SQ_GET) ) {
+ $MOD = 'options_main';
+ }
+
+ displayPageHeader($color, 'None');
+ echo " <br />\n";
+ /**
+ * Check if we need to link in a script.
+ */
+ if($scriptsrc) {
+ echo "<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n";
+ }
+ echo html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' ) . "\n"
+ . html_tag( 'tr', "\n" .
+ html_tag( 'td', '<strong>' . $title .'</strong>', 'center', $color[9] )
+ ) . "\n"
+ . html_tag( 'tr', "\n" .
+ html_tag( 'td', '<hr />', 'left' )
+ ) . "\n"
+ . html_tag( 'tr', "\n" .
+ html_tag( 'td', $body, 'left' )
+ ) . "\n";
+ /**
+ * Generate a nice "Return to Options" link, unless this is the
+ * starting page.
+ */
+ if ($MOD != "options_main"){
+ echo html_tag( 'tr', "\n" .
+ html_tag( 'td', '<hr />', 'left' )
+ ) . "\n"
+ . html_tag( 'tr', "\n" .
+ html_tag( 'td', '<a href="sqspell_options.php">'
+ . _("Back to "SpellChecker Options" page")
+ . '</a>',
+ 'center' )
+ ) . "\n";
+ }
+ /**
+ * Close the table and display the version.
+ */
+ echo html_tag( 'tr', "\n" .
+ html_tag( 'td', '<hr />', 'left' )
+ ) . "\n"
+ . html_tag( 'tr',
+ html_tag( 'td', 'SquirrelSpell ' . squirrelspell_version(), 'center', $color[9] )
+ ) . "\n</table>\n";
+ echo '</body></html>';
+}
+
+/**
+ * Function similar to the one above. This one is a general wrapper
+ * for the Squirrelspell pop-up window. It's called form nearly
+ * everywhere, except the check_me module, since that one is highly
+ * customized.
+ *
+ * @param string $onload Used to indicate and pass the name of a js function
+ * to call in a <body onload="function()" for automatic
+ * onload script execution.
+ * @param string $title Title of the page.
+ * @param string $scriptsrc If defined, link this javascript source page into
+ * the document using <script src="file.js"> format.
+ * @param string $body The content to include.
+ * @return void
+ */
+function sqspell_makeWindow($onload, $title, $scriptsrc, $body){
+ global $color, $SQSPELL_VERSION;
+
+ displayHtmlHeader($title,
+ ($scriptsrc ? "\n<script type=\"text/javascript\" src=\"js/$scriptsrc\"></script>\n" : ''));
+
+ echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" "
+ . "vlink=\"$color[7]\" alink=\"$color[7]\"";
+ /**
+ * Provide an onload="jsfunction()" if asked to.
+ */
+ if ($onload) {
+ echo " onload=\"$onload\"";
+ }
+ /**
+ * Draw the rest of the page.
+ */
+ echo ">\n"
+ . html_tag( 'table', "\n" .
+ html_tag( 'tr', "\n" .
+ html_tag( 'td', '<strong>' . $title . '</strong>', 'center', $color[9] )
+ ) . "\n" .
+ html_tag( 'tr', "\n" .
+ html_tag( 'td', '<hr />', 'left' )
+ ) . "\n" .
+ html_tag( 'tr', "\n" .
+ html_tag( 'td', $body, 'left' )
+ ) . "\n" .
+ html_tag( 'tr', "\n" .
+ html_tag( 'td', '<hr />', 'left' )
+ ) . "\n" .
+ html_tag( 'tr', "\n" .
+ html_tag( 'td', 'SquirrelSpell ' . squirrelspell_version(), 'center', $color[9] )
+ ) ,
+ '', '', 'width="100%" border="0" cellpadding="2"' )
+ . "</body>\n</html>\n";
+}
+
+/**
+ * Encryption function used by plugin (old format)
+ *
+ * This function does the encryption and decryption of the user
+ * dictionary. It is only available when PHP is compiled with
+ * mcrypt support (--with-mcrypt). See doc/CRYPTO for more
+ * information.
+ *
+ * @param $mode A string with either of the two recognized values:
+ * "encrypt" or "decrypt".
+ * @param $ckey The key to use for processing (the user's password
+ * in our case.
+ * @param $input Content to decrypt or encrypt, according to $mode.
+ * @return encrypted/decrypted content, or "PANIC" if the
+ * process bails out.
+ * @since 1.5.1 (sqspell 0.5)
+ * @deprecated
+ */
+function sqspell_crypto_old($mode, $ckey, $input){
+ /**
+ * Double-check if we have the mcrypt_generic function. Bail out if
+ * not so.
+ */
+ if (!function_exists('mcrypt_generic')) {
+ return 'PANIC';
+ }
+ /**
+ * Setup mcrypt routines.
+ */
+ $td = mcrypt_module_open(MCRYPT_Blowfish, "", MCRYPT_MODE_ECB, "");
+ $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
+ mcrypt_generic_init($td, $ckey, $iv);
+ /**
+ * See what we have to do depending on $mode.
+ * 'encrypt' -- Encrypt the content.
+ * 'decrypt' -- Decrypt the content.
+ */
+ switch ($mode){
+ case 'encrypt':
+ $crypto = mcrypt_generic($td, $input);
+ break;
+ case 'decrypt':
+ $crypto = mdecrypt_generic($td, $input);
+ /**
+ * See if it decrypted successfully. If so, it should contain
+ * the string "# SquirrelSpell". If not, then bail out.
+ */
+ if (!strstr($crypto, "# SquirrelSpell")){
+ $crypto='PANIC';