-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.php
211 lines (190 loc) · 7.59 KB
/
manage.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
<?php
/**
* index.php
* Author: Federico Mestrone
* Created: 14/12/2012 13:51
* Copyright: 2012, Moodsdesign Ltd
*/
$CUR_PAGE = 'manage';
unset($PLUGIN);
unset($PLUGIN_ID);
unset($error_message);
unset($success);
session_start();
if ( empty($_SESSION['PluginID']) ) {
header('Location: index.php');
exit;
}
$PLUGIN_ID = $_SESSION['PluginID'];
$filename = "data/$PLUGIN_ID";
if ( is_readable($filename) ) {
$raw = file_get_contents($filename);
$PLUGIN = unserialize($raw);
if ( empty($PLUGIN) ) {
$_SESSION['PluginErr'] = 'invalid';
header('Location: index.php');
exit;
}
}
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
/*
* Handle edit attempts
*/
$pluginid = $_POST['pluginid'];
$version = $_POST['version'];
$guid = $_POST['guid'];
$date = $_POST['date'];
$notes = $_POST['notes'];
if ( $PLUGIN_ID != $pluginid ) {
$error_message = '<li>Your request is inconsistent with the current session</li>';
} else if ( !$pluginid || !$version || !$guid ) {
$error_message = '<li>You must provide both your Plugin Version and its Download GUID on the Elgg community site</li>';
} else {
$PLUGIN['plugin_new_version'] = $version;
$PLUGIN['plugin_guid'] = $guid;
if ( $date ) {
$dt = date_create_from_format('Y-m-d', $date);
if ( $dt ) {
$time = $dt->getTimestamp();
}
}
if ( !$time ) {
$time = time();
}
$PLUGIN['plugin_timestamp'] = $time;
if ( !empty($notes) ) $PLUGIN['release_notes'] = $notes;
$raw = serialize($PLUGIN);
if ( file_put_contents("data/$PLUGIN_ID", $raw) ) {
$success = true;
} else {
$error_message = '<li>Could not save your version information</li>';
}
}
}
/*
* Handle end user requests from a web browser
*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Html Head -->
<?php require('elements/head.inc'); ?>
<!--/ Html Head -->
</head>
<body>
<!-- Navigation Bar -->
<?php require('elements/navbar.inc'); ?>
<!--/ Navigation Bar -->
<div id="wrap">
<div class="container">
<!-- Page Content -->
<div id="manage-form">
<form method="post" class="form-manage form-horizontal">
<h2 class="form-manage-heading">Version info</h2>
<div class="control-group">
<label class="control-label" for="pluginid">Plugin ID</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-folder-open"></i></span>
<input type="text" name="pluginid" value="<?php echo $PLUGIN_ID; ?>" id="pluginid" placeholder="Plugin ID" readonly="readonly">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="version">Plugin Version
<span rel="tooltip" data-placement="bottom" title="The version number of the latest release of your plugin.">
<i class="icon-question-sign"></i>
</span>
</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-tags"></i></span>
<input type="text" name="version" value="<?php echo $PLUGIN['plugin_new_version']; ?>" id="version" placeholder="Plugin Version">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="guid">Elgg Download GUID
<span rel="tooltip" data-placement="bottom" title="The GUID of the download link for your plugin on the Elgg community website.">
<i class="icon-question-sign"></i>
</span>
</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-download-alt"></i></span>
<input type="text" name="guid" value="<?php echo $PLUGIN['plugin_guid']; ?>" id="guid" placeholder="Elgg Download GUID">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="date">Release Date
<span rel="tooltip" data-placement="bottom" title="The date when the version was released (leave empty for current date).">
<i class="icon-question-sign"></i>
</span>
</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-calendar"></i></span>
<input type="text" name="date" value="<?php if ( $PLUGIN['plugin_timestamp'] ) echo date('Y-m-d', $PLUGIN['plugin_timestamp']); ?>" id="release-date" placeholder="Release Date">
<span class="help-block">Leave blank for today's date</span>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="notes">Release Notes
<span rel="tooltip" data-placement="bottom" title="A short description of the new features and/or fixes this version provides.">
<i class="icon-question-sign"></i>
</span>
</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-edit"></i></span>
<textarea name="notes" id="notes" placeholder="Release Notes"><?php echo $PLUGIN['release_notes']; ?></textarea>
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<button class="btn btn-large btn-primary" type="submit"> Save </button>
<a class="btn btn-large btn-info" href="index.php" role="button">Sign Out</a>
<a class="btn btn-large btn-info" href="#helpModal" role="button" data-toggle="modal"> Help </a>
</div>
</div>
<?php // focus on first field ?>
</form>
</div>
<?php if ( $success ) { ?>
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<h4>All good</h4>
Your version information has been saved successfully!
</div>
<?php } ?>
<?php if ( $error_message ) { ?>
<div class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">×</button>
<h4>An error has occurred</h4>
<ul>
<?php echo $error_message; ?>
</ul>
</div>
<?php } ?>
<!--/ Page Content -->
</div>
<div id="push"></div>
</div>
<!-- About Modal -->
<?php require('elements/about.inc'); ?>
<!--/ About Modal -->
<!-- Help Modal -->
<?php require('elements/help-manage.inc'); ?>
<!--/ Help Modal -->
<!-- Register Modal -->
<?php require('elements/register.inc'); ?>
<!--/ Register Modal -->
<!-- Page Footer -->
<?php require('elements/footer.inc'); ?>
<!--/ Page Footer -->
</body>
</html>