Show
Ignore:
Timestamp:
02/21/11 14:47:30 (2 years ago)
Author:
p_lindheimer
Message:

closes #4846 adds notification for amportal.conf and no dynamic hints, also adds method to notification class and freepbx_settings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.9/amp_conf/bin/retrieve_conf

    r11453 r11528  
    669669// Now we write on amportal.conf if it is writable, which allows legacy applications in the 
    670670// eco-system to take advantage of the settings. 
     671// we write out the error message here instead of in freepbx_settings so that we don't hit the db every single page load 
    671672// 
    672673if ($freepbx_conf->amportal_canwrite()) { 
    673674  file_put_contents('/etc/amportal.conf',$freepbx_conf->amportal_generate(true)); 
     675  $nt->delete('framework', 'AMPORTAL_NO_WRITE'); 
     676} elseif (!$nt->exists('framework', 'AMPORTAL_NO_WRITE')) { 
     677  $nt->add_error('framework', 'AMPORTAL_NO_WRITE', _("amportal.conf not writeable"), _("Your amportal.conf file is not writeable. FreePBX is running in a crippled mode until changed. You can run 'amportal chown' from the Linux command line to rectify this."),true); 
     678} 
     679 
     680// Let's move some more of our checks to retrieve_conf so that we are not constantly checking these on page loads 
     681// 
     682 
     683// Warn about default Manager Interface Password 
     684// 
     685if ($amp_conf['AMPMGRPASS'] == $freepbx_conf->get_conf_default_setting('AMPMGRPASS')) { 
     686  if (!$nt->exists('core', 'AMPMGRPASS')) { 
     687    $nt->add_warning('core', 'AMPMGRPASS', _("Default Asterisk Manager Password Used"), _("You are using the default Asterisk Manager password that is widely known, you should set a secure password")); 
     688  } 
     689} else { 
     690  $nt->delete('core', 'AMPMGRPASS'); 
     691} 
     692   
     693// Warn about default ARI Admin Password 
     694// 
     695if ($amp_conf['ARI_ADMIN_PASSWORD'] == $freepbx_conf->get_conf_default_setting('ARI_ADMIN_PASSWORD')) { 
     696  if (!$nt->exists('ari', 'ARI_ADMIN_PASSWORD')) { 
     697    $nt->add_warning('ari', 'ARI_ADMIN_PASSWORD', _("Default ARI Admin password Used"), _("You are using the default ARI Admin password that is widely known, you should change to a new password. Do this in Advanced Settings")); 
     698  } 
     699} else { 
     700  $nt->delete('ari', 'ARI_ADMIN_PASSWORD'); 
     701} 
     702   
     703// Warn about default Database Password 
     704// 
     705if ($amp_conf['AMPDBPASS'] == $freepbx_conf->get_conf_default_setting('AMPDBPASS')) { 
     706  if (!$nt->exists('core', 'AMPDBPASS')) { 
     707    $nt->add_warning('core', 'AMPDBPASS', _("Default SQL Password Used"), _("You are using the default SQL password that is widely known, you should set a secure password")); 
     708  } 
     709} else { 
     710  $nt->delete('core', 'AMPDBPASS'); 
     711} 
     712 
     713// Warn if in deviceanduser mode and not using DYNAMICHINTS 
     714// 
     715if ($amp_conf['AMPEXTENSIONS'] == 'deviceanduser' && !$amp_conf['DYNAMICHINTS']) { 
     716  if (!$nt->exists('framework', 'NO_DYNAMICHINTS')) { 
     717    $nt->add_warning('framework', 'NO_DYNAMICHINTS', _("Device & User Hints Issue"), _("You are set to Device and User mode but are not set to 'Dynamically Generate Hints' which can result in improper phone state behavior. This can be changed on the Advanced Settings page, check the tooltip for specific configuration details.")); 
     718  } 
     719} else { 
     720  $nt->delete('framework', 'NO_DYNAMICHINTS'); 
    674721} 
    675722 
  • freepbx/branches/2.9/amp_conf/htdocs/admin/libraries/freepbx_conf.class.php

    r11449 r11528  
    536536  } 
    537537 
     538  /** Get's the default value of a configuration setting from the database store. 
     539   * 
     540   * @param string  The setting to fetch. 
     541   * @return mixed  returns the default of the setting, or boolean false if the 
     542   *                setting does not exist. Since configuration booleans are 
     543   *                returned as '0' and '1', they can be differentiated by a 
     544   *                true boolean false (use === operator) if a setting does 
     545   *                not exist. 
     546   */ 
     547  function get_conf_default_setting($keyword) { 
     548    if (isset($this->db_conf_store[$keyword])) { 
     549      return $this->db_conf_store[$keyword]['defaultval']; 
     550    } else { 
     551      return false; 
     552    } 
     553  } 
     554 
    538555  /** Reset all conf settings specified int the passed in array to their defaults. 
    539556   * 
  • freepbx/branches/2.9/amp_conf/htdocs/admin/libraries/notifications.class.php

    r11113 r11528  
    2626  } 
    2727 
     28  function exists($module, $id) { 
     29    $count = sql("SELECT count(*) FROM notifications WHERE `module` = '$module' AND `id` = '$id'", 'getOne'); 
     30    return ($count); 
     31  } 
    2832 
    2933  function add_critical($module, $id, $display_text, $extended_text="", $link="", $reset=true, $candelete=false) { 
  • freepbx/branches/2.9/amp_conf/htdocs/admin/libraries/view.functions.php

    r11458 r11528  
    44  global $amp_conf; 
    55 
    6   $freepbx_conf =& freepbx_conf::create(); 
    7   $amp_conf_defaults =& $freepbx_conf->conf_defaults; 
    8  
    9   $nt = notifications::create($db); 
    10   if ($amp_conf['AMPMGRPASS'] == $amp_conf_defaults['AMPMGRPASS'][1]) { 
    11     $nt->add_warning('core', 'AMPMGRPASS', _("Default Asterisk Manager Password Used"), _("You are using the default Asterisk Manager password that is widely known, you should set a secure password")); 
    12   } else { 
    13     $nt->delete('core', 'AMPMGRPASS'); 
    14   } 
    15    
    16   if ($amp_conf['ARI_ADMIN_PASSWORD'] == $amp_conf_defaults['ARI_ADMIN_PASSWORD'][1]) { 
    17     $nt->add_warning('ari', 'ARI_ADMIN_PASSWORD', _("Default ARI Admin password Used"), _("You are using the default ARI Admin password that is widely known, you should change to a new password. Do this in Advanced Settings")); 
    18   } else { 
    19     $nt->delete('ari', 'ARI_ADMIN_PASSWORD'); 
    20   } 
    21    
    22   if ($amp_conf['AMPDBPASS'] == $amp_conf_defaults['AMPDBPASS'][1]) { 
    23     $nt->add_warning('core', 'AMPDBPASS', _("Default SQL Password Used"), _("You are using the default SQL password that is widely known, you should set a secure password")); 
    24   } else { 
    25     $nt->delete('core', 'AMPDBPASS'); 
    26   } 
     6  $nt = notifications::create($db); 
     7 
     8  // Moved most of the other checks to retrieve_conf to avoid running every page load. These have been left 
     9  // here becuase both of these settings could be affected differently in the php apache related settings vs. 
     10  // what retrieve_conf would see running the CLI version of php 
     11  // 
    2712   
    2813  // Check and increase php memory_limit if needed and if allowed on the system 
     
    4732    $nt->delete('core', 'MQGPC'); 
    4833  } 
     34 
    4935} 
    5036