Example #1
0
<?php

/**
 * SimplePHPCouch Example
 */
header('Content-Type: text/plain');
require 'CouchSimple.class.php';
$couch = new CouchSimple('test', 'localhost', 5984, null, null, true);
$doc = new stdClass();
$doc->_id = 'testdoc-1';
$doc->text = 'Hello SimplePHPCouch!';
echo $couch->storeDoc($doc);
echo "\n";
echo $couch->getDocById('testdoc-1');
echo "\n";
Example #2
0
header("Cache-Control: no-cache, must-revalidate");
error_reporting(0);
$rawUsername = $_REQUEST['username'];
$username = strtolower($rawUsername);
$password = $_REQUEST['password'];
$salt = $_REQUEST['salt'];
$onlineDB = $username;
$adminUsername = "******";
// 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";
$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);
Example #3
0
//error_reporting(0);
$rawUsername = $_REQUEST['username'];
$username = strtolower($rawUsername);
$password = $_REQUEST['password'];
$salt = $_REQUEST['salt'];
$onlineDB = $username;
$adminUsername = "******";
// 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);
Example #4
0
File: gigan.php Project: janl/gigan
<?php

// Note: this code is ugly. it scrapes JIRA's XML, it must be ugly.
date_default_timezone_set("Europe/Berlin");
// 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");