-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessing.php
More file actions
119 lines (95 loc) · 2.25 KB
/
processing.php
File metadata and controls
119 lines (95 loc) · 2.25 KB
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
<?php
$salt = 'ee2u1heu1298eh219812he1#$#%&/dhsa8d7g12';
if(isset($_POST['guid'])){
$guid = $_POST['guid'];
}else if(isset($_GET['guid'])){
$guid = $_GET['guid'];
}else{
die('error1');
}
$guid = stripslashes($guid);
$mysqli = new mysqli("localhost", 'processingb_usr', '9963101b2050dbf06e42','processingb');
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
$q = "SELECT * FROM sketches WHERE guid like '$guid';";
if (!$result = $mysqli->query($q) ) {
die('fuu');
}
$sketch = $result->fetch_assoc();
if(isset($sketch['guid']))
{
if(!empty($_POST['action']) && $_POST['action'] == 'unlock'){
if($sketch['passwd'] == md5($salt.$_POST['key'])){
echo "OK";
}else{
echo "Wrong password?";
}
exit;
}
if(!empty($_POST['action']) && $_POST['action'] == 'lock'){
$pass = md5($salt.$_POST['key']);
$q = "UPDATE sketches set passwd = '$pass' WHERE guid like '$guid'";
$mysqli->query($q );
echo "OK";
exit;
}
if(!empty($_GET['action']) && $_GET['action'] == 'get'){
// print_r($sketch);
// echo "FUUUUUUUUUUUUUUUUUUUCK";
$code = urldecode($sketch['code']);
// $code = str_replace("<xml xmlns=\"http://www.w3.org/1999/xhtml\">","",$code);
// $code = str_replace("</xml>","",$code);
echo $code;
exit;
}
if(!empty($_GET['action']) && $_GET['action'] == 'locked'){
if(strlen($sketch['passwd']) > 1){
echo "TRUE"; //check if saving is locked...
}else{
echo "FALSE";
}
exit;
}
}
if(empty($_POST['code'])){
echo $q;
print_r($sketch);
die("erro2");
}
$code = $_POST['code'];
if(empty($sketch['guid']))
{
$q = "INSERT INTO sketches VALUES (default,default,'".$code."','".$guid."',default)";
$mysqli->query($q );
echo "Created";
}else{
if(isset($sketch["passwd"])){
if(!isset($_POST['passwd'])){
echo "Locked...!?";
exit;
}
if($sketch['passwd'] != md5($salt.$_POST['passwd'])){
echo "Locked...!?";
exit;
}
}
echo "Saved";
$q = "UPDATE sketches set code = '$code' WHERE guid like '$guid'";
$mysqli->query($q );
}
// $sketch->free();
// echo $q;
$mysqli->close();
/**
create table sketches(
id int(11) not null auto_increment,
timestamp timestamp,
codigoFonte longtext,
nome varchar(255),
primary key(id)
);
**/
?>