-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.cgi
executable file
·167 lines (142 loc) · 4.87 KB
/
install.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
function urldecode() {
cat > /tmp/urldecode.sed << \EOF
s/%25/%/gi
s/%20/ /gi
s/%09/ /gi
s/%21/!/gi
s/%22/"/gi
s/%23/#/gi
s/%24/\$/gi
s/%26/\&/gi
s/%27/'\''/gi
s/%28/(/gi
s/%29/)/gi
s/%2a/\*/gi
s/%2b/+/gi
s/%2c/,/gi
s/%2d/-/gi
s/%2e/\./gi
s/%2f/\//gi
s/%3a/:/gi
s/%3b/;/gi
s/%3d/=/gi
s/%3e//gi
s/%3f/?/gi
s/%40/@/gi
s/%5b/\[/gi
s/%5c/\\/gi
s/%5d/\]/gi
s/%5e/\^/gi
s/%5f/_/gi
s/%60/`/gi
s/%7b/{/gi
s/%7c/|/gi
s/%7d/}/gi
s/%7e/~/gi
s/%09/ /gi
EOF
echo $1 | sed -f /tmp/urldecode.sed
rm -f /tmp/urldecode.sed
}
function msg() {
if [ ${HTTP_ACCEPT_LANGUAGE:0:2} = 'ja' ]; then
L=2
else
L=1
fi
MSG[10]="XOOPS Cube Legacy (XOOPS X) Setup"
MSG[20]="XOOPS Cube Legacy (XOOPS X) セットアップ"
MSG[11]=""xoops_trust_path" Settting"
MSG[21]=""xoops_trust_path" の設定"
MSG[12]="Please set server path of your "xoops_trust_path"."
MSG[22]="サーバー上に配置する "xoops_trust_path" のパスを指定してください。<br>できる限りドキュメントルート外に指定してください。ただし、PHP からアクセスできる場所に限ります。"
MSG[13]="HTTPS Proxy Config : <br>(Optional)"
MSG[23]="HTTPS プロキシ : <br>(任意設定)"
MSG[14]="(Optional)Please set proxy address for your server.<br>(e.g.) https://proxyuser:[email protected]:8080<br><span class="text-warning">WARNING: This option will override server's environment variable!</span>"
MSG[24]="必要であれば、あなたの環境で利用する HTTPS プロキシの指定をしてください。<br>(例) https://proxyuser:[email protected]:8080<br><span class="text-warning">注意事項: サーバーの環境変数「HTTPS_PROXY」を上書きします。</span>"
MSG[15]="OK & Upload & Please Wait"
MSG[25]="OK & アップロード & 少々お待ちください"
MSG[16]="Getting XOOPS X (ten) and extracting..."
MSG[26]="XOOPS X (ten) のパッケージを取得しサーバー上に配置しています..."
MSG[17]="Goto your XOOPS Cube Legacy installer"
MSG[27]="クリックして XOOPS Cube Legacy のインストーラーへ進む"
echo ${MSG[$L$1]}
}
function showForm() {
cat <<EOT
<h1 class="page-header">$(msg 0)</h1>
<h2>$(msg 1)</h2>
<form method="get" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="TRUST">xoops_trust_path : </label>
<div class="controls">
<input id="TRUST" name="TRUST" class="span6" style="height:30px" type="text" value="$1">
<p class="help-block">$(msg 2)</p>
</div>
</div>
<hr>
<div class="control-group">
<label class="control-label" for="https_proxy">$(msg 3)</label>
<div class="controls">
<input id="HTTPS_PROXY" name="HTTPS_PROXY" class="span6" style="height:30px;" type="text" value="$HTTPS_PROXY">
<p class="help-block">$(msg 4)</p>
</div>
</div>
<div class="form-actions">
<input type="submit" class="btn btn-primary" value="$(msg 5)">
</div>
</form>
EOT
}
# http header
echo -e "Content-Type: text/html; charset=UTF-8\n"
# decode QUERY_STRING
if [ $QUERY_STRING ]; then
saveIFS=$IFS
IFS='=&'
parm=($QUERY_STRING)
IFS=$saveIFS
for ((i=0; i<${#parm[@]}; i+=2))
do
declare ${parm[i]}=${parm[i+1]} >/dev/null 2>&1
done
export HTTPS_PROXY=$(urldecode $HTTPS_PROXY)
fi
# get document root
if [ $DOCUMENT_ROOT ]; then
DR=$DOCUMENT_ROOT
else
DR=`pwd`
fi
# output
echo "<html><head>"
echo "<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">"
echo "<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>"
echo "</head><body>"
if [ ! $TRUST ]; then
showForm "$(dirname ${DR})/xoops_trust_path"
else
TRUST=`echo $TRUST | sed 's/%2F/\//g'`
MSG=`mkdir $TRUST 2>&1`
if [ -d ${TRUST} ]; then
chmod 0600 ./${0##*/}
rm ./${0##*/}
if [ -e ./${0##*/} ]; then
perl -e "unlink(\"./${0##*/}\");"
fi
echo "<h1 class="page-header">$(msg 0)</h1>"
echo "<p class="lead">$(msg 6)</p>"
echo "<pre style=\"height:55%;overflow:auto;\">"
curl xoopsx.github.io/installer/install.sh|sed "s#<T>#$TRUST#"|sh 2>&1|cat
echo "</pre>"
echo "<div class="form-actions"><a href=\"./install/index.php\" class=\"btn btn-success\">$(msg 7)</a></div>"
else
echo "<div><span class=\"label label-important\">$MSG</span></div>"
if [ ${TRUST} = "${DR}/xoops_trust_path" ]; then
DR=`pwd`
fi
showForm "${DR}/xoops_trust_path"
fi
fi
echo "</body></html>"