qbox Posted July 17, 2008 Share Posted July 17, 2008 Hi I make html file like index.php <script type="text/javascript" src="http://localhost/test.php?ID="> </script> test.php file <?php header('Content-type: text/javascript'); echo "var myCounter = { init:function(mServer, mSesionID){ myCounter.Site=\"".$_GET['site']."\"; myCounter.Server=mServer; myCounter.IP=\"".$_SERVER['REMOTE_ADDR']."\"; myCounter.trackingImage = new Image(); myCounter.OnLoad(); }, OnLoad:function(){ var newHref = document.createElement(\"a\"); var newImage = document.createElement(\"img\"); var scriptRef = myCounter.getScriptElement(); var data=new Date(); var mTZO=(typeof(data.getTimezoneOffset)!='undefined') ? data.getTimezoneOffset() : ''; newHref.href = \"http://\" + myCounter.Serve + \"/counter/Statistic.php?site=\" + myCounter.Site; newHref.target = \"_top\"; var mImage = \"http://\" + myCounter.Server + \"/counter/counting.php?site=\" + myCounter.Site; if (myCounter.IP != \"\") mImage += \"&ip=\"+myCounter.IP; mImage += \"&w=\"+window.screen.width; mImage += \"&h=\"+window.screen.height; mImage += \"&clr=\"+window.screen.colorDepth; mImage += \"&tzo=\" + mTZO; mImage += \"&lang=\"+escape(navigator.language ? navigator.language : navigator.userLanguage); mImage += \"&pg=\"+escape(document.location); mImage += \"&js=1\"; if(navigator.cookieEnabled) mImage += \"&co=1\"; else mImage += \"&co=0\"; if(navigator.cpuClass) mImage += \"&cpu=\"+navigator.cpuClass; else mImage += \"&cpu=0\"; newImage.border = \"0\"; newImage.src = mImage; newHref.appendChild(newImage); myCounter.trackingImage.src = mImage; }, getScriptElement:function() { var refScript=null; refScript = document.getElementById( \"myCounter\" ); if (refScript) return refScript; var pageScripts = document.getElementsByTagName(\"script\"); for(var i=0;i<pageScripts.length;i++) { if (pageScripts[i].src) { var mSource = pageScripts[i].src.toLowerCase(); if (mSource.indexOf(\"site=\" + myCounter.Site) > 0) return pageScripts[i]; } } return null; } } window.onload = function() { myCounter.init(); }; "; ?> after this all information are send to counter.php file for calculating. But I want to print a image on the main page. I dont want to insert img tag in main page. I want somehow to show image from test.php file or counting.php file. test.php file generate a javascript and return to the main page.... Thank you. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 17, 2008 Share Posted July 17, 2008 you look like you are on the right track...counter.php just needs to return an image. is that what you are having problems with...returning an image? is it a static image or one dynamically created using the GD library? Quote Link to comment Share on other sites More sharing options...
qbox Posted July 17, 2008 Author Share Posted July 17, 2008 static and dinamic. lets first somehow return static image. can you tell me what to do? I think that returning static or dinamic isnt big diferencies... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 17, 2008 Share Posted July 17, 2008 <?php //All your stat code //Now we want to return an image $image = 'count.jpg'; header('Content-type: image/jpeg'); print file_get_contents($image); exit; ?> Quote Link to comment Share on other sites More sharing options...
qbox Posted July 17, 2008 Author Share Posted July 17, 2008 sorry... not working.... I try to open only the counting.php file, I receive header error. I put the code to the top, I see the picture but in all cases I didnt see picture on the first html page.... Quote Link to comment Share on other sites More sharing options...
qbox Posted July 17, 2008 Author Share Posted July 17, 2008 I think that I make mistake somewhere in javascript code because the counting.php alone return the image but I cant see the image on the first page.... I put the javascript code in a separate file and run it for there. The script send the collected information to the counting.php file and the information are saved in another file but the picture arent return... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 18, 2008 Share Posted July 18, 2008 make sure nothing is printed in the code above the part that sends the image. can you post the entire code for counter.php? Quote Link to comment Share on other sites More sharing options...
qbox Posted July 18, 2008 Author Share Posted July 18, 2008 counter.php <?php $name = "clock.jpg"; $fp = fopen($name, 'rb'); header("Content-Type: image/jpeg"); fpassthru($fp); fclose($fp); $str = $_SERVER['HTTP_USER_AGENT']; $ary = explode(';',$str); for($i=0;$i<count($ary);$i++){ $ary[$i] = str_replace(' ','',$ary[$i]); $ary[$i] = str_replace('xx','x ',$ary[$i]); } $fout = fopen("test", "wt"); $colector = $_GET['site']."\n"; $colector .= $_GET['ip']."\n"; $colector .= $_GET['w']."x".$_GET['h']."\n"; $colector .= $_GET['clr']."\n"; $colector .= $_GET['tzo']."\n"; $colector .= $_GET['lang']."\n"; $colector .= $_GET['pg']."\n"; $colector .= $_GET['js']."\n"; $colector .= $_GET['co']."\n"; $colector .= $_GET['cpu']."\n"; $colector .= $ary[2]."\n"; $colector .= $str."\n"; fwrite($fout, $colector); ?> im writing to the file for now. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 18, 2008 Share Posted July 18, 2008 ok...that code is good...i do get weird results in the JS though. at the end of the OnLoad function, have it write the image path out so you can see it, like so: OnLoad:function(){ var newHref = document.createElement(\"a\"); var newImage = document.createElement(\"img\"); var scriptRef = myCounter.getScriptElement(); var data=new Date(); var mTZO=(typeof(data.getTimezoneOffset)!='undefined') ? data.getTimezoneOffset() : ''; newHref.href = \"http://\" + myCounter.Serve + \"/counter/Statistic.php?site=\" + myCounter.Site; newHref.target = \"_top\"; var mImage = \"http://\" + myCounter.Server + \"/counter/counting.php?site=\" + myCounter.Site; if (myCounter.IP != \"\") mImage += \"&ip=\"+myCounter.IP; mImage += \"&w=\"+window.screen.width; mImage += \"&h=\"+window.screen.height; mImage += \"&clr=\"+window.screen.colorDepth; mImage += \"&tzo=\" + mTZO; mImage += \"&lang=\"+escape(navigator.language ? navigator.language : navigator.userLanguage); mImage += \"&pg=\"+escape(document.location); mImage += \"&js=1\"; if(navigator.cookieEnabled) mImage += \"&co=1\"; else mImage += \"&co=0\"; if(navigator.cpuClass) mImage += \"&cpu=\"+navigator.cpuClass; else mImage += \"&cpu=0\"; newImage.border = \"0\"; newImage.src = mImage; newHref.appendChild(newImage); myCounter.trackingImage.src = mImage; document.write(mImage); //Added this }, what is the path that it prints out? Quote Link to comment Share on other sites More sharing options...
qbox Posted July 19, 2008 Author Share Posted July 19, 2008 I didnt see picture again. The document.write(mImage); print me the path to count.php file here is the result http://localhost/counter/counting.php?site=SITE_NAME&ip=127.0.0.1&w=1280&h=800&clr=24&tzo=-180〈=en-US&pg=http%3A//localhost/count/&js=1&co=1&cpu=0 Quote Link to comment Share on other sites More sharing options...
qbox Posted July 20, 2008 Author Share Posted July 20, 2008 Any help ?? Quote Link to comment Share on other sites More sharing options...
qbox Posted July 20, 2008 Author Share Posted July 20, 2008 Finaly I solve IT! I dont know why but if I write capital characters in the site=SITE_NAME for examle didnt work.... its ok I got the point. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.