<?php
function executeSql($sqlFileToExecute)
{
$sqlErrorCode = "";
$f = fopen($sqlFileToExecute,"r+");
foreach ($sqlArray as $stmt) {
if (strlen($stmt)>3 && substr(ltrim($stmt),0,2)!='/*') {
$result = mysql_query($stmt);
if (!$result) {
$sqlErrorCode = mysql_errno();
$sqlErrorText = mysql_error();
$sqlStmt = $stmt;
break;
}
}
}
if ($sqlErrorCode == 0) {
return "Script is executed succesfully!";
} else {
return "An error occured during installation!<br/>"
. "Error code: $sqlErrorCode<br/>"
. "Error text: $sqlErrorText<br/>"
. "Statement:<br/> $sqlStmt<br/>";
}
}
function filter($data) {
$data = trim(
htmlspecialchars(strip_tags($data))); - здесь заменил
if (get_magic_quotes_gpc())
$data = stripslashes($data);
$data = mysql_real_escape_string($data);
}
function checkPwd($x,$y)
{
if(empty($x) | empty($y) ) { return false; }
if (strlen($x) < 4 || strlen($y) < 4) { return false; }
if (strcmp($x,$y) != 0) {
return false;
}
return true;
}
function VisIP()
{
if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$The=$_SERVER['HTTP_FORWARDED_FOR'];
else $The=$_SERVER['REMOTEADDR'];
return trim($The);
}
function Email($email){
return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE;
}
function User($username)
{
if (preg_match('/^[a-z\d_]{3,20}$/i', $username)) {
return true;
} else {
return false;
}
}
function Name($name)
{
if (preg_match('/^[a-zA-Z]$/i', $nume)) {
return true;
} else {
return false;
}
}
function 404'r($url) {
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
if ($httpCode >= 200 && $httpCode < 300) {
return false;
} else {
return true;
}
}
function truncer($trailing='...')
{
$length-=mb_strlen($trailing);
if (mb_strlen($str)> $length)
{
return mb_substr($str,0,$length).$trailing;
}
else
{
$res = $str;
}
return $res;
}
function get_datas($url)
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
}
function percent($num_amount, $num_total) {
echo $count;
}
?>[/spoil]
Что еще можете посоветовать?
Вот сам ХЕДЕР скрипта, который что то порит с кодировкой
[spoil]
<?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" "
Для просмотра ссылки Войди или Зарегистрируйся">
<html xmlns="
Для просмотра ссылки Войди или Зарегистрируйся">
<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; ?></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>