本文整理汇总了PHP中scrub函数的典型用法代码示例。如果您正苦于以下问题:PHP scrub函数的具体用法?PHP scrub怎么用?PHP scrub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scrub函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Sort
/**
* Sorts the Song List based on title
* @method Sort
* @return (SongLinkPlus_Pvm array)
*/
public function Sort()
{
function scrub($val)
{
return trim(preg_replace('/\\s+/', ' ', preg_replace('/\\W/', ' ', strtolower($val))));
}
$tieBreaker = 0;
$songsListRekeyed = array();
$titlesList = array();
$titleKey = '';
foreach ($this->SongList as $song) {
$titleKey = scrub($song->Title);
if (!isset($temp[$titleKey])) {
$titleKey .= ' _' . $tieBreaker . '_ugs87!';
$tieBreaker++;
}
$titlesList[] = $titleKey;
$songsListRekeyed[$titleKey] = $song;
}
sort($titlesList);
$this->SongList = array();
foreach ($titlesList as $key) {
$this->SongList[] = $songsListRekeyed[$key];
}
return $this->SongList;
}
示例2: scrub
/**
* Sanitizes data and optionally trims strings.
*
* All form data or any data coming from the client should be sanitized and escaped before storage or outputting to the client.
* PHP's htmlspecialchars function prevents cross-side-scripting (XSS) by converting special characters, such as the opening and
* closing carats in the <script> tag, to HTML entities.
*
* @param mixed [$data] What you want to sanitize
* @param boolean [$trim_strings] Whether or not the function should trim strings found in $data
* @return mixed sanitized $data
*/
function scrub($data, $trim_strings = false)
{
// base case
if (!isset($data)) {
return $data;
} else {
if (is_string($data)) {
if ($trim_strings) {
$data = trim($data);
}
return htmlspecialchars($data);
} else {
if (is_array($data)) {
$keys = array_keys($data);
for ($i = 0, $l = count($keys); $i < $l; $i++) {
$data[$keys[$i]] = scrub($data[$keys[$i]], $trim_strings);
}
return $data;
} else {
if (is_object($data)) {
foreach ($data as $property => $value) {
$data->{$property} = scrub($value, $trim_strings);
}
}
}
}
}
// other, e.g., boolean, number
return $data;
}
示例3: scrub
function scrub($data)
{
if (is_array($data) || is_object($data)) {
$output = array();
foreach ($data as $key => &$value) {
$outkey = utf8_encode($key);
if (is_array($value) || is_object($value)) {
$outval = scrub($value);
} else {
$enc = mb_detect_encoding($value);
if ($enc != "UTF-8") {
$outval = utf8_encode($value);
}
}
$output[$outkey] = $outval;
}
} else {
$output = $data;
}
return $output;
}
示例4: scrub
Copyright 2008 John-Paul Gignac
This file is part of Fossfactory-src.
Fossfactory-src is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fossfactory-src is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Fossfactory-src. If not, see <http://www.gnu.org/licenses/>.
*/
$id = scrub($_REQUEST['id']);
$submissionid = intval($_REQUEST['submissionid']);
$accept = scrub($_REQUEST['accept']);
if ($accept == 'true') {
list($rc, $err) = ff_acceptsubmission($username, $submissionid);
} elseif ($accept == 'false') {
list($rc, $err) = ff_rejectsubmission($username, $submissionid, $_REQUEST["rejectreason"], 0);
} elseif ($accept == 'prejudice') {
list($rc, $err) = ff_rejectsubmission($username, $submissionid, '', 1);
}
header("Location: " . projurl($id, "tab=submissions"));
?>
示例5: list
list($rc, $projinfo) = ff_getprojectinfo($id);
if ($rc == 0 && $projinfo['lead'] !== '' && $projinfo['lead'] === $username) {
$quiet = true;
}
}
list($rc, $postid) = ff_createpost("{$topicid}", "{$_REQUEST['subject']}", $body, $parent, $_REQUEST["anonymous"] ? '' : $username, '', $attachments, $_REQUEST["watchthread"] ? 1 : 0, projurl($id), $quiet);
if ($rc == 0 && $quiet) {
// Automatically accept the change proposal
header("Location: handlechange.php?" . "project={$id}&post={$postid}&accept=1");
exit;
}
header("Location: " . projurl($id, "post={$postid}" . ($parent ? "#p{$parent}" : "")));
exit;
}
} elseif (substr($topicid, 0, 5) == 'spect') {
$disputeid = scrub($_REQUEST['disputeid']);
$id = substr($topicid, 5);
if (isset($_REQUEST["subject"])) {
list($rc, $postid) = ff_createpost("{$topicid}", "{$_REQUEST['subject']}", "{$_REQUEST['body']}", $parent, $_REQUEST["anonymous"] ? '' : $username, '', $attachments, $_REQUEST["watchthread"] ? 1 : 0, "dispute.php?id={$disputeid}");
header("Location: dispute.php?id={$disputeid}&post={$postid}" . ($parent ? "#p{$parent}" : ""));
exit;
}
} elseif (substr($topicid, 0, 4) == 'proj') {
$id = substr($topicid, 4);
if ($username !== '' && $_REQUEST["watchproject"]) {
al_createwatch('$id-news', $username);
}
if (isset($_REQUEST["subject"])) {
list($rc, $postid) = ff_createpost("{$topicid}", "{$_REQUEST['subject']}", "{$_REQUEST['body']}", $parent, $_REQUEST["anonymous"] ? '' : $username, '', $attachments, $_REQUEST["watchthread"] ? 1 : 0, projurl($id));
header("Location: " . projurl($id, "post={$postid}" . ($parent ? "#p{$parent}" : "")));
exit;
示例6: error_log
error_log(date("Y-m-d H:i:s ") . "Successful PDT: {$info['txn_id']} {$info['txn_type']} {$err}\n{$dump}\n", 3, "{$GLOBALS['DATADIR']}/ipn-errors.log");
$custom = explode("/", $info["custom"]);
if ($info["txn_type"] === 'subscr_payment') {
if ($custom[4]) {
header("Location: " . projurl(urlencode($custom[4])));
} else {
header("Location: account.php?tab=subscription");
}
exit;
}
list($rc, $currencies) = ff_currencies();
if ($rc) {
print "Error fetching currencies: {$rc} {$currencies}";
exit;
}
$code = $info["mc_currency"];
$mult = $currencies[$code]["multiplier"];
$gross = round($info["mc_gross"] * $mult);
$fee = round($info["mc_fee"] * $mult);
if ($err !== 'Success' && $err !== 'Repeated transaction') {
// It was a project creation
header("Location: createdproject.php?p=" . scrub($err) . "&amt={$gross}{$code}");
exit;
}
if (sizeof($custom) == 1) {
// The transaction was a direct reserve deposit
header("Location: account.php?tab=reserve&err=deposit" . "¤cy={$code}&gross={$gross}&fee={$fee}");
exit;
}
header("Location: " . projurl($custom[1], "pp_err={$no_transfer}" . "¤cy={$code}&gross={$gross}&fee={$fee}"));
exit;
示例7: scrub
This file is part of Fossfactory-src.
Fossfactory-src is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fossfactory-src is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Fossfactory-src. If not, see <http://www.gnu.org/licenses/>.
*/
$id = scrub($id);
$hostname = $_SERVER["HTTP_HOST"];
if ($hostname === "www.fossfactory.org") {
$hostname = "git.fossfactory.org";
}
list($rc, $submissions) = ff_getsubmissions($id);
// Remove from the list any projects that have been rejected with prejudice
$s = array();
foreach ($submissions as $key => $submission) {
if ($submission["status"] === 'prejudice' && intval($_REQUEST["s"]) != intval($submission["id"])) {
continue;
}
$s[$key] = $submission;
}
$submissions = $s;
if ($rc || sizeof($submissions) == 0) {
示例8: scrub
Copyright 2008 John-Paul Gignac
This file is part of Fossfactory-src.
Fossfactory-src is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fossfactory-src is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Fossfactory-src. If not, see <http://www.gnu.org/licenses/>.
*/
$id = scrub($_REQUEST["id"]);
$tab = scrub($_REQUEST["tab"]);
if ($_GET['type'] == 'project') {
$stop = intval($_REQUEST["stop"]);
if ($GLOBALS["username"]) {
ff_setvote($GLOBALS["username"], $id, !$stop);
}
}
if ($_GET['type'] == 'funding' && ($_GET['vote'] == 'more' || $_GET['vote'] == 'less')) {
if ($GLOBALS['username']) {
ff_setfundingvote($GLOBALS['username'], $id, $_GET['vote'] == 'more');
}
}
header("Location: " . projurl($id, $tab ? "tab={$tab}" : ""));
示例9: scrub
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Fossfactory-src. If not, see <http://www.gnu.org/licenses/>.
*/
$searchkeyword = scrub($_REQUEST['q']);
$sort = scrub($_REQUEST['sort']);
if ($_REQUEST['limit'] != '') {
$limit = intval($_REQUEST['limit']);
}
if (isset($_REQUEST['offset'])) {
$offset = intval($_REQUEST['offset']);
}
$id = scrub("{$_REQUEST['id']}");
$amount = "{$_REQUEST['amount']}";
apply_template("Browse Projects", array(array("name" => "Projects", "href" => "browse.php")), '', array('style', 'header-style', 'footer-style', 'browse-style'));
include_once "formattext.php";
?>
<h1>Browse Projects</h1>
<script src="folder.js"></script>
<script>
function set_showpoor() {
document.getElementById('browse_table').className =
document.getElementById('showpoor').checked ? '' : 'hidepoor';
}
</script>
<style>
#browse_table.hidepoor .nobounty {
display: none;
示例10: scrub
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fossfactory-src is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Fossfactory-src. If not, see <http://www.gnu.org/licenses/>.
*/
$parentid = scrub($_REQUEST["id"]);
//get subprojects of project
list($rc, $subprojects) = ff_getsubprojects($parentid);
if ($rc) {
print "Internal error: {$rc} {$subprojects}";
exit;
}
foreach ($subprojects as $subproject) {
$allotment = round($_REQUEST["sub{$subproject['id']}"] * 10);
if (isset($_REQUEST["sub{$subproject['id']}"]) && $allotment >= 0 && $allotment <= 1000 && (!$subproject["allotted"] || $allotment != $subproject["allotment"])) {
ff_setallotment($username, $parentid, $subproject['id'], $allotment);
}
$priority = scrub($_REQUEST["pri{$subproject['id']}"]);
if ($priority !== $subproject["priority"]) {
ff_setpriority($username, $parentid, $subproject['id'], $priority);
}
}
header("Location: " . projurl($parentid, "tab=subprojects"));
exit;
示例11: str_replace
$basedir = str_replace('packages/sys/display', '', dirname(__FILE__));
$path = $basedir . 'managed_code/cache/';
$name = 'js_register_' . $_GET['plugin_file'] . '.php';
if (file_exists($path . $name)) {
$to_del = $path . $name;
$incfiles = unserialize(file_get_contents($path . $name));
foreach ($incfiles as $file_name => $params) {
if ($file_name != 'onload') {
$filter = '/[^A-Za-z_0-9.\\/]/';
$plugin_path = scrub($params['plugin_path']);
$clean_file_name = scrub($file_name);
if (isset($params['args'])) {
foreach ($params['args'] as $name => $value) {
$clean_name = scrub($name);
if (!isset(${$clean_name})) {
${$clean_name} = scrub($value);
} else {
trigger_error('Ahh! namespace conflict with variable: ' . $clean_name);
}
}
}
require_once $basedir . $plugin_path . $clean_file_name . '.js.php';
} else {
echo $params;
}
}
unlink($to_del);
}
function scrub($data)
{
/* $filter = '/[^A-Za-z_0-9.\/]/';
示例12: scrub
Fossfactory-src is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fossfactory-src is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Fossfactory-src. If not, see <http://www.gnu.org/licenses/>.
*/
$p = scrub($_REQUEST["p"]);
$reqmts = "{$_REQUEST['reqmts']}";
$priority = scrub($_REQUEST["priority"]);
$allotment = floatval($_REQUEST["allotment"]);
if (!$p) {
exit;
}
list($rc, $parent) = ff_getprojectinfo($p);
if ($rc) {
print "System error: {$rc} {$parent}";
softexit();
}
if (trim($reqmts)) {
if ($_REQUEST["stopspam"] !== 'yes') {
exit;
}
$tempdir = "{$GLOBALS['DATADIR']}/tempattachments/{$sid}";
$attachments = array();
示例13: htmlentities
?>
"">
<input type="hidden" name="currency_code" value="<?php
echo $GLOBALS["pref_currency"];
?>
">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="tax" value="0">
<input type="hidden" name="bn" value="PP-SponsorshipsBF">
<input type="hidden" name="return" value="<?php
echo htmlentities($GLOBALS["SITE_URL"]);
?>
paypal-return.php">
<input type="hidden" name="cancel_return" value="<?php
echo htmlentities($GLOBALS["SITE_URL"]) . projurl($id, "tab=" . scrub($_REQUEST["tab"]));
?>
">
<input type="hidden" name="notify_url" value="<?php
echo htmlentities($GLOBALS["SITE_URL"]);
?>
paypal-ipn.php">
<input type="hidden" name="custom" value="<?php
echo htmlentities($username);
?>
/<?php
echo $id;
?>
">
<div>
Sponsorship Amount: <?php
示例14: FeedItem
$item = new FeedItem();
$item->title = $e['subject'];
$item->link = $GLOBALS['SITE_URL'] . $e['url'];
$item->date = (int) $e['time'];
$item->description = formatText($e['body']);
$rss->addItem($item);
}
}
}
$rss->title = '[FF] ' . $pname;
$rss->description = 'Recent events affecting FOSS Factory project \'' . $pname . '\'';
$rss->link = $GLOBALS['SITE_URL'] . projurl($pid);
} else {
if ($_GET['src'] == 'userevents') {
include_once "formattext.php";
$user = scrub($_GET['u']);
list($rc, $watching) = al_getwatches($user);
if ($rc == 0) {
foreach ($watching as $w) {
list($rc, $events) = al_getrecentevents('watch:' . $w['eventid']);
if ($rc != 0) {
continue;
}
foreach ($events as $e) {
$item = new FeedItem();
$item->title = $e['subject'];
$item->link = $GLOBALS['SITE_URL'] . $e['url'];
$item->date = (int) $e['time'];
$item->description = formatText($e['body']);
$rss->addItem($item);
}
示例15: scrub
This file is part of Fossfactory-src.
Fossfactory-src is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fossfactory-src is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Fossfactory-src. If not, see <http://www.gnu.org/licenses/>.
*/
$id = scrub($_REQUEST['id']);
if ($GLOBALS['username'] == '') {
print "sorry, must login first";
softexit();
}
include_once 'formattext.php';
// Get the project info
list($rc, $projinfo) = ff_getprojectinfo($id);
if ($rc == 2) {
print "No such project: {$id}";
softexit();
}
$iserror = false;
$filenames = '';
if (isset($_REQUEST['submit'])) {
foreach ($_FILES["thefile"]["error"] as $key => $error) {