Exemplo n.º 1
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/unit.php';
if (!checkMysql()) {
    return true;
}
$t = new lime_test(3);
$t->comment('Mysql Drop Command');
// Setup
createAdminUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsername, $tempAdminPassword);
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
$t->comment('MysqlDropCommand executed by admin user with password');
$cmd = new nbMysqlDropCommand();
$commandLine = sprintf('%s %s %s', $dbName, $tempAdminUsername, $tempAdminPassword);
$t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'MysqlDrop executed successfully');
//TearDown
dropDatabaseUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsername);
// Setup
createAdminUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsernameWithNoPassword);
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
$t->comment('MysqlDropCommand executed by admin user without password');
$cmd = new nbMysqlDropCommand();
$commandLine = sprintf('%s %s', $dbName, $tempAdminUsernameWithNoPassword);
$t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'MysqlDrop executed successfully');
//TearDown
dropDatabaseUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsernameWithNoPassword);
// Setup
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
$cmd = new nbMysqlDropCommand();
$parser = new nbCommandLineParser();
$parser->setDefaultConfigurationDirs(dirname(__FILE__) . '/../data/config');
Exemplo n.º 2
0
function installMain(&$s)
{
    global $lll;
    global $hostName, $dbUser, $dbUserPw, $dbName, $dbPort, $dbSocket;
    global $scriptName;
    global $cookiePath;
    global $phpVersionMin, $mySqlVersionMin;
    $s = "";
    showInstallHeader($s1);
    $s .= $s1;
    // Ezt azert kommentezem ki, mert gyakran ujrainstallalok ugy hogy elozoleg
    // john-kent be voltam jelentkezve. Ilyen esetben mindig john
    // id-jevel hozta letre eloszor az admint, majd amikor john
    // letrehozasara kerult a sor, akkor hibat adott az install mondvan,
    // hogy ilyen id-ju juzer mar letezik:
    //if (!isset($_COOKIE["globalUserId"]))
    //{
    mt_srand((double) microtime() * 1000000);
    global $randIdMax, $randIdMin;
    if (!isset($randIdMin)) {
        $randIdMin = 0;
    }
    if (!isset($randIdMax)) {
        $randIdMax = getrandmax();
    }
    $randomId = (int) mt_rand($randIdMin, $randIdMax);
    setcookie("globalUserId", $randomId, Loginlib_ExpirationDate, $cookiePath);
    $_COOKIE["globalUserId"] = $randomId;
    //}
    if (isset($_POST["edit"])) {
        $s .= showEditForm(TRUE);
        return;
    }
    //if( isset($_POST["submit"]) &&
    //    $_POST["submit"]==$lll["install"] )
    //{
    //check file creation
    $ret = checkFileCreate();
    if ($ret == ok) {
        iPrint($lll["create_file_ok"], "ok", $sp);
        $s .= $sp;
        $createconf = TRUE;
    } else {
        if (!isset($_POST["confirm"])) {
            iPrint($lll["create_file_nok_ext"], "warn", $sp);
        } else {
            iPrint($lll["create_file_nok"], "warn", $sp);
        }
        $s .= $sp;
        $createconf = FALSE;
    }
    //check mysql connection
    $db->hostName = $hostName;
    $db->user = $dbUser;
    $db->password = $dbUserPw;
    $db->port = $dbPort;
    $db->socket = $dbSocket;
    $connectRet = checkMysql($db, $s1);
    $s .= $s1;
    if ($connectRet == ok) {
        iPrint($lll["mysql_found"], "ok", $sp);
        $s .= $sp;
        $connectok = TRUE;
        $pwok = TRUE;
    } elseif ($connectRet == mysql_access_denied) {
        iPrint($lll["mysql_found"], "ok", $sp);
        $s .= $sp;
        if ($dbUserPw == "") {
            iPrint(sprintf($lll["need_pw"], $dbUser), "warn", $sp);
            $s .= $sp;
            $s .= showEditForm(TRUE);
            return ok;
        } else {
            iPrint(sprintf($lll["incorr_pw"], $dbUser), "warn", $sp);
            $s .= $sp;
            $s .= showEditForm(TRUE);
            return ok;
        }
    } else {
        iPrint($lll["mysql_not_found"] . " (" . mysql_error() . ")", "warn", $sp);
        $s .= $sp;
        $s .= showEditForm(TRUE);
        return ok;
    }
    if (!DbInstall::checkComponentVersions($mySqlVersion, $phpVersion)) {
        iPrint(sprintf($lll["versionTooLow"], $mySqlVersionMin, $mySqlVersion, $phpVersionMin, $phpVersion), "err", $sp);
        $s .= $sp;
        return ok;
    }
    if (!isset($_POST["confirm"])) {
        $s .= showAskConfirm();
        return ok;
    }
    if (isset($_COOKIE["globalUserId"])) {
        iPrint($lll["cookieok"], "ok", $sp);
        $s .= $sp;
    } else {
        iPrint($lll["cookienok"], "err", $sp);
        $s .= $sp;
        return;
    }
    //check if db exists
    $ret = mysql_select_db($dbName);
    if ($ret) {
        iPrint(sprintf($lll["db_installed"], $dbName), "ok", $sp);
        $s .= $sp;
    } else {
        $ret = createDb();
        if ($ret != ok) {
            $s1 = sprintf($lll["cantcreatedb"], $dbUser);
            iPrint($s1, "warn", $sp);
            $s .= $sp;
            return ok;
        } else {
            iPrint(sprintf($lll["db_created"], $dbName), "ok", $sp);
            $s .= $sp;
            //select db
            $ret = mysql_select_db($dbName);
        }
    }
    $ret = DbInstall::installCreateTables();
    if ($ret != ok) {
        iPrint($lll["inst_create_table_err"], "err", $sp);
        $s .= $sp;
        return $ret;
    } else {
        iPrint($lll["tables_installed"], "ok", $sp);
        $s .= $sp;
    }
    createFirstAdmin();
    appFillTables();
    iPrint($lll["tables_filled"], "ok", $sp);
    $s .= $sp;
    if ($createconf) {
        //config file can be generated
        $ret = writeConfigFile($s1);
        if ($ret != ok) {
            $s .= $s1;
            return;
        }
    } else {
        //config can't be created
        iPrint($lll["compare_conf"], "warn", $sp);
        $s .= $sp;
        showConfFileHtml($s1);
        $s .= $s1;
        iPrint($lll["afterwrconf"], "warn", $s1);
        $s .= $s1;
    }
    iPrint($lll["move_inst_file"], "warn", $s1);
    $s .= $s1;
    iPrint(sprintf($lll["congrat"], "Noah's Classifieds"), "hurra", $s1);
    $s .= $s1;
    iPrint($lll["inst_ch_pw"], "warn", $s1);
    $s .= $s1;
    //send him to the application:
    $s .= "<a href='{$scriptName}'>" . sprintf($lll["inst_click"], "Noah's Classifieds") . "</a>";
    return ok;
}
Exemplo n.º 3
0
function getRequirements()
{
    return $requirements = array(array(t('bugfree', 'PHP version'), version_compare(PHP_VERSION, "5.1.0", ">="), PHP_VERSION, '5.1.0+'), array(t('bugfree', 'MySQL version'), ($message = checkMysql()) !== t('bugfree', 'Not Install') && $message, $message !== t('bugfree', 'Not Install') ? mysql_get_client_info() : $message, '5.0+'), array(t('bugfree', '$_SERVER variable'), ($message = checkServerVar()) === t('bugfree', 'Supported'), $message, t('bugfree', 'Supported')), array(t('bugfree', 'Reflection extension'), ($flag = class_exists('Reflection', false)) === true, $flag ? t('bugfree', 'Supported') : t('bugfree', 'Not Install'), t('bugfree', 'Supported')), array(t('bugfree', 'PCRE extension'), ($flag = extension_loaded("pcre")) === true, $flag ? t('bugfree', 'Supported') : t('bugfree', 'Not Install'), t('bugfree', 'Supported')), array(t('bugfree', 'SPL extension'), ($flag = extension_loaded("SPL")) === true, $flag ? t('bugfree', 'Supported') : t('bugfree', 'Not Install'), t('bugfree', 'Supported')), array(t('bugfree', 'PDO extension'), ($flag = extension_loaded('pdo')) === true, $flag ? t('bugfree', 'Supported') : t('bugfree', 'Not Install'), t('bugfree', 'Supported')), array(t('bugfree', 'JSON extension'), ($flag = extension_loaded('json')) === true, $flag ? t('bugfree', 'Supported') : t('bugfree', 'Not Install'), t('bugfree', 'Supported')), array(t('bugfree', 'PDO MySQL extension'), ($flag = extension_loaded('pdo_mysql')) === true, $flag ? t('bugfree', 'Supported') : t('bugfree', 'Not Install'), t('bugfree', 'Supported')));
}
Exemplo n.º 4
0
    die("Cannot be used in web server mode\n\n");
}
include_once dirname(__FILE__) . '/ressources/class.mysql.inc';
include_once dirname(__FILE__) . '/ressources/class.ldap.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . '/framework/frame.class.inc';
if (is_array($argv)) {
    if (preg_match("#--verbose#", implode(" ", $argv))) {
        $GLOBALS["VERBOSE"] = true;
        ini_set('html_errors', 0);
        ini_set('display_errors', 1);
        ini_set('error_reporting', E_ALL);
    }
}
if ($argv[1] == "--mysql") {
    checkMysql();
    exit;
}
if ($argv[1] == "--poweradmin") {
    poweradmin();
    exit;
}
if ($argv[1] == "--dnsseck") {
    dnsseck();
    exit;
}
function poweradmin()
{
    if (!is_file("/usr/share/poweradmin/index.php")) {
        echo "Starting......: PowerAdmin is not installed\n";
        return;
Exemplo n.º 5
0
<?php
if(posix_getuid()<>0){die("Cannot be used in web server mode\n\n");}
include_once(dirname(__FILE__) . '/ressources/class.mysql.inc');
include_once(dirname(__FILE__) . '/ressources/class.ldap.inc');
include_once(dirname(__FILE__) . '/framework/class.unix.inc');
include_once(dirname(__FILE__).'/framework/frame.class.inc');
if(is_array($argv)){if(preg_match("#--verbose#",implode(" ",$argv))){$GLOBALS["VERBOSE"]=true;	ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);}}


if($argv[1]=="--mysql"){checkMysql();exit;}
if($argv[1]=="--poweradmin"){poweradmin();exit;}





function poweradmin(){
if(!is_file("/usr/share/poweradmin/index.php")){
	echo "Starting......: PowerAdmin is not installed\n";
	return;
}

$q=new mysql();

$f[]="<?php";
$f[]="\$db_host		= '$q->mysql_server';";
$f[]="\$db_user		= '******';";
$f[]="\$db_pass		= '******';";
$f[]="\$db_name		= 'powerdns';";
$f[]="\$db_port		= '$q->mysql_port';";
$f[]="\$db_type		= 'mysql';";
Exemplo n.º 6
0
function start_recursor()
{
    $sock = new sockets();
    $unix = new unix();
    $DisablePowerDnsManagement = $sock->GET_INFO("DisablePowerDnsManagement");
    $PowerDNSRecursorQuerLocalAddr = $sock->GET_INFO("PowerDNSRecursorQuerLocalAddr");
    $EnablePDNS = $sock->GET_INFO("EnablePDNS");
    if (!is_numeric($DisablePowerDnsManagement)) {
        $DisablePowerDnsManagement = 0;
    }
    $EnableChilli = 0;
    $chilli = $unix->find_program("chilli");
    if (is_file($chilli)) {
        $EnableChilli = $sock->GET_INFO("EnableChilli");
        if (!is_numeric($EnableChilli)) {
            $EnableChilli = 0;
        }
    }
    if ($EnableChilli == 1) {
        echo "Stopping......: " . date("H:i:s") . "PowerDNS Recursor HotSpot is enabled...\n";
        stop_recursor();
        return;
    }
    if ($PowerDNSRecursorQuerLocalAddr == null) {
        $net = new networking();
        $net->ifconfig("eth0");
        if ($net->tcp_addr != null) {
            if ($net->tcp_addr != "0.0.0.0") {
                $PowerDNSRecursorQuerLocalAddr = $net->tcp_addr;
            }
        }
    }
    if (!is_numeric($EnablePDNS)) {
        $EnablePDNS = 0;
    }
    $nohup = $unix->find_program("nohup");
    $recursorbin = $unix->find_program("pdns_recursor");
    if (!is_file($recursorbin)) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor Not installed, aborting task\n";
    }
    $pid = pdns_recursor_pid();
    if ($unix->process_exists($pid)) {
        $pidtime = $unix->PROCCESS_TIME_MIN($pid);
        echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor Already running PID {$pid} since {$pidtime}mn\n";
        return;
    }
    if ($DisablePowerDnsManagement == 1) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor DisablePowerDnsManagement={$DisablePowerDnsManagement}, aborting task\n";
        return;
    }
    if ($EnablePDNS == 0) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor service is disabled, aborting task\n";
        stop_recursor();
        return;
    }
    $trace = null;
    $quiet = "yes";
    $PowerDNSLogLevel = $sock->GET_INFO("PowerDNSLogLevel");
    $PowerDNSLogsQueries = $sock->GET_INFO("PowerDNSLogsQueries");
    if (!is_numeric($PowerDNSLogLevel)) {
        $PowerDNSLogLevel = 1;
    }
    $query_local_address = " --query-local-address={$PowerDNSRecursorQuerLocalAddr}";
    if ($PowerDNSLogLevel > 8) {
        $trace = ' --trace';
    }
    if ($PowerDNSLogsQueries == 1) {
        $quiet = 'no';
    }
    echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor Network card to send queries {$PowerDNSRecursorQuerLocalAddr}\n";
    echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor Log level [{$PowerDNSLogLevel}]\n";
    echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor Verify MySQL DB...\n";
    checkMysql();
    @mkdir("/var/run/pdns", 0755, true);
    $cmdline = "{$nohup} {$recursorbin} --daemon --export-etc-hosts --socket-dir=/var/run/pdns --quiet={$quiet} --config-dir=/etc/powerdns{$trace} {$query_local_address} >/dev/null 2>&1 &";
    shell_exec($cmdline);
    sleep(1);
    $pid = pdns_recursor_pid();
    if (!$unix->process_exists($pid)) {
        for ($i = 0; $i < 5; $i++) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor waiting " . ($i + 1) . "/5\n";
            $pid = pdns_recursor_pid();
            if ($unix->process_exists($pid)) {
                break;
            }
        }
    }
    $pid = pdns_recursor_pid();
    if (!$unix->process_exists($pid)) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor failed\n";
        echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor \"{$cmdline}\"\n";
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS Recursor success PID {$pid}\n";
    }
}
Exemplo n.º 7
0
		$type = $dom->getElementsByTagName('response')->item(0)->getAttribute('type');
		if ($type=='ok') {
			$step=1;
		}
	}

	if ($step==1 && isset($ini['DB']['port']) && strlen($ini['DB']['port'])>0) {
		$ini['DB']['host'] .= ':' . $ini['DB']['port'];
	}
	
	// Проверяем предустановленные параметры подключения к базе
	if ($step==1 && isset($ini['DB']['host']) && strlen($ini['DB']['host'])>0
	 && isset($ini['DB']['dbname']) && strlen($ini['DB']['dbname'])>0
	 && isset($ini['DB']['user']) && strlen($ini['DB']['user'])>0
	 && isset($ini['DB']['password']) && strlen($ini['DB']['password'])>0 ) {
		$xml = checkMysql($ini['DB']);
		$dom = new DOMDocument();
		$dom->loadXML($xml);
		$type = $dom->getElementsByTagName('response')->item(0)->getAttribute('type');
		if ($type=='ok') {
			$step=2;
		}
	}

	// Предустановленный демосайт
	if (isset($ini['DEMOSITE']['name']) && strlen($ini['DEMOSITE']['name'])>0) {
		$demosite = $ini['DEMOSITE']['name'];
	}

}