本文整理汇总了PHP中_filter函数的典型用法代码示例。如果您正苦于以下问题:PHP _filter函数的具体用法?PHP _filter怎么用?PHP _filter使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_filter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mysqlcon
function mysqlcon() {
global $db_host, $db_user, $db_pass, $db_name, $db_charset;
if (!@mysql_connect($db_host, $db_user, $db_pass))
die(m_error(mysql_error()));
mysql_select_db($db_name);
mysql_query("SET NAMES "._filter($db_charset)."");
}
示例2: addAction
/**
* AJAX to install a widget
*/
public function addAction()
{
$module = $this->getModule();
$name = _filter($this->params('name'), 'regexp', array('regexp' => '/^[a-z0-9_\\-]+$/'));
$meta = sprintf('%s/meta/%s.php', Pi::service('module')->path($module), $name);
if (!file_exists($meta)) {
$meta = sprintf('%s/module/%s/meta/%s.php', Pi::path('custom'), $module, $name);
}
$block = (include $meta);
$block['type'] = $this->type;
$block['name'] = $name;
if (empty($block['render'])) {
$block['render'] = sprintf('Module\\Widget\\Render::%s', $name);
} else {
if (is_array($block['render'])) {
$block['render'] = $block['render'][0] . '::' . $block['render'][1];
$class = $block['render'][0];
$method = $block['render'][1];
} else {
list($class, $method) = explode('::', $block['render'], 2);
}
$renderClass = 'Custom\\Widget\\Render\\' . ucfirst($class);
if (!class_exists($renderClass)) {
$renderClass = 'Module\\Widget\\Render\\' . ucfirst($class);
}
$block['render'] = $renderClass . '::' . $method;
}
if (!isset($block['template'])) {
$block['template'] = $name;
}
//$block['template'] = $name;
$status = $this->addBlock($block);
if ($status) {
$message = sprintf(_a('The widget "%s" is installed.'), $name);
} else {
$message = sprintf(_a('The widget "%s" is not installed.'), $name);
}
return array('status' => $status, 'message' => $message);
}
示例3: array
if ($act == "itemcard") {
$modx->setPlaceholder('tsvoptions', $modx->runSnippet('TSVshop_options', array('docid' => $modx->documentIdentifier)));
$modx->setPlaceholder('tsvservices', '<input type="hidden" name="formula" value="[*price*]" /><input type="hidden" name="cart_icon" value="[*cart_icon*]" /><script type="text/javascript">Ucalc("' . $modx->documentIdentifier . '")</script>');
$modx->setPlaceholder('tsvprice', '<span id="price' . $modx->documentIdentifier . '">[*price*]</span>');
$modx->setPlaceholder('tsvbattr', 'onkeypress="return testKey(event)" onChange="UserCalc(\'' . $modx->documentIdentifier . '\')"');
$evt = $modx->invokeEvent("TSVshopOnViewItemCard", array("itemid" => $modx->documentIdentifier, "type" => $tsvshop['TypeCat']));
}
if ($act == "info") {
print '<div id="infoblock_cont">' . tsv_display_infoblock($cache) . '</div>';
}
if ($act == "basket") {
print '<div id="basket_cont">' . tsv_display_cart($cache, "basket") . '</div>';
}
if ($act == "checkout") {
print '<div id="checkout_cont">' . tsv_display_cart($cache, "checkout") . '</div>';
}
if ($act == "finish") {
print tsv_display_success($cache);
}
if ($a == "clear") {
tsv_clear_cart();
}
if ($a == "del") {
tsv_delete_item(_filter(intval($_GET['num'])));
}
if ($a == "add") {
tsv_add_item($cache, $idnum, $name, $opt, $icon, $qty, $url, $typeitem);
}
if ($a == "chq") {
tsv_modify_quantity(_filter(intval($_GET['num'])), _filter(floatval($_GET['qnt'])));
}
示例4: rand
'Q','R','S','T','U','V',
'W','X','Y','Z','1','2',
'3','4','5','6','7','8',
'9','0');
// Генерируем пароль
$pass = "";
for($i = 0; $i < $number; $i++){// Вычисляем случайный индекс массива
$index = rand(0, count($arr) - 1);
$pass .= $arr[$index];
}
return $pass;
}
$pass=generate_password($num);
$password = md5($pass);
if ($_POST['vindex'] == 'on') {$vindex = 1; } else {$vindex = 0;};
$send = mysql_query("INSERT INTO users VALUES(NULL,'"._filter($name)."','"._filter($password)."','"._filter($vindex)."')");
if ($send == 'true')
{
?>
Пользователь добавлен! Его логин - <?=$name?>, пароль - <?=$pass?>
<?
exit;
}
else
{
?>
Неизвестная ошибка
<?
示例5: map
function map($s) {
$s->assign("lat",LAT_YOLA);
$s->assign("lon",LON_YOLA);
$s->assign("YANDEX_KEY",YANDEX_KEY);
$ids = '';
$rooms = '';
$prices = '';
$prices_m = '';
$areas = '';
$addresses = '';
$storeys = '';
$dates = '';
$types = '';
$lons = '';
$lats = '';
$photos = '';
$icons = '';
if (!isset($_REQUEST['act']) || $_REQUEST['act']=='sales') {
$status=REALTY_STATUS_SALE;
}
else {
$status=REALTY_STATUS_RENT;
}
$res = _filter($status);
$add_sql = "f.updated_on>'".getNextDate(date('Y-m-d'),-30)."' AND t.status=".REALTY_STATUS_ACTIVE.' AND '.$res['sql'];
$db_res = Land::getFullListLink($add_sql);
while ($row = $db_res->fetchRow()) {
$ids .= $row['id'].',';
$rooms .= $row['rooms'].',';
$prices .= "'".number_format($row['price'],0)."',";
$prices_m .= "'".number_format($row['price_m'],0)."',";
$areas .= "'".$row['total_area']."',";
$addr = "{$row['street']}, {$row['tnum']}";
$addresses .= "'".$addr."',";
$date = explode(' ',$row['updated_on']);
$ds = explode('-',$date[0]);
$date = $ds[2].'.'.$ds[1].'.'.$ds[0];
$dates .= "'".$date."',";
$storeys .= "'".$row['storey']."/".$row['storeys']."',";
$types .= "'".Tenement::$TYPE[$row['ttype']]."',";
$lons .= "'".$row['lon']."',";
$lats .= "'".$row['lat']."',";
$photo = ($row['photo_tenement']!='') ? $row['tenement_id']."/".$row['photo_tenement']."_prev" : '';
$photos .= "'".$photo."',";
if ($row['price_m']<30000) {
$color = 'a';
}
else if ($row['price_m']<40000) {
$color = 'b';
}
else {
$color = 'c';
}
$ri = ($row['rooms']<4) ? $row['rooms'] : 3;
$icons .= "'".$ri."k".$color."',";
}
$s->assign("ids",$ids);
$s->assign("rooms",$rooms);
$s->assign("prices",$prices);
$s->assign("prices_m",$prices_m);
$s->assign("areas",$areas);
$s->assign("addresses",$addresses);
$s->assign("storeys",$storeys);
$s->assign("dates",$dates);
$s->assign("types",$types);
$s->assign("lons",$lons);
$s->assign("lats",$lats);
$s->assign("photos",$photos);
$s->assign("icons",$icons);
$block_html = Html::getBlock('Квартиры на продажу на карте Йошкар-Олы',Html::pagelandMap());
$s->assign("block_html",$block_html);
$s->display("land_map.tpl");
}
示例6: vieworder
function vieworder($filename)
{
global $modx, $shop_lang, $theme, $tsvshop, $tables, $moduleid, $modulea;
$user = $modx->userLoggedIn();
$out = "";
$output_sales_notice = "";
$output_sales_error = "";
$temp = "";
$act = $_GET['act'];
$id = _filter($_GET['idorder'], 1);
$filename = empty($filename) ? TSVSHOP_PATH . 'addons/sales/tpl/orderview.tpl' : $filename;
if ($user['usertype'] == "manager") {
if (!empty($act) && $act == "vieworder" && $tables['sales'] != "none" && $tsvshop['dborders'] != "" && !empty($id) && is_numeric($id)) {
if ($res = $modx->db->select('*', $tsvshop['dborders'], 'numorder = "' . $id . '"', 'numorder', '1')) {
$row = $modx->db->getRow($res);
$url = "index.php";
$tpl = get_file_contents($filename);
$row1 = array('moduleurl' => $url, 'modulea' => $modulea, 'moduleid' => $moduleid, 'theme' => $theme);
$tpltr = getStr($tpl, '<!--repeat-->', '<!--/repeat-->');
$row = array_merge($shop_lang, $row1, $row);
foreach ($row as $key => $value) {
if (in_array($key, explode(",", $tsvshop['SecFields']))) {
$value = DeCryptMessage($value, $tsvshop['SecPassword']);
}
if ($key == "dateorder") {
$value = date("d.m.Y H:i:s", $value);
}
if ($key == "status") {
$tpl = str_replace('[+buildstatus+]', '<select name="status" id="status">' . buildstatus($value, explode("||", $tsvshop['StatusOrder'])) . '</select>', $tpl);
}
$tpl = str_replace('[+' . $key . '+]', $value, $tpl);
}
if ($res = $modx->db->select('*', $tsvshop['dborders_details'], 'numorder = "' . $id . '"', 'numorder')) {
while ($order = $modx->db->getRow($res)) {
$row = array_merge($row, $order);
$r++;
$temp = str_replace('[+moduleid+]', $_GET['id'], $tpltr);
foreach ($order as $key => $value) {
$temp = str_replace('[+' . $key . '+]', $value, $temp);
}
$temp = str_replace('[+num+]', $r, $temp);
$out .= $temp;
}
$out = str_replace($tpltr, $out, $tpl);
$out = preg_replace('/(\\[\\+.*?\\+\\])/', '', $out);
return $out;
}
}
//---
}
}
}
示例7: _filter
function _filter($var, $sql = 0)
{
global $modx;
$tmp = array();
if (!is_array($var)) {
$var = shop_striptags($var);
$var = str_replace("\n", " ", $var);
$var = str_replace("\r", "", $var);
//$var = htmlentities($var);
if ($sql == 1) {
$var = $modx->db->escape($var);
}
} else {
foreach ($var as $k => $v) {
$tmp[$k] = _filter($v, $sql);
}
$var = $tmp;
unset($tmp);
}
return $var;
}
示例8: htmlspecialchars
$name = htmlspecialchars($_POST['sitename']);
$name = iconv( "utf-8", "windows-1251", $name);
$slogan = htmlspecialchars($_POST['slogan']);
$slogan = iconv( "utf-8", "windows-1251", $slogan);
$theme = htmlspecialchars($_POST['theme']);
$theme = iconv( "utf-8", "windows-1251", $theme);
$sp = htmlspecialchars($_POST['startpage']);
$sp = iconv( "utf-8", "windows-1251", $sp);
if ($_POST['on'] == 'on') {$vindex = 1; } else {$vindex = 0;};
$send = mysql_query("UPDATE config SET value = '"._filter($name)."' WHERE name = 'sitename'");
$send = mysql_query("UPDATE config SET value = '"._filter($slogan)."' WHERE name = 'siteslogan'");
$send = mysql_query("UPDATE config SET value = '"._filter($theme)."' WHERE name = 'theme'");
$send = mysql_query("UPDATE config SET value = '"._filter($vindex)."' WHERE name = 'notworking'");
$send = mysql_query("UPDATE config SET value = '"._filter($sp)."' WHERE name = 'sp'");
if ($send == 'true')
{
?>
Настройки сохранены
<?
die;
}
else
{
?>
Ошибка
<?
}
示例9: htmlspecialchars
if ($_POST) {
if (empty($_POST['name']))
{
?>
Введите название категории!
<?
exit;
}
$name = htmlspecialchars($_POST['name']);
$name = iconv( "utf-8", "windows-1251", $name);
if ($_POST['vindex'] == 'on') {$vindex = 1; } else {$vindex = 0;};
$send = mysql_query("INSERT INTO categories VALUES(NULL, '"._filter($name)."', '"._filter($vindex)."')");
if ($send == 'true')
{
?>
Категория добавлена!
<?
exit;
}
else
{
?>
<?=$errorlang?>
<?
示例10: mysql_query
else
{
?>
Ошибка!
<?
}
exit;
}
if ($_GET["action"] == 'edit' || !empty($_GET["id"])) {
$id =$_GET["id"];
$query = mysql_query("SELECT * FROM pages WHERE id='"._filter($id)."'");
$rower = mysql_fetch_array($query);
if (mysql_num_rows($query) == 0)
{
die ("Страница не существует!");
}
$title = $rower["name"];
示例11: mysql_query
mysql_query("INSERT INTO `users` (`login`, `password`, `admin`) VALUES
('"._filter($login)."', '"._filter($upass)."', 1)") or die(m_error(mysql_error()));
$date = date('Y-m-d H:i:s', $date);
mysql_query("INSERT INTO `config` (`id`, `name`, `value`) VALUES
(1, 'theme', 'lcms'),
(2, 'sitename', 'Light Cms'),
(3, 'siteslogan', 'Тест)))'),
(4, 'posts_num', '10'),
(5, 'cutpostcount', '1000'),
(6, 'cmsname', 'Light CMS'),
(7, 'curcmsver', '0.5.0 RC2'),
(8, 'mail', '"._filter($mail)."'),
(9, 'aupdate', '"._filter($au)."'),
(10, 'notworking', '0'),
(11, 'sp', '')") or die(m_error(mysql_error()));
?>
<script>
location="index.php";
document.location.href="index.php";
window.location.reload("index.php");
document.location.replace("index.php");
</script>
<?
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
示例12: filter
/**
* Filter value with filter_var
*
* @param mixed $value Value to be filtered
* @param int|string $filter
* String for filter name or int for filter_id
* @param mixed $options
* @return mixed
*/
public function filter($value, $filter, $options = null)
{
$value = _filter($value, $filter, $options);
return $value;
}
示例13: bark
bark("Прямой доступ к этому файлу не разрешен.");
}
$ip = $_SERVER['REMOTE_ADDR'];
$ipquery = mysql_query("SELECT * FROM views WHERE ip='" . _filter($ip) . "' AND postid = '" . _filter($id) . "'");
if (mysql_num_rows($ipquery) == 0) {
mysql_query("INSERT INTO views VALUES(NULL,'" . _filter($id) . "','" . _filter($ip) . "')");
mysql_query("UPDATE posts SET views = views + 1 WHERE id = " . _filter($id) . "");
}
$smarty->display('header.tpl');
$smarty->display('right.tpl');
$pnum = 10;
$curp = $pnum * $page;
$news = mysql_query("SELECT * FROM posts WHERE id='" . _filter($id) . "'");
$rows = array();
while ($row = mysql_fetch_array($news)) {
$rows[] = $row;
}
$smarty->assign('news', $rows);
$smarty->display('content.tpl');
$comm = mysql_query("SELECT * FROM comments WHERE postid = '" . _filter($id) . "' ORDER BY id DESC ");
$com = array();
while ($row = mysql_fetch_array($comm)) {
$com[] = $row;
}
$smarty->assign('comments', $com);
$smarty->display('comment.tpl');
?>
<hr />
<?
include ("templates/$theme/addcomment.php");
$smarty->display('footer.tpl');
示例14: define
include_once $_api_path . 'assets/snippets/tsvshop/admin/includes/core.inc.php';
include_once $_api_path . 'assets/snippets/tsvshop/include/cart.inc.php';
include_once $_api_path . 'assets/snippets/tsvshop/include/config.inc.php';
$modx->config['base_path'] = $tsvshop['basePath'];
$modx->config['modx_charset'] = $tsvshop['charset'];
define("TSVSHOP_PATH", MODX_BASE_PATH . "assets/snippets/tsvshop/");
define("TSVSHOP_URL", MODX_BASE_URL . "assets/snippets/tsvshop/");
define("TSVSHOP_SURL", MODX_SITE_URL . "assets/snippets/tsvshop/");
$mode = _filter($_REQUEST['mode']);
$idnum = _filter(intval($_REQUEST['idnum']));
$name = _filter($_REQUEST['name']);
$price = _filter($_REQUEST['price']);
$icon = _filter($_REQUEST['icon']);
$opt = _filter($_REQUEST['opt']);
$qty = ($q = _filter($_REQUEST['qty'])) ? $q : 1;
$typeitem = ($t = _filter($_REQUEST['typeitem'])) ? $t : 'physical';
//$url = ($u = _filter($_REQUEST['url'])) ? $u : "&tovar=".$idnum;
//$url = ($tsvshop['TypeCat']=='docs' || empty($tsvshop['TypeCat'])) ? $modx->makeUrl($idnum) : "&tovar=".$idnum;
$url = $idnum;
$addonspath = TSVSHOP_PATH . "addons/";
if (!($folders = $cache->cache('folders', 'tsvshop'))) {
$folders = scandir($addonspath, 1);
$cache->cache('folders', 'tsvshop', $folders);
}
foreach ($folders as $folder) {
if ($folder != "." && $folder != "..") {
$file = $addonspath . $folder . '/includes/functions.inc.php';
$langfile = $addonspath . $folder . '/lang/' . $tsvshop['lang'] . '.inc.php';
if ($tsvshop['addons_' . $folder . '_active'] == "yes") {
if (file_exists($file) && file_exists($langfile)) {
require_once $file;
示例15: mysql_query
else
{
?>
Ошибка!
<?
exit;
}
exit;
}
if ($_GET["action"] == 'edit' || !empty($_GET["id"])) {
$id =$_GET["id"];
$query = mysql_query("SELECT * FROM categories WHERE id='"._filter($id)."'");
$rower = mysql_fetch_array($query);
if (mysql_num_rows($query) == 0)
{
?>
Таких тут нет:)
<?
exit;
}