PDA

View Full Version : Getting there


chet
12-13-2004, 06:40 AM
Installed a breeze and also added a few mods/hacks, there are a couple of things I need to get done before I go live and one of them is: -

"how to install a module", if you take a look here (http://www.chetnet.co.uk/ntlstatus.php) you will see a server status php file, I want to be able to put a module in the centre block of my portal, I have the status php file sitting in my modules dir, I think I just need a template which I was hoping one of you guys could help me with

many thanks

Chet

theMusicMan
12-13-2004, 06:46 AM
Nope - don't see a php file, we see the output of that php file...:) If that is all you want to see in your CMPS Module, simply add http://www.chetnet.co.uk/ntlstatus.php as the only additional line in the module - you will then see the status page in your CMPS module.

Our Sponsors
 

chet
12-13-2004, 08:24 AM
Think I have done what you have told me, but the results are not right, the status appears right at the top of the portal, above the banner, here is what I have done

Copied the ntlstatus.php to my modules dir
Added a module called "NTL server status"
File to include ntlstatus.php

then the rest are left blank, I have asked to to be in the centre block.

Where did I go wrong

Thanks

Chet

theMusicMan
12-13-2004, 09:49 AM
Do you have a URL we can look at to see what is happening?

Also, try copying the html link to your template instead of the php file.

Our Sponsors
 

chet
12-13-2004, 09:52 AM
Is it ok to post url's of test boxes as its on the same licence as my live box

chet
12-13-2004, 10:05 AM
Its ok I have just checked about test box....

Excuse the layout, its a bit of a mess at the minute but I want to get all the modules I need before I start to line thing up, any way here is the link to my test box (http://82.20.89.149/cmps/)

Thanks for looking

Chet

Brian
12-13-2004, 10:53 AM
http://www.vbadvanced.com/forum/showthread.php?t=1337
http://www.vbadvanced.com/forum/showthread.php?t=1334

Those threads should explain your problem.

chet
12-13-2004, 12:45 PM
OK that stopped it showing at the top but now it does not show at all, I think it may be because I have not created a template or am I wide of the mark?, all I have done is added a new module and called the php file
You state below
Then add $variable to the new template you created where you would like the output from the file to appear.
So if I need to, how do I create a template so I can add the above $variable, well I know how to create a template just do not know what to put in it

Thanks

Chet

Brian
12-13-2004, 12:48 PM
The method of adding ob_start(); and ob_end(); mentioned in one of those would probably work out better for you in this case.

chet
12-13-2004, 01:08 PM
Sorry I'm not getting this at all because of the lack of knowleadge at the moment, am trying to learn :D

Could you take a look at the code for me and advise please

<?php
ob_start();
$ch = curl_init(); // create cURL handle (ch)
if (!$ch)
{
die('Failed to initialise application.');
}
// set some cURL options
$url = 'http://www.ntl-isp.ntl.com/ServiceStatus/';
$ret = curl_setopt($ch,CURLOPT_URL, $url);
$ret = curl_setopt($ch,CURLOPT_HEADER,false); //don't want the header information
$ret = curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); //follow any redirects
$ret = curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //collect data
$ret = curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)'); //pretend to be using MS IE6
$ret = curl_setopt($ch,CURLOPT_TIMEOUT,30); //timeout

// execute
$ret = curl_exec($ch);
if (empty($ret))
{
// some kind of an error happened - to display the error uncomment line below otherwise 'nice error displayed'.
//die(curl_error($ch));
die('Sorry, we are currently unable to obtain the current ntl: service status.');
curl_close($ch); // close cURL handler
}
else
{
curl_close($ch); // close cURL handler
//The table displaying the status is surrounded by a DIV tag - the only DIV tag in the document.
$start = strpos($ret,'<DIV align="center">') + 20; // + 20 so that the DIV tag is removed
$end = strpos($ret,'</DIV>');
$reqlen = $end - $start; //The length of the text required
//get the required text
$status = substr($ret, $start, $reqlen);
//replace relative paths with full paths
$status = str_replace('ServiceDetails.aspx', 'http://www.ntl-isp.ntl.com/ServiceStatus/ServiceDetails.aspx', $status);
$status = str_replace('images/', 'http://www.ntl-isp.ntl.com/ServiceStatus/images/', $status);
//dump the text
echo $status;
}
?>

