Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from ben-atherton/master
Browse files Browse the repository at this point in the history
Correct grammatical error and make all alerts dismassable
  • Loading branch information
seikan authored Dec 12, 2016
2 parents c22610c + 8702880 commit b7b5b92
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion pages/json.renew-machine.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'due_date' => date('Y-m-d', strtotime($row[0]['due_date'] . ' +' . $months[$row[0]['billing_cycle']] . ' months')),
));

$session->set('response', '<div class="alert alert-success"><span><i class="fa fa-check-circle"></i> "' . $row[0]['label'] . '" has been renewed.</span></div>');
$session->set('response', '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-check-circle"></i> "' . $row[0]['label'] . '" has been renewed.</span></div>');

die(json_encode(array(
'status' => 'OK',
Expand Down
46 changes: 23 additions & 23 deletions pages/json.save-machine.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
if(!$session->get('username'))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Session expired. Please sign in again to continue.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Session expired. Please sign in again to continue.</span></div>',
'id' => 'label',
)));

Expand Down Expand Up @@ -37,106 +37,106 @@
if(empty($label))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert a label.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert a label.</span></div>',
'id' => 'label',
)));

if(mb_strlen($label) > 100)
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Label exceed 100 characters in length.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Label exceed 100 characters in length.</span></div>',
'id' => 'label',
)));

if(!in_array($vmType, array(1, 2, 3, 4, 5)))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a virtualization type.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a virtualization type.</span></div>',
'id' => 'type',
)));

if(!preg_match('/^\d+$/', $memory))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for memory amount.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for memory amount.</span></div>',
'id' => 'memory',
)));

if(!in_array($memoryUnit, $units))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for memory.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for memory.</span></div>',
'id' => 'memoryUnit',
)));

if(!preg_match('/^\d+$/', $swap))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for swap amount.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for swap amount.</span></div>',
'id' => 'swap',
)));

if(!in_array($swapUnit, $units))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for swap.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for swap.</span></div>',
'id' => 'swapUnit',
)));

if(!preg_match('/^\d+$/', $diskSpace))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for disk space amount.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for disk space amount.</span></div>',
'id' => 'diskSpace',
)));

if(!in_array($diskSpaceUnit, $units))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for disk space.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for disk space.</span></div>',
'id' => 'diskSpaceUnit',
)));

if(!in_array($hddType, array(1, 2, 3, 4)))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a HDD type.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a HDD type.</span></div>',
'id' => 'hddType',
)));

if(!preg_match('/^\d+$/', $bandwidth))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for bandwidth amount.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert integer only for bandwidth amount.</span></div>',
'id' => 'bandwidth',
)));

if(!in_array($bandwidthUnit, $units))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for bandwidth.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a valid unit for bandwidth.</span></div>',
'id' => 'bandwidthUnit',
)));

if(!is_array($ipAddress))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid IP address.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid IP address.</span></div>',
'id' => 'ipAddresss',
)));

foreach($ipAddress as $ip)
if(!filter_var($ip, FILTER_VALIDATE_IP))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid IP address.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid IP address.</span></div>',
'id' => 'ipAddress\\[\\]',
)));

if(!getCountryNameByCode($countryCode))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a valid country.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a valid country.</span></div>',
'id' => 'countryCode',
)));

Expand All @@ -146,35 +146,35 @@
if($provider->affectedRows() == 0)
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a provider.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a provider.</span></div>',
'id' => 'providerId',
)));

if(!in_array($currencyCode, array_keys($config['currencies'])))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a valid currency.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a valid currency.</span></div>',
'id' => 'currencyCode',
)));

if(!preg_match('/^\d+\.\d{2}$/', $price))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid figure for price.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid figure for price.</span></div>',
'id' => 'price',
)));

if(!in_array($billingCycle, array(1, 2, 3, 4, 5)))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please select a valid billing cycle.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please select a valid billing cycle.</span></div>',
'id' => 'billingCycle',
)));

