-
Notifications
You must be signed in to change notification settings - Fork 60
/
my.php
150 lines (124 loc) · 5.54 KB
/
my.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
<?php
require_once(dirname(__FILE__).'/global.php');
require_once(dirname(__FILE__).'/users/users.php');
$current_user = User::require_login();
if (array_key_exists('delete', $_POST) && is_array($_POST['delete'])) {
$delete = array_keys($_POST['delete']);
$first = true;
foreach ($delete as $id) {
if (!is_numeric($id)) {
next;
}
if ($first) {
$first = false;
}
else
{
$deleteids.=', ';
}
$deleteids.=$id;
}
if (!$first) {
$query = sprintf("DELETE FROM user_urls WHERE user_id = %d AND url_id IN (%s)",
$current_user->getID(),
$deleteids
);
error_log($query);
$result = mysql_query($query);
if (!$result) {
error_log(mysql_error());
}
}
header('Location: '.$showslow_base.'my.php');
}
if (!$noMoreURLs && array_key_exists('url', $_REQUEST)
&& ($url = filter_var($_REQUEST['url'], FILTER_VALIDATE_URL)) !== false) {
require_once(dirname(__FILE__).'/beacon/beacon_functions.php');
$url_id = getUrlId($url);
$query = sprintf("INSERT IGNORE INTO user_urls (user_id, url_id) VALUES (%d, %d)",
$current_user->getID(),
$url_id
);
$result = mysql_query($query);
if (!$result) {
error_log(mysql_error());
}
header('Location: '.$showslow_base.'my.php');
}
if (in_array($current_user->getID(), $noMaxURLsForUsers)) {
$maxURLsPerUser = false;
}
$query = sprintf("SELECT urls.id, urls.url, yslow2.o, pagespeed.o as ps_o, last_update FROM urls INNER JOIN user_urls ON urls.id = user_urls.url_id LEFT JOIN yslow2 on urls.yslow2_last_id = yslow2.id LEFT JOIN pagespeed on urls.pagespeed_last_id = pagespeed.id WHERE user_urls.user_id = %d ORDER BY url", $current_user->getID());
$result = mysql_query($query);
if (!$result) {
error_log(mysql_error());
}
$noMoreURLs = false;
if ($maxURLsPerUser && mysql_num_rows($result) >= $maxURLsPerUser)
{
$noMoreURLs = true;
}
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
$TITLE = 'My URLs';
$SECTION = 'my';
require_once(dirname(__FILE__).'/header.php');
?>
<h1 style="margin-bottom: 0">Add URLs to monitor</h1>
<div style="font-size: small; margin-bottom: 1em">User: <a href="users/edit.php"><?php echo $current_user->getName(); ?></a></div>
<form action="" method="POST">
<table border="0">
<tr><td colspan="8" style="padding-bottom: 1em">
<?php
if ($noMoreURLs)
{
?>
<div title="URLs tracked are limited because of load constraints"><input type="text" size="80" name="url" disabled="disabled"/><input type="submit" name="add" value="add" disabled="disabled"/></div>
<?php } else { ?>
<input type="text" size="80" name="url"/><input type="submit" name="add" value="add" title="add URL to be measured"/>
<?php
}
?>
</td></tr>
<tr style="font-size: smaller; font-weight: bold">
<td style="text-align: right; padding-right: 0.7em">Timestamp</td>
<td colspan="2" style="text-align: right; padding-right: 0.7em">YSlow grade</td>
<td colspan="2" style="text-align: right; padding-right: 0.7em">Page Speed score</td>
<td style="text-align: center">Remove</td>
<td style="padding-left: 1em">URL</td>
</tr>
<?php
foreach ($rows as $row) {
?><tr>
<?php if ($row['last_update']) { ?>
<td style="text-align: right; padding-right: 1em"><a title="Time of last check for this URL" href="details/?url=<?php echo urlencode($row['url']); ?>"><?php echo htmlentities($row['last_update']); ?></a></td>
<?php if (!is_null($row['o'])) {?>
<td style="text-align: right; padding:0 10px 0 10px; white-space: nowrap;"><?php echo yslowPrettyScore($row['o'])?> (<?php echo $row['o']?>)</td>
<td><div style="background-color: silver; width: 101px" title="Current YSlow grade: <?php echo yslowPrettyScore($row['o'])?> (<?php echo $row['o']?>)"><div style="width: <?php echo $row['o']+1?>px; height: 0.7em; background-color: <?php echo scoreColor($row['o'])?>"/></div></td>
<?php } else { ?>
<td colspan="2"/>
<?php } ?>
<?php if (!is_null($row['ps_o'])) {?>
<td style="text-align: right; padding:0 10px 0 10px; white-space: nowrap;"><?php echo yslowPrettyScore($row['ps_o'])?> (<?php echo $row['ps_o']?>)</td>
<td><div style="background-color: silver; width: 101px" title="Current Page Speed score: <?php echo yslowPrettyScore($row['ps_o'])?> (<?php echo $row['ps_o']?>)"><div style="width: <?php echo $row['ps_o']+1?>px; height: 0.7em; background-color: <?php echo scoreColor($row['ps_o'])?>"/></div></td>
<?php } else { ?>
<td colspan="2"/>
<?php } ?>
<td style="text-align: center"><input type="submit" name="delete[<?php echo htmlentities($row['id'])?>]" value="X" style="font-size: xx-small" title="Stop monitoring this URL" onclick="return confirm('Are you sure you want to remove this URL?')"/></td>
<td style="padding-left: 1em; overflow: hidden; white-space: nowrap;"><a href="details/?url=<?php echo urlencode($row['url'])?>"><?php echo htmlentities(substr($row['url'], 0, 100))?><?php if (strlen($row['url']) > 100) { ?>...<?php } ?></a></td>
<?php } else { ?>
<td style="text-align: right; padding-right: 1em"><i title="added to the testing queue">queued</i></td>
<td colspan="4"/>
<td style="text-align: center"><input type="submit" name="delete[<?php echo htmlentities($row['id'])?>]" value="X" style="font-size: xx-small" title="Stop monitoring this URL" onclick="return confirm('Are you sure you want to remove this URL?')"/></td>
<td style="padding-left: 1em; overflow: hidden; white-space: nowrap;"><i title="Time of last check for this URL"><?php echo htmlentities(substr($row['url'], 0, 100))?><?php if (strlen($row['url']) > 100) { ?>...<?php } ?></i></td>
<?php } ?>
</tr><?php
}
mysql_free_result($result);
?>
</table>
</form>
<?php
require_once(dirname(__FILE__).'/footer.php');