示例#1
0
function getDbHostForIdentifier($dbIdentifier)
{
    $rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
    $result = $rds->describeDBInstances(['DBInstanceIdentifier' => $dbIdentifier]);
    $endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
    return $endpoint;
}
 /**
  * Get the value of a tag for a specified DB instance.
  *
  * @param string $instanceIdentifier Identifier of the DB instance to get
  *     the tag of.
  * @param string $tagKey Key of tag to get.
  * @return string|null Value of tag or null if the db instance or tag does
  *     not exist.
  */
 public function getRdsDbInstanceTag($instanceIdentifier, $tagKey)
 {
     // Compose the ARN of the DB instance.
     $accountId = explode(':', $this->iam->GetUser()['User']['Arn'])[4];
     $arn = sprintf('arn:aws:rds:%s:%s:db:%s', $this->region, $accountId, $instanceIdentifier);
     try {
         $tags = $this->rds->ListTagsForResource(['ResourceName' => $arn])['TagList'];
     } catch (Rds\Exception\DBInstanceNotFoundException $e) {
         return null;
     }
     foreach ($tags as $tag) {
         if ($tag['Key'] === $tagKey) {
             return $tag['Value'];
         }
     }
     return null;
 }
示例#3
0
<?php

// Start the session^M
require 'vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
// Create a table
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'ksrmp1db']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
print "============\n" . $endpoint . "================\n";
$link = mysqli_connect($endpoint, "krupavat", "Admin123", "KSRDB", "3306") or die("Error " . mysqli_error($link));
//echo "Here is the result: " . $link;
$create_table = 'CREATE TABLE IF NOT EXISTS userInfo 
(
 id INT NOT NULL AUTO_INCREMENT,
 uname VARCHAR(200) NOT NULL,
 email VARCHAR(200) NOT NULL,
 phone VARCHAR(20) NOT NULL,
 s3rawurl VARCHAR(255) NOT NULL,
 s3finishedurl VARCHAR(255) NOT NULL,   
 jpgfilename VARCHAR(255) NOT NULL,   
 status INT NOT NULL,
 createdat DATETIME DEFAULT CURRENT_TIMESTAMP,
 PRIMARY KEY(id)
)';
if (mysqli_query($link, $create_table) === TRUE) {
    printf("Table userInfo successfully created.\n");
}
示例#4
0
</div>


	<h3>Creating db dump in S3!!!</h3>
	
	<a href="index.php">Home Page</a>
</body>


<?php 
require 'vendor/autoload.php';
//Creating a dump of the RDS database instance
$db = 'usnehadb';
$username = '******';
$password = '******';
$dbclient = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-west-2']);
$result = $dbclient->describeDBInstances(['DBInstanceIdentifier' => 'usneha']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
$link = mysqli_connect($endpoint, "username", "password", "usnehadb") or die("Error " . mysqli_error($link));
// making a folder for storing backup
mkdir("/tmp/dbDump");
// path for backup folder
$dumpPath = '/tmp/dbDump/';
$fname = uniqid("dbdump", false);
$finalPath = $dumpPath . $fname . '.' . sql;
// found this line in stackoverflow
$sql = "mysqldump --user={$username} --password={$password} --host={$endpoint} {$db} > {$finalPath}";
exec($sql);
$bucketname = uniqid("dbdump", false);
$s3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-west-2']);
# AWS PHP SDK version 3 create bucket
<?php

session_start();
require 'vendor/autoload.php';
echo $_POST['phone'];
$phone = $_POST['phone'];
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'jaysharma-rds']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
$link = mysqli_connect($endpoint, "JaySharma", "sharma1234", "datadb") or die("Error " . mysqli_error($link));
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
$sql1 = "SELECT topicArn,topicName FROM snstopic ";
$result = mysqli_query($link, $sql1);
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        if ($row["topicName"] == 'A20344475-SNS-SERVICE') {
            $sns = new Aws\Sns\SnsClient(['version' => 'latest', 'region' => 'us-east-1']);
            $result = $sns->subscribe(['Endpoint' => $phone, 'Protocol' => 'sms', 'TopicArn' => $row["topicArn"]]);
        }
    }
}
$sArn = $result['SubscriptionArn'];
echo $subArn;
echo "Subscribe by replying Yes";
header("refresh:5;url=index.php");
?>

示例#6
0
<?php

