HermanlandWiki : WikkaHack

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Wikka Hack


This hacking is for Wikka Wiki 1.1.6.5
After the applying the hack,

Hack to save UTF-8 data to MySQL properly so that it can be displayed properly via PHPAdmin SQL client.




Hacking code taken from MySQL collation charset problem and patch for NucleusCMS and WikkaWiki
Change libs\Wakka.class.php
add line 60 to 62 inclusively
add line 73 to 91 inclusively

  1.     /**
  2.      * Constructor
  3.      */
  4.     function Wakka($config)
  5.     {
  6.         $this->config = $config;
  7.         $this->dblink = @mysql_connect($this->config["mysql_host"], $this->config["mysql_user"], $this->config["mysql_password"])
  8.         if ($this->dblink)
  9.         {
  10.             $charset = $this->_getDbCharset($this->config["mysql_database"]);
  11.             if($charset)
  12.                 @mysql_query("SET NAMES '$charset'", $this->dblink);
  13.  
  14.             if (!@mysql_select_db($this->config["mysql_database"], $this->dblink))
  15.             {
  16.                 @mysql_close($this->dblink);
  17.                 $this->dblink = false;
  18.             }
  19.         }
  20.         $this->VERSION = WAKKA_VERSION;
  21.     }
  22.  
  23.     function _getDbCharset($db) {
  24.         if (!$db) {
  25.             return false;
  26.         }
  27.  
  28.         // We use a SHOW CREATE DATABASE command to show the original
  29.         // SQL character set when DB was created.
  30.         $result = mysql_query("SHOW CREATE DATABASE `$db`", $this->dblink);
  31.         if (mysql_num_rows($result) < 0 ) {
  32.             // The specified db name is wrong!
  33.             return false;
  34.         }
  35.         $dbInfo = mysql_fetch_row($result);
  36.         $pattern = '/40100 DEFAULT CHARACTER SET (\w+) /';
  37.         if ( (preg_match($pattern, $dbInfo[1], $match) > 0) ) {
  38.             return $match[1];
  39.         }
  40.         return false;
  41.     }
  42.  
  43.  
  44.     /**
  45.      * Database methods
  46.      */


Hack to display UTF-8 character properly on edit screen when re-editting



Change libs\Wakka.class.php
change line 1773

  1.         // raw page handler
  2.         elseif ($this->method == "raw")
  3.         {
  4.             header("Content-type: text/plain; charset=UTF-8");
  5.             print($this->Method($this->method));
  6.         }
  7.         // grabcode page handler
  8.         elseif ($this->method == "grabcode")


Change templates\header.php
Add line 2
Change line 14

  1. <?php
  2.      header('Content-type: text/html; charset=UTF-8');
  3.     $message = $this->GetRedirectMessage();
  4.     $user = $this->GetUser();
  5.       $site_base = $this->GetConfigValue("base_url");
  6.       if ( substr_count($site_base, 'wikka.php?wakka=') > 0 ) $site_base = substr($site_base,0,-16);
  7. ?>
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11.     <title><?php echo $this->GetWakkaName().": ".$this->PageTitle(); ?></title>
  12.     <base href="<?php echo $site_base ?>" />
  13.     <?php if ($this->GetMethod() != 'show' || $this->page["latest"] == 'N' || $this->page["tag"] == 'SandBox') echo "<meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n"; ?>
  14.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  15.     <meta name="keywords" content="<?php echo $this->GetConfigValue("meta_keywords") ?>" />


Reference
Wikka project leader page containing wikka hack to make wikka as UTF-8 capable or as an invisible wiki engine etc.

CategoryHome

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.4099 seconds