vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Query Server for Apache version only (https://vborg.vbsupport.ru/showthread.php?t=62238)

Boofo 03-07-2004 04:23 AM

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(); 


Andreas 03-07-2004 04:53 AM

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]; 


Boofo 03-07-2004 06:38 AM

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)?

NTLDR 03-07-2004 04:25 PM

Is apache running as a module or as CGI? As apache_get_version() only works if its run as a module.

Boofo 03-07-2004 08:22 PM

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?

NTLDR 03-07-2004 09:22 PM

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 ;)

Boofo 03-07-2004 09:48 PM

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.

NTLDR 03-07-2004 10:04 PM

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.

Boofo 03-07-2004 10:18 PM

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();

NTLDR 03-08-2004 09:54 AM

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.


All times are GMT. The time now is 07:33 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.01271 seconds
  • Memory Usage 1,739KB
  • 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)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete