Ticket #4299 (closed Feature Requests: fixed)

Opened 2 years ago

Last modified 1 year ago

Show hostname next to server_name

Reported by: pnlarsson Assigned to:
Priority: minor Milestone: 2.9
Component: FreePBX Framework Version: SVN-HEAD
Keywords: hostname Cc:
Confirmation: Need Feedback SVN Revision (if applicable):
Backend Engine: All Backend Engine Version:

Description

Sometimes it's goood to know which hostname the box has, for example when the url is like pbx001 etc. So this oneliner patch does that.

/www/html/admin/views$ diff freepbx.php_org freepbx.php
162c162
< 		"<a href=\"http".(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=''?'s':'')."://".$_SERVER['HTTP_HOST']."\">".$_SERVER["SERVER_NAME"]."</a>"
---
> 		"<a href=\"http".(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=''?'s':'')."://".$_SERVER['HTTP_HOST']."\">".$_SERVER['SERVER_NAME'] .' ('.trim(`hostname -f`).')'."</a>"

Attachments

hostname_2.patch (1.7 kB) - added by pnlarsson on 05/29/10 15:39:44.
hostname_3.patch (2.0 kB) - added by pnlarsson on 06/18/10 09:33:48.
hostname_title.patch (1.3 kB) - added by pnlarsson on 12/01/10 14:55:58.
Patch to put the hostname in the title when SERVERINTITLE is set

Change History

05/26/10 09:47:13 changed by p_lindheimer

  • owner changed.
  • type changed from Bugs to Feature Requests.
  • component changed from Web interface to FreePBX Framework.

05/26/10 13:24:26 changed by mickecarlsson

  • status changed from new to closed.
  • type changed from Feature Requests to Bugs.
  • resolution set to fixed.

See r9770. If you remove that line and set in amportal.conf SERVERINTITLE=true the global $_SERVERSERVER_NAME? is displayed in the browser title.

SERVER_NAME is explained at php.net as follow:

The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

I will close the ticket as fixed.

05/26/10 13:32:11 changed by mickecarlsson

  • status changed from closed to reopened.
  • resolution deleted.

OK, opening the ticket again as a feature request as I now found out where the suggestion was displayed.

However, there was an error in the code for SERVERINTITLE, pnlarsson, is that OK or do you still want the hostname in the header?

05/26/10 13:32:20 changed by mickecarlsson

  • type changed from Bugs to Feature Requests.

05/26/10 17:07:04 changed by pnlarsson

The issue i have is that in my case SERVER_NAME != hostname and i would like to see the hostname of the box i'm messing around with. (Sorry for the bug submission - been too long since i did this...)

05/27/10 00:09:52 changed by mickecarlsson

If using "hostname -f" the hostname needs to be resolvable, either in dns or by the local hosts file. If it is not resolvable the result is "()". So I will submit the change without the "-f" part as I find the request quite useful.

05/27/10 00:11:02 changed by mickecarlsson

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [9772]) Close #4299 adds hostname in header for gui

05/29/10 11:33:15 changed by p_lindheimer

(In [9779]) revert r9772 re #4299 we are not going to call hostname on every call in addition to it has the potential of messing up the display with an unknown length and could have other un-forseen consequences (and if we were going to do this, we should be using php gethostname() (and then defining a substitute for php versions that don't have that function

05/29/10 15:39:44 changed by pnlarsson

  • attachment hostname_2.patch added.

05/29/10 15:42:16 changed by pnlarsson

  • status changed from closed to reopened.
  • resolution deleted.

Oki, a new patch with caching of the hostname, limiting it to 30 chars, and using gethostname if availibly otherwice using php_uname('n') (since 4.0.2).

06/01/10 16:11:04 changed by p_lindheimer

  • confirmation changed from Unreviewed to Need Feedback.

pnlarsson,

this doesn't work for me. When the Apply Configuration changes bar is up there are only 3-4 characters of my hostname showing.

I would suggest making a configuration variable in amportal.conf that lets you optionally replace the IP address that is normally presented there with the hostname. Default should be as it is. If it is set, then it should do the lookup (the way you did it looks good) and use that INSTEAD of the IP address.

06/15/10 16:37:15 changed by p_lindheimer

  • milestone changed from 2.8 to Cut Line.

06/18/10 09:33:48 changed by pnlarsson

  • attachment hostname_3.patch added.

06/18/10 09:36:06 changed by pnlarsson

Well, patch added that adds HOSTNAMEINSTEADOFSERVERNAME to amportal.conf, default false, that replaces SERVER_NAME with hostname.

Where is all the settings in amportal documented?

07/13/10 18:02:34 changed by p_lindheimer

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [10122]) Merged revisions 9746-9768,9770-10121 via svnmerge from http://www.freepbx.org/v2/svn/freepbx/branches/2.8

................

r9750 | p_lindheimer | 2010-05-25 10:10:09 -0700 (Tue, 25 May 2010) | 1 line

closes #4256 make all versions of parse_amportal_conf() use the same preg_match() line using framework's functions.inc.php as authoritative

................

r9770 | mickecarlsson | 2010-05-26 11:17:11 -0700 (Wed, 26 May 2010) | 1 line

Reverted r7730 so that amportal setting SERVERINTITLE starts working again. See also #4299

................

r9771 | mbrevda | 2010-05-26 11:30:20 -0700 (Wed, 26 May 2010) | 1 line

re: #4300; bug fix for firefox. IE wont remember expanded state between page reload, everything else seems to be working.

................

r9772 | mickecarlsson | 2010-05-26 22:11:01 -0700 (Wed, 26 May 2010) | 1 line

Close #4299 adds hostname in header for gui

................

r9777 | p_lindheimer | 2010-05-28 11:34:16 -0700 (Fri, 28 May 2010) | 1 line

closes #4306 make lnav sections expandable/collapse-able

................

r9779 | p_lindheimer | 2010-05-29 09:33:15 -0700 (Sat, 29 May 2010) | 1 line

revert r9772 re #4299 we are not going to call hostname on every call in addition to it has the potential of messing up the display with an unknown length and could have other un-forseen consequences (and if we were going to do this, we should be using php gethostname() (and then defining a substitute for php versions that don't have that function

................

r9780 | p_lindheimer | 2010-05-29 10:01:36 -0700 (Sat, 29 May 2010) | 1 line

fixes #4307 unable to press apply configuration changes bar. Please open a new bug for IE, tested to work on FF, Safari, Chrome - so something is up with IE or there is some sort of bug/mis-matched html tag or something that the others are immune to...

................

r9781 | p_lindheimer | 2010-05-29 10:25:39 -0700 (Sat, 29 May 2010) | 1 line

fix some formatting so viewing source pages is easier, and adds a closing div that appeared to be missing

................

r9782 | p_lindheimer | 2010-05-29 10:51:30 -0700 (Sat, 29 May 2010) | 1 line

