• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP valid_input函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中valid_input函数的典型用法代码示例。如果您正苦于以下问题:PHP valid_input函数的具体用法?PHP valid_input怎么用?PHP valid_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了valid_input函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: show_alert

 private function show_alert($index)
 {
     if (valid_input($index, VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
         return;
     } else {
         if ($index >= count($this->alerts)) {
             return;
         }
     }
     list($title, $type, $column) = $this->alerts[(int) $index];
     $cache = new cache($this->db, "dashboard_" . $this->user->username);
     if (($list = $cache->{$column}) === NULL) {
         $function = "get_" . $type . "_statistics";
         $list = $this->model->{$function}($column);
         $cache->store($column, $list, $this->settings->dashboard_page_refresh * 60 - 1);
     }
     if ($list == false) {
         return;
     }
     $this->output->open_tag("list", array("title" => $title));
     foreach ($list as $name => $item) {
         $this->output->add_tag("item", $name, array("count" => $item["today"], "change" => $item["change"]));
     }
     $this->output->close_tag();
 }
开发者ID:Wabuo,项目名称:monitor,代码行数:25,代码来源:dashboard.php


示例2: filename_oke

 public function filename_oke($file)
 {
     if (trim($file) == "") {
         return false;
     }
     return valid_input($file, VALIDATE_NUMBERS . VALIDATE_LETTERS . "/-_. ");
 }
开发者ID:shannara,项目名称:banshee,代码行数:7,代码来源:file.php


示例3: execute

 public function execute()
 {
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if ($_POST["submit_button"] == "Save collection") {
             /* Save collection
              */
             if ($this->model->save_oke($_POST) == false) {
                 $this->show_collection_form($_POST);
             } else {
                 if (isset($_POST["id"]) == false) {
                     /* Create collection
                      */
                     if ($this->model->create_collection($_POST) == false) {
                         $this->show_collection_form($_POST);
                     } else {
                         $this->show_collection_overview();
                     }
                 } else {
                     /* Update collection
                      */
                     if ($this->model->update_collection($_POST) == false) {
                         $this->show_collection_form($_POST);
                     } else {
                         $this->show_collection_overview();
                     }
                 }
             }
         } else {
             if ($_POST["submit_button"] == "Delete collection") {
                 /* Delete collection
                  */
                 if ($this->model->delete_collection($_POST["id"]) == false) {
                     $this->output->add_message("Error deleting collection.");
                     $this->show_collection_form($_POST);
                 } else {
                     $this->show_collection_overview();
                 }
             } else {
                 $this->show_collection_overview();
             }
         }
     } else {
         if ($this->page->pathinfo[2] == "new") {
             $collection = array();
             $this->show_collection_form($collection);
         } else {
             if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
                 if (($collection = $this->model->get_collection($this->page->pathinfo[2])) == false) {
                     $this->output->add_tag("result", "Collection not found.");
                 } else {
                     $this->show_collection_form($collection);
                 }
             } else {
                 $this->show_collection_overview();
             }
         }
     }
 }
开发者ID:shannara,项目名称:banshee,代码行数:58,代码来源:collection.php


示例4: save_oke

 public function save_oke($item)
 {
     $result = parent::save_oke($item);
     if (valid_input($item["name"], VALIDATE_LETTERS . "_", VALIDATE_NONEMPTY) == false) {
         $this->output->add_message("Invalid name");
         $result = false;
     }
     return $result;
 }
开发者ID:Wabuo,项目名称:monitor,代码行数:9,代码来源:language.php


