/** * ビュースクリプトをインクルードする * * ただし、インクルードしたファイルにクラスが正しく定義されているかどうかは保証しない * * @access private * @param array $forward_obj 遷移定義 * @param string $forward_name 遷移名 */ public function _includeViewScript($forward_obj, $forward_name) { $view_dir = $this->getViewdir(); // view_path属性チェック if (isset($forward_obj['view_path'])) { // フルパス指定サポート $tmp_path = $forward_obj['view_path']; if (Ethna_Util::isAbsolute($tmp_path) == false) { $tmp_path = $view_dir . $tmp_path; } if (file_exists($tmp_path) == false) { $this->logger->log(LOG_WARNING, 'view_path file not found [%s] -> try default', $tmp_path); } else { include_once $tmp_path; return; } } // デフォルトチェック $view_path = $this->getDefaultViewPath($forward_name); if (file_exists($view_dir . $view_path)) { include_once $view_dir . $view_path; return; } else { $this->logger->log(LOG_DEBUG, 'default view file not found [%s]', $view_path); $view_path = null; } }
/** * ログを出力する * * @access public * @param int $level ログレベル(LOG_DEBUG, LOG_NOTICE...) * @param string $message ログメッセージ(printf形式) */ public function log($level, $message) { $args = func_get_args(); if (count($args) > 2) { array_splice($args, 0, 2); $message = vsprintf($message, $args); } $this->logger->log($level, $message); }
/** * セッションに保存されたIPアドレスとアクセス元のIPアドレスが * 同一ネットワーク範囲かどうかを判別する(16bit mask) * * @access private * @param string $src_ip セッション開始時のアクセス元IPアドレス * @param string $dst_ip 現在のアクセス元IPアドレス * @return bool true:正常終了 false:不正なIPアドレス */ public function _validateRemoteAddr($src_ip, $dst_ip) { $src = ip2long($src_ip); $dst = ip2long($dst_ip); if (($src & 0xffff0000) == ($dst & 0xffff0000)) { return true; } else { $this->logger->log(LOG_NOTICE, "session IP validation failed [%s] - [%s]", $src_ip, $dst_ip); return false; } }
/** * フォーム値に変換フィルタを適用する * * @access protected * @param mixed $value フォーム値 * @param int $filter フィルタ定義 * @return mixed 変換結果 */ public function _filter($value, $filter) { if (is_null($filter)) { return $value; } foreach (preg_split('/\\s*,\\s*/', $filter) as $f) { $method = sprintf('_filter_%s', $f); if (method_exists($this, $method) == false) { $this->logger->log(LOG_WARNING, 'filter method is not defined [%s]', $method); continue; } $value = $this->{$method}($value); } return $value; }
/** * select, radio, checkbox の選択肢を取得する * * @access protected */ public function _getSelectorOptions($af, $def, $params) { // $params, $def の順で調べる $source = null; if (isset($params['option'])) { $source = $params['option']; } else { if (isset($def['option'])) { $source = $def['option']; } } // 未定義 or 定義済みの場合はそのまま if ($source === null) { return null; } else { if (is_array($source)) { return $source; } } // 選択肢を取得 $options = null; $split = array_map("trim", explode(',', $source)); if (count($split) === 1) { // アクションフォームから取得 $method_or_property = $split[0]; if (method_exists($af, $method_or_property)) { $options = $af->{$method_or_property}(); } else { $options = $af->{$method_or_property}; } } else { // マネージャから取得 $mgr = $this->backend->getManager($split[0]); $attr_list = $mgr->getAttrList($split[1]); if (is_array($attr_list)) { foreach ($attr_list as $key => $val) { $options[$key] = $val['name']; } } } if (is_array($options) === false) { $this->logger->log(LOG_WARNING, 'selector option is not valid. [actionform=%s, option=%s]', get_class($af), $source); return null; } return $options; }
/** * 指定された $type のプラグイン (のソース) をすべて検索する * * @access public * @param string $type プラグインの種類 */ public function searchAllPluginSrc($type) { // 後で見付かったもので上書きするので $this->appid_list の逆順とする $name_list = array(); $ext = $this->ctl->getExt('php'); foreach ($this->_dirlist as $dir) { $files = glob($dir . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . "/*." . $ext); if (!$files) { $this->logger->log(LOG_DEBUG, 'cannot open plugin directory: [%s/%s]', $dir, $type); continue; } $this->logger->log(LOG_DEBUG, 'plugin directory opened: [%s]', $dir); foreach ($files as $plugin_file) { $plugin_name = substr(basename($plugin_file), 0, -strlen($ext) - 1); $name_list[$plugin_name] = 0; } } foreach (array_keys($name_list) as $name) { // 冗長だがもう一度探しなおす $this->_searchPluginSrc($type, $name); } }