-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid-finder.php
More file actions
62 lines (42 loc) · 1.26 KB
/
Copy pathid-finder.php
File metadata and controls
62 lines (42 loc) · 1.26 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
<?php
require_once 'common.php';
global $channel, $photosDirectory;
$url = 'https://bahman.s3.ir-thr-at1.arvanstorage.com/CDN/static-files/cars/Images/carModel';
// Main Process
$idToFetchFrom = getLatestId() + 1;
processLinks($idToFetchFrom, $idToFetchFrom + 35);
// Functions
function getLatestId() {
global $photosDirectory;
$list = [];
$files = glob("$photosDirectory/*.png");
foreach ($files as $file)
$list[] = explode('/', explode('.', $file)[0])[1];
if (count($list) === 0)
return 0;
sort($list);
return end($list);
}
function processLinks($start, $end) {
global $url, $channel, $photosDirectory;
$latestOkId = null;
for ($i = $start; $i < $end; $i++) {
$photoLink = "$url/$i.png";
$photo = @file_get_contents($photoLink);
if ($photo) {
$latestOkId = $i;
file_put_contents("$photosDirectory/$i.png", $photo);
bot('sendPhoto', [
'chat_id' => $channel,
'photo' => $photoLink,
'caption' => "ID $i"
]);
echo "got $i\n";
}
}
if (($end - $latestOkId) < 10) {
echo "still have to check... \n";
processLinks($end, $end + 35);
}
return true;
}