-
Notifications
You must be signed in to change notification settings - Fork 1
/
export_photo.php
45 lines (38 loc) · 1.37 KB
/
export_photo.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
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
require_once 'meekrodb.2.2.class.php';
require_once("common.php");
function img_raw_to_file($data, $filename)
{
//$data = 'data:image/png;base64,AAAFBfj42Pj4';
list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data);
$data = base64_decode($data);
//file_put_contents('img.png', base64_decode($base64string));
//file_put_contents('/tmp/image.png', $data);
file_put_contents($filename, $data);
}
DB::$user = '####';
DB::$password = '####';
DB::$dbName = '####';
DB::$host = 'localhost'; //defaults to localhost if omitted
#DB::$port = '12345'; // defaults to 3306 if omitted
#DB::$encoding = 'utf8'; // defaults to latin1 if omitted
$max_id = 1000; // max visitor id to export
for ($i =0;$i<$max_id;$i++) {
$result = DB::queryFirstRow("SELECT vphoto FROM visitor WHERE visitor.vid=%i", $i);
$piclen = strlen($result['vphoto']);
$picpreview = substr($result['vphoto'], 0, 25);
$picraw = $result['vphoto'];
if ($piclen == 0) {
//print("vid". $i . " is empty");
continue;
}
print("\n". $i . " contents:".$picpreview . "len:" . $piclen);
$filepath = $i . ".png";
img_raw_to_file($picraw, $filepath);
}
exit;
?>