User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,519 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,821 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1111 | Replies: 7
Reply
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Rss, php, javascript nightmare! help?

  #1  
Oct 2nd, 2007
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(/<br>/ig, "<br />");
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?
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 7,012
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 368
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Rss, php, javascript nightmare! help?

  #2  
Oct 2nd, 2007
> 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.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

  #3  
Oct 2nd, 2007
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'. 
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

  #4  
Oct 3rd, 2007
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(/<br>/ig, "<br />");
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
[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 please

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'.
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

  #5  
Oct 3rd, 2007
so much for syntax highlight, i wrapped that last in code & inlinecode
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 7,012
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 368
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Rss, php, javascript nightmare! help?

  #6  
Oct 3rd, 2007
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.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

  #7  
Oct 3rd, 2007
nothing in the xml file its staying blank.
heres the link to the code.

http://support.invisionfree.com/inde...#entry10866133

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.
Last edited by Inny : Oct 3rd, 2007 at 2:35 pm.
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

  #8  
Oct 3rd, 2007
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>
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 4:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC