本文整理汇总了PHP中valid_input函数的典型用法代码示例。如果您正苦于以下问题:PHP valid_input函数的具体用法?PHP valid_input怎么用?PHP valid_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了valid_input函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: filename_oke
public function filename_oke($file)
{
if (trim($file) == "") {
return false;
}
return valid_input($file, VALIDATE_NUMBERS . VALIDATE_LETTERS . "/-_. ");
}
示例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();
}
}
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
}
示例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;
}
示例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;
}