The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
small hack if possible but not sure if can be done
i run an ftp server and i wanted to know if is is possible to view on main pafe if server is up or down without having to call it in using iframe as you can view source and get ftp details.
Basically just want an icon to represent if on/off but i cant suzz it out so any help would be appreciated ftp only holds maps etc for rtcw so aint used for piracy but its a boards ftp so would be neat if everyone can see if it on/off at a glance. |
#2
|
|||
|
|||
Add this where you want to show the icon:
It has a 5 second timeout for the connection, to make sure users don't have to wait too long for connection. Edit settings in ftp_connecct as required (host,port,timeout). <?php $ftp_conn = ftp_connect('ftp.mysite.com',21,5); if ($ftp_conn) { echo '<img src="ftponline.gif">'; ftp_close($ftp_conn); } else { echo '<img src="ftpoffline.gif">'; } ?> |
#3
|
|||
|
|||
tried to input this code into a few different locations but having no luck
any ideas on where is best place to put it also thanks for your help |
#4
|
|||
|
|||
Warning: Wrong parameter count for ftp_connect() in \vbb\showthread.php on line 912
|
#5
|
|||
|
|||
Hmm, looks like ftp functions require to be compiled into php which is not standard, and there are some errors with it on windows. Instead try:
<?php $ftp_conn=fsockopen('ftp.mysite.com',21,$errno,$er rstr,5); if ($ftp_conn) { echo 'Online'; fputs($ftp_conn,'BYE'); } else { echo 'Offline'; } ?> If connection fails you can use $errno and $errstr to view errormessages , if you know enough php to display them, but you don't have to use them. |
#6
|
|||
|
|||
ok tried the above and nothing shows - i put the code in index.php
i used the code from above this morning and it worked on my local copy but when i went on web to test it thats when i kept getting the errors. Basically im having probs knowing where is best place to put the code as php is not something i am good at. Also on a final note do these commands have to be supported by your host and if so do that mean i will either have to contact my web provider and see if they can switch them on Or am i flogging a dead horse - i know its a lot of hazzle just to see an on/offline gif but to me its deffo worth it so all help is appreciated. |
#7
|
||||
|
||||
Personally, I would do this somewhere outside vBulletin (or whatever public page you were going to use it in) and put it in a cronjob on the server. That way everytime someone loads the page, they wouldn't steal a connection to the FTP-server.
Imagine running something like Issvar's script on a high traffic site, like this. Every pageload would generate 1 connection to the FTP-server. It would probably slow the server down, as well as forcing you to increase the max number of connections... |
#8
|
|||
|
|||
ok Sparkz you raise some good points there that i was unaware of so how about if i go about it from a another angle.
A link on my main page to a page that shows if server is on/off etc so how would i incorporate this new code into that page ? remembering that the new page would`nt have anything to do with vbull so would be a totally new page |
#9
|
||||
|
||||
If you have access to crontab on your server, you can make Issvar's script run every x minutes, and write it's output to a file instead. Something along the lines of this:
PHP Code:
In your crontab, you would place something like this: 1-59 * * * * /path/to/lynx --source http://your.server.here/updatescript.php Then, in the page where you want to display this add something like this: PHP Code:
This is yet another untested thingy from me, but in theory (hey, all my stuff works in theory, right ), it should work. |
#10
|
|||
|
|||
lol that certainly is good help and more than i hoped for - but i dont have access to crontab so that counts that idea out.
But like you say all your ideas work and shame really as i would ov tested it as well. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|