Skip to content

Commit

Permalink
cleaned repeating lines with includes.php
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrogenous committed Jan 30, 2018
1 parent ce46665 commit 89cdf6b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 81 deletions.
50 changes: 1 addition & 49 deletions check.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."main.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."drive.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."dropbox.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."amazonwebservices.php");

use XUP\Uploader\Main;
use XUP\Uploader\Drive;
use XUP\Uploader\Dropbox;
use XUP\Uploader\AmazonWebServices;
require_once(__DIR__.DIRECTORY_SEPARATOR."includes.php");

$services = array("Drive" => null,"Dropbox" => null,"AmazonWebServices" => null);

Expand All @@ -19,43 +11,3 @@
$services[$service] = $adapter->check($formid,$qid);
}
exit(json_encode($services));
function injection($str) {
$bad = array(
'<!--', '-->',
"'", '"',
'<', '>',
'&', '$',
'=',
';',
'?',
'/',
'!',
'#',
'%20', //space
'%22', // "
'%3c', // <
'%253c', // <
'%3e', // >
'%0e', // >
'%28', // (
'%29', // )
'%2528', // (
'%26', // &
'%24', // $
'%3f', // ?
'%3b', // ;
'%3d', // =
'%2F', // /
'%2E', // .
// '46', // .
// '47' // /
);
do
{
$old = $str;
$str = str_replace($bad, ' ', $str);
}
while ($old !== $str);
return $str;
}

10 changes: 1 addition & 9 deletions database.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?php
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."main.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."drive.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."dropbox.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."amazonwebservices.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."functions.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."includes.php");

use XUP\Uploader\Main;
use XUP\Uploader\Drive;
use XUP\Uploader\Dropbox;
use XUP\Uploader\AmazonWebServices;
$output = array();
$services = $_POST["clouds"];
$services = explode(",",$services);
Expand Down
9 changes: 3 additions & 6 deletions file.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require_once(__DIR__.DIRECTORY_SEPARATOR."functions.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."includes.php");

if($_POST["action"] == "save"){
function fileNameExist($path,$filename){
Expand Down Expand Up @@ -100,10 +100,7 @@ function save($fileTmpName,$filePath,$fileName,$folder){

}

use XUP\Uploader\Main;
use XUP\Uploader\Drive;
use XUP\Uploader\Dropbox;
use XUP\Uploader\AmazonWebServices;

$output = array();
$services = array("Drive","Dropbox","AmazonWebServices");
$action = $_POST["action"];
Expand All @@ -114,7 +111,7 @@ function save($fileTmpName,$filePath,$fileName,$folder){
}
exit(json_encode($output));

function upload($adapter,$post) {
function upload($adapter,$post) {
$params = json_encode(array("formid" => injection($post["formid"]),"folder"=>injection($post["folder"]),"qid" => injection($post["qid"]), "key" => $post["key"], "file" => injection($post["file"]),"folderKey" => injection($post["folderKey"])));
return $adapter->upload($params);
}
Expand Down
6 changes: 1 addition & 5 deletions gearman/workers/amazonWorker.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php
require_once(DIRECTORY_SEPARATOR."www".DIRECTORY_SEPARATOR."v3".DIRECTORY_SEPARATOR."toprak".DIRECTORY_SEPARATOR."Adapter". DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php");
// require_once '/www/v3/toprak/lib/init.php';

use Aws\S3\S3Client;
use Aws\Common\Credentials\Credentials;
require_once(__DIR__.DIRECTORY_SEPARATOR."includes.php");

$worker = new GearmanWorker();
$worker->addServer("127.0.0.1", "4730");
Expand Down
7 changes: 1 addition & 6 deletions gearman/workers/driveWorker.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?php
require_once(DIRECTORY_SEPARATOR."www".DIRECTORY_SEPARATOR."v3".DIRECTORY_SEPARATOR."toprak".DIRECTORY_SEPARATOR."Adapter".DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."main.php");
require_once(DIRECTORY_SEPARATOR."www".DIRECTORY_SEPARATOR."v3".DIRECTORY_SEPARATOR."toprak".DIRECTORY_SEPARATOR."Adapter".DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR."autoload.php");
require_once(DIRECTORY_SEPARATOR."www".DIRECTORY_SEPARATOR."v3".DIRECTORY_SEPARATOR."toprak".DIRECTORY_SEPARATOR."Adapter".DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."drive.php");

use XUP\Uploader\Main;
use XUP\Uploader\Drive;
require_once(__DIR__.DIRECTORY_SEPARATOR."includes.php");

$worker = new GearmanWorker();
$worker->addServer("127.0.0.1", "4730");
Expand Down
5 changes: 0 additions & 5 deletions gearman/workers/dropboxWorker.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
require_once(DIRECTORY_SEPARATOR."www".DIRECTORY_SEPARATOR."v3".DIRECTORY_SEPARATOR."toprak".DIRECTORY_SEPARATOR."Adapter". DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php");
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client;
use Spatie\FlysystemDropbox\DropboxAdapter;

$worker = new GearmanWorker();
$worker->addServer("127.0.0.1", "4730");
$worker->addFunction("toprakDBX", "toprakDbxUpload");
Expand Down
15 changes: 14 additions & 1 deletion includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."drive.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."dropbox.php");
require_once(__DIR__.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR."XUP".DIRECTORY_SEPARATOR."adapters".DIRECTORY_SEPARATOR."amazonwebservices.php");
require_once(DIRECTORY_SEPARATOR."www".DIRECTORY_SEPARATOR."v3".DIRECTORY_SEPARATOR."toprak".DIRECTORY_SEPARATOR."Adapter". DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php");

use Aws\S3\S3Client;
use XUP\Uploader\Main;
use XUP\Uploader\Drive;
use XUP\Uploader\Dropbox;
use Spatie\Dropbox\Client;
use League\Flysystem\Filesystem;
use XUP\Uploader\AmazonWebServices;
use Aws\Common\Credentials\Credentials;
use Spatie\FlysystemDropbox\DropboxAdapter;


function injection($str) {
$bad = array(
'<!--', '-->',
Expand Down Expand Up @@ -71,7 +84,7 @@ function type($str){
}
return true;
}

function mime($str){
$neverAllow = array(
"application/octet-stream",
Expand Down

0 comments on commit 89cdf6b

Please sign in to comment.