-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdcpAction.php
executable file
·254 lines (218 loc) · 6.22 KB
/
dcpAction.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
require_once 'HTML/QuickForm/Action/Next.php';
require_once "dcpDatabase/dcpSun_Server.php";
require_once "dcpDatabase/dcpRegtool.php";
require_once "dcpDatabase/dcpServiceDesk.php";
require_once "dcpDatabase/dcpSun_ServerFromRegtool.php";
require_once "dcpDatabase/dcpProcedureVerificationFromServiceDesk.php";
class dcpAction extends HTML_QuickForm_Action_Next
{
var $page;
var $pageName;
function FormVerify (&$page, $actionName)
{
// save the form values and validation status to the session
$page->isFormBuilt() or $page->buildForm();
$pageName = $page->getAttribute('id');
// Get the container from the page's controller
$data =& $page->controller->container();
error_log("$data is data");
//$data =& $page->controller->container();
// $nextName = $data['values'][$pageName]['iradPageAB'];
// $data['values'][$pageName] = $page->exportValues();
// if (PEAR::isError($valid = $page->validate())) {
// return $valid;
// }
// $data['valid'][$pageName] = $valid;
// // Modal form and page is invalid: don't go further
// if ($page->controller->isModal() && !$data['valid'][$pageName]) {
// return $page->handle('display');
// }
}
function CheckUSPhoneNum($element_name, $element_value)
{
$PhoneNumber = ereg_replace("[^0-9]", "", $element_value); // Strip out non-numerics
if(ereg("^([2-9][0-9]{2})([2-9][0-9]{2})([0-9]{4})$", $PhoneNumber, $NumberParts)){
return "(" . $NumberParts[1] . ") " . $NumberParts[2] . "-" . $NumberParts[3];
} else {
return false;
}
}
/**
* Looks up a domain and makes sure it's valid; only works on *nix
*
* @param string $type Type of banning to check
* @param string $data The cooresponding data to check
* @return bool
*/
function FormDomainLookup($element, $value, $arg)
{
$value = str_replace('http://','',$value);
exec("host -t ns $value",$hasil);
if (ereg("host $value not found.",strtolower(trim($hasil[0])))) {
return false;
} else {
return true;
}
}
/**
* Makes sure an IP address is valid
*
* @param string $element_name name of form field to check
* @param string $element_value IP Address to check
* @return bool
*/
function CheckIP ($element_name,$element_value) {
$ip = $element_value;
if (($longip = ip2long($ip)) !== false)
{
if ($ip == long2ip($longip))
{
return true;
} else {
return false;
}
} else {
return false;
}
}
/**
* Makes sure a "date" isn't set to a past date.
*
* @param string $element_name name of form field to check
* @param string $element_value Date to Check
* @return bool
*/
function StopPastDate($element_name, $element_value)
{
global $vars, $now;
//check that it's a valid date first
$temp = explode('-', $element_value);
if(!checkdate($temp['1'],$temp['2'],$temp['0'])){
return false;
}
//now make sure the date isn't in the past.
if($element_value < $now){
return false;
} else {
return true;
}
}
/**
* Makes sure a "date" is a valid MYSQL format.
*
* @param string $element_name name of form field to check
* @param string $element_value Date to Check
* @return bool
*/
function ValidateMysqlDate($element_name, $element_value)
{
global $vars, $now;
//check that it's a valid date first
$temp = explode('-', $element_value);
if(!checkdate($temp['1'],$temp['2'],$temp['0'])){
return false;
}
return true;
}
/**
* Makes sure an integer is positive
*
* @param string $element_name name of form field to check
* @param string $element_value Int to Check
* @return bool
*/
function IsIntPositive($element_name, $element_value)
{
if (!is_numeric($element_value))
{
$element_value = (int)$element_value;
}
if($element_value < 1)
{
return FALSE;
}
//exit;
return TRUE;
}
/**
* Makes sure an integer isn't a decimal
*
* @param string $element_name name of form field to check
* @param string $element_value Int to Check
* @return bool
*/
function IsIntDecimal($element_name, $element_value)
{
if (!is_numeric($element_value))
{
$element_value = (int)$element_value;
}
if(strpos($element_value,'.') === FALSE){
return TRUE;
}
//exit;
return FALSE;
}
/**
* Makes sure a URL is valid
*
* @param string $element_name name of form field to check
* @param string $element_value URL to Check
* @return bool
*/
function IsURLValid($element_name,$element_value)
{
if (preg_match("/^(http(s?):\/\/|ftp:\/\/{1})((\w+\.){1,})\w{2,}$/i", $element_value)) {
return TRUE;
} else {
return FALSE;
}
}
/**
* Makes sure at least one file was uploaded
*
* @param string $element_name name of form field to check
* @param string $element_value
* @return bool
*/
function EnsureUploadedFile($element_name, $element_value)
{
foreach($_FILES AS $name => $data){
if($data['error'] == '0'){
return TRUE;
}
}
return FALSE;
}
function saveDcpRegtool ($sdesk_num, $values_array)
{
global $connection; // eventually this can get taken out
$dcpProcedure = new dcpProcedure();
$dcp = $dcpProcedure->joinDCPTables();
$dcp->get($sdesk_num);
$sun_server = $dcp->getLink('sysid');
$sysid = $sun_server->sysid;
$Sun_Server = new dcpSun_Server($connection,$sysid);
//DB_DataObject::debugLevel(5);
$original_sun_server = clone($sun_server); // clone is emulated in php4 for compatibility reasons.
error_log("made it here ONE");
foreach ($values_array as $label => $col) {
if ( $sun_server->$label )
{
$sun_server->$label = "$col";
}
elseif ( $label == 'frmware_disks_id' )
{
$Sun_Server->setFrmware_disks_id($col);
}
elseif ( $label == 'frmware_hba_id' )
{
$Sun_Server->setFrmware_hba_id($col);
}
}
$result = $sun_server->update($original_sun_server); // only update the difference between new and old
//DB_DataObject::debugLevel(0);
}
}
?>