コード例 #1
0
 function __construct($global_settings)
 {
     if (is_null($global_settings)) {
         require_once "resources/classes/global_settings.php";
         $global_settings = new global_settings();
     } elseif (!is_a($global_settings, 'global_settings')) {
         throw new Exception('The parameter $global_settings must be a global_settings object (or a subclass of)');
     }
     $this->global_settings = $global_settings;
     if (is_dir("/etc/fusionpbx")) {
         $this->config_php = "/etc/fusionpbx/config.php";
     } elseif (is_dir("/usr/local/etc/fusionpbx")) {
         $this->config_php = "/usr/local/etc/fusionpbx/config.php";
     } elseif (is_dir($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/resources")) {
         $this->config_php = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/config.php";
     } else {
         $this->config_php = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/config.php";
     }
     $this->config_php = normalize_path_to_os($this->config_php);
 }
コード例 #2
0
ファイル: functions.php プロジェクト: rdissauer/fusionpbx
 function recursive_delete($dir)
 {
     $dst = normalize_path_to_os($dst);
     //$this->write_debug("del /S /F /Q \"$dir\"");
     exec("del /S /F /Q \"{$dir}\"");
     clearstatcache();
 }
コード例 #3
0
ファイル: install_switch.php プロジェクト: shadowym/fusionpbx
 public function create_config_lua()
 {
     //define the database connection as global
     global $db;
     //send progress
     $this->write_progress("\tCreating " . $this->config_lua);
     //set the directories
     $path = dirname($this->config_lua);
     $parent_dir = basename($path);
     if ($parent_dir == 'resources' and !file_exists($path)) {
         $this->write_progress("\t... creating missing '{$path}'");
         if (!mkdir($path, 0755, true)) {
             throw new Exception("Failed to create the missing resources directory '{$path}'");
         }
     }
     //get the odbc information
     $sql = "select count(*) as num_rows from v_databases ";
     $sql .= "where database_driver = 'odbc' ";
     if (strlen($order_by) > 0) {
         $sql .= "order by {$order_by} {$order} ";
     }
     $prep_statement = $db->prepare($sql);
     if ($prep_statement) {
         $prep_statement->execute();
         $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
         unset($prep_statement);
         if ($row['num_rows'] > 0) {
             $odbc_num_rows = $row['num_rows'];
             $sql = "select * from v_databases ";
             $sql .= "where database_driver = 'odbc' ";
             $prep_statement = $db->prepare(check_sql($sql));
             $prep_statement->execute();
             $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
             foreach ($result as &$row) {
                 $dsn_name = $row["database_name"];
                 $dsn_username = $row["database_username"];
                 $dsn_password = $row["database_password"];
                 break;
                 //limit to 1 row
             }
             unset($prep_statement);
         } else {
             $odbc_num_rows = '0';
         }
     }
     //config.lua
     $fout = fopen($this->config_lua, "w");
     if (!$fout) {
         throw new Exception("Failed to open '" . $this->config_lua . "' for writing");
     }
     $tmp = "\n";
     $tmp .= "--set the variables\n";
     if (strlen($this->global_settings->switch_sounds_dir()) > 0) {
         $tmp .= normalize_path_to_os("\tsounds_dir = [[" . $this->global_settings->switch_sounds_dir() . "]];\n");
     }
     if (strlen($this->global_settings->switch_phrases_vdir()) > 0) {
         $tmp .= normalize_path_to_os("\tphrases_dir = [[" . $this->global_settings->switch_phrases_vdir() . "]];\n");
     }
     if (strlen($this->global_settings->switch_db_dir()) > 0) {
         $tmp .= normalize_path_to_os("\tdatabase_dir = [[" . $this->global_settings->switch_db_dir() . "]];\n");
     }
     if (strlen($this->global_settings->switch_recordings_dir()) > 0) {
         $tmp .= normalize_path_to_os("\trecordings_dir = [[" . $this->global_settings->switch_recordings_dir() . "]];\n");
     }
     if (strlen($this->global_settings->switch_storage_dir()) > 0) {
         $tmp .= normalize_path_to_os("\tstorage_dir = [[" . $this->global_settings->switch_storage_dir() . "]];\n");
     }
     if (strlen($this->global_settings->switch_voicemail_vdir()) > 0) {
         $tmp .= normalize_path_to_os("\tvoicemail_dir = [[" . $this->global_settings->switch_voicemail_vdir() . "]];\n");
     }
     if (strlen($this->global_settings->switch_script_dir()) > 0) {
         $tmp .= normalize_path_to_os("\tscripts_dir = [[" . $this->global_settings->switch_script_dir() . "]];\n");
     }
     $tmp .= normalize_path_to_os("\tphp_dir = [[" . PHP_BINDIR . "]];\n");
     if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
         $tmp .= "\tphp_bin = \"php.exe\";\n";
     } else {
         $tmp .= "\tphp_bin = \"php\";\n";
     }
     $tmp .= normalize_path_to_os("\tdocument_root = [[" . $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "]];\n");
     $tmp .= "\n";
     if (strlen($this->global_settings->db_type()) > 0 || strlen($dsn_name) > 0) {
         $tmp .= "--database information\n";
         $tmp .= "\tdatabase = {}\n";
         $tmp .= "\tdatabase[\"type\"] = \"" . $this->global_settings->db_type() . "\";\n";
         $tmp .= "\tdatabase[\"name\"] = \"" . $this->global_settings->db_name() . "\";\n";
         $tmp .= normalize_path_to_os("\tdatabase[\"path\"] = [[" . $this->global_settings->db_path() . "]];\n");
         if (strlen($dsn_name) > 0) {
             $tmp .= "\tdatabase[\"system\"] = \"odbc://" . $dsn_name . ":" . $dsn_username . ":" . $dsn_password . "\";\n";
             $tmp .= "\tdatabase[\"switch\"] = \"odbc://freeswitch:" . $dsn_username . ":" . $dsn_password . "\";\n";
         } elseif ($this->global_settings->db_type() == "pgsql") {
             $db_host = $this->global_settings->db_host();
             if ($db_host == 'localhost') {
                 $db_host = '127.0.0.1';
             }
             // lua cannot resolve localhost
             if (filter_var($db_host, FILTER_VALIDATE_IP)) {
                 $host_type = "hostaddr";
             } else {
                 $host_type = "host";
             }
             $tmp .= "\tdatabase[\"system\"] = \"pgsql://" . $host_type . "=" . $db_host . " port=" . $this->global_settings->db_port() . " dbname=" . $this->global_settings->db_name() . " user="******" password="******" options='' application_name='" . $this->global_settings->db_name() . "'\";\n";
             $tmp .= "\tdatabase[\"switch\"] = \"pgsql://" . $host_type . "=" . $db_host . " port=" . $this->global_settings->db_port() . " dbname=freeswitch user="******" password="******" options='' application_name='freeswitch'\";\n";
         } elseif ($this->global_settings->db_type() == "sqlite") {
             $tmp .= "\tdatabase[\"system\"] = \"sqlite://" . $this->global_settings->db_path() . "/" . $this->global_settings->db_name() . "\";\n";
             $tmp .= "\tdatabase[\"switch\"] = \"sqlite://" . $_SESSION['switch']['db']['dir'] . "\";\n";
         } elseif ($this->global_settings->db_type() == "mysql") {
             $tmp .= "\tdatabase[\"system\"] = \"\";\n";
             $tmp .= "\tdatabase[\"switch\"] = \"\";\n";
         }
         $tmp .= "\n";
     }
     $tmp .= "--set defaults\n";
     $tmp .= "\texpire = {}\n";
     $tmp .= "\texpire[\"directory\"] = \"3600\";\n";
     $tmp .= "\texpire[\"dialplan\"] = \"3600\";\n";
     $tmp .= "\texpire[\"languages\"] = \"3600\";\n";
     $tmp .= "\texpire[\"sofia.conf\"] = \"3600\";\n";
     $tmp .= "\texpire[\"acl.conf\"] = \"3600\";\n";
     $tmp .= "\n";
     $tmp .= "--set xml_handler\n";
     $tmp .= "\txml_handler = {}\n";
     $tmp .= "\txml_handler[\"fs_path\"] = false;\n";
     $tmp .= "\n";
     $tmp .= "--set the debug options\n";
     $tmp .= "\tdebug[\"params\"] = false;\n";
     $tmp .= "\tdebug[\"sql\"] = false;\n";
     $tmp .= "\tdebug[\"xml_request\"] = false;\n";
     $tmp .= "\tdebug[\"xml_string\"] = false;\n";
     $tmp .= "\tdebug[\"cache\"] = false;\n";
     $tmp .= "\n";
     $tmp .= "--additional info\n";
     $tmp .= "\tdomain_count = " . $this->global_settings->domain_count() . ";\n";
     $tmp .= normalize_path_to_os("\ttemp_dir = [[" . $this->global_settings->switch_temp_dir() . "]];\n");
     if (isset($_SESSION['domain']['dial_string']['text'])) {
         $tmp .= "\tdial_string = \"" . $_SESSION['domain']['dial_string']['text'] . "\";\n";
     }
     $tmp .= "\n";
     $tmp .= "--include local.lua\n";
     $tmp .= "\trequire(\"resources.functions.file_exists\");\n";
     $tmp .= "\tif (file_exists(\"/etc/fusionpbx/local.lua\")) then\n";
     $tmp .= "\t\tdofile(\"/etc/fusionpbx/local.lua\");\n";
     $tmp .= "\telseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n";
     $tmp .= "\t\tdofile(\"/usr/local/etc/fusionpbx/local.lua\");\n";
     $tmp .= "\telseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n";
     $tmp .= "\t\trequire(\"resources.local\");\n";
     $tmp .= "\tend\n";
     fwrite($fout, $tmp);
     unset($tmp);
     fclose($fout);
 }
コード例 #4
0
ファイル: system.php プロジェクト: kpabijanskas/fusionpbx
echo "<b>" . $text['header-sys-status'] . "</b>";
echo "<br><br>";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "\t<th class='th' colspan='2' align='left'>" . $text['title-sys-info'] . "</th>\n";
echo "</tr>\n";
if (permission_exists('system_view_info')) {
    echo "<tr>\n";
    echo "\t<td width='20%' class=\"vncell\" style='text-align: left;'>\n";
    echo "\t\t" . $text['label-version'] . "\n";
    echo "\t</td>\n";
    echo "\t<td class=\"row_style1\">\n";
    echo "\t\t" . software_version() . "\n";
    echo "\t</td>\n";
    echo "</tr>\n";
    $git_path = normalize_path_to_os($_SERVER['PROJECT_ROOT'] . "/.git");
    if (file_exists($git_path)) {
        $git_exe = 'git';
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'SUN') {
            $git_exe = shell_exec('which git');
        }
        $git_branch = shell_exec($git_exe . ' --git-dir=' . $git_path . ' name-rev --name-only HEAD');
        rtrim($git_branch);
        $git_commit = shell_exec($git_exe . ' --git-dir=' . $git_path . ' rev-parse HEAD');
        rtrim($git_commit);
        $git_origin = shell_exec($git_exe . ' --git-dir=' . $git_path . ' config --get remote.origin.url');
        rtrim($git_commit);
        echo "<tr>\n";
        echo "\t<td width='20%' class=\"vncell\" style='text-align: left;'>\n";
        echo "\t\t" . $text['label-git_info'] . "\n";
        echo "\t</td>\n";
コード例 #5
0
ファイル: system.php プロジェクト: stefanomarty/fusionpbx
echo "<b>" . $text['header-sys-status'] . "</b>";
echo "<br><br>";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "\t<th class='th' colspan='2' align='left'>" . $text['title-sys-info'] . "</th>\n";
echo "</tr>\n";
if (permission_exists('system_view_info')) {
    echo "<tr>\n";
    echo "\t<td width='20%' class=\"vncell\" style='text-align: left;'>\n";
    echo "\t\t" . $text['label-version'] . "\n";
    echo "\t</td>\n";
    echo "\t<td class=\"row_style1\">\n";
    echo "\t\t" . software_version() . "\n";
    echo "\t</td>\n";
    echo "</tr>\n";
    $git_path = normalize_path_to_os($_SERVER["DOCUMENT_ROOT"] . "/.git");
    if (file_exists($git_path)) {
        $git_branch = shell_exec('git --git-dir=' . $git_path . ' name-rev --name-only HEAD');
        rtrim($git_branch);
        $git_commit = shell_exec('git --git-dir=' . $git_path . ' rev-parse HEAD');
        rtrim($git_commit);
        $git_origin = shell_exec('git --git-dir=' . $git_path . ' config --get remote.origin.url');
        rtrim($git_commit);
        echo "<tr>\n";
        echo "\t<td width='20%' class=\"vncell\" style='text-align: left;'>\n";
        echo "\t\t" . $text['label-git_info'] . "\n";
        echo "\t</td>\n";
        echo "\t<td class=\"row_style1\">\n";
        echo "\t\t" . $text['label-git_branch'] . " " . $git_branch . "<br>\n";
        echo "\t\t" . $text['label-git_commit'] . " " . $git_commit . "<br>\n";
        echo "\t\t" . $text['label-git_origin'] . " " . $git_origin . "<br>\n";