]> git.treefish.org Git - fex.git/blob - htdocs/fexitinstaller
Original release 20160919
[fex.git] / htdocs / fexitinstaller
1 #!/usr/bin/perl -w
2
3 $user = $ENV{USER};
4 $authid = $ENV{ID};
5 $url = "$ENV{PROTO}://$ENV{HTTP_HOST}";
6 $fi = 'fexitinstaller.cmd';
7 $id = '%USERPROFILE%\\fex\\id';
8 $fe = 'http://fex.belwue.de/download/fexit.exe';
9 $fx = '%USERPROFILE%\\Desktop\\fexit.exe';
10 $ps = '%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe';
11 $cmd = <<EOD;
12   mkdir "%USERPROFILE%\\fex"
13   if not exist "$id" (
14     echo $url>"$id"
15     echo $user>>"$id"
16     echo $authid>>"$id"
17   )
18   $ps -command "& { (New-Object Net.WebClient).DownloadFile('$fe','$fx') }"
19   setx PATH "%PATH%;%USERPROFILE%\\Desktop"
20   \@echo.
21   \@set /p x="See fexit on Desktop."
22 EOD
23 #  \@explorer "%USERPROFILE%\\Desktop"
24 $cmd =~ s/^  //gm;
25 $cmd =~ s/\n/\r\n/g;
26
27 if (chdir "$::spooldir/$user" and open $fi,'>',$fi) {
28   print {$fi} $cmd;
29   close $fi;
30   system "$::FEXHOME/bin/fexsend ".
31          "-oKq -C 'fexit for your Windows desktop' $fi $user >/dev/null 2>&1";
32   if ($? == 0) {
33     print "<p>\n";
34     print "<h3>A fexit installer has been sent to you. Check your email.</h3>\n";
35   }
36   unlink $fi;
37 }
38
39 return '';