Example #1
0
            $path = $_REQUEST['server_path'];
            $path = trim($path) . "\\";
            $path = str_replace("\\\\", "/", $path);
            $path = str_replace("\\", "/", $path);
            $path = str_replace("//", "/", $path);
            setServerPath($path);
            $tmp_lua_config = new ConfigLUA($path . 'config.lua');
            $config['server'] = $tmp_lua_config->getConfig();
            if (isset($config['server']['mysqlHost'])) {
                echo 'File <b>config.lua</b> loaded from <font color="red"><i>' . $path . 'config.lua</i></font>. It looks like fine server config file. Now you can check database connection: <a href="install.php?page=step&step=2">STEP 2 - check database connection</a>';
            } else {
                echo 'File <b>config.lua</b> loaded from <font color="red"><i>' . $path . 'config.lua</i></font> and it\'s not valid TFS config.lua file. <a href="install.php?page=step&step=1">Go to STEP 1 - select other directory.</a> If it\'s your config.lua file from TFS contact with acc. maker author.';
            }
        } else {
            echo 'Please write you TFS directory below. Like: <i>C:\\Documents and Settings\\Gesior\\Desktop\\TFS 0.2.9\\</i><form action="install.php">
			<input type="text" name="server_path" size="90" value="' . htmlspecialchars(getServerPath()) . '" /><input type="hidden" name="page" value="step" /><input type="hidden" name="step" value="1" /><input type="submit" value="Set server path" />
			</form>';
        }
    } elseif ($step == 2) {
        echo '<h1>STEP ' . $step . '</h1>Check database connection<br>';
        echo 'If you don\'t see any errors press <a href="install.php?page=step&step=3">link to STEP 3 - Add tables and columns to DB</a>. If you see some errors it mean server has wrong configuration. Check FAQ or ask author of acc. maker.<br />';
        $SQL->connect();
        // show errors if can't connect
    } elseif ($step == 3) {
        echo '<h1>STEP ' . $step . '</h1>Add tables and columns to DB<br>';
        echo 'Installer try to add new tables and columns to database.<br>';
        $columns = array();
        //$columns[] = array('table', 'name_of_column', 'type', 'length', 'default');
        $columns[] = array('accounts', 'key', 'VARCHAR', '20', '0');
        $columns[] = array('accounts', 'email_new', 'VARCHAR', '255', '');
        $columns[] = array('accounts', 'email_new_time', 'INT', '11', '0');
Example #2
0
/**
 * Runs the installer
 *
 * @since 1.0
 * @package facileManager
 */
function installFM($proto, $compress)
{
    global $argv, $module_name, $data;
    unset($data['SERIALNO']);
    echo fM("Welcome to the {$module_name} installer.\n\n");
    echo fM("Please answer the following questions and the necessary configurations will be performed for you.\n\n");
    /** facileManager host **/
    echo "Please enter the location of the facileManager interface:\n";
    echo "    Examples include:\n";
    echo "\tfm.mydomain.com\n";
    echo "\tfm.mydomain.com:8443\n";
    echo "\tmydomain.com/fm\n";
    echo "\thttp://fm.mydomain.com/facileManager\n\n";
    echo 'Please enter the location of the facileManager interface: ';
    if (defined('FMHOST')) {
        $serverhost = FMHOST;
        echo FMHOST . "\n";
    } else {
        $serverhost = trim(fgets(STDIN));
    }
    /** Get server name from input */
    $server_location = getServerPath($serverhost);
    extract($server_location);
    $data['config'] = array();
    /** Run tests */
    echo fM("  --> Testing {$hostname} via https...");
    if (socketTest($hostname, 443)) {
        echo "ok\n";
        $proto = 'https';
    } else {
        echo "failed\n";
        echo fM("  --> Testing {$hostname} via http...");
        if (socketTest($hostname, 80)) {
            echo "ok\n";
            $proto = 'http';
        } else {
            echo "failed\n\n";
            echo fM("Cannot access {$hostname} with http or https.  Please correct this before proceeding.\n");
            exit(1);
        }
    }
    $data['config'][] = array('FMHOST', 'facileManager server', $hostname . '/' . $path);
    /** Account key **/
    $key = 'default';
    while (!isset($key)) {
        echo fM('Please enter your account key: ');
        $key = trim(fgets(STDIN));
    }
    $data['compress'] = $compress;
    $data['AUTHKEY'] = $key;
    $data['config'][] = array('AUTHKEY', 'Account number', $key);
    /** Test the authentication */
    echo fM('  --> Checking account details...');
    $url = "{$proto}://{$hostname}/{$path}admin-accounts.php?verify";
    $raw_data = getPostData($url, $data);
    $raw_data = $data['compress'] ? @unserialize(gzuncompress($raw_data)) : @unserialize($raw_data);
    echo $raw_data . "\n\n";
    if ($raw_data != 'Success') {
        echo "Installation failed.  ";
        echo !strlen($raw_data) ? fM("Could not communicate properly with {$hostname}.  Failed to access {$url}.") : fM('Please check your account key.');
        echo "\n";
        exit(1);
    }
    /** Server serial number **/
    $data['server_name'] = exec('hostname -f', $output, $rc);
    if ($rc > 0 || empty($data['server_name'])) {
        $data['server_name'] = php_uname('n');
    }
    $data['server_os'] = PHP_OS;
    $data['server_os_distro'] = detectOSDistro();
    echo fM('Please enter the serial number for ' . $data['server_name'] . ' (or leave blank to create new): ');
    if (defined('SERIALNO')) {
        $serialno = $data['server_serial_no'] = SERIALNO;
        echo SERIALNO . "\n";
    } else {
        $serialno = trim(fgets(STDIN));
    }
    $url = "{$proto}://{$hostname}/{$path}admin-servers.php?genserial";
    /** Process new server */
    if (empty($serialno)) {
        /** Generate new serial number */
        echo fM('  --> Generating new serial number: ');
        $serialno = $data['server_serial_no'] = generateSerialNo($url, $data);
        echo $serialno . "\n";
    }
    /** Add new server */
    echo fM('  --> Adding ' . $data['server_name'] . ' to the database...');
    $add_server_result = moduleAddServer($url, $data);
    extract($add_server_result, EXTR_OVERWRITE);
    echo fM($add_result);
    $data['SERIALNO'] = $serialno;
    $data['config'][] = array('SERIALNO', 'Server unique serial number', $serialno);
    $data = installFMModule($module_name, $proto, $compress, $data, $server_location, $url);
    /** Save the file */
    saveFMConfigFile($data);
    /** Complete installation */
    $url = "{$proto}://{$hostname}/{$path}admin-servers.php?install";
    $raw_data = getPostData($url, $data);
    /** Add log entry */
    addLogEntry('Client installed successfully.');
    echo fM("Installation is complete. Please login to the UI to ensure the server settings are correct.\n");
    /** chmod and prepend php to this file */
    chmod($argv[0], 0755);
    $contents = file_get_contents($argv[0]);
    $bin = '#!' . findProgram('php');
    if (strpos($contents, $bin) === false) {
        $contents = $bin . "\n" . $contents;
        file_put_contents($argv[0], $contents);
    }
    exit;
}