Exemplo n.º 1
0
//We only need to do this once!
require 'vendor/autoload.php';
//Get Connection Variables from VCAPS_SERVICES. We first need to pull in our Cloudant database
//connection variables from the VCAPS_SERVICES environment variable. This environment variable
//will be put in your project by Bluemix once you add the Cloudant database to your Bluemix
//application.
// vcap_services Extraction
$services_json = json_decode(getenv('VCAP_SERVICES'), true);
$VcapSvs = $services_json["cloudantNoSQLDB"][0]["credentials"];
// Extract the VCAP_SERVICES variables for Cloudant connection.
$myUsername = $VcapSvs["username"];
$myPassword = $VcapSvs["password"];
try {
    // Let's login to the database.
    $sag = new Sag($myUsername . ".cloudant.com");
    $sag->login($myUsername, $myPassword);
    // Now that we are logged in, we can create a database to use
    //$sag->createDatabase("ttpfeedback");
    $sag->setDatabase("ttpfeedback");
    /****feedback document starts ****/
    $namee = $_POST["name"];
    $com = $_POST["com"];
    $tweet = $_POST["tweet"];
    $acc = $_POST["service"];
    $sw = $_POST["topic"];
    $text = $_POST["text"];
    $rating = $_POST["rating"];
    /**test starts**/
    $ch = curl_init();
    $customer = array('EmailID' => $tweet, 'Organization' => $com, 'Rating' => $rating, 'Service' => $acc, 'Topics' => $sw, 'comments' => $text);
    $sag->put('"' . $namee . '"', $customer);
Exemplo n.º 2
0
 public function test_createDocWithSession()
 {
     $db = new Sag($this->couchIP);
     $db->setDatabase($this->couchDBName);
     $db->login('admin', 'passwd', Sag::$AUTH_COOKIE);
     $doc = new StdClass();
     $doc->sag = 'for couchdb';
     $res = $db->put('sag', $doc);
     $this->assertTrue($res->body->ok);
     $del_res = $db->delete('sag', $res->body->rev);
     $this->assertTrue($del_res->body->ok);
 }
Exemplo n.º 3
0
        exit;
    }
    header('Location: index.html');
    exit;
}
require_once 'Sag/Sag.php';
/*$username="******"; // Mysql username
$password="******"; // Mysql password
print_r($_POST);*/
// Define $myusername and $mypassword
$myusername = $_POST['username'];
$mypassword = $_POST['password'];
$s = new Sag();
/* cookie auth */
try {
    $res = $s->login($myusername, $mypassword, Sag::$AUTH_COOKIE);
    //$me = $s->get('org.couchdb.user:'******'username'])->body;
    if ($res->body->ok) {
        session_name('SlouchIn');
        session_id($res->cookies->AuthSession);
        session_start();
        $_SESSION['slouchin'] = array('name' => $myusername);
        header("Location: private.php");
        exit;
    }
} catch (SagCouchException $e) {
    echo 'Wrong Username or Password. <a href="index.html">Try Again?</a>';
}
/* HTTP Basic Auth code
  Don't use this unless you can *safely* store the user's username and password
  somewhere safe safely without risk in a safe place. Got it! :)
Exemplo n.º 4
0
Arquivo: run.php Projeto: hyla/sag
var_dump($_SESSION);
    </pre>

    <hr/>

    <p>
      <strong>Here are the results:</strong>

    <div>
      <?php 
ini_set('display_errors', true);
require 'CouchSessionStore.php';
require_once '../../src/Sag.php';
$sag = new Sag();
$sag->login('admin', 'password');
CouchSessionStore::setSag($sag);
session_start();
var_dump($_SESSION);
echo "<br/>";
if (!$_SESSION['userID']) {
    //Get user's info from the database ... or just hardcode it.
    $_SESSION['userID'] = 100;
    $_SESSION['firstName'] = "Sam";
}
printf("Welcome back %s (#%s)!<br/>\n", $_SESSION['firstName'], $_SESSION['userID']);
$_SESSION['time'] = time();
var_dump($_SESSION);
?>
    </div>
  </body>
Exemplo n.º 5
0
Arquivo: index.php Projeto: xwiz/sag
<?php

require_once '../../src/Sag.php';
session_start();
try {
    // We are going to get our page's content from Sag.
    $sag = new Sag('sbisbee.com');
    $sag->setDatabase('outlook');
    if ($_POST['login']) {
        echo '<p>Using login()';
        $_SESSION['AuthSession'] = $sag->login($_POST['username'], $_POST['password'], $sag::$AUTH_COOKIE);
    } else {
        if ($_SESSION['AuthSession']) {
            echo '<p>Using setCookie()';
            $sag->setCookie('AuthSession', $_SESSION['AuthSession']);
        }
    }
    $result = $sag->get('/');
} catch (Exception $e) {
    $error = $e->getMessage();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>proxyCookie example</title>
  </head>
  <body>
    <?php