protected function execute(InputInterface $input, OutputInterface $output) { $path = $input->getArgument('path'); if (substr($path, -1) == '/') { $path = substr($path, 0, strlen($path) - 1); } if (!is_dir($path)) { $output->writeln('<error>Error: Provided path not found</error>'); return; } $local = \TikiInit::getCredentialsFile(); if (!is_readable($local)) { $output->writeln('<error>Error: "' . $local . '" not readable.</error>'); return; } require $local; $args = array(); if ($user_tiki) { $args[] = "-u" . escapeshellarg($user_tiki); } if ($pass_tiki) { $args[] = "-p" . escapeshellarg($pass_tiki); } if ($host_tiki) { $args[] = "-h" . escapeshellarg($host_tiki); } $args[] = $dbs_tiki; $args = implode(' ', $args); $outputFile = $path . '/' . $dbs_tiki . '_' . date('Y-m-d_H:i:s') . '.sql.gz'; $command = "mysqldump --quick {$args} | gzip -5 > " . escapeshellarg($outputFile); exec($command); $output->writeln('<comment>Database backup completed: ' . $outputFile . '</comment>'); }
/** * @param $installer */ function upgrade_20120429_fix_collation_tiki($installer) { global $dbs_tiki; require TikiInit::getCredentialsFile(); $installer->query("ALTER DATABASE `" . $dbs_tiki . "` CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'"); unset($dbs_tiki); $results = $installer->fetchAll('SHOW TABLES'); foreach ($results as $table) { $installer->query('ALTER TABLE ' . reset($table) . ' convert to character set DEFAULT COLLATE DEFAULT'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $username = $input->getArgument('username'); $password = $input->getArgument('password'); $database = $input->getArgument('database'); if (!($hostname = $input->getOption('host', 'localhost'))) { $hostname = 'localhost'; } $twversion = new \TWVersion(); $version = $twversion->getBaseVersion(); $export_username = var_export($username, true); $export_password = var_export($password, true); $export_database = var_export($database, true); $export_hostname = var_export($hostname, true); $export_version = var_export($version, true); $out = <<<LOCALPHP <?php \$db_tiki='mysql'; \$dbversion_tiki={$export_version}; \$host_tiki={$export_hostname}; \$user_tiki={$export_username}; \$pass_tiki={$export_password}; \$dbs_tiki={$export_database}; \$client_charset='utf8'; // If you experience text encoding issues after updating (e.g. apostrophes etc showing up as strange characters) // \$client_charset='latin1'; // \$client_charset='utf8'; // See http://tiki.org/ReleaseNotes5.0#Known_Issues and http://doc.tiki.org/Understanding+Encoding for more info // If your php installation does not not have pdo extension // \$api_tiki = 'adodb'; // Want configurations managed at the system level or restrict some preferences? http://doc.tiki.org/System+Configuration // \$system_configuration_file = '/etc/tiki.ini'; // \$system_configuration_identifier = 'example.com'; LOCALPHP; $local_php = \TikiInit::getCredentialsFile(); file_put_contents($local_php, $out); $output->writeln("Wrote {$local_php}"); }
protected function execute(InputInterface $input, OutputInterface $output) { $tikilib = \TikiLib::lib('tiki'); $path = $input->getArgument('path'); if (substr($path, -1) == '/') { $path = substr($path, 0, strlen($path) - 1); } if (!is_dir($path)) { $output->writeln('<error>Error: Provided path not found</error>'); return; } $local = \TikiInit::getCredentialsFile(); if (!is_readable($local)) { $output->writeln('<error>Error: "' . $local . '" not readable.</error>'); return; } require $local; $root = getcwd(); if (!$root) { $output->writeln('<error>Error: Unable to derive source path</error>'); return; } if ($input->getOption('storageonly')) { $source = ''; } else { $source = escapeshellarg($root); } // get other directories if (!$input->getOption('nostorage')) { $query = "select distinct value from tiki_preferences where name like '%use_dir' union select att_store_dir from tiki_forums"; $result = $tikilib->query($query); $storage = array(); while ($res = $result->fetchRow()) { $storage[] = $res['value']; } foreach ($storage as $dir) { if (strpos($dir, '..') !== FALSE) { $output->writeln('<error>Warning: Unable to backup storage directory ' . $dir . ' (please use absolute path)</error>'); continue; } if (!empty($dir) && $input->getOption('storageonly') && substr($dir, 0, 1) != '/') { $dir = $root . '/' . $dir; } elseif (!$dir || substr($dir, 0, 1) != '/') { continue; } if (substr($dir, -1) == '/') { $dir = substr($dir, 0, strlen($dir) - 1); } if (!is_dir($dir)) { $output->writeln('<error>Warning: Unable to backup storage directory ' . $dir . ' (directory not found)</error>'); continue; } $source .= ' ' . escapeshellarg($dir); } } if (!$source) { $output->writeln('<error>Error: No backup sources found.</error>'); return; } $tarLocation = $path . '/' . $dbs_tiki . '_' . date('Y-m-d_H:i:s') . '.tar.bz2'; $tar = escapeshellarg($tarLocation); $command = "tar -cjf {$tar} {$source}"; exec($command); $output->writeln('<comment>Backup complete: ' . $tarLocation . '</comment>'); }
break; } // Global check if (is_null($base) || is_null($path)) { header('HTTP/1.0 500 Internal Server Error'); header('Content-Type: text/plain; charset=utf-8'); echo "Request could not be understood. Verify routing file."; exit; } tiki_route($path); if ($inclusion) { $_SERVER['PHP_SELF'] = $inclusion; include __DIR__ . '/' . $inclusion; } else { error_log("No route found - full:{$full} query:{$_SERVER['QUERY_STRING']}"); // Route to the "no-route" URL, if found require_once 'lib/init/initlib.php'; $local_php = TikiInit::getCredentialsFile(); if (file_exists($local_php)) { include $local_php; } if (empty($noroute_url)) { // Fail header('HTTP/1.0 404 Not Found'); header('Content-Type: text/plain; charset=utf-8'); echo "No route found. Please see http://dev.tiki.org/URL+Rewriting+Revamp"; } else { header('Location: ' . $noroute_url); } exit; }
/** * @param $patch */ function installPatch($patch) { if (!in_array($patch, $this->patches)) { return; } $schema = dirname(__FILE__) . "/schema/{$patch}.sql"; $script = dirname(__FILE__) . "/schema/{$patch}.php"; $profile = dirname(__FILE__) . "/schema/{$patch}.yml"; $pre = "pre_{$patch}"; $post = "post_{$patch}"; $standalone = "upgrade_{$patch}"; if (file_exists($script)) { require $script; } global $dbs_tiki; $local_php = TikiInit::getCredentialsFile(); if (empty($dbs_tiki) && is_readable($local_php)) { require $local_php; unset($db_tiki, $host_tiki, $user_tiki, $pass_tiki); } if (function_exists($standalone)) { $standalone($this); } else { if (function_exists($pre)) { $pre($this); } if (file_exists($profile)) { $status = $this->applyProfile($profile); } else { $status = $this->runFile($schema); } if (function_exists($post)) { $post($this); } } if (!isset($status) || $status) { $this->installed[] = $patch; $this->recordPatch($patch); } }