InPanel 1.2.1__py3-none-any.whl

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 (198) hide show
  1. inpanel/__init__.py +29 -0
  2. inpanel/acme.py +289 -0
  3. inpanel/aliyuncs.py +269 -0
  4. inpanel/app.py +514 -0
  5. inpanel/apt.py +223 -0
  6. inpanel/base.py +200 -0
  7. inpanel/config.py +139 -0
  8. inpanel/data/config.ini +29 -0
  9. inpanel/data/history +5 -0
  10. inpanel/data/runlogs.ini +12 -0
  11. inpanel/data/update_info.ini +4 -0
  12. inpanel/dnf.py +225 -0
  13. inpanel/lib/__init__.py +9 -0
  14. inpanel/lib/async_process.py +98 -0
  15. inpanel/lib/filelock.py +82 -0
  16. inpanel/lib/magic.py +233 -0
  17. inpanel/lib/pxssh.py +310 -0
  18. inpanel/lib/pyDes.py +867 -0
  19. inpanel/mod/__init__.py +0 -0
  20. inpanel/mod/apt.py +316 -0
  21. inpanel/mod/certificate.py +268 -0
  22. inpanel/mod/config.py +372 -0
  23. inpanel/mod/cron.py +315 -0
  24. inpanel/mod/disk.py +322 -0
  25. inpanel/mod/dnf.py +239 -0
  26. inpanel/mod/file.py +722 -0
  27. inpanel/mod/firewall.py +199 -0
  28. inpanel/mod/firewall_base.py +137 -0
  29. inpanel/mod/firewall_firewalld.py +170 -0
  30. inpanel/mod/firewall_iptables.py +176 -0
  31. inpanel/mod/firewall_macos.py +213 -0
  32. inpanel/mod/firewall_ufw.py +128 -0
  33. inpanel/mod/ftp.py +231 -0
  34. inpanel/mod/httpd.py +1205 -0
  35. inpanel/mod/lighttpd.py +26 -0
  36. inpanel/mod/login.py +98 -0
  37. inpanel/mod/mysql.py +577 -0
  38. inpanel/mod/named.py +26 -0
  39. inpanel/mod/nginx.py +2327 -0
  40. inpanel/mod/package.py +33 -0
  41. inpanel/mod/package_apt.py +62 -0
  42. inpanel/mod/package_base.py +77 -0
  43. inpanel/mod/package_dnf.py +62 -0
  44. inpanel/mod/package_map.py +366 -0
  45. inpanel/mod/package_yum.py +64 -0
  46. inpanel/mod/php.py +289 -0
  47. inpanel/mod/process.py +291 -0
  48. inpanel/mod/proftpd.py +26 -0
  49. inpanel/mod/pureftpd.py +26 -0
  50. inpanel/mod/query.py +108 -0
  51. inpanel/mod/server.py +1319 -0
  52. inpanel/mod/service.py +262 -0
  53. inpanel/mod/setting.py +228 -0
  54. inpanel/mod/shell.py +78 -0
  55. inpanel/mod/ssh.py +280 -0
  56. inpanel/mod/system.py +220 -0
  57. inpanel/mod/task.py +1337 -0
  58. inpanel/mod/ufw.py +14 -0
  59. inpanel/mod/user.py +306 -0
  60. inpanel/mod/vsftpd.py +67 -0
  61. inpanel/mod/yum.py +243 -0
  62. inpanel/plugins/__init__.py +10 -0
  63. inpanel/plugins/__pycache__/__init__.cpython-313.pyc +0 -0
  64. inpanel/plugins/acme/static/index.html +10 -0
  65. inpanel/plugins/acme/static/index.js +13 -0
  66. inpanel/plugins/shadowsocks-libev/__pycache__/info.cpython-313.pyc +0 -0
  67. inpanel/plugins/shadowsocks-libev/info.py +73 -0
  68. inpanel/plugins/shadowsocks-libev/static/index.html +70 -0
  69. inpanel/plugins/shadowsocks-libev/static/index.js +18 -0
  70. inpanel/public/css/global.css +138 -0
  71. inpanel/public/favicon.ico +0 -0
  72. inpanel/public/images/alipay.jpg +0 -0
  73. inpanel/public/images/loading.gif +0 -0
  74. inpanel/public/images/weixin.jpg +0 -0
  75. inpanel/public/index.html +94 -0
  76. inpanel/public/js/controllers/controllers.js +566 -0
  77. inpanel/public/js/controllers/database.js +590 -0
  78. inpanel/public/js/controllers/ecs.js +624 -0
  79. inpanel/public/js/controllers/file.js +940 -0
  80. inpanel/public/js/controllers/plugins.js +105 -0
  81. inpanel/public/js/controllers/service.js +1460 -0
  82. inpanel/public/js/controllers/site.js +1241 -0
  83. inpanel/public/js/controllers/utils.js +2319 -0
  84. inpanel/public/js/core.js +221 -0
  85. inpanel/public/js/directives.js +784 -0
  86. inpanel/public/js/filters.js +395 -0
  87. inpanel/public/js/services.js +257 -0
  88. inpanel/public/lib/angular/1.0.2/angular-resource.min.js +10 -0
  89. inpanel/public/lib/angular/1.0.2/angular.min.js +158 -0
  90. inpanel/public/lib/bootstrap/css/bootstrap-theme.css +587 -0
  91. inpanel/public/lib/bootstrap/css/bootstrap-theme.css.map +1 -0
  92. inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css +6 -0
  93. inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css.map +1 -0
  94. inpanel/public/lib/bootstrap/css/bootstrap.css +6757 -0
  95. inpanel/public/lib/bootstrap/css/bootstrap.css.map +1 -0
  96. inpanel/public/lib/bootstrap/css/bootstrap.min.css +6 -0
  97. inpanel/public/lib/bootstrap/css/bootstrap.min.css.map +1 -0
  98. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  99. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
  100. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  101. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  102. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
  103. inpanel/public/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
  104. inpanel/public/lib/bootstrap/img/glyphicons-halflings.png +0 -0
  105. inpanel/public/lib/bootstrap/js/bootstrap.js +2377 -0
  106. inpanel/public/lib/bootstrap/js/bootstrap.min.js +7 -0
  107. inpanel/public/lib/bootstrap/js/npm.js +13 -0
  108. inpanel/public/lib/codemirror/codemirror-compressed.js +1 -0
  109. inpanel/public/lib/codemirror/codemirror.css +173 -0
  110. inpanel/public/lib/jquery/jquery-1.12.4.min.js +5 -0
  111. inpanel/public/lib/md5/md5.js +379 -0
  112. inpanel/public/lib/md5/md5.min.js +1 -0
  113. inpanel/public/partials/database/index.html +172 -0
  114. inpanel/public/partials/database/mysql/dbedit.html +462 -0
  115. inpanel/public/partials/database/mysql/dbnew.html +348 -0
  116. inpanel/public/partials/database/mysql/useredit.html +310 -0
  117. inpanel/public/partials/database/mysql/usernew.html +97 -0
  118. inpanel/public/partials/directives/message.html +20 -0
  119. inpanel/public/partials/directives/navbar.html +25 -0
  120. inpanel/public/partials/directives/selector.html +57 -0
  121. inpanel/public/partials/directives/srvbase.html +72 -0
  122. inpanel/public/partials/directives/srvext.html +34 -0
  123. inpanel/public/partials/directives/srvfile.html +23 -0
  124. inpanel/public/partials/directives/srvinstall.html +34 -0
  125. inpanel/public/partials/directives/srvlog.html +23 -0
  126. inpanel/public/partials/directives/srvminiop.html +28 -0
  127. inpanel/public/partials/directives/srvuninstall.html +38 -0
  128. inpanel/public/partials/directives/srvupdate.html +30 -0
  129. inpanel/public/partials/ecs/account.html +156 -0
  130. inpanel/public/partials/ecs/ecs.html +198 -0
  131. inpanel/public/partials/ecs/index.html +40 -0
  132. inpanel/public/partials/ecs/setings.html +459 -0
  133. inpanel/public/partials/file/file.html +501 -0
  134. inpanel/public/partials/file/trash.html +95 -0
  135. inpanel/public/partials/ftp.html +36 -0
  136. inpanel/public/partials/log.html +83 -0
  137. inpanel/public/partials/login.html +79 -0
  138. inpanel/public/partials/logout.html +22 -0
  139. inpanel/public/partials/main.html +534 -0
  140. inpanel/public/partials/plugins/index.html +55 -0
  141. inpanel/public/partials/plugins/plugins.html +13 -0
  142. inpanel/public/partials/secure.html +13 -0
  143. inpanel/public/partials/service/apache.html +147 -0
  144. inpanel/public/partials/service/cron.html +71 -0
  145. inpanel/public/partials/service/index.html +293 -0
  146. inpanel/public/partials/service/iptables.html +40 -0
  147. inpanel/public/partials/service/lighttpd.html +63 -0
  148. inpanel/public/partials/service/mariadb.html +113 -0
  149. inpanel/public/partials/service/memcache.html +36 -0
  150. inpanel/public/partials/service/minio.html +44 -0
  151. inpanel/public/partials/service/mongodb.html +44 -0
  152. inpanel/public/partials/service/mysql.html +113 -0
  153. inpanel/public/partials/service/named.html +61 -0
  154. inpanel/public/partials/service/nginx.html +296 -0
  155. inpanel/public/partials/service/ntp.html +40 -0
  156. inpanel/public/partials/service/php.html +250 -0
  157. inpanel/public/partials/service/proftpd.html +59 -0
  158. inpanel/public/partials/service/pureftpd.html +59 -0
  159. inpanel/public/partials/service/redis.html +40 -0
  160. inpanel/public/partials/service/samba.html +58 -0
  161. inpanel/public/partials/service/sendmail.html +40 -0
  162. inpanel/public/partials/service/ssh.html +186 -0
  163. inpanel/public/partials/service/tomcat.html +65 -0
  164. inpanel/public/partials/service/vsftpd.html +195 -0
  165. inpanel/public/partials/setting.html +299 -0
  166. inpanel/public/partials/site/apache/site.html +277 -0
  167. inpanel/public/partials/site/index.html +344 -0
  168. inpanel/public/partials/site/nginx/site.html +558 -0
  169. inpanel/public/partials/sorry.html +19 -0
  170. inpanel/public/partials/storage/autofm.html +103 -0
  171. inpanel/public/partials/storage/backup.html +42 -0
  172. inpanel/public/partials/storage/index.html +360 -0
  173. inpanel/public/partials/storage/migrate.html +93 -0
  174. inpanel/public/partials/storage/movedata.html +98 -0
  175. inpanel/public/partials/storage/remote.html +77 -0
  176. inpanel/public/partials/utils/cron.html +486 -0
  177. inpanel/public/partials/utils/firewall.html +266 -0
  178. inpanel/public/partials/utils/index.html +193 -0
  179. inpanel/public/partials/utils/network.html +118 -0
  180. inpanel/public/partials/utils/process.html +239 -0
  181. inpanel/public/partials/utils/repository.html +373 -0
  182. inpanel/public/partials/utils/shell.html +28 -0
  183. inpanel/public/partials/utils/ssl.html +319 -0
  184. inpanel/public/partials/utils/time.html +109 -0
  185. inpanel/public/partials/utils/user.html +359 -0
  186. inpanel/public/robots.txt +2 -0
  187. inpanel/remote.py +109 -0
  188. inpanel/templates/file/preview.html +34 -0
  189. inpanel/templates/index.html +93 -0
  190. inpanel/utils.py +282 -0
  191. inpanel/web.py +1811 -0
  192. inpanel/yum.py +756 -0
  193. inpanel-1.2.1.dist-info/METADATA +399 -0
  194. inpanel-1.2.1.dist-info/RECORD +198 -0
  195. inpanel-1.2.1.dist-info/WHEEL +5 -0
  196. inpanel-1.2.1.dist-info/entry_points.txt +2 -0
  197. inpanel-1.2.1.dist-info/licenses/LICENSE +30 -0
  198. inpanel-1.2.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,566 @@
