forked from XTCUwU/VMProtect-Web-License-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivations_edit.php
136 lines (124 loc) · 4.47 KB
/
activations_edit.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
<?php
require_once "include/login.inc.php";
require_once "include/activation.inc.php";
require_once "include/product.inc.php";
if (isset($_REQUEST["p"]))
$obj = Activation::FromDb($_REQUEST["p"]);
else
if (isset($_REQUEST["id"]))
$obj = Activation::FromDb($_REQUEST["id"]);
if (!isset($obj) || $obj===FALSE)
$obj = new Activation();
$products = DbQuery("SELECT id, fullname, active FROM {$DB_PREFIX}vw_products ORDER BY fullname");
if ($_SERVER["REQUEST_METHOD"]=="POST")
{
if (empty($_POST["blocked"]))
$_POST["blocked"] = FALSE;
if ($_POST["act_count"] == "unlimited")
$_POST["act_count"] = "";
//Protect of changing code
unset($_POST["code"]);
ObjectFromArray($obj, $_POST);
$obj->Save() or die("alert('" . V_ERROR_TXT . ": '" . str_replace("'", "\\'", mysqli_error($mysqli_link)) . ");");
echo "loadcontent('activations');";
}
else
{
if ($obj->id==0)
echo "<h1>" . H_NEWACT_TXT ."</h1>";
else
echo "<h1>" . H_EDITACT_TXT . "</h1>";
?>
<div class="formDiv">
<form id="editForm" action="activations_edit.php" method="POST">
<input type="hidden" id="id" name="id" value="<?php echo $obj->id; ?>" />
<table class="formTbl">
<tr><th>
<label for="productid"><?php echo LIC_PROD_TXT; ?></label>
</th><td>
<select name="productid" id="productid" class="required noedit">
<?php if (!empty($products)) foreach ($products as $p) { ?>
<option value="<?php echo $p["id"]; ?>" <?php echo (!$p["active"]?"disabled":""); ?>><?php echo htmlspecialchars($p["fullname"]); ?></option>
<?php } ?>
</select>
</td></tr>
<tr><th>
<label for="name"><?php echo LIC_NAME_TXT; ?></label>
</th><td>
<input type="text" name="name" id="name" class="required" value="<?php echo htmlspecialchars($obj->name); ?>" />
</td></tr>
<tr><th>
<label for="email"><?php echo LIC_EMAIL_TXT; ?></label>
</th><td>
<input type="text" name="email" id="email" class="required email" value="<?php echo htmlspecialchars($obj->email); ?>" />
</td></tr>
<tr><th>
<label for="createdate"><?php echo LIC_DATE_TXT; ?></label>
</th><td>
<input type="text" name="createdate" id="createdate" class="date" value="<?php echo $obj->createdate; ?>" />
</td></tr>
<tr><th>
<label for="orderref"><?php echo LIC_ORDERREF_TXT; ?></label>
</th><td>
<input type="text" name="orderref" id="orderref" value="<?php echo htmlspecialchars($obj->orderref); ?>" />
</td></tr>
<tr><th>
<label for="act_count"><?php echo ACT_COUNT_TXT; ?></label>
</th><td>
<input type="text" name="act_count" id="act_count" value="<?php echo htmlspecialchars($obj->act_count); ?>" />
</td></tr>
<tr><th>
<label for="act_count"><?php echo ACT_EXPDATE_TXT; ?></label>
</th><td>
<input type="text" name="expiredate" id="expiredate" class="date" value="<?php echo $obj->expiredate; ?>" />
</td></tr>
<?php if ($obj->code!="") { ?>
<tr><th>
<label for="code"><?php echo ACT_CODE_TXT; ?></label>
</th><td>
<input type="text" name="code" id="code" readonly="readonly" value="<?php echo htmlspecialchars($obj->code); ?>" />
</td></tr>
<?php } ?>
<?php if ($obj->id!=0) { ?>
<tr><th>
<label for="blocked"><?php echo ACT_BLOCKED_TXT; ?></label>
</th><td>
<input type="checkbox" id="blocked" name="blocked" class="checkbox" value="1" />
</td></tr>
<?php } ?>
<tr>
<td></td>
<td style="padding-top:10px">
<a class="greenBtn" onclick="return saveForm('script')"><span><?php echo SAVE_TXT; ?></span><em></em></a>
</td>
</tr>
</table>
</form>
</div>
<script>
var isNew = <?php echo ($obj->id==0?"true":"false"); ?>;
function customValidate(){
if ($('#act_count').val() != '' && $('#act_count').val() != 'unlimited')
$('#act_count').each(validateNumeric);
}
function initContent(){
$('.date').datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });
if (!isNew){
$('.noedit').attr('disabled', 'disabled');
$('#blocked').prop('checked', <?php echo ($obj->blocked ? "true" : "false"); ?>);
}
$('#productid').val('<?php echo $obj->productid; ?>');
$('#act_count').focus(function(){
if ($(this).val() == 'unlimited')
$(this).removeClass('emptyText').val('');
});
$('#act_count').blur(function(){
if ($(this).val() == '')
$(this).val('unlimited').addClass('emptyText');
});
$('#act_count').trigger('blur');
}
</script>
<?php
}
?>