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 03-07-2004, 04:23 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Query Server for Apache version only

Can someone please tell me why I get an undefined function error when running this code in the functions.php? I want to query the server for the Apache version without getting the long string you get using SERVER_SOFTWARE.

PHP Code:
$apacheversion apache_get_version(); 
Reply With Quote
  #2  
Old 03-07-2004, 04:53 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

apache_get_version() is only available in PHP version > 4.3.2, so this might be the cause.

Try this snippet:
PHP Code:
$ar split("[/ ]"getenv("SERVER_SOFTWARE"));
$apacheversion $ar[1]; 
Reply With Quote
  #3  
Old 03-07-2004, 06:38 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you, sir. That worked great!

The server I am on is running PHP v4.3.3. I'm not sure why that code I posted doesn't work. It should have. :surprised:

Is there also a way to get the version of UNIX or Linux (as my server has)?
Reply With Quote
  #4  
Old 03-07-2004, 04:25 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is apache running as a module or as CGI? As apache_get_version() only works if its run as a module.
Reply With Quote
  #5  
Old 03-07-2004, 08:22 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You got me on that one. I have no idea which way they have it set up. Apparently, it must be set up as CGI since the script gives me the unknown function error, right? Is one way really any better than the other?

Also, is there a way to pull the Linix version number out, too?
Reply With Quote
  #6  
Old 03-07-2004, 09:22 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Apache as a module is the better method to use, take a look at the Server API part of phpinfo() at the very top and it should say Apache if your running it as a module.

For the Linux version info, provided you can run shell_exec() you can get the OS info with:

PHP Code:
$info shell_exec('uname'); 
There are various options to add to get different stuff:

Quote:
Usage: uname [OPTION]...
Print certain system information. With no OPTION, same as -s.

-a, --all print all information
-m, --machine print the machine (hardware) type
-n, --nodename print the machine's network node hostname
-r, --release print the operating system release
-s, --sysname print the operating system name
-p, --processor print the host processor type
-v print the operating system version
--help display this help and exit
--version output version information and exit
The info will be returned in the $info variable. I'd advise against making this information publicly available though
Reply With Quote
  #7  
Old 03-07-2004, 09:48 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there such a thing as this for the Linux version?

#1 SMP Mon Aug 18 14:34:09 EDT 2003

That's what it returns.

I only have this info displayed for Admins. It is not available to the other users.

The Server API just says Apache.
Reply With Quote
  #8  
Old 03-07-2004, 10:04 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you mean the Linux Kernel version then uname -r is what you want.

I've just tired apache_get_version(); on my server and it seems to work correctly for me with the Server API as Apache (ie a module), however, I think what you get returned from that is the same as you'll get from getenv('SERVER_SOFTWARE'); as both return Apache for me as I've set it to not show any other details in httpd.conf.
Reply With Quote
  #9  
Old 03-07-2004, 10:18 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It must be running as CGI on my server then. That would explain why I get the error. The code KirbyDE posted above gave me just the version number of Apache and nothing else. That's all I needed as I already have the other info.

I tried the -r and this is what I got:

2.4.20-20.7smp

Does that look right to you? What does the smp stand for?

What is the exact code you used with this? apache_get_version();
Reply With Quote
  #10  
Old 03-08-2004, 09:54 AM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, that looks right The SMP (symmetric multiprocessing) part means your kernel has been complied to support more than one CPU.

I just did:

PHP Code:
<?php

echo apache_get_version(); 

?>
Which gave me the same result as what I see on my phpinfo() page for the SERVER_SOFTWARE variable.
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 07:16 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.06400 seconds
  • Memory Usage 2,260KB
  • 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
  • (4)bbcode_php
  • (1)bbcode_quote
  • (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