Forum Moderators: coopster

Message Too Old, No Replies

Require file don't run

What am I doing wrong?

         

SkHsarki

4:48 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



Hello everyone!

I have a small problem with my script:

<img src="px.png" width="1" height="1" />
<?php
require("stats/required.php");
header("Location: [google.com");...]
?>

I want the "page" run the required.php (it's a counter),
but it don't run, I tried it with a text on the page too but what I got it NO text!

So I think it skips everything and just use the header part. Is there any way to fix this script to run the required.php and redirect at the same time?

Thank You very much!

jatar_k

4:54 pm on Jun 5, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld SkHsarki,

you should take a look at the file 'stats/required.php'

if you call that file directly does it work?

SkHsarki

4:57 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



Hm no, it doesn't. But if there's something on the page it worked. Why?

SkHsarki

5:03 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



The main cause is that it skips everything besides the header part. Because when I insert a text in the page too, it don't show the text.

jatar_k

5:40 pm on Jun 5, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you need to get it working when called directly first, then you can figure out the require issues after

does it give any errors? what happens, or doesn't happen, when you call the script directly?

SkHsarki

5:50 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



Well, it says nothing. Just plain blank white page. And it didn't logged it.

SkHsarki

5:54 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



Well here's the required.php file:

if (file_exists("stats/log/blocked/list"))
{
$mamamu = fopen("stats/log/blocked/list","r");
while(!feof($mamamu))
{
$basi = fread($mamamu,5000);
}
fclose($mamamu);
}
if (preg_match ("/".$HTTP_SERVER_VARS['REMOTE_ADDR']."/i", $basi))
{
}
else
{

$language = "&language=".$HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];
$host = "&host=".$HTTP_SERVER_VARS['HTTP_HOST'];
$ide = preg_replace("/&/","RUSIN40",$HTTP_SERVER_VARS['HTTP_REFERER']);
$ref = "&ref=".$ide;
//$url = "&url=".$HTTP_SERVER_VARS['phpSelf'];
$browser = "&browser=".$HTTP_SERVER_VARS['HTTP_USER_AGENT'];
$remadr = "&remadr=".$HTTP_SERVER_VARS['REMOTE_ADDR'];
$remhos = "&remhos=".gethostbyaddr($_SERVER['REMOTE_ADDR']);
setlocale (LC_TIME, "en_UK");
$year = "&year=".strftime ("%Y");
$month = "&month=".strftime ("%m");
$month_name = "&month_name=".strftime ("%B");
$day_week = "&day_week=".strftime ("%A");
$week = "&week=".strftime ("%W");
$day = "&day=".strftime ("%d");
$hour = "&hour=".strftime ("%H");
$minute = "&minute=".strftime ("%M");
$second = "&second=".strftime ("%S");
$day_of_year = "&day_of_year=".strftime ("%j");
$uri = $HTTP_SERVER_VARS['REQUEST_URI'];
$url = stripslashes("http://".$HTTP_SERVER_VARS['SERVER_NAME'].$uri);
$ide = preg_replace("/&/","RUSIN40",$url);
$url = "&url=".$ide;
$unique = $browser.$remadr."\n";

?>
<script language="javascript">
<!--//
var cpu = window.navigator.cpuClass;
var platform = window.navigator.platform;

if (navigator.appname != 'Netscape') {color= "?color="+screen.colorDepth+"&cpu="+cpu+"&platform="+platform;}
else {color = "?color="+screen.pixelDepth;}
avail = "&avail="+screen.availwidth+"x"+screen.availheight;
res = "&res="+screen.width+"x"+screen.height;
isize = '" width="0" height="0" border="0" hspace="0" vspace="0"';

img = '<div id="counter" style="position:absolute; left:0px; top:0px; width:1; height:1; z-index:1"><img name="img" src="stats/log.php'+color+'<? echo $language. $host. $ref. $browser. $url. $remadr. $remhos. $year. $month. $month_name. $day_week. $week. $day. $hour. $minute. $second. $day_of_year. $uri;?>'+avail+res+isize+'"></div>';

document.write(img);
//-->
</script>
<?
}
?>

[edited by: jatar_k at 3:31 pm (utc) on June 6, 2008]
[edit reason] fixed sidescroll [/edit]

jatar_k

6:07 pm on Jun 5, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



where is it writing?

can you see the img code in the source of the page?

SkHsarki

6:17 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



Into a file I don't think it needs now. it have got 777 CHMDO too.

yes I can see it!<body><script type="text/javascript" charset="utf-8" src="http://www.example.com/lib/webmaster/webmaster.js?scr=1&amp;username=skhsarki&amp;host=skhsarki.extra.hu&amp;rid=1403579003"></script><script language="javascript">
<!--//
var cpu = window.navigator.cpuClass;
var platform = window.navigator.platform;

if (navigator.appname != 'Netscape') {color= "?color="+screen.colorDepth+"&cpu="+cpu+"&platform="+platform;}
else {color = "?color="+screen.pixelDepth;}
avail = "&avail="+screen.availwidth+"x"+screen.availheight;
res = "&res="+screen.width+"x"+screen.height;
isize = '" width="0" height="0" border="0" hspace="0" vspace="0"';

img = '<div id="counter" style="position:absolute; left:0px; top:0px; width:1; height:1; z-index:1"><img name="img" src="stats/log.php'+color+'&language=hu-hu,hu;q=0.8,en-us;q=0.5,en;q=0.3&host=skhsarki.extra.hu&ref=&browser=Mozilla/5.0 (Windows; U; Windows NT 6.0; hu; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.12;MEGAUPLOAD 1.0&url=censored#*$!#*$!'+avail+res+isize+'"></div>';

document.write(img);
//-->
</script>

[edited by: eelixduppy at 6:33 pm (utc) on June 5, 2008]
[edit reason] example.com [/edit]

SkHsarki

12:36 pm on Jun 6, 2008 (gmt 0)

10+ Year Member



please help me...

what I know now is that if I use exit() it make the log.

is there a way to start the execution after exit()?

jatar_k

2:02 pm on Jun 6, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



where do you put the exit() to make it work?

SkHsarki

3:07 pm on Jun 6, 2008 (gmt 0)

10+ Year Member



after the require (stats/required.php)

jatar_k

3:28 pm on Jun 6, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



are you redirecting to another site?

maybe you could include the other content so as not to use the header function]]your code seems to rely on output and the header function won't work with previous output

SkHsarki

4:08 pm on Jun 6, 2008 (gmt 0)

10+ Year Member



I'm redirecting to a ZIP file.

jatar_k

4:26 pm on Jun 6, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



why not just serve the file then as opposed to redirecting to it?

or just do straight php logging instead of all the js stuff

it's the logic of the process that is having the problem so you need to change the logic a little bit to get it all working as desired

SkHsarki

7:00 pm on Jun 6, 2008 (gmt 0)

10+ Year Member



Hm but then... I'm just a beginner I don't know how to do that without this method.

SkHsarki

7:53 am on Jun 7, 2008 (gmt 0)

10+ Year Member



So any tips maybe?

I want to use this script I really do wanna.

SkHsarki

8:13 am on Jun 7, 2008 (gmt 0)

10+ Year Member



OK update: I've seen that NOTHING beyond the header is executed - for example now I wanted to do this as a Pop-up but the script isn't executed before the <php !

why?

SkHsarki

8:30 am on Jun 7, 2008 (gmt 0)

10+ Year Member



maybe I can do it with If statement?

SkHsarki

8:38 am on Jun 7, 2008 (gmt 0)

10+ Year Member



aaww i cant do this alone i cant program =( pls heeeelp

jatar_k

1:27 pm on Jun 7, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



nothing beyond the header will be executed

when you use the header function you redirect to the other page

if you can't program how did it get this far? You're going to have to learn a bit if you are going to make this work

you could start with this
header() [php.net]

mehh

5:56 pm on Jun 8, 2008 (gmt 0)

10+ Year Member



the header function is redirecting before the JavaScript is exicuted. if you don't want to do PHP logging to a javascript redirect.
window.location.href="http://example.com"

Also put a link for those with JS disabled.