Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
farisc0de committed Jun 12, 2022
1 parent 84125bf commit 139c12f
Show file tree
Hide file tree
Showing 63 changed files with 9,958 additions and 670 deletions.
3 changes: 2 additions & 1 deletion uploady/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"require": {
"phpmailer/phpmailer": "^6.2",
"google/recaptcha": "^1.2",
"sonata-project/google-authenticator": "^2.3"
"sonata-project/google-authenticator": "^2.3",
"farisc0de/phpfileuploading": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
57 changes: 47 additions & 10 deletions uploady/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions uploady/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,32 @@

<h3 class="text-center">Create an admin user</h3>

<div class="form-group">
<div class="pt-2">
<div class="form-label-group">
<input class="form-control" type="text" maxlength="15" id="username" name="username" placeholder="Username" required>
<small id="user_error" class="text-danger"></small>
</div>
</div>

<div class="form-group">
<div class="pt-3">
<div class="form-label-group">
<input class="form-control" type="password" minlength="8" id="password" name="password" placeholder="Password" required>
<small id="password_error" class="text-danger"></small>
</div>
</div>

<div class="form-group">
<div class="pt-3">
<div class="form-label-group">
<input class="form-control" type="email" id="email" name="email" placeholder="Email Address" required>
<small id="email_error" class="text-danger"></small>
</div>
</div>
<button type="submit" class="btn btn-primary btn-block" <?php echo $disabled; ?>>
Start Installation
</button>

<div class="pt-3">
<button type="submit" class="btn btn-primary btn-block" <?php echo $disabled; ?>>
Start Installation
</button>
</div>
</form>
</div>
</div>
Expand Down
135 changes: 103 additions & 32 deletions uploady/logic/installLogic.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?php

use Uploady\Migration\Options\Options;
use Uploady\Migration\Options\Types;

$utils = new Uploady\Utils();

$database = new Uploady\Database();

$install = new Uploady\Update($database, $utils);
$install = new \Uploady\Migration\Migration($database, $utils);

$upload = new \Uploady\Handler\Upload();
$upload = new Farisc0de\PhpFileUploading\Upload();

$php_alert = "";

Expand Down Expand Up @@ -68,32 +71,85 @@
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
$users = [
['id', 'int', 'UNSIGNED', 'NOT NULL'],
['username', 'varchar(25)', 'NOT NULL'],
['email', 'varchar(225)', 'NOT NULL'],
["password", "varchar(255)", "NOT NULL"],
['user_id', 'varchar(64)', 'NOT NULL'],
['is_admin', 'tinyint(1)', 'NOT NULL', 'DEFAULT 0'],
['failed_login', 'int', 'NOT NULL', 'DEFAULT 0'],
['last_login', 'timestamp', 'NOT NULL', 'DEFAULT CURRENT_TIMESTAMP'],
['reset_hash', 'varchar(64)', 'DEFAULT NULL'],
['created_at', 'timestamp', 'NULL', 'DEFAULT NULL'],
['activation_hash', 'varchar(64)', 'DEFAULT NULL'],
['is_active', 'tinyint(1)', 'NOT NULL', 'DEFAULT 0']
[
'id',
Types::Integer(),
Options::UnSigned(),
Options::NotNull()
],
[
'username', Types::String(25),
Options::NotNull()
],
[
'email',
Types::String(225),
Options::NotNull()
],
[
'password',
Types::String(225),
Options::NotNull()
],
[
'user_id',
Types::String(64),
Options::NotNull()
],
[
'is_admin',
Types::Boolean(),
Options::NotNull(),
Options::DefaultValue("0")
],
[
'failed_login',
Types::Integer(),
Options::NotNull(),
Options::DefaultValue("0")
],
[
'last_login',
Types::TimeStamp(),
Options::NotNull(),
Options::DefaultValue("CURRENT_TIMESTAMP")
],
[
'reset_hash',
Types::String(64),
Options::DefaultValue("NULL")
],
[
'created_at',
Types::TimeStamp(),
Options::Null(),
Options::DefaultValue("NULL")
],
[
'activation_hash',
Types::String(64),
Options::DefaultValue("NULL")
],
[
'is_active',
Types::Boolean(),
Options::NotNull(),
Options::DefaultValue("0")
]
];

$files = [
['id', 'int', 'NOT NULL'],
['file_id', 'varchar(100)', 'NOT NULL'],
['user_id', 'varchar(100)', 'NOT NULL'],
['file_data', 'text', 'NOT NULL'],
['uploaded_at', 'timestamp', 'NOT NULL']
['id', Types::Integer(), Options::NotNull()],
['file_id', Types::String(100), Options::NotNull()],
['user_id', Types::String(100), Options::NotNull()],
['file_data', 'text', Options::NotNull()],
['uploaded_at', Types::TimeStamp(), Options::NotNull()]
];

$settings = [
["id", "int(11)", "unsigned", "NOT NULL"],
["setting_key", "varchar(50)", "NOT NULL"],
["setting_value", "varchar(225)", "NOT NULL"],
["id", Types::Integer(), Options::UnSigned(), Options::NotNull()],
["setting_key", Types::String(50), Options::NotNull()],
["setting_value", Types::String(225), Options::NotNull()],
];

$install->createTable("users", $users);
Expand Down Expand Up @@ -233,25 +289,40 @@
]
);

