vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   if () -> <if> conversion (https://vborg.vbsupport.ru/showthread.php?t=92306)

silentshadow204 07-16-2005 03:57 AM

if () -> <if> conversion
 
This is for a module for vBadvanced CMPS but this is a coding question rather than CMPS support.

I've been successful in setting up the module to work with the portal system. The only problem I am having now is converting the php if () to something vbulletin will understand. I don't have a full grasp of php so converting the php to if statements is a bit confusing.

This is the setup for the ping php include
PHP Code:

<?
// The IP address to ping.
$ip = "70.84.217.62";

// This line actually executes the ping.
$cmd = shell_exec("ping -c 1 -w 1 $ip");

// This line determins if the ping was successful or not
$ping_results = explode(",",$cmd);

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

This is the php used for the echo of the html. "1 recieved" means the server is up and 0 means the server is down. I want different text and images to display when the server is up or down.
PHP Code:

if (eregi ("1 received"$ping_results[1], $out)) { echo " text "; } 

How would I convert the above into an <if> that vbulletin will understand and allow to be processed. If anyone has a better suggestion on how to do this, I'm all ears. The only stipulation is that the server will not respond to queries on port 80; port 4151 will respond to ping requests though. This script just checks if the server responds in general and not on a specific port.

Guest190829 07-16-2005 04:09 AM

You can have two seperate templates I guess if the server is up or down

PHP Code:

if (eregi ("1 received"$ping_results[1], $out)) { echo " text "; } 
{
    
//eval template that show images/text when the server is up
}
else
{

  
//eval other template that show images/text when server isn't up.



silentshadow204 07-16-2005 04:14 AM

Quote:

Originally Posted by Danny.VBT
You can have two seperate templates I guess if the server is up or down

PHP Code:

if (eregi ("1 received"$ping_results[1], $out)) { echo " text "; } 
{
    
//eval template that show images/text when the server is up
}
else
{

  
//eval other template that show images/text when server isn't up.



Wow, that's perfect. So simple that it didn't even occur to me. :ermm:

edit: Just implemented the code and it worked like a charm. Many thanks for your assistance.

Guest190829 07-16-2005 04:20 AM

No Problem, Glad I could help. :)


All times are GMT. The time now is 07:07 AM.

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.01133 seconds
  • Memory Usage 1,730KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete