I Have been using this script with mambo and would like to use it also with my TP installation but I cant seem to make this work!!
I always get this error from the php test!
Any idea why?
Parse error: parse error, unexpected '<' in /home/httpd/vhosts/musakk.net/httpdocs/forum/TPpreview.php(18) : eval()'d code on line 1
<?php
$host = "xevino.dyndns.org";
$port = "8000";
// Connect to server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
} else {
// Get data from server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");
// exit if connection broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(500000);
}
// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);
// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);
if ($status == "1") {
} else {
echo "<center>The radio station is currently down<br>Last Song that was<br>";
} }
// This is where you change the box layout
if (!$fp) {
echo "<center>Server Is Down, We are working on it, Maybe.";
} else {
echo "<center>Playing on the Radio: <br><marquee><a href=\"http://xevino.dyndns.org:8000/listen.pls\">$song</a></marquee><br>Bitrate @ $bit kpbs <br> Listeners: $current / $max";
}
?>
Try to lose the <?php and ?> tags, you don't need them.
Does it work better then..?
I get more errors if i take them out!
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/httpd/vhosts/musakk.net/httpdocs/forum/TPpreview.php(18) : eval()'d code on line 1
Parse error: parse error, unexpected $ in /home/httpd/vhosts/musakk.net/httpdocs/forum/TPpreview.php(18) : eval()'d code on line 1
???? any more suggestions?
This code...
if (!$fp) {
} else {
and this...
if ($status == "1") {
} else {
They both seem to miss a action if the statement is true..only the false outcome has a action defined. Try to define a dummy there, like:
if (!$fp) {
$dummy=true;
} else {
and this...
if ($status == "1") {
$dummy=true;
} else {
Deos that make any difference? (try it both with the <?php tags , and without.)
here the new code!
<?php
$host = "xevino.dyndns.org";
$port = "8000";
// Connect to server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
$dummy=true;
} else {
// Get data from server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");
// exit if connection broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(500000);
}
// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);
// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);
if ($status == "1") {
$dummy=true;
} else {
echo "<center>The radio station is currently down<br>Last Song that was<br>";
} }
// This is where you change the box layout
if (!$fp) {
echo "<center>Server Is Down, We are working on it, Maybe.";
} else {
echo "<center>Playing on the Radio: <br><marquee><a href=\"http://xevino.dyndns.org:8000/listen.pls\">$song</a></marquee><br>Bitrate @ $bit kpbs <br> Listeners: $current / $max";
}
?>
I did the changes and it still gave me the same errors?
With... the <?php
Parse error: parse error, unexpected '<' in /home/httpd/vhosts/musakk.net/httpdocs/forum/TPpreview.php(18) : eval()'d code on line 1
Without... the <?php
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/httpd/vhosts/musakk.net/httpdocs/forum/TPpreview.php(18) : eval()'d code on line 1
Parse error: parse error, unexpected $ in /home/httpd/vhosts/musakk.net/httpdocs/forum/TPpreview.php(18) : eval()'d code on line 1
any other thought?
Have you got this to work with other codes??
Just ignore the preview error, I just tried it in a phpbox-type block( without the <?php tags) and it worked perfectly. :)
Niiiicee!!!! it works!
Duuuude this is coming out reall goood!!
;D ;D ;D ;D ;D ;D ;D ;D :D :D :D :D :D :) :) :) :) :)
Thank yo soo much, your mod and all your support is incredible!
You have helped me with all my little fits!! this far!!
I THANK YOU VERY MUCHO!!!!
Sh33zo
apologies for bumping an old thread but I have a question about the php preview.
I have a block which displays fine although when I try to preview it I get the following error:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/britp2/public_html/forum/TPpreview.php(18) : eval()'d code on line 1
Parse error: parse error, unexpected $ in /home/britp2/public_html/forum/TPpreview.php(18) : eval()'d code on line 1
the code is simple:
echo $_SERVER['HTTP_USER_AGENT'];
And it works just fine in a browser. I have looked and couldnt find any ideas where to start about this one other than this thread!
:o
@redone
echo $_SERVER['HTTP_USER_AGENT'];
this one works fine with me.. did you select 'phpbox'
Fixed it.:
echo $_SERVER['HTTP_USER_AGENT'];
echo '<p>Your IP address is:</p>';
echo $_SERVER['REMOTE_ADDR'];
Works very well but still does not preview correctly even though the code works in a browser!
yes...the preview isn't perfect, its more of an "quick-fix" to see if something breaks. It doesn't run the code through the forum, but just on its own. So it might actually work fine..but not in the preview function.
The advantage is that if something break, it won't make the forum/portal break too.