-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
465 lines (431 loc) · 22.9 KB
/
index.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
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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
<?php
$repositoryServer = 'http://opensourcestore.info/s/';
$projectsDir = '.';
header("Content-Type: text/html; charset=UTF-8");
?><!DOCTYPE html>
<html>
<head>
<title>OSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<div class="container">
<a class="navbar-brand" href="index.php"> <img src="img/OSS.png" width="25px" height="25px"></a>
<a class="navbar-brand" href="?page=tools">Tools</a>
<a class="navbar-brand" href="?page=store">Store</a>
</div>
</div>
</nav>
<div class="container bs-docs-container"/>
<div class="row">
<?php
$storeError = false;
if((isset($_GET['page']) && $_GET['page'] === 'store') || isset($_GET["openSourceProject"])|| isset($_GET["category"])) {
if(false !== ($responseJson = @file_get_contents(sprintf($repositoryServer.'?action=%s', 'showCategories')))){?>
<div class="col-md-2">
<div class="bs-sidebar hidden-print" role="complementary">
<ul class="nav nav-pills nav-stacked">
<?php
$categories = json_decode($responseJson, true);
foreach($categories as $category){
?><li><a href="?category=<?php echo urlencode($category);?>"><?php echo urlencode($category);?></a></li><?php
}
?>
</ul>
</div>
</div>
<?php
}else{
?>
<div class="col-md-12">
<h2><span class="glyphicon glyphicon-warning-sign redSpan" ></span>Unable to join the open source store<span class="glyphicon glyphicon-warning-sign redSpan" ></h2>
<div>
The open source store is unjoinable, check your network or configuration.
</div>
</div>
<?php
$storeError = true;
}
}?>
<!-- show my apps -->
<?php
if(empty($_GET) || (isset($_GET['page']) && $_GET['page'] === 'tools')) {?>
<div class="col-md-12" role="main"><?php
$openSourceProjects = array();
$files = scandir($projectsDir);
foreach($files as $t) {
$projectDir = explode('_', $t);
if(2 === count($projectDir) && is_dir(sprintf('%s/%s', $projectsDir, $t))){
$projectName = $projectDir[0];
$projectVersion = $projectDir[1];
$openSourceProjects[] = array(
'name' => sprintf('%s (%s)', $projectName, $projectVersion),
'url' => sprintf('%s/%s', $projectsDir, $t),
'img' => sprintf('%s_%s/OSS_logo.png', $projectName, $projectVersion)
);
}
}
?><ul class="OSProjects"><?php
foreach($openSourceProjects as $openSourceProject){
?>
<li>
<a href="<?php if(isset($_GET["category"])){echo '?openSourceProject='.$openSourceProject['name'];}else{echo $openSourceProject['url'];}?>">
<div class="OSProjectIcon">
<img src="<?php echo $openSourceProject['img'];?>"/>
</div>
<div class="OSProjectName">
<?php echo $openSourceProject['name'];?>
</div>
</a>
</li>
<?php
}
?></ul>
</div>
<?php
}
else {?>
<!-- Show store apps -->
<?php if(false === $storeError) { ?>
<div class="col-md-10" role="main">
<?php
if(!isset($_GET["openSourceProject"])) {
$openSourceProjects = array();
if(isset($_GET["category"])) {
if(false !== ($responseJson = @file_get_contents(sprintf($repositoryServer.'?action=%s&category=%s', 'showOpenSourceProjects', $_GET["category"])))){
$openSourceProjects = json_decode($responseJson, true);
}
}
?><ul class="OSProjects"><?php
foreach($openSourceProjects as $openSourceProject){
//Download img
$projectImg = $openSourceProject['img'];
if(!is_file($projectImg)) {
if(false !== ($imgContent = @file_get_contents(sprintf('%s/%s', $repositoryServer, $projectImg)))){
file_put_contents($projectImg, $imgContent);
}
}
?>
<li>
<a href="<?php if(isset($_GET["category"])){echo '?openSourceProject='.$openSourceProject['name'];}else{echo $openSourceProject['url'];}?>">
<div class="OSProjectIcon">
<img src="<?php echo $openSourceProject['img'];?>"/>
</div>
<div class="OSProjectName">
<?php echo $openSourceProject['name'];?>
</div>
</a>
</li>
<?php
}
?></ul><?php
}
if(isset($_GET["openSourceProject"])) {
$version = 'last';
$projectType = 'zip';
$projectName=$_GET["openSourceProject"];
if(isset($_GET["version"])){
$version = $_GET["version"];
}
if(false !== ($responseJson = @file_get_contents(sprintf($repositoryServer.'?action=%s&openSourceProject=%s&version=%s', 'showOpenSourceProject', urlencode($_GET["openSourceProject"]), $version)))){
$openSourceProject = json_decode($responseJson, true);
$projectName=strtolower($openSourceProject['name']);
$version=$openSourceProject['version'];
$projectUrl = $openSourceProject['url'];
$projectImg = $openSourceProject['img'];
if(isset($openSourceProject['type'])){
$projectType = $openSourceProject['type'];
}
//Download img
if(!is_file($projectImg)) {
if(false !== ($imgContent = @file_get_contents(sprintf('%s/%s', $repositoryServer, $projectImg)))){
file_put_contents($projectImg, $imgContent);
}
}
?><div class="OSProject">
<div class="OSProjectHeader">
<div class="OSProjectIcon">
<img src="<?php echo $openSourceProject['img'];?>"/>
</div>
<div id="OSProjectVersion">
<?php
if(count($openSourceProject['versions']) > 1){?>
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<?php echo $openSourceProject['version'];?> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<?php
foreach($openSourceProject['versions'] as $versionTmp){
if($versionTmp !== $openSourceProject['version']){
?><li><a href="?openSourceProject=<?php echo $projectName;?>&version=<?php echo $versionTmp;?>"><?php echo $versionTmp;?></a></li><?php
}
}
?>
</ul>
</div>
<?php
}?>
</div>
<?php
$isInstalled = false;
if(is_dir(sprintf('%s_%s', strtolower($openSourceProject['name']), $openSourceProject['version']))) {
$isInstalled = true;
}
// Display download button OR goto button && delete button
?>
<div class="OSProjectPanelButton">
<button <?php if($isInstalled){echo ' style="display:none;" ';}?> id="OSProjectDownloadButton" class="btn btn-success OSProjectDownloadButton">Installer</button>
<a href="<?php echo sprintf('%s_%s', strtolower($openSourceProject['name']), $openSourceProject['version'].'/'); ?>" <?php if(!$isInstalled){echo ' style="display:none;" ';}?> id="OSProjectExecuteButton" class="btn btn-success">Executer</a>
<button <?php if(!$isInstalled){echo ' style="display:none;" ';}?> id="OSProjectDeleteButton" class="btn btn-danger">Supprimer</button>
<div id="OSProjectProgressBar" class="progress">
<div id="OSProjectProgressValue" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="90" style="width: 0%;">
<span class="sr-only">0% Complete</span>
</div>
</div>
</div>
</div>
<div class="divclear" />
<div>
<div class="redSpan" id="errorContainer">
<h3><span class="glyphicon glyphicon-warning-sign" >Error</h3>
<div id="errorMessage">
User and store package url are different
</div>
</div>
<div>
<h3>General informations</h3>
Application name: <?php echo $openSourceProject['name'];?>
<br/>
Author: <?php echo $openSourceProject['author'];?>
<br/>
<a href="<?php echo $openSourceProject['url'];?>">Package link</a>
<br/>
<a href="<?php echo $openSourceProject['link'];?>">Official Website</a>
<br/>
Version: <?php echo $openSourceProject['version'];?>
<br/>
Configuration:
<?php
if(isset($openSourceProject['configuration']) && $openSourceProject['configuration']){
?><span class="redSpan" title="You have to edit some files to configure the project" ><span class="glyphicon glyphicon-warning-sign" ></span><?php echo $openSourceProject['configuration'];?></span><?php
}else{
?><span class="greenSpan" title="The configuration is user friendly" ><span class="glyphicon glyphicon-thumbs-up"></span>Assisted</span><?php
}?>
<br/>
Database:
<?php
if(isset($openSourceProject['database']) && $openSourceProject['database']){
?><span class="redSpan" title="You have to configure some SQL access" ><span class="glyphicon glyphicon-warning-sign" ></span><?php echo $openSourceProject['database'];?></span><?php
}else{
?><span class="greenSpan" title="The datas are saved on web server" ><span class="glyphicon glyphicon-thumbs-up"></span>No database required</span><?php
}?>
<br/>
<?php
if(isset($openSourceProject['trust'])){
?>Trusted source: <span class="redSpan" title="This package is potentially unsafe" ><span class="glyphicon glyphicon-warning-sign"/>No</span><?php
}?>
</div>
<div>
<h3>Description</h3>
<div>
<?php echo $openSourceProject['description'];?>
</div>
</div>
<?php
if(isset($openSourceProject['features'])
&& count($openSourceProject['features']) > 0) { ?>
<div id="sceenShootsContainer">
<h3>Features</h3>
<ul>
<?php
foreach($openSourceProject['features'] as $feature) {
?><li><?php echo $feature;?></li><?php
}?>
</ul>
</div>
<?php
}
?>
<?php
if(isset($openSourceProject['screenshoots'])
&& count($openSourceProject['screenshoots']) > 0) { ?>
<div id="sceenShootsContainer">
<h3>Screenshoots</h3>
<div>
<?php
foreach($openSourceProject['screenshoots'] as $screenshoot) {
//Download img
if(!is_file($screenshoot)) {
if(false !== ($imgContent = file_get_contents(sprintf('%s/%s', $repositoryServer, $screenshoot)))){
file_put_contents($screenshoot, $imgContent);
}
}
?><img width="100%" alt="screenshoot" src="<?php echo $screenshoot; ?>" /><?php
}?>
</div>
</div>
<?php
}
?>
<div>
<h3>Debug technique</h3>
<?php echo $responseJson;?>
</div>
</div>
</div>
<?php
}
}?>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script>
var alertFallback = true;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
} else {
console.log = function() {};
}
}
$( ".categoryLink" ).click(function() {
$(this).parent().parent().children("ul li").attr("class", "");
$(this).parent().attr("class", "active");
$(this).parent().parent().children().children( "ul" ).slideUp("slow", function() {});
$(this).parent().children( "ul" ).slideDown( "slow", function() {});
});
</script>
<?php
if(isset($version)){
?>
<script>
var installationOver = false;
var projectFolder = '';
var getStatusInterval;
// Download and install Open Source Project
$( "#OSProjectDownloadButton" ).click(function() {
//start your long-running process
if(installationOver == false){
console.log('installation...');
$( "#OSProjectDownloadButton" ).attr('disabled', true);
$.ajax(
{
type: 'GET',
url: "install.php?version=" + "<?php echo $version; ?>"
+ "&openSourceProject=" + "<?php echo $projectName; ?>"
+ "&url=" + "<?php echo urlencode($projectUrl); ?>"
+ "&type=" + "<?php echo urlencode($projectType); ?>"
+ "&img=" + "<?php echo urlencode($projectImg); ?>",
async: true,
dataType: "json",
success:
function (data) {
clearInterval(getStatusInterval);
if(typeof(data.status) != "undefined" && data.status == 0){
installationOver = true;
projectFolder = data.name;
$( "#OSProjectDownloadButton" ).hide();
$( "#OSProjectDeleteButton" ).attr('disabled', false);
$( "#OSProjectExecuteButton" ).attr('disabled', false);
$( "#OSProjectExecuteButton" ).show();
$( "#OSProjectDeleteButton" ).show();
$( "#OSProjectProgressBar").css('visibility', 'hidden');
}else{
$("#errorContainer").show();
$("#errorMessage").text(data.message);
}
},
error: function (jqXHR, textStatus, errorThrown ) {
$("#errorContainer").show();
$("#errorMessage").text(textStatus);
},
});
$("#OSProjectProgressValue").width(0 + '%');
$( "#OSProjectProgressBar").css('visibility', 'visible');
getStatusInterval = setInterval("getStatus()", 2000);
}else{
console.log('Test...');
//Redirection on project folder
window.location= projectFolder;
}
});
// Check Progress of treatment and update progress bar
function getStatus() {
//check your progress
$.ajax(
{
type: 'GET',
url: "install.php?action=getProgress&version=" + "<?php echo $version; ?>" + "&openSourceProject=" + "<?php echo $projectName; ?>",
async: true,
dataType:"json",
success:
function (data) {
//assume the data returned in the percentage complete
var percentage = parseInt(data.progress);
console.log(data.progress);
//write your status somewhere, like a jQuery progress bar?
$("#OSProjectProgressValue").width(percentage + '%');
if(percentage >= 100){
clearInterval(getStatusInterval);
}
}
});
}
// Delete Open Source Project
$( "#OSProjectDeleteButton" ).click(function() {
//start your long-running process
console.log('suppression...');
$( "#OSProjectDeleteButton" ).attr('disabled', true);
$( "#OSProjectExecuteButton" ).hide();
$.ajax(
{
type: 'GET',
url: "install.php?action=delete&version=" + "<?php echo $version; ?>" + "&openSourceProject=" + "<?php echo $projectName; ?>",
async: true,
dataType: "json",
success:
function (data) {
console.log('suppression terminée');
clearInterval(getStatusInterval);
if(data.status == 0){
installationOver = false;
$( "#OSProjectDownloadButton" ).attr('disabled', false);
$( "#OSProjectDownloadButton" ).show();
$( "#OSProjectDeleteButton" ).hide();
$( "#OSProjectProgressBar").css('visibility', 'hidden');
}else{
console.log('probleme lors de la suppression');
}
}
});
$("#OSProjectProgressValue").width(0 + '%');
$( "#OSProjectProgressBar").css('visibility', 'visible');
getStatusInterval = setInterval("getStatus()", 2000);
});
</script>
<?php } ?>
</body>
</html>