/web/test/gallery/phpwebgallery/admin/_vti_cnf/admin_phpinfo.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|4886 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/cat_list.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|01 May 2005 14:19:38 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|01 May 2005 14:19:38 -0000 |
vti_cacheddtm:TX|01 May 2005 14:19:38 -0000 |
vti_filesize:IR|14963 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/cat_modify.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|7219 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/cat_options.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|8047 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/cat_perm.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|8731 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/configuration.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|14 May 2005 12:56:48 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|14 May 2005 12:56:48 -0000 |
vti_cacheddtm:TX|14 May 2005 12:56:48 -0000 |
vti_filesize:IR|14625 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/group_list.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|17 Jan 2005 20:02:44 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|17 Jan 2005 20:02:44 -0000 |
vti_cacheddtm:TX|17 Jan 2005 20:02:44 -0000 |
vti_filesize:IR|7308 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/group_perm.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|6208 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/help.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|2499 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/index.htm |
---|
0,0 → 1,17 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|09 May 2003 12:42:44 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|09 May 2003 12:42:44 -0000 |
vti_cacheddtm:TX|09 May 2003 12:42:44 -0000 |
vti_filesize:IR|133 |
vti_cachedtitle:SR|PhpWebGallery |
vti_cachedbodystyle:SR|<body> |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_title:SR|PhpWebGallery |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/infos_images.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|13387 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/picture_modify.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|01 May 2005 14:16:44 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|01 May 2005 14:16:44 -0000 |
vti_cacheddtm:TX|01 May 2005 14:16:44 -0000 |
vti_filesize:IR|10082 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/remote_site.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|22423 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/search.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|13 Jan 2005 09:18:50 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|13 Jan 2005 09:18:50 -0000 |
vti_cacheddtm:TX|13 Jan 2005 09:18:50 -0000 |
vti_filesize:IR|3991 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/stats.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|01 Feb 2005 06:28:38 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|01 Feb 2005 06:28:38 -0000 |
vti_cacheddtm:TX|01 Feb 2005 06:28:38 -0000 |
vti_filesize:IR|4226 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/thumbnail.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|20 Jan 2005 22:41:28 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|20 Jan 2005 22:41:28 -0000 |
vti_cacheddtm:TX|20 Jan 2005 22:41:28 -0000 |
vti_filesize:IR|13201 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/update.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|20 Apr 2005 19:09:50 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|20 Apr 2005 19:09:50 -0000 |
vti_cacheddtm:TX|20 Apr 2005 19:09:50 -0000 |
vti_filesize:IR|23430 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/user_perm.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|19 Jan 2005 22:36:44 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|19 Jan 2005 22:36:44 -0000 |
vti_cacheddtm:TX|19 Jan 2005 22:36:44 -0000 |
vti_filesize:IR|5924 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/_vti_cnf/waiting.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|16 Jan 2005 16:31:18 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|16 Jan 2005 16:31:18 -0000 |
vti_cacheddtm:TX|16 Jan 2005 16:31:18 -0000 |
vti_filesize:IR|5967 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/admin_phpinfo.php |
---|
0,0 → 1,82 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: admin_phpinfo.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.5 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if( !defined("PHPWG_ROOT_PATH") ) |
{ |
die ("Hacking attempt!"); |
} |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
ob_start(); |
phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES); |
$phpinfo = ob_get_contents(); |
ob_end_clean(); |
// Get used layout |
$layout = (preg_match('#bgcolor#i', $phpinfo)) ? 'old' : 'new'; |
$output=''; |
// Here we play around a little with the PHP Info HTML to try and stylise |
// it along phpBB's lines ... hopefully without breaking anything. The idea |
// for this was nabbed from the PHP annotated manual |
preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output); |
switch ($layout) |
{ |
case 'old': |
$output = preg_replace('#<table#', '<table class="table2"', $output[1][0]); |
$output = preg_replace('# bgcolor="\#(\w){6}"#', '', $output); |
$output = preg_replace('#(\w),(\w)#', '\1, \2', $output); |
$output = preg_replace('#border="0" cellpadding="3" cellspacing="1" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output); |
$output = preg_replace('#<tr valign="top"><td align="left">(.*?<a .*?</a>)(.*?)</td></tr>#s', '<tr class="row1"><td style="{background-color: #9999cc;}"><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td style="{background-color: #9999cc;}">\2</td><td style="{background-color: #9999cc;}">\1</td></tr></table></td></tr>', $output); |
$output = preg_replace('#<tr valign="baseline"><td[ ]{0,1}><b>(.*?)</b>#', '<tr><td class="row1" nowrap="nowrap">\1', $output); |
$output = preg_replace('#<td align="(center|left)">#', '<td class="row2">', $output); |
$output = preg_replace('#<td>#', '<td class="row2">', $output); |
$output = preg_replace('#valign="middle"#', '', $output); |
$output = preg_replace('#<tr >#', '<tr>', $output); |
$output = preg_replace('#<hr(.*?)>#', '', $output); |
$output = preg_replace('#<h1 align="center">#i', '<h1>', $output); |
$output = preg_replace('#<h2 align="center">#i', '<h2>', $output); |
break; |
case 'new': |
$output = preg_replace('#<table#', '<table class="table2"', $output[1][0]); |
$output = preg_replace('#(\w),(\w)#', '\1, \2', $output); |
$output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="2" width="95%"', $output); |
$output = preg_replace('#<tr class="v"><td>(.*?<a .*?</a>)(.*?)</td></tr>#s', '<tr class="throw"><td><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td>\2</td><td>\1</td></tr></table></td></tr>', $output); |
$output = preg_replace('#<td>#', '<td style="background-color: #444444;text-align:center;">', $output); |
$output = preg_replace('#<th>#', '<th class="throw">', $output); |
$output = preg_replace('#class="e"#', 'class="row1"', $output); |
$output = preg_replace('#class="v"#', 'class="row2"', $output); |
$output = preg_replace('# class="h"#', '', $output); |
$output = preg_replace('#<hr />#', '', $output); |
preg_match_all('#<div class="center">(.*)</div>#siU', $output, $output); |
$output = $output[1][0]; |
break; |
} |
$template->assign_var('ADMIN_CONTENT',$output); |
?> |
/web/test/gallery/phpwebgallery/admin/cat_list.php |
---|
0,0 → 1,479 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: cat_list.php,v $ |
// | last update : $Date: 2005/05/01 14:19:38 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.32.2.1 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if (!defined('PHPWG_ROOT_PATH')) |
{ |
die('Hacking attempt!'); |
} |
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
// +-----------------------------------------------------------------------+ |
// | initialization | |
// +-----------------------------------------------------------------------+ |
$errors = array(); |
$infos = array(); |
$categories = array(); |
$navigation = $lang['home']; |
// +-----------------------------------------------------------------------+ |
// | virtual categories management | |
// +-----------------------------------------------------------------------+ |
// request to delete a virtual category |
if (isset($_GET['delete']) and is_numeric($_GET['delete'])) |
{ |
delete_categories(array($_GET['delete'])); |
array_push($infos, $lang['cat_virtual_deleted']); |
ordering(); |
update_global_rank(); |
} |
// request to add a virtual category |
else if (isset($_POST['submit'])) |
{ |
// is the given category name only containing blank spaces ? |
if (preg_match('/^\s*$/', $_POST['virtual_name'])) |
{ |
array_push($errors, $lang['cat_error_name']); |
} |
if (!count($errors)) |
{ |
$parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL'; |
if ($parent_id != 'NULL') |
{ |
$query = ' |
SELECT id,uppercats,global_rank,visible,status |
FROM '.CATEGORIES_TABLE.' |
WHERE id = '.$parent_id.' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$parent = array('id' => $row['id'], |
'uppercats' => $row['uppercats'], |
'visible' => $row['visible'], |
'status' => $row['status'], |
'global_rank' => $row['global_rank']); |
} |
// what will be the inserted id ? |
$query = ' |
SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) |
FROM '.CATEGORIES_TABLE.' |
;'; |
list($next_id) = mysql_fetch_array(pwg_query($query)); |
$insert = array(); |
$insert{'id'} = $next_id++; |
$insert{'name'} = $_POST['virtual_name']; |
$insert{'rank'} = $_POST['rank']; |
$insert{'commentable'} = $conf['newcat_default_commentable']; |
// a virtual category can't be uploadable |
$insert{'uploadable'} = 'false'; |
if (isset($parent)) |
{ |
$insert{'id_uppercat'} = $parent{'id'}; |
$insert{'uppercats'} = $parent{'uppercats'}.','.$insert{'id'}; |
$insert{'global_rank'} = $parent{'global_rank'}.'.'.$insert{'rank'}; |
// at creation, must a category be visible or not ? Warning : if |
// the parent category is invisible, the category is automatically |
// create invisible. (invisible = locked) |
if ('false' == $parent['visible']) |
{ |
$insert{'visible'} = 'false'; |
} |
else |
{ |
$insert{'visible'} = $conf['newcat_default_visible']; |
} |
// at creation, must a category be public or private ? Warning : |
// if the parent category is private, the category is |
// automatically create private. |
if ('private' == $parent['status']) |
{ |
$insert{'status'} = 'private'; |
} |
else |
{ |
$insert{'status'} = $conf['newcat_default_status']; |
} |
} |
else |
{ |
$insert{'visible'} = $conf['newcat_default_visible']; |
$insert{'status'} = $conf['newcat_default_status']; |
$insert{'uppercats'} = $insert{'id'}; |
$insert{'global_rank'} = $insert{'rank'}; |
} |
$inserts = array($insert); |
// we have then to add the virtual category |
$dbfields = array('id','site_id','name','id_uppercat','rank', |
'commentable','uploadable','visible','status', |
'uppercats','global_rank'); |
mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); |
array_push($infos, $lang['cat_virtual_added']); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | Cache management | |
// +-----------------------------------------------------------------------+ |
$query = ' |
SELECT * |
FROM '.CATEGORIES_TABLE; |
if (!isset($_GET['parent_id'])) |
{ |
$query.= ' |
WHERE id_uppercat IS NULL'; |
} |
else |
{ |
$query.= ' |
WHERE id_uppercat = '.$_GET['parent_id']; |
} |
$query.= ' |
ORDER BY rank ASC |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_assoc($result)) |
{ |
$categories[$row['rank']] = $row; |
$categories[$row['rank']]['nb_subcats'] = 0; |
} |
// +-----------------------------------------------------------------------+ |
// | Navigation path | |
// +-----------------------------------------------------------------------+ |
if (isset($_GET['parent_id'])) |
{ |
$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; |
$navigation = '<a class="" href="'.add_session_id($base_url).'">'; |
$navigation.= $lang['home']; |
$navigation.= '</a>'; |
$navigation.= $conf['level_separator']; |
$current_category = get_cat_info($_GET['parent_id']); |
$navigation.= get_cat_display_name($current_category['name'], |
$base_url.'&parent_id=', |
false); |
} |
// +-----------------------------------------------------------------------+ |
// | rank updates | |
// +-----------------------------------------------------------------------+ |
$current_rank = 0; |
if (isset($_GET['up']) and is_numeric($_GET['up'])) |
{ |
// 1. searching the id of the category just above at the same level |
while (list ($id,$current) = each($categories)) |
{ |
if ($current['id'] == $_GET['up']) |
{ |
$current_rank = $current['rank']; |
break; |
} |
} |
if ($current_rank > 1) |
{ |
// 2. Exchanging ranks between the two categories |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = '.($current_rank-1).' |
WHERE id = '.$_GET['up'].' |
;'; |
pwg_query($query); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = '.$current_rank.' |
WHERE id = '.$categories[($current_rank-1)]['id'].' |
;'; |
pwg_query($query); |
// 3. Updating the cache array |
$categories[$current_rank] = $categories[($current_rank-1)]; |
$categories[($current_rank-1)] = $current; |
} |
else |
{ |
// 2. Updating the rank of our category to be after the previous max rank |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = '.(count($categories) + 1).' |
WHERE id = '.$_GET['up'].' |
;'; |
pwg_query($query); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = rank-1 |
WHERE id_uppercat '; |
if (empty($_GET['parent_id'])) |
{ |
$query.= 'IS NULL'; |
} |
else |
{ |
$query.= '= '.$_GET['parent_id']; |
} |
$query.= ' |
;'; |
pwg_query($query); |
// 3. Updating the cache array |
array_push($categories, $current); |
array_shift($categories); |
} |
update_global_rank(@$_GET['parent_id']); |
} |
else if (isset($_GET['down']) and is_numeric($_GET['down'])) |
{ |
// 1. searching the id of the category just above at the same level |
while (list ($id,$current) = each($categories)) |
{ |
if ($current['id'] == $_GET['down']) |
{ |
$current_rank = $current['rank']; |
break; |
} |
} |
if ($current_rank < count($categories)) |
{ |
// 2. Exchanging ranks between the two categories |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = '.($current_rank+1).' |
WHERE id = '.$_GET['down'].' |
;'; |
pwg_query($query); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = '.$current_rank.' |
WHERE id = '.$categories[($current_rank+1)]['id'].' |
;'; |
pwg_query($query); |
// 3. Updating the cache array |
$categories[$current_rank]=$categories[($current_rank+1)]; |
$categories[($current_rank+1)] = $current; |
} |
else |
{ |
// 2. updating the rank of our category to be the first one |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = 0 |
WHERE id = '.$_GET['down'].' |
;'; |
pwg_query($query); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET rank = rank+1 |
WHERE id_uppercat '; |
if (empty($_GET['parent_id'])) |
{ |
$query.= 'IS NULL'; |
} |
else |
{ |
$query.= '= '.$_GET['parent_id']; |
} |
$query.= ' |
;'; |
pwg_query($query); |
// 3. Updating the cache array |
array_unshift($categories, $current); |
array_pop($categories); |
} |
update_global_rank(@$_GET['parent_id']); |
} |
reset($categories); |
// +-----------------------------------------------------------------------+ |
// | template initialization | |
// +-----------------------------------------------------------------------+ |
$template->set_filenames(array('categories'=>'admin/cat_list.tpl')); |
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; |
if (isset($_GET['parent_id'])) |
{ |
$form_action.= '&parent_id='.$_GET['parent_id']; |
} |
if (count($categories) > 0) |
{ |
$next_rank = max(array_keys($categories)) + 1; |
} |
else |
{ |
$next_rank = 1; |
} |
$template->assign_vars(array( |
'CATEGORIES_NAV'=>$navigation, |
'NEXT_RANK'=>$next_rank, |
'F_ACTION'=>add_session_id($form_action), |
'L_ADD_VIRTUAL'=>$lang['cat_add'], |
'L_SUBMIT'=>$lang['submit'], |
'L_STORAGE'=>$lang['storage'], |
'L_NB_IMG'=>$lang['pictures'], |
'L_MOVE_UP'=>$lang['up'], |
'L_MOVE_DOWN'=>$lang['down'], |
'L_EDIT'=>$lang['edit'], |
'L_INFO_IMG'=>$lang['cat_image_info'], |
'L_DELETE'=>$lang['delete'], |
)); |
$tpl = array('cat_first','cat_last'); |
// +-----------------------------------------------------------------------+ |
// | errors & infos | |
// +-----------------------------------------------------------------------+ |
if (count($errors) != 0) |
{ |
$template->assign_block_vars('errors',array()); |
foreach ($errors as $error) |
{ |
$template->assign_block_vars('errors.error',array('ERROR'=>$error)); |
} |
} |
if (count($infos) != 0) |
{ |
$template->assign_block_vars('infos',array()); |
foreach ($infos as $info) |
{ |
$template->assign_block_vars('infos.info',array('INFO'=>$info)); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | Categories display | |
// +-----------------------------------------------------------------------+ |
$ranks = array(); |
if (count($categories) > 0) |
{ |
foreach ($categories as $category) |
{ |
$ranks[$category['id']] = $category['rank']; |
} |
$query = ' |
SELECT id_uppercat, COUNT(*) AS nb_subcats |
FROM '. CATEGORIES_TABLE.' |
WHERE id_uppercat IN ('.implode(',', array_keys($ranks)).') |
GROUP BY id_uppercat |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$categories[$ranks[$row['id_uppercat']]]['nb_subcats'] |
= $row['nb_subcats']; |
} |
} |
foreach ($categories as $category) |
{ |
$images_folder = PHPWG_ROOT_PATH.'template/'; |
$images_folder.= $user['template'].'/admin/images'; |
if ($category['visible'] == 'false') |
{ |
$image_src = $images_folder.'/icon_folder_lock.gif'; |
$image_alt = $lang['cat_private']; |
$image_title = $lang['cat_private']; |
} |
else if (empty($category['dir'])) |
{ |
$image_src = $images_folder.'/icon_folder_link.gif'; |
$image_alt = $lang['cat_virtual']; |
$image_title = $lang['cat_virtual']; |
} |
else |
{ |
if ($category['nb_subcats'] > 0) |
{ |
$image_src = $images_folder.'/icon_subfolder.gif'; |
} |
else |
{ |
$image_src = $images_folder.'/icon_folder.gif'; |
} |
$image_alt = ''; |
$image_title = ''; |
} |
$base_url = PHPWG_ROOT_PATH.'admin.php?page='; |
$cat_list_url = $base_url.'cat_list'; |
$self_url = $cat_list_url; |
if (isset($_GET['parent_id'])) |
{ |
$self_url.= '&parent_id='.$_GET['parent_id']; |
} |
$template->assign_block_vars( |
'category', |
array( |
'CATEGORY_IMG_SRC'=>$image_src, |
'CATEGORY_IMG_ALT'=>$image_alt, |
'CATEGORY_IMG_TITLE'=>$image_title, |
'CATEGORY_NAME'=>$category['name'], |
'CATEGORY_DIR'=>@$category['dir'], |
'CATEGORY_NB_IMG'=>$category['nb_images'], |
'U_CATEGORY'=> |
add_session_id($cat_list_url.'&parent_id='.$category['id']), |
'U_MOVE_UP'=>add_session_id($self_url.'&up='.$category['id']), |
'U_MOVE_DOWN'=>add_session_id($self_url.'&down='.$category['id']), |
'U_CAT_EDIT'=> |
add_session_id($base_url.'cat_modify&cat_id='.$category['id']), |
'U_CAT_DELETE'=>add_session_id($self_url.'&delete='.$category['id']), |
'U_INFO_IMG' |
=> add_session_id($base_url.'infos_images&cat_id='.$category['id']) |
)); |
if (!empty($category['dir'])) |
{ |
$template->assign_block_vars('category.storage' ,array()); |
} |
else |
{ |
$template->assign_block_vars('category.virtual' ,array()); |
} |
if ($category['nb_images'] > 0) |
{ |
$template->assign_block_vars('category.image_info' ,array()); |
} |
else |
{ |
$template->assign_block_vars('category.no_image_info' ,array()); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | sending html code | |
// +-----------------------------------------------------------------------+ |
$template->assign_var_from_handle('ADMIN_CONTENT', 'categories'); |
?> |
/web/test/gallery/phpwebgallery/admin/cat_modify.php |
---|
0,0 → 1,210 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: cat_modify.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.27 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if (!defined('PHPWG_ROOT_PATH')) |
{ |
die('Hacking attempt!'); |
} |
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
//---------------------------------------------------------------- verification |
if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) ) |
{ |
$_GET['cat_id'] = '-1'; |
} |
$template->set_filenames( array('categories'=>'admin/cat_modify.tpl') ); |
//--------------------------------------------------------- form criteria check |
if ( isset( $_POST['submit'] ) ) |
{ |
$query = 'SELECT status'; |
$query.= ' FROM '.CATEGORIES_TABLE; |
$query.= ' WHERE id = '.$_GET['cat_id']; |
$query.= ';'; |
$row = mysql_fetch_array( pwg_query( $query ) ); |
$query = 'UPDATE '.CATEGORIES_TABLE; |
$query.= ' SET name = '; |
if ( empty($_POST['name'])) |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'"; |
$query.= ', comment = '; |
if ( empty($_POST['comment'])) |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'"; |
if ( isset( $_POST['uploadable'] ) ) |
$query.= ", uploadable = '".$_POST['uploadable']."'"; |
if ( isset( $_POST['commentable'] ) ) |
$query.= ", commentable = '".$_POST['commentable']."'"; |
if ( isset( $_POST['associate'] ) ) |
{ |
$query.= ', id_uppercat = '; |
if ( $_POST['associate'] == -1 or $_POST['associate'] == '' ) |
$query.= 'NULL'; |
else |
$query.= $_POST['associate']; |
} |
$query.= ' WHERE id = '.$_GET['cat_id']; |
$query.= ';'; |
pwg_query( $query ); |
set_cat_visible(array($_GET['cat_id']), $_POST['visible']); |
set_cat_status(array($_GET['cat_id']), $_POST['status']); |
$template->assign_block_vars('confirmation' ,array()); |
} |
else if (isset($_POST['set_random_representant'])) |
{ |
set_random_representant(array($_GET['cat_id'])); |
} |
$query = ' |
SELECT * |
FROM '.CATEGORIES_TABLE.' |
WHERE id = '.$_GET['cat_id'].' |
;'; |
$category = mysql_fetch_array( pwg_query( $query ) ); |
// nullable fields |
foreach (array('comment','dir','site_id') as $nullable) |
{ |
if (!isset($category[$nullable])) |
{ |
$category[$nullable] = ''; |
} |
} |
// Navigation path |
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&parent_id='; |
$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">'; |
$navigation.= $lang['home'].'</a>'.$conf['level_separator']; |
$navigation.= get_cat_display_name_cache( |
$category['uppercats'], |
$url); |
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$_GET['cat_id']; |
$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; |
$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED'; |
if ($category['commentable'] == 'true') |
{ |
$commentable = 'COMMENTABLE_TRUE'; |
} |
else |
{ |
$commentable = 'COMMENTABLE_FALSE'; |
} |
if ($category['uploadable'] == 'true') |
{ |
$uploadable = 'UPLOADABLE_TRUE'; |
} |
else |
{ |
$uploadable = 'UPLOADABLE_FALSE'; |
} |
//----------------------------------------------------- template initialization |
$template->assign_vars(array( |
'CATEGORIES_NAV'=>$navigation, |
'CAT_NAME'=>$category['name'], |
'CAT_COMMENT'=>$category['comment'], |
$status=>'checked="checked"', |
$lock=>'checked="checked"', |
$commentable=>'checked="checked"', |
$uploadable=>'checked="checked"', |
'L_EDIT_CONFIRM'=>$lang['editcat_confirm'], |
'L_EDIT_NAME'=>$lang['name'], |
'L_STORAGE'=>$lang['storage'], |
'L_REMOTE_SITE'=>$lang['remote_site'], |
'L_EDIT_COMMENT'=>$lang['description'], |
'L_EDIT_CAT_OPTIONS'=>$lang['cat_options'], |
'L_EDIT_STATUS'=>$lang['conf_access'], |
'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'], |
'L_STATUS_PUBLIC'=>$lang['public'], |
'L_STATUS_PRIVATE'=>$lang['private'], |
'L_EDIT_LOCK'=>$lang['lock'], |
'L_EDIT_LOCK_INFO'=>$lang['editcat_lock_info'], |
'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'], |
'L_EDIT_UPLOADABLE_INFO'=>$lang['editcat_uploadable_info'], |
'L_EDIT_COMMENTABLE'=>$lang['comments'], |
'L_EDIT_COMMENTABLE_INFO'=>$lang['editcat_commentable_info'], |
'L_YES'=>$lang['yes'], |
'L_NO'=>$lang['no'], |
'L_SUBMIT'=>$lang['submit'], |
'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'], |
'F_ACTION'=>add_session_id($form_action) |
)); |
if ($category['nb_images'] > 0) |
{ |
$query = ' |
SELECT tn_ext,path |
FROM '.IMAGES_TABLE.' |
WHERE id = '.$category['representative_picture_id'].' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
$url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; |
$url.= '&image_id='.$category['representative_picture_id']; |
$template->assign_block_vars('representant', |
array('SRC' => $src, |
'URL' => $url)); |
} |
if (!empty($category['dir'])) |
{ |
$template->assign_block_vars( |
'storage', |
array('CATEGORY_DIR'=>preg_replace('/\/$/', |
'', |
get_complete_dir($category['id'])))); |
$template->assign_block_vars('upload' ,array()); |
} |
if (is_numeric($category['site_id']) and $category['site_id'] != 1) |
{ |
$query = ' |
SELECT galleries_url |
FROM '.SITES_TABLE.' |
WHERE id = '.$category['site_id'].' |
;'; |
list($galleries_url) = mysql_fetch_array(pwg_query($query)); |
$template->assign_block_vars('server', array('SITE_URL' => $galleries_url)); |
} |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'categories'); |
?> |
/web/test/gallery/phpwebgallery/admin/cat_options.php |
---|
0,0 → 1,260 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: cat_options.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.6 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if (!defined('PHPWG_ROOT_PATH')) |
{ |
die ("Hacking attempt!"); |
} |
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
// +-----------------------------------------------------------------------+ |
// | modification registration | |
// +-----------------------------------------------------------------------+ |
// print '<pre>'; |
// print_r($_POST); |
// print '</pre>'; |
if (isset($_POST['falsify']) |
and isset($_POST['cat_true']) |
and count($_POST['cat_true']) > 0) |
{ |
switch ($_GET['section']) |
{ |
case 'upload' : |
{ |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET uploadable = \'false\' |
WHERE id IN ('.implode(',', $_POST['cat_true']).') |
;'; |
pwg_query($query); |
break; |
} |
case 'comments' : |
{ |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET commentable = \'false\' |
WHERE id IN ('.implode(',', $_POST['cat_true']).') |
;'; |
pwg_query($query); |
break; |
} |
case 'visible' : |
{ |
set_cat_visible($_POST['cat_true'], 'false'); |
break; |
} |
case 'status' : |
{ |
set_cat_status($_POST['cat_true'], 'private'); |
break; |
} |
} |
} |
else if (isset($_POST['trueify']) |
and isset($_POST['cat_false']) |
and count($_POST['cat_false']) > 0) |
{ |
switch ($_GET['section']) |
{ |
case 'upload' : |
{ |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET uploadable = \'true\' |
WHERE id IN ('.implode(',', $_POST['cat_false']).') |
;'; |
pwg_query($query); |
break; |
} |
case 'comments' : |
{ |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET commentable = \'true\' |
WHERE id IN ('.implode(',', $_POST['cat_false']).') |
;'; |
pwg_query($query); |
break; |
} |
case 'visible' : |
{ |
set_cat_visible($_POST['cat_false'], 'true'); |
break; |
} |
case 'status' : |
{ |
set_cat_status($_POST['cat_false'], 'public'); |
break; |
} |
} |
} |
// +-----------------------------------------------------------------------+ |
// | template init | |
// +-----------------------------------------------------------------------+ |
$template->set_filenames(array('cat_options'=>'admin/cat_options.tpl')); |
if (!isset($_GET['section'])) |
{ |
$page['section'] = 'upload'; |
} |
else |
{ |
$page['section'] = $_GET['section']; |
} |
$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&section='; |
$template->assign_vars( |
array( |
'L_SUBMIT'=>$lang['submit'], |
'L_RESET'=>$lang['reset'], |
'F_ACTION'=>add_session_id($base_url.$page['section']) |
) |
); |
$template->assign_vars(array(strtoupper($page['section']).'_CLASS'=>'opened')); |
// +-----------------------------------------------------------------------+ |
// | form display | |
// +-----------------------------------------------------------------------+ |
// for each section, categories in the multiselect field can be : |
// |
// - true : uploadable for upload section |
// - false : un-uploadable for upload section |
// - NA : (not applicable) for virtual categories |
// |
// for true and false status, we associates an array of category ids, |
// function display_select_categories will use the given CSS class for each |
// option |
$cats_true = array(); |
$cats_false = array(); |
switch ($page['section']) |
{ |
case 'upload' : |
{ |
$query_true = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE uploadable = \'true\' |
AND dir IS NOT NULL |
AND site_id = 1 |
;'; |
$query_false = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE uploadable = \'false\' |
AND dir IS NOT NULL |
AND site_id = 1 |
;'; |
$template->assign_vars( |
array( |
'L_CAT_TITLE' => $lang['cat_upload_title'], |
'L_CAT_OPTIONS_TRUE' => $lang['authorized'], |
'L_CAT_OPTIONS_FALSE' => $lang['forbidden'], |
'L_CAT_OPTIONS_INFO' => $lang['cat_upload_info'], |
) |
); |
$template->assign_block_vars('upload', array()); |
break; |
} |
case 'comments' : |
{ |
$query_true = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE commentable = \'true\' |
;'; |
$query_false = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE commentable = \'false\' |
;'; |
$template->assign_vars( |
array( |
'L_CAT_TITLE' => $lang['cat_comments_title'], |
'L_CAT_OPTIONS_TRUE' => $lang['authorized'], |
'L_CAT_OPTIONS_FALSE' => $lang['forbidden'], |
'L_CAT_OPTIONS_INFO' => $lang['cat_comments_info'], |
) |
); |
$template->assign_block_vars('comments', array()); |
break; |
} |
case 'visible' : |
{ |
$query_true = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE visible = \'true\' |
;'; |
$query_false = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE visible = \'false\' |
;'; |
$template->assign_vars( |
array( |
'L_CAT_TITLE' => $lang['cat_lock_title'], |
'L_CAT_OPTIONS_TRUE' => $lang['unlocked'], |
'L_CAT_OPTIONS_FALSE' => $lang['locked'], |
'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'], |
) |
); |
$template->assign_block_vars('visible', array()); |
break; |
} |
case 'status' : |
{ |
$query_true = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE status = \'public\' |
;'; |
$query_false = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE status = \'private\' |
;'; |
$template->assign_vars( |
array( |
'L_CAT_TITLE' => $lang['cat_status_title'], |
'L_CAT_OPTIONS_TRUE' => $lang['cat_public'], |
'L_CAT_OPTIONS_FALSE' => $lang['cat_private'], |
'L_CAT_OPTIONS_INFO' => $lang['cat_status_info'], |
) |
); |
$template->assign_block_vars('status', array()); |
break; |
} |
} |
display_select_cat_wrapper($query_true,array(),'category_option_true'); |
display_select_cat_wrapper($query_false,array(),'category_option_false'); |
// +-----------------------------------------------------------------------+ |
// | sending html code | |
// +-----------------------------------------------------------------------+ |
$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options'); |
?> |
/web/test/gallery/phpwebgallery/admin/cat_perm.php |
---|
0,0 → 1,228 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: cat_perm.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.14 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
include_once( './admin/include/isadmin.inc.php' ); |
//----------------------------------------------------- template initialization |
$sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_perm.vtp' ); |
$error = array(); |
$tpl = array( 'permuser_authorized','permuser_forbidden','menu_groups', |
'submit','menu_users','permuser_parent_forbidden' ); |
templatize_array( $tpl, 'lang', $sub ); |
$vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); |
//-------------------------------------------------------------- category infos |
if ( isset( $_GET['cat_id'] ) ) |
{ |
check_cat_id( $_GET['cat_id'] ); |
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
{ |
$result = get_cat_info( $page['cat'] ); |
$page['cat_name'] = $result['name']; |
$page['id_uppercat'] = $result['id_uppercat']; |
} |
} |
//---------------------------------------------------------- permission updates |
if ( isset( $_POST['submit'] ) ) |
{ |
// groups access update |
$query = 'DELETE'; |
$query.= ' FROM '.PREFIX_TABLE.'group_access'; |
$query.= ' WHERE cat_id = '.$page['cat']; |
$query.= ';'; |
pwg_query( $query ); |
$query = 'SELECT id'; |
$query.= ' FROM '.PREFIX_TABLE.'groups'; |
$query.= ';'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$radioname = 'groupaccess-'.$row['id']; |
if ( $_POST[$radioname] == 0 ) |
{ |
$query = 'INSERT INTO '.PREFIX_TABLE.'group_access'; |
$query.= ' (cat_id,group_id) VALUES'; |
$query.= ' ('.$page['cat'].','.$row['id'].')'; |
$query.= ';'; |
pwg_query( $query ); |
} |
} |
// users access update |
$query = 'DELETE'; |
$query.= ' FROM '.PREFIX_TABLE.'user_access'; |
$query.= ' WHERE cat_id = '.$page['cat']; |
$query.= ';'; |
pwg_query( $query ); |
$query = 'SELECT id'; |
$query.= ' FROM '.USERS_TABLE; |
$query.= ';'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$radioname = 'useraccess-'.$row['id']; |
if ( $_POST[$radioname] == 0 ) |
{ |
$query = 'INSERT INTO '.PREFIX_TABLE.'user_access'; |
$query.= ' (cat_id,user_id) VALUES'; |
$query.= ' ('.$page['cat'].','.$row['id'].')'; |
$query.= ';'; |
pwg_query( $query ); |
} |
check_favorites( $row['id'] ); |
} |
// resynchronize all users |
synchronize_all_users(); |
} |
//---------------------------------------------------------------------- groups |
$query = 'SELECT id,name'; |
$query.= ' FROM '.PREFIX_TABLE.'groups'; |
$query. ';'; |
$result = pwg_query( $query ); |
if ( mysql_num_rows( $result ) > 0 ) |
{ |
$vtp->addSession( $sub, 'groups' ); |
// creating an array with all authorized groups for this category |
$query = 'SELECT group_id'; |
$query.= ' FROM '.PREFIX_TABLE.'group_access'; |
$query.= ' WHERE cat_id = '.$_GET['cat_id']; |
$query.= ';'; |
$subresult = pwg_query( $query ); |
$authorized_groups = array(); |
while ( $subrow = mysql_fetch_array( $subresult ) ) |
{ |
array_push( $authorized_groups, $subrow['group_id'] ); |
} |
// displaying each group |
while( $row = mysql_fetch_array( $result ) ) |
{ |
$vtp->addSession( $sub, 'group' ); |
if ( in_array( $row['id'], $authorized_groups ) ) |
{ |
$vtp->setVar( $sub, 'group.color', 'green' ); |
$vtp->setVar( $sub, 'group.authorized_checked', ' checked="checked"' ); |
} |
else |
{ |
$vtp->setVar( $sub, 'group.color', 'red' ); |
$vtp->setVar( $sub, 'group.forbidden_checked', ' checked="checked"' ); |
} |
$vtp->setVar( $sub, 'group.groupname', $row['name'] ); |
$vtp->setVar( $sub, 'group.id', $row['id'] ); |
$url = './admin.php?page=group_perm&group_id='.$row['id']; |
$vtp->setVar( $sub, 'group.group_perm_link', add_session_id( $url ) ); |
$vtp->closeSession( $sub, 'group' ); |
} |
$vtp->closeSession( $sub, 'groups' ); |
} |
//----------------------------------------------------------------------- users |
$query = 'SELECT id,username,status'; |
$query.= ' FROM '.USERS_TABLE; |
// only the webmaster can modify webmaster's permissions |
if ( $user['username'] != $conf['webmaster'] ) |
{ |
$query.= " WHERE username != '".$conf['webmaster']."'"; |
} |
$query.= ';'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$vtp->addSession( $sub, 'user' ); |
$vtp->setVar( $sub, 'user.id', $row['id'] ); |
$url = add_session_id( './admin.php?page=user_perm&user_id='.$row['id']); |
$vtp->setVar( $sub, 'user.user_perm_link', $url); |
if ( $row['username'] == 'guest' ) |
{ |
$row['username'] = $lang['guest']; |
} |
$vtp->setVar( $sub, 'user.username', $row['username'] ); |
// for color of user : (red means access forbidden, green authorized) we |
// ask all forbidden categories, including the groups rights |
$restrictions = get_user_restrictions( $row['id'], $row['status'], false ); |
$is_user_allowed = is_user_allowed( $page['cat'], $restrictions ); |
if ( $is_user_allowed == 0 ) |
{ |
$vtp->setVar( $sub, 'user.color', 'green' ); |
} |
else |
{ |
$vtp->setVar( $sub, 'user.color', 'red' ); |
} |
// for permission update button, we only ask forbidden categories for the |
// user, not taking into account the groups the user belongs to |
$restrictions = get_user_restrictions($row['id'],$row['status'],false,false); |
$is_user_allowed = is_user_allowed( $page['cat'], $restrictions ); |
if ( $is_user_allowed == 2 ) |
{ |
$vtp->addSession( $sub, 'parent_forbidden' ); |
$url = './admin.php?page=cat_perm&cat_id='.$page['id_uppercat']; |
$vtp->setVar( $sub, 'parent_forbidden.url', add_session_id( $url ) ); |
$vtp->closeSession( $sub, 'parent_forbidden' ); |
} |
if ( $is_user_allowed == 0 ) |
{ |
$vtp->setVar( $sub, 'user.authorized_checked', ' checked="checked"' ); |
} |
else |
{ |
$vtp->setVar( $sub, 'user.forbidden_checked', ' checked="checked"' ); |
} |
// user's group(s) |
$query = 'SELECT g.name as groupname, g.id as groupid'; |
$query.= ' FROM '.PREFIX_TABLE.'groups as g'; |
$query.= ', '.PREFIX_TABLE.'user_group as ug'; |
$query.= ' WHERE ug.group_id = g.id'; |
$query.= ' AND ug.user_id = '.$row['id']; |
$query.= ';'; |
$subresult = pwg_query( $query ); |
if ( mysql_num_rows( $subresult ) > 0 ) |
{ |
$vtp->addSession( $sub, 'usergroups' ); |
$i = 0; |
while( $subrow = mysql_fetch_array( $subresult ) ) |
{ |
$vtp->addSession( $sub, 'usergroup' ); |
if ( in_array( $subrow['groupid'], $authorized_groups ) ) |
{ |
$vtp->setVar( $sub, 'usergroup.color', 'green' ); |
} |
else |
{ |
$vtp->setVar( $sub, 'usergroup.color', 'red' ); |
} |
$vtp->setVar( $sub, 'usergroup.name', $subrow['groupname'] ); |
if ( $i < mysql_num_rows( $subresult ) - 1 ) |
{ |
$vtp->setVar( $sub, 'usergroup.separation', ',' ); |
} |
$vtp->closeSession( $sub, 'usergroup' ); |
$i++; |
} |
$vtp->closeSession( $sub, 'usergroups' ); |
} |
$vtp->closeSession( $sub, 'user' ); |
} |
//----------------------------------------------------------- sending html code |
$vtp->Parse( $handle , 'sub', $sub ); |
?> |
/web/test/gallery/phpwebgallery/admin/configuration.php |
---|
0,0 → 1,375 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: configuration.php,v $ |
// | last update : $Date: 2005/05/14 12:56:48 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.44.2.2 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if( !defined("PHPWG_ROOT_PATH") ) |
{ |
die ("Hacking attempt!"); |
} |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
//-------------------------------------------------------- sections definitions |
if (!isset($_GET['section'])) |
{ |
$page['section'] = 'general'; |
} |
else |
{ |
$page['section'] = $_GET['section']; |
} |
//------------------------------------------------------ $conf reinitialization |
$result = pwg_query('SELECT param,value FROM '.CONFIG_TABLE); |
while ($row = mysql_fetch_array($result)) |
{ |
$conf[$row['param']] = $row['value']; |
// if the parameter is present in $_POST array (if a form is submited), we |
// override it with the submited value |
if (isset($_POST[$row['param']])) |
{ |
$conf[$row['param']] = $_POST[$row['param']]; |
} |
} |
//------------------------------ verification and registration of modifications |
$errors = array(); |
if (isset($_POST['submit'])) |
{ |
$int_pattern = '/^\d+$/'; |
switch ($page['section']) |
{ |
case 'general' : |
{ |
// thumbnail prefix must only contain simple ASCII characters |
if (!preg_match('/^[\w-]*$/', $_POST['prefix_thumbnail'])) |
{ |
array_push($errors, $lang['conf_prefix_thumbnail_error']); |
} |
// as webmaster mail address shown on the website, it can be obfuscated |
// and no comply with normal mail address pattern |
break; |
} |
case 'comments' : |
{ |
// the number of comments per page must be an integer between 5 and 50 |
// included |
if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
or $_POST['nb_comment_page'] < 5 |
or $_POST['nb_comment_page'] > 50) |
{ |
array_push($errors, $lang['conf_nb_comment_page_error']); |
} |
break; |
} |
case 'default' : |
{ |
// periods must be integer values, they represents number of days |
if (!preg_match($int_pattern, $_POST['recent_period']) |
or $_POST['recent_period'] <= 0) |
{ |
array_push($errors, $lang['periods_error']); |
} |
// maxwidth |
if (isset($_POST['default_maxwidth']) |
and !empty($_POST['default_maxwidth']) |
and (!preg_match($int_pattern, $_POST['default_maxwidth']) |
or $_POST['default_maxwidth'] < 50)) |
{ |
array_push($errors, $lang['maxwidth_error']); |
} |
// maxheight |
if (isset($_POST['default_maxheight']) |
and !empty($_POST['default_maxheight']) |
and (!preg_match($int_pattern, $_POST['default_maxheight']) |
or $_POST['default_maxheight'] < 50)) |
{ |
array_push($errors, $lang['maxheight_error']); |
} |
break; |
} |
case 'upload' : |
{ |
// the maximum upload filesize must be an integer between 10 and 1000 |
if (!preg_match($int_pattern, $_POST['upload_maxfilesize']) |
or $_POST['upload_maxfilesize'] < 10 |
or $_POST['upload_maxfilesize'] > 1000) |
{ |
array_push($errors, $lang['conf_upload_maxfilesize_error']); |
} |
foreach (array('upload_maxwidth', |
'upload_maxheight', |
'upload_maxwidth_thumbnail', |
'upload_maxheight_thumbnail') |
as $field) |
{ |
if (!preg_match($int_pattern, $_POST[$field]) |
or $_POST[$field] < 10) |
{ |
array_push($errors, $lang['conf_'.$field.'_error']); |
} |
} |
break; |
} |
} |
// updating configuration if no error found |
if (count($errors) == 0) |
{ |
$result = pwg_query('SELECT * FROM '.CONFIG_TABLE); |
while ($row = mysql_fetch_array($result)) |
{ |
if (isset($_POST[$row['param']])) |
{ |
$query = ' |
UPDATE '.CONFIG_TABLE.' |
SET value = \''. str_replace("\'", "''", $_POST[$row['param']]).'\' |
WHERE param = \''.$row['param'].'\' |
;'; |
pwg_query($query); |
} |
} |
} |
} |
//----------------------------------------------------- template initialization |
$template->set_filenames( array('config'=>'admin/configuration.tpl') ); |
$action = PHPWG_ROOT_PATH.'admin.php?page=configuration'; |
$action.= '&section='.$page['section']; |
$template->assign_vars( |
array( |
'L_CONFIRM'=>$lang['conf_confirmation'], |
'L_YES'=>$lang['yes'], |
'L_NO'=>$lang['no'], |
'L_SUBMIT'=>$lang['submit'], |
'L_RESET'=>$lang['reset'], |
'F_ACTION'=>add_session_id($action) |
)); |
switch ($page['section']) |
{ |
case 'general' : |
{ |
$history_yes = ($conf['log']=='true')?'checked="checked"':''; |
$history_no = ($conf['log']=='false')?'checked="checked"':''; |
$notif_yes = ($conf['mail_notification']=='true')?'checked="checked"':''; |
$notif_no = ($conf['mail_notification']=='false')?'checked="checked"':''; |
$lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':''; |
$lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':''; |
$template->assign_block_vars( |
'general', |
array( |
'L_CONF_TITLE'=>$lang['conf_general_title'], |
'L_CONF_MAIL'=>$lang['conf_mail_webmaster'], |
'L_CONF_MAIL_INFO'=>$lang['conf_mail_webmaster_info'], |
'L_CONF_TN_PREFIX'=>$lang['conf_prefix'], |
'L_CONF_TN_PREFIX_INFO'=>$lang['conf_prefix_info'], |
'L_CONF_HISTORY'=>$lang['history'], |
'L_CONF_HISTORY_INFO'=>$lang['conf_log_info'], |
'L_CONF_NOTIFICATION'=>$lang['conf_notification'], |
'L_CONF_NOTIFICATION_INFO'=>$lang['conf_notification_info'], |
'L_CONF_GALLERY_LOCKED'=>$lang['conf_gallery_locked'], |
'L_CONF_GALLERY_LOCKED_INFO'=>$lang['conf_gallery_locked_info'], |
'ADMIN_MAIL'=>$conf['mail_webmaster'], |
'THUMBNAIL_PREFIX'=>$conf['prefix_thumbnail'], |
'HISTORY_YES'=>$history_yes, |
'HISTORY_NO'=>$history_no, |
'NOTIFICATION_YES'=>$notif_yes, |
'NOTIFICATION_NO'=>$notif_no, |
'GALLERY_LOCKED_YES'=>$lock_yes, |
'GALLERY_LOCKED_NO'=>$lock_no, |
)); |
break; |
} |
case 'comments' : |
{ |
$all_yes = ($conf['comments_forall']=='true')?'checked="checked"':''; |
$all_no = ($conf['comments_forall']=='false')?'checked="checked"':''; |
$validate_yes = ($conf['comments_validation']=='true')?'checked="checked"':''; |
$validate_no = ($conf['comments_validation']=='false')?'checked="checked"':''; |
$template->assign_block_vars( |
'comments', |
array( |
'L_CONF_TITLE'=>$lang['conf_comments_title'], |
'L_CONF_COMMENTS_ALL'=>$lang['conf_comments_forall'], |
'L_CONF_COMMENTS_ALL_INFO'=>$lang['conf_comments_forall_info'], |
'L_CONF_NB_COMMENTS_PAGE'=>$lang['conf_nb_comment_page'], |
'L_CONF_NB_COMMENTS_PAGE_INFO'=>$lang['conf_nb_comment_page'], |
'L_CONF_VALIDATE'=>$lang['conf_comments_validation'], |
'L_CONF_VALIDATE_INFO'=>$lang['conf_comments_validation_info'], |
'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
'COMMENTS_ALL_YES'=>$all_yes, |
'COMMENTS_ALL_NO'=>$all_no, |
'VALIDATE_YES'=>$validate_yes, |
'VALIDATE_NO'=>$validate_no |
)); |
break; |
} |
case 'default' : |
{ |
$show_yes = ($conf['show_nb_comments']=='true')?'checked="checked"':''; |
$show_no = ($conf['show_nb_comments']=='false')?'checked="checked"':''; |
$expand_yes = ($conf['auto_expand']=='true')?'checked="checked"':''; |
$expand_no = ($conf['auto_expand']=='false')?'checked="checked"':''; |
$template->assign_block_vars( |
'default', |
array( |
'L_CONF_TITLE'=>$lang['conf_default_title'], |
'L_CONF_LANG'=>$lang['language'], |
'L_CONF_LANG_INFO'=>$lang['conf_default_language_info'], |
'L_NB_IMAGE_LINE'=>$lang['nb_image_per_row'], |
'L_NB_IMAGE_LINE_INFO'=>$lang['conf_nb_image_line_info'], |
'L_NB_ROW_PAGE'=>$lang['nb_row_per_page'], |
'L_NB_ROW_PAGE_INFO'=>$lang['conf_nb_line_page_info'], |
'L_CONF_STYLE'=>$lang['theme'], |
'L_CONF_STYLE_INFO'=>$lang['conf_default_theme_info'], |
'L_CONF_RECENT'=>$lang['recent_period'], |
'L_CONF_RECENT_INFO'=>$lang['conf_recent_period_info'], |
'L_CONF_EXPAND'=>$lang['auto_expand'], |
'L_CONF_EXPAND_INFO'=>$lang['conf_default_expand_info'], |
'L_NB_COMMENTS'=>$lang['show_nb_comments'], |
'L_NB_COMMENTS_INFO'=>$lang['conf_show_nb_comments_info'], |
'L_MAXWIDTH'=>$lang['maxwidth'], |
'L_MAXHEIGHT'=>$lang['maxheight'], |
'CONF_LANG_SELECT'=>language_select($conf['default_language'], 'default_language'), |
'NB_IMAGE_LINE'=>$conf['nb_image_line'], |
'NB_ROW_PAGE'=>$conf['nb_line_page'], |
'CONF_STYLE_SELECT'=>style_select($conf['default_template'], 'default_template'), |
'CONF_RECENT'=>$conf['recent_period'], |
'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
'MAXWIDTH'=>$conf['default_maxwidth'], |
'MAXHEIGHT'=>$conf['default_maxheight'], |
'EXPAND_YES'=>$expand_yes, |
'EXPAND_NO'=>$expand_no, |
'SHOW_COMMENTS_YES'=>$show_yes, |
'SHOW_COMMENTS_NO'=>$show_no |
)); |
break; |
} |
case 'upload' : |
{ |
$template->assign_block_vars( |
'upload', |
array( |
'L_CONF_TITLE'=>$lang['conf_upload_title'], |
'L_CONF_MAXSIZE'=>$lang['conf_upload_maxfilesize'], |
'L_CONF_MAXSIZE_INFO'=>$lang['conf_upload_maxfilesize_info'], |
'L_CONF_MAXWIDTH'=>$lang['conf_upload_maxwidth'], |
'L_CONF_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_info'], |
'L_CONF_MAXHEIGHT'=>$lang['conf_upload_maxheight'], |
'L_CONF_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_info'], |
'L_CONF_TN_MAXWIDTH'=>$lang['conf_upload_tn_maxwidth'], |
'L_CONF_TN_MAXWIDTH_INFO'=>$lang['conf_upload_tn_maxwidth_info'], |
'L_CONF_TN_MAXHEIGHT'=>$lang['conf_upload_tn_maxheight'], |
'L_CONF_TN_MAXHEIGHT_INFO'=>$lang['conf_upload_tn_maxheight_info'], |
'UPLOAD_MAXSIZE'=>$conf['upload_maxfilesize'], |
'UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth'], |
'UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight'], |
'TN_UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth_thumbnail'], |
'TN_UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight_thumbnail'], |
)); |
break; |
} |
case 'session' : |
{ |
$authorize_remembering_yes = |
($conf['authorize_remembering']=='true')?'checked="checked"':''; |
$authorize_remembering_no = |
($conf['authorize_remembering']=='false')?'checked="checked"':''; |
$template->assign_block_vars( |
'session', |
array( |
'L_CONF_TITLE'=>$lang['conf_session_title'], |
'L_CONF_AUTHORIZE_REMEMBERING'=>$lang['conf_authorize_remembering'], |
'L_CONF_AUTHORIZE_REMEMBERING_INFO' => |
$lang['conf_authorize_remembering_info'], |
'AUTHORIZE_REMEMBERING_YES'=>$authorize_remembering_yes, |
'AUTHORIZE_REMEMBERING_NO'=>$authorize_remembering_no |
)); |
break; |
} |
case 'metadata' : |
{ |
$exif_yes = ($conf['use_exif']=='true')?'checked="checked"':''; |
$exif_no = ($conf['use_exif']=='false')?'checked="checked"':''; |
$iptc_yes = ($conf['use_iptc']=='true')?'checked="checked"':''; |
$iptc_no = ($conf['use_iptc']=='false')?'checked="checked"':''; |
$show_exif_yes = ($conf['show_exif']=='true')?'checked="checked"':''; |
$show_exif_no = ($conf['show_exif']=='false')?'checked="checked"':''; |
$show_iptc_yes = ($conf['show_iptc']=='true')?'checked="checked"':''; |
$show_iptc_no = ($conf['show_iptc']=='false')?'checked="checked"':''; |
$template->assign_block_vars( |
'metadata', |
array( |
'L_CONF_TITLE'=>$lang['conf_metadata_title'], |
'L_CONF_EXIF'=>$lang['conf_use_exif'], |
'L_CONF_EXIF_INFO'=>$lang['conf_use_exif_info'], |
'L_CONF_IPTC'=>$lang['conf_use_iptc'], |
'L_CONF_IPTC_INFO'=>$lang['conf_use_iptc_info'], |
'L_CONF_SHOW_EXIF'=>$lang['conf_show_exif'], |
'L_CONF_SHOW_EXIF_INFO'=>$lang['conf_show_exif_info'], |
'L_CONF_SHOW_IPTC'=>$lang['conf_show_iptc'], |
'L_CONF_SHOW_IPTC_INFO'=>$lang['conf_show_iptc_info'], |
'USE_EXIF_YES'=>$exif_yes, |
'USE_EXIF_NO'=>$exif_no, |
'USE_IPTC_YES'=>$iptc_yes, |
'USE_IPTC_NO'=>$iptc_no, |
'SHOW_EXIF_YES'=>$show_exif_yes, |
'SHOW_EXIF_NO'=>$show_exif_no, |
'SHOW_IPTC_YES'=>$show_iptc_yes, |
'SHOW_IPTC_NO'=>$show_iptc_no |
)); |
break; |
} |
} |
//-------------------------------------------------------------- errors display |
if ( sizeof( $errors ) != 0 ) |
{ |
$template->assign_block_vars('errors',array()); |
for ( $i = 0; $i < sizeof( $errors ); $i++ ) |
{ |
$template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); |
} |
} |
elseif ( isset( $_POST['submit'] ) ) |
{ |
$template->assign_block_vars('confirmation' ,array()); |
} |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
?> |
/web/test/gallery/phpwebgallery/admin/group_list.php |
---|
0,0 → 1,204 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: group_list.php,v $ |
// | last update : $Date: 2005/01/17 21:02:43 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.15 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if( !defined("PHPWG_ROOT_PATH") ) |
{ |
die ("Hacking attempt!"); |
} |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
//-------------------------------------------------------------- delete a group |
$error = array(); |
if ( isset( $_POST['delete'] ) && isset( $_POST['confirm_delete'] ) ) |
{ |
// destruction of the access linked to the group |
$query = 'DELETE FROM '.GROUP_ACCESS_TABLE; |
$query.= ' WHERE group_id = '.$_POST['group_id']; |
$query.= ';'; |
pwg_query( $query ); |
// destruction of the users links for this group |
$query = 'DELETE FROM ' . USER_GROUP_TABLE; |
$query.= ' WHERE group_id = '.$_POST['group_id']; |
pwg_query( $query ); |
// destruction of the group |
$query = 'DELETE FROM ' . GROUPS_TABLE; |
$query.= ' WHERE id = '.$_POST['group_id']; |
$query.= ';'; |
pwg_query( $query ); |
} |
//----------------------------------------------------------------- add a group |
elseif ( isset( $_POST['new'] ) ) |
{ |
if ( empty($_POST['newgroup']) || preg_match( "/'/", $_POST['newgroup'] ) |
or preg_match( '/"/', $_POST['newgroup'] ) ) |
{ |
array_push( $error, $lang['group_add_error1'] ); |
} |
if ( count( $error ) == 0 ) |
{ |
// is the group not already existing ? |
$query = 'SELECT id FROM '.GROUPS_TABLE; |
$query.= " WHERE name = '".$_POST['newgroup']."'"; |
$query.= ';'; |
$result = pwg_query( $query ); |
if ( mysql_num_rows( $result ) > 0 ) |
{ |
array_push( $error, $lang['group_add_error2'] ); |
} |
} |
if ( count( $error ) == 0 ) |
{ |
// creating the group |
$query = ' INSERT INTO '.GROUPS_TABLE; |
$query.= " (name) VALUES ('".$_POST['newgroup']."')"; |
$query.= ';'; |
pwg_query( $query ); |
} |
} |
//--------------------------------------------------------------- user management |
elseif ( isset( $_POST['add'] ) ) |
{ |
$userdata = getuserdata($_POST['username']); |
if (!$userdata) |
{ |
array_push($error, $lang['user_err_unknown']); |
} |
else |
{ |
// create a new association between the user and a group |
$query = ' |
INSERT INTO '.USER_GROUP_TABLE.' |
(user_id,group_id) |
VALUES |
('.$userdata['id'].','.$_POST['edit_group_id'].') |
;'; |
pwg_query($query); |
} |
} |
elseif (isset( $_POST['deny_user'] )) |
{ |
$sql_in = ''; |
$members = $_POST['members']; |
for($i = 0; $i < count($members); $i++) |
{ |
$sql_in .= ( ( $sql_in != '' ) ? ', ' : '' ) . intval($members[$i]); |
} |
$query = 'DELETE FROM ' . USER_GROUP_TABLE; |
$query.= ' WHERE user_id IN ('.$sql_in; |
$query.= ') AND group_id = '.$_POST['edit_group_id']; |
pwg_query( $query ); |
} |
//-------------------------------------------------------------- errors display |
if ( sizeof( $error ) != 0 ) |
{ |
$template->assign_block_vars('errors',array()); |
for ( $i = 0; $i < sizeof( $error ); $i++ ) |
{ |
$template->assign_block_vars('errors.error',array('ERROR'=>$error[$i])); |
} |
} |
//----------------------------------------------------------------- groups list |
$query = 'SELECT id,name FROM '.GROUPS_TABLE; |
$query.= ' ORDER BY id ASC;'; |
$result = pwg_query( $query ); |
$groups_display = '<select name="group_id">'; |
$groups_nb=0; |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$groups_nb++; |
$selected = ''; |
if (isset($_POST['group_id']) && $_POST['group_id']==$row['id']) |
$selected = 'selected'; |
$groups_display .= '<option value="' . $row['id'] . '" '.$selected.'>' . $row['name'] . '</option>'; |
} |
$groups_display .= '</select>'; |
$action = PHPWG_ROOT_PATH.'admin.php?page=group_list'; |
//----------------------------------------------------- template initialization |
$template->set_filenames( array('groups'=>'admin/group_list.tpl') ); |
$template->assign_vars(array( |
'S_GROUP_SELECT'=>$groups_display, |
'L_GROUP_SELECT'=>$lang['group_list_title'], |
'L_GROUP_CONFIRM'=>$lang['group_confirm_delete'], |
'L_LOOK_UP'=>$lang['edit'], |
'L_GROUP_DELETE'=>$lang['delete'], |
'L_CREATE_NEW_GROUP'=>$lang['group_add'], |
'L_GROUP_EDIT'=>$lang['group_edit'], |
'L_USER_NAME'=>$lang['login'], |
'L_USER_EMAIL'=>$lang['mail_address'], |
'L_USER_SELECT'=>$lang['Select'], |
'L_DENY_SELECTED'=>$lang['group_deny_user'], |
'L_ADD_MEMBER'=>$lang['group_add_user'], |
'L_FIND_USERNAME'=>$lang['Find_username'], |
'S_GROUP_ACTION'=>add_session_id($action), |
'U_SEARCH_USER' => add_session_id(PHPWG_ROOT_PATH.'admin/search.php') |
)); |
if ($groups_nb) |
{ |
$template->assign_block_vars('select_box',array()); |
} |
//----------------------------------------------------------------- add a group |
if ( isset( $_POST['edit']) || isset( $_POST['add']) || isset( $_POST['deny_user'] )) |
{ |
// Retrieving the group name |
$query = 'SELECT id, name FROM '.GROUPS_TABLE; |
$query.= " WHERE id = '".$_POST['group_id']."'"; |
$query.= ';'; |
$result = mysql_fetch_array(pwg_query( $query )); |
$template->assign_block_vars('edit_group',array( |
'GROUP_NAME'=>$result['name'], |
'GROUP_ID'=>$result['id'] |
)); |
// Retrieving all the users |
$query = 'SELECT id, username, mail_address'; |
$query.= ' FROM ('.USERS_TABLE.' as u'; |
$query.= ' LEFT JOIN '.USER_GROUP_TABLE.' as ug ON ug.user_id=u.id)'; |
$query.= " WHERE ug.group_id = '".$_POST['group_id']."';"; |
$result = pwg_query( $query ); |
$i=0; |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$class = ($i % 2)? 'row1':'row2'; $i++; |
$template->assign_block_vars('edit_group.user',array( |
'ID'=>$row['id'], |
'NAME'=>$row['username'], |
'EMAIL'=>$row['mail_address'], |
'T_CLASS'=>$class |
)); |
} |
} |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'groups'); |
?> |
/web/test/gallery/phpwebgallery/admin/group_perm.php |
---|
0,0 → 1,167 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: group_perm.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.16 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if( !defined("PHPWG_ROOT_PATH") ) |
{ |
die ("Hacking attempt!"); |
} |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
//--------------------------------------------------------------------- updates |
if (isset($_POST['falsify']) |
and isset($_POST['cat_true']) |
and count($_POST['cat_true']) > 0) |
{ |
// if you forbid access to a category, all sub-categories become |
// automatically forbidden |
$subcats = get_subcat_ids($_POST['cat_true']); |
$query = 'DELETE FROM '.GROUP_ACCESS_TABLE.' |
WHERE group_id = '.$_POST['group_id'].' |
AND cat_id IN ('.implode(',', $subcats).');'; |
pwg_query($query); |
} |
else if (isset($_POST['trueify']) |
and isset($_POST['cat_false']) |
and count($_POST['cat_false']) > 0) |
{ |
$uppercats = get_uppercat_ids($_POST['cat_false']); |
$private_uppercats = array(); |
$query = 'SELECT id |
FROM '.CATEGORIES_TABLE.' |
WHERE id IN ('.implode(',', $uppercats).') |
AND status = \'private\';'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($private_uppercats, $row['id']); |
} |
// retrying to authorize a category which is already authorized may cause |
// an error (in SQL statement), so we need to know which categories are |
// accesible |
$authorized_ids = array(); |
$query = 'SELECT cat_id |
FROM '.GROUP_ACCESS_TABLE.' |
WHERE group_id = '.$_POST['group_id'].';'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($authorized_ids, $row['cat_id']); |
} |
$inserts = array(); |
$to_autorize_ids = array_diff($private_uppercats, $authorized_ids); |
foreach ($to_autorize_ids as $to_autorize_id) |
{ |
array_push($inserts, array('group_id' => $_POST['group_id'], |
'cat_id' => $to_autorize_id)); |
} |
mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts); |
} |
//----------------------------------------------------- template initialization |
$query = 'SELECT id,name FROM '.GROUPS_TABLE; |
$query.= ' ORDER BY id ASC;'; |
$result = pwg_query( $query ); |
$groups_display = '<select name="group_id">'; |
$groups_nb=0; |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$groups_nb++; |
$selected = ''; |
if (isset($_POST['group_id']) && $_POST['group_id']==$row['id']) |
$selected = 'selected'; |
$groups_display .= '<option value="' . $row['id'] . '" '.$selected.'>' . $row['name'] . '</option>'; |
} |
$groups_display .= '</select>'; |
$action = PHPWG_ROOT_PATH.'admin.php?page=group_perm'; |
$template->set_filenames( array('groups'=>'admin/group_perm.tpl') ); |
$template->assign_vars(array( |
'S_GROUP_SELECT'=>$groups_display, |
'L_GROUP_SELECT'=>$lang['group_list_title'], |
'L_LOOK_UP'=>$lang['edit'], |
'S_GROUP_ACTION'=>add_session_id($action) |
)); |
if ($groups_nb) |
{ |
$template->assign_block_vars('select_box',array()); |
} |
if ( isset( $_POST['edit']) || isset($_POST['falsify']) || isset($_POST['trueify'])) |
{ |
$template->set_filenames(array('groups_auth'=>'admin/cat_options.tpl')); |
$template->assign_vars(array( |
'L_RESET'=>$lang['reset'], |
'L_CAT_OPTIONS_TRUE'=>$lang['authorized'], |
'L_CAT_OPTIONS_FALSE'=>$lang['forbidden'], |
'L_CAT_OPTIONS_INFO'=>$lang['permuser_info'], |
'HIDDEN_NAME'=> 'group_id', |
'HIDDEN_VALUE'=>$_POST['group_id'], |
'F_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=group_perm'), |
)); |
// only private categories are listed |
$query_true = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' INNER JOIN '.GROUP_ACCESS_TABLE.' ON cat_id = id |
WHERE status = \'private\' |
AND group_id = '.$_POST['group_id'].' |
;'; |
display_select_cat_wrapper($query_true,array(),'category_option_true'); |
$result = pwg_query($query_true); |
$authorized_ids = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($authorized_ids, $row['id']); |
} |
$query_false = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE status = \'private\''; |
if (count($authorized_ids) > 0) |
{ |
$query_false.= ' |
AND id NOT IN ('.implode(',', $authorized_ids).')'; |
} |
$query_false.= ' |
;'; |
display_select_cat_wrapper($query_false,array(),'category_option_false'); |
$template->assign_var_from_handle('ADMIN_CONTENT_2', 'groups_auth'); |
} |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'groups'); |
?> |
/web/test/gallery/phpwebgallery/admin/help.php |
---|
0,0 → 1,46 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: help.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.11 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
//----------------------------------------------------- template initialization |
$template->set_filenames( array('help'=>'admin/help.tpl') ); |
//----------------------------------------------------- help categories display |
$categories = array('images','thumbnails','database','access','groups', |
'remote','upload','virtual','infos'); |
foreach ($categories as $category) |
{ |
$template->assign_block_vars( |
'cat', |
array('NAME'=>$lang['help_'.$category.'_title'])); |
foreach ($lang['help_'.$category] as $item) |
{ |
$template->assign_block_vars('cat.item', array('CONTENT'=>$item)); |
} |
} |
$template->assign_var_from_handle('ADMIN_CONTENT', 'help'); |
?> |
/web/test/gallery/phpwebgallery/admin/images/_vti_cnf/global_stats.img.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|11 Jan 2005 19:04:20 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|11 Jan 2005 19:04:20 -0000 |
vti_cacheddtm:TX|11 Jan 2005 19:04:20 -0000 |
vti_filesize:IR|5624 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/images/_vti_cnf/index.htm |
---|
0,0 → 1,17 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|09 May 2003 12:42:44 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|09 May 2003 12:42:44 -0000 |
vti_cacheddtm:TX|09 May 2003 12:42:44 -0000 |
vti_filesize:IR|133 |
vti_cachedtitle:SR|PhpWebGallery |
vti_cachedbodystyle:SR|<body> |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_title:SR|PhpWebGallery |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/images/_vti_cnf/phpBarGraph.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|14157 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/images/global_stats.img.php |
---|
0,0 → 1,121 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: global_stats.img.php,v $ |
// | last update : $Date: 2005/01/11 20:04:19 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.6 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
//----------------------------------------------------------- include |
define('PHPWG_ROOT_PATH','../../'); |
define('IN_ADMIN', true); |
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
include_once( 'phpBarGraph.php' ); |
//------------------------------------------------ variable definition |
$outputFormat = "png"; |
$legend = $lang['stats_global_graph_title']; |
$imageHeight = 256; |
$imageWidth = 320; |
$sql = "SELECT DISTINCT COUNT(*), MONTH(date) |
FROM ".HISTORY_TABLE." |
WHERE (date > DATE_SUB(CURRENT_DATE(), INTERVAL 12 MONTH)) |
GROUP BY DATE_FORMAT(date,'%Y-%m') DESC;"; |
//------------------------------------------------ Image definition |
$image = ImageCreate($imageWidth, $imageHeight); |
//$image = ImageCreateTrueColor($imageWidth, $imageHeight); |
// Fill it with your favorite background color.. |
$backgroundColor = ImageColorAllocate($image, 184, 184, 184); |
ImageFill($image, 0, 0, $backgroundColor); |
$white = ImageColorAllocate($image, 0, 0, 0); |
// Interlace the image.. |
Imageinterlace($image, 1); |
// Create a new BarGraph.. |
$myBarGraph = new PhpBarGraph; |
$myBarGraph->SetX(10); // Set the starting x position |
$myBarGraph->SetY(10); // Set the starting y position |
$myBarGraph->SetWidth($imageWidth-20); // Set how wide the bargraph will be |
$myBarGraph->SetHeight($imageHeight-20); // Set how tall the bargraph will be |
$myBarGraph->SetNumOfValueTicks(3); // Set this to zero if you don't want to show any. These are the vertical bars to help see the values. |
// You can try uncommenting these lines below for different looks. |
// $myBarGraph->SetShowLabels(false); // The default is true. Setting this to false will cause phpBarGraph to not print the labels of each bar. |
$myBarGraph->SetShowValues(false); // The default is true. Setting this to false will cause phpBarGraph to not print the values of each bar. |
// $myBarGraph->SetBarBorder(false); // The default is true. Setting this to false will cause phpBarGraph to not print the border of each bar. |
// $myBarGraph->SetShowFade(false); // The default is true. Setting this to false will cause phpBarGraph to not print each bar as a gradient. |
// $myBarGraph->SetShowOuterBox(false); // The default is true. Setting this to false will cause phpBarGraph to not print the outside box. |
$myBarGraph->SetBarSpacing(5); // The default is 10. This changes the space inbetween each bar. |
// Add Values to the bargraph.. |
$result = pwg_query($sql) |
or die(mysql_errno().": ".mysql_error()."<BR>".$sql); |
//$monthes =array_fill(1,12,0); |
$monthes =array(); |
$date = getdate(); |
$current_month = $date['mon']; |
for ($i=0;$i<12;$i++) |
{ |
$monthes[(($current_month-$i+11)%12)+1]=0; |
} |
while ($r = mysql_fetch_row($result)) |
{ |
if (!$monthes[$r[1]]) $monthes[$r[1]]= $r[0]; |
} |
$monthes = array_reverse($monthes,true); |
while (list ($key,$value) = each($monthes)) |
{ |
$nls_key = substr($lang['month'][$key],0,3); |
$myBarGraph->AddValue($nls_key, $value); |
} |
//$myBarGraph->SetDebug(true); |
// Set the colors of the bargraph.. |
$myBarGraph->SetStartBarColor("6666ff"); // This is the color on the top of every bar. |
$myBarGraph->SetEndBarColor("2222aa"); // This is the color on the bottom of every bar. This is not used when SetShowFade() is set to false. |
$myBarGraph->SetLineColor("000000"); // This is the color all the lines and text are printed out with. |
// Print the BarGraph to the image.. |
$myBarGraph->DrawBarGraph($image); |
Imagestring($image, 2, 2, $imageHeight-14, $legend, $white); |
//------------------------------------------------ Image output |
if ($outputFormat == "png") |
{ |
header("Content-type: image/png"); |
ImagePNG($image); |
} |
else if ($outputFormat == "jpg") |
{ |
header("Content-type: image/jpeg"); |
Imagejpeg($image); |
} |
// Destroy the image. |
Imagedestroy($image); |
?> |
/web/test/gallery/phpwebgallery/admin/images/index.htm |
---|
0,0 → 1,8 |
<html> |
<head> |
<title>PhpWebGallery</title> |
</head> |
<body> |
No access authorized |
</body> |
</html> |
/web/test/gallery/phpwebgallery/admin/images/phpBarGraph.php |
---|
0,0 → 1,391 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: phpBarGraph.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.3 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
// Original PhpBarGraph Version 2.3 |
// Written By TJ Hunter (tjhunter@ruistech.com) |
// http://www.ruistech.com/phpBarGraph |
// This class has been adapted to fill phpWG requirements |
class PhpBarGraph |
{ |
/* -------------------------------- */ |
/* Preference Variables */ |
/* -------------------------------- */ |
var $_debug; |
var $_image; // The image to print the bargraph too. |
var $_x; // The starting column of the bargraph |
var $_y; // The starting row of the bargraph |
var $_width; // The width of the bargraph |
var $_height; // The height of the bargraph |
var $_startBarColorHex; // The top color of the bargraph |
var $_endBarColorHex; // The bottom color of the bargraph |
var $_lineColorHex; // The color of the lines and text |
var $_barSpacing; // The spacing width in between each bar |
var $_numOfValueTicks; // The number of horizontal rule ticks |
var $_values; // An array of arrays of the values of each bargraph and it's label |
var $_showLabels; // If true, print the labels to the image |
var $_showValues; // If true, print the values to the image |
var $_showBarBorder; // If true, draws a box of around each bar |
var $_showFade; // If true, draws each bar with a gradient |
var $_showOuterBox; // If true, draws the box on the outside of the bargraph |
/* -------------------------------- */ |
/* Private Variables */ |
/* -------------------------------- */ |
var $_topMargin; |
var $_bottomMargin; |
var $_leftMargin; |
var $_rightMargin; |
var $_barWidth; |
var $_minBarHeight; |
var $_maxBarHeight; |
var $_realMinBarHeight; |
var $_realMaxBarHeight; |
var $_buffer; |
function PhpBarGraph() |
{ |
$this->_debug = false; |
$this->_values = array(); |
$this->_startBarColorHex = "0000ff"; |
$this->_endBarColorHex = "ffffff"; |
$this->_lineColorHex = "000000"; |
$this->_barSpacing = 10; |
$this->_numOfValueTicks = 4; |
$this->_buffer = .5; |
$this->_showLabels = true; |
$this->_showValues = true; |
$this->_showBarBorder = true; |
$this->_showFade = true; |
$this->_showOuterBox = true; |
} |
function AddValue($labelName, $theValue) |
{ |
array_push($this->_values, array("label" => $labelName, "value" => $theValue)); |
} |
function SetDebug($debug) |
{ |
$this->_debug = $debug; |
} |
function SetX($x) |
{ |
$this->_x = $x; |
} |
function SetY($y) |
{ |
$this->_y = $y; |
} |
function SetWidth($width) |
{ |
$this->_width = $width; |
} |
function SetHeight($height) |
{ |
$this->_height = $height; |
} |
function SetStartBarColor($color) |
{ |
$this->_startBarColorHex = $color; |
} |
function SetEndBarColor($color) |
{ |
$this->_endBarColorHex = $color; |
} |
function SetLineColor($color) |
{ |
$this->_lineColorHex = $color; |
} |
function SetBarSpacing($barSpacing) |
{ |
$this->_barSpacing = $barSpacing; |
} |
function SetNumOfValueTicks($ticks) |
{ |
$this->_numOfValueTicks = $ticks; |
} |
function SetShowLabels($labels) |
{ |
$this->_showLabels = $labels; |
} |
function SetShowValues($values) |
{ |
$this->_showValues = $values; |
} |
function SetBarBorder($border) |
{ |
$this->_showBarBorder = $border; |
} |
function SetShowFade($fade) |
{ |
$this->_showFade = $fade; |
} |
function SetShowOuterBox($box) |
{ |
$this->_showOuterBox = $box; |
} |
function RGBColor($hexColor) // Returns an array of decimal values from a hex color |
{ |
$r = hexdec(substr($hexColor, 0, 2)); |
$g = hexdec(substr($hexColor, 2, 2)); |
$b = hexdec(substr($hexColor, 4, 2)); |
$RGBColors = array("red" => $r, "green" => $g, "blue" => $b); |
return $RGBColors; |
} |
function DebugPrint() // Prints a bunch of debug information. |
{ |
foreach($this->_values as $value) |
{ |
echo $value["label"] . "=" . $value["value"] . "<br>\n"; |
} |
$startColor = $this->RGBColor($this->_startBarColorHex); |
echo "StartColor: " . $startColor["red"] . ", " . $startColor["green"] . ", " . $startColor["blue"] . "<br>\n"; |
$endColor = $this->RGBColor($this->_endBarColorHex); |
echo "EndColor: " . $endColor["red"] . ", " . $endColor["green"] . ", " . $endColor["blue"] . "<br>\n"; |
$lineColor = $this->RGBColor($this->_lineColorHex); |
echo "LineColor: " . $lineColor["red"] . ", " . $lineColor["green"] . ", " . $lineColor["blue"] . "<br>\n"; |
echo "x=" . $this->_x . "<br>\n"; |
echo "y=" . $this->_y . "<br>\n"; |
echo "width=" . $this->_width . "<br>\n"; |
echo "height=" . $this->_height . "<br>\n"; |
echo "startBarColorHex=" . $this->_startBarColorHex . "<br>\n"; |
echo "endBarColorHex=" . $this->_endBarColorHex . "<br>\n"; |
echo "lineColorHex=" . $this->_lineColorHex . "<br>\n"; |
echo "barSpacing=" . $this->_barSpacing . "<br>\n"; |
echo "numOfValueTicks=" . $this->_numOfValueTicks . "<br>\n"; |
} |
function dif ($start,$end) |
{ |
if ($start >= $end) |
$dif = $start - $end; |
else |
$dif = $end - $start; |
return $dif; |
} |
function draw($start,$end,$pos,$step_width) |
{ |
if ($start > $end) |
$color = $start - $step_width * $pos; |
else |
$color = $start + $step_width * $pos; |
return $color; |
} |
function fadeBar($image, $x1, $y1, $x2, $y2, $colorsStart, $colorsEnd, $height, $width) // Draws a rectangle with a gradient |
{ |
$startColor = $this->RGBColor($colorsStart); |
$red_start = $startColor["red"]; |
$green_start = $startColor["green"]; |
$blue_start = $startColor["blue"]; |
$endColor = $this->RGBColor($colorsEnd); |
$red_end = $endColor["red"]; |
$green_end = $endColor["green"]; |
$blue_end = $endColor["blue"]; |
// difference between start and end |
$dif_red = $this->dif($red_start,$red_end); |
$dif_green = $this->dif($green_start,$green_end); |
$dif_blue = $this->dif($blue_start,$blue_end); |
$height = $height + 1; |
// width of one color step |
$step_red = $dif_red / $height; |
$step_green = $dif_green / $height; |
$step_blue = $dif_blue / $height; |
$width = $width - 1; |
for ($pos=0; $pos<=$height; $pos++) |
{ |
$color = imagecolorexact ($image, $this->draw($red_start,$red_end,$pos,$step_red), |
$this->draw($green_start,$green_end,$pos,$step_green), |
$this->draw($blue_start,$blue_end,$pos,$step_blue)); |
if ($color == -1) // If this color is already allocatated, don't allocate it again. |
{ |
$color = ImageColorAllocate($image,$this->draw($red_start,$red_end,$pos,$step_red), |
$this->draw($green_start,$green_end,$pos,$step_green), |
$this->draw($blue_start,$blue_end,$pos,$step_blue)); |
} |
imageline($image,$x1,$pos+$y1,$x1+$width,$pos+$y1,$color); |
} |
} |
function DrawBarGraph($image) |
{ |
if ($this->_debug) |
$this->DebugPrint(); |
// Setup the margins |
$this->_topMargin = 0; |
$this->_bottomMargin = 30; |
$this->_leftMargin = 20; |
$this->_rightMargin = $this->_barSpacing + 1 + 10; |
// setup the color for the lines |
$tempLineColor = $this->RGBColor($this->_lineColorHex); |
$lineColor = ImageColorAllocate($image, $tempLineColor["red"], $tempLineColor["green"], $tempLineColor["blue"]); |
$tempStartColor = $this->RGBColor($this->_startBarColorHex); |
$startColor = ImageColorAllocate($image, $tempStartColor["red"], $tempStartColor["green"], $tempStartColor["blue"]); |
// Figure out how wide each bar is going to be. |
$this->_barWidth = ($this->_width - ($this->_leftMargin + $this->_rightMargin + 1) - (count($this->_values) * $this->_barSpacing)) / count($this->_values); |
// Find out what the smallest and largest amount is. |
$this->_minBarHeight = $this->_values[0]["value"]; |
$this->_maxBarHeight = $this->_values[0]["value"]; |
for ($i=1; $i < count($this->_values); $i++) |
{ |
if ($this->_minBarHeight > $this->_values[$i]["value"]) |
{ |
$this->_minBarHeight = $this->_values[$i]["value"]; |
} |
if ($this->_maxBarHeight < $this->_values[$i]["value"]) |
{ |
$this->_maxBarHeight = $this->_values[$i]["value"]; |
} |
} |
if ($this->_minBarHeight == 0 && $this->_maxBarHeight > 0) // Having the min value as 0 looks funny |
{ |
$this->_minBarHeight = 1; |
} |
$buff = 1; |
// Figure out how tall the tallest and smallest bar are going to be. |
$this->_realMinBarHeight = $this->_minBarHeight - ($this->_minBarHeight * $buff + 1); |
$this->_realMaxBarHeight = $this->_maxBarHeight * ($this->_buffer + 1); |
$workArea = $this->_height - $this->_bottomMargin - $this->_topMargin - 1; |
// Print out all the ticks |
if ($this->_numOfValueTicks > $this->_maxBarHeight) |
{ |
$this->_numOfValueTicks = $this->_maxBarHeight; |
} |
for ($i=1; $i<=$this->_numOfValueTicks; $i++) |
{ |
$thisBarValue = floor((($this->_maxBarHeight - $this->_minBarHeight) / $this->_numOfValueTicks) * $i) + $this->_minBarHeight; |
$myTickheight = ($workArea / ($this->_maxBarHeight - $this->_realMinBarHeight) * ($thisBarValue - $this->_realMinBarHeight)); |
// Figure out where we're going to put this tick.. |
$y1 = $this->_height - $this->_bottomMargin - 1 - ($myTickheight); |
if ($thisBarValue >= $this->_minBarHeight) |
{ |
imageline($image, $this->_leftMargin - 5 + $this->_x, $y1 + $this->_y, $this->_width - $this->_rightMargin + $this->_barSpacing + $this->_x, $y1 + $this->_y, $lineColor); |
Imagestring($image, 1, $this->_leftMargin + $this->_x - 15, $y1 + $this->_y + 2, $thisBarValue, $lineColor); |
} |
} |
// Print out all the bars |
for ($i=1; $i<=count($this->_values); $i++) |
{ |
// Get the bar height for this bar. |
$myBarheight = ($workArea / ($this->_maxBarHeight - $this->_realMinBarHeight) * ($this->_values[$i-1]["value"] - $this->_realMinBarHeight)); |
// Figure out where we're going to put this bar.. |
$x1 = $this->_leftMargin + 1 + (($i-1) * $this->_barWidth) + ($i * $this->_barSpacing); |
$y1 = $this->_height - $this->_bottomMargin - 1 - ($myBarheight); |
$x2 = $this->_leftMargin + (($i-1) * $this->_barWidth) + ($i * $this->_barSpacing) + $this->_barWidth; |
$y2 = $this->_height - $this->_bottomMargin - 1; |
if ($this->_values[$i-1]["value"] != 0) // Don't print a bar if the value is 0 |
{ |
// Print the bar |
if ($this->_showFade) |
{ |
$this->fadeBar($image, $x1 + $this->_x, $y1 + $this->_y, $x2 + $this->_x, $y2 + $this->_y, $this->_startBarColorHex, $this->_endBarColorHex, $myBarheight, $this->_barWidth); |
} |
else |
{ |
ImageFilledRectangle($image, $x1 + $this->_x, $y1 + $this->_y, $x2 + $this->_x, $y2 + $this->_y, $startColor); |
} |
if ($this->_showBarBorder) |
{ |
ImageRectangle($image, $x1 + $this->_x, $y1 + $this->_y, $x2 + $this->_x, $y2 + $this->_y + 1, $lineColor); |
} |
} |
// Print the amount of the bar |
if ($this->_showValues) |
{ |
Imagestring($image, 2, $x1 + $this->_x, $this->_height-($this->_bottomMargin/2)-10 + $this->_y, $this->_values[$i-1]["value"], $lineColor); |
} |
// Print out the label of the bar. |
if ($this->_showLabels) |
{ |
Imagestring($image, 2, $x1 + $this->_x, $this->_height-($this->_bottomMargin/2) + $this->_y, $this->_values[$i-1]["label"], $lineColor); |
} |
} |
// draw the border box |
if ($this->_showOuterBox) |
{ |
ImageRectangle($image, $this->_leftMargin + $this->_x, $this->_topMargin + $this->_y, $this->_width - $this->_rightMargin + $this->_barSpacing + $this->_x, $this->_height - $this->_bottomMargin + $this->_y, $lineColor); |
} |
} |
} |
?> |
/web/test/gallery/phpwebgallery/admin/include/_vti_cnf/functions.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|08 Jan 2005 10:23:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|08 Jan 2005 10:23:52 -0000 |
vti_cacheddtm:TX|08 Jan 2005 10:23:52 -0000 |
vti_filesize:IR|33871 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/include/_vti_cnf/functions_metadata.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|13 Feb 2005 11:49:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|13 Feb 2005 11:49:52 -0000 |
vti_cacheddtm:TX|13 Feb 2005 11:49:52 -0000 |
vti_filesize:IR|5705 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/include/_vti_cnf/index.htm |
---|
0,0 → 1,17 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|09 May 2003 12:42:44 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|09 May 2003 12:42:44 -0000 |
vti_cacheddtm:TX|09 May 2003 12:42:44 -0000 |
vti_filesize:IR|133 |
vti_cachedtitle:SR|PhpWebGallery |
vti_cachedbodystyle:SR|<body> |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_title:SR|PhpWebGallery |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/include/_vti_cnf/isadmin.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 22:10:52 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 22:10:52 -0000 |
vti_cacheddtm:TX|07 Jan 2005 22:10:52 -0000 |
vti_filesize:IR|2043 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/admin/include/functions.php |
---|
0,0 → 1,1329 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: functions.php,v $ |
// | last update : $Date: 2005/01/08 11:23:52 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.48 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
include(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php'); |
$tab_ext_create_TN = array ( 'jpg', 'png', 'JPG', 'PNG' ); |
// is_image returns true if the given $filename (including the path) is a |
// picture according to its format and its extension. |
// As GD library can only generate pictures from jpeg and png files, if you |
// ask if the filename is an image for thumbnail creation (second parameter |
// set to true), the only authorized formats are jpeg and png. |
function is_image( $filename, $create_thumbnail = false ) |
{ |
global $conf, $tab_ext_create_TN; |
if (is_file($filename) |
and in_array(get_extension($filename), $conf['picture_ext'])) |
{ |
$size = getimagesize( $filename ); |
// $size[2] == 1 means GIF |
// $size[2] == 2 means JPG |
// $size[2] == 3 means PNG |
if ( !$create_thumbnail ) |
{ |
if ( in_array( get_extension( $filename ), $conf['picture_ext'] ) |
and ( $size[2] == 1 or $size[2] == 2 or $size[2] == 3 ) ) |
{ |
return true; |
} |
} |
else |
{ |
if ( in_array( get_extension( $filename ), $tab_ext_create_TN ) |
and ( $size[2] == 2 or $size[2] == 3 ) ) |
{ |
return true; |
} |
} |
} |
return false; |
} |
/** |
* returns an array with all picture files according to $conf['file_ext'] |
* |
* @param string $dir |
* @return array |
*/ |
function get_pwg_files($dir) |
{ |
global $conf; |
$pictures = array(); |
if ($opendir = opendir($dir)) |
{ |
while ($file = readdir($opendir)) |
{ |
if (in_array(get_extension($file), $conf['file_ext'])) |
{ |
array_push($pictures, $file); |
} |
} |
} |
return $pictures; |
} |
/** |
* returns an array with all thumbnails according to $conf['picture_ext'] |
* and $conf['prefix_thumbnail'] |
* |
* @param string $dir |
* @return array |
*/ |
function get_thumb_files($dir) |
{ |
global $conf; |
$prefix_length = strlen($conf['prefix_thumbnail']); |
$thumbnails = array(); |
if ($opendir = @opendir($dir.'/thumbnail')) |
{ |
while ($file = readdir($opendir)) |
{ |
if (in_array(get_extension($file), $conf['picture_ext']) |
and substr($file, 0, $prefix_length) == $conf['prefix_thumbnail']) |
{ |
array_push($thumbnails, $file); |
} |
} |
} |
return $thumbnails; |
} |
/** |
* returns an array with representative picture files of a directory |
* according to $conf['picture_ext'] |
* |
* @param string $dir |
* @return array |
*/ |
function get_representative_files($dir) |
{ |
global $conf; |
$pictures = array(); |
if ($opendir = @opendir($dir.'/pwg_representative')) |
{ |
while ($file = readdir($opendir)) |
{ |
if (in_array(get_extension($file), $conf['picture_ext'])) |
{ |
array_push($pictures, $file); |
} |
} |
} |
return $pictures; |
} |
function TN_exists( $dir, $file ) |
{ |
global $conf; |
$filename = get_filename_wo_extension( $file ); |
foreach ( $conf['picture_ext'] as $ext ) { |
$test = $dir.'/thumbnail/'.$conf['prefix_thumbnail'].$filename.'.'.$ext; |
if ( is_file ( $test ) ) |
{ |
return $ext; |
} |
} |
return false; |
} |
// The function delete_site deletes a site and call the function |
// delete_categories for each primary category of the site |
function delete_site( $id ) |
{ |
// destruction of the categories of the site |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE.' |
WHERE site_id = '.$id.' |
;'; |
$result = pwg_query($query); |
$category_ids = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($category_ids, $row['id']); |
} |
delete_categories($category_ids); |
// destruction of the site |
$query = ' |
DELETE FROM '.SITES_TABLE.' |
WHERE id = '.$id.' |
;'; |
pwg_query($query); |
} |
// The function delete_categories deletes the categories identified by the |
// (numeric) key of the array $ids. It also deletes (in the database) : |
// - all the elements of the category (delete_elements, see further) |
// - all the links between elements and this category |
// - all the restrictions linked to the category |
// The function works recursively. |
function delete_categories($ids) |
{ |
global $counts; |
if (count($ids) == 0) |
{ |
return; |
} |
// add sub-category ids to the given ids : if a category is deleted, all |
// sub-categories must be so |
$ids = get_subcat_ids($ids); |
// destruction of all the related elements |
$query = ' |
SELECT id |
FROM '.IMAGES_TABLE.' |
WHERE storage_category_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
$result = pwg_query($query); |
$element_ids = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($element_ids, $row['id']); |
} |
delete_elements($element_ids); |
// destruction of the links between images and this category |
$query = ' |
DELETE FROM '.IMAGE_CATEGORY_TABLE.' |
WHERE category_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
// destruction of the access linked to the category |
$query = ' |
DELETE FROM '.USER_ACCESS_TABLE.' |
WHERE cat_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
$query = ' |
DELETE FROM '.GROUP_ACCESS_TABLE.' |
WHERE cat_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
// destruction of the category |
$query = ' |
DELETE FROM '.CATEGORIES_TABLE.' |
WHERE id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
if (isset($counts['del_categories'])) |
{ |
$counts['del_categories']+= count($ids); |
} |
} |
// The function delete_elements deletes the elements identified by the |
// (numeric) values of the array $ids. It also deletes (in the database) : |
// - all the comments related to elements |
// - all the links between categories and elements |
// - all the favorites associated to elements |
function delete_elements($ids) |
{ |
global $counts; |
if (count($ids) == 0) |
{ |
return; |
} |
// destruction of the comments on the image |
$query = ' |
DELETE FROM '.COMMENTS_TABLE.' |
WHERE image_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
// destruction of the links between images and this category |
$query = ' |
DELETE FROM '.IMAGE_CATEGORY_TABLE.' |
WHERE image_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
// destruction of the favorites associated with the picture |
$query = ' |
DELETE FROM '.FAVORITES_TABLE.' |
WHERE image_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
// destruction of the rates associated to this element |
$query = ' |
DELETE FROM '.RATE_TABLE.' |
WHERE element_id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
// destruction of the image |
$query = ' |
DELETE FROM '.IMAGES_TABLE.' |
WHERE id IN ( |
'.wordwrap(implode(', ', $ids), 80, "\n").') |
;'; |
pwg_query($query); |
if (isset($counts['del_elements'])) |
{ |
$counts['del_elements']+= count($ids); |
} |
} |
// The delete_user function delete a user identified by the $user_id |
// It also deletes : |
// - all the access linked to this user |
// - all the links to any group |
// - all the favorites linked to this user |
// - all sessions linked to this user |
// - calculated permissions linked to the user |
function delete_user($user_id) |
{ |
// destruction of the access linked to the user |
$query = ' |
DELETE FROM '.USER_ACCESS_TABLE.' |
WHERE user_id = '.$user_id.' |
;'; |
pwg_query($query); |
// destruction of the group links for this user |
$query = ' |
DELETE FROM '.USER_GROUP_TABLE.' |
WHERE user_id = '.$user_id.' |
;'; |
pwg_query($query); |
// destruction of the favorites associated with the user |
$query = ' |
DELETE FROM '.FAVORITES_TABLE.' |
WHERE user_id = '.$user_id.' |
;'; |
pwg_query($query); |
// destruction of the sessions linked with the user |
$query = ' |
DELETE FROM '.SESSIONS_TABLE.' |
WHERE user_id = '.$user_id.' |
;'; |
pwg_query($query); |
// deletion of calculated permissions linked to the user |
$query = ' |
DELETE FROM '.USER_FORBIDDEN_TABLE.' |
WHERE user_id = '.$user_id.' |
;'; |
pwg_query($query); |
// destruction of the user |
$query = ' |
DELETE FROM '.USERS_TABLE.' |
WHERE id = '.$user_id.' |
;'; |
pwg_query($query); |
} |
/** |
* updates calculated informations about a set of categories : date_last and |
* nb_images. It also verifies that the representative picture is really |
* linked to the category. Optionnaly recursive. |
* |
* @param mixed category id |
* @param boolean recursive |
* @returns void |
*/ |
function update_category($ids = 'all', $recursive = false) |
{ |
// retrieving all categories to update |
$cat_ids = array(); |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE; |
if (is_array($ids)) |
{ |
if ($recursive) |
{ |
foreach ($ids as $num => $id) |
{ |
if ($num == 0) |
{ |
$query.= ' |
WHERE '; |
} |
else |
{ |
$query.= ' |
OR '; |
} |
$query.= 'uppercats REGEXP \'(^|,)'.$id.'(,|$)\''; |
} |
} |
else |
{ |
$query.= ' |
WHERE id IN ('.wordwrap(implode(', ', $ids), 80, "\n").')'; |
} |
} |
$query.= ' |
;'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
array_push($cat_ids, $row['id']); |
} |
$cat_ids = array_unique($cat_ids); |
if (count($cat_ids) == 0) |
{ |
return false; |
} |
// calculate informations about categories retrieved |
$query = ' |
SELECT category_id, |
COUNT(image_id) AS nb_images, |
MAX(date_available) AS date_last |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
WHERE category_id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') |
GROUP BY category_id |
;'; |
$result = pwg_query($query); |
$datas = array(); |
$query_ids = array(); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
array_push($query_ids, $row['category_id']); |
array_push($datas, array('id' => $row['category_id'], |
'date_last' => $row['date_last'], |
'nb_images' => $row['nb_images'])); |
} |
// if all links between a category and elements have disappeared, no line |
// is returned but the update must be done ! |
foreach (array_diff($cat_ids, $query_ids) as $id) |
{ |
array_push($datas, array('id' => $id, 'nb_images' => 0)); |
} |
$fields = array('primary' => array('id'), |
'update' => array('date_last', 'nb_images')); |
mass_updates(CATEGORIES_TABLE, $fields, $datas); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET representative_picture_id = NULL |
WHERE nb_images = 0 |
;'; |
pwg_query($query); |
if (count($cat_ids) > 0) |
{ |
$categories = array(); |
// find all categories where the setted representative is not possible |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE.' LEFT JOIN '.IMAGE_CATEGORY_TABLE.' |
ON id = category_id AND representative_picture_id = image_id |
WHERE representative_picture_id IS NOT NULL |
AND id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') |
AND category_id IS NULL |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($categories, $row['id']); |
} |
// find categories with elements and with no representant |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE.' |
WHERE representative_picture_id IS NULL |
AND nb_images != 0 |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($categories, $row['id']); |
} |
$categories = array_unique($categories); |
set_random_representant($categories); |
} |
} |
function check_date_format( $date ) |
{ |
// date arrives at this format : DD/MM/YYYY |
@list($day,$month,$year) = explode( '/', $date ); |
return @checkdate( $month, $day, $year ); |
} |
function date_convert( $date ) |
{ |
// date arrives at this format : DD/MM/YYYY |
// It must be transformed in YYYY-MM-DD |
list($day,$month,$year) = explode( '/', $date ); |
return $year.'-'.$month.'-'.$day; |
} |
function date_convert_back( $date ) |
{ |
// date arrives at this format : YYYY-MM-DD |
// It must be transformed in DD/MM/YYYY |
if ( $date != '' ) |
{ |
list($year,$month,$day) = explode( '-', $date ); |
return $day.'/'.$month.'/'.$year; |
} |
else |
{ |
return ''; |
} |
} |
// get_keywords returns an array with relevant keywords found in the string |
// given in argument. Keywords must be separated by comma in this string. |
// keywords must : |
// - be longer or equal to 3 characters |
// - not contain ', " or blank characters |
// - unique in the string ("test,test" -> "test") |
function get_keywords( $keywords_string ) |
{ |
$keywords = array(); |
$candidates = explode( ',', $keywords_string ); |
foreach ( $candidates as $candidate ) { |
if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) ) |
array_push( $keywords, $candidate ); |
} |
return array_unique( $keywords ); |
} |
/** |
* returns an array with the ids of the restricted categories for the user |
* |
* Returns an array with the ids of the restricted categories for the |
* user. If the $check_invisible parameter is set to true, invisible |
* categorie are added to the restricted one in the array. |
* |
* @param int $user_id |
* @param string $user_status |
* @param bool $check_invisible |
* @param bool $use_groups |
* @return array |
*/ |
function get_user_restrictions( $user_id, $user_status, |
$check_invisible, $use_groups = true ) |
{ |
// 1. retrieving ids of private categories |
$query = 'SELECT id FROM '.CATEGORIES_TABLE; |
$query.= " WHERE status = 'private'"; |
$query.= ';'; |
$result = pwg_query( $query ); |
$privates = array(); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
array_push( $privates, $row['id'] ); |
} |
// 2. retrieving all authorized categories for the user |
$authorized = array(); |
// 2.1. retrieving authorized categories thanks to personnal user |
// authorization |
$query = 'SELECT cat_id FROM '.USER_ACCESS_TABLE; |
$query.= ' WHERE user_id = '.$user_id; |
$query.= ';'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
array_push( $authorized, $row['cat_id'] ); |
} |
// 2.2. retrieving authorized categories thanks to group authorization to |
// which the user is a member |
if ( $use_groups ) |
{ |
$query = 'SELECT ga.cat_id'; |
$query.= ' FROM '.USER_GROUP_TABLE.' as ug'; |
$query.= ', '.GROUP_ACCESS_TABLE.' as ga'; |
$query.= ' WHERE ug.group_id = ga.group_id'; |
$query.= ' AND ug.user_id = '.$user_id; |
$query.= ';'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
array_push( $authorized, $row['cat_id'] ); |
} |
$authorized = array_unique( $authorized ); |
} |
$forbidden = array(); |
foreach ( $privates as $private ) { |
if ( !in_array( $private, $authorized ) ) |
{ |
array_push( $forbidden, $private ); |
} |
} |
if ( $check_invisible ) |
{ |
// 3. adding to the restricted categories, the invisible ones |
if ( $user_status != 'admin' ) |
{ |
$query = 'SELECT id FROM '.CATEGORIES_TABLE; |
$query.= " WHERE visible = 'false';"; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
array_push( $forbidden, $row['id'] ); |
} |
} |
} |
return array_unique( $forbidden ); |
} |
/** |
* updates the calculated data users.forbidden_categories, it includes |
* sub-categories of the direct forbidden categories |
* |
* @param nt $user_id |
* @return array |
*/ |
function update_user_restrictions( $user_id ) |
{ |
$restrictions = get_user_all_restrictions( $user_id ); |
// update the users.forbidden_categories in database |
$query = 'UPDATE '.USERS_TABLE; |
$query.= ' SET forbidden_categories = '; |
if ( count( $restrictions ) > 0 ) |
$query.= "'".implode( ',', $restrictions )."'"; |
else |
$query.= 'NULL'; |
$query .= ' WHERE id = '.$user_id; |
$query.= ';'; |
pwg_query( $query ); |
return $restrictions; |
} |
/** |
* returns all the restricted categories ids including sub-categories |
* |
* @param int $user_id |
* @return array |
*/ |
function get_user_all_restrictions( $user_id ) |
{ |
global $page; |
$query = 'SELECT status'; |
$query.= ' FROM '.USERS_TABLE; |
$query.= ' WHERE id = '.$user_id; |
$query.= ';'; |
$row = mysql_fetch_array( pwg_query( $query ) ); |
$base_restrictions=get_user_restrictions($user_id,$row['status'],true,true); |
$restrictions = $base_restrictions; |
foreach ( $base_restrictions as $category_id ) { |
echo $category_id.' is forbidden to user '.$user_id.'<br />'; |
$restrictions = |
array_merge( $restrictions, |
$page['plain_structure'][$category_id]['all_subcats_ids'] ); |
} |
return array_unique( $restrictions ); |
} |
// The function is_user_allowed returns : |
// - 0 : if the category is allowed with this $restrictions array |
// - 1 : if this category is not allowed |
// - 2 : if an uppercat category is not allowed |
// Note : the restrictions array must represent ONLY direct forbidden |
// categories, not all forbidden categories |
function is_user_allowed( $category_id, $restrictions ) |
{ |
if ( in_array( $category_id, $restrictions ) ) return 1; |
$query = 'SELECT uppercats'; |
$query.= ' FROM '.CATEGORIES_TABLE; |
$query.= ' WHERE id = '.$category_id; |
$query.= ';'; |
$row = mysql_fetch_array( pwg_query( $query ) ); |
$uppercats = explode( ',', $row['uppercats'] ); |
foreach ( $uppercats as $category_id ) { |
if ( in_array( $category_id, $restrictions ) ) return 2; |
} |
// no restriction found : the user is allowed to access this category |
return 0; |
} |
/** |
* returns an array containing sub-directories which can be a category |
* |
* directories nammed "thumbnail", "pwg_high" or "pwg_representative" are |
* omitted |
* |
* @param string $basedir |
* @return array |
*/ |
function get_category_directories( $basedir ) |
{ |
$sub_dirs = array(); |
if ( $opendir = opendir( $basedir ) ) |
{ |
while ( $file = readdir( $opendir ) ) |
{ |
if ($file != '.' |
and $file != '..' |
and $file != 'thumbnail' |
and $file != 'pwg_high' |
and $file != 'pwg_representative' |
and is_dir($basedir.'/'.$file)) |
{ |
array_push( $sub_dirs, $file ); |
} |
} |
} |
return $sub_dirs; |
} |
/** |
* returns an array containing sub-directories which can be a category, |
* recursive by default |
* |
* directories nammed "thumbnail", "pwg_high" or "pwg_representative" are |
* omitted |
* |
* @param string $basedir |
* @return array |
*/ |
function get_fs_directories($path, $recursive = true) |
{ |
$dirs = array(); |
if (is_dir($path)) |
{ |
if ($contents = opendir($path)) |
{ |
while (($node = readdir($contents)) !== false) |
{ |
if (is_dir($path.'/'.$node) |
and $node != '.' |
and $node != '..' |
and $node != 'thumbnail' |
and $node != 'pwg_high' |
and $node != 'pwg_representative') |
{ |
array_push($dirs, $path.'/'.$node); |
if ($recursive) |
{ |
$dirs = array_merge($dirs, get_fs_directories($path.'/'.$node)); |
} |
} |
} |
} |
} |
return $dirs; |
} |
/** |
* inserts multiple lines in a table |
* |
* @param string table_name |
* @param array dbfields |
* @param array inserts |
* @return void |
*/ |
function mass_inserts($table_name, $dbfields, $datas) |
{ |
// inserts all found categories |
$query = ' |
INSERT INTO '.$table_name.' |
('.implode(',', $dbfields).') |
VALUES'; |
foreach ($datas as $insert_id => $insert) |
{ |
$query.= ' |
'; |
if ($insert_id > 0) |
{ |
$query.= ','; |
} |
$query.= '('; |
foreach ($dbfields as $field_id => $dbfield) |
{ |
if ($field_id > 0) |
{ |
$query.= ','; |
} |
if (!isset($insert[$dbfield]) or $insert[$dbfield] == '') |
{ |
$query.= 'NULL'; |
} |
else |
{ |
$query.= "'".$insert[$dbfield]."'"; |
} |
} |
$query.=')'; |
} |
$query.= ' |
;'; |
pwg_query($query); |
} |
/** |
* updates multiple lines in a table |
* |
* @param string table_name |
* @param array dbfields |
* @param array datas |
* @return void |
*/ |
function mass_updates($tablename, $dbfields, $datas) |
{ |
// depending on the MySQL version, we use the multi table update or N |
// update queries |
$query = 'SELECT VERSION() AS version;'; |
$row = mysql_fetch_array(pwg_query($query)); |
if (count($datas) < 10 or version_compare($row['version'],'4.0.4') < 0) |
{ |
// MySQL is prior to version 4.0.4, multi table update feature is not |
// available |
foreach ($datas as $data) |
{ |
$query = ' |
UPDATE '.$tablename.' |
SET '; |
foreach ($dbfields['update'] as $num => $key) |
{ |
if ($num >= 1) |
{ |
$query.= ",\n "; |
} |
$query.= $key.' = '; |
if (isset($data[$key])) |
{ |
$query.= '\''.$data[$key].'\''; |
} |
else |
{ |
$query.= 'NULL'; |
} |
} |
$query.= ' |
WHERE '; |
foreach ($dbfields['primary'] as $num => $key) |
{ |
if ($num > 1) |
{ |
$query.= ' AND '; |
} |
$query.= $key.' = \''.$data[$key].'\''; |
} |
$query.= ' |
;'; |
pwg_query($query); |
} |
} |
else |
{ |
// creation of the temporary table |
$query = ' |
DESCRIBE '.$tablename.' |
;'; |
$result = pwg_query($query); |
$columns = array(); |
$all_fields = array_merge($dbfields['primary'], $dbfields['update']); |
while ($row = mysql_fetch_array($result)) |
{ |
if (in_array($row['Field'], $all_fields)) |
{ |
$column = $row['Field']; |
$column.= ' '.$row['Type']; |
if (!isset($row['Null']) or $row['Null'] == '') |
{ |
$column.= ' NOT NULL'; |
} |
if (isset($row['Default'])) |
{ |
$column.= " default '".$row['Default']."'"; |
} |
array_push($columns, $column); |
} |
} |
$temporary_tablename = $tablename.'_'.micro_seconds(); |
$query = ' |
CREATE TABLE '.$temporary_tablename.' |
( |
'.implode(",\n", $columns).', |
PRIMARY KEY (id) |
) |
;'; |
pwg_query($query); |
mass_inserts($temporary_tablename, $all_fields, $datas); |
// update of images table by joining with temporary table |
$query = ' |
UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2 |
SET '.implode("\n , ", |
array_map( |
create_function('$s', 'return "t1.$s = t2.$s";') |
, $dbfields['update'])).' |
WHERE '.implode("\n AND ", |
array_map( |
create_function('$s', 'return "t1.$s = t2.$s";') |
, $dbfields['primary'])).' |
;'; |
pwg_query($query); |
$query = ' |
DROP TABLE '.$temporary_tablename.' |
;'; |
pwg_query($query); |
} |
} |
/** |
* updates the global_rank of categories under the given id_uppercat |
* |
* @param int id_uppercat |
* @return void |
*/ |
function update_global_rank($id_uppercat = 'all') |
{ |
$query = ' |
SELECT id,rank |
FROM '.CATEGORIES_TABLE.' |
;'; |
$result = pwg_query($query); |
$ranks_array = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$ranks_array[$row['id']] = $row['rank']; |
} |
// which categories to update ? |
$uppercats_array = array(); |
$query = ' |
SELECT id,uppercats |
FROM '.CATEGORIES_TABLE; |
if (is_numeric($id_uppercat)) |
{ |
$query.= ' |
WHERE uppercats REGEXP \'(^|,)'.$id_uppercat.'(,|$)\' |
AND id != '.$id_uppercat.' |
'; |
} |
$query.= ' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$uppercats_array[$row['id']] = $row['uppercats']; |
} |
$datas = array(); |
foreach ($uppercats_array as $id => $uppercats) |
{ |
$data = array(); |
$data['id'] = $id; |
$global_rank = preg_replace('/(\d+)/e', |
"\$ranks_array['$1']", |
str_replace(',', '.', $uppercats)); |
$data['global_rank'] = $global_rank; |
array_push($datas, $data); |
} |
$fields = array('primary' => array('id'), 'update' => array('global_rank')); |
mass_updates(CATEGORIES_TABLE, $fields, $datas); |
} |
/** |
* change the visible property on a set of categories |
* |
* @param array categories |
* @param string value |
* @return void |
*/ |
function set_cat_visible($categories, $value) |
{ |
if (!in_array($value, array('true', 'false'))) |
{ |
return false; |
} |
// unlocking a category => all its parent categories become unlocked |
if ($value == 'true') |
{ |
$uppercats = get_uppercat_ids($categories); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET visible = \'true\' |
WHERE id IN ('.implode(',', $uppercats).') |
;'; |
pwg_query($query); |
} |
// locking a category => all its child categories become locked |
if ($value == 'false') |
{ |
$subcats = get_subcat_ids($categories); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET visible = \'false\' |
WHERE id IN ('.implode(',', $subcats).') |
;'; |
pwg_query($query); |
} |
} |
/** |
* change the status property on a set of categories : private or public |
* |
* @param array categories |
* @param string value |
* @return void |
*/ |
function set_cat_status($categories, $value) |
{ |
if (!in_array($value, array('public', 'private'))) |
{ |
return false; |
} |
// make public a category => all its parent categories become public |
if ($value == 'public') |
{ |
$uppercats = get_uppercat_ids($categories); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET status = \'public\' |
WHERE id IN ('.implode(',', $uppercats).') |
;'; |
pwg_query($query); |
} |
// make a category private => all its child categories become private |
if ($value == 'private') |
{ |
$subcats = get_subcat_ids($categories); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET status = \'private\' |
WHERE id IN ('.implode(',', $subcats).') |
;'; |
pwg_query($query); |
} |
} |
/** |
* returns all uppercats category ids of the given category ids |
* |
* @param array cat_ids |
* @return array |
*/ |
function get_uppercat_ids($cat_ids) |
{ |
if (!is_array($cat_ids) or count($cat_ids) < 1) |
{ |
return array(); |
} |
$uppercats = array(); |
$query = ' |
SELECT uppercats |
FROM '.CATEGORIES_TABLE.' |
WHERE id IN ('.implode(',', $cat_ids).') |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$uppercats = array_merge($uppercats, |
explode(',', $row['uppercats'])); |
} |
$uppercats = array_unique($uppercats); |
return $uppercats; |
} |
/** |
* set a new random representant to the categories |
* |
* @param array categories |
*/ |
function set_random_representant($categories) |
{ |
$datas = array(); |
foreach ($categories as $category_id) |
{ |
$query = ' |
SELECT image_id |
FROM '.IMAGE_CATEGORY_TABLE.' |
WHERE category_id = '.$category_id.' |
ORDER BY RAND() |
LIMIT 0,1 |
;'; |
list($representative) = mysql_fetch_array(pwg_query($query)); |
$data = array('id' => $category_id, |
'representative_picture_id' => $representative); |
array_push($datas, $data); |
} |
$fields = array('primary' => array('id'), |
'update' => array('representative_picture_id')); |
mass_updates(CATEGORIES_TABLE, $fields, $datas); |
} |
/** |
* order categories (update categories.rank and global_rank database fields) |
* |
* the purpose of this function is to give a rank for all categories |
* (insides its sub-category), even the newer that have none at te |
* beginning. For this, ordering function selects all categories ordered by |
* rank ASC then name ASC for each uppercat. |
* |
* @returns void |
*/ |
function ordering() |
{ |
$current_rank = 0; |
$current_uppercat = ''; |
$query = ' |
SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat |
FROM '.CATEGORIES_TABLE.' |
ORDER BY id_uppercat,rank,name |
;'; |
$result = pwg_query($query); |
$datas = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
if ($row['id_uppercat'] != $current_uppercat) |
{ |
$current_rank = 0; |
$current_uppercat = $row['id_uppercat']; |
} |
$data = array('id' => $row['id'], 'rank' => ++$current_rank); |
array_push($datas, $data); |
} |
$fields = array('primary' => array('id'), 'update' => array('rank')); |
mass_updates(CATEGORIES_TABLE, $fields, $datas); |
} |
/** |
* returns the fulldir for each given category id |
* |
* @param array cat_ids |
* @return array |
*/ |
function get_fulldirs($cat_ids) |
{ |
if (count($cat_ids) == 0) |
{ |
return array(); |
} |
// caching directories of existing categories |
$query = ' |
SELECT id, dir |
FROM '.CATEGORIES_TABLE.' |
WHERE dir IS NOT NULL |
;'; |
$result = pwg_query($query); |
$cat_dirs = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$cat_dirs[$row['id']] = $row['dir']; |
} |
// caching galleries_url |
$query = ' |
SELECT id, galleries_url |
FROM '.SITES_TABLE.' |
;'; |
$result = pwg_query($query); |
$galleries_url = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$galleries_url[$row['id']] = $row['galleries_url']; |
} |
// categories : id, site_id, uppercats |
$categories = array(); |
$query = ' |
SELECT id, uppercats, site_id |
FROM '.CATEGORIES_TABLE.' |
WHERE id IN ( |
'.wordwrap(implode(', ', $cat_ids), 80, "\n").') |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($categories, $row); |
} |
// filling $cat_fulldirs |
$cat_fulldirs = array(); |
foreach ($categories as $category) |
{ |
$uppercats = str_replace(',', '/', $category['uppercats']); |
$cat_fulldirs[$category['id']] = $galleries_url[$category['site_id']]; |
$cat_fulldirs[$category['id']].= preg_replace('/(\d+)/e', |
"\$cat_dirs['$1']", |
$uppercats); |
} |
return $cat_fulldirs; |
} |
/** |
* returns an array with all file system files according to |
* $conf['file_ext'] |
* |
* @param string $path |
* @param bool recursive |
* @return array |
*/ |
function get_fs($path, $recursive = true) |
{ |
global $conf; |
// because isset is faster than in_array... |
if (!isset($conf['flip_picture_ext'])) |
{ |
$conf['flip_picture_ext'] = array_flip($conf['picture_ext']); |
} |
if (!isset($conf['flip_file_ext'])) |
{ |
$conf['flip_file_ext'] = array_flip($conf['file_ext']); |
} |
$fs['elements'] = array(); |
$fs['thumbnails'] = array(); |
$fs['representatives'] = array(); |
$subdirs = array(); |
if (is_dir($path)) |
{ |
if ($contents = opendir($path)) |
{ |
while (($node = readdir($contents)) !== false) |
{ |
if (is_file($path.'/'.$node)) |
{ |
$extension = get_extension($node); |
// if (in_array($extension, $conf['picture_ext'])) |
if (isset($conf['flip_picture_ext'][$extension])) |
{ |
if (basename($path) == 'thumbnail') |
{ |
array_push($fs['thumbnails'], $path.'/'.$node); |
} |
else if (basename($path) == 'pwg_representative') |
{ |
array_push($fs['representatives'], $path.'/'.$node); |
} |
else |
{ |
array_push($fs['elements'], $path.'/'.$node); |
} |
} |
// else if (in_array($extension, $conf['file_ext'])) |
else if (isset($conf['flip_file_ext'][$extension])) |
{ |
array_push($fs['elements'], $path.'/'.$node); |
} |
} |
else if (is_dir($path.'/'.$node) |
and $node != '.' |
and $node != '..' |
and $node != 'pwg_high' |
and $recursive) |
{ |
array_push($subdirs, $node); |
} |
} |
} |
closedir($contents); |
foreach ($subdirs as $subdir) |
{ |
$tmp_fs = get_fs($path.'/'.$subdir); |
$fs['elements'] = array_merge($fs['elements'], |
$tmp_fs['elements']); |
$fs['thumbnails'] = array_merge($fs['thumbnails'], |
$tmp_fs['thumbnails']); |
$fs['representatives'] = array_merge($fs['representatives'], |
$tmp_fs['representatives']); |
} |
} |
return $fs; |
} |
/** |
* stupidly returns the current microsecond since Unix epoch |
*/ |
function micro_seconds() |
{ |
$t1 = explode(' ', microtime()); |
$t2 = explode('.', $t1[0]); |
$t2 = $t1[1].substr($t2[1], 0, 6); |
return $t2; |
} |
?> |
/web/test/gallery/phpwebgallery/admin/include/functions_metadata.php |
---|
0,0 → 1,207 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: functions_metadata.php,v $ |
// | last update : $Date: 2005/02/13 12:49:52 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.16 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php'); |
function get_sync_iptc_data($file) |
{ |
global $conf; |
$map = $conf['use_iptc_mapping']; |
$datefields = array('date_creation', 'date_available'); |
$iptc = get_iptc_data($file, $map); |
foreach ($iptc as $pwg_key => $value) |
{ |
if (in_array($pwg_key, $datefields)) |
{ |
if (preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) |
{ |
$iptc[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3]; |
} |
} |
} |
if (isset($iptc['keywords'])) |
{ |
// keywords separator is the comma, nothing else. Allowed characters in |
// keywords : [A-Za-z0-9], "-" and "_". All other characters will be |
// considered as separators |
$iptc['keywords'] = preg_replace('/[^\w-]+/', ',', $iptc['keywords']); |
$iptc['keywords'] = preg_replace('/^,+|,+$/', '', $iptc['keywords']); |
} |
return $iptc; |
} |
function update_metadata($files) |
{ |
global $conf; |
if (!defined('CURRENT_DATE')) |
{ |
define('CURRENT_DATE', date('Y-m-d')); |
} |
$datas = array(); |
foreach ($files as $id => $file) |
{ |
$data = array(); |
$data['id'] = $id; |
$data['filesize'] = floor(filesize($file)/1024); |
if ($image_size = @getimagesize($file)) |
{ |
$data['width'] = $image_size[0]; |
$data['height'] = $image_size[1]; |
} |
if ($conf['use_exif']) |
{ |
if (!function_exists('read_exif_data')) |
{ |
die('Exif extension not available, admin should disable exif use'); |
} |
if ($exif = @read_exif_data($file)) |
{ |
if (isset($exif['DateTime'])) |
{ |
preg_match('/^(\d{4}).(\d{2}).(\d{2})/',$exif['DateTime'],$matches); |
$data['date_creation'] = $matches[1].'-'.$matches[2].'-'.$matches[3]; |
} |
} |
} |
if ($conf['use_iptc']) |
{ |
$iptc = get_sync_iptc_data($file); |
if (count($iptc) > 0) |
{ |
foreach (array_keys($iptc) as $key) |
{ |
$data[$key] = addslashes($iptc[$key]); |
} |
} |
} |
$data['date_metadata_update'] = CURRENT_DATE; |
array_push($datas, $data); |
} |
if (count($datas) > 0) |
{ |
$update_fields = array('filesize','width','height','date_metadata_update'); |
if ($conf['use_exif']) |
{ |
array_push($update_fields, 'date_creation'); |
} |
if ($conf['use_iptc']) |
{ |
$update_fields = array_merge($update_fields, |
array_keys($conf['use_iptc_mapping'])); |
} |
$fields = array('primary' => array('id'), |
'update' => array_unique($update_fields)); |
mass_updates(IMAGES_TABLE, $fields, $datas); |
} |
} |
/** |
* returns an array associating element id (images.id) with its complete |
* path in the filesystem |
* |
* @param int id_uppercat |
* @param boolean recursive ? |
* @param boolean only newly added files ? |
* @return array |
*/ |
function get_filelist($category_id = '', $recursive = false, $only_new = false) |
{ |
// filling $cat_ids : all categories required |
$cat_ids = array(); |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE.' |
WHERE site_id = 1 |
AND dir IS NOT NULL'; |
if (is_numeric($category_id)) |
{ |
if ($recursive) |
{ |
$query.= ' |
AND uppercats REGEXP \'(^|,)'.$category_id.'(,|$)\' |
'; |
} |
else |
{ |
$query.= ' |
AND id = '.$category_id.' |
'; |
} |
} |
$query.= ' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($cat_ids, $row['id']); |
} |
if (count($cat_ids) == 0) |
{ |
return array(); |
} |
$files = array(); |
$query = ' |
SELECT id, path |
FROM '.IMAGES_TABLE.' |
WHERE storage_category_id IN ('.implode(',', $cat_ids).')'; |
if ($only_new) |
{ |
$query.= ' |
AND date_metadata_update IS NULL |
'; |
} |
$query.= ' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$files[$row['id']] = $row['path']; |
} |
return $files; |
} |
?> |
/web/test/gallery/phpwebgallery/admin/include/index.htm |
---|
0,0 → 1,8 |
<html> |
<head> |
<title>PhpWebGallery</title> |
</head> |
<body> |
No access authorized |
</body> |
</html> |
/web/test/gallery/phpwebgallery/admin/include/isadmin.inc.php |
---|
0,0 → 1,36 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: isadmin.inc.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.15 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
include( PHPWG_ROOT_PATH.'admin/include/functions.php' ); |
if ($user['status'] != 'admin') |
{ |
echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />'; |
echo '<a href="'.PHPWG_ROOT_PATH.'identification.php">'.$lang['identification'].'</a></div>'; |
exit(); |
} |
?> |
/web/test/gallery/phpwebgallery/admin/index.htm |
---|
0,0 → 1,8 |
<html> |
<head> |
<title>PhpWebGallery</title> |
</head> |
<body> |
No access authorized |
</body> |
</html> |
/web/test/gallery/phpwebgallery/admin/infos_images.php |
---|
0,0 → 1,351 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: infos_images.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.30 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if(!defined("PHPWG_ROOT_PATH")) |
{ |
die ("Hacking attempt!"); |
} |
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
// +-----------------------------------------------------------------------+ |
// | initialization | |
// +-----------------------------------------------------------------------+ |
check_cat_id($_GET['cat_id']); |
$errors = array(); |
if (isset($page['cat'])) |
{ |
// +-----------------------------------------------------------------------+ |
// | update individual options | |
// +-----------------------------------------------------------------------+ |
if (isset($_POST['submit'])) |
{ |
if (isset($_POST['associate']) and $_POST['associate'] != '') |
{ |
// does the uppercat id exists in the database ? |
if (!is_numeric($_POST['associate'])) |
{ |
array_push($errors, $lang['cat_unknown_id']); |
} |
else |
{ |
$query = 'SELECT id FROM '.CATEGORIES_TABLE; |
$query.= ' WHERE id = '.$_POST['associate']; |
$query.= ';'; |
if (mysql_num_rows(pwg_query($query)) == 0) |
array_push($errors, $lang['cat_unknown_id']); |
} |
} |
$query = 'SELECT id,file FROM '.IMAGES_TABLE; |
$query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; |
$query.= ' WHERE category_id = '.$page['cat']; |
$query.= ';'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$name = 'name-'.$row['id']; |
$author = 'author-'.$row['id']; |
$comment = 'comment-'.$row['id']; |
$date_creation = 'date_creation-'.$row['id']; |
$keywords = 'keywords-'.$row['id']; |
if (isset($_POST[$name])) |
{ |
$query = 'UPDATE '.IMAGES_TABLE.' SET name = '; |
if ($_POST[$name] == '') |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities($_POST[$name], ENT_QUOTES)."'"; |
$query.= ', author = '; |
if ($_POST[$author] == '') |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities($_POST[$author],ENT_QUOTES)."'"; |
$query.= ', comment = '; |
if ($_POST[$comment] == '') |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities($_POST[$comment],ENT_QUOTES)."'"; |
$query.= ', date_creation = '; |
if (check_date_format($_POST[$date_creation])) |
$query.= "'".date_convert($_POST[$date_creation])."'"; |
else if ($_POST[$date_creation] == '') |
$query.= 'NULL'; |
$query.= ', keywords = '; |
$keywords_array = get_keywords($_POST[$keywords]); |
if (count($keywords_array) == 0) $query.= 'NULL'; |
else $query.= "'".implode(',', $keywords_array)."'"; |
$query.= ' WHERE id = '.$row['id']; |
$query.= ';'; |
pwg_query($query); |
} |
// add link to another category |
if (isset($_POST['check-'.$row['id']]) |
and isset($_POST['associate']) |
and $_POST['associate'] != '') |
{ |
$query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE; |
$query.= ' (image_id,category_id) VALUES'; |
$query.= ' ('.$row['id'].','.$_POST['associate'].')'; |
$query.= ';'; |
pwg_query($query); |
} |
} |
if (isset($_POST['associate']) and $_POST['associate'] != '') |
{ |
update_category(array($_POST['associate'])); |
} |
// +-----------------------------------------------------------------------+ |
// | update general options | |
// +-----------------------------------------------------------------------+ |
if (isset($_POST['use_common_author'])) |
{ |
$query = 'SELECT image_id FROM '.IMAGE_CATEGORY_TABLE; |
$query.= ' WHERE category_id = '.$page['cat']; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$query = 'UPDATE '.IMAGES_TABLE; |
if ($_POST['author_cat'] == '') |
{ |
$query.= ' SET author = NULL'; |
} |
else |
{ |
$query.= ' SET author = '; |
$query.= "'".htmlentities($_POST['author_cat'], ENT_QUOTES)."'"; |
} |
$query.= ' WHERE id = '.$row['image_id']; |
$query.= ';'; |
pwg_query($query); |
} |
} |
if (isset($_POST['use_common_date_creation'])) |
{ |
if (check_date_format($_POST['date_creation_cat'])) |
{ |
$date = date_convert($_POST['date_creation_cat']); |
$query = 'SELECT image_id FROM '.IMAGE_CATEGORY_TABLE; |
$query.= ' WHERE category_id = '.$page['cat']; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$query = 'UPDATE '.IMAGES_TABLE; |
if ($_POST['date_creation_cat'] == '') |
{ |
$query.= ' SET date_creation = NULL'; |
} |
else |
{ |
$query.= " SET date_creation = '".$date."'"; |
} |
$query.= ' WHERE id = '.$row['image_id']; |
$query.= ';'; |
pwg_query($query); |
} |
} |
else |
{ |
array_push($errors, $lang['err_date']); |
} |
} |
if (isset($_POST['common_keywords']) and $_POST['keywords_cat'] != '') |
{ |
$query = 'SELECT id,keywords FROM '.IMAGES_TABLE; |
$query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; |
$query.= ' WHERE category_id = '.$page['cat']; |
$query.= ';'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
if (!isset($row['keywords'])) $specific_keywords = array(); |
else $specific_keywords = explode(',', $row['keywords']); |
$common_keywords = get_keywords($_POST['keywords_cat']); |
// first possiblity : adding the given keywords to all the pictures |
if ($_POST['common_keywords'] == 'add') |
{ |
$keywords = array_merge($specific_keywords, $common_keywords); |
$keywords = array_unique($keywords); |
} |
// second possiblity : removing the given keywords from all pictures |
// (without deleting the other specific keywords |
if ($_POST['common_keywords'] == 'remove') |
{ |
$keywords = array_diff($specific_keywords, $common_keywords); |
} |
// cleaning the keywords array, sometimes, an empty value still remain |
$keywords = array_remove($keywords, ''); |
// updating the picture with new keywords array |
$query = 'UPDATE '.IMAGES_TABLE.' SET keywords = '; |
if (count($keywords) == 0) |
{ |
$query.= 'NULL'; |
} |
else |
{ |
$query.= '"'; |
$i = 0; |
foreach ($keywords as $keyword) { |
if ($i++ > 0) $query.= ','; |
$query.= $keyword; |
} |
$query.= '"'; |
} |
$query.= ' WHERE id = '.$row['id']; |
$query.= ';'; |
pwg_query($query); |
} |
} |
} |
// +-----------------------------------------------------------------------+ |
// | form initialization | |
// +-----------------------------------------------------------------------+ |
if (!isset($_GET['start']) |
or !is_numeric($_GET['start']) |
or (is_numeric($_GET['start']) and $_GET['start'] < 0)) |
{ |
$page['start'] = 0; |
} |
else |
{ |
$page['start'] = $_GET['start']; |
} |
if (isset($_GET['num']) and is_numeric($_GET['num']) and $_GET['num'] >= 0) |
{ |
$max = $conf['info_nb_elements_page']; |
$page['start'] = floor($_GET['num'] / $max) * $max; |
} |
// Navigation path |
$current_category = get_cat_info($_GET['cat_id']); |
$url = PHPWG_ROOT_PATH.'admin.php?page=infos_images&cat_id='; |
$category_path = get_cat_display_name($current_category['name'], $url); |
$form_action = PHPWG_ROOT_PATH.'admin.php'; |
$form_action.= '?page=infos_images&cat_id='.$_GET['cat_id']; |
if($page['start']) |
{ |
$form_action.= '&start='.$_GET['start']; |
} |
$nav_bar = create_navigation_bar($form_action, |
$current_category['nb_images'], |
$page['start'], |
$conf['info_nb_elements_page'], |
''); |
// +-----------------------------------------------------------------------+ |
// | template initialization | |
// +-----------------------------------------------------------------------+ |
$template->set_filenames(array('infos_images'=>'admin/infos_images.tpl')); |
$template->assign_vars( |
array( |
'CATEGORY'=>$category_path, |
'NAV_BAR'=>$nav_bar, |
'L_INFOS_TITLE'=>$lang['infoimage_general'], |
'L_AUTHOR'=>$lang['author'], |
'L_INFOS_OVERALL_USE'=>$lang['infoimage_useforall'], |
'L_INFOS_CREATION_DATE'=>$lang['infoimage_creation_date'], |
'L_KEYWORD'=>$lang['keywords'], |
'L_KEYWORD_SEPARATION'=>$lang['infoimage_keyword_separation'], |
'L_INFOS_ADDTOALL'=>$lang['infoimage_addtoall'], |
'L_INFOS_REMOVEFROMALL'=>$lang['infoimage_removefromall'], |
'L_INFOS_DETAIL'=>$lang['infoimage_detailed'], |
'L_THUMBNAIL'=>$lang['thumbnail'], |
'L_INFOS_IMG'=>$lang['infoimage_title'], |
'L_INFOS_COMMENT'=>$lang['description'], |
'L_INFOS_ASSOCIATE'=>$lang['infoimage_associate'], |
'L_SUBMIT'=>$lang['submit'], |
'F_ACTION'=>add_session_id($form_action) |
)); |
// +-----------------------------------------------------------------------+ |
// | errors display | |
// +-----------------------------------------------------------------------+ |
if (count($errors) != 0) |
{ |
$template->assign_block_vars('errors',array()); |
foreach ($errors as $error) |
{ |
$template->assign_block_vars('errors.error',array('ERROR'=>$error)); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | form | |
// +-----------------------------------------------------------------------+ |
$array_cat_directories = array(); |
$pic_mod_base_url = PHPWG_ROOT_PATH.'admin.php'; |
$pic_mod_base_url = '?page=picture_modify&image_id='; |
$query = ' |
SELECT * |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
WHERE category_id = '.$page['cat'].' |
'.$conf['order_by'].' |
LIMIT '.$page['start'].','.$conf['info_nb_elements_page'].' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); |
$template->assign_block_vars( |
'picture', |
array( |
'ID_IMG'=>$row['id'], |
'URL_IMG'=>add_session_id($pic_mod_base_url.$row['id']), |
'TN_URL_IMG'=>$thumbnail_url, |
'FILENAME_IMG'=>$row['file'], |
'DEFAULTNAME_IMG'=>get_filename_wo_extension($row['file']), |
'NAME_IMG'=>@$row['name'], |
'DATE_IMG'=>date_convert_back(@$row['date_creation']), |
'AUTHOR_IMG'=>@$row['author'], |
'KEYWORDS_IMG'=>@$row['keywords'], |
'COMMENT_IMG'=>@$row['comment'] |
)); |
} |
// Virtualy associate a picture to a category |
$query = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
;'; |
display_select_cat_wrapper($query, |
array(), |
'associate_option', |
true); |
} |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'infos_images'); |
?> |
/web/test/gallery/phpwebgallery/admin/picture_modify.php |
---|
0,0 → 1,290 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: picture_modify.php,v $ |
// | last update : $Date: 2005/05/01 14:16:43 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.20.2.1 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if(!defined("PHPWG_ROOT_PATH")) |
{ |
die ("Hacking attempt!"); |
} |
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
//--------------------------------------------------------- update informations |
$errors = array(); |
// first, we verify whether there is a mistake on the given creation date |
if (isset($_POST['date_creation']) and !empty($_POST['date_creation'])) |
{ |
if (!check_date_format($_POST['date_creation'])) |
{ |
array_push($errors, $lang['err_date']); |
} |
} |
if (isset($_POST['submit']) and count($errors) == 0) |
{ |
$query = 'UPDATE '.IMAGES_TABLE.' SET name = '; |
if ($_POST['name'] == '') |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities($_POST['name'], ENT_QUOTES)."'"; |
$query.= ', author = '; |
if ($_POST['author'] == '') |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities($_POST['author'],ENT_QUOTES)."'"; |
$query.= ', comment = '; |
if ($_POST['comment'] == '') |
$query.= 'NULL'; |
else |
$query.= "'".htmlentities($_POST['comment'],ENT_QUOTES)."'"; |
$query.= ', date_creation = '; |
if (!empty($_POST['date_creation'])) |
$query.= "'".date_convert($_POST['date_creation'])."'"; |
else if ($_POST['date_creation'] == '') |
$query.= 'NULL'; |
$query.= ', keywords = '; |
$keywords_array = get_keywords($_POST['keywords']); |
if (count($keywords_array) == 0) |
$query.= 'NULL'; |
else |
{ |
$query.= "'"; |
foreach ($keywords_array as $i => $keyword) { |
if ($i > 0) $query.= ','; |
$query.= $keyword; |
} |
$query.= "'"; |
} |
$query.= ' WHERE id = '.$_GET['image_id']; |
$query.= ';'; |
pwg_query($query); |
} |
// associate the element to other categories than its storage category |
if (isset($_POST['associate']) |
and isset($_POST['cat_dissociated']) |
and count($_POST['cat_dissociated']) > 0) |
{ |
$datas = array(); |
foreach ($_POST['cat_dissociated'] as $category_id) |
{ |
array_push($datas, array('image_id' => $_GET['image_id'], |
'category_id' => $category_id)); |
} |
mass_inserts(IMAGE_CATEGORY_TABLE, array('image_id', 'category_id'), $datas); |
update_category($_POST['cat_dissociated']); |
} |
// dissociate the element from categories (but not from its storage category) |
if (isset($_POST['dissociate']) |
and isset($_POST['cat_associated']) |
and count($_POST['cat_associated']) > 0) |
{ |
$query = ' |
DELETE FROM '.IMAGE_CATEGORY_TABLE.' |
WHERE image_id = '.$_GET['image_id'].' |
AND category_id IN ('.implode(',',$_POST['cat_associated'] ).') |
'; |
pwg_query($query); |
update_category($_POST['cat_associated']); |
} |
// elect the element to represent the given categories |
if (isset($_POST['elect']) |
and isset($_POST['cat_dismissed']) |
and count($_POST['cat_dismissed']) > 0) |
{ |
$datas = array(); |
foreach ($_POST['cat_dismissed'] as $category_id) |
{ |
array_push($datas, |
array('id' => $category_id, |
'representative_picture_id' => $_GET['image_id'])); |
} |
$fields = array('primary' => array('id'), |
'update' => array('representative_picture_id')); |
mass_updates(CATEGORIES_TABLE, $fields, $datas); |
} |
// dismiss the element as representant of the given categories |
if (isset($_POST['dismiss']) |
and isset($_POST['cat_elected']) |
and count($_POST['cat_elected']) > 0) |
{ |
set_random_representant($_POST['cat_elected']); |
} |
// retrieving direct information about picture |
$query = ' |
SELECT i.*, c.uppercats |
FROM '.IMAGES_TABLE.' AS i |
INNER JOIN '.CATEGORIES_TABLE.' AS c ON i.storage_category_id = c.id |
WHERE i.id = '.$_GET['image_id'].' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$storage_category_id = $row['storage_category_id']; |
if (empty($row['name'])) |
{ |
$title = str_replace('_', ' ',get_filename_wo_extension($row['file'])); |
} |
else |
{ |
$title = $row['name']; |
} |
// Navigation path |
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); |
$url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id']; |
$query = ' |
SELECT category_id |
FROM '.IMAGE_CATEGORY_TABLE.' |
WHERE image_id = '.$_GET['image_id']; |
if (isset($user['forbidden_categories']) |
and !empty($user['forbidden_categories'])) |
{ |
$query.= ' |
AND category_id NOT IN ('.$user['forbidden_categories'].')'; |
} |
$query.= ' |
ORDER BY RAND() |
;'; |
$result = pwg_query($query); |
if (mysql_num_rows($result) > 0) |
{ |
list($category_id) = mysql_fetch_array($result); |
$url_img .= '&cat='.$category_id; |
} |
else |
{ |
$url_img .= '&cat='.$row['storage_category_id']; |
} |
$date = isset($_POST['date_creation']) && empty($errors) |
?$_POST['date_creation']:date_convert_back(@$row['date_creation']); |
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='; |
$storage_category = get_cat_display_name_cache($row['uppercats'], |
$url, |
false); |
//----------------------------------------------------- template initialization |
$template->set_filenames(array('picture_modify'=>'admin/picture_modify.tpl')); |
$template->assign_vars(array( |
'TITLE_IMG'=>$title, |
'STORAGE_CATEGORY_IMG'=>$storage_category, |
'PATH_IMG'=>$row['path'], |
'FILE_IMG'=>$row['file'], |
'TN_URL_IMG'=>$thumbnail_url, |
'URL_IMG'=>add_session_id($url_img), |
'DEFAULT_NAME_IMG'=>str_replace('_',' ',get_filename_wo_extension($row['file'])), |
'FILE_IMG'=>$row['file'], |
'NAME_IMG'=>isset($_POST['name'])?$_POST['name']:@$row['name'], |
'SIZE_IMG'=>@$row['width'].' * '.@$row['height'], |
'FILESIZE_IMG'=>@$row['filesize'].' KB', |
'REGISTRATION_DATE_IMG'=> format_date($row['date_available']), |
'AUTHOR_IMG'=>isset($_POST['author'])?$_POST['author']:@$row['author'], |
'CREATION_DATE_IMG'=>$date, |
'KEYWORDS_IMG'=>isset($_POST['keywords'])?$_POST['keywords']:@$row['keywords'], |
'COMMENT_IMG'=>isset($_POST['comment'])?$_POST['comment']:@$row['comment'], |
'L_UPLOAD_NAME'=>$lang['upload_name'], |
'L_DEFAULT'=>$lang['default'], |
'L_FILE'=>$lang['file'], |
'L_SIZE'=>$lang['size'], |
'L_FILESIZE'=>$lang['filesize'], |
'L_REGISTRATION_DATE'=>$lang['registration_date'], |
'L_AUTHOR'=>$lang['author'], |
'L_CREATION_DATE'=>$lang['creation_date'], |
'L_KEYWORDS'=>$lang['keywords'], |
'L_COMMENT'=>$lang['description'], |
'L_CATEGORIES'=>$lang['categories'], |
'L_DISSOCIATE'=>$lang['dissociate'], |
'L_INFOIMAGE_ASSOCIATE'=>$lang['infoimage_associate'], |
'L_SUBMIT'=>$lang['submit'], |
'L_RESET'=>$lang['reset'], |
'L_CAT_ASSOCIATED'=>$lang['infoimage_associated'], |
'L_CAT_DISSOCIATED'=>$lang['infoimage_dissociated'], |
'L_PATH'=>$lang['path'], |
'L_STORAGE_CATEGORY'=>$lang['storage_category'], |
'L_REPRESENTS'=>$lang['represents'], |
'L_DOESNT_REPRESENT'=>$lang['doesnt_represent'], |
'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?'.$_SERVER['QUERY_STRING']) |
)); |
//-------------------------------------------------------------- errors display |
if (count($errors) != 0) |
{ |
$template->assign_block_vars('errors',array()); |
foreach ($errors as $error) |
{ |
$template->assign_block_vars('errors.error',array('ERROR'=>$error)); |
} |
} |
// associate to another category ? |
$query = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = category_id |
WHERE image_id = '.$_GET['image_id'].' |
AND id != '.$storage_category_id.' |
;'; |
display_select_cat_wrapper($query,array(),'associated_option'); |
$result = pwg_query($query); |
$associateds = array($storage_category_id); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($associateds, $row['id']); |
} |
$query = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE id NOT IN ('.implode(',', $associateds).') |
;'; |
display_select_cat_wrapper($query,array(),'dissociated_option'); |
// representing |
$query = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE representative_picture_id = '.$_GET['image_id'].' |
;'; |
display_select_cat_wrapper($query,array(),'elected_option'); |
$query = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE id IN ('.implode(',', $associateds).') |
AND representative_picture_id != '.$_GET['image_id'].' |
;'; |
display_select_cat_wrapper($query,array(),'dismissed_option'); |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'picture_modify'); |
?> |
/web/test/gallery/phpwebgallery/admin/remote_site.php |
---|
0,0 → 1,755 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: remote_site.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.11 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if (!defined('PHPWG_ROOT_PATH')) |
{ |
die ("Hacking attempt!"); |
} |
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
define('CURRENT_DATE', date('Y-m-d')); |
// +-----------------------------------------------------------------------+ |
// | functions | |
// +-----------------------------------------------------------------------+ |
/** |
* requests the given $url (a remote create_listing_file.php) and fills a |
* list of lines corresponding to request output |
* |
* @param string $url |
* @return void |
*/ |
function remote_output($url) |
{ |
global $template, $errors, $lang; |
if($lines = @file($url)) |
{ |
$template->assign_block_vars('remote_output', array()); |
// cleaning lines from HTML tags |
foreach ($lines as $line) |
{ |
$line = trim(strip_tags($line)); |
if (preg_match('/^PWG-([A-Z]+)-/', $line, $matches)) |
{ |
$template->assign_block_vars( |
'remote_output.remote_line', |
array( |
'CLASS' => 'remote'.ucfirst(strtolower($matches[1])), |
'CONTENT' => $line |
) |
); |
} |
} |
} |
else |
{ |
array_push($errors, $lang['remote_site_file_not_found']); |
} |
} |
/** |
* returns an array where are linked the sub-categories id and there |
* directories corresponding to the given uppercat id |
* |
* @param int site_id |
* @param mixed id_uppercat |
* @return array |
*/ |
function database_subdirs($site_id, $id_uppercat) |
{ |
$database_dirs = array(); |
$query = ' |
SELECT id,dir |
FROM '.CATEGORIES_TABLE.' |
WHERE site_id = '.$site_id; |
if (!is_numeric($id_uppercat)) |
{ |
$query.= ' |
AND id_uppercat IS NULL'; |
} |
else |
{ |
$query.= ' |
AND id_uppercat = '.$id_uppercat; |
} |
// virtual categories not taken |
$query.= ' |
AND dir IS NOT NULL |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$database_dirs[$row['id']] = $row['dir']; |
} |
return $database_dirs; |
} |
/** |
* read $listing_file and update a remote site according to its id |
* |
* @param string listing_file |
* @param int site_id |
* @return void |
*/ |
function update_remote_site($listing_file, $site_id) |
{ |
global $lang, $counts, $template, $removes, $errors; |
if (@fopen($listing_file, 'r')) |
{ |
$counts = array( |
'new_elements' => 0, |
'new_categories' => 0, |
'del_elements' => 0, |
'del_categories' => 0 |
); |
$removes = array(); |
$xml_content = getXmlCode($listing_file); |
insert_remote_category($xml_content, $site_id, 'NULL', 0); |
update_category(); |
ordering(); |
update_global_rank(); |
$template->assign_block_vars( |
'update', |
array( |
'NB_NEW_CATEGORIES'=>$counts['new_categories'], |
'NB_DEL_CATEGORIES'=>$counts['del_categories'], |
'NB_NEW_ELEMENTS'=>$counts['new_elements'], |
'NB_DEL_ELEMENTS'=>$counts['del_elements'] |
)); |
if (count($removes) > 0) |
{ |
$template->assign_block_vars('update.removes', array()); |
} |
foreach ($removes as $remove) |
{ |
$template->assign_block_vars('update.removes.remote_remove', |
array('NAME'=>$remove)); |
} |
} |
else |
{ |
array_push($errors, $lang['remote_site_listing_not_found']); |
} |
} |
/** |
* searchs the "dir" node of the xml_dir given and insert the contained |
* categories if the are not in the database yet. The function also deletes |
* the categories that are in the database and not in the xml_file. |
* |
* @param string xml_content |
* @param int site_id |
* @param mixed id_uppercat |
* @param int level |
* @return void |
*/ |
function insert_remote_category($xml_content, $site_id, $id_uppercat, $level) |
{ |
global $counts, $removes, $conf; |
$uppercats = ''; |
// 0. retrieving informations on the category to display |
if (is_numeric($id_uppercat)) |
{ |
$query = ' |
SELECT id,name,uppercats,dir,status,visible |
FROM '.CATEGORIES_TABLE.' |
WHERE id = '.$id_uppercat.' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$parent = array('id' => $row['id'], |
'name' => $row['name'], |
'dir' => $row['dir'], |
'uppercats' => $row['uppercats'], |
'visible' => $row['visible'], |
'status' => $row['status']); |
insert_remote_element($xml_content, $id_uppercat); |
} |
// $xml_dirs contains dir names contained in the xml file for this |
// id_uppercat |
$xml_dirs = array(); |
$temp_dirs = getChildren($xml_content, 'dir'.$level); |
foreach ($temp_dirs as $temp_dir) |
{ |
array_push($xml_dirs, getAttribute($temp_dir, 'name')); |
} |
// $database_dirs contains dir names contained in the database for this |
// id_uppercat and site_id |
$database_dirs = database_subdirs($site_id, $id_uppercat); |
// 3. we have to remove the categories of the database not present anymore |
$to_delete = array(); |
foreach ($database_dirs as $id => $dir) |
{ |
if (!in_array($dir, $xml_dirs)) |
{ |
array_push($to_delete, $id); |
array_push($removes, get_complete_dir($id)); |
} |
} |
delete_categories($to_delete); |
// array of new categories to insert |
$inserts = array(); |
// calculate default value at category creation |
$create_values = array(); |
if (isset($parent)) |
{ |
// at creation, must a category be visible or not ? Warning : if |
// the parent category is invisible, the category is automatically |
// create invisible. (invisible = locked) |
if ('false' == $parent['visible']) |
{ |
$create_values{'visible'} = 'false'; |
} |
else |
{ |
$create_values{'visible'} = $conf['newcat_default_visible']; |
} |
// at creation, must a category be public or private ? Warning : |
// if the parent category is private, the category is |
// automatically create private. |
if ('private' == $parent['status']) |
{ |
$create_values{'status'} = 'private'; |
} |
else |
{ |
$create_values{'status'} = $conf['newcat_default_status']; |
} |
} |
else |
{ |
$create_values{'visible'} = $conf['newcat_default_visible']; |
$create_values{'status'} = $conf['newcat_default_status']; |
} |
foreach ($xml_dirs as $xml_dir) |
{ |
// 5. Is the category already existing ? we create a subcat if not |
// existing |
$category_id = array_search($xml_dir, $database_dirs); |
if (!is_numeric($category_id)) |
{ |
$name = str_replace('_', ' ', $xml_dir); |
$insert = array(); |
$insert{'dir'} = $xml_dir; |
$insert{'name'} = $name; |
$insert{'site_id'} = $site_id; |
$insert{'uppercats'} = 'undef'; |
$insert{'commentable'} = $conf['newcat_default_commentable']; |
$insert{'uploadable'} = 'false'; |
$insert{'status'} = $create_values{'status'}; |
$insert{'visible'} = $create_values{'visible'}; |
if (isset($parent)) |
{ |
$insert{'id_uppercat'} = $parent['id']; |
} |
array_push($inserts, $insert); |
} |
} |
// we have to create the category |
if (count($inserts) > 0) |
{ |
// inserts all found categories |
$dbfields = array('dir','name','site_id','uppercats','id_uppercat', |
'commentable','uploadable','status','visible'); |
mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); |
$counts{'new_categories'}+= count($inserts); |
// updating uppercats field |
$query = ' |
UPDATE '.CATEGORIES_TABLE; |
if (isset($parent)) |
{ |
$query.= " |
SET uppercats = CONCAT('".$parent['uppercats']."',',',id) |
WHERE id_uppercat = ".$id_uppercat; |
} |
else |
{ |
$query.= ' |
SET uppercats = id |
WHERE id_uppercat IS NULL'; |
} |
$query.= ' |
;'; |
pwg_query($query); |
} |
// Recursive call on the sub-categories (not virtual ones) |
$database_dirs = database_subdirs($site_id, $id_uppercat); |
foreach ($temp_dirs as $temp_dir) |
{ |
$dir = getAttribute($temp_dir, 'name'); |
$id_uppercat = array_search($dir, $database_dirs); |
insert_remote_category($temp_dir, $site_id, $id_uppercat, $level+1); |
} |
} |
/** |
* searchs the "root" node of $xml_dir (xml string), inserts elements in the |
* database if new |
* |
* @param string xml_dir |
* @param int category_id |
* @return void |
*/ |
function insert_remote_element($xml_dir, $category_id) |
{ |
global $counts, $lang, $removes; |
$output = ''; |
$root = getChild($xml_dir, 'root'); |
$xml_files = array(); |
$xml_elements = getChildren($root, 'element'); |
foreach ($xml_elements as $xml_element) |
{ |
array_push($xml_files, getAttribute($xml_element,'file')); |
} |
// we have to delete all the images from the database that are not in the |
// directory anymore (not in the XML anymore) |
$query = ' |
SELECT id,file |
FROM '.IMAGES_TABLE.' |
WHERE storage_category_id = '.$category_id.' |
;'; |
$result = pwg_query($query); |
$to_delete = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
if (!in_array($row['file'], $xml_files)) |
{ |
// local_dir is cached |
if (!isset($local_dir)) |
{ |
$local_dir = get_local_dir($category_id); |
} |
array_push($removes, $local_dir.$row['file']); |
array_push($to_delete, $row['id']); |
} |
} |
delete_elements($to_delete); |
$database_elements = array(); |
$query = ' |
SELECT file |
FROM '.IMAGES_TABLE.' |
WHERE storage_category_id = '.$category_id.' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($database_elements, $row['file']); |
} |
$inserts = array(); |
foreach ($xml_elements as $xml_element) |
{ |
// minimal tag : <element file="albatros.jpg"/> |
$file = getAttribute($xml_element, 'file'); |
// is the picture already existing in the database ? |
if (!in_array($file, $database_elements)) |
{ |
$insert = array(); |
$insert{'file'} = $file; |
$insert{'storage_category_id'} = $category_id; |
$insert{'date_available'} = CURRENT_DATE; |
$optional_atts = array('tn_ext', |
'representative_ext', |
'filesize', |
'width', |
'height', |
'date_creation', |
'author', |
'keywords', |
'name', |
'comment', |
'path'); |
foreach ($optional_atts as $att) |
{ |
if (getAttribute($xml_element, $att) != '') |
{ |
$insert{$att} = getAttribute($xml_element, $att); |
} |
} |
array_push($inserts, $insert); |
} |
} |
if (count($inserts) > 0) |
{ |
$dbfields = array('file','storage_category_id','date_available','tn_ext', |
'filesize','width','height','date_creation','author', |
'keywords','name','comment','path'); |
mass_inserts(IMAGES_TABLE, $dbfields, $inserts); |
$counts{'new_elements'}+= count($inserts); |
// what are the ids of the pictures in the $category_id ? |
$ids = array(); |
$query = ' |
SELECT id |
FROM '.IMAGES_TABLE.' |
WHERE storage_category_id = '.$category_id.' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($ids, $row['id']); |
} |
// recreation of the links between this storage category pictures and |
// its storage category |
$query = ' |
DELETE FROM '.IMAGE_CATEGORY_TABLE.' |
WHERE category_id = '.$category_id.' |
AND image_id IN ('.implode(',', $ids).') |
;'; |
pwg_query($query); |
$query = ' |
INSERT INTO '.IMAGE_CATEGORY_TABLE.' |
(category_id,image_id) |
VALUES'; |
foreach ($ids as $num => $image_id) |
{ |
$query.= ' |
'; |
if ($num > 0) |
{ |
$query.= ','; |
} |
$query.= '('.$category_id.','.$image_id.')'; |
} |
$query.= ' |
;'; |
pwg_query($query); |
// set a new representative element for this category |
$query = ' |
SELECT image_id |
FROM '.IMAGE_CATEGORY_TABLE.' |
WHERE category_id = '.$category_id.' |
ORDER BY RAND() |
LIMIT 0,1 |
;'; |
list($representative) = mysql_fetch_array(pwg_query($query)); |
$query = ' |
UPDATE '.CATEGORIES_TABLE.' |
SET representative_picture_id = '.$representative.' |
WHERE id = '.$category_id.' |
;'; |
pwg_query($query); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | template init | |
// +-----------------------------------------------------------------------+ |
$template->set_filenames(array('remote_site'=>'admin/remote_site.tpl')); |
$template->assign_vars( |
array( |
'L_SUBMIT'=>$lang['submit'], |
'L_REMOTE_SITE_CREATE'=>$lang['remote_site_create'], |
'L_REMOTE_SITE_GENERATE'=>$lang['remote_site_generate'], |
'L_REMOTE_SITE_GENERATE_HINT'=>$lang['remote_site_generate_hint'], |
'L_REMOTE_SITE_UPDATE'=>$lang['remote_site_update'], |
'L_REMOTE_SITE_UPDATE_HINT'=>$lang['remote_site_update_hint'], |
'L_REMOTE_SITE_CLEAN'=>$lang['remote_site_clean'], |
'L_REMOTE_SITE_CLEAN_HINT'=>$lang['remote_site_clean_hint'], |
'L_REMOTE_SITE_DELETE'=>$lang['remote_site_delete'], |
'L_REMOTE_SITE_DELETE_HINT'=>$lang['remote_site_delete_hint'], |
'L_NB_NEW_ELEMENTS'=>$lang['update_nb_new_elements'], |
'L_NB_NEW_CATEGORIES'=>$lang['update_nb_new_categories'], |
'L_NB_DEL_ELEMENTS'=>$lang['update_nb_del_elements'], |
'L_NB_DEL_CATEGORIES'=>$lang['update_nb_del_categories'], |
'L_REMOTE_SITE_REMOVED_TITLE'=>$lang['remote_site_removed_title'], |
'L_REMOTE_SITE_REMOVED'=>$lang['remote_site_removed'], |
'L_REMOTE_SITE_LOCAL_FOUND'=>$lang['remote_site_local_found'], |
'L_REMOTE_SITE_LOCAL_NEW'=>$lang['remote_site_local_new'], |
'L_REMOTE_SITE_LOCAL_UPDATE'=>$lang['remote_site_local_update'], |
'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=remote_site') |
) |
); |
// +-----------------------------------------------------------------------+ |
// | new site creation form | |
// +-----------------------------------------------------------------------+ |
$errors = array(); |
if (isset($_POST['submit'])) |
{ |
// site must start by http:// or https:// |
if (!preg_match('/^https?:\/\/[~\/\.\w-]+$/', $_POST['galleries_url'])) |
{ |
array_push($errors, $lang['remote_site_uncorrect_url']); |
} |
else |
{ |
$page['galleries_url'] = preg_replace('/[\/]*$/', |
'', |
$_POST['galleries_url']); |
$page['galleries_url'].= '/'; |
// site must not exists |
$query = ' |
SELECT COUNT(id) AS count |
FROM '.SITES_TABLE.' |
WHERE galleries_url = \''.$page['galleries_url'].'\' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
if ($row['count'] > 0) |
{ |
array_push($errors, $lang['remote_site_already_exists']); |
} |
} |
if (count($errors) == 0) |
{ |
$url = $page['galleries_url'].'create_listing_file.php'; |
$url.= '?action=test'; |
$url.= '&version='.PHPWG_VERSION; |
if ($lines = @file($url)) |
{ |
$first_line = strip_tags($lines[0]); |
if (!preg_match('/^PWG-INFO-2:/', $first_line)) |
{ |
array_push($errors, $lang['remote_site_error'].' : '.$first_line); |
} |
} |
else |
{ |
array_push($errors, $lang['remote_site_file_not_found']); |
} |
} |
if (count($errors) == 0) |
{ |
$query = ' |
INSERT INTO '.SITES_TABLE.' |
(galleries_url) |
VALUES |
(\''.$page['galleries_url'].'\') |
;'; |
pwg_query($query); |
$template->assign_block_vars( |
'confirmation', |
array( |
'CONTENT'=>$page['galleries_url'].' '.$lang['remote_site_created'] |
)); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | actions on site | |
// +-----------------------------------------------------------------------+ |
if (isset($_GET['site']) and is_numeric($_GET['site'])) |
{ |
$page['site'] = $_GET['site']; |
} |
if (isset($_GET['action'])) |
{ |
if (isset($page['site'])) |
{ |
$query = ' |
SELECT galleries_url |
FROM '.SITES_TABLE.' |
WHERE id = '.$page['site'].' |
;'; |
list($galleries_url) = mysql_fetch_array(pwg_query($query)); |
} |
switch($_GET['action']) |
{ |
case 'delete' : |
{ |
delete_site($page['site']); |
$template->assign_block_vars( |
'confirmation', |
array( |
'CONTENT'=>$galleries_url.' '.$lang['remote_site_deleted'] |
)); |
break; |
} |
case 'generate' : |
{ |
$title = $galleries_url.' : '.$lang['remote_site_generate']; |
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); |
remote_output($galleries_url.'create_listing_file.php?action=generate'); |
break; |
} |
case 'update' : |
{ |
$title = $galleries_url.' : '.$lang['remote_site_update']; |
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); |
update_remote_site($galleries_url.'listing.xml', $page['site']); |
break; |
} |
case 'clean' : |
{ |
$title = $galleries_url.' : '.$lang['remote_site_clean']; |
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); |
remote_output($galleries_url.'create_listing_file.php?action=clean'); |
break; |
} |
case 'local_update' : |
{ |
$local_listing = PHPWG_ROOT_PATH.'listing.xml'; |
$xml_content = getXmlCode($local_listing); |
$url = getAttribute(getChild($xml_content, 'informations'), 'url'); |
// is the site already existing ? |
$query = ' |
SELECT id |
FROM '.SITES_TABLE.' |
WHERE galleries_url = \''.addslashes($url).'\' |
;'; |
$result = pwg_query($query); |
if (mysql_num_rows($result) == 0) |
{ |
// we have to register this site in the database |
$query = ' |
INSERT INTO '.SITES_TABLE.' |
(galleries_url) |
VALUES |
(\''.$url.'\') |
;'; |
pwg_query($query); |
$site_id = mysql_insert_id(); |
} |
else |
{ |
// we get the already registered id |
$row = mysql_fetch_array($result); |
$site_id = $row['id']; |
} |
$title = $url.' : '.$lang['remote_site_local_update']; |
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); |
update_remote_site($local_listing, $site_id); |
break; |
} |
} |
} |
else |
{ |
// we search a "local" listing.xml file |
$local_listing = PHPWG_ROOT_PATH.'listing.xml'; |
if (is_file($local_listing)) |
{ |
$xml_content = getXmlCode($local_listing); |
$url = getAttribute(getChild($xml_content, 'informations'), 'url'); |
$base_url = PHPWG_ROOT_PATH.'admin.php?page=remote_site&action='; |
$template->assign_block_vars( |
'local', |
array( |
'URL' => $url, |
'U_UPDATE' => add_session_id($base_url.'local_update') |
) |
); |
// is the site already existing ? |
$query = ' |
SELECT COUNT(*) |
FROM '.SITES_TABLE.' |
WHERE galleries_url = \''.addslashes($url).'\' |
;'; |
list($count) = mysql_fetch_array(pwg_query($query)); |
if ($count == 0) |
{ |
$template->assign_block_vars('local.new_site', array()); |
} |
} |
} |
// +-----------------------------------------------------------------------+ |
// | remote sites list | |
// +-----------------------------------------------------------------------+ |
// site 1 is the local site, should not be taken into account |
$query = ' |
SELECT id, galleries_url |
FROM '.SITES_TABLE.' |
WHERE id != 1 |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$base_url = PHPWG_ROOT_PATH.'admin.php'; |
$base_url.= '?page=remote_site'; |
$base_url.= '&site='.$row['id']; |
$base_url.= '&action='; |
$template->assign_block_vars( |
'site', |
array( |
'NAME' => $row['galleries_url'], |
'U_GENERATE' => add_session_id($base_url.'generate'), |
'U_UPDATE' => add_session_id($base_url.'update'), |
'U_CLEAN' => add_session_id($base_url.'clean'), |
'U_DELETE' => add_session_id($base_url.'delete') |
) |
); |
} |
// +-----------------------------------------------------------------------+ |
// | errors display | |
// +-----------------------------------------------------------------------+ |
if (count($errors) != 0) |
{ |
$template->assign_block_vars('errors',array()); |
foreach ($errors as $error) |
{ |
$template->assign_block_vars('errors.error',array('ERROR'=>$error)); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | sending html code | |
// +-----------------------------------------------------------------------+ |
$template->assign_var_from_handle('ADMIN_CONTENT', 'remote_site'); |
?> |
/web/test/gallery/phpwebgallery/admin/search.php |
---|
0,0 → 1,108 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: search.php,v $ |
// | last update : $Date: 2005/01/13 10:18:49 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.8 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
define('PHPWG_ROOT_PATH','../'); |
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
//----------------------------------------------------- template initialization |
$title = $lang['Find_username']; |
include(PHPWG_ROOT_PATH.'include/page_header.php'); |
$template->set_filenames( array('search'=>'admin/search_username.tpl') ); |
$template->assign_vars(array( |
'USERNAME'=>( !empty($search_match) ) ? strip_tags($search_match) : '', |
'L_SEARCH_USERNAME'=>$lang['Find_username'], |
'L_SEARCH'=>$lang['search'], |
'L_SEARCH_EXPLAIN'=>$lang['search_explain'], |
'L_SELECT'=>$lang['Select'], |
'L_UPDATE_USERNAME'=>$lang['Look_up_user'], |
'L_CLOSE_WINDOW'=>$lang['Close'], |
'F_SEARCH_ACTION' => add_session_id($_SERVER['PHP_SELF']), |
)); |
//----------------------------------------------------------------- form action |
// |
// Define initial vars |
// |
if ( isset($_POST['mode']) || isset($_GET['mode']) ) |
{ |
$mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode']; |
} |
else |
{ |
$mode = ''; |
} |
$search_match = ''; |
if ( isset($_POST['search_username']) ) |
{ |
$search_match = $_POST['search_username']; |
} |
$username_list = ''; |
if ( !empty($search_match) ) |
{ |
$username_search = preg_replace('/\*/', '%', trim(strip_tags($search_match))); |
$sql = "SELECT username |
FROM " . USERS_TABLE . " |
WHERE username LIKE '" . str_replace("\'", "''", $username_search) . "' |
AND id <> ".ANONYMOUS." |
ORDER BY username"; |
if ( !($result = pwg_query($sql)) ) |
{ |
die('Could not obtain search results'); |
} |
if ( $row = mysql_fetch_array($result) ) |
{ |
do |
{ |
$username_list .= '<option value="' . $row['username'] . '">' . $row['username'] . '</option>'; |
} |
while ( $row = mysql_fetch_array($result) ); |
} |
else |
{ |
$username_list .= '<option>' . $lang['No_match']. '</option>'; |
} |
mysql_free_result($result); |
} |
//------------------------------------------------------------------ users list |
if ( !empty($username_list)) |
{ |
$template->assign_block_vars('switch_select_name', array( |
'F_USERNAME_OPTIONS'=>$username_list |
)); |
} |
$template->parse('search'); |
include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
?> |
/web/test/gallery/phpwebgallery/admin/stats.php |
---|
0,0 → 1,110 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: stats.php,v $ |
// | last update : $Date: 2005/02/01 07:28:38 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.22 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if( !defined("PHPWG_ROOT_PATH") ) |
{ |
die ("Hacking attempt!"); |
} |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
$url_img_global_report = PHPWG_ROOT_PATH.'admin/images/global_stats.img.php'; |
//----------------------------------------------------- template initialization |
$template->set_filenames( array('stats'=>'admin/stats.tpl') ); |
$template->assign_vars(array( |
'L_MONTH'=>$lang['w_month'], |
'L_PAGES_SEEN'=>$lang['stats_pages_seen'], |
'L_VISITORS'=>$lang['visitors'], |
'L_PICTURES'=>$lang['pictures'], |
'L_STAT_TITLE'=>$lang['stats_title'], |
'L_STAT_MONTH_TITLE'=>$lang['stats_month_title'], |
'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'], |
'IMG_MONTHLY_REPORT'=>add_session_id($url_img_global_report) |
)); |
//---------------------------------------------------------------- log history |
$query = ' |
SELECT DISTINCT COUNT(*) as p, |
MONTH(date) as m, |
YEAR(date) as y |
FROM '.HISTORY_TABLE.' |
GROUP BY DATE_FORMAT(date,\'%Y-%m\') DESC |
;'; |
$result = pwg_query( $query ); |
$i=0; |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$current_month = $row['y']."-"; |
if ($row['m'] <10) {$current_month.='0';} |
$current_month .= $row['m']; |
// Number of pictures seen |
$query = ' |
SELECT COUNT(*) as p, |
FILE as f |
FROM '.HISTORY_TABLE.' |
WHERE DATE_FORMAT(date,\'%Y-%m\') = \''.$current_month.'\' |
AND FILE = \'picture\' |
GROUP BY FILE |
;'; |
$pictures = mysql_fetch_array(pwg_query( $query )); |
// Number of different visitors |
$query = ' |
SELECT COUNT(*) as p, login |
FROM '.HISTORY_TABLE.' |
WHERE DATE_FORMAT(date,\'%Y-%m\') = \''.$current_month.'\' |
GROUP BY login, IP |
;'; |
$user_results = pwg_query( $query ); |
$nb_visitors = 0; |
$auth_users = array(); |
while ( $user_array = mysql_fetch_array( $user_results ) ) |
{ |
if ($user_array['login'] == 'guest') |
$nb_visitors += 1; |
else |
array_push($auth_users, $user_array['login']); |
} |
$nb_visitors +=count(array_unique($auth_users)); |
$class = ($i % 2)? 'row1':'row2'; $i++; |
$template->assign_block_vars('month',array( |
'MONTH'=>$lang['month'][$row['m']].' '.$row['y'], |
'PAGES'=>$row['p'], |
'VISITORS'=>$nb_visitors, |
'IMAGES'=>$pictures['p'], |
'T_CLASS'=>$class |
)); |
} |
$nb_visitors = mysql_num_rows( $result ); |
$days = array(); |
$max_nb_visitors = 0; |
$max_pages_seen = 0; |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'stats'); |
?> |
/web/test/gallery/phpwebgallery/admin/thumbnail.php |
---|
0,0 → 1,418 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: thumbnail.php,v $ |
// | last update : $Date: 2005/01/20 23:41:27 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.19 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
//------------------------------------------------------------------- functions |
// RatioResizeImg creates a new picture (a thumbnail since it is supposed to |
// be smaller than original picture !) in the sub directory named |
// "thumbnail". |
function RatioResizeImg($path, $newWidth, $newHeight, $tn_ext) |
{ |
global $conf, $lang, $errors; |
$filename = basename($path); |
$dirname = dirname($path); |
// extension of the picture filename |
$extension = get_extension($filename); |
if ($extension == 'jpg' or $extension == 'JPG') |
{ |
$srcImage = @imagecreatefromjpeg($path); |
} |
else if ($extension == 'png' or $extension == 'PNG') |
{ |
$srcImage = @imagecreatefrompng($path); |
} |
else |
{ |
unset($extension); |
} |
if ( isset( $srcImage ) ) |
{ |
// width/height |
$srcWidth = imagesx( $srcImage ); |
$srcHeight = imagesy( $srcImage ); |
$ratioWidth = $srcWidth/$newWidth; |
$ratioHeight = $srcHeight/$newHeight; |
// maximal size exceeded ? |
if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) ) |
{ |
if ( $ratioWidth < $ratioHeight) |
{ |
$destWidth = $srcWidth/$ratioHeight; |
$destHeight = $newHeight; |
} |
else |
{ |
$destWidth = $newWidth; |
$destHeight = $srcHeight/$ratioWidth; |
} |
} |
else |
{ |
$destWidth = $srcWidth; |
$destHeight = $srcHeight; |
} |
// according to the GD version installed on the server |
if ( $_POST['gd'] == 2 ) |
{ |
// GD 2.0 or more recent -> good results (but slower) |
$destImage = imagecreatetruecolor( $destWidth, $destHeight); |
imagecopyresampled( $destImage, $srcImage, 0, 0, 0, 0, |
$destWidth,$destHeight,$srcWidth,$srcHeight ); |
} |
else |
{ |
// GD prior to version 2 -> pretty bad results :-/ (but fast) |
$destImage = imagecreate( $destWidth, $destHeight); |
imagecopyresized( $destImage, $srcImage, 0, 0, 0, 0, |
$destWidth,$destHeight,$srcWidth,$srcHeight ); |
} |
$tndir = $dirname.'/thumbnail'; |
if (!is_dir($tndir)) |
{ |
if (!is_writable($dirname)) |
{ |
array_push($errors, '['.$dirname.'] : '.$lang['no_write_access']); |
return false; |
} |
umask(0000); |
mkdir($tndir, 0777); |
} |
$dest_file = $tndir.'/'.$conf['prefix_thumbnail']; |
$dest_file.= get_filename_wo_extension($filename); |
$dest_file.= '.'.$tn_ext; |
// creation and backup of final picture |
if (!is_writable($tndir)) |
{ |
array_push($errors, '['.$tndir.'] : '.$lang['no_write_access']); |
return false; |
} |
imagejpeg($destImage, $dest_file); |
// freeing memory ressources |
imagedestroy( $srcImage ); |
imagedestroy( $destImage ); |
list($tn_width, $tn_height) = getimagesize($dest_file); |
$tn_size = floor(filesize($dest_file) / 1024).' KB'; |
$info = array( 'path' => $path, |
'tn_file' => $dest_file, |
'tn_width' => $tn_width, |
'tn_height' => $tn_height, |
'tn_size' => $tn_size ); |
return $info; |
} |
// error |
else |
{ |
echo $lang['tn_no_support']." "; |
if ( isset( $extenstion ) ) |
{ |
echo $lang['tn_format'].' '.$extension; |
} |
else |
{ |
echo $lang['tn_thisformat']; |
} |
exit(); |
} |
} |
$errors = array(); |
$pictures = array(); |
$stats = array(); |
// +-----------------------------------------------------------------------+ |
// | template initialization | |
// +-----------------------------------------------------------------------+ |
$template->set_filenames( array('thumbnail'=>'admin/thumbnail.tpl') ); |
$template->assign_vars(array( |
'L_THUMBNAIL_TITLE'=>$lang['tn_dirs_title'], |
'L_UNLINK'=>$lang['tn_no_missing'], |
'L_MISSING_THUMBNAILS'=>$lang['tn_dirs_alone'], |
'L_RESULTS'=>$lang['tn_results_title'], |
'L_PATH'=>$lang['path'], |
'L_FILESIZE'=>$lang['filesize'], |
'L_WIDTH'=>$lang['tn_width'], |
'L_HEIGHT'=>$lang['tn_height'], |
'L_GENERATED'=>$lang['tn_results_gen_time'], |
'L_THUMBNAIL'=>$lang['thumbnail'], |
'L_PARAMS'=>$lang['tn_params_title'], |
'L_GD'=>$lang['tn_params_GD'], |
'L_GD_INFO'=>$lang['tn_params_GD_info'], |
'L_WIDTH_INFO'=>$lang['tn_params_width_info'], |
'L_HEIGHT_INFO'=>$lang['tn_params_height_info'], |
'L_CREATE'=>$lang['tn_params_create'], |
'L_CREATE_INFO'=>$lang['tn_params_create_info'], |
'L_FORMAT'=>$lang['tn_params_format'], |
'L_FORMAT_INFO'=>$lang['tn_params_format_info'], |
'L_SUBMIT'=>$lang['submit'], |
'L_REMAINING'=>$lang['tn_alone_title'], |
'L_TN_STATS'=>$lang['tn_stats'], |
'L_TN_NB_STATS'=>$lang['tn_stats_nb'], |
'L_TN_TOTAL'=>$lang['tn_stats_total'], |
'L_TN_MAX'=>$lang['tn_stats_max'], |
'L_TN_MIN'=>$lang['tn_stats_min'], |
'L_TN_AVERAGE'=>$lang['tn_stats_mean'], |
'L_ALL'=>$lang['tn_all'], |
'T_STYLE'=>$user['template'] |
)); |
// +-----------------------------------------------------------------------+ |
// | search pictures without thumbnails | |
// +-----------------------------------------------------------------------+ |
$wo_thumbnails = array(); |
$thumbnalized = array(); |
// what is the directory to search in ? |
$query = ' |
SELECT galleries_url |
FROM '.SITES_TABLE.' |
WHERE id = 1 |
;'; |
list($galleries_url) = mysql_fetch_array(pwg_query($query)); |
$basedir = preg_replace('#/*$#', '', $galleries_url); |
$fs = get_fs($basedir); |
// because isset is one hundred time faster than in_array |
$fs['thumbnails'] = array_flip($fs['thumbnails']); |
foreach ($fs['elements'] as $path) |
{ |
// only pictures need thumbnails |
if (in_array(get_extension($path), $conf['picture_ext'])) |
{ |
$dirname = dirname($path); |
$filename = basename($path); |
// only files matching the authorized filename pattern can be considered |
// as "without thumbnail" |
if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename)) |
{ |
continue; |
} |
// searching the element |
$filename_wo_ext = get_filename_wo_extension($filename); |
$tn_ext = ''; |
$base_test = $dirname.'/thumbnail/'; |
$base_test.= $conf['prefix_thumbnail'].$filename_wo_ext.'.'; |
foreach ($conf['picture_ext'] as $ext) |
{ |
if (isset($fs['thumbnails'][$base_test.$ext])) |
{ |
$tn_ext = $ext; |
break; |
} |
} |
if (empty($tn_ext)) |
{ |
array_push($wo_thumbnails, $path); |
} |
} |
} |
// +-----------------------------------------------------------------------+ |
// | thumbnails creation | |
// +-----------------------------------------------------------------------+ |
if (isset($_POST['submit'])) |
{ |
$errors = array(); |
$times = array(); |
$infos = array(); |
// checking criteria |
if (!ereg('^[0-9]{2,3}$', $_POST['width']) or $_POST['width'] < 10) |
{ |
array_push($errors, $lang['tn_err_width'].' 10'); |
} |
if (!ereg('^[0-9]{2,3}$', $_POST['height']) or $_POST['height'] < 10) |
{ |
array_push($errors, $lang['tn_err_height'].' 10'); |
} |
// picture miniaturization |
if (count($errors) == 0) |
{ |
$num = 1; |
foreach ($wo_thumbnails as $path) |
{ |
if (is_numeric($_POST['n']) and $num > $_POST['n']) |
{ |
break; |
} |
$starttime = get_moment(); |
if ($info = RatioResizeImg($path,$_POST['width'],$_POST['height'],'jpg')) |
{ |
$endtime = get_moment(); |
$info['time'] = ($endtime - $starttime) * 1000; |
array_push($infos, $info); |
array_push($times, $info['time']); |
array_push($thumbnalized, $path); |
$num++; |
} |
else |
{ |
break; |
} |
} |
if (count($infos) > 0) |
{ |
$sum = array_sum($times); |
$average = $sum / count($times); |
sort($times, SORT_NUMERIC); |
$max = array_pop($times); |
if (count($thumbnalized) == 1) |
{ |
$min = $max; |
} |
else |
{ |
$min = array_shift($times); |
} |
$template->assign_block_vars( |
'results', |
array( |
'TN_NB'=>count($infos), |
'TN_TOTAL'=>number_format($sum, 2, '.', ' ').' ms', |
'TN_MAX'=>number_format($max, 2, '.', ' ').' ms', |
'TN_MIN'=>number_format($min, 2, '.', ' ').' ms', |
'TN_AVERAGE'=>number_format($average, 2, '.', ' ').' ms' |
)); |
foreach ($infos as $i => $info) |
{ |
if ($info['time'] == $max) |
{ |
$class = 'worst_gen_time'; |
} |
else if ($info['time'] == $min) |
{ |
$class = 'best_gen_time'; |
} |
else |
{ |
$class = ''; |
} |
$template->assign_block_vars( |
'results.picture', |
array( |
'PATH'=>$info['path'], |
'TN_FILE_IMG'=>$info['tn_file'], |
'TN_FILESIZE_IMG'=>$info['tn_size'], |
'TN_WIDTH_IMG'=>$info['tn_width'], |
'TN_HEIGHT_IMG'=>$info['tn_height'], |
'GEN_TIME'=>number_format($info['time'], 2, '.', ' ').' ms', |
'T_CLASS'=>$class |
)); |
} |
} |
} |
} |
// +-----------------------------------------------------------------------+ |
// | errors display | |
// +-----------------------------------------------------------------------+ |
if (count($errors) != 0) |
{ |
$template->assign_block_vars('errors',array()); |
foreach ($errors as $error) |
{ |
$template->assign_block_vars('errors.error',array('ERROR'=>$error)); |
} |
} |
// +-----------------------------------------------------------------------+ |
// | form & pictures without thumbnails display | |
// +-----------------------------------------------------------------------+ |
$remainings = array_diff($wo_thumbnails, $thumbnalized); |
if (count($remainings) > 0) |
{ |
$form_url = PHPWG_ROOT_PATH.'admin.php?page=thumbnail'; |
$gd = !empty($_POST['gd']) ? $_POST['gd'] : 2; |
$width = !empty($_POST['width']) ? $_POST['width'] : $conf['tn_width']; |
$height = !empty($_POST['height']) ? $_POST['height'] : $conf['tn_height']; |
$n = !empty($_POST['n']) ? $_POST['n'] : 5; |
$gdlabel = 'GD'.$gd.'_CHECKED'; |
$nlabel = 'n_'.$n.'_CHECKED'; |
$template->assign_block_vars( |
'params', |
array( |
'F_ACTION'=>add_session_id($form_url), |
$gdlabel=>'checked="checked"', |
$nlabel=>'checked="checked"', |
'WIDTH_TN'=>$width, |
'HEIGHT_TN'=>$height |
)); |
$template->assign_block_vars( |
'remainings', |
array('TOTAL_IMG'=>count($remainings))); |
$num = 1; |
foreach ($remainings as $path) |
{ |
$class = ($num % 2) ? 'row1' : 'row2'; |
list($width, $height) = getimagesize($path); |
$size = floor(filesize($path) / 1024).' KB'; |
$template->assign_block_vars( |
'remainings.remaining', |
array( |
'NB_IMG'=>($num), |
'PATH'=>$path, |
'FILESIZE_IMG'=>$size, |
'WIDTH_IMG'=>$width, |
'HEIGHT_IMG'=>$height, |
'T_CLASS'=>$class |
)); |
$num++; |
} |
} |
else |
{ |
$template->assign_block_vars('warning', array()); |
} |
// +-----------------------------------------------------------------------+ |
// | return to admin | |
// +-----------------------------------------------------------------------+ |
$template->assign_var_from_handle('ADMIN_CONTENT', 'thumbnail'); |
?> |
/web/test/gallery/phpwebgallery/admin/update.php |
---|
0,0 → 1,750 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: update.php,v $ |
// | last update : $Date: 2005/04/20 19:09:50 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.47.2.1 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if (!defined('PHPWG_ROOT_PATH')) |
{ |
die ('Hacking attempt!'); |
} |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
define('CURRENT_DATE', date('Y-m-d')); |
$error_labels = array('PWG-UPDATE-1' => $lang['update_wrong_dirname_short'], |
'PWG-UPDATE-2' => $lang['update_missing_tn_short']); |
$errors = array(); |
$infos = array(); |
// +-----------------------------------------------------------------------+ |
// | directories / categories | |
// +-----------------------------------------------------------------------+ |
if (isset($_POST['submit']) |
and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')) |
{ |
$counts['new_categories'] = 0; |
$counts['del_categories'] = 0; |
$counts['del_elements'] = 0; |
$counts['new_elements'] = 0; |
// shall we simulate only |
if (isset($_POST['simulate']) and $_POST['simulate'] == 1) |
{ |
$simulate = true; |
} |
else |
{ |
$simulate = false; |
} |
$start = get_moment(); |
// which categories to update ? |
$cat_ids = array(); |
$query = ' |
SELECT id, uppercats, global_rank, status, visible |
FROM '.CATEGORIES_TABLE.' |
WHERE dir IS NOT NULL |
AND site_id = 1'; |
if (isset($_POST['cat']) and is_numeric($_POST['cat'])) |
{ |
if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1) |
{ |
$query.= ' |
AND uppercats REGEXP \'(^|,)'.$_POST['cat'].'(,|$)\' |
'; |
} |
else |
{ |
$query.= ' |
AND id = '.$_POST['cat'].' |
'; |
} |
} |
$query.= ' |
;'; |
$result = pwg_query($query); |
$db_categories = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$db_categories[$row['id']] = $row; |
} |
// get categort full directories in an array for comparison with file |
// system directory tree |
$db_fulldirs = get_fulldirs(array_keys($db_categories)); |
// what is the base directory to search file system sub-directories ? |
if (isset($_POST['cat']) and is_numeric($_POST['cat'])) |
{ |
$basedir = $db_fulldirs[$_POST['cat']]; |
} |
else |
{ |
$query = ' |
SELECT galleries_url |
FROM '.SITES_TABLE.' |
WHERE id = 1 |
;'; |
list($galleries_url) = mysql_fetch_array(pwg_query($query)); |
$basedir = preg_replace('#/*$#', '', $galleries_url); |
} |
// we need to have fulldirs as keys to make efficient comparison |
$db_fulldirs = array_flip($db_fulldirs); |
// finding next rank for each id_uppercat |
$next_rank['NULL'] = 1; |
$query = ' |
SELECT id_uppercat, MAX(rank)+1 AS next_rank |
FROM '.CATEGORIES_TABLE.' |
GROUP BY id_uppercat |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
// for the id_uppercat NULL, we write 'NULL' and not the empty string |
if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '') |
{ |
$row['id_uppercat'] = 'NULL'; |
} |
$next_rank[$row['id_uppercat']] = $row['next_rank']; |
} |
// next category id available |
$query = ' |
SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_id |
FROM '.CATEGORIES_TABLE.' |
;'; |
list($next_id) = mysql_fetch_array(pwg_query($query)); |
// retrieve file system sub-directories fulldirs |
$fs_fulldirs = get_fs_directories($basedir); |
// get_fs_directories doesn't include the base directory, so if it's a |
// category directory, we need to include it in our array |
if (isset($_POST['cat'])) |
{ |
array_push($fs_fulldirs, $basedir); |
} |
$inserts = array(); |
// new categories are the directories not present yet in the database |
foreach (array_diff($fs_fulldirs, array_keys($db_fulldirs)) as $fulldir) |
{ |
$dir = basename($fulldir); |
if (preg_match('/^[a-zA-Z0-9-_.]+$/', $dir)) |
{ |
$insert = array(); |
$insert{'id'} = $next_id++; |
$insert{'dir'} = $dir; |
$insert{'name'} = str_replace('_', ' ', $dir); |
$insert{'site_id'} = 1; |
$insert{'commentable'} = $conf['newcat_default_commentable']; |
$insert{'uploadable'} = $conf['newcat_default_uploadable']; |
$insert{'status'} = $conf{'newcat_default_status'}; |
$insert{'visible'} = $conf{'newcat_default_visible'}; |
if (isset($db_fulldirs[dirname($fulldir)])) |
{ |
$parent = $db_fulldirs[dirname($fulldir)]; |
$insert{'id_uppercat'} = $parent; |
$insert{'uppercats'} = |
$db_categories[$parent]['uppercats'].','.$insert{'id'}; |
$insert{'rank'} = $next_rank[$parent]++; |
$insert{'global_rank'} = |
$db_categories[$parent]['global_rank'].'.'.$insert{'rank'}; |
if ('private' == $db_categories[$parent]['status']) |
{ |
$insert{'status'} = 'private'; |
} |
if ('false' == $db_categories[$parent]['visible']) |
{ |
$insert{'visible'} = 'false'; |
} |
} |
else |
{ |
$insert{'uppercats'} = $insert{'id'}; |
$insert{'rank'} = $next_rank['NULL']++; |
$insert{'global_rank'} = $insert{'rank'}; |
} |
array_push($inserts, $insert); |
array_push($infos, array('path' => $fulldir, |
'info' => $lang['update_research_added'])); |
// add the new category to $db_categories and $db_fulldirs array |
$db_categories[$insert{'id'}] = |
array( |
'id' => $insert{'id'}, |
'status' => $insert{'status'}, |
'visible' => $insert{'visible'}, |
'uppercats' => $insert{'uppercats'}, |
'global_rank' => $insert{'global_rank'} |
); |
$db_fulldirs[$fulldir] = $insert{'id'}; |
$next_rank[$insert{'id'}] = 1; |
} |
else |
{ |
array_push($errors, array('path' => $fulldir, 'type' => 'PWG-UPDATE-1')); |
} |
} |
if (count($inserts) > 0) |
{ |
if (!$simulate) |
{ |
$dbfields = array( |
'id','dir','name','site_id','id_uppercat','uppercats','commentable', |
'uploadable','visible','status','rank','global_rank' |
); |
mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); |
} |
$counts['new_categories'] = count($inserts); |
} |
// to delete categories |
$to_delete = array(); |
foreach (array_diff(array_keys($db_fulldirs), $fs_fulldirs) as $fulldir) |
{ |
array_push($to_delete, $db_fulldirs[$fulldir]); |
unset($db_fulldirs[$fulldir]); |
array_push($infos, array('path' => $fulldir, |
'info' => $lang['update_research_deleted'])); |
} |
if (count($to_delete) > 0) |
{ |
if (!$simulate) |
{ |
delete_categories($to_delete); |
} |
$counts['del_categories'] = count($to_delete); |
} |
echo '<!-- scanning dirs : '; |
echo get_elapsed_time($start, get_moment()); |
echo ' -->'."\n"; |
} |
// +-----------------------------------------------------------------------+ |
// | files / elements | |
// +-----------------------------------------------------------------------+ |
if (isset($_POST['submit']) and $_POST['sync'] == 'files') |
{ |
$start_files = get_moment(); |
$start= $start_files; |
$fs = get_fs($basedir); |
echo '<!-- get_fs : '.get_elapsed_time($start, get_moment()).' -->'."\n"; |
$cat_ids = array_diff(array_keys($db_categories), $to_delete); |
$db_elements = array(); |
$db_unvalidated = array(); |
if (count($cat_ids) > 0) |
{ |
$query = ' |
SELECT id, path |
FROM '.IMAGES_TABLE.' |
WHERE storage_category_id IN ( |
'.wordwrap(implode(', ', $cat_ids), 80, "\n").') |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$db_elements[$row['id']] = $row['path']; |
} |
// searching the unvalidated waiting elements (they must not be taken into |
// account) |
$query = ' |
SELECT file,storage_category_id |
FROM '.WAITING_TABLE.' |
WHERE storage_category_id IN ( |
'.wordwrap(implode(', ', $cat_ids), 80, "\n").') |
AND validated = \'false\' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push( |
$db_unvalidated, |
array_search($row['storage_category_id'], |
$db_fulldirs).'/'.$row['file'] |
); |
} |
} |
// next element id available |
$query = ' |
SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id |
FROM '.IMAGES_TABLE.' |
;'; |
list($next_element_id) = mysql_fetch_array(pwg_query($query)); |
$start = get_moment(); |
// because isset is one hundred time faster than in_array |
$fs['thumbnails'] = array_flip($fs['thumbnails']); |
$fs['representatives'] = array_flip($fs['representatives']); |
$inserts = array(); |
$insert_links = array(); |
foreach (array_diff($fs['elements'], $db_elements, $db_unvalidated) as $path) |
{ |
$insert = array(); |
// storage category must exist |
$dirname = dirname($path); |
if (!isset($db_fulldirs[$dirname])) |
{ |
continue; |
} |
$filename = basename($path); |
if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename)) |
{ |
array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-1')); |
continue; |
} |
// searching the thumbnail |
$filename_wo_ext = get_filename_wo_extension($filename); |
$tn_ext = ''; |
$base_test = $dirname.'/thumbnail/'; |
$base_test.= $conf['prefix_thumbnail'].$filename_wo_ext.'.'; |
foreach ($conf['picture_ext'] as $ext) |
{ |
$test = $base_test.$ext; |
if (isset($fs['thumbnails'][$test])) |
{ |
$tn_ext = $ext; |
break; |
} |
} |
// 2 cases : the element is a picture or not. Indeed, for a picture |
// thumbnail is mandatory and for non picture element, thumbnail and |
// representative are optionnal |
if (in_array(get_extension($filename), $conf['picture_ext'])) |
{ |
// if we found a thumnbnail corresponding to our picture... |
if ($tn_ext != '') |
{ |
$insert{'id'} = $next_element_id++; |
$insert{'file'} = $filename; |
$insert{'storage_category_id'} = $db_fulldirs[$dirname]; |
$insert{'date_available'} = CURRENT_DATE; |
$insert{'tn_ext'} = $tn_ext; |
$insert{'path'} = $path; |
array_push($inserts, $insert); |
array_push($insert_links, |
array('image_id' => $insert{'id'}, |
'category_id' => $insert{'storage_category_id'})); |
array_push($infos, array('path' => $insert{'path'}, |
'info' => $lang['update_research_added'])); |
} |
else |
{ |
array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-2')); |
} |
} |
else |
{ |
// searching a representative |
$representative_ext = ''; |
$base_test = $dirname.'/pwg_representative/'.$filename_wo_ext.'.'; |
foreach ($conf['picture_ext'] as $ext) |
{ |
$test = $base_test.$ext; |
if (isset($fs['representatives'][$test])) |
{ |
$representative_ext = $ext; |
break; |
} |
} |
$insert{'id'} = $next_element_id++; |
$insert{'file'} = $filename; |
$insert{'storage_category_id'} = $db_fulldirs[$dirname]; |
$insert{'date_available'} = CURRENT_DATE; |
$insert{'path'} = $path; |
if ($tn_ext != '') |
{ |
$insert{'tn_ext'} = $tn_ext; |
} |
if ($representative_ext != '') |
{ |
$insert{'representative_ext'} = $representative_ext; |
} |
array_push($inserts, $insert); |
array_push($insert_links, |
array('image_id' => $insert{'id'}, |
'category_id' => $insert{'storage_category_id'})); |
array_push($infos, array('path' => $insert{'path'}, |
'info' => $lang['update_research_added'])); |
} |
} |
if (count($inserts) > 0) |
{ |
if (!$simulate) |
{ |
// inserts all new elements |
$dbfields = array( |
'id','file','storage_category_id','date_available','tn_ext' |
,'representative_ext','path' |
); |
mass_inserts(IMAGES_TABLE, $dbfields, $inserts); |
// insert all links between new elements and their storage category |
$dbfields = array('image_id','category_id'); |
mass_inserts(IMAGE_CATEGORY_TABLE, $dbfields, $insert_links); |
} |
$counts['new_elements'] = count($inserts); |
} |
// delete elements that are in database but not in the filesystem |
$to_delete_elements = array(); |
foreach (array_diff($db_elements, $fs['elements']) as $path) |
{ |
array_push($to_delete_elements, array_search($path, $db_elements)); |
array_push($infos, array('path' => $path, |
'info' => $lang['update_research_deleted'])); |
} |
if (count($to_delete_elements) > 0) |
{ |
if (!$simulate) |
{ |
delete_elements($to_delete_elements); |
} |
$counts['del_elements'] = count($to_delete_elements); |
} |
echo '<!-- scanning files : '; |
echo get_elapsed_time($start_files, get_moment()); |
echo ' -->'."\n"; |
// retrieving informations given by uploaders |
if (!$simulate) |
{ |
$query = ' |
SELECT id,file,storage_category_id,infos |
FROM '.WAITING_TABLE.' |
WHERE storage_category_id IN ( |
'.wordwrap(implode(', ', $cat_ids), 80, "\n").') |
AND validated = \'true\' |
;'; |
$result = pwg_query($query); |
$datas = array(); |
$fields = |
array( |
'primary' => array('id'), |
'update' => array('date_creation', 'author', 'name', 'comment') |
); |
$waiting_to_delete = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$data = array(); |
$query = ' |
SELECT id |
FROM '.IMAGES_TABLE.' |
WHERE storage_category_id = \''.$row['storage_category_id'].'\' |
AND file = \''.$row['file'].'\' |
;'; |
list($data['id']) = mysql_fetch_array(pwg_query($query)); |
foreach ($fields['update'] as $field) |
{ |
$data[$field] = getAttribute($row['infos'], $field); |
} |
array_push($datas, $data); |
array_push($waiting_to_delete, $row['id']); |
} |
if (count($datas) > 0) |
{ |
mass_updates(IMAGES_TABLE, $fields, $datas); |
// delete now useless waiting elements |
$query = ' |
DELETE |
FROM '.WAITING_TABLE.' |
WHERE id IN ('.implode(',', $waiting_to_delete).') |
;'; |
pwg_query($query); |
} |
} |
} |
// +-----------------------------------------------------------------------+ |
// | template initialization | |
// +-----------------------------------------------------------------------+ |
$template->set_filenames(array('update'=>'admin/update.tpl')); |
$result_title = ''; |
if (isset($simulate) and $simulate) |
{ |
$result_title.= $lang['update_simulation_title'].' '; |
} |
$result_title.= $lang['update_part_research']; |
// used_metadata string is displayed to inform admin which metadata will be |
// used from files for synchronization |
$used_metadata = $lang['metadata_basic'].' (filesize, width, height)'; |
if ($conf['use_exif']) |
{ |
$used_metadata.= ', '.$lang['metadata_exif'].' (date_creation)'; |
} |
if ($conf['use_iptc']) |
{ |
$used_metadata.= ', '.$lang['metadata_iptc']; |
$used_metadata.= '('; |
$used_metadata.= implode(', ', array_keys($conf['use_iptc_mapping'])); |
$used_metadata.= ')'; |
} |
$template->assign_vars( |
array( |
'L_SUBMIT'=>$lang['submit'], |
'L_RESET'=>$lang['reset'], |
'L_UPDATE_TITLE'=>$lang['update_default_title'], |
'L_UPDATE_SYNC_FILES'=>$lang['update_sync_files'], |
'L_UPDATE_SYNC_DIRS'=>$lang['update_sync_dirs'], |
'L_UPDATE_SYNC_ALL'=>$lang['update_sync_all'], |
'L_UPDATE_SYNC_METADATA'=>$lang['update_sync_metadata'], |
'L_UPDATE_SYNC_METADATA_NEW'=>$lang['update_sync_metadata_new'], |
'L_UPDATE_SYNC_METADATA_ALL'=>$lang['update_sync_metadata_all'], |
'L_UPDATE_CATS_SUBSET'=>$lang['update_cats_subset'], |
'L_RESULT_UPDATE'=>$result_title, |
'L_NB_NEW_ELEMENTS'=>$lang['update_nb_new_elements'], |
'L_NB_NEW_CATEGORIES'=>$lang['update_nb_new_categories'], |
'L_NB_DEL_ELEMENTS'=>$lang['update_nb_del_elements'], |
'L_NB_DEL_CATEGORIES'=>$lang['update_nb_del_categories'], |
'L_UPDATE_NB_ERRORS'=>$lang['update_nb_errors'], |
'L_SEARCH_SUBCATS_INCLUDED'=>$lang['search_subcats_included'], |
'L_UPDATE_WRONG_DIRNAME_INFO'=>$lang['update_wrong_dirname_info'], |
'L_UPDATE_MISSING_TN_INFO'=>$lang['update_missing_tn_info'], |
'PICTURE_EXT_LIST'=>implode(',', $conf['picture_ext']), |
'L_UPDATE_ERROR_LIST_TITLE'=>$lang['update_error_list_title'], |
'L_UPDATE_ERRORS_CAPTION'=>$lang['update_errors_caption'], |
'L_UPDATE_DISPLAY_INFO'=>$lang['update_display_info'], |
'L_UPDATE_SIMULATE'=>$lang['update_simulate'], |
'L_UPDATE_INFOS_TITLE'=>$lang['update_infos_title'], |
'L_RESULT_METADATA'=>$lang['update_result_metadata'], |
'L_ELEMENTS_METADATA_SYNC'=>$lang['update_elements_metadata_sync'], |
'L_USED_METADATA'=>$lang['update_used_metadata'], |
'METADATA_LIST' => $used_metadata |
)); |
// +-----------------------------------------------------------------------+ |
// | introduction : choices | |
// +-----------------------------------------------------------------------+ |
if (!isset($_POST['submit']) or (isset($simulate) and $simulate)) |
{ |
$template->assign_block_vars('introduction', array()); |
if (isset($simulate) and $simulate) |
{ |
switch ($_POST['sync']) |
{ |
case 'dirs' : |
{ |
$template->assign_vars( |
array('SYNC_DIRS_CHECKED'=>'checked="checked"')); |
break; |
} |
case 'files' : |
{ |
$template->assign_vars( |
array('SYNC_ALL_CHECKED'=>'checked="checked"')); |
break; |
} |
} |
if (isset($_POST['display_info']) and $_POST['display_info'] == 1) |
{ |
$template->assign_vars( |
array('DISPLAY_INFO_CHECKED'=>'checked="checked"')); |
} |
if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1) |
{ |
$template->assign_vars( |
array('SUBCATS_INCLUDED_CHECKED'=>'checked="checked"')); |
} |
if (isset($_POST['cat']) and is_numeric($_POST['cat'])) |
{ |
$cat_selected = array($_POST['cat']); |
} |
else |
{ |
$cat_selected = array(); |
} |
} |
else |
{ |
$template->assign_vars( |
array('SYNC_DIRS_CHECKED' => 'checked="checked"', |
'SUBCATS_INCLUDED_CHECKED'=>'checked="checked"')); |
$cat_selected = array(); |
} |
$query = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE site_id = 1 |
;'; |
display_select_cat_wrapper($query, |
$cat_selected, |
'introduction.category_option', |
false); |
} |
// +-----------------------------------------------------------------------+ |
// | synchronize files | |
// +-----------------------------------------------------------------------+ |
if (isset($_POST['submit']) |
and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')) |
{ |
$template->assign_block_vars( |
'update', |
array( |
'NB_NEW_CATEGORIES'=>$counts['new_categories'], |
'NB_DEL_CATEGORIES'=>$counts['del_categories'], |
'NB_NEW_ELEMENTS'=>$counts['new_elements'], |
'NB_DEL_ELEMENTS'=>$counts['del_elements'], |
'NB_ERRORS'=>count($errors), |
)); |
if (count($errors) > 0) |
{ |
$template->assign_block_vars('update.errors', array()); |
foreach ($errors as $error) |
{ |
$template->assign_block_vars( |
'update.errors.error', |
array( |
'ELEMENT' => $error['path'], |
'LABEL' => $error['type'].' ('.$error_labels[$error['type']].')' |
)); |
} |
} |
if (count($infos) > 0 |
and isset($_POST['display_info']) |
and $_POST['display_info'] == 1) |
{ |
$template->assign_block_vars('update.infos', array()); |
foreach ($infos as $info) |
{ |
$template->assign_block_vars( |
'update.infos.info', |
array( |
'ELEMENT' => $info['path'], |
'LABEL' => $info['info'] |
)); |
} |
} |
if (!$simulate) |
{ |
$start = get_moment(); |
update_category('all'); |
echo '<!-- update_category(all) : '; |
echo get_elapsed_time($start,get_moment()); |
echo ' -->'."\n"; |
$start = get_moment(); |
ordering(); |
update_global_rank(); |
echo '<!-- ordering categories : '; |
echo get_elapsed_time($start, get_moment()); |
echo ' -->'."\n"; |
} |
} |
// +-----------------------------------------------------------------------+ |
// | synchronize metadata | |
// +-----------------------------------------------------------------------+ |
else if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync'])) |
{ |
// sync only never synchronized files ? |
if ($_POST['sync'] == 'metadata_new') |
{ |
$opts['only_new'] = true; |
} |
else |
{ |
$opts['only_new'] = false; |
} |
$opts['category_id'] = ''; |
$opts['recursive'] = true; |
if (isset($_POST['cat'])) |
{ |
$opts['category_id'] = $_POST['cat']; |
// recursive ? |
if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1) |
{ |
$opts['recursive'] = false; |
} |
} |
$start = get_moment(); |
$files = get_filelist($opts['category_id'], |
$opts['recursive'], |
$opts['only_new']); |
echo '<!-- get_filelist : '; |
echo get_elapsed_time($start, get_moment()); |
echo ' -->'."\n"; |
$start = get_moment(); |
update_metadata($files); |
echo '<!-- metadata update : '; |
echo get_elapsed_time($start, get_moment()); |
echo ' -->'."\n"; |
$template->assign_block_vars( |
'metadata_result', |
array( |
'NB_ELEMENTS' => count($files), |
)); |
} |
// +-----------------------------------------------------------------------+ |
// | sending html code | |
// +-----------------------------------------------------------------------+ |
$template->assign_var_from_handle('ADMIN_CONTENT', 'update'); |
?> |
/web/test/gallery/phpwebgallery/admin/user_perm.php |
---|
0,0 → 1,170 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: user_perm.php,v $ |
// | last update : $Date: 2005/01/19 23:36:43 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.18 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if (!defined('IN_ADMIN')) |
{ |
die('Hacking attempt!'); |
} |
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
$userdata = array(); |
if (isset($_POST['submituser'])) |
{ |
$userdata = getuserdata($_POST['username']); |
} |
else if (isset($_GET['user_id'])) |
{ |
$userdata = getuserdata(intval($_GET['user_id'])); |
} |
else if (isset($_POST['falsify']) |
and isset($_POST['cat_true']) |
and count($_POST['cat_true']) > 0) |
{ |
$userdata = getuserdata(intval($_POST['userid'])); |
// if you forbid access to a category, all sub-categories become |
// automatically forbidden |
$subcats = get_subcat_ids($_POST['cat_true']); |
$query = ' |
DELETE FROM '.USER_ACCESS_TABLE.' |
WHERE user_id = '.$userdata['id'].' |
AND cat_id IN ('.implode(',', $subcats).') |
;'; |
pwg_query($query); |
} |
else if (isset($_POST['trueify']) |
and isset($_POST['cat_false']) |
and count($_POST['cat_false']) > 0) |
{ |
$userdata = getuserdata(intval($_POST['userid'])); |
$uppercats = get_uppercat_ids($_POST['cat_false']); |
$private_uppercats = array(); |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE.' |
WHERE id IN ('.implode(',', $uppercats).') |
AND status = \'private\' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($private_uppercats, $row['id']); |
} |
// retrying to authorize a category which is already authorized may cause |
// an error (in SQL statement), so we need to know which categories are |
// accesible |
$authorized_ids = array(); |
$query = ' |
SELECT cat_id |
FROM '.USER_ACCESS_TABLE.' |
WHERE user_id = '.$userdata['id'].' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($authorized_ids, $row['cat_id']); |
} |
$inserts = array(); |
$to_autorize_ids = array_diff($private_uppercats, $authorized_ids); |
foreach ($to_autorize_ids as $to_autorize_id) |
{ |
array_push($inserts, array('user_id' => $userdata['id'], |
'cat_id' => $to_autorize_id)); |
} |
mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts); |
} |
//----------------------------------------------------- template initialization |
if (empty($userdata)) |
{ |
$template->set_filenames(array('user' => 'admin/user_perm.tpl')); |
$base_url = PHPWG_ROOT_PATH.'admin.php?page='; |
$template->assign_vars(array( |
'L_SELECT_USERNAME'=>$lang['Select_username'], |
'L_LOOKUP_USER'=>$lang['Look_up_user'], |
'L_FIND_USERNAME'=>$lang['Find_username'], |
'L_AUTH_USER'=>$lang['permuser_only_private'], |
'L_SUBMIT'=>$lang['submit'], |
'F_SEARCH_USER_ACTION' => add_session_id($base_url.'user_perm'), |
'U_SEARCH_USER' => add_session_id(PHPWG_ROOT_PATH.'admin/search.php') |
)); |
} |
else |
{ |
$template->set_filenames(array('user'=>'admin/cat_options.tpl')); |
$template->assign_vars( |
array( |
'L_RESET'=>$lang['reset'], |
'L_CAT_OPTIONS_TRUE'=>$lang['authorized'], |
'L_CAT_OPTIONS_FALSE'=>$lang['forbidden'], |
'L_CAT_OPTIONS_INFO'=>$lang['permuser_info'], |
'HIDDEN_NAME'=> 'userid', |
'HIDDEN_VALUE'=>$userdata['id'], |
'F_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=user_perm'), |
)); |
// only private categories are listed |
$query_true = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_ACCESS_TABLE.' ON cat_id = id |
WHERE status = \'private\' |
AND user_id = '.$userdata['id'].' |
;'; |
display_select_cat_wrapper($query_true,array(),'category_option_true'); |
$result = pwg_query($query_true); |
$authorized_ids = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($authorized_ids, $row['id']); |
} |
$query_false = ' |
SELECT id,name,uppercats,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE status = \'private\''; |
if (count($authorized_ids) > 0) |
{ |
$query_false.= ' |
AND id NOT IN ('.implode(',', $authorized_ids).')'; |
} |
$query_false.= ' |
;'; |
display_select_cat_wrapper($query_false,array(),'category_option_false'); |
} |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'user'); |
?> |
/web/test/gallery/phpwebgallery/admin/waiting.php |
---|
0,0 → 1,149 |
<?php |
// +-----------------------------------------------------------------------+ |
// | PhpWebGallery - a PHP based picture gallery | |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
// +-----------------------------------------------------------------------+ |
// | branch : BSF (Best So Far) |
// | file : $RCSfile: waiting.php,v $ |
// | last update : $Date: 2005/01/16 17:31:18 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.18 $ |
// +-----------------------------------------------------------------------+ |
// | This program is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation | |
// | | |
// | This program 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 | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with this program; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
// | USA. | |
// +-----------------------------------------------------------------------+ |
if( !defined("PHPWG_ROOT_PATH") ) |
{ |
die ("Hacking attempt!"); |
} |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
//--------------------------------------------------------------------- updates |
if ( isset( $_POST['submit'] ) ) |
{ |
$query = 'SELECT * FROM '.WAITING_TABLE; |
$query.= " WHERE validated = 'false';"; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$key = 'validate-'.$row['id']; |
if ( isset( $_POST[$key] ) ) |
{ |
if ( $_POST[$key] == 'true' ) |
{ |
// The uploaded element was validated, we have to set the |
// "validated" field to "true" |
$query = 'UPDATE '.WAITING_TABLE; |
$query.= " SET validated = 'true'"; |
$query.= ' WHERE id = '.$row['id']; |
$query.= ';'; |
pwg_query( $query ); |
} |
else |
{ |
// The uploaded element was refused, we have to delete its reference |
// in the database and to delete the element as well. |
$query = 'DELETE FROM '.WAITING_TABLE; |
$query.= ' WHERE id = '.$row['id']; |
$query.= ';'; |
pwg_query( $query ); |
// deletion of the associated files |
$dir = get_complete_dir( $row['storage_category_id'] ); |
unlink( $dir.$row['file'] ); |
if (isset($row['tn_ext']) and $row['tn_ext'] != '' ) |
{ |
$thumbnail = $conf['prefix_thumbnail']; |
$thumbnail.= get_filename_wo_extension( $row['file'] ); |
$thumbnail.= '.'.$row['tn_ext']; |
$url = $dir.'thumbnail/'.$thumbnail; |
unlink( $url ); |
} |
} |
} |
} |
} |
//----------------------------------------------------- template initialization |
$template->set_filenames(array('waiting'=>'admin/waiting.tpl')); |
$template->assign_vars(array( |
'L_WAITING_CONFIRMATION'=>$lang['waiting_update'], |
'L_AUTHOR'=>$lang['author'], |
'L_THUMBNAIL'=>$lang['thumbnail'], |
'L_DATE'=>$lang['date'], |
'L_FILE'=>$lang['file'], |
'L_CATEGORY'=>$lang['category'], |
'L_SUBMIT'=>$lang['submit'], |
'L_RESET'=>$lang['reset'], |
'L_DELETE'=>$lang['delete'], |
'F_ACTION'=>add_session_id(str_replace( '&', '&', $_SERVER['REQUEST_URI'] )) |
)); |
//-------------------------------------------------------- confirmation message |
if (isset($_POST['submit'])) |
{ |
$template->assign_block_vars('confirmation' ,array()); |
} |
//---------------------------------------------------------------- form display |
$cat_names = array(); |
$query = 'SELECT * FROM '.WAITING_TABLE; |
$query.= " WHERE validated = 'false'"; |
$query.= ' ORDER BY storage_category_id'; |
$query.= ';'; |
$result = pwg_query( $query ); |
$i = 0; |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
if ( !isset( $cat_names[$row['storage_category_id']] ) ) |
{ |
$cat = get_cat_info( $row['storage_category_id'] ); |
$cat_names[$row['storage_category_id']] = array(); |
$cat_names[$row['storage_category_id']]['dir'] = |
PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] ); |
$cat_names[$row['storage_category_id']]['display_name'] = |
get_cat_display_name($cat['name']); |
} |
$preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file']; |
$class='row1'; |
if ( $i++ % 2== 0 ) $class='row2'; |
$template->assign_block_vars('picture' ,array( |
'WAITING_CLASS'=>$class, |
'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'], |
'ID_IMG'=>$row['id'], |
'DATE_IMG'=>format_date( $row['date'], 'unix', true ), |
'FILE_IMG'=>$row['file'], |
'PREVIEW_URL_IMG'=>$preview_url, |
'UPLOAD_EMAIL'=>$row['mail_address'], |
'UPLOAD_USERNAME'=>$row['username'] |
)); |
// is there an existing associated thumnail ? |
if ( !empty( $row['tn_ext'] )) |
{ |
$thumbnail = $conf['prefix_thumbnail']; |
$thumbnail.= get_filename_wo_extension( $row['file'] ); |
$thumbnail.= '.'.$row['tn_ext']; |
$url = $cat_names[$row['storage_category_id']]['dir']; |
$url.= 'thumbnail/'.$thumbnail; |
$template->assign_block_vars('picture.thumbnail' ,array( |
'PREVIEW_URL_TN_IMG'=>$url, |
'FILE_TN_IMG'=>$thumbnail |
)); |
} |
} |
//----------------------------------------------------------- sending html code |
$template->assign_var_from_handle('ADMIN_CONTENT', 'waiting'); |
?> |