private function input_args() { $tplvars = array(); $tplvars['pass'] = true; $this->database['username'] = trim($this->input->post('database_user')); $this->database['password'] = $this->input->post('database_password'); $this->database['hostname'] = trim($this->input->post('database_host') == "" ? 'localhost' : $this->input->post('database_host')); $this->database['database'] = trim($this->input->post('database_name') == "" ? 'OpenVBX' : $this->input->post('database_name')); $this->openvbx_settings = array(); $this->openvbx = array(); $this->openvbx_settings['twilio_sid'] = trim($this->input->post('twilio_sid')); $this->openvbx_settings['twilio_token'] = trim($this->input->post('twilio_token')); $this->openvbx['salt'] = md5(rand(10000, 99999)); $this->openvbx_settings['from_email'] = trim($this->input->post('from_email') == "" ? '' : $this->input->post('from_email')); $this->openvbx_settings['theme'] = $this->input->post('theme'); $this->openvbx_settings['iphone_theme'] = ''; $this->openvbx_settings['trial_number'] = '(415) 599-2671'; $this->openvbx_settings['schema-version'] = OpenVBX::getLatestSchemaVersion(); $this->openvbx_settings['rewrite_enabled'] = !strlen($this->input->post('rewrite_enabled')) ? 0 : $this->input->post('rewrite_enabled'); $this->user = array(); $this->user['email'] = trim($this->input->post('admin_email')); $this->user['password'] = $this->input->post('admin_pw'); $this->user['firstname'] = trim($this->input->post('admin_firstname')); $this->user['lastname'] = trim($this->input->post('admin_lastname')); $this->user['tenant_id'] = 1; $tplvars = array_merge($tplvars, $this->user, $this->database, $this->openvbx, $this->openvbx_settings); return $tplvars; }
public function setup() { $json['success'] = true; $json['message'] = ''; try { $currentSchemaVersion = OpenVBX::schemaVersion(); $upgradingToSchemaVersion = OpenVBX::getLatestSchemaVersion(); $upgradeScriptPath = VBX_ROOT . '/updates/'; $updates = scandir($upgradeScriptPath); $updatesToRun = array(); // Collect all files named numerically in /updates and key sort the list of updates foreach ($updates as $i => $update) { if (preg_match('/^(\\d+).(sql|php)$/', $update, $matches)) { $updateExtension = $matches[2]; $rev = $matches[1]; $updatesToRun[$rev] = array('type' => $updateExtension, 'filename' => $update, 'revision' => $rev); } } ksort($updatesToRun); // Cut the updates by the current schema version. $updatesToRun = array_slice($updatesToRun, $currentSchemaVersion); $tplvars = array('originalVersion' => $currentSchemaVersion, 'version' => $upgradingToSchemaVersion, 'updates' => $updatesToRun); foreach ($updatesToRun as $updateToRun) { $file = $updateToRun['filename']; $type = $updateToRun['type']; $revision = $updateToRun['revision']; switch ($type) { case 'php': require_once $upgradeScriptPath . $file; $runUpdateMethod = "runUpdate_{$revision}"; if (!function_exists($runUpdateMethod)) { throw new UpgradeException('runUpdate method missing from ' . $file . ': ' . $runUpdateMethod); } call_user_func($runUpdateMethod); break; case 'sql': $sql = @file_get_contents($upgradeScriptPath . $file); if (empty($sql)) { throw new UpgradeException("Unable to read update: {$file}", 1); } foreach (explode(";", $sql) as $stmt) { $stmt = trim($stmt); if (!empty($stmt)) { PluginData::sqlQuery($stmt); } } break; } } flush_minify_caches(); } catch (Exception $e) { $json['success'] = false; $json['message'] = $e->getMessage(); $json['step'] = $e->getCode(); } $json['tplvars'] = $tplvars; echo json_encode($json); }
public function setup() { $json['success'] = true; $json['message'] = ''; try { $currentSchemaVersion = OpenVBX::schemaVersion(); $upgradingToSchemaVersion = OpenVBX::getLatestSchemaVersion(); $sqlPath = VBX_ROOT . '/sql-updates/'; $updates = scandir($sqlPath); $files = array(); foreach ($updates as $i => $update) { if (preg_match('/^(\\d+).sql$/', $update)) { $rev = intval(str_replace('.sql', '', $update)); $files[$rev] = $update; } } ksort($files); $files = array_slice($files, $currentSchemaVersion); $tplvars = array('originalVersion' => $currentSchemaVersion, 'version' => $upgradingToSchemaVersion, 'updates' => $files); foreach ($files as $file) { $sql = @file_get_contents($sqlPath . $file); if (empty($sql)) { throw new UpgradeException("Unable to read update: {$file}", 1); } foreach (explode(";", $sql) as $stmt) { $stmt = trim($stmt); if (!empty($stmt)) { PluginData::sqlQuery($stmt); } } } } catch (Exception $e) { $json['success'] = false; $json['message'] = $e->getMessage(); $json['step'] = $e->getCode(); } $json['tplvars'] = $tplvars; echo json_encode($json); }
private function upgrade_check() { $currentSchemaVersion = OpenVBX::schemaVersion(false); $upgradingToSchemaVersion = OpenVBX::getLatestSchemaVersion(); if ($currentSchemaVersion != $upgradingToSchemaVersion) { redirect('upgrade'); } }
</fieldset> <button class="submit-button"><span>Update</span></button> </form> </div><!-- .vbx-tab-view --> <div id="settings-about" class="vbx-tab-view"> <h3>About</h3> <ul> <li>Current Version: <?php echo OpenVBX::version(); ?> </li> <li>Schema Version: <?php echo OpenVBX::schemaVersion(); ?> </li> <li>Latest Schema Available: <?php echo OpenVBX::getLatestSchemaVersion(); ?> </li> </ul> <p>Thanks to everyone involved, you made it better than envisioned!</p> <?php require_once 'license.php'; ?> </div> </div><!-- .vbx-content-main -->