Exemple #1
0
function installGarena()
{
    global $config;
    if (isInstalled("garena")) {
        return;
    }
    chdir($config['root_path']);
    rexec("svn co http://gcb.googlecode.com/svn/trunk/bin gcb-bin");
    mkdir($config['garena_path']);
    chmod($config['garena_path'], 0755);
    mkdir($config['garena_path'] . "lib");
    chmod($config['garena_path'] . "lib", 0755);
    copy($config['root_path'] . "gcb-bin/gcb.jar", $config['garena_path'] . "gcb.jar");
    copy($config['root_path'] . "gcb-bin/gcbrooms.txt", $config['garena_path'] . "gcbrooms.txt");
    copy($config['root_path'] . "gcb-bin/gkey.pem", $config['garena_path'] . "gkey.pem");
    copy($config['root_path'] . "gcb-bin/gcb.cfg", $config['garena_path'] . "gcb.cfg");
    recursiveCopy($config['root_path'] . "gcb-bin/lib", $config['garena_path'] . "lib");
    installFinish("garena");
}
function PageContent(&$sError)
{
    global $aConf, $permDirectories, $permFiles, $reversalDirectories, $reversalFiles;
    global $confFirst, $aDbConf, $aGeneral, $aRayFolders, $aRayFiles;
    $ret = '';
    switch ($_REQUEST['action']) {
        case 'step7':
            $ret .= loadDolphin();
            break;
        case 'step6':
            $dirName = '';
            $fileName = '';
            $errorMessage = '';
            foreach ($reversalDirectories as $dir) {
                if (isFullAccessible('../' . $dir)) {
                    //$passOk = false;
                    $dirName .= '&nbsp;&nbsp;&nbsp;' . $dir . ';<br />';
                }
            }
            if (strlen($dirName)) {
                $sError = 'error';
                $errorMessage .= '<strong>Next directories have inappropriate permissions</strong>:<br />' . $dirName;
            }
            foreach ($reversalFiles as $file) {
                if (isRWAccessible('../' . $file)) {
                    //$passOk = false;
                    $fileName .= '&nbsp;&nbsp;&nbsp;' . $file . ';<br /> ';
                }
            }
            if (strlen($fileName)) {
                $sError = 'error';
                $errorMessage .= '<strong>Next files have inappropriate permissions</strong>:<br />' . $fileName;
            }
            if (strlen($errorMessage)) {
                $ret .= showPermissions($errorMessage);
            } else {
                $ret .= loadDolphin();
            }
            break;
        case 'step5':
            $ret .= showPermissions();
            break;
        case 'step4':
            $errorMessage = '';
            foreach ($aGeneral as $key => $value) {
                if (!strlen($value['check'])) {
                    continue;
                }
                $funcbody = $value['check'];
                $func = create_function('$arg0', $funcbody);
                if (!$func($_POST[$key])) {
                    $errorMessage .= "Please, input valid data to <b>{$value['name']}</b> field<br />";
                    $error_arr[$key] = 1;
                    $passOk = false;
                    unset($_POST[$key]);
                } else {
                    $error_arr[$key] = 0;
                }
                $config_arr[$key]['def'] = $_POST[$key];
            }
            if (strlen($errorMessage)) {
                $sError = 'error';
                $ret .= installGeneralInfo($errorMessage);
            } else {
                $ret .= installFinish();
            }
            break;
        case 'step3':
            $errorMessage = '';
            foreach ($aDbConf as $key => $value) {
                if (!strlen($value['check'])) {
                    continue;
                }
                $funcbody = $value['check'];
                $func = create_function('$arg0', $funcbody);
                if (!$func($_POST[$key])) {
                    $errorMessage .= "Please, input valid data to <b>{$value['name']}</b> field<br />";
                    $error_arr[$key] = 1;
                    $passOk = false;
                    unset($_POST[$key]);
                } else {
                    $error_arr[$key] = 0;
                }
                $config_arr[$key]['def'] = $_POST[$key];
            }
            if (strlen($errorMessage)) {
                $sError = 'error';
                $ret .= installDBConf($errorMessage);
            } else {
                $ret .= installGeneralInfo();
            }
            break;
        case 'step2':
            $errorMessage = '';
            foreach ($confFirst as $key => $value) {
                if (!strlen($value['check'])) {
                    continue;
                }
                $funcbody = $value['check'];
                $func = create_function('$arg0', $funcbody);
                if (!$func($_POST[$key])) {
                    $errorMessage .= "Please, input valid data to <b>{$value['name']}</b> field<br />";
                    $error_arr[$key] = 1;
                    $passOk = false;
                    unset($_POST[$key]);
                } else {
                    $error_arr[$key] = 0;
                }
                $config_arr[$key]['def'] = $_POST[$key];
            }
            if (strlen($errorMessage)) {
                $sError = 'error';
                $ret .= installStepFirst($errorMessage);
            } else {
                $ret .= installDBConf();
            }
            break;
        case 'step1':
            $dirName = '';
            $errorMessage = '';
            foreach ($permDirectories as $dir) {
                if (!isFullAccessible('../' . $dir)) {
                    //$passOk = false;
                    $dirName .= '&nbsp;&nbsp;&nbsp;' . $dir . ';<br />';
                }
            }
            foreach ($aRayFolders as $dir) {
                if (!isFullAccessible('../' . $dir)) {
                    //$passOk = false;
                    $dirName .= '&nbsp;&nbsp;&nbsp;' . $dir . ';<br />';
                }
            }
            if (strlen($dirName)) {
                $sError = 'error';
                $errorMessage .= '<strong>Next directories have inappropriate permissions</strong>:<br />' . $dirName;
            }
            foreach ($permFiles as $file) {
                if (!isRWAccessible('../' . $file)) {
                    //$passOk = false;
                    $fileName .= '&nbsp;&nbsp;&nbsp;' . $file . ';<br /> ';
                }
            }
            foreach ($aRayFiles as $file) {
                if (strpos($file, 'ffmpeg') === FALSE) {
                    if (!isRWAccessible('../' . $file)) {
                        //$passOk = false;
                        $fileName .= '&nbsp;&nbsp;&nbsp;' . $file . ';<br /> ';
                    }
                } else {
                    if (!isFullAccessible('../' . $file)) {
                        //$passOk = false;
                        $fileName .= '&nbsp;&nbsp;&nbsp;' . $file . ';<br /> ';
                    }
                }
            }
            if (strlen($fileName)) {
                $sError = 'error';
                $errorMessage .= '<strong>Next files have inappropriate permissions</strong>:<br />' . $fileName;
            }
            if (strlen($errorMessage)) {
                $ret .= PreInstall($errorMessage);
            } else {
                $ret .= installStepFirst();
            }
            break;
        case 'preInstall':
            $ret .= PreInstall();
            break;
        default:
            $ret .= StartInstall();
    }
    return $ret;
}