removes the div that was wrapping a group of li tags (I don't think you can do that) which was messing up IE, however IE still can not reload, the modal orange box never comes up, re #4307

................

r9784 | mickecarlsson | 2010-05-29 13:56:17 -0700 (Sat, 29 May 2010) | 1 line

Fixed spelling error

................

r9787 | p_lindheimer | 2010-05-30 09:26:29 -0700 (Sun, 30 May 2010) | 1 line

closes #4253 cleanup default amportal.conf file (note: the patch still did not apply but the full copy was used so it should be good but please confirm)

................

r9788 | p_lindheimer | 2010-05-30 10:45:15 -0700 (Sun, 30 May 2010) | 1 line

add title to categories saying they can click to expand/collapse the section

................

r9799 | p_lindheimer | 2010-06-01 13:06:54 -0700 (Tue, 01 Jun 2010) | 1 line

closes #4311 use freepbx_menu.conf to make modifications to left navigation menu, if file is not present then the code path remains unchanged

................

r9812 | p_lindheimer | 2010-06-02 10:22:00 -0700 (Wed, 02 Jun 2010) | 13 lines

Merged revisions 9634-9729,9733-9795,9798-9811 via svnmerge from http://www.freepbx.org/v2/svn/freepbx/branches/2.7

........

r9634 | p_lindheimer | 2010-05-14 07:10:47 -0700 (Fri, 14 May 2010) | 1 line

fixes #4269 enclose clid_format in quotes

........

r9811 | p_lindheimer | 2010-06-02 10:09:25 -0700 (Wed, 02 Jun 2010) | 1 line

fixes #4255 enclose the full set of searchstrings in ()

........

................

r9814 | p_lindheimer | 2010-06-02 13:19:02 -0700 (Wed, 02 Jun 2010) | 1 line

dont't run category through htmlspecialchars as only moh uses it, do it there since it breaks other things re: #4179

................

r9831 | p_lindheimer | 2010-06-15 10:34:02 -0700 (Tue, 15 Jun 2010) | 1 line

fixes #4345 fail an install when install.php or install.sql (or unintall versions) fails

................

r9833 | GameGamer?43 | 2010-06-15 12:02:29 -0700 (Tue, 15 Jun 2010) | 1 line

closes #4333 - check if outboundCID is set and it's not set to nothing

................

r9834 | GameGamer?43 | 2010-06-15 12:08:17 -0700 (Tue, 15 Jun 2010) | 1 line

closes #4331 - added ext_meetmeadmin class, to handle the management of meetme conferences from within freepbx

................

r9836 | p_lindheimer | 2010-06-15 13:09:42 -0700 (Tue, 15 Jun 2010) | 1 line

closes #4339 add displayconnects=no as default value, only helps with 1.6+

................

r9877 | p_lindheimer | 2010-06-18 12:22:07 -0700 (Fri, 18 Jun 2010) | 1 line

add template for freepbx_menu.conf allowing lnav manipulation from the defaults re #4311

................

r9891 | p_lindheimer | 2010-06-22 11:46:43 -0700 (Tue, 22 Jun 2010) | 1 line

fixes #4366 and fixes #4354 guielements should not be trying to do translations on passed in values, this should be done in the calling module prior to passing in the value

................

r9917 | mbrevda | 2010-06-25 05:10:30 -0700 (Fri, 25 Jun 2010) | 1 line

re #4369, migrate before the user can hit reload

................

r9919 | mbrevda | 2010-06-25 08:02:08 -0700 (Fri, 25 Jun 2010) | 1 line

re #4369, remove time condition migration, that should be done from thre CC module; also remove core_get_routes function to avoid any conflicts with the same function name further down the line

................

r9922 | p_lindheimer | 2010-06-25 11:09:36 -0700 (Fri, 25 Jun 2010) | 1 line

define sql() if not defined, some install methods does not have this function defined

................

r9933 | p_lindheimer | 2010-06-25 12:52:35 -0700 (Fri, 25 Jun 2010) | 1 line

Creating release 2.8.0rc1

................

r9958 | mickecarlsson | 2010-06-26 06:29:32 -0700 (Sat, 26 Jun 2010) | 1 line

Updated amp.pot

................

r9959 | mickecarlsson | 2010-06-26 06:30:59 -0700 (Sat, 26 Jun 2010) | 1 line

Added missing license text

................

r9960 | mickecarlsson | 2010-06-26 06:32:21 -0700 (Sat, 26 Jun 2010) | 1 line

Updated language tool

................

r9961 | p_lindheimer | 2010-06-26 09:17:47 -0700 (Sat, 26 Jun 2010) | 1 line

closes #4376 setting repository select box to extended if such modules are present, also changes 'type' form tool to what ever is currently selected

................

r9967 | mickecarlsson | 2010-06-27 03:17:51 -0700 (Sun, 27 Jun 2010) | 1 line

Updated amp.pot with latest changes

................

r9970 | mickecarlsson | 2010-06-27 10:02:16 -0700 (Sun, 27 Jun 2010) | 1 line

Updated all amp languages for 2.8

................

r9977 | p_lindheimer | 2010-06-28 11:20:44 -0700 (Mon, 28 Jun 2010) | 1 line

fixes #4382 enapsulate symlinking/copying into a class with error reporting at end

................

r9985 | p_lindheimer | 2010-06-28 18:37:10 -0700 (Mon, 28 Jun 2010) | 1 line

fixes #4386 don't generate an orphaned basetag if no extenions exists, fail at that point instead

................

r9999 | p_lindheimer | 2010-06-29 14:49:29 -0700 (Tue, 29 Jun 2010) | 1 line

fixes #4389 dahdi compatibility mode broken, 1.4 still has legacy zap applications even when in DAHDI mode so can't count on those

................

r10003 | p_lindheimer | 2010-06-30 08:47:03 -0700 (Wed, 30 Jun 2010) | 1 line

include module js files after all the standard js files as they will typically require things like standard jquery libraries, etc.

................

r10005 | p_lindheimer | 2010-06-30 14:11:31 -0700 (Wed, 30 Jun 2010) | 1 line

perl version no longer used

................

r10007 | p_lindheimer | 2010-06-30 14:36:30 -0700 (Wed, 30 Jun 2010) | 1 line

make freepbx_featurecodes.conf a template so it does not get read every time unless use is using it

................

r10010 | p_lindheimer | 2010-06-30 15:16:06 -0700 (Wed, 30 Jun 2010) | 1 line

fixes #4388 don't symlink from other fw_fop, fw_ari, fw_langpack modules, they are like framework also re #4382 leftover code deleted

................

r10027 | mickecarlsson | 2010-07-03 01:48:04 -0700 (Sat, 03 Jul 2010) | 1 line

amportal.conf: small spelling error

................

r10028 | p_lindheimer | 2010-07-03 09:35:06 -0700 (Sat, 03 Jul 2010) | 1 line

remove warning from incorrect (but harmless) call to connectdirs::create() re #4400

................

r10037 | mickecarlsson | 2010-07-07 01:07:26 -0700 (Wed, 07 Jul 2010) | 1 line

Re #4402 change from split to explode in callmonitor.module

................

r10038 | p_lindheimer | 2010-07-07 14:44:25 -0700 (Wed, 07 Jul 2010) | 1 line

if destination file is a different symlink or an actual file, and the md5 of the files are identical, then don't complain, just write out an error log re #4388

................

r10040 | p_lindheimer | 2010-07-07 14:54:28 -0700 (Wed, 07 Jul 2010) | 9 lines

Merged revisions 10019 via svnmerge from http://www.freepbx.org/v2/svn/freepbx/branches/2.7

........

r10019 | p_lindheimer | 2010-07-01 07:12:54 -0700 (Thu, 01 Jul 2010) | 1 line

fixes #4185 use DAHDI channels when compatibility mode is used

........

................

r10041 | mbrevda | 2010-07-08 03:07:17 -0700 (Thu, 08 Jul 2010) | 1 line

closes #4403; symlink ari_modules dir on reload

................

r10044 | p_lindheimer | 2010-07-08 10:45:30 -0700 (Thu, 08 Jul 2010) | 1 line

create 2.8.0 release dir and migration script to add preloads if needed to modules.conf re #3963 and re #4411

................

r10045 | mickecarlsson | 2010-07-08 11:54:17 -0700 (Thu, 08 Jul 2010) | 1 line

Fixes typo

................

r10047 | mickecarlsson | 2010-07-08 12:00:17 -0700 (Thu, 08 Jul 2010) | 1 line

Fix that typo again

................

r10050 | p_lindheimer | 2010-07-08 12:19:33 -0700 (Thu, 08 Jul 2010) | 1 line

change struture for ari module symlinks to accomodate other assets re #4403

................

r10053 | p_lindheimer | 2010-07-09 09:32:37 -0700 (Fri, 09 Jul 2010) | 1 line

fixes #4413 don't change permissions on hidden folders in ASTVARLIBDIR to keep from affecting anything in the .ssh folder

................

r10054 | p_lindheimer | 2010-07-09 16:53:14 -0700 (Fri, 09 Jul 2010) | 1 line

closes #4418 adds ability for modules to include js scripts into the <head> of the page

................

r10055 | p_lindheimer | 2010-07-09 23:21:44 -0700 (Fri, 09 Jul 2010) | 1 line

keep apply config bar from fading if DEVELRELOAD is set

................

r10100 | mbrevda | 2010-07-12 02:50:42 -0700 (Mon, 12 Jul 2010) | 1 line

closes #4423; dont display a blamk page in ari if fm is not enabled

................

r10101 | mbrevda | 2010-07-12 02:53:02 -0700 (Mon, 12 Jul 2010) | 1 line

closes #4423; dont display a blamk page in ari if fm is not enabled

................

r10108 | p_lindheimer | 2010-07-13 08:30:28 -0700 (Tue, 13 Jul 2010) | 1 line

provide the src module when reporting symlink errors

................

r10109 | p_lindheimer | 2010-07-13 09:58:44 -0700 (Tue, 13 Jul 2010) | 1 line

use the extended repository when checking modules if Third Party Modules are present (used by automatic update checker), re #4376 and will also help re #4385 since the modules will show as new if the normal repository is ever checked followed by the extended repository

................

r10111 | p_lindheimer | 2010-07-13 15:53:18 -0700 (Tue, 13 Jul 2010) | 1 line

Creating release 2.8.0

................

11/22/10 15:23:54 changed by pnlarsson

  • status changed from closed to reopened.
  • version changed from 2.7-branch to SVN-HEAD.
  • resolution deleted.

It looks like this was closed by misstake - can't find any commited code.

What if we put the hostname in the window title instead - when SERVERINTITLE is set?

11/22/10 15:24:50 changed by pnlarsson

And not to replace the servername, just put the hostname next to the servername.

12/01/10 14:55:58 changed by pnlarsson

  • attachment hostname_title.patch added.

Patch to put the hostname in the title when SERVERINTITLE is set

12/08/10 16:46:49 changed by p_lindheimer

pnlarsson,

I would say this is fine other than one missing _(). Here it is with that tweaked, otherwise I say go for it an check it in:

Index: config.php
===================================================================
--- config.php	(revision 10662)
+++ config.php	(working copy)
@@ -399,9 +399,26 @@
 	$template['module_name'] = $module_name;
 	$template['module_page'] = $module_page;
 	if ($amp_conf['SERVERINTITLE']) {
-		$template['title'] = $_SERVER['SERVER_NAME']._(" FreePBX administration");
+
+	        // set the servername
+        	$server_hostname = '';
+               	if (isset($_SESSION['session_hostname'])){
+                       	$server_hostname = $_SESSION['session_hostname'];
+               	}else{
+                       	if (function_exists(gethostname)){
+                               	$server_hostname = trim(gethostname());
+                       	}else{
+                               	$server_hostname = trim(php_uname('n'));
+                       	}
+                       	if ($server_hostname != ''){
+                               	$server_hostname = ' (' . substr($server_hostname, 0, 30) . ')';
+                       	}
+                       	$_SESSION['session_hostname'] = $server_hostname;
+               	}
+
+		$template['title'] = $_SERVER['SERVER_NAME'] . $server_hostname . ' - '._('FreePBX administration');
 	} else {
-		$template['title'] = _("FreePBX administration");
+		$template['title'] = _('FreePBX administration');
 	}
 	$template['amp_conf'] = &$amp_conf;
 	$template['reload_needed'] = check_reload_needed();

12/08/10 16:46:58 changed by p_lindheimer

  • milestone changed from Cut Line to 2.9.

12/09/10 14:54:32 changed by pnlarsson

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [10677]) Adds hostname to title if SERVERINTITLE is set. Closes #4299

12/23/10 14:23:11 changed by p_lindheimer

(In [10724]) syntax error needs quotes with function_exists re #4299

01/26/11 15:21:54 changed by pnlarsson

(In [11134]) Adding missing DIVERISION_REASON when busy. Closes #4299