zabbix 文字化け調査
<td
class="normal"
style="cursor: pointer; "
onClick="
return show_popup_menu(
event,
[
[
'ã??ã?ªã?¬ã?¼',
null,
null,
{
'outer' : ['pum_oheader'],
'inner' : ['pum_iheader']
}
],
[
'ã?¤ã??ã?³ã??',
'tr_events.php?triggerid=12874',
{'tw' : '_blank'}
],
[
'ã?°ã?©ã??',
null,
null,
{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}
],
[
'Checksum of /etc/services',
'history.php?action=showgraph&itemid=19498&period=3600',
{'tw' : '_blank','sb' : 'Show graph of item \'Checksum of /etc/services\''}
]
],
170
);
"
onmouseover="
this.old_border=this.style.border;
this.style.border='1px dotted #0C0CF0'
"
onmouseout="this.style.border=this.old_border;"
>
</td>
- 表示タイプをデータとトリガに切り替えられる。
- パラメータ type が SHOW_DATA ならデータ表示
- パラメータ type が SHOW_TRIGGERS ならトリガー表示
- require_once "include/items.inc.php";
- $table=get_items_data_overview(...);
- $table->Show();
- function get_items_data_overview($groupid)
- $table=CTableInfo(S_NO_ITEMS_DEFINED);
- $items[desc,key,host]=db("select distinct hostid, host, itemid, key, type, value ... from hosts,items,left join functions left join triggers")
- foreach ($items as $descr => $ithosts) {
- $table_row=array(nbsp($descr));
- $it_ov_menu=array_merge(array(name, url, (target [tw], statusbar [sb]), css, submenu));
- $it_ov_menu=array_merge(array(S_GRAPHS,null,null,array('outer'=>array('pum_oheader'),'inner'=>array('pum_iheader')));
- name = (S_GRAPHS, S_LAST_HOUR_GRAPH, S_LAST_WEEK_GRAPH, S_LAST_MONTH_GRAPH)
- $it_ov_menu=new CPUMenu($it_ov_menu,170);
- $value_col->OnClick($it_ov_menu->GetOnActionJS());
- array_push($table_row,$value_col);
- $table->AddRow($table_row);
- }
- return $table;
- onClick="return show_popup_menu( を出力しているのは、include/classes/cpumenu.inc.php
- class CPUMenu
- function GetOnActionJS()
- return 'return show_popup_menu(event,'.zbx_jsvalue($this->items).','.zbx_jsvalue($this->width).');';
- $this->items を出力している
- function zbx_jsvalue
- phpオブジェクトから JavaScript での変数定義コードに変換
- ここでは値を取得していない。
- 別の場所で $this->items の値を出力している
- class CTag extends CObject
- function AddAction
- JavaScript での OnClick などのアクションを登録するため
- $this->options[$name] = htmlentities($str,ENT_COMPAT) となっている。
- htmlentities のデフォルト文字列は iso-8859-1
- utf-8 を指定すると良い.
- htmlentities($str,ENT_COMPAT,"utf-8") とすると文字化けは解消した。
- ユーザの文字コードは S_HTML_CHARSET として定数が定義されている
- $this->options[$name] = htmlentities($str,ENT_COMPAT,S_HTML_CHARSET) とすると文字化けが解消した。
- zabbix/php/map.php
- zabbix/php/include/maps.inc.php
- オリジナルの出力コード
ImageString($im, 2, $x_info, $y_info, $info_line, $color);
- $im: 画像オブジェクト
- 2: 文字フォント指定、最小から2つ目の大きさ
- $x_info, $y_info 文字位置指定
- $info_line 出力メッセージ
- ラスタフォント、ASCII文字のみ
- 日本語対応
- 文字列描画を ImageString から ImageTTFText に切替
- True Type Font 指定:
$font_path='/usr/local/share/ipa-ttfonts/fonts/ipag.ttf'
$info_line=iconv('utf-8','euc-jp',$info_line);
ImageTTFText( $im, 8, 0, $x_ifno, $y_info+10, $color, $font_path, $info_line);
- 国際化対応
- include/locales/ja_jp.inc.php は utf-8 で記述されている
- 出力 PNG の化け方は euc-jp 文字列を utf-8 として出力した場合に一致する。
- どこかにわざわざ出力文字列を utf-8 から euc-jp に変換している場所がある。