Skip to content

Commit

Permalink
Lots of touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
GM-Script-Writer-62850 committed Jul 17, 2013
1 parent 7e26bab commit 3c9b2ba
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 82 deletions.
32 changes: 26 additions & 6 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,31 @@ ErrorDocument 404 /inc/
# Compress file for faster network transfer
php_value output_handler ob_gzhandler
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript application/json
AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json
</IfModule>

# Some browsers look for a /favicon.ico file, this tells them where to get a favicon
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^favicon.ico$ /inc/images/favicon.png [L]
</IfModule>
# Cache Control + Define Content Type
<ifModule mod_headers.c>
<FilesMatch ".json$">
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Content-type "application/json; charset=UTF-8"
</FilesMatch>
<FilesMatch ".(png|jpg|tiff|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<FilesMatch ".(css|js)$">
Header set Cache-Control "max-age=86400, must-revalidate"
</FilesMatch>
<FilesMatch ".js$">
Header set Content-type "application/javascript; charset=UTF-8"
</FilesMatch>
<FilesMatch ".css$">
Header set Content-type "text/css; charset=UTF-8"
</FilesMatch>
<FilesMatch ".txt$">
Header set Content-type "text/plain; charset=UTF-8"
</FilesMatch>
<FilesMatch "^favicon.ico$">
Header set Content-type "image/png"
</FilesMatch>
</ifModule>
9 changes: 6 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ Enabling Auto-Deletion of old scans:
in cleaner.php) and deletes them.

Frequently asked questions/issues:
Some times when I download should be a large file I get nothing (a 0 byte file)
Why do is there a 404 error trying to display a 404 error
Apparently you are running the server in a subfolder on the domain, you will need to edit .htaccess with the full path relative to the root document
Basically if you put the server in /var/www/scanner/ you need to put /scanner before /inc in the .htaccess file
Sometimes when I download a large file I get nothing (a 0 byte file)
You will need to increase the max memory PHP can use,
To do this run this command:
cat /etc/php5/apache2/php.ini -n| grep memory_limit
Expand All @@ -163,8 +166,6 @@ Frequently asked questions/issues:
This more like a addon than a program so I am note sure if one of thoes would be approate, I have written bash
scripts to install and update this, if you look they are on the Downloads page in the Wiki
https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server/wiki/Downloads
I am getting 404 errors for favicon.ico in my error log, how can I stop that
sudo ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/ && sudo service apache2 restart
The brightness and contrast options do not work on lucid lynx.
This is because lucid has ImageMagick 6.5.7-8 and the brightness-contrast option was added in version 6.5.9
64Bit:
Expand Down Expand Up @@ -254,6 +255,8 @@ Installation Notes:
This command will give you a easy to remember URL for the scanner (I remember this not working on Windows XP clients)
echo http://$(uname -n).local/
Be sure to check http://www.canyouseeme.org/ so you know if people can use your scanner on the Internet, I suggest using a firewall to prevent this, or putting a password on it.
If you don't have a /etc/apache2/mods-enabled/headers.load file run this command, this enables catch control and defines mime types via .htaccess
sudo ln -s ../mods-available/headers.load /etc/apache2/mods-enabled/ && sudo service apache2 restart

