-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDownPlistCreator.php
More file actions
214 lines (172 loc) · 6.36 KB
/
DownPlistCreator.php
File metadata and controls
214 lines (172 loc) · 6.36 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
<?php
namespace CFPropertyList;
// 调试
error_reporting(0);
// error_reporting(0);
// ini_set( ‘display_errors’, ‘on’ );
/**
* Require CFPropertyList
*/
// require_once(__DIR__.’/../classes/CFPropertyList/CFPropertyList.php’);
require_once (__DIR__ . '/CFPropertyList/classes/CFPropertyList/CFPropertyList.php');
/**
*
*/
class DownPlistCreator
{
/**
* 根据传入的ipa文件生成供其下载使用的plist文件
*/
static public function createDownPlist( $ipaFilePath, $displayImagePath, $fullImagePath, $downPlistPath,
$bundleID,$bundleVersion) {
$downPlist = new CFPropertyList();
//添加root
$downPlist->add( $rootDict = new CFDictionary() );
$rootDict-> add( 'items', $itemsArray = new CFArray() );
$itemsArray->add($item0 = new CFDictionary());
$item0->add('assets', $assetsArray = new CFArray() );
$item0->add('metadata', $metadataDict = new CFDictionary() );
$assetsArray->add($asset0Dict = new CFDictionary());
$asset0Dict->add('kind',new CFString('software-package'));
// $asset0Dict->add('url',new CFString('https://192.168.0.110/new_app/pub_ipa/pipapai.ipa'));
$asset0Dict->add('url',new CFString($ipaFilePath));
$assetsArray->add($asset1Dict = new CFDictionary());
$asset1Dict->add('kind',new CFString('display-image'));
// $asset1Dict->add('url',new CFString('https://192.168.0.110/AppShop/app/gc.png'));
$asset1Dict->add('url',new CFString($displayImagePath));
$assetsArray->add($asset2Dict = new CFDictionary());
$asset2Dict->add('kind',new CFString('full-size-image'));
// $asset2Dict->add('url',new CFString('https://192.168.0.110/AppShop/app/gc.png'));
$asset2Dict->add('url',new CFString($fullImagePath));
// $metadataDict->add('bundle-identifier',new CFString('com.PIPAPAI.JobSeeker'));
// $metadataDict->add('bundle-version',new CFString('1.6.1'));
$metadataDict->add('bundle-identifier',new CFString($bundleID));
$metadataDict->add('bundle-version',new CFString($bundleVersion));
$metadataDict->add('kind',new CFString('software'));
$metadataDict->add('title',new CFString('pipapai'));
// $downPlist->saveBinary( "../new_app/pub_plist/down1.plist" );
$downPlist->saveBinary( $downPlistPath);
}
static public function readInfoPlist($infoPlistPath){
// echo $infoPlistPath;
// if (is_readable($infoPlistPath)) {
// echo 'The file is readable';
// } else {
// echo 'The file is not readable';
// }
// $infoPlist = new CFPropertyList($infoPlistPath,CFPropertyList::FORMAT_XML);
$infoPlist = new CFPropertyList($infoPlistPath);
foreach( $infoPlist->getValue(true) as $key => $value )
{
if( $key == "CFBundleIdentifier" )
{
$bundleID = $value->getValue();
}
if( $key == "CFBundleShortVersionString" )
{
$bundleVersion = $value->getValue();
}
// if( $value instanceof \Iterator )
// {
// // The value is a CFDictionary or CFArray, you may continue down the tree
// echo "xxxxxx".$key;
// echo '</br>';
// // echo $value->toArray();
// }else{
// echo "yyyyyy".$key.'::'.$value->getValue();
// echo '</br>';
// }
}
return array($bundleID,$bundleVersion);
// echo $bundleID->toArray() ;
// print_r($infoPlist->toArray());
// echo $infoPlist->toArray();
}
// static public 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;
// DownPlistCreator::readInfoPlist($infoPlistPath);
// }
}
// function tree($directory)
// {
// $mydir = dir($directory);
// echo "<ul>\n";
// while($file = $mydir->read())
// {
// if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!=".."))
// {
// echo "<li><font color=\"#ff00cc\"><b>$file</b></font></li>\n";
// tree("$directory/$file");
// }
// else
// echo "<li>$directory/$file</li>\n";
// }
// echo "</ul>\n";
// $mydir->close();
// }
// function listDir($dir)
// {
// if(is_dir($dir))
// {
// if ($dh = opendir($dir))
// {
// while (($file = readdir($dh)) !== false)
// {
// if((is_dir($dir."/".$file)) && $file!="." && $file!="..")
// {
// echo "<b><font color='red'>文件名:</font></b>",$file,"<br><hr>";
// listDir($dir."/".$file."/");
// }
// else
// {
// if($file!="." && $file!="..")
// {
// echo $file."<br>";
// }
// }
// }
// closedir($dh);
// }
// }
// }
?>