session_start();
require 'vendor/autoload.php';
#create RDSclient using the us-west-2
echo $_GET['raw'];
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-west-2']);
#fetch the DB instance read replcia to read content
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'itmo-544-SN-dbreplica']);
#get the end point to the instance
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
$link = mysqli_connect($endpoint, "SukanyaN", "SukanyaNDB", "itmo544SNDB");
?>

<!DOCTYPE html>
<html><head>
<!-- Magnific Popup core CSS file -->
<link rel="stylesheet" href="https://rawgit.com/sukanyaN/itmo-544-final/master/css/magnific-popup.css">

<!-- Bootstrap Core CSS -->
    <link href="https://rawgit.com/sukanyaN/itmo-544-final/master/css/bootstrap.min.css" rel="stylesheet">


<style>
.magnific-gallery
{
	list-style: none;
}

.magnific-gallery li
{
</head>
<body>
<div class="container">
<div class="header clearfix">
<h3 class="text-muted text-center">ITMO-544-MP-FINAL</h3>
</div>
<?php 
// Start the session
session_start();
// Include the AWS SDK using the Composer autoloader.
require 'vendor/autoload.php';
if (!empty($_POST)) {
    //echo $_POST['username'];
    //echo $_POST['password'];
    #create rds client
    $rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
    #DB Instance connection
    #to get the DBInstances Address
    $result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'mp1-vinodh-db']);
    $endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
    //print "============\n". $endpoint . "================\n";
    #DB CONNECTION SETUP
    $DB_USERNAME = "******";
    $DB_PASSWORD = "******";
    $DB_NAME = "customerrecords";
    $DB_PORT = 3306;
    $link = mysqli_connect($endpoint, $DB_USERNAME, $DB_PASSWORD, $DB_NAME, $DB_PORT);
    // check connection
    if (!$link) {
        die("Connection failed: " . mysqli_connect_error());
    } else {
示例#8
0
<html>
<head><title>Gallery</title>
</head>
<body>

<?php 
session_start();
$email = $_POST["email"];
echo $email;
require 'vendor/autoload.php';
$client = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
$result = $client->describeDBInstances(array('DBInstanceIdentifier' => 'itmo444-mp1'));
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
// Do something with the message
echo "============" . $endpoint . "================";
echo "Begin database";
$link = mysqli_connect($endpoint, "balrifai", "ilovebunnies", "balrifai") or die("Error " . mysqli_error($link));
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
} else {
    echo "Connection successful!";
}
//below line is unsafe - $email is not checked for SQL injection -- don't do this in real life or use an ORM instead
$link->real_query("SELECT * FROM User WHERE email = '{$email}'");
echo "Result set order...\n";
if ($result = $link->use_result()) {
    while ($row = $result->fetch_assoc()) {
        echo "<img src=\" " . $row['raws3url'] . "\" height='200' width='200' />";
    }
<html>
<head><title>Gallery</title>
  <!-- jQuery -->
  <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
  <!-- Fotorama -->
  <link href="fotorama.css" rel="stylesheet">
  <script src="fotorama.js"></script>
</head>
<body>

<?php 
session_start();
//$email = $_POST["email"];
//echo $email;
require 'vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
$resultrdb = $rds->describeDBInstances(array('DBInstanceIdentifier' => 'mp1SKread-replica'));
$endpointrdb = $resultrdb['DBInstances'][0]['Endpoint']['Address'];
//  echo "============\n". $endpointrdb . "================";
$linkrdb = mysqli_connect($endpointrdb, "testconnection1", "testconnection1", "Project1");
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
} else {
    //echo "Connection to RDB Success";
}
if (isset($_SESSION['useremail'])) {
    $email = $_SESSION['useremail'];
    //echo $email;
    $linkrdb->real_query("SELECT * FROM MiniProject1 where email='{$email}'");
    $resrdb = $linkrdb->use_result();
示例#10
0
<?php

session_start();
require 'vendor/autoload.php';
//create topic
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-west-2']);
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'itmo-544-sukanya']);
//echo "No error as of now";
//print_r($result);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
//    print "============\n". $endpoint . "================";
//echo "endpoint is available";
$link = mysqli_connect($endpoint, "SukanyaN", "SukanyaNDB", "itmo544SNDB") or die("Error " . mysqli_error($link));
//print_r($link);
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
$sql1 = "SELECT topicarn,topicname FROM topic ";
$result = mysqli_query($link, $sql1);
if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while ($row = mysqli_fetch_assoc($result)) {
        if ($row["topicname"] == 'Mp2-S3Upload1') {
            echo "";
        } else {
            $sns = new Aws\Sns\SnsClient(['version' => 'latest', 'region' => 'us-east-1']);
            $topicName = 'Mp2-S3Upload1';
            $result = $sns->createTopic(['Name' => $topicName]);
            $topicarn = $result['TopicArn'];
            //	echo "topic arn value is ----------- $topicarn";
示例#11
0
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);
// Start the session^M
require '/var/www/html/vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1', 'credentials' => ['key' => '', 'secret' => '']]);
// Create a table
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'jss-itmo444-db']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
print "============\r\n" . $endpoint . "================\r\n";
$link = new mysqli($endpoint, 'controller', 'letmein1234', 'jssitmo444db');
// Check connection
if ($link->connect_error) {
    die("Connection failed: " . $link->connect_error);
}
echo "Connected successfully\r\n";
#echo "Here is the result: " . $link;
$sql = "DROP TABLE IF EXISTS jssUserImages";
if (!mysqli_query($link, $sql)) {
    echo "Error : " . mysqli_error($link);
}
$sql = "CREATE TABLE jssUserImages  \n(\nidTable INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\nuserNameTable VARCHAR(20),\nuserEmailTable VARCHAR(20),\nuserTelephoneTable VARCHAR(20),\nrawS3URLTable VARCHAR(256),\nfinishedS3URLTable VARCHAR(256),\nfileNameTable VARCHAR(256),\nstateTable TINYINT(3),\ndateTable timestamp \n)";
$linkValue = $link->query($sql);
if ($linkValue === TRUE) {
    print "Created jssUserImages!\r\n";
} else {
    print "Table jssUserImages unable to be created!\r\n";
}
$link->close();
示例#12
0
 $path = '/tmp/Image/';
 $imageid = uniqid("Id");
 // concatenating name and type
 $imglocation = $imageid . '.' . $ext;
 $finalImgPath = $path . $imglocation;
 echo $ImgPath;
 $imgpath->writeImage($finalImgPath);
 //creating bucket to upload framed image
 $frames3bucket = uniqid("frameimage", false);
 echo $frames3bucket;
 $result = $s3->createBucket(['ACL' => 'public-read', 'Bucket' => $frames3bucket]);
 $result = $s3->putObject(['ACL' => 'public-read', 'Bucket' => $frames3bucket, 'Key' => "flipped" . $imglocation, 'SourceFile' => $finalImgPath]);
 $finishedimgurl = $result['ObjectURL'];
 echo "processed image uploaded to s3";
 // ------------------------------------------------------------------------------------------------------------------
 $rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-west-2']);
 $result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'usneha']);
 echo "fetching result from describe db instance";
 //print_r($result);
 $endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
 print "============\n" . $endpoint . "================";
 echo "endpoint is available";
 $link = mysqli_connect($endpoint, "username", "password", "usnehadb", 3306) or die("Error " . mysqli_error());
 print_r($link);
 if (mysqli_connect_errno()) {
     printf("Connect failed: %s\n", mysqli_connect_error());
     exit;
 }
 echo "Connected to RDS";
 # prepared statement to insert data into items of usnehadb
 $sql_insert = "INSERT INTO items (UName,Email,Phone,RawS3Url,FinalS3Url,JpgFileName,status,Ifsubscribed) VALUES (?,?,?,?,?,?,?,?)";
示例#13
0
    echo "File is valid, and was successfully uploaded.\n";
} else {
    echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
require '/var/www/html/vendor/autoload.php';
$userS3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-east-1', 'credentials' => ['key' => '', 'secret' => '']]);
$bucket = uniqid("jss-userImages", false);
# AWS PHP SDK version 3 create bucket
$result = $userS3->createBucket(['ACL' => 'public-read', 'Bucket' => $bucket]);
$result = $userS3->putObject(['ACL' => 'public-read', 'Bucket' => $bucket, 'Key' => $bucket, 'SourceFile' => $uploadfile]);
$rawurl = $bucket;
$url = $result['ObjectURL'];
echo $url;
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1', 'credentials' => ['key' => '', 'secret' => '']]);
$result = $rds->describeDBInstances(array('DBInstanceIdentifier' => 'jss-itmo444-db'));
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
echo "============\n" . $endpoint . "================";
$link = mysqli_connect($endpoint, "controller", "letmein1234", "jssitmo444db") or die("Error" . mysql_error($link));
/*check connection*/
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
/*Prepared statement, stage 1: prepare*/
if (!($stmt = $link->prepare("INSERT INTO jssUserImages (userNameTable,userEmailTable,userTelephoneTable,rawS3URLTable,finishedS3URLTable,fileNameTable,stateTable,dateTable) \n\tVALUES ('?','?','?','?','?','?','?','?')"))) {
    echo "Prepare failed: (" . $link->errno . ") " . $link->error;
} else {
    echo "Prepare complete!\n";
}
示例#14
0
<?php

// Start the session^M
require 'vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
$result = $rds->createDBInstance(['AllocatedStorage' => 10, 'DBInstanceClass' => 'db.t1.micro', 'DBInstanceIdentifier' => 'mp1-jrh', 'DBName' => 'customerrecords', 'Engine' => 'MySQL', 'EngineVersion' => '5.5.41', 'MasterUserPassword' => 'letmein888', 'MasterUsername' => 'controller', 'PubliclyAccessible' => true]);
print "Create RDS DB results: \n";
# print_r($rds);
$result = $rds->waitUntil('DBInstanceAvailable', ['DBInstanceIdentifier' => 'mp1-jrh']);
// Create a table
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'mp1-jrh']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
print "============\n" . $endpoint . "================\n";
$link = mysqli_connect($endpoint, "controller", "letmein888", "3306") or die("Error " . mysqli_error($link));
echo "Here is the result: " . $link;
$sql = "CREATE TABLE comments \n(\nID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\nPosterName VARCHAR(32),\nTitle VARCHAR(32),\nContent VARCHAR(500)\n)";
$con->query($sql);
?>

