Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2007, 05:23 AM
rayw rayw is offline
 
Join Date: Mar 2007
Location: Australia
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help - custom ping script!

Using this mod I want to imbed a custom Ping script into the page.

The script works fine, it pings a web address or IP fine however, the results are outputted to the very top of the web page, above the logo. I want the results to output right underneath the field that you type the web address/IP into.

Here is the ping script:
Code:
<?php 
 
error_reporting(E_ALL & ~E_NOTICE); 
 
define('NO_REGISTER_GLOBALS', 1); 
define('THIS_SCRIPT', 'page_ping'); // change this depending on your filename 
 
$phrasegroups = array( 

); 
 
$specialtemplates = array( 
     
); 
 
$globaltemplates = array( 
    'page_ping', 
); 
 
$actiontemplates = array( 

); 
 
chdir('/home/USERNAME/public_html/');
require_once('./global.php');  

// Start Ping
$_ip = $_SERVER['REMOTE_ADDR'];
if($_GET['do'] == 'ping')
{
$_domain = $_POST['domain'];
		echo "<pre>";
                   system ("ping -w 10 -c 5 $_domain");

  		echo "</pre>";
}

// End Ping

$pingresult = $_POST['ping -w 10 -c 5 $_domain'];

$navbits = array(); 
$navbits[$parent] = 'Ping'; 

$navbits = construct_navbits($navbits); 
eval('$navbar = "' . fetch_template('navbar') . '";'); 
eval('print_output("' . fetch_template('page_ping') . '");'); 

?>

Here is my template:
Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">Ping</td>
</tr>
<tr>
<td class="alt1">

Enter the IP Address or domain name of the server that you want to ping.<br>


<form method='post' action='page_ping.php?do=ping'><input type='text' name='domain' value=''>&nbsp;<input type='submit' value='Ping'></form>

<br /><br />

$pingresult

<br />

</td>
</tr>
</table>

$footer
</body>
</html>
You can try it yourself here: http://www.itresource.com.au/page_ping.php

What do I need to do to get this working correctly? I've tried many different things to get this working - currently this seems to be the most 'functional' for lack of a better word.

Any help would be greatly appreciated.

Thanks!
Reply With Quote
  #2  
Old 10-20-2007, 05:58 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Create a template for it instead of using 'echo'.

Regular echo is only suitable for debug with vBulletin.
Reply With Quote
  #3  
Old 10-20-2007, 10:35 AM
rayw rayw is offline
 
Join Date: Mar 2007
Location: Australia
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I'm going to need a bit more detail. I don't understand!
Reply With Quote
  #4  
Old 10-20-2007, 12:07 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

All your display should be in your templates. The PHP code should not print any output into the browser (except for the final print_output), but instead assign all the data into variables for use in the template.
Reply With Quote
  #5  
Old 10-23-2007, 09:21 AM
rayw rayw is offline
 
Join Date: Mar 2007
Location: Australia
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm! Not having much luck with this. I even tried dynamic AJAX inclusions using a script from dynamic drive and I still couldn't get it to work properly.

Unfortunately, I'm not the most talented coder out there.
Reply With Quote
  #6  
Old 10-23-2007, 09:54 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use this PHP instead of yours. The template doesn't need to be changed (keep the one you posted above).
PHP Code:
<?php 
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''page_ping');

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array();

// get special data templates from the datastore 
$specialtemplates = array();

// pre-cache templates used by all actions 
$globaltemplates = array(
    
'page_ping'
);

// pre-cache templates used by specific actions 
$actiontemplates = array();

// ########################## REQUIRE BACK-END ############################ 
chdir('/home/USERNAME/public_html');
require_once(
'./global.php'); 

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ######################################################################## 

// do pinging
if ($_GET['do'] == 'ping')
{
    
$domain $_POST['domain'];
    
system("ping -w 10 -c 5 $domain"$pingresult);
}

// prepare navbits
$navbits = array();
$navbits[] = 'Ping';
$navbits construct_navbits($navbits);

// spit out html
eval('$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('page_ping') . '");');
?>
Reply With Quote
  #7  
Old 10-23-2007, 10:08 AM
rayw rayw is offline
 
Join Date: Mar 2007
Location: Australia
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had something similar to what you have posted but I there were a few errors in mine when I tried to run it.

There are no errors in yours but check it out now (http://www.itresource.com.au/page_ping.php). I wont bother explaining, you will see the results yourself.
Reply With Quote
  #8  
Old 10-23-2007, 10:24 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<?php 
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''page_ping');

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array();

// get special data templates from the datastore 
$specialtemplates = array();

// pre-cache templates used by all actions 
$globaltemplates = array(
    
'page_ping'
);

// pre-cache templates used by specific actions 
$actiontemplates = array();

// ########################## REQUIRE BACK-END ############################ 
chdir('/home/USERNAME/public_html');
require_once(
'./global.php'); 

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ######################################################################## 

// do pinging
if ($_GET['do'] == 'ping')
{
    
$domain $_POST['domain'];
    
exec("ping -w 10 -c 5 $domain"$temp$pingresult);
}

// prepare navbits
$navbits = array();
$navbits[] = 'Ping';
$navbits construct_navbits($navbits);

// spit out html
eval('$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('page_ping') . '");');
?>
Reply With Quote
  #9  
Old 10-23-2007, 11:04 AM
rayw rayw is offline
 
Join Date: Mar 2007
Location: Australia
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Now no results appear, just a 0 under the form.
Reply With Quote
  #10  
Old 10-23-2007, 11:22 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<?php 
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''page_ping');

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array();

// get special data templates from the datastore 
$specialtemplates = array();

// pre-cache templates used by all actions 
$globaltemplates = array(
    
'page_ping'
);

// pre-cache templates used by specific actions 
$actiontemplates = array();

// ########################## REQUIRE BACK-END ############################ 
chdir('/home/USERNAME/public_html');
require_once(
'./global.php'); 

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ######################################################################## 

// do pinging
if ($_GET['do'] == 'ping')
{
    
$domain $_POST['domain'];
    
exec("ping -w 10 -c 5 $domain"$output);
}

// implode output
$pingresult implode('<br />'$output);

// prepare navbits
$navbits = array();
$navbits[] = 'Ping';
$navbits construct_navbits($navbits);

// spit out html
eval('$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('page_ping') . '");');
?>
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:02 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.07989 seconds
  • Memory Usage 2,282KB
  • Queries Executed 11 (?)
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_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete