当前位置: 首页>>代码示例>>PHP>>正文


PHP mysql::PRIVILEGES方法代码示例

本文整理汇总了PHP中mysql::PRIVILEGES方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::PRIVILEGES方法的具体用法?PHP mysql::PRIVILEGES怎么用?PHP mysql::PRIVILEGES使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysql的用法示例。


在下文中一共展示了mysql::PRIVILEGES方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SAVE_FREEWEB_MYSQL

function SAVE_FREEWEB_MYSQL()
{
    $servername = trim(strtolower($_POST["servername"]));
    if (substr($servername, 0, 1) == '.') {
        echo $servername . " FAILED\n";
        return;
    }
    $users = new usersMenus();
    $sock = new sockets();
    $FreewebsStorageDirectory = $sock->GET_INFO("FreewebsStorageDirectory");
    if (!$users->AsWebMaster) {
        return "FALSE";
    }
    $uid = $_POST["uid"];
    $mysql_database = format_mysql_table($_POST["mysql_database"]);
    $mysql_password = $_POST["mysql_password"];
    $mysql_username = $_POST["mysql_username"];
    $lvm_vg = $_POST["lvm_vg"];
    $vg_size = $_POST["vg_size"];
    $ServerIP = $_POST["ServerIP"];
    $ServerPort = 0;
    if (preg_match("#(.+?):([0-9]+)#", $ServerIP, $re)) {
        $ServerIP = $re[1];
        $ServerPort = $re[2];
    }
    if (!is_numeric($vg_size)) {
        $vg_size = 5000;
    }
    $ftpuser = $_POST["ftpuser"];
    $ftppassword = $_POST["ftppassword"];
    $useSSL = $_POST["useSSL"];
    if (!$users->PUREFTP_INSTALLED) {
        $_POST["useFTP"] = 0;
        $ftpuser = null;
        $ftppassword = null;
    }
    if ($_POST["useFTP"] == 1) {
        if ($ftpuser == null) {
            $_POST["useFTP"] = 0;
            $ftpuser = null;
            $ftppassword = null;
        }
    }
    $sql = "SELECT servername FROM freeweb WHERE servername='{$_POST["servername"]}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if ($ligne["servername"] != null) {
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if (!$users->AsSystemAdministrator) {
            $ou = $_SESSION["ou"];
        }
        $sql = "UPDATE freeweb SET \n\t\t\tmysql_password='{$mysql_password}',\n\t\t\tmysql_username='{$mysql_username}',\n\t\t\tmysql_database='{$mysql_database}',\n\t\t\tmysql_instance_id='{$_POST["mysql_instance_id"]}',\n\t\t\tftpuser='{$ftpuser}',\n\t\t\tftppassword='{$ftppassword}',\n\t\t\tuseMysql='{$_POST["useMysql"]}',\n\t\t\tuseFTP='{$_POST["useFTP"]}'\n\t\t\tWHERE servername='{$servername}'\n\t\t";
    }
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $q->BuildTables();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        if (preg_match("#Unknown column#i", $q->mysql_error)) {
            $q->BuildTables();
            $q->QUERY_SQL($sql, "artica_backup");
        }
    }
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    if ($_POST["useFTP"] == 1) {
        if ($users->PUREFTP_INSTALLED) {
            if (trim($ftpuser) != null) {
                if (trim($ftppassword) != null) {
                    $pure = new pureftpd_user();
                    if (!$pure->CreateUser($ftpuser, $ftppassword, $servername)) {
                        echo "FTP: Failed\n";
                        return;
                    }
                    $sock->getFrameWork("services.php?reload-pure-ftpd=yes");
                }
            }
        }
    }
    if ($_POST["useMysql"] == 1) {
        if (!$q->DATABASE_EXISTS($mysql_database)) {
            $q->CREATE_DATABASE("{$mysql_database}");
        }
        if (!$q->PRIVILEGES($mysql_username, $mysql_password, $mysql_database)) {
            echo "GRANT {$mysql_database} FAILED FOR {$mysql_username}\n{$q->mysql_error}";
        }
    }
    if (isset($_POST["ADD_DNS_ENTRY"])) {
        $dnsDOM = explode(".", $_POST["servername"]);
        $netbiosname = $dnsDOM[0];
        unset($dnsDOM[0]);
        $domainname = implode(".", $dnsDOM);
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns($domainname);
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:freeweb.edit.main.php

示例2: config


//.........这里部分代码省略.........
            if (preg_match("#define\\(#", $ligne)) {
                $ASASLT = true;
                break;
            }
        }
        if (!$ASASLT) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Unable to download salts !!\n";
            }
            build_progress("{$servername}: Acquiring Salts {failed}...", 110);
            return;
        }
        @file_put_contents("{$WORKING_DIRECTORY}/salts.php", @implode("\n", $fa));
    }
    build_progress("{$servername}: checking...", 48);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL host...........: \"{$DB_HOST}\"\n";
    }
    if (!$q->DATABASE_EXISTS($wordpressDB)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Create MySQL database: \"{$wordpressDB}\"\n";
        }
        $q->CREATE_DATABASE($wordpressDB);
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL database.......: \"{$wordpressDB}\"\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL user...........: \"{$DB_USER}\"\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL Password.......: \"{$DB_PASSWORD}\"\n";
    }
    $q->PRIVILEGES($DB_USER, $WordPressDBPass, $wordpressDB);
    $f[] = "<?php";
    $f[] = $Salts;
    $f[] = "/**";
    $f[] = " * The base configurations of the WordPress.";
    $f[] = " *";
    $f[] = " * This file has the following configurations: MySQL settings, Table Prefix,";
    $f[] = " * Secret Keys, WordPress Language, and ABSPATH. You can find more information";
    $f[] = " * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing";
    $f[] = " * wp-config.php} Codex page. You can get the MySQL settings from your web host.";
    $f[] = " *";
    $f[] = " * This file is used by the wp-config.php creation script during the";
    $f[] = " * installation. You don't have to use the web site, you can just copy this file";
    $f[] = " * to \"wp-config.php\" and fill in the values.";
    $f[] = " *";
    $f[] = " * @package WordPress";
    $f[] = " */";
    $f[] = "";
    $f[] = "// ** MySQL settings - You can get this info from your web host ** //";
    $f[] = "/** The name of the database for WordPress */";
    $f[] = "define('DB_NAME', '{$wordpressDB}');";
    $f[] = "";
    $f[] = "/** MySQL database username */";
    $f[] = "define('DB_USER', '{$DB_USER}');";
    $f[] = "";
    $f[] = "/** MySQL database password */";
    $f[] = "define('DB_PASSWORD', '{$DB_PASSWORD}');";
    $f[] = "";
    $f[] = "/** MySQL hostname */";
    $f[] = "define('DB_HOST', '{$DB_HOST}');";
    $f[] = "";
    $f[] = "/** Database Charset to use in creating database tables. */";
    $f[] = "define('DB_CHARSET', 'utf8');";
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:67,代码来源:exec.wordpress.php

示例3: OBM2_INSTALL

function OBM2_INSTALL($servername, $root, $hash = array())
{
    $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
    if ($root == null) {
        events("Starting install OBM2 Unable to stat root dir");
        return false;
    }
    if (!is_dir("/opt/artica/install/sources/obm")) {
        events("Starting install OBM2 Unable to stat /opt/artica/install/sources/obm");
        return false;
    }
    $sqlfiles = array("create_obmdb_2.3.mysql.sql", "obmdb_prefs_values_2.3.sql", "obmdb_default_values_2.3.sql", "obmdb_test_values_2.3.sql", "data-fr/obmdb_nafcode_2.3.sql", "data-fr/obmdb_ref_2.3.sql", "data-en/obmdb_nafcode_2.3.sql", "data-en/obmdb_ref_2.3.sql");
    $user = $hash["wwwmysqluser"][0];
    $mysql_password = $hash[strtolower("WWWMysqlPassword")][0];
    $appli_user = $hash["wwwappliuser"];
    $appli_password = $hash["wwwapplipassword"];
    if ($user == null) {
        events("Starting install OBM2 Unable to stat Mysql username");
        return false;
    }
    if ($mysql_password == null) {
        events("Starting install OBM2 Unable to stat Mysql password");
        return false;
    }
    @mkdir($root, 0755, true);
    $server_database = str_replace(".", "_", $servername);
    $server_database = str_replace("-", "_", $server_database);
    $q = new mysql();
    if (!$q->DATABASE_EXISTS($server_database)) {
        events("Starting install OBM2 sub-system mysql database {$server_database}...");
        $q->CREATE_DATABASE($server_database);
        if (!$q->DATABASE_EXISTS($server_database)) {
            events("Starting install OBM2 unable to create MYSQL Database");
            return false;
        }
    }
    events("Starting install OBM2 installing source code in {$root}");
    shell_exec("/bin/cp -rf /opt/artica/install/sources/obm/* {$root}/");
    if ($q->mysql_password != null) {
        $password = " --password={$q->mysql_password} ";
    } else {
        events("Starting install OBM2 installing tables datas with null password");
    }
    $unix = new unix();
    //<$sql_file
    $cmd = $unix->find_program("mysql") . " --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml ";
    $cmd = $cmd . " --user={$q->mysql_admin}{$password}";
    if (!OBM2_CheckObmTables($server_database)) {
        while (list($num, $filesql) = each($sqlfiles)) {
            if (is_file("/opt/artica/install/sources/obm/scripts/2.3/{$filesql}")) {
                events("installing {$filesql} SQL commands");
                shell_exec($cmd . " </opt/artica/install/sources/obm/scripts/2.3/{$filesql}");
            }
        }
    }
    $version = OBM2_VERSION($root);
    if ($version == null) {
        events("Starting install unable to stat version");
        return false;
    }
    events("Starting install OBM2 version {$version}");
    if (is_file("{$root}/scripts/2.3/updates/update-2.3.1-{$version}.mysql.sql")) {
        events("Starting updating OBM2 version 2.3.1-{$version}");
        shell_exec($cmd . " <{$root}/scripts/2.3/updates/update-2.3.1-{$version}.mysql.sql");
    } else {
        events("Starting updating unable to stat {$root}/scripts/2.3/updates/update-2.3.1-{$version}.mysql.sql");
    }
    //scripts/2.3/updates/update-2.3.1-2.3.2.mysql.sql
    $q->PRIVILEGES($user, $mysql_password, $server_database);
    OBM2_INSTALL_SCRIPTS($root, $servername, $server_database, $user, $mysql_password);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:71,代码来源:exec.www.install.php

示例4: Save


//.........这里部分代码省略.........
            $ou = $_SESSION["ou"];
        }
        $sql = "UPDATE freeweb SET \n\t\t\tmysql_password='{$mysql_password}',\n\t\t\tmysql_username='{$mysql_username}',\n\t\t\tmysql_database='{$mysql_database}',\n\t\t\tmysql_instance_id='{$_GET["mysql_instance_id"]}',\n\t\t\tftpuser='{$ftpuser}',\n\t\t\tftppassword='{$ftppassword}',\n\t\t\tuid='{$uid}',\n\t\t\tgpid='{$_GET["gpid"]}',\n\t\t\tuseMysql='{$_GET["useMysql"]}',\n\t\t\tuseFTP='{$_GET["useFTP"]}',\n\t\t\tlvm_vg='{$_GET["lvm_vg"]}',\n\t\t\tlvm_size='{$_GET["vg_size"]}',\n\t\t\tUseLoopDisk='{$_GET["UseLoopDisk"]}',\n\t\t\tLoopMounts='{$_GET["LoopMounts"]}',\n\t\t\twww_dir='{$_GET["www_dir"]}',\n\t\t\tUseReverseProxy='{$_GET["UseReverseProxy"]}',\n\t\t\tProxyPass='{$_GET["ProxyPass"]}',\n\t\t\tuseSSL='{$useSSL}',\n\t\t\tServerPort='{$ServerPort}',\n\t\t\tou='{$ou}',\n\t\t\tForwarder='{$_GET["Forwarder"]}',\n\t\t\tForwardTo='{$_GET["ForwardTo"]}',\n\t\t\tServerIP='{$ServerIP}'\n\t\t\tWHERE servername='{$servername}'\n\t\t";
    } else {
        $ApacheServerName = $sock->GET_INFO("ApacheServerName");
        if ($ApacheServerName == null) {
            $ApacheServerName = $users->fqdn;
        }
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if ($ou != null) {
            if ($FreewebsStorageDirectory != null) {
                $www_dir = "{$FreewebsStorageDirectory}/{$servername}";
            }
        }
        $sock = new sockets();
        $servername = str_replace('..', '.', $servername);
        $servername = str_replace('/', '.', $servername);
        $servername = str_replace('\\', '.', $servername);
        $servername = str_replace(' ', '.', $servername);
        $servername = str_replace('$', '.', $servername);
        $servername = str_replace('#', '.', $servername);
        $servername = str_replace('%', '.', $servername);
        $servername = str_replace('*', '.', $servername);
        if (substr($servername, strlen($servername) - 1, 1) == '.') {
            $servername = substr($servername, 0, strlen($servername) - 1);
        }
        if (substr($servername, 0, 1) == '.') {
            $servername = substr($servername, 1, strlen($servername));
        }
        if ($servername == $ApacheServerName) {
            echo $tpl->javascript_parse_text("{virtual_hostname_cannot_same_main_hostname}", 1);
            return;
        }
        if ($_GET["force-groupware"] != null) {
            $groupware_field = ",groupware";
            $groupware_value = ",'{$_GET["force-groupware"]}'";
        }
        if ($_GET["www_dir"] != null) {
            $www_dir_field = ",www_dir";
            $www_dir_value = ",'{$_GET["www_dir"]}'";
        }
        $sock->getFrameWork("freeweb.php?force-resolv=yes");
        $sql = "INSERT INTO freeweb (mysql_password,mysql_username,ftpuser,ftppassword,useSSL,servername,mysql_database,\n\t\tuid,gpid,useMysql,useFTP,lvm_vg,lvm_size,UseLoopDisk,LoopMounts,ou,domainname,www_dir,ServerPort,UseReverseProxy,\n\t\tProxyPass,Forwarder,ForwardTo,ForceInstanceZarafaID,mysql_instance_id,ServerIP{$groupware_field}{$www_dir_field})\n\t\tVALUES('{$mysql_password}','{$mysql_username}','{$ftpuser}','{$ftppassword}','{$useSSL}','{$servername}','{$mysql_database}',\n\t\t'{$uid}','{$_GET["gpid"]}','{$_GET["useMysql"]}',\n\t\t'{$_GET["useFTP"]}','{$_GET["lvm_vg"]}','{$_GET["vg_size"]}','{$_GET["UseLoopDisk"]}','{$_GET["LoopMounts"]}','{$ou}',\n\t\t'{$_GET["domainname"]}','{$FreewebsStorageDirectory}','{$ServerPort}','{$_GET["UseReverseProxy"]}','{$_GET["ProxyPass"]}',\n\t\t'{$_GET["Forwarder"]}','{$_GET["ForwardTo"]}','{$_GET["ForceInstanceZarafaID"]}','{$_GET["mysql_instance_id"]}','{$ServerIP}'{$groupware_value}{$www_dir_value}\n\t\t)";
    }
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $q->BuildTables();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("system.php?dns-linker=yes");
    if ($_GET["useFTP"] == 1) {
        if ($users->PUREFTP_INSTALLED) {
            if (trim($ftpuser) != null) {
                if (trim($ftppassword) != null) {
                    $pure = new pureftpd_user();
                    if (!$pure->CreateUser($ftpuser, $ftppassword, $servername)) {
                        echo "FTP: Failed\n";
                        return;
                    }
                    $sock->getFrameWork("services.php?reload-pure-ftpd=yes");
                }
            }
        }
    }
    if ($_GET["useMysql"] == 1) {
        if (!$q->DATABASE_EXISTS($mysql_database)) {
            $q->CREATE_DATABASE("{$mysql_database}");
        }
        if (!$q->PRIVILEGES($mysql_username, $mysql_password, $mysql_database)) {
            echo "GRANT {$mysql_database} FAILED FOR {$mysql_username}\n{$q->mysql_error}";
        }
    }
    if (isset($_GET["ADD_DNS_ENTRY"])) {
        $dnsDOM = explode(".", $_GET["servername"]);
        $netbiosname = $dnsDOM[0];
        unset($dnsDOM[0]);
        $domainname = implode(".", $dnsDOM);
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns($domainname);
        $pdns->EditIPName($netbiosname, $_GET["ADD_DNS_ENTRY"], "A");
    }
    if ($ligne["servername"] == null) {
        if ($_GET["force-groupware"] != null) {
            $sql = "INSERT INTO drupal_queue_orders(`ORDER`,`servername`) VALUES('INSTALL_GROUPWARE','{$servername}')";
            $q = new mysql();
            $q->QUERY_SQL($sql, "artica_backup");
            $sock->getFrameWork("freeweb.php?rebuild-vhost=yes&servername={$servername}");
        }
    }
    $sock->getFrameWork("services.php?freeweb-start=yes");
    sleep(2);
    $sock->getFrameWork("cmd.php?freeweb-restart=yes");
}
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:freeweb.edit.php

示例5: poweradmin

function poweradmin()
{
    if (!is_file("/usr/share/poweradmin/index.php")) {
        echo "Starting......: " . date("H:i:s") . " PowerAdmin is not installed\n";
        return;
    }
    $sock = new sockets();
    $PowerAdminUser = $sock->GET_INFO("PowerAdminUser");
    $PowerAdminPassword = $sock->GET_INFO("PowerAdminPassword");
    if ($PowerAdminUser == null) {
        $PowerAdminUser = time();
        $sock->SET_INFO("PowerAdminUser", $PowerAdminUser);
    }
    if ($PowerAdminPassword == null) {
        $PowerAdminPassword = microtime(false);
        $sock->SET_INFO("PowerAdminPassword", $PowerAdminPassword);
    }
    $q = new mysql();
    $q->PRIVILEGES($PowerAdminUser, $PowerAdminPassword, "powerdns");
    $unix = new unix();
    $f[] = "<?php";
    $f[] = "\$db_host\t\t= '{$q->mysql_server}';";
    $f[] = "\$db_user\t\t= '{$PowerAdminUser}';";
    $f[] = "\$db_pass\t\t= '{$PowerAdminPassword}';";
    $f[] = "\$db_name\t\t= 'powerdns';";
    $f[] = "\$db_port\t\t= '{$q->mysql_port}';";
    $f[] = "\$db_type\t\t= 'mysql';";
    $f[] = "\$iface_lang\t\t= 'en_EN';";
    $f[] = "\$cryptokey\t\t= '" . $unix->hostname_g() . "';";
    $f[] = "\$session_key\t\t= '" . $unix->hostname_g() . "';";
    $f[] = "\$password_encryption\t= 'md5';\t// or md5salt";
    $f[] = "\$iface_style\t\t= 'example';";
    $f[] = "\$iface_rowamount\t= 50;";
    $f[] = "\$iface_expire\t= 1800;";
    $f[] = "\$iface_zonelist_serial\t= false;";
    $f[] = "\$iface_title = 'PowerAdmin DNS WebConsole';";
    $f[] = "\$password_encryption='md5';";
    $f[] = "\$dns_ttl\t\t= 86400;";
    $f[] = "\$dns_fancy\t= false;";
    $f[] = "\$dns_strict_tld_check\t= true;";
    $f[] = "\$dns_hostmaster\t\t= 'hostmaster.example.net';";
    $f[] = "\$dns_ns1\t\t= 'ns1.example.net';";
    $f[] = "\$dns_ns2\t\t= 'ns2.example.net';";
    $f[] = "\$syslog_use  = True;";
    $f[] = "\$syslog_ident = 'poweradmin';";
    $f[] = "\$syslog_facility = LOG_USER;";
    $f[] = "?>";
    $sql = "DELETE FROM users WHERE id=1";
    $q->QUERY_SQL($sql, "powerdns");
    $ldap = new clladp();
    $pass = md5($ldap->ldap_password);
    $sql = "SELECT password,fullname,email FROM `users` WHERE id=1";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "powerdns"));
    if ($ligne["password"] != null) {
        $sql = "UPDATE `users` SET `username`= '{$ldap->ldap_admin}',`password`='{$pass}' ,`perm_templ`=1,`active`=1 WHERE id=1";
    } else {
        $sql = "INSERT INTO `users` (`id`, `username`, `password`, `fullname`, `email`, `description`, `perm_templ`, `active`) VALUES\n\t(1, '{$ldap->ldap_admin}', '{$pass}', 'Administrator', 'admin@example.net', 'Administrator with full rights.', 1, 1);";
    }
    $q->QUERY_SQL($sql, "powerdns");
    if (!$q->ok) {
        echo "Starting......: " . date("H:i:s") . " PowerAdmin {$ldap->ldap_admin} failed {$q->mysql_error}\n";
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerAdmin {$ldap->ldap_admin} ok\n";
    }
    @file_put_contents("/usr/share/poweradmin/inc/config.inc.php", @implode("\n", $f));
    echo "Starting......: " . date("H:i:s") . " PowerAdmin config.inc.php done\n";
    if (is_dir("/usr/share/poweradmin/install")) {
        shell_exec("/bin/rm -rf /usr/share/poweradmin/install >/dev/null 2>&1");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:70,代码来源:exec.pdns.php

示例6: Save


//.........这里部分代码省略.........
    $ServerPort = $_GET["ServerPort"];
    if (!is_numeric($ServerPort)) {
        $ServerPort = 0;
    }
    if ($_GET["UseDefaultPort"] == 1) {
        $ServerPort = 0;
    }
    if (!is_numeric($vg_size)) {
        $vg_size = 5000;
    }
    $ftpuser = $_GET["ftpuser"];
    $ftppassword = $_GET["ftppassword"];
    $useSSL = $_GET["useSSL"];
    if (!$users->PUREFTP_INSTALLED) {
        $_GET["useFTP"] = 0;
        $ftpuser = null;
        $ftppassword = null;
    }
    $sql = "SELECT servername FROM freeweb WHERE servername='{$_GET["servername"]}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if ($ligne["servername"] != null) {
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if (!$users->AsSystemAdministrator) {
            $ou = $_SESSION["ou"];
        }
        $sql = "UPDATE freeweb SET \n\t\t\tmysql_password='{$mysql_password}',\n\t\t\tmysql_username='{$mysql_username}',\n\t\t\tmysql_database='{$mysql_database}',\n\t\t\tftpuser='{$ftpuser}',\n\t\t\tftppassword='{$ftppassword}',\n\t\t\tuid='{$uid}',\n\t\t\tuseMysql='{$_GET["useMysql"]}',\n\t\t\tuseFTP='{$_GET["useFTP"]}',\n\t\t\tlvm_vg='{$_GET["lvm_vg"]}',\n\t\t\tlvm_size='{$_GET["vg_size"]}',\n\t\t\tUseLoopDisk='{$_GET["UseLoopDisk"]}',\n\t\t\tLoopMounts='{$_GET["LoopMounts"]}',\n\t\t\tUseReverseProxy='{$_GET["UseReverseProxy"]}',\n\t\t\tProxyPass='{$_GET["ProxyPass"]}',\n\t\t\tuseSSL='{$useSSL}',\n\t\t\tServerPort='{$ServerPort}',\n\t\t\tou='{$ou}',\n\t\t\tForwarder='{$_GET["Forwarder"]}',\n\t\t\tForwardTo='{$_GET["ForwardTo"]}'\n\t\t\t\n\t\t\tWHERE servername='{$servername}'\n\t\t";
    } else {
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if ($ou != null) {
            if ($FreewebsStorageDirectory != null) {
                $www_dir = "{$FreewebsStorageDirectory}/{$servername}";
            }
        }
        $sock = new sockets();
        $servername = str_replace('..', '.', $servername);
        $servername = str_replace('/', '.', $servername);
        $servername = str_replace('\\', '.', $servername);
        $servername = str_replace(' ', '.', $servername);
        $servername = str_replace('$', '.', $servername);
        $servername = str_replace('#', '.', $servername);
        $servername = str_replace('%', '.', $servername);
        $servername = str_replace('*', '.', $servername);
        if (substr($servername, strlen($servername) - 1, 1) == '.') {
            $servername = substr($servername, 0, strlen($servername) - 1);
        }
        if (substr($servername, 0, 1) == '.') {
            $servername = substr($servername, 1, strlen($servername));
        }
        $sock->getFrameWork("freeweb.php?force-resolv=yes");
        $sql = "INSERT INTO freeweb (mysql_password,mysql_username,ftpuser,ftppassword,useSSL,servername,mysql_database,\n\t\tuid,useMysql,useFTP,lvm_vg,lvm_size,UseLoopDisk,LoopMounts,ou,domainname,www_dir,ServerPort,UseReverseProxy,ProxyPass,Forwarder,ForwardTo)\n\t\tVALUES('{$mysql_password}','{$mysql_username}','{$ftpuser}','{$ftppassword}','{$useSSL}','{$servername}','{$mysql_database}',\n\t\t'{$uid}','{$_GET["useMysql"]}',\n\t\t'{$_GET["useFTP"]}','{$_GET["lvm_vg"]}','{$_GET["vg_size"]}','{$_GET["UseLoopDisk"]}','{$_GET["LoopMounts"]}','{$ou}',\n\t\t'{$_GET["domainname"]}','{$FreewebsStorageDirectory}','{$ServerPort}','{$_GET["UseReverseProxy"]}','{$_GET["ProxyPass"]}',\n\t\t'{$_GET["Forwarder"]}','{$_GET["ForwardTo"]}'\n\t\t)";
    }
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $q->BuildTables();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    if ($_GET["useFTP"] == 1) {
        if ($users->PUREFTP_INSTALLED) {
            if (trim($ftpuser) != null) {
                if (trim($ftppassword) != null) {
                    $pure = new pureftpd_user();
                    if (!$pure->CreateUser($ftpuser, $ftppassword, $servername)) {
                        echo "FTP: Failed\n";
                        return;
                    }
                    $sock->getFrameWork("services.php?reload-pure-ftpd=yes");
                }
            }
        }
    }
    if ($_GET["useMysql"] == 1) {
        if (!$q->DATABASE_EXISTS($mysql_database)) {
            $q->CREATE_DATABASE("{$mysql_database}");
        }
        if (!$q->PRIVILEGES($mysql_username, $mysql_password, $mysql_database)) {
            echo "GRANT {$mysql_database} FAILED FOR {$mysql_username}\n{$q->mysql_error}";
        }
    }
    if (isset($_GET["ADD_DNS_ENTRY"])) {
        $dnsDOM = explode(".", $_GET["servername"]);
        $netbiosname = $dnsDOM[0];
        unset($dnsDOM[0]);
        $domainname = implode(".", $dnsDOM);
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns($domainname);
        $pdns->EditIPName($netbiosname, $_GET["ADD_DNS_ENTRY"], "A");
    }
    $sock->getFrameWork("cmd.php?freeweb-restart=yes");
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例7: Save

function Save(){
	
	$servername=trim(strtolower($_GET["servername"]));
	if(substr($servername, 0,1)=='.'){echo $servername. " FAILED\n";return;}
	$users=new usersMenus();
	$sock=new sockets();
	$FreewebsStorageDirectory=$sock->GET_INFO("FreewebsStorageDirectory");
	
	if(!$users->AsWebMaster){return "FALSE";}
	$uid=$_GET["uid"];
	$mysql_database=format_mysql_table($_GET["mysql_database"]);
	$mysql_password=$_GET["mysql_password"];
	$mysql_username=$_GET["mysql_username"];
	$lvm_vg=$_GET["lvm_vg"];
	$vg_size=$_GET["vg_size"];
	$ServerPort=$_GET["ServerPort"];
	if(!is_numeric($ServerPort)){$ServerPort=0;}
	if($_GET["UseDefaultPort"]==1){$ServerPort=0;}

	if(!is_numeric($vg_size)){$vg_size=5000;}
	$ftpuser=$_GET["ftpuser"];
	$ftppassword=$_GET["ftppassword"];
	$useSSL=$_GET["useSSL"];
	
	if(!$users->PUREFTP_INSTALLED){
		$_GET["useFTP"]=0;
		$ftpuser=null;
		$ftppassword=null;
	}	
	
	
	
	$sql="SELECT servername FROM freeweb WHERE servername='{$_GET["servername"]}'";
	$q=new mysql();

	$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));	
	if($ligne["servername"]<>null){
		if($uid<>null){$u=new user($uid);$ou=$u->ou;}
		if(!$users->AsSystemAdministrator){$ou=$_SESSION["ou"];}
		
		$sql="UPDATE freeweb SET 
			mysql_password='$mysql_password',
			mysql_username='$mysql_username',
			ftpuser='$ftpuser',
			ftppassword='$ftppassword',
			uid='$uid',
			useMysql='{$_GET["useMysql"]}',
			useFTP='{$_GET["useFTP"]}',
			lvm_vg='{$_GET["lvm_vg"]}',
			lvm_size='{$_GET["vg_size"]}',
			UseLoopDisk='{$_GET["UseLoopDisk"]}',
			LoopMounts='{$_GET["LoopMounts"]}',
			UseReverseProxy='{$_GET["UseReverseProxy"]}',
			ProxyPass='{$_GET["ProxyPass"]}',
			useSSL='$useSSL',
			ServerPort='$ServerPort',
			ou='$ou',
			Forwarder='{$_GET["Forwarder"]}',
			ForwardTo='{$_GET["ForwardTo"]}'
			
			WHERE servername='$servername'
		";
	}else{
		if($uid<>null){$u=new user($uid);$ou=$u->ou;}
		if($ou<>null){if($FreewebsStorageDirectory<>null){$www_dir="$FreewebsStorageDirectory/$servername";}}
		$sock=new sockets();
		$sock->getFrameWork("freeweb.php?force-resolv=yes");
		$sql="INSERT INTO freeweb (mysql_password,mysql_username,ftpuser,ftppassword,useSSL,servername,mysql_database,
		uid,useMysql,useFTP,lvm_vg,lvm_size,UseLoopDisk,LoopMounts,ou,domainname,www_dir,ServerPort,UseReverseProxy,ProxyPass,Forwarder,ForwardTo)
		VALUES('$mysql_password','$mysql_username','$ftpuser','$ftppassword','$useSSL','$servername','$mysql_database',
		'$uid','{$_GET["useMysql"]}',
		'{$_GET["useFTP"]}','{$_GET["lvm_vg"]}','{$_GET["vg_size"]}','{$_GET["UseLoopDisk"]}','{$_GET["LoopMounts"]}','$ou',
		'{$_GET["domainname"]}','$FreewebsStorageDirectory','$ServerPort','{$_GET["UseReverseProxy"]}','{$_GET["ProxyPass"]}',
		'{$_GET["Forwarder"]}','{$_GET["ForwardTo"]}'
		)";
	}
	$q=new mysql();
	$q->BuildTables();
	$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){echo $q->mysql_error;return;}
	$sock=new sockets();
	
	if($_GET["useFTP"]==1){
		if($users->PUREFTP_INSTALLED){
			$pure=new pureftpd_user();
			if(!$pure->CreateUser($ftpuser,$ftppassword,$servername)){
				echo "FTP: Failed\n";
				return;
			}
		}
	}
	
	if($_GET["useMysql"]==1){
		if(!$q->DATABASE_EXISTS($mysql_database)){$q->CREATE_DATABASE("$mysql_database");}
		if(!$q->PRIVILEGES($mysql_username,$mysql_password,$mysql_database)){
			echo "GRANT $mysql_database FAILED FOR $mysql_username\n$q->mysql_error";
		}
	}
	

//.........这里部分代码省略.........
开发者ID:rsd,项目名称:artica-1.5,代码行数:101,代码来源:freeweb.edit.php


注:本文中的mysql::PRIVILEGES方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。