Blame | Last modification | View Log | RSS feed
<?
//------------------------------------------------------------------------------
// FICHIER : $RCSfile: adsi_cache.fonct.php,v $
// AUTEUR : $Author: jpm $
// VERSION : $Revision: 1.1 $
// DATE : $Date: 2004-06-16 14:26:35 $
//------------------------------------------------------------------------------
// GSite - Web site management in PHP - gus module
//
// Copyright (C) 2001 COUDOUNEAU Laurent (lc@gsite.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//==============================================================================
//==============================================================================
function listCaches ($db, $link, $project, $locale,
$baseURL, $baseURLjs,
$msg) {
//----------------------------------------------------------------------------
// Javascript.
$goMsg = addslashes (gs_getLabel ($db, $link, 'delete', $locale, 'gsite', false));
js_register ('deleteCache',
" function deleteCache (oSelect) {"."\n".
" var url = '$baseURLjs'+'&guscmd=delcache';"."\n".
" if (oSelect.selectedIndex != -1) {"."\n".
" url += '&gusprjid='+oSelect.options[oSelect.selectedIndex].value;"."\n".
" if (window.confirm ('$goMsg')) {"."\n".
" document.location = url;"."\n".
" }"."\n".
" }"."\n".
" }"."\n"
);
//----------------------------------------------------------------------------
// Buttons.
$i = 0;
//-- Delete cache.
$btInfos1[$i++] = array (
'text' => 'gus_del',
'appl' => 'gus',
'url' => 'javascript:deleteCache (document.gform.gselect)');
$btInfos1[$i++] = array ('space' => true);
//-- Logout.
$btInfos1[$i++] = array (
'text' => 'logout',
'appl' => 'gsite',
'url' => $baseURL.'&auth_logout=1');
$button1 =
gs_genericButtons ($db, $link, $locale,
$btInfos1,
false);
//----------------------------------------------------------------------------
// List caches.
$query =
"select ".
"C_PROJECT, ".
"SUM(C_LENGTH) as UNZIP, ".
"SUM(C_GZ_LENGTH) as ZIP, ".
"COUNT(C_MD5_URL) as PAGES ".
"from $db.CACHE ".
"group by C_PROJECT ".
"order by C_PROJECT";
$result = mysql_query ($query, $link);
if (! $result) {
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
}
//----------------------------------------------------------------------------
// Build form.
$text = '';
$text .= "\n".'<FORM name="gform" action="document.php" method="get">';
$text .= "\n".' <SELECT class="gusInput" name="gselect" size="20" ondblclick="javascript:deleteCache (document.gform.gselect)">';
while ($row = mysql_fetch_object ($result)) {
$ratio = ((int) (($row->UNZIP / $row->ZIP) * 100)) / 100;
$size = ((int) (($row->ZIP / 1024) * 100)) / 100;
$infos = htmlentities ("$row->C_PROJECT ($row->PAGES pages - $size Ko - $ratio x)");
$text .= "\n".' <OPTION value="'.htmlentities ($row->C_PROJECT).'">';
$text .= $infos;
$text .= '</OPTION>';
}
$text .= "\n".' </SELECT>';
$text .= "\n".'</FORM>';
mysql_free_result ($result);
//----------------------------------------------------------------------------
// Build page.
$title = gs_getLabel ($db, $link, 'gus_title4', $locale, 'gus');
return
buildPage (
$button1,
'',
$title,
$text,
$msg);
}
//==============================================================================
//==============================================================================
function delCache ($db, $link, $gusprjid) {
$query = "delete from $db.CACHE where C_PROJECT='$gusprjid'";
$result = mysql_query ($query, $link);
if (! $result) {
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
}
}
//------------------------------------------------------------------------------
// $Log: not supported by cvs2svn $
// Revision 1.1 2003/10/10 09:58:21 alex
// installation
//
// Revision 1.1.1.1 2002/10/02 07:32:21 root
// initialisation site de Tela
//
// Revision 1.2 2002/06/14 07:22:22 lc
// Bug LC0021 : use js_register
//
// Revision 1.1 2002/02/26 08:22:21 lc
// Initial revision.
//
//-- End of source ------------------------------------------------------------
?>