Page 1 of 1

Host generated code

Posted: Thu Oct 30, 2003 1:22 pm
by jbatty
I have auto generated an XML document from text entered in a HTML form's textarea using PHP4. (by using regular expressions to specify the tags). I then have another script that parse the saved XML into an array ....
the structure of the XML is like this.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<questions>
<item>
   <questionId>1a</questionId>
  <question>How many days in a leap year?</question>
   <choice>336</choice>
   <choice>356</choice>
   <choice>365</choice>
   <choice>400</choice>
   <answer>B</answer>
</item>
<item>
   <questionId>2a</questionId>
  <question>How many inches in a foot?</question>
   <choice>11</choice>
   <choice>12</choice>
   <choice>13</choice>
   <choice>30</choice>
   <answer>B</answer>
</item>
</questions>
The problem now is that my free host Lycos is automatically appending some javascript to the end of the XML like this

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<questions>
<item>
   <questionId>1a</questionId>
  <question>How many days in a leap year?</question>
   <choice>336</choice>
   <choice>356</choice>
   <choice>365</choice>
   <choice>400</choice>
   <answer>B</answer>
</item>
<item>
   <questionId>2a</questionId>
  <question>How many inches in a foot?</question>
   <choice>11</choice>
   <choice>12</choice>
   <choice>13</choice>
   <choice>30</choice>
   <answer>B</answer>
</item>
</questions>



</pre></xmp></noscript>

<!-- START RedMeasure V4 - Java v1.1  $Revision: 1.9 $ -->
<!-- COPYRIGHT 2000 Red Sheriff Limited -->

<script language="JavaScript"><!--
var pCid="uk_lycos-uk_0";
var w0=1;
var refR=escape(document.referrer);
if (refR.length>=252) refR=refR.substring(0,252)+"...";
//--></script>
<script language="JavaScript1.1"><!--
var w0=0;
//--></script>
<script language="JavaScript1.1" src="http://lycos-eu.imrworldwide.com/a1.js">
</script>
<script language="JavaScript"><!--
if(w0)&#123;
var imgN='<img src="http://lycos-eu.imrworldwide.com/cgi-bin/count?ref='+
	refR+'&cid='+pCid+'" width=1 height=1>';
if(navigator.userAgent.indexOf('Mac')!=-1)&#123;document.write(imgN);
&#125;else&#123;
	document.write('<applet code="Measure.class" '+
	'codebase="http://lycos-eu.imrworldwide.com/"'+'width=1 height=2>'+
	'<param name="ref" value="'+refR+'">'+'<param name="cid" value="'+pCid+
	'"><textflow>'+imgN+'</textflow></applet>');
	&#125;
&#125;
document.write("<COMMENT>");
//-->
</script>
<noscript>
<img src="http://lycos-eu.imrworldwide.com/cgi-bin/count?cid=uk_lycos-uk_0" width=1 height=1>
</noscript>
</COMMENT>
<!-- END RedMeasure V4 --> 

<script language="javascript" src="http://ads.tripod.lycos.co.uk/ad/test_frame_size.js"></script>
<script language="javascript">
if (!AD_clientWindowSize()) &#123;
        document.write("<NOSC"+"RIPT>");
&#125;
</script>

<script type="text/javascript">
        function setCookie(name, value, expires, path, domain, secure) &#123;
           var curCookie = name + "=" + escape(value) +
             ((expires) ? "; expires=" + expires.toGMTString() : "") +
             ((path) ? "; path=" + path : "") +
             ((domain) ? "; domain=" + domain : "") +
             ((secure) ? "; secure" : "");
           document.cookie = curCookie;
        &#125;

        var ad_url = "http://ads.tripod.lycos.co.uk/ad/google/frame.php?_url="+escape(self.location);
        var ref=window.document.referrer;


        if(parent.LycosAdFrame) &#123;
                if(parent.memberPage && parent.memberPage.document.title ) &#123;
                        parent.document.title=parent.memberPage.document.title;
                &#125;

                if(parent.LycosAdFrame && parent.LycosAdFrame.location && (ref != "" && (ref+"?" != window.location) && (ref.substr(ref.length-1,1) != "/")) ) &#123;
                        //parent.LycosAdFrame.location.href=ad_url;
                        parent.LycosAdFrame.location.replace(ad_url);
                &#125;
                setCookie("adFrameForcePHP",0,0," ");
                parent.document.body.cols = "*,140";
        &#125;
        else if(top.LycosAdFrame && top.LycosAdFrame.location) &#123;
                if ((ref != "" && (ref+"?" != top.window.location) && (ref.substr(ref.length-1,1) != "?"))) &#123;
                        //top.LycosAdFrame.location.href=ad_url;
                        top.LycosAdFrame.location.replace(ad_url);
                &#125;
                setCookie("adFrameForcePHP",0,0," ");
                top.document.body.cols = "*,140";
        &#125;
        else &#123;
                if (!window.opener) &#123;
                        setCookie("adFrameForcePHP",1,0," ");
                &#125;
                else &#123;
                        setCookie("adFrameForcePHP",0,0," ");
                &#125;
        &#125;

</script>


<script type="text/javascript" src="http://ads.tripod.lycos.co.uk/ad/ad.php?cat=noref&mkw=&CC=uk&ord=3fa15aec&adpref="></script>
Thereby voiding it as an XML document.
How can i tackle this problem?

Posted: Thu Oct 30, 2003 2:36 pm
by RTT
Purchase some proper hosting? ;)

Posted: Thu Oct 30, 2003 3:43 pm
by Fredix
ooooh that's bad, man!

But telling you to get a paid hoster is not a real solution so:

If you are sure that lycos APPENDS the crap everytime you can run a php script first that erases everything that comes after </questions>.

Posted: Thu Oct 30, 2003 4:59 pm
by jbatty
Thanks Fredix - could you please point out how best to write a code that does delete everything after </question>

Posted: Fri Oct 31, 2003 3:12 am
by twigletmac
Check out the strstr() function - it generally returns everything after the bit you are looking for, but if you read the user comments there are a number of solutions for retrieving all the text before what you are looking for.

Mac

Posted: Fri Oct 31, 2003 7:45 am
by JayBird
I would have to agree with Volka.

These free hosting companies aren't as stupid as you think.

Mark

Posted: Fri Oct 31, 2003 7:49 am
by volka
Bech100: I just removed my previous post.
Although I still believe the code is append after the script ran it is probably possible to remove it since a second script is involved to read the first document. ;-)
But the question remains: When and where does this second script run?

Posted: Sat Nov 01, 2003 7:10 am
by Fredix
btw:

Lycos appends this stuff only to some files like html and xml, right? What about giving your xml file a name like data.stuff or data.jpg (if this works this is the simpliest solution) otherwise do what twigletmac said.

I'm a little confused by Bech100 and volka.

greets,
Fredix