root/freepbx/trunk/amp_conf/htdocs/admin/common/db_connect.php

Revision 6492, 3.8 kB (checked in by p_lindheimer, 5 years ago)

Merged revisions 6458-6459,6461-6490 via svnmerge from
http://svn.freepbx.org/freepbx/branches/2.5

........

r6462 | p_lindheimer | 2008-08-24 20:37:24 -0700 (Sun, 24 Aug 2008) | 1 line


Creating release 2.5.0rc2

........

r6474 | p_lindheimer | 2008-08-25 12:06:13 -0700 (Mon, 25 Aug 2008) | 1 line


fixes #3104 - looks like some of the code paths do extra urlencodes/decodes - this looks like it does it

........

r6477 | p_lindheimer | 2008-08-25 15:26:43 -0700 (Mon, 25 Aug 2008) | 1 line


fixes #3107 don't include module specific css/js files twice in some circumstances

........

r6478 | sasargen | 2008-08-26 05:30:34 -0700 (Tue, 26 Aug 2008) | 1 line


fixes #3104 - removes manual urlencode of checkbox values because they are form fields and are automatically urlencoded by the browser when the form is submitted

........

r6483 | p_lindheimer | 2008-08-26 12:15:04 -0700 (Tue, 26 Aug 2008) | 1 line


closes #3093 reset the execution time limit to the system configured limit before each module download and install so downloading many modules at once does not result in a timeout failure, this still counts on a reasonable php.ini setting for any given installation of which the default is typically adeqaute

........

r6484 | p_lindheimer | 2008-08-26 19:06:13 -0700 (Tue, 26 Aug 2008) | 1 line


closes #3113 and ref #3090 - puts error in notification panel if magic_quotes_gpc is enabled

........

r6486 | p_lindheimer | 2008-08-27 11:40:19 -0700 (Wed, 27 Aug 2008) | 1 line


improve the symlink failure message to provide feedback on what can be done to resolve the issue

........

r6490 | p_lindheimer | 2008-08-27 22:29:03 -0700 (Wed, 27 Aug 2008) | 1 line


updated CHANGES

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 //Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
3 //
4 //This program is free software; you can redistribute it and/or
5 //modify it under the terms of the GNU General Public License
6 //as published by the Free Software Foundation; either version 2
7 //of the License, or (at your option) any later version.
8 //
9 //This program is distributed in the hope that it will be useful,
10 //but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //GNU General Public License for more details.
13
14 require_once('DB.php'); //PEAR must be installed
15
16 $db_engine = $amp_conf["AMPDBENGINE"];
17
18 switch ($db_engine)
19 {
20     case "pgsql":
21     case "mysql":
22         /* datasource in in this style:
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); // attempt connection
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         /* on centos this extension is not loaded by default */
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 // if connection failed show error
67 // don't worry about this for now, we get to it in the errors section
68 if(DB::isError($db)) {
69     die_freepbx($db->getMessage());
70 }
71
72 // Now send or delete warning wrt to default passwords:
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 // Check and increase php memory_limit if needed and if allowed on the system
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 // send error if magic_quotes_gpc is enabled on this system as much of the code base assumes not
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
Note: See TracBrowser for help on using the browser.