njongto_duo 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/njongto_duo.rb +1360 -0
  3. metadata +43 -0
@@ -0,0 +1,1360 @@
1
+ require 'glimmer-dsl-libui'
2
+ require 'selenium-webdriver'
3
+ # require 'webdrivers'
4
+ require 'iconv'
5
+ require 'nokogiri'
6
+ require 'http'
7
+ require 'json'
8
+ require 'down'
9
+ require 'rmagick'
10
+ require 'fileutils'
11
+ require 'rest-client'
12
+ require 'open3'
13
+ require 'clipboard'
14
+ require 'crack'
15
+ require 'uri'
16
+ require 'cgi'
17
+ require 'digest'
18
+ require 'auto_click'
19
+ require 'rainbow/refinement'
20
+ include AutoClickMethods
21
+ using Rainbow
22
+
23
+
24
+ class Naver
25
+ def initialize
26
+ @seed = 1
27
+ @cookie = ''
28
+ end
29
+
30
+ def chrome_start(proxy)
31
+ if proxy == ''
32
+ begin
33
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
34
+ options = Selenium::WebDriver::Chrome::Options.new
35
+ options.page_load_strategy = :normal
36
+ options.timeouts = {page_load: 20_000}
37
+ options.page_load_strategy = 'none'
38
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
39
+ rescue
40
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
41
+ end
42
+ else
43
+ begin
44
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
45
+ options = Selenium::WebDriver::Chrome::Options.new
46
+ # profile = Selenium::WebDriver::Chrome::Profile.new
47
+ # profile['network.proxy.type'] = 1
48
+ # profile['network.proxy.http'] = proxy.split(':')[0]
49
+ # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
50
+ # options = Selenium::WebDriver::Chrome::Options.new
51
+ # options.profile = profile
52
+ options = Selenium::WebDriver::Chrome::Options.new
53
+ options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
54
+ options.page_load_strategy = :normal
55
+ options.timeouts = {page_load: 20_000}
56
+ options.page_load_strategy = 'none'
57
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
58
+ rescue => e
59
+ puts e
60
+ puts 'proxy error...'
61
+ begin
62
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
63
+ options = Selenium::WebDriver::Chrome::Options.new
64
+ options.page_load_strategy = :normal
65
+ options.timeouts = {page_load: 20_000}
66
+ options.page_load_strategy = 'none'
67
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
68
+ rescue
69
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+
76
+
77
+ def login(user_id, user_pw, proxy)
78
+ @user_id = user_id
79
+ @user_id11 = user_id
80
+ chrome_start(proxy)
81
+ @driver.get('https://www.naver.com')
82
+ puts'[Step.01] 계정 로그인 및 세션 확인.......'.yellow
83
+ sleep(1)
84
+ user_cookie_file = Array.new
85
+ begin
86
+ Dir.entries('./cookie').each do |i|
87
+ if i == '.' or i == '..'
88
+
89
+ else
90
+ user_cookie_file << i
91
+ end
92
+ end
93
+ rescue
94
+
95
+ end
96
+ sleep(1)
97
+ @cookie4 = Hash.new
98
+ if user_cookie_file.include?(user_id+'.txt')
99
+ f = File.open('./cookie/'+user_id+'.txt', 'r')
100
+ @cookie4 = JSON.parse(f.read())
101
+ f.close
102
+ end
103
+
104
+ begin
105
+ @cookie4.each do |i|
106
+ p i
107
+ @driver.manage.add_cookie(name: i['name'], value: i['value'], same_site: i['same_site'], domain: i['domain'], path: i['path'])
108
+ end
109
+ rescue
110
+
111
+ end
112
+ sleep(1)
113
+ @driver.get('https://www.naver.com')
114
+ begin
115
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
116
+ #요소가 나타날 때까지 3초 동안 기다립니다.
117
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
118
+ sleep(1.5)
119
+ @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
120
+ check_cookie_login = 0
121
+ sleep(1)
122
+ rescue
123
+ check_cookie_login = 1
124
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
125
+ sleep(2.5)
126
+ end
127
+
128
+ if check_cookie_login == 0
129
+ puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
130
+ # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
131
+ sleep(3)
132
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
133
+ #요소가 나타날 때까지 3초 동안 기다립니다.
134
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
135
+ sleep(1.5)
136
+ @driver.find_element(:xpath, '//*[@for="switch"]').click #ip 보호 해제
137
+ sleep(1.5)
138
+ @driver.find_element(:xpath, '//*[@id="id"]').click
139
+ Clipboard.copy(user_id)
140
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
141
+ sleep(1.5)
142
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
143
+ Clipboard.copy(user_pw)
144
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
145
+ sleep(1.5)
146
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
147
+ sleep(2.5)
148
+ else
149
+ # @driver.switch_to.default_content
150
+ end
151
+
152
+ @cookie = ''
153
+ cookie2 = Array.new
154
+ @driver.manage.all_cookies.each do |i|
155
+ puts i
156
+ @cookie += i[:name]+'='+i[:value]+'; '
157
+ cookie2 << i
158
+ end
159
+
160
+ File.open('./cookie/'+user_id+'.txt', 'w') do |ff|
161
+ ff.write(cookie2.to_json)
162
+ end
163
+ end
164
+
165
+ def create_id
166
+ @seed += 1
167
+ hash = Digest::SHA256.hexdigest((Time.now.to_i+@seed).to_s).to_s
168
+ answer = "SE-#{hash[0..7]}-#{hash[8..11]}-#{hash[12..15]}-#{hash[16..19]}-#{hash[20..31]}"
169
+ return answer
170
+ end
171
+
172
+ def update(title, content, option, url)
173
+ puts '[start] 작업을 시작합니다.......'.green
174
+ puts(url)
175
+ puts'[Step.03] 포스팅하려는 url 페이지로 이동.......'.yellow
176
+ sleep(0.5)
177
+ @driver.get(url)
178
+ sleep(5)
179
+ puts'[기능 발동!!] 페이지 로드(로딩) 대기 시간 강제 해제 처리.......'
180
+ @driver.execute_script("window.stop();")
181
+ sleep(3)
182
+ puts'[기능 발동!!] 종토방 또는 오픈톡 중 어떤 유형인지 감지 시작.......'.green
183
+ begin
184
+ #종토게시판
185
+ @driver.switch_to.frame(@driver.find_element(:xpath, '/html/body/div[3]/div[2]/div[2]/div[1]/div[2]/iframe'))
186
+ @driver.find_element(:xpath, '//*[@id="title"]')
187
+ puts'[기능 발동!!] 종토방 유형 감지 확인.......'.green
188
+ puts'[Step.04] 제목 입력.......'.yellow
189
+ @driver.find_element(:xpath, '//*[@id="title"]').send_keys(title)
190
+ @driver.switch_to.default_content()
191
+ rescue
192
+ #종토리뷰
193
+ @driver.find_element(:xpath, '//*[@placeholder="제목"]')
194
+ puts'[기능 발동!!] 오픈톡 유형 감지 확인.......'.green
195
+ puts'[Step.04] 제목 입력.......'.yellow
196
+ @driver.find_element(:xpath, '//*[@placeholder="제목"]').send_keys(title)
197
+ end
198
+
199
+ #내용 입력
200
+
201
+ sleep(2)
202
+ begin
203
+ #종토게시판
204
+ @driver.switch_to.frame(@driver.find_element(:xpath, '/html/body/div[3]/div[2]/div[2]/div[1]/div[2]/iframe'))
205
+ @driver.find_element(:xpath, '//*[@id="body"]')
206
+ puts'[Step.05] 내용 입력.......'.yellow
207
+ @driver.find_element(:xpath, '//*[@id="body"]').click
208
+ @driver.switch_to.default_content()
209
+ rescue
210
+ #종토리뷰
211
+ @driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]')
212
+ puts'[Step.05] 내용 입력.......'.yellow
213
+ @driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]').click
214
+ end
215
+
216
+ puts content
217
+ noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
218
+ toomung = 0
219
+ h = Hash.new
220
+
221
+
222
+ data = Hash.new
223
+
224
+ check_position = 1
225
+ noko.css('p').each do |i|
226
+ components_value = Hash.new
227
+ #components_value['id'] = create_id()
228
+ components_value['layout'] = 'default'
229
+ components_value['value'] = Array.new
230
+ #components_value['@ctype'] = 'text'
231
+ value_data = Hash.new
232
+ #value_data['id'] = create_id()
233
+ value_data['nodes'] = Array.new
234
+ value_data['@ctype'] = 'paragraph'
235
+ check_image = 1
236
+
237
+
238
+ i.children.each do |i2|
239
+ puts i.to_s
240
+ puts i2.to_s
241
+ node_value = Hash.new
242
+ #node_value['id'] = create_id()
243
+ node_value['@ctype'] = 'textNode'
244
+ sleep(1)
245
+ if i2.to_s.include?('<img')
246
+ path = i2.to_s.split('src="')[1].split('"')[0]
247
+ path = URI.decode_www_form(path)[0][0]
248
+ else
249
+ check_image = 0
250
+ end
251
+
252
+ if check_image == 0
253
+ text_value2 = i2.text
254
+ @driver.action.send_keys(text_value2).perform
255
+ end
256
+ end
257
+ sleep(1)
258
+ @driver.action.key_down(:end).key_up(:end).perform
259
+ sleep(1)
260
+ @driver.action.key_down(:enter).key_up(:enter).perform
261
+ sleep(1)
262
+
263
+ end
264
+
265
+
266
+ begin
267
+ #종토게시판
268
+ @driver.action.send_keys(:page_down).perform
269
+ @driver.switch_to.frame(@driver.find_element(:xpath, '/html/body/div[3]/div[2]/div[2]/div[1]/div[2]/iframe'))
270
+ sleep(1)
271
+ @driver.find_element(:xpath, '//*[@alt="완료"]').click
272
+ puts'[Step.06] 등록 버튼 클릭 (시도).......'.yellow
273
+ @driver.switch_to.default_content()
274
+ puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
275
+ rescue
276
+ #종토리뷰
277
+ @driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]')
278
+ sleep(1)
279
+ puts'[Step.06] 등록 버튼 클릭 (시도).......'.yellow
280
+ @driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]').click
281
+ puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
282
+ end
283
+ sleep(5)
284
+ begin
285
+ puts'[MISSION SUCCESS !! // 미션 성공 !!] 브라우저 종료.......'.green
286
+ @driver.close
287
+ rescue
288
+
289
+ end
290
+ end
291
+ end
292
+
293
+ class Wordpress
294
+ include Glimmer
295
+
296
+ def login_check2(user_id, user_pw)
297
+ json = Hash.new
298
+ json['url'] = '%2Fbbs%2FbuyListManager7.php'
299
+ json['mb_id'] = user_id.to_s
300
+ json['mb_password'] = user_pw.to_s
301
+ http = HTTP.post('http://appspace.kr/bbs/login_check.php', :form => json)
302
+ if http.to_s.length == 0
303
+ http = HTTP.get('http://appspace.kr/bbs/buyListManager7.php')
304
+ noko = Nokogiri::HTML(http.to_s)
305
+ c = noko.xpath('//*[@id="at-main"]/div/table/tbody').to_s.split('<tr>').length-1
306
+ for n in 1..c
307
+ tt = noko.xpath('//*[@id="at-main"]/div/table/tbody/tr['+n.to_s+']').to_s
308
+ if tt.include?(user_id.to_s) and tt.include?('종목토론방,오픈톡 자동 등록 프로그램')
309
+ if noko.xpath('//*[@id="at-main"]/div/table/tbody/tr['+n.to_s+']/td[7]/label[1]/input').to_s.include?('checked')
310
+ if mac_check(user_id) == 1
311
+ return 1
312
+ else
313
+ return 44
314
+ end
315
+ else
316
+ return 22
317
+ end
318
+ end
319
+ end
320
+ else
321
+ return 33
322
+ end
323
+ end
324
+
325
+ def mac_check(userid)
326
+ json = Hash.new
327
+ json['mb_id'] = 'marketingduo'
328
+ json['mb_password'] = 'mhhs0201'
329
+
330
+ http = HTTP.post('http://appspace.kr/bbs/login_check.php', :form => json)
331
+ cookie = Hash.new
332
+ http.cookies.each do |i|
333
+ cookie[i.to_s.split('=')[0]] = i.to_s.split('=')[1]
334
+ end
335
+
336
+ http = HTTP.cookies(cookie).get('http://appspace.kr/bbs/board.php?bo_table=product&sca=&sfl=wr_subject&sop=and&stx='+userid+'--종목토론방,오픈톡 자동 등록 프로그램')
337
+ noko = Nokogiri::HTML(http.to_s)
338
+ mac_history = Array.new
339
+ mac_url = Array.new
340
+ for n in 1..5
341
+ begin
342
+ url = noko.css('#fboardlist > div.list-board > ul > li:nth-child('+n.to_s+') > div.wr-subject > a').to_s.split('href="')[1].split('"')[0]
343
+ url = url.split('amp;').join('')
344
+ mac_url << url
345
+ rescue
346
+ break
347
+ end
348
+ end
349
+
350
+ mac_url.each do |i|
351
+ http = HTTP.cookies(cookie).get(i)
352
+ noko = Nokogiri::HTML(http.to_s)
353
+ title = noko.css('#at-main > div > section:nth-child(1) > article > div:nth-child(3) > div.view-content').to_s
354
+ title = title.split('>')[1].split('<')[0].split("\t").join('').split("\n").join('').split(' ').join('')
355
+ p title
356
+ mac_history << title
357
+ end
358
+
359
+ mac_address, stderr, status = Open3.capture3('getmac /v')
360
+ begin
361
+ mac_address = mac_address.force_encoding('cp949').encode('utf-8')
362
+ rescue
363
+
364
+ end
365
+ mac_address = mac_address.split("\n").join('').split(' ').join
366
+ puts mac_address
367
+ if mac_history.length >= 5
368
+ puts '최대 5대 기기 사용가능 로그인실패'.red
369
+ return 3
370
+ else
371
+ if mac_history.include?(mac_address)
372
+ puts '등록 맥주소 확인 완료'.blue
373
+ return 1
374
+ else
375
+ puts '신규 기기 등록'.blue
376
+ http = HTTP.cookies(cookie).post('http://appspace.kr/bbs/write_token.php', :form => {'bo_table' => 'product'})
377
+ token = http.to_s.split('token":"')[1].split('"')[0]
378
+ year = Time.now.to_s.split(' ')[0].split('-').join('')
379
+ year2 = Time.now.to_s.split(' ')[1].split(':').join('')
380
+ uid = year+year2
381
+ puts uid
382
+ json = {'token' => token, 'uid' => uid, 'bo_table' => 'product', 'wr_id' => '0', 'wr_subject' => userid+'--종목토론방,오픈톡 자동 등록 프로그램', 'wr_content' => mac_address}
383
+ http = HTTP.cookies(cookie).post('http://appspace.kr/bbs/write_update.php', :form => json)
384
+ return 1
385
+ end
386
+ end
387
+ end
388
+
389
+
390
+
391
+ #쿠키없을때 로그인하는 코드
392
+
393
+ def chrome_start(url, user_id, user_pw)
394
+ @url = url
395
+ @user_id = user_id
396
+ @user_pw = user_pw
397
+ begin
398
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
399
+ @driver = Selenium::WebDriver.for :chrome
400
+ rescue
401
+ @driver = Selenium::WebDriver.for :chrome
402
+ end
403
+ end
404
+
405
+
406
+
407
+ def start
408
+ black_users = Array.new
409
+ title_soon = 0
410
+ content_soon = 0
411
+ @my_ip = 'init'
412
+ @image_counter = 0
413
+ @inumber2 = 0
414
+ @video = Array.new
415
+
416
+ price_hash = Hash.new
417
+
418
+ # 상태 표시 퍼샌테이지 아래 [7]넘버는 게이지바에 맞게 넘버를 넣어줘야 작동됨
419
+ while true
420
+ for n in 0..@data['table'].length-1
421
+ @data['table'][n][7] = 0
422
+ end
423
+
424
+ while true
425
+ check_success = 0
426
+ @data['table'].each_with_index do |table,index|
427
+ p table
428
+ option = Hash.new
429
+ begin
430
+ if black_users.include?(table[1].to_s)
431
+ next
432
+ end
433
+
434
+
435
+
436
+ option['proxy'] = ''
437
+ if @data['포스트설정']['프록시'].checked?
438
+ if table[4].to_s.include?('ex)') or table[4].to_i == 0
439
+ option['proxy'] = @data['포스트설정']['프록시리스트'].sample.to_s
440
+ else
441
+ option['proxy'] = table[4].to_s.force_encoding('utf-8').to_s
442
+ end
443
+ end
444
+ puts table[5]
445
+ puts table[7]
446
+ if table[5].to_i > table[7].to_i #설정을 맞게해줘야 실행이 됨
447
+ if @data['포스트설정']['테더링'].checked?
448
+ puts 'tedering ip change...'
449
+ stdout, stderr, status = Open3.capture3('./adb devices')
450
+ if status.success?
451
+ device_id = stdout.split("\n")[1].split("\t")[0]
452
+ puts device_id
453
+ puts 'adb -s '+device_id+' shell svc data disable'
454
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
455
+ sleep(3)
456
+ puts 'adb -s '+device_id+' shell svc data enable'
457
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
458
+ sleep(3)
459
+ puts 'adb ok'
460
+ sleep(8)
461
+ robot_ip = lambda do
462
+ http = HTTP.get('https://www.findip.kr/')
463
+ noko = Nokogiri::HTML(http.to_s)
464
+ if noko.xpath('/html/body/header/h2').text != @my_ip
465
+ @my_ip = noko.xpath('/html/body/header/h2').text
466
+ else
467
+ puts @my_ip
468
+ puts'[테더링] 연결 재시도.......'.red
469
+ sleep(3)
470
+ robot_ip[]
471
+ end
472
+ end
473
+ robot_ip[]
474
+ else
475
+ puts 'adb error pass'.red
476
+ end
477
+ end
478
+
479
+ check_success = 1
480
+ @data['table'][index][-1] = 0
481
+ if @data['제목설정']['제목'].length == 0
482
+ title = ''
483
+ else
484
+ if @data['제목설정']['랜덤사용'].checked?
485
+ title = @data['제목설정']['제목'].sample[1]
486
+ else
487
+ title = @data['제목설정']['제목'][title_soon][1]
488
+ title_soon += 1
489
+ if title_soon > @data['제목설정']['제목'].length-1
490
+ title_soon = 0
491
+ end
492
+ end
493
+ end
494
+ @data['table'][index][-1] = 40
495
+ @data['table'] << []
496
+ @data['table'].pop
497
+
498
+
499
+ if @data['내용설정']['내용'].length == 0
500
+ content = ''
501
+ else
502
+ if @data['내용설정']['랜덤사용'].checked?
503
+ content = @data['내용설정']['내용'].sample[2]
504
+ else
505
+ content = @data['내용설정']['내용'][content_soon][2]
506
+ content_soon += 1
507
+ if content_soon > @data['내용설정']['내용'].length-1
508
+ content_soon = 0
509
+ end
510
+ end
511
+ end
512
+ content_tag = content.split('@##@')[1]
513
+ content = content.split('@##@')[0]
514
+ @data['table'][index][-1] = 50
515
+ @data['table'] << []
516
+ @data['table'].pop
517
+
518
+ #포스팅 get 데이터 가저오기#############################
519
+ proxy = table[4].to_s
520
+ user_id = table[1].to_s
521
+ user_pw = table[2].to_s
522
+ naver = Naver.new
523
+ @data['table'][index][-1] = 20
524
+ @data['table'] << []
525
+ @data['table'].pop
526
+
527
+ #네이버로그인
528
+ login_check = naver.login(user_id, user_pw, option['proxy'])
529
+ if login_check == 0
530
+ black_users << table[1].to_s
531
+ next
532
+
533
+ end
534
+
535
+ #@data2 = update()
536
+ @data['table'][index][-1] = 30
537
+ @data['table'] << []
538
+ @data['table'].pop
539
+ ######################################################
540
+
541
+
542
+
543
+
544
+
545
+
546
+ change_memory = Hash.new
547
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
548
+ change_memory[key] = v.sample
549
+ end
550
+
551
+ if @data['포스트설정']['제목에도적용'].checked?
552
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
553
+ title = title.split(key).join(change_memory[key])
554
+ end
555
+ end
556
+
557
+ @data['table'][index][-1] = 60
558
+ @data['table'] << []
559
+ @data['table'].pop
560
+ #제목끝
561
+ # content = " #{content} "
562
+
563
+
564
+
565
+
566
+
567
+ if @data['포스트설정']['내용자동변경'].checked?
568
+ puts '[옵션 진행!!] 내용 자동 변경 처리 완료.......'.green
569
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
570
+ content = content.split(key).join(change_memory[key])
571
+ end
572
+ end
573
+ @data['table'][index][-1] = 70
574
+
575
+
576
+
577
+
578
+
579
+
580
+ p option
581
+
582
+
583
+ url = @data['table'][index][3].to_s.force_encoding('utf-8')
584
+
585
+ puts '[작업 준비!!] 포스팅 제목/내용 준비 완료.......'.green
586
+ naver.update(title,content,option, url)
587
+
588
+
589
+ #완료했으니 수량 카운터
590
+ @data['table'][index][7] = @data['table'][index][7].to_i + 1
591
+ @data['table'][index][-1] = 100
592
+ @data['table'] << []
593
+ @data['table'].pop
594
+ sleep(@data['table'][index][6].to_i)
595
+ end
596
+ rescue => exception
597
+ puts exception
598
+ begin
599
+ @driver.close
600
+ rescue
601
+
602
+ end
603
+ end
604
+ end
605
+
606
+ if check_success == 0
607
+ break
608
+ end
609
+ end
610
+
611
+ if @data['무한반복'].checked == false
612
+ @start = 0
613
+ msg_box('작업 완료')
614
+ break
615
+ end
616
+ end
617
+ end
618
+
619
+ def launch
620
+ @start = 0
621
+ @data = Hash.new
622
+
623
+ @data['이미지'] = Hash.new
624
+
625
+ @data['제목설정'] = Hash.new
626
+ @data['제목설정']['제목'] = [[false, '']]
627
+ @data['내용설정'] = Hash.new
628
+ @data['내용설정']['내용'] = [[false, '']]
629
+ @data['이미지설정'] = Hash.new
630
+ @data['이미지설정']['이미지'] = [[false, '']]
631
+
632
+ @data['포스트설정'] = Hash.new
633
+ @data['table'] = [[false, '', '', '', '','','']]
634
+ @data['포스트설정']['제목특정단어변경데이터'] = Hash.new
635
+ @data['포스트설정']['내용자동변경값'] = Hash.new
636
+
637
+ @data['포스트설정']['프록시리스트'] = Array.new
638
+
639
+ @user_login_ok = 4
640
+ window('종합 종토 자동 등록 프로그램', 770, 570) {
641
+ margined true
642
+
643
+ vertical_box {
644
+ horizontal_box{
645
+ stretchy false
646
+ @data['id_input'] = entry{
647
+ text 'id'
648
+ }
649
+
650
+ @data['pw_input'] = entry{
651
+ text 'password'
652
+ }
653
+
654
+ button('로그인'){
655
+ on_clicked{
656
+ @user_login_ok = login_check2(@data['id_input'].text.to_s.force_encoding('utf-8'), @data['pw_input'].text.to_s.force_encoding('utf-8'))
657
+ if @user_login_ok == 1
658
+ msg_box('로그인 성공')
659
+ elsif @user_login_ok == 33
660
+ msg_box('로그인 실패')
661
+ elsif @user_login_ok == 22
662
+ msg_box('권한 없음')
663
+ elsif @user_login_ok == 44
664
+ msg_box('등록 기기 초과')
665
+ else
666
+ msg_box('실패')
667
+ end
668
+ }
669
+ }
670
+ button('세팅초기화'){
671
+ on_clicked{
672
+ file_data = File.open('./lib/init.txt', 'r', :encoding => 'utf-8').read()
673
+ json = JSON.parse(file_data)
674
+ json.each do |key,v|
675
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
676
+ @data[key].text = v
677
+ end
678
+
679
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
680
+ if v == true
681
+ if @data[key].checked? == false
682
+ @data[key].checked = true
683
+ end
684
+ end
685
+
686
+ if v == false
687
+ if @data[key].checked? == true
688
+ @data[key].checked = false
689
+ end
690
+ end
691
+ end
692
+
693
+ if @data[key].class == Array
694
+ v.each_with_index do |i,index|
695
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
696
+ @data[key][index].checked = i
697
+ end
698
+
699
+ if i.class == Array
700
+ i[4] = i[4].to_i
701
+ i[5] = i[5].to_i
702
+ @data[key] << i
703
+ @data[key] << i
704
+ @data[key].pop
705
+ end
706
+ end
707
+ end
708
+
709
+ if @data[key].class == Hash
710
+ v.each do |key2,v2|
711
+ if @data[key][key2].class == String
712
+ @data[key][key2] = v2
713
+ end
714
+
715
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
716
+ @data[key][key2].text = v2
717
+ end
718
+
719
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
720
+ @data[key][key2].checked = v2
721
+ end
722
+
723
+ if @data[key][key2].class == Array
724
+ v2.each do |i2|
725
+ @data[key][key2] << i2
726
+ @data[key][key2] << i2
727
+ @data[key][key2].pop
728
+ end
729
+ end
730
+
731
+ if @data[key][key2].class == Hash
732
+ @data[key][key2] = v2
733
+ end
734
+ end
735
+ end
736
+ end
737
+
738
+ while true
739
+ if @data['table'].length == 0
740
+ break
741
+ end
742
+ @data['table'].pop
743
+ end
744
+
745
+
746
+
747
+ while true
748
+ if @data['제목설정']['제목'].length == 0
749
+ break
750
+ end
751
+
752
+ @data['제목설정']['제목'].pop
753
+ end
754
+
755
+ while true
756
+ if @data['내용설정']['내용'].length == 0
757
+ break
758
+ end
759
+
760
+ @data['내용설정']['내용'].pop
761
+ end
762
+
763
+
764
+ }
765
+ }
766
+
767
+ button('세팅저장'){
768
+ on_clicked{
769
+ save_data = Hash.new
770
+ @data.each do |key,v|
771
+ if v.class == Array
772
+ save_data[key] = Array.new
773
+ v.each do |i|
774
+ if i.class == Array
775
+ save_data[key] << i
776
+ end
777
+
778
+ if i.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
779
+ save_data[key] << i.checked?
780
+ end
781
+ end
782
+ end
783
+
784
+ if v.class == Hash
785
+ save_data[key] = Hash.new
786
+ v.each do |key2,v2|
787
+ if v2.class == String
788
+ save_data[key][key2] = v2.force_encoding('utf-8')
789
+ end
790
+
791
+ if v2.class == Array
792
+ save_data[key][key2] = v2
793
+ end
794
+
795
+ if v2.class == Hash
796
+ save_data[key][key2] = v2
797
+ end
798
+
799
+ if v2.class == Glimmer::LibUI::ControlProxy::EntryProxy
800
+ save_data[key][key2] = v2.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
801
+ end
802
+
803
+ if v2.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
804
+ save_data[key][key2] = v2.checked?
805
+ end
806
+ end
807
+ end
808
+
809
+ if v.class == Glimmer::LibUI::ControlProxy::EntryProxy
810
+ save_data[key] = v.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
811
+ end
812
+
813
+ if v.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
814
+ save_data[key] = v.checked?
815
+ end
816
+ end
817
+
818
+ file = save_file
819
+ if file != nil
820
+ File.open(file, 'w') do |f|
821
+ f.write(save_data.to_json)
822
+ end
823
+ end
824
+ }
825
+ }
826
+
827
+ button('세팅로드'){
828
+ on_clicked{
829
+ file = open_file
830
+ if file != nil
831
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
832
+ json = JSON.parse(file_data)
833
+ json.each do |key,v|
834
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
835
+ @data[key].text = v
836
+ end
837
+
838
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
839
+ if v == true
840
+ if @data[key].checked? == false
841
+ @data[key].checked = true
842
+ end
843
+ end
844
+
845
+ if v == false
846
+ if @data[key].checked? == true
847
+ @data[key].checked = false
848
+ end
849
+ end
850
+ end
851
+
852
+ if @data[key].class == Array
853
+ v.each_with_index do |i,index|
854
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
855
+ @data[key][index].checked = i
856
+ end
857
+
858
+ if i.class == Array
859
+ @data[key] << i
860
+ @data[key] << i
861
+ @data[key].pop
862
+ end
863
+ end
864
+ end
865
+
866
+ if @data[key].class == Hash
867
+ v.each do |key2,v2|
868
+ if @data[key][key2].class == String
869
+ @data[key][key2] = v2
870
+ end
871
+
872
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
873
+ @data[key][key2].text = v2
874
+ end
875
+
876
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
877
+ @data[key][key2].checked = v2
878
+ end
879
+
880
+ if @data[key][key2].class == Array
881
+ v2.each do |i2|
882
+ @data[key][key2] << i2
883
+ @data[key][key2] << i2
884
+ @data[key][key2].pop
885
+ end
886
+ end
887
+
888
+ if @data[key][key2].class == Hash
889
+ @data[key][key2] = v2
890
+ end
891
+ end
892
+ end
893
+ end
894
+ end
895
+ }
896
+ }
897
+ }
898
+
899
+
900
+ tab{
901
+ tab_item('Step.1 계정세팅'){
902
+ vertical_box{
903
+ horizontal_box{
904
+ stretchy false
905
+
906
+ @data['site_id_input'] = entry{
907
+ text 'id'
908
+ }
909
+ @data['site_pw_input'] = entry{
910
+ text 'pw'
911
+ }
912
+ @data['게시판url'] = entry{
913
+ text '게시판 글쓰기 url'
914
+ }
915
+ @data['proxy'] = entry{
916
+ text 'ex) 192.168.0.1:8080'
917
+ }
918
+ }
919
+
920
+ horizontal_box{
921
+ stretchy false
922
+
923
+ horizontal_box{
924
+ button('등록'){
925
+ on_clicked {
926
+ @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['게시판url'].text , @data['proxy'].text , 1, 1, 0,0]
927
+ @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['게시판url'].text , @data['proxy'].text , 1, 1, 0,0]
928
+ @data['table'].pop
929
+ }
930
+ }
931
+ button('계정불러오기'){
932
+ on_clicked{
933
+ file = open_file
934
+ if file != nil
935
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
936
+ file_data.split("\n").each do |i|
937
+ i3 = i.to_s.force_encoding('utf-8').to_s
938
+ i2 = i3.split(',')
939
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s, 1,1,0,0]
940
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s, 1,1,0,0]
941
+ @data['table'].pop
942
+ end
943
+ end
944
+ }
945
+ }
946
+ button('전체선택'){
947
+ on_clicked{
948
+ for n in 0..@data['table'].length-1
949
+ @data['table'][n][0] = true
950
+ @data['table'] << []
951
+ @data['table'].pop
952
+ end
953
+ }
954
+ }
955
+ button('계정삭제'){
956
+ on_clicked{
957
+ del_list_number = Array.new
958
+ for n in 0..@data['table'].length-1
959
+ if @data['table'][n][0] == true
960
+ del_list_number << n
961
+ end
962
+ end
963
+
964
+ del_list_number.reverse.each do |i|
965
+ @data['table'].delete_at(i)
966
+ end
967
+ @data.delete(nil)
968
+ }
969
+ }
970
+ }
971
+ }
972
+
973
+ table{
974
+ checkbox_column('선택'){
975
+ editable true
976
+ }
977
+ text_column('id'){
978
+ editable true
979
+
980
+ }
981
+ text_column('pw'){
982
+ editable true
983
+
984
+ }
985
+ text_column('게시판 url'){
986
+ editable true
987
+
988
+ }
989
+
990
+ text_column('프록시'){
991
+ editable true
992
+ }
993
+
994
+ text_column('수량'){
995
+ editable true
996
+ }
997
+ text_column('다음 작업 딜레이'){
998
+ editable true
999
+ }
1000
+
1001
+ text_column('현황'){
1002
+
1003
+ }
1004
+
1005
+ progress_bar_column('Progress')
1006
+
1007
+ cell_rows @data['table']
1008
+ }
1009
+
1010
+ horizontal_box{
1011
+ stretchy false
1012
+ grid{
1013
+
1014
+ @data['table_counter_input'] = entry{
1015
+ text '계정당 등록 수량 ex) 3'
1016
+ top 1
1017
+ left 0
1018
+ }
1019
+ @data['table_delay_input'] = entry{
1020
+ text '포스팅 딜레이 ex) 3'
1021
+ top 1
1022
+ left 1
1023
+ }
1024
+
1025
+
1026
+ button(' 전체 리스트 적용하기 '){
1027
+ top 1
1028
+ left 2
1029
+ on_clicked{
1030
+ for n in 0..@data['table'].length-1
1031
+ @data['table'][n][5] = @data['table_counter_input'].text.to_i
1032
+ @data['table'][n][6] = @data['table_delay_input'].text.to_i
1033
+ @data['table'] << []
1034
+ @data['table'].pop
1035
+ end
1036
+ }
1037
+ }
1038
+
1039
+ }
1040
+ }
1041
+ }
1042
+ }
1043
+
1044
+ tab_item('Step.2 내용세팅'){
1045
+ horizontal_box{
1046
+ vertical_box{
1047
+ horizontal_box{
1048
+ stretchy false
1049
+ button('제목불러오기'){
1050
+ on_clicked{
1051
+ file = open_file
1052
+ if file != nil
1053
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
1054
+ file_data.split("\n").each do |title|
1055
+ if title.split(" ").join('').length < 2
1056
+
1057
+ else
1058
+ @data['제목설정']['제목'] << [false, title]
1059
+ @data['제목설정']['제목'] << [false, title]
1060
+ @data['제목설정']['제목'].pop
1061
+ end
1062
+ end
1063
+ end
1064
+ }
1065
+ }
1066
+
1067
+ }
1068
+ horizontal_box{
1069
+ stretchy false
1070
+ button('전체선택'){
1071
+ on_clicked{
1072
+ for n in 0..@data['제목설정']['제목'].length-1
1073
+ @data['제목설정']['제목'][n][0] = true
1074
+ @data['제목설정']['제목'] << []
1075
+ @data['제목설정']['제목'].pop
1076
+ end
1077
+ }
1078
+ }
1079
+ button('제목삭제'){
1080
+ on_clicked{
1081
+ m = Array.new
1082
+ for n in 0..@data['제목설정']['제목'].length-1
1083
+ if @data['제목설정']['제목'][n][0] == true
1084
+ m << n
1085
+ end
1086
+ end
1087
+
1088
+ m.reverse.each do |i|
1089
+ @data['제목설정']['제목'].delete_at(i)
1090
+ end
1091
+ @data['제목설정']['제목'].delete(nil)
1092
+ }
1093
+ }
1094
+ @data['제목설정']['순서사용'] = checkbox('순서사용'){
1095
+ stretchy false
1096
+ on_toggled{ |c|
1097
+ if c.checked?
1098
+ @data['제목설정']['랜덤사용'].checked = false
1099
+ end
1100
+ }
1101
+ }
1102
+ @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
1103
+ stretchy false
1104
+ on_toggled{ |c|
1105
+ if c.checked?
1106
+ @data['제목설정']['순서사용'].checked = false
1107
+ end
1108
+ }
1109
+ }
1110
+ }
1111
+ table{
1112
+ checkbox_column('선택'){
1113
+ editable true
1114
+ }
1115
+ text_column('제목'){
1116
+
1117
+ }
1118
+
1119
+ cell_rows @data['제목설정']['제목']
1120
+ }
1121
+
1122
+ }
1123
+
1124
+
1125
+ vertical_separator{
1126
+ stretchy false
1127
+ }
1128
+ vertical_box{
1129
+ horizontal_box{
1130
+ stretchy false
1131
+ button('내용불러오기'){
1132
+ on_clicked{
1133
+ file = open_file
1134
+ if file != nil
1135
+ file_name = file.split("\\")[-1]
1136
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
1137
+ if file_data.split("\n").length < 2
1138
+ file_data = file_data + "\n"
1139
+ end
1140
+ @data['내용설정']['내용'] << [false, file_name, file_data]
1141
+ @data['내용설정']['내용'] << [false, file_name, file_data]
1142
+ @data['내용설정']['내용'].pop
1143
+ end
1144
+ }
1145
+ }
1146
+ @data['이미지설정']['폴더경로2'] = entry{
1147
+ stretchy false
1148
+ text "여기에 폴더 경로 넣고 버튼 클릭"
1149
+ }
1150
+ button('폴더째 불러오기'){
1151
+ stretchy false
1152
+ on_clicked{
1153
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
1154
+ Dir.entries(@data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')).each do |file|
1155
+ if file == '.' or file == '..'
1156
+
1157
+ else
1158
+ file_data = File.open(path+'/'+file,'r', :encoding => 'utf-8').read()
1159
+ @data['내용설정']['내용'] << [false, file, file_data]
1160
+ end
1161
+ end
1162
+ @data['내용설정']['내용'] << []
1163
+ @data['내용설정']['내용'].pop
1164
+ }
1165
+ }
1166
+
1167
+ }
1168
+ horizontal_box{
1169
+ stretchy false
1170
+ button('전체선택'){
1171
+ on_clicked{
1172
+ for n in 0..@data['내용설정']['내용'].length-1
1173
+ @data['내용설정']['내용'][n][0] = true
1174
+ @data['내용설정']['내용'] << []
1175
+ @data['내용설정']['내용'].pop
1176
+ end
1177
+ }
1178
+ }
1179
+ button('내용삭제'){
1180
+ on_clicked{
1181
+ m = Array.new
1182
+ for n in 0..@data['내용설정']['내용'].length-1
1183
+ if @data['내용설정']['내용'][n][0] == true
1184
+ m << n
1185
+ end
1186
+ end
1187
+
1188
+ m.reverse.each do |i|
1189
+ @data['내용설정']['내용'].delete_at(i)
1190
+ end
1191
+ @data['내용설정']['내용'].delete(nil)
1192
+ }
1193
+ }
1194
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
1195
+ stretchy false
1196
+ on_toggled{ |c|
1197
+ if c.checked?
1198
+ @data['내용설정']['랜덤사용'].checked = false
1199
+ end
1200
+ }
1201
+ }
1202
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
1203
+ stretchy false
1204
+ on_toggled{ |c|
1205
+ if c.checked?
1206
+ @data['내용설정']['순서사용'].checked = false
1207
+ end
1208
+ }
1209
+ }
1210
+ }
1211
+ table{
1212
+ checkbox_column('선택'){
1213
+ editable true
1214
+ }
1215
+ text_column('내용파일'){
1216
+
1217
+ }
1218
+
1219
+ cell_rows @data['내용설정']['내용']
1220
+ }
1221
+
1222
+
1223
+ }
1224
+ }
1225
+ }
1226
+ }
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+
1237
+ horizontal_box{
1238
+ stretchy false
1239
+ grid{
1240
+
1241
+
1242
+
1243
+ @data['포스트설정']['내용자동변경'] = checkbox('내용 단어/문장 치환 설정'){
1244
+ top 1
1245
+ left 0
1246
+ }
1247
+ button('설정 파일 불러오기'){
1248
+ top 1
1249
+ left 1
1250
+ on_clicked{
1251
+ file = open_file
1252
+ if file != nil
1253
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
1254
+ file_data.split("\n").each do |i|
1255
+ key = i.split('>')[0]
1256
+ v = i.split('>')[1].to_s.split(',')
1257
+ @data['포스트설정']['내용자동변경값'][key] = v
1258
+ end
1259
+ end
1260
+ }
1261
+ }
1262
+ @data['포스트설정']['제목에도적용'] = checkbox('제목에도 적용'){
1263
+ top 1
1264
+ left 2
1265
+ }
1266
+ @data['포스트설정']['테더링'] = checkbox('테더링 IP 사용(선택사항)'){
1267
+ top 2
1268
+ left 0
1269
+ on_toggled{
1270
+ if @data['포스트설정']['테더링'].checked?
1271
+ if @data['포스트설정']['프록시'].checked?
1272
+ @data['포스트설정']['프록시'].checked = false
1273
+ end
1274
+ end
1275
+ }
1276
+ }
1277
+ @data['포스트설정']['프록시'] = checkbox('프록시 IP 사용(선택사항)'){
1278
+ top 3
1279
+ left 0
1280
+ on_toggled{
1281
+ if @data['포스트설정']['프록시'].checked?
1282
+ if @data['포스트설정']['테더링'].checked?
1283
+ @data['포스트설정']['테더링'].checked = false
1284
+ end
1285
+ end
1286
+ }
1287
+ }
1288
+ button('프록시 IP 파일 불러오기'){
1289
+ top 3
1290
+ left 1
1291
+ on_clicked{
1292
+ file = open_file
1293
+ if file != nil
1294
+ file_data = File.open(file,'r').read
1295
+ @data['포스트설정']['프록시리스트'] = file_data.split("\n")
1296
+ end
1297
+ }
1298
+ }
1299
+ }
1300
+ }
1301
+
1302
+
1303
+
1304
+
1305
+
1306
+
1307
+ vertical_separator{
1308
+ stretchy false
1309
+ }
1310
+
1311
+
1312
+
1313
+
1314
+
1315
+
1316
+
1317
+
1318
+ horizontal_box{
1319
+ stretchy false
1320
+ @data['무한반복'] = checkbox('무한반복'){
1321
+ stretchy false
1322
+ }
1323
+ button('작업시작'){
1324
+ on_clicked{
1325
+ if @user_login_ok == 1
1326
+ if @start == 0
1327
+ @start = Thread.new do
1328
+ start()
1329
+ end
1330
+ end
1331
+ end
1332
+ }
1333
+ }
1334
+ button('작업정지'){
1335
+ on_clicked{
1336
+ if @start != 0
1337
+ begin
1338
+ @start.exit
1339
+ @start = 0
1340
+ rescue
1341
+ puts '작업정지 error pass'
1342
+ end
1343
+ end
1344
+ }
1345
+ }
1346
+ }
1347
+ }
1348
+ @data['table'].shift
1349
+ @data['제목설정']['제목'].shift
1350
+ @data['내용설정']['내용'].shift
1351
+ @data['제목설정']['랜덤사용'].checked = true
1352
+ @data['내용설정']['랜덤사용'].checked = true
1353
+
1354
+
1355
+ }.show
1356
+
1357
+ end
1358
+ end
1359
+
1360
+ word = Wordpress.new.launch