<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Заливка файлов на failiem.lv]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=17681</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17681&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Заливка файлов на failiem.lv».]]></description>
		<lastBuildDate>Mon, 13 Mar 2023 08:48:31 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK: Заливка файлов на failiem.lv]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=157151#p157151</link>
			<description><![CDATA[<p>Размер файлов до 5 гигов.<br /></p><div class="codebox"><pre><code>path := &quot;D:\test.mp4&quot;

ComObjError(false)
HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
HTTP.Open(&quot;GET&quot;, &quot;https://failiem.lv&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
RegexMatch(HTTP.ResponseText, &quot;s)PHPSESSID=(.+?)&quot;&quot;&quot;, match)
phpsessid := match1

HTTP.Open(&quot;GET&quot;, &quot;https://failiem.lv/server_scripts/get_upload_id.php?show_add_key=1&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
RegexMatch(HTTP.ResponseText, &quot;s)(.+?),.+?,(.+?)$&quot;, match)
up_id := match1, key := match2

now := A_NowUTC
EnvSub, now,1970, seconds
now .= A_MSec
objParam := {file: [path]}
CreateFormData(PostData, hdr_ContentType, objParam)

HTTP.SetTimeouts(0, 0, 0, 0)
HTTP.Open(&quot;POST&quot;, &quot;https://free.failiem.lv/save_file.php?PHPSESSID=&quot; phpsessid &quot;&amp;up_id=&quot; up_id &quot;&amp;ignore_user_abort=1&amp;skip_update=1&amp;key=&quot; key &quot;&amp;v=&quot; now, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, hdr_ContentType)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send(PostData)
HTTP.WaitForResponse()
uploadedLink := &quot;https://failiem.lv/u/&quot; up_id

; проверка загрузки
HTTP.SetTimeouts(0, 60000, 30000, 30000)
HTTP.Open(&quot;GET&quot;, uploadedLink, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
if InStr(HTTP.ResponseText, &quot;tools_button_download&quot;)
   msgbox % clipboard := uploadedLink
else
   msgbox Error
return


; CreateFormData() by tmplinshi, AHK Topic: https://autohotkey.com/boards/viewtopic.php?t=7647
; Thanks to Coco: https://autohotkey.com/boards/viewtopic.php?p=41731#p41731
; Modified version by SKAN, 09/May/2016

CreateFormData(ByRef retData, ByRef retHeader, objParam) {
	New CreateFormData(retData, retHeader, objParam)
}

Class CreateFormData {

	__New(ByRef retData, ByRef retHeader, objParam) {

		Local CRLF := &quot;`r`n&quot;, i, k, v, str, pvData
		; Create a random Boundary
		Local Boundary := this.RandomBoundary()
		Local BoundaryLine := &quot;------------------------------&quot; . Boundary

    this.Len := 0 ; GMEM_ZEROINIT|GMEM_FIXED = 0x40
    this.Ptr := DllCall( &quot;GlobalAlloc&quot;, &quot;UInt&quot;,0x40, &quot;UInt&quot;,1, &quot;Ptr&quot;  )          ; allocate global memory

		; Loop input paramters
		For k, v in objParam
		{
			If IsObject(v) {
				For i, FileName in v
				{
					str := BoundaryLine . CRLF
					     . &quot;Content-Disposition: form-data; name=&quot;&quot;&quot; . k . &quot;&quot;&quot;; filename=&quot;&quot;&quot; . FileName . &quot;&quot;&quot;&quot; . CRLF
					     . &quot;Content-Type: &quot; . this.MimeType(FileName) . CRLF . CRLF
          this.StrPutUTF8( str )
          this.LoadFromFile( Filename )
          this.StrPutUTF8( CRLF )
				}
			} Else {
				str := BoundaryLine . CRLF
				     . &quot;Content-Disposition: form-data; name=&quot;&quot;&quot; . k &quot;&quot;&quot;&quot; . CRLF . CRLF
				     . v . CRLF
        this.StrPutUTF8( str )
			}
		}

		this.StrPutUTF8( BoundaryLine . &quot;--&quot; . CRLF )

    ; Create a bytearray and copy data in to it.
    retData := ComObjArray( 0x11, this.Len ) ; Create SAFEARRAY = VT_ARRAY|VT_UI1
    pvData  := NumGet( ComObjValue( retData ) + 8 + A_PtrSize )
    DllCall( &quot;RtlMoveMemory&quot;, &quot;Ptr&quot;,pvData, &quot;Ptr&quot;,this.Ptr, &quot;Ptr&quot;,this.Len )

    this.Ptr := DllCall( &quot;GlobalFree&quot;, &quot;Ptr&quot;,this.Ptr, &quot;Ptr&quot; )                   ; free global memory 

    retHeader := &quot;multipart/form-data; boundary=----------------------------&quot; . Boundary
	}

  StrPutUTF8( str ) {
    Local ReqSz := StrPut( str, &quot;utf-8&quot; ) - 1
    this.Len += ReqSz                                  ; GMEM_ZEROINIT|GMEM_MOVEABLE = 0x42
    this.Ptr := DllCall( &quot;GlobalReAlloc&quot;, &quot;Ptr&quot;,this.Ptr, &quot;UInt&quot;,this.len + 1, &quot;UInt&quot;, 0x42 )   
    StrPut( str, this.Ptr + this.len - ReqSz, ReqSz, &quot;utf-8&quot; )
  }
  
  LoadFromFile( Filename ) {
    Local objFile := FileOpen( FileName, &quot;r&quot; )
    this.Len += objFile.Length                     ; GMEM_ZEROINIT|GMEM_MOVEABLE = 0x42 
    this.Ptr := DllCall( &quot;GlobalReAlloc&quot;, &quot;Ptr&quot;,this.Ptr, &quot;UInt&quot;,this.len, &quot;UInt&quot;, 0x42 )
    objFile.RawRead( this.Ptr + this.Len - objFile.length, objFile.length )
    objFile.Close()       
  }

	RandomBoundary() {
		str := &quot;0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z&quot;
		Sort, str, D| Random
		str := StrReplace(str, &quot;|&quot;)
		Return SubStr(str, 1, 12)
	}

	MimeType(FileName) {
		n := FileOpen(FileName, &quot;r&quot;).ReadUInt()
		Return (n        = 0x474E5089) ? &quot;image/png&quot;
		     : (n        = 0x38464947) ? &quot;image/gif&quot;
		     : (n&amp;0xFFFF = 0x4D42    ) ? &quot;image/bmp&quot;
		     : (n&amp;0xFFFF = 0xD8FF    ) ? &quot;image/jpeg&quot;
		     : (n&amp;0xFFFF = 0x4949    ) ? &quot;image/tiff&quot;
		     : (n&amp;0xFFFF = 0x4D4D    ) ? &quot;image/tiff&quot;
		     : &quot;application/octet-stream&quot;
	}

}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=13605">Тема для обсуждения</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 13 Mar 2023 08:48:31 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=157151#p157151</guid>
		</item>
	</channel>
</rss>
