Rss, php, javascript nightmare! help?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Rss, php, javascript nightmare! help?

 
0
  #1
Oct 2nd, 2007
im trying to build a rss feed that will work with my software.

php code

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $t = 15;
  4. $nt = 15000;
  5.  
  6. $filename3 = "xrssdone.txt";
  7. $content3 = file("xrssdone.txt");
  8.  
  9. $done = explode("|",$content3[0]);
  10. $num = explode("showtopic=",$_GET["newlink"]);
  11. $nummin = explode("&",$num[1]);
  12. echo $nummin[0];
  13. for ($i=0; $i<$nt; $i++) {
  14. if ($nummin[0] == $done[$i]) {
  15. $donebefore = "1";
  16. break;
  17. }
  18. }
  19. echo $donebefore;
  20. if ($donebefore != "1") {
  21.  
  22. $newtitle = $_GET["newtitle"];
  23. $newlink = $_GET["newlink"];
  24. $newmsg = $_GET["newmsg"];
  25. $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>';
  26. $newall = "<item><title>";
  27. $newall .= $newtitle;
  28. $newall .= "</title><link>";
  29. $newall .= $newlink;
  30. $newall .= "</link><description>";
  31. $newall .= $newmsg;
  32. $newall .= "</description></item>";
  33. $newall2 = $newall."|||^^*^^|||";
  34. $begin .= $newall;
  35. $end = "</channel></rss>";
  36. $filename = "xrss.xml";
  37. $content = file("xrss.xml");
  38. $filename2 = "xrssmsgs.txt";
  39. $content2 = file("xrssmsgs.txt");
  40. $cont2x = explode("|||^^*^^|||",$content2[0]);
  41. $fp = fopen($filename,"w+");
  42. fwrite($fp,$begin);
  43. for ($i=0; $i<$t; $i++) {
  44. fwrite($fp,$cont2x[$i]);
  45. }
  46. fwrite($fp,$end);
  47. for ($i=0; $i<$t; $i++) {
  48. $cont2x[$i] .= "|||^^*^^|||";
  49. }
  50. $fp2 = fopen($filename2,"w+");
  51. fwrite($fp2,$newall2);
  52. for ($i=0; $i<$t; $i++) {
  53. fwrite($fp2,$cont2x[$i]);
  54. }
  55. for ($i=0; $i<$nt; $i++) {
  56. if ($done[$i] == "" && $donethat != 1) {
  57. $done[$i] .= $nummin[0];
  58. $donethat = 1;
  59. }
  60. }
  61. for ($i=0; $i<$nt; $i++) {
  62. $done[$i] .= "|";
  63.  
  64. }
  65. $fp3 = fopen($filename3,"w+");
  66. for ($i=0; $i<$nt; $i++) {
  67. fwrite($fp3,$done[$i]);
  68. }
  69. }
  70. else {
  71. echo "done";
  72. }
  73.  
  74. ?>

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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function constrain(str,n){
  2. if(str.length > n){
  3. var s = str.substr(0, n);
  4. var words = s.split(' ');
  5. words[words.length-1] = '';
  6. str = words.join(' ') + lm;
  7. }
  8. return str;
  9. }
  10. if (location.search.match("showtopic=")) {
  11. var title = document.title;
  12. var link = location.href;
  13. var link2 = link.split("&");
  14. var foruml = "";
  15. var foruml2 = "";
  16. var fixmsg = "";
  17. var yes = 0;
  18. var as3 = new Array();
  19. var is3 = new Array();
  20. var st3 = new Array();
  21. var ss3 = new Array();
  22. var fixmsg4 = new Array();
  23. var fid = document.getElementById('navstrip');
  24. foruml = fid.innerHTML.split("showforum=");
  25. foruml2 = foruml[1].split('">');
  26. for (i=0;i<forums.length;i++) {
  27. if (foruml2[0] == forums[i]) {
  28. yes = 1;
  29. }
  30. }
  31. if (forums[0] == "0") {
  32. yes = 1;
  33. }
  34. if (yes == 1) {
  35. var x=document.getElementsByTagName('DIV');
  36. for(i=0;i<x.length;i++) {
  37. if(x[i].className=='postcolor') {
  38. msg = x[i];
  39. msg2 = msg.innerHTML.split("'");
  40. for(c=0;c<msg2.length;c++) {
  41. fixmsg += msg2[c];
  42. }
  43. as = fixmsg.match(/<a/i);
  44. if (as != "null") {
  45. as2 = fixmsg.split(/a>/i);
  46. for (k=0; k<as2.length; k++) {
  47. as3[k] = as2[k].replace(/<a.*<\//i, lr);
  48. }
  49. as4 = as3.join("");
  50. fixmsg = as4;
  51. }
  52. fixmsg2 = fixmsg.replace(/<br>/ig, "<br />");
  53. fixmsg = fixmsg2;
  54. is = fixmsg.match(/<img/i);
  55. if (is != "null") {
  56. is2 = fixmsg.split(/">/i);
  57. for (k=0; k<is2.length; k++) {
  58. is3[k] = is2[k].replace(/<img.{5,}border="0/i, ir);
  59. }
  60. is4 = is3.join("");
  61. fixmsg = is4;
  62. }
  63. fixmsg2 = fixmsg.split(/<!--endemo-->/i);
  64. for (i=0; i<fixmsg2.length; i++) {
  65. fixmsg3 = fixmsg2[i].replace(ir,"");
  66. fixmsg4[i] = fixmsg3.replace(/<!--emo.*-->/i, "");
  67. }
  68. fixmsg = fixmsg4.join("");
  69. fixmsg2 = fixmsg.split(/<!--emo.{2,5}-->/i);
  70. fixmsg = fixmsg2.join("");
  71. ss = fixmsg.match(/<span/i);
  72. if (ss != "null") {
  73. ss = fixmsg.replace(/;/ig, "<end>");
  74. ss2 = ss.split(/nd>/i);
  75. for (k=0; k<ss2.length; k++) {
  76. ss3[k] = ss2[k].replace(/<span.*<e/i, "");
  77. ss4 = ss3[k].replace(/<\/span>/ig,"");
  78. ss3[k] = ss4;
  79. }
  80. ss4 = ss3.join("");
  81. fixmsg = ss4;
  82. }
  83. fixmsg2 = constrain(fixmsg,1900);
  84. fixmsg = fixmsg2;
  85. document.write("<span style='display:none'><iframe border='0' height='1' width='1' src='"+xrssphp+"?newtitle="+title+"&newlink="+link2[0]+"&newmsg="+fixmsg+"'></iframe></span>");
  86. break;
  87. }
  88. }
  89. }
  90. }

and

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. var forums = new Array();
  3. forums[0] = "25";
  4. var rssphp = "http://free.hostultra.com/~inny/xrss.php";
  5. var lr = "[link removed]";
  6. var ir = "[image removed]";
  7. var lm = "… Click link to view full post.";
  8. </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
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,617
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Rss, php, javascript nightmare! help?

 
0
  #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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

 
0
  #3
Oct 2nd, 2007
Sorry Sir!
I get this error

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. The XML page cannot be displayed
  2. Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
  3.  
  4.  
  5. --------------------------------------------------------------------------------
  6.  
  7. 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 Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

 
0
  #4
Oct 3rd, 2007
im trying to build a rss feed that will work with my software.

php code


JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <span class="ad_notxt"><code class="inlinecode"><?php
  2.  
  3. $t = 15;
  4. $nt = 15000;
  5.  
  6. $filename3 = "xrssdone.txt";
  7. $content3 = file("xrssdone.txt");
  8.  
  9. $done = explode("|",$content3[0]);
  10. $num = explode("showtopic=",$_GET["newlink"]);
  11. $nummin = explode("&",$num[1]);
  12. echo $nummin[0];
  13. for ($i=0; $i<$nt; $i++) {
  14. if ($nummin[0] == $done[$i]) {
  15. $donebefore = "1";
  16. break;
  17. }
  18. }
  19. echo $donebefore;
  20. if ($donebefore != "1") {
  21.  
  22. $newtitle = $_GET["newtitle"];
  23. $newlink = $_GET["newlink"];
  24. $newmsg = $_GET["newmsg"];
  25. $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>';
  26. $newall = "<item><title>";
  27. $newall .= $newtitle;
  28. $newall .= "</title><link>";
  29. $newall .= $newlink;
  30. $newall .= "</link><description>";
  31. $newall .= $newmsg;
  32. $newall .= "</description></item>";
  33. $newall2 = $newall."|||^^*^^|||";
  34. $begin .= $newall;
  35. $end = "</channel></rss>";
  36. $filename = "xrss.xml";
  37. $content = file("xrss.xml");
  38. $filename2 = "xrssmsgs.txt";
  39. $content2 = file("xrssmsgs.txt");
  40. $cont2x = explode("|||^^*^^|||",$content2[0]);
  41. $fp = fopen($filename,"w+");
  42. fwrite($fp,$begin);
  43. for ($i=0; $i<$t; $i++) {
  44. fwrite($fp,$cont2x[$i]);
  45. }
  46. fwrite($fp,$end);
  47. for ($i=0; $i<$t; $i++) {
  48. $cont2x[$i] .= "|||^^*^^|||";
  49. }
  50. $fp2 = fopen($filename2,"w+");
  51. fwrite($fp2,$newall2);
  52. for ($i=0; $i<$t; $i++) {
  53. fwrite($fp2,$cont2x[$i]);
  54. }
  55. for ($i=0; $i<$nt; $i++) {
  56. if ($done[$i] == "" && $donethat != 1) {
  57. $done[$i] .= $nummin[0];
  58. $donethat = 1;
  59. }
  60. }
  61. for ($i=0; $i<$nt; $i++) {
  62. $done[$i] .= "|";
  63.  
  64. }
  65. $fp3 = fopen($filename3,"w+");
  66. for ($i=0; $i<$nt; $i++) {
  67. fwrite($fp3,$done[$i]);
  68. }
  69. }
  70. else {
  71. echo "done";
  72. }
  73.  
  74. ?></code></span>

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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <span class="ad_notxt"><code class="inlinecode">
  2. function constrain(str,n){
  3. if(str.length > n){
  4. var s = str.substr(0, n);
  5. var words = s.split(' ');
  6. words[words.length-1] = '';
  7. str = words.join(' ') + lm;
  8. }
  9. return str;
  10. }
  11. if (location.search.match("showtopic=")) {
  12. var title = document.title;
  13. var link = location.href;
  14. var link2 = link.split("&");
  15. var foruml = "";
  16. var foruml2 = "";
  17. var fixmsg = "";
  18. var yes = 0;
  19. var as3 = new Array();
  20. var is3 = new Array();
  21. var st3 = new Array();
  22. var ss3 = new Array();
  23. var fixmsg4 = new Array();
  24. var fid = document.getElementById('navstrip');
  25. foruml = fid.innerHTML.split("showforum=");
  26. foruml2 = foruml[1].split('">');
  27. for (i=0;i<forums.length;i++) {
  28. if (foruml2[0] == forums[i]) {
  29. yes = 1;
  30. }
  31. }
  32. if (forums[0] == "0") {
  33. yes = 1;
  34. }
  35. if (yes == 1) {
  36. var x=document.getElementsByTagName('DIV');
  37. for(i=0;i<x.length;i++) {
  38. if(x[i].className=='postcolor') {
  39. msg = x[i];
  40. msg2 = msg.innerHTML.split("'");
  41. for(c=0;c<msg2.length;c++) {
  42. fixmsg += msg2[c];
  43. }
  44. as = fixmsg.match(/<a/i);
  45. if (as != "null") {
  46. as2 = fixmsg.split(/a>/i);
  47. for (k=0; k<as2.length; k++) {
  48. as3[k] = as2[k].replace(/<a.*<\//i, lr);
  49. }
  50. as4 = as3.join("");
  51. fixmsg = as4;
  52. }
  53. fixmsg2 = fixmsg.replace(/<br>/ig, "<br />");
  54. fixmsg = fixmsg2;
  55. is = fixmsg.match(/<img/i);
  56. if (is != "null") {
  57. is2 = fixmsg.split(/">/i);
  58. for (k=0; k<is2.length; k++) {
  59. is3[k] = is2[k].replace(/<img.{5,}border="0/i, ir);
  60. }
  61. is4 = is3.join("");
  62. fixmsg = is4;
  63. }
  64. fixmsg2 = fixmsg.split(/<!--endemo-->/i);
  65. for (i=0; i<fixmsg2.length; i++) {
  66. fixmsg3 = fixmsg2[i].replace(ir,"");
  67. fixmsg4[i] = fixmsg3.replace(/<!--emo.*-->/i, "");
  68. }
  69. fixmsg = fixmsg4.join("");
  70. fixmsg2 = fixmsg.split(/<!--emo.{2,5}-->/i);
  71. fixmsg = fixmsg2.join("");
  72. ss = fixmsg.match(/<span/i);
  73. if (ss != "null") {
  74. ss = fixmsg.replace(/;/ig, "<end>");
  75. ss2 = ss.split(/nd>/i);
  76. for (k=0; k<ss2.length; k++) {
  77. ss3[k] = ss2[k].replace(/<span.*<e/i, "");
  78. ss4 = ss3[k].replace(/<\/span>/ig,"");
  79. ss3[k] = ss4;
  80. }
  81. ss4 = ss3.join("");
  82. fixmsg = ss4;
  83. }
  84. fixmsg2 = constrain(fixmsg,1900);
  85. fixmsg = fixmsg2;
  86. document.write("<span style='display:none'><iframe border='0' height='1' width='1' src='"+xrssphp+"?newtitle="+title+"&newlink="+link2[0]+"&newmsg="+fixmsg+"'></iframe></span>");
  87. break;
  88. }
  89. }
  90. }
  91. }</code></span>

and
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. [inlinecode]<script type="text/javascript">
  2. var forums = new Array();
  3. forums[0] = "25";
  4. var rssphp = "http://free.hostultra.com/~inny/xrss.php";
  5. var lr = "[link removed]";
  6. var ir = "[image removed]";
  7. var lm = "… Click link to view full post.";
  8. </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 Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

 
0
  #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 Quick reply to this message  
Join Date: Jun 2006
Posts: 7,617
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Rss, php, javascript nightmare! help?

 
0
  #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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

 
0
  #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 Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Rss, php, javascript nightmare! help?

 
0
  #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
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="ISO-8859-1" ?>
  2. <rss version="2.0">
  3.  
  4. <channel>
  5.  
  6. <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>
  7.  
  8. </channel>
  9.  
  10. </rss>

2nd

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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <rss version="2.0">
  3. <channel>
  4. <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>
  5. </channel>
  6. </rss>
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC