/** * Initializes the route. * This method is invoked after the route is created by the route manager. */ public function init() { $credentials = new Credentials($this->params['key'], $this->params['secret']); $this->dynamoDb = DynamoDbClient::factory(['region' => $this->params['region'], 'credentials' => $credentials, 'base_url' => isset($this->params['base_url']) ? $this->params['base_url'] : '']); $this->tableName = $this->sessionTable; parent::init(); }
/** * (non-PHPdoc) * * @see common_persistence_Driver::connect() */ function connect($key, array $params) { $connectConfig = isset($params['client']) ? $params['client'] : array_intersect_key($params, array_flip(array('key', 'secret', 'region'))); $this->client = DynamoDbClient::factory($connectConfig); $this->tableName = $params['table']; return new common_persistence_AdvKeyValuePersistence($params, $this); }
/** * @param string $key The AWS access Key * @param string $secret The AWS secret Key * @param string $region The DynamoDB region endpoint * @throws \RuntimeException */ public function __construct($key, $secret, $region) { if (!class_exists('Aws\\DynamoDb\\DynamoDbClient')) { throw new \RuntimeException('Missing AWS PHP SDK'); } $this->connector = DynamoDbClient::factory(array('key' => $key, 'secret' => $secret, 'region' => $region, 'version' => '2011-12-05')); }
/** * Initialize the dynamodb client. */ public function init() { parent::init(); //For v2 compatibility. //TODO: remove deprecated. $this->_client = DynamoDbClient::factory($this->config); }
/** * Initialize the client. */ public function init() { $this->_client = DynamoDbClient::factory($this->config); if ($this->keyPrefix === null) { $this->keyPrefix = substr(md5(Yii::$app->id), 0, 5); } parent::init(); }
public function __construct($region = false) { if (!$region && !($region = getenv("AWS_DEFAULT_REGION"))) { throw new \Exception("Set 'AWS_DEFAULT_REGION' environment variable!"); } $this->region = $region; $this->sns = SnsClient::factory(['region' => $region]); $this->ddb = DynamoDbClient::factory(['region' => $region]); }
/** * @param null $table */ public function __construct($table = null) { if (empty($table)) { $this->table = ORDER_QUEUE_TABLE_NAME; } else { $this->table = $table; } /** * Get client */ $this->client = DynamoDbClient::factory(["key" => AWS_TEAM_COMMUNICATION_KEY, "secret" => AWS_TEAM_COMMUNICATION_SECRET, 'region' => AWS_TEAM_COMMUNICATION_TABLE_REGION]); }
public function __construct() { $bucket = Config::get('storage.bucket', 'default'); $key = Config::get('storage.key'); $secret = Config::get('storage.secret'); $client = DynamoDbClient::factory(array('key' => $key, 'secret' => $secret, 'region' => '<region name>')); $config = new SessionHandlerConfig(array('table_name' => 'sessions')); // Make sure locking strategy has been provided or provide a default $factory = new LockingStrategyFactory(); $strategy = $factory->factory($strategy, $config); // Return an instance of the session handler parent::__construct($client, $strategy, $config); }
public function __construct($connection, $config = array()) { if (!$connection instanceof DynamoDbClient) { if (!is_array($connection)) { throw new \InvalidArgumentException('First argument to OAuth2\\Storage\\Dynamodb must be an instance a configuration array containt key, secret, region'); } if (!array_key_exists("key", $connection) || !array_key_exists("secret", $connection) || !array_key_exists("region", $connection)) { throw new \InvalidArgumentException('First argument to OAuth2\\Storage\\Dynamodb must be an instance a configuration array containt key, secret, region'); } $this->client = DynamoDbClient::factory(array('key' => $connection["key"], 'secret' => $connection["secret"], 'region' => $connection["region"])); } else { $this->client = $connection; } $this->config = array_merge(array('client_table' => 'oauth_clients', 'access_token_table' => 'oauth_access_tokens', 'refresh_token_table' => 'oauth_refresh_tokens', 'code_table' => 'oauth_authorization_codes', 'user_table' => 'oauth_users', 'jwt_table' => 'oauth_jwt', 'scope_table' => 'oauth_scopes', 'public_key_table' => 'oauth_public_keys'), $config); }
public static function get() { if (LocalDBClientBuilder::$client == null) { LocalDBClientBuilder::$client = DynamoDbClient::factory(array('region' => 'us-west-2', 'version' => 'latest', 'endpoint' => 'http://localhost:8000', 'key' => 'myKey', 'secret' => 'mySecret')); // AMO: TODO remove debug plugin //LocalDBClientBuilder::$client->addSubscriber(LogPlugin::getDebugPlugin()); } return LocalDBClientBuilder::$client; /* $sdk = new Aws\Sdk([ 'region' => 'us-west-2', 'version' => 'latest', 'endpoint' => 'http://localhost:8080' ]); $dynamodb = $sdk->createDynamoDb();*/ }
/** * @depends testUsesInstanceProfileCredentialsByDefault */ public function testClientsUseInstanceProfileCredentials(array $creds) { $this->skipIfNotEc2(); list($credentials, $client) = $creds; $dynamo = DynamoDbClient::factory(array('credentials' => $credentials)); // Ensure that the correct credentials object and client are being used $this->assertSame($credentials, $dynamo->getCredentials()); if ($this->useMocks()) { $this->setMockResponse($client, array('metadata/iam_security_credentials', 'metadata/iam_security_credentials_webapp')); $this->setMockResponse($dynamo, 'dynamodb/list_tables_final'); } // Expire the credentials $credentials->setExpiration(0); // List a table, causing a credential refresh and list table request $this->assertInternalType('array', $dynamo->listTables()); }
public function __construct($options, $table) { // refer to the Session class to find the session timeout value (if it exists) // in terms of DynamoDB, session_lifetime is the time to mark the inactive // session to be garbage collected // if {@link GarbageCollectSessionCronTask} is running periodically on your // server (via the silverstripe-crontask module), then the inactive session // will get removed from the DynamoDB session table. if (!isset($options['session_lifetime'])) { $timeout = Config::inst()->get('Session', 'timeout'); if ($timeout != null) { $options['session_lifetime'] = $timeout; } } $this->client = DynamoDbClient::factory($options); $this->table = $table; $this->handler = SessionHandler::factory(array('dynamodb_client' => $this->client, 'table_name' => $this->table)); }
/** * @return NonceInterface */ private function getNonceObjectByDatabaseType($app) { $connection = $app['config']->get('vjroby-laravel-nonce::database_connection'); switch ($app['config']->get('vjroby-laravel-nonce::database_type')) { case self::DATABASE_TYPE_DYNAMODB: if (isset($this->client)) { return $this->client; } $dynamoDbDomain = App::make('aws')->get('DynamoDb'); $client = DynamoDbClient::factory(['credentials' => $dynamoDbDomain->getCredentials(), 'region' => $app['config']->get('vjroby-laravel-nonce::dynamodb_table_region')]); $nonceDynamo = new NonceDynamoStorage(); $nonceDynamo->setClient($client); $nonceDynamo->setTableName($app['config']->get('vjroby-laravel-nonce::dynamodb_table_name')); return $nonceDynamo; break; case self::DATABASE_TYPE_MYSQL: return new Nonce($connection); break; default: return new Nonce($connection); break; } }
public function setupSession() { if( defined('DEBUG') ){ session_start(); return; } $client = DynamoDbClient::factory(array( 'key' => 'AKIAIDBPOWSJGOKXMFXQ', 'secret' => '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', 'region' => Region::EU_WEST_1 )); $sessionHandler = $client->registerSessionHandler( array('table_name' => 'session_table', 'hash_key' => 'id', 'lifetime' => 86400, 'session_locking' => false)); session_start(); }
echo "<option value='pdf materials'>PDF Materials</option>"; echo "</optgroup>"; echo "</select></label></br>"; echo "<label>Upload Image:</label>"; echo "<input type='file' name='image'><br>"; echo "<input type='submit' value='Add to basket'>"; echo "</form>"; echo "<form action='sellsure.php' method='post'>"; echo "<input type='submit' value='Go back to search page'>"; echo "</form>"; require 'aws-autoloader.php'; use Aws\DynamoDb\DynamoDbClient; use Aws\Common\Enum\Region; use Aws\DynamoDb\Enum\Type; use Aws\S3\S3Client; $client = DynamoDbClient::factory(array('credentials' => array('key' => 'key', 'secret' => 'secret'), 'region' => 'us-east-1')); if (isset($_POST['itemname']) && isset($_POST['itemdesc'])) { $category = @$_POST['category']; $itemid = uniqid(); $itemname = $_POST['itemname']; $itemdescription = $_POST['itemdesc']; $image_name = @$_FILES['image']['name']; $image_temp = @$_FILES['image']['tmp_name']; $image_type = pathinfo($image_name, PATHINFO_EXTENSION); $size = @$_FILES['image']['size']; /*echo $userid; echo "<br>"; echo $itemid; echo "<br>"; echo $itemdescription; echo "<br>";
/** * Connect to dynamodb */ protected static function connect() { self::$dynamodb = DynamoDbClient::factory(['region' => 'local', 'endpoint' => 'http://localhost:4567', 'credentials' => ['key' => 'none', 'secret' => 'none'], 'request.options' => ['connect_timeout' => 3], 'client.backoff' => false]); }
/** * @covers Aws\DynamoDb\DynamoDbClient::registerSessionHandler */ public function testCanRegisterSessionHandlerFromClient() { $client = DynamoDbClient::factory(array('key' => 'foo', 'secret' => 'bar', 'region' => 'us-west-1')); $this->assertInstanceOf('Aws\\DynamoDb\\Session\\SessionHandler', $client->registerSessionHandler()); }
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); date_default_timezone_set("UTC"); ini_set('max_execution_time', 300); require "src/aws/aws-autoloader.php"; use Aws\DynamoDb\DynamoDbClient; use Aws\DynamoDb\Model\BatchRequest\WriteRequestBatch; use Aws\DynamoDb\Model\BatchRequest\PutRequest; use Aws\DynamoDb\Model\Item; include 'src/GetZooplaData.php'; include '../cred.php'; $zoopla = new GetZooplaData(); //header('Content-type: application/xml'); $client = DynamoDbClient::factory(array('key' => $aws_key, 'secret' => $aws_secret, 'region' => 'eu-west-1')); $putBatch = WriteRequestBatch::factory($client); $updateTime = time() - 7 * 24 * 3600; $dbStationInfo = $client->scan(array('TableName' => 'station_info')); foreach ($dbStationInfo['Items'] as $item) { if (isset($item['last_updated']['S'])) { if (intval($item['last_updated']['S']) < $updateTime) { // die($item['last_updated']['S'] . " : " . $updateTime); $stations_stationName[] = $item['station_name']['S']; $stations_postCode[] = $item['post_code']['S']; $stations_londonZone[] = $item['london_zone']['S']; $stations_stationId[] = $item['station_id']['S']; if (isset($item['last_updated'])) { $stations_lastUpdate[] = $item['last_updated']['S']; } else { $stations_lastUpdate[] = 0;
<br/> <br/> <input type="submit" value="Register" name="register"/> </fieldset> </form> <?php error_reporting(E_ALL); ini_set('display_errors', 'On'); if (isset($_POST['register'])) { $user = $_POST['userName']; $fullName = $_POST['fullName']; $email = $_POST['email']; $pass = md5($_POST['password']); //connect to dynamodb $client = DynamoDbClient::factory(array('credentials' => array('aws_access_key_id' => '', 'aws_secret_access_key' => ''), 'region' => '')); $response = $client->query(array('TableName' => 'registerUsers', 'KeyConditions' => array('ID' => array('ComparisonOperator' => 'EQ', 'AttributeValueList' => array(array('S' => $user)))))); $count = count(array_filter($response['Items'])); //if username already taken if ($count > 0) { echo "Error! UserName already taken please select a different username"; } else { //save data in dynamodb $response = $client->putItem(array('TableName' => 'registerUsers', 'Item' => array('ID' => array('S' => $user), 'PWD' => array('S' => $pass), 'fullName' => array('S' => $fullName), 'email' => array('S' => $email)))); //go back to login header("Location:Login.php"); exit; } } ?> </body>
protected static function _setupClient($connection_name = self::DEFAULT_CONNECTION) { if (!isset(self::$_client[$connection_name])) { $params = self::getConfig(null, $connection_name); /* if (self::getConfig('key', $connection_name) && self::getConfig('secret', $connection_name)) { $params['credentials'] = new Credentials( self::getConfig('key', $connection_name), self::getConfig('secret', $connection_name) ); } */ if (self::getConfig('base_url', $connection_name)) { $params['endpoint'] = self::getConfig('base_url', $connection_name); } //$client = new DynamoDbClient($params); $client = DynamoDbClient::factory($params); self::$_client[$connection_name] = $client; } }
/** * @expectedException \Aws\Common\Exception\TransferException */ public function testWrapsCurlExceptions() { $this->getServiceBuilder()->get('dynamodb', true); $client = DynamoDbClient::factory(array('key' => 'foo', 'secret' => 'bar', 'region' => 'us-west-1', 'client.backoff' => false, 'base_url' => 'http://localhost:123', 'curl.options' => array(CURLOPT_TIMEOUT_MS => 1))); $client->listTables(); }
public function getClient() { return DynamoDbClient::factory($this->config); }
<?php require 'lib/aws.phar'; use Aws\DynamoDb\DynamoDbClient; $client = DynamoDbClient::factory(array('profile' => 'guest1', 'region' => 'eu-central-1')); // Create an "errors" table echo "creating table..." . "\n"; $client->createTable(array('TableName' => 'errors', 'AttributeDefinitions' => array(array('AttributeName' => 'id', 'AttributeType' => 'N'), array('AttributeName' => 'time', 'AttributeType' => 'N')), 'KeySchema' => array(array('AttributeName' => 'id', 'KeyType' => 'HASH'), array('AttributeName' => 'time', 'KeyType' => 'RANGE')), 'ProvisionedThroughput' => array('ReadCapacityUnits' => 10, 'WriteCapacityUnits' => 20))); // Wait until the table is created and active echo "Waiting for table creation..." . "\n"; $client->waitUntil('TableExists', array('TableName' => 'errors')); echo "table done." . "\n"; ?> <html lang="en"> <head> <meta charset="utf-8" /> <title>Hello World</title> </head> <body> A hellow world page 5 <?php echo "pgp enabled"; ?> </body> </html>
<h1> Thankyou for your submission!</h1> <?php /** * Created by PhpStorm. * User: Tidus * Date: 14-7-28 * Time: 9:20 p.m. */ require "vendor/autoload.php"; use Aws\DynamoDb\DynamoDbClient; use Aws\Common\Enum\Region; use Aws\DynamoDb\Enum\Type; use Aws\DynamoDb\Enum\AttributeAction; use Aws\DynamoDb\Enum\ReturnValue; $client = DynamoDbClient::factory(array('key' => 'AKIAJ2TIE2BO4YR7ROVQ', 'secret' => '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', 'region' => Region::AP_SOUTHEAST_2)); $tableName = "CoGeo_Place_Database"; $placeId = $_POST["placeId"]; $feeling1 = $_POST["feeling1"]; $feeling2 = $_POST["feeling2"]; $feeling3 = $_POST["feeling3"]; $feeling4 = $_POST["feeling4"]; $feeling5 = $_POST["feeling5"]; $feeling6 = $_POST["feeling6"]; $feeling7 = $_POST["feeling7"]; $placeReference = $_POST["placeReference"]; ################################################################ //Adding data to CoGeo Primary Database $response = $client->putItem(array("TableName" => $tableName, "Item" => $client->formatAttributes(array("PlaceId" => $placeId, "Chatty" => $feeling1, "Buzz" => $feeling2, "Pump" => $feeling3, "Adventure" => $feeling4, "Bustle" => $feeling5, "LoveyDovey" => $feeling6, "Trackies" => $feeling7, "PlaceReference" => $placeReference)), "ReturnConsumedCapacity" => 'TOTAL', "Expected" => array("Name" => array("ComparisonOperator" => "NULL")))); echo "<br />"; ?>
<html> <head> <meta charset="utf-8"> <title>formHandler </title> <?php require '../vendor/autoload.php'; use Aws\DynamoDb\DynamoDbClient; use Aws\DynamoDb\Exception\DynamoDbException; ?> </head> <body> <?php try { $client = DynamoDbClient::factory(array('credentials' => array('key' => 'AKIAILB7YAAEVCHDD2KQ', 'secret' => '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'), 'region' => 'eu-west-1')); $email = $_POST['email']; $password = $_POST['password']; $confirmPassword = $_POST['confirm_password']; $lastname = $_POST['firstname']; $firstname = $_POST['lastname']; $response = $client->getItem(array('TableName' => 'Users', 'Key' => array('email' => array('S' => $email)))); if ($response['Item'] == null) { $client->putItem(array('TableName' => 'Users', 'Item' => array('email' => array('S' => $email), 'password' => array('S' => $password), 'lastname' => array('S' => $lastname), 'firstname' => array('S' => $firstname)))); echo "Vous existez!"; } else { echo "L'email saisie est déjà utilisée par un autre utilisateur."; } } catch (DynamoDbException $e) { echo '<p>Exception dynamoDB reçue : ', $e->getMessage(), "\n</p>"; } catch (Exception $e) {
function connect_dynamoDB($config) { $client = DynamoDbClient::factory(array('key' => $config->aws->key, 'secret' => $config->aws->secret, 'region' => $config->aws->region)); return $client; }
private function getDynamoDbClient() { $config = array(); // check for environment variables if (($key = $this->getEnvVar('AWS_ACCESS_KEY_ID')) && ($secret = $this->getEnvVar('AWS_SECRET_KEY'))) { $config['key'] = $key; $config['secret'] = $secret; } else { // fall back on ~/.aws/credentials file // @see http://docs.aws.amazon.com/aws-sdk-php/guide/latest/credentials.html#credential-profiles if (!file_exists($this->getEnvVar('HOME') . '/.aws/credentials')) { $this->dynamodb = new NullStorage('DynamoDb', 'No aws credentials file found, and no AWS_ACCESS_KEY_ID or AWS_SECRET_KEY environment variable set'); return; } // set profile in AWS_PROFILE environment variable, defaults to "default" $config['profile'] = $this->getEnvVar('AWS_PROFILE', 'default'); } // set region in AWS_REGION environment variable, defaults to "us-east-1" $config['region'] = $this->getEnvVar('AWS_REGION', \Aws\Common\Enum\Region::US_EAST_1); return \Aws\DynamoDb\DynamoDbClient::factory($config); }
private function getDynamoDbClient() { $client = DynamoDbClient::factory(array('profile' => 'project1', 'version' => 'latest', 'region' => 'us-west-2', 'endpoint' => 'http://localhost:8000')); return $client; }
<?php session_start(); require 'aws/aws-autoloader.php'; require 'config.php'; use Aws\DynamoDb\DynamoDbClient; use Aws\Common\Enum\Region; use Aws\DynamoDb\Enum\Type; use Aws\DynamoDb\Enum\AttributeAction; use Aws\DynamoDb\Enum\ReturnValue; use Aws\DynamoDb\Enum\KeyType; use Aws\S3\S3Client; $client = DynamoDbClient::factory($config); $s3 = S3Client::factory($config); $actionMessage = null; $errorMessage = null; $actionMessage = @$_GET['act']; if ($_SERVER['REQUEST_METHOD'] == "POST") { $usrId = @$_POST['userid']; $password = md5(@$_POST['password']); $response = $client->getItem(array("TableName" => "usr_reg", "Key" => array("useremail" => array(Type::STRING => $usrId), "password" => array(Type::STRING => $password)))); if (count($response) > 0) { $_SESSION['userId'] = $response['Item']['Id']['N']; $_SESSION['username'] = $response['Item']['name']['S']; } else { $errorMessage = "Invalid username or password"; } } include 'includes/header.php'; ?>
/** * @param $region * @param $key * @param $secret */ public function __construct($region, $key, $secret) { $this->client = \Aws\DynamoDb\DynamoDbClient::factory(['region' => $region, 'credentials' => ['key' => $key, 'secret' => $secret], 'version' => '2012-08-10']); }