/** * 起動処理です。 * ロケールの設定を行います。 */ public static function start() { // デフォルトのロケールを設定する。 if (Vizualizer_Configure::get("locale") !== null) { setlocale(LC_ALL, Vizualizer_Configure::get("locale")); } }
function execute($params) { // 実行時間制限を解除 ini_set("max_execution_time", 0); // リクエストを取得 $post = Vizualizer::request(); $images = array(); if (is_array($_FILES) && is_array($_FILES['file'])) { if ($params->check("path")) { $saveDir = VIZUALIZER_SITE_ROOT . $params->get("path"); } else { $saveDir = Vizualizer_Configure::get("upload_root") . "/images/" . sha1("site" . Vizualizer_Configure::get("site_id")) . "/file/"; } $saveFile = uniqid("DZ-"); $info = pathinfo($_FILES['file']['name']); $saveFile .= "." . $info["extension"]; if (!file_exists($saveDir)) { mkdir($saveDir, 0777, true); } move_uploaded_file($_FILES['file']['tmp_name'], $saveDir . "/" . $saveFile); ob_end_clean(); if ($params->get("type", "path") == "base") { echo $saveFile; } else { echo str_replace(VIZUALIZER_SITE_ROOT, VIZUALIZER_SUBDIR, $saveDir . "/" . $saveFile); } exit; } }
public static function start() { // セッション管理クラスをインクルード switch (Vizualizer_Configure::get("session_manager")) { case "": case false: ini_set("session.save_handler", "files"); break; case "memcached": if (strpos(Vizualizer_Configure::get("memcache"), ":") > 0) { list($host, $port) = explode(":", Vizualizer_Configure::get("memcache")); } else { $host = Vizualizer_Configure::get("memcache"); $port = 0; } if (!($port > 0)) { $port = 11211; } ini_set("session.save_handler", "memcache"); ini_set("session.save_path", $host . ":" . $port); break; default: ini_set("session.save_handler", "user"); $manager = "Vizualizer_Session_Handler_" . str_replace("SessionHandler", "", Vizualizer_Configure::get("session_manager")); Vizualizer_Session_Manager::create(new $manager()); break; } session_cache_limiter('must-revalidate'); session_start(); Vizualizer_Session::startup(); }
public static function start() { // デフォルトのタイムゾーンを設定する。 if (Vizualizer_Configure::get("timezone") !== "") { date_default_timezone_set(Vizualizer_Configure::get("timezone")); } }
function execute($params) { // 実行時間制限を解除 ini_set("max_execution_time", 0); // リクエストを取得 $post = Vizualizer::request(); $images = array(); if (is_array($_FILES)) { foreach ($_FILES as $key1 => $upload) { if ($_FILES[$key1]["error"] == 0) { $this->debug(var_export($_FILES, true)); // 保存先のディレクトリを構築 $saveDir = Vizualizer_Configure::get("upload_root") . "/images/" . sha1("site" . Vizualizer_Configure::get("site_id")) . "/" . $key1 . "/"; if (!file_exists($saveDir)) { mkdir($saveDir, 0777, true); } // 保存するファイル名を構築 $info = pathinfo($_FILES[$key1]["name"]); $saveFile = sha1(uniqid($_FILES[$key1]["name"])) . (!empty($info["extension"]) ? "." . $info["extension"] : ""); // 保存するファイルを移動 move_uploaded_file($_FILES[$key1]["tmp_name"], $saveDir . $saveFile); // 登録した内容をPOSTに設定 $post->set($key1 . "_name", $_FILES[$key1]["name"]); $post->set($key1, str_replace(VIZUALIZER_SITE_ROOT, VIZUALIZER_SUBDIR, $saveDir . $saveFile)); } } if ($params->check("reload")) { $this->reload($params->get("reload")); } } }
/** * ファクトリクラスを生成する。 * * @param string $file * @param int $expires * @return Vizualizer_Cache_Memory Vizualizer_Cache_File */ public static function create($file, $expires = 3600) { if (class_exists("Memcache") && Vizualizer_Configure::get("memcache") !== "") { return new Vizualizer_Cache_Memory(Vizualizer_Configure::get("site_domain"), $file, $expires); } else { return new Vizualizer_Cache_File(Vizualizer_Configure::get("site_domain"), $file, $expires); } }
/** * システム実行の基準時間をリセットする。 */ public static function reset() { if (Vizualizer_Configure::get("SYSTEM_CURRENT_TIME") == null) { self::$calendar = new Vizualizer_Data_Calendar(); } else { self::$calendar = new Vizualizer_Data_Calendar(strtotime(Vizualizer_Configure::get("SYSTEM_CURRENT_TIME"))); } }
/** * Smarty {inline_css} function plugin * * Type: function<br> * Name: inline_css<br> * Purpose: inline css activate plugin.<br> * * @author Naohisa Minagawa <minagawa at web-life dot co dot jp> * @param array $params parameters * @param object $smarty Smarty object * @param object $template template object * @return string null */ function smarty_function_inline_css($params, $template) { $attr = Vizualizer::attr(); $script = ""; if (!empty($params["href"])) { $script .= "<style"; if (!empty($params["type"])) { $script .= " type=\"" . $params["type"] . "\""; } else { $script .= " type=\"text/css\""; } if (!empty($params["media"])) { $script .= " media=\"" . $params["media"] . "\""; } else { $script .= " media=\"all\""; } $script .= ">\r\n"; if (substr($params["href"], 0, 7) !== "http://" && substr($params["href"], 0, 8) !== "https://") { if (substr($params["href"], 0, 1) !== "/") { $info = pathinfo($attr["templateName"]); $params["href"] = $info["dirname"] . "/" . $params["href"]; } $params["href"] = VIZUALIZER_URL . $params["href"]; } if (class_exists("Memcache") && Vizualizer_Configure::get("memcache_contents") && Vizualizer_Configure::get("memcache") !== "") { // memcacheの場合は静的コンテンツをmemcacheにキャッシュする。 $contents = Vizualizer_Cache_Factory::create("inlineCss_" . urlencode($params["href"])); $data = $contents->export(); if (empty($data)) { if (($buffer = file_get_contents($params["href"])) !== FALSE) { $contents->set("content", $buffer); } $data = $contents->export(); } $script .= $data["content"]; } else { if (($buffer = file_get_contents($params["href"])) !== FALSE) { $script .= $buffer; } } $script .= "\r\n</style>"; } return $script; }
/** * ファイルアップロード処理のメインクラス */ public function execute() { if (!empty($_FILES)) { $result = array(); $tmpName = $_FILES["file"]['tmp_name']; $result["tmp_name"] = $tmpName; if (!is_dir(Vizualizer_Configure::get("upload_root"))) { mkdir(Vizualizer_Configure::get("upload_root")); } $destName = date("Ym"); if (!is_dir(Vizualizer_Configure::get("upload_root") . DIRECTORY_SEPARATOR . $destName)) { mkdir(Vizualizer_Configure::get("upload_root") . DIRECTORY_SEPARATOR . $destName); } $destName .= DIRECTORY_SEPARATOR . date("d"); if (!is_dir(Vizualizer_Configure::get("upload_root") . DIRECTORY_SEPARATOR . $destName)) { mkdir(Vizualizer_Configure::get("upload_root") . DIRECTORY_SEPARATOR . $destName); } $result["dest_dir"] = $destName; $path = pathinfo($_FILES["file"]['name']); $fileName = $path["filename"] . "_" . date("His") . "." . $path["extension"]; $result["dest_file"] = $fileName; if (move_uploaded_file($tmpName, Vizualizer_Configure::get("upload_root") . DIRECTORY_SEPARATOR . $destName . DIRECTORY_SEPARATOR . $fileName)) { switch ($path["extension"]) { case "jpg": case "jpeg": if (Vizualizer_Configure::get("jpegoptim") !== null) { exec(Vizualizer_Configure::get("jpegoptim") . " -m100 -o -p --strip-all " . Vizualizer_Configure::get("upload_root") . DIRECTORY_SEPARATOR . $destName . DIRECTORY_SEPARATOR . $fileName); } break; case "png": if (Vizualizer_Configure::get("optipng") !== null) { exec(Vizualizer_Configure::get("optipng") . " " . Vizualizer_Configure::get("upload_root") . DIRECTORY_SEPARATOR . $destName . DIRECTORY_SEPARATOR . $fileName); } break; } $result["filename"] = $destName . DIRECTORY_SEPARATOR . $fileName; } else { $result["error"] = "Upload Failed."; } return $result; } }
public static function start() { // エラーメッセージを限定させる。 if (Vizualizer_Configure::get("display_error") != "On") { Vizualizer_Configure::set("display_error", "Off"); } if (Vizualizer_Configure::get("debug")) { if (defined("E_DEPRECATED")) { error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED); } else { error_reporting(E_ALL & ~E_STRICT); } ini_set('display_errors', Vizualizer_Configure::get("display_error")); ini_set('log_errors', 'On'); } else { error_reporting(E_ERROR); ini_set('display_errors', Vizualizer_Configure::get("display_error")); ini_set('log_errors', 'On'); } }
/** * キャッシュの内容を保存する。 */ protected function save() { if (Vizualizer_Configure::get("cache")) { if (!is_dir($this->cacheRoot)) { mkdir($this->cacheRoot); chmod($this->cacheRoot, 0777); } if (!is_dir($this->cacheRoot . DIRECTORY_SEPARATOR . $this->server)) { mkdir($this->cacheRoot . DIRECTORY_SEPARATOR . $this->server); chmod($this->cacheRoot . DIRECTORY_SEPARATOR . $this->server, 0777); } if (($fp = fopen($this->cacheRoot . DIRECTORY_SEPARATOR . $this->server . DIRECTORY_SEPARATOR . $this->file . ".php", "w+")) !== FALSE) { fwrite($fp, "<" . "?php\r\n"); foreach ($this->values as $key => $value) { fwrite($fp, '$this->values["' . $key . '"] = ' . var_export($value, TRUE) . ";\r\n"); } fclose($fp); chmod($this->cacheRoot . DIRECTORY_SEPARATOR . $this->server . DIRECTORY_SEPARATOR . $this->file . ".php", 0666); } } }
/** * PDF出力の処理を実行する。 * 出力処理にはHaruを使用します。 * @param $name モデルクラスの名前 * @param $result 出力したファイルのパスを格納するキー */ protected function output($name = "", $result = "") { // 結果のPDFを出力する。 if (!empty($name) && !empty($result)) { // 出力するPDFファイル名を生成 $saveDir = Vizualizer_Configure::get("upload_root") . "/pdf/" . sha1("site" . Vizualizer_Configure::get("site_id")) . "/" . $name . "/"; if (!file_exists($saveDir)) { mkdir($saveDir, 0777, true); } // 保存するファイル名を構築 $saveFile = sha1(uniqid()) . ".pdf"; // 保存するファイルを移動 $this->document->save($saveDir . $saveFile); // 登録した内容をPOSTに設定 $attr = Vizualizer::attr(); $attr[$result] = str_replace(VIZUALIZER_SITE_ROOT, VIZUALIZER_SUBDIR, $saveDir . $saveFile); } else { header("Content-Type: application/pdf"); $this->document->output(); exit; } }
/** * 静的コンテンツを取得する。 */ protected static function getStaticContents($filter = null) { $attr = Vizualizer::attr(); // 静的コンテンツをキャッシュする。 $contents = Vizualizer_Cache_Factory::create("content" . strtr($attr["userTemplate"] . $attr["templateName"], array("/" => "_"))); $data = $contents->export(); if (empty($data)) { if (($buffer = file_get_contents(Vizualizer_Configure::get("site_home") . $attr["userTemplate"] . $attr["templateName"])) !== FALSE) { $mtime = filemtime(Vizualizer_Configure::get("site_home") . $attr["userTemplate"] . $attr["templateName"]); $contents->set("modified", date("F d Y H:i:s.", $mtime)); if ($filter !== null) { $contents->set("data", $filter($buffer)); } else { $contents->set("data", $buffer); } } $data = $contents->export(); } header("Cache-Control: public"); header("Last-Modified: " . $data["modified"]); return $data["data"]; }
/** * Smarty {loadmodule} function plugin * * Type: function<br> * Name: loadmodule<br> * Purpose: load framework module.<br> * * @author Naohisa Minagawa <minagawa at web-life dot co dot jp> * @param array $params parameters * @param object $smarty Smarty object * @param object $template template object * @return string null */ function smarty_function_loadmodule($params, $template) { // nameパラメータは必須です。 if (empty($params['name'])) { trigger_error("loadmodule: missing name parameter", E_USER_WARNING); return; } if (!empty($params["if"])) { $result = true; $expression = '$result = ' . str_replace('_POST', '$_POST', $params["if"]) . ';'; eval($expression); if (!$result) { return; } } // パラメータを変数にコピー $name = $params['name']; // errorパラメータはエラー例外時に指定されたテンプレートに変更する。 if (isset($params["error"])) { $error = $params['error']; } else { $error = ""; } // モジュールのクラスが利用可能か調べる。 $errors = null; try { // モジュール用のクラスをリフレクション list($namespace, $class) = explode(".", $name, 2); $loader = new Vizualizer_Plugin($namespace); $object = $loader->loadModule($class); if (method_exists($object, "start")) { Vizualizer_Logger::writeDebug("=========== " . $name . " start ==========="); // 検索条件と並べ替えキー以外を無効化する。 if (isset($params["clear"]) && $params["clear"] == "1") { if (isset($params["sort_key"]) && !empty($params["sort_key"])) { $_POST = array("search" => $_POST["search"], $params["sort_key"] => $_POST[$params["sort_key"]]); } else { $_POST = array("search" => $_POST["search"]); } } if (!empty($params["key_prefix"])) { $object->key_prefix = $params["key_prefix"]; } else { $object->key_prefix = ""; } if (!empty($params["continue"])) { $object->continue = $params["continue"]; } else { $object->continue = ""; } $object->execute(new Vizualizer_Plugin_Module_Parameters($params)); Vizualizer_Logger::writeDebug("=========== " . $name . " end ==========="); } else { Vizualizer_Logger::writeAlert($name . " is not plugin module."); } } catch (Vizualizer_Exception_Invalid $e) { // 入力エラーなどの例外(ただし、メッセージリストを空にすると例外処理を行わない) Vizualizer_Logger::writeError($e->getMessage(), $e); $errors = $e->getErrors(); } catch (Vizualizer_Exception_Database $e) { // システムエラーの例外処理 Vizualizer_Logger::writeError($e->getMessage(), $e); $errors = array(Vizualizer::ERROR_TYPE_DATABASE => $e->getMessage()); } catch (Vizualizer_Exception_System $e) { // システムエラーの例外処理 Vizualizer_Logger::writeError($e->getMessage(), $e); $errors = array(Vizualizer::ERROR_TYPE_SYSTEM => $e->getMessage()); } catch (Exception $e) { // 不明なエラーの例外処理 Vizualizer_Logger::writeError($e->getMessage(), $e); $errors = array(Vizualizer::ERROR_TYPE_UNKNOWN => $e->getMessage()); } // エラー配列をスタックさせる if (is_array($errors) && !empty($errors)) { $attr = Vizualizer::attr(); // エラー用配列が配列になっていない場合は初期化 $errorData = $attr[Vizualizer::ERROR_KEY]; if (!is_array($errorData)) { $errorData = array(); } // エラー内容をマージさせる。 foreach ($errors as $key => $message) { if ($key != "" && !array_key_exists($key, $errorData)) { $errorData[$key] = $message; } } $templateEngine = $attr["template"]; if (!empty($error)) { // errorパラメータが渡っている場合はスタックさせたエラーを全て出力してエラー画面へ $templateEngine->assign("ERRORS", $errorData); unset($attr[Vizualizer::ERROR_KEY]); $info = pathinfo($error); switch ($info["extension"]) { case "php": // PHPを実行する場合、インクルードパスの最優先をテンプレートのディレクトリに設定 ini_set("include_path", Vizualizer_Configure::get("site_home") . $attr["userTemplate"] . PATH_SEPARATOR . ini_get("include_path")); $source = file_get_contents(Vizualizer_Configure::get("site_home") . $attr["userTemplate"] . DIRECTORY_SEPARATOR . $error); // 先頭のPHPタグを除去 $source = "?>" . $source; // バッファを除去 ob_end_clean(); ob_start(); eval($source); // 実行後のデータを取得し、バッファを再度除去 $source = ob_get_contents(); ob_end_clean(); ob_start(); // ソースデータをリソース化 $source = "eval:" . $source; // テンプレートを表示 $templateEngine->display($source); exit; default: $templateEngine->display($error); exit; } } else { $attr[Vizualizer::ERROR_KEY] = $errorData; } } }
/** * デバッグログを出力する。 * * @param s string $message エラーメッセージ * @param int $level 出力するデバッグレベル(最大99) */ public static function debug($message, $level = 1) { if (Vizualizer_Configure::get("debug")) { $debugLevel = Vizualizer_Configure::get("debug_level"); if ($debugLevel >= 99 || $level <= $debugLevel) { self::writeMessage(self::LOG_DEBUG, $message); } } }
public static function start() { // REQUEST URIから実際に出力するテンプレートファイルを特定 $attributes = Vizualizer::attr(); $attributes["templateName"] = str_replace("?" . $_SERVER["QUERY_STRING"], "", $_SERVER["REQUEST_URI"]); if (VIZUALIZER_SUBDIR != "") { if (strpos($attributes["templateName"], VIZUALIZER_SUBDIR) === 0) { $attributes["templateName"] = substr($attributes["templateName"], strlen(VIZUALIZER_SUBDIR)); } } // テンプレートにシンボリックリンクを作成する。 if (Vizualizer_Configure::get("site_home") !== null && Vizualizer_Configure::get("site_home") !== "") { if (!is_dir(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_contents")) { mkdir(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_contents"); } if (!file_exists(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_contents" . DIRECTORY_SEPARATOR . Vizualizer_Configure::get("site_domain"))) { Vizualizer_Logger::writeDebug("CREATE SYMBOLIC LINK : " . VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_contents" . DIRECTORY_SEPARATOR . Vizualizer_Configure::get("site_domain") . " => " . Vizualizer_Configure::get("site_home")); symlink(Vizualizer_Configure::get("site_home"), VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_contents" . DIRECTORY_SEPARATOR . Vizualizer_Configure::get("site_domain")); } if (is_writable(Vizualizer_Configure::get("site_home"))) { if (!file_exists(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "mobile")) { symlink(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "default", Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "mobile"); } if (!file_exists(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "sphone")) { symlink(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "default", Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "sphone"); } if (!file_exists(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "iphone")) { symlink(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "sphone", Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "iphone"); } if (!file_exists(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "android")) { symlink(Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "sphone", Vizualizer_Configure::get("site_home") . DIRECTORY_SEPARATOR . "android"); } } } // ユーザーのテンプレートを取得する。 if (Vizualizer_Configure::get("device") !== null) { if (Vizualizer_Configure::get("device")->isMobile()) { if (Vizualizer_Configure::get("device")->isSmartPhone()) { if (Vizualizer_Configure::get("device")->getDeviceType() == "iPhone") { $attributes["userTemplate"] = DIRECTORY_SEPARATOR . "iphone"; } elseif (Vizualizer_Configure::get("device")->getDeviceType() == "Android") { $attributes["userTemplate"] = DIRECTORY_SEPARATOR . "android"; } $attributes["userTemplate"] = DIRECTORY_SEPARATOR . "sphone"; } else { $attributes["userTemplate"] = DIRECTORY_SEPARATOR . "mobile"; } } else { $attributes["userTemplate"] = DIRECTORY_SEPARATOR . "default"; } } else { $attributes["userTemplate"] = DIRECTORY_SEPARATOR . "default"; } // テンプレートがディレクトリかどうか調べ、ディレクトリの場合はファイル名に落とす。 // 呼び出し先がディレクトリで最後がスラッシュでない場合は最後にスラッシュを補完 if (is_dir(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"])) { if (is_dir(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"]) && substr($attributes["templateName"], -1) != DIRECTORY_SEPARATOR) { $attributes["templateName"] .= DIRECTORY_SEPARATOR; } if (substr($attributes["templateName"], -1) === DIRECTORY_SEPARATOR) { if (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"] . "index.html")) { $attributes["templateName"] .= "index.html"; } elseif (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"] . "index.htm")) { $attributes["templateName"] .= "index.htm"; } elseif (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"] . "index.php")) { $attributes["templateName"] .= "index.php"; } elseif (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"] . "index.xml")) { $attributes["templateName"] .= "index.xml"; } else { // いずれも存在しない場合はダミーとしてindex.htmlを設定しておく $attributes["templateName"] .= "index.html"; } } } if (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"]) || is_dir(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"])) { if (is_dir(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"]) && substr($attributes["templateName"], -1) != DIRECTORY_SEPARATOR) { $attributes["templateName"] .= DIRECTORY_SEPARATOR; } // 呼び出し先がスラッシュで終わっている場合にはファイル名を補完 if (substr($attributes["templateName"], -1) === DIRECTORY_SEPARATOR) { if (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"] . "index.html")) { $attributes["templateName"] .= "index.html"; } elseif (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"] . "index.htm")) { $attributes["templateName"] .= "index.htm"; } elseif (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . $attributes["templateName"] . "index.xml")) { $attributes["templateName"] .= "index.xml"; } else { // いずれも存在しない場合はダミーとしてindex.htmlを設定しておく $attributes["templateName"] .= "index.html"; } } } if (substr($attributes["templateName"], -1) === DIRECTORY_SEPARATOR) { // いずれも存在しない場合はダミーとしてindex.htmlを設定しておく $attributes["templateName"] .= "index.html"; } // テンプレートの存在するパスを取得する。 define("TEMPLATE_DIRECTORY", dirname($attributes["templateName"])); }
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @author Naohisa Minagawa <*****@*****.**> * @copyright Copyright (c) 2010, Vizualizer * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 * @since PHP 5.3 * @version 1.0.0 */ use Aws\S3\S3Client; use Aws\S3\Exception\S3Exception; putenv("AWS_ACCESS_KEY_ID=" . Vizualizer_Configure::get("AWS_ACCESS_KEY_ID")); putenv("AWS_SECRET_ACCESS_KEY=" . Vizualizer_Configure::get("AWS_SECRET_ACCESS_KEY")); /** * レジからの注文データを取得するためのバッチです。 * * @package VizualizerTrade * @author Naohisa Minagawa <*****@*****.**> */ class VizualizerStock_Batch_Import extends Vizualizer_Plugin_Batch { public function getName() { return "Order Import"; } public function getFlows() { return array("importOrders");
/** * ページ出力用のメソッドをオーバーライドしています。 * 携帯のページについて、SJISに変換し、カナを半角にしています。 * * @access public */ public function display($template, $cache_id = null, $compile_id = null, $parent = null) { // キャッシュ無効にするヘッダを送信 header("P3P: CP='UNI CUR OUR'"); header("Expires: Thu, 01 Dec 1994 16:00:00 GMT"); header("Last-Modified: " . Vizualizer::now()->gmDate("D, d M Y H:i:s") . " GMT"); if (array_key_exists("HTTPS", $_SERVER) && $_SERVER['HTTPS'] == 'on') { header("Cache-Control: must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); } else { header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); } $attr = Vizualizer::attr(); $templateEngine = $attr["template"]; $templateEngine->assign("configure", Vizualizer_Configure::values()); $templateEngine->assign("post", Vizualizer::request()); $templateEngine->assign("attr", $attr); $templateEngine->assign("session", Vizualizer_Session::values()); $templateEngine->assign("sessionName", session_name()); $templateEngine->assign("sessionId", session_id()); // display template Vizualizer_Logger::writeDebug("Template Dir : " . var_export($this->template_dir, true)); if (Vizualizer_Configure::get("device")->isFuturePhone()) { // モバイルの時は出力するHTMLをデータとして取得 $content = trim($this->core->fetch($template, $cache_id, $compile_id, $parent)); // カタカナを半角にする。 $content = mb_convert_kana($content, "k"); // ソフトバンク以外の場合は、SJISエンコーディングに変換 if (Vizualizer_Configure::get("device")->getDeviceType() != "Softbank") { header("Content-Type: text/html; charset=Shift_JIS"); if (preg_match("/<meta\\s+http-equiv\\s*=\\s*\"Content-Type\"\\s+content\\s*=\\s*\"([^;]+);\\s*charset=utf-8\"\\s*\\/?>/i", $content, $params) > 0) { header("Content-Type: " . $params[1] . "; charset=Shift_JIS"); $content = str_replace($params[0], "<meta http-equiv=\"Content-Type\" content=\"" . $params[1] . "; charset=Shift_JIS\" />", $content); } else { header("Content-Type: text/html; charset=Shift_JIS"); } echo mb_convert_encoding($content, "Shift_JIS", "UTF-8"); } else { header("Content-Type: text/html; charset=UTF-8"); echo $content; } } else { header("Content-Type: text/html; charset=UTF-8"); echo trim($this->fetch($template, $cache_id, $compile_id, $parent)); } }
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false) { $attributes = Vizualizer::attr(); // 標準で使用できるパラメータを登録 $templateEngine = $attributes["template"]; $templateEngine->assign("configure", Vizualizer_Configure::values()); $templateEngine->assign("post", Vizualizer::request()); $templateEngine->assign("attr", $attributes); $templateEngine->assign("session", Vizualizer_Session::values()); $templateEngine->assign("sessionName", session_name()); $templateEngine->assign("sessionId", session_id()); // リソースの利用を判定 $prefix = substr($template, 0, strpos($template, ":")); if (ctype_alpha($prefix) && $prefix != "file") { return $this->core->fetch($template, $cache_id, $compile_id, $parent, $display); } else { if (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . "/" . $template)) { return $this->core->fetch($template, $cache_id, $compile_id, $parent, $display); } elseif (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . "/err404.html")) { return $this->core->fetch("err404.html", $cache_id, $compile_id, $parent, $display); } else { header("HTTP/1.0 404 Not Found"); echo "ファイルが存在しません。"; exit; } } }
/** * パラメータを正常化する関数 * * @param mixed $value 正常化する値 * @return mixed 正常化された値 */ protected function normalize($value) { if (is_array($value)) { foreach ($value as $i => $val) { if (Vizualizer_Configure::get("device") !== false && Vizualizer_Configure::get("device")->isFuturePhone()) { $i = mb_convert_encoding($i, "UTF-8", "Shift_JIS"); } $value[$i] = $this->normalize($val); } } else { if (get_magic_quotes_gpc() == "1") { $value = str_replace("\\\"", "\"", $value); $value = str_replace("\\\\'", "\\'", $value); $value = str_replace("\\\\", "\\", $value); } if (Vizualizer_Configure::get("device") !== false && Vizualizer_Configure::get("device")->isFuturePhone()) { $value = mb_convert_encoding($value, "UTF-8", "Shift_JIS"); } } return $value; }
/** * キャッシュの内容を保存する。 */ public function save() { if (Vizualizer_Configure::get("cache")) { $this->mem->set($this->server . ":" . $this->file, serialize($this->values), 0, $this->expires); } }
/** * 起動処理です。 * 設定ファイルを読み込み、システムの設定を行います。 */ public static function start() { // SERVER_NAMEが未設定の場合はlocalhostを割当 if (!isset($_SERVER["SERVER_NAME"])) { $serverName = getenv("PHP_SERVER_NAME"); if (!empty($serverName)) { $_SERVER["SERVER_NAME"] = $serverName; } else { $_SERVER["SERVER_NAME"] = "localhost"; } } // デフォルトの設定 Vizualizer_Configure::set("timezone", "Asia/Tokyo"); Vizualizer_Configure::set("locale", "ja_JP.UTF-8"); Vizualizer_Configure::set("select_month", array("01" => "1月", "02" => "2月", "03" => "3月", "04" => "4月", "05" => "5月", "06" => "6月", "07" => "7月", "08" => "8月", "09" => "9月", "10" => "10月", "11" => "11月", "12" => "12月")); $selectDay = array(); for ($i = 1; $i <= 31; $i++) { $selectDay[sprintf("%02d", $i)] = $i . "日"; } Vizualizer_Configure::set("select_day", array("01" => "1日", "02" => "2日", "03" => "3日", "04" => "4日", "05" => "5日", "06" => "6日", "07" => "7日", "08" => "8日", "09" => "9日", "10" => "10日", "11" => "11日", "12" => "12日", "13" => "13日", "14" => "14日", "15" => "15日", "16" => "16日", "17" => "17日", "18" => "18日", "19" => "19日", "20" => "20日", "21" => "21日", "22" => "22日", "23" => "23日", "24" => "24日", "25" => "25日", "26" => "26日", "27" => "27日", "28" => "28日", "29" => "29日", "30" => "30日", "31" => "31日")); $selectHour = array(); $selectHalfHour = array(); for ($i = 0; $i <= 23; $i++) { $hh = sprintf("%02d", $i); $selectHour[$hh . ":00"] = $i . ":00"; $selectHalfHour[$hh . ":00"] = $i . ":00"; $selectHalfHour[$hh . ":30"] = $i . ":30"; } Vizualizer_Configure::set("select_hour", array("00:00" => "0:00", "01:00" => "1:00", "02:00" => "2:00", "03:00" => "3:00", "04:00" => "4:00", "05:00" => "5:00", "06:00" => "6:00", "07:00" => "7:00", "08:00" => "8:00", "09:00" => "9:00", "10:00" => "10:00", "11:00" => "11:00", "12:00" => "12:00", "13:00" => "13:00", "14:00" => "14:00", "15:00" => "15:00", "16:00" => "16:00", "17:00" => "17:00", "18:00" => "18:00", "19:00" => "19:00", "20:00" => "20:00", "21:00" => "21:00", "22:00" => "22:00", "23:00" => "23:00")); Vizualizer_Configure::set("select_half_hour", array("00:00" => "0:00", "00:30" => "0:30", "01:00" => "1:00", "01:30" => "1:30", "02:00" => "2:00", "02:30" => "2:30", "03:00" => "3:00", "03:30" => "3:30", "04:00" => "4:00", "04:30" => "4:30", "05:00" => "5:00", "05:30" => "5:30", "06:00" => "6:00", "06:30" => "6:30", "07:00" => "7:00", "07:30" => "7:30", "08:00" => "8:00", "08:30" => "8:30", "09:00" => "9:00", "09:30" => "9:30", "10:00" => "10:00", "10:30" => "10:30", "11:00" => "11:00", "11:30" => "11:30", "12:00" => "12:00", "12:30" => "12:30", "13:00" => "13:00", "13:30" => "13:30", "14:00" => "14:00", "14:30" => "14:30", "15:00" => "15:00", "15:30" => "15:30", "16:00" => "16:00", "16:30" => "16:30", "17:00" => "17:00", "17:30" => "17:30", "18:00" => "18:00", "18:30" => "18:30", "19:00" => "19:00", "19:30" => "19:30", "20:00" => "20:00", "20:30" => "20:30", "21:00" => "21:00", "21:30" => "21:30", "22:00" => "22:00", "22:30" => "22:30", "23:00" => "23:00", "23:30" => "23:30")); Vizualizer_Configure::set("debug", true); Vizualizer_Configure::set("debug_level", 99); Vizualizer_Configure::set("display_error", "On"); Vizualizer_Configure::set("session_manager", ""); // プラグインとテンプレートのパス if (!file_exists(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "templates")) { mkdir(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "templates"); chmod(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "templates", 0777); } Vizualizer_Configure::set("site_home", VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "templates"); if (!file_exists(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_logs")) { mkdir(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_logs"); chmod(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_logs", 0777); } Vizualizer_Configure::set("log_root", VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_logs"); Vizualizer_Configure::set("upload_root", VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "upload"); Vizualizer_Configure::set("max_logs", 100); // データベースの接続設定 Vizualizer_Configure::set("database", array()); // memcacheのホスト設定 Vizualizer_Configure::set("memcache", ""); // コンテンツのmemcache利用設定 Vizualizer_Configure::set("memcache_contents", false); // JSONインターフェイス用キー設定 Vizualizer_Configure::set("json_key", ""); // Facebookのプロトコル Vizualizer_Configure::set("facebook_protocol", "http"); // FacebookのAPP ID Vizualizer_Configure::set("facebook_app_id", ""); // FacebookのAPP Secret Vizualizer_Configure::set("facebook_app_secret", ""); // サイトコード Vizualizer_Configure::set("site_code", "default"); // サイト名 Vizualizer_Configure::set("site_name", "デフォルトサイト"); // サイトドメイン Vizualizer_Configure::set("site_domain", $_SERVER["SERVER_NAME"]); // デフォルトのテンプレートエンジン Vizualizer_Configure::set("template", "Smarty"); // 設定ファイルを読み込み $siteDomain = Vizualizer_Configure::get("site_domain"); if (file_exists(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_configure" . DIRECTORY_SEPARATOR . "configure_" . $siteDomain . ".php")) { require VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_configure" . DIRECTORY_SEPARATOR . "configure_" . $siteDomain . ".php"; } else { // 一つ上の階層の設定がある場合はそちらを見に行く。 list($dummy, $siteDomain) = explode(".", $siteDomain, 2); if (!empty($siteDomain) && file_exists(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_configure" . DIRECTORY_SEPARATOR . "configure_" . $siteDomain . ".php")) { require VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_configure" . DIRECTORY_SEPARATOR . "configure_" . $siteDomain . ".php"; } elseif (file_exists(VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_configure" . DIRECTORY_SEPARATOR . "configure.php")) { // ホスト別の設定が無い場合はデフォルトの設定ファイルを使用する。 require VIZUALIZER_SITE_ROOT . DIRECTORY_SEPARATOR . "_configure" . DIRECTORY_SEPARATOR . "configure.php"; } } // データベースを初期化する。 Vizualizer_Database_Factory::initialize(Vizualizer_Configure::get("database")); }