-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.php
46 lines (33 loc) · 1.61 KB
/
save.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
<?php
$password = "";
$db_connection = new mysqli("localhost", "root", $password);
if ($db_connection->connect_error) {
die("Connection failed: " . $db_connection->connect_error);
}
$db_connection->select_db('smgen');
function MakeGuid() {
$tl = str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT) . str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT);
$tm = str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT);
$th = mt_rand(0, 255);
$th = $th & hexdec('0f');
$th = $th ^ hexdec('40');
$th = str_pad(dechex($th), 2, '0', STR_PAD_LEFT);
$cs = mt_rand(0, 255);
$cs = $cs & hexdec('3f');
$cs = $cs ^ hexdec('80');
$cs = str_pad(dechex($cs), 2, '0', STR_PAD_LEFT);
$clock_seq_low = str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT);
$node = str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT) . str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT) . str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT);
return $tl . '-' . $tm . '-' . $th . $cs . '-' . $clock_seq_low . '-' . $node;
}
$_POST['indentUseSpaces'] = $_POST['indentUseSpaces'] == 'true' ? true : false;
foreach($_POST['fields'] as &$field) {
$field['doNotSave'] = $field['doNotSave'] == 'true' ? true : false;
$field['doNotLoad'] = $field['doNotLoad'] == 'true' ? true : false;
}
$dataEncoded = json_encode($_POST);
$guid = MakeGuid();
$dataEscaped = $db_connection->real_escape_string($dataEncoded);
$query = "INSERT INTO `smgen` (`guid`, `data`) VALUES ('{$guid}', '{$dataEscaped}')";
$db_connection->query($query);
die($guid);