Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2002, 04:34 PM
Mr_P Mr_P is offline
 
Join Date: Jan 2002
Location: Uk.
Posts: 202
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 05-08-2002, 02:30 AM
Issvar Issvar is offline
 
Join Date: Mar 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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">'; }
?>
Reply With Quote
  #3  
Old 05-08-2002, 07:23 AM
Mr_P Mr_P is offline
 
Join Date: Jan 2002
Location: Uk.
Posts: 202
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 05-08-2002, 07:43 AM
Mr_P Mr_P is offline
 
Join Date: Jan 2002
Location: Uk.
Posts: 202
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Warning: Wrong parameter count for ftp_connect() in \vbb\showthread.php on line 912
Reply With Quote
  #5  
Old 05-08-2002, 01:07 PM
Issvar Issvar is offline
 
Join Date: Mar 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 05-08-2002, 01:35 PM
Mr_P Mr_P is offline
 
Join Date: Jan 2002
Location: Uk.
Posts: 202
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 05-08-2002, 01:52 PM
Sparkz's Avatar
Sparkz Sparkz is offline
 
Join Date: Nov 2001
Posts: 544
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #8  
Old 05-08-2002, 02:23 PM
Mr_P Mr_P is offline
 
Join Date: Jan 2002
Location: Uk.
Posts: 202
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 05-08-2002, 02:45 PM
Sparkz's Avatar
Sparkz Sparkz is offline
 
Join Date: Nov 2001
Posts: 544
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
<?php
$offbutton 
"/images/offbutton.gif";
$onbutton "/images/onbutton.gif";
$outfile "/path/to/file.txt";
$fp fopen ($outfile'w');
 
$ftp_conn=fsockopen('ftp.mysite.com',21,$errno,$errstr,5); 
if (
$ftp_conn) {
   
fputs ($fp$onbutton);
   
fputs ($ftp_conn,'BYE');
} else {
   
fputs ($fp$offbutton);
}

fclose ($fp);
?>
Please not that the file referenced in $outfile has to be writable by the webserver (if calling this script with lynx or wget, etc)

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:
$myfile "/path/to/file.txt";
$fp fopen ($myfile'r');
$ftpbutton fread ($fp4096);
fclose ($fp); 
If I am not mistaken now, you should be able to use $ftpbutton in some template on that page. If it is a path to an image, like I did in my suggestion here, you would put something like <img src="$ftpbutton"> in your template.

This is yet another untested thingy from me, but in theory (hey, all my stuff works in theory, right ), it should work.
Reply With Quote
  #10  
Old 05-08-2002, 03:26 PM
Mr_P Mr_P is offline
 
Join Date: Jan 2002
Location: Uk.
Posts: 202
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:31 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09111 seconds
  • Memory Usage 2,259KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete