Skip to content
This repository
Browse code

Fix a dialplan and inbound routes bug.

git-svn-id: http://fusionpbx.googlecode.com/svn/trunk@322 e2954ef0-caed-11de-bd98-e341d93cc3cc
  • Loading branch information...
commit 9c8391e9e2119cb575e1c39d89600e13761403c9 1 parent 50dc5f6
Mark J Crane authored
40 fusionpbx/includes/install/source.xml
@@ -926,9 +926,9 @@
926 926 <src>
927 927 <type>file</type>
928 928 <path>mod/recordings/v_recordings.php</path>
929   - <last_mod>Fri, 06 Aug 2010 08:21:52 GMT</last_mod>
930   - <md5>c14100f1b535f96974626b13328a3090</md5>
931   - <size>16499</size>
  929 + <last_mod>Fri, 13 Aug 2010 09:56:26 GMT</last_mod>
  930 + <md5>fe57be200d70bf00adc7130d3661b299</md5>
  931 + <size>16500</size>
932 932 </src>
933 933 <src>
934 934 <type>file</type>
@@ -1801,9 +1801,9 @@
1801 1801 <src>
1802 1802 <type>file</type>
1803 1803 <path>mod/ivr_menu/v_ivr_menu.php</path>
1804   - <last_mod>Sat, 07 Aug 2010 03:29:02 GMT</last_mod>
1805   - <md5>242160e93508dd07e97c0aac365ab045</md5>
1806   - <size>5400</size>
  1804 + <last_mod>Fri, 13 Aug 2010 09:54:23 GMT</last_mod>
  1805 + <md5>88952d0acd6984bbca3011577122cdc2</md5>
  1806 + <size>5401</size>
1807 1807 </src>
1808 1808 <src>
1809 1809 <type>file</type>
@@ -1836,9 +1836,9 @@
1836 1836 <src>
1837 1837 <type>file</type>
1838 1838 <path>mod/ivr_menu/v_ivr_menu_options_edit.php</path>
1839   - <last_mod>Tue, 10 Aug 2010 22:48:11 GMT</last_mod>
1840   - <md5>9001a479d993ddb25912afd519d2a5dd</md5>
1841   - <size>11107</size>
  1839 + <last_mod>Fri, 13 Aug 2010 07:31:47 GMT</last_mod>
  1840 + <md5>dbba360c885da5cbb0503eb9164aa2f7</md5>
  1841 + <size>11720</size>
1842 1842 </src>
1843 1843 <src>
1844 1844 <type>directory</type>
@@ -2179,9 +2179,9 @@
2179 2179 <src>
2180 2180 <type>file</type>
2181 2181 <path>mod/public_includes/v_public_includes_add.php</path>
2182   - <last_mod>Thu, 15 Jul 2010 07:04:48 GMT</last_mod>
2183   - <md5>d8ae36f452f7d3533d639009362a3ed1</md5>
2184   - <size>25747</size>
  2182 + <last_mod>Sat, 14 Aug 2010 07:04:05 GMT</last_mod>
  2183 + <md5>ad75b8f2fe06a7e38cf0e161aa5814a3</md5>
  2184 + <size>26225</size>
2185 2185 </src>
2186 2186 <src>
2187 2187 <type>file</type>
@@ -2382,9 +2382,9 @@
2382 2382 <src>
2383 2383 <type>file</type>
2384 2384 <path>mod/dialplan/v_dialplan_includes_add.php</path>
2385   - <last_mod>Thu, 15 Jul 2010 08:24:11 GMT</last_mod>
2386   - <md5>2f0bdbf84e398722b43b148447108e2e</md5>
2387   - <size>26429</size>
  2385 + <last_mod>Sat, 14 Aug 2010 07:00:52 GMT</last_mod>
  2386 + <md5>3d234f0355ce2c1b332ce504260d568e</md5>
  2387 + <size>26489</size>
2388 2388 </src>
2389 2389 <src>
2390 2390 <type>directory</type>
@@ -4468,9 +4468,9 @@
4468 4468 <src>
4469 4469 <type>file</type>
4470 4470 <path>includes/lib_switch.php</path>
4471   - <last_mod>Tue, 10 Aug 2010 22:28:23 GMT</last_mod>
4472   - <md5>684480b884229a6e48a7fe287089616c</md5>
4473   - <size>219456</size>
  4471 + <last_mod>Fri, 13 Aug 2010 07:28:11 GMT</last_mod>
  4472 + <md5>cc000f02b36cb5245e8b9263d4703662</md5>
  4473 + <size>219471</size>
4474 4474 </src>
4475 4475 <src>
4476 4476 <type>file</type>
@@ -5070,8 +5070,8 @@
5070 5070 <src>
5071 5071 <type>file</type>
5072 5072 <path>index.php</path>
5073   - <last_mod>Wed, 11 Aug 2010 06:50:33 GMT</last_mod>
5074   - <md5>68aa1842bbb2858a2a574adbf8347fd4</md5>
  5073 + <last_mod>Fri, 13 Aug 2010 07:40:03 GMT</last_mod>
  5074 + <md5>a192fed1e029a560100bb31a526215da</md5>
5075 5075 <size>11455</size>
5076 5076 </src>
5077 5077 <src>
4 fusionpbx/includes/lib_switch.php
@@ -556,7 +556,7 @@ function ListFiles($dir) {
556 556 }
557 557 }
558 558
559   -function switch_select_destination($select_type, $select_name, $select_value, $select_style, $action='') {
  559 +function switch_select_destination($select_type, $select_label, $select_name, $select_value, $select_style, $action='') {
560 560 //$select_type = "ivr"; //$select_type='dialplan'
561 561 global $config, $db, $v_id;
562 562 $v_settings_array = v_settings();
@@ -601,7 +601,7 @@ function switch_select_destination($select_type, $select_name, $select_value, $s
601 601 if (ifgroup("superadmin")) {
602 602 echo " <select name='".$select_name."' class='formfld' style='".$select_style."' onchange='changeToInput(this);'>\n";
603 603 if (strlen($select_value) > 0) {
604   - echo " <option value='".$action.":".$select_value."' selected='selected'>".$select_value."</option>\n";
  604 + echo " <option value='".$action.":".$select_value."' selected='selected'>".$select_label."</option>\n";
605 605 }
606 606 }
607 607 else {
2  fusionpbx/index.php
@@ -81,7 +81,7 @@
81 81
82 82 //get the software information
83 83 //include "includes/v_version.php";
84   - $software_version = "1.1.26";
  84 + $software_version = "1.1.27";
85 85 echo "<table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
86 86 echo "<tr>\n";
87 87 echo " <th colspan='2' align='left'>System Information</th>\n";
840 fusionpbx/install.php
@@ -67,25 +67,50 @@ function sys_get_temp_dir() {
67 67 //set the max execution time to 1 hour
68 68 ini_set('max_execution_time',3600);
69 69
70   -//define the variables
71   - $dbtype = '';
72   - $dbfilename = '';
73   - $dbfilepath = '';
74   - $dbhost = '';
75   - $dbport = '';
76   - $dbname = '';
77   - $dbusername = '';
78   - $dbpassword = '';
79   -
80   -//install_ prefix was used to so these variables aren't overwritten by config.php
81   - $install_v_dir = '';
82   - $install_php_dir = '';
83   - $install_tmp_dir = '';
84   - $install_v_backup_dir = '';
85   -
86   - //set the default dbfilepath
87   - if (strlen($dbfilepath) == 0) { //secure dir
88   - $dbfilepath = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
  70 +//set php variables with data from http
  71 + $db_type = $_POST["db_type"];
  72 + $db_filename = $_POST["db_filename"];
  73 + $db_host = $_POST["db_host"];
  74 + $db_port = $_POST["db_port"];
  75 + $db_name = $_POST["db_name"];
  76 + $db_username = $_POST["db_username"];
  77 + $db_password = $_POST["db_password"];
  78 + $db_create_username = $_POST["db_create_username"];
  79 + $db_create_password = $_POST["db_create_password"];
  80 + $db_filepath = $_POST["db_filepath"];
  81 + $install_step = $_POST["install_step"];
  82 + $install_secure_dir = $_POST["install_secure_dir"];
  83 + $install_php_dir = $_POST["install_php_dir"];
  84 + $install_tmp_dir = $_POST["install_tmp_dir"];
  85 + $install_v_backup_dir = $_POST["install_v_backup_dir"];
  86 + $install_v_dir = $_POST["install_v_dir"];
  87 +
  88 +//clean up the values
  89 + $install_v_dir = realpath($install_v_dir);
  90 + $install_v_dir = str_replace("\\", "/", $install_v_dir);
  91 +
  92 + $install_php_dir = realpath($_POST["install_php_dir"]);
  93 + $install_php_dir = str_replace("\\", "/", $install_php_dir);
  94 +
  95 + $install_tmp_dir = realpath($_POST["install_tmp_dir"]);
  96 + $install_tmp_dir = str_replace("\\", "/", $install_tmp_dir);
  97 +
  98 + $install_v_backup_dir = realpath($_POST["install_v_backup_dir"]);
  99 + $install_v_backup_dir = str_replace("\\", "/", $install_v_backup_dir);
  100 +
  101 +//set the default install_secure_dir
  102 + if (strlen($install_secure_dir) == 0) { //secure dir
  103 + $install_secure_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
  104 + }
  105 +
  106 +//set the default db_filepath
  107 + if (strlen($db_filepath) == 0) { //secure dir
  108 + $db_filepath = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
  109 + }
  110 +
  111 +//set the default db_filename
  112 + if ($db_type == "sqlite") {
  113 + if (strlen($db_filename) == 0) { $db_filename = "fusionpbx.db"; }
89 114 }
90 115
91 116 //find the freeswitch directory
@@ -195,31 +220,11 @@ function sys_get_temp_dir() {
195 220 }
196 221
197 222
198   -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
  223 +if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
199 224
200 225 $msg = '';
201   - $dbtype = $_POST["dbtype"];
202   - $dbfilename = $_POST["dbfilename"];
203   - $dbfilepath = $_POST["dbfilepath"];
204   - $dbhost = $_POST["dbhost"];
205   - $dbport = $_POST["dbport"];
206   - $dbname = $_POST["dbname"];
207   - $dbusername = $_POST["dbusername"];
208   - $dbpassword = $_POST["dbpassword"];
209   - $install_v_dir = realpath($_POST["install_v_dir"]);
210   - $install_v_dir = str_replace("\\", "/", $install_v_dir);
211   -
212   - $install_php_dir = realpath($_POST["install_php_dir"]);
213   - $install_php_dir = str_replace("\\", "/", $install_php_dir);
214   -
215   - $install_tmp_dir = realpath($_POST["install_tmp_dir"]);
216   - $install_tmp_dir = str_replace("\\", "/", $install_tmp_dir);
217   -
218   - $install_v_backup_dir = realpath($_POST["install_v_backup_dir"]);
219   - $install_v_backup_dir = str_replace("\\", "/", $install_v_backup_dir);
220   -
221 226 //check for all required data
222   - if (strlen($dbtype) == 0) { $msg .= "Please provide the Database Type<br>\n"; }
  227 + if (strlen($db_type) == 0) { $msg .= "Please provide the Database Type<br>\n"; }
223 228 if (strlen($install_v_dir) == 0) { $msg .= "Please provide the Switch Directory<br>\n"; }
224 229 if (strlen($install_php_dir) == 0) { $msg .= "Please provide the PHP Directory<br>\n"; }
225 230 if (strlen($install_tmp_dir) == 0) { $msg .= "Please provide the Temp Directory<br>\n"; }
@@ -229,7 +234,7 @@ function sys_get_temp_dir() {
229 234 //some windows operating systems report read only but are writable
230 235 }
231 236 else {
232   - $msg .= "<b>Write access to ".$install_v_dir." and its sub-directories is required.</b><br />\n";
  237 + //$msg .= "<b>Write access to ".$install_v_dir." and its sub-directories is required.</b><br />\n";
233 238 }
234 239 }
235 240 if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
@@ -280,26 +285,26 @@ function sys_get_temp_dir() {
280 285 $tmp_config .= "//-----------------------------------------------------\n";
281 286 $tmp_config .= "\n";
282 287 $tmp_config .= " //set the database type\n";
283   - $tmp_config .= " \$dbtype = '".$dbtype."'; //sqlite, mysql, pgsql, others with a manually created PDO connection\n";
  288 + $tmp_config .= " \$dbtype = '".$db_type."'; //sqlite, mysql, pgsql, others with a manually created PDO connection\n";
284 289 $tmp_config .= "\n";
285   - if ($dbtype == "sqlite") {
  290 + if ($db_type == "sqlite") {
286 291 $tmp_config .= " //sqlite: the dbfilename and dbfilepath are automatically assigned however the values can be overidden by setting the values here.\n";
287   - $tmp_config .= " \$dbfilename = '".$dbfilename."'; //host name/ip address + '.db' is the default database filename\n";
288   - $tmp_config .= " \$dbfilepath = '".$dbfilepath."'; //the path is determined by a php variable\n";
  292 + $tmp_config .= " \$dbfilename = '".$db_filename."'; //host name/ip address + '.db' is the default database filename\n";
  293 + $tmp_config .= " \$dbfilepath = '".$db_filepath."'; //the path is determined by a php variable\n";
289 294 }
290 295 $tmp_config .= "\n";
291 296 $tmp_config .= " //mysql: database connection information\n";
292   - if ($dbtype == "mysql") {
293   - if ($dbhost == "localhost") {
  297 + if ($db_type == "mysql") {
  298 + if ($db_host == "localhost") {
294 299 //if localhost is used it defaults to a Unix Socket which doesn't seem to work.
295 300 //replace localhost with 127.0.0.1 so that it will connect using TCP
296   - $dbhost = "127.0.0.1";
  301 + $db_host = "127.0.0.1";
297 302 }
298   - $tmp_config .= " \$dbhost = '".$dbhost."';\n";
299   - $tmp_config .= " \$dbport = '".$dbport."';\n";
300   - $tmp_config .= " \$dbname = '".$dbname."';\n";
301   - $tmp_config .= " \$dbusername = '".$dbusername."';\n";
302   - $tmp_config .= " \$dbpassword = '".$dbpassword."';\n";
  303 + $tmp_config .= " \$dbhost = '".$db_host."';\n";
  304 + $tmp_config .= " \$dbport = '".$db_port."';\n";
  305 + $tmp_config .= " \$dbname = '".$db_name."';\n";
  306 + $tmp_config .= " \$dbusername = '".$db_username."';\n";
  307 + $tmp_config .= " \$dbpassword = '".$db_password."';\n";
303 308 }
304 309 else {
305 310 $tmp_config .= " //\$dbhost = '';\n";
@@ -310,19 +315,19 @@ function sys_get_temp_dir() {
310 315 }
311 316 $tmp_config .= "\n";
312 317 $tmp_config .= " //pgsql: database connection information\n";
313   - if ($dbtype == "pgsql") {
314   - $tmp_config .= " \$dbhost = '".$dbhost."'; //set the host only if the database is not local\n";
315   - $tmp_config .= " \$dbport = '".$dbport."';\n";
316   - $tmp_config .= " \$dbname = '".$dbname."';\n";
317   - $tmp_config .= " \$dbusername = '".$dbusername."';\n";
318   - $tmp_config .= " \$dbpassword = '".$dbpassword."';\n";
  318 + if ($db_type == "pgsql") {
  319 + $tmp_config .= " \$dbhost = '".$db_host."'; //set the host only if the database is not local\n";
  320 + $tmp_config .= " \$dbport = '".$db_port."';\n";
  321 + $tmp_config .= " \$dbname = '".$db_name."';\n";
  322 + $tmp_config .= " \$dbusername = '".$db_username."';\n";
  323 + $tmp_config .= " \$dbpassword = '".$db_password."';\n";
319 324 }
320 325 else {
321   - $tmp_config .= " //\$dbhost = '".$dbhost."'; //set the host only if the database is not local\n";
322   - $tmp_config .= " //\$dbport = '".$dbport."';\n";
323   - $tmp_config .= " //\$dbname = '".$dbname."';\n";
324   - $tmp_config .= " //\$dbusername = '".$dbusername."';\n";
325   - $tmp_config .= " //\$dbpassword = '".$dbpassword."';\n";
  326 + $tmp_config .= " //\$dbhost = '".$db_host."'; //set the host only if the database is not local\n";
  327 + $tmp_config .= " //\$dbport = '".$db_port."';\n";
  328 + $tmp_config .= " //\$dbname = '".$db_name."';\n";
  329 + $tmp_config .= " //\$dbusername = '".$db_username."';\n";
  330 + $tmp_config .= " //\$dbpassword = '".$db_password."';\n";
326 331 }
327 332 $tmp_config .= "\n";
328 333 $tmp_config .= " //show errors\n";
@@ -345,11 +350,11 @@ function sys_get_temp_dir() {
345 350 //copy the secure directory
346 351 $srcdir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
347 352 //if the directory already exists do not copy over it.
348   - if (!is_dir($dbfilepath)) {
  353 + if (!is_dir($install_secure_dir)) {
349 354 //only copy if the src and dest are different
350   - if ($srcdir != $dbfilepath) {
351   - if (!is_dir($dbfilepath)) { mkdir($dbfilepath,0777,true); }
352   - recursive_copy($srcdir, $dbfilepath);
  355 + if ($srcdir != $install_secure_dir) {
  356 + if (!is_dir($install_secure_dir)) { mkdir($install_secure_dir,0777,true); }
  357 + recursive_copy($srcdir, $install_secure_dir);
353 358 }
354 359 }
355 360 unset($srcdir);
@@ -360,13 +365,44 @@ function sys_get_temp_dir() {
360 365 fclose($fout);
361 366
362 367 //load data into the database
363   - if ($dbtype == "sqlite") {
  368 + if ($db_type == "sqlite") {
364 369 //sqlite database will be created when the config.php is loaded and only if the database file does not exist
  370 + $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/sqlite.sql';
  371 + $file_contents = file_get_contents($filename);
  372 + unset($filename);
  373 + try {
  374 + $db = new PDO('sqlite:'.$db_filepath.'/'.$db_filename); //sqlite 3
  375 + //$db = new PDO('sqlite::memory:'); //sqlite 3
  376 + $db->beginTransaction();
  377 + }
  378 + catch (PDOException $error) {
  379 + print "error: " . $error->getMessage() . "<br/>";
  380 + die();
  381 + }
  382 +
  383 + //replace \r\n with \n then explode on \n
  384 + $file_contents = str_replace("\r\n", "\n", $file_contents);
  385 +
  386 + //loop line by line through all the lines of sql code
  387 + $stringarray = explode("\n", $file_contents);
  388 + $x = 0;
  389 + foreach($stringarray as $sql) {
  390 + try {
  391 + $db->query($sql);
  392 + }
  393 + catch (PDOException $error) {
  394 + echo "error: " . $error->getMessage() . " sql: $sql<br/>";
  395 + //die();
  396 + }
  397 + $x++;
  398 + }
  399 + unset ($file_contents, $sql);
  400 + $db->commit();
365 401 }
366 402
367 403 //--- begin: create the pgsql database -----------------------------------------
368 404 /*
369   - if ($dbtype == "pgsql") {
  405 + if ($db_type == "pgsql") {
370 406
371 407 $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/pgsql.sql';
372 408 $file_contents = file_get_contents($filename);
@@ -376,12 +412,12 @@ function sys_get_temp_dir() {
376 412
377 413 //database connection
378 414 try {
379   - if (strlen($dbhost) > 0) {
380   - if (strlen($dbport) == 0) { $dbport = "5432"; }
381   - $dbsql = new PDO("pgsql:host=localhost port=5432 user=$dbusername password=$dbpassword");
  415 + if (strlen($db_host) > 0) {
  416 + if (strlen($db_port) == 0) { $db_port = "5432"; }
  417 + $db_sql = new PDO("pgsql:host=localhost port=5432 user=$db_username password=$db_password");
382 418 }
383 419 else {
384   - $dbsql = new PDO("pgsql:user=$dbusername password=$dbpassword");
  420 + $db_sql = new PDO("pgsql:user=$db_username password=$db_password");
385 421 }
386 422 }
387 423 catch (PDOException $error) {
@@ -391,22 +427,22 @@ function sys_get_temp_dir() {
391 427
392 428 //create the database
393 429 $sql = "";
394   - $sql .= "CREATE DATABASE $dbname; ";
  430 + $sql .= "CREATE DATABASE $db_name; ";
395 431 //echo $sql;
396   - $dbsql->query($sql);
  432 + $db_sql->query($sql);
397 433 unset($sql);
398 434
399 435 //close database connection_aborted
400   - $dbsql = null;
  436 + $db_sql = null;
401 437
402   - //open database connection with $dbname
  438 + //open database connection with $db_name
403 439 try {
404   - if (strlen($dbhost) > 0) {
405   - if (strlen($dbport) == 0) { $dbport = "5432"; }
406   - $dbsql = new PDO("pgsql:host=localhost port=5432 dbname=$dbname user=$dbusername password=$dbpassword");
  440 + if (strlen($db_host) > 0) {
  441 + if (strlen($db_port) == 0) { $db_port = "5432"; }
  442 + $db_sql = new PDO("pgsql:host=localhost port=5432 db_name=$db_name user=$db_username password=$db_password");
407 443 }
408 444 else {
409   - $dbsql = new PDO("pgsql:dbname=$dbname user=$dbusername password=$dbpassword");
  445 + $db_sql = new PDO("pgsql:db_name=$db_name user=$db_username password=$db_password");
410 446 }
411 447 }
412 448 catch (PDOException $error) {
@@ -423,7 +459,7 @@ function sys_get_temp_dir() {
423 459 foreach($stringarray as $sql) {
424 460 if (strlen($sql) > 3) {
425 461 try {
426   - $dbsql->query($sql);
  462 + $db_sql->query($sql);
427 463 }
428 464 catch (PDOException $error) {
429 465 echo "error: " . $error->getMessage() . " sql: $sql<br/>";
@@ -432,57 +468,60 @@ function sys_get_temp_dir() {
432 468 }
433 469 $x++;
434 470 }
435   - unset ($dbsql, $file_contents, $sql);
  471 + unset ($db_sql, $file_contents, $sql);
436 472 }
437 473 */
438 474 //--- end: create the pgsql database -----------------------------------------
439 475
440 476
441 477 //--- begin: create the mysql database -----------------------------------------
442   - if ($dbtype == "mysql") {
  478 + if ($db_type == "mysql") {
443 479 $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/mysql.sql';
444 480 $file_contents = file_get_contents($filename);
445   - //echo "<pre>\n";
446   - //echo $file_contents;
447   - //echo "</pre>\n";
448 481
449 482 //database connection
450 483 try {
451   - if (strlen($dbhost) == 0 && strlen($dbport) == 0) {
452   - //if both host and port are empty use the unix socket
453   - $dbsql = new PDO("mysql:host=$dbhost;unix_socket=/var/run/mysqld/mysqld.sock;", $dbusername, $dbpassword);
454   - }
455   - else {
456   - if (strlen($dbport) == 0) {
457   - //leave out port if it is empty
458   - $dbsql = new PDO("mysql:host=$dbhost;", $dbusername, $dbpassword);
  484 + if (strlen($db_host) == 0 && strlen($db_port) == 0) {
  485 + //if both host and port are empty use the unix socket
  486 + $db_sql = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_username, $db_password);
459 487 }
460 488 else {
461   - $dbsql = new PDO("mysql:host=$dbhost;port=$dbport;", $dbusername, $dbpassword);
  489 + if (strlen($db_port) == 0) {
  490 + //leave out port if it is empty
  491 + $db_sql = new PDO("mysql:host=$db_host;", $db_username, $db_password);
  492 + }
  493 + else {
  494 + $db_sql = new PDO("mysql:host=$db_host;port=$db_port;", $db_username, $db_password);
  495 + }
462 496 }
463   - }
464   - $dbsql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
465   - }
466   - catch (PDOException $error) {
467   - print "error: " . $error->getMessage() . "<br/>";
468   - //die();
469   - }
470   -
471   - //create the database
472   - try {
473   - $dbsql->query("CREATE DATABASE $dbname;");
  497 + $db_sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
474 498 }
475 499 catch (PDOException $error) {
476   - //database exists so upgrade the schema
477   - $display_results = false;
478   - require_once "core/upgrade/upgrade_schema.php";
479   - header("Location: ".PROJECT_PATH."/login.php");
480   - exit;
  500 + print "error: " . $error->getMessage() . "<br/>";
  501 + //die();
481 502 }
482 503
  504 + //create the database
  505 + $db_sql->query("CREATE DATABASE $db_name;");
  506 +
483 507 //select the database
484   - $dbsql->query("USE $dbname;");
  508 + $db_sql->query("USE $db_name;");
485 509
  510 + //include the new config.php file
  511 + require_once "includes/config.php";
  512 +
  513 + //load the default database into memory and compare it with the active database
  514 + $display_results = false;
  515 + require_once "includes/lib_schema.php";
  516 + db_upgrade_schema ($db, $db_type, $display_results);
  517 +
  518 + //add the defaults data into the database
  519 +
  520 + //redirect to the login page
  521 + header("Location: ".PROJECT_PATH."/login.php");
  522 + exit;
  523 +
  524 + /*
486 525 //replace \r\n with \n then explode on \n
487 526 $file_contents = str_replace("\r\n", "\n", $file_contents);
488 527
@@ -492,7 +531,7 @@ function sys_get_temp_dir() {
492 531 foreach($stringarray as $sql) {
493 532 if (strlen($sql) > 3) {
494 533 try {
495   - $dbsql->query($sql);
  534 + $db_sql->query($sql);
496 535 }
497 536 catch (PDOException $error) {
498 537 //echo "error on line $x: " . $error->getMessage() . " sql: $sql<br/>";
@@ -501,15 +540,12 @@ function sys_get_temp_dir() {
501 540 }
502 541 $x++;
503 542 }
504   - unset ($dbsql, $file_contents, $sql);
505   -
  543 + unset ($db_sql, $file_contents, $sql);
  544 + */
506 545 }
507 546 //--- end: create the mysql database -----------------------------------------
508 547
509 548
510   - //include the new config.php file
511   - require_once "includes/config.php";
512   -
513 549 //set system settings paths
514 550 //$install_v_dir = ''; //freeswitch directory
515 551 //$install_php_dir = '';
@@ -690,8 +726,8 @@ function sys_get_temp_dir() {
690 726 unset($srcfile, $destfile);
691 727
692 728 //activate the .htaccess file
693   - $srcfile = $dbfilepath.'/htaccess.tmp';
694   - $destfile = $dbfilepath.'/.htaccess';
  729 + $srcfile = $install_secure_dir.'/htaccess.tmp';
  730 + $destfile = $install_secure_dir.'/.htaccess';
695 731 if (!copy($srcfile, $destfile)) {
696 732 //echo "failed to copy $srcfile to $destfile...\n";
697 733 //exit;
@@ -706,7 +742,7 @@ function sys_get_temp_dir() {
706 742
707 743 //redirect to the login page
708 744 $msg = "</strong><br />\n";
709   - $msg .= "Congratulations, the installation has been completed. <br />";
  745 + $msg .= "Installation is complete. <br />";
710 746 $msg .= "<br /> ";
711 747 $msg .= "<strong>Getting Started:</strong><br /> ";
712 748 $msg .= "<ul><li>There are two levels of admins 1. superadmin 2. admin.<br />";
@@ -728,20 +764,12 @@ function sys_get_temp_dir() {
728 764
729 765
730 766 //temp sqlite db
731   - $dbfilepath = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH;
732   - //if (file_exists($dbfilepath.'/'.$dbfilename)) {
733   - // unlink($dbfilepath.'/'.$dbfilename);
734   - //}
735 767 //--- begin: create the sqlite db file -----------------------------------------
736 768 $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/sqlite.sql';
737 769 $file_contents = file_get_contents($filename);
738 770 unset($filename);
739   - //echo "<pre>\n";
740   - //echo $file_contents;
741   - //echo "</pre>\n";
742   - //exit;
743 771 try {
744   - //$db_temp = new PDO('sqlite:'.$dbfilepath.'/'.$dbfilename); //sqlite 3
  772 + //$db_temp = new PDO('sqlite:'.$db_filepath.'/'.$db_filename); //sqlite 3
745 773 $db_temp = new PDO('sqlite::memory:'); //sqlite 3
746 774 $db_temp->beginTransaction();
747 775 }
@@ -757,19 +785,13 @@ function sys_get_temp_dir() {
757 785 $stringarray = explode("\n", $file_contents);
758 786 $x = 0;
759 787 foreach($stringarray as $sql) {
760   - //create the call detail records database
761   - //if (strtolower(substr($sql, 0, 18)) == "create table v_cdr") {
762   - // //add the CDR database from lib_cdr.php
763   - //}
764   - //else { //create the tables and fill in the basic settings
765   - try {
766   - $db_temp->query($sql);
767   - }
768   - catch (PDOException $error) {
769   - echo "error: " . $error->getMessage() . " sql: $sql<br/>";
770   - //die();
771   - }
772   - //}
  788 + try {
  789 + $db_temp->query($sql);
  790 + }
  791 + catch (PDOException $error) {
  792 + echo "error: " . $error->getMessage() . " sql: $sql<br/>";
  793 + //die();
  794 + }
773 795 $x++;
774 796 }
775 797 unset ($file_contents, $sql);
@@ -847,215 +869,343 @@ function sys_get_temp_dir() {
847 869 //exit;
848 870 }
849 871
850   - echo "<form method='post' name='frm' action=''>\n";
851   - echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
852   -
853   - echo "<tr>\n";
854   - echo "<td align='left' width='30%' nowrap><b>Installation</b></td>\n";
855   - echo "<td width='70%' align='right'>&nbsp;</td>\n";
856   - //echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_dialplan_includes_edit.php?id=".$dialplan_include_id."'\" value='Back'></td>\n";
857   - echo "</tr>\n";
858   -?>
859   -<script type="text/javascript">
860   -function dbtype_onchange() {
861   - var dbtype = document.getElementById("dbtype").value;
862   -
863   - if (dbtype == "mysql") {
864   -
865   - document.getElementById("desc_dbtype").innerHTML = "If you use the root database account the database can be created automatically. However if preferred the database can be created manually with the <a href='<?php echo PROJECT_PATH; ?>/includes/install/sql/mysql.sql' target='_blank'>mysql.sql</a> script. ";
866   -
867   - document.getElementById("desc_dbfilename").innerHTML = "Not applicable"; document.frm.dbfilename.value = ''; document.frm.dbfilename.disabled = true;
868   - document.getElementById("desc_dbfilepath").innerHTML = "Choose the database where the settings will be stored. <br />Path to the secure folder that contains PHP command line scripts.";
869   - document.getElementById("desc_dbhost").innerHTML = "Recommended for MySQL."; document.frm.dbhost.disabled = false;
870   - document.getElementById("desc_dbport").innerHTML = "Optional if the database is using the default port."; document.frm.dbport.disabled = false;
871   - document.getElementById("desc_dbname").innerHTML = "Required for MySQL."; document.frm.dbname.value = 'fusionpbx'; document.frm.dbname.disabled = false;
872   - document.getElementById("desc_dbusername").innerHTML = "Required for MySQL. "; document.frm.dbusername.disabled = false;
873   - document.getElementById("desc_dbpassword").innerHTML = "Required for MySQL."; document.frm.dbpassword.disabled = false;
874   - }
875   - else if (dbtype == "pgsql") {
876   - document.getElementById("desc_dbtype").innerHTML = "Choose the database where the settings will be stored. <br /><b>Note: Before proceeding use the <a href='<?php echo PROJECT_PATH; ?>/includes/install/sql/pgsql.sql' target='_blank'>pgsql.sql</a> script to setup the database.</b>";
877   -
878   - document.getElementById("desc_dbfilename").innerHTML = "Not applicable"; document.frm.dbfilename.value = ''; document.frm.dbfilename.disabled = true;
879   - document.getElementById("desc_dbfilepath").innerHTML = "Path to the secure folder that contains PHP command line scripts.";
880   - document.getElementById("desc_dbhost").innerHTML = "Optional for PostgreSQL when the database is local."; document.frm.dbhost.disabled = false;
881   - document.getElementById("desc_dbport").innerHTML = "Optional if the database is using the default port."; document.frm.dbport.disabled = false;
882   - document.getElementById("desc_dbname").innerHTML = "Required for PostgreSQL."; document.frm.dbname.value = 'fusionpbx'; document.frm.dbname.disabled = false;
883   - document.getElementById("desc_dbusername").innerHTML = "Required for PostgreSQL."; document.frm.dbusername.disabled = false;
884   - document.getElementById("desc_dbpassword").innerHTML = "Required for PostgreSQL."; document.frm.dbpassword.disabled = false;
  872 +
  873 +/*
  874 +pgsql
  875 + document.getElementById("desc_db_type").innerHTML = "Choose the database where the settings will be stored. <br /><b>Note: Before proceeding use the <a href='<?php echo PROJECT_PATH; ?>/includes/install/sql/pgsql.sql' target='_blank'>pgsql.sql</a> script to setup the database.</b>";
  876 +
  877 + document.getElementById("desc_db_filename").innerHTML = "Not applicable"; document.frm.db_filename.value = ''; document.frm.db_filename.disabled = true;
  878 + document.getElementById("desc_install_secure_dir").innerHTML = "Path to the secure folder that contains PHP command line scripts.";
  879 + document.getElementById("desc_db_host").innerHTML = "Optional for PostgreSQL when the database is local."; document.frm.db_host.disabled = false;
  880 + document.getElementById("desc_db_port").innerHTML = "Optional if the database is using the default port."; document.frm.db_port.disabled = false;
  881 + document.getElementById("desc_db_name").innerHTML = "Required for PostgreSQL."; document.frm.db_name.value = 'fusionpbx'; document.frm.db_name.disabled = false;
  882 + document.getElementById("desc_db_username").innerHTML = "Required for PostgreSQL."; document.frm.db_username.disabled = false;
  883 + document.getElementById("desc_db_password").innerHTML = "Required for PostgreSQL."; document.frm.db_password.disabled = false;
  884 +*/
  885 +
  886 +// begin step 1 --------------------------------------
  887 + if ($_POST["install_step"] == "") {
  888 + echo "<form method='post' name='frm' action=''>\n";
  889 + echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
  890 +
  891 + echo "<tr>\n";
  892 + echo "<td align='left' width='30%' nowrap><b>Installation: Step 1</b></td>\n";
  893 + echo "<td width='70%' align='right'>&nbsp;</td>\n";
  894 + //echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_dialplan_includes_edit.php?id=".$dialplan_include_id."'\" value='Back'></td>\n";
  895 + echo "</tr>\n";
  896 +
  897 + $db_type = $_POST["db_type"];
  898 + $install_step = $_POST["install_step"];
  899 +
  900 + echo "<tr>\n";
  901 + echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  902 + echo " Database Type:\n";
  903 + echo "</td>\n";
  904 + echo "<td class='vtable' align='left'>\n";
  905 + echo " <select name='db_type' id='db_type' class='formfld' id='form_tag' onchange='db_type_onchange();'>\n";
  906 + if (extension_loaded('pdo_pgsql')) { echo " <option value='pgsql'>postgresql</option>\n"; }
  907 + if (extension_loaded('pdo_mysql')) { echo " <option value='mysql'>mysql</option>\n"; }
  908 + if (extension_loaded('pdo_sqlite')) { echo " <option value='sqlite' selected>sqlite</option>\n"; } //set sqlite as the default
  909 + echo " </select><br />\n";
  910 + echo " \n";
  911 + echo "\n";
  912 + echo "</td>\n";
  913 + echo "</tr>\n";
  914 +
  915 + echo "<tr>\n";
  916 + echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  917 + echo " Secure Directory:\n";
  918 + echo "</td>\n";
  919 + echo "<td class='vtable' align='left'>\n";
  920 + echo " <input class='formfld' type='text' name='install_secure_dir' maxlength='255' value=\"$install_secure_dir\"><br />\n";
  921 + echo " Path to the secure directory that contains PHP command line scripts.\n";
  922 + echo "\n";
  923 + echo "</td>\n";
  924 + echo "</tr>\n";
  925 +
  926 + echo "<tr>\n";
  927 + echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  928 + echo " FreeSWITCH Directory:\n";
  929 + echo "</td>\n";
  930 + echo "<td class='vtable' align='left'>\n";
  931 + echo " <input class='formfld' type='text' name='install_v_dir' maxlength='255' value=\"$install_v_dir\">\n";
  932 + echo "<br />\n";
  933 + echo "\n";
  934 + echo "</td>\n";
  935 + echo "</tr>\n";
  936 +
  937 + echo "<tr>\n";
  938 + echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  939 + echo " PHP Directory:\n";
  940 + echo "</td>\n";
  941 + echo "<td class='vtable' align='left'>\n";
  942 + echo " <input class='formfld' type='text' name='install_php_dir' maxlength='255' value=\"$install_php_dir\"><br />\n";
  943 + echo "Path to PHP's bin or executable directory.<br />\n";
  944 + echo "</td>\n";
  945 + echo "</tr>\n";
  946 +
  947 + echo "<tr>\n";
  948 + echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  949 + echo " Temp Directory:\n";
  950 + echo "</td>\n";
  951 + echo "<td class='vtable' align='left'>\n";
  952 + echo " <input class='formfld' type='text' name='install_tmp_dir' maxlength='255' value=\"".realpath(sys_get_temp_dir())."\"><br />\n";
  953 + echo "Set this to the temporary directory.<br />\n";
  954 + echo "</td>\n";
  955 + echo "</tr>\n";
  956 +
  957 + echo "<tr>\n";
  958 + echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  959 + echo " Backup Directory:\n";
  960 + echo "</td>\n";
  961 + echo "<td class='vtable' align='left'>\n";
  962 + echo " <input class='formfld' type='text' name='install_v_backup_dir' maxlength='255' value=\"".realpath(sys_get_temp_dir())."\"><br />\n";
  963 + echo "Set a backup directory.<br />\n";
  964 + echo "</td>\n";
  965 + echo "</tr>\n";
  966 +
  967 + echo " <tr>\n";
  968 + echo " <td colspan='2' align='right'>\n";
  969 + echo " <input type='hidden' name='install_step' value='2'>\n";
  970 + echo " <input type='submit' name='submit' class='btn' value='Next'>\n";
  971 + echo " </td>\n";
  972 + echo " </tr>";
  973 +
  974 + echo "</table>";
  975 + echo "</form>";
  976 + echo "</div>";
885 977 }
886   - else if (dbtype == "sqlite") {
887   - document.getElementById("desc_dbtype").innerHTML = "Choose the database where the settings will be stored. <br />The sqlite database will be created automatically.";
888   - document.frm.dbfilename.value = 'fusionpbx.db';
889   - document.getElementById("desc_dbfilename").innerHTML = "Default: fusiopbx.db. If the field is left empty then the file name is determined by the host or IP address."; document.frm.dbfilename.disabled = false;
890   - document.getElementById("desc_dbfilepath").innerHTML = "Path to the secure folder that contains PHP command line scripts and the SQLite database.";
891   - document.getElementById("desc_dbhost").innerHTML = "Not applicable"; document.frm.dbhost.value = ''; document.frm.dbhost.disabled = true;
892   - document.getElementById("desc_dbport").innerHTML = "Not applicable"; document.frm.dbport.value = ''; document.frm.dbport.disabled = true;
893   - document.getElementById("desc_dbname").innerHTML = "Not applicable"; document.frm.dbname.value = ''; document.frm.dbname.disabled = true;
894   - document.getElementById("desc_dbusername").innerHTML = "Not applicable"; document.frm.dbusername.value = ''; document.frm.dbusername.disabled = true;
895   - document.getElementById("desc_dbpassword").innerHTML = "Not applicable"; document.frm.dbpassword.value = ''; document.frm.dbpassword.disabled = true;
  978 +// end step 1 --------------------------------------
  979 +
  980 +
  981 +// begin step 2, sqlite --------------------------------------
  982 + if ($_POST["install_step"] == "2" && $_POST["db_type"] == "sqlite") {
  983 +
  984 + echo "<form method='post' name='frm' action=''>\n";
  985 + echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
  986 +
  987 + echo "<tr>\n";
  988 + echo "<td align='left' width='30%' nowrap><b>Installation: Step 2 - SQLite</b></td>\n";
  989 + echo "<td width='70%' align='right'>&nbsp;</td>\n";
  990 + //echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_dialplan_includes_edit.php?id=".$dialplan_include_id."'\" value='Back'></td>\n";
  991 + echo "</tr>\n";
  992 +
  993 + echo "<tr>\n";
  994 + echo "<td class='vncell' 'valign='top' align='left' nowrap>\n";
  995 + echo " Database Filename:\n";
  996 + echo "</td>\n";
  997 + echo "<td class='vtable' align='left'>\n";
  998 + echo " <input class='formfld' type='text' name='db_filename' maxlength='255' value=\"$db_filename\"><br />\n";
  999 + echo " Default: fusiopbx.db. If the field is left empty then the file name is determined by the host or IP address.\n";
  1000 + echo "\n";
  1001 + echo "</td>\n";
  1002 + echo "</tr>\n";
  1003 +
  1004 + echo "<tr>\n";
  1005 + echo "<td class='vncell' 'valign='top' align='left' nowrap>\n";
  1006 + echo " Database Directory:\n";
  1007 + echo "</td>\n";
  1008 + echo "<td class='vtable' align='left'>\n";
  1009 + echo " <input class='formfld' type='text' name='db_filepath' maxlength='255' value=\"$db_filepath\"><br />\n";
  1010 + echo " Path to the secure folder that contains PHP command line scripts and the SQLite database.\n";
  1011 + echo "</td>\n";
  1012 + echo "</tr>\n";
  1013 +
  1014 + echo " <tr>\n";
  1015 + echo " <td colspan='2' align='right'>\n";
  1016 + echo " <input type='hidden' name='db_type' value='$db_type'>\n";
  1017 + echo " <input type='hidden' name='install_secure_dir' value='$install_secure_dir'>\n";
  1018 + echo " <input type='hidden' name='install_v_dir' value='$install_v_dir'>\n";
  1019 + echo " <input type='hidden' name='install_php_dir' value='$install_php_dir'>\n";
  1020 + echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
  1021 + echo " <input type='hidden' name='install_v_backup_dir' value='$install_v_backup_dir'>\n";
  1022 + echo " <input type='hidden' name='install_step' value='3'>\n";
  1023 + echo " <input type='submit' name='submit' class='btn' value='Next'>\n";
  1024 + echo " </td>\n";
  1025 + echo " </tr>";
  1026 +
  1027 + echo "</table>";
  1028 + echo "</form>";
  1029 + echo "</div>";
896 1030 }
897   - if (dbtype == "") {
898   - document.getElementById("desc_dbfilename").innerHTML = "";
899   - document.getElementById("desc_dbfilepath").innerHTML = "";
900   - document.getElementById("desc_dbhost").innerHTML = "";
901   - document.getElementById("desc_dbport").innerHTML = "";
902   - document.getElementById("desc_dbname").innerHTML = "";
903   - document.getElementById("desc_dbusername").innerHTML = "";
904   - document.getElementById("desc_dbpassword").innerHTML = "";
  1031 +
  1032 +
  1033 +// begin step 2, mysql --------------------------------------
  1034 + if ($_POST["install_step"] == "2" && $_POST["db_type"] == "mysql") {
  1035 +
  1036 + echo "If you use the root database account the database can be created automatically. However if preferred the database can be created manually with the <a href='<?php echo PROJECT_PATH; ?>/includes/install/sql/mysql.sql' target='_blank'>mysql.sql</a> script. ";
  1037 +
  1038 + echo "<form method='post' name='frm' action=''>\n";
  1039 + echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
  1040 +
  1041 + echo "<tr>\n";
  1042 + echo "<td align='left' width='30%' nowrap><b>Installation: Step 2 - MySQL</b></td>\n";
  1043 + echo "<td width='70%' align='right'>&nbsp;</td>\n";
  1044 + //echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_dialplan_includes_edit.php?id=".$dialplan_include_id."'\" value='Back'></td>\n";
  1045 + echo "</tr>\n";
  1046 +
  1047 + echo "<tr>\n";
  1048 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1049 + echo " Database Host:\n";
  1050 + echo "</td>\n";
  1051 + echo "<td class='vtable' align='left'>\n";
  1052 + echo " <input class='formfld' type='text' name='db_host' maxlength='255' value=\"$db_host\"><br />\n";
  1053 + echo " Recommended for MySQL.\n";
  1054 + echo "\n";
  1055 + echo "</td>\n";
  1056 + echo "</tr>\n";
  1057 +
  1058 + echo "<tr>\n";
  1059 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1060 + echo " Database Port:\n";
  1061 + echo "</td>\n";
  1062 + echo "<td class='vtable' align='left'>\n";
  1063 + echo " <input class='formfld' type='text' name='db_port' maxlength='255' value=\"$db_port\"><br />\n";
  1064 + echo " Optional if the database is using the default port.\n";
  1065 + echo "\n";
  1066 + echo "</td>\n";
  1067 + echo "</tr>\n";
  1068 +
  1069 + echo "<tr>\n";
  1070 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1071 + echo " Database Name:\n";
  1072 + echo "</td>\n";
  1073 + echo "<td class='vtable' align='left'>\n";
  1074 + echo " <input class='formfld' type='text' name='db_name' maxlength='255' value=\"$db_name\"><br />\n";
  1075 + echo " Required for MySQL\n";
  1076 + echo "\n";
  1077 + echo "</td>\n";
  1078 + echo "</tr>\n";
  1079 +
  1080 + echo "<tr>\n";
  1081 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1082 + echo " Database Username:\n";
  1083 + echo "</td>\n";
  1084 + echo "<td class='vtable' align='left'>\n";
  1085 + echo " <input class='formfld' type='text' name='db_username' maxlength='255' value=\"$db_username\"><br />\n";
  1086 + echo " Required for MySQL\n";
  1087 + echo "\n";
  1088 + echo "</td>\n";
  1089 + echo "</tr>\n";
  1090 +
  1091 + echo "<tr>\n";
  1092 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1093 + echo " Database Password:\n";
  1094 + echo "</td>\n";
  1095 + echo "<td class='vtable' align='left'>\n";
  1096 + echo " <input class='formfld' type='text' name='db_password' maxlength='255' value=\"$db_password\"><br />\n";
  1097 + echo " Required for MySQL\n";
  1098 + echo "\n";
  1099 + echo "</td>\n";
  1100 + echo "</tr>\n";
  1101 +
  1102 + echo " <tr>\n";
  1103 + echo " <td colspan='2' align='right'>\n";
  1104 + echo " <input type='hidden' name='db_type' value='$db_type'>\n";
  1105 + echo " <input type='hidden' name='install_secure_dir' value='$install_secure_dir'>\n";
  1106 + echo " <input type='hidden' name='install_v_dir' value='$install_v_dir'>\n";
  1107 + echo " <input type='hidden' name='install_php_dir' value='$install_php_dir'>\n";
  1108 + echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
  1109 + echo " <input type='hidden' name='install_v_backup_dir' value='$install_v_backup_dir'>\n";
  1110 + echo " <input type='submit' name='submit' class='btn' value='Next'>\n";
  1111 + echo " </td>\n";
  1112 + echo " </tr>";
  1113 +
  1114 + echo "</table>";
  1115 + echo "</form>";
  1116 + echo "</div>";
905 1117 }
906   -}
907   -</script>
908   -<?php
909 1118
910   - echo "<tr>\n";
911   - echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
912   - echo " Database Type:\n";
913   - echo "</td>\n";
914   - echo "<td class='vtable' align='left'>\n";
915   - echo " <select name='dbtype' id='dbtype' class='formfld' id='form_tag' onchange='dbtype_onchange();'>\n";
916   - if (extension_loaded('pdo_pgsql')) { echo " <option value='pgsql'>postgresql</option>\n"; }
917   - if (extension_loaded('pdo_mysql')) { echo " <option value='mysql'>mysql</option>\n"; }
918   - if (extension_loaded('pdo_sqlite')) { echo " <option value='sqlite' selected>sqlite</option>\n"; } //set sqlite as the default
919   - echo " </select><br />\n";
920   - echo " <span id='desc_dbtype'></span><br />\n";
921   - echo "\n";
922   - echo "</td>\n";
923   - echo "</tr>\n";
924   -
925   - echo "<tr>\n";
926   - echo "<td class='vncell' 'valign='top' align='left' nowrap>\n";
927   - echo " Database Filename:\n";
928   - echo "</td>\n";
929   - echo "<td class='vtable' align='left'>\n";
930   - echo " <input class='formfld' type='text' name='dbfilename' maxlength='255' value=\"$dbfilename\"><br />\n";
931   - echo " <span id='desc_dbfilename'></span><br />\n";
932   - echo "\n";
933   - echo "</td>\n";
934   - echo "</tr>\n";
935   -
936   - echo "<tr>\n";
937   - echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
938   - echo " Secure Directory:\n";
939   - echo "</td>\n";
940   - echo "<td class='vtable' align='left'>\n";
941   - echo " <input class='formfld' type='text' name='dbfilepath' maxlength='255' value=\"$dbfilepath\"><br />\n";
942   - echo " <span id='desc_dbfilepath'></span><br />\n";
943   - echo "\n";
944   - echo "</td>\n";
945   - echo "</tr>\n";
946   -
947   - echo "<tr>\n";
948   - echo "<td class='vncell' valign='top' align='left' nowrap>\n";
949   - echo " Database Host:\n";
950   - echo "</td>\n";
951   - echo "<td class='vtable' align='left'>\n";
952   - echo " <input class='formfld' type='text' name='dbhost' maxlength='255' value=\"$dbhost\"><br />\n";
953   - echo " <span id='desc_dbhost'></span><br />\n";
954   - echo "\n";
955   - echo "</td>\n";
956   - echo "</tr>\n";
957   -
958   - echo "<tr>\n";
959   - echo "<td class='vncell' valign='top' align='left' nowrap>\n";
960   - echo " Database Port:\n";
961   - echo "</td>\n";
962   - echo "<td class='vtable' align='left'>\n";
963   - echo " <input class='formfld' type='text' name='dbport' maxlength='255' value=\"$dbport\"><br />\n";
964   - echo " <span id='desc_dbport'></span><br />\n";
965   - echo "\n";
966   - echo "</td>\n";
967   - echo "</tr>\n";
968   -
969   - echo "<tr>\n";
970   - echo "<td class='vncell' valign='top' align='left' nowrap>\n";
971   - echo " Database Name:\n";
972   - echo "</td>\n";
973   - echo "<td class='vtable' align='left'>\n";
974   - echo " <input class='formfld' type='text' name='dbname' maxlength='255' value=\"$dbname\"><br />\n";
975   - echo " <span id='desc_dbname'></span><br />\n";
976   - echo "\n";
977   - echo "</td>\n";
978   - echo "</tr>\n";
979   -
980   - echo "<tr>\n";
981   - echo "<td class='vncell' valign='top' align='left' nowrap>\n";
982   - echo " Database Username:\n";
983   - echo "</td>\n";
984   - echo "<td class='vtable' align='left'>\n";
985   - echo " <input class='formfld' type='text' name='dbusername' maxlength='255' value=\"$dbusername\"><br />\n";
986   - echo " <span id='desc_dbusername'></span><br />\n";
987   - echo "\n";
988   - echo "</td>\n";
989   - echo "</tr>\n";
990   -
991   - echo "<tr>\n";
992   - echo "<td class='vncell' valign='top' align='left' nowrap>\n";
993   - echo " Database Password:\n";
994   - echo "</td>\n";
995   - echo "<td class='vtable' align='left'>\n";
996   - echo " <input class='formfld' type='text' name='dbpassword' maxlength='255' value=\"$dbpassword\"></span><br />\n";
997   - echo " <span id='desc_dbpassword'></span><br />\n";
998   - echo "\n";
999   - echo "</td>\n";
1000   - echo "</tr>\n";
1001   -
1002   - echo "<tr>\n";
1003   - echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
1004   - echo " FreeSWITCH Directory:\n";
1005   - echo "</td>\n";
1006   - echo "<td class='vtable' align='left'>\n";
1007   - echo " <input class='formfld' type='text' name='install_v_dir' maxlength='255' value=\"$install_v_dir\">\n";
1008   - echo "<br />\n";
1009   - echo "\n";
1010   - echo "</td>\n";
1011   - echo "</tr>\n";
1012   -
1013   - echo "<tr>\n";
1014   - echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
1015   - echo " PHP Directory:\n";
1016   - echo "</td>\n";
1017   - echo "<td class='vtable' align='left'>\n";
1018   - echo " <input class='formfld' type='text' name='install_php_dir' maxlength='255' value=\"$install_php_dir\"><br />\n";
1019   - echo "Path to PHP's bin or executable directory.<br />\n";
1020   - echo "</td>\n";
1021   - echo "</tr>\n";
1022   -
1023   - echo "<tr>\n";
1024   - echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
1025   - echo " Temp Directory:\n";
1026   - echo "</td>\n";
1027   - echo "<td class='vtable' align='left'>\n";
1028   - echo " <input class='formfld' type='text' name='install_tmp_dir' maxlength='255' value=\"".realpath(sys_get_temp_dir())."\"><br />\n";
1029   - echo "Set this to the temporary directory.<br />\n";
1030   - echo "</td>\n";
1031   - echo "</tr>\n";
1032   -
1033   - echo "<tr>\n";
1034   - echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
1035   - echo " Backup Directory:\n";
1036   - echo "</td>\n";
1037   - echo "<td class='vtable' align='left'>\n";
1038   - echo " <input class='formfld' type='text' name='install_v_backup_dir' maxlength='255' value=\"".realpath(sys_get_temp_dir())."\"><br />\n";
1039   - echo "Set a backup directory.<br />\n";
1040   - echo "</td>\n";
1041   - echo "</tr>\n";
1042   -
1043   - echo " <tr>\n";
1044   - echo " <td colspan='2' align='right'>\n";
1045   - echo " <input type='submit' name='submit' class='btn' value='Install'>\n";
1046   - echo " </td>\n";
1047   - echo " </tr>";
1048   - echo "</table>";
1049   - echo "</form>";
1050   - echo "</div>";
1051   - echo "<script type=\"text/javascript\">dbtype_onchange();</script>\n";
  1119 + // begin step 2, pgsql --------------------------------------
  1120 + if ($_POST["install_step"] == "2" && $_POST["db_type"] == "pgsql") {
  1121 +
  1122 + echo "<form method='post' name='frm' action=''>\n";
  1123 + echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
  1124 +
  1125 + echo "<tr>\n";
  1126 + echo "<td align='left' width='30%' nowrap><b>Installation: Step 2 - Postgres</b></td>\n";
  1127 + echo "<td width='70%' align='right'>&nbsp;</td>\n";
  1128 + //echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_dialplan_includes_edit.php?id=".$dialplan_include_id."'\" value='Back'></td>\n";
  1129 + echo "</tr>\n";
  1130 +
  1131 + echo "<tr>\n";
  1132 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1133 + echo " Database Host:\n";
  1134 + echo "</td>\n";
  1135 + echo "<td class='vtable' align='left'>\n";
  1136 + echo " <input class='formfld' type='text' name='db_host' maxlength='255' value=\"$db_host\"><br />\n";
  1137 + echo " \n";
  1138 + echo "\n";
  1139 + echo "</td>\n";
  1140 + echo "</tr>\n";
  1141 +
  1142 + echo "<tr>\n";
  1143 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1144 + echo " Database Port:\n";
  1145 + echo "</td>\n";
  1146 + echo "<td class='vtable' align='left'>\n";
  1147 + echo " <input class='formfld' type='text' name='db_port' maxlength='255' value=\"$db_port\"><br />\n";
  1148 + echo " \n";
  1149 + echo "\n";
  1150 + echo "</td>\n";
  1151 + echo "</tr>\n";
  1152 +
  1153 + echo "<tr>\n";
  1154 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1155 + echo " Database Name:\n";
  1156 + echo "</td>\n";
  1157 + echo "<td class='vtable' align='left'>\n";
  1158 + echo " <input class='formfld' type='text' name='db_name' maxlength='255' value=\"$db_name\"><br />\n";
  1159 + echo " \n";
  1160 + echo "\n";
  1161 + echo "</td>\n";
  1162 + echo "</tr>\n";
  1163 +
  1164 + echo "<tr>\n";
  1165 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1166 + echo " Database Username:\n";
  1167 + echo "</td>\n";
  1168 + echo "<td class='vtable' align='left'>\n";
  1169 + echo " <input class='formfld' type='text' name='db_username' maxlength='255' value=\"$db_username\"><br />\n";
  1170 + echo " \n";
  1171 + echo "\n";
  1172 + echo "</td>\n";
  1173 + echo "</tr>\n";
  1174 +
  1175 + echo "<tr>\n";
  1176 + echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  1177 + echo " Database Password:\n";
  1178 + echo "</td>\n";
  1179 + echo "<td class='vtable' align='left'>\n";
  1180 + echo " <input class='formfld' type='text' name='db_password' maxlength='255' value=\"$db_password\"><br />\n";
  1181 + echo " \n";
  1182 + echo "\n";
  1183 + echo "</td>\n";
  1184 + echo "</tr>\n";
  1185 +
  1186 + echo " <tr>\n";
  1187 + echo " <td colspan='2' align='right'>\n";
  1188 + echo " <input type='hidden' name='db_type' value='$db_type'>\n";
  1189 + echo " <input type='hidden' name='install_secure_dir' value='$install_secure_dir'>\n";
  1190 + echo " <input type='hidden' name='install_v_dir' value='$install_v_dir'>\n";
  1191 + echo " <input type='hidden' name='install_php_dir' value='$install_php_dir'>\n";
  1192 + echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
  1193 + echo " <input type='hidden' name='install_v_backup_dir' value='$install_v_backup_dir'>\n";
  1194 + echo " <input type='submit' name='submit' class='btn' value='Install'>\n";
  1195 + echo " </td>\n";
  1196 + echo " </tr>";
  1197 +
  1198 + echo "</table>";
  1199 + echo "</form>";
  1200 + echo "</div>";
  1201 + }
1052 1202
1053 1203
1054 1204 // add the content to the template and then send output -----------------------
1055 1205 $body = $content_from_db.ob_get_contents(); //get the output from the buffer
1056 1206 ob_end_clean(); //clean the buffer
1057   -
1058 1207 ob_start();
  1208 +
1059 1209 $template = $strheadertop.$template;
1060 1210 eval('?>' . $template . '<?php ');
1061 1211 $template = ob_get_contents(); //get the output from the buffer
8 fusionpbx/mod/dialplan/v_dialplan_includes_add.php
@@ -526,8 +526,8 @@ function type_onchange(field_type) {
526 526 echo "</td>\n";
527 527 echo "<td class='vtable' align='left'>\n";
528 528
529   -//switch_select_destination(select_type, select_name, select_value, select_style);
530   -switch_select_destination("dialplan", "action_1", $action_1, "width: 60%;");
  529 +//switch_select_destination(select_type, select_label, select_name, select_value, select_style, action);
  530 +switch_select_destination("dialplan", "",