Brian
12-13-2004, 01:14 PM
Actually since everything is stored in a variable and then printed out, this should work better:
<?php
$ch = curl_init(); // create cURL handle (ch)
if (!$ch)
{
die('Failed to initialise application.');
}
// set some cURL options
$url = 'http://www.ntl-isp.ntl.com/ServiceStatus/';
$ret = curl_setopt($ch,CURLOPT_URL, $url);
$ret = curl_setopt($ch,CURLOPT_HEADER,false); //don't want the header information
$ret = curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); //follow any redirects
$ret = curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //collect data
$ret = curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)'); //pretend to be using MS IE6
$ret = curl_setopt($ch,CURLOPT_TIMEOUT,30); //timeout

// execute
$ret = curl_exec($ch);
if (empty($ret))
{
// some kind of an error happened - to display the error uncomment line below otherwise 'nice error displayed'.
//die(curl_error($ch));
die('Sorry, we are currently unable to obtain the current ntl: service status.');
curl_close($ch); // close cURL handler
}
else
{
curl_close($ch); // close cURL handler
//The table displaying the status is surrounded by a DIV tag - the only DIV tag in the document.
$start = strpos($ret,'<DIV align="center">') + 20; // + 20 so that the DIV tag is removed
$end = strpos($ret,'</DIV>');
$reqlen = $end - $start; //The length of the text required
//get the required text
$status = substr($ret, $start, $reqlen);
//replace relative paths with full paths
$status = str_replace('ServiceDetails.aspx', 'http://www.ntl-isp.ntl.com/ServiceStatus/ServiceDetails.aspx', $status);
$status = str_replace('images/', 'http://www.ntl-isp.ntl.com/ServiceStatus/images/', $status);
//dump the text

eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_server') . '";');

}
?>

Then create a new template called 'adv_portal_server' and just add $status in the template.

chet
12-13-2004, 01:37 PM
Amazing, thank you very much :D

Chet

chet
12-13-2004, 01:44 PM
How do I make it a little more narrower as its pushing my right hand boxes wider than the screen width

Cheers

Brian
12-13-2004, 02:06 PM
Looks like the width is pulled from the site you're getting that info from.

chet
12-13-2004, 02:25 PM
Thanks for taking time out to help me

Chet

chet
12-13-2004, 03:55 PM
I have been having a think, could the server status be added to the footer at all, then I would not have to get it resized

Chet

chet
12-15-2004, 03:41 AM
Is it possible to put the server status in the footer, if so how would I get it there, I was thinking of having below the "Copyright ©2000 - 2004, Jelsoft Enterprises Ltd. "

Chet

theMusicMan
12-15-2004, 11:51 AM
If you use CMPS there are two footers. Edit either your adv_portal_footer template or the vB footer template...

chet
12-16-2004, 12:37 PM
Thanks for the reply, what do I put in footer, every time I copy and paste the above code over I just get raw code in the footer and not the server status

Thanks

Chet

chet
12-16-2004, 01:57 PM
from further reading I underatand I can call the php file to be included in the footer, I have tried searching for the command but unable to find what I need

How would I call the php file to be included in the footer

Chet

chet
12-16-2004, 03:32 PM
I have put this in my adv_portal_footer

<? php include "ntlstatus.php";?>

I'm not seeing any output at all, where do I need to put the php file, at the minute its in my cmps dir