示例5: execute

 public function execute()
 {
     $this->output->description = "News";
     $this->output->keywords = "news";
     $this->output->title = "News";
     $this->output->add_alternate("News", "application/rss+xml", "/news.xml");
     if ($this->page->type == "xml") {
         /* RSS feed
          */
         $rss = new RSS($this->output);
         if ($rss->fetch_from_cache("news_rss") == false) {
             $rss->title = $this->settings->head_title . " news";
             $rss->description = $this->settings->head_description;
             if (($news = $this->model->get_news(0, $this->settings->news_rss_page_size)) != false) {
                 foreach ($news as $item) {
                     $link = "/news/" . $item["id"];
                     $rss->add_item($item["title"], $item["content"], $link, $item["timestamp"]);
                 }
             }
             $rss->to_output();
         }
     } else {
         if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
             /* News item
              */
             if (($item = $this->model->get_news_item($this->page->pathinfo[1])) == false) {
                 $this->output->add_tag("result", "Unknown news item");
             } else {
                 $this->output->title = $item["title"] . " - News";
                 $item["timestamp"] = date("j F Y, H:i", strtotime($item["timestamp"]));
                 $this->output->record($item, "news");
             }
         } else {
             /* News overview
              */
             if (($count = $this->model->count_news()) === false) {
                 $this->output->add_tag("result", "Database error");
                 return;
             }
             $paging = new pagination($this->output, "news", $this->settings->news_page_size, $count);
             if (($news = $this->model->get_news($paging->offset, $paging->size)) === false) {
                 $this->output->add_tag("result", "Database error");
                 return;
             }
             foreach ($news as $item) {
                 $item["timestamp"] = date("j F Y, H:i", $item["timestamp"]);
                 $this->output->record($item, "news");
             }
             $paging->show_browse_links(7, 3);
         }
     }
 }
开发者ID:shannara,项目名称:banshee,代码行数:52,代码来源:news.php


示例6: show_item_form

 public function show_item_form($item)
 {
     if (valid_input($item["id"], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
         if (($users = $this->model->get_users($item["id"])) !== false) {
             $this->output->open_tag("users");
             foreach ($users as $user) {
                 $this->output->record($user, "user");
             }
             $this->output->close_tag();
         }
     }
     parent::show_item_form($item);
 }
开发者ID:shannara,项目名称:banshee,代码行数:13,代码来源:organisation.php


示例7: execute

 public function execute()
 {
     if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
         $this->show_collection_overview();
     } else {
         if (($collection = $this->model->get_collection($this->page->pathinfo[1])) == false) {
             $this->output->add_tag("result", "Collection not found.");
         } else {
             $this->show_collection($collection);
         }
     }
     $this->output->add_tag("title", $this->title);
     $this->output->title = $this->title;
 }
开发者ID:shannara,项目名称:banshee,代码行数:14,代码来源:collection.php


示例8: execute

 public function execute()
 {
     if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
         $this->show_album($this->page->pathinfo[1]);
     } else {
         if (valid_input($this->page->pathinfo[1], VALIDATE_NONCAPITALS . VALIDATE_NUMBERS . "_.", VALIDATE_NONEMPTY)) {
             $this->show_photo($this->page->pathinfo[1]);
         } else {
             $this->show_albums();
         }
     }
     $this->output->add_tag("title", $this->title);
     $this->output->title = $this->title;
 }
开发者ID:shannara,项目名称:banshee,代码行数:14,代码来源:photo.php


示例9: execute

 public function execute()
 {
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if ($_POST["submit_button"] == "Save message") {
             /* Update message
              */
             if ($this->model->save_oke($_POST) == false) {
                 $this->show_message_form($_POST);
             } else {
                 if ($this->model->update_message($_POST) === false) {
                     $this->output->add_message("Database error while updating message.");
                     $this->show_message_form($_POST);
                 } else {
                     $topic_id = $this->model->get_topic_id($_POST["id"]);
                     $this->user->log_action("forum message %d (topic:%d) updated", $_POST["id"], $topic_id);
                     $this->show_message_overview();
                 }
             }
         } else {
             if ($_POST["submit_button"] == "delete") {
                 /* Delete message
                  */
                 $topic_id = $this->model->get_topic_id($_POST["id"]);
                 if ($this->model->delete_message($_POST["message_id"]) == false) {
                     $this->output->add_tag("result", "Database error while deleting message.");
                 } else {
                     $this->user->log_action("forum message %d (topic:%d) deleted", $_POST["message_id"], $topic_id);
                     $this->show_message_overview();
                 }
             } else {
                 $this->show_message_overview();
             }
         }
     } else {
         if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
             /* Edit existing message
              */
             if (($message = $this->model->get_message($this->page->pathinfo[2])) == false) {
                 $this->output->add_tag("result", "Message not found.");
             } else {
                 $this->show_message_form($message);
             }
         } else {
             /* Show message overview
              */
             $this->show_message_overview();
         }
     }
 }
开发者ID:shannara,项目名称:banshee,代码行数:49,代码来源:forum.php


