$canExeRead = Misc::canExecuteRead(nZEDb_RES); if (is_string($canExeRead)) { exit($canExeRead); } unset($canExeRead); } if (!isset($argv[1])) { $message = <<<HELP This script can export a predb dump file. You may use the full path, or a relative path. For exporting, the path must be writeable by mysql, any existing file [predb_dump.csv] will be overwritten. php {$argv[0]} /path/to/write/to ...: To export. HELP; exit($message); } else { $path = !preg_match('#^/#', $argv[1]) ? getcwd() . '/' . $argv[1] : $argv[1]; } if (file_exists($path) && is_file($path)) { unlink($path); } Misc::clearScreen(); $table = isset($argv[2]) ? $argv[2] : 'predb'; $predb = new PreDb(); if (nZEDb_ECHOCLI) { echo "Exporting table: {$table} to '{$path}'\n"; } $result = $predb->executeExport(['enclosed' => '', 'fields' => '\\t\\t', 'limit' => 0, 'lines' => '\\r\\n', 'path' => $path]); if ($result == false) { echo "ERROR: Failed to export file!\n"; }
* @copyright 2015 nZEDb */ require_once realpath(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'indexer.php'); use nzedb\db\PreDb; use nzedb\utility\Misc; if (!Misc::isWin()) { $canExeRead = Misc::canExecuteRead(nZEDb_RES); if (is_string($canExeRead)) { exit($canExeRead); } unset($canExeRead); } if (!isset($argv[1])) { $message = <<<HELP This script can export a predb dump file. You may use the full path, or a relative path. For exporting, the path must be writeable by mysql, any existing file [predb_dump.csv] will be overwritten. php {$argv[0]} /path/to/write/to ...: To export. HELP; exit($message); } else { $path = !preg_match('#^/#', $argv[1]) ? getcwd() . '/' . $argv[1] : $argv[1]; } if (file_exists($path) && is_file($path)) { unlink($path); } Misc::clearScreen(); $table = isset($argv[2]) ? $argv[2] : 'predb'; $predb = new PreDb(); $predb->executeExport(['enclosed' => " ENCLOSED BY \"'\" ", 'fields' => '\\t\\t', 'lines' => '\\r\\n', 'path' => $path]);
if (nZEDb_DEBUG) { echo "Fetching predb_dump list from GitHub\n"; } $result = Misc::getUrl(['url' => $url, 'requestheaders' => ['Content-Type: application/json', 'User-Agent: nZEDb']]); if ($result === false) { exit('Error connecting to GitHub, try again later?' . PHP_EOL); } if (nZEDb_DEBUG) { echo "Extracting filenames from list.\n"; } $data = json_decode($result, true); if (is_null($data)) { exit("Error: {$result}"); } $total = count($data); $predb = new PreDb(); $progress = $predb->progress(settings_array()); foreach ($data as $file) { if (preg_match("#^https://raw\\.githubusercontent\\.com/nZEDb/nZEDbPre_Dumps/master/dumps/{$filePattern}\$#", $file['download_url'])) { if (preg_match("#^{$filePattern}\$#", $file['name'], $match)) { $timematch = $progress['last']; // Skip patches the user does not want. if ($match[1] < $timematch) { echo 'Skipping dump ' . $match[2] . ', as your minimum unix time argument is ' . $timematch . PHP_EOL; --$total; continue; } // Download the dump. $dump = Misc::getUrl(['url' => $file['download_url']]); echo "Downloading: {$file['download_url']}\n"; if (!$dump) {
if (!(isset($argv[1]) && in_array(strtolower($argv[1]), $db) && isset($argv[2]) && is_file($argv[2]))) { $message = <<<HELP This script can import a predb dump file. You may use the full path, or a relative path. For importing, the script insert new rows and update existing matched rows. For databases not on the local system, use remote, else use local. php {$argv[0]} [remote | local] /path/to/filename HELP; exit($message); } else { $path = !preg_match('#^/#', $argv[2]) ? getcwd() . '/' . $argv[2] : $argv[2]; } $argv[1] = strtolower($argv[1]); Misc::clearScreen(); $table = isset($argv[3]) ? $argv[3] : 'predb'; $predb = new PreDb(); $local = $argv[1] === 'local'; echo $predb->log->info("Clearing import table"); // Truncate to clear any old data $predb->executeTruncate(); // Import file into predb_imports $predb->executeLoadData(['fields' => '\\t\\t', 'lines' => '\\r\\n', 'local' => $local, 'path' => $path]); //$predb->executeLoadData($path, $local); // Remove any titles where length <=8 echo $predb->log->info("Deleting any records where title <=8 from Temporary Table"); $predb->executeDeleteShort(); // Add any groups that do not currently exist $predb->executeAddGroups(); // Fill the group_id $predb->executeUpdateGroupID(); echo $predb->log->info("Inserting records from temporary table into predb table");