/
runthisapp.php
102 lines (86 loc) · 1.94 KB
/
runthisapp.php
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
<?php
require_once __DIR__ . '/lib/cfpropertylist/CFPropertyList.php';
require_once __DIR__ . '/asn.php';
//Step 1 check needed params:
if (!isset($_GET['udid'], $_GET['app'], $_GET['ver']))
{
die('parameters udid, app and ver are needed');
}
//step 2 check that user is allowed to dl this app and this version:
//TODO using $_GET["udid"]
//step3 check that this app is already signed for this udid
//if not sign it.
function isAppSignedForUdid($udid, $app, $ver)
{
$plistValue = __DIR__ . '/app/AppSalesMobile/Payload/AppSalesMobile.app/embedded.mobileprovision';
$plistValue = retreivePlistFromAsn($plistValue);
if (empty($plistValue)) {
die("unable to read plist from configuration profile challenge.");
}
$plist = new CFPropertyList();
$plist->parse($plistValue, CFPropertyList::FORMAT_AUTO);
$plistData = $plist->toArray();
$provisionedDevices = $plistData['ProvisionedDevices'];
$found = false;
foreach ($provisionedDevices as $device)
{
if (strtoupper($device) == strtoupper($udid)) {
return true;
}
}
return false;
}
$isAppSigned = isAppSignedForUdid($_GET['udid'], $_GET['app'], $_GET['ver']);
//step4 provid link to dld app
?>
<html>
<head>
<script src="js/jquery-1.6.1.min.js"></script>
<script>
function showTheLink(bool) {
if (bool) {
$("#link").css("display", "inline");
$("#wait").css("display", "none");
} else {
$("#link").css("display", "none");
$("#wait").css("display", "inline");
}
}
</script>
<style>
#link {
display: none;
}
</style>
</head>
<body>
<span id="link">
here is your link: <a href="toto.ipa"><?php echo $_GET['app'] ?></a>
</span>
<?php
if ($isAppSigned) {
?>
<script>
showTheLink(true);
</script>
<?php
} else {
?>
<span id="wait">
Please Wait...
</span>
<script>
$.ajax({
type: "POST",
url: "sign.php",
data: "app=<?php echo $_GET['app'] ?>&ver=<?php echo $_GET['ver'] ?>&udid=<?php echo $_GET['udid'] ?>",
success: function(msg){
showTheLink(true);
}
});
</script>
<?php
}
?>
</body>
</html>