<?php

require $_SERVER['DOCUMENT_ROOT'] . '/application/system/Environment.php';
$key = filter_var($_GET['key'], FILTER_UNSAFE_RAW);
if (preg_match('/[\\w\\d]{32}/', $key)) {
    $options = array('database' => Configuration::kDatabaseName);
    $db = new CouchDB($options);
    $query_options = array('key' => $key);
    $result = $db->view('users/accountAuthorization', $query_options);
    if (count($result) > 0) {
        $authtoken = $result[0]['value']['key'];
        if ($authtoken == $key) {
            $user = new User();
            $db_user = $db->document($result[0]['value']['user']);
            $user->initWithArray($db_user);
            $user->isValid = true;
            $user->save();
            $db->delete($result[0]['value']['_id'], $result[0]['value']['_rev']);
        }
    }
    header('location: /');
}
 *    use this file except in compliance with the License.  You may obtain a copy
 *    of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 *    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 *    PURPOSE. See the License for the specific language governing permissions and
 *    limitations under the License.
 *
 *    Author: Adam Venturella - aventurella@gmail.com
 *
 *    @package Sample 
 *    @author Adam Venturella <*****@*****.**>
 *    @copyright Copyright (C) 2009 Adam Venturella
 *    @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
 *
 **/
/**
 * Sample
 */
require 'couchdb/CouchDB.php';
$newdb = 'newdb';
$options = array('database' => $newdb);
$db = new CouchDB($options);
$document_id = 'target_documnet_id';
$document_revision = 'revision_id';
// assumes a documnet exists with a given id, an exception will be thrown on error
$db->delete($document_id);
// avoid an extra lookup by provding the latest document revsion:
// $db->delete($document_id, $document_revision);
Example #3
0
 /**
  * @expectedException Exception
  */
 public function testDocumentDeleteWithNoDatabaseOption()
 {
     $couchdb = new CouchDB();
     $couchdb->delete(1234);
 }