vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #perl2exe_include "Tk.pm";
|
2 | #perl2exe_include "Tk/DialogBox.pm"
|
||
3 | ##perl2exe_include "File/BSDGlob.pm"
|
||
4 | ##perl2exe_include "Compress/Bzip2.pm"
|
||
5 | |||
6 | use Tk; |
||
7 | require LWP::UserAgent; |
||
8 | |||
9 | |||
10 | |||
11 | my $message = ""; |
||
12 | my $url = "http://demo.dkpsystem.com"; |
||
13 | open(IN,"<url.txt"); |
||
14 | $url = <IN>; |
||
15 | close(IN); |
||
16 | my $myversion; |
||
17 | open(IN,"<GuildRaidSnapShot.toc"); |
||
18 | while(<IN>){ |
||
19 | if(/Version (\S+)/i){ |
||
20 | $myversion = $1; |
||
21 | } |
||
22 | } |
||
23 | close(IN); |
||
24 | |||
25 | my $mw = MainWindow->new; |
||
26 | $mw->title("GRSS DKP Downloader"); |
||
27 | $mw->Label(-text => "DKPSystem.com's GuildRaidSnapShot DKP Downloader",-foreground=>"darkred",-relief=>"groove")->pack; |
||
28 | $mw->Label(-text => "Enter the URL of your website")->pack; |
||
29 | $mw->Entry(-textvariable => \$url,-background=>"white",-width=>"30")->pack; |
||
30 | $mw->Label(-textvariable => \$message)->pack; |
||
31 | $mw->Button(-text => "Cancel",-width=>10,-command => sub {exit})->pack(-side=>"left",-anchor=>"s"); |
||
32 | $mw->Button(-text => "OK",-width=>10,-command => sub {&downloadfile($url)})->pack(-side=>"right",-anchor=>"s"); |
||
33 | MainLoop; |
||
34 | |||
35 | sub downloadfile |
||
36 | { |
||
37 | my $newurl = $_[0]; |
||
38 | $newurl = lc($newurl); |
||
39 | if($newurl =~ /^(?:http:\/\/)?([a-zA-Z0-9\.\-]+)/){ |
||
40 | $newurl = "http://$1/luadkp.php"; |
||
41 | $url = $1; |
||
42 | } |
||
43 | $message = "Downloading $newurl"; |
||
44 | |||
45 | my $ua = LWP::UserAgent->new; |
||
46 | $ua->timeout(25); |
||
47 | $ua->env_proxy; |
||
48 | |||
49 | my $response = $ua->get($newurl); |
||
50 | |||
51 | if ($response->is_success) { |
||
52 | open(OUT,">url.txt"); |
||
53 | print OUT $url; |
||
54 | close(OUT); |
||
55 | open(OUT,">GRSS_Data.lua"); |
||
56 | print OUT $response->content; |
||
57 | close(OUT); |
||
58 | $mw->Dialog(-title => "Downloaded!",-text => "The download was a success. Simply type /console reloadui in WoW, or close WoW and reopen it.", -buttons => ['OK'])->Show(); |
||
59 | #print "checking version my version $myversion\n";
|
||
60 | my $version = $ua->get("http://www.dkpsystem.com/grssversion"); |
||
61 | if($version->is_success){ |
||
62 | #print "Current Version ".$version->content."\n";
|
||
63 | if($version->content != $myversion){ |
||
64 | $newversion = $version->content; |
||
65 | $newversion =~ s/\n//gs; |
||
66 | my $yesno=$mw->Dialog(-title => "New Version!!",-text => "Would you like GRSS to Automatically download the new version '$newversion' for you?", -default_button => "Yes", -buttons => ['Yes','No'])->Show(); |
||
67 | if($yesno =~ /Yes/){ |
||
68 | &downloadpatch($ua); |
||
69 | } |
||
70 | } |
||
71 | } |
||
72 | exit; |
||
73 | }else{ |
||
74 | $mw->Dialog(-title => "Not Good...",-text => "Unfortunately, the URL entered didn't work. Make sure you have it entered properly and try again", -buttons => ['OK'])->Show(); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | sub downloadpatch |
||
79 | { |
||
80 | my $prefix = "http://www.dkpsystem.com/files/GRSS"; |
||
81 | my $ua = $_[0]; |
||
82 | my $status; |
||
83 | $status=&downloadindependentfile("$prefix/GuildRaidSnapShot.lua","GuildRaidSnapShot.lua",$ua); |
||
84 | $status=&downloadindependentfile("$prefix/GuildRaidSnapShot.toc","GuildRaidSnapShot.toc",$ua) if($status); |
||
85 | $status=&downloadindependentfile("$prefix/readme.txt","readme.txt",$ua) if($status); |
||
86 | $status=&downloadindependentfile("$prefix/GuildRaidSnapShot.xml","GuildRaidSnapShot.xml",$ua) if($status); |
||
87 | $status=&downloadindependentfile("$prefix/GRSSWaitingInvite.xml","GRSSWaitingInvite.xml",$ua) if($status); |
||
88 | if($status){ |
||
89 | $mw->Dialog(-title => "Successful",-text => "Patch downloaded successfully", -buttons => ['OK'])->Show(); |
||
90 | }else{ |
||
91 | my $yesno=$mw->Dialog(-title => "Upgrade Failed!",-text => "Patch download Failed! Try Again?", -default_button => "Yes",-buttons => ['Yes','No'])->Show(); |
||
92 | if($yesno =~ /Yes/){ |
||
93 | &downloadpatch($ua); |
||
94 | } |
||
95 | } |
||
96 | } |
||
97 | |||
98 | |||
99 | sub downloadindependentfile |
||
100 | { |
||
101 | my $newurl = $_[0]; |
||
102 | my $localfilename = $_[1]; |
||
103 | my $ua = $_[2]; |
||
104 | $message = "Downloading $newurl"; |
||
105 | |||
106 | my $ua = LWP::UserAgent->new; |
||
107 | $ua->timeout(25); |
||
108 | $ua->env_proxy; |
||
109 | |||
110 | my $response = $ua->get($newurl); |
||
111 | |||
112 | if ($response->is_success) { |
||
113 | open(OUT,">$localfilename"); |
||
114 | print OUT $response->content; |
||
115 | close(OUT); |
||
116 | return 1; |
||
117 | }else{ |
||
118 | return 0; |
||
119 | } |
||
120 | } |