コード例 #1
0
$templateDB = "library";
$couch = new CouchSimple($options);
// See if we can make a connection
// If username, password and salt aren't all given, then echo back "" as onlineDB name
if ($username != $adminUsername || $password != $adminPassword) {
    echo "<p>Must include username and password</p>";
} else {
    /*
    	// Replicates template to all DB's
    	$resp = $couch->send("POST", "/_replicate", '{
    		"_design/library":[
    			"30-b4cb01005961645cd98322e499befb8a"
    		]
    	}'); */
    // Get a list of all databases online, and replicate with each
    $resp = $couch->send("GET", "/_all_dbs");
    $ignoreUsers = preg_replace('/\\"_users\\",/', '', $resp);
    $ignoreReplicator = preg_replace('/\\"_replicator\\",/', '', $ignoreUsers);
    $ignoreLibrary = preg_replace('/\\"' . $templateDB . '\\",/', '', $ignoreReplicator);
    $ignoreQuotations = preg_replace('/\\"/', '', $ignoreLibrary);
    $ignoreLeftBracket = preg_replace('/\\[/', '', $ignoreQuotations);
    $ignoreBreaks = preg_replace('/\\n/', '', $ignoreLeftBracket);
    $ignoreRightBracket = preg_replace('/\\]/', '', $ignoreBreaks);
    $DBArray = explode(',', $ignoreRightBracket);
    $totalDBs = count($DBArray);
    $repArray = array();
    $compactArray = array();
    $i = 1;
    while ($i <= $totalDBs) {
        $currentNum = $i;
        $currentDB = $DBArray[$currentNum - 1];
コード例 #2
0
// Change these to flat file on root possibly
$adminPassword = "******";
// Change these to flat file on root possibly
$options['host'] = "example.com";
// Location of all onlineDB's
$options['port'] = 5984;
$templateDB = "library";
// Location of the DB that will serve as a template
$couch = new CouchSimple($options);
// See if we can make a connection
// If username, password and salt aren't all given, then echo back "" as onlineDB name
if ($username == "" || $password == "" || $salt == "") {
    echo "";
} else {
    // Get a list of all databases in CouchDb
    $resp = $couch->send("GET", "/_all_dbs");
    var_export($resp, true);
    $checkForDB = preg_match('/"' . $username . '"/', $resp);
    // If there is already an onlineDB with their username, iterate numerically (rwadholm1, rwadholm2, etc.)
    // until their onlineDB name is unique.
    $i = 1;
    while ($checkForDB >= 1) {
        $onlineDB = $username . $i;
        $checkForDB = preg_match('/"' . $onlineDB . '"/', $resp);
        $i++;
    }
    // Create a new database
    $resp1 = $couch->send("PUT", "/" . $onlineDB);
    var_export($resp1, true);
    // Create a new user account with all credentials for the new database
    $resp2 = $couch->send("PUT", "/_users/org.couchdb.user%3A" . $onlineDB, '{
コード例 #3
0
ファイル: gigan.php プロジェクト: janl/gigan
// customise here
$xml_file_name = "couchdb.xml";
$db = "gigan";
$couchdb_host = "127.0.0.1";
$couchdb_port = 5984;
$couchdb_user = "";
$couchdb_pass = "";
$jira_attachment_url = "http://issues.apache.org/jira/secure/attachment/";
// stop customising
$couch = new CouchSimple(array("host" => $couchdb_host, "port" => $couchdb_port, "user" => $couchdb_user, "pass" => $couchdb_pass));
$ids = array();
if (!isset($_ENV["GIGAN_BOOT"])) {
    echo "Updating\n";
    // ask gigan for the last updated bug's updated timestamp
    echo "debug: getting latest update\n";
    $latest_update_result = $couch->send("GET", "/{$db}/_design/gigan/_view/latest-update?descending=true&limit=1");
    $latest_update_result = json_decode($latest_update_result);
    $latest_update = $latest_update_result->rows[0]->key;
    echo "debug: latest update: {$latest_update}\n";
    echo "debug: getting latest comment update\n";
    $latest_comment_update_result = $couch->send("GET", "/{$db}/_design/gigan/_view/latest-comment-update?descending=true&limit=1");
    $latest_comment_update_result = json_decode($latest_comment_update_result);
    $latest_comment_update = $latest_comment_update_result->rows[0]->key;
    echo "debug: latest comment update: {$latest_comment_update}\n";
    // read the JIRA RSS feed until it finds a date that is < that timestamp
    echo "getting the rss feed ...";
    $rss = file_get_contents("https://issues.apache.org/jira/sr/jira.issueviews:searchrequest-rss/temp/SearchRequest.xml?pid=12310780&sorter/field=updated&sorter/order=DESC&tempMax=50");
    echo "done\n";
    $xml = simplexml_load_string($rss, $class_name = "SimpleXMLElement", LIBXML_ERR_NONE);
    foreach ($xml->channel->item as $bug) {
        $date = strtotime((string) $bug->pubDate) . "000";