-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.php
196 lines (177 loc) · 6.86 KB
/
images.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
* Vân Thiên Hùng chuyên lừa đảo, lợi dụng tín nhiệm lừa tiền anh em lập trình.
* Hứa hẹn thanh toán, tới ngày thì than thở kêu chưa thu được tiền từ năm này qua tháng nọ, hẹn tới hẹn lui không có hồi kết.
* Tới lúc bị anh em Dev đòi thì xoá Zalo, đổi pass server nhằm chặn anh em Dev vào phá.
* Đã quỵt tiền 2 người tổng cộng 70 triệu
* Chúc may mắn cho anh em nào đang làm tiếp với Vân Thiên Hùng ^^!.
*/
define('__ROOT_PATH', dirname(__FILE__));
define('_lib','./admin/lib/');
@include _lib."config.php";
@include_once _lib."function.php";
global $d;
global $lang;
$d = new func_index($config['database']);
date_default_timezone_set('Asia/Ho_Chi_Minh');
// process for products
$query = 'SELECT `id`, `image_path` FROM #_sanpham WHERE `image_path` != "" AND `image_path` IS NOT NULL GROUP BY `image_path`';
$items = $d->o_fet($query);
$pushData = [];
$countItem = 0;
$totalItem = count($items);
foreach ($items as $key => $value) {
if ($countItem == 100) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://images.vanthienhung.vn/api/storage-image',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode(['images' => $pushData]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
));
$response = curl_exec($curl);
curl_close($curl);
$countItem = 0;
$pushData = [];
}
$pushData[] = [
'product_id' => $value['id'],
'source' => getenv('APP_URL'),
'path' => getenv('THUMB_SITE_FOLDER'),
'image_type' => 'thumbnail',
'image_path' => $value['image_path']
];
$countItem++;
if (($totalItem - 1) - $key == 0) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://images.vanthienhung.vn/api/storage-image',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode(['images' => $pushData]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
));
$response = curl_exec($curl);
curl_close($curl);
}
}
//db_slide_sp
$slides = $d->o_fet("select * from #_slide_sp");
$sliderData = [];
foreach ($slides as $key => $slide) {
$sliderData[] = [
'product_id' => $slide['id'],
'source' => getenv('APP_URL'),
'path' => getenv('THUMB_SITE_FOLDER'),
'image_type' => 'slide',
'image_path' => $slide['image_path']
];
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://images.vanthienhung.vn/api/storage-image',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode(['images' => $sliderData]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
));
$response = curl_exec($curl);
curl_close($curl);
//db_gallery
$galleries = $d->o_fet("SELECT * FROM `#_gallery`");
$galleryData = [];
foreach ($galleries as $key => $gallery) {
$galleryData[] = [
'product_id' => $gallery['id'],
'source' => getenv('APP_URL'),
'path' => getenv('THUMB_SITE_FOLDER'),
'image_type' => 'partner',
'image_path' => $gallery['picture']
];
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://images.vanthienhung.vn/api/storage-image',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode(['images' => $galleryData]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
));
$response = curl_exec($curl);
curl_close($curl);
//Process for Gallery
$queryGallery = 'SELECT `id`, `id_sp`, `image_path` FROM #_sanpham_hinhanh WHERE `image_path` != "" AND `image_path` IS NOT NULL';
$productGalleries = $d->o_fet($queryGallery);
if (count($productGalleries) > 0) {
$pushDataGallery = [];
$countItemGallery = 0;
$totalItem = count($productGalleries);
foreach ($productGalleries as $keyG => $valueG) {
if ($countItemGallery == 100) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://images.vanthienhung.vn/api/storage-image',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode(['images' => $pushDataGallery]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
));
$response = curl_exec($curl);
curl_close($curl);
$countItemGallery = 0;
$pushDataGallery = [];
}
$pushDataGallery[] = [
'product_id' => $valueG['id_sp'],
'source' => getenv('APP_URL'),
'path' => getenv('THUMB_SITE_FOLDER'),
'image_type' => 'productGallery',
'image_path' => $valueG['image_path']
];
$countItemGallery++;
if (($totalItem - 1) - $keyG == 0) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://images.vanthienhung.vn/api/storage-image',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode(['images' => $pushDataGallery]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
));
$response = curl_exec($curl);
curl_close($curl);
}
}
}
file_put_contents('images-log.txt', 'Done sync at ' . date('Y-m-d H:i:s'));