Esempio n. 1
0
 function execute($params)
 {
     if ($params->check("value") && $params->check("key")) {
         $post = Vizualizer::request();
         $post->set($params->get("key"), $params->get("value"));
     }
 }
Esempio n. 2
0
 function execute($params)
 {
     $post = Vizualizer::request();
     if ($post[$params->get("key")] != $post[$params->get("key2")]) {
         throw new Vizualizer_Exception_Invalid($params->get("key"), $params->get("value") . $params->get("suffix", "の入力内容が一致しません。"));
     }
 }
Esempio n. 3
0
 function execute($params)
 {
     $post = Vizualizer::request();
     if ((!isset($post[$params->get("key")]) || $post[$params->get("key")] == "") && empty($errors[$params->get("key")])) {
         throw new Vizualizer_Exception_Invalid($params->get("key"), $params->get("value") . $params->get("suffix", "が未入力です。"));
     }
 }
Esempio n. 4
0
 protected function executeImpl($type, $name, $key)
 {
     $post = Vizualizer::request();
     if ($post["delete"]) {
         // サイトデータを取得する。
         $loader = new Vizualizer_Plugin($type);
         $model = $loader->loadModel($name);
         $model->findByPrimaryKey($post[$key]);
         // データが検索された場合のみ削除処理を実施
         if ($model->{$key} > 0) {
             // トランザクションデータベースの取得
             $connection = Vizualizer_Database_Factory::begin(strtolower($type));
             try {
                 $model->delete();
                 // エラーが無かった場合、処理をコミットする。
                 Vizualizer_Database_Factory::commit($connection);
                 // 画面をリロードする。
                 if (!$this->continue) {
                     // 登録に使ったキーを無効化
                     $this->removeInput("delete");
                     $this->removeInput($key);
                     $this->reload();
                 }
             } catch (Exception $e) {
                 Vizualizer_Database_Factory::rollback($connection);
                 throw new Vizualizer_Exception_Database($e);
             }
         }
     }
 }
Esempio n. 5
0
 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"));
         }
     }
 }
Esempio n. 6
0
 function execute($params)
 {
     if ($params->check("target") && $params->check("result")) {
         $post = Vizualizer::request();
         $post->set($params->get("result"), $post[$params->get("target")]);
     }
 }
Esempio n. 7
0
 function execute($params)
 {
     // リクエストを取得
     $attr = Vizualizer::attr();
     $geocoder = new Vizualizer_Geocoding_Google($params->get("lang", "en"));
     $attr[$params->get("result", "geocoder")] = $geocoder;
 }
Esempio n. 8
0
 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;
     }
 }
Esempio n. 9
0
 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;
         }
     }
 }
Esempio n. 10
0
 function execute($params)
 {
     $post = Vizualizer::request();
     if ($params->check("key") && is_array($post[$params->check("key")])) {
         $post->set($params->get("key"), implode($params->get("delimiter"), $post[$params->check("key")]));
     }
 }
Esempio n. 11
0
 function execute($params)
 {
     // パラメータを調整
     $post = Vizualizer::request();
     $month = $post["ym"];
     if (empty($month) || preg_match("/[0-9]{4}-[0-9]{2}/", $month) == 0) {
         $month = date("Y-m");
     }
     // クエリを生成
     $loader = new Vizualizer_Plugin("stock");
     $orders = $loader->loadTable("Orders");
     $select = new Vizualizer_Query_Select($orders);
     $select->addColumn("SUBSTR(" . $orders->order_date . ", 1, 10)", "order_date");
     $select->addColumn("SUM(" . $orders->price . ")", "price");
     $select->where("order_date LIKE ?", array($month . "-%"));
     $select->group("SUBSTR(" . $orders->order_date . ", 1, 10)");
     // 生成したクエリに対して検索を実行し、結果をモデルとして取得
     $order = $loader->loadModel("Order");
     $orders = $order->queryAllBy($select);
     // 結果を属性に設定
     $attr = Vizualizer::attr();
     $attr["sales"] = $orders;
     $attr["thismonth"] = date("Y-m-01", strtotime($month . "-01"));
     $attr["nextmonth"] = date("Y-m", strtotime("+1 month", strtotime($month . "-01")));
     $attr["lastmonth"] = date("Y-m", strtotime("-1 month", strtotime($month . "-01")));
 }
