-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.php
More file actions
161 lines (144 loc) · 6.04 KB
/
plugins.php
File metadata and controls
161 lines (144 loc) · 6.04 KB
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
<?php
/**
* index.php
* Author: Federico Mestrone
* Created: 14/12/2012 13:51
* Copyright: 2012, Moodsdesign Ltd
*/
$CUR_PAGE = 'plugins';
unset($PLUGIN);
unset($PLUGIN_ID);
session_start();
$PLUGIN_ID = $_SESSION['PluginID'];
if ( !empty($PLUGIN_ID) ) {
$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;
}
}
}
/**
* http://pkarl.com/articles/contextual-user-friendly-time-and-dates-php/
* @param $small_ts
* @param int|bool(false) $large_ts
* @return bool(false)|string
*/
function contextualTime($small_ts, $large_ts = false) {
if ( !$large_ts ) $large_ts = time();
$n = $large_ts - $small_ts;
if ( $n <= 1 ) return 'less than 1 second ago';
if ( $n < (60) ) return $n . ' seconds ago';
if ( $n < (60*60) ) { $minutes = round($n/60); return 'about ' . $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ago'; }
if ( $n < (60*60*16) ) { $hours = round($n/(60*60)); return 'about ' . $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ago'; }
if ( $n < (time() - strtotime('yesterday')) ) return 'yesterday';
if ( $n < (60*60*24) ) { $hours = round($n/(60*60)); return 'about ' . $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ago'; }
if ( $n < (60*60*24*6.5) ) return 'about ' . round($n/(60*60*24)) . ' days ago';
if ( $n < (time() - strtotime('last week')) ) return 'last week';
if ( round($n/(60*60*24*7)) == 1 ) return 'about a week ago';
if ( $n < (60*60*24*7*3.5) ) return 'about ' . round($n/(60*60*24*7)) . ' weeks ago';
if ( $n < (time() - strtotime('last month')) ) return 'last month';
if ( round($n/(60*60*24*7*4)) == 1 ) return 'about a month ago';
if ( $n < (60*60*24*7*4*11.5) ) return 'about ' . round($n/(60*60*24*7*4)) . ' months ago';
if ( $n < (time() - strtotime('last year')) ) return 'last year';
if ( round($n/(60*60*24*7*52)) == 1 ) return 'about a year ago';
if ( $n >= (60*60*24*7*4*12) ) return 'about ' . round($n/(60*60*24*7*52)) . ' years ago';
return false;
}
/*
* 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="plugins-table">
<h2 class="form-signin-heading">Registered plugins</h2>
<?php
$found = false;
if ( $handle = opendir('data') ) {
while ( false !== ($entry = readdir($handle)) ) {
if ( $entry[0] != '.' && is_file("data/$entry") && is_readable("data/$entry") ) {
$raw = file_get_contents("data/$entry");
if ( ($data = unserialize($raw)) ) {
if ( !$found ) {
$found = true;
echo '<table class="table table-hover">';
echo '<thead>';
echo '<tr><th>';
echo 'Plugin ID';
echo '</th><th>';
echo 'Version';
echo '</th><th>';
echo 'URL <small>(first 50 chars)</small>';
echo '</th><th>';
echo 'Release';
echo '</th></tr>';
echo '</thead>';
}
echo '<tr><td>';
echo $entry;
echo '</td><td>';
if ( empty($data['plugin_new_version']) ) {
echo '<span rel="tooltip" data-placement="bottom" title="The author of this plugin has not registered any released versions yet."><i class="icon-ban-circle"></i></span>';
} else {
echo $data['plugin_new_version'];
}
echo "</td><td><a href=\"$data[plugin_url]\" target=\"_blank\">";
echo substr($data['plugin_url'], 0, 50);
echo '</a></td><td>';
if ( empty($data['plugin_timestamp']) ) {
echo '<span rel="tooltip" data-placement="bottom" title="The author of this plugin has not registered any released versions yet."><i class="icon-ban-circle"></i></span>';
} else {
echo contextualTime($data['plugin_timestamp']);
echo '<span rel="tooltip" data-placement="bottom" title="';
echo date('D d M Y',$data['plugin_timestamp']);
echo '"> <i class="icon-calendar"></i></span>';
}
echo '</td></tr>';
}
}
}
closedir($handle);
if ( $found ) {
echo '</table>';
}
}
?>
<?php if ( !$found ) { ?>
<div class="alert alert-info">
<h4>No Registered Plugins</h4>
There are no plugins that use Version Check with this Versions Server at the moment
</div>
<?php } ?>
</div>
<!--/ Page Content -->
</div>
<div id="push"></div>
</div>
<!-- About Modal -->
<?php require('elements/about.inc'); ?>
<!--/ About Modal -->
<!-- Register Modal -->
<?php require('elements/register.inc'); ?>
<!--/ Register Modal -->
<!-- Page Footer -->
<?php require('elements/footer.inc'); ?>
<!--/ Page Footer -->
</body>
</html>