Denora Stats (discontinued) > phpDenora 1.4.x Support (Read Only)

phpdenora.php and remote.php don't work

(1/1)

Cobraz:
Hi,

First, I am French and I'm sorry for the poor quality of my English ;-)

So, I'm trying for days to use phpdenora.php and remote.php to incorporate data directly to my site but it didn't work.

I want to get the code to display the typical information on this page that it works: http://serveur.skreikes.fr/~sgr/phpdenora/index.php?m=c&p=chan&sort=words&type=2&chan=%23stargate-reborn

... but my page with my code shown: No Data! ==> For see it, go to : http://serveur.skreikes.fr/~sgr/phpdenora/stats.php


here is the code of my page stats.php:


--- Code: ---<?php
// $Id$

/* ---------------------------------------------.
This file is an example on how the remote   |
data fetch feature of phpDenora can be used |
   ---------------------------------------------´
*/

#die('This is an example file and should be used for testing only.<br />If you want to test, edit me and comment the \'die\' line');

# Set this to the URL of your phpDenora installation, trailing slash included
$phpdenora_url = "http://serveur.skreikes.fr/~sgr/phpdenora/";
# Set this to the wished time format
#$denora_format_time = "%A %d %B %Y, %I:%M %p"; # 12 hour format
$denora_format_time = "%A %d %B %Y, %R"; # 24 hour format

ini_set('display_errors','on');

/* This useful function parses the data and returns an array */
function remote_data($func,$param)
{
global $phpdenora_url;
flush();
$data = fopen($phpdenora_url."remote.php?func=".$func."&param=".$param, "rt");
if (!$data) {
die("Unable to connect to $phpdenora_url");
}
$i = 0; $array = array();
while ($line = fgets($data)) {
$line = str_replace("\n", "", $line);
$vals = explode("\t", $line);
if (count($vals) > 1) {
$j = 0;
foreach ($vals as $val) {
$array[$i][$j++] = $val;
}
}
else {
$array[$i] = $line;
}
$i++;
}
return $array;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>phpDenora Remote Example</title>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #333333;
}
body {
background-color: #F5F3EB;
margin: 0px;
}
div.section {
width: 600px;
margin-left: auto;
margin-right: auto;
margin-bottom: 5px;
padding: 3px;
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
}
-->
</style></head>

<body>
<div style="border-bottom: 1px solid #CCCCCC; background-color: #66CCFF; margin: 0px 0px 5px 0px; padding: 3px;"><h1 style="text-align: center;">phpDenora Remote Example</h1></div>
<div class="section"><h2>Welcome</h2>
<p>This file can serve you as an example of how to access and process the remote information phpDenora makes available, so you can easilly integrate that into your web site. </p>
<p>You can find more information in docs/REMOTE </p>
</div>
<?php
/* ------------------.
Some Examples... |
   ------------------´
*/

/* Get the number of users in a channel */
$chan = "#stargate-reborn";
echo "<div class=\"section\"><h2>Channel Stats for $chan</h2>";
echo "<h3>Channel users</h3>";
if ($data = remote_data("numinchan",urlencode(html_entity_decode($chan)))) {
if (count($data) >= 1 && $data[0])
echo "<p>There are currently <strong>".$data[0]."</strong> users on <strong>$chan</strong>.</p>";
else
echo "<p>The channel <strong>$chan</strong> seems to be empty</p>";
} else { echo "<p>No data</p>"; }

/* Get the user list */
if ($data = remote_data("userlist",urlencode(html_entity_decode($chan)))) {
echo "<ul>";
foreach ($data as $user) {
echo "<li>$user</li>";
}
echo "</ul>";
} else { echo "<p>No data</p>"; }

/* Get the user peak of a channel */
if ($data = remote_data("chanpeak",urlencode(html_entity_decode($chan)))) {
if (count($data) >= 2 && $data[0])
echo "<p>User peak: <strong>".$data[0]."</strong> on <strong>".strftime($denora_format_time, $data[1])."</strong>.</p>";
} else { echo "<p>No data</p>"; }

/* Get the channel topic */
echo "<h3>Channel topic</h3>";
if ($data = remote_data("chantopic",urlencode(html_entity_decode($chan)))) {
if (count($data) >= 3 && $data[0]) {
echo "<p>Topic: " . $data[0] . "</p>";
echo "<p>Set by: <strong>" . $data[1] . "</strong> on <strong>" . strftime($denora_format_time, $data[2]) . "</strong></p>";
} else {
echo "<p><em>No topic set</em></p>";
}
} else { echo "<p>No data</p>"; }

echo "</div><div class=\"section\"><h2>User Stats</h2>";

/* Get the opers list */
echo "<h3>Current Operators</h3>";
if ($data = remote_data("operlist",urlencode(html_entity_decode($chan)))) {
echo "<ul>";
foreach ($data as $user) {
echo "<li>$user</li>";
}
echo "</ul>";
} else { echo "<p>No data</p>"; }

echo "</div>";



?>

<img src="http://serveur.skreikes.fr/~sgr/phpdenora/libs/phpdenora/graphs/bar.php?theme=modern&lang=fr&mode=chan&chan=%23stargate-reborn&type=2" alt="Global Cuntry Stats" />

</body>
</html>
--- End code ---


Only my graph works...

Please, help me ! :)

CrazyCat:
Hi Cobraz,

Do you think to enable the $pd_enremote in your config ?

--- Code: ---# Enable the remote api interface, which enables to easilly embed data in web sites
$pd_enremote = true;
--- End code ---

Cobraz:
Thanks CrazyCat, it works ! (a huge oversight =S)

I have a second question:

What is the code to bring up a chart like the second part of this stats page : http://serveur.skreikes.fr/~sgr/phpdenora/index.php?m=c&p=chan&sort=words&type=2&chan=%23stargate-reborn ... with the stats of a user chan

Cob.

Navigation

[0] Message Index

Go to full version