PHP code in template?

i just moved it to the same directory, renamed the callback script 'index.php', now i get no error, but i also get no text or anything.
Don't use echo. Assign whatever you want to output to the browser to your $output variable.
 
Here are my files as it stands at the moment:

/Library/Example/Scripts/index.php
PHP:
<?php
class Example_Scripts_index {
  public static function getHtml() {
    include '/online.php';
    return $output;
  }
}
?>
/Library/Example/Scripts/online.php
PHP:
<?php
$output = 'Hello World';
?>

node_category_level_1
Code:
<xen:callback class="Example_Scripts_index" method="getHtml"></xen:callback>

Everything is good, no? Im getting no error, and no result.

Don't use echo. Assign whatever you want to output to the browser to your $output variable.
im not using echo.
 
As an example change your index.php to this:

PHP:
<?php
class Example_Scripts_index {
  public static function getHtml() {
    //include '/forum/serverstatus/online.php';
    $output = 'Hello World';
    return $output;
  }
}
?>
 
I don't think you are including the online.php file correctly. Use a relative or full path. The way you have it right now is assuming you have online.php in the root of your file system.
 
As an example change your index.php to this:

PHP:
<?php
class Example_Scripts_index {
  public static function getHtml() {
    //include '/forum/serverstatus/online.php';
    $output = 'Hello World';
    return $output;
  }
}
?>
that worked.
 
I don't think you are including the online.php file correctly. Use a relative or full path. The way you have it right now is assuming you have online.php in the root of your file system.
didnt work. i even tried moving the file to the root directory and still not working.
 
The include should be something like:

PHP:
include '/home/path/www/forum/serverstatus/online.php';
 
The include should be something like:

PHP:
include '/home/path/www/forum/serverstatus/online.php';
nope. my path is actually /var/www/vhosts/domain.com/httpdocs/forum/serverstatus/online.php and that doesnt work either.
 
As a test, change the online.php to this:

PHP:
<?php
$output = 'Hello World';
?>

Also make sure index.php returns $output.
 
Can you repost the content of your online.php file?

PHP:
<?php
$ip = "xxx.xxx.xxx";
$port = "xx";
$online = @fsockopen( $ip, $port, $errno, $errstr, 200);
if($online >= 1) {
echo '<a href="#"><img src="/forum/serveronline.png"></a>';
}
else {
echo '<a href="#"><img src="/forum/serveroffline.png"></a>';
}
?>
 
PHP:
<?php
$ip = "xxx.xxx.xxx";
$port = "xx";
$online = @fsockopen( $ip, $port, $errno, $errstr, 200);
if($online >= 1) {
echo '<a href="#"><img src="/forum/serveronline.png"></a>';
}
else {
echo '<a href="#"><img src="/forum/serveroffline.png"></a>';
}
?>

Don't use echo. Instead, assign that output to $output.
 
no work. this is frustrating me.

Just for debugging purposes, change online.php to:

PHP:
<?php
$ip = "xxx.xxx.xxx";$port = "xx";$online = @fsockopen( $ip, $port, $errno, $errstr, 200);
if($online >= 1) {
echo '<a href="#"><img src="/forum/serveronline.png"></a>';
}
else {
echo '<a href="#"><img src="/forum/serveroffline.png"></a>';
}

exit;
?>

Does it shows you the image?
 
nope. tis no working.

In that case I suggest you double check the path. Make sure this is the correct path.

/var/www/vhosts/domain.com/httpdocs/forum/serverstatus/online.php

make sure the chmod rights are at least 644 on index.php and online.php.
 
Top Bottom