<?php

// Start the session
require '../itmo-544-444-app/vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
$s3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-east-1']);
// Create a table
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'mp1-jgl']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
print "============\n" . $endpoint . "================\n";
$link = mysqli_connect($endpoint, "controller", "letmein888", "customerrecords") or die("Error " . mysqli_error($link));
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
//Create the table jgldata
$sql = "CREATE TABLE jgldata\n(\nID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\nuname VARCHAR(20),\nemail VARCHAR(50),\nphone VARCHAR(20),\nfilename VARCHAR(256),\ns3rawurl VARCHAR(256),\ns3finishedurl VARCHAR(256),\nstate TINYINT(3)CHECK(state IN(0,1,2)),\ndate TIMESTAMP \n\n)";
$link->query($sql);
//chmod("setup-lite.php",0600);
shell_exec("chmod 600 setup.php");
示例#16
0
<?php

// Start the session
require 'var/www/html/vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'itmo444-mp1']);
$rds->waitUntil('DBInstanceAvailable', ['DBInstanceIdentifier' => 'itmo444-mp1']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
print "============\n" . $endpoint . "================\n";
$link = mysqli_connect($endpoint, "balrifai", "ilovebunnies", "balrifai", 3306) or die("Error " . mysqli_error($link));
echo "Here is the result: " . $link;
$sql = "CREATE TABLE IF NOT EXISTS User \n(\nID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\nemail VARCHAR(20),\nusername VARCHAR(20),\ntelephone VARCHAR(20),\nraws3url VARCHAR(256),\nfinished3url VARCHCAR(256),\nfilename VARCHAR(256),\nstate TINYINT(3),\ndatetime VARCHAR\n\n)";
$link->query($sql);
shell - exec("chmod 600 setup.php");
示例#17
0
<?php

// Start the session^M
require 'vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-west-2']);
$result = $rds->createDBInstance(['AllocatedStorage' => 5, 'DBInstanceClass' => 'db.t1.micro', 'DBInstanceIdentifier' => 'isu-db', 'DBName' => 'customerrecords', 'Engine' => 'MySQL', 'MasterUserPassword' => 'ilovebunnies', 'MasterUsername' => 'controller', 'PubliclyAccessible' => true]);
print "Create RDS DB results: \n";
# print_r($rds);
$result = $rds->waitUntil('DBInstanceAvailable', ['DBInstanceIdentifier' => 'isu-db']);
// Create a table
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'isu-db']);
print_r($result);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
print "============\n" . $endpoint . "================\n";
print_r($endpoint);
//$endpoint = substr($endpoint,0,-5);
//print "================\n".$endpoint."===================\n";
$link = mysqli_connect($endpoint, "controller", "ilovebunnies", "customerrecords") or die("Error " . mysqli_error($link));
//echo "Here is the result: " . $link;
$sql = "CREATE TABLE comments \n(\nID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\nPosterName VARCHAR(32),\nTitle VARCHAR(32),\nContent VARCHAR(500)\n)";
$link > query($sql);
<?php

