コード例 #1
0
function handle_delete()
{
    global $def_coy, $db_connections, $comp_subdirs, $path_to_root;
    $id = (int) $_GET['id'];
    // First make sure all company directories from the one under removal are writable.
    // Without this after operation we end up with changed per-company owners!
    for ($i = $id; $i < count($db_connections); $i++) {
        $comp_path = company_path($i);
        if (!is_dir($comp_path) || !is_writable($comp_path)) {
            display_error(_('Broken company subdirectories system. You have to remove this company manually.'));
            return;
        }
    }
    // make sure config file is writable
    if (!is_writeable($path_to_root . "/config_db.php")) {
        display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
        return;
    }
    // rename directory to temporary name to ensure all
    // other subdirectories will have right owners even after
    // unsuccessfull removal.
    $cdir = company_path($id);
    $tmpname = company_path('/old_' . $id);
    if (!@rename($cdir, $tmpname)) {
        display_error(_('Cannot rename subdirectory to temporary name.'));
        return;
    }
    // 'shift' company directories names
    for ($i = $id + 1; $i < count($db_connections); $i++) {
        if (!rename(company_path($i), company_path($i - 1))) {
            display_error(_("Cannot rename company subdirectory"));
            return;
        }
    }
    $err = remove_connection($id);
    if ($err == 0) {
        display_error(_("Error removing Database: ") . $dbase . _(", please remove it manually"));
    }
    if ($def_coy == $id) {
        $def_coy = 0;
    }
    $error = write_config_db();
    if ($error == -1) {
        display_error(_("Cannot open the configuration file - ") . $path_to_root . "/config_db.php");
    } else {
        if ($error == -2) {
            display_error(_("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php");
        } else {
            if ($error == -3) {
                display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
            }
        }
    }
    if ($error != 0) {
        @rename($tmpname, $cdir);
        return;
    }
    // finally remove renamed company directory
    @flush_dir($tmpname, true);
    if (!@rmdir($tmpname)) {
        display_error(_("Cannot remove temporary renamed company data directory ") . $tmpname);
        return;
    }
    display_notification(_("Selected company has been deleted"));
}
コード例 #2
0
ファイル: index.php プロジェクト: knjy24/FrontAccounting
function do_install()
{
    global $path_to_root, $db_connections, $def_coy, $installed_extensions, $tb_pref_counter, $dflt_lang, $installed_languages;
    $coa = $_SESSION['inst_set']['coa'];
    if (install_connect_db() && db_import($path_to_root . '/sql/' . $coa, $_SESSION['inst_set'])) {
        $con = $_SESSION['inst_set'];
        $table_prefix = $con['tbpref'];
        $def_coy = 0;
        $tb_pref_counter = 0;
        $db_connections = array(0 => array('name' => $con['name'], 'host' => $con['host'], 'dbuser' => $con['dbuser'], 'dbpassword' => $con['dbpassword'], 'dbname' => $con['dbname'], 'tbpref' => $table_prefix));
        $_SESSION['wa_current_user']->cur_con = 0;
        update_company_prefs(array('coy_name' => $con['name']));
        $admin = get_user_by_login('admin');
        update_user_prefs($admin['id'], array('language' => $con['lang'], 'password' => md5($con['pass']), 'user_id' => $con['admin']));
        if (!copy($path_to_root . "/config.default.php", $path_to_root . "/config.php")) {
            display_error(_("Cannot save system configuration file 'config.php'."));
            return false;
        }
        $err = write_config_db($table_prefix != "");
        if ($err == -1) {
            display_error(_("Cannot open 'config_db.php' configuration file."));
            return false;
        } else {
            if ($err == -2) {
                display_error(_("Cannot write to the 'config_db.php' configuration file."));
                return false;
            } else {
                if ($err == -3) {
                    display_error(_("Configuration file 'config_db.php' is not writable. Change its permissions so it is, then re-run installation step."));
                    return false;
                }
            }
        }
        // update default language
        if (file_exists($path_to_root . "/lang/installed_languages.inc")) {
            include_once $path_to_root . "/lang/installed_languages.inc";
        }
        $dflt_lang = $_POST['lang'];
        write_lang();
        return true;
    }
    return false;
}
コード例 #3
0
ファイル: create_coy.php プロジェクト: ravenii/guardocs
function handle_delete()
{
    global $comp_path, $def_coy, $db_connections, $comp_subdirs;
    $id = $_GET['id'];
    $err = remove_connection($id);
    if ($err == 0) {
        display_error(tr("Error removing Database: ") . $dbase . tr(", please remove it manuallly"));
    }
    if ($def_coy == $id) {
        $def_coy = 0;
    }
    $error = write_config_db();
    if ($error == -1) {
        display_error(tr("Cannot open the configuration file - ") . $path_to_root . "/config_db.php");
    } else {
        if ($error == -2) {
            display_error(tr("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php");
        } else {
            if ($error == -3) {
                display_error(tr("The configuration file ") . $path_to_root . "/config_db.php" . tr(" is not writable. Change its permissions so it is, then re-run the operation."));
            }
        }
    }
    if ($error != 0) {
        return;
    }
    $cdir = $comp_path . '/' . $id;
    flush_dir($cdir);
    if (!rmdir($cdir)) {
        display_error(tr("Cannot remove company data directory ") . $cdir);
        return;
    }
    meta_forward($_SERVER['PHP_SELF']);
}
コード例 #4
0
ファイル: save.php プロジェクト: ravenii/guardocs
if ($admin_password != $admin_repassword) {
    set_error('Sorry, the two Administrator account passwords you entered do not match');
}
// End admin user details code
include_once $path_to_root . "/includes/db/connect_db.inc";
include_once $path_to_root . "/admin/db/maintenance_db.inc";
include_once $path_to_root . "/config_db.php";
$id = count($db_connections);
$db_connections[$id]['name'] = $company_name;
$db_connections[$id]['host'] = $database_host;
$db_connections[$id]['dbuser'] = $database_username;
$db_connections[$id]['dbpassword'] = $database_password;
$db_connections[$id]['dbname'] = $database_name;
$def_coy = $id;
$config_filename = $path_to_root . '/config_db.php';
$err = write_config_db();
if ($err == -1) {
    set_error("Cannot open the configuration file ({$config_filename})");
} else {
    if ($err == -2) {
        set_error("Cannot write to the configuration file ({$config_filename})");
    } else {
        if ($err == -3) {
            set_error("The configuration file {$config_filename} is not writable. Change its permissions so it is, then re-run step 4.");
        }
    }
}
// Try connecting to database
$db = mysql_connect($database_host, $database_username, $database_password);
if (!$db) {
    set_error('Database host name, username and/or password incorrect. MySQL Error:<br />' . mysql_error());
コード例 #5
0
ファイル: installNewDB.php プロジェクト: viglesiasce/tl_RC1
    $errors += 1;
    echo "<p />" . "TestLink setup couldn't install the default site into the selected database. " . "The last error to occur was <i>" . $sqlParser->sql_errors[count($sqlParser->sql_errors) - 1]["error"] . '</i> during the execution of SQL statement <span class="mono">' . strip_tags($sqlParser->sql_errors[count($sqlParser->sql_errors) - 1]["sql"]) . "</span>";
    close_html_and_exit();
} else {
    echo "<span class='ok'>OK!</span>";
}
// -----------------------------------------------------------------------------
echo "</b><br />Writing configuration file:<b> ";
$data['db_host'] = $db_server;
$data['db_login'] = $user_host[0];
$data['db_passwd'] = $tl_db_passwd;
$data['db_name'] = $db_name;
$data['db_type'] = $db_type;
$data['db_table_prefix'] = $db_table_prefix;
$cfg_file = "../config_db.inc.php";
$yy = write_config_db($cfg_file, $data);
// -----------------------------------------------------------------------------
if (strcasecmp('ko', $yy['status']) == 0) {
    echo "<span class='notok'>Failed!</span></b>";
    $errors += 1;
    echo "<p />" . "TestLink couldn't write the config file. Please copy the following into the " . '<span class="mono"> ' . $cfg_file . '</span> file:<br />' . '<textarea style="width:400px; height:160px;">' . $yy['cfg_string'] . "</textarea>";
    echo "Once that's been done, you can log into TestLink by pointing your browser at your TestLink site.";
    close_html_and_exit();
} else {
    echo "<span class='ok'>OK!</span>";
}
// 20080308 - franciscom
important_reminder();
echo '</b><p /><br><div><span class="headers">' . "{$inst_type_verbose} was successful!" . '</span><br>' . 'You can now log into the <a href="../index.php">' . 'TestLink (using login name:admin / password:admin - Please Click Me!)</a>.</div>';
$db->close();
close_html_and_exit();
コード例 #6
0
ファイル: save.php プロジェクト: xuxudodo/weberp-cvs
}
$db_connections[$id]['name'] = $company_name;
$db_connections[$id]['host'] = $database_host;
$db_connections[$id]['dbuser'] = $database_username;
$db_connections[$id]['dbpassword'] = $database_password;
$db_connections[$id]['dbname'] = $database_name;
$db_connections[$id]['tbpref'] = $table_prefix;
$db_connections[$id]['timezone'] = $timezone;
$def_coy = $id;
$config_filename = $path_to_root . '/config.php';
$change_dir = $path_to_root . '/companies/weberpdemo';
$cmp_dir = $path_to_root . '/companies/' . $database_name;
// exec('cp '.$change_dir.' '. $cmp_dir.' -rR');
dircopy($change_dir, $cmp_dir, 0);
//move($change_dir,$cmp_dir);
$err = write_config_db($table_prefix != "");
if ($err == -1) {
    set_error("Cannot open the configuration file ({$config_filename})");
} else {
    if ($err == -2) {
        set_error("Cannot write to the configuration file ({$config_filename})");
    } else {
        if ($err == -3) {
            set_error("The configuration file {$config_filename} is not writable. Change its permissions so it is, then re-run step 4.");
        }
    }
}
// Try connecting to database
$db = mysql_connect($database_host, $database_username, $database_password);
if (!$db) {
    set_error('Database host name, username and/or password incorrect. MySQL Error:<br />' . mysql_error());