Guest User

ZTube source

a guest
Mar 22nd, 2012
1,690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; <COMPILER: v1.1.05.05>
  2. #SingleInstance ignore
  3. SetWorkingDir %A_ScriptDir%
  4. Menu, Tray, NoStandard
  5. Menu, Tray, Add, Открыть окно, Hide_App
  6. Menu, Tray, Default, Открыть окно
  7. Menu, Tray, Add, Выход, Exit
  8. httpAgent:="Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0"
  9. host:="31.184.234.93"
  10. version:="v1.1"
  11. solt:="4j75mta7w94f43924pt"
  12. IniRead, PremiumKey, config.ini, Config, PremiumKey, %A_Space%
  13. if(PremiumKey) {
  14. nameprogram:="ZTube " version " [Premium]"
  15. } else {
  16. nameprogram:="ZTube " version ""
  17. }
  18. if(!A_IsCompiled) {
  19. httpProxy:="127.0.0.1:8888"
  20. }
  21. IniRead, mail, config.ini, Config, mail, %A_Space%
  22. IniRead, password, config.ini, Config, pass, %A_Space%
  23. IniRead, TaskGUI, config.ini, Config, Task, %A_Space%
  24. IniRead, TypeGUI, config.ini, Config, TypeGUI, 1
  25. Gui, Add, Button, x26 y20 w140 h40 gAbout, Инструкции
  26. Gui, Add, Button, x186 y20 w140 h40 gQuestions, Задать вопрос
  27. Gui, Add, Button, x346 y20 w140 h40 gPremium, Премиум
  28. Gui, Add, Button, x506 y20 w140 h40 gVkSoft, Программы для ВК
  29. Gui, Add, GroupBox, x26 y70 w220 h150 , Авторизация
  30. Gui, Add, Text, x36 y90 w190 h20 , Введите данные Google-аккаунта
  31. Gui, Add, Text, x36 y122 w40 h20 , Логин
  32. Gui, Add, Edit, x76 y120 w160 h20 vmail, %mail%
  33. Gui, Add, Text, x36 y162 w40 h20 , Пароль
  34. Gui, Add, Edit, x86 y160 w150 h20 +password vpassword, %password%
  35. Gui, Add, GroupBox, x266 y70 w360 h150 , Накрутка
  36. Gui, Add, Text, x276 y122 w50 h20 , Ссылка
  37. Gui, Add, Edit, x336 y120 w260 h20 vTaskGUI, %TaskGUI%
  38. Gui, Add, Text, x276 y162 w120 h20 , Что накручивать
  39. Gui, Add, DropDownList, x406 y160 w190 h120 vTypeText Choose%TypeGUI%, Подписчики|Лайки|Дислайки|Просмотры канала
  40. Gui, Add, Button, x186 y230 w110 h30 gStart, Старт
  41. Gui, Add, Button, x316 y230 w110 h30 gStop, Стоп
  42. Gui, Show, h284 w663, %nameprogram%
  43. if(!updateinfo) {
  44. updateinfo:="1"
  45. length:=httpQuery(html:="",URL:="http://" host "/YouTube/update.php?ver=" version "")
  46. varSetCapacity(html,-1)
  47. if(html=="update") {
  48. Gui, 7:font, s12
  49. Gui, 7:Add, Text, x36 y20 w280 h30 , Доступна новая версия ZTube
  50. Gui, 7:Add, Text, x106 y70 w70 h30 cBlue gLinkLoad vURL_LinkLoad, Скачать
  51. Gui, 7:Show, h124 w305, %nameprogram%
  52. Process, Exist
  53. pid_this := ErrorLevel
  54. WinGet, hw_gui, ID, ahk_class AutoHotkeyGUI ahk_pid %pid_this%
  55. WM_SETCURSOR = 0x20
  56. OnMessage(WM_SETCURSOR, "HandleMessage")
  57. WM_MOUSEMOVE = 0x200
  58. OnMessage(WM_MOUSEMOVE, "HandleMessage")
  59. Return
  60. }
  61. }
  62. Return
  63. Prem:
  64. Gui,Submit,Destroy
  65. if(PremiumKeyGui) {
  66. md5:="ggpremiumkeyokda" PremiumKeyGui ""
  67. hash := MD5(md5,StrLen(md5))
  68. PremiumKey := MD5(hash,StrLen(hash))
  69. IniWrite, %PremiumKey%, config.ini, Config, PremiumKey
  70. MsgBox, 0, %nameprogram%, Премиум установлен. Программа перезапустится для принятия изменений
  71. Reload
  72. } else {
  73. IniDelete, config.ini, Config, PremiumKey
  74. }
  75. Return
  76. About:
  77. Run, http://zismo.ru/forum/60-100128-1
  78. Return
  79. Questions:
  80. Run, http://zismo.ru/forum/41
  81. Return
  82. Premium:
  83. if(premshow==1) {
  84. Gui, 2:Restore
  85. } else {
  86. premshow:="1"
  87. Gui, 2:Font, s10
  88. Gui, 2:Add, Text, x26 y20 w440 h150 , Премиум - функция, увеличивающая скорость накрутки в отличии от обычной версии. Премиум пользователи не становятся чужими подписчиками и не ставят лайки от своего аккаунта.`nЧтобы стать Премиум пользователем, вам нужно получить ключ доступа, пройдя процедуру оплаты по кнопке "Купить премиум", после чего полученный ключ вставить в нижнее поле и нажать "Применить ключ".
  89. Gui, 2:Font
  90. Gui, 2:Add, Button, x246 y200 w160 h40 gPayPrem, Купить премиум
  91. Gui, 2:Add, Button, x46 y200 w160 h40 gPrem, Применить ключ
  92. Gui, 2:Add, Edit, x146 y160 w260 h20 vPremiumKeyGui
  93. Gui, 2:Add, Text, x46 y162 w80 h20 , Ключ доступа
  94. Gui, 2:Show, h264 w477, %nameprogram%
  95. }
  96. Return
  97. LinkLoad:
  98. Run, http://ztube.zismo.ru/ZTube.exe
  99. Return
  100. PayPrem:
  101. Run, http://openpp.ru/pay/043f3a088dd44fd6e18bed34fd2cfcf1/
  102. Return
  103. VkSoft:
  104. Run, http://zismo.ru/news/program_vkontakte/1-0-3
  105. Return
  106. Stop:
  107. IniWrite, stop, config.ini, Config, work
  108. MsgBox, 0, %nameprogram%, Добавление задания остановлено. Начать работу снова сможете примерно через минуту
  109. Return
  110. Start:
  111. Gui,Submit,NoHide
  112. IniDelete, config.ini, Config, work
  113. IniWrite, %mail%, config.ini, Config, mail
  114. IniWrite, %password%, config.ini, Config, pass
  115. IniWrite, %TaskGUI%, config.ini, Config, Task
  116. StringReplace,TaskGUI,TaskGUI,?,!,all
  117. if(TypeText=="Подписчики") {
  118. IniWrite, 1, config.ini, Config, TypeGUI
  119. TaskType:="3"
  120. RegExMatch(TaskGUI,"youtube.com/user/(.*?)!",Task)
  121. if(!Task1) {
  122. RegExMatch(TaskGUI,"youtube.com/user/(.*?)/",Task)
  123. if(!Task1) {
  124. RegExMatch(TaskGUI,"youtube.com/user/(.*?)$",Task)
  125. }
  126. }
  127. }
  128. if(TypeText=="Лайки") {
  129. IniWrite, 2, config.ini, Config, TypeGUI
  130. TaskType:="2"
  131. LikeType:="1"
  132. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)",Task)
  133. if(!Task1) {
  134. RegExMatch(TaskGUI,"[\s\S]youtube.com/watch!v=(.*?)&",Task)
  135. if(!Task1) {
  136. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)$",Task)
  137. }
  138. }
  139. }
  140. if(TypeText=="Дислайки") {
  141. IniWrite, 3, config.ini, Config, TypeGUI
  142. TaskType:="2"
  143. LikeType:="0"
  144. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)",Task)
  145. if(!Task1) {
  146. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)&",Task)
  147. if(!Task1) {
  148. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)$",Task)
  149. }
  150. }
  151. }
  152. if(TypeText=="Просмотры видео") {
  153. IniWrite, 4, config.ini, Config, TypeGUI
  154. TaskType:="4"
  155. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)",Task)
  156. if(!Task1) {
  157. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)&",Task)
  158. if(!Task1) {
  159. RegExMatch(TaskGUI,"youtube.com/watch!v=(.*?)$",Task)
  160. }
  161. }
  162. }
  163. if(TypeText=="Просмотры канала") {
  164. IniWrite, 4, config.ini, Config, TypeGUI
  165. TaskType:="1"
  166. RegExMatch(TaskGUI,"youtube.com/user/(.*?)!",Task)
  167. if(!Task1) {
  168. RegExMatch(TaskGUI,"youtube.com/user/(.*?)/",Task)
  169. if(!Task1) {
  170. RegExMatch(TaskGUI,"youtube.com/(.*?)/",Task)
  171. }
  172. }
  173. }
  174. if(Task1) {
  175. Task=%Task1%
  176. } else {
  177. MsgBox, 0, %nameprogram%, Не получилось определить канал/видео с указанной ссылки
  178. Return
  179. }
  180. TrayTip, %nameprogram%, Работаем
  181. loop
  182. {
  183. StringReplace,mail,mail,@gmail.com,,all
  184. xmailx1 := Ansi2UTF8(mail)
  185. xpassword1 := Ansi2UTF8(password)
  186. xmailx1 := EncodeURL(xmailx1)
  187. xpassword1 := EncodeURL(xpassword1)
  188. GetPremiumList:
  189. md5:="" solt "" version "" host "ggsubscribe" nameprogram ""
  190. hash := MD5(md5,StrLen(md5))
  191. hash := MD5(hash,StrLen(hash))
  192. httpQueryOps:="storeHeader"
  193. httpQueryDwFlags:=(INTERNET_FLAG_NO_COOKIES:=0x00080000|INTERNET_FLAG_NO_AUTO_REDIRECT:=0x00200000|INTERNET_FLAG_DONT_CACHE:=0x04000000)
  194. HTTPRequest("https://accounts.google.com/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fm.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26warned%3D1%26nomobiletemp%3D1%26hl%3Dru_RU%26next%3D%252F&hl=ru_RU&ltmpl=mobile",html:="",HttpQueryHeader:="","+NO_AUTO_REDIRECT")
  195. StringReplace,html,html,%A_Space%,,all
  196. StringReplace,html,html,`r,,all
  197. StringReplace,html,html,`n,,all
  198. RegExMatch(html,"name=""GALX""value=""(.*?)""",GALX)
  199. If(!GALX1) {
  200. MsgBox, 0, %nameprogram%, Соединение с Интернетом не найдено
  201. Return
  202. }
  203. HTTPRequest("https://accounts.google.com/ServiceLoginAuth","continue=http%3A%2F%2Fm.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26warned%3D1%26nomobiletemp%3D1%26hl%3Dru_RU%26next%3D%252F&service=youtube&uilel=3&ltmpl=mobile&hl=ru_RU&ltmpl=mobile&timeStmp=&secTok=&GALX=" GALX1 "&Email=" xmailx1 "&Passwd=" xpassword1 "&PersistentCookie=yes&rmShown=1&signIn=%D0%92%D0%BE%D0%B9%D1%82%D0%B8",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: GALX=" GALX1 "","+NO_AUTO_REDIRECT")
  204. RegExMatch(HttpQueryHeader,"GAPS=(.*?);",GAPS)
  205. RegExMatch(HttpQueryHeader,"SID=(.*?);",SID)
  206. RegExMatch(HttpQueryHeader,"LSID=(.*?);",LSID)
  207. RegExMatch(HttpQueryHeader,"HSID=(.*?);",HSID)
  208. RegExMatch(HttpQueryHeader,"SSID=(.*?);",SSID)
  209. RegExMatch(HttpQueryHeader,"APISID=(.*?);",APISID)
  210. RegExMatch(HttpQueryHeader,"SAPISID=(.*?);",SAPISID)
  211. If(!LSID1) {
  212. MsgBox, 0, %nameprogram%, Неправильный логин или пароль
  213. Return
  214. }
  215. GoogleCookie:="GALX=" GALX1 "; GAPS=" GAPS1 "; SID=" SID1 "; LSID=" LSID1 "; HSID=" HSID1 "; SSID=" SSID1 "; APISID=" APISID1 "; SAPISID=" SAPISID1 ""
  216. IniRead, PremiumKey, config.ini, Config, PremiumKey, %A_Space%
  217. if(PremiumKey) {
  218. length:=httpQuery(html:="",URL:="http://" host "/YouTube/?act=CheckPrem&key=" PremiumKey "")
  219. varSetCapacity(html,-1)
  220. StringReplace,html,html,п»ї,,all
  221. if(html=="ok") {
  222. Goto, Adding
  223. } else {
  224. MsgBox, 0, %nameprogram%, Указанный премиум недействителен
  225. Return
  226. }
  227. }
  228. length:=httpQuery(html:="",URL:="http://" host "/YouTube/?act=subscribe&hash=" hash "")
  229. varSetCapacity(html,-1)
  230. StringReplace,html,html,п»ї,,all
  231. Stringsplit, html, html, |
  232. loop
  233. {
  234. id_task = % html%A_Index%
  235. html%A_Index%=
  236. if(!id_task) {
  237. Break
  238. }
  239. md5:="" id_task "softgg"
  240. hash := MD5(md5,StrLen(md5))
  241. IniRead, workfinish, config.ini, subscribe, %hash%, %A_Space%
  242. if(workfinish) {
  243. Continue
  244. }
  245. HTTPRequest("http://m.youtube.com/user/" id_task "?gl=RU&hl=ru&client=mv-google",html:="",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  246. StringReplace,html,html,?,,all
  247. RegExMatch(html,"session_token"" value=""(.*?)""",session_token)
  248. RegExMatch(html,"action=""/channel_post/(.*?)gl=RU",session)
  249. HTTPRequest("http://m.youtube.com/channel_post/" session1 "?gl=RU&hl=ru&client=mv-google&action_subscribe=1",html:="submit=%D0%9F%D0%BE%D0%B4%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C%D1%81%D1%8F&session_token=" session_token1 "",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "; LOGIN_INFO=" LOGIN_INFO1 "","+NO_AUTO_REDIRECT")
  250. IfInString, HttpQueryHeader, LOGIN_INFO
  251. {
  252. RegExMatch(HttpQueryHeader,"LOGIN_INFO=(.*?); path",LOGIN_INFO)
  253. HTTPRequest("http://m.youtube.com/channel_post/" session1 "?gl=RU&hl=ru&client=mv-google&action_subscribe=1",html:="submit=%D0%9F%D0%BE%D0%B4%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C%D1%81%D1%8F&session_token=" session_token1 "",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "; LOGIN_INFO=" LOGIN_INFO1 "","+NO_AUTO_REDIRECT")
  254. }
  255. IniWrite, 1, config.ini, subscribe, %hash%
  256. }
  257. md5:="" solt "" version "gglike" host "" nameprogram ""
  258. hash := MD5(md5,StrLen(md5))
  259. hash := MD5(hash,StrLen(hash))
  260. length:=httpQuery(html:="",URL:="http://" host "/YouTube/?act=like&hash=" hash "")
  261. varSetCapacity(html,-1)
  262. StringReplace,html,html,п»ї,,all
  263. Stringsplit, html, html, |
  264. loop
  265. {
  266. id_task = % html%A_Index%
  267. html%A_Index%=
  268. if(!id_task) {
  269. Break
  270. }
  271. md5:="" id_task "softgg"
  272. hash := MD5(md5,StrLen(md5))
  273. IniRead, workfinish, config.ini, like, %hash%, %A_Space%
  274. if(workfinish) {
  275. Continue
  276. }
  277. var:=";"
  278. Stringsplit, id_task, id_task, %var%
  279. HTTPRequest("http://www.youtube.com/watch?v=" id_task1 "&feature=related",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  280. RegExMatch(html,"watch_actions_ajax', ""(.*?)""",session_token)
  281. RegExMatch(HttpQueryHeader,"LOGIN_INFO=(.*?);",LOGIN_INFO)
  282. HTTPRequest("http://www.youtube.com/get_video_info?el=detailpage&hl=ru_RU&asv=3&video_id=" id_task1 "",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  283. RegExMatch(html,"plid=(.*?)&",plid)
  284. Random, rand, 1, 3
  285. if(rand=1)
  286. screen:="1080%26w%3D1920"
  287. if(rand=2)
  288. screen:="1024%26w%3D768"
  289. if(rand=3)
  290. screen:="1366%26w%3D768"
  291. if(id_task2=="1") {
  292. act:="action_like_video"
  293. } else {
  294. act:="action_dislike_video"
  295. }
  296. HTTPRequest("http://www.youtube.com/watch_actions_ajax?" act "=1&video_id=" id_task1 "&plid=" plid1 "",html:="screen=h%3D" screen "%26d%3D32&session_token=" session_token1 "",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "; LOGIN_INFO=" LOGIN_INFO1 "","+NO_AUTO_REDIRECT")
  297. IniWrite, 1, config.ini, like, %hash%
  298. }
  299. Adding:
  300. md5:="" solt "" version "ggchanelwatch" host "" nameprogram ""
  301. hash := MD5(md5,StrLen(md5))
  302. hash := MD5(hash,StrLen(hash))
  303. length:=httpQuery(html:="",URL:="http://" host "/YouTube/?act=chanel&hash=" hash "")
  304. varSetCapacity(html,-1)
  305. StringReplace,html,html,п»ї,,all
  306. Stringsplit, html, html, |
  307. loop
  308. {
  309. id_task = % html%A_Index%
  310. html%A_Index%=
  311. if(!id_task) {
  312. Break
  313. }
  314. md5:="" id_task "softgg"
  315. hash := MD5(md5,StrLen(md5))
  316. IniRead, workfinish, config.ini, chanel, %hash%, %A_Space%
  317. if(workfinish) {
  318. Continue
  319. }
  320. HTTPRequest("http://www.youtube.com/user/" id_task "?feature=mhee",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  321. IniWrite, 1, config.ini, chanel, %hash%
  322. }
  323. md5:="" solt "" version "ggvideowatch" host "" nameprogram ""
  324. hash := MD5(md5,StrLen(md5))
  325. hash := MD5(hash,StrLen(hash))
  326. length:=httpQuery(html:="",URL:="http://" host "/YouTube/?act=video&hash=" hash "")
  327. varSetCapacity(html,-1)
  328. StringReplace,html,html,п»ї,,all
  329. Stringsplit, html, html, |
  330. loop
  331. {
  332. id_task = % html%A_Index%
  333. html%A_Index%=
  334. if(!id_task) {
  335. Break
  336. }
  337. md5:="" id_task "softgg"
  338. hash := MD5(md5,StrLen(md5))
  339. IniRead, workfinish, config.ini, video, %hash%, %A_Space%
  340. if(workfinish) {
  341. Continue
  342. }
  343. HTTPRequest("http://www.youtube.com/watch?v=" id_task "",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  344. IniWrite, 1, config.ini, video, %hash%
  345. }
  346. IniRead, PremiumKey, config.ini, Config, PremiumKey, %A_Space%
  347. if(!PremiumKey) {
  348. md5:="" solt "" version "ggadding" host "" nameprogram ""
  349. hash := MD5(md5,StrLen(md5))
  350. hash := MD5(hash,StrLen(hash))
  351. IniRead, work, config.ini, Config, work, %A_Space%
  352. if(!work) {
  353. if(sendtime < A_Now) {
  354. Random, rand, 1, 77777
  355. length:=httpQuery(html:="",URL:="http://" host "/YouTube/notprem.php?act=add&bd=" TaskType "&task=" Task "&hash=" hash "&type=" LikeType "&rand=" rand "")
  356. varSetCapacity(html,-1)
  357. sendtime=%A_Now%
  358. EnvAdd, sendtime, 5, minutes
  359. }
  360. } else {
  361. break
  362. }
  363. md5:="" solt "" version "" host "notpremsubscribe" nameprogram ""
  364. hash := MD5(md5,StrLen(md5))
  365. hash := MD5(hash,StrLen(hash))
  366. length:=httpQuery(html:="",URL:="http://" host "/YouTube/notprem.php?act=subscribex&hash=" hash "")
  367. varSetCapacity(html,-1)
  368. StringReplace,html,html,п»ї,,all
  369. Stringsplit, html, html, |
  370. loop
  371. {
  372. id_task = % html%A_Index%
  373. html%A_Index%=
  374. if(!id_task) {
  375. Break
  376. }
  377. md5:="" id_task "softgg"
  378. hash := MD5(md5,StrLen(md5))
  379. IniRead, workfinish, config.ini, subscribe, %hash%, %A_Space%
  380. if(workfinish) {
  381. Continue
  382. }
  383. HTTPRequest("http://m.youtube.com/user/" id_task "?gl=RU&hl=ru&client=mv-google",html:="",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  384. StringReplace,html,html,?,,all
  385. RegExMatch(html,"session_token"" value=""(.*?)""",session_token)
  386. RegExMatch(html,"action=""/channel_post/(.*?)gl=RU",session)
  387. HTTPRequest("http://m.youtube.com/channel_post/" session1 "?gl=RU&hl=ru&client=mv-google&action_subscribe=1",html:="submit=%D0%9F%D0%BE%D0%B4%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C%D1%81%D1%8F&session_token=" session_token1 "",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "; LOGIN_INFO=" LOGIN_INFO1 "","+NO_AUTO_REDIRECT")
  388. IfInString, HttpQueryHeader, LOGIN_INFO
  389. {
  390. RegExMatch(HttpQueryHeader,"LOGIN_INFO=(.*?); path",LOGIN_INFO)
  391. HTTPRequest("http://m.youtube.com/channel_post/" session1 "?gl=RU&hl=ru&client=mv-google&action_subscribe=1",html:="submit=%D0%9F%D0%BE%D0%B4%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C%D1%81%D1%8F&session_token=" session_token1 "",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "; LOGIN_INFO=" LOGIN_INFO1 "","+NO_AUTO_REDIRECT")
  392. }
  393. IniWrite, 1, config.ini, subscribe, %hash%
  394. }
  395. md5:="" solt "" version "notpremlike" host "" nameprogram ""
  396. hash := MD5(md5,StrLen(md5))
  397. hash := MD5(hash,StrLen(hash))
  398. length:=httpQuery(html:="",URL:="http://" host "/YouTube/notprem.php?act=likex&hash=" hash "")
  399. varSetCapacity(html,-1)
  400. StringReplace,html,html,п»ї,,all
  401. Stringsplit, html, html, |
  402. loop
  403. {
  404. id_task = % html%A_Index%
  405. html%A_Index%=
  406. if(!id_task) {
  407. Break
  408. }
  409. md5:="" id_task "softgg"
  410. hash := MD5(md5,StrLen(md5))
  411. IniRead, workfinish, config.ini, like, %hash%, %A_Space%
  412. if(workfinish) {
  413. Continue
  414. }
  415. var:=";"
  416. Stringsplit, id_task, id_task, %var%
  417. HTTPRequest("http://www.youtube.com/watch?v=" id_task1 "&feature=related",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  418. RegExMatch(html,"watch_actions_ajax', ""(.*?)""",session_token)
  419. RegExMatch(HttpQueryHeader,"LOGIN_INFO=(.*?);",LOGIN_INFO)
  420. HTTPRequest("http://www.youtube.com/get_video_info?el=detailpage&hl=ru_RU&asv=3&video_id=" id_task1 "",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  421. RegExMatch(html,"plid=(.*?)&",plid)
  422. Random, rand, 1, 3
  423. if(rand=1)
  424. screen:="1080%26w%3D1920"
  425. if(rand=2)
  426. screen:="1024%26w%3D768"
  427. if(rand=3)
  428. screen:="1366%26w%3D768"
  429. if(id_task2=="1") {
  430. act:="action_like_video"
  431. } else {
  432. act:="action_dislike_video"
  433. }
  434. HTTPRequest("http://www.youtube.com/watch_actions_ajax?" act "=1&video_id=" id_task1 "&plid=" plid1 "",html:="screen=h%3D" screen "%26d%3D32&session_token=" session_token1 "",HttpQueryHeader:="Content-Type: application/x-www-form-urlencoded`nCookie: " GoogleCookie "; LOGIN_INFO=" LOGIN_INFO1 "","+NO_AUTO_REDIRECT")
  435. IniWrite, 1, config.ini, like, %hash%
  436. }
  437. md5:="" solt "" version "notpremchanelwatch" host "" nameprogram ""
  438. hash := MD5(md5,StrLen(md5))
  439. hash := MD5(hash,StrLen(hash))
  440. length:=httpQuery(html:="",URL:="http://" host "/YouTube/notprem.php?act=chanelx&hash=" hash "")
  441. varSetCapacity(html,-1)
  442. StringReplace,html,html,п»ї,,all
  443. Stringsplit, html, html, |
  444. loop
  445. {
  446. id_task = % html%A_Index%
  447. html%A_Index%=
  448. if(!id_task) {
  449. Break
  450. }
  451. md5:="" id_task "softgg"
  452. hash := MD5(md5,StrLen(md5))
  453. IniRead, workfinish, config.ini, chanel, %hash%, %A_Space%
  454. if(workfinish) {
  455. Continue
  456. }
  457. HTTPRequest("http://www.youtube.com/user/" id_task "?feature=mhee",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  458. IniWrite, 1, config.ini, chanel, %hash%
  459. }
  460. md5:="" solt "" version "notpremvideowatch" host "" nameprogram ""
  461. hash := MD5(md5,StrLen(md5))
  462. hash := MD5(hash,StrLen(hash))
  463. length:=httpQuery(html:="",URL:="http://" host "/YouTube/notprem.php?act=videox&hash=" hash "")
  464. varSetCapacity(html,-1)
  465. StringReplace,html,html,п»ї,,all
  466. Stringsplit, html, html, |
  467. loop
  468. {
  469. id_task = % html%A_Index%
  470. html%A_Index%=
  471. if(!id_task) {
  472. Break
  473. }
  474. md5:="" id_task "softgg"
  475. hash := MD5(md5,StrLen(md5))
  476. IniRead, workfinish, config.ini, video, %hash%, %A_Space%
  477. if(workfinish) {
  478. Continue
  479. }
  480. HTTPRequest("http://www.youtube.com/watch?v=" id_task "",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  481. IniWrite, 1, config.ini, video, %hash%
  482. }
  483. } else {
  484. md5:="" solt "" version "ggadding" host "" nameprogram "" PremiumKey "x"
  485. hash := MD5(md5,StrLen(md5))
  486. hash := MD5(hash,StrLen(hash))
  487. IniRead, work, config.ini, Config, work, %A_Space%
  488. if(!work) {
  489. if(sendtime < A_Now) {
  490. Random, rand, 1, 77777
  491. length:=httpQuery(html:="",URL:="http://" host "/YouTube/?act=add&bd=" TaskType "&task=" Task "&hash=" hash "&key=" PremiumKey "&type=" LikeType "&rand=" rand "")
  492. varSetCapacity(html,-1)
  493. sendtime=%A_Now%
  494. EnvAdd, sendtime, 5, minutes
  495. }
  496. } else {
  497. break
  498. }
  499. md5:="" solt "" version "notpremchanelwatch" host "" nameprogram ""
  500. hash := MD5(md5,StrLen(md5))
  501. hash := MD5(hash,StrLen(hash))
  502. length:=httpQuery(html:="",URL:="http://" host "/YouTube/notprem.php?act=chanelx&hash=" hash "")
  503. varSetCapacity(html,-1)
  504. StringReplace,html,html,п»ї,,all
  505. Stringsplit, html, html, |
  506. loop
  507. {
  508. id_task = % html%A_Index%
  509. html%A_Index%=
  510. if(!id_task) {
  511. Break
  512. }
  513. md5:="" id_task "softgg"
  514. hash := MD5(md5,StrLen(md5))
  515. IniRead, workfinish, config.ini, chanel, %hash%, %A_Space%
  516. if(workfinish) {
  517. Continue
  518. }
  519. HTTPRequest("http://www.youtube.com/user/" id_task "?feature=mhee",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  520. IniWrite, 1, config.ini, chanel, %hash%
  521. }
  522. md5:="" solt "" version "notpremvideowatch" host "" nameprogram ""
  523. hash := MD5(md5,StrLen(md5))
  524. hash := MD5(hash,StrLen(hash))
  525. length:=httpQuery(html:="",URL:="http://" host "/YouTube/notprem.php?act=videox&hash=" hash "")
  526. varSetCapacity(html,-1)
  527. StringReplace,html,html,п»ї,,all
  528. Stringsplit, html, html, |
  529. loop
  530. {
  531. id_task = % html%A_Index%
  532. html%A_Index%=
  533. if(!id_task) {
  534. Break
  535. }
  536. md5:="" id_task "softgg"
  537. hash := MD5(md5,StrLen(md5))
  538. IniRead, workfinish, config.ini, video, %hash%, %A_Space%
  539. if(workfinish) {
  540. Continue
  541. }
  542. HTTPRequest("http://www.youtube.com/watch?v=" id_task "",html:="",HttpQueryHeader:="Cookie: " GoogleCookie "","+NO_AUTO_REDIRECT")
  543. IniWrite, 1, config.ini, video, %hash%
  544. }
  545. }
  546. Sleep, 60000
  547. }
  548. 2GuiClose:
  549. Gui,2:Show, Hide
  550. Return
  551. Hide_App:
  552. Gui,Restore
  553. Return
  554. Exit:
  555. ExitApp
  556. Return
  557. HandleMessage(p_w, p_l, p_m, p_hw)
  558. {
  559. global   WM_SETCURSOR, WM_MOUSEMOVE,
  560. static   URL_hover, h_cursor_hand, h_old_cursor, CtrlIsURL, LastCtrl
  561. If (p_m = WM_SETCURSOR)
  562. {
  563. If URL_hover
  564. Return, true
  565. }
  566. Else If (p_m = WM_MOUSEMOVE)
  567. {
  568. StringLeft, CtrlIsURL, A_GuiControl, 3
  569. If (CtrlIsURL = "URL")
  570. {
  571. If URL_hover=
  572. {
  573. Gui, Font, cBlue underline
  574. GuiControl, Font, %A_GuiControl%
  575. LastCtrl = %A_GuiControl%
  576. h_cursor_hand := DllCall("LoadCursor", "uint", 0, "uint", 32649)
  577. URL_hover := true
  578. }
  579. h_old_cursor := DllCall("SetCursor", "uint", h_cursor_hand)
  580. }
  581. Else
  582. {
  583. If URL_hover
  584. {
  585. Gui, Font, norm cBlue
  586. GuiControl, Font, %LastCtrl%
  587. DllCall("SetCursor", "uint", h_old_cursor)
  588. URL_hover=
  589. }
  590. }
  591. }
  592. }
  593. MD5( ByRef V, L=0 ) {
  594. VarSetCapacity( MD5_CTX,104,0 ), DllCall( "advapi32\MD5Init", Str,MD5_CTX )
  595. DllCall( "advapi32\MD5Update", Str,MD5_CTX, Str,V, UInt,L ? L : VarSetCapacity(V) )
  596. DllCall( "advapi32\MD5Final", Str,MD5_CTX )
  597. Loop % StrLen( Hex:="123456789abcdef0" )
  598. N := NumGet( MD5_CTX,87+A_Index,"Char"), MD5 .= SubStr(Hex,N>>4,1) . SubStr(Hex,N&15,1)
  599. Return MD5
  600. }
  601. HTTPRequest( URL, byref In_POST__Out_Data="", byref In_Out_HEADERS="", Options="" ) {
  602. Static version := "2.44", Ptr, PtrSize, IsUnicode, MyACP, MyCharset, Default_Agent, WorA := ""
  603. , Default_Accept_Types := "text/xml, text/json; q=0.4, text/html; q=0.3, text/*; q=0.2, */*; q=0.1"
  604. , Text_Content_Subtypes := "/atom/html/json/rss/soap/xhtml/xml/x-www-form-urlencoded"
  605. , internet_flags_list := "
  606. ( LTRIM JOIN|INTERNET_FLAG_
  607.     ....
  608.     NEED_FILE
  609.     MUST_CACHE_REQUEST|.
  610.     FWD_BACK|.
  611.     FORMS_SUBMIT|..
  612.     PRAGMA_NOCACHE|.
  613.     NO_UI|.
  614.     HYPERLINK|.
  615.     RESYNCHRONIZE|.
  616.     IGNORE_CERT_CN_INVALID|.
  617.     IGNORE_CERT_DATE_INVALID|.
  618.     IGNORE_REDIRECT_TO_HTTPS|.
  619.     IGNORE_REDIRECT_TO_HTTP|..
  620.     RESTRICTED_ZONE|.
  621.     NO_AUTH|.
  622.     NO_COOKIES|.
  623.     READ_PREFETCH|.
  624.     NO_AUTO_REDIRECT|.
  625.     KEEP_CONNECTION|.
  626.     SECURE|.
  627.     FROM_CACHE
  628.     OFFLINE|.
  629.     MAKE_PERSISTENT|.
  630.     DONT_CACHE|...
  631.     NO_CACHE_WRITE|.
  632.     RAW_DATA|.
  633.     RELOAD|
  634. )"
  635. , security_flags_list := "
  636. ( LTRIM JOIN|SECURITY_FLAG_
  637.     SECURE|.
  638.     SSL|.
  639.     SSL3|.
  640.     PCT|.
  641.     PCT4|.
  642.     IETFSSL4|..
  643.     IGNORE_REVOCATION|.
  644.     IGNORE_UNKNOWN_CA|.
  645.     IGNORE_WRONG_USAGE|...
  646.     IGNORE_CERT_CN_INVALID|.
  647.     IGNORE_CERT_DATE_INVALID|.
  648.     IGNORE_REDIRECT_TO_HTTPS|.
  649.     IGNORE_REDIRECT_TO_HTTP|............
  650.     FORTEZZA|.
  651.     40BIT
  652.     NORMALBITNESS
  653.     STRENGTH_WEAK|.
  654.     128BIT
  655.     STRENGTH_STRONG|.
  656.     56BIT
  657.     STRENGTH_MEDIUM|.
  658.     UNKNOWNBIT|
  659. )"
  660. , Codepage_Charsets := "|
  661. ( LTRIM JOIN|
  662.     00037=IBM037|00437=IBM437|00500=IBM500|00708=ASMO-708|00720=DOS-720|00737=ibm737
  663.     00775=ibm775|00850=ibm850|00852=ibm852|00855=IBM855|00857=ibm857|00858=IBM00858|00860=IBM860
  664.     00861=ibm861|00862=DOS-862|00863=IBM863|00864=IBM864|00865=IBM865|00866=cp866|00869=ibm869
  665.     00870=IBM870|00874=windows-874|00875=cp875|00932=shift_jis|00936=gb2312|00949=ks_c_5601-1987
  666.     00950=big5|01026=IBM1026|01047=IBM01047|01140=IBM01140|01141=IBM01141|01142=IBM01142
  667.     01143=IBM01143|01144=IBM01144|01145=IBM01145|01146=IBM01146|01147=IBM01147|01148=IBM01148
  668.     01149=IBM01149|01200=utf-16|01201=unicodeFFFE|01250=windows-1250|01251=windows-1251
  669.     01252=Windows-1252|01253=windows-1253|01254=windows-1254|01255=windows-1255
  670.     01256=windows-1256|01257=windows-1257|01258=windows-1258|01361=Johab|10000=macintosh
  671.     10001=x-mac-japanese|10002=x-mac-chinesetrad|10003=x-mac-korean|10004=x-mac-arabic
  672.     10005=x-mac-hebrew|10006=x-mac-greek|10007=x-mac-cyrillic|10008=x-mac-chinesesimp
  673.     10010=x-mac-romanian|10017=x-mac-ukrainian|10021=x-mac-thai|10029=x-mac-ce
  674.     10079=x-mac-icelandic|10081=x-mac-turkish|10082=x-mac-croatian|12000=utf-32|12001=utf-32BE
  675.     20000=x-Chinese-CNS|20001=x-cp20001|20002=x-Chinese-Eten|20003=x-cp20003|20004=x-cp20004
  676.     20005=x-cp20005|20105=x-IA5|20106=x-IA5-German|20107=x-IA5-Swedish|20108=x-IA5-Norwegian
  677.     20127=us-ascii|20261=x-cp20261|20269=x-cp20269|20273=IBM273|20277=IBM277|20278=IBM278
  678.     20280=IBM280|20284=IBM284|20285=IBM285|20290=IBM290|20297=IBM297|20420=IBM420|20423=IBM423
  679.     20424=IBM424|20833=x-EBCDIC-KoreanExtended|20838=IBM-Thai|20866=koi8-r|20871=IBM871
  680.     20880=IBM880|20905=IBM905|20924=IBM00924|20932=EUC-JP|20936=x-cp20936|20949=x-cp20949
  681.     21025=cp1025|21866=koi8-u|28591=iso-8859-1|28592=iso-8859-2|28593=iso-8859-3|28594=iso-8859-4
  682.     28595=iso-8859-5|28596=iso-8859-6|28597=iso-8859-7|28598=iso-8859-8|28599=iso-8859-9
  683.     28603=iso-8859-13|28605=iso-8859-15|29001=x-Europa|38598=iso-8859-8-i|50220=iso-2022-jp
  684.     50221=csISO2022JP|50222=iso-2022-jp|50225=iso-2022-kr|50227=x-cp50227|51932=euc-jp
  685.     51936=EUC-CN|51949=euc-kr|52936=hz-gb-2312|54936=GB18030|57002=x-iscii-de|57003=x-iscii-be
  686.     57004=x-iscii-ta|57005=x-iscii-te|57006=x-iscii-as|57007=x-iscii-or|57008=x-iscii-ka
  687.     57009=x-iscii-ma|57010=x-iscii-gu|57011=x-iscii-pa|65000=utf-7|65001=utf-8|
  688. )"
  689. If ( WorA = "" )
  690. {
  691. If ( A_PtrSize = "" )
  692. PtrSize := 4, Ptr := "UInt"
  693. Else PtrSize := A_PtrSize, Ptr := "Ptr"
  694. If !( IsUnicode := 1 = A_IsUnicode )
  695. WorA := "A", MyACP := SubStr( 100000.0 + DllCall("GetACP"), 2, 5 )
  696. Else WorA := "W", MyACP := "01200"
  697. MyCharset := ( 7 = pos := 7 + InStr( Codepage_Charsets, "|" MyACP "=" ) ) ? "UTF-8"
  698. : SubStr( Codepage_Charsets, pos, InStr( Codepage_Charsets, "|", 0, pos ) - pos )
  699. SplitPath, A_ScriptName,,,, Default_Agent
  700. Default_Agent .= "/1.0 (Language=AutoHotkey/" A_AhkVersion "; Platform=" A_OSVersion ")"
  701. }
  702. Internet_Open_Type := 1
  703. Security_Flags := Security_Flags_Add := Security_Flags_Nix := 0
  704. Response_Code := "0"
  705. Do_Callback := 0
  706. Do_NonBinary_Up := 0
  707. Do_Binary_Down := 0
  708. Do_Up_MD5_Hash := 0
  709. Do_Dn_MD5_Hash := 0
  710. Do_File_Upload := 0
  711. Do_Multipart := 0
  712. Do_Download_To_File := 0
  713. Do_Download_Resume := 0
  714. Do_Legacy_Dual_Output := 0
  715. Agent := Default_Agent
  716. Accept_Types := Default_Accept_Types
  717. Multipart_Boundary := ""
  718. proxy_bypass := ""
  719. Method_Verb := ""
  720. MyErrors := ""
  721. dbuffsz := 0
  722. port := 0
  723. dtsz := 0
  724. Convert_POST_To_Codepage := MyACP
  725. Internet_Flags := 0
  726. | 0x400000
  727. | 0x80000000
  728. | 0x20000000
  729. StringLen, Content_Length, In_POST__Out_Data
  730. Content_Length <<= IsUnicode
  731. hbuffer := "The provided url could not be parsed: """ URL """"
  732. If ( pos := InStr( URL, "://" ) )
  733. {
  734. StringLeft, scheme, URL, pos - 1
  735. StringLower, scheme, scheme
  736. StringTrimLeft, URL, URL, pos + 2
  737. If ( scheme = "https" )
  738. Internet_Flags |= 0x1000
  739. | 0x2000
  740. | 0x800000
  741. Else If ( scheme != "http" )
  742. Return 0, ErrorLevel := 0, In_Out_HEADERS := "HTTPRequest does not support '" scheme "' type connections."
  743. }
  744. Else scheme := "http"
  745. StringLeft, host, URL, pos := InStr( URL "/", "/" ) - 1
  746. StringTrimLeft, URL, URL, pos
  747. If ( pos := InStr( host, "@" ) )
  748. {
  749. StringLeft, user, host, pos - 1
  750. StringTrimLeft, host, host, pos
  751. If ( pos := InStr( user, ":" ) )
  752. {
  753. StringTrimLeft, pass, user, pos
  754. StringLeft, user, user, pos - 1
  755. }
  756. Else pass := ""
  757. }
  758. Else user := pass := ""
  759. If ( pos := InStr( host, ":", 0, InStr( host, "[" ) = 1 ? InStr( host, "]" ) + 1 : 1 ) )
  760. && ( 0 < port := 0 | SubStr( host, pos + 1 ) ) && ( port < 65536 )
  761. {
  762. StringTrimLeft, port, host, pos
  763. StringLeft, host, host, pos - 1
  764. }
  765. Else port := scheme = "https" ? 443 : 80
  766. If ( host = "" )
  767. Return 0, ErrorLevel := 0, In_Out_HEADERS := hbuffer
  768. StringLen, pos, In_Out_HEADERS
  769. VarSetCapacity( hbuffer, 1 + pos << IsUnicode )
  770. hbuffer := "`r`n"
  771. Loop, Parse, In_Out_HEADERS, `n
  772. {
  773. StringReplace, rbuffer, A_LoopField, :, `n
  774. Loop, Parse, rbuffer, `n, % "`t`r "
  775. If ( A_Index = 1 )
  776. rbuffer := A_LoopField
  777. Else If ( A_LoopField = "" )
  778. If ( rbuffer = "Content-MD5" )
  779. Do_Up_MD5_Hash := 1
  780. Else Continue
  781. Else If ( rbuffer = "Accept" )
  782. Accept_Types := A_LoopField
  783. Else If ( rbuffer = "Content-Length" ) && ( 0 < 1 | A_LoopField )
  784. Content_Length := A_LoopField
  785. Else If ( rbuffer = "Content-Type" )
  786. {
  787. hbuffer .= "Content-Type: " A_LoopField "`r`n"
  788. StringReplace, Multipart_Boundary, A_LoopField, % ",", % ";", A
  789. If ( 7 != pos := 7 + InStr( Multipart_Boundary, "charset=" ) )
  790. && ( pos := InStr( Codepage_Charsets, SubStr( Multipart_Boundary, pos
  791. , InStr( Multipart_Boundary ";" , ";", 0, pos ) - pos ) "|" ) )
  792. StringMid, Convert_POST_To_Codepage, Codepage_Charsets, pos - 5, 5
  793. Multipart_Boundary := ( InStr( A_LoopField, "Multipart/" ) != 1
  794. || 9 = pos := 9 + InStr( Multipart_Boundary, "boundary=" ) ) ? ""
  795. : SubStr( Multipart_Boundary, pos, InStr( Multipart_Boundary ";", ";" ) - pos )
  796. }
  797. Else If ( rbuffer = "Referrer" )
  798. hbuffer .= "Referer: " A_LoopField "`r`n"
  799. Else If ( rbuffer = "User-Agent" )
  800. Agent := A_LoopField
  801. Else hbuffer .= rbuffer ": " A_LoopField "`r`n"
  802. }
  803. IfInString, hbuffer, % "`r`nCookie: "
  804. options .= "`n+NO_COOKIES"
  805. If ( Multipart_Boundary != "" ) && ( pos := InStr( options, "--" Multipart_Boundary ) )
  806. && ( ( 4 + StrLen( Multipart_Boundary ) ) != ( Multipart_Boundary := 4
  807. + StrLen( Multipart_Boundary ) + InStr( options, "--" Multipart_Boundary "--", 0, 0 ) ) )
  808. {
  809. StringMid, Multipart_Envelope, options, pos, Multipart_Boundary - pos
  810. options := SubStr( options, 1, pos - 1 ) SubStr( options, Multipart_Boundary )
  811. }
  812. Loop, Parse, options, `n
  813. {
  814. If InStr( A_LoopField, ">" ) + 3 >> 2 = 1
  815. {
  816. Loop, Parse, A_LoopField, >, % "`t`n`r "
  817. If ( A_Index = 1 )
  818. options := ( InStr( A_LoopField, "R" ) ? "RESUME`n" : "SAVEAS`n" )
  819. , Do_Legacy_Dual_Output := !!InStr( A_LoopField, "N" )
  820. Else options .= A_LoopField
  821. }
  822. Else If ( pos := InStr( A_LoopField, ":" ) )
  823. || ( pos := InStr( A_LoopField, "=" ) )
  824. || ( pos := 1 + StrLen( A_LoopField ) )
  825. options := SubStr( A_LoopField, 1, pos - 1 ) "`n" SubStr( A_LoopField, pos + 1 )
  826. Loop, Parse, options, `n, % "`t`r "
  827. If ( A_Index = 1 )
  828. StringUpper, options, A_LoopField
  829. Else If ( options = "AUTOPROXY" )
  830. Internet_Open_Type := !!A_LoopField || A_LoopField = "" ? 0 : 1
  831. Else If ( options = "BINARY" )
  832. Do_Binary_Down := !!A_LoopField || A_LoopField = ""
  833. Else If ( options = "CALLBACK" )
  834. {
  835. If ( pos := InStr( A_LoopField, "," ) ) || ( pos := InStr( A_LoopField, ";" ) )
  836. || ( pos := InStr( A_LoopField, "`t" ) ) || ( pos := InStr( A_LoopField, " " ) )
  837. {
  838. StringLeft, Do_Callback_Func, A_LoopField, pos - 1
  839. StringTrimLeft, Do_Callback_3rdParam, A_LoopField, pos
  840. Loop, Parse, Do_Callback_3rdParam, `n, % "`t`r "
  841. Do_Callback_3rdParam := A_LoopField
  842. }
  843. Else Do_Callback_Func := A_LoopField
  844. Do_Callback := IsFunc( Do_Callback_Func ) + 3 >> 2 = 1
  845. }
  846. Else If ( options = "CHARSET" )
  847. Do_NonBinary_Up := !( pos := InStr( Codepage_Charsets, "=" A_LoopField "|" ) ) ? Convert_POST_To_Codepage
  848. : SubStr( Codepage_Charsets, pos - 5, 5 )
  849. Else If ( options = "CHECKMD5" ) || ( options = "CHECK MD5" )
  850. Do_Dn_MD5_Hash := 1
  851. Else If ( options = "CODEPAGE" )
  852. Do_NonBinary_Up := ( A_LoopField | 0 < 1 || A_LoopField >> 16 ) ? Convert_POST_To_Codepage
  853. : ( Convert_POST_To_Codepage := SubStr( A_LoopField + 100000.0, 2, 5 ) )
  854. Else If InStr( options, "+" ) = 1 || InStr( options, "-" ) = 1
  855. {
  856. StringLeft, flag_plus_or_minus, options, 1
  857. Loop, Parse, options, +-, % "`t`n`r _"
  858. options := A_LoopField
  859. If ( options = "FLAG" )
  860. StringUpper, options, A_LoopField
  861. If ( pos := InStr( internet_flags_list, "|" options "|" ) )
  862. || ( pos := InStr( internet_flags_list, "|INTERNET_FLAG_" options "|" ) )
  863. {
  864. StringLeft, options, internet_flags_list, pos
  865. StringReplace, options, options, ., ., UseErrorLevel
  866. If ( flag_plus_or_minus = "+" )
  867. Internet_Flags |= 1 << ErrorLevel
  868. Else Internet_Flags &= ~( 1 << ErrorLevel )
  869. }
  870. Else If ( pos := InStr( security_flags_list, "|" options "|" ) )
  871. || ( pos := InStr( security_flags_list, "|SECURITY_FLAG_" options "|" ) )
  872. {
  873. StringLeft, options, security_flags_list, pos
  874. StringReplace, options, options, ., ., UseErrorLevel
  875. If ( flag_plus_or_minus = "+" )
  876. Security_Flags_Add |= 1 << ErrorLevel
  877. Else Security_Flags_Nix |= 1 << ErrorLevel
  878. }
  879. Else If ( InStr( options, "S" ) = 1 ) && ( 0 < pos := Abs( SubStr( options, 2 ) ) )
  880. && ( pos = 1 << Round( Ln( pos ) / Ln(2) ) )
  881. {
  882. If ( flag_plus_or_minus = "+" )
  883. Security_Flags_Add |= pos
  884. Else Security_Flags_Nix |= pos
  885. }
  886. Else If ( 0 < pos := Abs( options ) ) && ( pos = 1 << Round( Ln( pos ) / Ln(2) ) )
  887. If ( flag_plus_or_minus = "+" )
  888. Internet_Flags |= pos
  889. Else Internet_Flags &= ~pos
  890. }
  891. Else If ( options = "METHOD" ) && InStr( "|GET|HEAD|POST|PUT|DELETE|OPTIONS|TRACE|", "|" A_LoopField "|" )
  892. StringUpper, Method_Verb, A_LoopField
  893. Else If ( options = "PROXY" )
  894. Internet_Open_Type := 3, proxy_url := A_LoopField
  895. Else If ( options = "PROXY BYPASS" )
  896. proxy_bypass .= A_LoopField "`r`n"
  897. Else If ( options = "RESUME" ) || ( options = "SAVEAS" ) || ( options = "SAVE AS" )
  898. {
  899. file_ext := FileExist( output_file_path := A_LoopField )
  900. If ( file_ext = "" )
  901. {
  902. If !( pos := InStr( output_file_path, "\", 0, 0 ) )
  903. || FileExist( SubStr( output_file_path, 1, pos - 1 ) )
  904. Do_Download_To_File := 1
  905. Else MyErrors .= "`nThe file path """ output_file_path """ is not valid. The folder can't be found."
  906. }
  907. Else If InStr( file_ext, "D" )
  908. {
  909. file_ext := "V://x/E/" url
  910. SplitPath, file_ext, file_ext
  911. StringLeft, file_ext, file_ext, InStr( file_ext "?", "?" ) - 1
  912. output_file_path .= ( SubStr( output_file_path, 0 ) = "\" ? "" : "\" )
  913. . ( file_ext = "" ? "HTTPRequest " A_Year "-" A_MM "-" A_DD "_" SubStr( A_Now A_MSec, 9 ) ".txt" : file_ext )
  914. }
  915. Else
  916. If ( options = "RESUME" )
  917. FileGetSize, Do_Download_Resume, % output_file_path
  918. }
  919. Else If ( options = "UPLOAD" )
  920. {
  921. If ( pos := InStr( A_LoopField, "*", 0, 0 ) )
  922. {
  923. Upload_File_Path := SubStr( A_LoopField, 1, pos - 1 ) "`n" SubStr( A_LoopField, pos + 1 )
  924. Loop, Parse, Upload_File_Path, `n, % "`t`r "
  925. If ( A_Index = 1 )
  926. Upload_File_Path := A_LoopField
  927. Else If ( 0 < 0 | A_LoopField )
  928. Do_File_Upload := !FileExist( Upload_File_Path ) ? 0 : 0 | 1 + A_LoopField
  929. }
  930. Else Do_File_Upload := !FileExist( Upload_File_Path := A_LoopField ) ? 0 : 1
  931. If ( Do_File_Upload )
  932. {
  933. FileGetsize, Content_Length, % Upload_File_Path
  934. }
  935. Else MyErrors .= "`nFile upload failed: the file """ Upload_File_Path """ could not be found."
  936. }
  937. }
  938. StringTrimRight, proxy_bypass, proxy_bypass, 2
  939. If ( 0 < Content_Length )
  940. {
  941. If ( Do_File_Upload )
  942. {
  943. VarSetCapacity( dbuffer, 4096, 0 )
  944. dbuffsz := Content_Length := SubStr( Content_Length + 0.0, 1, 1 + FLOOR( LOG( Content_Length )))
  945. hbuffer .= "Content-Length: " Content_Length "`r`n"
  946. IfNotInString, hbuffer, % "`r`nContent-Type: "
  947. {
  948. SplitPath, Upload_File_Path,,, file_ext
  949. hbuffer .= "Content-Type: " ( file_ext = "xml" ? "text/xml"
  950. : file_ext = "txt" ? "application/x-www-form-urlencoded"
  951. : "application/octet-stream" ) "`r`n"
  952. }
  953. If ( Do_Up_MD5_Hash )
  954. hbuffer .= "Content-MD5: " HTTPRequest_MD5( hbuffer, Upload_File_Path ) "`r`n"
  955. }
  956. Else If !( Do_NonBinary_Up ) || ( Do_NonBinary_Up = MyACP ) || ( Do_Multipart )
  957. {
  958. VarSetCapacity( dbuffer, dbuffsz := Content_Length, 0 )
  959. DllCall( "RtlMoveMemory", Ptr, &dbuffer, Ptr, &In_POST__Out_Data, "Int", Content_Length )
  960. Content_Length := SubStr( Content_Length + 0.0, 1, 1 + FLOOR( LOG( Content_Length )))
  961. hbuffer .= "Content-Length: " Content_Length "`r`n"
  962. IfNotInString, hbuffer, % "`r`nContent-Type: "
  963. hbuffer .= "Content-Type: " ( InStr( dbuffer, "<?xml" ) + 3 >> 2 = 1 ? "text/xml"
  964. : "application/x-www-form-urlencoded" ) "; charset=" MyCharset
  965. }
  966. Else
  967. {
  968. IfNotInString, hbuffer, % "`r`nContent-Type: "
  969. {
  970. hbuffer .= "Content-Type: " ( InStr( dbuffer, "<?xml" ) + 3 >> 2 = 1 ? "text/xml"
  971. : "application/x-www-form-urlencoded" )
  972. If ( 7 != pos := 7 + InStr( Codepage_Charsets, "|" Do_NonBinary_Up "=" ) )
  973. hbuffer .= "; charset=" SubStr( Codepage_Charsets, pos, InStr( Codepage_Charsets, "|", 0, pos ) - pos )
  974. hbuffer .= "`r`n"
  975. }
  976. If ( IsUnicode )
  977. pos := &In_POST__Out_Data, rbuffsz := Content_Length >> 1
  978. Else
  979. {
  980. If ( 0 < rbuffsz := DllCall( "MultiByteToWideChar", "UInt", MyACP, "UInt", 0, Ptr, &In_POST__Out_Data, "Int", Content_Length, Ptr, 0, "Int", 0 ) )
  981. {
  982. VarSetCapacity( rbuffer, rbuffsz + 1 << 1, 0 )
  983. DllCall( "MultiByteToWideChar", "UInt", MyACP, "UInt", 0, Ptr, &In_POST__Out_Data, "Int", Content_Length, Ptr, pos := &rbuffer, "Int", rbuffsz )
  984. }
  985. Else MyErrors .= "`nThere was a problem converting codepage " MyACP " to " Convert_POST_To_Codepage ". 'MultiByteToWideChar' failed: Return value = " rbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  986. }
  987. If ( 0 < rbuffsz )
  988. If ( 0 < dbuffsz := DllCall( "WideCharToMultiByte", "UInt", Do_NonBinary_Up, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, 0, "Int", 0, Ptr, 0, Ptr, 0 ) )
  989. {
  990. VarSetCapacity( dbuffer, dbuffsz + 1, 0 )
  991. DllCall( "WideCharToMultiByte", "UInt", Do_NonBinary_Up, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, &dbuffer, "Int", dbuffsz, Ptr, 0, Ptr, 0 )
  992. Content_Length := SubStr( dbuffsz + 0.0, 1, 1 + FLOOR( LOG( dbuffsz )))
  993. hbuffer .= "Content-Length: " Content_Length "`r`n"
  994. }
  995. Else MyErrors .= "`nThere was a problem converting codepage " MyACP " to " Convert_POST_To_Codepage ". 'WideCharToMultiByte' failed: Return value = " dbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  996. VarSetCapacity( rbuffer, 0 )
  997. If ( Do_Up_MD5_Hash )
  998. hbuffer .= "Content-MD5: " HTTPRequest_MD5( dbuffer, dbuffsz ) "`r`n"
  999. }
  1000. pos := 24 + PtrSize * 4
  1001. VarSetCapacity( INTERNET_BUFFERS, pos, 0 )
  1002. NumPut( pos, INTERNET_BUFFERS, 0, "Int" )
  1003. NumPut( Content_Length, INTERNET_BUFFERS, pos - 12, "Int" )
  1004. }
  1005. Loop, Parse, Accept_Types, "
  1006. If ( A_Index = 1 )
  1007. StringReplace, Accept_Types, A_LoopField, `,, `n, A
  1008. Else If ( A_Index & 1 )
  1009. {
  1010. StringReplace, Accept_PtrArray, A_LoopField, `,, `n, A
  1011. Accept_Types .= Accept_PtrArray
  1012. }
  1013. Else Accept_Types .= """" A_LoopField """"
  1014. Loop, Parse, Accept_Types, `n, % "`t`r "
  1015. If ( 1 = pos := A_Index )
  1016. Accept_Types := A_LoopField
  1017. Else Accept_Types .= "`n" A_LoopField
  1018. VarSetCapacity( Accept_PtrArray, pos * PtrSize + PtrSize, 0 )
  1019. pos := 0
  1020. Loop, Parse, Accept_Types, `n
  1021. {
  1022. NumPut( &Accept_Types + pos, Accept_PtrArray, A_Index * PtrSize - PtrSize, Ptr )
  1023. pos += 1 + StrLen( A_LoopField ) << IsUnicode
  1024. NumPut( 0, Accept_Types, pos - 1 - IsUnicode, IsUnicode ? "UShort" : "UChar" )
  1025. }
  1026. Method_Verb := Method_Verb != "" ? Method_Verb : 0 < Content_Length ? "POST" : "GET"
  1027. StringTrimLeft, hbuffer, hbuffer, 2
  1028. If InStr( MyErrors, "`n" )
  1029. Return 0, In_Out_HEADERS := SubStr( MyErrors, 2 ), ErrorLevel := oel
  1030. If !( hModule := DllCall( "LoadLibrary" WorA, "Str", "WinINet.dll", Ptr ) )
  1031. MyErrors .= "`nThere was a problem loading WinINet.dll. 'LoadLibrary" WorA "' failed: Return value = " hModule ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1032. Else    If !( hInternet := Internet_Open_Type != 3 ? DllCall( "WinINet\InternetOpen" WorA, Ptr, &Agent, "UInt", Internet_Open_Type, Ptr, 0, Ptr, 0, "UInt", 0, Ptr )
  1033. : DllCall( "WinINet\InternetOpen" WorA, Ptr, &Agent, "UInt", 3, ptr, &proxy_url, Ptr, proxy_bypass = "" ? 0 : &proxy_bypass, "UInt", 0, Ptr ) )
  1034. MyErrors .= "`nThere was a problem initializing WinINet. 'WinINet\InternetOpen" WorA "' failed: Return value = " hInternet ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1035. Else If !( hConnection := DllCall( "WinINet\InternetConnect" WorA, Ptr, hInternet, Ptr, &Host, "UInt", Port, Ptr, &User, Ptr, &Pass, "UInt", 3, "UInt", Internet_Flags, "UInt", 0, Ptr ) )
  1036. MyErrors .= "`nThere was a problem opening a HTTP session. 'WinINet\InternetConnect" WorA "' failed: Return value = " hConnection ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1037. Else If !( hRequest := DllCall( "WinINet\HttpOpenRequest" WorA, Ptr, hConnection, Ptr, &Method_Verb, Ptr, &URL, "Str", "HTTP/1.1", Ptr, 0, Ptr, &Accept_PtrArray, "UInt", Internet_Flags, Ptr ) )
  1038. MyErrors .= "`nThere was a problem creating a HTTP request. 'WinINet\HttpOpenRequest" WorA "' failed: Return value = " hRequest ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1039. Else If ( hbuffer != "" ) && !DllCall( "WinINet\HttpAddRequestHeaders" WorA, Ptr, hRequest, Ptr, &hbuffer, "UInt", StrLen( hbuffer ), "UInt", 0xA0000000 )
  1040. MyErrors .= "`nThere was a problem adding one or more headers to the request. 'WinINet\HttpAddRequestHeaders" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError "`nHeaders: `n" hbuffer
  1041. Else If ( Security_Flags_Add || Security_Flags_Nix ) && !DllCall( "WinINet\InternetQueryOption" WorA, Ptr, hRequest, "UInt", 31, "UInt*", Security_Flags, "UInt*", 4 )
  1042. MyErrors .= "`nThere was a problem retrieving the security flags. 'WinINet\InternetQueryOption" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1043. Else If ( Security_Flags_Add || Security_Flags_Nix ) && !DllCall( "WinINet\InternetSetOption" WorA, Ptr, hRequest, "UInt", 31, "UInt*", pos := ( ~Security_Flags_Nix & Security_Flags ) | Security_Flags_Add, "UInt*", 4 )
  1044. MyErrors .= "`nThere was a problem setting the security flags. 'WinINet\InternetSetOption" WorA "' failed: Flags value = " pos ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1045. Else If !( 0 < Content_Length ) && !DllCall( "WinINet\HttpSendRequest" WorA, Ptr, hRequest, Ptr, 0, "UInt", 0, Ptr, 0, "UInt", 0 )
  1046. MyErrors .= "`nThere was a problem sending the " Method_Verb " request. 'WinINet\HttpSendRequest" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1047. Else If ( 0 < Content_Length ) && !DllCall( "WinINet\HttpSendRequestEx" WorA, Ptr, hRequest, Ptr, &INTERNET_BUFFERS, Ptr, 0, "UInt", 0, Ptr, 0 )
  1048. MyErrors .= "`nThere was a problem sending the " Method_Verb " request. 'WinINet\HttpSendRequestEx" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1049. Else If ( 0 < Content_Length )
  1050. {
  1051. If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( -1, Content_Length, Do_Callback_3rdParam ) )
  1052. MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. Zero bytes were uploaded."
  1053. Else    If ( Do_File_Upload ) && !( Do_File_Upload := DllCall( "CreateFile" WorA, Ptr, &Upload_File_Path, "UInt", 0x80000000, "UInt", 0, Ptr, 0, "UInt", 4, "UInt", 0, Ptr, 0, Ptr ) )
  1054. MyErrors .= "`nThere was a problem opening the file to upload """ Upload_File_Path """. 'CreateFile" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1055. Else
  1056. {
  1057. size := 0
  1058. Loop
  1059. If ( Content_Length <= size )
  1060. Break
  1061. Else IfInString, MyErrors, `n
  1062. Break
  1063. Else
  1064. {
  1065. If ( size < Do_Multipart )
  1066. {
  1067. pos := &rbuffer
  1068. dtsz := Do_Multipart - size < 4096 ? Do_Multipart - size : 4096
  1069. }
  1070. Else If ( Do_Multipart + dbuffsz <= size )
  1071. {
  1072. pos := &rbuffer + Do_Multipart
  1073. dtsz := Content_Length - size < 4096 ? Content_Length - size : 4096
  1074. }
  1075. Else If ( Do_File_Upload ) && !DllCall( "ReadFile", Ptr, Do_File_Upload, Ptr, pos := &dbuffer, "UInt", dbuffsz - size < 4096 ? dbuffsz - size : 4096, "Int*", dtsz, Ptr, 0 )
  1076. {
  1077. MyErrors .= "`nThere was a problem reading from the file """ Upload_File_Path """. 'ReadFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1078. Break
  1079. }
  1080. Else
  1081. {
  1082. pos := &dbuffer + size
  1083. dtsz := dbuffsz - size < 4096 ? dbuffsz - size : 4096
  1084. }
  1085. If !DllCall( "WinINet\InternetWriteFile", Ptr, hRequest, Ptr, pos, "UInt", dtsz + 0, "Int*", dtsz )
  1086. MyErrors .= "`nThere was a problem uploading the POST data. 'WinINet\InternetWriteFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1087. Else
  1088. {
  1089. size += dtsz
  1090. If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( size / Content_Length - 1, Content_Length, Do_Callback_3rdParam ) )
  1091. MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. " size " bytes were uploaded."
  1092. }
  1093. }
  1094. If ( Do_File_Upload ) && !DllCall( "CloseHandle", Ptr, Do_File_Upload )
  1095. MyErrors .= "`nThere was a problem closing the file """ Upload_File_Path """. 'CloseHandle' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1096. }
  1097. DllCall( "WinINet\HttpEndRequest" WorA, Ptr, hRequest, Ptr, 0, "UInt", 0, Ptr, 0 )
  1098. }
  1099. Content_Length := size := rbuffsz := 0
  1100. If InStr( MyErrors, "`n" )
  1101. hbuffer := ""
  1102. Else
  1103. {
  1104. DllCall( "WinINet\InternetQueryDataAvailable", Ptr, hRequest, "Int*", Content_Length, "UInt", 0, Ptr, 0 )
  1105. If VarSetCapacity( hbuffer, hbuffsz := 4096, 0 )
  1106. && !DllCall( "WinINet\HttpQueryInfo" WorA, Ptr, hRequest, "UInt", 22, Ptr, &hbuffer, "Int*", hbuffsz, Ptr, 0 )
  1107. && VarSetCapacity( hbuffer, hbuffsz, 0 )
  1108. && !DllCall( "WinINet\HttpQueryInfo" WorA, Ptr, hRequest, "UInt", 22, Ptr, &hbuffer, "Int*", hbuffsz, Ptr, 0 )
  1109. MyErrors .= "`nThere was a problem reading the response headers. 'WinINet\HttpQueryInfo" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1110. Else
  1111. {
  1112. VarSetCapacity( hbuffer, -1 )
  1113. StringReplace, hbuffer, hbuffer, `r`n, `n, A
  1114. StringMid, Response_Code, hbuffer, InStr( hbuffer, " " ) + 1, 3
  1115. If ( 17 != pos := 17 + InStr( hbuffer, "`nContent-Length: " ) )
  1116. StringMid, Content_Length, hbuffer, pos, InStr( hbuffer, "`n", 0, pos ) - pos
  1117. }
  1118. }
  1119. If ( Content_Length ) && !InStr( MyErrors, "`n" )
  1120. {
  1121. If ( Do_Download_To_File ) && !( Do_Download_To_File := DllCall( "CreateFile" WorA, Ptr, &output_file_path, "UInt", 0x40000000, "UInt", 0, Ptr, 0, "UInt", 4, "UInt", 0, Ptr, 0, Ptr ) )
  1122. MyErrors .= "`nThere was a problem opening/creating the output file for writing data: """ output_file_path """. 'CreateFile" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1123. Else If ( Do_Download_Resume ) && !DllCall( "SetFilePointerEx", Ptr, Do_Download_To_File, "Int64", Do_Download_Resume, Ptr, 0, "UInt", 0 )
  1124. MyErrors .= "`nThere was a problem seeking to the end of the output file for resuming the download. 'SetFilePointerEx' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1125. Else If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( Do_Download_Resume, Content_Length + Do_Download_Resume, Do_Callback_3rdParam ) )
  1126. MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. Zero bytes were downloaded."
  1127. Else
  1128. {
  1129. VarSetCapacity( dbuffer, dbuffsz := Do_Download_To_File ? 4096 : 4096 + Content_Length, 0 )
  1130. Loop
  1131. IfInString, MyErrors, `n
  1132. Break
  1133. Else
  1134. {
  1135. If ( Do_Download_To_File )
  1136. pos := &dbuffer
  1137. Else If ( size + 4096 < Content_Length )
  1138. pos := &dbuffer + size
  1139. Else
  1140. {
  1141. VarSetCapacity( rbuffer, rbuffsz := size + 4096 + 1, 0 )
  1142. pos := &rbuffer + size
  1143. }
  1144. If !DllCall( "WinINet\InternetReadFile", Ptr, hRequest, Ptr, pos, "UInt", 4096, "Int*", dtsz )
  1145. MyErrors .= "`nThere was a problem downoading data. 'WinINet\InternetReadFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1146. Else If !dtsz
  1147. {
  1148. If ( Do_Callback )
  1149. %Do_Callback_Func%( 1, Content_Length + Do_Download_Resume, Do_Callback_3rdParam )
  1150. Break
  1151. }
  1152. Else If ( Do_Download_To_File ) && !DllCall( "WriteFile", Ptr, Do_Download_To_File, Ptr, pos, "UInt", dtsz, "Int*", 0, Ptr, 0 )
  1153. MyErrors .= "`nThere was a problem writing data to the disk. 'WriteFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1154. Else If !( Do_Download_To_File ) && ( size < rbuffsz )
  1155. {
  1156. DllCall( "RtlMoveMemory", Ptr, &rbuffer, Ptr, &dbuffer, "Int", size )
  1157. VarSetCapacity( dbuffer, Content_Length := 4096 + ( size += dtsz ), 0 )
  1158. DllCall( "RtlMoveMemory", Ptr, &dbuffer, Ptr, &rbuffer, "Int", size )
  1159. rbuffsz := 0
  1160. }
  1161. Else size += dtsz
  1162. If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( ( size + Do_Download_Resume ) / ( Content_Length + Do_Download_Resume ), Content_Length + Do_Download_Resume, Do_Callback_3rdParam ) )
  1163. MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. " size " bytes were uploaded."
  1164. }
  1165. If ( Do_Download_To_File )
  1166. {
  1167. If ( Do_Legacy_Dual_Output )
  1168. {
  1169. VarSetCapacity( dbuffer, size + 1, 0 )
  1170. If !DllCall( "ReadFile", Ptr, Do_Download_To_File, Ptr, &dbuffer, "UInt", size, Ptr, 0, Ptr, 0 )
  1171. MyErrors .= "`nThere was a problem reading the file """ output_file_path """. 'ReadFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1172. }
  1173. If !DllCall( "CloseHandle", Ptr, Do_Download_To_File )
  1174. MyErrors .= "`nThere was a problem closing the file """ output_file_path """. 'CloseHandle' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1175. }
  1176. }
  1177. }
  1178. DllCall( "WinINet\InternetCloseHandle", Ptr, hRequest )
  1179. DllCall( "WinINet\InternetCloseHandle", Ptr, hConnection )
  1180. DllCall( "WinINet\InternetCloseHandle", Ptr, hInternet )
  1181. DllCall( "FreeLibrary", Ptr, hModule )
  1182. If ( Do_Dn_MD5_Hash ) && InStr( hbuffer, "`nContent-MD5: " )
  1183. If ( Do_Download_To_File )
  1184. hbuffer .= "`nComputed-MD5: " HTTPRequest_MD5( rbuffer, output_file_path )
  1185. Else hbuffer .= "`nComputed-MD5: " HTTPRequest_MD5( dbuffer, size )
  1186. If ( size ) && ( !( Do_Download_To_File ) || ( Do_Legacy_Dual_Output ) )
  1187. {
  1188. If ( 15 != pos := 15 + InStr( hbuffer, "`nContent-Type: " ) )
  1189. StringMid, Content_Type, hbuffer, pos, InStr( hbuffer "`n", "`n", 0, pos ) - pos
  1190. Else Content_Type := "text/plain; charset=" MyCharset
  1191. If ( 7 != pos := 7 + InStr( Content_Type, "charset=" ) )
  1192. && ( pos := InStr( Codepage_Charsets, SubStr( Content_Type, pos
  1193. , InStr( Content_Type ";" , ";", 0, pos ) - pos ) "|" ) )
  1194. StringMid, Convert_POST_To_Codepage, Codepage_Charsets, pos - 5, 5
  1195. Else Convert_POST_To_Codepage := IsUnicode ? "65001" : MyACP
  1196. StringLeft, Content_Type, Content_Type, InStr( Content_Type ";", ";" ) - 1
  1197. If !( pos := InStr( Content_Type, "text/" ) = 1 )
  1198. Loop, Parse, Text_Content_Subtypes, /
  1199. If ( pos |= 0 < InStr( Content_Type, "/" A_LoopField ) )
  1200. Break
  1201. If ( Do_Binary_Down ) || !( pos ) || ( Convert_POST_To_Codepage = MyACP )
  1202. {
  1203. VarSetCapacity( In_POST__Out_Data, size + 2, 0 )
  1204. DllCall( "RtlMoveMemory", Ptr, &In_POST__Out_Data, Ptr, &dbuffer, "Int", size )
  1205. If ( pos )
  1206. VarSetCapacity( In_POST__Out_Data, -1 )
  1207. }
  1208. Else
  1209. {
  1210. If ( Convert_POST_To_Codepage = "01200" )
  1211. {
  1212. pos := &dbuffer
  1213. rbuffsz := size >> 1
  1214. }
  1215. Else If ( 0 < rbuffsz := DllCall( "MultiByteToWideChar", "UInt", Convert_POST_To_Codepage, "UInt", 0, Ptr, &dbuffer, "Int", size, Ptr, 0, "Int", 0 ) )
  1216. {
  1217. VarSetCapacity( rbuffer, rbuffsz + 1 << 1 )
  1218. DllCall( "MultiByteToWideChar", "UInt", Convert_POST_To_Codepage, "UInt", 0, Ptr, &dbuffer, "Int", size, Ptr, pos := &rbuffer, "Int", rbuffsz )
  1219. }
  1220. Else MyErrors .= "`nThere was a problem converting codepage " Convert_POST_To_Codepage " to " MyACP ". 'MultiByteToWideChar' failed: Return value = " rbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1221. If ( IsUnicode )
  1222. {
  1223. VarSetCapacity( In_POST__Out_Data, rbuffsz + 1 << 1, 0 )
  1224. DllCall( "RtlMoveMemory", Ptr, &In_POST__Out_Data, Ptr, &rbuffer, "Int", rbuffsz << 1 )
  1225. VarSetCapacity( In_POST__Out_Data, -1 )
  1226. }
  1227. Else If ( 0 < rbuffsz ) && ( 0 < dbuffsz := DllCall( "WideCharToMultiByte", "UInt", MyACP, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, 0, "Int", 0, Ptr, 0, Ptr, 0 ) )
  1228. {
  1229. VarSetCapacity( In_POST__Out_Data, dbuffsz + 1, 0 )
  1230. DllCall( "WideCharToMultiByte", "UInt", MyACP, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, &In_POST__Out_Data, "Int", dbuffsz, Ptr, 0, Ptr, 0 )
  1231. size := dbuffsz
  1232. VarSetCapacity( In_POST__Out_Data, -1 )
  1233. }
  1234. Else MyErrors .= "`nThere was a problem converting codepage " Convert_POST_To_Codepage " to " MyACP ". 'WideCharToMultiByte' failed: Return value = " dbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
  1235. }
  1236. }
  1237. Else
  1238. In_POST__Out_Data := ""
  1239. In_Out_HEADERS := SubStr( hbuffer, 1, -1 ) . SubStr( MyErrors, 1 + ( hbuffer = "" ) )
  1240. Return size, dbuffer := "", hbuffer := "", rbuffer := "", ErrorLevel := Response_Code
  1241. }
  1242. HTTPRequest_MD5( byref data, length=-1 ) {
  1243. Static s, k, pty, u, p:=0, r := "GLQVGLQVGLQVGLQVEINTEINTEINTEINTDKPWDKPWDKPWDKPWFJOUFJOUFJOUFJOU"
  1244. If !( p )
  1245. {
  1246. VarSetCapacity( k, 256 )
  1247. VarSetCapacity( S, 64, 0 )
  1248. u := !!A_IsUnicode
  1249. pty := A_PtrSize = "" ? "UInt" : "Ptr"
  1250. Loop, 64
  1251. NumPut( i := Floor(Abs(Sin(A_Index)) * 0x100000000 ), k, A_Index - 1 << 2, "UInt" )
  1252. }
  1253. If length IS NOT NUMBER
  1254. IfExist, % length
  1255. {
  1256. hFile := DllCall( "CreateFile" ( u ? "W" : "A" ), "Str", length
  1257. , "UInt", 0x80000000
  1258. , "UInt", 0, pty, 0
  1259. , "UInt", 4
  1260. , "UInt", 0, pty, 0, Ptr )
  1261. VarSetCapacity( l, 8 )
  1262. DllCall( "GetFileSizeEx", pty, hFile, pty, &l )
  1263. length := NumGet( l, 0, "Int64" )
  1264. }
  1265. If Round( length ) < 1
  1266. length := StrLen( dat ) << u
  1267. ha := 0x67452301, hb := 0xEFCDAB89, hc := 0x98BADCFE, hd := 0x10325476
  1268. Loop % length + 72 >> 6
  1269. {
  1270. If ( f := length - 64 > ( e := A_Index - 1 << 6 ) ? 64 : length > e ? length - e : 0 )
  1271. If ( hFile )
  1272. DllCall( "ReadFile", pty, hFile, pty, &s, "UInt", f, pty, &l, pty, 0 )
  1273. Else DllCall( "RtlMoveMemory", pty, &s, pty, &data + e, "UInt", f )
  1274. If ( f != 64 && e <= length )
  1275. NumPut( 128, s, f, "UChar" )
  1276. If ( f < 56 )
  1277. Loop 8
  1278. NumPut( ( ( length << 3 ) >> ( A_Index - 1 << 3 ) ) & 255, s, 55 + A_Index, "UChar" )
  1279. a := ha, b := hb, c := hc, d := hd
  1280. Loop 64
  1281. {
  1282. e := NumGet( r, ( i := A_Index - 1 ) << u, "UChar" ) & 31
  1283. f := 0 = ( j := i >> 4 ) ? (b&c)|(~b&d) : j=1 ? (d&b)|(~d&c) : j=2 ? b^c^d : c^(~d|b)
  1284. g := &s + (( i * ( 3817 >> j * 3 & 7 ) + ( 328 >> j * 3 & 7 ) & 15 ) << 2 )
  1285. w := (*(g+3) << 24 | *(g+2) << 16 | *(g+1) << 8 | *g) + a + f + NumGet(k,i<<2,"UInt")
  1286. a := d, d := c, c := b, b += w << e | (( w & 0xFFFFFFFF ) >> ( 32 - e ))
  1287. }
  1288. ha := ha+a&0xFFFFFFFF, hb := hb+b&0xFFFFFFFF, hc := hc+c&0xFFFFFFFF, hd := hd+d&0xFFFFFFFF
  1289. VarSetCapacity( S, 64, 0 )
  1290. }
  1291. If ( hFile )
  1292. DllCall( "CloseHandle", pty, hFile )
  1293. Loop 32
  1294. g:=1&(i:=A_Index-1), e:=Chr(97+(i>>3))
  1295. , f:=15&(h%e%>>((!g-g+i&7)<<2)), s.=Chr(48+f+39*(9<f))
  1296. s .= "0000"
  1297. Loop 6
  1298. Loop, % 4+0*(g := Abs("0x" SubStr( s,A_Index*6-5,6)))
  1299. i:=(g>>6*(4-A_Index))&63, s.=i=63 ? "/" : i=62 ? "+" : Chr(i<26 ? i+65 : i<52 ? i+71 : i-4)
  1300. Return SubStr( s, 37, 22 ) "=="
  1301. }
  1302. httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="")
  1303. {   global httpQueryOps, httpAgent, httpProxy, httpProxyByPass, httpQueryReferer, httpQueryAcceptType
  1304. , httpQueryDwFlags
  1305. defaultOps =
  1306.    (LTrim Join|
  1307.       httpAgent=script|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
  1308.       SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
  1309.       SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
  1310.       INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
  1311. )
  1312. Loop,Parse,defaultOps,|
  1313. {
  1314. RegExMatch(A_LoopField,"(?P<Option>[^=]+)=(?P<Default>.*)",http)
  1315. if StrLen(%httpOption%)=0
  1316. %httpOption% := httpDefault
  1317. }
  1318. hModule := DllCall("LoadLibrary", "Str", "WinINet.Dll")
  1319. offset_name_length:= "4-lpszScheme-255|16-lpszHostName-1024|28-lpszUserName-1024|"
  1320. . "36-lpszPassword-1024|44-lpszUrlPath-1024|52-lpszExtrainfo-1024"
  1321. VarSetCapacity(URL_COMPONENTS,60,0)
  1322. NumPut(60,URL_COMPONENTS,0), NumPut(255,URL_COMPONENTS,12), NumPut(0xffff,URL_COMPONENTS,24)
  1323. Loop,Parse,offset_name_length,|
  1324. {
  1325. RegExMatch(A_LoopField,"(?P<Offset>\d+)-(?P<Name>[a-zA-Z]+)-(?P<Size>\d+)",iCU_)
  1326. VarSetCapacity(%iCU_Name%,iCU_Size,0)
  1327. NumPut(&%iCU_Name%,URL_COMPONENTS,iCU_Offset)
  1328. NumPut(iCU_Size,URL_COMPONENTS,iCU_Offset+4)
  1329. }
  1330. DllCall("WinINet\InternetCrackUrlA","Str",lpszUrl,"uInt",StrLen(lpszUrl),"uInt",0,"uInt",&URL_COMPONENTS)
  1331. Loop,Parse,offset_name_length,|
  1332. {
  1333. RegExMatch(A_LoopField,"-(?P<Name>[a-zA-Z]+)-",iCU_)
  1334. VarSetCapacity(%iCU_Name%,-1)
  1335. }
  1336. nPort:=NumGet(URL_COMPONENTS,24,"uInt")
  1337. dwFlags := httpQueryDwFlags
  1338. if (lpszScheme = "https")
  1339. dwFlags |= (INTERNET_FLAG_SECURE|SECURITY_FLAG_IGNORE_CERT_CN_INVALID
  1340. |SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)
  1341. if (lpszScheme="unknown") {
  1342. Result := "ERR: No Valid URL supplied."
  1343. Return StrLen(Result)
  1344. }
  1345. hInternet := DllCall("WinINet\InternetOpenA"
  1346. ,"Str",httpAgent,"UInt"
  1347. ,(httpProxy != 0 ?  INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT )
  1348. ,"Str",httpProxy,"Str",httpProxyBypass,"Uint",0)
  1349. hConnect := DllCall("WinINet\InternetConnectA"
  1350. ,"uInt",hInternet,"Str",lpszHostname, "Int",nPort
  1351. ,"Str",lpszUserName, "Str",lpszPassword,"uInt",INTERNET_SERVICE_HTTP
  1352. ,"uInt",0,"uInt*",0)
  1353. if (Strlen(POSTDATA)>0) {
  1354. HTTPVerb:="POST"
  1355. if StrLen(Headers)=0
  1356. Headers:="Content-Type: application/x-www-form-urlencoded"
  1357. } else
  1358. HTTPVerb:="GET"
  1359. hRequest := DllCall("WinINet\HttpOpenRequestA"
  1360. ,"uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo
  1361. ,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes
  1362. ,"uInt",dwFlags,"uInt",Context:=0 )
  1363. sRequest := DllCall("WinINet\HttpSendRequestA"
  1364. , "uInt",hRequest,"Str",Headers, "uInt",Strlen(Headers)
  1365. , "Str",POSTData,"uInt",Strlen(POSTData))
  1366. VarSetCapacity(header, 2048, 0)
  1367. VarSetCapacity(header_len, 4, 0)
  1368. Loop, 5
  1369. if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest
  1370. ,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
  1371. break
  1372. If (headerRequest=1) {
  1373. VarSetCapacity(res,headerLength:=NumGet(header_len),32)
  1374. DllCall("RtlMoveMemory","uInt",&res,"uInt",&header,"uInt",headerLength)
  1375. Loop,% headerLength
  1376. if (*(&res-1+a_index)=0)
  1377. NumPut(Asc("`n"),res,a_index-1,"uChar")
  1378. VarSetCapacity(res,-1)
  1379. } else
  1380. res := "timeout"
  1381. Loop,Parse,res,`n,`r
  1382. {
  1383. RetValue := A_LoopField
  1384. break
  1385. }
  1386. If (RetValue="timeout") {
  1387. html := "Error: timeout"
  1388. return -1
  1389. }
  1390. RetValue := RegExReplace(RetValue,"HTTP/1\.[01]\s+")
  1391. RetValue := SubStr(RetValue,1,3)
  1392. if strlen(HTTPQueryOps)>0 {
  1393. if (instr(HTTPQueryOps,"showHeader"))
  1394. MsgBox % res
  1395. if (instr(HTTPQueryOps,"storeHeader"))
  1396. global HttpQueryHeader := res
  1397. if (instr(HTTPQueryOps,"updateSize")) {
  1398. Loop,Parse,res,`n
  1399. If RegExMatch(A_LoopField,"Content-Length:\s+?(?P<Size>\d+)",full) {
  1400. global HttpQueryFullSize := fullSize
  1401. break
  1402. }
  1403. if (fullSize+0=0)
  1404. HttpQueryFullSize := "size unavailable"
  1405. }
  1406. }
  1407. if !(InStr("100 200 201 202 500 502",RetValue)) {
  1408. Result := RetValue " " RetMsg
  1409. return StrLen(Result)
  1410. }
  1411. VarSetCapacity(BytesRead,4,0)
  1412. fsize := 0
  1413. Loop
  1414. {  bc := A_Index
  1415. VarSetCapacity(buffer%bc%,1024,0)
  1416. ReadFile := DllCall("wininet\InternetReadFile"
  1417. ,"uInt",hRequest,"uInt",&buffer%bc%,"uInt",1024,"uInt",&BytesRead)
  1418. ReadBytes := NumGet(BytesRead)
  1419. If ((ReadFile!=0)&&(!ReadBytes))
  1420. break
  1421. Else {
  1422. fsize += ReadBytes
  1423. sizeArray .= ReadBytes "|"
  1424. }
  1425. if (instr(HTTPQueryOps,"updateSize"))
  1426. Global HttpQueryCurrentSize := fsize
  1427. }
  1428. sizeArray := SubStr(sizeArray,1,-1)
  1429. VarSetCapacity(result,fSize+1,0)
  1430. Dest := &result
  1431. Loop,Parse,SizeArray,|
  1432. DllCall("RtlMoveMemory","uInt",Dest,"uInt",&buffer%A_Index%,"uInt",A_LoopField)
  1433. , Dest += A_LoopField
  1434. DllCall("WinINet\InternetCloseHandle", "uInt", hRequest)
  1435. DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
  1436. DllCall("WinINet\InternetCloseHandle", "uInt", hConnect)
  1437. DllCall("FreeLibrary", "UInt", hModule)
  1438. return fSize
  1439. }
  1440. EncodeURL( p_data, p_reserved=true, p_encode=true )
  1441. {
  1442. old_FormatInteger := A_FormatInteger
  1443. SetFormat, Integer, hex
  1444. unsafe =
  1445.       ( Join LTrim
  1446.          25000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20
  1447.          22233C3E5B5C5D5E607B7C7D7F808182838485868788898A8B8C8D8E8F9091929394
  1448.          95969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6
  1449.          B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8
  1450.          D9DADBDCDDDEDF7EE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9
  1451.          FAFBFCFDFEFF
  1452. )
  1453. if ( p_reserved )
  1454. unsafe = %unsafe%24262B2C2F3A3B3D3F40
  1455. if ( p_encode )
  1456. loop, % StrLen( unsafe )//2
  1457. {
  1458. StringMid, token, unsafe, A_Index*2-1, 2
  1459. StringReplace, p_data, p_data, % Chr( "0x" token ), `%%token%, all
  1460. }
  1461. else
  1462. loop, % StrLen( unsafe )//2
  1463. {
  1464. StringMid, token, unsafe, A_Index*2-1, 2
  1465. StringReplace, p_data, p_data, `%%token%, % Chr( "0x" token ), all
  1466. }
  1467. SetFormat, Integer, %old_FormatInteger%
  1468. return, p_data
  1469. }
  1470. DecodeURL( p_data )
  1471. {
  1472. return, EncodeURL( p_data, true, false )
  1473. }
  1474. Ansi2Oem(sString)
  1475. {
  1476. Ansi2Unicode(sString, wString, 0)
  1477. Unicode2Ansi(wString, zString, 1)
  1478. Return zString
  1479. }
  1480. Oem2Ansi(zString)
  1481. {
  1482. Ansi2Unicode(zString, wString, 1)
  1483. Unicode2Ansi(wString, sString, 0)
  1484. Return sString
  1485. }
  1486. Ansi2UTF8(sString)
  1487. {
  1488. Ansi2Unicode(sString, wString, 0)
  1489. Unicode2Ansi(wString, zString, 65001)
  1490. Return zString
  1491. }
  1492. UTF82Ansi(zString)
  1493. {
  1494. Ansi2Unicode(zString, wString, 65001)
  1495. Unicode2Ansi(wString, sString, 0)
  1496. Return sString
  1497. }
  1498. Ansi2Unicode(ByRef sString, ByRef wString, CP = 0)
  1499. {
  1500. nSize := DllCall("MultiByteToWideChar"
  1501. , "Uint", CP
  1502. , "Uint", 0
  1503. , "Uint", &sString
  1504. , "int",  -1
  1505. , "Uint", 0
  1506. , "int",  0)
  1507. VarSetCapacity(wString, nSize * 2)
  1508. DllCall("MultiByteToWideChar"
  1509. , "Uint", CP
  1510. , "Uint", 0
  1511. , "Uint", &sString
  1512. , "int",  -1
  1513. , "Uint", &wString
  1514. , "int",  nSize)
  1515. }
  1516. Unicode2Ansi(ByRef wString, ByRef sString, CP = 0)
  1517. {
  1518. nSize := DllCall("WideCharToMultiByte"
  1519. , "Uint", CP
  1520. , "Uint", 0
  1521. , "Uint", &wString
  1522. , "int",  -1
  1523. , "Uint", 0
  1524. , "int",  0
  1525. , "Uint", 0
  1526. , "Uint", 0)
  1527. VarSetCapacity(sString, nSize)
  1528. DllCall("WideCharToMultiByte"
  1529. , "Uint", CP
  1530. , "Uint", 0
  1531. , "Uint", &wString
  1532. , "int",  -1
  1533. , "str",  sString
  1534. , "int",  nSize
  1535. , "Uint", 0
  1536. , "Uint", 0)
  1537. }
Advertisement
Add Comment
Please, Sign In to add comment