session_start();
require 'vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-west-2']);
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'Project1db']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
echo "============\n" . $endpoint . "================";
$link = mysqli_connect($endpoint, "nandini", "nandinipwd", "Project1db") or die("Error " . mysqli_error($link));
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
mkdir("/tmp/Backup");
$path = '/tmp/Backup/';
$bname = uniqid("Bckupname", false);
$append = $bname . '.' . sql;
$BackPath = $path . $append;
echo $BackPath;
$cmd = "mysqldump --user=nandini --password=nandinipwd --host={$endpoint} Project1db > {$BackPath}";
exec($cmd);
$bucketname = uniqid("dbbackupbucket", false);
$s3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-west-2']);
# AWS PHP SDK version 3 create bucket
$result = $s3->createBucket(['ACL' => 'public-read', 'Bucket' => $bucketname]);
# PHP version 3
$result = $s3->putObject(['ACL' => 'public-read', 'Bucket' => $bucketname, 'Key' => $append, 'SourceFile' => $BackPath]);
$objectruledb = $s3->putBucketLifecycleConfiguration(['Bucket' => $bucketname, 'LifecycleConfiguration' => ['Rules' => [['Expiration' => ['Date' => '2015-12-24'], 'Prefix' => ' ', 'Status' => 'Enabled']]]]);
session_destroy();
header("location: gallery.php");
print "</pre>";
require 'vendor/autoload.php';
$s3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-east-1']);
#print_r($s3);
$bucket = uniqid("Sneha", false);
#$result = $s3->createBucket(array(
#    'Bucket' => $bucket
#));
#
## AWS PHP SDK version 3 create bucket
$result = $s3->createBucket(['ACL' => 'public-read', 'Bucket' => $bucket]);
#print_r($result);
$result = $s3->putObject(['ACL' => 'public-read', 'Bucket' => $bucket, 'Key' => $uploadfile, 'ContentType' => $_FILES['userfile']['type'], 'Body' => fopen($uploadfile, 'r+')]);
$url = $result['ObjectURL'];
echo $url;
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1']);
$result = $rds->describeDBInstances(array('DBInstanceIdentifier' => 'db1'));
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
echo "============\n" . $endpoint . "================";
$link = mysqli_connect($endpoint, "testconnection1", "testconnection1", "Project1");
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
} else {
    echo "Success";
}
#create sns client
$sns = new Aws\Sns\SnsClient(['version' => 'latest', 'region' => 'us-east-1']);
#print_r($result);
//echo "sns Topic";
//to list topics
示例#20
0
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);
// Start the session^M
require '/var/www/html/vendor/autoload.php';
$rds = new Aws\Rds\RdsClient(['version' => 'latest', 'region' => 'us-east-1', 'credentials' => ['key' => '', 'secret' => '']]);
$result = $rds->createDBInstance(['AllocatedStorage' => 10, 'DBInstanceClass' => 'db.t1.micro', 'DBInstanceIdentifier' => 'jss-itmo444-db', 'DBName' => 'jsstestdb', 'Engine' => 'MySQL', 'MasterUserPassword' => 'letmein1234', 'MasterUsername' => 'controller', 'PubliclyAccessible' => true]);
print "Create RDS DB results: \n";
# print_r($rds);
$result = $rds->waitUntil('DBInstanceAvailable', ['DBInstanceIdentifier' => 'jss-itmo444-db']);
// Create a table
$result = $rds->describeDBInstances(['DBInstanceIdentifier' => 'jss-itmo444-db']);
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
print "============\n" . $endpoint . "================\n";
$link = mysqli_connect($endpoint, "controller", "letmein1234", "jss-itmo444-db") or die("Error " . mysqli_error($link));
#echo "Here is the result: " . $link;
$sql = "DROP TABLE IF EXISTS jssUserImages";
if (!mysqli_query($link, $sql)) {
    echo "Error : " . mysqli_error($link);
}
$sql = "CREATE TABLE jssUserImages  \n(\nID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\nusername VARCHAR(20),\nuseremail VARCHAR(20),\ntelephone VARCHAR(20),\nraws3url VARCHAR(256),\nfinisheds3url VARCHAR(256),\nfilename VARCHAR(256),\nstate TINYINT(3),\ndatetime timestamp \n)";