Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local javascript #35

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it is kept simple and functional. Free for everyone.

Manual
----------------------------------
You have to upload index.php into your server.
You have to upload 'index.php' and the folder 'javascript' into your server.
If you open index.php you can edit several settings.
You should make sure the edited file will be saved in UTF-8!

Expand Down
72 changes: 59 additions & 13 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,37 @@
//
$_CONFIG['require_login'] = false;

// Whether store the passwords as sha256-hashes or not.
// It's bad practice to store passwords in plain text.
// If set to true, you shuld add the passwords-hashes instead of the passwords,
// in 'users' below.
//$_CONFIG['hash_psw'] = false;
//$_CONFIG['hash_psw'] = true;

// Default: $_CONFIG['hash_psw'] = false;

$_CONFIG['hash_psw'] = false;

//
// Usernames and passwords for restricting access to the page.
// The format is: array(username, password, status)

// Status can be either "user" or "admin". User can read the page, admin can upload and delete.
// For example: $_CONFIG['users'] = array(array("username1", "password1", "user"), array("username2", "password2", "admin"));
// You can also keep require_login=false and specify an admin.
// That way everyone can see the page but username and password are needed for uploading.
// For example: $_CONFIG['users'] = array(array("username", "password", "admin"));
// For example: $_CONFIG['users'] = array(array("username", "sha256 of password", "admin"));

// It's bad practice to store passwords in plain text.
// You'd better use sha256-hashes for example:
//$_CONFIG['users'] = array(array("admin", "secret", "admin"),
// array("test", "password", "user")); // may be replaced by:
//$_CONFIG['users'] = array(array("admin", "2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b", "admin"),
// array("test", "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", "user"));

// If the password contains national characters, make sure it's utf-8 encoded when you hash it!
// N.B. set hash_psw = true above.

// Default: $_CONFIG['users'] = array();
//
$_CONFIG['users'] = array();
Expand Down Expand Up @@ -860,22 +883,35 @@
$_TRANSLATIONS["sv"] = array(
"file_name" => "Filnamn",
"size" => "Storlek",
"last_changed" => "Senast andrad",
"last_changed" => "Senast ändrad",
"total_used_space" => "Totalt upptaget utrymme",
"free_space" => "Ledigt utrymme",
"password" => "Losenord",
"password" => "Lösenord",
"upload" => "Ladda upp",
"failed_upload" => "Fel vid uppladdning av fil!",
"failed_move" => "Fel vid flytt av fil till mapp!",
"wrong_password" => "Fel losenord",
"wrong_password" => "Fel lösenord",
"make_directory" => "Ny mapp",
"new_dir_failed" => "Fel vid skapande av mapp",
"chmod_dir_failed" => "Fel vid andring av mappens egenskaper",
"chmod_dir_failed" => "Fel vid ändring av mappens egenskaper",
"unable_to_read_dir" => "Kan inte lasa den filen",
"location" => "Plats",
"root" => "Hem"
"root" => "Hem",
"log_file_permission_error" => "Scriptet har inte behörighet att skriva till loggfilen.",
"upload_not_allowed" => "Skriptets konfiguration tillåter inte uppladdning till denna katalog.",
"upload_dir_not_writable" => "Denna katalog har inte behörigheter för att skriva.",
"mobile_version" => "Mobilvisning",
"standard_version" => "Standardvisning",
"page_load_time" => "Sidan laddades på %.2f ms",
"wrong_pass" => "Fel användarnamn eller lösenord",
"username" => "Användarnamn",
"log_in" => "Logga in",
"upload_type_not_allowed" => "Denna filtyp är det inte tillåtet att ladda upp.",
"del" => "Ta bort",
"log_out" => "Logga ut"
);


// Turkish
$_TRANSLATIONS["tr"] = array(
"file_name" => "Dosya Adı",
Expand Down Expand Up @@ -1558,6 +1594,7 @@ function css()
AAAAAElFTkSuQmCC";
$_IMAGES["jpg"] = $_IMAGES["image"];
$_IMAGES["jpeg"] = $_IMAGES["image"];
$_IMAGES["tif"] = $_IMAGES["image"];
$_IMAGES["js"] = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0
U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHdSURBVDjLjZNPaxNBGIdrLwURLznWgkcv
IrQhRw9FGgy01IY0TVsQ0q6GFkT0kwjJId9AP4AHP4Q9FO2hJ7El2+yf7OzMbja7Sf0578QdNybF
Expand Down Expand Up @@ -1931,23 +1968,31 @@ public static function init()
}
header( "Location: ".$addr.$param);
}
else
$encodeExplorer->setErrorString("wrong_pass");
else $encodeExplorer->setErrorString("wrong_pass");
}
}

public static function isUser($userName, $userPass)
{
foreach(EncodeExplorer::getConfig("users") as $user)
{
if($user[1] == $userPass)

if (EncodeExplorer::getConfig('hash_psw') == true)
{
$key = hash(sha256, $userPass, $raw_output = false);
}
else
$key = $userPass;

if($user[1] == $key)
{
if(strlen($userName) == 0 || $userName == $user[0])
{
return true;
}
}
}

return false;
}

Expand Down Expand Up @@ -2354,7 +2399,7 @@ function debug()
function isImage()
{
$type = $this->getType();
if($type == "png" || $type == "jpg" || $type == "gif" || $type == "jpeg")
if($type == "png" || $type == "jpg" || $type == "gif" || $type == "jpeg" || $type == "tif")
return true;
return false;
}
Expand Down Expand Up @@ -2872,6 +2917,7 @@ function outputHtml()
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=<?php print $this->getConfig('charset'); ?>">
<meta name=“robots” content=“noindex, nofollow”>
<?php css(); ?>
<!-- <meta charset="<?php print $this->getConfig('charset'); ?>" /> -->
<?php
Expand All @@ -2880,9 +2926,9 @@ function outputHtml()
|| (GateKeeper::isDeleteAllowed()))
{
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="./javascript/jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[

$(document).ready(function() {
<?php
if(GateKeeper::isDeleteAllowed()){
Expand Down Expand Up @@ -2947,7 +2993,7 @@ function(){
}
?>
});
//]]>

</script>
<?php
}
Expand Down
16 changes: 16 additions & 0 deletions javascript/jquery.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions javascript/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Source:

https://developers.google.com/speed/libraries/#jquery

https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js

Local javascript for better security, reliability and speed.