Apache Tricks:
Enabling .htaccess
Expand Down
1 change: 1 addition & 0 deletions favicon.ico
1 change: 1 addition & 0 deletions imgur.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
header('Content-type: application/json; charset=UTF-8');
if(!function_exists('curl_version'))
die('{"album":false,"images":[],"success":false,"error":"<code>php5-curl</code>/<code>php-curl</code> is not installed on the server"}');
function json_curl($data,$type,$anon){// type = upload/image||album ; anon = true|false
Expand Down
62 changes: 31 additions & 31 deletions inc/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@
</div>

<div class="box">
<h2>Trouble Shooting</h2>
<h2>Color Sceme</h2>
<p>
If you are having issues loading the Scanned Files page due to over population you can <a href="index.php?page=Scans&amp;delete=Remove" onclick="return confirm('Delete all scanned files?')">
Remove All the Scans</a> with that link. If you are having another issue you may want to read the <a href="index.php?page=About">Release Notes</a> or
take a look at the <a href="index.php?page=PHP%20Information">PHP Configuration</a>.
Select a Color:
<select onchange="if(this.value!='void')changeColor(this.value);">
<option value="void">Please Select</option>
<option value="3c9642x3c7796" style="background-color:#3c9642;color:#3c7796;">Green</option>
<option value="3c7796x963c8f" style="background-color:#3c7796;color:#963c8f;">Blue</option>
<option value="963c8fx3c7796" style="background-color:#963c8f;color:#3c7796;">Purple</option>
<option value="663366x3c7796" style="background-color:#663366;color:#3c7796;">Dark Purple</option>
<option value="000000x999999" style="background-color:#000000;color:#999999;">Black</option>
<option value="996633xbfbfbf" style="background-color:#996633;color:#bfbfbf;">Light Brown</option>
<option value="848484xbfbfbf" style="background-color:#848484;color:#bfbfbf;">Gray</option>
<option value="383838x838383" style="background-color:#383838;color:#838383;">Dark Gray</option>
<option value="ff007exbb045e" style="background-color:#ff007e;color:#bb045e;">Pink</option>
</select>
</p>
<!-- Manual color picker (for theme development)-->
<!--<input value="000000xFFFFFF" onkeypress="if(event.which==13){changeColor(this.value);return false;}"/>-->
</div>

<div class="box">
<h2>Email Configuration</h2>
<p><input type="submit" value="Edit" onclick="emailManager(null);"/>
<input type="submit" value="Delete" onclick="deleteEmail();" style="float:right;"/></p>
</div>

</div>
Expand Down Expand Up @@ -65,6 +83,15 @@
</div>
<div class="column">

<div class="box">
<h2>Trouble Shooting</h2>
<p>
If you are having issues loading the Scanned Files page due to over population you can <a href="index.php?page=Scans&amp;delete=Remove" onclick="return confirm('Delete all scanned files?')">
Remove All the Scans</a> with that link or you can use <a href="index.php?page=Scans&filter=1&t=0">this link</a> so you can use the scan filter. If you are having another issue you may want to read the <a href="index.php?page=About">Release Notes</a> or
take a look at the <a href="index.php?page=PHP%20Information">PHP Configuration</a>.
</p>
</div>

<div class="box">
<h2>Debug Console</h2>
<p><?php
Expand All @@ -88,33 +115,6 @@
</p>
</div>

<div class="box">
<h2>Color Sceme</h2>
<p>
Select a Color:
<select onchange="if(this.value!='void')changeColor(this.value);">
<option value="void">Please Select</option>
<option value="3c9642x3c7796" style="background-color:#3c9642;color:#3c7796;">Green</option>
<option value="3c7796x963c8f" style="background-color:#3c7796;color:#963c8f;">Blue</option>
<option value="963c8fx3c7796" style="background-color:#963c8f;color:#3c7796;">Purple</option>
<option value="663366x3c7796" style="background-color:#663366;color:#3c7796;">Dark Purple</option>
<option value="000000x999999" style="background-color:#000000;color:#999999;">Black</option>
<option value="996633xbfbfbf" style="background-color:#996633;color:#bfbfbf;">Light Brown</option>
<option value="848484xbfbfbf" style="background-color:#848484;color:#bfbfbf;">Gray</option>
<option value="383838x838383" style="background-color:#383838;color:#838383;">Dark Gray</option>
<option value="ff007exbb045e" style="background-color:#ff007e;color:#bb045e;">Pink</option>
</select>
</p>
<!-- Manual color picker (for theme development)-->
<!--<input value="000000xFFFFFF" onkeypress="if(event.which==13){changeColor(this.value);return false;}"/>-->
</div>

<div class="box">
<h2>Email Configuration</h2>
<p><input type="submit" value="Edit" onclick="emailManager(null);"/>
<input type="submit" value="Delete" onclick="deleteEmail();" style="float:right;"/></p>
</div>

<div class="box">
<h2>Update Checker</h2>
<p class="center">
Expand Down
7 changes: 4 additions & 3 deletions inc/cookie.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// http://techpatterns.com/downloads/javascript_cookies.php
// Why are cookies managed as strings?
function Set_Cookie( name, value, expires, path, domain, secure ){
if(!path) path=window.location.pathname.substr(0,window.location.pathname.lastIndexOf('/')+1);// Added this line
var today = new Date();
today.setTime( today.getTime() );
if ( expires ){
Expand All @@ -14,9 +14,10 @@ function Set_Cookie( name, value, expires, path, domain, secure ){
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function Delete_Cookie( name, path, domain ) {// edited, dont delete non-existat cookies
function Delete_Cookie( name, path ) {// edited, don't delete non-existent cookies
if(!path) path=window.location.pathname.substr(0,window.location.pathname.lastIndexOf('/')+1);// Added this line
document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( domain ) ? ";domain=" + document.domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
8 changes: 4 additions & 4 deletions inc/header.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html><?php $path=is_numeric($GLOBALS['PAGE'])?'/':''; ?>
<!DOCTYPE html><html><?php $path=is_numeric($GLOBALS['PAGE'])?substr($_SERVER['PHP_SELF'],0,strlen(end(explode('/',$_SERVER['PHP_SELF'])))*-1-4):''; ?>
<head>
<meta charset="UTF-8"/>
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="chrome=1"><![endif]-->
Expand All @@ -13,9 +13,9 @@
echo '<link id="style_new" rel="stylesheet" href="inc/style.php'.(isset($_COOKIE["colors"])?'?colors='.$_COOKIE["colors"]:'').'" type="text/css"/>';
?>
<link rel="shortcut icon" href="<?php echo $path; ?>inc/images/favicon.png"/>
<link rel="stylesheet" type="text/css" href="<?php echo $path; ?>jquery/imgareaselect-0.9.10/css/imgareaselect-animated.css"/>
<script type="text/javascript" src="<?php echo $path; ?>jquery/imgareaselect-0.9.10/scripts/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo $path; ?>jquery/imgareaselect-0.9.10/scripts/jquery.imgareaselect.pack.js"></script>
<?php echo in_array($GLOBALS['PAGE'],Array("Scan","Edit"))?'<script type="text/javascript" src="'.$path.'jquery/imgareaselect-0.9.10/scripts/jquery.imgareaselect.pack.js"></script>'.
'<link rel="stylesheet" type="text/css" href="'.$path.'jquery/imgareaselect-0.9.10/css/imgareaselect-animated.css"/>':''; ?>
<script type="text/javascript" src="<?php echo $path; ?>inc/model-dialog.js"></script>
<script type="text/javascript" src="<?php echo $path; ?>inc/cookie.js"></script>
<script type="text/javascript" src="<?php echo $path; ?>inc/main.js"></script>
Expand Down Expand Up @@ -52,7 +52,7 @@
</div>

<div class="tab<?php echo $GLOBALS['PAGE']=="Login"||is_numeric($GLOBALS['PAGE'])?' active':''; ?>">
<a href="/"><?php echo $_SERVER['SERVER_NAME']; ?></a>
<a href="/"<?php echo $GLOBALS['RequireLogin']&&$GLOBALS['Auth']&&$GLOBALS['PAGE']!='Login'?' onclick="Delete_Cookie(\'Authenticated\',false)">Logout':'>'.$_SERVER['SERVER_NAME']; ?></a>
<div class="topleft top"></div>
<div class="bottomleft bottom"></div>
<div class="topright top"></div>
Expand Down
4 changes: 3 additions & 1 deletion inc/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function js($X){
$PAGE=http_response_code();
$NAME="PHP Scanner Server";
$VER="1.3-8_dev";
$page="Error";
$page=($PAGE==200?"Success":"Error");
$Auth=true;
$RequireLogin=false;
include("header.php");
?>
<div class="box box-full"><h2>HTTP Status Code: <?php echo $PAGE; ?></h2><p class="center"><?php echo $PAGE==200?'Ok, you found me':'That is a error'; ?></p></div>
Expand Down
1 change: 1 addition & 0 deletions inc/login.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
if(isset($_POST['json'])&&!isset($PAGE)){
header('Content-type: application/json; charset=UTF-8');
$file='../config/.htaccess';
if(!is_file($file)){// For security reasons
$file=@fopen($file,'w+');
Expand Down
31 changes: 14 additions & 17 deletions inc/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,14 @@ function changeColor(colors){
N.href='inc/style.php?colors='+colors+'&nocache='+new Date().getTime();
document.body.setAttribute('onunload',"if(!document.cookie)alert('The color theme was not saved because you have cookies disabled')");
}
function lastScan(scan,preview,scanner,source,size,ele){
generic=scan.slice(5);
previewIMG.src='scans/'+preview;
function lastScan(data,ele){
generic=data.raw.slice(5);
scan=data.scan;
previewIMG.src='scans/'+data.preview;
ias.setOptions({'enable': true });
ias.update();
getID('sel').removeAttribute('style');
document.scanning.scanner.value=scanner;
scannerChange(document.scanning.scanner);
document.scanning.scanner.disabled='disabled';
document.scanning.source.value=source;
document.scanning.size.value=size;
sendE(document.scanning.size,'change');
config(data.fields);
ele.parentNode.parentNode.innerHTML='<h2>'+generic+'</h2><p><a class="tool icon download" href="download.php?file='+scan+'"><span class="tip">Download</span></a> '+
'<a class="tool icon zip" href="download.php?file='+scan+'&amp;compress"><span class="tip">Download Zip</span></a> '+
'<a class="tool icon pdf" href="#" onclick="PDF_popup(\''+generic+'\');"><span class="tip">Download PDF</span></a> '+
Expand Down Expand Up @@ -408,7 +404,7 @@ function paperChange(ele){
document.scanning.ornt.removeAttribute('disabled');
}
function rotateChange(ele){
var val=ele.value;
var val=Number(ele.value);
ele.nextSibling[TC]=(val==180?'Upside-down':(val<0?'Counterclockwise':'Clockwise'));
var prefixes = 't WebkitT MozT OT msT'.split(' ');
for(var prefix in prefixes){
Expand All @@ -424,6 +420,7 @@ function rotateChange(ele){
return;
ias.setOptions({ "hide": true, "disable": true, "fadeSpeed": false, "rotating": true });
ele.style[prefix]='rotate('+val+'deg)';// To DO add scale(X%)
printMsg('Debug',encodeHTML(ele.style[prefix]),'center',0);
setTimeout(function(){// We can not leave it rotated, it brutally screws up cropping
ele.style[prefix]='';
setTimeout(function(){
Expand Down Expand Up @@ -464,14 +461,14 @@ function toggleDebug(keyboard){
if(debug){
if(debug.style.display=='inherit'){
debug.removeAttribute('style');
Set_Cookie( 'debug', false, 1, '/', '', '' );
Set_Cookie('debug',false,1,false,null,null);
if(keyboard&&debugLink)
debugLink[TC]='Show';
return false;
}
else{
debug.style.display='inherit';
Set_Cookie( 'debug', true, 1, '/', '', '' );
Set_Cookie('debug',true,1,false,null,null);
if(keyboard&&debugLink)
debugLink[TC]='Hide';
return true;
Expand All @@ -480,7 +477,7 @@ function toggleDebug(keyboard){
}
function toggleFortune(e){
e=(e=='Hide'?false:true)
Set_Cookie( 'fortune', e, 1, '/', '', '' );
Set_Cookie('fortune',e,1,false,null,null);
return e;
}
function scanReset(){
Expand Down Expand Up @@ -1275,29 +1272,29 @@ function enableColumns(ele,e,b){ // They work flawlessly in Firefox so it does n
ele.removeAttribute('class');// disable
if(e){
e.nextSibling[TC]='Enable';
Delete_Cookie( 'columns', '/', '' );
Delete_Cookie('columns',false);
}
}
else if(ele.className.indexOf('columns')==-1){
ele.className+=' columns';// enable
if(e){
e.nextSibling[TC]='Disable';
Set_Cookie( 'columns', true, 1, '/', '', '' );
Set_Cookie('columns',true,1,false,null,null);
}
}
else{
ele.className=ele.className.substring(0,ele.className.indexOf(' columns'));// Disable preserve original class name
if(e){
e.nextSibling[TC]='Enable';
Delete_Cookie( 'columns', '/', '' );
Delete_Cookie('columns',false);
}
}
}
else{// enable
ele.className='columns';
if(e){
e.nextSibling[TC]='Disable';
Set_Cookie( 'columns', true, 1, '/', '', '' );
Set_Cookie('columns',true,1,false,null,null);
}
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion inc/phpinfo.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php phpinfo(); ?>
<?php header('Content-Type: text/html; charset=utf-8');phpinfo(); ?>
12 changes: 7 additions & 5 deletions inc/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@
<span class="tool icon email-off"><span class="tip">Email (Disabled)</span></span>
<?php
$ls='<span class="tool icon recent-off"><span class="tip">Last Scan (Disabled)</span></span>';
if(isset($_COOKIE["scan"])&&isset($_COOKIE["preview"])&&isset($_COOKIE["size"])&&isset($_COOKIE["source"])){
if(file_exists("scans/".$_COOKIE["scan"])&&file_exists("scans/".$_COOKIE["preview"]))
echo "<a class=\"tool icon recent\" onclick=\"lastScan('".html(js($_COOKIE["scan"]))."','".html(js($_COOKIE["preview"]))."','".html(js($_COOKIE["scanner"]))."','".
html(js($_COOKIE["source"]))."','".html(js($_COOKIE["size"]))."',this);\" href=\"javascript:void(null)\"><span class=\"tip\">Last Scan</span></a>";
else
if(isset($_COOKIE["lastScan"])){
$cookie=json_decode($_COOKIE['lastScan']);
if(file_exists("scans/".$cookie->{"raw"})&&file_exists("scans/".$cookie->{"preview"}))
echo "<a class=\"tool icon recent\" onclick=\"lastScan(".html(json_encode($cookie)).",this);\" href=\"javascript:void(null)\"><span class=\"tip\">Last Scan</span></a>";
else{
echo $ls;
setcookie ("lastScan", "", 0);
}
}
else
echo $ls;
Expand Down
10 changes: 6 additions & 4 deletions inc/style.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
// Chrome's and IE's css columns break things
$expires=86400;//24 hrs
header('Content-type: text/css');
header('Content-type: text/css; charset=UTF-8');
header("Pragma: public");
header("Cache-Control: maxage=".$expires);
header('Expires: '.gmdate('D, d M Y H:i:s',time()+$expires).' GMT');
if(isset($_GET['colors'])){//10 years long enough for a cookie to stick arround?
setcookie("colors",$_GET['colors'],time()+(60*60*24*365*10),"/",$_SERVER['SERVER_NAME']);
setcookie("colors",$_GET['colors'],time()+(60*60*24*365.25*10),substr($_SERVER['PHP_SELF'],0,strlen(end(explode('/',$_SERVER['PHP_SELF'])))*-1-4),$_SERVER['SERVER_NAME']);
$COLORS=explode('x',$_GET['colors']);
}
else{
Expand Down Expand Up @@ -39,9 +39,9 @@
}

body, #header, #message table, .side_box, .side_box h2, #preview, #preview_links img, #preview_img p, #preview h2, .box, .box img, .box pre.border, .box h2, #footer, #debug pre, .tab.active > div.top, .dualForm .footer {
-webkit-transition-property: background, border, color;
-webkit-transition-property: background-color, border, color;
-webkit-transition-duration: <?php echo $transitionTime; ?>;
transition-property: background, border, color;
transition-property: background-color, border, color;
transition-duration: <?php echo $transitionTime; ?>;
}
body {
Expand Down Expand Up @@ -720,11 +720,13 @@
float: right;
width: 200px;
height: 125px;
overflow: hidden;
}
.dualForm .largeButton span{
transform: rotate(-20deg) scale(5);
-ms-transform: rotate(-20deg) scale(5);
-webkit-transform: rotate(-20deg) scale(5);
width: auto;
}

#text-editor {
Expand Down
Loading

0 comments on commit 3c9b2ba

Please sign in to comment.