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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
<?php
//
// Adding / editing a stackbuild application
//
// $Id: applicationedit.php,v 1.2 2007-09-12 19:45:39 mha Exp $
//
class Admin_ApplicationEdit extends PgForm {
function __construct() {
$this->navsection = 'admin';
}
function SetupForm() {
$DoCopy = false;
if ('POST' != $_SERVER['REQUEST_METHOD']) {
if (isset($_GET['action']) && $_GET['action'] == 'del') {
if (empty($_GET['id']) || empty($_GET['version']) || empty($_GET['platform'])) {
throw new Exception('Id, version or platform not specified');
}
$this->pg_query("DELETE FROM applications WHERE id='" . pg_escape_string($_GET['id']) . "' AND version='" . pg_escape_string($_GET['version']) . "' AND platform='" . pg_escape_string($_GET['platform']) . "'");
header('Location: applications.php');
exit(0);
} else if (isset($_GET['action']) && $_GET['action'] == 'cp') {
$DoCopy = true;
}
if (!empty($_GET['id']) && !empty($_GET['version']) && !empty($_GET['platform'])) {
$rs = $this->pg_query(
"SELECT id AS origid,version AS origversion,platform AS origplatform,id,version,platform,secondaryplatform,name,NULLIF(active,false) AS active,description,category,pgversion,edbversion,format,installoptions,upgradeoptions,checksum,mirrorpath,alturl,dependencies,versionkey FROM applications WHERE id='" . pg_escape_string($_GET['id']) . "' AND version='" . pg_escape_string($_GET['version']) . "' AND platform='" . pg_escape_string($_GET['platform']) . "'");
if (pg_num_rows($rs)) {
$defaults = pg_fetch_array($rs, 0, PGSQL_ASSOC);
}
}
$this->form->setDefaults($defaults);
}
$txtf = array('size' => 52);
$txta = array('cols' => 40, 'rows'=>8);
if ($DoCopy == false) {
$this->form->addElement('hidden','origid');
$this->form->addElement('hidden','origversion');
$this->form->addElement('hidden','origplatform');
}
$this->form->addElement('text','id','ID', $txtf);
$this->form->addElement('text','version','Version', $txtf);
$this->form->addElement('select','platform','Platform',$this->fetch_platform_list());
$this->form->addElement('select','secondaryplatform','Secondary Platform',$this->fetch_secondaryplatform_list());
$this->form->addElement('text','name','Name', $txtf);
$this->form->addElement('checkbox','active',null,'Is active? (<b>Always</b> verify all data before activating!)');
$this->form->addElement('textarea','description','Description',$txta);
$this->form->addElement('text','category','Category', $txtf);
$this->form->addElement('text','pgversion','PostgreSQL version', $txtf);
$this->form->addElement('text','edbversion','EnterpriseDB version', $txtf);
$this->form->addElement('select','format','Format',$this->fetch_format_list());
$this->form->addElement('text','installoptions','Install options', $txtf);
$this->form->addElement('text','upgradeoptions', 'Upgrade options', $txtf);
$this->form->addElement('text','checksum','Checksum', $txtf);
$this->form->addElement('text','mirrorpath','Mirror path', $txtf);
$this->form->addElement('text','alturl','Alternate URL', $txtf);
$this->form->addElement('text','dependencies','Dependencies (varchar[])', $txtf);
$this->form->addElement('text','versionkey','Version registry key', $txtf);
}
function ProcessForm($f) {
$origid = pg_escape_string($f['origid']);
$origversion = pg_escape_string($f['origversion']);
$origplatform = pg_escape_string($f['origplatform']);
$id = pg_escape_string($f['id']);
$version = pg_escape_string($f['version']);
$platform = pg_escape_string($f['platform']);
$secondaryplatform = pg_escape_string($f['secondaryplatform']);
$name = pg_escape_string($f['name']);
$active = pg_escape_string($f['active']);
if (trim($active) == '')
$active=0;
$description = pg_escape_string($f['description']);
$category = pg_escape_string($f['category']);
$pgversion = pg_escape_string($f['pgversion']);
$edbversion = pg_escape_string($f['edbversion']);
$format = pg_escape_string($f['format']);
$installoptions = pg_escape_string($f['installoptions']);
$upgradeoptions = pg_escape_string($f['upgradeoptions']);
$checksum = pg_escape_string($f['checksum']);
$mirrorpath = pg_escape_string($f['mirrorpath']);
$alturl = pg_escape_string($f['alturl']);
$dependencies = pg_escape_string($f['dependencies']);
if ($dependencies == '')
$dependencies = '{}';
$versionkey = pg_escape_string($f['versionkey']);
if (empty($origid)) {
$this->pg_query("INSERT INTO applications (id, version, platform, secondaryplatform, name, active, description, category, pgversion, edbversion, format, installoptions, upgradeoptions, checksum, mirrorpath, alturl, dependencies, versionkey) VALUES " .
"('" . $id . "','" . $version . "','" . $platform . "','" . $secondaryplatform . "','" . $name . "'," . $active . "::bool,'" . $description . "','" . $category . "','" . $pgversion . "','" . $edbversion . "','" . $format . "','" . $installoptions . "','" . $upgradeoptions . "','" . $checksum . "','" . $mirrorpath . "','" . $alturl . "','" . $dependencies . "','" . $versionkey . "');");
} else {
$this->pg_query("UPDATE applications SET id='" . $id . "', version='" . $version . "', platform='" . $platform . "', secondaryplatform='" . $secondaryplatform . "', name='" . $name . "', active=" . $active . "::bool, description='" . $description . "', category='" . $category . "', pgversion='" . $pgversion . "', edbversion='" . $edbversion . "', format='" . $format . "', installoptions='" . $installoptions . "', upgradeoptions='" . $upgradeoptions . "', checksum='" . $checksum . "', mirrorpath='" . $mirrorpath . "', alturl='" . $alturl . "', dependencies='" . $dependencies . "', versionkey='" . $versionkey . "' WHERE id='" . $origid . "' AND version='" . $origversion . "' AND platform='" . $origplatform . "'");
}
$this->redirect_relative = '/admin/applications.php';
}
function RenderThanks() {
}
function fetch_platform_list() {
$c = array();
$c['linux'] = 'Linux (32bit)';
$c['linux-x64'] = 'Linux (64bit)';
$c['osx'] = 'Mac OS X';
$c['windows'] = 'Windows (32bit)';
$c['windows-x64'] = 'Windows (64bit)';
return $c;
}
function fetch_secondaryplatform_list() {
$c = array();
$c[''] = 'None';
$c['linux'] = 'Linux (32bit)';
$c['linux-x64'] = 'Linux (64bit)';
$c['osx'] = 'Mac OS X';
$c['windows'] = 'Windows (32bit)';
$c['windows-x64'] = 'Windows (64bit)';
return $c;
}
function fetch_format_list() {
$c = array();
$c['bin'] = 'Linux .bin';
$c['app'] = 'Mac .app';
$c['pkg'] = 'Mac .pkg';
$c['mpkg'] = 'Mac .mpkg';
$c['exe'] = 'Windows .exe';
$c['msi'] = 'Windows .msi';
return $c;
}
}
?>
|