-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
134 lines (104 loc) · 3.99 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
<?php
if (!is_file(__DIR__ . '/config.php'))
{
throw new Exception('configuration not found.');
}
require __DIR__ . '/config.php';
require_once __DIR__ . '/vendor/autoload.php';
?>
<!doctype html>
<html>
<head>
<title>Enter game list</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" />
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.2/handlebars.min.js"></script>
<script type="text/javascript">
var progressInterval;
$(document).ready(function () {
var tpl = Handlebars.compile($('#progressTemplate').html());
progressInterval = setInterval(function () {
$.get('./progress.php', function (data) {
$("#out").html(tpl({"data": data}));
});
}
, 2000);
});
</script>
</head>
<body>
<?php
/**
* gog.com games downloader written in PHP
*
*
* @author Ketwaroo D. Yaasir
*/
$dl = new \Gogdl\Downloader(GOGPHPDL_USERNAME, GOGPHPDL_PASSWORD);
$dl->setAuthFile(GOGPHPDL_BASE_DIR . '/.gogauth')
->setDownloadDir(GOGPHPDL_DOWNLOAD_DIR)
->setWgetBin(GOGPHPDL_WGET);
$progress = new \Gogdl\ProgressServer();
$progress->setProgressChacheDir(GOGPHPDL_DOWNLOAD_DIR);
if (!empty($_POST['games']))
{
$dlList = array_filter(preg_split('~[\r\n,]+~', $_POST['games']));
if (!empty($dlList))
{
// run through decorator
$progress->runDownloader($dl, $dlList);
}
}
if (!empty($_POST['gamelist']))
{
$user= ($dl->init()->apiGetUserDetails());
p($user);
try
{
//p($dl->init()->apiGetGamesList($user['user']['id']));
p($dl->init()->apiGetGamesList($user['user']['xywka']));
p($dl->init()->apiGetGamesList($user['user']['email']));
p($dl->init()->apiGetGamesList($user['user']['hash']));
}
catch (\Exception $exc)
{
p($exc);
}
die;
}
?>
<form method="post">
<p>Enter gogdownloader links. one per line. eg.</p>
<p><code>gogdownloader://beneath_a_steel_sky/installer_win_en</code></p>
<p><textarea name="games" id="games" cols="100" rows="15"></textarea></p>
<p><button type="submit" class="btn btn-default">Submit</button></p>
</form>
<form method="post">
<input type="hidden" name="gamelist" value="1"/>
<button type="submit" class="btn btn-default">Game list</button>
</form>
<div id="out"></div>
<div id="progressTemplate" class="hide">
<div class="row">
{{#each data}}
<h4 class="col-xs-12">{{game}}</h4>
{{#each this.files}}
<div class="game-progress col-xs-6">{{file}}</div>
<div class="completed col-xs-2">{{currentSize}}</div>
<div class="completed col-xs-2">{{expectedSize}}</div>
<div class="completed col-xs-2">{{progress}}%</div>
{{/each}}
{{/each}}
</div>
</div>
<?php
$log = $dl->log();
if (!empty($log))
{
echo '<pre>', print_r($log, 1), '</pre>';
}
?>
</body>
</html>