Merge branch 'dev'
This commit is contained in:
commit
f75d7dc6df
6 changed files with 132 additions and 44 deletions
14
bin/cronTask.sh
Normal file
14
bin/cronTask.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
queueDir="../cache/cronTask/"
|
||||||
|
|
||||||
|
for file in $queueDir*.hash
|
||||||
|
do
|
||||||
|
if [ -f $file ];
|
||||||
|
then
|
||||||
|
while read site hashUrl thumbSize sizeNameDir onlyThumb
|
||||||
|
do
|
||||||
|
bash thumb_server.sh "$site" "$hashUrl" "$thumbSize" "$sizeNameDir" "$onlyThumb" "0"
|
||||||
|
rm $file
|
||||||
|
done < $file
|
||||||
|
fi
|
||||||
|
done
|
|
@ -9,9 +9,11 @@ thumbSize=$3 # size of thumb widthxheight ex : 190x90
|
||||||
sizeNameDir=$4 # name of size dir
|
sizeNameDir=$4 # name of size dir
|
||||||
onlyThumb=$5 # make only thumbshot no full size image
|
onlyThumb=$5 # make only thumbshot no full size image
|
||||||
waitForResult=$6 # if true we try to make soon as possible or add to queue
|
waitForResult=$6 # if true we try to make soon as possible or add to queue
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
##### DON'T EDIT THIS PARAM USE #####
|
##### DON'T EDIT THIS PARAM USE #####
|
||||||
##### cache/config/serverOptions.php #####
|
##### cache/config/serverOptions.php #####
|
||||||
|
##### for overwrite options #####
|
||||||
##########################################
|
##########################################
|
||||||
maxThread=1 # max parralle work. For me the best is nb core - 1
|
maxThread=1 # max parralle work. For me the best is nb core - 1
|
||||||
timeOut=60 # default time out, after this time the site are declared in error
|
timeOut=60 # default time out, after this time the site are declared in error
|
||||||
|
@ -26,15 +28,15 @@ startPath=$sizeNameDir/$firstLevel/$secondLevel/
|
||||||
|
|
||||||
if [ $site == "manual" ]
|
if [ $site == "manual" ]
|
||||||
then
|
then
|
||||||
site=$(cat "cache/tmp/manual.txt")
|
site=$(cat "../cache/tmp/manual.txt")
|
||||||
echo '' > "cache/tmp/manual.txt"
|
echo '' > "../cache/tmp/manual.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "cache/img/$startPath"
|
mkdir -p "../cache/img/$startPath"
|
||||||
|
|
||||||
if [ -f "cache/config/serverOptions.php" ]
|
if [ -f "../cache/config/serverOptions.php" ]
|
||||||
then
|
then
|
||||||
source "cache/config/serverOptions.php"
|
source "../cache/config/serverOptions.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $currentProcess -gt $maxQueue ]
|
if [ $currentProcess -gt $maxQueue ]
|
||||||
|
@ -52,9 +54,9 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
timeout $timeOut ./bin/phantomjs --disk-cache=false --local-storage-path=/bin/ --ignore-ssl-errors=true /bin/rasterize.js "$site" "cache/tmp/$hashUrl.png"
|
timeout $timeOut ./phantomjs --disk-cache=false --local-storage-path=bin/ --ignore-ssl-errors=true rasterize.js "$site" "../cache/tmp/$hashUrl.png"
|
||||||
|
|
||||||
if [ ! -f "cache/tmp/$hashUrl.png" ]
|
if [ ! -f "../cache/tmp/$hashUrl.png" ]
|
||||||
then
|
then
|
||||||
echo 0
|
echo 0
|
||||||
errorCode=`echo $(curl -k --write-out %{http_code} --silent -S --connect-timeout $timeOut \--no-keepalive --output /dev/null $site)`
|
errorCode=`echo $(curl -k --write-out %{http_code} --silent -S --connect-timeout $timeOut \--no-keepalive --output /dev/null $site)`
|
||||||
|
@ -63,10 +65,10 @@ then
|
||||||
errorCode='manual'
|
errorCode='manual'
|
||||||
fi
|
fi
|
||||||
case $errorCode in
|
case $errorCode in
|
||||||
000) cp "bin/000.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/000.png" "cache/img/$startPath""$hashUrl.png" ;;
|
000) cp "../bin/000.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/000.png" "../cache/img/$startPath""$hashUrl.png" ;;
|
||||||
200) cp "bin/error.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/error.png" "cache/img/$startPath""$hashUrl.png" ;;
|
200) cp "../bin/error.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/error.png" "../cache/img/$startPath""$hashUrl.png" ;;
|
||||||
404) cp "bin/404.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/404.png" "cache/img/$startPath""$hashUrl.png" ;;
|
404) cp "../bin/404.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/404.png" "../cache/img/$startPath""$hashUrl.png" ;;
|
||||||
*) cp "bin/error.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/error.png" "cache/img/$startPath""$hashUrl.png" ;;
|
*) cp "..bin/error.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/error.png" "../cache/img/$startPath""$hashUrl.png" ;;
|
||||||
esac
|
esac
|
||||||
if $log
|
if $log
|
||||||
then
|
then
|
||||||
|
@ -74,40 +76,40 @@ then
|
||||||
logDate=`date +'[%a %d %b %Y] [%H:%M:%S]'`
|
logDate=`date +'[%a %d %b %Y] [%H:%M:%S]'`
|
||||||
if [ $errorCode == 200 ]
|
if [ $errorCode == 200 ]
|
||||||
then
|
then
|
||||||
echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "cache/logs/retry/"$hashUrl".log"
|
echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "../cache/logs/retry/"$hashUrl".log"
|
||||||
else
|
else
|
||||||
echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "cache/logs/other/"$hashUrl".log"
|
echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "../cache/logs/other/"$hashUrl".log"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [ $onlyThumb == 1 ]
|
if [ $onlyThumb == 1 ]
|
||||||
then
|
then
|
||||||
convert "cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 -filter Lanczos -thumbnail "$thumbSize" "cache/img/$startPath""$hashUrl""_thumb.png"
|
convert "../cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 -filter Lanczos -thumbnail "$thumbSize" "../cache/img/$startPath""$hashUrl""_thumb.png"
|
||||||
if [ $optimizeTool ]
|
if [ $optimizeTool ]
|
||||||
then
|
then
|
||||||
eval $optimizeTool "cache/img/$startPath""$hashUrl""_thumb.png"
|
eval $optimizeTool "../cache/img/$startPath""$hashUrl""_thumb.png"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
convert "cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 "cache/img/$startPath""$hashUrl.png"
|
convert "../cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 "../cache/img/$startPath""$hashUrl.png"
|
||||||
convert "cache/img/$startPath""$hashUrl.png" -filter Lanczos -thumbnail "$thumbSize" "cache/img/$startPath""$hashUrl""_thumb.png"
|
convert "../cache/img/$startPath""$hashUrl.png" -filter Lanczos -thumbnail "$thumbSize" "../cache/img/$startPath""$hashUrl""_thumb.png"
|
||||||
if [ $optimizeTool ]
|
if [ $optimizeTool ]
|
||||||
then
|
then
|
||||||
eval $optimizeTool "cache/img/$startPath""$hashUrl""_thumb.png" "cache/img/$startPath""$hashUrl.png"
|
eval $optimizeTool "../cache/img/$startPath""$hashUrl""_thumb.png" "../cache/img/$startPath""$hashUrl.png"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
rm "cache/tmp/$hashUrl.png"
|
rm "../cache/tmp/$hashUrl.png"
|
||||||
|
|
||||||
if [ $onlyThumb ]
|
if [ $onlyThumb ]
|
||||||
then
|
then
|
||||||
if [[ -f "cache/img/$startPath""$hashUrl""_thumb.png" ]]
|
if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" ]]
|
||||||
then
|
then
|
||||||
echo 1
|
echo 1
|
||||||
else
|
else
|
||||||
echo 0
|
echo 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ -f "cache/img/$startPath""$hashUrl""_thumb.png" && -f "cache/img/$startPath""$hashUrl.png" ]]
|
if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" && -f "../cache/img/$startPath""$hashUrl.png" ]]
|
||||||
then
|
then
|
||||||
echo 1
|
echo 1
|
||||||
else
|
else
|
||||||
|
@ -118,5 +120,5 @@ if $log
|
||||||
then
|
then
|
||||||
end_time=`date +%s`
|
end_time=`date +%s`
|
||||||
logDate=`date +'[%a %d %b %Y] [%H:%M:%S]'`
|
logDate=`date +'[%a %d %b %Y] [%H:%M:%S]'`
|
||||||
echo $logDate `expr $end_time - $start_time`s >> 'cache/logs/success.txt'
|
echo $logDate `expr $end_time - $start_time`s >> '../cache/logs/success.txt'
|
||||||
fi
|
fi
|
||||||
|
|
2
inc/.htaccess
Normal file
2
inc/.htaccess
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Allow from none
|
||||||
|
Deny from all
|
|
@ -14,7 +14,7 @@ if (isset($ui['log']) && !in_array($ui['log'], $acceptParam['log']) || $_SESSION
|
||||||
die('Tell me, Mr Anderson, what good is a phone call if you\'re unable to speak ?');
|
die('Tell me, Mr Anderson, what good is a phone call if you\'re unable to speak ?');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($ui['log'])) {
|
if (empty($ui['log']) && empty($ui['ac'])) {
|
||||||
$ui['log'] = 'success';
|
$ui['log'] = 'success';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +123,16 @@ function keepThisThumb($hash, $log) {
|
||||||
if (isset($ui['clear']) && (int)$ui['clear'] === 1) {
|
if (isset($ui['clear']) && (int)$ui['clear'] === 1) {
|
||||||
clearLog($ui['log']);
|
clearLog($ui['log']);
|
||||||
}
|
}
|
||||||
?>
|
if (isset($ui['ac']) && $ui['ac'] === 'delete' && isset($ui['thumb']) && !empty($ui['thumb'])) {
|
||||||
<div class="hMenu">
|
$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 '<div class="hMenu">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="?p=admin&log=success">Success</a>
|
<a href="?p=admin&log=success">Success</a>
|
||||||
|
@ -138,14 +146,52 @@ if (isset($ui['clear']) && (int)$ui['clear'] === 1) {
|
||||||
<li>
|
<li>
|
||||||
<a href="?p=admin&log=other">Other error</a>
|
<a href="?p=admin&log=other">Other error</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="?p=admin&ac=delete">Delete thumbshot</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="?logout=1">Logout</a>
|
<a href="?logout=1">Logout</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="log">
|
<div id="log">';
|
||||||
<?php
|
if ($ui['ac'] === 'delete') {
|
||||||
if ($ui['log'] === 'success') {
|
if (isset($ui['deleteUrl']) && testValidUrl($ui['deleteUrl']) !== true) {
|
||||||
|
unset($ui['deleteUrl']);
|
||||||
|
echo '<div>Not a valid url.</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
<form method="post" action="?">
|
||||||
|
<p>
|
||||||
|
<label>Url </label>';
|
||||||
|
if (empty($ui['deleteUrl'])) {
|
||||||
|
echo '<input type="text" name="deleteUrl"/>';
|
||||||
|
} else {
|
||||||
|
echo '<input type="text" name="deleteUrl" value="', $ui['deleteUrl'], '"/>';
|
||||||
|
}
|
||||||
|
echo '</p>
|
||||||
|
<p>
|
||||||
|
<input type="hidden" name="p" value="admin"/>
|
||||||
|
<input type="hidden" name="ac" value="delete"/>
|
||||||
|
<input type="submit"/>
|
||||||
|
</p>
|
||||||
|
</form>';
|
||||||
|
if (!empty($ui['deleteUrl'])) {
|
||||||
|
$ui['deleteUrl'] = trim(rawurldecode($ui['deleteUrl']));
|
||||||
|
$ui['deleteUrl'] = rtrim($ui['deleteUrl'], '/');
|
||||||
|
$hashUrl = sha1($GLOBALS['config']['salt'].$ui['deleteUrl']);
|
||||||
|
$imgUrl = pathForFile('m', $hashUrl);
|
||||||
|
echo '</div>
|
||||||
|
<div id="result">
|
||||||
|
<p>
|
||||||
|
<a href="', $imgUrl, '.png"><img src="', $imgUrl, '_thumb.png"/></a>
|
||||||
|
</p>
|
||||||
|
<a href="?p=admin&ac=delete&thumb=', $hashUrl, '">Delete this thumb</a>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (isset($ui['log']) && $ui['log'] === 'success') {
|
||||||
$logs = parseSuccessLog();
|
$logs = parseSuccessLog();
|
||||||
if (!empty($logs)) {
|
if (!empty($logs)) {
|
||||||
$nbThumb = 0;
|
$nbThumb = 0;
|
||||||
|
@ -157,7 +203,7 @@ if ($ui['log'] === 'success') {
|
||||||
}
|
}
|
||||||
echo '<p class="clear" ><a href="?p=admin&log=success&clear=1">Clear success log</a></p>';
|
echo '<p class="clear" ><a href="?p=admin&log=success&clear=1">Clear success log</a></p>';
|
||||||
}
|
}
|
||||||
if ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other') {
|
if (isset($ui['log']) && ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other')) {
|
||||||
if (isset($ui['hash']) && !empty($ui['hash'])) {
|
if (isset($ui['hash']) && !empty($ui['hash'])) {
|
||||||
$ui['hash'] = validHash($ui['hash']);
|
$ui['hash'] = validHash($ui['hash']);
|
||||||
if (isset($ui['root']) && (int)$ui['root'] === 1) {
|
if (isset($ui['root']) && (int)$ui['root'] === 1) {
|
||||||
|
@ -165,6 +211,9 @@ if ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other'
|
||||||
}
|
}
|
||||||
if (isset($ui['cache']) && (int)$ui['cache'] === 1) {
|
if (isset($ui['cache']) && (int)$ui['cache'] === 1) {
|
||||||
$success['filePath'] = pathForFile($ui['s'], $ui['hash']).'.png';
|
$success['filePath'] = pathForFile($ui['s'], $ui['hash']).'.png';
|
||||||
|
if (!file_exists($success['filePath'])) {
|
||||||
|
$success['filePath'] = 'data:image/png;base64,'.base64_encode(file_get_contents('bin/error.png'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($ui['keep']) && (int)$ui['keep'] === 1) {
|
if (isset($ui['keep']) && (int)$ui['keep'] === 1) {
|
||||||
keepThisThumb($ui['hash'], $ui['log']);
|
keepThisThumb($ui['hash'], $ui['log']);
|
||||||
|
@ -176,7 +225,7 @@ if ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other'
|
||||||
if (!empty($logs)) {
|
if (!empty($logs)) {
|
||||||
echo '<ul>';
|
echo '<ul>';
|
||||||
foreach ($logs as $value) {
|
foreach ($logs as $value) {
|
||||||
echo '<li>', htmlentities(strip_tags($value['3'])), htmlentities(strip_tags($value['0'])), '</br><a href="?p=admin&log=', $ui['log'], '&hash=', $value['1'], '&mGen=1#result">manuel launch</a> <a href="', htmlentities(strip_tags($value['0'])), '">view site</a> <a href="?p=admin&log=', $ui['log'], '&hash=', $value['1'], '&cache=1&s=', $value['2'], '#result">view image in cache</a></li>';
|
echo '<li>', htmlentities(strip_tags($value['3'])), htmlentities(strip_tags($value['0'])), '</br><a href="?p=admin&log=', $ui['log'], '&hash=', $value['1'], '&mGen=1#result">manuel launch</a> <a href="', htmlentities(strip_tags($value['0'])), '">view site</a> <a href="?p=admin&log=', $ui['log'], '&hash=', $value['1'], '&cache=1&s=', $value['2'], '#result">view image in cache</a></li>';
|
||||||
}
|
}
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,10 +233,9 @@ if ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
if (!empty($success)) {
|
if (!empty($success)) {
|
||||||
echo '<div id="result">';
|
echo '<div id="result">';
|
||||||
echo '<img src="', $success['filePath'], '?r=', time(), '" style="width:100%;"/>';
|
echo '<img src="', $success['filePath'], '?r=', time(), '" style="width:100%;"/>';
|
||||||
echo '<p><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['filePath'], '" onclick="this.select()"/></p>';
|
echo '<p><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['filePath'], '" onclick="this.select()"/></p>';
|
||||||
echo '<a href="?p=admin&log=', $ui['log'], '&hash=', $ui['hash'], '&root=1">Try with root domain</a> / ';
|
echo '<a href="?p=admin&log=', $ui['log'], '&hash=', $ui['hash'], '&root=1">Try with root domain</a> / ';
|
||||||
echo '<a href="?p=admin&log=', $ui['log'], '&hash=', $ui['hash'], '&keep=1">Keep this thumbshot</a>';
|
echo '<a href="?p=admin&log=', $ui['log'], '&hash=', $ui['hash'], '&keep=1">Keep this thumbshot</a>';
|
||||||
|
|
44
index.php
44
index.php
|
@ -30,8 +30,8 @@ $GLOBALS['config']['thumbSize'] = array(
|
||||||
);
|
);
|
||||||
// Remove image older than 12 hours
|
// Remove image older than 12 hours
|
||||||
$GLOBALS['config']['expireCache'] = 12;
|
$GLOBALS['config']['expireCache'] = 12;
|
||||||
// Disable exec command for launch script and use cron task
|
// Disable exec command and use cron task
|
||||||
$GLOBALS['config']['disableExec'] = false;
|
$GLOBALS['config']['disableExec'] = true;
|
||||||
// Enable log for success, suspect, error
|
// Enable log for success, suspect, error
|
||||||
$GLOBALS['config']['log'] = false;
|
$GLOBALS['config']['log'] = false;
|
||||||
|
|
||||||
|
@ -145,17 +145,30 @@ function launchScript($url, $hashUrl, $width, $size, $onlyThumb, $waitForResult
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($GLOBALS['config']['disableExec'] === false) {
|
if ($GLOBALS['config']['disableExec'] === false) {
|
||||||
|
chdir('bin/');
|
||||||
if ($waitForResult === false) {
|
if ($waitForResult === false) {
|
||||||
exec('bin/thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb.' > /dev/null &', $result);
|
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb.' > /dev/null &', $result);
|
||||||
} else {
|
} else {
|
||||||
exec('bin/thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb.' 1', $result);
|
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb.' 1', $result);
|
||||||
}
|
}
|
||||||
|
chdir('../');
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
makeQueueFile($url, $hashUrl, $width, $size, $onlyThumb);
|
||||||
|
$result = 0;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeQueueFile($url, $hashUrl, $width, $size, $onlyThumb) {
|
||||||
|
$url = str_replace('\'', '', $url);
|
||||||
|
$hashUrl = str_replace('\'', '', $hashUrl);
|
||||||
|
$width = str_replace('\'', '', $width);
|
||||||
|
if (!file_exists('cache/cronTask/'.$hashUrl.'.hash')) {
|
||||||
|
$data = $url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb. "\n";
|
||||||
|
file_put_contents('cache/cronTask/'.$hashUrl.'.hash', $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function testValidUrl($url) {
|
function testValidUrl($url) {
|
||||||
$url = trim($url);
|
$url = trim($url);
|
||||||
if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
|
if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
|
||||||
|
@ -168,7 +181,7 @@ function testValidUrl($url) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return array('msg' => 'Url are not valid.');
|
return array('msg' => 'Not a valid url.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,6 +257,9 @@ function install() {
|
||||||
if (!is_dir('cache/tmp') && !mkdir('cache/tmp', 0705)) {
|
if (!is_dir('cache/tmp') && !mkdir('cache/tmp', 0705)) {
|
||||||
die('Error on create dir "cache/tmp".');
|
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());
|
$salt = sha1(uniqid(rand(), true).'_'.mt_rand());
|
||||||
$serverKey = substr(sha1(uniqid(rand(), true).'_'.mt_rand().$salt), 0, 12);
|
$serverKey = substr(sha1(uniqid(rand(), true).'_'.mt_rand().$salt), 0, 12);
|
||||||
$encryptServerKey = sha1($serverKey.$salt);
|
$encryptServerKey = sha1($serverKey.$salt);
|
||||||
|
@ -279,6 +295,9 @@ function checkInstall() {
|
||||||
if (!is_file('cache/config/.htaccess')) {
|
if (!is_file('cache/config/.htaccess')) {
|
||||||
file_put_contents('cache/config/.htaccess', "Allow from none\nDeny from all\n");
|
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')) {
|
if (!is_file('bin/.htaccess')) {
|
||||||
file_put_contents('bin/.htaccess', "Allow from none\nDeny from all\n");
|
file_put_contents('bin/.htaccess', "Allow from none\nDeny from all\n");
|
||||||
}
|
}
|
||||||
|
@ -367,9 +386,9 @@ function n_print($data, $name = '') {
|
||||||
echo '<h2>', $name, '</h2>';
|
echo '<h2>', $name, '</h2>';
|
||||||
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
|
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
|
||||||
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">
|
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">
|
||||||
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
||||||
</legend>';
|
</legend>';
|
||||||
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
|
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
|
||||||
echo '
|
echo '
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<br />
|
<br />
|
||||||
|
@ -552,7 +571,7 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
|
||||||
}
|
}
|
||||||
if ((isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'api')) {
|
if ((isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'api')) {
|
||||||
$res = launchScript($defUrl, $hashUrl, $width, $ui['s'], $GLOBALS['config']['onlyThumb'], true);
|
$res = launchScript($defUrl, $hashUrl, $width, $ui['s'], $GLOBALS['config']['onlyThumb'], true);
|
||||||
} elseif ((isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'form')) {
|
} elseif (isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'form') {
|
||||||
$res = launchScript($defUrl, $hashUrl, $width, 'shortLive', $GLOBALS['config']['onlyThumb'], true);
|
$res = launchScript($defUrl, $hashUrl, $width, 'shortLive', $GLOBALS['config']['onlyThumb'], true);
|
||||||
} else {
|
} else {
|
||||||
$res = launchScript($defUrl, $hashUrl, $width, $ui['s'], $GLOBALS['config']['onlyThumb'], false);
|
$res = launchScript($defUrl, $hashUrl, $width, $ui['s'], $GLOBALS['config']['onlyThumb'], false);
|
||||||
|
@ -561,6 +580,9 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
|
||||||
$file = 'bin/loadingGen';
|
$file = 'bin/loadingGen';
|
||||||
printThumbShot($file);
|
printThumbShot($file);
|
||||||
} else {
|
} else {
|
||||||
|
if ($GLOBALS['config']['disableExec'] === true) {
|
||||||
|
$file = 'bin/loadingGen';
|
||||||
|
}
|
||||||
$success = array(
|
$success = array(
|
||||||
'normal' => $file.'.png',
|
'normal' => $file.'.png',
|
||||||
'thumb' => $file.'_thumb.png'
|
'thumb' => $file.'_thumb.png'
|
||||||
|
@ -576,11 +598,11 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>SoShot</title>
|
<title>SoShot</title>
|
||||||
<meta name="description" content="Personal webshot">
|
<meta name="description" content="Personal webshot">
|
||||||
<link rel="stylesheet" href="inc/style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
require getPage($ui['p']);
|
require getPage($ui['p']);
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -22,7 +22,7 @@ a:visited {
|
||||||
form, #result, #header, .message, .hMenu, #log {
|
form, #result, #header, .message, .hMenu, #log {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 50%;
|
width: 60%;
|
||||||
margin: 1em auto;
|
margin: 1em auto;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
Loading…
Reference in a new issue