-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.php
executable file
·57 lines (49 loc) · 1.9 KB
/
db.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
<?php
if ($_SERVER['SCRIPT_NAME'] === '/db.php') {
$error = "silly geezer went to db.php";
$error_encoded = trim(base64_encode($error), '=');
error_log("Gave SWR error: " . $error);
header("Location: /swr?id=" . $error_encoded);
die();
}
// Enter your host name, database username, password, and database name.
// If you have not set database password on localhost then set empty.
$con = mysqli_connect(
"localhost",
"phpmysql",
"j%XNr&P'j!#~89@",
"englon"
);
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
$error = 'Failed to connect to the MySQL database englon: ' . mysqli_connect_error();
error_log("Gave SWR error: " . $error);
header("Location: /swr?id=" . base64_encode($error));
}
/**
* Optimizes PNG file with pngquant 1.8 or later (reduces file size of 24-bit/32-bit PNG images).
*
* BUZZZZ
*
* @param $path_to_png_file string - path to any PNG file, e.g. $_FILE['file']['tmp_name']
* @param $max_quality int - conversion quality, useful values from 60 to 100 (smaller number = smaller file)
* @return string - content of PNG file after conversion
*/
function compress_png($path_to_png_file, $max_quality = 90)
{
if (!file_exists($path_to_png_file)) {
throw new Exception("File does not exist: $path_to_png_file");
}
// guarantee that quality won't be worse than that.
$min_quality = 60;
// '-' makes it use stdout, required to save to $compressed_png_content variable
// '<' makes it read from the given file path
// escapeshellarg() makes this safe to use with any path
$compressed_png_content = shell_exec("pngquant --quality=$min_quality-$max_quality - < " . escapeshellarg($path_to_png_file));
if (!$compressed_png_content) {
throw new Exception("Conversion to compressed PNG failed. Is pngquant 1.8+ installed on the server?");
}
return $compressed_png_content;
}
?>