/* * ************************************************************************************* * * Load couchdb views and documents * * ************************************************************************************* */ if ($ok) { include_once($dolibarr_main_document_root . "/core/db/couchdb/lib/couchClient.php"); //print '<input type="hidden" name="couchdb_user_root" value="' . $_POST['couchdb_user_root'] . '">'; //print '<input type="hidden" name="couchdb_pass_root" value="' . $_POST['couchdb_pass_root'] . '">'; try { $host = substr($conf->Couchdb->host, 7); $couchdb = new couchClient('http://' . $_POST['couchdb_user_root'] . ':' . $_POST['couchdb_pass_root'] . '@' . $host . ':' . $conf->Couchdb->port . '/', $conf->Couchdb->name, array("cookie_auth" => false)); $couchdb->getDatabaseInfos(); $dir = "couchdb/json/"; // Create views and documents $handle = @opendir($dir); // Dir may not exists if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { if (preg_match('/\.json$/i', $file)) { $fp = fopen($dir . $file, "r"); if ($fp) { $json = fread($fp, filesize($dir . $file)); $obj = json_decode($json); // Test if exist document in database : upgrade try {
} else { echo "It seems that something wrong happened. You can have more details using :\n"; echo "the exception class with get_class(\$e) : " . get_class($e) . "\n"; echo "the exception error code with \$e->getCode() : " . $e->getCode() . "\n"; echo "the exception error message with \$e->getMessage() : " . $e->getMessage() . "\n"; } } /** *CouchDB gives lots of details for a single database * *Let's see that * */ echo "Getting database informations\n"; try { $db_infos = $client->getDatabaseInfos(); } catch (Exception $e) { echo "Something weird happened :" . $e->getMessage() . " (errcode=" . $e->getCode() . ")\n"; exit(1); } echo "Database informations : \n" . print_r($db_infos, true) . "\n"; echo "Displaying database disk usage using \$db_infos->disk_size: " . $db_infos->disk_size . " bytes\n"; /** * Finally delete database * * * */ echo "Deleting database\n"; try { $result = $client->deleteDatabase();