-
Notifications
You must be signed in to change notification settings - Fork 0
/
assignment2.php
52 lines (41 loc) · 1.05 KB
/
assignment2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* AWS Template Generator test harness
*
* PHP version 7
*
* @category N/A
* @package N/A
* @author Bill Hayden <[email protected]>
* @copyright 2017 Bill Hayden
* @license Public Domain
* @link https://github.com/haydentech/vanad2
*/
require_once "AWS_Template.php";
if (php_sapi_name() == 'cli') {
$shortopts = '';
$longopts = array(
'instances:',
'instance-type:',
'allow-ssh-from:'
);
$options = getopt($shortopts, $longopts);
} else {
$options = &$_GET;
}
$aws_template = new AWS_Template_Generator();
if (array_key_exists('instance-type', $options)) {
$aws_template->setInstanceType($options['instance-type']);
}
if (array_key_exists('instances', $options)) {
$aws_template->setInstanceCount((int)$options['instances']);
}
if (array_key_exists('allow-ssh-from', $options)) {
$aws_template->setSSHAllowedRange($options['allow-ssh-from']);
}
if (php_sapi_name() == 'cli') {
print($aws_template->textOutput());
} else {
print($aws_template->htmlOutput());
}
?>