| 566 | | /* RC: WE SOULDN'T NEED THESE WITH NEW PHP DIALPARTIES |
|---|
| 567 | | // **** Make sure we have libasteriskperl |
|---|
| 568 | | $perl_test = "perl -e 'use Asterisk::AGI'"; |
|---|
| 569 | | outn( "Checking for libasteriskperl (perl bindings for asterisk)..." ); |
|---|
| 570 | | exec( " $perl_test &> /dev/null", $perl_output, $perl_result ); |
|---|
| 571 | | if ( $perl_result != 0) |
|---|
| 572 | | { |
|---|
| 573 | | out("FAILED\nReturn code from \"$perl_test\" is: " . $perl_result ); |
|---|
| 574 | | fatal( "Please install libasteriskperl from your vendor.\nThis perl module is needed for executing dialparties.agi." ); |
|---|
| 575 | | } |
|---|
| 576 | | out("OK"); |
|---|
| 577 | | |
|---|
| 578 | | // **** Make sure we have Net::Telnet |
|---|
| 579 | | $perl_test = "perl -e 'use Net::Telnet'"; |
|---|
| 580 | | outn( "Checking for Net::Telnet (used by dialparties.agi)..." ); |
|---|
| 581 | | exec( " $perl_test &> /dev/null", $perl_output, $perl_result ); |
|---|
| 582 | | if ( $perl_result != 0) |
|---|
| 583 | | { |
|---|
| 584 | | out("FAILED\nReturn code from \"$perl_test\" is: " . $perl_result ); |
|---|
| 585 | | fatal( "Please install Net::Telnet from your vendor or CPAN.\nThis perl module is needed for executing dialparties.agi." ); |
|---|
| 586 | | } |
|---|
| 587 | | out("OK"); |
|---|
| 588 | | */ |
|---|
| 589 | | |
|---|
| 792 | | $db_engine = 'mysql'; |
|---|
| 793 | | |
|---|
| 794 | | $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; |
|---|
| 795 | | |
|---|
| 796 | | if (!function_exists($db_engine.'_connect')) { |
|---|
| 797 | | out("FAILED"); |
|---|
| 798 | | fatal($db_engine." PHP libraries not installed"); |
|---|
| 799 | | } |
|---|
| 800 | | |
|---|
| 801 | | $db = DB::connect($datasource); // attempt connection |
|---|
| | 768 | |
|---|
| | 769 | // we still support older configurations, and fall back |
|---|
| | 770 | // into mysql when no other engine is defined |
|---|
| | 771 | if ($db_engine == "") |
|---|
| | 772 | { |
|---|
| | 773 | $db_engine = "mysql"; |
|---|
| | 774 | } |
|---|
| | 775 | |
|---|
| | 776 | switch ($db_engine) |
|---|
| | 777 | { |
|---|
| | 778 | case "pgsql": |
|---|
| | 779 | case "mysql": |
|---|
| | 780 | // datasource in in this style: dbengine://username:password@host/database |
|---|
| | 781 | if (!function_exists($db_engine.'_connect')) { |
|---|
| | 782 | out("FAILED"); |
|---|
| | 783 | fatal($db_engine." PHP libraries not installed"); |
|---|
| | 784 | } |
|---|
| | 785 | |
|---|
| | 786 | $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; |
|---|
| | 787 | $db = DB::connect($datasource); // attempt connection |
|---|
| | 788 | break; |
|---|
| | 789 | |
|---|
| | 790 | case "sqlite": |
|---|
| | 791 | if (! @ include('DB/sqlite.php')) |
|---|
| | 792 | { |
|---|
| | 793 | out("FAILED"); |
|---|
| | 794 | fatal( "Your PHP installation lacks SQLite support" ); |
|---|
| | 795 | } |
|---|
| | 796 | |
|---|
| | 797 | if (!isset($amp_conf["AMPDBFILE"])) |
|---|
| | 798 | die("You must setup properly AMPDBFILE in /etc/amportal.conf"); |
|---|
| | 799 | |
|---|
| | 800 | if (isset($amp_conf["AMPDBFILE"]) == "") |
|---|
| | 801 | die("AMPDBFILE in /etc/amportal.conf cannot be blank"); |
|---|
| | 802 | |
|---|
| | 803 | $DSN = array ( |
|---|
| | 804 | "database" => $amp_conf["AMPDBFILE"], |
|---|
| | 805 | "mode" => 0666 |
|---|
| | 806 | ); |
|---|
| | 807 | |
|---|
| | 808 | $db = new DB_sqlite(); |
|---|
| | 809 | $db->connect( $DSN ); |
|---|
| | 810 | break; |
|---|
| | 811 | |
|---|
| | 812 | default: |
|---|
| | 813 | die( "Unknown SQL engine: [$db_engine]"); |
|---|
| | 814 | } |
|---|