示例10: __construct

 public function __construct($db, $settings, $user)
 {
     $this->db = $db;
     $this->settings = $settings;
     $this->user = $user;
     /* AJAX request
      */
     if ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest" || $_GET["output"] == "ajax") {
         $this->ajax_request = true;
     }
     /* Select module
      */
     if (is_true(ENFORCE_HTTPS) && $_SERVER["HTTPS"] != "on") {
         header(sprintf("Location: https://%s%s", $_SERVER["HTTP_HOST"], $_SERVER["REQUEST_URI"]));
         header("Strict-Transport-Security: max-age=31536000");
         $this->module = ERROR_MODULE;
         $this->http_code = 301;
     } else {
         if (is_false(WEBSITE_ONLINE) && $_SERVER["REMOTE_ADDR"] != WEBSITE_ONLINE) {
             $this->module = "banshee/offline";
         } else {
             if ($this->db->connected == false) {
                 if (module_exists("setup") && is_true(DEBUG_MODE)) {
                     $this->module = "setup";
                 } else {
                     $this->module = ERROR_MODULE;
                     $this->http_code = 500;
                 }
             } else {
                 list($this->url) = explode("?", $_SERVER["REQUEST_URI"], 2);
                 $path = trim($this->url, "/");
                 if ($path == "") {
                     $page = $this->settings->start_page;
                 } else {
                     if (valid_input($path, VALIDATE_URL, VALIDATE_NONEMPTY)) {
                         $page = $path;
                     } else {
                         $this->module = ERROR_MODULE;
                         $this->http_code = 404;
                     }
                 }
                 $this->pathinfo = explode("/", $page);
             }
         }
     }
     if ($this->module === null) {
         $this->select_module($page);
     }
 }
开发者ID:shannara,项目名称:banshee,代码行数:49,代码来源:page.php


示例11: save_oke

 public function save_oke($page)
 {
     $result = true;
     if (valid_input(trim($page["url"]), VALIDATE_URL, VALIDATE_NONEMPTY) == false) {
         $this->output->add_message("URL is empty or contains invalid characters.");
         $result = false;
     } else {
         if (strpos($page["url"], "//") !== false || $page["url"][0] !== "/") {
             $this->output->add_message("Invalid URL.");
             $result = false;
         }
     }
     if (in_array($page["language"], array_keys(config_array(SUPPORTED_LANGUAGES))) == false) {
         $this->output->add_message("Language not supported.");
         $result = false;
     }
     if (($layouts = $this->get_layouts()) != false) {
         if (in_array($page["layout"], $layouts) == false) {
             $this->output->add_message("Invalid layout.");
             $result = false;
         }
     }
     if (trim($page["title"]) == "") {
         $this->output->add_message("Empty title not allowed.");
         $result = false;
     }
     if (valid_input($page["language"], VALIDATE_NONCAPITALS, 2) == false) {
         $this->output->add_message("Invalid language code.");
         $result = false;
     }
     $module = ltrim($page["url"], "/");
     $public_pages = page_to_module(config_file("public_pages"));
     $private_pages = page_to_module(config_file("private_pages"));
     if (in_array($module, $public_pages) || in_array($module, $private_pages)) {
         $this->output->add_message("URL belongs to a module.");
         $result = false;
     } else {
         $query = "select * from pages where id!=%d and url=%s limit 1";
         if (($page = $this->db->execute($query, $page["id"], $page["url"])) != false) {
             if (count($page) > 0) {
                 $this->output->add_message("URL belongs to another page.");
                 $result = false;
             }
         }
     }
     return $result;
 }
开发者ID:Wabuo,项目名称:monitor,代码行数:47,代码来源:page.php


