-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
182 additions
and
19 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
const BASE_HOST = "https://imageup.ru"; | ||
|
||
function Authenticate() { | ||
local login = ServerParams.getParam("Login"); | ||
local password = ServerParams.getParam("Password"); | ||
|
||
if(login == "" ) { | ||
WriteLog("error", "Login should not be empty!"); | ||
return 0; | ||
} | ||
|
||
nm.addQueryParam("login",login); | ||
nm.addQueryParam("password", password); | ||
nm.addQueryParam("username", login); | ||
nm.addQueryParam("autologin", "on"); | ||
nm.setUrl(BASE_HOST + "/login.html"); | ||
nm.doPost(""); | ||
|
||
if (nm.responseCode() == 200) { | ||
if (nm.responseBody().find("Добро пожаловать на сайт") != null) { | ||
return 1; | ||
} | ||
} | ||
WriteLog("error", "[imageup.ru] authentication failed."); | ||
|
||
return 0; | ||
} | ||
|
||
function UploadFile(fileName, options) { | ||
nm.doGet(BASE_HOST + "/"); | ||
local doc = Document(nm.responseBody()); | ||
local maxFileSize = doc.find("input[name=MAX_FILE_SIZE]").attr("value"); | ||
local fileFieldName = doc.find("input[type=file]").attr("name"); | ||
if (fileFieldName == "") { | ||
fileFieldName = "file2022"; | ||
} | ||
local timestamp = 0, token = ""; | ||
local captchaAnswer = ""; | ||
local reg = CRegExp("token'\\s*:\\s*'(.+?)'", "mi"); | ||
if (reg.match(nm.responseBody()) ) { | ||
token = reg.getMatch(1); | ||
} | ||
local reg2 = CRegExp("timestamp'\\s*:\\s*'(.+?)'", "mi"); | ||
if ( reg2.match(nm.responseBody()) ) { | ||
timestamp = reg2.getMatch(1); | ||
} | ||
|
||
local captchaUrl = doc.find("#captcha").attr("src"); | ||
if (captchaUrl != "") { | ||
if (captchaUrl.find("https://") == null) { | ||
captchaUrl = BASE_HOST + captchaUrl; | ||
} | ||
captchaAnswer = AskUserCaptcha(nm, captchaUrl); | ||
if (captchaAnswer == "") { | ||
return -1; | ||
} | ||
} | ||
|
||
nm.setUrl(BASE_HOST + "/"); | ||
nm.addQueryParam("MAX_FILE_SIZE", maxFileSize); | ||
nm.addQueryParamFile(fileFieldName, fileName, ExtractFileName(fileName), GetFileMimeType(fileName)); | ||
if (captchaAnswer != "") { | ||
nm.addQueryParam("captchatext", captchaAnswer); | ||
} | ||
|
||
nm.addQueryParam("makepreview", "on"); | ||
nm.addQueryParam("previewsize", "300"); | ||
nm.addQueryParam("textonpreview", "on"); | ||
nm.addQueryParam("textonpreview_opt", "1"); | ||
nm.addQueryParam("textonpreview_inp", ""); | ||
nm.addQueryParam("radiobox", "1"); | ||
nm.addQueryParam("usertext", ""); | ||
nm.addQueryParam("resize", "500"); | ||
nm.addQueryParam("rotate", "0"); | ||
|
||
nm.doUploadMultipartData(); | ||
|
||
if (nm.responseCode() == 200) { | ||
local doc2 = Document(nm.responseBody()); | ||
local viewUrl = doc2.find("#id8").attr("value"); | ||
local directUrl = doc2.find("#id7").attr("value"); | ||
local deleteUrl = doc2.find("#id_delete").attr("value"); | ||
local previewBbCode = doc2.find("#id3").attr("value"); | ||
local reg = CRegExp("\\[img\\](.+?)\\[/img\\]", "im"); | ||
local thumbUrl = ""; | ||
|
||
if (viewUrl != "" && viewUrl.find("https://") != 0) { | ||
viewUrl = "https://" + viewUrl; | ||
} | ||
|
||
options.setDirectUrl(directUrl); | ||
options.setViewUrl(viewUrl); | ||
options.setDeleteUrl(deleteUrl); | ||
|
||
if (reg.match(previewBbCode) ) { | ||
options.setThumbUrl(reg.getMatch(1)); | ||
} | ||
|
||
if (directUrl != "" || viewUrl != ""){ | ||
return 1; | ||
} else { | ||
WriteLog("error", "[imageup.ru] Failed to obtain image link"); | ||
} | ||
} else { | ||
WriteLog("error", "[imageup.ru] Failed to upload, response code = " + nm.responseCode()); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const BASE_HOST = "https://yapic.ru"; | ||
|
||
function UploadFile(fileName, options) { | ||
nm.doGet(BASE_HOST + "/"); | ||
if (nm.responseCode() != 200) { | ||
WriteLog("error", "[yapic.ru] Cannot obtain token!"); | ||
return 0; | ||
} | ||
local timestamp = 0, token = ""; | ||
local reg = CRegExp("token'\\s*:\\s*'(.+?)'", "mi"); | ||
if (reg.match(nm.responseBody()) ) { | ||
token = reg.getMatch(1); | ||
} | ||
local reg2 = CRegExp("timestamp'\\s*:\\s*'(.+?)'", "mi"); | ||
if ( reg2.match(nm.responseBody()) ) { | ||
timestamp = reg2.getMatch(1); | ||
} | ||
nm.setUrl(BASE_HOST + "/includes/upload.php"); | ||
nm.addQueryParamFile("Filedata", fileName, ExtractFileName(fileName), GetFileMimeType(fileName)); | ||
nm.addQueryParam("timestamp", timestamp); | ||
nm.addQueryParam("token", token); | ||
nm.doUploadMultipartData(); | ||
|
||
if (nm.responseCode() == 200) { | ||
local t = ParseJSON(nm.responseBody()); | ||
if ("success" in t && t.success) { | ||
options.setDirectUrl(t.preview); | ||
options.setViewUrl(t.url); | ||
if (t.url != ""){ | ||
return 1; | ||
} | ||
} | ||
} else { | ||
WriteLog("error", "[yapic.ru] Failed to upload, response code = " + nm.responseCode()); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters