| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
require_once('DB.php'); |
|---|
| 15 |
|
|---|
| 16 |
$db_engine = $amp_conf["AMPDBENGINE"]; |
|---|
| 17 |
|
|---|
| 18 |
switch ($db_engine) |
|---|
| 19 |
{ |
|---|
| 20 |
case "pgsql": |
|---|
| 21 |
case "mysql": |
|---|
| 22 |
|
|---|
| 23 |
dbengine://username:password@host/database */ |
|---|
| 24 |
|
|---|
| 25 |
$db_user = $amp_conf["AMPDBUSER"]; |
|---|
| 26 |
$db_pass = $amp_conf["AMPDBPASS"]; |
|---|
| 27 |
$db_host = $amp_conf["AMPDBHOST"]; |
|---|
| 28 |
$db_name = $amp_conf["AMPDBNAME"]; |
|---|
| 29 |
|
|---|
| 30 |
$datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; |
|---|
| 31 |
$db = DB::connect($datasource); |
|---|
| 32 |
break; |
|---|
| 33 |
|
|---|
| 34 |
case "sqlite": |
|---|
| 35 |
die_freepbx("SQLite2 support is deprecated. Please use sqlite3 only."); |
|---|
| 36 |
break; |
|---|
| 37 |
|
|---|
| 38 |
case "sqlite3": |
|---|
| 39 |
if (!isset($amp_conf["AMPDBFILE"])) |
|---|
| 40 |
die_freepbx("You must setup properly AMPDBFILE in /etc/amportal.conf"); |
|---|
| 41 |
|
|---|
| 42 |
if (isset($amp_conf["AMPDBFILE"]) == "") |
|---|
| 43 |
die_freepbx("AMPDBFILE in /etc/amportal.conf cannot be blank"); |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
if (! extension_loaded('sqlite3') && ! extension_loaded('SQLITE3')) |
|---|
| 47 |
dl('sqlite3.so'); |
|---|
| 48 |
|
|---|
| 49 |
if (! @require_once('DB/sqlite3.php') ) |
|---|
| 50 |
{ |
|---|
| 51 |
die_freepbx("Your PHP installation has no PEAR/SQLite3 support. Please install php-sqlite3 and php-pear."); |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
$datasource = "sqlite3:///" . $amp_conf["AMPDBFILE"] . "?mode=0666"; |
|---|
| 55 |
$options = array( |
|---|
| 56 |
'debug' => 4, |
|---|
| 57 |
'portability' => DB_PORTABILITY_NUMROWS |
|---|
| 58 |
); |
|---|
| 59 |
$db = DB::connect($datasource, $options); |
|---|
| 60 |
break; |
|---|
| 61 |
|
|---|
| 62 |
default: |
|---|
| 63 |
die_freepbx( "Unknown SQL engine: [$db_engine]"); |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
if(DB::isError($db)) { |
|---|
| 69 |
die_freepbx($db->getMessage()); |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
$nt = notifications::create($db); |
|---|
| 75 |
|
|---|
| 76 |
if ($amp_conf['AMPDBPASS'] == $amp_conf_defaults['AMPDBPASS'][1]) { |
|---|
| 77 |
$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")); |
|---|
| 78 |
} else { |
|---|
| 79 |
$nt->delete('core', 'AMPDBPASS'); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
$current_memory_limit = rtrim(ini_get('memory_limit'),'M'); |
|---|
| 85 |
$proper_memory_limit = '100'; |
|---|
| 86 |
if ($current_memory_limit < $proper_memory_limit) { |
|---|
| 87 |
if (ini_set('memory_limit',$proper_memory_limit.'M') !== false) { |
|---|
| 88 |
$nt->add_notice('core', 'MEMLIMIT', _("Memory Limit Changed"), sprintf(_("Your memory_limit, %sM, is set too low and has been increased to %sM. You may want to change this in you php.ini config file"),$current_memory_limit,$proper_memory_limit)); |
|---|
| 89 |
} else { |
|---|
| 90 |
$nt->add_warning('core', 'MEMERR', _("Low Memory Limit"), sprintf(_("Your memory_limit, %sM, is set too low and may cause problems. FreePBX is not able to change this on your system. You should increase this to %sM in you php.ini config file"),$current_memory_limit,$proper_memory_limit)); |
|---|
| 91 |
} |
|---|
| 92 |
} else { |
|---|
| 93 |
$nt->delete('core', 'MEMLIMIT'); |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
if(get_magic_quotes_gpc()) { |
|---|
| 99 |
$nt->add_error('core', 'MQGPC', _("Magic Quotes GPC"), _("You have magic_quotes_gpc enabled in your php.ini, http or .htaccess file which will cause errors in some modules. FreePBX expects this to be off and runs under that assumption")); |
|---|
| 100 |
} else { |
|---|
| 101 |
$nt->delete('core', 'MQGPC'); |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|