示例12: execute

 public function execute()
 {
     if (($letters = $this->model->get_first_letters()) === false) {
         $this->output->add_tag("result", "Database error");
         return;
     }
     $this->output->description = "Dictionary";
     if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
         /* Show word
          */
         if (($word = $this->model->get_word($this->page->pathinfo[1])) == false) {
             $this->output->add_tag("result", "Unknown word");
             return;
         }
         $this->output->keywords = $word["word"] . ", dictionary";
         $this->output->title = $word["word"] . " - Dictionary";
         $first_letter = strtolower(substr($word["word"], 0, 1));
         $this->output->open_tag("word");
         $this->show_letters($letters, $first_letter);
         $this->output->record($word, "word");
         $this->output->close_tag();
     } else {
         /* Show overview
          */
         $this->output->keywords = "dictionary";
         $this->output->title = "Dictionary";
         if (valid_input($this->page->pathinfo[1], VALIDATE_NONCAPITALS, 1) == false) {
             $first_letter = $letters[0]["char"];
         } else {
             $first_letter = $this->page->pathinfo[1];
         }
         if (($words = $this->model->get_words($first_letter)) === false) {
             $this->output->add_tag("result", "Database error.");
             return;
         }
         $this->output->open_tag("overview");
         $this->show_letters($letters, $first_letter);
         $this->output->open_tag("words");
         foreach ($words as $word) {
             $this->output->record($word, "word");
         }
         $this->output->close_tag();
         $this->output->close_tag();
     }
 }
开发者ID:shannara,项目名称:banshee,代码行数:45,代码来源:dictionary.php


示例13: execute

 public function execute()
 {
     $this->output->description = "Poll";
     $this->output->keywords = "poll";
     if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
         /* Show poll
          */
         if (($poll = $this->model->get_poll($this->page->pathinfo[1])) == false) {
             $this->output->add_tag("result", "Poll not found");
         } else {
             $this->output->title = $poll["question"] . " - Poll";
             $this->output->open_tag("poll", array("id" => $poll["id"]));
             $this->output->add_tag("question", $poll["question"]);
             $votes = 0;
             foreach ($poll["answers"] as $answer) {
                 $votes += (int) $answer["votes"];
             }
             $this->output->open_tag("answers", array("votes" => $votes));
             foreach ($poll["answers"] as $answer) {
                 unset($answer["poll_id"]);
                 $answer["percentage"] = $votes > 0 ? round(100 * (int) $answer["votes"] / $votes) : 0;
                 $this->output->record($answer, "answer");
             }
             $this->output->close_tag();
             $this->output->close_tag();
         }
     } else {
         $this->show_active_poll();
         /* Poll overview
          */
         $this->output->title = "Poll";
         if (($polls = $this->model->get_polls()) === false) {
             $this->output->add_tag("result", "Database error");
         } else {
             $active_poll_id = $this->model->get_active_poll_id();
             $this->output->open_tag("polls");
             foreach ($polls as $poll) {
                 if ($poll["id"] != $active_poll_id) {
                     $this->output->add_tag("question", $poll["question"], array("id" => $poll["id"]));
                 }
             }
             $this->output->close_tag();
         }
     }
 }
开发者ID:shannara,项目名称:banshee,代码行数:45,代码来源:poll.php


