Joomler!.net - Decided on Joomla!

デル株式会社

Jboard is Multiple Board!

Home » Blog » substr
2 votes
Written by:Joomler! 4132 hits Friday, 16 May 2008 16:13

「日本語で9文字以上のユーザー名でユーザー登録すると文字化けする。」と問い合わせがあったので少しHackしてみました。

これは、Joomla!1.0.xの場合です。

これには2つの原因があります。データベースの文字数制限と、ユーザー登録時の文字数制限です。

まず、phpMyAdminでデータベースを開きます。

  1. jos_usersのテーブルを開き、テーブルの構造を表示させます。
  2. フィールド欄のusename行の操作欄に鉛筆マークの様な画像(変更)が見えますのでそれをクリックします。
  3. 長さ/値の値を25から51(今回、ここでは倍の文字数にしました。51にすることで17文字のユーザー名が登録できます。)に変更して保存します。

次にRoot/includes/joomla.phpを開き以下の行を変更します。(2826行目付近)

// check that username is not greater than 25 characters
$username = $this->username;
if ( strlen($username) > 25 ) {
    $this->username = substr( $username, 0, 25 );
}

の25の部分をデータベースと同様に51に変更します。

// check that username is not greater than 25 characters
$username = $this->username;
if ( strlen($username) > 51 ) {
    $this->username = substr( $username, 0, 51 );
}

以上で日本語17文字のユーザー名まで登録できるようになりました。

今回は、51としましたがお好みで3の倍数になるように変更されても良いのではないでしょうか。

 
2 votes
Written by:Joomler! 4587 hits Saturday, 26 April 2008 17:50

また、Fireboardのコードを変更しちゃいました。

投稿メッセージ中にコードを入力するとうちではSyntaxHighliterプラグインによってHighlightされますが、コード中に改行が入っていても<br />タグに変換されてしまうため見苦しいものになっていました。

そこで・・・。

root/components/com_fireboard/template/default/smile.class.php 内5カ所を変更・追加しました。

if ($break == "\r")
$break = "\n";

while (list(, $value) = each($content))

if ($break == "\r")
$break = "\n";
$textarea = false;
while (list(, $value) = each($content))

のように

if ((!count($innbr) && in_array($t[1], $nobr)) || in_array($t[1], $innbr))
$innbr[] = $t[1];
// Otherwise this is a closing tag

if ((!count($innbr) && in_array($t[1], $nobr)) || in_array($t[1], $innbr))
$innbr[] = $t[1];
// Otherwise this is a closing tag
if(strpos($value, 'name="code"')){
 $textarea = true;
}

のように

if (in_array(substr($value, 1), $innbr))
unset($innbr[count($innbr)]);

if (in_array(substr($value, 1), $innbr))
unset($innbr[count($innbr)]);

if(strpos($value, 'textarea')){
 $textarea = false;
}

のように

if (!count($innbr) && !$textarea)
$value = str_replace("\r", "<br />\n", $value);

if (!count($innbr) && !$textarea)
$value = str_replace("\r", "<br />\n", $value);

のように変更してみました。

この変更は、少し場当たり的と言えるかもしれませんが、一番簡単で私の目的は成し得ていますので十分と言えると思っています。

 
1 votes
Written by:Joomler! 5146 hits Tuesday, 22 January 2008 16:18

ついでにホームディレクトリが、デフォルトでは一つ上の階層になっているのを本来のホームに変更してみました。

Root/administrator/components/com_joomlaxplorer/config/conf.php

$dir_above = substr( $mosConfig_absolute_path, 0, strrpos( $mosConfig_absolute_path, $GLOBALS["separator"] ));
        if( !@is_readable($dir_above)) {
                $GLOBALS["home_dir"] = $mosConfig_absolute_path;
                // the url corresponding with the home directory: (no trailing '/')
                $GLOBALS["home_url"] = $mosConfig_live_site;
        }
        else {
                $GLOBALS["home_dir"] = $dir_above;
                // the url corresponding with the home directory: (no trailing '/')
                $GLOBALS["home_url"] = substr( $mosConfig_live_site, 0, strrpos($mosConfig_live_site, '/'));
        }

//       $dir_above = substr( $mosConfig_absolute_path, 0, strrpos( $mosConfig_absolute_path, $GLOBALS["separator"] ));
//      if( !@is_readable($dir_above)) {
                $GLOBALS["home_dir"] = $mosConfig_absolute_path;
                // the url corresponding with the home directory: (no trailing '/')
                $GLOBALS["home_url"] = $mosConfig_live_site;
//      }
//      else {
//              $GLOBALS["home_dir"] = $dir_above;
//              // the url corresponding with the home directory: (no trailing '/')
//              $GLOBALS["home_url"] = substr( $mosConfig_live_site, 0, strrpos($mosConfig_live_site, '/'));
//      }

のようにコメントアウトしただけです。

このコード上部に書かれているように1.3.0からサイトの一つ上の階層を表示するように変更されたようです。以前から気になっていたのですが、バグかと思っていました。



 

JContentPlus for Joomla!1.5 powered by Joomler!.net

joomler.net is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries.
joomler.net is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.