if(!empty($dueDate) && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $dueDate))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid due date.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid due date.</span></div>',
'id' => 'dueDate',
)));

Expand Down Expand Up @@ -206,7 +206,7 @@
'notes' => html_entity_decode($notes),
));

$session->set('response', '<div class="alert alert-success"><span><i class="fa fa-check-circle"></i> "' . $label . '" has been added.</span></div>');
$session->set('response', '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-check-circle"></i> "' . $label . '" has been added.</span></div>');
}
else{
$machine->update('machine_id', '=' . $machineId, array(
Expand Down Expand Up @@ -234,7 +234,7 @@
'notes' => html_entity_decode($notes),
));

$session->set('response', '<div class="alert alert-success"><span><i class="fa fa-check-circle"></i> "' . $label . '" has been updated.</span></div>');
$session->set('response', '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-check-circle"></i> "' . $label . '" has been updated.</span></div>');
}

die(json_encode(array(
Expand Down
18 changes: 9 additions & 9 deletions pages/json.save-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
if(!$session->get('username'))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Session expired. Please sign in again to continue.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Session expired. Please sign in again to continue.</span></div>',
'id' => 'label',
)));

Expand All @@ -17,42 +17,42 @@
if(empty($name))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert provider name.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert provider name.</span></div>',
'id' => 'name',
)));

if(mb_strlen($name) > 100)
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Provider name exceed 100 characters in length.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Provider name exceed 100 characters in length.</span></div>',
'id' => 'name',
)));

if(!filter_var($website, FILTER_VALIDATE_URL))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid provider website.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid provider website.</span></div>',
'id' => 'website',
)));

if(empty($controlPanel))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert control panel name.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert control panel name.</span></div>',
'id' => 'controlPanel',
)));

if(mb_strlen($controlPanel) > 50)
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Control panel name exceed 50 characters in length.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Control panel name exceed 50 characters in length.</span></div>',
'id' => 'controlPanel',
)));

if(!filter_var($cpUrl, FILTER_VALIDATE_URL))
die(json_encode(array(
'status' => 'ERROR',
'response' => '<div class="alert alert-danger"><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid control panel URL.</span></div>',
'response' => '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-exclamation-triangle"></i> Please insert a valid control panel URL.</span></div>',
'id' => 'cpUrl',
)));

Expand All @@ -66,7 +66,7 @@
'cp_url' => $cpUrl,
));

$session->set('response', '<div class="alert alert-success"><span><i class="fa fa-check-circle"></i> "' . $name . '" has been added.</span></div>');
$session->set('response', '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-check-circle"></i> "' . $name . '" has been added.</span></div>');
}
else{
$provider->update('provider_id', '=' . $providerId, array(
Expand All @@ -76,7 +76,7 @@
'cp_url' => $cpUrl,
));

$session->set('response', '<div class="alert alert-success"><span><i class="fa fa-check-circle"></i> "' . $name . '" has been updated.</span></div>');
$session->set('response', '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-check-circle"></i> "' . $name . '" has been updated.</span></div>');
}

die(json_encode(array(
Expand Down
5 changes: 3 additions & 2 deletions pages/machine.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@

if(isset($_POST['remove'])){
$machine->delete('machine_id', '=' . $_POST['remove']);
$session->set('response', '<div class="alert alert-success"><span><i class="fa fa-check-circle"></i> The machine has been removed.</span></div>');
$session->set('response', '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span><i class="fa fa-check-circle"></i> The machine has been removed.</span></div>');
}

if(isset($_POST['hideInactiveVM']))
Expand Down Expand Up @@ -683,7 +683,8 @@
}
else{
echo '
<div class="alert alert-info">
<div class="alert alert-info alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<span><i class="fa fa-exclamation-circle"></i> There is no machine added.</span>
</div>';
}
Expand Down
Loading

0 comments on commit b7b5b92

Please sign in to comment.