954,219 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Rss, php, javascript nightmare! help?

im trying to build a rss feed that will work with my software.

php code

<?php

$t = 15;
$nt = 15000;

$filename3 = "xrssdone.txt";
$content3 = file("xrssdone.txt");

$done = explode("|",$content3[0]);
$num = explode("showtopic=",$_GET["newlink"]);
$nummin = explode("&",$num[1]);
echo $nummin[0];
for ($i=0; $i<$nt; $i++) {
  if ($nummin[0] == $done[$i]) {
    $donebefore = "1";
    break;
  }
}
echo $donebefore;
if ($donebefore != "1") {

$newtitle = $_GET["newtitle"];
$newlink = $_GET["newlink"];
$newmsg = $_GET["newmsg"];
$begin = '<?xml version="1.0" encoding="ISO-8859-1" ?><rss version="2.0"><channel><title>Reptile Planet</title><link>http://herproom.5.forumer.com/index.php?</link><description>New Topics Reptile News</description>';
$newall = "<item><title>";
$newall .= $newtitle;
$newall .= "</title><link>";
$newall .= $newlink;
$newall .= "</link><description>";
$newall .= $newmsg;
$newall .= "</description></item>";
$newall2 = $newall."|||^^*^^|||";
$begin .= $newall;
$end = "</channel></rss>";
$filename = "xrss.xml";
$content = file("xrss.xml");
$filename2 = "xrssmsgs.txt";
$content2 = file("xrssmsgs.txt");
$cont2x = explode("|||^^*^^|||",$content2[0]);
$fp = fopen($filename,"w+");
fwrite($fp,$begin);
for ($i=0; $i<$t; $i++) {
  fwrite($fp,$cont2x[$i]);
}
fwrite($fp,$end);
for ($i=0; $i<$t; $i++) {
  $cont2x[$i] .= "|||^^*^^|||";
}
$fp2 = fopen($filename2,"w+");
fwrite($fp2,$newall2);
for ($i=0; $i<$t; $i++) {
  fwrite($fp2,$cont2x[$i]);
}
for ($i=0; $i<$nt; $i++) {
  if ($done[$i] == "" && $donethat != 1) {
    $done[$i] .= $nummin[0];
    $donethat = 1;
  }
}
for ($i=0; $i<$nt; $i++) {
  $done[$i] .= "|";
  
}
$fp3 = fopen($filename3,"w+");
for ($i=0; $i<$nt; $i++) {
  fwrite($fp3,$done[$i]);
}
}
else {
echo "done";
}

?>


the three other files mentioned in it are hosted in the same root folder and are being written to. im using this javascript

