Beispiel #1
0
 /**
  * Get or set our $_COOKIE var via . sperated array access
  *
  * @param key string A period seperated string of array keys and values
  * @param value string The value to be set
  *
  * @return string
  */
 static function cookie($key, $value = null)
 {
     $key = ID . '_' . $key;
     if (!is_null($value)) {
         //set the cookie expirey to 24 hours time
         setcookie($key, Encrypt::encrypt($value), time() + 3600 * 24);
         return;
     }
     return Encrypt::decrypt($_COOKIE[$key]);
 }
$username = '******';
$password = '******';
// Enter your Network Name
$network = 'yournetworkname';
// Enter the API endpoint. This should be "https://sandbox.crowdvalley.com/v1"
// unless you have a paid account with Crowd Valley and you are using the live API
$apiURL = "https://sandbox.crowdvalley.com/v1";
//
//
// No need to touch anything below this line
//
//
// if API is under Basic Authentication, enter BasicAuth username and password
$apiBasicUsername = '';
$apiBasicPassword = '';
$header = new Header($apiKey, $apiSecret);
$encrypt = new Encrypt();
$encryptedPass = $encrypt->encrypt($apiSecret, $password, 16);
$token = $header->createToken($username, $encryptedPass);
echo $token . "\n\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiBasicUsername . ":" . $apiBasicPassword);
$headers = array();
$headers[] = 'cv-auth: ' . $token;
$headers[] = 'network: ' . $network;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec($ch);
curl_close($ch);
print $server_output . "\n";
Beispiel #3
0
 protected function encrypt_obj()
 {
     foreach ($this->_encrypted as $e) {
         if (isset($this->{$e}) && !empty($this->{$e})) {
             if (!isset($td)) {
                 $td = new Encrypt($_SESSION['user']->getKey());
             }
             $this->{$e} = $td->encrypt($this->{$e});
         }
     }
 }
Beispiel #4
0
         }
     }
     $repo = new Repo();
     $row = $repo->getArraySingle($repo->buildSql(array('table' => 'individual', 'index' => 'email', 'value' => $email, 'columns' => array('email'))));
     if (count($row)) {
         $message[] = 'Email address is already taken.';
         $validation_errors[] = 'email';
     }
     if (!empty($validation_errors)) {
         http_response_code(400);
         header("Content-Type: application/json");
         echo json_encode(array('success' => false, 'validation_errors' => $validation_errors, 'message' => "<div class='notice bad'><p>" . implode("<br/>", $message) . "</p></div>"));
         exit;
     }
     $individual = new Individual('');
     $success = $individual->create(array('name_first' => $name_first, 'name_last' => $name_last, 'email' => $email, 'hash' => $encrypt->encrypt($secret)));
     if ($success == true) {
         $action = 'show_success';
     }
 } elseif ($ax == 'update_secret') {
     if ($secret == $secret_validation) {
         $store_hash_success = $encrypt->storeHash($encrypt->encrypt($secret), $individual_id);
     }
 } elseif ($ax == 'submit-login') {
     if ($email == '') {
         $validation_errors[] = 'email';
         $message[] = 'Please enter your email address.';
     }
     if ($secret == '') {
         $validation_errors[] = 'secret';
         $message[] = 'Please enter your password.';
Beispiel #5
0
 public function setPassword($value, $key = NULL)
 {
     if (is_null($value)) {
         $this->password = NULL;
     } else {
         if (!$this->username) {
             // Without username you can't set the password
             $this->tempPass = $this->password = $value;
         } else {
             $newPass = Encrypt::hashPassword($value);
             $this->password = NULL;
             $this->get('password');
             if ($this->password != $newPass) {
                 // Only fiddle with the key if it's a change in password (prevents multiple passes)
                 $this->password = $newPass;
                 if (!$key) {
                     // Allow a key to be sent with the setPassword
                     $key = $this->getKey();
                 }
                 if ($key) {
                     $td = new Encrypt($value);
                     $this->dbkey = $td->encrypt($key);
                 }
             }
             unset($this->tempPass);
         }
     }
 }
$username = '******';
$password = '******';
// Enter your Network Name
$network = 'yournetworkname';
// Enter the API endpoint. This should be "https://sandbox.crowdvalley.com/v1"
// unless you have a paid account with Crowd Valley and you are using the live API
$apiURL = "https://sandbox.crowdvalley.com/v1";
//
//
// No need to touch anything below this line
//
//
// if API is under Basic Authentication, enter BasicAuth username and password
$apiBasicUsername = '';
$apiBasicPassword = '';
$header = new Header($apiKey, $apiSecret);
$encrypt = new Encrypt();
$encryptedPass = $encrypt->encrypt($password, $apiSecret);
$token = $header->createToken($username, $encryptedPass);
echo $token . "\n\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiBasicUsername . ":" . $apiBasicPassword);
$headers = array();
$headers[] = 'cv-auth: ' . $token;
$headers[] = 'network: ' . $network;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec($ch);
curl_close($ch);
print $server_output . "\n";