mysqli_close($conn); } ?> <div class="container"> <h1>Simple StackExchange</h1> <br><br><br> <div class="box1"> <div class="SubTitle"> <h2>The question topic goes here </h2> </div> <div class="content" id="q" > <?php readQuestion($_GET["id"]); ?> </div> </div> <div class="box2"> <?php readAnswer($_GET["id"]); ?> </div> <div class="answerform"> Your Answer
require_once dirname(__FILE__) . '/includes/initializer.php'; // ask the necessary data $_config['mysql']['NAME'] = readQuestion('Enter the database name', 'any'); $projecthost = readQuestion('Enter project host (eq. x.yourname.com)', 'any'); $projectalias = readQuestion('Enter project alias (eq. x.yourname.nl)', 'any'); // MODX admin user $adminUser = $_config['modx']['username']; $adminUser = !empty($adminUser) ? $adminUser : '******'; // MODX admin password $adminPassword = $_config['modx']['password']; $adminPassword = !empty($adminPassword) ? $adminPassword : generatePassword(); // MODX admin email $adminEmail = $_config['modx']['email']; //if(!isset($adminEmail) || empty($adminEmail)) { while (empty($adminEmail)) { $adminEmail = readQuestion('Please enter the MODX Manager emailaddress', 'any'); } // Creating project root path echo date('Y-m-d H:i:s') . ' [INFO] Creating project directory...' . "\n"; mkdir($projectpath, 0755, true); chdir($projectpath); // moves PHP to project path $out = exec('cd ' . $projectpath); // moves environment to project path // -------------------------- // APACHE VHS if (strtolower($_config['apacheCreateVHS']) == 'yes') { // create virtualhost file echo date('Y-m-d H:i:s') . ' [INFO] Creating Apache VirtualHost file...' . "\n"; $tplFile = dirname(__FILE__) . '/templates/vhs.apache.tpl'; if (!empty($projectalias)) {
<?php require_once dirname(__FILE__) . '/functions.php'; require_once dirname(__FILE__) . '/configcheck.php'; // get some defaults $projectname = getopt("p:"); if (!isset($projectname) || empty($projectname)) { $projectname = readQuestion('Please enter a project folder (relative to: ' . $_config['projectsPath'] . ')', 'any'); if (empty($projectname)) { die(date('Y-m-d H:i:s') . ' [INIT ERROR] Please specify a project directory... Installer aborted, try again!' . "\n"); } } $projectpath = $_config['projectsPath'] . rtrim($projectname, '/') . '/'; if (!isset($isNewInstall) || $isNewInstall === false) { // add new installs; below cannot be initialized!! if (!file_exists($projectpath)) { die(date('Y-m-d H:i:s') . ' [INIT ERROR] Project directory "' . $projectpath . '" doesn\'t exists... Installer aborted, try again!' . "\n"); } define('MODX_API_MODE', true); /* this can be used to disable caching in MODX absolutely */ $modx_cache_disabled = false; /* include custom core config and define core path */ include $projectpath . 'config.core.php'; if (!defined('MODX_CORE_PATH')) { die(date('Y-m-d H:i:s') . ' [INIT ERROR] MODX_CORE_PATH not set after including "' . $projectpath . 'config.core.php"... Installer aborted, try again!' . "\n"); } /* include the modX class */ if (!@(include_once MODX_CORE_PATH . "model/modx/modx.class.php")) { die(date('Y-m-d H:i:s') . ' [ERROR 503] MODX core cannot be loaded... Installer aborted, try again!' . "\n"); } /** @var modX $modx An instance of the MODX class */
/** * Downloads and installs packages * @param $packageName * @param array $installOptions * @return bool */ function downloadAndInstallPackage($packageName, $installOptions = array()) { global $modx, $defaultProvider, $productVersion; // setting back default provider each time because it can be overwritten $provider = $defaultProvider; // check if there isset another provider setting if (isset($installOptions['_provider']) && !empty($installOptions['_provider'])) { // check if all options are set well $params = array_merge(array('name' => '', 'service_url' => '', 'username' => '', 'api_key' => '', 'description' => ''), $installOptions['_provider']); // check if it exists already $provider = $modx->getObject('transport.modTransportProvider', array('name' => $params['name'])); if (empty($provider) || !is_object($provider)) { foreach ($params as $key => $value) { if (empty($value)) { $newVal = readQuestion('Please enter provider setting "' . $key . '" for package "' . $packageName . '"', 'any'); if (empty($newVal) && $key != 'description') { $modx->log(modX::LOG_LEVEL_ERROR, 'Cannot continue adding package "' . $packageName . '"! Reason: missing provider settings! SKIPPED...'); return false; } } } // create provider $provider = $modx->newObject('transport.modTransportProvider', $params); if (!$provider->save()) { $modx->log(modX::LOG_LEVEL_ERROR, 'Cannot continue adding package "' . $packageName . '"! Reason: provider cannot be initialized...'); return false; } } if ($provider->verify() !== true) { $modx->log(modX::LOG_LEVEL_ERROR, 'Cannot continue adding package "' . $packageName . '"! Reason: provider cannot be verified...'); $error = $provider->verify(); if (!empty($error) && is_string($error)) { $modx->log(modX::LOG_LEVEL_ERROR, 'PROVIDER SAYS: ' . $error); } return false; } $provider->getClient(); } // continue install $modx->log(modX::LOG_LEVEL_INFO, 'Heading to install ' . $packageName . '...'); $response = $provider->request('package', 'GET', array('supports' => $productVersion, 'query' => $packageName)); if (!empty($response)) { $foundPackages = simplexml_load_string($response->response); foreach ($foundPackages as $foundPackage) { if ($foundPackage->name == $packageName) { /* define version */ $sig = explode('-', $foundPackage->signature); $versionSignature = explode('.', $sig[1]); //download file file_put_contents($modx->getOption('core_path') . 'packages/' . $foundPackage->signature . '.transport.zip', file_get_contents($foundPackage->location)); /* add in the package as an object so it can be upgraded */ /** @var modTransportPackage $package */ $package = $modx->newObject('transport.modTransportPackage'); $package->set('signature', $foundPackage->signature); $package->fromArray(array('created' => date('Y-m-d h:i:s'), 'updated' => null, 'state' => 1, 'workspace' => 1, 'provider' => 1, 'source' => $foundPackage->signature . '.transport.zip', 'package_name' => $packageName, 'version_major' => $versionSignature[0], 'version_minor' => !empty($versionSignature[1]) ? $versionSignature[1] : 0, 'version_patch' => !empty($versionSignature[2]) ? $versionSignature[2] : 0)); if (!empty($sig[2])) { $r = preg_split('/([0-9]+)/', $sig[2], -1, PREG_SPLIT_DELIM_CAPTURE); if (is_array($r) && !empty($r)) { $package->set('release', $r[0]); $package->set('release_index', isset($r[1]) ? $r[1] : '0'); } else { $package->set('release', $sig[2]); } } $success = $package->save(); if ($success) { $package->install(); } else { $modx->log(modX::LOG_LEVEL_ERROR, 'Could not save package ' . $foundPackage->name); } break; } } return true; } return false; }