Esempio n. 12
0
 function execute($params)
 {
     $post = Vizualizer::request();
     if (!empty($post[$params->get("key")]) && !ctype_digit($post[$params->get("key")])) {
         throw new Vizualizer_Exception_Invalid($params->get("key"), $params->get("value") . $params->get("suffix", "は半角数値で入力してください。"));
     }
 }
Esempio n. 13
0
 function execute($params)
 {
     $attr = Vizualizer::attr();
     $errors = $attr[Vizualizer::ERROR_KEY];
     if (!empty($errors)) {
         throw new Vizualizer_Exception_Invalid("", "");
     }
 }
Esempio n. 14
0
 function execute($params)
 {
     $post = Vizualizer::request();
     if (!empty($post[$params->get("key")])) {
         if (preg_match("/^[a-zA-Z0-9!\$&*.=^`|~#%'+\\/?_{}-]+@([a-zA-Z0-9_-]+\\.)+[a-zA-Z]{2,}\$/", $post[$params->get("key")]) == 0) {
             throw new Vizualizer_Exception_Invalid($params->get("key"), $params->get("value") . $params->get("suffix", "は正しいメールアドレスではありません。"));
         }
     }
 }
Esempio n. 15
0
 function execute($params)
 {
     $post = Vizualizer::request();
     if (!empty($post[$params->get("key")])) {
         if (Vizualizer::now()->getTime() < strtotime($post[$params->get("key")])) {
             throw new Vizualizer_Exception_Invalid($params->get("key"), $params->get("value") . $params->get("suffix", "は未来の日付です。"));
         }
     }
 }
Esempio n. 16
0
 protected function executeImpl($type, $name, $value, $result)
 {
     // サイトデータを取得する。
     $loader = new Vizualizer_Plugin($type);
     $model = $loader->loadModel($name);
     $model->setIgnoreOperator(true);
     $model->findByPrimaryKey($value);
     $attr = Vizualizer::attr();
     $attr[$result] = $model;
 }
Esempio n. 17
0
 function execute($params)
 {
     $post = Vizualizer::request();
     $extra = "";
     if ($params->get("space", "0") == "1") {
         $extra = "  ";
     }
     if (!empty($post[$params->get("key")]) && preg_match("/^[ァ-ヶー" . $extra . "]+\$/u", $post[$params->get("key")]) == 0) {
         throw new Vizualizer_Exception_Invalid($params->get("key"), $params->get("value") . $params->get("suffix", "はカタカナで入力してください。"));
     }
 }
Esempio n. 18
0
/**
 * Smarty {now} function plugin
 *
 * Type: function<br>
 * Name: uniqid<br>
 * Purpose: call vizualizer current time control function.<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_now($params, $template)
{
    $time = Vizualizer::now();
    if (!empty($params["value"])) {
        $time = $time->strToTime($params["value"]);
    }
    if (!empty($params["format"])) {
        return $time->date($params["format"]);
    }
    return $time->date("Y-m-d H:i:s");
}
Esempio n. 19
0
 function execute($params)
 {
     // リクエストを取得
     $post = Vizualizer::request();
     if ($params->check("key") || $params->check("address")) {
         $address = $params->get("address", $post[$params->get("key")]);
         $geocoder = new Vizualizer_Geocoding_Google("ja");
         $data = $geocoder->getAddressData($address);
         $attr = Vizualizer::attr();
         $attr[$params->get("result", "geocodes")] = $data["results"];
     }
 }
/**
 * Smarty {end_session} function plugin
 *
 * Type: function<br>
 * Name: end_session<br>
 * Purpose: end session 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_end_session($params, $template)
{
    // テンプレートに各種変数を割り当て
    $attr = Vizualizer::attr();
    $template = $attr["template"];
    $template->assign("configure", Vizualizer_Configure::values());
    $template->assign("post", Vizualizer::request());
    $template->assign("attr", $attr);
    $template->assign("sessionName", session_name());
    $template->assign("sessionId", session_id());
    Vizualizer_Logger::writeDebug("Page Session Ended.");
}
Esempio n. 21
0
/**
 * Smarty {input} modifier plugin
 *
 * Type: modifier<br>
 * Name: input<br>
 * Purpose: modify value prefer input<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_modifier_input($value, $key, $subkey = "")
{
    $post = Vizualizer::request();
    if ($value === null || $value === "" || isset($post[$key])) {
        if ($subkey != "" && is_array($post[$key])) {
            return $post[$key][$subkey];
        } else {
            return $post[$key];
        }
    }
    return $value;
}
Esempio n. 22
0
 function execute($params)
 {
     if ($params->check("key")) {
         $post = Vizualizer::request();
         if (!is_array($post[$params->get("key")])) {
             if ($params->check("delimiter") && !empty($post[$params->get("key")])) {
                 $post->set($params->get("key"), explode($params->get("delimiter"), $post[$params->get("key")]));
             } else {
                 $post->set($params->get("key"), array());
             }
         }
     }
 }
Esempio n. 23
0
 function execute($params)
 {
     $this->executeImpl("Stock", "Menu", "menu_id");
     $post = Vizualizer::request();
     $loader = new Vizualizer_Plugin("stock");
     $model = $loader->loadModel("Menu");
     $model->findByPrimaryKey($post["menu_id"]);
     if ($model->menu_id > 0 && $model->fixed_flg == "1") {
         $orderDetail = $loader->loadModel("OrderDetail");
         $orderDetails = $orderDetail->findAllBy(array("set_id" => $model->set_id, "choice_id" => $model->choice_id, "ne:provision_flg" => "1"));
         foreach ($orderDetails as $orderDetail) {
             $orderDetail->provision();
         }
     }
 }
Esempio n. 24
0
 function execute($params)
 {
     $post = Vizualizer::request();
     $attr = Vizualizer::attr();
     $errors = $attr[Vizualizer::ERROR_KEY];
     if (!empty($errors) && ($params->check("url") || $params->check("urlkey"))) {
         VizualizerSession::set("LAST_ERRORS", array(Vizualizer::ERROR_KEY => $errors, Vizualizer::INPUT_KEY => $post));
         if ($params->check("url")) {
             header("Location: " . $params->get("url"));
             exit;
         } else {
             header("Location: " . $post[$params->get("urlkey")]);
             exit;
         }
     }
 }
Esempio n. 25
0
 protected function executeImpl($type, $name, $primary_key)
 {
     $post = Vizualizer::request();
     if ($post["add"] || $post["save"]) {
         // サイトデータを取得する。
         $loader = new Vizualizer_Plugin($type);
         $model = $loader->loadModel($name);
         if (!empty($post[$this->key_prefix . $primary_key])) {
             $model->findByPrimaryKey($post[$this->key_prefix . $primary_key]);
             if (!($model->{$primary_key} > 0)) {
                 $model = $loader->loadModel($name, array($primary_key => $post[$this->key_prefix . $primary_key]));
             }
         }
         foreach ($post as $key => $value) {
             if (!empty($this->key_prefix)) {
                 if (substr($key, 0, strlen($this->key_prefix)) == $this->key_prefix) {
                     $key = preg_replace("/^" . $this->key_prefix . "/", "", $key);
                     $model->{$key} = $value;
                 }
             } else {
                 $model->{$key} = $value;
             }
         }
         // トランザクションの開始
         $connection = Vizualizer_Database_Factory::begin(strtolower($type));
         try {
             $model->save();
             if (!empty($this->key_prefix)) {
                 $post->set($this->key_prefix . $primary_key, $model->{$primary_key});
             } else {
                 $post->set($primary_key, $model->{$primary_key});
             }
             // エラーが無かった場合、処理をコミットする。
             Vizualizer_Database_Factory::commit($connection);
             // 画面をリロードする。
             if (!$this->continue) {
                 // 登録に使用したキーを無効化
                 $this->removeInput("add");
                 $this->removeInput("save");
                 $this->reload();
             }
         } catch (Exception $e) {
             Vizualizer_Database_Factory::rollback($connection);
             throw new Vizualizer_Exception_Database($e);
         }
     }
 }
Esempio n. 26
0
 function execute($params)
 {
     if ($params->check("result")) {
         $post = Vizualizer::request();
         if ($params->check("parent")) {
             $parent = $post[$params->get("parent")];
             if (empty($parent[$params->get("result")])) {
                 $parent[$params->get("result")] = Vizualizer::now()->date($params->get("format", "Y-m-d"));
                 $post->set($params->get("parent"), $parent);
             }
         } else {
             if (empty($post[$params->get("result")])) {
                 $post->set($params->get("result"), Vizualizer::now()->date($params->get("format", "Y-m-d")));
             }
         }
     }
 }
/**
 * Smarty {start_session} function plugin
 *
 * Type: function<br>
 * Name: start_session<br>
 * Purpose: start session 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_start_session($params, $template)
{
    // POSTにINPUT=NEWが渡った場合は、入力をクリアする。
    $post = Vizualizer::request();
    /*
     * $inputData = Vizualizer_Session::get(Vizualizer::INPUT_KEY); if
     * (is_array($inputData)) { if (array_key_exists(TEMPLATE_DIRECTORY,
     * $inputData)) { if (isset($post["INPUT"]) && $post["INPUT"] == "NEW") {
     * unset($inputData[TEMPLATE_DIRECTORY]); } //
     * INPUT_DATAのセッションの内容をPOSTに戻す。(POST優先) if
     * (is_array($inputData[TEMPLATE_DIRECTORY])) { foreach
     * ($inputData[TEMPLATE_DIRECTORY] as $key => $value) { if
     * (!isset($post[$key])) { $post[$key] = $value; } } } }
     * Vizualizer_Session::set(Vizualizer::INPUT_KEY, $inputData); }
     */
    Vizualizer_Logger::writeDebug("Page Session Started.");
}
/**
 * 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;
}
Esempio n. 29
0
 function execute($params)
 {
     $post = Vizualizer::request();
     $attr = Vizualizer::attr();
     if ($params->check("daily")) {
         $search = $post["search"];
         if (empty($search["pre:order_date"])) {
             $search["pre:order_date"] = date("Y-m-d");
             $post->set("search", $search);
         }
         $attr["thisday"] = date("Y-m-d", strtotime($search["pre:order_date"]));
         $attr["lastday"] = date("Y-m-d", strtotime("-1 day", strtotime($attr["thisday"])));
         $attr["nextday"] = date("Y-m-d", strtotime("+1 day", strtotime($attr["thisday"])));
     }
     $loader = new Vizualizer_Plugin("stock");
     $model = $loader->loadModel("Order");
     $attr["total"] = $model->summeryBy("price", $post["search"]);
     $this->executeImpl($params, "Stock", "Order", $params->get("result", "orders"));
 }
Esempio n. 30
0
 function execute($params)
 {
     $post = Vizualizer::request();
     $errors = array();
     $result = "";
     if ($params->check("year") && isset($post[$params->get("year")]) && is_numeric($post[$params->get("year")]) && $params->check("month") && isset($post[$params->get("month")]) && is_numeric($post[$params->get("month")]) && $params->check("day") && isset($post[$params->get("day")]) && is_numeric($post[$params->get("day")])) {
         $result .= sprintf("%04d", $post[$params->get("year")]);
         $result .= "-";
         $result .= sprintf("%02d", $post[$params->get("month")]);
         $result .= "-";
         $result .= sprintf("%02d", $post[$params->get("day")]);
         if (Vizualizer::now()->strToTime($result)->date("Y-m-d") != $result) {
             throw new Vizualizer_Exception_Invalid($params->get("result"), $params->get("result_name") . $params->get("suffix", "は日付の指定が正しくありません。"));
         }
         if ($params->check("hour") && isset($post[$params->get("hour")]) && is_numeric($post[$params->get("hour")]) && $params->check("minute") && isset($post[$params->get("minute")]) && is_numeric($post[$params->get("minute")])) {
             if (!empty($post[$params->get("result")])) {
                 $post[$params->get("result")] .= " ";
             }
             $result .= sprintf("%02d", $post[$params->get("hour")]);
             $result .= ":";
             $result .= sprintf("%02d", $post[$params->get("minute")]);
             if (Vizualizer::now()->strToTime($result)->date("Y-m-d H:i") != $result) {
                 throw new Vizualizer_Exception_Invalid($params->get("result"), $params->get("result_name") . $params->get("suffix", "は日付の指定が正しくありません。"));
             }
             if ($params->check("second") && isset($post[$params->get("second")]) && is_numeric($post[$params->get("second")])) {
                 $result .= ":";
                 $result .= sprintf("%02d", $post[$params->get("second")]);
                 if (Vizualizer::now()->strToTime($result)->date("Y-m-d H:i:s") != $result) {
                     throw new Vizualizer_Exception_Invalid($params->get("result"), $params->get("result_name") . $params->get("suffix", "は日付の指定が正しくありません。"));
                 }
             }
         } elseif ($params->check("hourminute") && isset($post[$params->get("hourminute")])) {
             if (!empty($result)) {
                 $result .= " ";
             }
             $result .= $post[$params->get("hourminute")];
             if (Vizualizer::now()->strToTime($result)->date("Y-m-d H:i") != $result) {
                 throw new Vizualizer_Exception_Invalid($params->get("result"), $params->get("result_name") . $params->get("suffix", "は日付の指定が正しくありません。"));
             }
         }
         $post->set($params->get("result"), $result);
     }
 }