function constrain(str,n){ 
  if(str.length > n){  
    var s = str.substr(0, n);
    var words = s.split(' '); 
    words[words.length-1] = '';
    str = words.join(' ') + lm;
  }
return str;
}
if (location.search.match("showtopic=")) {
var title = document.title;
var link = location.href;
var link2 = link.split("&");
var foruml = "";
var foruml2 = "";
var fixmsg = "";
var yes = 0;
var as3 = new Array();
var is3 = new Array();
var st3 = new Array();
var ss3 = new Array();
var fixmsg4 = new Array();
var fid = document.getElementById('navstrip');
foruml = fid.innerHTML.split("showforum=");
foruml2 = foruml[1].split('">');
for (i=0;i<forums.length;i++) {
if (foruml2[0] == forums[i]) {
yes = 1;
}
}
if (forums[0] == "0") {
yes = 1;
}
if (yes == 1) {
var x=document.getElementsByTagName('DIV');
for(i=0;i<x.length;i++) {
if(x[i].className=='postcolor') {
msg = x[i];
msg2 = msg.innerHTML.split("'");
for(c=0;c<msg2.length;c++) {
fixmsg += msg2[c];
}
as = fixmsg.match(/<a/i);
if (as != "null") {
as2 = fixmsg.split(/a>/i);
for (k=0; k<as2.length; k++) {
as3[k] = as2[k].replace(/<a.*<\//i, lr);
}
as4 = as3.join("");
fixmsg = as4;
}
fixmsg2 = fixmsg.replace(//ig, "");
fixmsg = fixmsg2;
is = fixmsg.match(/<img/i);
if (is != "null") {
is2 = fixmsg.split(/">/i);
for (k=0; k<is2.length; k++) {
is3[k] = is2[k].replace(/<img.{5,}border="0/i, ir);
}
is4 = is3.join("");
fixmsg = is4;
}
fixmsg2 = fixmsg.split(/<!--endemo-->/i);
for (i=0; i<fixmsg2.length; i++) {
fixmsg3 = fixmsg2[i].replace(ir,"");
fixmsg4[i] = fixmsg3.replace(/<!--emo.*-->/i, "");
}
fixmsg = fixmsg4.join("");
fixmsg2 = fixmsg.split(/<!--emo.{2,5}-->/i);
fixmsg = fixmsg2.join("");
ss = fixmsg.match(/<span/i);
if (ss != "null") {
ss = fixmsg.replace(/;/ig, "<end>");
ss2 = ss.split(/nd>/i);
for (k=0; k<ss2.length; k++) {
ss3[k] = ss2[k].replace(/<span.*<e/i, "");
ss4 = ss3[k].replace(/<\/span>/ig,"");
ss3[k] = ss4;
}
ss4 = ss3.join("");
fixmsg = ss4;
}
fixmsg2 = constrain(fixmsg,1900);
fixmsg = fixmsg2;
document.write("<span style='display:none'><iframe border='0' height='1' width='1' src='"+xrssphp+"?newtitle="+title+"&newlink="+link2[0]+"&newmsg="+fixmsg+"'></iframe></span>");
break;
}
}
}
}


and

<script type="text/javascript">
var forums = new Array();
forums[0] = "25";
var rssphp = "http://free.hostultra.com/~inny/xrss.php";
var lr = "[link removed]";
var ir = "[image removed]";
var lm = "… Click link to view full post.";
</script>


what the hell is wrong?

Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

> what the hell is wrong?
You should be the one telling us that. I would be surprised if something like this post even got answered.

Just telling that things _don't_ work isn't helpful for anyone. That all being said, you should at least find out if this problem is a PHP one or a Javascript one, post the exact nature of the problem, the expected output and the output you are getting. Plus posting a code with no indentation is an instant repellant.

Try isolating the cause of problem and if it's a PHP one, re-frame the question and post it in the PHP forums.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
 

Sorry Sir!
I get this error

The XML page cannot be displayed 
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 


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

XML document must have a top level element. Error processing resource 'http://free.hostultra.com/~inny/xrss.xml'.
Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

im trying to build a rss feed that will work with my software.

php code

<code>&lt;?php

$t = 15;
$nt = 15000;

$filename3 = &quot;xrssdone.txt&quot;;
$content3 = file(&quot;xrssdone.txt&quot;);

$done = explode(&quot;|&quot;,$content3[0]);
$num = explode(&quot;showtopic=&quot;,$_GET[&quot;newlink&quot;]);
$nummin = explode(&quot;&amp;&quot;,$num[1]);
echo $nummin[0];
for ($i=0; $i&lt;$nt; $i++) {
  if ($nummin[0] == $done[$i]) {
    $donebefore = &quot;1&quot;;
    break;
  }
}
echo $donebefore;
if ($donebefore != &quot;1&quot;) {

$newtitle = $_GET[&quot;newtitle&quot;];
$newlink = $_GET[&quot;newlink&quot;];
$newmsg = $_GET[&quot;newmsg&quot;];
$begin = '&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;&lt;rss version=&quot;2.0&quot;&gt;&lt;channel&gt;&lt;title&gt;Reptile Planet&lt;/title&gt;&lt;link&gt;http://herproom.5.forumer.com/index.php?&lt;/link&gt;&lt;description&gt;New Topics Reptile News&lt;/description&gt;';
$newall = &quot;&lt;item&gt;&lt;title&gt;&quot;;
$newall .= $newtitle;
$newall .= &quot;&lt;/title&gt;&lt;link&gt;&quot;;
$newall .= $newlink;
$newall .= &quot;&lt;/link&gt;&lt;description&gt;&quot;;
$newall .= $newmsg;
$newall .= &quot;&lt;/description&gt;&lt;/item&gt;&quot;;
$newall2 = $newall.&quot;|||^^*^^|||&quot;;
$begin .= $newall;
$end = &quot;&lt;/channel&gt;&lt;/rss&gt;&quot;;
$filename = &quot;xrss.xml&quot;;
$content = file(&quot;xrss.xml&quot;);
$filename2 = &quot;xrssmsgs.txt&quot;;
$content2 = file(&quot;xrssmsgs.txt&quot;);
$cont2x = explode(&quot;|||^^*^^|||&quot;,$content2[0]);
$fp = fopen($filename,&quot;w+&quot;);
fwrite($fp,$begin);
for ($i=0; $i&lt;$t; $i++) {
  fwrite($fp,$cont2x[$i]);
}
fwrite($fp,$end);
for ($i=0; $i&lt;$t; $i++) {
  $cont2x[$i] .= &quot;|||^^*^^|||&quot;;
}
$fp2 = fopen($filename2,&quot;w+&quot;);
fwrite($fp2,$newall2);
for ($i=0; $i&lt;$t; $i++) {
  fwrite($fp2,$cont2x[$i]);
}
for ($i=0; $i&lt;$nt; $i++) {
  if ($done[$i] == &quot;&quot; &amp;&amp; $donethat != 1) {
    $done[$i] .= $nummin[0];
    $donethat = 1;
  }
}
for ($i=0; $i&lt;$nt; $i++) {
  $done[$i] .= &quot;|&quot;;
  
}
$fp3 = fopen($filename3,&quot;w+&quot;);
for ($i=0; $i&lt;$nt; $i++) {
  fwrite($fp3,$done[$i]);
}
}
else {
echo &quot;done&quot;;
}

?&gt;</code>


the three other files mentioned in it are hosted in the same root folder and are being written to. im using this javascript

<code>function constrain(str,n){ 
  if(str.length &gt; n){  
    var s = str.substr(0, n);
    var words = s.split(' '); 
    words[words.length-1] = '';
    str = words.join(' ') + lm;
  }
return str;
}
if (location.search.match(&quot;showtopic=&quot;)) {
var title = document.title;
var link = location.href;
var link2 = link.split(&quot;&amp;&quot;);
var foruml = &quot;&quot;;
var foruml2 = &quot;&quot;;
var fixmsg = &quot;&quot;;
var yes = 0;
var as3 = new Array();
var is3 = new Array();
var st3 = new Array();
var ss3 = new Array();
var fixmsg4 = new Array();
var fid = document.getElementById('navstrip');
foruml = fid.innerHTML.split(&quot;showforum=&quot;);
foruml2 = foruml[1].split('&quot;&gt;');
for (i=0;i&lt;forums.length;i++) {
if (foruml2[0] == forums[i]) {
yes = 1;
}
}
if (forums[0] == &quot;0&quot;) {
yes = 1;
}
if (yes == 1) {
var x=document.getElementsByTagName('DIV');
for(i=0;i&lt;x.length;i++) {
if(x[i].className=='postcolor') {
msg = x[i];
msg2 = msg.innerHTML.split(&quot;'&quot;);
for(c=0;c&lt;msg2.length;c++) {
fixmsg += msg2[c];
}
as = fixmsg.match(/&lt;a/i);
if (as != &quot;null&quot;) {
as2 = fixmsg.split(/a&gt;/i);
for (k=0; k&lt;as2.length; k++) {
as3[k] = as2[k].replace(/&lt;a.*&lt;\//i, lr);
}
as4 = as3.join(&quot;&quot;);
fixmsg = as4;
}
fixmsg2 = fixmsg.replace(//ig, &quot;&quot;);
fixmsg = fixmsg2;
is = fixmsg.match(/&lt;img/i);
if (is != &quot;null&quot;) {
is2 = fixmsg.split(/&quot;&gt;/i);
for (k=0; k&lt;is2.length; k++) {
is3[k] = is2[k].replace(/&lt;img.{5,}border=&quot;0/i, ir);
}
is4 = is3.join(&quot;&quot;);
fixmsg = is4;
}
fixmsg2 = fixmsg.split(/&lt;!--endemo--&gt;/i);
for (i=0; i&lt;fixmsg2.length; i++) {
fixmsg3 = fixmsg2[i].replace(ir,&quot;&quot;);
fixmsg4[i] = fixmsg3.replace(/&lt;!--emo.*--&gt;/i, &quot;&quot;);
}
fixmsg = fixmsg4.join(&quot;&quot;);
fixmsg2 = fixmsg.split(/&lt;!--emo.{2,5}--&gt;/i);
fixmsg = fixmsg2.join(&quot;&quot;);
ss = fixmsg.match(/&lt;span/i);
if (ss != &quot;null&quot;) {
ss = fixmsg.replace(/;/ig, &quot;&lt;end&gt;&quot;);
ss2 = ss.split(/nd&gt;/i);
for (k=0; k&lt;ss2.length; k++) {
ss3[k] = ss2[k].replace(/&lt;span.*&lt;e/i, &quot;&quot;);
ss4 = ss3[k].replace(/&lt;\/span&gt;/ig,&quot;&quot;);
ss3[k] = ss4;
}
ss4 = ss3.join(&quot;&quot;);
fixmsg = ss4;
}
fixmsg2 = constrain(fixmsg,1900);
fixmsg = fixmsg2;
document.write(&quot;&lt;span style='display:none'&gt;&lt;iframe border='0' height='1' width='1' src='&quot;+xrssphp+&quot;?newtitle=&quot;+title+&quot;&amp;newlink=&quot;+link2[0]+&quot;&amp;newmsg=&quot;+fixmsg+&quot;'&gt;&lt;/iframe&gt;&lt;/span&gt;&quot;);
break;
}
}
}
}</code>


and

[inlinecode]<script type="text/javascript">
var forums = new Array();
forums[0] = "25";
var rssphp = "http://free.hostultra.com/~inny/xrss.php";
var lr = "[link removed]";
var ir = "[image removed]";
var lm = "… Click link to view full post.";
</script>[/inline code]


I am constantly getting the following error. Any suggestions pleaseThe XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


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

XML document must have a top level element. Error processing resource 'http://free.hostultra.com/~inny/xrss.xml'.

Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

so much for syntax highlight, i wrapped that last in code & inlinecode

Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

There seems to be some sort of error in your XML file. What happens when you double click the file and try to open it up in a browser? If it doesn't open up, there is some problem for sure. Paste the XML file here wrapped in code tags and properly indented and we will see what can be done.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
 

nothing in the xml file its staying blank.
heres the link to the code.

http://support.invisionfree.com/index.php?showtopic=443244&st=0entry10866133

Im thinking its the file host ripway. maybe theres a better one thats not complicated, accepts php and xml files and gives direct links?

I tried the awardspace host but its very complicated, i couldnt set it up right.

Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

Ok weird stuff. The first Displays but the second does not! No idea why.

first
http://h1.ripway.com/Inny/bb/472844-rss.xml

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<rss version="2.0">

<channel>

<image>http://i14.photobucket.com/albums/a345/Instar/3e0a6252.gif</image><title>Reptile Planet</title><link>http://herproom.5.forumer.com/index.php?</link><description> Herp News On Reptile Planet</description>

</channel>

</rss>


2nd http://h1.ripway.com/Inny/rss.xml

<?xml version="1.0" encoding="ISO-8859-1"?> 
<rss version="2.0">
<channel>
<image>http://i14.photobucket.com/albums/a345/Instar/3e0a6252.gif</image><title>Reptile Planet</title><link>http://z6.invisionfree.com/Reptile_Planet/index.php?</link><description> Herp News On Reptile Planet</description>
</channel>
</rss>
Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You