<? //Make a connection require_once('/var/www/html/src/php/setup.php'); if(!isset($PDOconn)) $PDOconn = newPDOconn(); //logged in? $domain = CDConsts::getAPIDomain(); session_start(); if(!isset($_SESSION['userID'])) { //No header('Location: '.$domain); return false; } //Make user if(!isset($User)) $User = new User($_SESSION['userID'], $PDOconn); $Viewer = $User; $title = 'Preferences'; $content = '/var/www/html/src/html/preferences.html'; require_once('/var/www/html/src/html/blank.html'); ?>
$fileExt .= $fileName[$i]; } $fileExt = ".".strrev($fileExt); //Create the image require_once('/var/www/html/api/image/obj/Image.php'); $Image = new Image(NULL, $PDOconn); //Generate new filename $Image->ID = $Image->generateUniqueID(); $newFileName = $Image->ID; $newFileNameWithExt = $newFileName.$fileExt; $accessKey = CDConsts::getConst("AWS_ACCESS_KEY", 'charValue', $PDOconn); $secretKey = CDConsts::getConst("AWS_SECRET_KEY", 'charValue', $PDOconn); $client = S3Client::factory(array( 'key' => $accessKey, 'secret' => $secretKey )); //Get the bucket $cdimageBucket; $bucketName = "greatdays"; $result = $client->listBuckets(); foreach ($result['Buckets'] as $bucket) { // Each Bucket value will contain a Name and CreationDate if($bucket['Name'] == $bucketName)
public function delete() { if(!$this->exists) return false; $accessKey = CDConsts::getConst("AWS_ACCESS_KEY", 'charValue', $this->PDOconn); $secretKey = CDConsts::getConst("AWS_SECRET_KEY", 'charValue', $this->PDOconn); $client = S3Client::factory(array( 'key' => $accessKey, 'secret' => $secretKey )); $result = $client->deleteObject(array( 'Bucket' => 'greatdays', 'Key' => "/img/".$this->row['filename'] )); $sql = "DELETE FROM image WHERE objectID=:objectID"; $stmtB = $this->PDOconn->prepare($sql); $paramsB[':objectID'] = $this->ID; $stmtB->execute($paramsB); return true; }