chet
12-17-2004, 06:11 AM
Anybody :(

chet
12-17-2004, 10:23 AM
I also have the full path there now aswell

<? php include("/home/httpd/vhosts/localhost.localdomain/httpdocs/ntlstatus.php"); ?>

If you then look at the web page source, I see that both are there but not contents being shown, still awaiting for the answer

Chet

Brian
12-17-2004, 11:21 AM
You can't put PHP code like that in your templates. Your best bet would be to add it somewhere within the print_portal_output() function in your vba_cmps_include_bottom.php file.

chet
12-17-2004, 11:30 AM
I guess you know what the next question is going to be...........

Yep, how would I go about achieving that

Chet

triage
12-17-2004, 05:05 PM
we have added
$status
to the footer and that will display the server status...but only provided the module is active (the one that pushes all the content to the right).
is this because the coding above only allows it to beadded to the footer when the module is active?
is it possible to get it to show when the module above is not active?
any help appreciated and appologies for the dumb questions.

[edit] should of added this is the same query as above as chet and myself are working together on this.

Brian
12-17-2004, 05:12 PM
/forum/includes/vba_cmps_include_top.php - Look for this:
eval('print_output("' . fetch_template('adv_portal') . '");');

And try adding your include statement right above that.

triage
12-17-2004, 05:48 PM
i could not find that in
/forum/includes/vba_cmps_include_top.php
but did find it in
/forum/includes/vba_cmps_include_bottom.php which you referenced ealier

when doing as you requested in bottom.php i get

Parse error: parse error, unexpected '<' in /home/httpd/vhosts/localhost.localdomain/httpdocs/portal/forum/includes/vba_cmps_include_bottom.php on line 198

Fatal error: Call to undefined function: print_portal_output() in /home/httpd/vhosts/localhost.localdomain/httpdocs/cmps/index.php on line 27

triage
12-17-2004, 07:06 PM
ok.....got rid of the error message (i left the <? php ?> in the line)
however it is now at the top of the page above the logo and everything......would like it at the bottom by the footer....sorry for being a pain.

Brian
12-18-2004, 10:56 AM
Are you still using the same file that I modified a few posts above?

triage
12-18-2004, 04:38 PM
if i use the one you modified i get
Fatal error: Call to undefined function: fetch_template() in /home/httpd/vhosts/localhost.localdomain/httpdocs/serverstatus.php on line 39
at the top of the page above the logo

if i use the orriginal i get it displaying but at the top of the page above the logo

Brian
12-18-2004, 06:05 PM
Remove the line of code there where you see the fetch_template() function.

triage
12-29-2004, 12:38 PM
sorry for the delay in getting back to you....we had a technicla issue with the test box.

i removed the line
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_server') . '";');

and now it doesnt show at all...the error has gone but it is displaying nothing

chet
01-04-2005, 06:14 AM
This is the code we are using now but we do not get any output, also if I type the url in to OE I just get a blank page

Thanks for the continued support

Chet

<?php
$ch = curl_init(); // create cURL handle (ch)
if (!$ch)
{
die('Failed to initialise application.');
}
// set some cURL options
$url = 'http://www.ntl-isp.ntl.com/ServiceStatus/';
$ret = curl_setopt($ch,CURLOPT_URL, $url);
$ret = curl_setopt($ch,CURLOPT_HEADER,false); //don't want the header information
$ret = curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); //follow any redirects
$ret = curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //collect data
$ret = curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)'); //pretend to be using MS IE6
$ret = curl_setopt($ch,CURLOPT_TIMEOUT,30); //timeout

// execute
$ret = curl_exec($ch);
if (empty($ret))
{
// some kind of an error happened - to display the error uncomment line below otherwise 'nice error displayed'.
//die(curl_error($ch));
die('Sorry, we are currently unable to obtain the current ntl: service status.');
curl_close($ch); // close cURL handler
}
else
{
curl_close($ch); // close cURL handler
//The table displaying the status is surrounded by a DIV tag - the only DIV tag in the document.
$start = strpos($ret,'<DIV align="center">') + 20; // + 20 so that the DIV tag is removed
$end = strpos($ret,'</DIV>');
$reqlen = $end - $start; //The length of the text required
//get the required text
$status = substr($ret, $start, $reqlen);
//replace relative paths with full paths
$status = str_replace('ServiceDetails.aspx', 'http://www.ntl-isp.ntl.com/ServiceStatus/ServiceDetails.aspx', $status);
$status = str_replace('images/', 'http://www.ntl-isp.ntl.com/ServiceStatus/images/', $status);
//dump the text



}
?>