1
+ var LoginCtrl = [
2
+ '$scope', '$rootScope', '$location', 'Module', 'Message', 'Request',
3
+ function ($scope, $rootScope, $location, Module, Message, Request) {
4
+ var module = 'login';
5
+ Module.init(module, '登录');
6
+ $scope.loginText = '登录';
7
+ $scope.errorText = '';
8
+ $scope.showForgetPwdMsg = false;
9
+ $scope.loaded = true;
10
+ $scope.username = '';
11
+ $scope.password = '';
12
+
13
+ var password_strength = function (pwd) {
14
+ var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
15
+ var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
16
+ var enoughRegex = new RegExp("(?=.{6,}).*", "g");
17
+ if (false == enoughRegex.test(pwd)) {
18
+ return '无安全性可言';
19
+ } else if (strongRegex.test(pwd)) {
20
+ return '高';
21
+ } else if (mediumRegex.test(pwd)) {
22
+ return '一般';
23
+ } else {
24
+ return '低';
25
+ }
26
+ };
27
+
28
+ $scope.login = function (rawpwd) {
29
+ $scope.errorText = '';
30
+ if ($scope.username.replace(/(^\s*)|(\s*$)/g, '') === '') {
31
+ $scope.errorText = '用户名不能为空!';
32
+ return
33
+ }
34
+ if ($scope.password.replace(/(^\s*)|(\s*$)/g, '') === '') {
35
+ $scope.errorText = '密码不能为空!';
36
+ return
37
+ }
38
+ $scope.loginText = '登录中...';
39
+ Request.post('/api/login', {
40
+ username: $scope.username,
41
+ password: rawpwd ? $scope.password : hex_md5($scope.password)
42
+ }, function (data) {
43
+ if (data.code >= 0) {
44
+ $scope.loaded = false;
45
+ var path = $rootScope.loginto ? $rootScope.loginto : '/';
46
+ var section = $rootScope.loginto_section;
47
+ if (data.code == 0) {
48
+ $location.path(path);
49
+ if (section) {
50
+ $scope.sec(section);
51
+ }
52
+ } else {
53
+ // need to check the password strength
54
+ $scope.pwdStrength = password_strength($scope.password);
55
+ if ($scope.pwdStrength != '高') {
56
+ Message.setError(false);
57
+ Message.setWarning(false);
58
+ $('#main').hide();
59
+ $scope.loginMessage = data.msg;
60
+ $scope.loginWarning = true;
61
+ } else {
62
+ $location.path(path);
63
+ if (section) {
64
+ $scope.sec(section);
65
+ }
66
+ }
67
+ }
68
+ } else {
69
+ $scope.loginText = '登录';
70
+ }
71
+ });
72
+ };
73
+ }
74
+ ];
75
+
76
+ var LogoutCtrl = [
77
+ '$scope', '$location', 'Module', 'Request', 'Timeout',
78
+ function ($scope, $location, Module, Request, Timeout) {
79
+ var module = 'logout';
80
+ Module.init(module, '退出登录');
81
+ $scope.loaded = false;
82
+ Timeout(function () {
83
+ $scope.loaded = true;
84
+ Request.get('/api/xsrf', function () {
85
+ Request.post('/api/logout', {}, function (data) {
86
+ Timeout(function () {
87
+ $location.path('/');
88
+ }, 3000, module);
89
+ });
90
+ });
91
+ }, 1000, module);
92
+ }
93
+ ];
94
+
95
+ var deepUpdate = function (orgObj, newObj) {
96
+ for (i in newObj) {
97
+ if (typeof (newObj[i]) == 'object') {
98
+ deepUpdate(orgObj[i], newObj[i]);
99
+ } else {
100
+ if (orgObj[i] != newObj[i]) {
101
+ orgObj[i] = newObj[i];
102
+ }
103
+ }
104
+ }
105
+ };
106
+
107
+ var MainCtrl = [
108
+ '$scope', '$routeParams', '$location', 'Module', 'Timeout', 'Request',
109
+ function ($scope, $routeParams, $location, Module, Timeout, Request) {
110
+ var module = 'main';
111
+ Module.init(module, '首页');
112
+ Module.initSection('server');
113
+ $scope.version = {};
114
+ $scope.info = null;
115
+ $scope.loaded = false;
116
+
117
+ $scope.detectVer = true;
118
+ $scope.hasNewver = false;
119
+ $scope.auto_refresh = false;
120
+
121
+ $scope.load = function () {
122
+ $scope.loadInfo('**');
123
+ $scope.checkUpVersion();
124
+ };
125
+
126
+ $scope.checkUpVersion = function () {
127
+ Request.get('/api/version', function (res) {
128
+ $scope.version = res.data;
129
+ $scope.checkNewVersion();
130
+ });
131
+ }
132
+
133
+ $scope.checkNewVersion = function () {
134
+ Request.get('/api/setting/upver', function (data) {
135
+ if (data.code == -1) {
136
+ $scope.upverMessage = data.msg;
137
+ } else if (data.code == 0) {
138
+ var v = data.data;
139
+ if (
140
+ !!v && parseFloat(v.version) > parseFloat($scope.version.version)
141
+ ) {
142
+ $scope.detectVer = false;
143
+ $scope.hasNewver = true;
144
+ }
145
+ }
146
+ });
147
+ };
148
+
149
+ $scope.checkUpdate = function () {
150
+ $location.path('/setting');
151
+ $scope.sec('upversion');
152
+ }
153
+
154
+ $scope.loadInfo = function (items) {
155
+ if (!items) items = '*';
156
+ Request.get('/api/query/' + items, function (data) {
157
+ if ($scope.info == null) {
158
+ $scope.info = data;
159
+ $scope.info['server.cpustat']['total']['used_rate'] = '获取中...';
160
+ for (var i = 0; i < data['server.netifaces'].length; i++) {
161
+ $scope.info['server.netifaces'][i]['rx_speed'] = '0';
162
+ $scope.info['server.netifaces'][i]['tx_speed'] = '0';
163
+ }
164
+ if (!$scope.loaded) $scope.loaded = true;
165
+ } else {
166
+ if ($scope.info) {
167
+ // caculate the cpu usage
168
+ var stat = data['server.cpustat']['total'];
169
+ var orgstat = $scope.info['server.cpustat']['total'];
170
+ var used = (stat['used'] - orgstat['used']) / (stat['all'] - orgstat['all']);
171
+ used = Math.round(used * 10000) * 10;
172
+ var idle = 100000 - used;
173
+ used = ((used + 1) / 1000).toString();
174
+ idle = ((idle + 1) / 1000).toString();
175
+ stat['used_rate'] = used.substring(0, used.length - 1) + '%';
176
+ stat['idle_rate'] = idle.substring(0, idle.length - 1) + '%';
177
+ // caculate the network speeds
178
+ var ifs = data['server.netifaces'];
179
+ var orgifs = $scope.info['server.netifaces'];
180
+ for (var i = 0; i < ifs.length; i++) {
181
+ var td = ifs[i]['timestamp'] - orgifs[i]['timestamp'];
182
+ if (td > 0) {
183
+ ifs[i]['rx_speed'] = Math.round((ifs[i]['rx_bytes'] - orgifs[i]['rx_bytes']) / td);
184
+ ifs[i]['tx_speed'] = Math.round((ifs[i]['tx_bytes'] - orgifs[i]['tx_bytes']) / td);
185
+ }
186
+ }
187
+ }
188
+ deepUpdate($scope.info, data);
189
+ }
190
+ if ($scope.auto_refresh) {
191
+ Timeout($scope.loadInfo, 1000, module);
192
+ }
193
+ });
194
+ };
195
+
196
+ $scope.refresh = function () {
197
+ $scope.loadInfo();
198
+ };
199
+ $scope.auto_refresh_open = function () {
200
+ $scope.auto_refresh = true;
201
+ $scope.loadInfo();
202
+ };
203
+ $scope.auto_refresh_close = function () {
204
+ $scope.auto_refresh = false;
205
+ };
206
+ }
207
+ ];
208
+
209
+ var FtpCtrl = [
210
+ '$scope', 'Module',
211
+ function ($scope, Module) {
212
+ var module = 'ftp';
213
+ Module.init(module, 'FTP管理');
214
+ $scope.loaded = false;
215
+
216
+ var section = Module.getSection();
217
+ $scope.load = function () {
218
+ $scope.loaded = true;
219
+ if (section && section == 'users') {
220
+ $scope.loadUsers();
221
+ } else if (section && section == 'process') {
222
+ $scope.loadProcess();
223
+ } else {
224
+ $scope.loadUsers();
225
+ }
226
+ }
227
+ $scope.loadUsers = function () {
228
+ $scope.sec('users');
229
+ Module.setSection('users');
230
+ };
231
+ $scope.loadProcess = function () {
232
+ $scope.sec('process');
233
+ Module.setSection('process');
234
+ };
235
+ }
236
+ ];
237
+
238
+ var BackupCtrl = ['$scope', 'Module',
239
+ function ($scope, Module) {
240
+ var module = 'backup';
241
+ Module.init(module, '备份管理');
242
+ $scope.loaded = false;
243
+
244
+ var section = Module.getSection();
245
+ $scope.load = function () {
246
+ $scope.loaded = true;
247
+ if (section && section == 'files') {
248
+ $scope.loadFiles();
249
+ } else if (section && section == 'database') {
250
+ $scope.loadDatabase();
251
+ } else if (section && section == 'remote') {
252
+ $scope.loadRemote();
253
+ } else {
254
+ $scope.loadFiles();
255
+ }
256
+ }
257
+ $scope.loadFiles = function () {
258
+ $scope.sec('files');
259
+ Module.setSection('files');
260
+ };
261
+ $scope.loadDatabase = function () {
262
+ $scope.sec('database');
263
+ Module.setSection('database');
264
+ };
265
+ $scope.loadRemote = function () {
266
+ $scope.sec('remote');
267
+ Module.setSection('remote');
268
+ };
269
+ }
270
+ ];
271
+
272
+ var SecureCtrl = [
273
+ '$scope', 'Module',
274
+ function ($scope, Module) {
275
+ var module = 'secure';
276
+ Module.init(module, '安全管理');
277
+ $scope.loaded = true;
278
+ }
279
+ ];
280
+
281
+ var LogCtrl = [
282
+ '$scope', 'Module',
283
+ function ($scope, Module) {
284
+ var module = 'log';
285
+ Module.init(module, '日志管理');
286
+ $scope.loaded = true;
287
+ }
288
+ ];
289
+
290
+ var SettingCtrl = [
291
+ '$scope', '$routeParams', 'Module', 'Timeout', 'Message', 'Request',
292
+ function ($scope, $routeParams, Module, Timeout, Message, Request) {
293
+ var module = 'setting';
294
+ Module.init(module, '系统设置');
295
+ Module.initSection('authinfo');
296
+ $scope.version = {};
297
+ $scope.newVersion = '';
298
+ $scope.newReleasetime = '';
299
+ $scope.showUpdateBtn = false;
300
+ $scope.showRestartBtn = true;
301
+ $scope.loaded = true;
302
+ $scope.password = '';
303
+ $scope.passwordc = '';
304
+
305
+ $scope.load = function () {
306
+ Request.get('/api/version', function (res) {
307
+ $scope.version = res.data;
308
+ $scope.checkUpVersion();
309
+ });
310
+ }
311
+
312
+ $scope.loadAuthInfo = function () {
313
+ Request.get('/api/setting/auth', function (res) {
314
+ $scope.username = res.username;
315
+ $scope.passwordcheck = res.passwordcheck;
316
+ });
317
+ }
318
+ $scope.loadServerInfo = function () {
319
+ Request.get('/api/setting/server', function (res) {
320
+ $scope.forcehttps = res.forcehttps;
321
+ $scope.ip = res.ip;
322
+ $scope.port = res.port;
323
+ $scope.sslkey = res.sslkey;
324
+ $scope.sslcrt = res.sslcrt;
325
+ });
326
+ }
327
+ $scope.loadRuntimeInfo = function () {
328
+ Request.get('/api/setting/runtime', function (res) {
329
+ $scope.runtime_mode = res.mode;
330
+ });
331
+ }
332
+ $scope.loadAccessKey = function () {
333
+ Request.get('/api/setting/accesskey', function (res) {
334
+ $scope.accesskey = res.accesskey;
335
+ $scope.accesskeyenable = res.accesskeyenable;
336
+ });
337
+ }
338
+ $scope.updateAuthInfo = function () {
339
+ Request.post('/api/setting/auth', {
340
+ username: $scope.username,
341
+ password: $scope.password ? hex_md5($scope.password) : '',
342
+ passwordc: $scope.passwordc ? hex_md5($scope.passwordc) : '',
343
+ passwordcheck: $scope.passwordcheck
344
+ }, function (res) {
345
+ if (res.code == 0) $scope.loadAuthInfo();
346
+ });
347
+ };
348
+ $scope.updateServerInfo = function () {
349
+ Request.post('/api/setting/server', {
350
+ forcehttps: $scope.forcehttps,
351
+ ip: $scope.ip,
352
+ port: $scope.port,
353
+ sslkey: $scope.sslkey,
354
+ sslcrt: $scope.sslcrt
355
+ }, function (res) {
356
+ if (res.code == 0) $scope.loadServerInfo();
357
+ });
358
+ };
359
+
360
+ $scope.updateRuntimeInfo = function () {
361
+ Request.post('/api/setting/runtime', {
362
+ mode: $scope.runtime_mode
363
+ }, function (res) {
364
+ if (res.code == 0) $scope.loadRuntimeInfo();
365
+ });
366
+ };
367
+
368
+ // ssl selector
369
+ $scope.selectsslcrt = function () {
370
+ $scope.selector_title = '请选择证书文件(*.crt)';
371
+ $scope.selector.onlydir = false;
372
+ $scope.selector.onlyfile = true;
373
+ $scope.selector.load('/');
374
+ $scope.selector.selecthandler = function (path) {
375
+ $('#selector').modal('hide');
376
+ $scope.sslcrt = path;
377
+ };
378
+ $('#selector').modal();
379
+ };
380
+ $scope.selectsslkey = function () {
381
+ $scope.selector_title = '请选择私钥文件(*.key)';
382
+ $scope.selector.onlydir = false;
383
+ $scope.selector.onlyfile = true;
384
+ $scope.selector.load('/');
385
+ $scope.selector.selecthandler = function (path) {
386
+ $('#selector').modal('hide');
387
+ $scope.sslkey = path;
388
+ };
389
+ $('#selector').modal();
390
+ };
391
+
392
+ $scope.updateAccessKey = function () {
393
+ Request.post('/api/setting/accesskey', {
394
+ accesskey: $scope.accesskey,
395
+ accesskeyenable: $scope.accesskeyenable
396
+ }, function (res) {
397
+ if (res.code == 0) $scope.loadAccessKey();
398
+ });
399
+ };
400
+ $scope.checkUpVersion = function () {
401
+ $scope.upverMessage = '正在检测新版本...';
402
+ Request.get('/api/setting/upver?force=1', function (data) {
403
+ if (data.code == -1) {
404
+ $scope.upverMessage = data.msg;
405
+ } else if (data.code == 0) {
406
+ var v = data.data;
407
+ if (
408
+ !!v && parseFloat(v.version.split('.').join('')) > parseFloat($scope.version.version.split('.').join(''))
409
+ ) {
410
+ $scope.upverMessage = '<table class="table table-hover table-bordered">' +
411
+ '<thead><tr><th colspan="2">有可用的新版本</th></tr></thead>' +
412
+ '<tbody><tr><td style="width: 200px;">版本信息:</td><td>v' + v.version + '</td></tr>' +
413
+ '<tr><td>发布时间:</td><td>' + v.releasetime + '</td></tr>' +
414
+ '<tr><td>变更记录:</td><td><a href="' + v.changelog + '" target="_blank">' +
415
+ '查看版本变更记录</a></td></tr></tbody></table>';
416
+ $scope.updateBtnText = '开始在线升级';
417
+ $scope.showUpdateBtn = true;
418
+ $scope.newVersion = v.version;
419
+ $scope.newReleasetime = v.releasetime;
420
+ } else {
421
+ $scope.upverMessage = '当前已是最新版本!';
422
+ }
423
+ }
424
+ });
425
+ };
426
+ $scope.update = function () {
427
+ $scope.upverMessage = '正在升级,请稍候...'
428
+ $scope.showUpdateBtn = false;
429
+ Request.post('/api/backend/update', {}, function (data) {
430
+ var getUpdateStatus = function () {
431
+ Request.get('/api/backend/update', function (data) {
432
+ Message.setInfo('')
433
+ if (data.msg) $scope.upverMessage = data.msg;
434
+ if (data.code == -1) {
435
+ return false;
436
+ } else if (data.status == 'finish' && data.code == 0) {
437
+ // restart service
438
+ $scope.upverMessage = '正在重启 InPanel...';
439
+ Timeout(function () {
440
+ Request.post('/api/backend/service_restart', {
441
+ service: 'inpanel'
442
+ }, function (data) {
443
+ var getRestartStatus = function () {
444
+ Request.get('/api/backend/service_restart_inpanel', function (data) {
445
+ Message.setInfo('')
446
+ if (data.msg) $scope.upverMessage = data.msg;
447
+ Timeout(getRestartStatus, 500, module);
448
+ }, function (data, status) { // error occur because server is terminate
449
+ if (status == 403 || status == 0) {
450
+ $scope.upverMessage = '升级成功!请刷新页面重新登录。';
451
+ $scope.forceUpdateStatic();
452
+ return false;
453
+ }
454
+ return true;
455
+ });
456
+ };
457
+ Timeout(getRestartStatus, 500, module);
458
+ });
459
+ }, 1000, module);
460
+ } else {
461
+ Timeout(getUpdateStatus, 500, module);
462
+ }
463
+ });
464
+ };
465
+ Timeout(getUpdateStatus, 500, module);
466
+ });
467
+ };
468
+ $scope.restartMessage = '是否要重启 InPanel 服务 ?';
469
+ $scope.restart = function () {
470
+ $scope.restartMessage = '正在重启,请稍候...'
471
+ $scope.showRestartBtn = false;
472
+ Timeout(function () {
473
+ Request.post('/api/backend/service_restart', {
474
+ service: 'inpanel'
475
+ }, function (data) {
476
+ var getRestartStatus = function () {
477
+ Request.get('/api/backend/service_restart_inpanel', function (data) {
478
+ if (data.msg) $scope.restartMessage = data.msg;
479
+ Timeout(getRestartStatus, 500, module);
480
+ }, function (data, status) { // error occur because server is terminate
481
+ if (status == 403 || status == 0) {
482
+ $scope.restartMessage = '重启成功!请刷新页面重新登录。';
483
+ return false;
484
+ }
485
+ return true;
486
+ });
487
+ };
488
+ Timeout(getRestartStatus, 500, module);
489
+ });
490
+ }, 1000, module);
491
+ };
492
+
493
+ $scope.genaccesskey = function () {
494
+ var randstring = '';
495
+ for (var i = 0; i < 32; i++) {
496
+ randstring += String.fromCharCode(Math.floor(256 * Math.random()));
497
+ }
498
+
499
+ // JS base64 REF: http://stackoverflow.com/questions/246801/how-can-you-encode-to-base64-using-javascript
500
+ var b64encode = function (input) {
501
+ var b64keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
502
+ var output = "";
503
+ var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
504
+ var i = 0;
505
+
506
+ while (i < input.length) {
507
+
508
+ chr1 = input.charCodeAt(i++);
509
+ chr2 = input.charCodeAt(i++);
510
+ chr3 = input.charCodeAt(i++);
511
+
512
+ enc1 = chr1 >> 2;
513
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
514
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
515
+ enc4 = chr3 & 63;
516
+
517
+ if (isNaN(chr2)) {
518
+ enc3 = enc4 = 64;
519
+ } else if (isNaN(chr3)) {
520
+ enc4 = 64;
521
+ }
522
+
523
+ output = output +
524
+ b64keyStr.charAt(enc1) + b64keyStr.charAt(enc2) +
525
+ b64keyStr.charAt(enc3) + b64keyStr.charAt(enc4);
526
+ }
527
+
528
+ return output;
529
+ };
530
+
531
+ $scope.accesskey = b64encode(randstring);
532
+ };
533
+
534
+ $scope.forceUpdateStatic = function () {
535
+ // 前端静态资源重新加载
536
+ $scope.version['version'] = $scope.newVersion;
537
+ $scope.version['releasetime'] = $scope.newReleasetime;
538
+ releasetime = $scope.newReleasetime;
539
+ _v = new Date($scope.newReleasetime.replace(/-/g, '/')).getTime() / 1000;
540
+ [
541
+ 'core',
542
+ 'services',
543
+ 'controllers/controllers',
544
+ 'controllers/service',
545
+ 'controllers/file',
546
+ 'controllers/site',
547
+ 'controllers/database',
548
+ 'controllers/ecs',
549
+ 'controllers/utils',
550
+ 'directives',
551
+ 'filters'
552
+ ].forEach(function (item) {
553
+ $.getScript('/js/' + item + '.js');
554
+ });
555
+ };
556
+ }
557
+ ];
558
+
559
+ var SorryCtrl = [
560
+ '$scope', 'Module', '$timeout',
561
+ function ($scope, Module, $timeout) {
562
+ var module = 'sorry';
563
+ Module.init(module, '页面不存在');
564
+ $scope.loaded = true;
565
+ }
566
+ ];