Changeset 13393

Show
Ignore:
Timestamp:
02/02/12 11:59:38 (1 year ago)
Author:
mbrevda
Message:

re #4909 - reuse cdrdb object, take three - nothing should have been changed in bootstrap.php, all changes should be in common.php. Thanks jdccdevel. Please test this and report back!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/amp_conf/htdocs/recordings/includes/common.php

    r13119 r13393  
    9393 */ 
    9494function databaseLogon() { 
    95   global $STANDALONE; 
    96  
    97   global $ASTERISKMGR_DBHOST; 
    98  
    99   global $AMP_FUNCTIONS_FILES; 
    100   global $AMPORTAL_CONF_FILE; 
    101  
    102   global $LEGACY_AMP_DBENGINE; 
    103   global $LEGACY_AMP_DBFILE; 
    104   global $LEGACY_AMP_DBHOST; 
    105   global $LEGACY_AMP_DBNAME; 
    106  
    107   global $ASTERISKCDR_DBENGINE; 
    108   global $ASTERISKCDR_DBFILE; 
    109   global $ASTERISKCDR_DBHOST; 
    110   global $ASTERISKCDR_DBNAME; 
    111  
    112   global $ARI_DISABLED_MODULES; 
    113  
    114   global $ARI_ADMIN_USERNAME; 
    115   global $ARI_ADMIN_PASSWORD; 
    116   global $ariadminusername; 
    117   global $ariadminpassword; 
    118  
    119   global $loaded_modules; 
    120  
    121   // This variable is a global in the FreePBX function.inc.php but needs to be 
    122   // declared here or the is not seen when parse_amprotaconf() is eventually called 
    123   // ?php bug? 
    124   // 
    125   global $amp_conf_defaults; 
     95  global $AMPORTAL_CONF_FILE, 
     96      $AMP_FUNCTIONS_FILES, 
     97      $ARI_ADMIN_PASSWORD, 
     98      $ARI_ADMIN_USERNAME, 
     99      $ARI_DISABLED_MODULES, 
     100      $ASTERISKMGR_DBHOST, 
     101      $LEGACY_AMP_DBENGINE, 
     102      $LEGACY_AMP_DBFILE, 
     103      $LEGACY_AMP_DBHOST, 
     104      $LEGACY_AMP_DBNAME, 
     105      $amp_conf,  
     106      $amp_conf_defaults,  
     107      $amp_usedevstate, 
     108      $ariadminpassword, 
     109      $ariadminusername, 
     110      $asterisk_manager_interface,  
     111      $astman,  
     112      $cdrdb,  
     113      $db,  
     114      $loaded_modules, 
     115      $STANDALONE; 
     116 
    126117 
    127118  // get user 
     
    130121    $mgruser = $STANDALONE['asterisk_mgruser']; 
    131122    $mgrpass = $STANDALONE['asterisk_mgrpass']; 
    132     $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; 
    133     $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; 
    134     $asteriskcdr_dbuser = $STANDALONE['asteriskcdr_dbuser']; 
    135     $asteriskcdr_dbpass = $STANDALONE['asteriskcdr_dbpass']; 
    136     $asteriskcdr_dbhost = $ASTERISKCDR_DBHOST; 
    137     $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; 
    138123  } else { 
    139      
    140     global $amp_conf, $amp_usedevstate; 
     124 
    141125    $ariadminusername = isset($amp_conf["ARI_ADMIN_USERNAME"]) ? $amp_conf["ARI_ADMIN_USERNAME"] : $ARI_ADMIN_USERNAME; 
    142126    $ariadminpassword = isset($amp_conf["ARI_ADMIN_PASSWORD"]) ? $amp_conf["ARI_ADMIN_PASSWORD"] : $ARI_ADMIN_PASSWORD; 
     
    144128    $mgruser = $amp_conf['AMPMGRUSER']; 
    145129    $mgrpass = $amp_conf['AMPMGRPASS']; 
    146  
    147     $amp_dbengine = isset($amp_conf["AMPDBENGINE"]) ? $amp_conf["AMPDBENGINE"] : $LEGACY_AMP_DBENGINE; 
    148     $amp_dbfile = isset($amp_conf["AMPDBFILE"]) ? $amp_conf["AMPDBFILE"] : $LEGACY_AMP_DBFILE; 
    149     $amp_dbuser = $amp_conf["AMPDBUSER"]; 
    150     $amp_dbpass = $amp_conf["AMPDBPASS"]; 
    151     $amp_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $LEGACY_AMP_DBHOST; 
    152     $amp_dbname = isset($amp_conf["AMPDBNAME"]) ? $amp_conf["AMPDBNAME"] : $LEGACY_AMP_DBNAME; 
    153  
    154     $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; 
    155     $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; 
    156     $asteriskcdr_dbuser = $amp_conf["AMPDBUSER"]; 
    157     $asteriskcdr_dbpass = $amp_conf["AMPDBPASS"]; 
    158     $asteriskcdr_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $ASTERISKCDR_DBHOST; 
    159     $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; 
    160130     
    161131    $amp_usedevstate = isset($amp_conf["USEDEVSTATE"]) ? strtolower(trim($amp_conf["USEDEVSTATE"])) : 0; 
     
    166136    } 
    167137 
    168   } 
    169  
    170   // asterisk manager interface (berkeley database I think) 
    171   global $asterisk_manager_interface; 
     138  } 
     139 
    172140  $asterisk_manager_interface = new AsteriskManagerInterface(); 
    173141 
    174142  $success = $asterisk_manager_interface->Connect($mgrhost,$mgruser,$mgrpass); 
    175143  if (!$success) { 
    176     $_SESSION['ari_error'] =   
    177       _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" .  
    178       _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" .  
    179       _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
    180       _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
    181     return FALSE; 
    182   } 
    183  
    184  
    185   global $astman; 
     144    $_SESSION['ari_error'] =   
     145      _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" .  
     146      _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" .  
     147      _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
     148      _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
     149    return FALSE; 
     150  } 
     151 
    186152  if (!isset($astman) || !$astman) { 
    187153    // couldn't connect to astman 
    188         $_SESSION['ari_error'] = 
    189         _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" . 
    190         _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" . 
    191         _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
    192         _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
    193   } 
    194  
    195  
    196   global $db; 
     154    $_SESSION['ari_error'] = 
     155      _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" . 
     156      _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" . 
     157      _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
     158      _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
     159  } 
     160 
    197161  if (isset($db) && $db) { 
    198162    $_SESSION['dbh_asterisk'] = $db; 
    199   } else { 
    200     $_SESSION['ari_error'] .= _("Cannot connect to the $amp_dbname database") . "<br>" . 
    201                               _("Check AMP installation, asterisk, and ARI main.conf"); 
    202      return FALSE; 
    203 
     163  } 
    204164 
    205165  // cdr database 
    206   if (in_array('callmonitor',array_keys($loaded_modules))) { 
    207    $cdrdb = new Database(); 
    208     $_SESSION['dbh_cdr'] = $cdrdb->logon($asteriskcdr_dbengine, 
    209                                       $asteriskcdr_dbfile, 
    210                                       $asteriskcdr_dbuser,  
    211                                       $asteriskcdr_dbpass, 
    212                                       $asteriskcdr_dbhost, 
    213                                       $asteriskcdr_dbname); 
    214     if (!isset($_SESSION['dbh_cdr'])) { 
    215       $_SESSION['ari_error'] .= sprintf(_("Cannot connect to the $asteriskcdr_dbname database"),$asteriskcdr_dbname) . "<br>" . 
    216                                _("Check AMP installation, asterisk, and ARI main.conf"); 
    217       return FALSE; 
    218     } 
    219   } 
    220  
    221   return TRUE; 
     166  if (isset($cdrdb) && $cdrdb) { 
     167    $_SESSION['dbh_cdr'] = $cdrdb; 
     168  } 
     169   
     170  return TRUE; 
    222171} 
    223172