diff --git a/.gitignore b/.gitignore
index 1a17728..9a6a1b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ cache/*
!cache/index.html
.project
.settings
+composer.lock
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..d145db8
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,5 @@
+{
+ "require": {
+ "embed/embed": "^3.3"
+ }
+}
diff --git a/inc/admin.php b/inc/admin.php
index 824a741..c0a4b44 100644
--- a/inc/admin.php
+++ b/inc/admin.php
@@ -1,180 +1,229 @@
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;
+ }
+
}
-function tryWithCurl($hash, $log) {
- $line = file_get_contents('cache/logs/'.$log.'/'.$hash.'.log');
- $line = trim($line);
- $line = explode(' --- ', $line);
- //$hash = sha1($GLOBALS['config']['salt'].rawurldecode($line[1]));
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $line[1]);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_USERAGENT, 'SoShot - perSOnal thumbSHOTer');
- $resultat = curl_exec($ch);
- curl_close($ch);
- $searchStr = array(
- 'href="//',
- 'src="//',
- 'content="//'
- );
- $replaceStr = array(
- 'href="http://',
- 'src="http://',
- 'content="http://'
- );
- $resultat = str_replace($searchStr, $replaceStr, $resultat);
- file_put_contents('cache/tmp/'.$line[2].'.html', $resultat);
- chdir('bin/');
- exec('bash thumb_server.sh ../cache/tmp/'.$hash.'.html '.escapeshellarg($line[2]).' '.escapeshellarg($line[3]).' '.escapeshellarg($line[4]).' trc 1 noErrorLog', $result);
- chdir('../');
- unlink('cache/tmp/'.$hash.'.html');
- if ((int)$result[0] == 1) {
- $res['success'] = 1;
- $res['filePath'] = pathForFile($line[4], $hash).'.png';
- $res['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents($res['filePath']));
- return $res;
- }
-}
-
-if (isset($ui['clear']) && (int)$ui['clear'] === 1) {
- clearLog($ui['log']);
+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');
- }
+ $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['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
';
+ $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['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']);
+ }
}
- 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'));
- }
+ $logs = parseFailLog($ui['log']);
+ if (!empty($logs)) {
+ echo '';
+ } else {
+ echo 'No result';
}
- 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']);
- }
- }
- $logs = parseFailLog($ui['log']);
- if (!empty($logs)) {
- echo '';
- } else {
- echo 'No result';
- }
}
echo '';
if (!empty($response) && $response['success'] === 1) {
- echo '';
+ echo '';
}
-if (!empty($response) && $response['error'] === 1) {
- echo '';
-}
-?>
\ No newline at end of file
+if (!empty($response) && !empty($response['error']) && $response['error'] === 1) {
+ echo '';
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index 5d6cc4d..0d76444 100644
--- a/index.php
+++ b/index.php
@@ -1,7 +1,7 @@
'120x90',
- 'm' => '200x160',
- 'l' => '300x240',
- 'xl' => '400x320',
- 'xxl' => '500x400'
+ 's' => '120x90',
+ 'm' => '200x160',
+ 'l' => '300x240',
+ 'xl' => '400x320',
+ 'xxl' => '500x400',
);
// create thumshot 1280x1024
$GLOBALS['config']['activeFullSize'] = false;
@@ -36,93 +36,95 @@ $GLOBALS['config']['disableExec'] = false;
// Enable log for success, suspect, error
$GLOBALS['config']['log'] = true;
if (file_exists('cache/config/options.php')) {
- require 'cache/config/options.php';
+ require 'cache/config/options.php';
}
if (get_magic_quotes_gpc()) {
- function stripslashes_deep($value) {
- $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
- return $value;
- }
+ function stripslashes_deep($value)
+ {
+ $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
+ return $value;
+ }
- $_POST = array_map('stripslashes_deep', $_POST);
- $_GET = array_map('stripslashes_deep', $_GET);
- $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
+ $_POST = array_map('stripslashes_deep', $_POST);
+ $_GET = array_map('stripslashes_deep', $_GET);
+ $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
if (!empty($_POST)) {
- $ui = $_POST;
- $ui['request'] = 'form';
- $ui['iw'] = 1;
- unset($_POST);
+ $ui = $_POST;
+ $ui['request'] = 'form';
+ $ui['iw'] = 1;
+ unset($_POST);
}
if (!empty($_GET)) {
- $ui = $_GET;
- $ui['request'] = 'api';
- unset($_GET);
+ $ui = $_GET;
+ $ui['request'] = 'api';
+ unset($_GET);
}
if (empty($ui['request'])) {
- $ui['request'] = '';
+ $ui['request'] = '';
}
if (empty($ui['p'])) {
- $ui['p'] = 'index';
+ $ui['p'] = 'index';
}
if (empty($ui['fr'])) {
- $ui['fr'] = '';
+ $ui['fr'] = '';
}
if (empty($ui['t'])) {
- $ui['t'] = 't';
+ $ui['t'] = 't';
}
-if (isset($ui['logout']) && (int)$ui['logout'] === 1) {
- session_destroy();
- header("Location:?");
- exit();
+if (isset($ui['logout']) && (int) $ui['logout'] === 1) {
+ session_destroy();
+ header("Location:?");
+ exit();
}
if (!file_exists('cache/config/genConf.php')) {
- $serverKey = install();
- $ui['p'] = 'install';
+ $serverKey = install();
+ $ui['p'] = 'install';
}
require 'cache/config/genConf.php';
if ($GLOBALS['config']['pwd'] === 'install' && $ui['p'] !== 'install') {
- reloadInstall();
- header("Location:?");
+ reloadInstall();
+ header("Location:?");
}
if (($GLOBALS['config']['onlyLocalServer'] === true && $_SERVER['REMOTE_ADDR'] !== '127.0.0.1') || checkIfBan() === true) {
- header("HTTP/1.0 404 Not Found");
- echo "404 Not Found ";
- echo "The page that you have requested could not be found.";
- exit();
+ header("HTTP/1.0 404 Not Found");
+ echo "404 Not Found ";
+ echo "The page that you have requested could not be found.";
+ exit();
}
if ($GLOBALS['config']['NoWebPage'] === true && empty($_GET)) {
- header("HTTP/1.0 404 Not Found");
- echo "404 Not Found ";
- echo "The page that you have requested could not be found.";
- exit();
+ header("HTTP/1.0 404 Not Found");
+ echo "404 Not Found ";
+ echo "The page that you have requested could not be found.";
+ exit();
}
-function testExistImg($file) {
- if ($GLOBALS['config']['activeFullSize'] && $GLOBALS['config']['activeComplete']) {
- if (file_exists($file.'_thumb.png') && file_exists($file.'.png') && file_exists($file.'_complete.png')) {
- return true;
+function testExistImg($file)
+{
+ if ($GLOBALS['config']['activeFullSize'] && $GLOBALS['config']['activeComplete']) {
+ if (file_exists($file . '_thumb.png') && file_exists($file . '.png') && file_exists($file . '_complete.png')) {
+ return true;
+ } else {
+ return false;
+ }
+ } elseif ($GLOBALS['config']['activeFullSize']) {
+ if (file_exists($file . '_thumb.png') && file_exists($file . '.png')) {
+ return true;
+ } else {
+ return false;
+ }
+ } elseif ($GLOBALS['config']['activeComplete']) {
+ if (file_exists($file . '_thumb.png') && file_exists($file . '_complete.png')) {
+ return true;
+ } else {
+ return false;
+ }
} else {
- return false;
+ if (file_exists($file . '_thumb.png')) {
+ return true;
+ } else {
+ return false;
+ }
}
- } elseif ($GLOBALS['config']['activeFullSize']) {
- if (file_exists($file.'_thumb.png') && file_exists($file.'.png')) {
- return true;
- } else {
- return false;
- }
- } elseif ($GLOBALS['config']['activeComplete']) {
- if (file_exists($file.'_thumb.png') && file_exists($file.'_complete.png')) {
- return true;
- } else {
- return false;
- }
- } else {
- if (file_exists($file.'_thumb.png')) {
- return true;
- } else {
- return false;
- }
- }
}
/**
@@ -137,279 +139,296 @@ function testExistImg($file) {
* @param $waitForResult (bool)
* @return
*/
-function launchScript($url, $hashUrl, $width, $size, $waitForResult = false) {
- $oriHash = $hashUrl;
- $hashUrl = escapeshellarg($hashUrl);
- $url = escapeshellarg($url);
- $width = escapeshellarg($width);
- if ($GLOBALS['config']['activeFullSize'] && $GLOBALS['config']['activeComplete']) {
- $renderType = 'trc';
- } elseif ($GLOBALS['config']['activeFullSize']) {
- $renderType = 'tr';
- } elseif ($GLOBALS['config']['activeComplete']) {
- $renderType = 'tc';
- } else {
- $renderType = 't';
- }
- if ($GLOBALS['config']['disableExec'] === false) {
- if (!file_exists('cache/tmp/'.$oriHash.'.lock')) {
- touch('cache/tmp/'.$oriHash.'.lock');
- chdir('bin/');
- if ($waitForResult === false) {
- exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' > /dev/null &', $result);
- } else {
- exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' 1', $result);
- }
- chdir('../');
+function launchScript($url, $hashUrl, $width, $size, $waitForResult = false)
+{
+ $oriHash = $hashUrl;
+ $hashUrl = escapeshellarg($hashUrl);
+ $url = escapeshellarg($url);
+ $width = escapeshellarg($width);
+ if ($GLOBALS['config']['activeFullSize'] && $GLOBALS['config']['activeComplete']) {
+ $renderType = 'trc';
+ } elseif ($GLOBALS['config']['activeFullSize']) {
+ $renderType = 'tr';
+ } elseif ($GLOBALS['config']['activeComplete']) {
+ $renderType = 'tc';
} else {
- return 0;
+ $renderType = 't';
}
- } else {
- makeQueueFile($url, $hashUrl, $width, $size, $renderType);
- $result = 0;
- }
- return $result;
-}
-
-function makeQueueFile($url, $hashUrl, $width, $size, $renderType) {
- $url = str_replace('\'', '', $url);
- $hashUrl = str_replace('\'', '', $hashUrl);
- $width = str_replace('\'', '', $width);
- if (!file_exists('cache/cronTask/'.$hashUrl.'.hash')) {
- $data = $url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType."\n";
- file_put_contents('cache/cronTask/'.$hashUrl.'.hash', $data);
- }
-}
-
-function testValidUrl($url) {
- $url = trim($url);
- if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
- $url = parse_url($url);
- if (!in_array($url['scheme'], array(
- 'http',
- 'https'
- ))) {
- return array('msg' => 'Url must be start by http or https.');
+ if ($GLOBALS['config']['disableExec'] === false) {
+ if (!file_exists('cache/tmp/' . $oriHash . '.lock')) {
+ touch('cache/tmp/' . $oriHash . '.lock');
+ chdir('bin/');
+ if ($waitForResult === false) {
+ exec('bash thumb_server.sh ' . $url . ' ' . $hashUrl . ' ' . $width . ' ' . $size . ' ' . $renderType . ' > /dev/null &', $result);
+ } else {
+ exec('bash thumb_server.sh ' . $url . ' ' . $hashUrl . ' ' . $width . ' ' . $size . ' ' . $renderType . ' 1', $result);
+ }
+ chdir('../');
+ } else {
+ return 0;
+ }
+ } else {
+ makeQueueFile($url, $hashUrl, $width, $size, $renderType);
+ $result = 0;
}
- return true;
- } else {
- return array('msg' => 'Not a valid url.');
- }
+ return $result;
}
-function genToken() {
- $token = sha1(uniqid(rand(), true).'_'.mt_rand());
- $_SESSION['token'] = $token;
- $_SESSION['tokenTime'] = time();
- return $token;
+function makeQueueFile($url, $hashUrl, $width, $size, $renderType)
+{
+ $url = str_replace('\'', '', $url);
+ $hashUrl = str_replace('\'', '', $hashUrl);
+ $width = str_replace('\'', '', $width);
+ if (!file_exists('cache/cronTask/' . $hashUrl . '.hash')) {
+ $data = $url . ' ' . $hashUrl . ' ' . $width . ' ' . $size . ' ' . $renderType . "\n";
+ file_put_contents('cache/cronTask/' . $hashUrl . '.hash', $data);
+ }
}
-function verifToken($token) {
- if ($token !== $_SESSION['token'] || $_SESSION['tokenTime'] <= time() - 24000) {
- ban();
- die('So Long, and Thanks for All the Fish.');
- }
+function testValidUrl($url)
+{
+ $url = trim($url);
+ if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
+ $url = parse_url($url);
+ if (!in_array($url['scheme'], array(
+ 'http',
+ 'https',
+ ))) {
+ return array('msg' => 'Url must be start by http or https.');
+ }
+ return true;
+ } else {
+ return array('msg' => 'Not a valid url.');
+ }
}
-function checkIfBan() {
- require 'cache/logs/banUser.php';
- $userIp = $_SERVER['REMOTE_ADDR'];
- if (isset($banList[$userIp]) && $banList[$userIp]['nbBan'] >= $GLOBALS['config']['maxErrorBeforeBan'] && $banList[$userIp]['lastBan'] + $GLOBALS['config']['banTime'] > time()) {
- return true;
- } elseif (isset($banList[$userIp]) && $banList[$userIp]['lastBan'] + $GLOBALS['config']['banTime'] < time()) {
- unban();
- return false;
- } else {
- return false;
- }
+function genToken()
+{
+ $token = sha1(uniqid(rand(), true) . '_' . mt_rand());
+ $_SESSION['token'] = $token;
+ $_SESSION['tokenTime'] = time();
+ return $token;
}
-function ban() {
- require 'cache/logs/banUser.php';
- $userIp = $_SERVER['REMOTE_ADDR'];
- if (isset($banList[$userIp])) {
- $banList[$userIp]['lastBan'] = time();
- $banList[$userIp]['nbBan']++;
- } else {
- $banList[$userIp]['lastBan'] = time();
- $banList[$userIp]['nbBan'] = 1;
- }
- file_put_contents('cache/logs/banUser.php', "");
+function verifToken($token)
+{
+ if ($token !== $_SESSION['token'] || $_SESSION['tokenTime'] <= time() - 24000) {
+ ban();
+ die('So Long, and Thanks for All the Fish.');
+ }
}
-function unBan() {
- require 'cache/logs/banUser.php';
- $userIp = $_SERVER['REMOTE_ADDR'];
- unset($banList[$userIp]);
- file_put_contents('cache/logs/banUser.php', "");
+function checkIfBan()
+{
+ require 'cache/logs/banUser.php';
+ $userIp = $_SERVER['REMOTE_ADDR'];
+ if (isset($banList[$userIp]) && $banList[$userIp]['nbBan'] >= $GLOBALS['config']['maxErrorBeforeBan'] && $banList[$userIp]['lastBan'] + $GLOBALS['config']['banTime'] > time()) {
+ return true;
+ } elseif (isset($banList[$userIp]) && $banList[$userIp]['lastBan'] + $GLOBALS['config']['banTime'] < time()) {
+ unban();
+ return false;
+ } else {
+ return false;
+ }
}
-function install() {
- if (!is_writable('cache')) {
- die('Make dir "cache" writable');
- }
- if (!is_dir('cache/config') && !mkdir('cache/config', 0705)) {
- die('Error on create dir "cache/config".');
- }
- if (!is_dir('cache/img') && !mkdir('cache/img', 0705)) {
- die('Error on create dir "cache/img".');
- }
- if (!is_dir('cache/logs') && !mkdir('cache/logs', 0705)) {
- die('Error on create dir "cache/logs".');
- }
- if (!is_dir('cache/logs/suspect') && !mkdir('cache/logs/suspect', 0705)) {
- die('Error on create dir "cache/logs/suspect".');
- }
- if (!is_dir('cache/logs/retry') && !mkdir('cache/logs/retry', 0705)) {
- die('Error on create dir "cache/logs/retry".');
- }
- if (!is_dir('cache/logs/other') && !mkdir('cache/logs/other', 0705)) {
- die('Error on create dir "cache/logs/other".');
- }
- if (!is_dir('cache/tmp') && !mkdir('cache/tmp', 0705)) {
- die('Error on create dir "cache/tmp".');
- }
- if (!is_dir('cache/cronTask') && !mkdir('cache/cronTask', 0705)) {
- die('Error on create dir "cache/cronTask".');
- }
- $salt = sha1(uniqid(rand(), true).'_'.mt_rand());
- $serverKey = substr(sha1(uniqid(rand(), true).'_'.mt_rand().$salt), 0, 12);
- $encryptServerKey = sha1($serverKey.$salt);
- if (!is_file('cache/config/genConf.php')) {
- file_put_contents('cache/config/genConf.php', "
+function ban()
+{
+ require 'cache/logs/banUser.php';
+ $userIp = $_SERVER['REMOTE_ADDR'];
+ if (isset($banList[$userIp])) {
+ $banList[$userIp]['lastBan'] = time();
+ $banList[$userIp]['nbBan']++;
+ } else {
+ $banList[$userIp]['lastBan'] = time();
+ $banList[$userIp]['nbBan'] = 1;
+ }
+ file_put_contents('cache/logs/banUser.php', "");
+}
+
+function unBan()
+{
+ require 'cache/logs/banUser.php';
+ $userIp = $_SERVER['REMOTE_ADDR'];
+ unset($banList[$userIp]);
+ file_put_contents('cache/logs/banUser.php', "");
+}
+
+function install()
+{
+ if (!is_writable('cache')) {
+ die('Make dir "cache" writable');
+ }
+ if (!is_dir('cache/config') && !mkdir('cache/config', 0705)) {
+ die('Error on create dir "cache/config".');
+ }
+ if (!is_dir('cache/img') && !mkdir('cache/img', 0705)) {
+ die('Error on create dir "cache/img".');
+ }
+ if (!is_dir('cache/logs') && !mkdir('cache/logs', 0705)) {
+ die('Error on create dir "cache/logs".');
+ }
+ if (!is_dir('cache/logs/suspect') && !mkdir('cache/logs/suspect', 0705)) {
+ die('Error on create dir "cache/logs/suspect".');
+ }
+ if (!is_dir('cache/logs/retry') && !mkdir('cache/logs/retry', 0705)) {
+ die('Error on create dir "cache/logs/retry".');
+ }
+ if (!is_dir('cache/logs/other') && !mkdir('cache/logs/other', 0705)) {
+ die('Error on create dir "cache/logs/other".');
+ }
+ if (!is_dir('cache/tmp') && !mkdir('cache/tmp', 0705)) {
+ die('Error on create dir "cache/tmp".');
+ }
+ if (!is_dir('cache/cronTask') && !mkdir('cache/cronTask', 0705)) {
+ die('Error on create dir "cache/cronTask".');
+ }
+ $salt = sha1(uniqid(rand(), true) . '_' . mt_rand());
+ $serverKey = substr(sha1(uniqid(rand(), true) . '_' . mt_rand() . $salt), 0, 12);
+ $encryptServerKey = sha1($serverKey . $salt);
+ if (!is_file('cache/config/genConf.php')) {
+ file_put_contents('cache/config/genConf.php', "
");
- }
- if (!is_file('cache/config/serverOptions.php')) {
- touch('cache/config/serverOptions.php');
- }
- if (!is_file('cache/index.html')) {
- touch('cache/index.html');
- }
- if (!is_file('cache/config/options.php')) {
- file_put_contents('cache/config/options.php', "");
- }
- if (!is_file('cache/logs/banUser.php')) {
- file_put_contents('cache/logs/banUser.php', "");
- }
- $GLOBALS['config']['serverKey'] = $encryptServerKey;
- $GLOBALS['config']['salt'] = $salt;
- $GLOBALS['config']['pwd'] = 'install';
- $GLOBALS['config']['apikey'] = $serverKey;
- return $serverKey;
-}
-
-function checkInstall() {
- if (!is_file('.htaccess')) {
- file_put_contents('.htaccess', "AddDefaultCharset UTF-8\nOptions -Indexes\nDirectoryIndex index.php index.html\nFileETag none\nSetOutputFilter DEFLATE\n");
- }
- if (!is_file('cache/logs/.htaccess')) {
- file_put_contents('cache/logs/.htaccess', "Allow from none\nDeny from all\n");
- }
- if (!is_file('cache/config/.htaccess')) {
- file_put_contents('cache/config/.htaccess', "Allow from none\nDeny from all\n");
- }
- if (!is_file('cache/cronTask/.htaccess')) {
- file_put_contents('cache/config/.htaccess', "Allow from none\nDeny from all\n");
- }
- if (!is_file('bin/.htaccess')) {
- file_put_contents('bin/.htaccess', "Allow from none\nDeny from all\n");
- }
-}
-
-function removeOlderThan($dir = 'cache/img/shortLive') {
- if (is_dir($dir)) {
- $objects = scandir($dir);
- foreach ($objects as $object) {
- if ($object !== '.' && $object !== '..' && $object) {
- if (filetype($dir.'/'.$object) === 'dir') {
- removeOlderThan($dir.'/'.$object);
- } else {
- if (fileatime($dir.'/'.$object) < time() - 3600 * $GLOBALS['config']['expireCache']) {
- unlink($dir.'/'.$object);
- }
- }
- }
}
- reset($objects);
- }
+ if (!is_file('cache/config/serverOptions.php')) {
+ touch('cache/config/serverOptions.php');
+ }
+ if (!is_file('cache/index.html')) {
+ touch('cache/index.html');
+ }
+ if (!is_file('cache/config/options.php')) {
+ file_put_contents('cache/config/options.php', "");
+ }
+ if (!is_file('cache/logs/banUser.php')) {
+ file_put_contents('cache/logs/banUser.php', "");
+ }
+ $GLOBALS['config']['serverKey'] = $encryptServerKey;
+ $GLOBALS['config']['salt'] = $salt;
+ $GLOBALS['config']['pwd'] = 'install';
+ $GLOBALS['config']['apikey'] = $serverKey;
+ return $serverKey;
}
-function pathForFile($size, $hashUrl) {
- $startPath = substr($hashUrl, 0, 2).'/'.substr($hashUrl, 2, 2).'/';
- if (empty($size)) {
- $size = tryDetectSize($startPath.$hashUrl);
- }
- $file = 'cache/img/'.$size.'/'.$startPath.$hashUrl;
- return $file;
+function checkInstall()
+{
+ if (!is_file('.htaccess')) {
+ file_put_contents('.htaccess', "AddDefaultCharset UTF-8\nOptions -Indexes\nDirectoryIndex index.php index.html\nFileETag none\nSetOutputFilter DEFLATE\n");
+ }
+ if (!is_file('cache/logs/.htaccess')) {
+ file_put_contents('cache/logs/.htaccess', "Allow from none\nDeny from all\n");
+ }
+ if (!is_file('cache/config/.htaccess')) {
+ file_put_contents('cache/config/.htaccess', "Allow from none\nDeny from all\n");
+ }
+ if (!is_file('cache/cronTask/.htaccess')) {
+ file_put_contents('cache/config/.htaccess', "Allow from none\nDeny from all\n");
+ }
+ if (!is_file('bin/.htaccess')) {
+ file_put_contents('bin/.htaccess', "Allow from none\nDeny from all\n");
+ }
}
-function tryDetectSize($file) {
- if (is_file('cache/img/s/'.$file.'_thumb.png')) {
- return 's';
- }
- if (is_file('cache/img/m/'.$file.'_thumb.png')) {
- return 'm';
- }
- if (is_file('cache/img/l/'.$file.'_thumb.png')) {
- return 'l';
- }
- if (is_file('cache/img/xl/'.$file.'_thumb.png')) {
- return 'xl';
- }
- if (is_file('cache/img/xxl/'.$file.'_thumb.png')) {
- return 'xxl';
- }
+function removeOlderThan($dir = 'cache/img/shortLive')
+{
+ if (is_dir($dir)) {
+ $objects = scandir($dir);
+ foreach ($objects as $object) {
+ if ($object !== '.' && $object !== '..' && $object) {
+ if (filetype($dir . '/' . $object) === 'dir') {
+ removeOlderThan($dir . '/' . $object);
+ } else {
+ if (fileatime($dir . '/' . $object) < time() - 3600 * $GLOBALS['config']['expireCache']) {
+ unlink($dir . '/' . $object);
+ }
+ }
+ }
+ }
+ reset($objects);
+ }
}
-function validHash($hash) {
- if (empty($hash)) {
- die('You talking to me');
- }
- if (!preg_match('/^[0-9a-f]{40}$/i', $hash)) {
- die('I don\'t understand biiip bip bip biiiip bip bip bip biiiiiiip biip ...');
- }
- return $hash;
+function pathForFile($size, $hashUrl)
+{
+ $startPath = substr($hashUrl, 0, 2) . '/' . substr($hashUrl, 2, 2) . '/';
+ if (empty($size)) {
+ $size = tryDetectSize($startPath . $hashUrl);
+ }
+ $file = 'cache/img/' . $size . '/' . $startPath . $hashUrl;
+ return $file;
}
-function checkAdmin($pwd) {
- $pwd = sha1($GLOBALS['config']['salt'].$pwd.$GLOBALS['config']['serverKey']);
- if (validHash($pwd) !== $GLOBALS['config']['pwd']) {
- ban();
- die('1, 2, 3, 4, 5 ? That\'s amazing ! I\'ve got the same combination on my luggage !');
- }
- $_SESSION['login'] = true;
- return true;
+function tryDetectSize($file)
+{
+ if (is_file('cache/img/s/' . $file . '_thumb.png')) {
+ return 's';
+ }
+ if (is_file('cache/img/m/' . $file . '_thumb.png')) {
+ return 'm';
+ }
+ if (is_file('cache/img/l/' . $file . '_thumb.png')) {
+ return 'l';
+ }
+ if (is_file('cache/img/xl/' . $file . '_thumb.png')) {
+ return 'xl';
+ }
+ if (is_file('cache/img/xxl/' . $file . '_thumb.png')) {
+ return 'xxl';
+ }
}
-function savePass($passOne, $passTwo, $token) {
- verifToken($token);
- if ($passOne !== $passTwo || empty($passOne) || empty($passTwo)) {
- reloadInstall();
- } else {
- $GLOBALS['config']['pwd'] = sha1($GLOBALS['config']['salt'].$passOne.$GLOBALS['config']['serverKey']);
- $confServerKey = $GLOBALS['config']['serverKey'];
- $confSalt = $GLOBALS['config']['salt'];
- $confPwd = $GLOBALS['config']['pwd'];
- $apikey = $GLOBALS['config']['apikey'];
- $confFile = '
+function validHash($hash)
+{
+ if (empty($hash)) {
+ die('You talking to me');
+ }
+ if (!preg_match('/^[0-9a-f]{40}$/i', $hash)) {
+ die('I don\'t understand biiip bip bip biiiip bip bip bip biiiiiiip biip ...');
+ }
+ return $hash;
+}
+
+function checkAdmin($pwd)
+{
+ $pwd = sha1($GLOBALS['config']['salt'] . $pwd . $GLOBALS['config']['serverKey']);
+ if (validHash($pwd) !== $GLOBALS['config']['pwd']) {
+ ban();
+ die('1, 2, 3, 4, 5 ? That\'s amazing ! I\'ve got the same combination on my luggage !');
+ }
+ $_SESSION['login'] = true;
+ return true;
+}
+
+function savePass($passOne, $passTwo, $token)
+{
+ verifToken($token);
+ if ($passOne !== $passTwo || empty($passOne) || empty($passTwo)) {
+ reloadInstall();
+ } else {
+ $GLOBALS['config']['pwd'] = sha1($GLOBALS['config']['salt'] . $passOne . $GLOBALS['config']['serverKey']);
+ $confServerKey = $GLOBALS['config']['serverKey'];
+ $confSalt = $GLOBALS['config']['salt'];
+ $confPwd = $GLOBALS['config']['pwd'];
+ $apikey = $GLOBALS['config']['apikey'];
+ $confFile = '
';
- file_put_contents('cache/config/genConf.php', $confFile);
- }
- header("Location:?");
+ file_put_contents('cache/config/genConf.php', $confFile);
+ }
+ header("Location:?");
}
-function reloadInstall() {
- array_map('unlink', glob("cache/config/*"));
+function reloadInstall()
+{
+ array_map('unlink', glob("cache/config/*"));
}
/**
@@ -422,241 +441,247 @@ function reloadInstall() {
* @return false affiche les clef valeur du tableau $data
* @example n_print($array, 'Tableau de valeur');
*/
-function n_print($data, $name = '') {
- $aBackTrace = debug_backtrace();
- echo '', $name, ' ';
- echo '';
- echo '
- ', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
+function n_print($data, $name = '')
+{
+ $aBackTrace = debug_backtrace();
+ echo '', $name, ' ';
+ echo ' ';
+ echo '
+ ', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
';
- echo '', htmlentities(print_r($data, 1)), ' ';
- echo '
+ echo '', htmlentities(print_r($data, 1)), ' ';
+ echo '
';
}
-function printThumbShot($file, $renderType) {
- ob_end_clean();
- header("Content-type: image/png");
- header('Expires: ', gmdate('D, d M Y H:i:s', time()).' GMT');
- switch ($renderType) {
- case 'c' :
- echo file_get_contents($file.'_complete.png');
- break;
- case 'r' :
- echo file_get_contents($file.'.png');
- break;
- default :
- echo file_get_contents($file.'_thumb.png');
- break;
- }
- exit();
+function printThumbShot($file, $renderType)
+{
+ ob_end_clean();
+ header("Content-type: image/png");
+ header('Expires: ', gmdate('D, d M Y H:i:s', time()) . ' GMT');
+ switch ($renderType) {
+ case 'c':
+ echo file_get_contents($file . '_complete.png');
+ break;
+ case 'r':
+ echo file_get_contents($file . '.png');
+ break;
+ default:
+ echo file_get_contents($file . '_thumb.png');
+ break;
+ }
+ exit();
}
-function getPage($page) {
- $page = htmlspecialchars($page);
- switch ($page) {
- case 'login' :
- return 'inc/login.php';
- break;
- case 'install' :
- return 'inc/install.php';
- break;
- case 'admin' :
- return 'inc/admin.php';
- break;
- default :
- return 'inc/index.php';
- break;
- }
+function getPage($page)
+{
+ $page = htmlspecialchars($page);
+ switch ($page) {
+ case 'login':
+ return 'inc/login.php';
+ break;
+ case 'install':
+ return 'inc/install.php';
+ break;
+ case 'admin':
+ return 'inc/admin.php';
+ break;
+ default:
+ return 'inc/index.php';
+ break;
+ }
}
-function testIfImg($url) {
- $ext = strtolower(pathinfo($url, PATHINFO_EXTENSION));
- if ($ext === 'jpg' || $ext === 'jpeg' || $ext === 'png' || $ext === 'gif') {
- return $ext;
- } else {
- return false;
- }
+function testIfImg($url)
+{
+ $ext = strtolower(pathinfo($url, PATHINFO_EXTENSION));
+ if ($ext === 'jpg' || $ext === 'jpeg' || $ext === 'png' || $ext === 'gif' || $ext === 'ico') {
+ return $ext;
+ } else {
+ return false;
+ }
}
-function makeImgThumb($url, $ext, $hashUrl, $width, $path, $renderType) {
- if (!function_exists('imagecreatefromjpeg')) {
- return false;
- }
- $image = file_get_contents($url);
- $fullSize = file_put_contents('cache/tmp/'.$hashUrl.'.'.$ext, $image);
- if ($ext === 'jpg' || $ext === 'jpeg') {
- $tmpImg = imagecreatefromjpeg('cache/tmp/'.$hashUrl.'.'.$ext);
- }
- if ($ext === 'png') {
- $tmpImg = imagecreatefrompng('cache/tmp/'.$hashUrl.'.'.$ext);
- }
- if ($ext === 'gif') {
- $tmpImg = imagecreatefromgif('cache/tmp/'.$hashUrl.'.'.$ext);
- }
- if (!$tmpImg) {
- unlink('cache/tmp/'.$hashUrl.'.'.$ext);
- return false;
- }
- $w = imagesx($tmpImg);
- $h = imagesy($tmpImg);
- $ystart = 0;
- $yheight = $h;
- if ($h > $w) { $ystart = ($h / 2) - ($w / 2);
- $yheight = $w / 2;
- }
- $nh = min(floor(($h * $width) / $w), $width);
- $im2 = imagecreatetruecolor($width, $nh);
- imagecopyresampled($im2, $tmpImg, 0, 0, 0, $ystart, $width, $nh, $w, $yheight);
- $tempname = 'cache/tmp/'.$hashUrl.'_TEMP.png';
- imagepng($im2, $tempname, 9);
- if (!is_dir($path)) {
- mkdir($path, 0775, true);
- }
- imagedestroy($tmpImg);
- imagedestroy($im2);
- unlink('cache/tmp/'.$hashUrl.'.'.$ext);
- rename($tempname, $path.$hashUrl.'_thumb.png');
- if (file_exists($path.$hashUrl.'_thumb.png')) {
- return true;
- } else {
- return false;
- }
+function makeImgThumb($url, $ext, $hashUrl, $width, $path, $renderType=null)
+{
+ if (!function_exists('imagecreatefromjpeg')) {
+ return false;
+ }
+ $image = file_get_contents($url);
+ $fullSize = file_put_contents('cache/tmp/' . $hashUrl . '.' . $ext, $image);
+ if ($ext === 'jpg' || $ext === 'jpeg') {
+ $tmpImg = imagecreatefromjpeg('cache/tmp/' . $hashUrl . '.' . $ext);
+ }
+ if ($ext === 'png') {
+ $tmpImg = imagecreatefrompng('cache/tmp/' . $hashUrl . '.' . $ext);
+ }
+ if ($ext === 'gif') {
+ $tmpImg = imagecreatefromgif('cache/tmp/' . $hashUrl . '.' . $ext);
+ }
+ if (!$tmpImg) {
+ unlink('cache/tmp/' . $hashUrl . '.' . $ext);
+ return false;
+ }
+ $w = imagesx($tmpImg);
+ $h = imagesy($tmpImg);
+ $ystart = 0;
+ $yheight = $h;
+ if ($h > $w) {$ystart = ($h / 2) - ($w / 2);
+ $yheight = $w / 2;
+ }
+ $nh = min(floor(($h * $width) / $w), $width);
+ $im2 = imagecreatetruecolor($width, $nh);
+ imagecopyresampled($im2, $tmpImg, 0, 0, 0, $ystart, $width, $nh, $w, $yheight);
+ $tempname = 'cache/tmp/' . $hashUrl . '_TEMP.png';
+ imagepng($im2, $tempname, 9);
+ if (!is_dir($path)) {
+ mkdir($path, 0775, true);
+ }
+ imagedestroy($tmpImg);
+ imagedestroy($im2);
+ unlink('cache/tmp/' . $hashUrl . '.' . $ext);
+ rename($tempname, $path . $hashUrl . '_thumb.png');
+ if (file_exists($path . $hashUrl . '_thumb.png')) {
+ return true;
+ } else {
+ return false;
+ }
}
-function checkHmac($receiveHmac, $url){
- if($receiveHmac === makeHmac($url, $GLOBALS['config']['apikey'])){
- return true;
- }
- else {
- return false;
- }
+function checkHmac($receiveHmac, $url)
+{
+ if ($receiveHmac === makeHmac($url, $GLOBALS['config']['apikey'])) {
+ return true;
+ } else {
+ return false;
+ }
}
-function makeHmac($url){
- return hash_hmac('sha1',$url, $GLOBALS['config']['apikey']);
+function makeHmac($url)
+{
+ return hash_hmac('sha1', $url, $GLOBALS['config']['apikey']);
}
/*
- $image = file_get_contents('http://www.url.com/image.jpg');
- file_put_contents('/images/image.jpg', $image); //save the image on your server
+$image = file_get_contents('http://www.url.com/image.jpg');
+file_put_contents('/images/image.jpg', $image); //save the image on your server
*
*
*/
checkInstall();
removeOlderThan();
if (empty($defUrl)) {
- $defUrl = $GLOBALS['config']['defaultUrl'];
+ $defUrl = $GLOBALS['config']['defaultUrl'];
}
if (isset($ui['s']) && array_key_exists($ui['s'], $GLOBALS['config']['thumbSize'])) {
- $width = $GLOBALS['config']['thumbSize'][$ui['s']];
+ $width = $GLOBALS['config']['thumbSize'][$ui['s']];
} else {
- $width = $GLOBALS['config']['defaultThumbSize'];
+ $width = $GLOBALS['config']['defaultThumbSize'];
}
// Generate or return img
if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' && $ui['p'] !== 'admin') {
- if (empty($ui['url'])) {
- die('You see in this world there\'s two kinds of people, my friend. Those with loaded guns, and those who dig. You dig.');
- }
- $ui['sendUrl'] = $ui['url'];
- $ui['url'] = trim(rawurldecode($ui['url']));
- $ui['url'] = rtrim($ui['url'], '/');
- $hashUrl = sha1($GLOBALS['config']['salt'].$ui['url']);
- $startPath = substr($hashUrl, 0, 2).'/'.substr($hashUrl, 2, 2).'/';
- $file = 'cache/img/'.$ui['s'].'/'.$startPath.$hashUrl;
- $testUrl = testValidUrl($ui['url']);
- $defUrl = $ui['url'];
- if ($ui['request'] === 'form') {
- $file = 'cache/img/shortLive/'.$startPath.$hashUrl;
- $file = 'cache/img/shortLive/'.$startPath.$hashUrl;
- }
- if (testExistImg($file) === true && (int)$ui['fr'] !== 1) {
- if ($ui['request'] === 'api') {
- if (checkHmac($ui['hm'], $ui['sendUrl'])){
- printThumbShot($file, $ui['t']);
- } else {
- ban();
- die('I take a chips and give it to Godzilla. I give high kick in Chuck Norris face and I go to ... Humm .... Ehh .... Arg ....... KAMOULOX ! Well done Jean Pierre.');
- }
+ if (empty($ui['url'])) {
+ die('You see in this world there\'s two kinds of people, my friend. Those with loaded guns, and those who dig. You dig.');
}
+ $ui['sendUrl'] = $ui['url'];
+ $ui['url'] = trim(rawurldecode($ui['url']));
+ $ui['url'] = rtrim($ui['url'], '/');
+ $hashUrl = sha1($GLOBALS['config']['salt'] . $ui['url']);
+ $startPath = substr($hashUrl, 0, 2) . '/' . substr($hashUrl, 2, 2) . '/';
+ $file = 'cache/img/' . $ui['s'] . '/' . $startPath . $hashUrl;
+ $testUrl = testValidUrl($ui['url']);
+ $defUrl = $ui['url'];
if ($ui['request'] === 'form') {
- $success = array(
- 'normal' => $file.'.png',
- 'thumb' => $file.'_thumb.png',
- 'complete' => $file.'_complete.png'
- );
+ $file = 'cache/img/shortLive/' . $startPath . $hashUrl;
+ $file = 'cache/img/shortLive/' . $startPath . $hashUrl;
}
- } else {
- if ($ui['request'] === 'api') {
- if (empty($ui['hm']) || empty($ui['hm'])) {
- die('Are you Ken ?');
- }
- if (!checkHmac($ui['hm'], $ui['sendUrl'])) {
- ban();
- die('I take a chips and give it to Godzilla. I give high kick in Chuck Norris face and I go to ... Humm .... Ehh .... Arg ....... KAMOULOX ! Well done Jean Pierre.');
- }
- } else {
- verifToken($ui['token']);
- }
- if ($testUrl !== true) {
- if (!file_exists('cache/logs/'.$hashUrl.'log')) {
- file_put_contents('cache/logs/suspect/'.$hashUrl.'.log', $_SERVER['REMOTE_ADDR'].' --- '.$ui['url'].' --- '.$hashUrl.' --- '.$width.' --- '.$ui['s'].' --- '.$renderType.' --- true'."\n");
- }
- if ($ui['request'] === 'api') {
- printThumbShot('bin/error', $ui['t']);
- } else {
- $success = array(
- 'normal' => 'bin/error.png',
- 'thumb' => 'bin/error_thumb.png',
- 'complete' => 'bin/error.png'
- );
- }
- } else {
- $ext = testIfImg($ui['url']);
- if ($ext !== false) {
- $genWidth = explode("x", $width);
+ if (testExistImg($file) === true && (int) $ui['fr'] !== 1) {
if ($ui['request'] === 'api') {
- $makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/'.$ui['s'].'/'.$startPath, $ui['t']);
- } else {
- $makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/shortLive/'.$startPath, $ui['t']);
+ if (checkHmac($ui['hm'], $ui['sendUrl'])) {
+ printThumbShot($file, $ui['t']);
+ } else {
+ ban();
+ die('I take a chips and give it to Godzilla. I give high kick in Chuck Norris face and I go to ... Humm .... Ehh .... Arg ....... KAMOULOX ! Well done Jean Pierre.');
+ }
}
- if ($makeImg === true) {
- $GLOBALS['config']['disableExec'] = true;
- if ($ui['request'] === 'api') {
- printThumbShot($file, $ui['t']);
- } else {
+ if ($ui['request'] === 'form') {
$success = array(
- 'normal' => $file.'.png',
- 'thumb' => $file.'_thumb.png',
- 'complete' => $file.'_complete.png'
+ 'normal' => $file . '.png',
+ 'thumb' => $file . '_thumb.png',
+ 'complete' => $file . '_complete.png',
);
- }
}
- }
- if ((isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'api')) {
- $res = launchScript($defUrl, $hashUrl, $width, $ui['s'], true);
- } elseif (isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'form') {
- $res = launchScript($defUrl, $hashUrl, $width, 'shortLive', true);
- } else {
- $res = launchScript($defUrl, $hashUrl, $width, $ui['s'], false);
- }
- if ($ui['request'] === 'api') {
- $file = 'bin/loadingGen';
- printThumbShot($file, $ui['t']);
- } else {
- if ($GLOBALS['config']['disableExec'] === true) {
- $file = 'bin/loadingGen';
+ } else {
+ if ($ui['request'] === 'api') {
+ if (empty($ui['hm']) || empty($ui['hm'])) {
+ die('Are you Ken ?');
+ }
+ if (!checkHmac($ui['hm'], $ui['sendUrl'])) {
+ ban();
+ die('I take a chips and give it to Godzilla. I give high kick in Chuck Norris face and I go to ... Humm .... Ehh .... Arg ....... KAMOULOX ! Well done Jean Pierre.');
+ }
+ } else {
+ verifToken($ui['token']);
+ }
+ if ($testUrl !== true) {
+ if (!file_exists('cache/logs/' . $hashUrl . 'log')) {
+ file_put_contents('cache/logs/suspect/' . $hashUrl . '.log', $_SERVER['REMOTE_ADDR'] . ' --- ' . $ui['url'] . ' --- ' . $hashUrl . ' --- ' . $width . ' --- ' . $ui['s'] . ' --- ' . $renderType . ' --- true' . "\n");
+ }
+ if ($ui['request'] === 'api') {
+ printThumbShot('bin/error', $ui['t']);
+ } else {
+ $success = array(
+ 'normal' => 'bin/error.png',
+ 'thumb' => 'bin/error_thumb.png',
+ 'complete' => 'bin/error.png',
+ );
+ }
+ } else {
+ $ext = testIfImg($ui['url']);
+ if ($ext !== false) {
+ $genWidth = explode("x", $width);
+ if ($ui['request'] === 'api') {
+ $makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/' . $ui['s'] . '/' . $startPath, $ui['t']);
+ } else {
+ $makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/shortLive/' . $startPath, $ui['t']);
+ }
+ if ($makeImg === true) {
+ $GLOBALS['config']['disableExec'] = true;
+ if ($ui['request'] === 'api') {
+ printThumbShot($file, $ui['t']);
+ } else {
+ $success = array(
+ 'normal' => $file . '.png',
+ 'thumb' => $file . '_thumb.png',
+ 'complete' => $file . '_complete.png',
+ );
+ }
+ }
+ }
+ if ((isset($ui['iw']) && (int) $ui['iw'] === 1 && $ui['request'] === 'api')) {
+ $res = launchScript($defUrl, $hashUrl, $width, $ui['s'], true);
+ } elseif (isset($ui['iw']) && (int) $ui['iw'] === 1 && $ui['request'] === 'form') {
+ $res = launchScript($defUrl, $hashUrl, $width, 'shortLive', true);
+ } else {
+ $res = launchScript($defUrl, $hashUrl, $width, $ui['s'], false);
+ }
+ if ($ui['request'] === 'api') {
+ $file = 'bin/loadingGen';
+ printThumbShot($file, $ui['t']);
+ } else {
+ if ($GLOBALS['config']['disableExec'] === true) {
+ $file = 'bin/loadingGen';
+ }
+ $success = array(
+ 'normal' => $file . '.png',
+ 'thumb' => $file . '_thumb.png',
+ 'complete' => $file . '_complete.png',
+ );
+ }
}
- $success = array(
- 'normal' => $file.'.png',
- 'thumb' => $file.'_thumb.png',
- 'complete' => $file.'_complete.png'
- );
- }
}
- }
}
?>
@@ -669,7 +694,7 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
+require getPage($ui['p']);
+?>