Jump to content
Nestle

Fatal error: Call to undefined function filter, Qual o significado disto?

Recommended Posts

Nestle

Olá a todos,

É assim...

Ando com uns problemas no meu website e preciso de uma pequena ajuda.

Neste momento esta a dar-me este seguinte erro na minha página PHP :

Fatal error: Call to undefined function filter() in /home/teamspk/public_html/swapper/header.php on line 10

Não sei o porquê de dar esse erro, e vou deixar abaixo o código todo da página PHP para vocês verem, e se quiserem ajudarem.

<?php
if(!isset($site))
{
include 'config.php';
}
foreach($_GET as $key => $value) {
$gets[$key] = filter($value);
}
foreach($_POST as $key => $value) {
$_POST[$key] = filter($value);
}

if(isset($gets['r']))
{
$refid = $gets['r'];
if(isset($_SERVER['HTTP_REFERER']))
{
$httpref = $_SERVER['HTTP_REFERER'];
}
else
{
$httpref = "";
}
$ip = VisitorIP();

$sameid = mysql_fetch_object(mysql_query("SELECT ip FROM `users` WHERE `id`='{$refid}'"));
if(!isset($sameid->ip))
{
setcookie("ref", $refid, time()+ (365 * 24 * 60 * 60));
}
else if($sameid->ip != $ip)
{
setcookie("ref", $refid, time()+ (365 * 24 * 60 * 60));
}


$visits = mysql_query("SELECT id FROM `visits` WHERE `ip`='{$ip}' AND `user`='{$refid}'");
$num = mysql_num_rows($visits);
if($num == 0 && !preg_match("/\bhost-tracker\b/i", $httpref)) {
mysql_query("UPDATE `users` SET `coins`=`coins`+'1', `promote`=`promote`+'1' WHERE `id`='{$refid}'");
mysql_query("INSERT INTO `visits` (user, ip, referer, date) VALUES('{$refid}', '{$ip}', '{$httpref}', NOW())");
}
}

if(isset($_POST['loginUsername'])) {
$accounts = mysql_query("SELECT * FROM `users` WHERE `username`='{$_POST['loginUsername']}' AND `pass`=MD5('{$_POST['loginPassword']}')");
$exists = mysql_num_rows($accounts);
$userdata = mysql_fetch_object($accounts);
if($exists == 0){
?><script>alert("Incorrect Username/Password!");document.location.href='index.php'</script><?php
}else if($userdata->banned > 0){
?><script>alert("Your account is banned!");</script><?php
}else if($userdata->activate > 0){
?><script>alert("You need to confirm your email first!");</script><?php
}else if($exists > 0) {
$_SESSION['IP'] = VisitorIP();
mysql_query("UPDATE `users` SET `online`=NOW() WHERE `username`='{$_POST['loginUsername']}'");
$user = mysql_query("SELECT * FROM `users` WHERE `username`='{$_POST['loginUsername']}'");
$_SESSION['data'] = mysql_fetch_object($user);
$_SESSION['username'] = $_POST['loginUsername'];
echo "<script>document.location.href='index.php'</script>";
}
else{
?><script>alert("Incorrect Username/Password!");document.location.href='index.php'</script><?php
}
}

if(isset($_SESSION['username'])){
$user = mysql_query("SELECT *,UNIX_TIMESTAMP(`online`) AS `online` FROM `users` WHERE `username`='{$_SESSION['username']}'");
$data = mysql_fetch_object($user);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?
if ($site->translate == "Enabled"){?>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
autoDisplay: false,
floatPosition: google.translate.TranslateElement.FloatPosition.TOP_RIGHT
});
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<?}?>



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $site->site_name; ?> - Get Facebook Fans, Twitter Followers, Youtube Views, Google +1's, Stumbleupon Followers, Digg Followers, Website Hits, Twitter ReTweets, and MORE!</title>
<meta name="description" content="<?php echo $site->site_description; ?>" />

<link href="styleOrig.css" rel="stylesheet" type="text/css" />
<link href="template/style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="jquery.js"></script>

</head>

<body>

<!-- start HOLDER -->
<div id="holder">

<!-- start HEADER -->
<div id="header">

<!-- start WRAP -->
<div class="wrap">

<a href="index.php" class="logo"></a>

