Wordpress Integration mit Vanilla [Bugreport]

Veröffentlicht am 21.12.2006 | Kommentar schreiben | Tags: wordpress, vanilla

Bei der Integration von Wordpress und dem Forum Vanilla, durch die Anleitung von lussumo.com, gibt es ein paar Unsauberheiten, die ich im folgenden kurz erläutern möchte.

Es geht darum, dass das Script davon ausgeht, dass die Tabellen von Wordpress mit dem Prefix "wp_" installiert werden, intalliert man jedoch mehrere Wordpress Versionen auf einem Server und nutzt die selbe Datenbank, so heißt bei einer Installation das Prefix anders und schon funktioniert das Script nicht mehr.

Folgende Datei bearbeiten: /library/People/People.Class.Authenticator.php

Die Funktion GetIdentity() wird wie folgt geändert:

function GetIdentity() {
    global $table_prefix;
    $this->GetWordpressSettings();
   
    // Examine the cookie values for session info
    $login = ForceIncomingCookieString($this->UserCookieName, '');
    $pass = ForceIncomingCookieString($this->PassCookieName, '');
    $dbpass = '';
    $UserID = 0;
   
    if ($login != '' && $pass != '') {
        $s = "select id, user_pass from " . $table_prefix . "users where user_login = '".FormatStringForDatabaseInput($login)."'";
   
        $Result = $this->Context->Database->Execute($s,
            'WordpressAuthenticator',
            'GetIdentity',
            'An error occurred while attempting to retrieve session data.');
   
        if ($Result) {
            while ($rows = $this->Context->Database->GetRow($Result)) {
                $UserID = ForceInt($rows['id'], 0);
                $dbpass = ForceString($rows['user_pass'], '');
            }
   
            // If the double-md5d password doesn't match the one in the cookie - don't authenticate
            if (md5($dbpass) != $pass) {
                $UserID = 0;
            }
        }
    }
   
    return $UserID;
}

Die Funktion GetWordpressSettings() wird wie folgt geändert

function GetWordpressSettings() {
    global $table_prefix;
    if ($this->WordpressSettingsRetrieved == '0') {
        $siteurl = '';
        $home = '';
        $s = "select option_name, option_value from " . $table_prefix . "options where option_name = 'siteurl' or option_name = 'home'";
        $DataSet = $this->Context->Database->Execute($s,
            'WordpressAuthenticator',
            'GetCookieName',
            'An error occurred while retrieving cookie names.');
        if ($DataSet) {
            while ($rows = $this->Context->Database->GetRow($DataSet)) {
                if ($rows['option_name'] == 'siteurl') {
                    $siteurl = ForceString($rows['option_value'], '');
                } else if ($rows['option_name'] == 'home') {
                    $home = ForceString($rows['option_value'], '');
                }
            }
        }       
        $this->CookiePath = preg_replace('|https?://[^/]+|i', '', $home . '/' );
        $this->SiteCookiePath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );
        $this->CookieHash = md5($siteurl);
        $this->UserCookieName = 'wordpressuser_'.$this->CookieHash;
        $this->PassCookieName = 'wordpresspass_'.$this->CookieHash;
        $this->WordpressSettingsRetrieved = '1';
    }
}

Zurück zur Artikel-Übersicht


Kommentare

    Noch keine Kommentare vorhanden

     

*


*

Letzte Artikel

Letzte Kommentare