commit version 1.1
This commit is contained in:
22
README.md
Normal file
22
README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
About FileSync
|
||||
|
||||
FileSync is designed to store a backup of your file(s) on remote servers.
|
||||
|
||||
Due to the limitations of php script timeout files should be small. For example: 6 SSL keys zipped to a file is around 90kb. This is small enough to use for this.
|
||||
Do not try to backup files that are several mbs. It may not work correctly.
|
||||
How it works
|
||||
|
||||
Unpack FileSync.zip to a folder on your server. For example: https://example.com/filesync/
|
||||
Add the other servers that you will link to in the server list.
|
||||
When you upload a file to your server it will also send the file to the linked servers.
|
||||
You can upload a new version of the file at a later time. It will also update the linked servers.
|
||||
|
||||
File status
|
||||
|
||||
✔ - Good - Multiple servers have a backup of this file.
|
||||
|
||||
⚠ - Warning - You do not have a backup of this file locally.
|
||||
To resolve: Use the download button to get the file from a remote server. Then re-upload that file.
|
||||
|
||||
✖ - Critical - No other servers have a backup of this file.
|
||||
To resolve: You should contact the other admins to resolve server availability. Then try to upload the file again.
|
||||
30
config.php
Normal file
30
config.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
//Date Format
|
||||
$Date_Format='F j, Y, g:i a';
|
||||
|
||||
//Database Config
|
||||
//Choose a datbase MYSQL or SQLITE (Only use one or the other).
|
||||
require_once('includes/DB_SQLITE.php');
|
||||
//require_once('includes/DB_MYSQL.php');
|
||||
|
||||
function database($key=''){
|
||||
//For SQLITE only a path to the db file is needed.
|
||||
//MYSQL requires server credentials.
|
||||
$database=[
|
||||
'database' => 'filesync.sqlite', //'kro_server',
|
||||
'host' => 'localhost',
|
||||
'user' => '',
|
||||
'pass' => ''
|
||||
];
|
||||
|
||||
return isset($database[$key]) ? $database[$key] : null;
|
||||
}
|
||||
//Table Config
|
||||
function table($key='', $link=''){
|
||||
$table=[
|
||||
'FILE_TABLE'=>'filesync'
|
||||
];
|
||||
|
||||
return isset($table[$key]) ? $table[$key] : null;
|
||||
}
|
||||
?>
|
||||
BIN
filesync.sqlite
Normal file
BIN
filesync.sqlite
Normal file
Binary file not shown.
17
includes/DB_MYSQL.php
Normal file
17
includes/DB_MYSQL.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
//MySQL Database Connection - Version 1.0
|
||||
|
||||
function DBconnect($database,$host,$user,$pass){return mysqli_connect($host,$user,$pass,$database);}
|
||||
function DBclose($link){mysqli_close($link);}
|
||||
function DBquery($link,$query){return mysqli_query($link,$query);}
|
||||
function DBnum_rows($result){return mysqli_num_rows($result);}
|
||||
function DBresult($result,$i=0,$field=0){
|
||||
$rows = mysqli_num_rows($result);
|
||||
if ($rows && $i <= ($rows-1) && $i >=0){
|
||||
mysqli_data_seek($result,$i);
|
||||
$data = (is_numeric($field)) ? mysqli_fetch_row($result) : mysqli_fetch_assoc($result);
|
||||
if (isset($data[$field])){ return $data[$field]; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
19
includes/DB_SQLITE.php
Normal file
19
includes/DB_SQLITE.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
//SQLite3 Database Connection - Version 1.0
|
||||
|
||||
//Debug remove $GLOBALS from DBqerry and DBresult
|
||||
|
||||
function DBconnect($database){return new SQLite3($database, SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);}
|
||||
function DBclose($link){$link->close();}
|
||||
function DBquery($link,$query){return $link->query($query);}
|
||||
function DBnum_rows($result){$n=0; while($result->fetchArray()){$n++;} return $n;}
|
||||
function DBresult($result,$i=0,$field=0){
|
||||
$n=0;
|
||||
$value = false;
|
||||
while ($row = $result->fetchArray()) {
|
||||
if($n==$i){if(isset($row[$field])){$value=$row[$field];}}
|
||||
$n++;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
?>
|
||||
25
includes/isMobile.php
Normal file
25
includes/isMobile.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
function isMobile(){
|
||||
return (isset($_GET['m'])||
|
||||
(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|
|
||||
hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|
|
||||
palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|
|
||||
wap|windows ce|xda|xiino/i',$_SERVER['HTTP_USER_AGENT'])||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]
|
||||
i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|
|
||||
attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|
|
||||
cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el
|
||||
(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|
|
||||
od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|
|
||||
tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|
|
||||
kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|
|
||||
m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|
|
||||
zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|
|
||||
wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|
|
||||
pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|
|
||||
zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|
|
||||
sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|
|
||||
lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|
|
||||
vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |
|
||||
nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($_SERVER['HTTP_USER_AGENT'],0,4))));
|
||||
}
|
||||
?>
|
||||
405
index.php
Normal file
405
index.php
Normal file
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
//TODO
|
||||
//logging?
|
||||
//resolve conflicts?
|
||||
|
||||
//FINALIZE
|
||||
//change version number
|
||||
|
||||
error_reporting(0);
|
||||
require_once('config.php');
|
||||
require_once('includes/isMobile.php');
|
||||
|
||||
//Version / Site
|
||||
$VERSION='1.1';
|
||||
$DB_VERSION='1.0';
|
||||
$COMPATIBLE=array('1.0','1.1');
|
||||
$SITE_URL = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
||||
$ip=$_SERVER['REMOTE_ADDR'];
|
||||
|
||||
|
||||
//Init
|
||||
$s_output='';
|
||||
$f_output='';
|
||||
$server_list=array();
|
||||
$file_list=array();
|
||||
$user='';
|
||||
$tab='files';
|
||||
|
||||
//Connect to Database
|
||||
$link=DBconnect(database('database'), database('host'), database('user'), database('pass'));
|
||||
|
||||
//Create Table
|
||||
$query="CREATE TABLE IF NOT EXISTS ".table('FILE_TABLE')." (id int(10) PRIMARY KEY UNIQUE, type int(1), ip varchar(15), user varchar(32), file varchar(32), time int(10), url varchar(32))";
|
||||
DBquery($link,$query);
|
||||
|
||||
//id type ip user file time url
|
||||
//===============================
|
||||
//id type=1 ip user '' '' ''
|
||||
//id type=2 ip '' '' time url
|
||||
//id type=3 ip user file time ''
|
||||
|
||||
//Get User
|
||||
$query="SELECT * FROM ".table('FILE_TABLE')." WHERE type = 1 LIMIT 1";
|
||||
$result = DBquery($link,$query); $rows = DBnum_rows($result);
|
||||
if($rows==1){$user=DBresult($result,0,'user');}
|
||||
|
||||
//Get Server List
|
||||
$server_list[0]=$SITE_URL;
|
||||
$query="SELECT * FROM ".table('FILE_TABLE')." WHERE type = 2";
|
||||
$result = DBquery($link,$query); $rows = DBnum_rows($result);
|
||||
for($i=0;$i<$rows;$i++){$server_list[$i+1]=DBresult($result,$i,'url');}
|
||||
|
||||
//POST
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
$id=isset($_POST['time'])?FILTER_SANITIZE_STRING($_POST['time']):time();
|
||||
$ip=isset($_POST['ip'])?FILTER_SANITIZE_STRING($_POST['ip']):$ip;
|
||||
|
||||
switch($_POST['formid']){
|
||||
case 'ping':
|
||||
echo $DB_VERSION;
|
||||
|
||||
//Close Database
|
||||
DBclose($link);
|
||||
exit(); break;
|
||||
case 'list':
|
||||
$user= FILTER_SANITIZE_STRING($_POST['user']);
|
||||
$query="SELECT * FROM ".table('FILE_TABLE')." WHERE type = 3 AND user = '$user'";
|
||||
$result = DBquery($link,$query); $rows = DBnum_rows($result);
|
||||
for($i=0;$i<$rows;$i++){echo DBresult($result,$i,'file').'|'.DBresult($result,$i,'time').'|';}
|
||||
|
||||
//Close Database
|
||||
DBclose($link);
|
||||
exit(); break;
|
||||
case 'name':
|
||||
$user= FILTER_SANITIZE_STRING($_POST['user']);
|
||||
|
||||
$query="DELETE FROM ".table('FILE_TABLE')." WHERE type = 1"; DBquery($link,$query);
|
||||
$query="INSERT INTO ".table('FILE_TABLE')." VALUES ('$id', 1, '$ip', '$user', '', '', '')"; DBquery($link,$query);
|
||||
break;
|
||||
case 'server':
|
||||
$tab='settings';
|
||||
|
||||
$server= FILTER_SANITIZE_STRING($_POST['server']);
|
||||
$content = curl($server, array('formid' => 'ping', 'ip'=>$ip));
|
||||
|
||||
if(CheckVersion($content) && $server!=$SITE_URL){
|
||||
//store server
|
||||
$query="INSERT INTO ".table('FILE_TABLE')." VALUES ('$id', 2, '$ip', '', '', '', '$server')"; DBquery($link,$query);
|
||||
$server_list[count($server_list)]=$server;
|
||||
|
||||
$s_output = "<span style='text-align: center; display: block;'>The server was added.</span><br>";
|
||||
$server='';
|
||||
}
|
||||
else{$s_output = "<span style='text-align: center; display: block; color:#ff0000;'>Error. The server could not be added.</span><br>";}
|
||||
|
||||
break;
|
||||
case 'deleteserver':
|
||||
$tab='settings';
|
||||
|
||||
foreach($server_list as $s){
|
||||
if(isset($_POST['del_'.FILTER_('.',$s)])){
|
||||
$query="DELETE FROM ".table('FILE_TABLE')." WHERE url='$s'"; DBquery($link,$query);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Get Server List
|
||||
$server_list=array();
|
||||
$server_list[0]=$SITE_URL;
|
||||
$query="SELECT * FROM ".table('FILE_TABLE')." WHERE type = 2";
|
||||
$result = DBquery($link,$query); $rows = DBnum_rows($result);
|
||||
for($i=0;$i<$rows;$i++){$server_list[$i+1]=DBresult($result,$i,'url');}
|
||||
|
||||
break;
|
||||
case 'file':
|
||||
if($_POST['request'] == $SITE_URL){
|
||||
//Close Database
|
||||
DBclose($link);
|
||||
exit();
|
||||
}
|
||||
|
||||
//Upload Algorythm
|
||||
//1:get user from db
|
||||
if(isset($_POST['user'])){$user = $_POST['user'];}
|
||||
|
||||
if($user==''){$f_output="<span style='text-align: center; display: block; color:#ff0000;'>Error. User not result.</span><br>";}
|
||||
else{
|
||||
//Create Paths
|
||||
$target_path = "save/";
|
||||
$target_path = FILTER_SPACES($target_path .$user."-". basename( $_FILES['uploadedfile']['name']));
|
||||
|
||||
$store_path = "save/store/";
|
||||
$store_path = FILTER_SPACES($store_path .$user."-". basename( $_FILES['uploadedfile']['name']));
|
||||
|
||||
//2a:Backup the old file if it exists
|
||||
if(file_exists($target_path)){rename($target_path, $store_path);}
|
||||
//2b:copy the new file to the storage folder
|
||||
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
|
||||
$f_output="<span style='text-align: center; display: block;'>The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded</span><br>";
|
||||
//2c:insert the file record
|
||||
$query="DELETE FROM ".table('FILE_TABLE')." WHERE user='$user' AND file='".basename( $_FILES['uploadedfile']['name'])."'"; DBquery($link,$query);
|
||||
$query="INSERT INTO ".table('FILE_TABLE')." VALUES ('$id', 3, '$ip', '$user', '".basename( $_FILES['uploadedfile']['name'])."', '$id', '')"; DBquery($link,$query);
|
||||
}
|
||||
else{$f_output="<span style='text-align: center; display: block; color:#ff0000;'>There was an error uploading the file, please try again!</span><br>";}
|
||||
|
||||
//3:send file/post data to the servers
|
||||
$post=array('formid'=>'file', 'user'=>$user, 'ip'=>$ip, 'time'=>$id, 'uploadedfile'=>new CurlFile($target_path, '', $_FILES['uploadedfile']['name']),'request'=>$SITE_URL);
|
||||
foreach ($server_list as $s) {curl($s, $post);}
|
||||
}
|
||||
break;
|
||||
case 'deletefile':
|
||||
if($_POST['request'] == $SITE_URL){
|
||||
//Close Database
|
||||
DBclose($link);
|
||||
exit();
|
||||
}
|
||||
|
||||
if(isset($_POST['user'])){$user = $_POST['user'];}
|
||||
|
||||
$query="SELECT * FROM ".table('FILE_TABLE')." WHERE type = 3";
|
||||
$result = DBquery($link,$query); $rows = DBnum_rows($result);
|
||||
for($i=0;$i<$rows;$i++){
|
||||
if(isset($_POST['del_'.FILTER_('.', DBresult($result,$i,'file'))])){break;}
|
||||
}
|
||||
if($i<$rows){
|
||||
$filename=DBresult($result,$i,'file');
|
||||
$query="DELETE FROM ".table('FILE_TABLE')." WHERE user='$user' AND file='".$filename."'"; DBquery($link,$query);
|
||||
|
||||
$post=array('formid'=>'deletefile', 'user'=>$user, 'ip'=>$ip, 'time'=>$id, 'del_'.FILTER_('.',$filename)=>'X', 'request'=>$SITE_URL);
|
||||
foreach ($server_list as $s) {curl($s, $post);}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Build File List
|
||||
if($user!=''){
|
||||
$post=array('formid'=>'list', 'user'=>$user, 'ip'=>$ip, 'time'=>time());
|
||||
foreach ($server_list as $s) {
|
||||
$content = explode('|',curl($s, $post));
|
||||
if(count($content)>=2){
|
||||
|
||||
switch($s==$SITE_URL){
|
||||
case true:
|
||||
for($i=0;$i<count($content);$i+=2){
|
||||
if($content[$i]!=""){$file_list[$content[$i]]=array('file'=>$content[$i], 'time'=>$content[$i+1], 'server'=>$s, 'status'=>1);}
|
||||
}
|
||||
break;
|
||||
case false:
|
||||
for($i=0;$i<count($content);$i+=2){
|
||||
if(array_key_exists($content[$i],$file_list)){
|
||||
//exists
|
||||
$f=$file_list[$content[$i]];
|
||||
if($f['time'] == $content[$i+1] && $f['status'] >= 1){$f['status'] += 1; $file_list[$content[$i]] = $f;}
|
||||
if($f['time'] > $content[$i+1]){$f['time'] = $content[$i+1]; $f['server'] = $s; $f['status'] = 0; $file_list[$content[$i]] = $f;}
|
||||
}
|
||||
else{
|
||||
//doesnt exist
|
||||
if($content[$i]!=""){
|
||||
$file_list[$content[$i]]=array('file'=>$content[$i], 'time'=>$content[$i+1], 'server'=>$s, 'status'=>0);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Set Tab State
|
||||
$tab = $user=='' || count($server_list)<=1?'settings':$tab;
|
||||
|
||||
//Close Database
|
||||
DBclose($link);
|
||||
|
||||
//Functions
|
||||
function CheckVersion(string $check){
|
||||
$result=false;
|
||||
foreach($GLOBALS['COMPATIBLE'] as $v){
|
||||
if($v==$check){$result=true; break;}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function curl($url, $post){
|
||||
$handle=curl_init();
|
||||
curl_setopt($handle, CURLOPT_URL, $url);
|
||||
curl_setopt($handle, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($handle, CURLOPT_POSTFIELDS, $post);
|
||||
$content = curl_exec($handle);
|
||||
curl_close($handle);
|
||||
|
||||
return $content;
|
||||
}
|
||||
function ShortHash($hash){
|
||||
$arr = str_split($hash);
|
||||
$start=0;$length=0;
|
||||
foreach($arr as $c){
|
||||
if (is_numeric($c)) {
|
||||
if($start==0){$start=(intval($c)<5?intval($c)+5:intval($c));} else{$length=(intval($c)<5?intval($c)+5:intval($c));}
|
||||
if($length!=0){break;}
|
||||
}
|
||||
}
|
||||
return substr($hash, $start, $length);
|
||||
}
|
||||
function FILTER_(string $search, string $string): string{return str_replace($search,'_',$string);}
|
||||
function FILTER_SPACES(string $string): string{return str_replace(' ','_',$string);}
|
||||
function FILTER_SANITIZE_STRING(string $string): string { return str_replace(["'", '"'], [''', '"'], preg_replace('/\x00|<[^>]*>?/', '', $string)); }
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="styles.css?v=<?php echo time();?>">
|
||||
<?php echo isMobile()?'<link rel="stylesheet" href="styles_m.css?v='.time().'">':'';?>
|
||||
|
||||
</head>
|
||||
<body onload="showcontent('<?php echo $tab; ?>')">
|
||||
<!-- Start Div-->
|
||||
<div class='center' style="width:60%;">
|
||||
|
||||
<h1>File Sync<?php echo $user!=''?' - '.$user:'';?></h1>
|
||||
|
||||
<label class='click' onclick="showcontent('files')">File Server</label> | <label class='click' onclick="showcontent('settings')">Settings</label> | <label class='click' onclick="showcontent('about')">About</label>
|
||||
|
||||
<div id='content'></div>
|
||||
|
||||
<!-- Settings Div-->
|
||||
<div id='settings' style='display:none;'>
|
||||
|
||||
<h2>Settings</h2>
|
||||
<div style="border: 2px solid #ccc; font-family: verdana; padding: 7px; margin: 5px;">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="formid" value="name" />
|
||||
<label>Identity: </label><input style="width: 330px;" onkeypress="return event.key != ' '" onkeydown="return /[a-z]/i.test(event.key)" type=text name=user placeholder="Your Name / Website" value="<?php echo ($user!=''?$user:''); ?>">
|
||||
<hr style="border:none;">
|
||||
<input name="ip" type="hidden" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
|
||||
<div class='center'><input type=submit name=submit value=Submit></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2>Servers</h2>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="formid" value="deleteserver" />
|
||||
<input name="ip" type="hidden" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
|
||||
<ul>
|
||||
<?php
|
||||
if (count($server_list)<=1) {echo '<li>none</li>';}
|
||||
else {
|
||||
foreach ($server_list as $s) {
|
||||
echo $s==$SITE_URL?'':'<li>'.$s.' <input title="Delete this server?" type=submit name="del_'.FILTER_('.',$s).'" value=X onclick=\'return confirm("Are you sure you want to delete the server?\n\n'.$s.'")\'></li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
<div style="border: 2px solid #ccc; font-family: verdana; padding: 7px; margin: 5px;">
|
||||
<?php echo $s_output; ?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="formid" value="server" />
|
||||
<label>Add Server: </label><input style="width: 330px;" onkeypress="return event.key != ' '" type=text name=server placeholder="Server Url" value="<?php echo (isset($server)?$server:''); ?>">
|
||||
<hr style="border:none;">
|
||||
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
|
||||
<div class='center'><input type=submit name=submit value=Add></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Settings Div-->
|
||||
|
||||
<!-- Files Div-->
|
||||
<div id='files' style='display:none;'>
|
||||
|
||||
<h2>Upload</h2>
|
||||
<div style="border: 2px solid #ccc; font-family: verdana; padding: 7px; margin: 5px;">
|
||||
<?php echo $f_output; ?>
|
||||
<form enctype="multipart/form-data" method="POST">
|
||||
<input type="hidden" name="formid" value="file">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="533554432">
|
||||
<label>Choose a file to upload: </label>
|
||||
<input name="uploadedfile" type="file">
|
||||
<hr style="border:none;">
|
||||
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
|
||||
<input type="hidden" name="request" value="form">
|
||||
<div class='center'><input type="submit" value="Upload"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2>Files on Server</h2>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="formid" value="deletefile" />
|
||||
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
|
||||
<input type="hidden" name="request" value="form">
|
||||
|
||||
|
||||
<ul>
|
||||
<table style="border-collapse: separate; border-spacing: 30px 0px;">
|
||||
<?php
|
||||
$tooltip[0]='Critical - No other servers have a backup of this file.';
|
||||
$tooltip[1]='Warning - You do not have a backup of this file locally.';
|
||||
$tooltip[2]='Good - Multiple servers have a backup of this file.';
|
||||
|
||||
if (count($file_list)==0) {echo '<tr><td><li>none</li></td></tr>';}
|
||||
else{
|
||||
|
||||
foreach($file_list as $f) {
|
||||
$download_link='<a href="'.FILTER_SPaCES($f['server']."save/".$user."-".$f['file']).'" download="'.$f['file'].'"><button type="button">Download</button></a>';
|
||||
$fcolor=($f['status']>=2?'#00ff00':($f['status']==1?'#ff0000':'#ff8000'));
|
||||
$ficon=($f['status']>=2?'✔':($f['status']==1?'✖':'⚠'));
|
||||
$ftooltip=$f['file'].' - '.($f['status']>=2?$tooltip[2]:($f['status']==1?$tooltip[0]:$tooltip[1]));
|
||||
|
||||
//$ficon=($f['status']>=2?'✔️':($f['status']==1?'⚠️':'❌'));
|
||||
echo '<tr style="color:'.$fcolor.';">';
|
||||
echo '<td title="'.$ftooltip.'"><li >'.$f['file'].'</li></td>';
|
||||
echo '<td title="'.$ftooltip.'">'.date($Date_Format, $f['time']).'</td>';
|
||||
echo '<td title="'.$ftooltip.'">'.$ficon.'</td>';
|
||||
echo '<td>'.$download_link.'</td>';
|
||||
echo '<td><input title="Delete this file?" type=submit name="del_'.FILTER_('.',$f['file']).'" value=X onclick=\'return confirm("Are you sure you want to delete this file?\n\n'.$f['file'].'")\'></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
<label class='click' onclick="toggle('legend')">Click to show status info</label>
|
||||
<div id='legend' style="display:none;">
|
||||
<h2>Status Info</h2>
|
||||
<div style="border: 2px solid #ccc; font-family: verdana; padding: 7px; margin: 5px; ">
|
||||
<ul>
|
||||
<li style="color:#00ff00;"><?php echo '✔ - '.$tooltip[2];?></li>
|
||||
<li style="color:#ff8000;"><?php echo '⚠ - '.$tooltip[1];?></li>
|
||||
<li style="color:#ff0000;"><?php echo '✖ - '.$tooltip[0];?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Files Div-->
|
||||
|
||||
<!-- About Div-->
|
||||
<div id='about' style='display:none;'>
|
||||
<?php include('readme.html'); ?>
|
||||
</div>
|
||||
<!-- About Div-->
|
||||
|
||||
</div>
|
||||
<!-- End Div-->
|
||||
|
||||
<script>
|
||||
function showcontent(id) {document.getElementById('content').innerHTML = document.getElementById(id).innerHTML;}
|
||||
function toggle(id) {
|
||||
var element = document.getElementById(id);
|
||||
element.style.display = (element.style.display === "none" ? "block" : "none");
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
27
readme.html
Normal file
27
readme.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<h2>About FileSync</h2>
|
||||
<p>FileSync is designed to store a backup of your file(s) on remote servers.</p>
|
||||
<p>Due to the limitations of php script timeout files should be small. For example: 6 SSL keys zipped to a file is around 90kb. This is small enough to use for this.
|
||||
Do not try to backup files that are several mbs. It may not work correctly.</p>
|
||||
|
||||
<h2>How it works</h2>
|
||||
<ul>
|
||||
<li>Unpack FileSync.zip to a folder on your server. For example: https://example.com/filesync/</li>
|
||||
<li>Add the other servers that you will link to in the server list.</li>
|
||||
<li>When you upload a file to your server it will also send the file to the linked servers.</li>
|
||||
<li>You can upload a new version of the file at a later time. It will also update the linked servers.</li>
|
||||
</ul>
|
||||
|
||||
<h2>File status</h2>
|
||||
<ul>
|
||||
<li><span style="color:#00ff00;">✔ - Good - Multiple servers have a backup of this file.</span>
|
||||
<br><br>
|
||||
</li>
|
||||
<li><span style="color:#ff8000;">⚠ - Warning - You do not have a backup of this file locally.</span><br>
|
||||
To resolve: Use the download button to get the file from a remote server. Then re-upload that file.
|
||||
<br><br>
|
||||
</li>
|
||||
<li><span style="color:#ff0000;">✖ - Critical - No other servers have a backup of this file.</span><br>
|
||||
To resolve: You should contact the other admins to resolve server availability. Then try to upload the file again.
|
||||
<br><br>
|
||||
</li>
|
||||
</ul>
|
||||
0
save/Place_Holder.txt
Normal file
0
save/Place_Holder.txt
Normal file
0
save/store/Place_Holder.txt
Normal file
0
save/store/Place_Holder.txt
Normal file
25
styles.css
Normal file
25
styles.css
Normal file
@@ -0,0 +1,25 @@
|
||||
html,body {
|
||||
background-color:#303030;
|
||||
color:#CCCCCC;
|
||||
margin:0;
|
||||
font-family: "Lato", sans-serif;
|
||||
}
|
||||
.center {max-width: fit-content; margin: auto;}
|
||||
h1{color:#CCCCCC;}
|
||||
h2{color:#CCCCCC;}
|
||||
h3{
|
||||
color:#CCCCCC;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
input,button{background-color: #555555; color: #CCC;}
|
||||
.form-button{background-color: #555555; color: #CCC; border-width:1px; border-style:solid; border-color:grey; margin-top: 8px;}
|
||||
select{background-color: #555555; color: #CCC;}
|
||||
.form-center{text-align:center;}
|
||||
.form-element{display:flex;}
|
||||
.form-input{border-width:1px; border-style:solid; border-color:grey; width:100%; font-family:arial; margin:2px; padding-left:2px;}
|
||||
.form-error{border-width:1px; border-style:solid; border-color:red; width:100%; font-family:arial; margin:2px; padding-left:2px;}
|
||||
.form-submit{color:#4caf50; font-family:arial; margin:2px;}
|
||||
.left{text-align: left;}
|
||||
.right{text-align: right;}
|
||||
.click{cursor: pointer; text-decoration: underline;}
|
||||
6
styles_m.css
Normal file
6
styles_m.css
Normal file
@@ -0,0 +1,6 @@
|
||||
html {font-size:2.25em;}
|
||||
button,input {font-size:1.25em;}
|
||||
input[type=checkbox] {
|
||||
transform: scale(1.25);
|
||||
margin: 10px;
|
||||
}
|
||||
Reference in New Issue
Block a user