diff --git a/pixelapi/file.go b/pixelapi/file.go
index 2fd7343..f584520 100644
--- a/pixelapi/file.go
+++ b/pixelapi/file.go
@@ -24,6 +24,7 @@ type FileInfo struct {
MimeType string `json:"mime_type"`
MimeImage string `json:"mime_image"`
ThumbnailHREF string `json:"thumbnail_href"`
+ Availability string `json:"availability"`
}
// GetFileInfo gets the FileInfo from the pixeldrain API
diff --git a/res/static/script/Toolbar.js b/res/static/script/Toolbar.js
index e6c9dda..0e73270 100644
--- a/res/static/script/Toolbar.js
+++ b/res/static/script/Toolbar.js
@@ -30,7 +30,56 @@ var Toolbar = {
}
},
download: function () {
- document.getElementById("download_frame").src = "/api/file/" + Viewer.currentFile + "?download";
+ var triggerDL = function(){
+ document.getElementById("download_frame").src = "/api/file/" + Viewer.currentFile + "?download";
+ }
+
+ if (captchaKey === "a"){
+ // If the server doesn't support captcha there's no use in checking
+ // availability
+ triggerDL();
+ return;
+ }
+
+ $.getJSON(
+ apiEndpoint + "/file/" + Viewer.currentFile + "/availability"
+ ).done(function(data){
+ if(data.success === true){
+ // Downloading is allowed, start the download
+ triggerDL();
+ }
+ }).fail(function(data){
+ if(data.responseJSON.success === false) {
+ var popupDiv = document.getElementById("captcha_popup");
+ var popupTitle = document.getElementById("captcha_popup_title");
+ var popupContent = document.getElementById("captcha_popup_content");
+ var popupCaptcha = document.getElementById("captcha_popup_captcha");
+
+ if(data.responseJSON.value === "file_rate_limited_captcha_required") {
+ popupTitle.innerText = "Rate limiting enabled!";
+ popupContent.innerText = "This file is using a suspicious "+
+ "amount of bandwidth relative to its popularity. To "+
+ "continue downloading this file you will have to "+
+ "prove that you're a human first.";
+ }else if(data.responseJSON.value === "virus_detected_captcha_required"){
+ popupTitle.innerText = "Malware warning!";
+ popupContent.innerText = "According to our scanning "+
+ "systems this file may contain a virus of type '"+
+ data.responseJSON.extra+"'. You can continue "+
+ "downloading this file at your own risk, but you will "+
+ "have to prove that you're a human first.";
+ }
+
+ // Load the recaptcha script with a load function
+ $.getScript("https://www.google.com/recaptcha/api.js?onload=loadCaptcha&render=explicit");
+
+ popupDiv.style.opacity = "1";
+ popupDiv.style.visibility = "visible";
+ }else{
+ // No JSON, try download anyway
+ triggerDL();
+ }
+ });
},
downloadList: function(){
if(!Viewer.isList){
@@ -97,6 +146,23 @@ function copyText(text) {
return success;
}
+function loadCaptcha(){
+ grecaptcha.render("captcha_popup_captcha", {
+ sitekey: captchaKey,
+ theme: "dark",
+ callback: function(token){
+ document.getElementById("download_frame").src = "/api/file/" + Viewer.currentFile +
+ "?download&recaptcha_response="+token;
+
+ setTimeout(function(){
+ var popupDiv = document.getElementById("captcha_popup");
+ popupDiv.style.opacity = "0";
+ popupDiv.style.visibility = "hidden";
+ }, 1000)
+ }
+ });
+}
+
var DetailsWindow = {
visible: false,
popupDiv: document.getElementById("info_popup"),
diff --git a/res/static/style/layout.css b/res/static/style/layout.css
index 90ee469..236b09f 100644
--- a/res/static/style/layout.css
+++ b/res/static/style/layout.css
@@ -103,12 +103,13 @@ body{
font-family: "Lato Thin", sans-serif;
font-weight: bold;
font-size: 1.8em;
- transition: box-shadow 0.5s;
+ transition: box-shadow 2s;
}
.navigation a:hover {
background: linear-gradient(var(--highlight_color), var(--highlight_color_dark));
box-shadow: var(--highlight_border), 2px 2px 8px var(--shadow_color);
color: var(--highlight_text_color);
+ transition: box-shadow 0.5s;
text-decoration: none;
}
.navigation .icon {
diff --git a/res/static/style/viewer.css b/res/static/style/viewer.css
index ba2fba1..e0909fd 100644
--- a/res/static/style/viewer.css
+++ b/res/static/style/viewer.css
@@ -190,7 +190,6 @@ body{
/* =====================
|| MISC COMPONENTS ||
===================== */
-
.full_popup{
position: fixed;
visibility: hidden;
@@ -208,6 +207,28 @@ body{
box-shadow: var(--shadow_color) 0px 0px 50px;
z-index: 100;
}
+.captcha_popup{
+ position: fixed;
+ visibility: hidden;
+ opacity: 0;
+ transition: visibility 1s, opacity 1s, left 1s;
+ background-color: var(--background_color);
+ border-color: var(--accent_color_dark_border);
+ height: auto;
+ width: 450px;
+ max-width: 100%;
+ top: 10%;
+ left: 50%;
+ transform: translate(-50%, -10%);
+ padding: 0 10px;
+ box-sizing: border-box;
+ text-align: left;
+ box-shadow: var(--shadow_color) 0px 0px 50px;
+ z-index: 101;
+}
+#captcha_popup_captcha > div {
+ display: inline-block;
+}
table {width: auto !important;}
table > tbody > tr {border: none !important;}
diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html
index 99e1ea1..336c779 100644
--- a/res/template/file_viewer.html
+++ b/res/template/file_viewer.html
@@ -29,7 +29,10 @@
-
+
@@ -163,6 +166,12 @@
+
+
+
+
+
+
diff --git a/res/template/home.html b/res/template/home.html
index 8b3ac04..a1993fa 100644
--- a/res/template/home.html
+++ b/res/template/home.html
@@ -61,24 +61,36 @@
nobody will see it.
-
What cookies does pixeldrain use?
+
Does pixeldrain cost any money?
- When uploading a file pixeldrain will install a cookie named
- 'pduploads'. This cookie keeps a dot-separated list of all files
- you have uploaded anonymously in this browser. This cookie is
- only used for viewing your upload history.
-
-
- When logging in to a pixeldrain account a cookie named
- 'pd_auth_key' will be installed. This cookie keeps your login
- session active. When you delete it you will be logged out of
- your account.
-
-
- When you use the style selector at the bottom of this page a
- cookie called 'style' will be set. This cookie controls the
- appearance of the website for you.
+ No, pixeldrain is completely free at the moment. While there is
+ an advertisement on the file downloading page, it doesn't
+ generate nearly enough revenue to pay for maintaining this
+ service. That's why I'd really appreciate it if you could spare
+ some coins. Possible methods for donating are:
+ BasicAttentionToken: Donate BAT by clicking the BAT icon in
+ your address bar. If you don't have Brave browser yet you
+ can download it here:
+ Install Brave.
+ Installing and using Brave with this referral link also
+ counts as a 5$ donation.
+
+
+ Siacoin:
+ 26117c19ca3975b315d663dcbbc19cf9c07274f441689d4392ed380b2337589ef1aacfbdc93f
+ (this address points directly at the storage backend.
+ Donations will be used for paying storage contracts with Sia
+ hosts)
+
- No, pixeldrain is completely free at the moment. While there is
- an advertisement on the file downloading page, it doesn't
- generate nearly enough revenue to pay for maintaining this
- service. That's why I'd really appreciate it if you could spare
- some coins. Possible methods for donating are:
+ When uploading a file pixeldrain will install a cookie named
+ 'pduploads'. This cookie keeps a dot-separated list of all files
+ you have uploaded anonymously in this browser. This cookie is
+ only used for viewing your upload history.
+
+
+ When logging in to a pixeldrain account a cookie named
+ 'pd_auth_key' will be installed. This cookie keeps your login
+ session active. When you delete it you will be logged out of
+ your account.
+
+
+ When you use the style selector at the bottom of this page a
+ cookie called 'style' will be set. This cookie controls the
+ appearance of the website for you.
- Siacoin:
- 26117c19ca3975b315d663dcbbc19cf9c07274f441689d4392ed380b2337589ef1aacfbdc93f
- (this address points directly at the storage backend.
- Donations will be used for paying storage contracts with Sia
- hosts)
-