-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck.php
More file actions
398 lines (340 loc) · 13.5 KB
/
check.php
File metadata and controls
398 lines (340 loc) · 13.5 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
//在显示登录界面之前,首先判断是否保存了用户登录信息,如果有,则自动登录
error_reporting(0);
header('Content-type: text/html; charset=utf-8');
include('conn_mysql.php');
include('DownPlistCreator.php');
session_start();
?>
<html>
<head>
<meta charset="utf-8">
<title>AppShop--Pipapai.inc</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Loading Bootstrap -->
<link href="/AppShop/Flat-UI-master/dist/css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Loading Flat UI -->
<link href="/AppShop/Flat-UI-master/dist/css/flat-ui.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
<script src="../../dist/js/vendor/html5shiv.js"></script>
<script src="../../dist/js/vendor/respond.min.js"></script>
<![endif]-->
<style type="text/css">
.text {
height: 65px;
overflow: hidden;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="container">
<nav role="navigation" class="navbar navbar-inverse navbar-embossed navbar-lg">
<div class="navbar-header">
<button data-target="#bs-example-navbar-collapse-17" data-toggle="collapse" class="navbar-toggle" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="../index.php" class="navbar-brand">AppShop</a>
</div>
<?php
if($_SESSION[UserName]!=''){
?>
<div id="bs-example-navbar-collapse-17" class="collapse navbar-collapse">
<p class="navbar-text navbar-right"><a class="navbar-link" href="logout.php">退出</a></p>
<p class="navbar-text navbar-right"><a class="navbar-link" href="./member/membercenter.php"><?php echo $_SESSION[UserName]; ?></a></p>
</div>
<?php
}else{
?>
<div id="bs-example-navbar-collapse-17" class="collapse navbar-collapse">
<p class="navbar-text navbar-right"><a class="navbar-link" href="login.php">登录</a></p>
</div>
<?php
}
?>
</nav>
<?php
// include('local_ip.php');
header('Content-type: text/html; charset=utf-8');
// 定义一个函数getIP()
function getIP()
{
global $ip;
if (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else $ip = "Unknow";
return $ip;
}
function getInfoPlist($ipaFilePath){
$dirPath = dirname($ipaFilePath);
$fileExtension = pathinfo($ipaFilePath, PATHINFO_EXTENSION);
$dirPath = $dirPath.'/'.basename($ipaFilePath,'.'.$fileExtension);
// echo $dirPath;
if (!file_exists($dirPath)) {
mkdir($dirPath);
}
$zip=new ZipArchive();//新建一个ZipArchive的对象
if($zip->open($ipaFilePath)===TRUE){
$zip->extractTo($dirPath);//假设解压缩到在当前路径下images文件夹内
$zip->close();//关闭处理的zip文件
}
$payloadPath = $dirPath."/Payload";
// echo $payloadPath;
// $payloadDir = opendir($payloadPath);
// $copyPath = readdir($payloadDir);
// echo $copyPath;
$infoPlistPath;
if(is_dir($payloadPath))
{
if ($dh = opendir($payloadPath))
{
while (($file = readdir($dh)) !== false)
{
if((is_dir($payloadPath."/".$file)) && $file!="." && $file!="..")
{
// echo "<b><font color='red'>文件名:</font></b>",$file,"<br><hr>";
$infoPlistPath = $payloadPath."/".$file."/Info.plist";
}
else
{
if($file!="." && $file!="..")
{
// echo $file."<br>";
}
}
}
closedir($dh);
}
}
// echo $infoPlistPath;
return $infoPlistPath;
// readInfoPlist($infoPlistPath);
}
function deleteAll($path) {
$op = dir($path);
while(false != ($item = $op->read())) {
if($item == '.' || $item == '..') {
continue;
}
if(is_dir($op->path.'/'.$item)) {
deleteAll($op->path.'/'.$item);
rmdir($op->path.'/'.$item);
} else {
unlink($op->path.'/'.$item);
}
}
rmdir($path);
}
$ipd=getIP();
if($_POST['submit']){
if (!is_uploaded_file($_FILES["upfile"]['tmp_name']))
{
?>
<h4>上传失败!请选择要上传的文件!</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
$app_name1 = $_FILES["upfile"]['name'];
include('conn_mysql.php');
$sql="select distinct app_name from new_app_info where app_name= '$app_name1' and app_status=1 and app_power in (1,2,3) ";
$result1=mysqli_query($conn,$sql);
@ $row = mysqli_fetch_array($result1);
if($app_name1==$row[app_name]){
?>
<h4>上传失败!<?php echo $app_name1 ?>该APP已经存在,请先删除后,再试一次</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
$ar=explode('.',$app_name1);
$lcy=count($ar);
if($_POST[style] ==''){
?>
<h4>上传失败!请选择安装平台!</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
if($ar[$lcy-1] =="ipa" || $ar[$lcy-1]=="apk"){
}
else{
?>
<h4>上传失败!文件类型不正确,请选择正确的文件类型!</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$ServerUrl=$_SERVER['DOCUMENT_ROOT'];
if($_POST['release']=="1"){
if($ar[$lcy-1] =="ipa")
{
$project_id = $_POST['project'];
$sql="select * from new_config_prj where prj_num = $project_id";
$result1=mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result1)){
$project_name =$row[prj_name];
}
//$destination_folder="./new_app/pub_ipa/"; //上传文件路径
$destination_folder="/new_app/pub_ipa/"; //上传文件路径
$file = $_FILES["upfile"];
$filename=$file["tmp_name"];
$pinfo=pathinfo($file["name"]);
$ftype=$pinfo['basename'];
$destination_folder = $ServerUrl.$destination_folder;
if(!file_exists($destination_folder))
{
mkdir($destination_folder);
}
$destination = $destination_folder.$ftype;
if(!move_uploaded_file ($filename, $destination))
{
?>
<h4>移动文件出错</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
$infoPlistPath = getInfoPlist($destination);
$idAndversion = CFPropertyList\DownPlistCreator::readInfoPlist($infoPlistPath);
$fileNameMD5 = md5(basename($destination,".ipa"));
$downPlistPath = '../new_app/pub_plist/'.$fileNameMD5.'.plist';
$downFileIcon = 'https://192.168.1.175/new_app/project_icon/'.$project_name.'.png';
CFPropertyList\DownPlistCreator::createDownPlist('https://192.168.1.175/new_app/pub_ipa/'.basename($destination),$downFileIcon,
$downFileIcon,$downPlistPath,$idAndversion[0],$idAndversion[1]);
$unloadPackgePath = $destination_folder.basename($destination,".ipa");
deleteAll($unloadPackgePath);
// $na=explode('.',$app_name1);
// $su=array_pop($na);
// $string = implode('.',$na);
// $make_dir_command=$destination_folder."apptemp/auto_pub_bid '{$_SESSION['UserName']}' $app_name1 $string ";
// // echo $make_dir_command;
// // exit;
// exec($make_dir_command,$output,$return);
// if($return==0){
// echo "Plist文件生成成功!";
// }
// else{
// echo "Plist文件生成失败!";
// echo "xxxxxx";
// print_r($output);
// echo "xxxxxx";
// print_r($return);
// echo "xxxxxx";
// print_r($make_dir_command);
// exit;
// echo '<a href="./member/myapp.php">返回</a>';
// }
}
else{
$destination_folder="/new_app/pub_apk/"; //上传android文件路径
$file = $_FILES["upfile"];
$filename=$file["tmp_name"];
$pinfo=pathinfo($file["name"]);
$ftype=$pinfo['basename'];
$destination_folder = $ServerUrl.$destination_folder;
if(!file_exists($destination_folder))
{
mkdir($destination_folder);
}
$destination = $destination_folder.$ftype;
if(!move_uploaded_file ($filename, $destination))
{
?>
<h4>移动文件出错</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
}
}
if($_POST['release']=="2"){
if($ar[$lcy-1] =="ipa")
{
$project_id = $_POST['project'];
$sql="select * from new_config_prj where prj_num = $project_id";
$result1=mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result1)){
$project_name =$row[prj_name];
}
//$destination_folder="./new_app/pub_ipa/"; //上传文件路径
$destination_folder="/new_app/pri_ipa/"; //上传文件路径
$file = $_FILES["upfile"];
$filename=$file["tmp_name"];
$pinfo=pathinfo($file["name"]);
$ftype=$pinfo['basename'];
$destination_folder = $ServerUrl.$destination_folder;
if(!file_exists($destination_folder))
{
mkdir($destination_folder);
}
$destination = $destination_folder.$ftype;
if(!move_uploaded_file ($filename, $destination))
{
?>
<h4>移动文件出错</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
$infoPlistPath = getInfoPlist($destination);
$idAndversion = CFPropertyList\DownPlistCreator::readInfoPlist($infoPlistPath);
$fileNameMD5 = md5(basename($destination,".ipa"));
$downPlistPath = '../new_app/pri_plist/'.$fileNameMD5.'.plist';
$downFileIcon = 'https://192.168.1.175/new_app/project_icon/'.$project_name.'.png';
CFPropertyList\DownPlistCreator::createDownPlist('https://192.168.1.175/new_app/pri_ipa/'.basename($destination),$downFileIcon,
$downFileIcon,$downPlistPath,$idAndversion[0],$idAndversion[1]);
$unloadPackgePath = $destination_folder.basename($destination,".ipa");
deleteAll($unloadPackgePath);
}
else{
$destination_folder="./new_app/pri_apk/"; //上传android文件路径
$file = $_FILES["upfile"];
$filename=$file["tmp_name"];
$pinfo=pathinfo($file["name"]);
$ftype=$pinfo['basename'];
$destination = $destination_folder.$ftype;
if(!move_uploaded_file ($filename, $destination))
{
?>
<h4>移动文件出错</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
}
}
//插入数据
include('conn_mysql.php');
$app_name = $_FILES["upfile"]['name'];
$sql="insert into new_app_info (project,platform,version,app_name,app_status,app_power,add_time,add_name,add_ip,del_name) values('$_POST[project]','$_POST[style]','','$app_name','1','$_POST[release]',now(),'$_SESSION[UserName]','$ipd','')";
if( $result=mysqli_query($conn,$sql)){
?>
<h4>恭喜!您的文件上传成功!</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
else{
?>
<h4>数据插入失败!</h4>
<h4><a href="./member/membercenter.php">返回</a></h4>
<?php
exit;
}
}
?>
</div>
</body>
</html>