AIR Wiki : WikiCodeChanges

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

Wikka Code Changes


The current version of Wikka is 1.1.6.0. The changed made to the code (for this particular installation for the AIR Wiki) apply to the installation of 1.1.6.0.

Support for multi-line table description


See Wikka:TableAction for details

In ./wikka.php, find the Action function. Then replace this line:
    preg_match("/^([A-Za-z0-9]*)\s+(.*)$/", $action, $matches);
by this:
    preg_match("/^([A-Za-z0-9]*)\s+(.*)$/s", $action, $matches);
and replace this line:
    preg_match_all("/([A-Za-z0-9]*)=\"(.*)\"/U", $vars_temp, $matches);
by this:
    preg_match_all("/([A-Za-z0-9]*)=\"(.*)\"/sU", $vars_temp, $matches);

In both cases, all we do is add an 's' after the final '/' of the regular expression, which will make it match across multiple lines.

Encoding of GeSHi blocks


Geshi is responsible for displaying the code blocks.

The default installation of Wikka displayed the error
htmlentities(): charset `646' not supported, assuming iso-8859-1 in /home/www/WWW/files/research/air/wiki/3rdparty/plugins/geshi/geshi.php
for example on the FormattingRules page.

In ./wikka.php, find the GeSHi_Highlight function. Then add the "set_encoding" line:

$geshi =& new GeSHi($sourcecode, $language, $this->config['geshi_languages_path']);    /* existing code */
$geshi->set_encoding('UTF-8');    /* set encoding (new line) */

You may follow this bug at Wikka:WikkaBugs

Smaller GeSHi blocks


In css/wikka.css, find the style for the code class. Then replace this line:
    padding: 6px 3px 13px 3px;    /* padding-bottom solves hor. scrollbar hiding single line of code in IE6 but causes vert. scrollbar... */

by this line:
    padding: 3px 3px 3px 3px;    /* though luck for loosy IE6, I'd say! */


User Groups


Implemented the relatively simple group code as described on Wikka:ACLsWithUserGroups.

In ./wikka.php, find the HasAccess function. Then change
        // aha! a user entry.
        default:
            if ($line == $user)
            {
                return !$negate;
            }

to:
        // aha! a user entry.
        default:
            if ($line == $user)
            {
                return !$negate;
            }
            // this may be a UserGroup so we check if $user is part of the group
            else if (($this->isGroupMember($user, $line)))
            {
                return !$negate;
            }

Secondly, also in wikka.php, add the isGroupMember function (after TrimACLs function for example):
    // returns true if $who is member of $group
    function isGroupMember($who, $group)
    {
        $thegroup=$this->LoadPage($group);
        if ($thegroup) {
            $search = "+".$who."+"; // In the GroupListPages, the participants logins have to be embbeded inside '+' signs
            return (boolean)(substr_count($thegroup["body"], $search));
        }
        else return false;
    }


Record IP address


in actions/usersettings.php:

after line 17, add (be carefull with the , at the end of the line):
        "remoteaddr = '".mysql_real_escape_string($_SERVER["REMOTE_ADDR"])."' ".


after line 162, add:
        "remoteaddr = '".mysql_real_escape_string($_SERVER["REMOTE_ADDR"])."', ".


In the database:
ALTER TABLE wikka_users ADD COLUMN remoteaddr varchar(64);


Simple Spam Filter


in handlers/page/addcomment.php:

Addition of two regular expressions, and split the line
$body = nl2br($this->htmlspecialchars_ent(trim($_POST["body"])));

into two lines

        $redirectmessage = "";

        $body = trim($_POST["body"]);

        if (!$body)
        {
                $redirectmessage = "Comment body was empty -- not saved!";
        }
        elseif (preg_match('/\[url=/', $body))
        {
                $redirectmessage = "Comment discarded. No BBCode is allowed in the comment (sorry, we get too much spam)";
        }
        elseif (preg_match('/<a\s+[^>]*href=/s', $body))
        {
                $redirectmessage = "Comment discarded. No HTML is allowed in the comment (sorry, we get too much spam)";
        }
        elseif (preg_match('/((http|[^\/]www).*){4}/s', $body))
        {
                $redirectmessage = "Comment discarded. Only three website references (http, www) are allowed (sorry, we get too much spam)";
        }
        else
        {
                // store new comment
                $body = nl2br($this->htmlspecialchars_ent($body));
                $this->SaveComment($this->tag, $body);
        }


Let users know they should put spam in the comments:

handlers/page/show.php, line 98:
<label for="commentbox">Add a comment to this page (no HTML allowed and max. 2 URL references):<br />


Known (unfixed) Bugs


Comments in formatted PHP code


GeSHi has a habit of adding a trailing line if the PHP code contains a comment using // or #.
For example
echo "hello world"; // How do you do?
 
This does not happen if /* */ is used for comments. For example
echo "hello world"; /* How do you do? */


Blank space after comments


If a comment is followed by a blank line, like this:

% %
comment
% %

Line


Then, this generated code will have two <br/> lines:

<div class="code">comment</div>
<br />
<br />
Line


This really should only be one <br />. Note that this is unrelated if a carriage return is used in front of the last % %.

Doubleclick Editing Preference

Doubleclick Editing User preference is not applies; even if is unchecked, all pages are doubleclickable

HTTP Result Codes

Wikka does always return a "200 OK" result code, never a "404 Not Found" or a "403 Not Allowed" code, even if those are more applicable.

Ending return bad layout

The Layout of a page looks wrong if the last character of the wiki is not a carriage return (the text with "Edit page" etc. is also indented)

Template

See if the template of these pages can be modified to (a) include the UvA menu on the left and (b) have a 'noindex" tag, since these page show up a bit too high on Google.

Categories
CategoryWiki
CategoryLogs
CategoryProcedures
CategorySysAdmin

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

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.0
Page was generated in 0.2733 seconds