image);
if ($ext !== false) {
$original = file_get_contents($info->image);
file_put_contents('cache/tmp/' . $hash . '.' . $ext, $original);
$res['success'] = 1;
$res['filePath'] = 'cache/tmp/' . $hash . '.' . $ext;
$res['base64'] = 'data:image/png;base64,' . base64_encode($original);
unlink('cache/tmp/' . $hash . '.' . $ext);
$startPath = 'cache/img/' . $line[4] . '/' . substr($hash, 0, 2) . '/' . substr($hash, 2, 2) . '/';
$width = explode("x", $line[3]);
$thumb = makeImgThumb($info->image, $ext, $hash, $width[0], $startPath);
return $res;
} else {
$res['error'] = 1;
$res['msg'] = 'Error with OpenGraph data';
return $res;
}
}
if (isset($ui['clear']) && (int) $ui['clear'] === 1) {
clearLog($ui['log']);
}
if (isset($ui['ac']) && $ui['ac'] === 'delete' && isset($ui['thumb']) && !empty($ui['thumb'])) {
$imgUrl = pathForFile('m', $ui['thumb']);
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $imgUrl . '.png')) {
unlink($_SERVER['DOCUMENT_ROOT'] . '/' . $imgUrl . '.png');
}
if (file_exists($imgUrl . '_thumb.png')) {
unlink($_SERVER['DOCUMENT_ROOT'] . '/' . $imgUrl . '_thumb.png');
}
}
echo '
';
if (isset($ui['ac']) && $ui['ac'] === 'delete') {
if (!empty($ui['delThumb']) && $ui['delThumb']) {
delAndRegen($ui['delThumb'], $size);
}
if (isset($ui['deleteUrl']) && testValidUrl($ui['deleteUrl']) !== true) {
unset($ui['deleteUrl']);
echo '
Not a valid url.
';
}
echo '
';
if (!empty($ui['deleteUrl'])) {
$ui['deleteUrl'] = trim(rawurldecode($ui['deleteUrl']));
$ui['deleteUrl'] = rtrim($ui['deleteUrl'], '/');
$hashUrl = sha1($GLOBALS['config']['salt'] . $ui['deleteUrl']);
$imgUrl = pathForFile('', $hashUrl);
echo '
';
}
}
if (isset($ui['log']) && $ui['log'] === 'success') {
$logs = parseSuccessLog();
if (!empty($logs)) {
$nbThumb = 0;
$nbThumb = count($logs['genTime']);
echo 'Total request : ', $nbThumb, '';
echo 'Moyenne per request : ', round(array_sum($logs['genTime']) / $nbThumb, 2), 's (min (', min($logs['genTime']), 's) max (', max($logs['genTime']), 's))';
} else {
echo 'No result';
}
echo 'Clear success log
';
}
if (isset($ui['log']) && ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other')) {
if (isset($ui['hash']) && !empty($ui['hash'])) {
//$ui['hash'] = validHash($ui['hash']);
if (isset($ui['root']) && (int) $ui['root'] === 1) {
$response = tryRootDomain($ui['hash'], $ui['log']);
}
if (isset($ui['cache']) && (int) $ui['cache'] === 1) {
$response['success'] = 1;
$response['filePath'] = pathForFile($ui['s'], $ui['hash']) . '.png';
$response['base64'] = 'data:image/png;base64,' . base64_encode(file_get_contents($response['filePath']));
if (!file_exists($response['filePath'])) {
$response['base64'] = 'data:image/png;base64,' . base64_encode(file_get_contents('bin/error.png'));
}
}
if (isset($ui['keep']) && (int) $ui['keep'] === 1) {
keepThisThumb($ui['hash'], $ui['log']);
}
if (isset($ui['mGen']) && (int) $ui['mGen'] === 1) {
$response = manualGen($ui['hash'], $ui['log']);
}
if (isset($ui['tryCurl']) && (int) $ui['tryCurl'] === 1) {
$response = tryWithCurl($ui['hash'], $ui['log']);
}
if (isset($ui['openGraph']) && (int) $ui['openGraph'] === 1) {
$response = tryWithOpenGraph($ui['hash'], $ui['log']);
}
}
$logs = parseFailLog($ui['log']);
if (!empty($logs)) {
echo '';
} else {
echo 'No result';
}
}
echo '';
if (!empty($response) && $response['success'] === 1) {
echo '';
}
if (!empty($response) && !empty($response['error']) && $response['error'] === 1) {
echo '';
}