Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Delirious committed Feb 15, 2024
1 parent 8181879 commit ee1ea5f
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 21 deletions.
34 changes: 16 additions & 18 deletions uploady/actions/upload_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,22 @@
exit();
}

if (
!$upload->checkExtension()
) {
http_response_code(400);
echo json_encode([
"error" => $lang["general"]['file_type_is_not_allowed'],
]);
exit();
}

if (
!$upload->checkMime()
) {
http_response_code(400);
echo json_encode([
"error" => $lang["general"]['file_mime_type_is_not_allowed'],
]);
exit();
if($settings->getSettingValue("protections_enable")){
if (!$upload->checkExtension()) {
http_response_code(400);
echo json_encode([
"error" => $lang["general"]['file_type_is_not_allowed'],
]);
exit();
}

if (!$upload->checkMime()) {
http_response_code(400);
echo json_encode([
"error" => $lang["general"]['file_mime_type_is_not_allowed'],
]);
exit();
}
}

if ($upload->upload()) {
Expand Down
28 changes: 27 additions & 1 deletion uploady/admin/settings/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,50 @@
<label class="custom-control-label" for="public_upload">Public Upload</label>
</div>
</div>


<div class="form-group">
<input hidden name="protections_enable" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="protections_enable" value="1" name="protections_enable" type="checkbox" <?= ($settings->getSettingValue('protections_enable') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="protections_enable">Enable MIME/extension Protections</label>
</div>
</div>

<hr />

<div class="form-group">
<input hidden name="instagram_enable" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="instagram_enable" value="1" name="instagram_enable" type="checkbox" <?= ($settings->getSettingValue('instagram_enable') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="instagram_enable">Enable Instagram Link</label>
</div>

<div class="form-label-group">
<input class="form-control" type="text" id="instagram_link" name="instagram_link" placeholder="Instagram Link" value="<?= $settings->getSettingValue('instagram_link'); ?>">
<label for="instagram_link"><i class="fab fa-instagram"></i> Instagram Link</label>
</div>
</div>

<div class="form-group">
<input hidden name="twitter_enable" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="twitter_enable" value="1" name="twitter_enable" type="checkbox" <?= ($settings->getSettingValue('twitter_enable') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="twitter_enable">Enable Twitter Link</label>
</div>

<div class="form-label-group">
<input class="form-control" type="text" id="twitter_link" name="twitter_link" placeholder="Twitter Link" value="<?= $settings->getSettingValue('twitter_link'); ?>">
<label for="twitter_link"><i class="fab fa-twitter"></i> Twitter Link</label>
</div>
</div>

<div class="form-group">
<input hidden name="linkedin_enable" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="linkedin_enable" value="1" name="linkedin_enable" type="checkbox" <?= ($settings->getSettingValue('linkedin_enable') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="linkedin_enable">Enable LinkedIn Link</label>
</div>

<div class="form-label-group">
<input class="form-control" type="text" id="linkedin_link" name="linkedin_link" placeholder="LinkedIn Link" value="<?= $settings->getSettingValue('linkedin_link'); ?>">
<label for="linkedin_link"><i class="fab fa-linkedin-in"></i> LinkedIn Link</label>
Expand Down
6 changes: 6 additions & 0 deletions uploady/components/footer.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
<div class="text-center container">
<ul class="list-inline">
<?php if ($settings->getSettingValue('twitter_enable') == true) : ?>
<li class="list-inline-item">
<a href="<?= $st['twitter_link'] ?>" class="btn btn-info rounded-circle">
<i class="fab fa-twitter text-white"></i>
</a>
</li>
<?php endif; ?>
<?php if ($settings->getSettingValue('instagram_enable') == true) : ?>
<li class="list-inline-item">
<a href="<?= $st['instagram_link'] ?>" class="btn btn-danger rounded-circle">
<i class="fab fa-instagram text-white"></i>
</a>
</li>
<?php endif; ?>
<?php if ($settings->getSettingValue('linkedin_enable') == true) : ?>
<li class="list-inline-item">
<a href="<?= $st['linkedin_link'] ?>" class="btn btn-primary rounded-circle">
<i class="fab fa-linkedin-in text-white"></i>
</a>
</li>
<?php endif; ?>
</ul>
</div>

Expand Down
32 changes: 32 additions & 0 deletions uploady/logic/installLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,38 @@
]
);

$install->insertValue(
"settings",
[
'setting_key' => 'twitter_enable',
'setting_value' => '1'
]
);

$install->insertValue(
"settings",
[
'setting_key' => 'instagram_enable',
'setting_value' => '1'
]
);

$install->insertValue(
"settings",
[
'setting_key' => 'linkedin_enable',
'setting_value' => '1'
]
);

$install->insertValue(
"settings",
[
'setting_key' => 'protections_enable',
'setting_value' => '1'
]
);

$install->insertValue("pages", [
'slug' => 'about',
'deletable' => false
Expand Down
15 changes: 13 additions & 2 deletions uploady/src/Uploady/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,26 @@ public function updateSettings($settings_array)
$res = [];

foreach ($settings_array as $setting_key => $setting_value) {
$this->db->prepare("UPDATE settings SET setting_value = :value WHERE setting_key = :key");
$this->db->prepare("SELECT setting_key FROM settings WHERE setting_key = :key");
$this->db->bind(":key", $setting_key, \PDO::PARAM_STR);
$this->db->execute();
$setting_exists = $this->db->single();

if ($setting_exists) {
// If setting exists, update it
$this->db->prepare("UPDATE settings SET setting_value = :value WHERE setting_key = :key");
} else {
// If setting doesn't exist, insert it
$this->db->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (:key, :value)");
}

$this->db->bind(":key", $setting_key, \PDO::PARAM_STR);
$this->db->bind(":value", $setting_value, \PDO::PARAM_STR);

array_push($res, $this->db->execute());
}

return in_array(false, $res) ? false : true;
return !in_array(false, $res);
}

/**
Expand Down

0 comments on commit ee1ea5f

Please sign in to comment.