示例14: save_oke

 public function save_oke($word)
 {
     $result = true;
     if (valid_input($word["word"], VALIDATE_LETTERS . VALIDATE_NUMBERS . " -_", VALIDATE_NONEMPTY) == false) {
         $this->output->add_message("Word contains invalid characters or is empty.");
         $result = false;
     } else {
         if (valid_input($word["word"], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
             $this->output->add_message("Word must contain letters.");
             $result = false;
         }
     }
     if (trim($word["short_description"]) == "") {
         $this->output->add_message("The short description cannot be empty.");
         $result = false;
     }
     return $result;
 }
开发者ID:shannara,项目名称:banshee,代码行数:18,代码来源:dictionary.php


示例15: vote

 public function vote($answer)
 {
     if ($_POST["submit_button"] != "Vote") {
         return false;
     }
     if ($answer == null) {
         return false;
     }
     $_SERVER["REQUEST_METHOD"] = "GET";
     if (valid_input($answer, VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
         return false;
     }
     if (($poll = $this->get_active_poll()) == false) {
         return false;
     }
     $today = strtotime("today 00:00:00");
     if ($poll["end"] < $today) {
         return false;
     }
     if ($this->user_may_vote($poll["id"]) == false) {
         return false;
     }
     $query = "select * from poll_answers where poll_id=%d order by answer";
     if (($answers = $this->db->execute($query, $poll["id"])) == false) {
         return false;
     }
     $answer = (int) $answer;
     if ($answer >= count($answers)) {
         return false;
     }
     $answer_id = $answers[$answer]["id"];
     setcookie("last_poll_id", (int) $poll["id"], time() + 100 * DAY);
     $_COOKIE["last_poll_id"] = (int) $poll["id"];
     /* Log selected item
      */
     if (($fp = fopen("../logfiles/poll.log", "a")) != false) {
         fputs($fp, $_SERVER["REMOTE_ADDR"] . "|" . date("Y-m-d H:i:s") . "|" . $poll["id"] . "|" . $answer . "\n");
         fclose($fp);
     }
     $query = "update poll_answers set votes=votes+1 where id=%d";
     return $this->db->query($query, $answer_id) != false;
 }
开发者ID:shannara,项目名称:banshee,代码行数:42,代码来源:poll.php


示例16: valid_signup

 public function valid_signup($data)
 {
     $result = true;
     if (strlen($data["username"]) < $this->minimum_username_length || valid_input($data["username"], VALIDATE_NONCAPITALS, VALIDATE_NONEMPTY) == false) {
         $this->output->add_message("Your username must consist of lowercase letters with a mimimum length of %d.", $this->minimum_username_length);
         $result = false;
     }
     if (valid_email($data["email"]) == false) {
         $this->output->add_message("Invalid e-mail address.");
         $result = false;
     }
     if ($result == false) {
         return false;
     }
     if (strlen($data["password"]) < $this->minimum_password_length) {
         $this->output->add_message("The length of your password must be equal or greater than %d.", $this->minimum_password_length);
         $result = false;
     }
     if (strlen($data["fullname"]) < $this->mimimum_fullname_length) {
         $this->output->add_message("The length of your name must be equal or greater than %d.", $this->mimimum_fullname_length);
         $result = false;
     }
     $query = "select * from users where username=%s or email=%s";
     if (($users = $this->db->execute($query, $data["username"], $data["email"])) === false) {
         $this->output->add_message("Error while validating sign up.");
         return false;
     }
     foreach ($users as $user) {
         if ($user["username"] == $data["username"]) {
             $this->output->add_message("This username is already taken.");
             $result = false;
         }
         if ($data["email"] != "") {
             if ($user["email"] == $data["email"]) {
                 $this->output->add_message("This e-mail address has already been used to register an account.");
                 $result = false;
             }
         }
     }
     return $result;
 }
开发者ID:shannara,项目名称:banshee,代码行数:41,代码来源:register.php


示例17: __construct

 public function __construct($output, $name, $page_size, $list_size)
 {
     $this->output = $output;
     $this->name = $name;
     $this->page_size = $page_size;
     $this->list_size = $list_size;
     if ($this->page_size <= 0 || $this->list_size <= 0) {
         $this->error = true;
         return;
     }
     /* Calculate maximum page number
      */
     $this->max_page = $this->list_size / $this->page_size;
     if ($this->max_page == floor($this->max_page)) {
         $this->max_page -= 1;
     } else {
         $this->max_page = floor($this->max_page);
     }
     /* Initialize session storage
      */
     if (is_array($_SESSION["pagination"]) == false) {
         $_SESSION["pagination"] = array();
     }
     if (isset($_SESSION["pagination"][$name]) == false) {
         $_SESSION["pagination"][$name] = $this->page;
     }
     /* Calulate page number
      */
     $this->page =& $_SESSION["pagination"][$name];
     if (isset($_GET["offset"])) {
         if (valid_input($_GET["offset"], VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
             $this->page = 0;
         } else {
             if (($this->page = (int) $_GET["offset"]) > $this->max_page) {
                 $this->page = $this->max_page;
             }
         }
     }
     #$this->output->add_css("banshee/pagination.css");
 }
开发者ID:shannara,项目名称:banshee,代码行数:40,代码来源:pagination.php


示例18: execute

 public function execute()
 {
     if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
         $offset = 0;
     } else {
         $offset = $this->page->pathinfo[2];
     }
     if (isset($_SESSION["admin_actionlog_size"]) == false) {
         $_SESSION["admin_actionlog_size"] = $this->model->get_log_size();
     }
     $paging = new pagination($this->output, "admin_actionlog", $this->settings->admin_page_size, $_SESSION["admin_actionlog_size"]);
     if (($log = $this->model->get_action_log($paging->offset, $paging->size)) === false) {
         $this->output->add_tag("result", "Error reading action log.");
         return;
     }
     $users = array($this->user->id => $this->user->username);
     $this->output->open_tag("log");
     $this->output->open_tag("list");
     foreach ($log as $entry) {
         $user_id = $entry["user_id"];
         list($user_id, $switch_id) = explode(":", $user_id);
         if (isset($users[$user_id]) == false) {
             if (($user = $this->model->get_user($user_id)) !== false) {
                 $users[$user_id] = $user["username"];
             }
         }
         if (isset($users[$switch_id]) == false) {
             if (($switch = $this->model->get_user($switch_id)) !== false) {
                 $users[$switch_id] = $switch["username"];
             }
         }
         $entry["username"] = isset($users[$user_id]) ? $users[$user_id] : "-";
         $entry["switch"] = isset($users[$switch_id]) ? $users[$switch_id] : "-";
         $this->output->record($entry, "entry");
     }
     $this->output->close_tag();
     $paging->show_browse_links();
     $this->output->close_tag();
 }
开发者ID:shannara,项目名称:banshee,代码行数:39,代码来源:action.php


示例19: tag

	/**
	 * Provides support for the ecart('cartitem') tags
	 * 
	 * @since 1.1
	 *
	 * @return mixed
	 **/
	function tag ($id,$property,$options=array()) {
		global $Ecart;

		// Return strings with no options
		switch ($property) {
			case "id": return $id;
			case "product": return $this->product;
			case "name": return $this->name;
			case "type": return $this->type;
			case "link":
			case "url":
				return ecarturl(ECART_PRETTYURLS?$this->slug:array('ecart_pid'=>$this->product));
			case "sku": return $this->sku;
		}

		$taxes = isset($options['taxes'])?value_is_true($options['taxes']):null;
		if (in_array($property,array('price','newprice','unitprice','total','tax','options')))
			$taxes = ecart_taxrate($taxes,$this->taxable,$this) > 0?true:false;

		// Handle currency values
		$result = "";
		switch ($property) {
			case "discount": $result = (float)$this->discount; break;
			case "unitprice": $result = (float)$this->unitprice+($taxes?$this->unittax:0); break;
			case "unittax": $result = (float)$this->unittax; break;
			case "discounts": $result = (float)$this->discounts; break;
			case "tax": $result = (float)$this->tax; break;
			case "total": $result = (float)$this->total+($taxes?($this->unittax*$this->quantity):0); break;
		}
		if (is_float($result)) {
			if (isset($options['currency']) && !value_is_true($options['currency'])) return $result;
			else return money($result);
		}

		// Handle values with complex options
		switch ($property) {
			case "taxrate": return percentage($this->taxrate*100,array('precision' => 1)); break;
			case "quantity":
				$result = $this->quantity;
				if ($this->type == "Donation" && $this->donation['var'] == "on") return $result;
				if (isset($options['input']) && $options['input'] == "menu") {
					if (!isset($options['value'])) $options['value'] = $this->quantity;
					if (!isset($options['options']))
						$values = "1-15,20,25,30,35,40,45,50,60,70,80,90,100";
					else $values = $options['options'];

					if (strpos($values,",") !== false) $values = explode(",",$values);
					else $values = array($values);
					$qtys = array();
					foreach ($values as $value) {
						if (strpos($value,"-") !== false) {
							$value = explode("-",$value);
							if ($value[0] >= $value[1]) $qtys[] = $value[0];
							else for ($i = $value[0]; $i < $value[1]+1; $i++) $qtys[] = $i;
						} else $qtys[] = $value;
					}
					$result = '<select name="items['.$id.']['.$property.']">';
					foreach ($qtys as $qty)
						$result .= '<option'.(($qty == $this->quantity)?' selected="selected"':'').' value="'.$qty.'">'.$qty.'</option>';
					$result .= '</select>';
				} elseif (isset($options['input']) && valid_input($options['input'])) {
					if (!isset($options['size'])) $options['size'] = 5;
					if (!isset($options['value'])) $options['value'] = $this->quantity;
					$result = '<input type="'.$options['input'].'" name="items['.$id.']['.$property.']" id="items-'.$id.'-'.$property.'" '.inputattrs($options).'/>';
				} else $result = $this->quantity;
				break;
			case "remove":
				$label = __("Remove");
				if (isset($options['label'])) $label = $options['label'];
				if (isset($options['class'])) $class = ' class="'.$options['class'].'"';
				else $class = ' class="remove"';
				if (isset($options['input'])) {
					switch ($options['input']) {
						case "button":
							$result = '<button type="submit" name="remove['.$id.']" value="'.$id.'"'.$class.' tabindex="">'.$label.'</button>'; break;
						case "checkbox":
						    $result = '<input type="checkbox" name="remove['.$id.']" value="'.$id.'"'.$class.' tabindex="" title="'.$label.'"/>'; break;
					}
				} else {
					$result = '<a href="'.href_add_query_arg(array('cart'=>'update','item'=>$id,'quantity'=>0),ecarturl(false,'cart')).'"'.$class.'>'.$label.'</a>';
				}
				break;
			case "optionlabel": $result = $this->option->label; break;
			case "options":
				$class = "";
				if (!isset($options['before'])) $options['before'] = '';
				if (!isset($options['after'])) $options['after'] = '';
				if (isset($options['show']) &&
					strtolower($options['show']) == "selected")
					return (!empty($this->option->label))?
						$options['before'].$this->option->label.$options['after']:'';

				if (isset($options['class'])) $class = ' class="'.$options['class'].'" ';
//.........这里部分代码省略.........
开发者ID:robbiespire,项目名称:paQui,代码行数:101,代码来源:Item.php


示例20: execute

 public function execute()
 {
     $this->page_size = $this->settings->admin_page_size;
     /* Work-around for the most fucking annoying crap browser in the world: IE
      */
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         foreach ($_FILES as $i => $file) {
             if ($file["type"] == "image/pjpeg") {
                 $files[$i]["type"] = "image/jpeg";
             }
         }
         if ($_POST["title"] == "" && isset($_POST["photo_album_id"])) {
             if (($count = $this->model->count_photos_in_album($_POST["photo_album_id"])) !== false) {
                 $_POST["title"] = "Photo " . ($count + 1);
             }
         }
     }
     if (isset($_SESSION["photo_album"]) == false) {
         if (($albums = $this->model->get_albums()) != false) {
             $_SESSION["photo_album"] = (int) $albums[0]["id"];
         }
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["submit_button"] == "album") {
     }
     if (($album_count = $this->model->count_albums()) === false) {
         $this->output->add_tag("result", "Error counting albums");
         return;
     } else {
         if ($album_count == 0) {
             $this->output->add_tag("result", "No albums have been created. Click <a href=\"/cms/albums\">here</a> to create a new photo album.");
             return;
         }
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if ($_POST["submit_button"] == "album") {
             /* Select album
              */
             if ($this->model->valid_album_id($_POST["album"])) {
                 $_SESSION["photo_album"] = (int) $_POST["album"];
             } else {
                 $this->output->add_system_warning("Invalid album id");
             }
             $this->show_overview();
         } else {
             if ($_POST["submit_button"] == "Upload photos") {
                 /* Upload photos
                  */
                 if ($this->model->upload_oke($_FILES["photos"]) == false) {
                     $this->show_overview();
                 } else {
                     if ($this->model->create_photos($_FILES["photos"], $_POST) == false) {
                     } else {
                         $this->show_overview();
                     }
                 }
             } else {
                 if ($_POST["submit_button"] == "Save photo") {
                     /* Save photo
                      */
                     if ($this->model->edit_oke($_POST) == false) {
                         $this->show_edit_form($_POST);
                     } else {
                         if ($this->model->update_photo($_POST) == false) {
                             $this->show_edit_form($_POST);
                         } else {
                             $this->show_overview();
                         }
                     }
                 } else {
                     if ($_POST["submit_button"] == "Delete photo") {
                         /* Delete photo
                          */
                         if ($this->model->delete_photo($_POST["id"]) == false) {
                             $this->output->add_message("Error while deleting photo.");
                             $this->show_edit_form($_POST);
                         } else {
                             $this->show_overview();
                         }
                     } else {
                         $this->show_overview();
                     }
                 }
             }
         }
     } else {
         if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
             if (($photo = $this->model->get_photo($this->page->pathin 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP valid_login函数代码示例发布时间:2022-05-23
下一篇:
PHP valid_id函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap