Webサイト作成

最近一部で妙に知名度が上がっている群馬県、の、草津温泉の観光ボランティアガイド「草津ゆけむりガイド」のホームページをリニューアルしました。

草津ゆけむりガイド

地元のボランティアが同行して町の名所を案内してくれます。
お一人様500円と良心価格です。

ExpressionWeb

作成には Microsoft Expression Web を使用しました。
テンプレート埋め込みで複数ページ間のレイアウト統一やリンク維持がらくらくです。CSSもまともに扱えます。ホームページビルダーあたりでイマイチ感があったらお試しを。
付属の Super Preview が逸品。IEFirefoxSafariChromeなどでの表示のされかたの違いをピクセル単位で図示してくれます。

Expression Studio Web Professional 4.0 日本語版

ServerMan@VPSにMySQL

MySQLのインストールメモ。

インストール

# yum install mysql-server

設定の変更

# cat /etc/my.cnf
[mysql]
default-character-set=utf8

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
default-character-set=utf8
bind-address=127.0.0.1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
システムテーブルを作成する
# mysql_install_db

セキュアな初期設定

rootパスワードの設定以外は 'y' でよさげ。

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
起動
# /etc/init.d/mysqld start
Starting MySQL:                                            [  OK  ]
自動起動の設定
# chkconfig mysqld on

ServerMan@VPSにX11&Firefoxをインストール

harvester2011-04-17


自宅内や社内のネットワークから、自宅内や社内のWebサーバにアクセスすると、外部からのアクセスと異なって思うような結果にならないことがある。

出島としてお手軽なDTIのServerMan@VPSでブラウザを使えると便利なので、一式インストールを試みた。

X11のインストール

# yum groupinstall "X Window System"

vnc-serverのインストール

# yum install vnc-server
パスワードを設定
# vncpasswd
Password:
Verify:
  • 使用するユーザでパスワードを設定する
vncserverの設定変更
# vi /etc/sysconfig/vncservers

2行足す

NCSERVERS="2:username"
VNCSERVERARGS[2]="-geometry 1200x800"
vncserverの開始
# /etc/init.d/vncserver start
自動起動を設定
# chkconfig vncserver on

VNCクライアントから ":2" に接続すると、twmでXの画面が表示される。

Firefoxをインストール

# yum install firefox

日本語関連をインストール

Firefoxを起動させてみたところ、ひらがなカタカナは表示されるものの漢字が表示されなかったので、日本語関連をインストール。

# yum groupinstall "Japanese Support"

GNOMEをインストール

調子に乗ってGNOMEもインストールしてみる

# yum groupinstall "GNOME Desktop Environment"
起動スクリプトの修正
$ vi ~/.vnc/xstartup

ファイル下方の twmコメントアウトして gnome-session を追加。
ついでに日本語モードに。

#twm &
LANG=ja-JP.UTF-8
export LANG
exec gnome-session

vncserver を再起動

# /etc/init.d/vncserver restart

さすがにちょっと重いかなー。

MTEntries の tags モディファイア で変数を使ってハマる

エントリ一覧を取得する際、<MTEntries tags="@index"> のようにタグ指定すれば絞り込むことが出来る。
エントリ一覧を取得する部分を使いまわすためにテンプレート化するとき、タグ指定部分を <MTEntries tags="$var"> のようにすればテンプレートの呼び出し側から"$var"を与えることができるが、

<MTEntries tags="@$var OR @all"> 

のように指定すると、"$var"が文字列扱いになってしまい展開されない。

そんなときは、tags="" に最終的に突っ込みたい文字列全体をあらかじめ別の変数で展開しておけばよい模様。

<$mt:SetVar name="var" value="tagtext"$>
<mt:SetVarBlock name="query">@<$mt:GetVar name="var"$> OR @all</mt:SetVarBlock>
<mt:Entries tags="$query">

こうすると tags="$query" は tags="@tagtext OR @all" となる。

ややこしいなぁ。

[PHP]指定文字数で改行

  function mb_ret( $str ,$width ){
    $split = preg_split( '/(?<!^)(?!$)/u', $str );
    $line = '';
    $ret = '';
    while( count($split) > 0 ){
      $line .= array_shift($split);
      if( mb_strwidth($line) > $width or count($split) < 1 ){
        $ret .= $line."\n";
        $line = '';
      };
    };
    return $ret;
  }

PHPからXML-RPC2を使用して、MTのエントリーにカテゴリを付けようとしてどはまり。

$client = XML_RPC2_Client::create('http://example.jp/cgi-bin/mt/mt-xmlrpc.cgi', array('prefix' => 'mt.', 'encoding' => 'utf-8', 'debug' => true));
try {
$result = $client->setPostCategories($entry_id, $user, $pass, array( 'categoryId' => '200' ));
  var_dump($result);
} catch (XML_RPC2_FaultException $e) {
  var_dump($e);
} catch (Exception $e) {
  var_dump($e);
}

上記のようなコードで $entry_id のエントリにカテゴリID'200' を付加しようとしたところ

Not an ARRAY reference at /var/www/cgi-bin/mt/lib/MT/XMLRPCServer.pm line 988

こんなエラーになってしまう。

「配列のリファレンスが探してるのと違う」的なエラーのもよう。スペルミスはしてないしなーと試行錯誤すること数時間。次のようにしたらtrue(成功)が帰ってきた。

$client = XML_RPC2_Client::create('http://example.jp/cgi-bin/mt/mt-xmlrpc.cgi', array('prefix' => 'mt.', 'encoding' => 'utf-8', 'debug' => true));
try {
$result = $client->setPostCategories($entry_id, $user, $pass, array( array( 'categoryId' => '200' )));
  var_dump($result);
} catch (XML_RPC2_FaultException $e) {
  var_dump($e);
} catch (Exception $e) {
  var_dump($e);
}

'categoryId' が固定だから複数カテゴリを列挙したりisPrimaryをつけるにはこうなるのかー。。

[FileMaker][PHP] PHP Site Assistantで生成したサイトでPHPのNoticeが出る対処

FileMaker Server 11 の PHP Site Assistant で生成したサイトで、部分的にこんなNoticeが表示される場合がある。

Notice: Only variable references should be returned by reference 〜〜 LayoutImpl.php

どうもPHPのバージョンによる問題のようで、FileMakerAPIはPHP4で書かれていてWebサーバ側がPHP5だと起きるのかな?と思われる。
あれー、でもFileMakerServerのディレクトリ配下にPHPが含まれてるし、バージョン違いでの問題なんてあるのかなぁと腑に落ちない点もあるものの、以下の対処でとりあえず回避できた(と思う)。

C:\Program Files (x86)\FileMaker\FileMaker Server\Web Publishing\publishing-engine\php\FileMaker\Implementation\LayoutImpl.php (深い)
の37行目あたりを書き換える

return $Vcb5e100e =& new FileMaker_Error($this->_fm, 'Field Not Found');

↓↓

$ret = $Vcb5e100e =& new FileMaker_Error($this->_fm, 'Field Not Found');
return $ret;