-
Notifications
You must be signed in to change notification settings - Fork 58
/
auto_update.php
122 lines (117 loc) · 3.56 KB
/
auto_update.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
<?php
include("inc/meta.html");
include("inc/title.html");
include("inc/class.html");
include("inc/header.html");
$isInStage = (strpos($_SERVER["SCRIPT_FILENAME"], 'www-stage') != false);
?>
<h1>MozTW Website Online Update</h1>
<?php
if(isset($_POST["rebuild_git"]) && $_POST["rebuild_git"])
{
# processing
?>
<p>Starting pull updates of browser-pairs game...</p>
<pre id='progress_blk' title='still processing, please wait...'
style='padding: 5px; maring: 5px; cursor: wait;
border: 1px solid green;
border-bottom: 1px dotted red'><?php
$cmd = '/home/moztw/repo/base/autoupdate/update-git.sh';
$cmd .= ' 2>&1';
echo "Command: " . htmlspecialchars($cmd) . "\n\n";
ob_flush();
flush();
$handle = popen("" . $cmd, "r");
while($s= fgets($handle, 1024)) {
// read from the pipe
print htmlspecialchars($s);
fwrite($handle, "p\n");
ob_flush();
flush();
}
pclose($handle);
?>
</pre><script type='text/javascript'>
<!--
document.getElementById('progress_blk').style.border = '1px solid black';
document.getElementById('progress_blk').style.cursor = 'default';
document.getElementById('progress_blk').title = 'ready';
// -->
</script>
<?php
}
if(isset($_POST["rebuild_yes"]) && $_POST["rebuild_yes"])
{
# processing
?>
<p>Starting pulling updates of moztw website...</p>
<pre id='progress_blk' title='still processing, please wait...'
style='padding: 5px; maring: 5px; cursor: wait;
border: 1px solid green;
border-bottom: 1px dotted red'><?php
$cmd = '/home/moztw/repo/base/autoupdate/update.sh';
$opt = '';
if ($isInStage) {
$opt .= ' stage';
} else {
$opt .= ' www';
}
if(isset($_POST["rebuild_md5"]) && $_POST["rebuild_md5"])
$opt .= ' md5';
if(isset($_POST["rebuild_cache"]) && $_POST["rebuild_cache"])
$opt .= ' cache';
$cmd .= $opt;
$cmd .= ' 2>&1';
echo "Command: " . htmlspecialchars($cmd) . "\n\n";
ob_flush();
flush();
// system("" . $cmd);
$handle = popen("" . $cmd, "r");
while($s= fgets($handle, 1024)) {
// read from the pipe
print htmlspecialchars($s);
fwrite($handle, "p\n");
ob_flush();
flush();
}
pclose($handle);
?>
</pre><script type='text/javascript'>
<!--
document.getElementById('progress_blk').style.border = '1px solid black';
document.getElementById('progress_blk').style.cursor = 'default';
document.getElementById('progress_blk').title = 'ready';
// -->
</script>
<?php
} else {
# index page
?>
<form method="post"><fieldset>
<p style="color: blue; font-weight:bold;">Update MozTW Website:<br><br>
<label style="color: black;">Confirm to update main repo for MozTW website <?php if ($isInStage) echo "<b>stage</b>"; ?>.
<input id='xgeneral' type='checkbox' name='rebuild_yes' checked>
</label>
</p>
<p style="color: blue; font-weight:bold;">Update other Git repos:<br><br>
<label style="color: black;">Confirm to update browser-pairs and other git repos.
<input id='xgit' type="checkbox" name="rebuild_git">
</label>
</p>
<hr>
<p style="color: blue; font-weight:bold;">Optional Git rebuild process:<br><br>
<label style="color: black;">Recalculate MD5 information <b style='color: red;'>(if files in dls/ were changed, and very slow)</b>
<input id='xmd5' type="checkbox" name="rebuild_md5">
</label><br>
<label style="color: black;">Rebuild all HTML caches <b style='color: red;'>(if htdocs/inc/*.html were modified)</b>
<input id='xcache' type="checkbox" name="rebuild_cache">
</label>
</p>
<hr>
<input type='submit' value='Start Update'>
</fieldset></form>
<?php
}
include("inc/footer.html");
include("inc/end.html");
?>