6 |
jpm |
1 |
<?
|
|
|
2 |
//------------------------------------------------------------------------------
|
|
|
3 |
// FICHIER : $RCSfile: adsi_cache.fonct.php,v $
|
|
|
4 |
// AUTEUR : $Author: jpm $
|
|
|
5 |
// VERSION : $Revision: 1.1 $
|
|
|
6 |
// DATE : $Date: 2004-06-16 14:26:35 $
|
|
|
7 |
//------------------------------------------------------------------------------
|
|
|
8 |
// GSite - Web site management in PHP - gus module
|
|
|
9 |
//
|
|
|
10 |
// Copyright (C) 2001 COUDOUNEAU Laurent (lc@gsite.org)
|
|
|
11 |
//
|
|
|
12 |
// This library is free software; you can redistribute it and/or
|
|
|
13 |
// modify it under the terms of the GNU Lesser General Public
|
|
|
14 |
// License as published by the Free Software Foundation; either
|
|
|
15 |
// version 2.1 of the License, or (at your option) any later version.
|
|
|
16 |
//
|
|
|
17 |
// This library is distributed in the hope that it will be useful,
|
|
|
18 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
19 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
20 |
// Lesser General Public License for more details.
|
|
|
21 |
//
|
|
|
22 |
// You should have received a copy of the GNU Lesser General Public
|
|
|
23 |
// License along with this library; if not, write to the Free Software
|
|
|
24 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
25 |
//------------------------------------------------------------------------------
|
|
|
26 |
//------------------------------------------------------------------------------
|
|
|
27 |
|
|
|
28 |
//==============================================================================
|
|
|
29 |
//==============================================================================
|
|
|
30 |
|
|
|
31 |
function listCaches ($db, $link, $project, $locale,
|
|
|
32 |
$baseURL, $baseURLjs,
|
|
|
33 |
$msg) {
|
|
|
34 |
//----------------------------------------------------------------------------
|
|
|
35 |
// Javascript.
|
|
|
36 |
|
|
|
37 |
$goMsg = addslashes (gs_getLabel ($db, $link, 'delete', $locale, 'gsite', false));
|
|
|
38 |
|
|
|
39 |
js_register ('deleteCache',
|
|
|
40 |
" function deleteCache (oSelect) {"."\n".
|
|
|
41 |
" var url = '$baseURLjs'+'&guscmd=delcache';"."\n".
|
|
|
42 |
" if (oSelect.selectedIndex != -1) {"."\n".
|
|
|
43 |
" url += '&gusprjid='+oSelect.options[oSelect.selectedIndex].value;"."\n".
|
|
|
44 |
" if (window.confirm ('$goMsg')) {"."\n".
|
|
|
45 |
" document.location = url;"."\n".
|
|
|
46 |
" }"."\n".
|
|
|
47 |
" }"."\n".
|
|
|
48 |
" }"."\n"
|
|
|
49 |
);
|
|
|
50 |
|
|
|
51 |
//----------------------------------------------------------------------------
|
|
|
52 |
// Buttons.
|
|
|
53 |
|
|
|
54 |
$i = 0;
|
|
|
55 |
|
|
|
56 |
//-- Delete cache.
|
|
|
57 |
$btInfos1[$i++] = array (
|
|
|
58 |
'text' => 'gus_del',
|
|
|
59 |
'appl' => 'gus',
|
|
|
60 |
'url' => 'javascript:deleteCache (document.gform.gselect)');
|
|
|
61 |
|
|
|
62 |
$btInfos1[$i++] = array ('space' => true);
|
|
|
63 |
|
|
|
64 |
//-- Logout.
|
|
|
65 |
$btInfos1[$i++] = array (
|
|
|
66 |
'text' => 'logout',
|
|
|
67 |
'appl' => 'gsite',
|
|
|
68 |
'url' => $baseURL.'&auth_logout=1');
|
|
|
69 |
|
|
|
70 |
$button1 =
|
|
|
71 |
gs_genericButtons ($db, $link, $locale,
|
|
|
72 |
$btInfos1,
|
|
|
73 |
false);
|
|
|
74 |
|
|
|
75 |
//----------------------------------------------------------------------------
|
|
|
76 |
// List caches.
|
|
|
77 |
|
|
|
78 |
$query =
|
|
|
79 |
"select ".
|
|
|
80 |
"C_PROJECT, ".
|
|
|
81 |
"SUM(C_LENGTH) as UNZIP, ".
|
|
|
82 |
"SUM(C_GZ_LENGTH) as ZIP, ".
|
|
|
83 |
"COUNT(C_MD5_URL) as PAGES ".
|
|
|
84 |
"from $db.CACHE ".
|
|
|
85 |
"group by C_PROJECT ".
|
|
|
86 |
"order by C_PROJECT";
|
|
|
87 |
|
|
|
88 |
$result = mysql_query ($query, $link);
|
|
|
89 |
|
|
|
90 |
if (! $result) {
|
|
|
91 |
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
//----------------------------------------------------------------------------
|
|
|
95 |
// Build form.
|
|
|
96 |
|
|
|
97 |
$text = '';
|
|
|
98 |
$text .= "\n".'<FORM name="gform" action="document.php" method="get">';
|
|
|
99 |
$text .= "\n".' <SELECT class="gusInput" name="gselect" size="20" ondblclick="javascript:deleteCache (document.gform.gselect)">';
|
|
|
100 |
|
|
|
101 |
while ($row = mysql_fetch_object ($result)) {
|
|
|
102 |
$ratio = ((int) (($row->UNZIP / $row->ZIP) * 100)) / 100;
|
|
|
103 |
$size = ((int) (($row->ZIP / 1024) * 100)) / 100;
|
|
|
104 |
$infos = htmlentities ("$row->C_PROJECT ($row->PAGES pages - $size Ko - $ratio x)");
|
|
|
105 |
|
|
|
106 |
$text .= "\n".' <OPTION value="'.htmlentities ($row->C_PROJECT).'">';
|
|
|
107 |
$text .= $infos;
|
|
|
108 |
$text .= '</OPTION>';
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
$text .= "\n".' </SELECT>';
|
|
|
112 |
|
|
|
113 |
$text .= "\n".'</FORM>';
|
|
|
114 |
|
|
|
115 |
mysql_free_result ($result);
|
|
|
116 |
|
|
|
117 |
//----------------------------------------------------------------------------
|
|
|
118 |
// Build page.
|
|
|
119 |
|
|
|
120 |
$title = gs_getLabel ($db, $link, 'gus_title4', $locale, 'gus');
|
|
|
121 |
|
|
|
122 |
return
|
|
|
123 |
buildPage (
|
|
|
124 |
$button1,
|
|
|
125 |
'',
|
|
|
126 |
$title,
|
|
|
127 |
$text,
|
|
|
128 |
$msg);
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
//==============================================================================
|
|
|
132 |
//==============================================================================
|
|
|
133 |
|
|
|
134 |
function delCache ($db, $link, $gusprjid) {
|
|
|
135 |
$query = "delete from $db.CACHE where C_PROJECT='$gusprjid'";
|
|
|
136 |
|
|
|
137 |
$result = mysql_query ($query, $link);
|
|
|
138 |
|
|
|
139 |
if (! $result) {
|
|
|
140 |
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
//------------------------------------------------------------------------------
|
|
|
145 |
// $Log: not supported by cvs2svn $
|
|
|
146 |
// Revision 1.1 2003/10/10 09:58:21 alex
|
|
|
147 |
// installation
|
|
|
148 |
//
|
|
|
149 |
// Revision 1.1.1.1 2002/10/02 07:32:21 root
|
|
|
150 |
// initialisation site de Tela
|
|
|
151 |
//
|
|
|
152 |
// Revision 1.2 2002/06/14 07:22:22 lc
|
|
|
153 |
// Bug LC0021 : use js_register
|
|
|
154 |
//
|
|
|
155 |
// Revision 1.1 2002/02/26 08:22:21 lc
|
|
|
156 |
// Initial revision.
|
|
|
157 |
//
|
|
|
158 |
//-- End of source ------------------------------------------------------------
|
|
|
159 |
?>
|