/web/test/gallery/phpwebgallery/include/.cvsignore |
---|
0,0 → 1,0 |
mysql.inc.php |
/web/test/gallery/phpwebgallery/include/_vti_cnf/category_calendar.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|02 May 2005 20:59:48 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|02 May 2005 20:59:48 -0000 |
vti_cacheddtm:TX|02 May 2005 20:59:48 -0000 |
vti_filesize:IR|13945 |
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/include/_vti_cnf/category_default.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|4678 |
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/include/_vti_cnf/category_recent_cats.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|17 Jan 2005 20:49:48 -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:49:48 -0000 |
vti_cacheddtm:TX|17 Jan 2005 20:49:48 -0000 |
vti_filesize:IR|3922 |
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/include/_vti_cnf/category_subcats.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|4153 |
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/include/_vti_cnf/common.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|08 Jan 2005 22:32:26 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|08 Jan 2005 22:32:26 -0000 |
vti_cacheddtm:TX|08 Jan 2005 22:32:26 -0000 |
vti_filesize:IR|4839 |
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/include/_vti_cnf/config.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|01 May 2005 07:47:50 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|01 May 2005 07:47:50 -0000 |
vti_cacheddtm:TX|01 May 2005 07:47:50 -0000 |
vti_filesize:IR|8287 |
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/include/_vti_cnf/constants.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|14 May 2005 13:39:00 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|14 May 2005 13:39:00 -0000 |
vti_cacheddtm:TX|14 May 2005 13:39:00 -0000 |
vti_filesize:IR|3094 |
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/include/_vti_cnf/functions.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|02 May 2005 20:44:28 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|02 May 2005 20:44:28 -0000 |
vti_cacheddtm:TX|02 May 2005 20:44:28 -0000 |
vti_filesize:IR|17885 |
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/include/_vti_cnf/functions_category.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|02 May 2005 20:59:48 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|02 May 2005 20:59:48 -0000 |
vti_cacheddtm:TX|02 May 2005 20:59:48 -0000 |
vti_filesize:IR|25575 |
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/include/_vti_cnf/functions_group.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|4211 |
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/include/_vti_cnf/functions_html.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|07 Jan 2005 23:18:40 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|07 Jan 2005 23:18:40 -0000 |
vti_cacheddtm:TX|07 Jan 2005 23:18:40 -0000 |
vti_filesize:IR|12289 |
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/include/_vti_cnf/functions_metadata.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|3126 |
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/include/_vti_cnf/functions_session.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|4693 |
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/include/_vti_cnf/functions_user.inc.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|19 Jan 2005 22:34:42 -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:34:42 -0000 |
vti_cacheddtm:TX|19 Jan 2005 22:34:42 -0000 |
vti_filesize:IR|10299 |
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/include/_vti_cnf/functions_xml.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|4829 |
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/include/_vti_cnf/index.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|1893 |
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/include/_vti_cnf/mysql.inc.php |
---|
0,0 → 1,15 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|31 Jul 2005 20:23:37 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|14 May 2005 13:51:26 -0000 |
vti_backlinkinfo:VX| |
vti_nexttolasttimemodified:TW|14 May 2005 13:51:26 -0000 |
vti_cacheddtm:TX|31 Jul 2005 20:23:37 -0000 |
vti_filesize:IR|187 |
vti_cachedneedsrewrite:BR|false |
vti_cachedhasbots:BR|false |
vti_cachedhastheme:BR|false |
vti_cachedhasborder:BR|false |
vti_charset:SR|windows-1250 |
/web/test/gallery/phpwebgallery/include/_vti_cnf/page_header.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|30 Jan 2005 21:16:32 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|30 Jan 2005 21:16:32 -0000 |
vti_cacheddtm:TX|30 Jan 2005 21:16:32 -0000 |
vti_filesize:IR|2460 |
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/include/_vti_cnf/page_tail.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|01 May 2005 07:47:50 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|01 May 2005 07:47:50 -0000 |
vti_cacheddtm:TX|01 May 2005 07:47:50 -0000 |
vti_filesize:IR|2770 |
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/include/_vti_cnf/scripts.js |
---|
0,0 → 1,6 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|01 Oct 2004 22:50:50 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_cacheddtm:TX|01 Oct 2004 22:50:50 -0000 |
vti_filesize:IR|622 |
vti_backlinkinfo:VX| |
/web/test/gallery/phpwebgallery/include/_vti_cnf/template.php |
---|
0,0 → 1,14 |
vti_encoding:SR|utf8-nl |
vti_timelastmodified:TR|12 Mar 2005 09:51:08 -0000 |
vti_extenderversion:SR|6.0.2.5516 |
vti_author:SR|KAKLIK\\Jakub |
vti_modifiedby:SR|KAKLIK\\Jakub |
vti_timecreated:TR|12 Mar 2005 09:51:08 -0000 |
vti_cacheddtm:TX|12 Mar 2005 09:51:08 -0000 |
vti_filesize:IR|17827 |
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/include/_vti_cnf/user.inc.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|5901 |
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/include/category_calendar.inc.php |
---|
0,0 → 1,434 |
<?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: category_calendar.inc.php,v $ |
// | last update : $Date: 2005/05/02 20:59:47 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.15.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. | |
// +-----------------------------------------------------------------------+ |
/** |
* This file is included by category.php to show thumbnails for the category |
* calendar |
* |
*/ |
// years of image availability |
$query = ' |
SELECT YEAR('.$conf['calendar_datefield'].') AS year, COUNT(id) AS count |
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' |
'.$page['where'].' |
AND id = image_id |
GROUP BY year |
;'; |
$result = pwg_query($query); |
$calendar_years = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$calendar_years[$row['year']] = $row['count']; |
} |
// if the year requested is not among the available years, we unset the |
// variable |
if (isset($page['calendar_year']) |
and !isset($calendar_years[$page['calendar_year']])) |
{ |
unset($page['calendar_year']); |
} |
// years navigation bar creation |
$years_nav_bar = ''; |
foreach ($calendar_years as $calendar_year => $nb_picture_year) |
{ |
if (isset($page['calendar_year']) |
and $calendar_year == $page['calendar_year']) |
{ |
$years_nav_bar.= ' <span class="dateSelected">'.$calendar_year.'</span>'; |
} |
else |
{ |
$url = PHPWG_ROOT_PATH.'category.php?cat=calendar'; |
$url.= '&year='.$calendar_year; |
$url = add_session_id($url); |
$years_nav_bar.= ' <a href="'.$url.'">'.$calendar_year.'</a>'; |
} |
} |
$template->assign_block_vars( |
'calendar', |
array('YEARS_NAV_BAR' => $years_nav_bar) |
); |
// months are calculated (to know which months are available, and how many |
// pictures per month we can find) only if a year is requested. |
if (isset($page['calendar_year'])) |
{ |
// creation of hash associating the number of the month in the year with |
// the number of picture for this month : $calendar_months |
$query = ' |
SELECT DISTINCT(MONTH('.$conf['calendar_datefield'].')) AS month |
, COUNT(id) AS count |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
'.$page['where'].' |
AND '.$conf['calendar_datefield'].' |
BETWEEN \''.$page['calendar_year'].'-1-1\' |
AND \''.$page['calendar_year'].'-12-31\' |
GROUP BY MONTH('.$conf['calendar_datefield'].') |
;'; |
$result = pwg_query($query); |
$calendar_months = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$calendar_months[$row['month']] = $row['count']; |
} |
// if a month is requested and is not among the available months, we unset |
// the requested month |
if (isset($page['calendar_month']) |
and !isset($calendar_months[$page['calendar_month']])) |
{ |
unset($page['calendar_month']); |
} |
// months navigation bar creation |
$months_nav_bar = ''; |
foreach ($calendar_months as $calendar_month => $nb_picture_month) |
{ |
if (isset($page['calendar_month']) |
and $calendar_month == $page['calendar_month']) |
{ |
$months_nav_bar.= ' <span class="dateSelected">'; |
$months_nav_bar.= $lang['month'][(int)$calendar_month]; |
$months_nav_bar.= '</span>'; |
} |
else |
{ |
$url = PHPWG_ROOT_PATH.'category.php?cat=calendar&month='; |
$url.= $page['calendar_year'].'.'.sprintf('%02s', $calendar_month); |
$months_nav_bar.= ' '; |
$months_nav_bar.= '<a href="'.add_session_id($url).'">'; |
$months_nav_bar.= $lang['month'][(int)$calendar_month]; |
$months_nav_bar.= '</a>'; |
} |
} |
$template->assign_block_vars( |
'calendar', |
array('MONTHS_NAV_BAR' => $months_nav_bar)); |
} |
/** |
* 4 sub-cases are possibles for the calendar category : |
* |
* 1. show years if no year is requested |
* 2. show months of the requested year if no month is requested |
* 3. show days of the {year,month} requested if no day requested |
* 4. show categories of the requested day (+ a special category gathering |
* all categories) |
*/ |
if (!isset($page['calendar_year'])) |
{ |
$nb_pics = count($calendar_years); |
} |
elseif (!isset($page['calendar_month'])) |
{ |
$nb_pics = count($calendar_months); |
} |
elseif (!isset($page['calendar_day'])) |
{ |
// creation of hash associating the number of the day in the month with |
// the number of picture for this day : $calendar_days |
$query = ' |
SELECT DISTINCT('.$conf['calendar_datefield'].') AS day, COUNT(id) AS count |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
'.$page['where'].' |
AND '.$conf['calendar_datefield'].' |
BETWEEN \''.$page['calendar_year'].'-'.$page['calendar_month'].'-1\' |
AND \''.$page['calendar_year'].'-'.$page['calendar_month'].'-31\' |
GROUP BY day |
;'; |
$result = pwg_query($query); |
$calendar_days = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
$calendar_days[$row['day']] = $row['count']; |
} |
$nb_pics = count($calendar_days); |
} |
elseif (isset($page['calendar_day'])) |
{ |
// $page['calendar_date'] is the concatenation of year-month-day. simplier |
// to use in SQ queries |
$page['calendar_date'] = $page['calendar_year']; |
$page['calendar_date'].= '-'.$page['calendar_month']; |
$page['calendar_date'].= '-'.$page['calendar_day']; |
$query = ' |
SELECT category_id AS category, COUNT(id) AS count |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
'.$page['where'].' |
AND '.$conf['calendar_datefield'].' = \''.$page['calendar_date'].'\' |
GROUP BY category_id |
;'; |
$result = pwg_query($query); |
$calendar_categories = array(); |
// special category 0 : gathering all available categories (0 cannot be a |
// oregular category identifier) |
$calendar_categories[0] = 0; |
while ($row = mysql_fetch_array($result)) |
{ |
$calendar_categories[$row['category']] = $row['count']; |
} |
// update the total number of pictures for this day |
$calendar_categories[0] = array_sum($calendar_categories); |
$nb_pics = count($calendar_categories); |
} |
// template thumbnail initialization |
if ($nb_pics > 0) |
{ |
$template->assign_block_vars('thumbnails', array()); |
// first line |
$template->assign_block_vars('thumbnails.line', array()); |
// current row displayed |
$row_number = 0; |
} |
if (!isset($page['calendar_year'])) |
{ |
// for each month of this year, display a random picture |
foreach ($calendar_years as $calendar_year => $nb_pics) |
{ |
$query = ' |
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
'.$page['where'].' |
AND '.$conf['calendar_datefield'].' |
BETWEEN \''.$calendar_year.'-1-1\' |
AND \''.$calendar_year.'-12-31\' |
ORDER BY RAND() |
LIMIT 0,1 |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
$name = $calendar_year.' ('.$nb_pics.')'; |
$thumbnail_title = $lang['calendar_picture_hint'].$name; |
$url_link = PHPWG_ROOT_PATH.'category.php?cat=calendar'; |
$url_link.= '&year='.$calendar_year; |
$template->assign_block_vars( |
'thumbnails.line.thumbnail', |
array( |
'IMAGE'=>$thumbnail_src, |
'IMAGE_ALT'=>$row['file'], |
'IMAGE_TITLE'=>$thumbnail_title, |
'IMAGE_NAME'=>$name, |
'U_IMG_LINK'=>add_session_id($url_link) |
) |
); |
// create a new line ? |
if (++$row_number == $user['nb_image_line']) |
{ |
$template->assign_block_vars('thumbnails.line', array()); |
$row_number = 0; |
} |
} |
} |
elseif (!isset($page['calendar_month'])) |
{ |
// for each month of this year, display a random picture |
foreach ($calendar_months as $calendar_month => $nb_pics) |
{ |
$query = ' |
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
'.$page['where'].' |
AND '.$conf['calendar_datefield'].' |
BETWEEN \''.$page['calendar_year'].'-'.$calendar_month.'-1\' |
AND \''.$page['calendar_year'].'-'.$calendar_month.'-31\' |
ORDER BY RAND() |
LIMIT 0,1 |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
$name = $lang['month'][$calendar_month]; |
$name.= ' '.$page['calendar_year']; |
$name.= ' ('.$nb_pics.')'; |
$thumbnail_title = $lang['calendar_picture_hint'].$name; |
$url_link = PHPWG_ROOT_PATH.'category.php?cat=calendar'; |
$url_link.= '&month='.$page['calendar_year'].'.'; |
if ($calendar_month < 10) |
{ |
// adding leading zero |
$url_link.= '0'; |
} |
$url_link.= $calendar_month; |
$template->assign_block_vars( |
'thumbnails.line.thumbnail', |
array( |
'IMAGE'=>$thumbnail_src, |
'IMAGE_ALT'=>$row['file'], |
'IMAGE_TITLE'=>$thumbnail_title, |
'IMAGE_NAME'=>$name, |
'U_IMG_LINK'=>add_session_id($url_link) |
) |
); |
// create a new line ? |
if (++$row_number == $user['nb_image_line']) |
{ |
$template->assign_block_vars('thumbnails.line', array()); |
$row_number = 0; |
} |
} |
} |
elseif (!isset($page['calendar_day'])) |
{ |
// for each day of the requested month, display a random picture |
foreach ($calendar_days as $calendar_day => $nb_pics) |
{ |
$query = ' |
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path |
, DAYOFWEEK(\''.$calendar_day.'\') AS dow |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id |
'.$page['where'].' |
AND '.$conf['calendar_datefield'].' = \''.$calendar_day.'\' |
ORDER BY RAND() |
LIMIT 0,1 |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
list($year,$month,$day) = explode('-', $calendar_day); |
$name = $lang['day'][$row['dow']-1]; |
$name.= ' '.$day; |
$name.= ' ('.$nb_pics.')'; |
$thumbnail_title = $lang['calendar_picture_hint'].$name; |
$url_link = PHPWG_ROOT_PATH.'category.php'; |
$url_link.= '?cat=calendar&day='.str_replace('-', '.', $calendar_day); |
$template->assign_block_vars( |
'thumbnails.line.thumbnail', |
array( |
'IMAGE'=>$thumbnail_src, |
'IMAGE_ALT'=>$row['file'], |
'IMAGE_TITLE'=>$thumbnail_title, |
'IMAGE_NAME'=>$name, |
'U_IMG_LINK'=>add_session_id($url_link) |
) |
); |
// create a new line ? |
if (++$row_number == $user['nb_image_line']) |
{ |
$template->assign_block_vars('thumbnails.line', array()); |
$row_number = 0; |
} |
} |
} |
elseif (isset($page['calendar_day'])) |
{ |
$old_level_separator = $conf['level_separator']; |
$conf['level_separator'] = '<br />'; |
// for each category of this day, display a random picture |
foreach ($calendar_categories as $calendar_category => $nb_pics) |
{ |
if ($calendar_category == 0) |
{ |
$name = '['.$lang['all_categories'].']'; |
} |
else |
{ |
$cat_infos = get_cat_info( $calendar_category ); |
$name = get_cat_display_name($cat_infos['name'],'',false); |
$name = '['.$name.']'; |
} |
$name.= ' ('.$nb_pics.')'; |
$query = ' |
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path |
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' |
'.$page['where'].' |
AND '.$conf['calendar_datefield'].' = \''.$page['calendar_date'].'\''; |
if ($calendar_category != 0) |
{ |
$query.= ' |
AND category_id = '.$calendar_category; |
} |
$query.= ' |
AND id = image_id |
ORDER BY RAND() |
LIMIT 0,1 |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
$thumbnail_title = $lang['calendar_picture_hint'].$name; |
$url_link = PHPWG_ROOT_PATH.'category.php?cat=search'; |
$url_link.= '&search='.$conf['calendar_datefield'].':'.$_GET['day']; |
if ($calendar_category != 0) |
{ |
$url_link.= '--cat:'.$calendar_category.'|AND'; |
} |
$template->assign_block_vars( |
'thumbnails.line.thumbnail', |
array( |
'IMAGE'=>$thumbnail_src, |
'IMAGE_ALT'=>$row['file'], |
'IMAGE_TITLE'=>$thumbnail_title, |
'IMAGE_NAME'=>$name, |
'U_IMG_LINK'=>add_session_id($url_link) |
) |
); |
$template->assign_block_vars('thumbnails.line.thumbnail.bullet',array()); |
// create a new line ? |
if (++$row_number == $user['nb_image_line']) |
{ |
$template->assign_block_vars('thumbnails.line', array()); |
$row_number = 0; |
} |
} |
$conf['level_separator'] = $old_level_separator; |
} |
?> |
/web/test/gallery/phpwebgallery/include/category_default.inc.php |
---|
0,0 → 1,140 |
<?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: category_default.inc.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.17 $ |
// +-----------------------------------------------------------------------+ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
/** |
* This file is included by category.php to show thumbnails for the default |
* case |
* |
*/ |
/** |
* $array_cat_directories is a cache hash associating category id with their |
* complete directory |
*/ |
$array_cat_directories = array(); |
$query = ' |
SELECT DISTINCT(id),path,file,date_available |
,tn_ext,name,filesize,storage_category_id,average_rate |
FROM '.IMAGES_TABLE.' AS i |
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id |
'.$page['where'].' |
'.$conf['order_by'].' |
LIMIT '.$page['start'].','.$page['nb_image_page'].' |
;'; |
//echo '<pre>'.$query.'</pre>'; |
$result = pwg_query($query); |
// template thumbnail initialization |
if ( mysql_num_rows($result) > 0 ) |
{ |
$template->assign_block_vars('thumbnails', array()); |
// first line |
$template->assign_block_vars('thumbnails.line', array()); |
// current row displayed |
$row_number = 0; |
} |
while ($row = mysql_fetch_array($result)) |
{ |
// name of the picture |
if (isset($row['name']) and $row['name'] != '') |
{ |
$name = $row['name']; |
} |
else |
{ |
$name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); |
} |
if ($page['cat'] == 'best_rated') |
{ |
$name = '('.$row['average_rate'].') '.$name; |
} |
if ($page['cat'] == 'search') |
{ |
$name = replace_search($name, $_GET['search']); |
} |
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); |
// message in title for the thumbnail |
$thumbnail_title = $row['file']; |
if (isset($row['filesize'])) |
{ |
$thumbnail_title .= ' : '.$row['filesize'].' KB'; |
} |
// url link on picture.php page |
$url_link = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat']; |
$url_link.= '&image_id='.$row['id']; |
if ($page['cat'] == 'search') |
{ |
$url_link.= '&search='.$_GET['search']; |
} |
else if ($page['cat'] == 'list') |
{ |
$url_link.= '&list='.$_GET['list']; |
} |
$template->assign_block_vars( |
'thumbnails.line.thumbnail', |
array( |
'IMAGE' => $thumbnail_url, |
'IMAGE_ALT' => $row['file'], |
'IMAGE_TITLE' => $thumbnail_title, |
'IMAGE_NAME' => $name, |
'IMAGE_TS' => get_icon($row['date_available']), |
'IMAGE_STYLE' => 'thumb_picture', |
'U_IMG_LINK' => add_session_id($url_link) |
) |
); |
if ($user['show_nb_comments'] |
and is_numeric($page['cat']) |
and $page['cat_commentable']) |
{ |
$query = ' |
SELECT COUNT(*) AS nb_comments |
FROM '.COMMENTS_TABLE.' |
WHERE image_id = '.$row['id'].' |
AND validated = \'true\' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$template->assign_block_vars( |
'thumbnails.line.thumbnail.nb_comments', |
array('NB_COMMENTS'=>$row['nb_comments'])); |
} |
// create a new line ? |
if (++$row_number == $user['nb_image_line']) |
{ |
$template->assign_block_vars('thumbnails.line', array()); |
$row_number = 0; |
} |
} |
?> |
/web/test/gallery/phpwebgallery/include/category_recent_cats.inc.php |
---|
0,0 → 1,96 |
<?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: category_recent_cats.inc.php,v $ |
// | last update : $Date: 2005/01/17 21:49:48 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.12 $ |
// +-----------------------------------------------------------------------+ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
/** |
* This file is included by category.php to show thumbnails for recent_cats |
* category |
* |
*/ |
// retrieving categories recently update, ie containing pictures added |
// recently. The calculated table field categories.date_last will be |
// easier to use |
$query = ' |
SELECT c.id AS category_id,uppercats,representative_picture_id,path,file,tn_ext |
FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGES_TABLE.' AS i |
ON i.id = c.representative_picture_id |
WHERE date_last > SUBDATE(CURRENT_DATE |
,INTERVAL '.$user['recent_period'].' DAY)'; |
if ( $user['forbidden_categories'] != '' ) |
{ |
$query.= ' |
AND c.id NOT IN ('.$user['forbidden_categories'].')'; |
} |
$query.= ' |
;'; |
$result = pwg_query( $query ); |
// template thumbnail initialization |
if (mysql_num_rows($result) > 0) |
{ |
$template->assign_block_vars('thumbnails', array()); |
// first line |
$template->assign_block_vars('thumbnails.line', array()); |
// current row displayed |
$row_number = 0; |
} |
$old_level_separator = $conf['level_separator']; |
$conf['level_separator'] = '<br />'; |
// for each category, we have to search a recent picture to display and |
// the name to display |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$name = get_cat_display_name_cache($row['uppercats'], '', false); |
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
$url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id']; |
$template->assign_block_vars( |
'thumbnails.line.thumbnail', |
array( |
'IMAGE' => $thumbnail_src, |
'IMAGE_ALT' => $row['file'], |
'IMAGE_TITLE' => $lang['hint_category'], |
'IMAGE_NAME' => '['.$name.']', |
'IMAGE_STYLE' => 'thumb_category', |
'U_IMG_LINK' => add_session_id($url_link) |
) |
); |
$template->assign_block_vars('thumbnails.line.thumbnail.bullet',array()); |
// create a new line ? |
if (++$row_number == $user['nb_image_line']) |
{ |
$template->assign_block_vars('thumbnails.line', array()); |
$row_number = 0; |
} |
} |
$conf['level_separator'] = $old_level_separator; |
?> |
/web/test/gallery/phpwebgallery/include/category_subcats.inc.php |
---|
0,0 → 1,119 |
<?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: category_subcats.inc.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.9 $ |
// +-----------------------------------------------------------------------+ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
/** |
* This file is included by category.php to show thumbnails for a category |
* that have only subcategories |
* |
*/ |
$query = ' |
SELECT id, name, date_last |
FROM '.CATEGORIES_TABLE.' |
WHERE id_uppercat '; |
if (!isset($page['cat']) or !is_numeric($page['cat'])) |
{ |
$query.= 'is NULL'; |
} |
else |
{ |
$query.= '= '.$page['cat']; |
} |
// we must not show pictures of a forbidden category |
if ($user['forbidden_categories'] != '') |
{ |
$query.= ' AND id NOT IN ('.$user['forbidden_categories'].')'; |
} |
$query.= ' |
ORDER BY rank |
;'; |
$result = pwg_query($query); |
// template thumbnail initialization |
if (mysql_num_rows($result) > 0) |
{ |
$template->assign_block_vars('thumbnails', array()); |
// first line |
$template->assign_block_vars('thumbnails.line', array()); |
// current row displayed |
$row_number = 0; |
} |
while ($row = mysql_fetch_array($result)) |
{ |
$query = ' |
SELECT path, tn_ext |
FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGES_TABLE.' AS i |
ON i.id = c.representative_picture_id |
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\''; |
// we must not show pictures of a forbidden category |
if ($user['forbidden_categories'] != '') |
{ |
$query.= ' |
AND c.id NOT IN ('.$user['forbidden_categories'].')'; |
} |
$query.= ' |
ORDER BY RAND() |
LIMIT 0,1 |
;'; |
$element_result = pwg_query($query); |
if (mysql_num_rows($element_result) == 0) |
{ |
continue; |
} |
$element_row = mysql_fetch_array($element_result); |
$thumbnail_link = get_thumbnail_src($element_row['path'], |
@$element_row['tn_ext']); |
$thumbnail_title = $lang['hint_category']; |
$url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['id']; |
$template->assign_block_vars( |
'thumbnails.line.thumbnail', |
array( |
'IMAGE' => $thumbnail_link, |
'IMAGE_ALT' => $row['name'], |
'IMAGE_TITLE' => $thumbnail_title, |
'IMAGE_NAME' => '['.$row['name'].']', |
'IMAGE_TS' => get_icon(@$row['date_last']), |
'IMAGE_STYLE' => 'thumb_category', |
'U_IMG_LINK' => add_session_id($url_link) |
) |
); |
$template->assign_block_vars('thumbnails.line.thumbnail.bullet',array()); |
// create a new line ? |
if (++$row_number == $user['nb_image_line']) |
{ |
$template->assign_block_vars('thumbnails.line', array()); |
$row_number = 0; |
} |
} |
?> |
/web/test/gallery/phpwebgallery/include/common.inc.php |
---|
0,0 → 1,166 |
<?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: common.inc.php,v $ |
// | last update : $Date: 2005/01/08 23:32:25 $ |
// | 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!'); |
} |
// determine the initial instant to indicate the generation time of this page |
$t1 = explode( ' ', microtime() ); |
$t2 = explode( '.', $t1[0] ); |
$t2 = $t1[1].'.'.$t2[1]; |
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime |
// |
// addslashes to vars if magic_quotes_gpc is off this is a security |
// precaution to prevent someone trying to break out of a SQL statement. |
// |
if( !get_magic_quotes_gpc() ) |
{ |
if( is_array( $_GET ) ) |
{ |
while( list($k, $v) = each($_GET) ) |
{ |
if( is_array($_GET[$k]) ) |
{ |
while( list($k2, $v2) = each($_GET[$k]) ) |
{ |
$_GET[$k][$k2] = addslashes($v2); |
} |
@reset($_GET[$k]); |
} |
else |
{ |
$_GET[$k] = addslashes($v); |
} |
} |
@reset($_GET); |
} |
if( is_array($_POST) ) |
{ |
while( list($k, $v) = each($_POST) ) |
{ |
if( is_array($_POST[$k]) ) |
{ |
while( list($k2, $v2) = each($_POST[$k]) ) |
{ |
$_POST[$k][$k2] = addslashes($v2); |
} |
@reset($_POST[$k]); |
} |
else |
{ |
$_POST[$k] = addslashes($v); |
} |
} |
@reset($_POST); |
} |
if( is_array($_COOKIE) ) |
{ |
while( list($k, $v) = each($_COOKIE) ) |
{ |
if( is_array($_COOKIE[$k]) ) |
{ |
while( list($k2, $v2) = each($_COOKIE[$k]) ) |
{ |
$_COOKIE[$k][$k2] = addslashes($v2); |
} |
@reset($_COOKIE[$k]); |
} |
else |
{ |
$_COOKIE[$k] = addslashes($v); |
} |
} |
@reset($_COOKIE); |
} |
} |
// |
// Define some basic configuration arrays this also prevents malicious |
// rewriting of language and otherarray values via URI params |
// |
$conf = array(); |
$page = array(); |
$user = array(); |
$lang = array(); |
include(PHPWG_ROOT_PATH .'include/mysql.inc.php'); |
if (!defined('PHPWG_INSTALLED')) |
{ |
header('Location: install.php'); |
exit; |
} |
include(PHPWG_ROOT_PATH . 'include/constants.php'); |
include(PHPWG_ROOT_PATH . 'include/config.inc.php'); |
include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); |
include(PHPWG_ROOT_PATH . 'include/template.php'); |
// Database connection |
mysql_connect( $cfgHote, $cfgUser, $cfgPassword ) |
or die ( "Could not connect to database server" ); |
mysql_select_db( $cfgBase ) |
or die ( "Could not connect to database" ); |
// |
// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR |
// since basic gallery information is not available |
// |
$query = ' |
SELECT param,value |
FROM '.CONFIG_TABLE.' |
;'; |
if (!($result = pwg_query($query))) |
{ |
die("Could not query config information"); |
} |
while ( $row =mysql_fetch_array( $result ) ) |
{ |
if ( isset( $row['value'] ) ) |
{ |
$conf[$row['param']] = $row['value']; |
} |
else |
{ |
$conf[$row['param']] = ''; |
} |
// If the field is true or false, the variable is transformed into a |
// boolean value. |
if ( $conf[$row['param']] == 'true' or $conf[$row['param']] == 'false' ) |
{ |
$conf[$row['param']] = get_boolean( $conf[$row['param']] ); |
} |
} |
include(PHPWG_ROOT_PATH.'include/user.inc.php'); |
?> |
/web/test/gallery/phpwebgallery/include/config.inc.php |
---|
0,0 → 1,198 |
<?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: config.inc.php,v $ |
// | last update : $Date: 2005/05/01 07:47:49 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.53.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. | |
// +-----------------------------------------------------------------------+ |
/** |
* configuration page |
* |
* Set configuration parameters that are not in the table config. In the |
* application, configuration parameters are considered in the same way |
* coming from config table or config.inc.php. |
* |
* Why having some parameters in config table and others in config.inc.php ? |
* Modifying config.inc.php is a "hard" task for low skilled users, they |
* need a GUI for this : admin/configuration. But only parameters that might |
* be modified by low skilled users are in config table, other parameters |
* are in config.inc.php |
*/ |
// order_by : how to change the order of display for images in a category ? |
// |
// There are several fields that can order the display : |
// |
// - date_available : the date of the adding to the gallery |
// - file : the name of the file |
// - id : element identifier |
// - date_creation : date of element creation |
// |
// Once you've chosen which field(s) to use for ordering, you must chose the |
// ascending or descending order for each field. examples : |
// |
// 1. $conf['order_by'] = " order by date_available desc, file asc"; |
// will order pictures by date_available descending & by filename ascending |
// |
// 2. $conf['order_by'] = " order by file asc"; |
// will only order pictures by file ascending without taking into account |
// the date_available |
$conf['order_by'] = ' ORDER BY date_available DESC, file ASC, id ASC'; |
// slideshow_period : waiting time in seconds before loading a new page |
// during automated slideshow |
$conf['slideshow_period'] = 4; |
// last_days : options for X last days to displays for comments |
$conf['last_days'] = array(1,2,3,10,30,365); |
// file_ext : file extensions (case sensitive) authorized |
$conf['file_ext'] = array('jpg','JPG','png','PNG','gif','GIF','mpg','zip', |
'avi','mp3','ogg'); |
// picture_ext : file extensions for picture file, must be a subset of |
// file_ext |
$conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF'); |
// top_number : number of element to display for "best rated" and "most |
// visited" categories |
$conf['top_number'] = 15; |
// anti-flood_time : number of seconds between 2 comments : 0 to disable |
$conf['anti-flood_time'] = 60; |
// show_iptc_mapping : is used for showing IPTC metadata on picture.php |
// page. For each key of the array, you need to have the same key in the |
// $lang array. For example, if my first key is 'iptc_keywords' (associated |
// to '2#025') then you need to have $lang['iptc_keywords'] set in |
// language/$user['language']/common.lang.php. If you don't have the lang |
// var set, the key will be simply displayed |
// |
// To know how to associated iptc_field with their meaning, use |
// tools/metadata.php |
$conf['show_iptc_mapping'] = array( |
'iptc_keywords' => '2#025', |
'iptc_caption_writer' => '2#122', |
'iptc_byline_title' => '2#085', |
'iptc_caption' => '2#120' |
); |
// use_iptc_mapping : in which IPTC fields will PhpWebGallery find image |
// information ? This setting is used during metadata synchronisation. It |
// associates a phpwebgallery_images column name to a IPTC key |
$conf['use_iptc_mapping'] = array( |
'keywords' => '2#025', |
'date_creation' => '2#055', |
'author' => '2#122', |
'name' => '2#005', |
'comment' => '2#120' |
); |
// show_exif_fields : in EXIF fields, you can choose to display fields in |
// sub-arrays, for example ['COMPUTED']['ApertureFNumber']. for this, add |
// 'COMPUTED;ApertureFNumber' in $conf['show_exif_fields'] |
// |
// The key displayed in picture.php will be $lang['exif_field_Make'] for |
// example and if it exists. For compound fields, only take into account the |
// last part : for key 'COMPUTED;ApertureFNumber', you need |
// $lang['exif_field_ApertureFNumber'] |
// |
// for PHP version newer than 4.1.2 : |
// $conf['show_exif_fields'] = array('CameraMake','CameraModel','DateTime'); |
// |
$conf['show_exif_fields'] = array('Make', |
'Model', |
'DateTime', |
'COMPUTED;ApertureFNumber'); |
// calendar_datefield : date field of table "images" used for calendar |
// catgory |
$conf['calendar_datefield'] = 'date_creation'; |
// rate : enable feature for rating elements |
$conf['rate'] = true; |
// remember_me_length : time of validity for "remember me" cookies, in |
// seconds. |
$conf['remember_me_length'] = 31536000; |
// session_length : time of validity for normal session, in seconds. |
$conf['session_length'] = 3600; |
// session_id_size : a session identifier is compound of alphanumeric |
// characters and is case sensitive. Each character is among 62 |
// possibilities. The number of possible sessions is |
// 62^$conf['session_id_size']. |
// |
// 62^5 = 916,132,832 |
// 62^10 = 839,299,365,868,340,224 |
// |
$conf['session_id_size'] = 10; |
// info_nb_elements_page : number of elements to display per page on |
// admin/infos_images |
$conf['info_nb_elements_page'] = 5; |
// show_queries : for debug purpose, show queries and execution times |
$conf['show_queries'] = false; |
// show_gt : display generation time at the bottom of each page |
$conf['show_gt'] = true; |
// newcat_default_commentable : at creation, must a category be commentable |
// or not ? |
$conf['newcat_default_commentable'] = 'true'; |
// newcat_default_uploadable : at creation, must a category be uploadable or |
// not ? |
$conf['newcat_default_uploadable'] = 'false'; |
// newcat_default_visible : at creation, must a category be visible or not ? |
// Warning : if the parent category is invisible, the category is |
// automatically create invisible. (invisible = locked) |
$conf['newcat_default_visible'] = 'true'; |
// newcat_default_status : at creation, must a category be public or private |
// ? Warning : if the parent category is private, the category is |
// automatically create private. |
$conf['newcat_default_status'] = 'public'; |
// level_separator : character string used for separating a category level |
// to the sub level. Suggestions : ' / ', ' » ', ' → ', ' - ', |
// ' >' |
$conf['level_separator'] = ' / '; |
// paginate_pages_around : on paginate navigation bar, how many pages |
// display before and after the current page ? |
$conf['paginate_pages_around'] = 2; |
// tn_width : default width for thumbnails creation |
$conf['tn_width'] = 128; |
// tn_height : default height for thumbnails creation |
$conf['tn_height'] = 96; |
// show_version : shall the version of PhpWebGallery be displayed at the |
// bottom of each page ? |
$conf['show_version'] = false; |
?> |
/web/test/gallery/phpwebgallery/include/constants.php |
---|
0,0 → 1,61 |
<?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: constants.php,v $ |
// | last update : $Date: 2005/05/14 13:39:00 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.20.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. | |
// +-----------------------------------------------------------------------+ |
// Default settings |
define('PHPWG_VERSION', '1.4.1'); |
define('PHPWG_URL', 'http://www.phpwebgallery.net'); |
define('PHPWG_FORUM_URL', 'http://forum.phpwebgallery.net'); |
// User level |
define('ANONYMOUS', 2); |
// Error codes |
define('GENERAL_MESSAGE', 200); |
define('GENERAL_ERROR', 202); |
define('CRITICAL_MESSAGE', 203); |
define('CRITICAL_ERROR', 204); |
// Table names |
define('CATEGORIES_TABLE', $prefixeTable.'categories'); |
define('COMMENTS_TABLE', $prefixeTable.'comments'); |
define('CONFIG_TABLE', $prefixeTable.'config'); |
define('FAVORITES_TABLE', $prefixeTable.'favorites'); |
define('GROUP_ACCESS_TABLE', $prefixeTable.'group_access'); |
define('GROUPS_TABLE', $prefixeTable.'groups'); |
define('HISTORY_TABLE', $prefixeTable.'history'); |
define('IMAGE_CATEGORY_TABLE', $prefixeTable.'image_category'); |
define('IMAGES_TABLE', $prefixeTable.'images'); |
define('SESSIONS_TABLE', $prefixeTable.'sessions'); |
define('SITES_TABLE', $prefixeTable.'sites'); |
define('USER_ACCESS_TABLE', $prefixeTable.'user_access'); |
define('USER_GROUP_TABLE', $prefixeTable.'user_group'); |
define('USERS_TABLE', $prefixeTable.'users'); |
define('WAITING_TABLE', $prefixeTable.'waiting'); |
define('IMAGE_METADATA_TABLE', $prefixeTable.'image_metadata'); |
define('RATE_TABLE', $prefixeTable.'rate'); |
define('USER_FORBIDDEN_TABLE', $prefixeTable.'user_forbidden'); |
?> |
/web/test/gallery/phpwebgallery/include/functions.inc.php |
---|
0,0 → 1,621 |
<?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.inc.php,v $ |
// | last update : $Date: 2005/05/02 20:44:27 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.55.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. | |
// +-----------------------------------------------------------------------+ |
include_once( PHPWG_ROOT_PATH .'include/functions_user.inc.php' ); |
include_once( PHPWG_ROOT_PATH .'include/functions_session.inc.php' ); |
include_once( PHPWG_ROOT_PATH .'include/functions_category.inc.php' ); |
include_once( PHPWG_ROOT_PATH .'include/functions_xml.inc.php' ); |
include_once( PHPWG_ROOT_PATH .'include/functions_group.inc.php' ); |
include_once( PHPWG_ROOT_PATH .'include/functions_html.inc.php' ); |
//----------------------------------------------------------- generic functions |
// get_boolean transforms a string to a boolean value. If the string is |
// "false" (case insensitive), then the boolean value false is returned. In |
// any other case, true is returned. |
function get_boolean( $string ) |
{ |
$boolean = true; |
if ( preg_match( '/^false$/i', $string ) ) |
{ |
$boolean = false; |
} |
return $boolean; |
} |
/** |
* returns boolean string 'true' or 'false' if the given var is boolean |
* |
* @param mixed $var |
* @return mixed |
*/ |
function boolean_to_string($var) |
{ |
if (is_bool($var)) |
{ |
if ($var) |
{ |
return 'true'; |
} |
else |
{ |
return 'false'; |
} |
} |
else |
{ |
return $var; |
} |
} |
// array_remove removes a value from the given array if the value existed in |
// this array. |
function array_remove( $array, $value ) |
{ |
$output = array(); |
foreach ( $array as $v ) { |
if ( $v != $value ) array_push( $output, $v ); |
} |
return $output; |
} |
// The function get_moment returns a float value coresponding to the number |
// of seconds since the unix epoch (1st January 1970) and the microseconds |
// are precised : e.g. 1052343429.89276600 |
function get_moment() |
{ |
$t1 = explode( ' ', microtime() ); |
$t2 = explode( '.', $t1[0] ); |
$t2 = $t1[1].'.'.$t2[1]; |
return $t2; |
} |
// The function get_elapsed_time returns the number of seconds (with 3 |
// decimals precision) between the start time and the end time given. |
function get_elapsed_time( $start, $end ) |
{ |
return number_format( $end - $start, 3, '.', ' ').' s'; |
} |
// - The replace_space function replaces space and '-' characters |
// by their HTML equivalent &nbsb; and − |
// - The function does not replace characters in HTML tags |
// - This function was created because IE5 does not respect the |
// CSS "white-space: nowrap;" property unless space and minus |
// characters are replaced like this function does. |
// - Example : |
// <div class="foo">My friend</div> |
// ( 01234567891111111111222222222233 ) |
// ( 0123456789012345678901 ) |
// becomes : |
// <div class="foo">My friend</div> |
function replace_space( $string ) |
{ |
//return $string; |
$return_string = ''; |
// $remaining is the rest of the string where to replace spaces characters |
$remaining = $string; |
// $start represents the position of the next '<' character |
// $end represents the position of the next '>' character |
$start = 0; |
$end = 0; |
$start = strpos ( $remaining, '<' ); // -> 0 |
$end = strpos ( $remaining, '>' ); // -> 16 |
// as long as a '<' and his friend '>' are found, we loop |
while ( is_numeric( $start ) and is_numeric( $end ) ) |
{ |
// $treatment is the part of the string to treat |
// In the first loop of our example, this variable is empty, but in the |
// second loop, it equals 'My friend' |
$treatment = substr ( $remaining, 0, $start ); |
// Replacement of ' ' by his equivalent ' ' |
$treatment = str_replace( ' ', ' ', $treatment ); |
$treatment = str_replace( '-', '−', $treatment ); |
// composing the string to return by adding the treated string and the |
// following HTML tag -> 'My friend</div>' |
$return_string.= $treatment.substr( $remaining, $start, $end-$start+1 ); |
// the remaining string is deplaced to the part after the '>' of this |
// loop |
$remaining = substr ( $remaining, $end + 1, strlen( $remaining ) ); |
$start = strpos ( $remaining, '<' ); |
$end = strpos ( $remaining, '>' ); |
} |
$treatment = str_replace( ' ', ' ', $remaining ); |
$treatment = str_replace( '-', '−', $treatment ); |
$return_string.= $treatment; |
return $return_string; |
} |
// get_extension returns the part of the string after the last "." |
function get_extension( $filename ) |
{ |
return substr( strrchr( $filename, '.' ), 1, strlen ( $filename ) ); |
} |
// get_filename_wo_extension returns the part of the string before the last |
// ".". |
// get_filename_wo_extension( 'test.tar.gz' ) -> 'test.tar' |
function get_filename_wo_extension( $filename ) |
{ |
return substr( $filename, 0, strrpos( $filename, '.' ) ); |
} |
/** |
* returns an array contening sub-directories, excluding "CVS" |
* |
* @param string $dir |
* @return array |
*/ |
function get_dirs($directory) |
{ |
$sub_dirs = array(); |
if ($opendir = opendir($directory)) |
{ |
while ($file = readdir($opendir)) |
{ |
if ($file != '.' |
and $file != '..' |
and is_dir($directory.'/'.$file) |
and $file != 'CVS') |
{ |
array_push($sub_dirs, $file); |
} |
} |
} |
return $sub_dirs; |
} |
// The get_picture_size function return an array containing : |
// - $picture_size[0] : final width |
// - $picture_size[1] : final height |
// The final dimensions are calculated thanks to the original dimensions and |
// the maximum dimensions given in parameters. get_picture_size respects |
// the width/height ratio |
function get_picture_size( $original_width, $original_height, |
$max_width, $max_height ) |
{ |
$width = $original_width; |
$height = $original_height; |
$is_original_size = true; |
if ( $max_width != "" ) |
{ |
if ( $original_width > $max_width ) |
{ |
$width = $max_width; |
$height = floor( ( $width * $original_height ) / $original_width ); |
} |
} |
if ( $max_height != "" ) |
{ |
if ( $original_height > $max_height ) |
{ |
$height = $max_height; |
$width = floor( ( $height * $original_width ) / $original_height ); |
$is_original_size = false; |
} |
} |
if ( is_numeric( $max_width ) and is_numeric( $max_height ) |
and $max_width != 0 and $max_height != 0 ) |
{ |
$ratioWidth = $original_width / $max_width; |
$ratioHeight = $original_height / $max_height; |
if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) ) |
{ |
if ( $ratioWidth < $ratioHeight ) |
{ |
$width = floor( $original_width / $ratioHeight ); |
$height = $max_height; |
} |
else |
{ |
$width = $max_width; |
$height = floor( $original_height / $ratioWidth ); |
} |
$is_original_size = false; |
} |
} |
$picture_size = array(); |
$picture_size[0] = $width; |
$picture_size[1] = $height; |
return $picture_size; |
} |
//-------------------------------------------- PhpWebGallery specific functions |
/** |
* returns an array with a list of {language_code => language_name} |
* |
* @returns array |
*/ |
function get_languages() |
{ |
$dir = opendir(PHPWG_ROOT_PATH.'language'); |
$languages = array(); |
while ($file = readdir($dir)) |
{ |
$path = PHPWG_ROOT_PATH.'language/'.$file; |
if (is_dir($path) and !is_link($path) and file_exists($path.'/iso.txt')) |
{ |
list($language_name) = @file($path.'/iso.txt'); |
$languages[$file] = $language_name; |
} |
} |
closedir($dir); |
@asort($languages); |
@reset($languages); |
return $languages; |
} |
/** |
* replaces the $search into <span style="$style">$search</span> in the |
* given $string. |
* |
* case insensitive replacements, does not replace characters in HTML tags |
* |
* @param string $string |
* @param string $search |
* @param string $style |
* @return string |
*/ |
function add_style( $string, $search, $style ) |
{ |
//return $string; |
$return_string = ''; |
$remaining = $string; |
$start = 0; |
$end = 0; |
$start = strpos ( $remaining, '<' ); |
$end = strpos ( $remaining, '>' ); |
while ( is_numeric( $start ) and is_numeric( $end ) ) |
{ |
$treatment = substr ( $remaining, 0, $start ); |
$treatment = preg_replace( '/('.$search.')/i', |
'<span style="'.$style.'">\\0</span>', |
$treatment ); |
$return_string.= $treatment.substr( $remaining, $start, $end-$start+1 ); |
$remaining = substr ( $remaining, $end + 1, strlen( $remaining ) ); |
$start = strpos ( $remaining, '<' ); |
$end = strpos ( $remaining, '>' ); |
} |
$treatment = preg_replace( '/('.$search.')/i', |
'<span style="'.$style.'">\\0</span>', |
$remaining ); |
$return_string.= $treatment; |
return $return_string; |
} |
// replace_search replaces a searched words array string by the search in |
// another style for the given $string. |
function replace_search( $string, $search ) |
{ |
// FIXME : with new advanced search, this function needs a rewrite |
return $string; |
$words = explode( ',', $search ); |
$style = 'background-color:white;color:red;'; |
foreach ( $words as $word ) { |
$string = add_style( $string, $word, $style ); |
} |
return $string; |
} |
function pwg_log( $file, $category, $picture = '' ) |
{ |
global $conf, $user; |
if ($conf['log']) |
{ |
$query = ' |
INSERT INTO '.HISTORY_TABLE.' |
(date,login,IP,file,category,picture) |
VALUES |
(NOW(), |
\''.(($user['id'] == 2) ? 'guest' : addslashes($user['username'])).'\', |
\''.$_SERVER['REMOTE_ADDR'].'\', |
\''.addslashes($file).'\', |
\''.addslashes($category).'\', |
\''.addslashes($picture).'\') |
;'; |
pwg_query($query); |
} |
} |
// format_date returns a formatted date for display. The date given in |
// argument can be a unixdate (number of seconds since the 01.01.1970) or an |
// american format (2003-09-15). By option, you can show the time. The |
// output is internationalized. |
// |
// format_date( "2003-09-15", 'us', true ) -> "Monday 15 September 2003 21:52" |
function format_date($date, $type = 'us', $show_time = false) |
{ |
global $lang; |
list($year,$month,$day,$hour,$minute,$second) = array(0,0,0,0,0,0); |
switch ( $type ) |
{ |
case 'us' : |
{ |
list($year,$month,$day) = explode('-', $date); |
break; |
} |
case 'unix' : |
{ |
list($year,$month,$day,$hour,$minute) = |
explode('.', date('Y.n.j.G.i', $date)); |
break; |
} |
case 'mysql_datetime' : |
{ |
preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', |
$date, $out); |
list($year,$month,$day,$hour,$minute,$second) = |
array($out[1],$out[2],$out[3],$out[4],$out[5],$out[6]); |
break; |
} |
} |
$formated_date = ''; |
// before 1970, Microsoft Windows can't mktime |
if ($year >= 1970) |
{ |
// we ask midday because Windows think it's prior to midnight with a |
// zero and refuse to work |
$formated_date.= $lang['day'][date('w', mktime(12,0,0,$month,$day,$year))]; |
} |
$formated_date.= ' '.$day; |
$formated_date.= ' '.$lang['month'][(int)$month]; |
$formated_date.= ' '.$year; |
if ($show_time) |
{ |
$formated_date.= ' '.$hour.':'.$minute; |
} |
return $formated_date; |
} |
// notify sends a email to every admin of the gallery |
function notify( $type, $infos = '' ) |
{ |
global $conf; |
$headers = 'From: <'.$conf['mail_webmaster'].'>'."\n"; |
$headers.= 'Reply-To: '.$conf['mail_webmaster']."\n"; |
$headers.= 'X-Mailer: PhpWebGallery, PHP '.phpversion(); |
$options = '-f '.$conf['mail_webmaster']; |
// retrieving all administrators |
$query = 'SELECT username,mail_address,language'; |
$query.= ' FROM '.USERS_TABLE; |
$query.= " WHERE status = 'admin'"; |
$query.= ' AND mail_address IS NOT NULL'; |
$query.= ';'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
$to = $row['mail_address']; |
include( PHPWG_ROOT_PATH.'language/'.$row['language'].'/common.lang.php' ); |
$content = $lang['mail_hello']."\n\n"; |
switch ( $type ) |
{ |
case 'upload' : |
$subject = $lang['mail_new_upload_subject']; |
$content.= $lang['mail_new_upload_content']; |
break; |
case 'comment' : |
$subject = $lang['mail_new_comment_subject']; |
$content.= $lang['mail_new_comment_content']; |
break; |
} |
$infos = str_replace( ' ', ' ', $infos ); |
$infos = str_replace( '−', '-', $infos ); |
$content.= "\n\n".$infos; |
$content.= "\n\n-- \nPhpWebGallery ".PHPWG_VERSION; |
$content = wordwrap( $content, 72 ); |
@mail( $to, $subject, $content, $headers, $options ); |
} |
} |
function pwg_write_debug() |
{ |
global $debug; |
$fp = @fopen( './log/debug.log', 'a+' ); |
fwrite( $fp, "\n\n" ); |
fwrite( $fp, $debug ); |
fclose( $fp ); |
} |
function pwg_query($query) |
{ |
global $conf,$page; |
$start = get_moment(); |
$result = mysql_query($query) or my_error($query."\n"); |
$time = get_moment() - $start; |
if (!isset($page['count_queries'])) |
{ |
$page['count_queries'] = 0; |
$page['queries_time'] = 0; |
} |
$page['count_queries']++; |
$page['queries_time']+= $time; |
if ($conf['show_queries']) |
{ |
$output = ''; |
$output.= '<pre>['.$page['count_queries'].'] '; |
$output.= "\n".$query; |
$output.= "\n".'(this query time : '; |
$output.= number_format($time, 3, '.', ' ').' s)</b>'; |
$output.= "\n".'(total SQL time : '; |
$output.= number_format($page['queries_time'], 3, '.', ' ').' s)'; |
$output.= '</pre>'; |
echo $output; |
} |
return $result; |
} |
function pwg_debug( $string ) |
{ |
global $debug,$t2,$count_queries; |
$now = explode( ' ', microtime() ); |
$now2 = explode( '.', $now[0] ); |
$now2 = $now[1].'.'.$now2[1]; |
$time = number_format( $now2 - $t2, 3, '.', ' ').' s'; |
$debug.= '['.$time.', '; |
$debug.= $count_queries.' queries] : '.$string; |
$debug.= "\n"; |
} |
/** |
* Redirects to the given URL |
* |
* Note : once this function called, the execution doesn't go further |
* (presence of an exit() instruction. |
* |
* @param string $url |
* @return void |
*/ |
function redirect( $url ) |
{ |
global $user, $template, $lang_info, $conf, $lang, $t2, $page; |
// $refresh, $url_link and $title are required for creating an automated |
// refresh page in header.tpl |
$refresh = 0; |
$url_link = $url; |
$title = 'redirection'; |
include( PHPWG_ROOT_PATH.'include/page_header.php' ); |
$template->set_filenames( array( 'redirect' => 'redirect.tpl' ) ); |
$template->parse('redirect'); |
include( PHPWG_ROOT_PATH.'include/page_tail.php' ); |
exit(); |
} |
/** |
* returns $_SERVER['QUERY_STRING'] whitout keys given in parameters |
* |
* @param array $rejects |
* @returns string |
*/ |
function get_query_string_diff($rejects = array()) |
{ |
$query_string = ''; |
$str = $_SERVER['QUERY_STRING']; |
parse_str($str, $vars); |
$is_first = true; |
foreach ($vars as $key => $value) |
{ |
if (!in_array($key, $rejects)) |
{ |
if ($is_first) |
{ |
$query_string.= '?'; |
$is_first = false; |
} |
else |
{ |
$query_string.= '&'; |
} |
$query_string.= $key.'='.$value; |
} |
} |
return $query_string; |
} |
/** |
* returns available templates |
*/ |
function get_templates() |
{ |
return get_dirs(PHPWG_ROOT_PATH.'template'); |
} |
/** |
* returns thumbnail filepath (or distant URL if thumbnail is remote) for a |
* given element |
* |
* the returned string can represente the filepath of the thumbnail or the |
* filepath to the corresponding icon for non picture elements |
* |
* @param string path |
* @param string tn_ext |
* @return string |
*/ |
function get_thumbnail_src($path, $tn_ext = '') |
{ |
global $conf, $user; |
if ($tn_ext != '') |
{ |
$src = substr_replace(get_filename_wo_extension($path), |
'/thumbnail/'.$conf['prefix_thumbnail'], |
strrpos($path,'/'), |
1); |
$src.= '.'.$tn_ext; |
} |
else |
{ |
$src = PHPWG_ROOT_PATH; |
$src.= 'template/'.$user['template'].'/mimetypes/'; |
$src.= strtolower(get_extension($path)).'.png'; |
} |
return $src; |
} |
// my_error returns (or send to standard output) the message concerning the |
// error occured for the last mysql query. |
function my_error($header) |
{ |
$error = '<pre>'; |
$error.= $header; |
$error.= '[mysql error '.mysql_errno().'] '; |
$error.= mysql_error(); |
$error.= '</pre>'; |
die ($error); |
} |
?> |
/web/test/gallery/phpwebgallery/include/functions_category.inc.php |
---|
0,0 → 1,840 |
<?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_category.inc.php,v $ |
// | last update : $Date: 2005/05/02 20:59:47 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.66.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. | |
// +-----------------------------------------------------------------------+ |
/** |
* Provides functions to handle categories. |
* |
* |
*/ |
/** |
* Is the category accessible to the connected user ? |
* |
* Note : if the user is not authorized to see this category, page creation |
* ends (exit command in this function) |
* |
* @param int category id to verify |
* @return void |
*/ |
function check_restrictions( $category_id ) |
{ |
global $user,$lang; |
if ( in_array( $category_id, $user['restrictions'] ) ) |
{ |
echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />'; |
echo '<a href="'.add_session_id( './category.php' ).'">'; |
echo $lang['thumbnails'].'</a></div>'; |
exit(); |
} |
} |
/** |
* Checks whether the argument is a right parameter category id |
* |
* The argument is a right parameter if corresponds to one of these : |
* |
* - is numeric and corresponds to a category in the database |
* - equals 'fav' (for favorites) |
* - equals 'search' (when the result of a search is displayed) |
* - equals 'most_visited' |
* - equals 'best_rated' |
* - equals 'recent_pics' |
* - equals 'recent_cats' |
* - equals 'calendar' |
* - equals 'list' |
* |
* The function fills the global var $page['cat'] and returns nothing |
* |
* @param mixed category id or special category name |
* @return void |
*/ |
function check_cat_id( $cat ) |
{ |
global $page; |
unset( $page['cat'] ); |
if ( isset( $cat ) ) |
{ |
if ( isset( $page['plain_structure'][$cat] ) ) |
{ |
$page['cat'] = $cat; |
} |
else if ( is_numeric( $cat ) ) |
{ |
$query = 'SELECT id'; |
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$cat.';'; |
$result = pwg_query( $query ); |
if ( mysql_num_rows( $result ) != 0 ) |
{ |
$page['cat'] = $cat; |
} |
} |
if ( $cat == 'fav' |
or $cat == 'most_visited' |
or $cat == 'best_rated' |
or $cat == 'recent_pics' |
or $cat == 'recent_cats' |
or $cat == 'calendar' ) |
{ |
$page['cat'] = $cat; |
} |
if ($cat == 'search' and isset($_GET['search'])) |
{ |
$page['cat'] = $cat; |
} |
if ($cat == 'list' |
and isset($_GET['list']) |
and preg_match('/^\d+(,\d+)*$/', $_GET['list'])) |
{ |
$page['cat'] = 'list'; |
} |
} |
} |
function get_categories_menu() |
{ |
global $page,$user; |
$infos = array(''); |
$query = ' |
SELECT name,id,date_last,nb_images,global_rank |
FROM '.CATEGORIES_TABLE.' |
WHERE 1 = 1'; // stupid but permit using AND after it ! |
if (!$user['expand']) |
{ |
$query.= ' |
AND (id_uppercat is NULL'; |
if (isset ($page['tab_expand']) and count($page['tab_expand']) > 0) |
{ |
$query.= ' OR id_uppercat IN ('.implode(',',$page['tab_expand']).')'; |
} |
$query.= ')'; |
} |
if ($user['forbidden_categories'] != '') |
{ |
$query.= ' |
AND id NOT IN ('.$user['forbidden_categories'].')'; |
} |
$query.= ' |
;'; |
$result = pwg_query($query); |
$cats = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($cats, $row); |
} |
usort($cats, 'global_rank_compare'); |
return get_html_menu_category($cats); |
} |
function count_user_total_images() |
{ |
global $user; |
$query = 'SELECT SUM(nb_images) AS total'; |
$query.= ' FROM '.CATEGORIES_TABLE; |
if ( count( $user['restrictions'] ) > 0 ) |
$query.= ' WHERE id NOT IN ('.$user['forbidden_categories'].')'; |
$query.= ';'; |
$row = mysql_fetch_array( pwg_query( $query ) ); |
if ( !isset( $row['total'] ) ) $row['total'] = 0; |
return $row['total']; |
} |
/** |
* Retrieve informations about a category in the database |
* |
* Returns an array with following keys : |
* |
* - comment |
* - dir : directory, might be empty for virtual categories |
* - name : an array with indexes from 0 (lowest cat name) to n (most |
* uppercat name findable) |
* - nb_images |
* - id_uppercat |
* - site_id |
* - |
* |
* @param int category id |
* @return array |
*/ |
function get_cat_info( $id ) |
{ |
$infos = array('nb_images','id_uppercat','comment','site_id' |
,'dir','date_last','uploadable','status','visible' |
,'representative_picture_id','uppercats','commentable'); |
$query = ' |
SELECT '.implode(',', $infos).' |
FROM '.CATEGORIES_TABLE.' |
WHERE id = '.$id.' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
$cat = array(); |
foreach ($infos as $info) |
{ |
if (isset($row[$info])) |
{ |
$cat[$info] = $row[$info]; |
} |
else |
{ |
$cat[$info] = ''; |
} |
// If the field is true or false, the variable is transformed into a |
// boolean value. |
if ($cat[$info] == 'true' or $cat[$info] == 'false') |
{ |
$cat[$info] = get_boolean( $cat[$info] ); |
} |
} |
$cat['comment'] = nl2br($cat['comment']); |
$names = array(); |
$query = ' |
SELECT name,id |
FROM '.CATEGORIES_TABLE.' |
WHERE id IN ('.$cat['uppercats'].') |
;'; |
$result = pwg_query($query); |
while($row = mysql_fetch_array($result)) |
{ |
$names[$row['id']] = $row['name']; |
} |
// category names must be in the same order than uppercats list |
$cat['name'] = array(); |
foreach (explode(',', $cat['uppercats']) as $cat_id) |
{ |
$cat['name'][$cat_id] = $names[$cat_id]; |
} |
return $cat; |
} |
// get_complete_dir returns the concatenation of get_site_url and |
// get_local_dir |
// Example : "pets > rex > 1_year_old" is on the the same site as the |
// PhpWebGallery files and this category has 22 for identifier |
// get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/" |
function get_complete_dir( $category_id ) |
{ |
return get_site_url($category_id).get_local_dir($category_id); |
} |
// get_local_dir returns an array with complete path without the site url |
// Example : "pets > rex > 1_year_old" is on the the same site as the |
// PhpWebGallery files and this category has 22 for identifier |
// get_local_dir(22) returns "pets/rex/1_year_old/" |
function get_local_dir( $category_id ) |
{ |
global $page; |
$uppercats = ''; |
$local_dir = ''; |
if ( isset( $page['plain_structure'][$category_id]['uppercats'] ) ) |
{ |
$uppercats = $page['plain_structure'][$category_id]['uppercats']; |
} |
else |
{ |
$query = 'SELECT uppercats'; |
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id; |
$query.= ';'; |
$row = mysql_fetch_array( pwg_query( $query ) ); |
$uppercats = $row['uppercats']; |
} |
$upper_array = explode( ',', $uppercats ); |
$database_dirs = array(); |
$query = 'SELECT id,dir'; |
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$uppercats.')'; |
$query.= ';'; |
$result = pwg_query( $query ); |
while( $row = mysql_fetch_array( $result ) ) |
{ |
$database_dirs[$row['id']] = $row['dir']; |
} |
foreach ($upper_array as $id) |
{ |
$local_dir.= $database_dirs[$id].'/'; |
} |
return $local_dir; |
} |
// retrieving the site url : "http://domain.com/gallery/" or |
// simply "./galleries/" |
function get_site_url($category_id) |
{ |
global $page; |
$query = ' |
SELECT galleries_url |
FROM '.SITES_TABLE.' AS s,'.CATEGORIES_TABLE.' AS c |
WHERE s.id = c.site_id |
AND c.id = '.$category_id.' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
return $row['galleries_url']; |
} |
// initialize_category initializes ;-) the variables in relation |
// with category : |
// 1. calculation of the number of pictures in the category |
// 2. determination of the SQL query part to ask to find the right category |
// $page['where'] is not the same if we are in |
// - simple category |
// - search result |
// - favorites displaying |
// - most visited pictures |
// - best rated pictures |
// - recent pictures |
// - defined list (used for random) |
// 3. determination of the title of the page |
// 4. creation of the navigation bar |
function initialize_category( $calling_page = 'category' ) |
{ |
pwg_debug( 'start initialize_category' ); |
global $page,$lang,$user,$conf; |
if ( isset( $page['cat'] ) ) |
{ |
// $page['nb_image_page'] is the number of picture to display on this page |
// By default, it is the same as the $user['nb_image_page'] |
$page['nb_image_page'] = $user['nb_image_page']; |
// $url is used to create the navigation bar |
$url = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat']; |
if ( isset($page['expand']) ) $url.= '&expand='.$page['expand']; |
// simple category |
if ( is_numeric( $page['cat'] ) ) |
{ |
$result = get_cat_info( $page['cat'] ); |
$page['comment'] = $result['comment']; |
$page['cat_dir'] = $result['dir']; |
$page['cat_name'] = $result['name']; |
$page['cat_nb_images'] = $result['nb_images']; |
$page['cat_site_id'] = $result['site_id']; |
$page['cat_uploadable'] = $result['uploadable']; |
$page['cat_commentable'] = $result['commentable']; |
$page['uppercats'] = $result['uppercats']; |
$page['title'] = |
get_cat_display_name($page['cat_name'], |
'', |
false); |
$page['where'] = ' WHERE category_id = '.$page['cat']; |
} |
else |
{ |
if ($page['cat'] == 'search' |
or $page['cat'] == 'most_visited' |
or $page['cat'] == 'recent_pics' |
or $page['cat'] == 'recent_cats' |
or $page['cat'] == 'best_rated' |
or $page['cat'] == 'calendar' |
or $page['cat'] == 'list') |
{ |
// we must not show pictures of a forbidden category |
if ( $user['forbidden_categories'] != '' ) |
{ |
$forbidden = ' category_id NOT IN '; |
$forbidden.= '('.$user['forbidden_categories'].')'; |
} |
} |
// search result |
if ( $page['cat'] == 'search' ) |
{ |
// analyze search string given in URL (created in search.php) |
$tokens = explode('|', $_GET['search']); |
if (isset($tokens[1]) and $tokens[1] == 'AND') |
{ |
$search['mode'] = 'AND'; |
} |
else |
{ |
$search['mode'] = 'OR'; |
} |
$search_tokens = explode('--', $tokens[0]); |
foreach ($search_tokens as $search_token) |
{ |
$tokens = explode(':', $search_token); |
$field_name = $tokens[0]; |
$field_content = $tokens[1]; |
$tokens = explode('~', $tokens[1]); |
if (isset($tokens[1])) |
{ |
$search['fields'][$field_name]['mode'] = $tokens[1]; |
} |
else |
{ |
$search['fields'][$field_name]['mode'] = ''; |
} |
$search['fields'][$field_name]['words'] = array(); |
$tokens = explode(',', $tokens[0]); |
foreach ($tokens as $token) |
{ |
array_push($search['fields'][$field_name]['words'], |
htmlentities($token)); |
} |
} |
$page['title'] = $lang['search_result']; |
if ( $calling_page == 'picture' ) |
{ |
$page['title'].= ' : <span style="font-style:italic;">'; |
$page['title'].= $_GET['search']."</span>"; |
} |
// SQL where clauses are stored in $clauses array during query |
// construction |
$clauses = array(); |
$textfields = array('file', 'name', 'comment', 'keywords', 'author'); |
foreach ($textfields as $textfield) |
{ |
if (isset($search['fields'][$textfield])) |
{ |
$local_clauses = array(); |
foreach ($search['fields'][$textfield]['words'] as $word) |
{ |
array_push($local_clauses, $textfield." LIKE '%".$word."%'"); |
} |
// adds brackets around where clauses |
array_walk($local_clauses,create_function('&$s','$s="(".$s.")";')); |
array_push($clauses, |
implode(' '.$search['fields'][$textfield]['mode'].' ', |
$local_clauses)); |
} |
} |
if (isset($search['fields']['allwords'])) |
{ |
$fields = array('file', 'name', 'comment', 'keywords', 'author'); |
// in the OR mode, request bust be : |
// ((field1 LIKE '%word1%' OR field2 LIKE '%word1%') |
// OR (field1 LIKE '%word2%' OR field2 LIKE '%word2%')) |
// |
// in the AND mode : |
// ((field1 LIKE '%word1%' OR field2 LIKE '%word1%') |
// AND (field1 LIKE '%word2%' OR field2 LIKE '%word2%')) |
$word_clauses = array(); |
foreach ($search['fields']['allwords']['words'] as $word) |
{ |
$field_clauses = array(); |
foreach ($fields as $field) |
{ |
array_push($field_clauses, $field." LIKE '%".$word."%'"); |
} |
// adds brackets around where clauses |
array_push($word_clauses, implode(' OR ', $field_clauses)); |
} |
array_walk($word_clauses, create_function('&$s','$s="(".$s.")";')); |
array_push($clauses, |
implode(' '.$search['fields']['allwords']['mode'].' ', |
$word_clauses)); |
} |
$datefields = array('date_available', 'date_creation'); |
foreach ($datefields as $datefield) |
{ |
$key = $datefield; |
if (isset($search['fields'][$key])) |
{ |
$local_clause = $datefield." = '"; |
$local_clause.= str_replace('.', '-', |
$search['fields'][$key]['words'][0]); |
$local_clause.= "'"; |
array_push($clauses, $local_clause); |
} |
foreach (array('after','before') as $suffix) |
{ |
$key = $datefield.'-'.$suffix; |
if (isset($search['fields'][$key])) |
{ |
$local_clause = $datefield; |
if ($suffix == 'after') |
{ |
$local_clause.= ' >'; |
} |
else |
{ |
$local_clause.= ' <'; |
} |
if (isset($search['fields'][$key]['mode']) |
and $search['fields'][$key]['mode'] == 'inc') |
{ |
$local_clause.= '='; |
} |
$local_clause.= " '"; |
$local_clause.= str_replace('.', '-', |
$search['fields'][$key]['words'][0]); |
$local_clause.= "'"; |
array_push($clauses, $local_clause); |
} |
} |
} |
if (isset($search['fields']['cat'])) |
{ |
if ($search['fields']['cat']['mode'] == 'sub_inc') |
{ |
// searching all the categories id of sub-categories |
$cat_ids = get_subcat_ids($search['fields']['cat']['words']); |
} |
else |
{ |
$cat_ids = $search['fields']['cat']['words']; |
} |
$local_clause = 'category_id IN ('.implode(',', $cat_ids).')'; |
array_push($clauses, $local_clause); |
} |
// adds brackets around where clauses |
array_walk($clauses, create_function('&$s', '$s = "(".$s.")";')); |
$page['where'] = 'WHERE '.implode(' '.$search['mode'].' ', $clauses); |
if ( isset( $forbidden ) ) $page['where'].= ' AND '.$forbidden; |
$query = ' |
SELECT COUNT(DISTINCT(id)) AS nb_total_images |
FROM '.IMAGES_TABLE.' |
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
'.$page['where'].' |
;'; |
$url.= '&search='.$_GET['search']; |
} |
// favorites displaying |
else if ( $page['cat'] == 'fav' ) |
{ |
check_user_favorites(); |
$page['title'] = $lang['favorites']; |
$page['where'] = ', '.FAVORITES_TABLE.' AS fav'; |
$page['where'].= ' WHERE user_id = '.$user['id']; |
$page['where'].= ' AND fav.image_id = id'; |
$query = 'SELECT COUNT(*) AS nb_total_images'; |
$query.= ' FROM '.FAVORITES_TABLE; |
$query.= ' WHERE user_id = '.$user['id']; |
$query.= ';'; |
} |
// pictures within the short period |
else if ( $page['cat'] == 'recent_pics' ) |
{ |
$page['title'] = $lang['recent_pics_cat']; |
// We must find the date corresponding to : |
// today - $conf['periode_courte'] |
$date = time() - 60*60*24*$user['recent_period']; |
$page['where'] = " WHERE date_available > '"; |
$page['where'].= date( 'Y-m-d', $date )."'"; |
if ( isset( $forbidden ) ) $page['where'].= ' AND '.$forbidden; |
$query = ' |
SELECT COUNT(DISTINCT(id)) AS nb_total_images |
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic |
ON id = ic.image_id |
'.$page['where'].' |
;'; |
} |
// categories containing recent pictures |
else if ( $page['cat'] == 'recent_cats' ) |
{ |
$page['title'] = $lang['recent_cats_cat']; |
$page['cat_nb_images'] = 0; |
} |
// most visited pictures |
else if ( $page['cat'] == 'most_visited' ) |
{ |
$page['title'] = $conf['top_number'].' '.$lang['most_visited_cat']; |
$page['where'] = 'WHERE hit > 0'; |
if (isset($forbidden)) |
{ |
$page['where'] = "\n".' AND '.$forbidden; |
} |
$conf['order_by'] = ' ORDER BY hit DESC, file ASC'; |
// $page['cat_nb_images'] equals $conf['top_number'] unless there |
// are less visited items |
$query =' |
SELECT COUNT(DISTINCT(id)) AS count |
FROM '.IMAGES_TABLE.' |
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
'.$page['where'].' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
if ($row['count'] < $conf['top_number']) |
{ |
$page['cat_nb_images'] = $row['count']; |
} |
else |
{ |
$page['cat_nb_images'] = $conf['top_number']; |
} |
unset($query); |
if ( isset( $page['start'] ) |
and ($page['start']+$user['nb_image_page']>=$conf['top_number'])) |
{ |
$page['nb_image_page'] = $conf['top_number'] - $page['start']; |
} |
} |
else if ( $page['cat'] == 'calendar' ) |
{ |
$page['cat_nb_images'] = 0; |
$page['title'] = $lang['calendar']; |
if (isset($_GET['year']) |
and preg_match('/^\d+$/', $_GET['year'])) |
{ |
$page['calendar_year'] = (int)$_GET['year']; |
} |
if (isset($_GET['month']) |
and preg_match('/^(\d+)\.(\d{2})$/', $_GET['month'], $matches)) |
{ |
$page['calendar_year'] = (int)$matches[1]; |
$page['calendar_month'] = (int)$matches[2]; |
} |
if (isset($_GET['day']) |
and preg_match('/^(\d+)\.(\d{2})\.(\d{2})$/', |
$_GET['day'], |
$matches)) |
{ |
$page['calendar_year'] = (int)$matches[1]; |
$page['calendar_month'] = (int)$matches[2]; |
$page['calendar_day'] = (int)$matches[3]; |
} |
if (isset($page['calendar_year'])) |
{ |
$page['title'] .= ' ('; |
if (isset($page['calendar_day'])) |
{ |
if ($page['calendar_year'] >= 1970) |
{ |
$unixdate = mktime(0,0,0, |
$page['calendar_month'], |
$page['calendar_day'], |
$page['calendar_year']); |
$page['title'].= $lang['day'][date("w", $unixdate)]; |
} |
$page['title'].= ' '.$page['calendar_day'].', '; |
} |
if (isset($page['calendar_month'])) |
{ |
$page['title'] .= $lang['month'][$page['calendar_month']].' '; |
} |
$page['title'] .= $page['calendar_year']; |
$page['title'] .= ')'; |
} |
$page['where'] = 'WHERE '.$conf['calendar_datefield'].' IS NOT NULL'; |
if (isset($forbidden)) |
{ |
$page['where'].= ' AND '.$forbidden; |
} |
} |
else if ($page['cat'] == 'best_rated') |
{ |
$page['title'] = $conf['top_number'].' '.$lang['best_rated_cat']; |
$page['where'] = ' WHERE average_rate IS NOT NULL'; |
if (isset($forbidden)) |
{ |
$page['where'].= ' AND '.$forbidden; |
} |
$conf['order_by'] = ' ORDER BY average_rate DESC, id ASC'; |
// $page['cat_nb_images'] equals $conf['top_number'] unless there |
// are less rated items |
$query =' |
SELECT COUNT(DISTINCT(id)) AS count |
FROM '.IMAGES_TABLE.' |
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
'.$page['where'].' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
if ($row['count'] < $conf['top_number']) |
{ |
$page['cat_nb_images'] = $row['count']; |
} |
else |
{ |
$page['cat_nb_images'] = $conf['top_number']; |
} |
unset($query); |
if (isset($page['start']) |
and ($page['start']+$user['nb_image_page']>=$conf['top_number'])) |
{ |
$page['nb_image_page'] = $conf['top_number'] - $page['start']; |
} |
} |
else if ($page['cat'] == 'list') |
{ |
$page['title'] = $lang['random_cat']; |
$page['where'] = 'WHERE 1=1'; |
if (isset($forbidden)) |
{ |
$page['where'].= ' AND '.$forbidden; |
} |
$page['where'].= ' AND image_id IN ('.$_GET['list'].')'; |
$page['cat_nb_images'] = count(explode(',', $_GET['list'])); |
$url.= '&list='.$_GET['list']; |
} |
if (isset($query)) |
{ |
$result = pwg_query( $query ); |
$row = mysql_fetch_array( $result ); |
$page['cat_nb_images'] = $row['nb_total_images']; |
} |
} |
if ( $calling_page == 'category' ) |
{ |
$page['navigation_bar'] = |
create_navigation_bar( $url, $page['cat_nb_images'], $page['start'], |
$user['nb_image_page'], 'back' ); |
} |
} |
else |
{ |
$page['title'] = $lang['no_category']; |
} |
pwg_debug( 'end initialize_category' ); |
} |
function display_select_categories($categories, |
$selecteds, |
$blockname, |
$fullname = true) |
{ |
global $template; |
foreach ($categories as $category) |
{ |
$selected = ''; |
if (in_array($category['id'], $selecteds)) |
{ |
$selected = ' selected="selected"'; |
} |
if ($fullname) |
{ |
$option = get_cat_display_name_cache($category['uppercats'], |
'', |
false); |
} |
else |
{ |
$option = str_repeat(' ', |
(3 * substr_count($category['global_rank'], '.'))); |
$option.= '- '.$category['name']; |
} |
$template->assign_block_vars( |
$blockname, |
array('SELECTED'=>$selected, |
'VALUE'=>$category['id'], |
'OPTION'=>$option |
)); |
} |
} |
function display_select_cat_wrapper($query, $selecteds, $blockname, |
$fullname = true) |
{ |
$result = pwg_query($query); |
$categories = array(); |
if (!empty($result)) |
{ |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($categories, $row); |
} |
} |
usort($categories, 'global_rank_compare'); |
display_select_categories($categories, $selecteds, $blockname, $fullname); |
} |
/** |
* returns all subcategory identifiers of given category ids |
* |
* @param array ids |
* @return array |
*/ |
function get_subcat_ids($ids) |
{ |
$query = ' |
SELECT DISTINCT(id) |
FROM '.CATEGORIES_TABLE.' |
WHERE '; |
foreach ($ids as $num => $category_id) |
{ |
if ($num > 0) |
{ |
$query.= ' |
OR '; |
} |
$query.= 'uppercats REGEXP \'(^|,)'.$category_id.'(,|$)\''; |
} |
$query.= ' |
;'; |
$result = pwg_query($query); |
$subcats = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($subcats, $row['id']); |
} |
return $subcats; |
} |
function global_rank_compare($a, $b) |
{ |
return strnatcasecmp($a['global_rank'], $b['global_rank']); |
} |
?> |
/web/test/gallery/phpwebgallery/include/functions_group.inc.php |
---|
0,0 → 1,109 |
<?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_group.inc.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
// get_group_restrictions returns an array containing all unaccessible |
// category ids. |
function get_group_restrictions( $group_id ) |
{ |
// 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 group |
$authorized = array(); |
$query = 'SELECT cat_id FROM '.GROUP_ACCESS_TABLE; |
$query.= ' WHERE group_id = '.$group_id; |
$query.= ';'; |
$result = pwg_query( $query ); |
while ( $row = mysql_fetch_array( $result ) ) |
{ |
array_push( $authorized, $row['cat_id'] ); |
} |
$forbidden = array(); |
foreach ( $privates as $private ) { |
if ( !in_array( $private, $authorized ) ) |
{ |
array_push( $forbidden, $private ); |
} |
} |
return $forbidden; |
} |
// get_all_group_restrictions returns an array with ALL unaccessible |
// category ids, including sub-categories |
function get_all_group_restrictions( $group_id ) |
{ |
$restricted_cats = get_group_restrictions( $group_id ); |
foreach ( $restricted_cats as $restricted_cat ) { |
$sub_restricted_cats = get_subcats_id( $restricted_cat ); |
foreach ( $sub_restricted_cats as $sub_restricted_cat ) { |
array_push( $restricted_cats, $sub_restricted_cat ); |
} |
} |
return $restricted_cats; |
} |
// The function is_group_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 |
function is_group_allowed( $category_id, $restrictions ) |
{ |
$lowest_category_id = $category_id; |
$is_root = false; |
while ( !$is_root and !in_array( $category_id, $restrictions ) ) |
{ |
$query = 'SELECT id_uppercat FROM '.CATEGORIES_TABLE; |
$query.= ' WHERE id = '.$category_id; |
$query.= ';'; |
$row = mysql_fetch_array( pwg_query( $query ) ); |
if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = ''; |
if ( $row['id_uppercat'] == '' ) $is_root = true; |
$category_id = $row['id_uppercat']; |
} |
if ( in_array( $lowest_category_id, $restrictions ) ) |
{ |
return 1; |
} |
if ( in_array( $category_id, $restrictions ) ) |
{ |
return 2; |
} |
// this group is allowed to go in this category |
return 0; |
} |
?> |
/web/test/gallery/phpwebgallery/include/functions_html.inc.php |
---|
0,0 → 1,452 |
<?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_html.inc.php,v $ |
// | last update : $Date: 2005/01/08 00:18:39 $ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
function get_icon( $date ) |
{ |
global $user, $conf, $lang; |
if (!preg_match('/\d{4}-\d{2}-\d{2}/', $date)) |
{ |
return ''; |
} |
list( $year,$month,$day ) = explode( '-', $date ); |
$unixtime = mktime( 0, 0, 0, $month, $day, $year ); |
$diff = time() - $unixtime; |
$day_in_seconds = 24*60*60; |
$output = ''; |
$title = $lang['recent_image'].' '; |
if ( $diff < $user['recent_period'] * $day_in_seconds ) |
{ |
$icon_url = './template/'.$user['template'].'/theme/'; |
$icon_url.= 'recent.gif'; |
$title .= $user['recent_period']; |
$title .= ' '.$lang['days']; |
$size = getimagesize( $icon_url ); |
$output = '<img title="'.$title.'" src="'.$icon_url.'" style="border:0;'; |
$output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="" />'; |
} |
return $output; |
} |
function create_navigation_bar($url, $nb_element, $start, |
$nb_element_page, $link_class) |
{ |
global $lang, $conf; |
$pages_around = $conf['paginate_pages_around']; |
$navbar = ''; |
// current page detection |
if (!isset($start) |
or !is_numeric($start) |
or (is_numeric($start) and $start < 0)) |
{ |
$start = 0; |
} |
// navigation bar useful only if more than one page to display ! |
if ($nb_element > $nb_element_page) |
{ |
// current page and last page |
$cur_page = ceil($start / $nb_element_page) + 1; |
$maximum = ceil($nb_element / $nb_element_page); |
// link to first page ? |
if ($cur_page != 1) |
{ |
$navbar.= '<a href="'; |
$navbar.= add_session_id($url.'&start=0'); |
$navbar.= '" class="'.$link_class.'">'.$lang['first_page']; |
$navbar.= '</a>'; |
} |
else |
{ |
$navbar.= $lang['first_page']; |
} |
$navbar.= ' | '; |
// link on previous page ? |
if ( $start != 0 ) |
{ |
$previous = $start - $nb_element_page; |
$navbar.= '<a href="'; |
$navbar.= add_session_id( $url.'&start='.$previous ); |
$navbar.= '" class="'.$link_class.'">'.$lang['previous_page']; |
$navbar.= '</a>'; |
} |
else |
{ |
$navbar.= $lang['previous_page']; |
} |
$navbar.= ' | '; |
if ($cur_page > $pages_around + 1) |
{ |
$navbar.= ' <a href="'; |
$navbar.= add_session_id($url.'&start=0'); |
$navbar.= '" class="'.$link_class.'">1</a>'; |
if ($cur_page > $pages_around + 2) |
{ |
$navbar.= ' ...'; |
} |
} |
// inspired from punbb source code |
for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1; |
$i < $stop; |
$i++) |
{ |
if ($i < 1 or $i > $maximum) |
{ |
continue; |
} |
else if ($i != $cur_page) |
{ |
$temp_start = ($i - 1) * $nb_element_page; |
$navbar.= ' <a href="'; |
$navbar.= add_session_id($url.'&start='.$temp_start); |
$navbar.= '" class="'.$link_class.'">'.$i.'</a>'; |
} |
else |
{ |
$navbar.= ' <span class="pageNumberSelected">'; |
$navbar.= $i.'</span>'; |
} |
} |
if ($cur_page < ($maximum - $pages_around)) |
{ |
$temp_start = ($maximum - 1) * $nb_element_page; |
if ($cur_page < ($maximum - $pages_around - 1)) |
{ |
$navbar.= ' ...'; |
} |
$navbar.= ' <a href="'; |
$navbar.= add_session_id($url.'&start='.$temp_start); |
$navbar.= '" class="'.$link_class.'">'.$maximum.'</a>'; |
} |
$navbar.= ' | '; |
// link on next page ? |
if ( $nb_element > $nb_element_page |
&& $start + $nb_element_page < $nb_element ) |
{ |
$next = $start + $nb_element_page; |
$navbar.= '<a href="'; |
$navbar.= add_session_id( $url.'&start='.$next ); |
$navbar.= '" class="'.$link_class.'">'.$lang['next_page'].'</a>'; |
} |
else |
{ |
$navbar.= $lang['next_page']; |
} |
$navbar.= ' | '; |
// link to last page ? |
if ($cur_page != $maximum) |
{ |
$temp_start = ($maximum - 1) * $nb_element_page; |
$navbar.= '<a href="'; |
$navbar.= add_session_id($url.'&start='.$temp_start); |
$navbar.= '" class="'.$link_class.'">'.$lang['last_page']; |
$navbar.= '</a>'; |
} |
else |
{ |
$navbar.= $lang['last_page']; |
} |
} |
return $navbar; |
} |
// |
// Pick a language, any language ... |
// |
function language_select($default, $select_name = "language") |
{ |
$available_lang = get_languages(); |
$lang_select = '<select name="' . $select_name . '" onchange="this.form.submit()">'; |
foreach ($available_lang as $code => $displayname) |
{ |
$selected = ( strtolower($default) == strtolower($code) ) ? ' selected="selected"' : ''; |
$lang_select .= '<option value="' . $code . '"' . $selected . '>' . ucwords($displayname) . '</option>'; |
} |
$lang_select .= '</select>'; |
return $lang_select; |
} |
// |
// Pick a template/theme combo, |
// |
function style_select($default_style, $select_name = "style") |
{ |
$templates = get_templates(); |
$style_selected = '<select name="' . $select_name . '" >'; |
foreach ($templates as $template) |
{ |
$selected = ( $template == $default_style ) ? ' selected="selected"' : ''; |
$style_selected.= '<option value="'.$template.'"'.$selected.'>'; |
$style_selected.= $template.'</option>'; |
} |
$style_selected .= '</select>'; |
return $style_selected; |
} |
/** |
* returns the list of categories as a HTML string |
* |
* categories string returned contains categories as given in the input |
* array $cat_informations. $cat_informations array must be an association |
* of {category_id => category_name}. If url input parameter is empty, |
* returns only the categories name without links. |
* |
* @param array cat_informations |
* @param string url |
* @param boolean replace_space |
* @return string |
*/ |
function get_cat_display_name($cat_informations, |
$url = 'category.php?cat=', |
$replace_space = true) |
{ |
global $conf; |
$output = ''; |
$is_first = true; |
foreach ($cat_informations as $id => $name) |
{ |
if ($is_first) |
{ |
$is_first = false; |
} |
else |
{ |
$output.= $conf['level_separator']; |
} |
if ($url == '') |
{ |
$output.= $name; |
} |
else |
{ |
$output.= ' |
<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.$url.$id).'">'.$name.'</a>'; |
} |
} |
if ($replace_space) |
{ |
return replace_space($output); |
} |
else |
{ |
return $output; |
} |
} |
/** |
* returns the list of categories as a HTML string, with cache of names |
* |
* categories string returned contains categories as given in the input |
* array $cat_informations. $uppercats is the list of category ids to |
* display in the right order. If url input parameter is empty, returns only |
* the categories name without links. |
* |
* @param string uppercats |
* @param string url |
* @param boolean replace_space |
* @return string |
*/ |
function get_cat_display_name_cache($uppercats, |
$url = 'category.php?cat=', |
$replace_space = true) |
{ |
global $cat_names, $conf; |
if (!isset($cat_names)) |
{ |
$query = ' |
SELECT id,name |
FROM '.CATEGORIES_TABLE.' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
$cat_names[$row['id']] = $row['name']; |
} |
} |
$output = ''; |
$is_first = true; |
foreach (explode(',', $uppercats) as $category_id) |
{ |
$name = $cat_names[$category_id]; |
if ($is_first) |
{ |
$is_first = false; |
} |
else |
{ |
$output.= $conf['level_separator']; |
} |
if ($url == '') |
{ |
$output.= $name; |
} |
else |
{ |
$output.= ' |
<a class="" |
href="'.add_session_id(PHPWG_ROOT_PATH.$url.$category_id).'">'.$name.'</a>'; |
} |
} |
if ($replace_space) |
{ |
return replace_space($output); |
} |
else |
{ |
return $output; |
} |
} |
/** |
* returns the HTML code for a category item in the menu (for category.php) |
* |
* HTML code generated uses logical list tags ul and each category is an |
* item li. The paramter given is the category informations as an array, |
* used keys are : id, name, nb_images, date_last |
* |
* @param array categories |
* @return string |
*/ |
function get_html_menu_category($categories) |
{ |
global $page, $lang; |
$ref_level = 0; |
$menu = ' |
<ul class="menu">'; |
foreach ($categories as $category) |
{ |
$level = substr_count($category['global_rank'], '.'); |
if ($level > $ref_level) |
{ |
$menu.= ' |
<ul class="menu">'; |
} |
else if ($level < $ref_level) |
{ |
// we may have to close more than one level at the same time... |
$menu.= str_repeat("\n</ul>",($ref_level-$level)); |
} |
$ref_level = $level; |
$menu.= ' |
<li>'; |
$url = add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']); |
$class = ''; |
if (isset($page['cat']) |
and is_numeric($page['cat']) |
and $category['id'] == $page['cat']) |
{ |
$class = 'menuCategorySelected'; |
} |
else |
{ |
$class = 'menuCategoryNotSelected'; |
} |
$menu.= ' |
<a href="'.$url.'" |
title="'.$lang['hint_category'].'" |
class="'.$class.'"> |
'.$category['name'].' |
</a>'; |
if ($category['nb_images'] > 0) |
{ |
$menu.= ' |
<span class="menuInfoCat" |
title="'.$category['nb_images'].' |
'.$lang['images_available'].'"> |
['.$category['nb_images'].'] |
</span> |
'.get_icon($category['date_last']); |
} |
$menu.= '</li>'; |
} |
$menu.= ' |
</ul>'; |
return $menu; |
} |
/** |
* returns HTMLized comment contents retrieved from database |
* |
* newlines becomes br tags, _word_ becomes underline, /word/ becomes |
* italic, *word* becomes bolded |
* |
* @param string content |
* @return string |
*/ |
function parse_comment_content($content) |
{ |
$content = nl2br($content); |
// replace _word_ by an underlined word |
$pattern = '/_([^\s]*)_/'; |
$replacement = '<span style="text-decoration:underline;">\1</span>'; |
$content = preg_replace($pattern, $replacement, $content); |
// replace *word* by a bolded word |
$pattern = '/\*([^\s]*)\*/'; |
$replacement = '<span style="font-weight:bold;">\1</span>'; |
$content = preg_replace($pattern, $replacement, $content); |
// replace /word/ by an italic word |
$pattern = '/\/([^\s]*)\//'; |
$replacement = '<span style="font-style:italic;">\1</span>'; |
$content = preg_replace($pattern, $replacement, $content); |
return $content; |
} |
?> |
/web/test/gallery/phpwebgallery/include/functions_metadata.inc.php |
---|
0,0 → 1,94 |
<?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.inc.php,v $ |
// | last update : $Date: 2005/01/07 23:10:51 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.4 $ |
// +-----------------------------------------------------------------------+ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
/** |
* returns informations from IPTC metadata, mapping is done at the beginning |
* of the function |
* |
* @param string $filename |
* @return array |
*/ |
function get_iptc_data($filename, $map) |
{ |
$result = array(); |
// Read IPTC data |
$iptc = array(); |
$imginfo = array(); |
getimagesize($filename, $imginfo); |
if (isset($imginfo['APP13'])) |
{ |
$iptc = iptcparse($imginfo['APP13']); |
if (is_array($iptc)) |
{ |
$rmap = array_flip($map); |
foreach (array_keys($rmap) as $iptc_key) |
{ |
if (isset($iptc[$iptc_key][0])) |
{ |
if ($iptc_key == '2#025') |
{ |
$value = implode(',', |
array_map('clean_iptc_value',$iptc[$iptc_key])); |
} |
else |
{ |
$value = clean_iptc_value($iptc[$iptc_key][0]); |
} |
foreach (array_keys($map, $iptc_key) as $pwg_key) |
{ |
$result[$pwg_key] = $value; |
} |
} |
} |
} |
} |
return $result; |
} |
/** |
* return a cleaned IPTC value |
* |
* @param string value |
* @return string |
*/ |
function clean_iptc_value($value) |
{ |
// strip leading zeros (weird Kodak Scanner software) |
while ($value[0] == chr(0)) |
{ |
$value = substr($value, 1); |
} |
// remove binary nulls |
$value = str_replace(chr(0x00), ' ', $value); |
return $value; |
} |
?> |
/web/test/gallery/phpwebgallery/include/functions_session.inc.php |
---|
0,0 → 1,144 |
<?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_session.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. | |
// +-----------------------------------------------------------------------+ |
// The function generate_key creates a string with pseudo random characters. |
// the size of the string depends on the $conf['session_id_size']. |
// Characters used are a-z A-Z and numerical values. Examples : |
// "Er4Tgh6", "Rrp08P", "54gj" |
// input : none (using global variable) |
// output : $key |
function generate_key($size) |
{ |
global $conf; |
$md5 = md5(substr(microtime(), 2, 6)); |
$init = ''; |
for ( $i = 0; $i < strlen( $md5 ); $i++ ) |
{ |
if ( is_numeric( $md5[$i] ) ) $init.= $md5[$i]; |
} |
$init = substr( $init, 0, 8 ); |
mt_srand( $init ); |
$key = ''; |
for ( $i = 0; $i < $size; $i++ ) |
{ |
$c = mt_rand( 0, 2 ); |
if ( $c == 0 ) $key .= chr( mt_rand( 65, 90 ) ); |
else if ( $c == 1 ) $key .= chr( mt_rand( 97, 122 ) ); |
else $key .= mt_rand( 0, 9 ); |
} |
return $key; |
} |
/** |
* create a new session and returns the session identifier |
* |
* - find a non-already-used session key |
* - create a session in database |
* - return session identifier |
* |
* @param int userid |
* @param int session_lentgh : in seconds |
* @return string |
*/ |
function session_create($userid, $session_length) |
{ |
global $conf; |
// 1. searching an unused session key |
$id_found = false; |
while (!$id_found) |
{ |
$generated_id = generate_key($conf['session_id_size']); |
$query = ' |
SELECT id |
FROM '.SESSIONS_TABLE.' |
WHERE id = \''.$generated_id.'\' |
;'; |
$result = pwg_query($query); |
if (mysql_num_rows($result) == 0) |
{ |
$id_found = true; |
} |
} |
// 3. inserting session in database |
$query = ' |
INSERT INTO '.SESSIONS_TABLE.' |
(id,user_id,expiration) |
VALUES |
(\''.$generated_id.'\','.$userid.', |
ADDDATE(NOW(), INTERVAL '.$session_length.' SECOND)) |
;'; |
pwg_query($query); |
$expiration = $session_length + time(); |
setcookie('id', $generated_id, $expiration, cookie_path()); |
return $generated_id; |
} |
// add_session_id adds the id of the session to the string given in |
// parameter as $url. If the session id is the first parameter to the url, |
// it is preceded by a '?', else it is preceded by a '&'. If the |
// parameter $redirect is set to true, '&' is used instead of '&'. |
function add_session_id( $url, $redirect = false ) |
{ |
global $page, $user; |
if ( $user['has_cookie'] ) return $url; |
$amp = '&'; |
if ( $redirect ) |
{ |
$amp = '&'; |
} |
if ( !$user['is_the_guest'] ) |
{ |
if ( preg_match( '/\.php\?/',$url ) ) |
{ |
return $url.$amp.'id='.$page['session_id']; |
} |
else |
{ |
return $url.'?id='.$page['session_id']; |
} |
} |
else |
{ |
return $url; |
} |
} |
// cookie_path returns the path to use for the PhpWebGallery cookie. |
// If PhpWebGallery is installed on : |
// http://domain.org/meeting/gallery/category.php |
// cookie_path will return : "/meeting/gallery" |
function cookie_path() |
{ |
return substr($_SERVER['PHP_SELF'],0,strrpos( $_SERVER['PHP_SELF'],'/')); |
} |
?> |
/web/test/gallery/phpwebgallery/include/functions_user.inc.php |
---|
0,0 → 1,382 |
<?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_user.inc.php,v $ |
// | last update : $Date: 2005/01/19 23:34:42 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.37 $ |
// +-----------------------------------------------------------------------+ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
// validate_mail_address verifies whether the given mail address has the |
// right format. ie someone@domain.com "someone" can contain ".", "-" or |
// even "_". Exactly as "domain". The extension doesn't have to be |
// "com". The mail address can also be empty. |
// If the mail address doesn't correspond, an error message is returned. |
function validate_mail_address( $mail_address ) |
{ |
global $lang; |
if ( $mail_address == '' ) |
{ |
return ''; |
} |
$regex = '/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)*\.[a-z]+$/'; |
if ( !preg_match( $regex, $mail_address ) ) |
{ |
return $lang['reg_err_mail_address']; |
} |
} |
function register_user($login, $password, $password_conf, |
$mail_address, $status = 'guest') |
{ |
global $lang, $conf; |
$errors = array(); |
// login must not |
// 1. be empty |
// 2. start ou end with space character |
// 3. include ' or " characters |
// 4. be already used |
if ($login == '') |
{ |
array_push($errors, $lang['reg_err_login1']); |
} |
if (ereg("^.* $", $login)) |
{ |
array_push($errors, $lang['reg_err_login2']); |
} |
if (ereg("^ .*$", $login)) |
{ |
array_push($errors, $lang['reg_err_login3']); |
} |
if (ereg("'", $login) or ereg("\"", $login)) |
{ |
array_push($errors, $lang['reg_err_login4']); |
} |
else |
{ |
$query = ' |
SELECT id |
FROM '.USERS_TABLE.' |
WHERE username = \''.$login.'\' |
;'; |
$result = pwg_query($query); |
if (mysql_num_rows($result) > 0) |
{ |
array_push($errors, $lang['reg_err_login5']); |
} |
} |
// given password must be the same as the confirmation |
if ($password != $password_conf) |
{ |
array_push($errors, $lang['reg_err_pass']); |
} |
$error_mail_address = validate_mail_address($mail_address); |
if ($error_mail_address != '') |
{ |
array_push($errors, $error_mail_address); |
} |
// if no error until here, registration of the user |
if (count($errors) == 0) |
{ |
$insert = array(); |
$insert['username'] = $login; |
$insert['password'] = md5($password); |
$insert['status'] = $status; |
$insert['template'] = $conf['default_template']; |
$insert['nb_image_line'] = $conf['nb_image_line']; |
$insert['nb_line_page'] = $conf['nb_line_page']; |
$insert['language'] = $conf['default_language']; |
$insert['recent_period'] = $conf['recent_period']; |
$insert['expand'] = boolean_to_string($conf['auto_expand']); |
$insert['show_nb_comments'] = boolean_to_string($conf['show_nb_comments']); |
if ( $mail_address != '' ) |
{ |
$insert['mail_address'] = $mail_address; |
} |
if ($conf['default_maxwidth'] != '') |
{ |
$insert['maxwidth'] = $conf['default_maxwidth']; |
} |
if ($conf['default_maxheight'] != '') |
{ |
$insert['maxheight'] = $conf['default_maxheight']; |
} |
$query = ' |
INSERT INTO '.USERS_TABLE.' |
('.implode(',', array_keys($insert)).') |
VALUES |
('; |
$is_first = true; |
foreach (array_keys($insert) as $field) |
{ |
if (!$is_first) |
{ |
$query.= ','; |
} |
$query.= "'".$insert[$field]."'"; |
$is_first = false; |
} |
$query.= ') |
;'; |
pwg_query($query); |
} |
return $errors; |
} |
function update_user( $user_id, $mail_address, $status, |
$use_new_password = false, $password = '' ) |
{ |
$error = array(); |
$i = 0; |
$error_mail_address = validate_mail_address( $mail_address ); |
if ( $error_mail_address != '' ) |
{ |
$error[$i++] = $error_mail_address; |
} |
if ( sizeof( $error ) == 0 ) |
{ |
$query = 'UPDATE '.USERS_TABLE; |
$query.= " SET status = '".$status."'"; |
if ( $use_new_password ) |
{ |
$query.= ", password = '".md5( $password )."'"; |
} |
$query.= ', mail_address = '; |
if ( $mail_address != '' ) |
{ |
$query.= "'".$mail_address."'"; |
} |
else |
{ |
$query.= 'NULL'; |
} |
$query.= ' WHERE id = '.$user_id; |
$query.= ';'; |
pwg_query( $query ); |
} |
return $error; |
} |
function check_login_authorization($guest_allowed = true) |
{ |
global $user,$lang,$conf,$template; |
if ($user['is_the_guest'] and !$guest_allowed) |
{ |
echo '<div style="text-align:center;">'.$lang['only_members'].'<br />'; |
echo '<a href="./identification.php">'.$lang['ident_title'].'</a></div>'; |
exit(); |
} |
if ($conf['gallery_locked']) |
{ |
echo '<div style="text-align:center;">'; |
echo $lang['gallery_locked_message']; |
echo '</div>'; |
if ($user['status'] != 'admin') |
{ |
exit(); |
} |
} |
} |
function setup_style($style) |
{ |
return new Template(PHPWG_ROOT_PATH.'template/'.$style); |
} |
function getuserdata($user) |
{ |
$sql = "SELECT * FROM " . USERS_TABLE; |
$sql.= " WHERE "; |
$sql .= ( ( is_integer($user) ) ? "id = $user" : "username = '" . str_replace("\'", "''", $user) . "'" ) . " AND id <> " . ANONYMOUS; |
$result = pwg_query($sql); |
return ( $row = mysql_fetch_array($result) ) ? $row : false; |
} |
/* |
* deletes favorites of the current user if he's not allowed to see them |
* |
* @return void |
*/ |
function check_user_favorites() |
{ |
global $user; |
if ($user['forbidden_categories'] == '') |
{ |
return; |
} |
$query = ' |
SELECT f.image_id |
FROM '.FAVORITES_TABLE.' AS f INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic |
ON f.image_id = ic.image_id |
WHERE f.user_id = '.$user['id'].' |
AND ic.category_id IN ('.$user['forbidden_categories'].') |
;'; |
$result = pwg_query($query); |
$elements = array(); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($elements, $row['image_id']); |
} |
if (count($elements) > 0) |
{ |
$query = ' |
DELETE FROM '.FAVORITES_TABLE.' |
WHERE image_id IN ('.implode(',', $elements).') |
AND user_id = '.$user['id'].' |
;'; |
pwg_query($query); |
} |
} |
/** |
* update table user_forbidden for the given user |
* |
* table user_forbidden contains calculated data. Calculation is based on |
* private categories minus categories authorized to the groups the user |
* belongs to minus the categories directly authorized to the user |
* |
* @param int user_id |
* @param string user_status |
* @return string forbidden_categories |
*/ |
function calculate_permissions($user_id, $user_status) |
{ |
$private_array = array(); |
$authorized_array = array(); |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE.' |
WHERE status = \'private\' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($private_array, $row['id']); |
} |
// if user is not an admin, locked categories can be considered as private$ |
if ($user_status != 'admin') |
{ |
$query = ' |
SELECT id |
FROM '.CATEGORIES_TABLE.' |
WHERE visible = \'false\' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($private_array, $row['id']); |
} |
$private_array = array_unique($private_array); |
} |
// retrieve category ids directly authorized to the user |
$query = ' |
SELECT cat_id |
FROM '.USER_ACCESS_TABLE.' |
WHERE user_id = '.$user_id.' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($authorized_array, $row['cat_id']); |
} |
// retrieve category ids authorized to the groups the user belongs to |
$query = ' |
SELECT cat_id |
FROM '.USER_GROUP_TABLE.' AS ug INNER JOIN '.GROUP_ACCESS_TABLE.' AS ga |
ON ug.group_id = ga.group_id |
WHERE ug.user_id = '.$user_id.' |
;'; |
$result = pwg_query($query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($authorized_array, $row['cat_id']); |
} |
// uniquify ids : some private categories might be authorized for the |
// groups and for the user |
$authorized_array = array_unique($authorized_array); |
// only unauthorized private categories are forbidden |
$forbidden_array = array_diff($private_array, $authorized_array); |
$query = ' |
DELETE FROM '.USER_FORBIDDEN_TABLE.' |
WHERE user_id = '.$user_id.' |
;'; |
pwg_query($query); |
$forbidden_categories = implode(',', $forbidden_array); |
$query = ' |
INSERT INTO '.USER_FORBIDDEN_TABLE.' |
(user_id,need_update,forbidden_categories) |
VALUES |
('.$user_id.',\'false\',\''.$forbidden_categories.'\') |
;'; |
pwg_query($query); |
return $forbidden_categories; |
} |
/** |
* returns the username corresponding to the given user identifier if exists |
* |
* @param int user_id |
* @return mixed |
*/ |
function get_username($user_id) |
{ |
$query = ' |
SELECT username |
FROM '.USERS_TABLE.' |
WHERE id = '.intval($user_id).' |
;'; |
$result = pwg_query($query); |
if (mysql_num_rows($result) > 0) |
{ |
list($username) = mysql_fetch_row($result); |
} |
else |
{ |
return false; |
} |
return $username; |
} |
?> |
/web/test/gallery/phpwebgallery/include/functions_xml.inc.php |
---|
0,0 → 1,130 |
<?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_xml.inc.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. | |
// +-----------------------------------------------------------------------+ |
define( 'ATT_REG', '\w+' ); |
define( 'VAL_REG', '[^"]*' ); |
//------------------------------------------------------------------- functions |
// getContent returns the content of a tag |
// |
// example : getContent( "<name>Joe</name>" ) returns "Joe" |
// |
// It also works with strings containing themself sub-tags : |
// <perso><name>Jean</name><firstname>Billie</fisrtname></perso> -> |
// <name>Jean</name><firstname>Billie</firstname> |
function getContent( $element ) |
{ |
// deleting start of the tag |
$content = preg_replace( '/^<[^>]+>/', '', $element ); |
// deleting end of the tag |
$content = preg_replace( '/<\/[^>]+>$/', '', $content ); |
// replacing multiple instance of space character |
$content = preg_replace( '/\s+/', ' ', $content ); |
return $content; |
} |
// The function get Attribute returns the value corresponding to the |
// attribute $attribute for the tag $element. |
function getAttribute( $element, $attribute ) |
{ |
// echo htmlentities($element).'<br /><br />'; |
$regex = '/^<\w+[^>]*'.$attribute.'\s*=\s*"('.VAL_REG.')"/i'; |
if ( preg_match( $regex, $element, $out ) ) return $out[1]; |
else return ''; |
} |
function deprecated_getAttribute( $element, $attribute ) |
{ |
// Retrieving string with tag name and all attributes |
$regex = '/^<\w+( '.ATT_REG.'="'.VAL_REG.'")*/'; |
preg_match( $regex, $element, $out ); |
// Splitting string for retrieving separately attributes |
// and corresponding values |
$regex = '/('.ATT_REG.')="('.VAL_REG.')"/'; |
preg_match_all( $regex, $out[0], $out ); |
// Searching and returning the value of the requested attribute |
for ( $i = 0; $i < sizeof( $out[0] ); $i++ ) |
{ |
if ( $out[1][$i] == $attribute ) |
{ |
return $out[2][$i]; |
} |
} |
return ''; |
} |
// The function getChild returns the first child |
// exemple : getChild( "<table><tr>XXX</tr><tr>YYY</tr></table>", "tr" ) |
// returns "<tr>XXX</tr>" |
function getChild( $document, $node ) |
{ |
$regex = '/<'.$node.'(\s+'.ATT_REG.'="'.VAL_REG.'")*'; |
$regex.= '(\s*\/>|>.*<\/'.$node.'>)/U'; |
preg_match( $regex, $document, $out ); |
return $out[0]; |
} |
// getChildren returns a list of the children identified by the $node |
// example : |
// getChild( "<table><tr>XXX</tr><tr>YYY</tr></table>", "tr" ) |
// returns an array with : |
// $array[0] equals "<tr>XXX</tr>" |
// $array[1] equals "<tr>YYY</tr>" |
function getChildren( $document, $node ) |
{ |
$regex = '/<'.$node.'(\s+'.ATT_REG.'="'.VAL_REG.'")*'; |
$regex.= '(\s*\/>|>.*<\/'.$node.'>)/U'; |
preg_match_all( $regex, $document, $out ); |
return $out[0]; |
} |
// get_CodeXML places the content of a text file in a PHP variable and |
// return it. If the file can't be opened, returns false. |
function getXmlCode( $filename ) |
{ |
$file = fopen( $filename, 'r' ); |
if ( !$file ) |
{ |
return false; |
} |
$xml_content = ''; |
while ( !feof( $file ) ) |
{ |
$xml_content .= fgets( $file, 1024 ); |
} |
fclose( $file ); |
$xml_content = str_replace( "\n", '', $xml_content ); |
$xml_content = str_replace( "\t", '', $xml_content ); |
return $xml_content; |
} |
?> |
/web/test/gallery/phpwebgallery/include/index.php |
---|
0,0 → 1,32 |
<?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: index.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. | |
// +-----------------------------------------------------------------------+ |
$url = '../category.php'; |
header( 'Request-URI: '.$url ); |
header( 'Content-Location: '.$url ); |
header( 'Location: '.$url ); |
exit(); |
?> |
/web/test/gallery/phpwebgallery/include/mysql.inc.php |
---|
0,0 → 1,10 |
<?php |
$cfgBase = 'phpwebgallery'; |
$cfgUser = 'chaosdell'; |
$cfgPassword = 'sesvul'; |
$cfgHote = 'localhost'; |
$prefixeTable = 'phpwebgallery_'; |
define('PHPWG_INSTALLED', true); |
?> |
/web/test/gallery/phpwebgallery/include/page_header.php |
---|
0,0 → 1,58 |
<?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: page_header.php,v $ |
// | last update : $Date: 2005/01/30 22:16:31 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.13 $ |
// +-----------------------------------------------------------------------+ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
// |
// Start output of page |
// |
$template->set_filenames(array('header'=>'header.tpl')); |
$css = PHPWG_ROOT_PATH.'template/'.$user['template']; |
$css.= '/'.$user['template'].'.css'; |
$template->assign_vars( |
array( |
'CONTENT_ENCODING' => $lang_info['charset'], |
'PAGE_TITLE' => $title, |
'LANG'=>$lang_info['code'], |
'DIR'=>$lang_info['direction'], |
'T_STYLE' => $css |
)); |
// refresh |
if ( isset( $refresh ) and intval($refresh) >= 0 and isset( $url_link ) ) |
{ |
$template->assign_vars( |
array( |
'REFRESH_TIME' => $refresh, |
'U_REFRESH' => add_session_id( $url_link ) |
)); |
$template->assign_block_vars('refresh', array()); |
} |
$template->parse('header'); |
?> |
/web/test/gallery/phpwebgallery/include/page_tail.php |
---|
0,0 → 1,66 |
<?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: page_tail.php,v $ |
// | last update : $Date: 2005/05/01 07:47:49 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.18.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. | |
// +-----------------------------------------------------------------------+ |
$template->set_filenames(array('tail'=>'footer.tpl')); |
$template->assign_vars( |
array( |
'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', |
'MAIL'=>$conf['mail_webmaster'], |
'L_GEN_TIME' => $lang['generation_time'], |
'L_SQL_QUERIES_IN' => $lang['sql_queries_in'], |
'L_SEND_MAIL' => $lang['send_mail'], |
'L_TITLE_MAIL' => $lang['title_send_mail'], |
'L_WEBMASTER'=>$lang['webmaster'], |
'L_POWERED_BY'=>$lang['powered_by'] |
)); |
//------------------------------------------------------------- generation time |
if ($conf['show_gt']) |
{ |
$time = get_elapsed_time($t2, get_moment()); |
if (!isset($page['count_queries'])) |
{ |
$page['count_queries'] = 0; |
$page['queries_time'] = 0; |
} |
$template->assign_block_vars( |
'debug', |
array('TIME' => $time, |
'NB_QUERIES' => $page['count_queries'], |
'SQL_TIME' => number_format($page['queries_time'],3,'.',' ').' s')); |
} |
// |
// Generate the page |
// |
$template->parse('tail'); |
$template->p(); |
?> |
/web/test/gallery/phpwebgallery/include/scripts.js |
---|
0,0 → 1,32 |
function SelectAll( formulaire ) |
{ |
len = formulaire.elements.length; |
var i=0; |
for( i = 0; i < len; i++) |
{ |
if ( formulaire.elements[i].type=='checkbox' |
&& formulaire.elements[i].name != 'copie') |
{ |
formulaire.elements[i].checked = true; |
} |
} |
} |
function Inverser( formulaire ) |
{ |
len = formulaire.elements.length; |
var i=0; |
for( i=0; i<len; i++) |
{ |
if ( formulaire.elements[i].type=='checkbox' |
&& formulaire.elements[i].name != 'copie') |
{ |
formulaire.elements[i].checked = !formulaire.elements[i].checked; |
} |
} |
} |
function phpWGOpenWindow(theURL,winName,features) |
{ |
window.open(theURL,winName,features); |
} |
/web/test/gallery/phpwebgallery/include/template.php |
---|
0,0 → 1,523 |
<?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: template.php,v $ |
// | last update : $Date: 2005/03/12 10:51:08 $ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
/** |
* Template class. By Nathan Codding of the phpBB group. The interface was |
* originally inspired by PHPLib templates, and the template file formats |
* are quite similar. |
*/ |
class Template { |
var $classname = "Template"; |
// variable that holds all the data we'll be substituting into |
// the compiled templates. |
// ... |
// This will end up being a multi-dimensional array like this : |
// $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value |
// if it's a root-level variable, it'll be like this: |
// $this->_tpldata[.][0][varname] == value |
var $_tpldata = array(); |
// Hash of filenames for each template handle. |
var $files = array(); |
// Root template directory. |
var $root = ""; |
// this will hash handle names to the compiled code for that handle. |
var $compiled_code = array(); |
// This will hold the uncompiled code for that handle. |
var $uncompiled_code = array(); |
// output |
var $output = ''; |
/** |
* Constructor. Simply sets the root dir. |
* |
*/ |
function Template($root = ".") |
{ |
$this->set_rootdir($root); |
} |
/** |
* Destroys this template object. Should be called when you're done with |
* it, in order to clear out the template data so you can load/parse a new |
* template set. |
*/ |
function destroy() |
{ |
$this->_tpldata = array(); |
} |
/** |
* Sets the template root directory for this Template object. |
*/ |
function set_rootdir($dir) |
{ |
if (!is_dir($dir)) |
{ |
return false; |
} |
$this->root = $dir; |
return true; |
} |
/** |
* Sets the template filenames for handles. $filename_array should be a |
* hash of handle => filename pairs. |
*/ |
function set_filenames($filename_array) |
{ |
if (!is_array($filename_array)) |
{ |
return false; |
} |
reset($filename_array); |
while(list($handle, $filename) = each($filename_array)) |
{ |
$this->files[$handle] = $this->make_filename($filename); |
} |
return true; |
} |
/** |
* Load the file for the handle, compile the file, and run the compiled |
* code. This will print out the results of executing the template. |
*/ |
function pparse($handle) |
{ |
if (!$this->loadfile($handle)) |
{ |
die("Template->pparse(): Couldn't load template file for handle $handle"); |
} |
// actually compile the template now. |
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) |
{ |
// Actually compile the code now. |
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]); |
} |
// Run the compiled code. |
//echo ("<!-- ".$this->compiled_code[$handle]." -->"); |
eval($this->compiled_code[$handle]); |
return true; |
} |
/** |
* fills $output template var |
*/ |
function parse($handle) |
{ |
if (!$this->loadfile($handle)) |
{ |
die("Template->pparse(): Couldn't load template file for handle $handle"); |
} |
// actually compile the template now. |
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) |
{ |
// Actually compile the code now. |
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle], true, '_str'); |
} |
// Run the compiled code. |
$_str = ''; |
eval($this->compiled_code[$handle]); |
$this->output.= $_str; |
return true; |
} |
/** |
* prints $output template var |
*/ |
function p() |
{ |
echo $this->output; |
} |
/** |
* Inserts the uncompiled code for $handle as the value of $varname in the |
* root-level. This can be used to effectively include a template in the |
* middle of another template. |
* |
* Note that all desired assignments to the variables in $handle should be |
* done BEFORE calling this function. |
*/ |
function assign_var_from_handle($varname, $handle) |
{ |
if (!$this->loadfile($handle)) |
{ |
die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle"); |
} |
// Compile it, with the "no echo statements" option on. |
$_str = ""; |
$code = $this->compile($this->uncompiled_code[$handle], true, '_str'); |
// evaluate the variable assignment. |
eval($code); |
// assign the value of the generated variable to the given varname. |
$this->assign_var($varname, $_str); |
return true; |
} |
/** |
* Block-level variable assignment. Adds a new block iteration with the |
* given variable assignments. Note that this should only be called once |
* per block iteration. |
*/ |
function assign_block_vars($blockname, $vararray) |
{ |
if (strstr($blockname, '.')) |
{ |
// Nested block. |
$blocks = explode('.', $blockname); |
$blockcount = sizeof($blocks) - 1; |
$str = '$this->_tpldata'; |
for ($i = 0; $i < $blockcount; $i++) |
{ |
$str .= '[\'' . $blocks[$i] . '.\']'; |
eval('$lastiteration = sizeof(' . $str . ') - 1;'); |
$str .= '[' . $lastiteration . ']'; |
} |
// Now we add the block that we're actually assigning to. |
// We're adding a new iteration to this block with the given |
// variable assignments. |
$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;'; |
// Now we evaluate this assignment we've built up. |
eval($str); |
} |
else |
{ |
// Top-level block. Add a new iteration to this block with the |
// variable assignments we were given. |
$this->_tpldata[$blockname . '.'][] = $vararray; |
} |
return true; |
} |
/** |
* Root-level variable assignment. Adds to current assignments, overriding |
* any existing variable assignment with the same name. |
*/ |
function assign_vars($vararray) |
{ |
reset ($vararray); |
while (list($key, $val) = each($vararray)) |
{ |
$this->_tpldata['.'][0][$key] = $val; |
} |
return true; |
} |
/** |
* Root-level variable assignment. Adds to current assignments, overriding |
* any existing variable assignment with the same name. |
*/ |
function assign_var($varname, $varval) |
{ |
$this->_tpldata['.'][0][$varname] = $varval; |
return true; |
} |
/** |
* Generates a full path+filename for the given filename, which can either |
* be an absolute name, or a name relative to the rootdir for this |
* Template object. |
*/ |
function make_filename($filename) |
{ |
// Check if it's an absolute or relative path. |
if (substr($filename, 0, 1) != '/') |
{ |
$filename = $this->root.'/'.$filename; |
} |
if (!file_exists($filename)) |
{ |
die("Template->make_filename(): Error - file $filename does not exist"); |
} |
return $filename; |
} |
/** |
* If not already done, load the file for the given handle and populate |
* the uncompiled_code[] hash with its code. Do not compile. |
*/ |
function loadfile($handle) |
{ |
// If the file for this handle is already loaded and compiled, do |
// nothing. |
if (isset($this->uncompiled_code[$handle]) |
and !empty($this->uncompiled_code[$handle])) |
{ |
return true; |
} |
// If we don't have a file assigned to this handle, die. |
if (!isset($this->files[$handle])) |
{ |
die("Template->loadfile(): No file specified for handle $handle"); |
} |
$filename = $this->files[$handle]; |
$str = implode("", @file($filename)); |
if (empty($str)) |
{ |
die("Template->loadfile(): File $filename for handle $handle is empty"); |
} |
$this->uncompiled_code[$handle] = $str; |
return true; |
} |
/** |
* Compiles the given string of code, and returns the result in a string. |
* |
* If "do_not_echo" is true, the returned code will not be directly |
* executable, but can be used as part of a variable assignment for use in |
* assign_code_from_handle(). |
*/ |
function compile($code, $do_not_echo = false, $retvar = '') |
{ |
// replace \ with \\ and then ' with \'. |
$code = str_replace('\\', '\\\\', $code); |
$code = str_replace('\'', '\\\'', $code); |
// change template varrefs into PHP varrefs |
// This one will handle varrefs WITH namespaces |
$varrefs = array(); |
preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs); |
$varcount = sizeof($varrefs[1]); |
for ($i = 0; $i < $varcount; $i++) |
{ |
$namespace = $varrefs[1][$i]; |
$varname = $varrefs[3][$i]; |
$new = $this->generate_block_varref($namespace, $varname); |
$code = str_replace($varrefs[0][$i], $new, $code); |
} |
// This will handle the remaining root-level varrefs |
$code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . ( ( isset($this->_tpldata[\'.\'][0][\'\1\']) ) ? $this->_tpldata[\'.\'][0][\'\1\'] : \'\' ) . \'', $code); |
// Break it up into lines. |
$code_lines = explode("\n", $code); |
$block_nesting_level = 0; |
$block_names = array(); |
$block_names[0] = "."; |
// Second: prepend echo ', append ' . "\n"; to each line. |
$line_count = sizeof($code_lines); |
for ($i = 0; $i < $line_count; $i++) |
{ |
$code_lines[$i] = chop($code_lines[$i]); |
if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m)) |
{ |
$n[0] = $m[0]; |
$n[1] = $m[1]; |
// Added: dougk_ff7-Keeps templates from bombing if begin is on |
// the same line as end.. I think. :) |
if ( preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n) ) |
{ |
$block_nesting_level++; |
$block_names[$block_nesting_level] = $m[1]; |
if ($block_nesting_level < 2) |
{ |
// Block is not nested. |
$code_lines[$i] = '$_' . $n[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;'; |
$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; |
$code_lines[$i] .= "\n" . '{'; |
} |
else |
{ |
// This block is nested. |
// Generate a namespace string for this block. |
$namespace = implode('.', $block_names); |
// strip leading period from root level.. |
$namespace = substr($namespace, 2); |
// Get a reference to the data array for this block that depends on the |
// current indices of all parent blocks. |
$varref = $this->generate_block_data_ref($namespace, false); |
// Create the for loop code to iterate over this block. |
$code_lines[$i] = '$_' . $n[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; |
$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; |
$code_lines[$i] .= "\n" . '{'; |
} |
// We have the end of a block. |
unset($block_names[$block_nesting_level]); |
$block_nesting_level--; |
$code_lines[$i] .= '} // END ' . $n[1]; |
$m[0] = $n[0]; |
$m[1] = $n[1]; |
} |
else |
{ |
// We have the start of a block. |
$block_nesting_level++; |
$block_names[$block_nesting_level] = $m[1]; |
if ($block_nesting_level < 2) |
{ |
// Block is not nested. |
$code_lines[$i] = '$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;'; |
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; |
$code_lines[$i] .= "\n" . '{'; |
} |
else |
{ |
// This block is nested. |
// Generate a namespace string for this block. |
$namespace = implode('.', $block_names); |
// strip leading period from root level.. |
$namespace = substr($namespace, 2); |
// Get a reference to the data array for this block that |
// depends on the current indices of all parent blocks. |
$varref = $this->generate_block_data_ref($namespace, false); |
// Create the for loop code to iterate over this block. |
$code_lines[$i] = '$_' . $m[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; |
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; |
$code_lines[$i] .= "\n" . '{'; |
} |
} |
} |
else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m)) |
{ |
// We have the end of a block. |
unset($block_names[$block_nesting_level]); |
$block_nesting_level--; |
$code_lines[$i] = '} // END ' . $m[1]; |
} |
else |
{ |
// We have an ordinary line of code. |
if (!$do_not_echo) |
{ |
$code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";'; |
} |
else |
{ |
$code_lines[$i] = '$' . $retvar . '.= \'' . $code_lines[$i] . '\' . "\\n";'; |
} |
} |
} |
// Bring it back into a single string of lines of code. |
$code = implode("\n", $code_lines); |
return $code ; |
} |
/** |
* Generates a reference to the given variable inside the given (possibly |
* nested) block namespace. This is a string of the form: ' |
* . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] |
* . ' It's ready to be inserted into an "echo" line in one of the |
* templates. NOTE: expects a trailing "." on the namespace. |
*/ |
function generate_block_varref($namespace, $varname) |
{ |
// Strip the trailing period. |
$namespace = substr($namespace, 0, strlen($namespace) - 1); |
// Get a reference to the data block for this namespace. |
$varref = $this->generate_block_data_ref($namespace, true); |
// Prepend the necessary code to stick this in an echo line. |
// Append the variable reference. |
$varref .= '[\'' . $varname . '\']'; |
$varref = '\' . ( ( isset(' . $varref . ') ) ? ' . $varref . ' : \'\' ) . \''; |
return $varref; |
} |
/** |
* Generates a reference to the array of data values for the given |
* (possibly nested) block namespace. This is a string of the form: |
* $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
* |
* If $include_last_iterator is true, then [$_childN_i] will be appended |
* to the form shown above. NOTE: does not expect a trailing "." on the |
* blockname. |
*/ |
function generate_block_data_ref($blockname, $include_last_iterator) |
{ |
// Get an array of the blocks involved. |
$blocks = explode(".", $blockname); |
$blockcount = sizeof($blocks) - 1; |
$varref = '$this->_tpldata'; |
// Build up the string with everything but the last child. |
for ($i = 0; $i < $blockcount; $i++) |
{ |
$varref .= '[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]'; |
} |
// Add the block reference for the last child. |
$varref .= '[\'' . $blocks[$blockcount] . '.\']'; |
// Add the iterator for the last child if requried. |
if ($include_last_iterator) |
{ |
$varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
} |
return $varref; |
} |
} |
?> |
/web/test/gallery/phpwebgallery/include/user.inc.php |
---|
0,0 → 1,184 |
<?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.inc.php,v $ |
// | last update : $Date: 2005/01/08 11:23:52 $ |
// | last modifier : $Author: plg $ |
// | revision : $Revision: 1.29 $ |
// +-----------------------------------------------------------------------+ |
// | 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. | |
// +-----------------------------------------------------------------------+ |
// retrieving connected user informations |
if (isset($_COOKIE['id'])) |
{ |
$session_id = $_COOKIE['id']; |
$user['has_cookie'] = true; |
} |
else if (isset($_GET['id'])) |
{ |
$session_id = $_GET['id']; |
$user['has_cookie'] = false; |
} |
else |
{ |
$user['has_cookie'] = false; |
} |
if (isset($session_id) |
and ereg("^[0-9a-zA-Z]{".$conf['session_id_size']."}$", $session_id)) |
{ |
$page['session_id'] = $session_id; |
$query = ' |
SELECT user_id,expiration,NOW() AS now |
FROM '.SESSIONS_TABLE.' |
WHERE id = \''.$page['session_id'].'\' |
;'; |
$result = pwg_query($query); |
if (mysql_num_rows($result) > 0) |
{ |
$row = mysql_fetch_array($result); |
if (strnatcmp($row['expiration'], $row['now']) < 0) |
{ |
// deletion of the session from the database, because it is |
// out-of-date |
$delete_query = ' |
DELETE FROM '.SESSIONS_TABLE.' |
WHERE id = \''.$page['session_id'].'\' |
;'; |
pwg_query($delete_query); |
} |
else |
{ |
$user['id'] = $row['user_id']; |
$user['is_the_guest'] = false; |
} |
} |
} |
if (!isset($user['id'])) |
{ |
$user['id'] = 2; |
$user['is_the_guest'] = true; |
} |
$query = ' |
SELECT u.*, uf.* |
FROM '.USERS_TABLE.' AS u LEFT JOIN '.USER_FORBIDDEN_TABLE.' AS uf |
ON id = user_id |
WHERE u.id = '.$user['id'].' |
;'; |
$row = mysql_fetch_array(pwg_query($query)); |
// affectation of each value retrieved in the users table into a variable of |
// the array $user. |
foreach ($row as $key => $value) |
{ |
if (!is_numeric($key)) |
{ |
// If the field is true or false, the variable is transformed into a |
// boolean value. |
if ($value == 'true' or $value == 'false') |
{ |
$user[$key] = get_boolean($value); |
} |
else |
{ |
$user[$key] = $value; |
} |
} |
} |
// properties of user guest are found in the configuration |
if ($user['is_the_guest']) |
{ |
$user['template'] = $conf['default_template']; |
$user['nb_image_line'] = $conf['nb_image_line']; |
$user['nb_line_page'] = $conf['nb_line_page']; |
$user['language'] = $conf['default_language']; |
$user['maxwidth'] = $conf['default_maxwidth']; |
$user['maxheight'] = $conf['default_maxheight']; |
$user['recent_period'] = $conf['recent_period']; |
$user['expand'] = $conf['auto_expand']; |
$user['show_nb_comments'] = $conf['show_nb_comments']; |
} |
// if no information were found about user in user_forbidden table OR the |
// forbidden categories must be updated : only if current user is in public |
// part |
if (!defined('IN_ADMIN') or !IN_ADMIN) |
{ |
if (!isset($user['need_update']) |
or !is_bool($user['need_update']) |
or $user['need_update'] == true) |
{ |
$user['forbidden_categories'] = calculate_permissions($user['id'], |
$user['status']); |
} |
} |
// forbidden_categories is a must be empty, at least |
if (!isset($user['forbidden_categories'])) |
{ |
$user['forbidden_categories'] = ''; |
} |
// special for $user['restrictions'] array |
$user['restrictions'] = explode(',', $user['forbidden_categories']); |
if ($user['restrictions'][0] == '') |
{ |
$user['restrictions'] = array(); |
} |
// calculation of the number of picture to display per page |
$user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; |
if (empty($user['language']) |
or !file_exists(PHPWG_ROOT_PATH.'language/'. |
$user['language'].'/common.lang.php')) |
{ |
$user['language'] = $conf['default_language']; |
} |
include_once(PHPWG_ROOT_PATH.'language/'.$user['language'].'/common.lang.php'); |
// displaying the username in the language of the connected user, instead of |
// "guest" as you can find in the database |
if ($user['is_the_guest']) |
{ |
$user['username'] = $lang['guest']; |
} |
// only if we are in the administration section |
if (defined('IN_ADMIN') and IN_ADMIN) |
{ |
$langdir = PHPWG_ROOT_PATH.'language/'.$user['language']; |
if (!file_exists($langdir.'/admin.lang.php')) |
{ |
$langdir = PHPWG_ROOT_PATH.'language/'.$conf['default_language']; |
} |
include_once($langdir.'/admin.lang.php'); |
include_once($langdir.'/faq.lang.php'); |
} |
if (empty($user['template'])) |
{ |
$user['template'] = $conf['default_template']; |
} |
$template = setup_style($user['template']); |
?> |