<?php if(!isset($data)) { ?>
<!-- start LOGINBOX -->
<div class="loginBox">

<form method="post">
<input type="text" name="loginUsername" class="loginInput" value="Username" onclick="if(this.value=='Username'){this.value=''}" onblur="if(this.value==''){this.value='Username'}" />
<input type="password" name="loginPassword" class="loginInput" value="Password" onclick="if(this.value=='Password'){this.value=''}" onblur="if(this.value==''){this.value='Password'}" />
<input type="submit" class="loginSubmit" value="Login" />
</form>

</div>
<!-- end LOGINBOX -->

<p class="forgot"><a href="resetpassword.php">Reset Password</a>         |         <a href="resendactivation.php">Resend Activation</a></p>
<?php }else{ ?>
<!-- start LOGINBOX -->
<div class="loginBox">

<p class="coins"><b><?php echo $data->coins; ?></b> Coins <a href="buy.php">Buy Coins</a>  
  <b>$<?php echo $data->cash; ?></b> <? if($data->cash >= "10.00") { echo "<a href='payout.php'>Request Payout</a>"; } else { echo "<a href='refer.php'>Earn Cash</a>"; };?>     <br><b><?php echo $data->premium; ?> Days</b> Left <? if($data->premium > "0") { echo "<a href='upgrade.php'>Buy More Time</a>"; } else { echo "<a href='upgrade.php'>Upgrade Now</a>"; };?></p>

</div>
<!-- end LOGINBOX -->
<?php } ?>

<!-- start NAVIGATION -->
<ul id="navigation" class="dropdown"<?php if(isset($data)) { ?> style="margin-top:30px;"<?php } ?>>

<li><a href="index.php">Home</a></li>
<?php if(isset($data)) { ?>
<li><a href="javascript:;">Earn Coins</a>
<ul>
<?php $menu = hook_filter('top_menu_earn',""); echo $menu; ?>
</ul>
</li>
<li><a href="javascript:;">Account</a>
<ul>
<li><a href="addsite.php">Add Site</a></li>
<li><a href="sites.php">My Sites</a></li>
<li><a href="addban.php">Add Banner</a></li>
<li><a href="mybans.php?p=bn">My Banners</a></li>
<li><a href="addtexts.php">Add Text Ad</a></li>
<li><a href="mytexts.php?p=ta">My Text Ads</a></li>
<li><a href="googleconfig.php?a">Google+ Account</a></li>
<li><a href="ytsubconfig.php?a">Youtube Account</a></li>
<li><a href="pinterestconfig.php?a">Pinterest Account</a></li>
<li><a href="soundcloudconfig.php?a">Soundcloud Account</a></li>
<li><a href="buy.php">Buy Coins</a></li>
<li><a href="upgrade.php">Premium Membership</a></li>
<li><a href='coupon.php'>Coupon</a></li>
<li><a href='refer.php'>Promote/Refer</a></li>
<? if($site->refcontest == 'Enabled'){?>
<li><a href='refcontest.php'>Referral Contest</a></li>
<?}?>
<li><a href='settings.php'>Settings</a></li>
</ul>
</li>
<?php } ?>
<li><a href="blog.php">Blog</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="stats.php">Stats</a></li>
<li><a href="tos.php">Terms</a></li>
<?php if(!isset($data)) { ?>
<li><a href="register.php">Register</a></li>
<?php }else{ ?>
<li><a href="logout.php">Logout</a></li>
<?php } ?>

</ul>
<!-- end NAVIGATION -->

</div>
<!-- end WRAP -->

</div>
<!-- end HEADER -->

<!-- start MAIN -->
<div id="main">

<!-- start WRAP -->
<div class="wrap">

Agradeço toda a ajuda,

Cumprimentos e obrigado!

Edited by brunoais
(geshi feito por yoda)| Título muito melhorado.

Share this post


Link to post
Share on other sites
Nestle

A função filter() não existe, é o que o erro diz.

Não percebo nada de PHP, portanto obrigado, mas como resolvo isso?

Share this post


Link to post
Share on other sites
Virneto

A função filter está alí para filtrar os dados que chegam. É um procedimento de segurança.

Podes pegar no teu código e simplesmente retirar aquele filtro, o que NÃO É SEGURO:

$gets[$key] = $value;
...
$_POST[key]=$value;
...

ou podes vir aqui [http://www.php.net/manual/pt_BR/function.filter-var.php]e aprender sobre filtrar variáveis em php com a função filter_var. Este é o procedimento recomendado.

Outra opção que tens é criar uma função com nome filter e fazer a validação das variáveis.

http://php.net/manual/pt_BR/functions.user-defined.php

Edited by Virneto
  • Vote 1

"Que inquieto desejo vos tortura, Seres elementares, força obscura? Em volta de que ideia gravitais?" >> Anthero de Quental

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Linuxando.com | ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.