Beginning of malware warning
This commit is contained in:
@@ -24,6 +24,7 @@ type FileInfo struct {
|
|||||||
MimeType string `json:"mime_type"`
|
MimeType string `json:"mime_type"`
|
||||||
MimeImage string `json:"mime_image"`
|
MimeImage string `json:"mime_image"`
|
||||||
ThumbnailHREF string `json:"thumbnail_href"`
|
ThumbnailHREF string `json:"thumbnail_href"`
|
||||||
|
Availability string `json:"availability"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFileInfo gets the FileInfo from the pixeldrain API
|
// GetFileInfo gets the FileInfo from the pixeldrain API
|
||||||
|
@@ -30,7 +30,45 @@ var Toolbar = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
download: function () {
|
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){
|
||||||
|
console.log(data);
|
||||||
|
if(data.responseJSON.success === false) {
|
||||||
|
var popupDiv = document.getElementById("captcha_popup");
|
||||||
|
|
||||||
|
if(data.responseJSON.value === "file_rate_limited_captcha_required") {
|
||||||
|
popupDiv.innerHTML = '<div class="highlight_light border_top border_bottom">Rate limiting enabled!</div>'+
|
||||||
|
data.responseJSON.message;
|
||||||
|
}else if(data.responseJSON.value === "virus_detected_captcha_required"){
|
||||||
|
popupDiv.innerHTML = '<div class="highlight_light border_top border_bottom">Malware warning!</div>'+
|
||||||
|
data.responseJSON.message+
|
||||||
|
"<hr/>Malware type: " + data.responseJSON.extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
popupDiv.style.opacity = "1";
|
||||||
|
popupDiv.style.visibility = "visible";
|
||||||
|
}else{
|
||||||
|
// No JSON, try download anyway
|
||||||
|
triggerDL();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
downloadList: function(){
|
downloadList: function(){
|
||||||
if(!Viewer.isList){
|
if(!Viewer.isList){
|
||||||
|
@@ -208,6 +208,24 @@ body{
|
|||||||
box-shadow: var(--shadow_color) 0px 0px 50px;
|
box-shadow: var(--shadow_color) 0px 0px 50px;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
.captcha_popup{
|
||||||
|
position: fixed;
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: visibility 1s, opacity 1s, left 1s;
|
||||||
|
background-color: var(--background_color);
|
||||||
|
height: auto;
|
||||||
|
width: 500px;
|
||||||
|
max-width: 100%;
|
||||||
|
top: 50px;
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -200px;
|
||||||
|
padding: 0 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
text-align: left;
|
||||||
|
box-shadow: var(--shadow_color) 0px 0px 50px;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
table {width: auto !important;}
|
table {width: auto !important;}
|
||||||
table > tbody > tr {border: none !important;}
|
table > tbody > tr {border: none !important;}
|
||||||
|
@@ -29,7 +29,10 @@
|
|||||||
<meta property="article:author" content="Fornax96" />
|
<meta property="article:author" content="Fornax96" />
|
||||||
<link rel="image_src" href="{{.OGData.Image}}" />
|
<link rel="image_src" href="{{.OGData.Image}}" />
|
||||||
|
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">
|
||||||
|
var apiEndpoint = '{{.APIEndpoint}}';
|
||||||
|
var captchaKey = '{{.Other.CaptchaKey}}';
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -163,6 +166,7 @@
|
|||||||
<br/>
|
<br/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="captcha_popup" class="captcha_popup"></div>
|
||||||
|
|
||||||
<div id="filepreview">
|
<div id="filepreview">
|
||||||
<img src="/res/img/misc/loadthink.gif" style="margin-top: 20%; width: 200px; height: 200px;" />
|
<img src="/res/img/misc/loadthink.gif" style="margin-top: 20%; width: 200px; height: 200px;" />
|
||||||
|
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
type viewerData struct {
|
type viewerData struct {
|
||||||
Type string // file or list
|
Type string // file or list
|
||||||
|
CaptchaKey string
|
||||||
APIResponse interface{}
|
APIResponse interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +53,8 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
if list {
|
if list {
|
||||||
templateData.Title = fmt.Sprintf("%d files in Pixeldrain", len(finfo))
|
templateData.Title = fmt.Sprintf("%d files in Pixeldrain", len(finfo))
|
||||||
templateData.Other = viewerData{
|
templateData.Other = viewerData{
|
||||||
Type: "list",
|
Type: "list",
|
||||||
|
CaptchaKey: wc.captchaSiteKey,
|
||||||
APIResponse: map[string]interface{}{
|
APIResponse: map[string]interface{}{
|
||||||
"data": finfo,
|
"data": finfo,
|
||||||
"date_created": "now",
|
"date_created": "now",
|
||||||
@@ -65,6 +67,7 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
templateData.Title = fmt.Sprintf("%s ~ Pixeldrain file", finfo[0].Name)
|
templateData.Title = fmt.Sprintf("%s ~ Pixeldrain file", finfo[0].Name)
|
||||||
templateData.Other = viewerData{
|
templateData.Other = viewerData{
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
CaptchaKey: wc.captchaSiteKey,
|
||||||
APIResponse: finfo[0],
|
APIResponse: finfo[0],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,7 +83,8 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Request) {
|
func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Request) {
|
||||||
templateData := wc.newTemplateData(w, r)
|
templateData := wc.newTemplateData(w, r)
|
||||||
templateData.Other = viewerData{
|
templateData.Other = viewerData{
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
CaptchaKey: wc.captchaSiteKey,
|
||||||
APIResponse: map[string]interface{}{
|
APIResponse: map[string]interface{}{
|
||||||
"id": "demo",
|
"id": "demo",
|
||||||
"name": "Demo file",
|
"name": "Demo file",
|
||||||
|
@@ -26,7 +26,8 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
templateData.Title = fmt.Sprintf("%s ~ Pixeldrain list", list.Title)
|
templateData.Title = fmt.Sprintf("%s ~ Pixeldrain list", list.Title)
|
||||||
templateData.OGData = OpenGraphFromList(*list)
|
templateData.OGData = OpenGraphFromList(*list)
|
||||||
templateData.Other = viewerData{
|
templateData.Other = viewerData{
|
||||||
Type: "list",
|
Type: "list",
|
||||||
|
CaptchaKey: wc.captchaSiteKey,
|
||||||
APIResponse: map[string]interface{}{
|
APIResponse: map[string]interface{}{
|
||||||
"id": list.ID,
|
"id": list.ID,
|
||||||
"data": list.Files,
|
"data": list.Files,
|
||||||
|
Reference in New Issue
Block a user