-
Notifications
You must be signed in to change notification settings - Fork 0
/
workerCashFiles.php
36 lines (32 loc) · 932 Bytes
/
workerCashFiles.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
<?php
function file_get_contents_curl($url) {
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,$url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
return $query;
}
function createImage($imgURL){
for($i = 0; $i < 60; $i++){
$img = file_get_contents_curl($imgURL);
if ($img){
break;
}else{
$img = false;
}
sleep(0.5);
}
return $img;
}
function Cash($file, $adress){
$image = createImage($file);
if(!($image)){
file_put_contents("./error.txt", "cant cash file: ".$adress."\n", FILE_APPEND);
}else{
imagejpeg(imagecreatefromstring($image) , $adress);
}
}
Cash($argv[1], $argv[2]);