This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompress_do.php
109 lines (94 loc) · 3.1 KB
/
compress_do.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
<?php
session_start();
$allowed = false;
if (isset($_SESSION['lvl']) && isset($_SESSION['login_rew'])){
if ($_SESSION['login_rew'] == "apophis"){
$allowed = true;
}
}
if (!$allowed) {
die("Error! Jen pro povolane lidi!");
exit;
}
$noOutputBuffer = 1;
include "db/conn.php";
/*
mysql_query("
INSERT INTO `3_comm_4_texts` SELECT id AS text_id, text AS text_content, compressed AS text_compressed, whisText AS text_whisText FROM 3_comm_4;
INSERT INTO `3_comm_3_texts` SELECT id AS text_id, text AS text_content, compressed AS text_compressed FROM 3_comm_3;
INSERT INTO `3_comm_2_texts` SELECT id AS text_id, text AS text_content, compressed AS text_compressed FROM 3_comm_2;
INSERT INTO `3_comm_1_texts` SELECT id AS text_id, text AS text_content, compressed AS text_compressed FROM 3_comm_1;
UPDATE 3_comm_1 SET mid = id;
UPDATE 3_comm_2 SET mid = id;
UPDATE 3_comm_3 SET mid = id;
UPDATE 3_comm_4 SET mid = id;
");
*/
exit;
$doDecompress = 0;
if (isset($_GET['w'])) $doDecompress = $_GET['w'];
if ($doDecompress > 0) $doDecompress = 1;
else $doDecompress = 0;
if(isset($_GET['s']) && isset($_GET['i'])){
if (ctype_digit($_GET['s']) && ctype_digit($_GET['i'])){
// $cS = mysql_query("SELECT id,text,compressed FROM 3_comm_$_GET[s] WHERE compressed = ".$doDecompress." ORDER BY id ASC LIMIT $_GET[i],1000");
$cS = mysql_query("SELECT id,text,compressed FROM 3_comm_$_GET[s] ORDER BY id ASC LIMIT $_GET[i],1000");
$cnt=0;
if ($doDecompress){
while($c = mysql_fetch_row($cS)){
if ($c[2]==0) continue;
$binarka = addslashes(gzuncompress($c[1]));
if (strlen($binarka) < 1) {
echo "ERROR!!!";
break;
}
mysql_query("UPDATE 3_comm_$_GET[s] SET text = '$binarka', compressed = 0 WHERE id = '$c[0]'");
if (mysql_affected_rows()) $cnt++;
}
}
else {
while($c = mysql_fetch_row($cS)){
if ($c[2]>0) continue;
$binarka = gzcompress($c[1],9);
if (strlen($binarka) < strlen($c[1])) {
$binarka = bin2hex($binarka);
mysql_query("UPDATE 3_comm_$_GET[s] SET text = 0x$binarka, compressed = 1 WHERE id = '$c[0]'");
if (mysql_affected_rows()) $cnt++;
}
}
}
if ($cnt > 0) echo $cnt;
else echo "nothing done";
}
else {
$cS = mysql_query("SELECT id,text,compressed FROM 3_clanky ORDER BY id ASC LIMIT $_GET[i],100");
$cnt=0;
if ($doDecompress){
while($c = mysql_fetch_row($cS)){
if ($c[2]==0) continue;
$binarka = addslashes(gzuncompress($c[1]));
if (strlen($binarka) < 1) {
echo "ERROR!!!";
break;
}
mysql_query("UPDATE 3_clanky SET text = '$binarka', compressed = '0' WHERE id = '$c[0]'");
if (mysql_affected_rows()) $cnt++;
}
}
else {
while($c = mysql_fetch_row($cS)){
if ($c[2]>0) continue;
$binarka = gzcompress($c[1],9);
if (strlen($binarka) < strlen($c[1])) {
$binarka = bin2hex($binarka);
mysql_query("UPDATE 3_clanky SET text = 0x$binarka, compressed = '1' WHERE id = '$c[0]'");
if (mysql_affected_rows()) $cnt++;
}
}
}
if ($cnt > 0) echo $cnt;
else echo "nothing done";
}
}
else echo "error";
?>