$install->isPrimary("users", "id");
$install->setPrimary("users", "id");

$install->isUnique("users", "email");
$install->setUnique("users", "email");

$install->isUnique("users", "user_id");
$install->setUnique("users", "user_id");

$install->isUnique("users", "activation_hash");
$install->setUnique("users", "activation_hash");

$install->isAutoinc("users", ["id", "int(11)", "unsigned", "NOT NULL"]);
$install->setAutoinc("users", [
"id",
Types::Integer(),
Options::UnSigned(),
Options::NotNull()
]);

$install->isPrimary("files", "id");
$install->setPrimary("files", "id");

$install->isUnique("files", "file_id");
$install->setUnique("files", "file_id");

$install->isAutoinc("files", ["id", "int(11)", "unsigned", "NOT NULL"]);
$install->setAutoinc("files", [
"id",
Types::Integer(),
Options::UnSigned(),
Options::NotNull()
]);

$install->isPrimary("settings", "id");
$install->setPrimary("settings", "id");

$install->isAutoinc("settings", ["id", "int(11)", "unsigned", "NOT NULL"]);
$install->setAutoinc("settings", [
"id",
Types::Integer(),
Options::UnSigned(),
Options::NotNull()
]);

// Enable Production Mode
/* -------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion uploady/logic/supportedLogic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$filter = json_decode(
file_get_contents("src/Uploady/Handler/filter.json"),
file_get_contents("vendor/farisc0de/phpfileuploading/src/filter.json"),
true
);

Expand Down
22 changes: 12 additions & 10 deletions uploady/logic/uploadLogic.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<?php

use Uploady\Handler\Upload;
use Uploady\Handler\UploadHandler;

$upload = new Upload;
$utilty = new Farisc0de\PhpFileUploading\Utility();

$upload = new Farisc0de\PhpFileUploading\Upload();

$handler = new UploadHandler($db);

$upload->setController("src/Uploady/Handler/");
$upload->setController("vendor/farisc0de/phpfileuploading/src/");

$upload->setSiteUrl(SITE_URL);

if ($_SERVER['REQUEST_METHOD'] == "POST") {
$inputs = $upload->fixArray($_FILES['file']);
$inputs = $utilty->fixArray($_FILES['file']);

if (count($inputs) > 10) {
$utils->redirect('index.php?error=1');
}

$upload->setUserID(
(isset($_SESSION['user_id']) ? $_SESSION['user_id'] : $upload->generateUserID())
);
$upload->generateUserID();

$upload->createUserCloud(UPLOAD_FOLDER);

Expand All @@ -32,11 +34,11 @@

foreach ($inputs as $file) {

$upload->setFileID($upload->generateFileID());
$upload->generateFileID();

$upload->setUpload($file);
$upload->setUpload(new Farisc0de\PhpFileUploading\File($file));

if ($upload->checkIfEmpty()) {
if ($upload->checkIfNotEmpty()) {

$upload->hashName();

Expand Down
2 changes: 1 addition & 1 deletion uploady/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$data = $user->getUserData($username);

if (!isset($_SESSION['user_id'])) {
$_SESSION["user_id"] = $data->user_id;
$_SESSION["user_id"] = hash("sha1", $data->user_id);
}
}

Expand Down
Loading

0 comments on commit 139c12f

Please sign in to comment.