├── .gitignore ├── 99-liip-developer.ini ├── AWSSDKforPHP ├── _compatibility_test │ ├── sdk_compatibility_test.php │ └── sdk_compatibility_test_cli.php ├── _samples │ ├── cli-ec2_sorting_and_filtering.php │ ├── cli-s3_get_urls_for_uploads.php │ └── html-sdb_create_domain_data.php ├── config-sample.inc.php ├── lib │ ├── cachecore │ │ ├── cacheapc.class.php │ │ ├── cachecore.class.php │ │ ├── cachefile.class.php │ │ ├── cachemc.class.php │ │ ├── cachepdo.class.php │ │ ├── cachexcache.class.php │ │ └── icachecore.interface.php │ ├── requestcore │ │ └── requestcore.class.php │ └── yaml │ │ └── lib │ │ ├── sfYaml.php │ │ ├── sfYamlDumper.php │ │ ├── sfYamlInline.php │ │ └── sfYamlParser.php ├── sdk.class.php ├── services │ ├── as.class.php │ ├── cloudformation.class.php │ ├── cloudfront.class.php │ ├── cloudwatch.class.php │ ├── ec2.class.php │ ├── elasticbeanstalk.class.php │ ├── elb.class.php │ ├── emr.class.php │ ├── iam.class.php │ ├── importexport.class.php │ ├── rds.class.php │ ├── s3.class.php │ ├── sdb.class.php │ ├── ses.class.php │ ├── sns.class.php │ └── sqs.class.php └── utilities │ ├── array.class.php │ ├── batchrequest.class.php │ ├── complextype.class.php │ ├── hadoopstep.class.php │ ├── info.class.php │ ├── manifest.class.php │ ├── mimetypes.class.php │ ├── policy.class.php │ ├── request.class.php │ ├── response.class.php │ ├── simplexml.class.php │ ├── stacktemplate.class.php │ ├── stepconfig.class.php │ └── utilities.class.php ├── LICENSE ├── buildAll.sh ├── buildAndUpload.sh ├── config.inc.php-dist ├── create_package.sh ├── getLatestVersions.php ├── index.html.tmpl ├── info.html ├── install.sh ├── install_vendors.sh ├── invalidateCloudfront.php ├── liip.png ├── local.gif ├── update_httpd_conf.sh ├── update_vendors.sh ├── uploadFile.php └── upload_info.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /config.inc.php 2 | /index.html 3 | /index.html.bottom 4 | /packager/ -------------------------------------------------------------------------------- /99-liip-developer.ini: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; This file extends the default php.ini-development shipped with PHP 3 | ; http://svn.php.net/viewvc/php/php-src/trunk/php.ini-development 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 7 | ; adjust those settings as required 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9 | 10 | [liip] 11 | memory_limit = 256M 12 | 13 | ; Liip Zurich 14 | date.timezone = Europe/Zurich 15 | date.default_latitude = 47.38 16 | date.default_longitude = 8.5244 17 | 18 | ; Liip Fribourg 19 | ; date.default_latitude = 46.8042 20 | ; date.default_longitude = 7.1547 21 | 22 | 23 | ; from the manual http://php.net/manual/en/datetime.configuration.php 24 | 25 | ; Lat/Long for SE corner of Parliament Square (near Big Ben/Houses of Parliament): 26 | ; date.timezone = "Europe/London" 27 | ; date.default_latitude = 51.500181 28 | ; date.default_longitude = -0.12619 29 | 30 | ; Berlin center district near "Neptunbrunnen" 31 | ; date.timezone = "Europe/Berlin" 32 | ; date.default_latitude = 52.5194 33 | ; date.default_longitude = 13.4067 34 | 35 | ; date.timezone = "Asia/Shanghai" 36 | ; date.default_latitude = 31.5167 37 | ; date.default_longitude = 121.4500 38 | 39 | 40 | detect_unicode = Off 41 | session.gc_maxlifetime = 14400 42 | error_reporting = E_ALL | E_STRICT 43 | error_log = /var/log/apache2/php_errors.log 44 | mysql.default_socket = /tmp/mysql.sock 45 | 46 | ;disable gc, since it seems to crash ext/intl [chregu, 3.1.2011] 47 | ;enabled it again, let's see if it works better now [chregu, 3.4.2013] 48 | ;zend.enable_gc = off 49 | 50 | ; if you need to create phar files, activate this setting 51 | ; phar.readonly = false 52 | 53 | ; Liip PHP extensions you should have at hand for development 54 | ; apc (available but disabled by default) 55 | ; curl 56 | ; gettext 57 | ; intl 58 | ; mbstring 59 | ; memcache 60 | ; memcached 61 | ; mongodb 62 | ; mssql 63 | ; mysql 64 | ; mysqli 65 | ; mysqlnd 66 | ; OAuth 67 | ; openssl 68 | ; pdo 69 | ; pdo_mysql 70 | ; pdo_pgsql 71 | ; pdo_sqlite 72 | ; pgsql 73 | ; Phar 74 | ; solr 75 | ; tidy 76 | ; xhprof 77 | ; xsl 78 | ; xslcache (available but disabled by default) 79 | ; xdebug 80 | -------------------------------------------------------------------------------- /AWSSDKforPHP/_compatibility_test/sdk_compatibility_test_cli.php: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env php 2 | =')); 6 | $simplexml_ok = extension_loaded('simplexml'); 7 | $json_ok = (extension_loaded('json') && function_exists('json_encode') && function_exists('json_decode')); 8 | $spl_ok = extension_loaded('spl'); 9 | $pcre_ok = extension_loaded('pcre'); 10 | if (function_exists('curl_version')) 11 | { 12 | $curl_version = curl_version(); 13 | $curl_ok = (function_exists('curl_exec') && in_array('https', $curl_version['protocols'], true)); 14 | } 15 | $file_ok = (function_exists('file_get_contents') && function_exists('file_put_contents')); 16 | 17 | // Optional, but recommended 18 | $openssl_ok = (extension_loaded('openssl') && function_exists('openssl_sign')); 19 | $zlib_ok = extension_loaded('zlib'); 20 | 21 | // Optional 22 | $apc_ok = extension_loaded('apc'); 23 | $xcache_ok = extension_loaded('xcache'); 24 | $memcached_ok = extension_loaded('memcached'); 25 | $memcache_ok = extension_loaded('memcache'); 26 | $mc_ok = ($memcache_ok || $memcached_ok); 27 | $pdo_ok = extension_loaded('pdo'); 28 | $pdo_sqlite_ok = extension_loaded('pdo_sqlite'); 29 | $sqlite2_ok = extension_loaded('sqlite'); 30 | $sqlite3_ok = extension_loaded('sqlite3'); 31 | $sqlite_ok = ($pdo_ok && $pdo_sqlite_ok && ($sqlite2_ok || $sqlite3_ok)); 32 | 33 | function success($s = 'Yes') 34 | { 35 | return "\033[1;37m\033[42m " . $s . " \033[0m"; 36 | } 37 | 38 | function failure($s = 'No ') 39 | { 40 | return "\033[1;37m\033[41m " . $s . " \033[0m"; 41 | } 42 | 43 | ///////////////////////////////////////////////////////////////////////// 44 | 45 | echo PHP_EOL; 46 | 47 | echo 'AWS SDK for PHP' . PHP_EOL; 48 | echo 'PHP Environment Compatibility Test (CLI)' . PHP_EOL; 49 | echo '----------------------------------------' . PHP_EOL; 50 | echo PHP_EOL; 51 | 52 | echo 'PHP 5.2 or newer... ' . ($php_ok ? (success() . ' ' . phpversion()) : failure()) . PHP_EOL; 53 | echo 'cURL with SSL... ' . ($curl_ok ? (success() . ' ' . $curl_version['version'] . ' (' . $curl_version['ssl_version'] . ')') : failure($curl_version['version'] . (in_array('https', $curl_version['protocols'], true) ? ' (with ' . $curl_version['ssl_version'] . ')' : ' (without SSL)'))) . PHP_EOL; 54 | echo 'Standard PHP Library... ' . ($spl_ok ? success() : failure()) . PHP_EOL; 55 | echo 'SimpleXML... ' . ($simplexml_ok ? success() : failure()) . PHP_EOL; 56 | echo 'JSON... ' . ($json_ok ? success() : failure()) . PHP_EOL; 57 | echo 'PCRE... ' . ($pcre_ok ? success() : failure()) . PHP_EOL; 58 | echo 'File system read/write... ' . ($file_ok ? success() : failure()) . PHP_EOL; 59 | echo 'OpenSSL extension... ' . ($openssl_ok ? success() : failure()) . PHP_EOL; 60 | echo 'Zlib... ' . ($zlib_ok ? success() : failure()) . PHP_EOL; 61 | echo 'APC... ' . ($apc_ok ? success() : failure()) . PHP_EOL; 62 | echo 'XCache... ' . ($xcache_ok ? success() : failure()) . PHP_EOL; 63 | echo 'Memcache... ' . ($memcache_ok ? success() : failure()) . PHP_EOL; 64 | echo 'Memcached... ' . ($memcached_ok ? success() : failure()) . PHP_EOL; 65 | echo 'PDO... ' . ($pdo_ok ? success() : failure()) . PHP_EOL; 66 | echo 'SQLite 2... ' . ($sqlite2_ok ? success() : failure()) . PHP_EOL; 67 | echo 'SQLite 3... ' . ($sqlite3_ok ? success() : failure()) . PHP_EOL; 68 | echo 'PDO-SQLite driver... ' . ($pdo_sqlite_ok ? success() : failure()) . PHP_EOL; 69 | echo PHP_EOL; 70 | 71 | echo '----------------------------------------' . PHP_EOL; 72 | echo PHP_EOL; 73 | 74 | if ($php_ok && $curl_ok && $simplexml_ok && $spl_ok && $json_ok && $pcre_ok && $file_ok) 75 | { 76 | 77 | echo 'Your environment meets the minimum requirements for using the AWS SDK for PHP!' . PHP_EOL . PHP_EOL; 78 | if ($openssl_ok) { echo '* The OpenSSL extension is installed. This will allow you to use CloudFront Private URLs and decrypt Windows instance passwords.' . PHP_EOL . PHP_EOL; } 79 | if ($zlib_ok) { echo '* The Zlib extension is installed. The SDK will automatically leverage the compression capabilities of Zlib.' . PHP_EOL . PHP_EOL; } 80 | 81 | $storage_types = array(); 82 | if ($file_ok) { $storage_types[] = 'The file system'; } 83 | if ($apc_ok) { $storage_types[] = 'APC'; } 84 | if ($xcache_ok) { $storage_types[] = 'XCache'; } 85 | if ($sqlite_ok && $sqlite3_ok) { $storage_types[] = 'SQLite 3'; } 86 | elseif ($sqlite_ok && $sqlite2_ok) { $storage_types[] = 'SQLite 2'; } 87 | if ($memcached_ok) { $storage_types[] = 'Memcached'; } 88 | elseif ($memcache_ok) { $storage_types[] = 'Memcache'; } 89 | echo '* Storage types available for response caching: ' . implode(', ', $storage_types) . PHP_EOL . PHP_EOL; 90 | 91 | if (!$openssl_ok) { echo '* You\'re missing the OpenSSL extension, which means that you won\'t be able to take advantage of CloudFront Private URLs or Windows password decryption.' . PHP_EOL . PHP_EOL; } 92 | if (!$zlib_ok) { echo '* You\'re missing the Zlib extension, which means that responses from Amazon\'s services will take a little longer to download and you won\'t be able to take advantage of compression with the response caching feature.' . PHP_EOL . PHP_EOL; } 93 | } 94 | else 95 | { 96 | if (!$php_ok) { echo '* PHP: You are running an unsupported version of PHP.' . PHP_EOL . PHP_EOL; } 97 | if (!$curl_ok) { echo '* cURL: The cURL extension is not available. Without cURL, the SDK cannot connect to -- or authenticate with -- Amazon\'s services.' . PHP_EOL . PHP_EOL; } 98 | if (!$simplexml_ok) { echo '* SimpleXML: The SimpleXML extension is not available. Without SimpleXML, the SDK cannot parse the XML responses from Amazon\'s services.' . PHP_EOL . PHP_EOL; } 99 | if (!$spl_ok) { echo '* SPL: Standard PHP Library support is not available. Without SPL support, the SDK cannot autoload the required PHP classes.' . PHP_EOL . PHP_EOL; } 100 | if (!$json_ok) { echo '* JSON: JSON support is not available. AWS leverages JSON heavily in many of its services.' . PHP_EOL . PHP_EOL; } 101 | if (!$pcre_ok) { echo '* PCRE: Your PHP installation doesn\'t support Perl-Compatible Regular Expressions (PCRE). Without PCRE, the SDK cannot do any filtering via regular expressions.' . PHP_EOL . PHP_EOL; } 102 | if (!$file_ok) { echo '* File System Read/Write: The file_get_contents() and/or file_put_contents() functions have been disabled. Without them, the SDK cannot read from, or write to, the file system.' . PHP_EOL . PHP_EOL; } 103 | } 104 | 105 | echo '----------------------------------------' . PHP_EOL; 106 | echo PHP_EOL; 107 | 108 | if ($php_ok && $curl_ok && $simplexml_ok && $spl_ok && $json_ok && $pcre_ok && $file_ok && $openssl_ok && $zlib_ok && ($apc_ok || $xcache_ok || $mc_ok || $sqlite_ok)) 109 | { 110 | echo 'Bottom Line: Yes, you can!' . PHP_EOL; 111 | echo 'Your PHP environment is ready to go, and can take advantage of all possible features!' . PHP_EOL; 112 | } 113 | elseif ($php_ok && $curl_ok && $simplexml_ok && $spl_ok && $json_ok && $pcre_ok && $file_ok) 114 | { 115 | echo 'Bottom Line: Yes, you can!' . PHP_EOL; 116 | echo 'Your PHP environment is ready to go! There are a couple of minor features that you won\'t be able to take advantage of, but nothing that\'s a show-stopper.' . PHP_EOL; 117 | } 118 | else 119 | { 120 | echo 'Bottom Line: We\'re sorry...' . PHP_EOL; 121 | echo 'Your PHP environment does not support the minimum requirements for the AWS SDK for PHP.' . PHP_EOL; 122 | } 123 | 124 | echo PHP_EOL; 125 | ?> 126 | -------------------------------------------------------------------------------- /AWSSDKforPHP/_samples/cli-ec2_sorting_and_filtering.php: -------------------------------------------------------------------------------- 1 | . 23 | 24 | * You already understand the fundamentals of object-oriented PHP. 25 | 26 | * You've verified that your PHP environment passes the SDK Compatibility Test. 27 | 28 | * You've already added your credentials to your config.inc.php file, as per the 29 | instructions in the Getting Started Guide. 30 | 31 | TO RUN: 32 | * Run this file on your web server by loading it in your browser, OR... 33 | * Run this file from the command line with `php cli-ec2_sorting_and_filtering.php`. 34 | */ 35 | 36 | 37 | /*%******************************************************************************************%*/ 38 | // SETUP 39 | 40 | // Enable full-blown error reporting. http://twitter.com/rasmus/status/7448448829 41 | error_reporting(-1); 42 | 43 | // Set HTML headers 44 | header("Content-type: text/html; charset=utf-8"); 45 | 46 | // Include the SDK 47 | require_once '../sdk.class.php'; 48 | 49 | 50 | /*%******************************************************************************************%*/ 51 | // THE GOALS & PREPARATION 52 | 53 | /* 54 | 1. The goal of this exercise is to retrieve a list of all image IDs that are prefixed with "aki-". 55 | 2. We should end up with an indexed array of string values (just the image IDs). 56 | */ 57 | 58 | // Instantiate the AmazonEC2 class 59 | $ec2 = new AmazonEC2(); 60 | 61 | // Get the response from a call to the DescribeImages operation. 62 | $response = $ec2->describe_images(); 63 | 64 | 65 | /*%******************************************************************************************%*/ 66 | // THE LONG WAY 67 | 68 | // Prepare to collect AKIs. 69 | $akis = array(); 70 | 71 | // Loop through the response... 72 | foreach ($response->body->imagesSet->item as $item) 73 | { 74 | // Stringify the value 75 | $image_id = (string) $item->imageId; 76 | 77 | // Filter the value against a PCRE regular expression. 78 | if (preg_match('/aki/i', $image_id)) 79 | { 80 | // If the name matches our pattern, add it to the list. 81 | $akis[] = $image_id; 82 | } 83 | } 84 | 85 | // Display 86 | print_r($akis); 87 | 88 | 89 | /*%******************************************************************************************%*/ 90 | // THE SHORT WAY 91 | 92 | // Look through the body, grab ALL nodes, stringify the values, and filter them with the 93 | // PCRE regular expression. 94 | $akis = $response->body->imageId()->map_string('/aki/i'); 95 | 96 | // Display 97 | print_r($akis); 98 | -------------------------------------------------------------------------------- /AWSSDKforPHP/_samples/cli-s3_get_urls_for_uploads.php: -------------------------------------------------------------------------------- 1 | . 23 | 24 | * You already understand the fundamentals of object-oriented PHP. 25 | 26 | * You've verified that your PHP environment passes the SDK Compatibility Test. 27 | 28 | * You've already added your credentials to your config.inc.php file, as per the 29 | instructions in the Getting Started Guide. 30 | 31 | TO RUN: 32 | * Run this file on your web server by loading it in your browser, OR... 33 | * Run this file from the command line with `php cli-s3_get_urls_for_uploads.php`. 34 | */ 35 | 36 | 37 | /*%******************************************************************************************%*/ 38 | // SETUP 39 | 40 | // Enable full-blown error reporting. http://twitter.com/rasmus/status/7448448829 41 | error_reporting(-1); 42 | 43 | // Set plain text headers 44 | header("Content-type: text/plain; charset=utf-8"); 45 | 46 | // Include the SDK 47 | require_once '../sdk.class.php'; 48 | 49 | 50 | /*%******************************************************************************************%*/ 51 | // UPLOAD FILES TO S3 52 | 53 | // Instantiate the AmazonS3 class 54 | $s3 = new AmazonS3(); 55 | 56 | // Determine a completely unique bucket name (all lowercase) 57 | $bucket = 'php-sdk-getting-started-' . strtolower($s3->key) . '-' . time(); 58 | 59 | // Create our new bucket in the US-West region. 60 | $create_bucket_response = $s3->create_bucket($bucket, AmazonS3::REGION_US_W1); 61 | 62 | // Provided that the bucket was created successfully... 63 | if ($create_bucket_response->isOK()) 64 | { 65 | /* Since AWS follows an "eventual consistency" model, sleep and poll 66 | until the bucket is available. */ 67 | $exists = $s3->if_bucket_exists($bucket); 68 | while (!$exists) 69 | { 70 | // Not yet? Sleep for 1 second, then check again 71 | sleep(1); 72 | $exists = $s3->if_bucket_exists($bucket); 73 | } 74 | 75 | /* 76 | Get a list of files to upload. We'll use some helper functions we've 77 | defined below. This assumes that you have a directory called "test_files" 78 | that actually contains some files you want to upload. 79 | */ 80 | $list_of_files = filter_file_list(glob('./test_files/*')); 81 | 82 | // Prepare to hold the individual filenames 83 | $individual_filenames = array(); 84 | 85 | // Loop over the list, referring to a single file at a time 86 | foreach ($list_of_files as $file) 87 | { 88 | // Grab only the filename part of the path 89 | $filename = explode(DIRECTORY_SEPARATOR, $file); 90 | $filename = array_pop($filename); 91 | 92 | // Store the filename for later use 93 | $individual_filenames[] = $filename; 94 | 95 | /* Prepare to upload the file to our new S3 bucket. Add this 96 | request to a queue that we won't execute quite yet. */ 97 | $s3->batch()->create_object($bucket, $filename, array( 98 | 'fileUpload' => $file 99 | )); 100 | } 101 | 102 | /* Execute our queue of batched requests. This may take a few seconds to a 103 | few minutes depending on the size of the files and how fast your upload 104 | speeds are. */ 105 | $file_upload_response = $s3->batch()->send(); 106 | 107 | /* Since a batch of requests will return multiple responses, let's 108 | make sure they ALL came back successfully using `areOK()` (singular 109 | responses use `isOK()`). */ 110 | if ($file_upload_response->areOK()) 111 | { 112 | // Loop through the individual filenames 113 | foreach ($individual_filenames as $filename) 114 | { 115 | /* Display a URL for each of the files we uploaded. Since uploads default to 116 | private (you can choose to override this setting when uploading), we'll 117 | pre-authenticate the file URL for the next 5 minutes. */ 118 | echo $s3->get_object_url($bucket, $filename, '5 minutes') . PHP_EOL . PHP_EOL; 119 | } 120 | } 121 | } 122 | 123 | 124 | /*%******************************************************************************************%*/ 125 | // HELPER FUNCTIONS 126 | 127 | // Filters the list for only files 128 | function filter_file_list($arr) 129 | { 130 | return array_values(array_filter(array_map('file_path', $arr))); 131 | } 132 | 133 | // Callback used by filter_file_list() 134 | function file_path($file) 135 | { 136 | return !is_dir($file) ? realpath($file) : null; 137 | } 138 | -------------------------------------------------------------------------------- /AWSSDKforPHP/_samples/html-sdb_create_domain_data.php: -------------------------------------------------------------------------------- 1 | . 23 | 24 | * You already understand the fundamentals of object-oriented PHP. 25 | 26 | * You've verified that your PHP environment passes the SDK Compatibility Test. 27 | 28 | * You've already added your credentials to your config.inc.php file, as per the 29 | instructions in the Getting Started Guide. 30 | 31 | TO RUN: 32 | * Run this file on your web server by loading it in your browser. It will generate HTML output. 33 | */ 34 | 35 | 36 | /*%******************************************************************************************%*/ 37 | // SETUP 38 | 39 | // Enable full-blown error reporting. http://twitter.com/rasmus/status/7448448829 40 | error_reporting(-1); 41 | 42 | // Set HTML headers 43 | header("Content-type: text/html; charset=utf-8"); 44 | 45 | // Include the SDK 46 | require_once '../sdk.class.php'; 47 | 48 | 49 | /*%******************************************************************************************%*/ 50 | // ADD DATA TO SIMPLEDB 51 | 52 | // Instantiate the AmazonSDB class 53 | $sdb = new AmazonSDB(); 54 | 55 | // Store the name of the domain 56 | $domain = 'php-sdk-getting-started'; 57 | 58 | // Create the domain 59 | $new_domain = $sdb->create_domain($domain); 60 | 61 | // Was the domain created successfully? 62 | if ($new_domain->isOK()) 63 | { 64 | // Add a batch of item-key-values to your domain 65 | $add_attributes = $sdb->batch_put_attributes($domain, array( 66 | 'Item_01' => array( 67 | 'Category' => 'Clothes', 68 | 'Subcategory' => 'Sweater', 69 | 'Name' => 'Cathair Sweater', 70 | 'Color' => 'Siamese', 71 | 'Size' => array('Small', 'Medium', 'Large') 72 | ), 73 | 'Item_02' => array( 74 | 'Category' => 'Clothes', 75 | 'Subcategory' => 'Pants', 76 | 'Name' => 'Designer Jeans', 77 | 'Color' => 'Paisley Acid Wash', 78 | 'Size' => array('30x32', '32x32', '32x34') 79 | ), 80 | 'Item_03' => array( 81 | 'Category' => 'Clothes', 82 | 'Subcategory' => 'Pants', 83 | 'Name' => 'Sweatpants', 84 | 'Color' => array('Blue', 'Yellow', 'Pink'), 85 | 'Size' => 'Large', 86 | 'Year' => array('2006', '2007') 87 | ), 88 | 'Item_04' => array( 89 | 'Category' => 'Car Parts', 90 | 'Subcategory' => 'Engine', 91 | 'Name' => 'Turbos', 92 | 'Make' => 'Audi', 93 | 'Model' => 'S4', 94 | 'Year' => array('2000', '2001', '2002') 95 | ), 96 | 'Item_05' => array( 97 | 'Category' => 'Car Parts', 98 | 'Subcategory' => 'Emissions', 99 | 'Name' => 'O2 Sensor', 100 | 'Make' => 'Audi', 101 | 'Model' => 'S4', 102 | 'Year' => array('2000', '2001', '2002') 103 | ), 104 | )); 105 | 106 | // Were the attributes added successfully? 107 | if ($add_attributes->isOK()) 108 | { 109 | // Add an additional size to Item_01 110 | $append_attributes = $sdb->put_attributes($domain, 'Item_01', array( 111 | 'Size' => 'Extra Large' 112 | )); 113 | 114 | // Were the new attributes appended successfully? 115 | if ($append_attributes->isOK()) 116 | { 117 | // Use a SELECT expression to query the data. 118 | // Notice the use of backticks around the domain name. 119 | $results = $sdb->select("SELECT * FROM `{$domain}` WHERE Category = 'Clothes'"); 120 | 121 | // Get all of the nodes in the response 122 | $items = $results->body->Item(); 123 | 124 | // Re-structure the data so access is easier (see helper function below) 125 | $data = reorganize_data($items); 126 | 127 | // Generate HTML from the data (see helper function below) 128 | $html = generate_html_table($data); 129 | } 130 | } 131 | } 132 | 133 | 134 | /*%******************************************************************************************%*/ 135 | // HELPER FUNCTIONS 136 | 137 | function reorganize_data($items) 138 | { 139 | // Collect rows and columns 140 | $rows = array(); 141 | $columns = array(); 142 | 143 | // Loop through each of the items 144 | foreach ($items as $item) 145 | { 146 | // Let's append to a new row 147 | $row = array(); 148 | $row['id'] = (string) $item->Name; 149 | 150 | // Loop through the item's attributes 151 | foreach ($item->Attribute as $attribute) 152 | { 153 | // Store the column name 154 | $column_name = (string) $attribute->Name; 155 | 156 | // If it doesn't exist yet, create it. 157 | if (!isset($row[$column_name])) 158 | { 159 | $row[$column_name] = array(); 160 | } 161 | 162 | // Append the new value to any existing values 163 | // (Remember: Entries can have multiple values) 164 | $row[$column_name][] = (string) $attribute->Value; 165 | natcasesort($row[$column_name]); 166 | 167 | // If we've not yet collected this column name, add it. 168 | if (!in_array($column_name, $columns, true)) 169 | { 170 | $columns[] = $column_name; 171 | } 172 | } 173 | 174 | // Append the row we created to the list of rows 175 | $rows[] = $row; 176 | } 177 | 178 | // Return both 179 | return array( 180 | 'columns' => $columns, 181 | 'rows' => $rows, 182 | ); 183 | } 184 | 185 | function generate_html_table($data) 186 | { 187 | // Retrieve row/column data 188 | $columns = $data['columns']; 189 | $rows = $data['rows']; 190 | 191 | // Generate shell of HTML table 192 | $output = '
' . PHP_EOL; 193 | $output .= ''; 194 | $output .= ''; 195 | $output .= ''; // Corner of the table headers 196 | 197 | // Add the table headers 198 | foreach ($columns as $column) 199 | { 200 | $output .= ''; 201 | } 202 | 203 | // Finish the tag 204 | $output .= ''; 205 | $output .= '' . PHP_EOL; 206 | $output .= ''; 207 | 208 | // Loop through the rows 209 | foreach ($rows as $row) 210 | { 211 | // Display the item name as a header 212 | $output .= '' . PHP_EOL; 213 | $output .= ''; 214 | 215 | // Pull out the data, in column order 216 | foreach ($columns as $column) 217 | { 218 | // If we have a value, concatenate the values into a string. Otherwise, nothing. 219 | $output .= ''; 220 | } 221 | 222 | $output .= '' . PHP_EOL; 223 | } 224 | 225 | // Close out our table 226 | $output .= ''; 227 | $output .= '
' . $column . '
' . $row['id'] . '' . (isset($row[$column]) ? implode(', ', $row[$column]) : '') . '
'; 228 | 229 | return $output; 230 | } 231 | 232 | 233 | ?> 234 | 235 | 236 | 237 | sdb_create_domain_data 238 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | -------------------------------------------------------------------------------- /AWSSDKforPHP/config-sample.inc.php: -------------------------------------------------------------------------------- 1 | . 53 | */ 54 | define('AWS_CLOUDFRONT_KEYPAIR_ID', ''); 55 | 56 | /** 57 | * The contents of the *.pem private key that matches with the CloudFront key-pair ID. Found in the AWS 58 | * Security Credentials. This can be set programmatically with . 59 | */ 60 | define('AWS_CLOUDFRONT_PRIVATE_KEY_PEM', ''); 61 | 62 | /** 63 | * Set the value to true to enable autoloading for classes not prefixed with "Amazon" or "CF". If enabled, 64 | * load `sdk.class.php` last to avoid clobbering any other autoloaders. 65 | */ 66 | define('AWS_ENABLE_EXTENSIONS', 'false'); 67 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/cachecore/cacheapc.class.php: -------------------------------------------------------------------------------- 1 | . Adheres 4 | * to the ICacheCore interface. 5 | * 6 | * @version 2009.10.10 7 | * @copyright 2006-2010 Ryan Parman 8 | * @copyright 2006-2010 Foleeo, Inc. 9 | * @copyright 2008-2010 Contributors 10 | * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License 11 | * @link http://github.com/skyzyx/cachecore CacheCore 12 | * @link http://getcloudfusion.com CloudFusion 13 | * @link http://php.net/apc APC 14 | */ 15 | class CacheAPC extends CacheCore implements ICacheCore 16 | { 17 | 18 | /*%******************************************************************************************%*/ 19 | // CONSTRUCTOR 20 | 21 | /** 22 | * Constructs a new instance of this class. 23 | * 24 | * @param string $name (Required) A name to uniquely identify the cache object. 25 | * @param string $location (Required) The location to store the cache object in. This may vary by cache method. 26 | * @param integer $expires (Required) The number of seconds until a cache object is considered stale. 27 | * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true. 28 | * @return object Reference to the cache object. 29 | */ 30 | public function __construct($name, $location, $expires, $gzip = true) 31 | { 32 | parent::__construct($name, null, $expires, $gzip); 33 | $this->id = $this->name; 34 | } 35 | 36 | /** 37 | * Creates a new cache. 38 | * 39 | * @param mixed $data (Required) The data to cache. 40 | * @return boolean Whether the operation was successful. 41 | */ 42 | public function create($data) 43 | { 44 | $data = serialize($data); 45 | $data = $this->gzip ? gzcompress($data) : $data; 46 | 47 | return apc_add($this->id, $data, $this->expires); 48 | } 49 | 50 | /** 51 | * Reads a cache. 52 | * 53 | * @return mixed Either the content of the cache object, or boolean `false`. 54 | */ 55 | public function read() 56 | { 57 | if ($data = apc_fetch($this->id)) 58 | { 59 | $data = $this->gzip ? gzuncompress($data) : $data; 60 | return unserialize($data); 61 | } 62 | 63 | return false; 64 | } 65 | 66 | /** 67 | * Updates an existing cache. 68 | * 69 | * @param mixed $data (Required) The data to cache. 70 | * @return boolean Whether the operation was successful. 71 | */ 72 | public function update($data) 73 | { 74 | $data = serialize($data); 75 | $data = $this->gzip ? gzcompress($data) : $data; 76 | 77 | return apc_store($this->id, $data, $this->expires); 78 | } 79 | 80 | /** 81 | * Deletes a cache. 82 | * 83 | * @return boolean Whether the operation was successful. 84 | */ 85 | public function delete() 86 | { 87 | return apc_delete($this->id); 88 | } 89 | 90 | /** 91 | * Implemented here, but always returns `false`. APC manages its own expirations. 92 | * 93 | * @return boolean Whether the cache is expired or not. 94 | */ 95 | public function is_expired() 96 | { 97 | return false; 98 | } 99 | 100 | /** 101 | * Implemented here, but always returns `false`. APC manages its own expirations. 102 | * 103 | * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. 104 | */ 105 | public function timestamp() 106 | { 107 | return false; 108 | } 109 | 110 | /** 111 | * Implemented here, but always returns `false`. APC manages its own expirations. 112 | * 113 | * @return boolean Whether the operation was successful. 114 | */ 115 | public function reset() 116 | { 117 | return false; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/cachecore/cachecore.class.php: -------------------------------------------------------------------------------- 1 | name = $name; 67 | $this->location = $location; 68 | $this->expires = $expires; 69 | $this->gzip = $gzip; 70 | 71 | return $this; 72 | } 73 | 74 | /** 75 | * Allows for chaining from the constructor. Requires PHP 5.3 or newer. 76 | * 77 | * @param string $name (Required) A name to uniquely identify the cache object. 78 | * @param string $location (Required) The location to store the cache object in. This may vary by cache method. 79 | * @param integer $expires (Required) The number of seconds until a cache object is considered stale. 80 | * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true. 81 | * @return object Reference to the cache object. 82 | */ 83 | public static function init($name, $location, $expires, $gzip = true) 84 | { 85 | if (version_compare(PHP_VERSION, '5.3.0', '<')) 86 | { 87 | throw new Exception('PHP 5.3 or newer is required to use CacheCore::init().'); 88 | } 89 | 90 | $self = get_called_class(); 91 | return new $self($name, $location, $expires, $gzip); 92 | } 93 | 94 | /** 95 | * Provides a simple, straightforward cache-logic mechanism. Useful for non-complex response caches. 96 | * 97 | * @param string|function $callback (Required) The name of the function to fire when we need to fetch new data to cache. 98 | * @param array params (Optional) Parameters to pass into the callback function, as an array. 99 | * @return array The cached data being requested. 100 | */ 101 | public function response_manager($callback, $params = null) 102 | { 103 | // Automatically handle $params values. 104 | $params = is_array($params) ? $params : array($params); 105 | 106 | if ($data = $this->read()) 107 | { 108 | if ($this->is_expired()) 109 | { 110 | if ($data = call_user_func_array($callback, $params)) 111 | { 112 | $this->update($data); 113 | } 114 | else 115 | { 116 | $this->reset(); 117 | $data = $this->read(); 118 | } 119 | } 120 | } 121 | else 122 | { 123 | if ($data = call_user_func_array($callback, $params)) 124 | { 125 | $this->create($data); 126 | } 127 | } 128 | 129 | return $data; 130 | } 131 | } 132 | 133 | 134 | /*%******************************************************************************************%*/ 135 | // CORE DEPENDENCIES 136 | 137 | // Include the ICacheCore interface. 138 | if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'icachecore.interface.php')) 139 | { 140 | include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'icachecore.interface.php'; 141 | } 142 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/cachecore/cachefile.class.php: -------------------------------------------------------------------------------- 1 | . Adheres 4 | * to the ICacheCore interface. 5 | * 6 | * @version 2009.10.10 7 | * @copyright 2006-2010 Ryan Parman 8 | * @copyright 2006-2010 Foleeo, Inc. 9 | * @copyright 2008-2010 Contributors 10 | * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License 11 | * @link http://github.com/skyzyx/cachecore CacheCore 12 | * @link http://getcloudfusion.com CloudFusion 13 | */ 14 | class CacheFile extends CacheCore implements ICacheCore 15 | { 16 | 17 | /*%******************************************************************************************%*/ 18 | // CONSTRUCTOR 19 | 20 | /** 21 | * Constructs a new instance of this class. 22 | * 23 | * @param string $name (Required) A name to uniquely identify the cache object. 24 | * @param string $location (Required) The location to store the cache object in. This may vary by cache method. 25 | * @param integer $expires (Required) The number of seconds until a cache object is considered stale. 26 | * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true. 27 | * @return object Reference to the cache object. 28 | */ 29 | public function __construct($name, $location, $expires, $gzip = true) 30 | { 31 | parent::__construct($name, $location, $expires, $gzip); 32 | $this->id = $this->location . '/' . $this->name . '.cache'; 33 | } 34 | 35 | /** 36 | * Creates a new cache. 37 | * 38 | * @param mixed $data (Required) The data to cache. 39 | * @return boolean Whether the operation was successful. 40 | */ 41 | public function create($data) 42 | { 43 | if (file_exists($this->id)) 44 | { 45 | return false; 46 | } 47 | elseif (file_exists($this->location) && is_writeable($this->location)) 48 | { 49 | $data = serialize($data); 50 | $data = $this->gzip ? gzcompress($data) : $data; 51 | 52 | return (bool) file_put_contents($this->id, $data); 53 | } 54 | 55 | return false; 56 | } 57 | 58 | /** 59 | * Reads a cache. 60 | * 61 | * @return mixed Either the content of the cache object, or boolean `false`. 62 | */ 63 | public function read() 64 | { 65 | if (file_exists($this->id) && is_readable($this->id)) 66 | { 67 | $data = file_get_contents($this->id); 68 | $data = $this->gzip ? gzuncompress($data) : $data; 69 | $data = unserialize($data); 70 | 71 | if ($data === false) 72 | { 73 | /* 74 | This should only happen when someone changes the gzip settings and there is 75 | existing data or someone has been mucking about in the cache folder manually. 76 | Delete the bad entry since the file cache doesn't clean up after itself and 77 | then return false so fresh data will be retrieved. 78 | */ 79 | $this->delete(); 80 | return false; 81 | } 82 | 83 | return $data; 84 | } 85 | 86 | return false; 87 | } 88 | 89 | /** 90 | * Updates an existing cache. 91 | * 92 | * @param mixed $data (Required) The data to cache. 93 | * @return boolean Whether the operation was successful. 94 | */ 95 | public function update($data) 96 | { 97 | if (file_exists($this->id) && is_writeable($this->id)) 98 | { 99 | $data = serialize($data); 100 | $data = $this->gzip ? gzcompress($data) : $data; 101 | 102 | return (bool) file_put_contents($this->id, $data); 103 | } 104 | 105 | return false; 106 | } 107 | 108 | /** 109 | * Deletes a cache. 110 | * 111 | * @return boolean Whether the operation was successful. 112 | */ 113 | public function delete() 114 | { 115 | if (file_exists($this->id)) 116 | { 117 | return unlink($this->id); 118 | } 119 | 120 | return false; 121 | } 122 | 123 | /** 124 | * Checks whether the cache object is expired or not. 125 | * 126 | * @return boolean Whether the cache is expired or not. 127 | */ 128 | public function is_expired() 129 | { 130 | if ($this->timestamp() + $this->expires < time()) 131 | { 132 | return true; 133 | } 134 | 135 | return false; 136 | } 137 | 138 | /** 139 | * Retrieves the timestamp of the cache. 140 | * 141 | * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. 142 | */ 143 | public function timestamp() 144 | { 145 | clearstatcache(); 146 | 147 | if (file_exists($this->id)) 148 | { 149 | $this->timestamp = filemtime($this->id); 150 | return $this->timestamp; 151 | } 152 | 153 | return false; 154 | } 155 | 156 | /** 157 | * Resets the freshness of the cache. 158 | * 159 | * @return boolean Whether the operation was successful. 160 | */ 161 | public function reset() 162 | { 163 | if (file_exists($this->id)) 164 | { 165 | return touch($this->id); 166 | } 167 | 168 | return false; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/cachecore/cachemc.class.php: -------------------------------------------------------------------------------- 1 | . Adheres 4 | * to the ICacheCore interface. 5 | * 6 | * @version 2010.05.17 7 | * @copyright 2006-2010 Ryan Parman 8 | * @copyright 2006-2010 Foleeo, Inc. 9 | * @copyright 2008-2010 Contributors 10 | * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License 11 | * @link http://github.com/skyzyx/cachecore CacheCore 12 | * @link http://getcloudfusion.com CloudFusion 13 | * @link http://php.net/memcache Memcache 14 | * @link http://php.net/memcached Memcached 15 | */ 16 | class CacheMC extends CacheCore implements ICacheCore 17 | { 18 | /** 19 | * Holds the Memcache object. 20 | */ 21 | var $memcache = null; 22 | 23 | /** 24 | * Whether the Memcached extension is being used (as opposed to Memcache). 25 | */ 26 | var $is_memcached = false; 27 | 28 | 29 | /*%******************************************************************************************%*/ 30 | // CONSTRUCTOR 31 | 32 | /** 33 | * Constructs a new instance of this class. 34 | * 35 | * @param string $name (Required) A name to uniquely identify the cache object. 36 | * @param string $location (Required) The location to store the cache object in. This may vary by cache method. 37 | * @param integer $expires (Required) The number of seconds until a cache object is considered stale. 38 | * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true. 39 | * @return object Reference to the cache object. 40 | */ 41 | public function __construct($name, $location, $expires, $gzip = true) 42 | { 43 | parent::__construct($name, null, $expires, $gzip); 44 | $this->id = $this->name; 45 | 46 | // Prefer Memcached over Memcache. 47 | if (class_exists('Memcached')) 48 | { 49 | $this->memcache = new Memcached(); 50 | $this->is_memcached = true; 51 | } 52 | elseif (class_exists('Memcache')) 53 | { 54 | $this->memcache = new Memcache(); 55 | } 56 | else 57 | { 58 | return false; 59 | } 60 | 61 | // Enable compression, if available 62 | if ($this->gzip) 63 | { 64 | if ($this->is_memcached) 65 | { 66 | $this->memcache->setOption(Memcached::OPT_COMPRESSION, true); 67 | } 68 | else 69 | { 70 | $this->gzip = MEMCACHE_COMPRESSED; 71 | } 72 | } 73 | 74 | // Process Memcached servers. 75 | if (isset($location) && sizeof($location) > 0) 76 | { 77 | foreach ($location as $loc) 78 | { 79 | if (isset($loc['port']) && !empty($loc['port'])) 80 | { 81 | $this->memcache->addServer($loc['host'], $loc['port']); 82 | } 83 | else 84 | { 85 | $this->memcache->addServer($loc['host'], 11211); 86 | } 87 | } 88 | } 89 | 90 | return $this; 91 | } 92 | 93 | /** 94 | * Creates a new cache. 95 | * 96 | * @param mixed $data (Required) The data to cache. 97 | * @return boolean Whether the operation was successful. 98 | */ 99 | public function create($data) 100 | { 101 | if ($this->is_memcached) 102 | { 103 | return $this->memcache->set($this->id, $data, $this->expires); 104 | } 105 | return $this->memcache->set($this->id, $data, $this->gzip, $this->expires); 106 | } 107 | 108 | /** 109 | * Reads a cache. 110 | * 111 | * @return mixed Either the content of the cache object, or boolean `false`. 112 | */ 113 | public function read() 114 | { 115 | if ($this->is_memcached) 116 | { 117 | return $this->memcache->get($this->id); 118 | } 119 | return $this->memcache->get($this->id, $this->gzip); 120 | } 121 | 122 | /** 123 | * Updates an existing cache. 124 | * 125 | * @param mixed $data (Required) The data to cache. 126 | * @return boolean Whether the operation was successful. 127 | */ 128 | public function update($data) 129 | { 130 | if ($this->is_memcached) 131 | { 132 | return $this->memcache->replace($this->id, $data, $this->expires); 133 | } 134 | return $this->memcache->replace($this->id, $data, $this->gzip, $this->expires); 135 | } 136 | 137 | /** 138 | * Deletes a cache. 139 | * 140 | * @return boolean Whether the operation was successful. 141 | */ 142 | public function delete() 143 | { 144 | return $this->memcache->delete($this->id); 145 | } 146 | 147 | /** 148 | * Implemented here, but always returns `false`. Memcache manages its own expirations. 149 | * 150 | * @return boolean Whether the cache is expired or not. 151 | */ 152 | public function is_expired() 153 | { 154 | return false; 155 | } 156 | 157 | /** 158 | * Implemented here, but always returns `false`. Memcache manages its own expirations. 159 | * 160 | * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. 161 | */ 162 | public function timestamp() 163 | { 164 | return false; 165 | } 166 | 167 | /** 168 | * Implemented here, but always returns `false`. Memcache manages its own expirations. 169 | * 170 | * @return boolean Whether the operation was successful. 171 | */ 172 | public function reset() 173 | { 174 | return false; 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/cachecore/cachepdo.class.php: -------------------------------------------------------------------------------- 1 | . Adheres 4 | * to the ICacheCore interface. 5 | * 6 | * @version 2009.10.10 7 | * @copyright 2006-2010 Ryan Parman 8 | * @copyright 2006-2010 Foleeo, Inc. 9 | * @copyright 2008-2010 Contributors 10 | * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License 11 | * @link http://github.com/skyzyx/cachecore CacheCore 12 | * @link http://getcloudfusion.com CloudFusion 13 | * @link http://php.net/pdo PDO 14 | */ 15 | class CachePDO extends CacheCore implements ICacheCore 16 | { 17 | /** 18 | * Reference to the PDO connection object. 19 | */ 20 | var $pdo = null; 21 | 22 | /** 23 | * Holds the parsed URL components. 24 | */ 25 | var $dsn = null; 26 | 27 | /** 28 | * Holds the PDO-friendly version of the connection string. 29 | */ 30 | var $dsn_string = null; 31 | 32 | /** 33 | * Holds the prepared statement for creating an entry. 34 | */ 35 | var $create = null; 36 | 37 | /** 38 | * Holds the prepared statement for reading an entry. 39 | */ 40 | var $read = null; 41 | 42 | /** 43 | * Holds the prepared statement for updating an entry. 44 | */ 45 | var $update = null; 46 | 47 | /** 48 | * Holds the prepared statement for resetting the expiry of an entry. 49 | */ 50 | var $reset = null; 51 | 52 | /** 53 | * Holds the prepared statement for deleting an entry. 54 | */ 55 | var $delete = null; 56 | 57 | /** 58 | * Holds the response of the read so we only need to fetch it once instead of doing 59 | * multiple queries. 60 | */ 61 | var $store_read = null; 62 | 63 | 64 | /*%******************************************************************************************%*/ 65 | // CONSTRUCTOR 66 | 67 | /** 68 | * Constructs a new instance of this class. 69 | * 70 | * Tested with [MySQL 5.0.x](http://mysql.com), [PostgreSQL](http://postgresql.com), and 71 | * [SQLite 3.x](http://sqlite.org). SQLite 2.x is assumed to work. No other PDO-supported databases have 72 | * been tested (e.g. Oracle, Microsoft SQL Server, IBM DB2, ODBC, Sybase, Firebird). Feel free to send 73 | * patches for additional database support. 74 | * 75 | * See for more information. 76 | * 77 | * @param string $name (Required) A name to uniquely identify the cache object. 78 | * @param string $location (Required) The location to store the cache object in. This may vary by cache method. 79 | * @param integer $expires (Required) The number of seconds until a cache object is considered stale. 80 | * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true. 81 | * @return object Reference to the cache object. 82 | */ 83 | public function __construct($name, $location, $expires, $gzip = true) 84 | { 85 | // Make sure the name is no longer than 40 characters. 86 | $name = sha1($name); 87 | 88 | // Call parent constructor and set id. 89 | parent::__construct($name, $location, $expires, $gzip); 90 | $this->id = $this->name; 91 | $options = array(); 92 | 93 | // Check if the location contains :// (e.g. mysql://user:pass@hostname:port/table) 94 | if (stripos($location, '://') === false) 95 | { 96 | // No? Just pass it through. 97 | $this->dsn = parse_url($location); 98 | $this->dsn_string = $location; 99 | } 100 | else 101 | { 102 | // Yes? Parse and set the DSN 103 | $this->dsn = parse_url($location); 104 | $this->dsn_string = $this->dsn['scheme'] . ':host=' . $this->dsn['host'] . ((isset($this->dsn['port'])) ? ';port=' . $this->dsn['port'] : '') . ';dbname=' . substr($this->dsn['path'], 1); 105 | } 106 | 107 | // Make sure that user/pass are defined. 108 | $user = isset($this->dsn['user']) ? $this->dsn['user'] : null; 109 | $pass = isset($this->dsn['pass']) ? $this->dsn['pass'] : null; 110 | 111 | // Set persistence for databases that support it. 112 | switch ($this->dsn['scheme']) 113 | { 114 | case 'mysql': // MySQL 115 | case 'pgsql': // PostgreSQL 116 | $options[PDO::ATTR_PERSISTENT] = true; 117 | break; 118 | } 119 | 120 | // Instantiate a new PDO object with a persistent connection. 121 | $this->pdo = new PDO($this->dsn_string, $user, $pass, $options); 122 | 123 | // Define prepared statements for improved performance. 124 | $this->create = $this->pdo->prepare("INSERT INTO cache (id, expires, data) VALUES (:id, :expires, :data)"); 125 | $this->read = $this->pdo->prepare("SELECT id, expires, data FROM cache WHERE id = :id"); 126 | $this->reset = $this->pdo->prepare("UPDATE cache SET expires = :expires WHERE id = :id"); 127 | $this->delete = $this->pdo->prepare("DELETE FROM cache WHERE id = :id"); 128 | } 129 | 130 | /** 131 | * Creates a new cache. 132 | * 133 | * @param mixed $data (Required) The data to cache. 134 | * @return boolean Whether the operation was successful. 135 | */ 136 | public function create($data) 137 | { 138 | $data = serialize($data); 139 | $data = $this->gzip ? gzcompress($data) : $data; 140 | 141 | $this->create->bindParam(':id', $this->id); 142 | $this->create->bindParam(':data', $data); 143 | $this->create->bindParam(':expires', $this->generate_timestamp()); 144 | 145 | return (bool) $this->create->execute(); 146 | } 147 | 148 | /** 149 | * Reads a cache. 150 | * 151 | * @return mixed Either the content of the cache object, or boolean `false`. 152 | */ 153 | public function read() 154 | { 155 | if (!$this->store_read) 156 | { 157 | $this->read->bindParam(':id', $this->id); 158 | $this->read->execute(); 159 | $this->store_read = $this->read->fetch(PDO::FETCH_ASSOC); 160 | } 161 | 162 | if ($this->store_read) 163 | { 164 | $data = $this->store_read['data']; 165 | $data = $this->gzip ? gzuncompress($data) : $data; 166 | 167 | return unserialize($data); 168 | } 169 | 170 | return false; 171 | } 172 | 173 | /** 174 | * Updates an existing cache. 175 | * 176 | * @param mixed $data (Required) The data to cache. 177 | * @return boolean Whether the operation was successful. 178 | */ 179 | public function update($data) 180 | { 181 | $this->delete(); 182 | return $this->create($data); 183 | } 184 | 185 | /** 186 | * Deletes a cache. 187 | * 188 | * @return boolean Whether the operation was successful. 189 | */ 190 | public function delete() 191 | { 192 | $this->delete->bindParam(':id', $this->id); 193 | return $this->delete->execute(); 194 | } 195 | 196 | /** 197 | * Checks whether the cache object is expired or not. 198 | * 199 | * @return boolean Whether the cache is expired or not. 200 | */ 201 | public function is_expired() 202 | { 203 | if ($this->timestamp() + $this->expires < time()) 204 | { 205 | return true; 206 | } 207 | 208 | return false; 209 | } 210 | 211 | /** 212 | * Retrieves the timestamp of the cache. 213 | * 214 | * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. 215 | */ 216 | public function timestamp() 217 | { 218 | if (!$this->store_read) 219 | { 220 | $this->read->bindParam(':id', $this->id); 221 | $this->read->execute(); 222 | $this->store_read = $this->read->fetch(PDO::FETCH_ASSOC); 223 | } 224 | 225 | if ($this->store_read) 226 | { 227 | $value = $this->store_read['expires']; 228 | 229 | // If 'expires' isn't yet an integer, convert it into one. 230 | if (!is_numeric($value)) 231 | { 232 | $value = strtotime($value); 233 | } 234 | 235 | $this->timestamp = date('U', $value); 236 | return $this->timestamp; 237 | } 238 | 239 | return false; 240 | } 241 | 242 | /** 243 | * Resets the freshness of the cache. 244 | * 245 | * @return boolean Whether the operation was successful. 246 | */ 247 | public function reset() 248 | { 249 | $this->reset->bindParam(':id', $this->id); 250 | $this->reset->bindParam(':expires', $this->generate_timestamp()); 251 | return (bool) $this->reset->execute(); 252 | } 253 | 254 | /** 255 | * Returns a list of supported PDO database drivers. Identical to . 256 | * 257 | * @return array The list of supported database drivers. 258 | * @link http://php.net/pdo.getavailabledrivers PHP Method 259 | */ 260 | public function get_drivers() 261 | { 262 | return PDO::getAvailableDrivers(); 263 | } 264 | 265 | /** 266 | * Returns a timestamp value apropriate to the current database type. 267 | * 268 | * @return mixed Timestamp for MySQL and PostgreSQL, integer value for SQLite. 269 | */ 270 | protected function generate_timestamp() 271 | { 272 | // Define 'expires' settings differently. 273 | switch ($this->dsn['scheme']) 274 | { 275 | // These support timestamps. 276 | case 'mysql': // MySQL 277 | case 'pgsql': // PostgreSQL 278 | $expires = date(DATE_FORMAT_MYSQL, time()); 279 | break; 280 | 281 | // These support integers. 282 | case 'sqlite': // SQLite 3 283 | case 'sqlite2': // SQLite 2 284 | $expires = time(); 285 | break; 286 | } 287 | 288 | return $expires; 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/cachecore/cachexcache.class.php: -------------------------------------------------------------------------------- 1 | . Adheres 4 | * to the ICacheCore interface. 5 | * 6 | * @version 2009.10.10 7 | * @copyright 2006-2010 Ryan Parman 8 | * @copyright 2006-2010 Foleeo, Inc. 9 | * @copyright 2008-2010 Contributors 10 | * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License 11 | * @link http://github.com/skyzyx/cachecore CacheCore 12 | * @link http://getcloudfusion.com CloudFusion 13 | * @link http://xcache.lighttpd.net XCache 14 | */ 15 | class CacheXCache extends CacheCore implements ICacheCore 16 | { 17 | 18 | /*%******************************************************************************************%*/ 19 | // CONSTRUCTOR 20 | 21 | /** 22 | * Constructs a new instance of this class. 23 | * 24 | * @param string $name (Required) A name to uniquely identify the cache object. 25 | * @param string $location (Required) The location to store the cache object in. This may vary by cache method. 26 | * @param integer $expires (Required) The number of seconds until a cache object is considered stale. 27 | * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true. 28 | * @return object Reference to the cache object. 29 | */ 30 | public function __construct($name, $location, $expires, $gzip = true) 31 | { 32 | parent::__construct($name, null, $expires, $gzip); 33 | $this->id = $this->name; 34 | } 35 | 36 | /** 37 | * Creates a new cache. 38 | * 39 | * @param mixed $data (Required) The data to cache. 40 | * @return boolean Whether the operation was successful. 41 | */ 42 | public function create($data) 43 | { 44 | $data = serialize($data); 45 | $data = $this->gzip ? gzcompress($data) : $data; 46 | 47 | return xcache_set($this->id, $data, $this->expires); 48 | } 49 | 50 | /** 51 | * Reads a cache. 52 | * 53 | * @return mixed Either the content of the cache object, or boolean `false`. 54 | */ 55 | public function read() 56 | { 57 | if ($data = xcache_get($this->id)) 58 | { 59 | $data = $this->gzip ? gzuncompress($data) : $data; 60 | return unserialize($data); 61 | } 62 | 63 | return false; 64 | } 65 | 66 | /** 67 | * Updates an existing cache. 68 | * 69 | * @param mixed $data (Required) The data to cache. 70 | * @return boolean Whether the operation was successful. 71 | */ 72 | public function update($data) 73 | { 74 | $data = serialize($data); 75 | $data = $this->gzip ? gzcompress($data) : $data; 76 | 77 | return xcache_set($this->id, $data, $this->expires); 78 | } 79 | 80 | /** 81 | * Deletes a cache. 82 | * 83 | * @return boolean Whether the operation was successful. 84 | */ 85 | public function delete() 86 | { 87 | return xcache_unset($this->id); 88 | } 89 | 90 | /** 91 | * Defined here, but always returns false. XCache manages it's own expirations. It's worth 92 | * mentioning that if the server is configured for a long xcache.var_gc_interval then it IS 93 | * possible for expired data to remain in the var cache, though it is not possible to access 94 | * it. 95 | * 96 | * @return boolean Whether the cache is expired or not. 97 | */ 98 | public function is_expired() 99 | { 100 | return false; 101 | } 102 | 103 | /** 104 | * Implemented here, but always returns `false`. XCache manages its own expirations. 105 | * 106 | * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. 107 | */ 108 | public function timestamp() 109 | { 110 | return false; 111 | } 112 | 113 | /** 114 | * Implemented here, but always returns `false`. XCache manages its own expirations. 115 | * 116 | * @return boolean Whether the operation was successful. 117 | */ 118 | public function reset() 119 | { 120 | return false; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/cachecore/icachecore.interface.php: -------------------------------------------------------------------------------- 1 | class. 5 | * 6 | * @version 2009.03.22 7 | * @copyright 2006-2010 Ryan Parman 8 | * @copyright 2006-2010 Foleeo, Inc. 9 | * @copyright 2008-2010 Contributors 10 | * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License 11 | * @link http://github.com/skyzyx/cachecore CacheCore 12 | * @link http://getcloudfusion.com CloudFusion 13 | */ 14 | interface ICacheCore 15 | { 16 | /** 17 | * Creates a new cache. 18 | * 19 | * @param mixed $data (Required) The data to cache. 20 | * @return boolean Whether the operation was successful. 21 | */ 22 | public function create($data); 23 | 24 | /** 25 | * Reads a cache. 26 | * 27 | * @return mixed Either the content of the cache object, or boolean `false`. 28 | */ 29 | public function read(); 30 | 31 | /** 32 | * Updates an existing cache. 33 | * 34 | * @param mixed $data (Required) The data to cache. 35 | * @return boolean Whether the operation was successful. 36 | */ 37 | public function update($data); 38 | 39 | /** 40 | * Deletes a cache. 41 | * 42 | * @return boolean Whether the operation was successful. 43 | */ 44 | public function delete(); 45 | 46 | /** 47 | * Checks whether the cache object is expired or not. 48 | * 49 | * @return boolean Whether the cache is expired or not. 50 | */ 51 | public function is_expired(); 52 | 53 | /** 54 | * Retrieves the timestamp of the cache. 55 | * 56 | * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. 57 | */ 58 | public function timestamp(); 59 | 60 | /** 61 | * Resets the freshness of the cache. 62 | * 63 | * @return boolean Whether the operation was successful. 64 | */ 65 | public function reset(); 66 | } 67 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/yaml/lib/sfYaml.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /** 12 | * sfYaml offers convenience methods to load and dump YAML. 13 | * 14 | * @package symfony 15 | * @subpackage yaml 16 | * @author Fabien Potencier 17 | * @version SVN: $Id: sfYaml.class.php 8988 2008-05-15 20:24:26Z fabien $ 18 | */ 19 | class sfYaml 20 | { 21 | static protected 22 | $spec = '1.2'; 23 | 24 | /** 25 | * Sets the YAML specification version to use. 26 | * 27 | * @param string $version The YAML specification version 28 | */ 29 | static public function setSpecVersion($version) 30 | { 31 | if (!in_array($version, array('1.1', '1.2'))) 32 | { 33 | throw new InvalidArgumentException(sprintf('Version %s of the YAML specifications is not supported', $version)); 34 | } 35 | 36 | self::$spec = $version; 37 | } 38 | 39 | /** 40 | * Gets the YAML specification version to use. 41 | * 42 | * @return string The YAML specification version 43 | */ 44 | static public function getSpecVersion() 45 | { 46 | return self::$spec; 47 | } 48 | 49 | /** 50 | * Loads YAML into a PHP array. 51 | * 52 | * The load method, when supplied with a YAML stream (string or file), 53 | * will do its best to convert YAML in a file into a PHP array. 54 | * 55 | * Usage: 56 | * 57 | * $array = sfYaml::load('config.yml'); 58 | * print_r($array); 59 | * 60 | * 61 | * @param string $input Path of YAML file or string containing YAML 62 | * 63 | * @return array The YAML converted to a PHP array 64 | * 65 | * @throws InvalidArgumentException If the YAML is not valid 66 | */ 67 | public static function load($input) 68 | { 69 | $file = ''; 70 | 71 | // if input is a file, process it 72 | if (strpos($input, "\n") === false && is_file($input)) 73 | { 74 | $file = $input; 75 | 76 | ob_start(); 77 | $retval = include($input); 78 | $content = ob_get_clean(); 79 | 80 | // if an array is returned by the config file assume it's in plain php form else in YAML 81 | $input = is_array($retval) ? $retval : $content; 82 | } 83 | 84 | // if an array is returned by the config file assume it's in plain php form else in YAML 85 | if (is_array($input)) 86 | { 87 | return $input; 88 | } 89 | 90 | require_once dirname(__FILE__).'/sfYamlParser.php'; 91 | 92 | $yaml = new sfYamlParser(); 93 | 94 | try 95 | { 96 | $ret = $yaml->parse($input); 97 | } 98 | catch (Exception $e) 99 | { 100 | throw new InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); 101 | } 102 | 103 | return $ret; 104 | } 105 | 106 | /** 107 | * Dumps a PHP array to a YAML string. 108 | * 109 | * The dump method, when supplied with an array, will do its best 110 | * to convert the array into friendly YAML. 111 | * 112 | * @param array $array PHP array 113 | * @param integer $inline The level where you switch to inline YAML 114 | * 115 | * @return string A YAML string representing the original PHP array 116 | */ 117 | public static function dump($array, $inline = 2) 118 | { 119 | require_once dirname(__FILE__).'/sfYamlDumper.php'; 120 | 121 | $yaml = new sfYamlDumper(); 122 | 123 | return $yaml->dump($array, $inline); 124 | } 125 | } 126 | 127 | /** 128 | * Wraps echo to automatically provide a newline. 129 | * 130 | * @param string $string The string to echo with new line 131 | */ 132 | function echoln($string) 133 | { 134 | echo $string."\n"; 135 | } 136 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/yaml/lib/sfYamlDumper.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | require_once(dirname(__FILE__).'/sfYamlInline.php'); 12 | 13 | /** 14 | * sfYamlDumper dumps PHP variables to YAML strings. 15 | * 16 | * @package symfony 17 | * @subpackage yaml 18 | * @author Fabien Potencier 19 | * @version SVN: $Id: sfYamlDumper.class.php 10575 2008-08-01 13:08:42Z nicolas $ 20 | */ 21 | class sfYamlDumper 22 | { 23 | /** 24 | * Dumps a PHP value to YAML. 25 | * 26 | * @param mixed $input The PHP value 27 | * @param integer $inline The level where you switch to inline YAML 28 | * @param integer $indent The level o indentation indentation (used internally) 29 | * 30 | * @return string The YAML representation of the PHP value 31 | */ 32 | public function dump($input, $inline = 0, $indent = 0) 33 | { 34 | $output = ''; 35 | $prefix = $indent ? str_repeat(' ', $indent) : ''; 36 | 37 | if ($inline <= 0 || !is_array($input) || empty($input)) 38 | { 39 | $output .= $prefix.sfYamlInline::dump($input); 40 | } 41 | else 42 | { 43 | $isAHash = array_keys($input) !== range(0, count($input) - 1); 44 | 45 | foreach ($input as $key => $value) 46 | { 47 | $willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value); 48 | 49 | $output .= sprintf('%s%s%s%s', 50 | $prefix, 51 | $isAHash ? sfYamlInline::dump($key).':' : '-', 52 | $willBeInlined ? ' ' : "\n", 53 | $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2) 54 | ).($willBeInlined ? "\n" : ''); 55 | } 56 | } 57 | 58 | return $output; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /AWSSDKforPHP/lib/yaml/lib/sfYamlInline.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | require_once dirname(__FILE__).'/sfYaml.php'; 12 | 13 | /** 14 | * sfYamlInline implements a YAML parser/dumper for the YAML inline syntax. 15 | * 16 | * @package symfony 17 | * @subpackage yaml 18 | * @author Fabien Potencier 19 | * @version SVN: $Id: sfYamlInline.class.php 16177 2009-03-11 08:32:48Z fabien $ 20 | */ 21 | class sfYamlInline 22 | { 23 | const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')'; 24 | 25 | /** 26 | * Convert a YAML string to a PHP array. 27 | * 28 | * @param string $value A YAML string 29 | * 30 | * @return array A PHP array representing the YAML string 31 | */ 32 | static public function load($value) 33 | { 34 | $value = trim($value); 35 | 36 | if (0 == strlen($value)) 37 | { 38 | return ''; 39 | } 40 | 41 | if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) 42 | { 43 | $mbEncoding = mb_internal_encoding(); 44 | mb_internal_encoding('ASCII'); 45 | } 46 | 47 | switch ($value[0]) 48 | { 49 | case '[': 50 | $result = self::parseSequence($value); 51 | break; 52 | case '{': 53 | $result = self::parseMapping($value); 54 | break; 55 | default: 56 | $result = self::parseScalar($value); 57 | } 58 | 59 | if (isset($mbEncoding)) 60 | { 61 | mb_internal_encoding($mbEncoding); 62 | } 63 | 64 | return $result; 65 | } 66 | 67 | /** 68 | * Dumps a given PHP variable to a YAML string. 69 | * 70 | * @param mixed $value The PHP variable to convert 71 | * 72 | * @return string The YAML string representing the PHP array 73 | */ 74 | static public function dump($value) 75 | { 76 | if ('1.1' === sfYaml::getSpecVersion()) 77 | { 78 | $trueValues = array('true', 'on', '+', 'yes', 'y'); 79 | $falseValues = array('false', 'off', '-', 'no', 'n'); 80 | } 81 | else 82 | { 83 | $trueValues = array('true'); 84 | $falseValues = array('false'); 85 | } 86 | 87 | switch (true) 88 | { 89 | case is_resource($value): 90 | throw new InvalidArgumentException('Unable to dump PHP resources in a YAML file.'); 91 | case is_object($value): 92 | return '!!php/object:'.serialize($value); 93 | case is_array($value): 94 | return self::dumpArray($value); 95 | case null === $value: 96 | return 'null'; 97 | case true === $value: 98 | return 'true'; 99 | case false === $value: 100 | return 'false'; 101 | case ctype_digit($value): 102 | return is_string($value) ? "'$value'" : (int) $value; 103 | case is_numeric($value): 104 | return is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : (is_string($value) ? "'$value'" : $value); 105 | case false !== strpos($value, "\n") || false !== strpos($value, "\r"): 106 | return sprintf('"%s"', str_replace(array('"', "\n", "\r"), array('\\"', '\n', '\r'), $value)); 107 | case preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value): 108 | return sprintf("'%s'", str_replace('\'', '\'\'', $value)); 109 | case '' == $value: 110 | return "''"; 111 | case preg_match(self::getTimestampRegex(), $value): 112 | return "'$value'"; 113 | case in_array(strtolower($value), $trueValues): 114 | return "'$value'"; 115 | case in_array(strtolower($value), $falseValues): 116 | return "'$value'"; 117 | case in_array(strtolower($value), array('null', '~')): 118 | return "'$value'"; 119 | default: 120 | return $value; 121 | } 122 | } 123 | 124 | /** 125 | * Dumps a PHP array to a YAML string. 126 | * 127 | * @param array $value The PHP array to dump 128 | * 129 | * @return string The YAML string representing the PHP array 130 | */ 131 | static protected function dumpArray($value) 132 | { 133 | // array 134 | $keys = array_keys($value); 135 | if ( 136 | (1 == count($keys) && '0' == $keys[0]) 137 | || 138 | (count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2)) 139 | { 140 | $output = array(); 141 | foreach ($value as $val) 142 | { 143 | $output[] = self::dump($val); 144 | } 145 | 146 | return sprintf('[%s]', implode(', ', $output)); 147 | } 148 | 149 | // mapping 150 | $output = array(); 151 | foreach ($value as $key => $val) 152 | { 153 | $output[] = sprintf('%s: %s', self::dump($key), self::dump($val)); 154 | } 155 | 156 | return sprintf('{ %s }', implode(', ', $output)); 157 | } 158 | 159 | /** 160 | * Parses a scalar to a YAML string. 161 | * 162 | * @param scalar $scalar 163 | * @param string $delimiters 164 | * @param array $stringDelimiter 165 | * @param integer $i 166 | * @param boolean $evaluate 167 | * 168 | * @return string A YAML string 169 | */ 170 | static public function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) 171 | { 172 | if (in_array($scalar[$i], $stringDelimiters)) 173 | { 174 | // quoted scalar 175 | $output = self::parseQuotedScalar($scalar, $i); 176 | } 177 | else 178 | { 179 | // "normal" string 180 | if (!$delimiters) 181 | { 182 | $output = substr($scalar, $i); 183 | $i += strlen($output); 184 | 185 | // remove comments 186 | if (false !== $strpos = strpos($output, ' #')) 187 | { 188 | $output = rtrim(substr($output, 0, $strpos)); 189 | } 190 | } 191 | else if (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) 192 | { 193 | $output = $match[1]; 194 | $i += strlen($output); 195 | } 196 | else 197 | { 198 | throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', $scalar)); 199 | } 200 | 201 | $output = $evaluate ? self::evaluateScalar($output) : $output; 202 | } 203 | 204 | return $output; 205 | } 206 | 207 | /** 208 | * Parses a quoted scalar to YAML. 209 | * 210 | * @param string $scalar 211 | * @param integer $i 212 | * 213 | * @return string A YAML string 214 | */ 215 | static protected function parseQuotedScalar($scalar, &$i) 216 | { 217 | if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/A', substr($scalar, $i), $match)) 218 | { 219 | throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i))); 220 | } 221 | 222 | $output = substr($match[0], 1, strlen($match[0]) - 2); 223 | 224 | if ('"' == $scalar[$i]) 225 | { 226 | // evaluate the string 227 | $output = str_replace(array('\\"', '\\n', '\\r'), array('"', "\n", "\r"), $output); 228 | } 229 | else 230 | { 231 | // unescape ' 232 | $output = str_replace('\'\'', '\'', $output); 233 | } 234 | 235 | $i += strlen($match[0]); 236 | 237 | return $output; 238 | } 239 | 240 | /** 241 | * Parses a sequence to a YAML string. 242 | * 243 | * @param string $sequence 244 | * @param integer $i 245 | * 246 | * @return string A YAML string 247 | */ 248 | static protected function parseSequence($sequence, &$i = 0) 249 | { 250 | $output = array(); 251 | $len = strlen($sequence); 252 | $i += 1; 253 | 254 | // [foo, bar, ...] 255 | while ($i < $len) 256 | { 257 | switch ($sequence[$i]) 258 | { 259 | case '[': 260 | // nested sequence 261 | $output[] = self::parseSequence($sequence, $i); 262 | break; 263 | case '{': 264 | // nested mapping 265 | $output[] = self::parseMapping($sequence, $i); 266 | break; 267 | case ']': 268 | return $output; 269 | case ',': 270 | case ' ': 271 | break; 272 | default: 273 | $isQuoted = in_array($sequence[$i], array('"', "'")); 274 | $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i); 275 | 276 | if (!$isQuoted && false !== strpos($value, ': ')) 277 | { 278 | // embedded mapping? 279 | try 280 | { 281 | $value = self::parseMapping('{'.$value.'}'); 282 | } 283 | catch (InvalidArgumentException $e) 284 | { 285 | // no, it's not 286 | } 287 | } 288 | 289 | $output[] = $value; 290 | 291 | --$i; 292 | } 293 | 294 | ++$i; 295 | } 296 | 297 | throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence)); 298 | } 299 | 300 | /** 301 | * Parses a mapping to a YAML string. 302 | * 303 | * @param string $mapping 304 | * @param integer $i 305 | * 306 | * @return string A YAML string 307 | */ 308 | static protected function parseMapping($mapping, &$i = 0) 309 | { 310 | $output = array(); 311 | $len = strlen($mapping); 312 | $i += 1; 313 | 314 | // {foo: bar, bar:foo, ...} 315 | while ($i < $len) 316 | { 317 | switch ($mapping[$i]) 318 | { 319 | case ' ': 320 | case ',': 321 | ++$i; 322 | continue 2; 323 | case '}': 324 | return $output; 325 | } 326 | 327 | // key 328 | $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false); 329 | 330 | // value 331 | $done = false; 332 | while ($i < $len) 333 | { 334 | switch ($mapping[$i]) 335 | { 336 | case '[': 337 | // nested sequence 338 | $output[$key] = self::parseSequence($mapping, $i); 339 | $done = true; 340 | break; 341 | case '{': 342 | // nested mapping 343 | $output[$key] = self::parseMapping($mapping, $i); 344 | $done = true; 345 | break; 346 | case ':': 347 | case ' ': 348 | break; 349 | default: 350 | $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); 351 | $done = true; 352 | --$i; 353 | } 354 | 355 | ++$i; 356 | 357 | if ($done) 358 | { 359 | continue 2; 360 | } 361 | } 362 | } 363 | 364 | throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $mapping)); 365 | } 366 | 367 | /** 368 | * Evaluates scalars and replaces magic values. 369 | * 370 | * @param string $scalar 371 | * 372 | * @return string A YAML string 373 | */ 374 | static protected function evaluateScalar($scalar) 375 | { 376 | $scalar = trim($scalar); 377 | 378 | if ('1.1' === sfYaml::getSpecVersion()) 379 | { 380 | $trueValues = array('true', 'on', '+', 'yes', 'y'); 381 | $falseValues = array('false', 'off', '-', 'no', 'n'); 382 | } 383 | else 384 | { 385 | $trueValues = array('true'); 386 | $falseValues = array('false'); 387 | } 388 | 389 | switch (true) 390 | { 391 | case 'null' == strtolower($scalar): 392 | case '' == $scalar: 393 | case '~' == $scalar: 394 | return null; 395 | case 0 === strpos($scalar, '!str'): 396 | return (string) substr($scalar, 5); 397 | case 0 === strpos($scalar, '! '): 398 | return intval(self::parseScalar(substr($scalar, 2))); 399 | case 0 === strpos($scalar, '!!php/object:'): 400 | return unserialize(substr($scalar, 13)); 401 | case ctype_digit($scalar): 402 | $raw = $scalar; 403 | $cast = intval($scalar); 404 | return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); 405 | case in_array(strtolower($scalar), $trueValues): 406 | return true; 407 | case in_array(strtolower($scalar), $falseValues): 408 | return false; 409 | case is_numeric($scalar): 410 | return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); 411 | case 0 == strcasecmp($scalar, '.inf'): 412 | case 0 == strcasecmp($scalar, '.NaN'): 413 | return -log(0); 414 | case 0 == strcasecmp($scalar, '-.inf'): 415 | return log(0); 416 | case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): 417 | return floatval(str_replace(',', '', $scalar)); 418 | case preg_match(self::getTimestampRegex(), $scalar): 419 | return strtotime($scalar); 420 | default: 421 | return (string) $scalar; 422 | } 423 | } 424 | 425 | static protected function getTimestampRegex() 426 | { 427 | return <<[0-9][0-9][0-9][0-9]) 430 | -(?P[0-9][0-9]?) 431 | -(?P[0-9][0-9]?) 432 | (?:(?:[Tt]|[ \t]+) 433 | (?P[0-9][0-9]?) 434 | :(?P[0-9][0-9]) 435 | :(?P[0-9][0-9]) 436 | (?:\.(?P[0-9]*))? 437 | (?:[ \t]*(?PZ|(?P[-+])(?P[0-9][0-9]?) 438 | (?::(?P[0-9][0-9]))?))?)? 439 | $~x 440 | EOF; 441 | } 442 | } 443 | -------------------------------------------------------------------------------- /AWSSDKforPHP/services/cloudformation.class.php: -------------------------------------------------------------------------------- 1 | CloudFormation Product Page. 32 | * 33 | * Amazon CloudFormation makes use of other AWS products. If you need additional technical information about a specific AWS 34 | * product, you can find the product's technical documentation at http://aws.amazon.com/documentation/. 35 | * 36 | * @version Thu Feb 24 12:16:40 PST 2011 37 | * @license See the included NOTICE.md file for complete information. 38 | * @copyright See the included NOTICE.md file for complete information. 39 | * @link http://aws.amazon.com/cloudformation/Amazon CloudFormation 40 | * @link http://aws.amazon.com/documentation/cloudformation/Amazon CloudFormation documentation 41 | */ 42 | class AmazonCloudFormation extends CFRuntime 43 | { 44 | 45 | /*%******************************************************************************************%*/ 46 | // CLASS CONSTANTS 47 | 48 | /** 49 | * Specify the default queue URL. 50 | */ 51 | const DEFAULT_URL = 'cloudformation.us-east-1.amazonaws.com'; 52 | 53 | /** 54 | * Specify the queue URL for the US-East (Northern Virginia) Region. 55 | */ 56 | const REGION_US_E1 = self::DEFAULT_URL; 57 | 58 | /** 59 | * Specify the queue URL for the US-West (Northern California) Region. 60 | */ 61 | const REGION_US_W1 = 'cloudformation.us-west-1.amazonaws.com'; 62 | 63 | /** 64 | * Specify the queue URL for the EU (Ireland) Region. 65 | */ 66 | const REGION_EU_W1 = 'cloudformation.eu-west-1.amazonaws.com'; 67 | 68 | /** 69 | * Specify the queue URL for the Asia Pacific (Singapore) Region. 70 | */ 71 | const REGION_APAC_SE1 = 'cloudformation.ap-southeast-1.amazonaws.com'; 72 | 73 | 74 | /*%******************************************************************************************%*/ 75 | // SETTERS 76 | 77 | /** 78 | * This allows you to explicitly sets the region for the service to use. 79 | * 80 | * @param string $region (Required) The region to explicitly set. Available options are , , , or . 81 | * @return $this A reference to the current instance. 82 | */ 83 | public function set_region($region) 84 | { 85 | $this->set_hostname($region); 86 | return $this; 87 | } 88 | 89 | 90 | /*%******************************************************************************************%*/ 91 | // CONSTRUCTOR 92 | 93 | /** 94 | * Constructs a new instance of . 95 | * 96 | * @param string $key (Optional) Your Amazon API Key. If blank, it will look for the AWS_KEY constant. 97 | * @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the AWS_SECRET_KEY constant. 98 | * @return boolean false if no valid values are set, otherwise true. 99 | */ 100 | public function __construct($key = null, $secret_key = null) 101 | { 102 | $this->api_version = '2010-05-15'; 103 | $this->hostname = self::DEFAULT_URL; 104 | 105 | if (!$key && !defined('AWS_KEY')) 106 | { 107 | throw new CloudFormation_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.'); 108 | } 109 | 110 | if (!$secret_key && !defined('AWS_SECRET_KEY')) 111 | { 112 | throw new CloudFormation_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.'); 113 | } 114 | 115 | return parent::__construct($key, $secret_key); 116 | } 117 | 118 | 119 | /*%******************************************************************************************%*/ 120 | // SERVICE METHODS 121 | 122 | /** 123 | * 124 | * Creates a stack as specified in the template. Once the call completes successfully, the stack creation starts. You can 125 | * check the status of the stack via the DescribeStacks API. 126 | * 127 | * AWS CloudFormation allows you to create and delete related AWS resources together as a unit called a stack. You define 128 | * the characteristics of a stack using a template, which is a JSON-compliant text file. For more information, go to the AWS CloudFormation User Guide. 130 | * 131 | * Currently, the quota for stacks is 20 per region. 132 | * 133 | * @param string $stack_name (Required) The name associated with the Stack. The name must be unique within your AWS account. Must contain only alphanumeric characters (case sensitive) and start with an alpha character. Maximum length of the name is 255 characters. 134 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    135 | *
  • TemplateBody - string - Optional - Structure containing the template body. (For more information, go to the AWS CloudFormation User Guide.) You must pass TemplateBody or TemplateURL. If both are passed, only TemplateBody is used.
  • 136 | *
  • TemplateURL - string - Optional - Location of file containing the template body. (For more information, go to the AWS CloudFormation User Guide.) You must pass TemplateURL or TemplateBody. If both are passed, only TemplateBody is used.
  • 137 | *
  • Parameters - array - Optional - A list of Parameter structures.
      138 | *
    • x - array - This represents a simple array index.
        139 | *
      • ParameterKey - string - Optional - The key associated with the parameter.
      • 140 | *
      • ParameterValue - string - Optional - The value associated with the parameter.
      • 141 | *
    • 142 | *
  • 143 | *
  • DisableRollback - boolean - Optional - Boolean to enable or disable rollback on stack creation failures. Default: false
  • 144 | *
  • TimeoutInMinutes - integer - Optional - If the time limit is exceeded, the stack is marked CREATE_FAILED; if RollbackOnFailure is set, the stack will be rolled back.
  • 145 | *
  • NotificationARNs - string|array - Optional - The Simple Notification Service (SNS) topic ARNs to publish stack related events. You can find your SNS topic ARNs using the SNS console or your Command Line Interface (CLI). Pass a string for a single value, or an indexed array for multiple values.
  • 146 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
147 | * @return CFResponse A object containing a parsed HTTP response. 148 | */ 149 | public function create_stack($stack_name, $opt = null) 150 | { 151 | if (!$opt) $opt = array(); 152 | $opt['StackName'] = $stack_name; 153 | 154 | // Optional parameter 155 | if (isset($opt['Parameters'])) 156 | { 157 | $opt = array_merge($opt, CFComplexType::map(array( 158 | 'Parameters' => $opt['Parameters'] 159 | ), 'member')); 160 | unset($opt['Parameters']); 161 | } 162 | 163 | // Optional parameter 164 | if (isset($opt['NotificationARNs'])) 165 | { 166 | $opt = array_merge($opt, CFComplexType::map(array( 167 | 'NotificationARNs' => (is_array($opt['NotificationARNs']) ? $opt['NotificationARNs'] : array($opt['NotificationARNs'])) 168 | ), 'member')); 169 | unset($opt['NotificationARNs']); 170 | } 171 | 172 | return $this->authenticate('CreateStack', $opt, $this->hostname); 173 | } 174 | 175 | /** 176 | * 177 | * Validates a specified template. 178 | * 179 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    180 | *
  • TemplateBody - string - Optional - Structure containing the template body. (For more information, go to the AWS CloudFormation User Guide.)
  • 181 | *
  • TemplateURL - string - Optional - Location of file containing the template body. (For more information, go to the AWS CloudFormation User Guide.)
  • 182 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
183 | * @return CFResponse A object containing a parsed HTTP response. 184 | */ 185 | public function validate_template($opt = null) 186 | { 187 | if (!$opt) $opt = array(); 188 | 189 | return $this->authenticate('ValidateTemplate', $opt, $this->hostname); 190 | } 191 | 192 | /** 193 | * 194 | * Returns the description for the specified stack; if no stack name was specified, then it returns the description for 195 | * all the stacks created. 196 | * 197 | * If a specified stack does not exist or has been successfully deleted, a ValidationError is returned. 198 | * 199 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    200 | *
  • StackName - string - Optional - The name or the unique identifier associated with the stack. Default: null
  • 201 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
202 | * @return CFResponse A object containing a parsed HTTP response. 203 | */ 204 | public function describe_stacks($opt = null) 205 | { 206 | if (!$opt) $opt = array(); 207 | 208 | return $this->authenticate('DescribeStacks', $opt, $this->hostname); 209 | } 210 | 211 | /** 212 | * 213 | * Returns all the stack related events for the AWS account. If StackName is specified, returns events 214 | * related to all the stacks with the given name. If StackName is not specified, returns all the events for 215 | * the account. For more information about a stack's event history, go to the AWS CloudFormation User Guide. 217 | * 218 | * Events are returned, even if the stack has been successfully deleted. If the stack never existed, a 219 | * ValidationError is returned. 220 | * 221 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    222 | *
  • StackName - string - Optional - The name or the unique identifier associated with the stack. Default: null
  • 223 | *
  • NextToken - string - Optional - String that identifies the start of the next list of events, if there is one. Default: null
  • 224 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
225 | * @return CFResponse A object containing a parsed HTTP response. 226 | */ 227 | public function describe_stack_events($opt = null) 228 | { 229 | if (!$opt) $opt = array(); 230 | 231 | return $this->authenticate('DescribeStackEvents', $opt, $this->hostname); 232 | } 233 | 234 | /** 235 | * 236 | * Returns the template body for a specified stack name. 237 | * 238 | * If the stack does not exist or the stack has been successfully deleted, a ValidationError is returned. 239 | * 240 | * @param string $stack_name (Required) The name or the unique identifier associated with the stack. 241 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    242 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
243 | * @return CFResponse A object containing a parsed HTTP response. 244 | */ 245 | public function get_template($stack_name, $opt = null) 246 | { 247 | if (!$opt) $opt = array(); 248 | $opt['StackName'] = $stack_name; 249 | 250 | return $this->authenticate('GetTemplate', $opt, $this->hostname); 251 | } 252 | 253 | /** 254 | * 255 | * Deletes a specified stack. Once the call completes successfully, stack deletion starts. Deleted stacks do not show up 256 | * in the DescribeStacks API if the deletion has been completed successfully. 257 | * 258 | * @param string $stack_name (Required) The name or the unique identifier associated with the stack. 259 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    260 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
261 | * @return CFResponse A object containing a parsed HTTP response. 262 | */ 263 | public function delete_stack($stack_name, $opt = null) 264 | { 265 | if (!$opt) $opt = array(); 266 | $opt['StackName'] = $stack_name; 267 | 268 | return $this->authenticate('DeleteStack', $opt, $this->hostname); 269 | } 270 | 271 | /** 272 | * 273 | * Returns AWS resource descriptions. If StackName is specified, all the associated resources that are part 274 | * of the stack are returned. If PhysicalResourceId is specified, all the associated resources of the stack 275 | * the resource belongs to are returned. 276 | * 277 | * You can use LogicalResourceId to filter the returned result. For more information about resources, the 278 | * LogicalResourceId and PhysicalResourceId, go to the AWS CloudFormation User Guide. 280 | * 281 | * If the stack does not exist or the stack has been successfully deleted, a ValidationError is returned. 282 | * 283 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    284 | *
  • StackName - string - Optional - The name or the unique identifier associated with the stack. Default: null
  • 285 | *
  • LogicalResourceId - string - Optional - The logical name of the resource specified in the template. Default: null
  • 286 | *
  • PhysicalResourceId - string - Optional - The name or unique identifier that corresponds to a physical instance ID of a resource supported by AWS CloudFormation. For example, for an Amazon Elastic Compute Cloud (EC2) instance, PhysicalResourceId corresponds to the InstanceId. You can pass the EC2 InstanceId to DescribeStackResources to find what stack the instance belongs to and what other resources are part of the stack. Default: null
  • 287 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
288 | * @return CFResponse A object containing a parsed HTTP response. 289 | */ 290 | public function describe_stack_resources($opt = null) 291 | { 292 | if (!$opt) $opt = array(); 293 | 294 | return $this->authenticate('DescribeStackResources', $opt, $this->hostname); 295 | } 296 | } 297 | 298 | 299 | /*%******************************************************************************************%*/ 300 | // EXCEPTIONS 301 | 302 | /** 303 | * Default CloudFormation Exception. 304 | */ 305 | class CloudFormation_Exception extends Exception {} -------------------------------------------------------------------------------- /AWSSDKforPHP/services/importexport.class.php: -------------------------------------------------------------------------------- 1 | . 49 | * 50 | * @param string $key (Optional) Your Amazon API Key. If blank, it will look for the AWS_KEY constant. 51 | * @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the AWS_SECRET_KEY constant. 52 | * @return boolean false if no valid values are set, otherwise true. 53 | */ 54 | public function __construct($key = null, $secret_key = null) 55 | { 56 | $this->api_version = '2010-06-01'; 57 | $this->hostname = self::DEFAULT_URL; 58 | 59 | if (!$key && !defined('AWS_KEY')) 60 | { 61 | throw new ImportExport_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.'); 62 | } 63 | 64 | if (!$secret_key && !defined('AWS_SECRET_KEY')) 65 | { 66 | throw new ImportExport_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.'); 67 | } 68 | 69 | return parent::__construct($key, $secret_key); 70 | } 71 | 72 | 73 | /*%******************************************************************************************%*/ 74 | // SERVICE METHODS 75 | 76 | /** 77 | * 78 | * This operation initiates the process of scheduling an upload or download of your data. You include in the request a 79 | * manifest that describes the data transfer specifics. The response to the request includes a job ID, which you can use in 80 | * other operations, a signature that you use to identify your storage device, and the address where you should ship your 81 | * storage device. 82 | * 83 | * @param string $job_type (Required) Specifies whether the job to initiate is an import or export job. [Allowed values: Import, Export] 84 | * @param string $manifest (Required) The UTF-8 encoded text of the manifest file. 85 | * @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job. 86 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    87 | *
  • ManifestAddendum - string - Optional - For internal use only.
  • 88 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
89 | * @return CFResponse A object containing a parsed HTTP response. 90 | */ 91 | public function create_job($job_type, $manifest, $validate_only, $opt = null) 92 | { 93 | if (!$opt) $opt = array(); 94 | $opt['JobType'] = $job_type; 95 | $opt['Manifest'] = $manifest; 96 | $opt['ValidateOnly'] = $validate_only; 97 | 98 | return $this->authenticate('CreateJob', $opt, $this->hostname); 99 | } 100 | 101 | /** 102 | * 103 | * This operation cancels a specified job. Only the job owner can cancel it. The operation fails if the job has already 104 | * started or is complete. 105 | * 106 | * @param string $job_id (Required) A unique identifier which refers to a particular job. 107 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    108 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
109 | * @return CFResponse A object containing a parsed HTTP response. 110 | */ 111 | public function cancel_job($job_id, $opt = null) 112 | { 113 | if (!$opt) $opt = array(); 114 | $opt['JobId'] = $job_id; 115 | 116 | return $this->authenticate('CancelJob', $opt, $this->hostname); 117 | } 118 | 119 | /** 120 | * 121 | * This operation returns information about a job, including where the job is in the processing pipeline, the status of 122 | * the results, and the signature value associated with the job. You can only return information about jobs you own. 123 | * 124 | * @param string $job_id (Required) A unique identifier which refers to a particular job. 125 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    126 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
127 | * @return CFResponse A object containing a parsed HTTP response. 128 | */ 129 | public function get_status($job_id, $opt = null) 130 | { 131 | if (!$opt) $opt = array(); 132 | $opt['JobId'] = $job_id; 133 | 134 | return $this->authenticate('GetStatus', $opt, $this->hostname); 135 | } 136 | 137 | /** 138 | * 139 | * This operation returns the jobs associated with the requester. AWS Import/Export lists the jobs in reverse 140 | * chronological order based on the date of creation. For example if Job Test1 was created 2009Dec30 and Test2 was created 141 | * 2010Feb05, the ListJobs operation would return Test2 followed by Test1. 142 | * 143 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    144 | *
  • MaxJobs - integer - Optional - Sets the maximum number of jobs returned in the response. If there are additional jobs that were not returned because MaxJobs was exceeded, the response contains true. To return the additional jobs, see Marker.
  • 145 | *
  • Marker - string - Optional - Specifies the JOBID to start after when listing the jobs created with your account. AWS Import/Export lists your jobs in reverse chronological order. See MaxJobs.
  • 146 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
147 | * @return CFResponse A object containing a parsed HTTP response. 148 | */ 149 | public function list_jobs($opt = null) 150 | { 151 | if (!$opt) $opt = array(); 152 | 153 | return $this->authenticate('ListJobs', $opt, $this->hostname); 154 | } 155 | 156 | /** 157 | * 158 | * You use this operation to change the parameters specified in the original manifest file by supplying a new manifest 159 | * file. The manifest file attached to this request replaces the original manifest file. You can only use the operation 160 | * after a CreateJob request but before the data transfer starts and you can only use it on jobs you own. 161 | * 162 | * @param string $job_id (Required) A unique identifier which refers to a particular job. 163 | * @param string $manifest (Required) The UTF-8 encoded text of the manifest file. 164 | * @param string $job_type (Required) Specifies whether the job to initiate is an import or export job. [Allowed values: Import, Export] 165 | * @param boolean $validate_only (Required) Validate the manifest and parameter values in the request but do not actually create a job. 166 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    167 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
168 | * @return CFResponse A object containing a parsed HTTP response. 169 | */ 170 | public function update_job($job_id, $manifest, $job_type, $validate_only, $opt = null) 171 | { 172 | if (!$opt) $opt = array(); 173 | $opt['JobId'] = $job_id; 174 | $opt['Manifest'] = $manifest; 175 | $opt['JobType'] = $job_type; 176 | $opt['ValidateOnly'] = $validate_only; 177 | 178 | return $this->authenticate('UpdateJob', $opt, $this->hostname); 179 | } 180 | } 181 | 182 | 183 | /*%******************************************************************************************%*/ 184 | // EXCEPTIONS 185 | 186 | /** 187 | * Default ImportExport Exception. 188 | */ 189 | class ImportExport_Exception extends Exception {} -------------------------------------------------------------------------------- /AWSSDKforPHP/services/ses.class.php: -------------------------------------------------------------------------------- 1 | Amazon SES Developer Guide. 25 | * 26 | * @version Thu Feb 24 12:20:37 PST 2011 27 | * @license See the included NOTICE.md file for complete information. 28 | * @copyright See the included NOTICE.md file for complete information. 29 | * @link http://aws.amazon.com/ses/Amazon Simple Email Service 30 | * @link http://aws.amazon.com/documentation/ses/Amazon Simple Email Service documentation 31 | */ 32 | class AmazonSES extends CFRuntime 33 | { 34 | 35 | /*%******************************************************************************************%*/ 36 | // CLASS CONSTANTS 37 | 38 | /** 39 | * Specify the default queue URL. 40 | */ 41 | const DEFAULT_URL = 'email.us-east-1.amazonaws.com'; 42 | 43 | /** 44 | * Specify the queue URL for the US-East (Northern Virginia) Region. 45 | */ 46 | const REGION_US_E1 = self::DEFAULT_URL; 47 | 48 | 49 | /*%******************************************************************************************%*/ 50 | // SETTERS 51 | 52 | /** 53 | * This allows you to explicitly sets the region for the service to use. 54 | * 55 | * @param string $region (Required) The region to explicitly set. Available options are , , , or . 56 | * @return $this A reference to the current instance. 57 | */ 58 | public function set_region($region) 59 | { 60 | $this->set_hostname($region); 61 | return $this; 62 | } 63 | 64 | /** 65 | * Throws an error because SSL is required for the Amazon Email Service. 66 | * 67 | * @return void 68 | */ 69 | public function disable_ssl() 70 | { 71 | throw new Email_Exception('SSL/HTTPS is REQUIRED for Amazon Email Service and cannot be disabled.'); 72 | } 73 | 74 | 75 | /*%******************************************************************************************%*/ 76 | // CONSTRUCTOR 77 | 78 | /** 79 | * Constructs a new instance of . 80 | * 81 | * @param string $key (Optional) Your Amazon API Key. If blank, it will look for the AWS_KEY constant. 82 | * @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the AWS_SECRET_KEY constant. 83 | * @return boolean false if no valid values are set, otherwise true. 84 | */ 85 | public function __construct($key = null, $secret_key = null) 86 | { 87 | $this->api_version = '2010-12-01'; 88 | $this->hostname = self::DEFAULT_URL; 89 | 90 | if (!$key && !defined('AWS_KEY')) 91 | { 92 | throw new Email_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.'); 93 | } 94 | 95 | if (!$secret_key && !defined('AWS_SECRET_KEY')) 96 | { 97 | throw new Email_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.'); 98 | } 99 | 100 | return parent::__construct($key, $secret_key); 101 | } 102 | 103 | 104 | /*%******************************************************************************************%*/ 105 | // SERVICE METHODS 106 | 107 | /** 108 | * 109 | * Returns the user's current activity limits. 110 | * 111 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    112 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
113 | * @return CFResponse A object containing a parsed HTTP response. 114 | */ 115 | public function get_send_quota($opt = null) 116 | { 117 | if (!$opt) $opt = array(); 118 | 119 | return $this->authenticate('GetSendQuota', $opt, $this->hostname, 3); 120 | } 121 | 122 | /** 123 | * 124 | * Returns a list containing all of the email addresses that have been verified. 125 | * 126 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    127 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
128 | * @return CFResponse A object containing a parsed HTTP response. 129 | */ 130 | public function list_verified_email_addresses($opt = null) 131 | { 132 | if (!$opt) $opt = array(); 133 | 134 | return $this->authenticate('ListVerifiedEmailAddresses', $opt, $this->hostname, 3); 135 | } 136 | 137 | /** 138 | * 139 | * Returns the user's sending statistics. The result is a list of data points, representing the last two weeks of sending 140 | * activity. 141 | * 142 | * Each data point in the list contains statistics for a 15-minute interval. 143 | * 144 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    145 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
146 | * @return CFResponse A object containing a parsed HTTP response. 147 | */ 148 | public function get_send_statistics($opt = null) 149 | { 150 | if (!$opt) $opt = array(); 151 | 152 | return $this->authenticate('GetSendStatistics', $opt, $this->hostname, 3); 153 | } 154 | 155 | /** 156 | * 157 | * Composes an email message based on input data, and then immediately queues the message for sending. 158 | * 159 | * If you have not yet requested production access to Amazon SES, then you will only be able to send email to and from 160 | * verified email addresses. For more information, go to the Amazon SES Developer Guide. 162 | * 163 | * @param string $source (Required) The sender's email address. 164 | * @param array $destination (Required) The destination for this email, composed of To:, From:, and CC: fields.
    165 | *
  • ToAddresses - string|array - Optional - The To: field(s) of the message. Pass a string for a single value, or an indexed array for multiple values.
  • 166 | *
  • CcAddresses - string|array - Optional - The CC: field(s) of the message. Pass a string for a single value, or an indexed array for multiple values.
  • 167 | *
  • BccAddresses - string|array - Optional - The BCC: field(s) of the message. Pass a string for a single value, or an indexed array for multiple values.
  • 168 | *
169 | * @param array $message (Required) The message to be sent.
    170 | *
  • Subject - array - Required - The subject of the message: A short summary of the content, which will appear in the recipient's inbox. Takes an associative array of parameters that can have the following keys:
      171 | *
    • Data - string - Required - The textual data of the content.
    • 172 | *
    • Charset - string - Optional - The character set of the content.
    • 173 | *
  • 174 | *
  • Body - array - Required - The message body. Takes an associative array of parameters that can have the following keys:
      175 | *
    • Text - array - Optional - The content of the message, in text format. Use this for text-based email clients, or clients on high-latency networks (such as mobile devices). Takes an associative array of parameters that can have the following keys:
        176 | *
      • Data - string - Required - The textual data of the content.
      • 177 | *
      • Charset - string - Optional - The character set of the content.
      • 178 | *
    • 179 | *
    • Html - array - Optional - The content of the message, in HTML format. Use this for email clients that can process HTML. You can include clickable links, formatted text, and much more in an HTML message. Takes an associative array of parameters that can have the following keys:
        180 | *
      • Data - string - Required - The textual data of the content.
      • 181 | *
      • Charset - string - Optional - The character set of the content.
      • 182 | *
    • 183 | *
  • 184 | *
185 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    186 | *
  • ReplyToAddresses - string|array - Optional - The reply-to email address(es) for the message. If the recipient replies to the message, each reply-to address will receive the reply. Pass a string for a single value, or an indexed array for multiple values.
  • 187 | *
  • ReturnPath - string - Optional - The email address to which bounce notifications are to be forwarded. If the message cannot be delivered to the recipient, then an error message will be returned from the recipient's ISP; this message will then be forwarded to the email address specified by the ReturnPath parameter.
  • 188 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
189 | * @return CFResponse A object containing a parsed HTTP response. 190 | */ 191 | public function send_email($source, $destination, $message, $opt = null) 192 | { 193 | if (!$opt) $opt = array(); 194 | $opt['Source'] = $source; 195 | 196 | // Collapse these list values for the required parameter 197 | if (isset($destination['ToAddresses'])) 198 | { 199 | $destination['ToAddresses'] = CFComplexType::map(array( 200 | 'member' => (is_array($destination['ToAddresses']) ? $destination['ToAddresses'] : array($destination['ToAddresses'])) 201 | )); 202 | } 203 | 204 | // Collapse these list values for the required parameter 205 | if (isset($destination['CcAddresses'])) 206 | { 207 | $destination['CcAddresses'] = CFComplexType::map(array( 208 | 'member' => (is_array($destination['CcAddresses']) ? $destination['CcAddresses'] : array($destination['CcAddresses'])) 209 | )); 210 | } 211 | 212 | // Collapse these list values for the required parameter 213 | if (isset($destination['BccAddresses'])) 214 | { 215 | $destination['BccAddresses'] = CFComplexType::map(array( 216 | 'member' => (is_array($destination['BccAddresses']) ? $destination['BccAddresses'] : array($destination['BccAddresses'])) 217 | )); 218 | } 219 | 220 | // Required parameter 221 | $opt = array_merge($opt, CFComplexType::map(array( 222 | 'Destination' => (is_array($destination) ? $destination : array($destination)) 223 | ), 'member')); 224 | 225 | // Required parameter 226 | $opt = array_merge($opt, CFComplexType::map(array( 227 | 'Message' => (is_array($message) ? $message : array($message)) 228 | ), 'member')); 229 | 230 | // Optional parameter 231 | if (isset($opt['ReplyToAddresses'])) 232 | { 233 | $opt = array_merge($opt, CFComplexType::map(array( 234 | 'ReplyToAddresses' => (is_array($opt['ReplyToAddresses']) ? $opt['ReplyToAddresses'] : array($opt['ReplyToAddresses'])) 235 | ), 'member')); 236 | unset($opt['ReplyToAddresses']); 237 | } 238 | 239 | return $this->authenticate('SendEmail', $opt, $this->hostname, 3); 240 | } 241 | 242 | /** 243 | * 244 | * Deletes the specified email address from the list of verified addresses. 245 | * 246 | * @param string $email_address (Required) An email address to be removed from the list of verified addreses. 247 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    248 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
249 | * @return CFResponse A object containing a parsed HTTP response. 250 | */ 251 | public function delete_verified_email_address($email_address, $opt = null) 252 | { 253 | if (!$opt) $opt = array(); 254 | $opt['EmailAddress'] = $email_address; 255 | 256 | return $this->authenticate('DeleteVerifiedEmailAddress', $opt, $this->hostname, 3); 257 | } 258 | 259 | /** 260 | * 261 | * Verifies an email address. This action causes a confirmation email message to be sent to the specified address. 262 | * 263 | * @param string $email_address (Required) The email address to be verified. 264 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    265 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
266 | * @return CFResponse A object containing a parsed HTTP response. 267 | */ 268 | public function verify_email_address($email_address, $opt = null) 269 | { 270 | if (!$opt) $opt = array(); 271 | $opt['EmailAddress'] = $email_address; 272 | 273 | return $this->authenticate('VerifyEmailAddress', $opt, $this->hostname, 3); 274 | } 275 | 276 | /** 277 | * 278 | * Sends an email message, with header and content specified by the client. The SendRawEmail action is useful 279 | * for sending multipart MIME emails. The raw text of the message must comply with Internet email standards; otherwise, the 280 | * message cannot be sent. 281 | * 282 | * If you have not yet requested production access to Amazon SES, then you will only be able to send email to and from 283 | * verified email addresses. For more information, go to the Amazon SES Developer Guide. 285 | * 286 | * @param array $raw_message (Required) The raw text of the message. The client is responsible for ensuring the following:
  • Message must contain a header and a body, separated by a blank line.
  • All required header fields must be present.
  • Each part of a multipart MIME message must be formatted properly.
  • MIME content types must be among those supported by Amazon SES. Refer to the Amazon SES Developer Guide for more details.
  • Content must be base64-encoded, if MIME requires it.
    287 | *
  • Data - blob - Required - The raw data of the message. The client must ensure that the message format complies with Internet email standards regarding email header fields, MIME types, MIME encoding, and base64 encoding (if necessary). For more information, go to the Amazon SES Developer Guide.
  • 288 | *
289 | * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    290 | *
  • Source - string - Optional - The sender's email address.
  • 291 | *
  • Destinations - string|array - Optional - A list of destinations for the message. Pass a string for a single value, or an indexed array for multiple values.
  • 292 | *
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
293 | * @return CFResponse A object containing a parsed HTTP response. 294 | */ 295 | public function send_raw_email($raw_message, $opt = null) 296 | { 297 | if (!$opt) $opt = array(); 298 | 299 | // Optional parameter 300 | if (isset($opt['Destinations'])) 301 | { 302 | $opt = array_merge($opt, CFComplexType::map(array( 303 | 'Destinations' => (is_array($opt['Destinations']) ? $opt['Destinations'] : array($opt['Destinations'])) 304 | ), 'member')); 305 | unset($opt['Destinations']); 306 | } 307 | 308 | // Required parameter 309 | $opt = array_merge($opt, CFComplexType::map(array( 310 | 'RawMessage' => (is_array($raw_message) ? $raw_message : array($raw_message)) 311 | ), 'member')); 312 | 313 | return $this->authenticate('SendRawEmail', $opt, $this->hostname, 3); 314 | } 315 | } 316 | 317 | 318 | /*%******************************************************************************************%*/ 319 | // EXCEPTIONS 320 | 321 | /** 322 | * Exception: Email_Exception 323 | * Default Email Exception. 324 | */ 325 | class Email_Exception extends Exception {} 326 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/array.class.php: -------------------------------------------------------------------------------- 1 | object extends PHP's built-in object by providing convenience methods for 23 | * rapidly manipulating array data. Specifically, the `CFArray` object is intended for working with 24 | * and objects that are returned by AWS services. 25 | * 26 | * @version 2010.12.06 27 | * @license See the included NOTICE.md file for more information. 28 | * @copyright See the included NOTICE.md file for more information. 29 | * @link http://aws.amazon.com/php/ PHP Developer Center 30 | * @link http://php.net/ArrayObject ArrayObject 31 | */ 32 | class CFArray extends ArrayObject 33 | { 34 | /** 35 | * Constructs a new instance of the class. 36 | * 37 | * @param mixed $input (Optional) The input parameter accepts an array or an Object. The default value is an empty array. 38 | * @param integer $flags (Optional) Flags to control the behavior of the ArrayObject object. Defaults to . 39 | * @param string $iterator_class (Optional) Specify the class that will be used for iteration of the object. is the default class used. 40 | * @return mixed Either an array of matches, or a single element. 41 | */ 42 | public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iterator_class = 'ArrayIterator') 43 | { 44 | return parent::__construct($input, $flags, $iterator_class); 45 | } 46 | 47 | /** 48 | * Handles how the object is rendered when cast as a string. 49 | * 50 | * @return string The word "Array". 51 | */ 52 | public function __toString() 53 | { 54 | return 'Array'; 55 | } 56 | 57 | /** 58 | * Maps each element in the object as an integer. 59 | * 60 | * @return array The contents of the object mapped as integers. 61 | */ 62 | public function map_integer() 63 | { 64 | return array_map('intval', $this->getArrayCopy()); 65 | } 66 | 67 | /** 68 | * Maps each element in the CFArray object as a string. 69 | * 70 | * @param string $pcre (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against. 71 | * @return array The contents of the object mapped as strings. If there are no results, the method will return an empty array. 72 | */ 73 | public function map_string($pcre = null) 74 | { 75 | $list = array_map('strval', $this->getArrayCopy()); 76 | $dlist = array(); 77 | 78 | if ($pcre) 79 | { 80 | foreach ($list as $item) 81 | { 82 | $dlist[] = preg_match($pcre, $item) ? $item : null; 83 | } 84 | 85 | $list = array_values(array_filter($dlist)); 86 | } 87 | 88 | return $list; 89 | } 90 | 91 | /** 92 | * Verifies that _all_ responses were successful. A single failed request will cause to return false. Equivalent to , except it applies to all responses. 93 | * 94 | * @return boolean Whether _all_ requests were successful or not. 95 | */ 96 | public function areOK() 97 | { 98 | $dlist = array(); 99 | $list = $this->getArrayCopy(); 100 | 101 | foreach ($list as $response) 102 | { 103 | if ($response instanceof CFResponse) 104 | { 105 | $dlist[] = $response->isOK(); 106 | } 107 | } 108 | 109 | return (array_search(false, $dlist, true) !== false) ? false : true; 110 | } 111 | 112 | /** 113 | * Iterates over a object, and executes a function for each matched element. 114 | * 115 | * @param string|function $callback (Required) The callback function to execute. PHP 5.3 or newer can use an anonymous function. 116 | * @param mixed $bind (Optional) A variable from the calling scope to pass-by-reference into the local scope of the callback function. 117 | * @return CFArray The original object. 118 | */ 119 | public function each($callback, &$bind = null) 120 | { 121 | $items = $this->getArrayCopy(); 122 | $max = count($items); 123 | 124 | for ($i = 0; $i < $max; $i++) 125 | { 126 | $callback($items[$i], $i, $bind); 127 | } 128 | 129 | return $this; 130 | } 131 | 132 | /** 133 | * Passes each element in the current object through a function, and produces a new object containing the return values. 134 | * 135 | * @param string|function $callback (Required) The callback function to execute. PHP 5.3 or newer can use an anonymous function. 136 | * @param mixed $bind (Optional) A variable from the calling scope to pass-by-reference into the local scope of the callback function. 137 | * @return CFArray A new object containing the return values. 138 | */ 139 | public function map($callback, &$bind = null) 140 | { 141 | $items = $this->getArrayCopy(); 142 | $max = count($items); 143 | $collect = array(); 144 | 145 | for ($i = 0; $i < $max; $i++) 146 | { 147 | $collect[] = $callback($items[$i], $i, $bind); 148 | } 149 | 150 | return new CFArray($collect); 151 | } 152 | 153 | /** 154 | * Reduces the list of nodes by passing each value in the current object through a function. The node will be removed if the function returns `false`. 155 | * 156 | * @param string|function $callback (Required) The callback function to execute. PHP 5.3 or newer can use an anonymous function. 157 | * @param mixed $bind (Optional) A variable from the calling scope to pass-by-reference into the local scope of the callback function. 158 | * @return CFArray A new object containing the return values. 159 | */ 160 | public function reduce($callback, &$bind = null) 161 | { 162 | $items = $this->getArrayCopy(); 163 | $max = count($items); 164 | $collect = array(); 165 | 166 | for ($i = 0; $i < $max; $i++) 167 | { 168 | if ($callback($items[$i], $i, $bind) !== false) 169 | { 170 | $collect[] = $items[$i]; 171 | } 172 | } 173 | 174 | return new CFArray($collect); 175 | } 176 | 177 | /** 178 | * Gets the first result in the array. 179 | * 180 | * @return mixed The first result in the object. Returns `false` if there are no items in the array. 181 | */ 182 | public function first() 183 | { 184 | $items = $this->getArrayCopy(); 185 | return count($items) ? $items[0] : false; 186 | } 187 | 188 | /** 189 | * Gets the last result in the array. 190 | * 191 | * @return mixed The last result in the object. Returns `false` if there are no items in the array. 192 | */ 193 | public function last() 194 | { 195 | $items = $this->getArrayCopy(); 196 | return count($items) ? end($items) : false; 197 | } 198 | 199 | /** 200 | * Removes all `null` values from an array. 201 | * 202 | * @return CFArray A new object containing the non-null values. 203 | */ 204 | public function compress() 205 | { 206 | return new CFArray(array_filter($this->getArrayCopy())); 207 | } 208 | 209 | /** 210 | * Reindexes the array, starting from zero. 211 | * 212 | * @return CFArray A new object with indexes starting at zero. 213 | */ 214 | public function reindex() 215 | { 216 | return new CFArray(array_values($this->getArrayCopy())); 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/batchrequest.class.php: -------------------------------------------------------------------------------- 1 | queue = array(); 65 | $this->limit = $limit ? $limit : -1; 66 | return $this; 67 | } 68 | 69 | /** 70 | * Adds a new cURL handle to the request queue. 71 | * 72 | * @param resource $handle (Required) A cURL resource to add to the queue. 73 | * @return $this A reference to the current instance. 74 | */ 75 | public function add($handle) 76 | { 77 | $this->queue[] = $handle; 78 | return $this; 79 | } 80 | 81 | /** 82 | * Executes the batch request queue. 83 | * 84 | * @param array $opt (DO NOT USE) Enabled for compatibility with the method this overrides, although any values passed will be ignored. 85 | * @return array An indexed array of objects. 86 | */ 87 | public function send($opt = null) 88 | { 89 | $http = new $this->request_class(); 90 | 91 | // Make the request 92 | $response = $http->send_multi_request($this->queue, array( 93 | 'limit' => $this->limit 94 | )); 95 | 96 | return $response; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/complextype.class.php: -------------------------------------------------------------------------------- 1 | function. 35 | * @param string $member (Optional) The name of the "member" property that AWS uses for lists in certain services. Defaults to an empty string. 36 | * @param string $default_key (Optional) The default key to use when the value for `$data` is a string. Defaults to an empty string. 37 | * @return array The option group parameters to merge into another method's `$opt` parameter. 38 | */ 39 | public static function json($json, $member = '', $default_key = '') 40 | { 41 | return self::option_group(json_decode($json, true), $member, $default_key); 42 | } 43 | 44 | /** 45 | * Takes a YAML object, as a string, to convert to query string keys. 46 | * 47 | * @param string $yaml (Required) A YAML object. 48 | * @param string $member (Optional) The name of the "member" property that AWS uses for lists in certain services. Defaults to an empty string. 49 | * @param string $default_key (Optional) The default key to use when the value for `$data` is a string. Defaults to an empty string. 50 | * @return array The option group parameters to merge into another method's `$opt` parameter. 51 | */ 52 | public static function yaml($yaml, $member = '', $default_key = '') 53 | { 54 | return self::option_group(sfYaml::load($yaml), $member, $default_key); 55 | } 56 | 57 | /** 58 | * Takes an associative array to convert to query string keys. 59 | * 60 | * @param array $map (Required) An associative array. 61 | * @param string $member (Optional) The name of the "member" property that AWS uses for lists in certain services. Defaults to an empty string. 62 | * @param string $default_key (Optional) The default key to use when the value for `$data` is a string. Defaults to an empty string. 63 | * @return array The option group parameters to merge into another method's `$opt` parameter. 64 | */ 65 | public static function map($map, $member = '', $default_key = '') 66 | { 67 | return self::option_group($map, $member, $default_key); 68 | } 69 | 70 | /** 71 | * A protected method that is used by , and . 72 | * 73 | * @param string|array $data (Required) The data to iterate over. 74 | * @param string $member (Optional) The name of the "member" property that AWS uses for lists in certain services. Defaults to an empty string. 75 | * @param string $key (Optional) The default key to use when the value for `$data` is a string. Defaults to an empty string. 76 | * @param array $out (Optional) INTERNAL ONLY. The array that contains the calculated values up to this point. 77 | * @return array The option group parameters to merge into another method's `$opt` parameter. 78 | */ 79 | public static function option_group($data, $member = '', $key = '', &$out = array()) 80 | { 81 | $reset = $key; 82 | 83 | if (is_array($data)) 84 | { 85 | foreach ($data as $k => $v) 86 | { 87 | // Avoid 0-based indexes. 88 | if (is_int($k)) 89 | { 90 | $k = $k + 1; 91 | 92 | if ($member !== '') 93 | { 94 | $key .= '.' . $member; 95 | } 96 | } 97 | 98 | $key .= (($key === '') ? $k : '.' . $k); 99 | 100 | if (is_array($v)) 101 | { 102 | self::option_group($v, $member, $key, $out); 103 | } 104 | elseif ($v instanceof CFStepConfig) 105 | { 106 | self::option_group($v->get_config(), $member, $key, $out); 107 | } 108 | else 109 | { 110 | $out[$key] = $v; 111 | } 112 | 113 | $key = $reset; 114 | } 115 | } 116 | else 117 | { 118 | $out[$key] = $data; 119 | } 120 | 121 | return $out; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/hadoopstep.class.php: -------------------------------------------------------------------------------- 1 | object. 42 | */ 43 | protected static function script_runner($script, $args = null) 44 | { 45 | if (!$args) $args = array(); 46 | array_unshift($args, $script); 47 | 48 | return array( 49 | 'Jar' => 's3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar', 50 | 'Args' => $args 51 | ); 52 | } 53 | 54 | /** 55 | * Prepares a Hive or Pig script before passing it to the script runner. 56 | * 57 | * @param string $type (Required) The type of script to run. [Allowed values: `hive`, `pig`]. 58 | * @param array $args (Optional) An indexed array of arguments to pass to the script. 59 | * @return array A standard array that is intended to be passed into a object. 60 | * @link http://hive.apache.org Apache Hive 61 | * @link http://pig.apache.org Apache Pig 62 | */ 63 | protected static function hive_pig_script($type, $args = null) 64 | { 65 | if (!$args) $args = array(); 66 | $args = is_array($args) ? $args : array($args); 67 | $args = array_merge(array('--base-path', 's3://us-east-1.elasticmapreduce/libs/' . $type . '/'), $args); 68 | 69 | return self::script_runner('s3://us-east-1.elasticmapreduce/libs/' . $type . '/' . $type . '-script', $args); 70 | } 71 | 72 | 73 | /*%******************************************************************************************%*/ 74 | // USER-FACING METHODS 75 | 76 | /** 77 | * When ran as the first step in your job flow, enables the Hadoop debugging UI in the AWS 78 | * Management Console. 79 | * 80 | * @return array A standard array that is intended to be passed into a object. 81 | */ 82 | public static function enable_debugging() 83 | { 84 | return self::script_runner('s3://us-east-1.elasticmapreduce/libs/state-pusher/0.1/fetch'); 85 | } 86 | 87 | /** 88 | * Step that installs Hive on your job flow. 89 | * 90 | * @return array A standard array that is intended to be passed into a object. 91 | * @link http://hive.apache.org Apache Hive 92 | */ 93 | public static function install_hive() 94 | { 95 | return self::hive_pig_script('hive', '--install-hive'); 96 | } 97 | 98 | /** 99 | * Step that runs a Hive script on your job flow. 100 | * 101 | * @param string $script (Required) The script to run with `script-runner.jar`. 102 | * @param array $args (Optional) An indexed array of arguments to pass to the script. 103 | * @return array A standard array that is intended to be passed into a object. 104 | * @link http://hive.apache.org Apache Hive 105 | */ 106 | public static function run_hive_script($script, $args = null) 107 | { 108 | if (!$args) $args = array(); 109 | $args = is_array($args) ? $args : array($args); 110 | $args = array_merge(array('--run-hive-script', '--args', '-f', $script), $args); 111 | 112 | return self::hive_pig_script('hive', $args); 113 | } 114 | 115 | /** 116 | * Step that installs Pig on your job flow. 117 | * 118 | * @return array A standard array that is intended to be passed into a object. 119 | * @link http://pig.apache.org Apache Pig 120 | */ 121 | public static function install_pig() 122 | { 123 | return self::hive_pig_script('pig', '--install-pig'); 124 | } 125 | 126 | /** 127 | * Step that runs a Pig script on your job flow. 128 | * 129 | * @param string $script (Required) The script to run with `script-runner.jar`. 130 | * @param array $args (Optional) An indexed array of arguments to pass to the script. 131 | * @return array A standard array that is intended to be passed into a object. 132 | * @link http://pig.apache.org Apache Pig 133 | */ 134 | public static function run_pig_script($script, $args = null) 135 | { 136 | if (!$args) $args = array(); 137 | $args = is_array($args) ? $args : array($args); 138 | $args = array_merge(array('--run-pig-script', '--args', '-f', $script), $args); 139 | 140 | return self::hive_pig_script('pig', $args); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/info.class.php: -------------------------------------------------------------------------------- 1 | api_version; 64 | unset($obj); 65 | } 66 | 67 | return $collect; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/manifest.class.php: -------------------------------------------------------------------------------- 1 | function. 36 | * @return string A YAML manifest document. 37 | */ 38 | public static function json($json) 39 | { 40 | $map = json_decode($json, true); 41 | return sfYaml::dump($map); 42 | } 43 | 44 | /** 45 | * Takes an associative array to convert to a YAML manifest. 46 | * 47 | * @param array $map (Required) An associative array. 48 | * @return string A YAML manifest document. 49 | */ 50 | public static function map($map) 51 | { 52 | return sfYaml::dump($map); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/mimetypes.class.php: -------------------------------------------------------------------------------- 1 | 'video/3gpp', 36 | 'ai' => 'application/postscript', 37 | 'aif' => 'audio/x-aiff', 38 | 'aifc' => 'audio/x-aiff', 39 | 'aiff' => 'audio/x-aiff', 40 | 'asc' => 'text/plain', 41 | 'atom' => 'application/atom+xml', 42 | 'au' => 'audio/basic', 43 | 'avi' => 'video/x-msvideo', 44 | 'bcpio' => 'application/x-bcpio', 45 | 'bin' => 'application/octet-stream', 46 | 'bmp' => 'image/bmp', 47 | 'cdf' => 'application/x-netcdf', 48 | 'cgm' => 'image/cgm', 49 | 'class' => 'application/octet-stream', 50 | 'cpio' => 'application/x-cpio', 51 | 'cpt' => 'application/mac-compactpro', 52 | 'csh' => 'application/x-csh', 53 | 'css' => 'text/css', 54 | 'dcr' => 'application/x-director', 55 | 'dif' => 'video/x-dv', 56 | 'dir' => 'application/x-director', 57 | 'djv' => 'image/vnd.djvu', 58 | 'djvu' => 'image/vnd.djvu', 59 | 'dll' => 'application/octet-stream', 60 | 'dmg' => 'application/octet-stream', 61 | 'dms' => 'application/octet-stream', 62 | 'doc' => 'application/msword', 63 | 'dtd' => 'application/xml-dtd', 64 | 'dv' => 'video/x-dv', 65 | 'dvi' => 'application/x-dvi', 66 | 'dxr' => 'application/x-director', 67 | 'eps' => 'application/postscript', 68 | 'etx' => 'text/x-setext', 69 | 'exe' => 'application/octet-stream', 70 | 'ez' => 'application/andrew-inset', 71 | 'flv' => 'video/x-flv', 72 | 'gif' => 'image/gif', 73 | 'gram' => 'application/srgs', 74 | 'grxml' => 'application/srgs+xml', 75 | 'gtar' => 'application/x-gtar', 76 | 'gz' => 'application/x-gzip', 77 | 'hdf' => 'application/x-hdf', 78 | 'hqx' => 'application/mac-binhex40', 79 | 'htm' => 'text/html', 80 | 'html' => 'text/html', 81 | 'ice' => 'x-conference/x-cooltalk', 82 | 'ico' => 'image/x-icon', 83 | 'ics' => 'text/calendar', 84 | 'ief' => 'image/ief', 85 | 'ifb' => 'text/calendar', 86 | 'iges' => 'model/iges', 87 | 'igs' => 'model/iges', 88 | 'jnlp' => 'application/x-java-jnlp-file', 89 | 'jp2' => 'image/jp2', 90 | 'jpe' => 'image/jpeg', 91 | 'jpeg' => 'image/jpeg', 92 | 'jpg' => 'image/jpeg', 93 | 'js' => 'application/x-javascript', 94 | 'kar' => 'audio/midi', 95 | 'latex' => 'application/x-latex', 96 | 'lha' => 'application/octet-stream', 97 | 'lzh' => 'application/octet-stream', 98 | 'm3u' => 'audio/x-mpegurl', 99 | 'm4a' => 'audio/mp4a-latm', 100 | 'm4p' => 'audio/mp4a-latm', 101 | 'm4u' => 'video/vnd.mpegurl', 102 | 'm4v' => 'video/x-m4v', 103 | 'mac' => 'image/x-macpaint', 104 | 'man' => 'application/x-troff-man', 105 | 'mathml' => 'application/mathml+xml', 106 | 'me' => 'application/x-troff-me', 107 | 'mesh' => 'model/mesh', 108 | 'mid' => 'audio/midi', 109 | 'midi' => 'audio/midi', 110 | 'mif' => 'application/vnd.mif', 111 | 'mov' => 'video/quicktime', 112 | 'movie' => 'video/x-sgi-movie', 113 | 'mp2' => 'audio/mpeg', 114 | 'mp3' => 'audio/mpeg', 115 | 'mp4' => 'video/mp4', 116 | 'mpe' => 'video/mpeg', 117 | 'mpeg' => 'video/mpeg', 118 | 'mpg' => 'video/mpeg', 119 | 'mpga' => 'audio/mpeg', 120 | 'ms' => 'application/x-troff-ms', 121 | 'msh' => 'model/mesh', 122 | 'mxu' => 'video/vnd.mpegurl', 123 | 'nc' => 'application/x-netcdf', 124 | 'oda' => 'application/oda', 125 | 'ogg' => 'application/ogg', 126 | 'ogv' => 'video/ogv', 127 | 'pbm' => 'image/x-portable-bitmap', 128 | 'pct' => 'image/pict', 129 | 'pdb' => 'chemical/x-pdb', 130 | 'pdf' => 'application/pdf', 131 | 'pgm' => 'image/x-portable-graymap', 132 | 'pgn' => 'application/x-chess-pgn', 133 | 'pic' => 'image/pict', 134 | 'pict' => 'image/pict', 135 | 'png' => 'image/png', 136 | 'pnm' => 'image/x-portable-anymap', 137 | 'pnt' => 'image/x-macpaint', 138 | 'pntg' => 'image/x-macpaint', 139 | 'ppm' => 'image/x-portable-pixmap', 140 | 'ppt' => 'application/vnd.ms-powerpoint', 141 | 'ps' => 'application/postscript', 142 | 'qt' => 'video/quicktime', 143 | 'qti' => 'image/x-quicktime', 144 | 'qtif' => 'image/x-quicktime', 145 | 'ra' => 'audio/x-pn-realaudio', 146 | 'ram' => 'audio/x-pn-realaudio', 147 | 'ras' => 'image/x-cmu-raster', 148 | 'rdf' => 'application/rdf+xml', 149 | 'rgb' => 'image/x-rgb', 150 | 'rm' => 'application/vnd.rn-realmedia', 151 | 'roff' => 'application/x-troff', 152 | 'rtf' => 'text/rtf', 153 | 'rtx' => 'text/richtext', 154 | 'sgm' => 'text/sgml', 155 | 'sgml' => 'text/sgml', 156 | 'sh' => 'application/x-sh', 157 | 'shar' => 'application/x-shar', 158 | 'silo' => 'model/mesh', 159 | 'sit' => 'application/x-stuffit', 160 | 'skd' => 'application/x-koan', 161 | 'skm' => 'application/x-koan', 162 | 'skp' => 'application/x-koan', 163 | 'skt' => 'application/x-koan', 164 | 'smi' => 'application/smil', 165 | 'smil' => 'application/smil', 166 | 'snd' => 'audio/basic', 167 | 'so' => 'application/octet-stream', 168 | 'spl' => 'application/x-futuresplash', 169 | 'src' => 'application/x-wais-source', 170 | 'sv4cpio' => 'application/x-sv4cpio', 171 | 'sv4crc' => 'application/x-sv4crc', 172 | 'svg' => 'image/svg+xml', 173 | 'swf' => 'application/x-shockwave-flash', 174 | 't' => 'application/x-troff', 175 | 'tar' => 'application/x-tar', 176 | 'tcl' => 'application/x-tcl', 177 | 'tex' => 'application/x-tex', 178 | 'texi' => 'application/x-texinfo', 179 | 'texinfo' => 'application/x-texinfo', 180 | 'tif' => 'image/tiff', 181 | 'tiff' => 'image/tiff', 182 | 'tr' => 'application/x-troff', 183 | 'tsv' => 'text/tab-separated-values', 184 | 'txt' => 'text/plain', 185 | 'ustar' => 'application/x-ustar', 186 | 'vcd' => 'application/x-cdlink', 187 | 'vrml' => 'model/vrml', 188 | 'vxml' => 'application/voicexml+xml', 189 | 'wav' => 'audio/x-wav', 190 | 'wbmp' => 'image/vnd.wap.wbmp', 191 | 'wbxml' => 'application/vnd.wap.wbxml', 192 | 'webm' => 'video/webm', 193 | 'wml' => 'text/vnd.wap.wml', 194 | 'wmlc' => 'application/vnd.wap.wmlc', 195 | 'wmls' => 'text/vnd.wap.wmlscript', 196 | 'wmlsc' => 'application/vnd.wap.wmlscriptc', 197 | 'wmv' => 'video/x-ms-wmv', 198 | 'wrl' => 'model/vrml', 199 | 'xbm' => 'image/x-xbitmap', 200 | 'xht' => 'application/xhtml+xml', 201 | 'xhtml' => 'application/xhtml+xml', 202 | 'xls' => 'application/vnd.ms-excel', 203 | 'xml' => 'application/xml', 204 | 'xpm' => 'image/x-xpixmap', 205 | 'xsl' => 'application/xml', 206 | 'xslt' => 'application/xslt+xml', 207 | 'xul' => 'application/vnd.mozilla.xul+xml', 208 | 'xwd' => 'image/x-xwindowdump', 209 | 'xyz' => 'chemical/x-xyz', 210 | 'zip' => 'application/zip', 211 | ); 212 | 213 | /** 214 | * Attempt to match the file extension to a known mime-type. 215 | * 216 | * @param string $ext (Required) The file extension to attempt to map. 217 | * @return string The mime-type to use for the file extension. 218 | */ 219 | public static function get_mimetype($ext) 220 | { 221 | return (isset(self::$mime_types[$ext]) ? self::$mime_types[$ext] : 'application/octet-stream'); 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/policy.class.php: -------------------------------------------------------------------------------- 1 | (e.g. , ). 46 | * @param string|array $policy (Required) The associative array representing the S3 policy to use, or a string of JSON content. 47 | * @return $this A reference to the current instance. 48 | * @link http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?HTTPPOSTForms.html S3 Policies 49 | * @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?AccessPolicyLanguage.html Access Policy Language 50 | */ 51 | public function __construct($auth, $policy) 52 | { 53 | $this->auth = $auth; 54 | 55 | if (is_array($policy)) // We received an associative array... 56 | { 57 | $this->json_policy = json_encode($policy); 58 | } 59 | else // We received a valid, parseable JSON string... 60 | { 61 | $this->json_policy = json_encode(json_decode($policy, true)); 62 | } 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Get the key from the authenticated instance. 69 | * 70 | * @return string The key from the authenticated instance. 71 | */ 72 | public function get_key() 73 | { 74 | return $this->auth->key; 75 | } 76 | 77 | /** 78 | * Base64-encodes the JSON string. 79 | * 80 | * @return string The Base64-encoded version of the JSON string. 81 | */ 82 | public function get_policy() 83 | { 84 | return base64_encode($this->json_policy); 85 | } 86 | 87 | /** 88 | * Gets the JSON string with the whitespace removed. 89 | * 90 | * @return string The JSON string without extraneous whitespace. 91 | */ 92 | public function get_json() 93 | { 94 | return $this->json_policy; 95 | } 96 | 97 | /** 98 | * Gets the JSON string with the whitespace removed. 99 | * 100 | * @return string The Base64-encoded, signed JSON string. 101 | */ 102 | public function get_policy_signature() 103 | { 104 | return base64_encode(hash_hmac('sha1', $this->get_policy(), $this->auth->secret_key)); 105 | } 106 | 107 | /** 108 | * Decode a policy that was returned from the service. 109 | * 110 | * @param string $response (Required) The policy returned by AWS that you want to decode into an object. 111 | * @return string The Base64-encoded, signed JSON string. 112 | */ 113 | public static function decode_policy($response) 114 | { 115 | return json_decode(urldecode($response), true); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/request.class.php: -------------------------------------------------------------------------------- 1 | ). 33 | */ 34 | public $request_class = 'CFRequest'; 35 | 36 | /** 37 | * The default class to use for HTTP Responses (defaults to ). 38 | */ 39 | public $response_class = 'CFResponse'; 40 | 41 | 42 | /*%******************************************************************************************%*/ 43 | // CONSTRUCTOR 44 | 45 | /** 46 | * Constructs a new instance of this class. 47 | * 48 | * @param string $url (Optional) The URL to request or service endpoint to query. 49 | * @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` 50 | * @param array $helpers (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class. 51 | * @return $this A reference to the current instance. 52 | */ 53 | public function __construct($url = null, $proxy = null, $helpers = null) 54 | { 55 | parent::__construct($url, $proxy, $helpers); 56 | 57 | // Standard settings for all requests 58 | $this->add_header('Expect', '100-continue'); 59 | $this->set_useragent(CFRUNTIME_USERAGENT); 60 | 61 | return $this; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/response.class.php: -------------------------------------------------------------------------------- 1 | element. 49 | */ 50 | public function __call($name, $arguments) 51 | { 52 | // Remap $this 53 | $self = $this; 54 | 55 | // Re-base the XML 56 | $self = new CFSimpleXML($self->asXML()); 57 | 58 | // Determine XPath query 59 | $self->xpath_expression = 'descendant-or-self::' . $name; 60 | 61 | // Get the results and augment with CFArray 62 | $results = $self->xpath($self->xpath_expression); 63 | if (!count($results)) return false; 64 | $results = new CFArray($results); 65 | 66 | // If an integer was passed, return only that result 67 | if (isset($arguments[0]) && is_int($arguments[0])) 68 | { 69 | if (isset($results[$arguments[0]])) 70 | { 71 | return $results[$arguments[0]]; 72 | } 73 | 74 | return false; 75 | } 76 | 77 | return $results; 78 | } 79 | 80 | /** 81 | * Wraps the results of an XPath query in a object. 82 | * 83 | * @param string $expr (Required) The XPath expression to use to query the XML response. 84 | * @return CFArray A object containing the results of the XPath query. 85 | */ 86 | public function query($expr) 87 | { 88 | return new CFArray($this->xpath($expr)); 89 | } 90 | 91 | /** 92 | * Gets the parent or a preferred ancestor of the current element. 93 | * 94 | * @param string $node (Optional) Name of the ancestor element to match and return. 95 | * @return CFSimpleXML A object containing the requested node. 96 | */ 97 | public function parent($node = null) 98 | { 99 | if ($node) 100 | { 101 | $parents = $this->xpath('ancestor-or-self::' . $node); 102 | } 103 | else 104 | { 105 | $parents = $this->xpath('parent::*'); 106 | } 107 | 108 | return $parents[0]; 109 | } 110 | 111 | /** 112 | * Gets the current XML node as a true string. 113 | * 114 | * @return string The current XML node as a true string. 115 | */ 116 | public function to_string() 117 | { 118 | return (string) $this; 119 | } 120 | 121 | /** 122 | * Gets the current XML node as a true array. 123 | * 124 | * @return array The current XML node as a true array. 125 | */ 126 | public function to_array() 127 | { 128 | return new CFArray(json_decode(json_encode($this), true)); 129 | } 130 | 131 | /** 132 | * Whether or not the current node exactly matches the compared value. 133 | * 134 | * @param string $value (Required) The value to compare the current node to. 135 | * @return boolean Whether or not the current node exactly matches the compared value. 136 | */ 137 | public function is($value) 138 | { 139 | return ((string) $this === $value); 140 | } 141 | 142 | /** 143 | * Whether or not the current node contains the compared value. 144 | * 145 | * @param string $value (Required) The value to use to determine whether it is contained within the node. 146 | * @return boolean Whether or not the current node contains the compared value. 147 | */ 148 | public function contains($value) 149 | { 150 | return (stripos((string) $this, $value) !== false); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/stacktemplate.class.php: -------------------------------------------------------------------------------- 1 | strict JSON-specific formatting. 35 | * @return string A JSON representation of the template. 36 | */ 37 | public static function json($template) 38 | { 39 | return json_encode(json_decode($template, true)); 40 | } 41 | 42 | /** 43 | * Converts an associative array (map) of the template into a JSON string. 44 | * 45 | * @param array $template (Required) An associative array that maps directly to its JSON counterpart. 46 | * @return string A JSON representation of the template. 47 | */ 48 | public static function map($template) 49 | { 50 | return json_encode($template); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/stepconfig.class.php: -------------------------------------------------------------------------------- 1 | config = $config; 52 | } 53 | 54 | /** 55 | * Constructs a new instance of this class, and allows chaining. 56 | * 57 | * @param array $config (Required) An associative array representing the Hadoop step configuration. 58 | * @return $this A reference to the current instance. 59 | */ 60 | public static function init($config) 61 | { 62 | if (version_compare(PHP_VERSION, '5.3.0', '<')) 63 | { 64 | throw new Exception('PHP 5.3 or newer is required to instantiate a new class with CLASS::init().'); 65 | } 66 | 67 | $self = get_called_class(); 68 | return new $self($config); 69 | } 70 | 71 | /** 72 | * Returns a JSON representation of the object when typecast as a string. 73 | * 74 | * @return string A JSON representation of the object. 75 | * @link http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring PHP Magic Methods 76 | */ 77 | public function __toString() 78 | { 79 | return json_encode($this->config); 80 | } 81 | 82 | /** 83 | * Returns the configuration data. 84 | * 85 | * @return array The configuration data. 86 | */ 87 | public function get_config() 88 | { 89 | return $this->config; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /AWSSDKforPHP/utilities/utilities.class.php: -------------------------------------------------------------------------------- 1 | getConstant($const); 83 | } 84 | 85 | /** 86 | * Convert a HEX value to Base64. 87 | * 88 | * @param string $str (Required) Value to convert. 89 | * @return string Base64-encoded string. 90 | */ 91 | public function hex_to_base64($str) 92 | { 93 | $raw = ''; 94 | 95 | for ($i = 0; $i < strlen($str); $i += 2) 96 | { 97 | $raw .= chr(hexdec(substr($str, $i, 2))); 98 | } 99 | 100 | return base64_encode($raw); 101 | } 102 | 103 | /** 104 | * Convert an associative array into a query string. 105 | * 106 | * @param array $array (Required) Array to convert. 107 | * @return string URL-friendly query string. 108 | */ 109 | public function to_query_string($array) 110 | { 111 | $temp = array(); 112 | 113 | foreach ($array as $key => $value) 114 | { 115 | $temp[] = rawurlencode($key) . '=' . rawurlencode($value); 116 | } 117 | 118 | return implode('&', $temp); 119 | } 120 | 121 | /** 122 | * Convert an associative array into a sign-able string. 123 | * 124 | * @param array $array (Required) Array to convert. 125 | * @return string URL-friendly sign-able string. 126 | */ 127 | public function to_signable_string($array) 128 | { 129 | $t = array(); 130 | 131 | foreach ($array as $k => $v) 132 | { 133 | $t[] = $this->encode_signature2($k) . '=' . $this->encode_signature2($v); 134 | } 135 | 136 | return implode('&', $t); 137 | } 138 | 139 | /** 140 | * Encode the value according to RFC 3986. 141 | * 142 | * @param string $string (Required) String to convert. 143 | * @return string URL-friendly sign-able string. 144 | */ 145 | public function encode_signature2($string) 146 | { 147 | $string = rawurlencode($string); 148 | return str_replace('%7E', '~', $string); 149 | } 150 | 151 | /** 152 | * Convert a query string into an associative array. Multiple, identical keys will become an indexed array. 153 | * 154 | * @param string $qs (Required) Query string to convert. 155 | * @return array Associative array of keys and values. 156 | */ 157 | public function query_to_array($qs) 158 | { 159 | $query = explode('&', $qs); 160 | $data = array(); 161 | 162 | foreach ($query as $q) 163 | { 164 | $q = explode('=', $q); 165 | 166 | if (isset($data[$q[0]]) && is_array($data[$q[0]])) 167 | { 168 | $data[$q[0]][] = urldecode($q[1]); 169 | } 170 | else if (isset($data[$q[0]]) && !is_array($data[$q[0]])) 171 | { 172 | $data[$q[0]] = array($data[$q[0]]); 173 | $data[$q[0]][] = urldecode($q[1]); 174 | } 175 | else 176 | { 177 | $data[urldecode($q[0])] = urldecode($q[1]); 178 | } 179 | } 180 | return $data; 181 | } 182 | 183 | /** 184 | * Return human readable file sizes. 185 | * 186 | * @author Aidan Lister 187 | * @author Ryan Parman 188 | * @license http://www.php.net/license/3_01.txt PHP License 189 | * @param integer $size (Required) Filesize in bytes. 190 | * @param string $unit (Optional) The maximum unit to use. Defaults to the largest appropriate unit. 191 | * @param string $default (Optional) The format for the return string. Defaults to `%01.2f %s`. 192 | * @return string The human-readable file size. 193 | * @link http://aidanlister.com/repos/v/function.size_readable.php Original Function 194 | */ 195 | public function size_readable($size, $unit = null, $default = null) 196 | { 197 | // Units 198 | $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'); 199 | $mod = 1024; 200 | $ii = count($sizes) - 1; 201 | 202 | // Max unit 203 | $unit = array_search((string) $unit, $sizes); 204 | if ($unit === null || $unit === false) 205 | { 206 | $unit = $ii; 207 | } 208 | 209 | // Return string 210 | if ($default === null) 211 | { 212 | $default = '%01.2f %s'; 213 | } 214 | 215 | // Loop 216 | $i = 0; 217 | while ($unit != $i && $size >= 1024 && $i < $ii) 218 | { 219 | $size /= $mod; 220 | $i++; 221 | } 222 | 223 | return sprintf($default, $size, $sizes[$i]); 224 | } 225 | 226 | /** 227 | * Convert a number of seconds into Hours:Minutes:Seconds. 228 | * 229 | * @param integer $seconds (Required) The number of seconds to convert. 230 | * @return string The formatted time. 231 | */ 232 | public function time_hms($seconds) 233 | { 234 | $time = ''; 235 | 236 | // First pass 237 | $hours = (int) ($seconds / 3600); 238 | $seconds = $seconds % 3600; 239 | $minutes = (int) ($seconds / 60); 240 | $seconds = $seconds % 60; 241 | 242 | // Cleanup 243 | $time .= ($hours) ? $hours . ':' : ''; 244 | $time .= ($minutes < 10 && $hours > 0) ? '0' . $minutes : $minutes; 245 | $time .= ':'; 246 | $time .= ($seconds < 10) ? '0' . $seconds : $seconds; 247 | 248 | return $time; 249 | } 250 | 251 | /** 252 | * Returns the first value that is set. Based on [Try.these()](http://api.prototypejs.org/language/Try/these/) from [Prototype](http://prototypejs.org). 253 | * 254 | * @param array $attrs (Required) The attributes to test, as strings. Intended for testing properties of the $base object, but also works with variables if you place an @ symbol at the beginning of the command. 255 | * @param object $base (Optional) The base object to use, if any. 256 | * @param mixed $default (Optional) What to return if there are no matches. Defaults to `null`. 257 | * @return mixed Either a matching property of a given object, boolean `false`, or any other data type you might choose. 258 | */ 259 | public function try_these($attrs, $base = null, $default = null) 260 | { 261 | if ($base) 262 | { 263 | foreach ($attrs as $attr) 264 | { 265 | if (isset($base->$attr)) 266 | { 267 | return $base->$attr; 268 | } 269 | } 270 | } 271 | else 272 | { 273 | foreach ($attrs as $attr) 274 | { 275 | if (isset($attr)) 276 | { 277 | return $attr; 278 | } 279 | } 280 | } 281 | 282 | return $default; 283 | } 284 | 285 | /** 286 | * Can be removed once all calls are updated. 287 | * 288 | * @deprecated Use instead. 289 | * @param mixed $obj (Required) The PHP object to convert into a JSON string. 290 | * @return string A JSON string. 291 | */ 292 | public function json_encode($obj) 293 | { 294 | return json_encode($obj); 295 | } 296 | 297 | /** 298 | * Converts a SimpleXML response to an array structure. 299 | * 300 | * @param ResponseCore $response (Required) A response value. 301 | * @return array The response value as a standard, multi-dimensional array. 302 | */ 303 | public function convert_response_to_array(ResponseCore $response) 304 | { 305 | return json_decode(json_encode($response), true); 306 | } 307 | 308 | /** 309 | * Checks to see if a date stamp is ISO-8601 formatted, and if not, makes it so. 310 | * 311 | * @param string $datestamp (Required) A date stamp, or a string that can be parsed into a date stamp. 312 | * @return string An ISO-8601 formatted date stamp. 313 | */ 314 | public function convert_date_to_iso8601($datestamp) 315 | { 316 | if (!preg_match('/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}((\+|-)\d{2}:\d{2}|Z)/m', $datestamp)) 317 | { 318 | return gmdate(self::DATE_FORMAT_ISO8601, strtotime($datestamp)); 319 | } 320 | 321 | return $datestamp; 322 | } 323 | 324 | /** 325 | * Determines whether the data is Base64 encoded or not. 326 | * 327 | * @license http://us.php.net/manual/en/function.base64-decode.php#81425 PHP License 328 | * @param string $s (Required) The string to test. 329 | * @return boolean Whether the string is Base64 encoded or not. 330 | */ 331 | public function is_base64($s) 332 | { 333 | return (bool) preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $s); 334 | } 335 | 336 | /** 337 | * Decodes `\uXXXX` entities into their real unicode character equivalents. 338 | * 339 | * @param string $s (Required) The string to decode. 340 | * @return string The decoded string. 341 | */ 342 | public function decode_uhex($s) 343 | { 344 | preg_match_all('/\\\u([0-9a-f]{4})/i', $s, $matches); 345 | $matches = $matches[count($matches) - 1]; 346 | $map = array(); 347 | 348 | foreach ($matches as $match) 349 | { 350 | if (!isset($map[$match])) 351 | { 352 | $map['\u' . $match] = html_entity_decode('&#' . hexdec($match) . ';', ENT_NOQUOTES, 'UTF-8'); 353 | } 354 | } 355 | 356 | return str_replace(array_keys($map), $map, $s); 357 | } 358 | 359 | /** 360 | * Generates a random GUID. 361 | * 362 | * @author Alix Axel 363 | * @license http://www.php.net/license/3_01.txt PHP License 364 | * @return string A random GUID. 365 | */ 366 | public function generate_guid() 367 | { 368 | return sprintf( 369 | '%04X%04X-%04X-%04X-%04X-%04X%04X%04X', 370 | mt_rand(0, 65535), 371 | mt_rand(0, 65535), 372 | mt_rand(0, 65535), 373 | mt_rand(16384, 20479), 374 | mt_rand(32768, 49151), 375 | mt_rand(0, 65535), 376 | mt_rand(0, 65535), 377 | mt_rand(0, 65535) 378 | ); 379 | } 380 | } 381 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011 liip ag 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /buildAll.sh: -------------------------------------------------------------------------------- 1 | bash buildAndUpload.sh 5.3 && bash buildAndUpload.sh 5.4 && bash buildAndUpload.sh 5.5 2 | -------------------------------------------------------------------------------- /buildAndUpload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | run() { 4 | "$@" 5 | if [ $? -ne 0 ] 6 | then 7 | echo "$* failed with exit code $?" 8 | exit 1 9 | else 10 | return 0 11 | fi 12 | } 13 | 14 | OS_VERSION=`sw_vers -productVersion | grep -o 10\..` 15 | 16 | if [[ $OS_VERSION == "10.8" || [[ $OS_VERSION = "10.9" ]]; then 17 | OSNAME="mountainlion" 18 | else 19 | OSNAME="snowleopard" 20 | fi 21 | 22 | if [ -z $1 ]; then 23 | echo "Please state the PHP version to be compiled as 5.3, 5.4 or 5.5" 24 | exit 1; 25 | fi 26 | 27 | PHP_VERSION=$1 28 | PHP_VERSION_UNDERSCORE=$(echo $PHP_VERSION | sed -e 's/\./_/g') 29 | 30 | 31 | cd ../build-entropy-php 32 | 33 | run git remote update 34 | 35 | run git co ${PHP_VERSION_UNDERSCORE}_$OSNAME 36 | run git rebase origin/${PHP_VERSION_UNDERSCORE}_$OSNAME 37 | run sudo bash ./deletePeclSources.sh 38 | 39 | run sudo bash ./build-php.sh 40 | 41 | cd ../php-osx 42 | 43 | run bash create_package.sh $PHP_VERSION 44 | -------------------------------------------------------------------------------- /config.inc.php-dist: -------------------------------------------------------------------------------- 1 | . 53 | */ 54 | define('AWS_CLOUDFRONT_KEYPAIR_ID', ''); 55 | 56 | /** 57 | * The contents of the *.pem private key that matches with the CloudFront key-pair ID. Found in the AWS 58 | * Security Credentials. This can be set programmatically with . 59 | */ 60 | define('AWS_CLOUDFRONT_PRIVATE_KEY_PEM', ''); 61 | 62 | /** 63 | * Set the value to true to enable autoloading for classes not prefixed with "Amazon" or "CF". If enabled, 64 | * load `sdk.class.php` last to avoid clobbering any other autoloaders. 65 | */ 66 | define('AWS_ENABLE_EXTENSIONS', 'false'); 67 | -------------------------------------------------------------------------------- /create_package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # creates a local.ch package for the packager 3 | 4 | ORIPWD=$PWD 5 | OS_VERSION=`sw_vers -productVersion | egrep -o '10\.[0-9]+'` 6 | PHP_VERSION=`/usr/local/php5/bin/php -v | head -1` 7 | PHP_VERSION_FULL=`echo $PHP_VERSION | egrep -o '[5-9]\.[0-9]+\.[0-9][^ ]*' ` 8 | PHP_VERSION_MAJOR=`echo $PHP_VERSION_FULL | egrep -o '[5-9]\.[0-9]+'` 9 | 10 | # package type (subfolder in packager) 11 | 12 | TYPE=$PHP_VERSION_MAJOR 13 | echo "Detected PHP Version:" $TYPE; 14 | 15 | if [ -z $1 ]; then 16 | echo "" 17 | else 18 | if [[ $1 != $PHP_VERSION_MAJOR ]]; then 19 | echo "$1 and installed php version ($PHP_VERSION_MAJOR) mismatch. Aborting" 20 | exit 2; 21 | fi 22 | fi 23 | 24 | #if [[ $TYPE == "5.3" ]]; then 25 | # TYPE="tools" 26 | #fi 27 | 28 | if [[ $OS_VERSION == "10.8" ]]; then 29 | TYPE="$TYPE-10.8" 30 | elif [[ $OS_VERSION == "10.10" ]]; then 31 | TYPE="$TYPE-10.10" 32 | fi 33 | 34 | echo "Creating package for TYPE: $TYPE"; 35 | 36 | 37 | # name of the package 38 | NAME=frontenddev 39 | # create a revision 40 | REL=${PHP_VERSION_FULL}-$(date +%Y%m%d-%H%M%S) 41 | 42 | 43 | # root folder for the package creation 44 | root="/tmp/$NAME-package" 45 | 46 | USER=chregu 47 | 48 | # check if php was build localy 49 | if [ ! -d "/usr/local/php5" ]; then 50 | echo "you need to build php first!" 51 | exit 1 52 | fi 53 | if [ -h "/usr/local/php5" ]; then 54 | echo "Target is a symbolic link! Looks like you have a php5 package installed! Done..." 55 | exit 1 56 | fi 57 | 58 | echo "packaging ..." 59 | 60 | # remove root if it exists 61 | [ -d "$root" ] && rm -rf $root 62 | 63 | #create the package root folder 64 | mkdir $root 65 | mkdir -p $root/usr/local/ 66 | 67 | # copy the php5 package contents 68 | cp -R /usr/local/php5 $root/usr/local/php5-$REL 69 | 70 | # create metadata 71 | mkdir $root/pkg 72 | echo "name: $TYPE-$NAME 73 | version: $REL 74 | #depends: tools-memcached 75 | " >$root/pkg/info 76 | 77 | 78 | echo "downloading latest php.ini-liip" 79 | cp 99-liip-developer.ini $root/usr/local/php5-$REL/php.d/99-liip-developer.ini 80 | 81 | # generate post-initial (executed only on the inital, first installation) 82 | cp deploy/post-initial $root/pkg/post-initial 83 | 84 | # generate post-install 85 | echo "# post-install" >$root/pkg/post-install 86 | echo "# symlink" >>$root/pkg/post-install 87 | echo "rm -f '/usr/local/php5' && ln -s '/usr/local/php5-$REL' '/usr/local/php5'" >>$root/pkg/post-install 88 | echo "# create php.ini based on php.ini-development" >>$root/pkg/post-install 89 | echo "cp /usr/local/php5/lib/php.ini-development /usr/local/php5/lib/php.ini" >>$root/pkg/post-install 90 | cat update_httpd_conf.sh >> $root/pkg/post-install 91 | echo "# restart apache" >>$root/pkg/post-install 92 | echo "if sudo launchctl list | grep org.apache.httpd >/dev/null; then" >>$root/pkg/post-install 93 | echo "echo 'Restarting Apache'" >>$root/pkg/post-install 94 | echo "/usr/sbin/httpd -t && /usr/sbin/apachectl restart" >>$root/pkg/post-install 95 | echo "if [[ $? != 0 ]]; then" >>$root/pkg/post-install 96 | echo "echo '**********' ">>$root/pkg/post-install 97 | echo "echo 'INFO: If you got an error about incompatible libxml2 libraries, please restart apache by hand with:'" >>$root/pkg/post-install 98 | echo "echo 'sudo apachectl restart'" >>$root/pkg/post-install 99 | echo "echo '**********' ">>$root/pkg/post-install 100 | echo "fi" >>$root/pkg/post-install 101 | echo "fi" >>$root/pkg/post-install 102 | 103 | echo "Tag the release" 104 | ODIR=$PWD 105 | cd ../build-entropy-php/ 106 | git tag $REL-$TYPE 107 | cd $ODIR 108 | 109 | 110 | # tar the package 111 | cd $root 112 | 113 | echo "Tar the package $TYPE-$NAME-$REL.tar.bz2" 114 | tar -cjf ../$TYPE-$NAME-$REL.tar.bz2 --exclude 'share/doc/' --exclude 'man/' . || exit 1 115 | 116 | # upload to liip 117 | UPLOADDIR=/Volumes/s3-liip/php-osx.liip.ch/ 118 | UPLOADDIR=/tmp/ 119 | mkdir -p $UPLOADDIR/install/$TYPE/$NAME/ 120 | 121 | cd $ORIPWD 122 | 123 | php uploadFile.php $root/../$TYPE-$NAME-$REL.tar.bz2 install/$TYPE/$NAME/$TYPE-$NAME-$REL.tar.bz2 "application/x-gzip" 124 | 125 | echo "install/$TYPE/$NAME/$TYPE-$NAME-$REL.tar.bz2" > $UPLOADDIR/install/$TYPE-$NAME-latest.dat 126 | 127 | php uploadFile.php $root/../install/$TYPE-$NAME-latest.dat install/$TYPE-$NAME-latest.dat "text/plain" 128 | 129 | tar -czf /tmp/packager.tgz packager && php uploadFile.php /tmp/packager.tgz packager/packager.tgz "application/x-gzip" 130 | 131 | echo "Get latest uploaded versions on S3\n"; 132 | php getLatestVersions.php > index.html.bottom 133 | echo "" >> index.html.bottom 134 | cat index.html.tmpl index.html.bottom > index.html 135 | 136 | 137 | php uploadFile.php index.html index.html "text/html" 138 | php uploadFile.php install.sh install.sh "text/plain" 139 | 140 | echo "Invalidate CloudFront Cache"; 141 | php invalidateCloudfront.php 142 | 143 | #scp ../$TYPE-$NAME-$REL.tar.gz $USER@dev2.liip.ch:/home/liip/dev2/install/$TYPE/$NAME/ 144 | #ssh -l $USER dev2.liip.ch "ln -sf ../${TYPE}/${NAME}/${TYPE}-${NAME}-${REL}.tar.gz /home/liip/dev2/install/www/${TYPE}-${NAME}.tar.gz" 145 | 146 | echo "done ..." 147 | 148 | 149 | -------------------------------------------------------------------------------- /getLatestVersions.php: -------------------------------------------------------------------------------- 1 | get_object( 36 | 'php-osx.liip.ch', 37 | 'install/'.$src.'-frontenddev-latest.dat' 38 | ); 39 | 40 | 41 | if ($response->isOK()) { 42 | preg_match("/([5-9]\.[0-9]+)-(10\.[0-9]+){0,1}-*frontenddev-([0-9\.(alphabetaRC\-dev)]+)-([0-9]{8})-([0-9]+)/",$response->body,$matches); 43 | if ($matches[2] == "") { 44 | $matches[2] = "10.6 /10.7 "; 45 | } 46 | if ($matches[2] == "10.8") { 47 | $matches[2] = "10.8 /10.9 "; 48 | } 49 | if ($matches[2] == "10.10") { 50 | $matches[2] = "10.10-10.13"; 51 | } 52 | preg_match("/([0-9]{4})([0-9]{2})([0-9]{2})/",$matches[4],$date); 53 | $text = "PHP " . $matches[3] . " for OS X " . $matches[2] . " uploaded at " . $date[1] ."-" . $date[2] . "-" . $date[3] ."\n"; 54 | 55 | 56 | } else { 57 | print "failed \n"; 58 | } 59 | return $text; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /index.html.tmpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PHP for OS X / macOS as binary package 7 | 57 | 69 | 70 | 71 | 72 | 73 |

PHP 5.3 to 7.3 for OS X / macOS 10.6 to 10.13
as binary package

74 | 75 |
76 | 77 | Installation | 78 | FAQ | 79 | Additional important notes | 80 | 81 | (Alternative) Installation by "hand" | 82 | 83 | Included extensions | 84 | Uninstall | 85 | 86 | Source code | 87 | Thanks | 88 | Support | 89 | Latest releases 90 | 91 |

Intro

92 |

This package installs the (usually) latest PHP 7.3/7.2/7.1/7.0/5.6/5.5/5.4/5.3 on OS X 10.6 (aka Snow Leopard), 93 | OS X 10.7 (aka Lion) 94 | and OS X 10.8 (aka Mountain Lion) 95 | and OS X 10.9 (aka Mavericks) 96 | and OS X 10.10 (aka Yosemite) 97 | and OS X 10.11 (aka El Capitan) 98 | and macOS 10.12 (aka Sierra) 99 | and macOS 10.13 (aka High Sierra) 100 | in /usr/local/php5. It installs many useful extensions (see below) and ini-settings and is what we at Liip 101 | use for our development. It's especially suited for Symfony 2 development. 102 | 103 | It also provides a decent php.ini with all settings configured according to "Best Practices". 104 | 105 |

106 |

It doesn't install Apache, MySQL or any other external programs. It uses the Apache installation, which comes with OS X and for installing MySQL you can for example use 107 | Homebrew. The package is based on entropy's php package 108 | . 109 |

110 | 111 |

112 | One Line Installation 113 |

114 |

All you need to do to install the whole thing is opening up a Shell and execute the following line: 115 |

116 |

PHP 7.3 (Next stable) - 10.10 and later

117 |
118 | curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
119 | 
120 |

PHP 7.2 (Current stable) - 10.10 and later

121 |
122 | curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2
123 | 
124 |

PHP 7.1 (Old stable) - 10.10 and later

125 |
126 | curl -s https://php-osx.liip.ch/install.sh | bash -s 7.1
127 | 
128 |

PHP 7.0 (Old stable) - 10.10 and later

129 |
130 | curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
131 | 
132 |

PHP 5.6 (Old stable) - 10.8 and later

133 |
134 | curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
135 | 
136 |

PHP 5.5 (End of life) - All OS X versions

137 |
138 | curl -s https://php-osx.liip.ch/install.sh | bash -s 5.5
139 | 
140 |

PHP 5.4 (End of life) - All OS X versions

141 |
142 | curl -s https://php-osx.liip.ch/install.sh | bash -s 5.4
143 | 
144 |

PHP 5.3 (End of life) - All OS X versions

145 |
146 | curl -s https://php-osx.liip.ch/install.sh | bash -s 5.3
147 | 
148 |

149 | It will ask you for your password. We install the packager in /usr/local/packer and PHP into 150 | /usr/local/php5 and for this, we need your password. We don't do anything bad with it. 151 | 152 |

153 | 154 | 155 |

Frequently Asked Questions

156 | 157 |

Why does php -v on the command line still show my old version?

158 |

php-osx doesn't overwrite the php binaries installed by Apple, but installs everything in /usr/local/php5. 159 | The new php binary is therefore in /usr/local/php5/bin/php.

160 | 161 |

You can also adjust your PATH do include that directory, eg. write into your ~/.profile file the following 162 |

163 | export PATH=/usr/local/php5/bin:$PATH
164 | 
165 |

166 |

Why is Europe/Zurich the default timezone? Where to change that?

167 | 168 |

Because we are based in Zurich (and Fribourg and Lausanne). Change the file in /usr/local/php5/php.d/99-liip-developer.ini to adjust that.

169 | 170 | 171 |

It doesn't take my php.ini values

172 | 173 |

We introduced our own ini file to be able to easily overwrite the standard values with our recommended values. You can find it in /usr/local/php5/php.d/99-liip-developer.ini 174 |

175 |

As this is read last, it will overwrite values defined in other files. You can also just delete the file.

176 | 177 |

Why is the MySQL Socket configured to use /tmp/mysql.sock and how to change that?

178 | 179 |

If you download the native binary from mysql.com, that server uses /tmp/mysql.sock as its socket location (see this). Therefore we choose that value as default.

180 |

You can change that value in /usr/local/php5/php.d/99-liip-developer.ini

181 | 182 |

How to install pecl extensions?

183 | 184 |
185 | sudo /usr/local/php5/bin/pecl install pecl_http
186 | 
187 | 188 |

Where is the memcached daemon?

189 | 190 |

We started not including the memcached daemon anymore. But you can install it by hand with

191 |
192 |  sudo /usr/local/packager/packager.py install tools-memcached
193 | 
194 | 195 |

How can I help?

196 | 197 |

This project is hosted on github here https://github.com/liip/build-entropy-php/. The website itself and install.sh 198 | is hosted on https://github.com/liip/php-osx/. 199 | It's all Open Source, so feel free to fork it and send Pull Requests, if you want to change/fix something.

200 | 201 |

I have more questions. Where to put them?

202 | 203 |

You have basically three options: 204 |

209 | 210 |

Additional important notes

211 | 212 |

32 bit only systems (no workie)

213 |

214 | It only works on a 64-bit-capable system. This means not on very old hardware with Intel Core Duo and Intel Core Solo processors (see http://support.apple.com/kb/ht3696 for the overview). If anyone wants to make it work on those systems too, please tell us how (We tried, but didn't came up with anything running in a decent amount of time) 215 |

216 | 217 |

php.ini

218 |

The php.ini is located in /usr/local/php5/lib/php.ini, additional config files are located in /usr/local/php5/php.d/. The php.ini is based on php.ini-development

219 | 220 |

Liip php.ini

221 |

222 | The Liip php.ini for development is located in /usr/local/php5/php.d/99-liip-developer.ini. 223 |

224 | 225 |

Re-installs into new directory

226 |

227 | All installed files go in a new directory with every update, you have to manually maintain/merge your changes from the old directory! (like pear installs) 228 |

229 | 230 |

apc, twig and xslcache

231 |

232 | apc, twig and xslcache need to be enabled manually in /usr/local/php5/php.d/50-extension-$name.ini. 233 |

234 | 235 |

xdebug

236 |

xdebug settings needs to be configured (idekey etc) manually in /usr/local/php5/php.d/50-extension-xdebug.ini. 237 |

238 |

apache error with ulimit

239 |

240 | If you are seeing "/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument" when loading apache, here is a fix 241 |

242 | 243 | 244 |

More history and all that

245 |

246 | See this blog post for even more background info. 247 |

248 | 249 | 250 | 251 | 252 |

(Alternative) Installation by "hand"

253 |

254 | If you don't trust us, here's the code of install.sh, which you can run by yourself (instead of the one-liner above): 255 | 256 |

257 |
258 | curl -s -o /tmp/packager.tgz https://php-osx.liip.ch/packager/packager.tgz
259 | sudo tar -C /usr/local  -xzf /tmp/packager.tgz
260 | sudo /usr/local/packager/packager.py install 5.4-frontenddev
261 | 
262 |

263 | If you already have installed the packager and just want to update the PHP package, you can do it with 264 | the following line. 265 | 266 |

267 |
268 | sudo /usr/local/packager/packager.py install tools-frontenddev
269 | 
270 | 
271 | 272 | 281 |

Included extensions

282 |

283 | bcmath 284 | bz2 285 | calendar 286 | Core 287 | ctype 288 | curl 289 | date 290 | dom 291 | dtrace 292 | ereg 293 | exif 294 | fileinfo 295 | filter 296 | ftp 297 | gd 298 | gettext 299 | hash 300 | iconv 301 | imap 302 | intl 303 | json 304 | ldap 305 | libxml 306 | mbstring 307 | mcrypt 308 | memcache 309 | memcached 310 | mhash 311 | mongodb 312 | odbc 313 | mysql 314 | mysqli 315 | mysqlnd 316 | OAuth 317 | odbc 318 | openssl 319 | pcntl 320 | pcre 321 | PDO 322 | pdo_dblib 323 | pdo_mysql 324 | pdo_pgsql 325 | pdo_sqlite 326 | pgsql 327 | Phar 328 | posix 329 | Reflection 330 | session 331 | shmop 332 | SimpleXML 333 | soap 334 | sockets 335 | solr 336 | SPL 337 | SQLite 338 | sqlite3 339 | standard 340 | sysvmsg 341 | sysvsem 342 | sysvshm 343 | tidy 344 | tokenizer 345 | wddx 346 | xdebug 347 | xhprof 348 | xml 349 | xmlreader 350 | xmlrpc 351 | xmlwriter 352 | xsl 353 | zip 354 | zlib 355 | Xdebug 356 |

357 |

available but disabled by default: apc, xslcache, twig, uploadprogress 358 | 359 |

360 |

See this output of phpinfo() for more info.

361 | 362 | 363 | 364 | 365 | 366 |

Uninstall

367 | 368 |

Change in /etc/apache2/httpd.conf

369 | 370 |
LoadModule php5_module /usr/local/php5/libphp5.so
371 | 
372 | 373 |

to

374 | 375 |
LoadModule php5_module        libexec/apache2/libphp5.so
376 | 
377 | 378 | 379 |

also delete the file +php-osx.conf and +entropy-php.conf in /etc/apache2/other 380 |

and optionally remove /usr/local/php5-*

381 | 382 | 383 |

Reinstall

384 | 385 |

To reinstall an already installed package, it's version has to be removed from the file /usr/local/packager/registry.log.

386 |
sudo $EDITOR /usr/local/packager/registry.log
387 | 388 |

To forget all installed packages simply remove the file:

389 |
sudo rm -rf /usr/local/packager/registry.log
390 | 391 | 392 |

Source Code 393 |

394 |
    395 |
  • 396 | build-entropy-php. Needed for generating the PHP binaries and all the needed libraries 397 |
  • 398 |
  • 399 | packager by local.ch. This downloads and install the package on your computer. 400 | 401 |
  • 402 |
  • 403 | php-osx. The scripts needed for doing the package and this webpage 404 | 405 |
  • 406 | 407 |
408 | 409 |

Thanks 410 |

411 |

412 | Thanks to Local.ch, which made all the groundwork for this. And thanks to Liip (and especially Patrick) for everything else. 413 |

414 | 415 |

Local.ch Liip

416 | 417 |

Support 418 |

419 |

420 | We can't provide support for this, but Pull Requests are always welcome. And use the github issues page 421 | for filing bug reports. 422 |

423 | 432 |

Latest releases 433 |

434 |
435 | 


--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
  1 | #!/bin/bash
  2 | 
  3 | # package type (subfolder in packager)
  4 | 
  5 | # default version to install
  6 | DEFAULT=5.6
  7 | 
  8 | if [ -z $1 ]; then
  9 | 	TYPE=$DEFAULT
 10 | else
 11 | 	TYPE=$1
 12 | fi
 13 | 
 14 | if [[ $TYPE = "force" ]]; then
 15 | 	if [ -z $2 ]; then
 16 | 		TYPE=$DEFAULT
 17 | 	else
 18 | 		TYPE=$2
 19 | 	fi
 20 | fi
 21 | 
 22 | if [[ $TYPE != "force" ]]; then
 23 |     OS_VERSION_PATCH=`sw_vers -productVersion | egrep --color=never -o '10\.[0-9]+\.[0-9]+'`
 24 |     OS_VERSION=`echo $OS_VERSION_PATCH | cut -f 1,2 -d "."`
 25 |     OS_SUB=`echo $OS_VERSION_PATCH | cut -f 2 -d "."`
 26 |     OS_SUB=`expr $OS_SUB`
 27 |     OS_PATCH=`echo $OS_VERSION_PATCH | cut -f 3 -d "."`
 28 |     OS_PATCH=`expr $OS_PATCH`
 29 |     if [[ $OS_VERSION == "10.15" ]]; then
 30 |             echo "Detected macOS Catalina 10.15. All ok."
 31 |     elif [[ $OS_VERSION == "10.14" ]]; then
 32 |         if [[ $OS_PATCH < 4 ]]; then
 33 |             echo "****"
 34 |             echo "[WARNING]"
 35 |             echo "Detected macOS Mojave <= 10.14.3. There are serious issues with it, due to the original apache not loading"
 36 |             echo "foreign libraries anymore. PHP within apache will most certainly not work anymore if you proceed!"
 37 |             echo "The cli version still will."
 38 |             echo "See this issue at https://github.com/liip/php-osx/issues/249 for details and discussion"
 39 |             echo "****"
 40 |             if [[ $1 = "force" ]]; then
 41 |               echo "Proceeding"
 42 |             else
 43 |                 echo "Restart this script with"
 44 |                 echo " curl -s https://php-osx.liip.ch/install.sh | bash -s force $1"
 45 |                 echo "to really install it"
 46 |                 echo "****"
 47 |                 exit 1
 48 |             fi
 49 |         else
 50 |             echo "Detected macOS Mojave >= 10.14.4. All ok."
 51 |         fi
 52 | 	elif [[ $OS_VERSION == "10.13" ]]; then
 53 |                 echo "Detected macOS High Sierra 10.13. All ok."
 54 | 	elif [[ $OS_VERSION == "10.12" ]]; then
 55 | 		echo "Detected macOS Sierra 10.12. All ok."
 56 | 	elif [[ $OS_VERSION == "10.11" ]]; then
 57 | 		echo "Detected OS X El Capitan 10.11. All ok."
 58 | 	elif [[ $OS_VERSION == "10.10" ]]; then
 59 | 		echo "Detected OS X Yosemite 10.10. All ok."
 60 | 	elif [[ $OS_VERSION == "10.9" ]]; then
 61 | 		echo "Detected OS X Mavericks 10.9 All ok."
 62 | 	elif [[ $OS_VERSION == "10.8" ]]; then
 63 | 		echo "Detected OS X Mountain Lion 10.8 All ok."
 64 | 	elif [[ $OS_VERSION == "10.7" ]]; then
 65 | 		echo "Detected OS X Lion 10.7. All ok."
 66 | 	elif [[ $OS_VERSION == "10.6" ]]; then
 67 | 		echo "Detected OS X Snow Leopard 10.6 All ok."
 68 | 	else
 69 | 		echo "****"
 70 | 		echo "Your version of OS X ($OS_VERSION) is not supported, you need at least 10.6"
 71 | 		echo "Stopping installation..."
 72 | 		echo "If you think that's wrong, try"
 73 | 		echo "****"
 74 | 		echo "curl -o install.sh -s https://php-osx.liip.ch/install.sh | bash install.sh force"
 75 | 		echo "****"
 76 | 		exit 2
 77 | 	fi
 78 | 	if [[ -f /usr/sbin/sysctl ]]; then
 79 | 	    SYSCTL="/usr/sbin/sysctl"
 80 | 	elif [[ -f /sbin/sysctl ]]; then
 81 | 	    SYSCTL="/sbin/sysctl"
 82 | 	else
 83 | 	    SYSCTL="sysctl"
 84 | 	fi
 85 | 
 86 | 	HAS64BIT=`$SYSCTL -n hw.cpu64bit_capable 2> /dev/null`
 87 | 	if [[ $HAS64BIT != 1 ]]; then
 88 | 		echo "****"
 89 | 		echo "ERROR! 32 BIT NOT SUPPORTED!"
 90 | 		echo "****"
 91 | 		echo "No 64bit capable system found. Your hardware is too old."
 92 | 		echo "We don't support that (yet). Patches are welcome ;)"
 93 | 		echo "If you think that's wrong, try"
 94 | 		echo "****"
 95 | 		echo "curl -o install.sh -s https://php-osx.liip.ch/install.sh | bash install.sh force"
 96 | 		echo "****"
 97 | 		exit 1
 98 | 	fi
 99 | fi
100 | 
101 | 
102 | 
103 | if [[ $OS_VERSION = "10.8" ]] || [[ $OS_VERSION = "10.9" ]]; then
104 | 	if [[ $TYPE = "5.4" ]]; then
105 | 		TYPE=5.4-10.8
106 | 	elif [[ $TYPE = "5.5" ]]; then
107 | 		TYPE=5.5-10.8
108 | 	elif [[ $TYPE = "5.6" ]]; then
109 | 		TYPE=5.6-10.8
110 | 	elif [[ $TYPE = "5.3" ]]; then
111 | 	   TYPE=5.3-10.8
112 | 	fi
113 | fi
114 | 
115 | # 10.11 and later should be compatible with 10.10 versions for now.
116 | # See https://github.com/liip/build-entropy-php/issues/16 for more
117 | if [[ $OS_SUB -gt 9 ]]; then
118 | 	if [[ $TYPE = "5.4" ]]; then
119 | 		TYPE=5.4-10.10
120 | 	elif [[ $TYPE = "5.5" ]]; then
121 | 		TYPE=5.5-10.10
122 | 	elif [[ $TYPE = "5.6" ]]; then
123 | 		TYPE=5.6-10.10
124 | 	elif [[ $TYPE = "7.0" ]]; then
125 | 		TYPE=7.0-10.10
126 | 	elif [[ $TYPE = "7.1" ]]; then
127 | 		TYPE=7.1-10.10
128 | 	elif [[ $TYPE = "7.2" ]]; then
129 | 		TYPE=7.2-10.10
130 | 	elif [[ $TYPE = "7.3" ]]; then
131 | 		TYPE=7.3-10.10
132 | 	elif [[ $TYPE = "5.3" ]]; then
133 | 		TYPE=5.3-10.10
134 | 	fi
135 | fi
136 | 
137 | if [[ $TYPE = "5.6" ]]; then
138 | 	echo "PHP 5.6 is not available for OS X < 10.8"
139 | 	exit 1
140 | elif [[ $TYPE = "7.3" ]]; then
141 | 	echo "PHP 7.3 is not available for OS X < 10.10"
142 | 	exit 1
143 | elif [[ $TYPE = "7.2" ]]; then
144 | 	echo "PHP 7.2 is not available for OS X < 10.10"
145 | 	exit 1
146 | elif [[ $TYPE = "7.1" ]]; then
147 | 	echo "PHP 7.1 is not available for OS X < 10.10"
148 | 	exit 1
149 | elif [[ $TYPE = "7.0" ]]; then
150 | 	echo "PHP 7.0 is not available for OS X < 10.10"
151 | 	exit 1
152 | fi
153 | 
154 | 
155 | 
156 | echo "Get packager.tgz";
157 | curl -s -o /tmp/packager.tgz https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/packager/packager.tgz
158 | 
159 | echo "Unpack packager.tgz";
160 | echo "Please type in your password, as we want to install this into /usr/local"
161 | if [ !  -d /usr/local ] ; then sudo mkdir /usr/local; fi
162 | sudo  tar -C /usr/local -xzf /tmp/packager.tgz
163 | 
164 | if [[ -f /usr/bin/python2.7 ]]; then
165 |    PYTHONPATH=/usr/bin/python2.7
166 | elif [[ -f /usr/bin/python2.6 ]]; then
167 |    PYTHONPATH=/usr/bin/python2.6
168 | elif [[ -f /usr/bin/python ]]; then
169 |    PYTHONPATH=/usr/bin/python
170 | else
171 |    PYTHONPATH=$(which python)
172 | fi
173 | 
174 | echo "Start packager (may take some time) using $PYTHONPATH";
175 | 
176 | sudo $PYTHONPATH /usr/local/packager/packager.py install $TYPE-frontenddev
177 | cd $ORIPWD
178 | echo "Finished."
179 | 


--------------------------------------------------------------------------------
/install_vendors.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | 
3 | # Packager
4 | git clone git@github.com:liip/packager.git packager
5 | 
6 | 


--------------------------------------------------------------------------------
/invalidateCloudfront.php:
--------------------------------------------------------------------------------
 1 | create_invalidation("E3GN2MEVU47B0I", uniqid("uploadScript"), '*');
 7 | 
 8 | 
 9 | 
10 | 
11 | 


--------------------------------------------------------------------------------
/liip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liip/php-osx/d191b3efcbaeaeee8ab51b8158286371747da133/liip.png


--------------------------------------------------------------------------------
/local.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/liip/php-osx/d191b3efcbaeaeee8ab51b8158286371747da133/local.gif


--------------------------------------------------------------------------------
/update_httpd_conf.sh:
--------------------------------------------------------------------------------
 1 | # try to update http.conf if there's the standard config
 2 | SEARCH=`httpd -MT 2> /dev/null| grep php5`
 3 | if [[ -n $SEARCH ]]
 4 | then
 5 | #deactivate php5_module in httpd.conf
 6 | apxs -e -A -n php5 libphp5.so 2> /dev/null
 7 | #search of there's an old entry to /usr/local/php5/libphp5.so in httpd.conf
 8 | SEARCH2=`grep /usr/local/php5/libphp5.so /etc/apache2/httpd.conf `
 9 | if [[ -n $SEARCH2 ]]
10 | then
11 | cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.before-phposx
12 | # remove the old line from httpd.conf
13 | sed 's/LoadModule php5_module \/usr\/local\/php5\/libphp5.so//' < /etc/apache2/httpd.conf.before-phposx > /etc/apache2/httpd.conf
14 | fi
15 | fi
16 | 
17 | # OS X 10.6 doesn't have an other directoty
18 | if [[ -d /etc/apache2/other ]]
19 | then
20 |     if [[ ! -h /etc/apache2/other/+php-osx.conf ]]
21 |     then
22 |       echo "Create symlink /usr/local/php5/entropy-php.conf /etc/apache2/other/+php-osx.conf"
23 |       ln -s /usr/local/php5/entropy-php.conf /etc/apache2/other/+php-osx.conf
24 |     fi
25 | else
26 |     if [[ ! -h /etc/apache2/sites/+php-osx.conf ]]
27 |     then
28 |       echo "Create symlink /usr/local/php5/entropy-php.conf /etc/apache2/sites/+php-osx.conf"
29 |       ln -s /usr/local/php5/entropy-php.conf /etc/apache2/sites/+php-osx.conf
30 |     fi
31 | fi
32 | 
33 | # try adjusting /usr/sbin/envvars
34 | DYLD_PATH=`. /usr/sbin/envvars && echo $DYLD_LIBRARY_PATH | grep /usr/lib:`
35 | if [[ -n $DYLD_PATH ]]
36 | then
37 | echo "#added by php-osx" >> /usr/sbin/envvars
38 | echo 'DYLD_LIBRARY_PATH="'` echo -n $DYLD_LIBRARY_PATH | sed 's/\/usr\/lib://' `'"' >> /usr/sbin/envvars
39 | echo 'export DYLD_LIBRARY_PATH' >> /usr/sbin/envvars
40 | echo "Removed /usr/lib from DYLD_LIBRARY_PATH in /usr/sbin/envvars"
41 | fi
42 | 


--------------------------------------------------------------------------------
/update_vendors.sh:
--------------------------------------------------------------------------------
 1 | #!/bin/sh
 2 | 
 3 | 
 4 | 
 5 | # Packager
 6 | cd packager
 7 | 
 8 | git pull 
 9 | 
10 | 


--------------------------------------------------------------------------------
/uploadFile.php:
--------------------------------------------------------------------------------
 1 | create_object('php-osx.liip.ch', $dst, array(
27 |     'fileUpload' => $src,
28 |     'acl' => AmazonS3::ACL_PUBLIC,
29 |     'contentType' => $type,
30 |     'storage' => AmazonS3::STORAGE_REDUCED,
31 | 
32 |     ));
33 | 
34 |     // Success?
35 | 
36 |     if ($response->isOK()) {
37 |         print "done\n";
38 |     } else {
39 |         print "failed \n";
40 |     }
41 | 
42 | }
43 | 


--------------------------------------------------------------------------------
/upload_info.sh:
--------------------------------------------------------------------------------
1 | wget -O info.html http://localhost/info.php && php uploadFile.php info.html info.html "text/html"
2 | 


--------------------------------------------------------------------------------