Compare commits
18 commits
Author | SHA1 | Date | |
---|---|---|---|
|
50d99d7f43 | ||
|
db2ac75bb6 | ||
|
f05a541c55 | ||
|
6615c91e30 | ||
|
38326b5c93 | ||
|
ab9097cfec | ||
|
4647d2281a | ||
|
93277f9fbb | ||
|
39e65897dc | ||
|
600c108a1f | ||
|
2e14b0a79f | ||
|
22b608fd64 | ||
|
65c52a2a20 | ||
|
7b5bb0e3fc | ||
|
6f269bc035 | ||
|
b56bd6748a | ||
|
6b5f3a4a82 | ||
|
0a848308df |
16 changed files with 177 additions and 42 deletions
|
@ -329,7 +329,7 @@ else
|
|||
$template->assign_vars(array(
|
||||
'CATEGORIES_NAV'=>$navigation,
|
||||
'NEXT_RANK'=>$next_rank,
|
||||
'F_ACTION'=>$form_action,
|
||||
'F_ACTION'=>add_session_id($form_action),
|
||||
|
||||
'L_ADD_VIRTUAL'=>$lang['cat_add'],
|
||||
'L_SUBMIT'=>$lang['submit'],
|
||||
|
|
|
@ -66,12 +66,8 @@ if (isset($_POST['submit']))
|
|||
{
|
||||
array_push($errors, $lang['conf_prefix_thumbnail_error']);
|
||||
}
|
||||
// mail must be formatted as follows : name@server.com
|
||||
$pattern = '/^[\w-]+(\.[\w-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/';
|
||||
if (!preg_match($pattern, $_POST['mail_webmaster']))
|
||||
{
|
||||
array_push($errors, $lang['conf_mail_webmaster_error']);
|
||||
}
|
||||
// as webmaster mail address shown on the website, it can be obfuscated
|
||||
// and no comply with normal mail address pattern
|
||||
break;
|
||||
}
|
||||
case 'comments' :
|
||||
|
@ -94,6 +90,22 @@ if (isset($_POST['submit']))
|
|||
{
|
||||
array_push($errors, $lang['periods_error']);
|
||||
}
|
||||
// maxwidth
|
||||
if (isset($_POST['default_maxwidth'])
|
||||
and !empty($_POST['default_maxwidth'])
|
||||
and (!preg_match($int_pattern, $_POST['default_maxwidth'])
|
||||
or $_POST['default_maxwidth'] < 50))
|
||||
{
|
||||
array_push($errors, $lang['maxwidth_error']);
|
||||
}
|
||||
// maxheight
|
||||
if (isset($_POST['default_maxheight'])
|
||||
and !empty($_POST['default_maxheight'])
|
||||
and (!preg_match($int_pattern, $_POST['default_maxheight'])
|
||||
or $_POST['default_maxheight'] < 50))
|
||||
{
|
||||
array_push($errors, $lang['maxheight_error']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'upload' :
|
||||
|
@ -255,6 +267,8 @@ switch ($page['section'])
|
|||
'CONF_STYLE_SELECT'=>style_select($conf['default_template'], 'default_template'),
|
||||
'CONF_RECENT'=>$conf['recent_period'],
|
||||
'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
|
||||
'MAXWIDTH'=>$conf['default_maxwidth'],
|
||||
'MAXHEIGHT'=>$conf['default_maxheight'],
|
||||
'EXPAND_YES'=>$expand_yes,
|
||||
'EXPAND_NO'=>$expand_no,
|
||||
'SHOW_COMMENTS_YES'=>$show_yes,
|
||||
|
|
|
@ -159,7 +159,33 @@ else
|
|||
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
$url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id'];
|
||||
$url_img .= '&cat='.$row['storage_category_id'];
|
||||
|
||||
$query = '
|
||||
SELECT category_id
|
||||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
WHERE image_id = '.$_GET['image_id'];
|
||||
|
||||
if (isset($user['forbidden_categories'])
|
||||
and !empty($user['forbidden_categories']))
|
||||
{
|
||||
$query.= '
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')';
|
||||
}
|
||||
$query.= '
|
||||
ORDER BY RAND()
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
if (mysql_num_rows($result) > 0)
|
||||
{
|
||||
list($category_id) = mysql_fetch_array($result);
|
||||
$url_img .= '&cat='.$category_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$url_img .= '&cat='.$row['storage_category_id'];
|
||||
}
|
||||
|
||||
$date = isset($_POST['date_creation']) && empty($errors)
|
||||
?$_POST['date_creation']:date_convert_back(@$row['date_creation']);
|
||||
|
||||
|
|
|
@ -453,6 +453,62 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
|
|||
echo '<!-- scanning files : ';
|
||||
echo get_elapsed_time($start_files, get_moment());
|
||||
echo ' -->'."\n";
|
||||
|
||||
// retrieving informations given by uploaders
|
||||
if (!$simulate)
|
||||
{
|
||||
$query = '
|
||||
SELECT id,file,storage_category_id,infos
|
||||
FROM '.WAITING_TABLE.'
|
||||
WHERE storage_category_id IN (
|
||||
'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
|
||||
AND validated = \'true\'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
$datas = array();
|
||||
$fields =
|
||||
array(
|
||||
'primary' => array('id'),
|
||||
'update' => array('date_creation', 'author', 'name', 'comment')
|
||||
);
|
||||
|
||||
$waiting_to_delete = array();
|
||||
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$query = '
|
||||
SELECT id
|
||||
FROM '.IMAGES_TABLE.'
|
||||
WHERE storage_category_id = \''.$row['storage_category_id'].'\'
|
||||
AND file = \''.$row['file'].'\'
|
||||
;';
|
||||
list($data['id']) = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
foreach ($fields['update'] as $field)
|
||||
{
|
||||
$data[$field] = getAttribute($row['infos'], $field);
|
||||
}
|
||||
|
||||
array_push($datas, $data);
|
||||
array_push($waiting_to_delete, $row['id']);
|
||||
}
|
||||
|
||||
if (count($datas) > 0)
|
||||
{
|
||||
mass_updates(IMAGES_TABLE, $fields, $datas);
|
||||
|
||||
// delete now useless waiting elements
|
||||
$query = '
|
||||
DELETE
|
||||
FROM '.WAITING_TABLE.'
|
||||
WHERE id IN ('.implode(',', $waiting_to_delete).')
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template initialization |
|
||||
|
|
17
category.php
17
category.php
|
@ -183,13 +183,16 @@ $template->assign_block_vars(
|
|||
'NAME' => $lang['most_visited_cat']
|
||||
));
|
||||
// best rated
|
||||
$template->assign_block_vars(
|
||||
'special_cat',
|
||||
array(
|
||||
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
|
||||
'TITLE' => $lang['best_rated_cat_hint'],
|
||||
'NAME' => $lang['best_rated_cat']
|
||||
));
|
||||
if ($conf['rate'])
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'special_cat',
|
||||
array(
|
||||
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
|
||||
'TITLE' => $lang['best_rated_cat_hint'],
|
||||
'NAME' => $lang['best_rated_cat']
|
||||
));
|
||||
}
|
||||
// random
|
||||
$template->assign_block_vars(
|
||||
'special_cat',
|
||||
|
|
|
@ -406,7 +406,7 @@ SELECT file,tn_ext,'.$conf['calendar_datefield'].',path
|
|||
$url_link.= '&search='.$conf['calendar_datefield'].':'.$_GET['day'];
|
||||
if ($calendar_category != 0)
|
||||
{
|
||||
$url_link.= ';cat:'.$calendar_category.'|AND';
|
||||
$url_link.= '--cat:'.$calendar_category.'|AND';
|
||||
}
|
||||
|
||||
$template->assign_block_vars(
|
||||
|
|
|
@ -191,4 +191,8 @@ $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;
|
||||
?>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// Default settings
|
||||
define('PHPWG_VERSION', '1.4.0RC3');
|
||||
define('PHPWG_VERSION', '1.4.1');
|
||||
define('PHPWG_URL', 'http://www.phpwebgallery.net');
|
||||
define('PHPWG_FORUM_URL', 'http://forum.phpwebgallery.net');
|
||||
|
||||
|
|
|
@ -340,11 +340,11 @@ INSERT INTO '.HISTORY_TABLE.'
|
|||
(date,login,IP,file,category,picture)
|
||||
VALUES
|
||||
(NOW(),
|
||||
\''.(($user['id'] == 2) ? 'guest' : $user['username']).'\',
|
||||
\''.(($user['id'] == 2) ? 'guest' : addslashes($user['username'])).'\',
|
||||
\''.$_SERVER['REMOTE_ADDR'].'\',
|
||||
\''.$file.'\',
|
||||
\''.$category.'\',
|
||||
\''.$picture.'\')
|
||||
\''.addslashes($file).'\',
|
||||
\''.addslashes($category).'\',
|
||||
\''.addslashes($picture).'\')
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
|
|
|
@ -155,20 +155,30 @@ SELECT name,id,date_last,nb_images,global_rank
|
|||
return get_html_menu_category($cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the total number of elements viewable in the gallery by the
|
||||
* connected user
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
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.= ';';
|
||||
$query = '
|
||||
SELECT COUNT(DISTINCT(image_id)) as total
|
||||
FROM '.IMAGE_CATEGORY_TABLE;
|
||||
if (count($user['restrictions']) > 0)
|
||||
{
|
||||
$query.= '
|
||||
WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
|
||||
}
|
||||
$query.= '
|
||||
;';
|
||||
|
||||
$row = mysql_fetch_array( pwg_query( $query ) );
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
if ( !isset( $row['total'] ) ) $row['total'] = 0;
|
||||
return $row['total'];
|
||||
return isset($row['total']) ? $row['total'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -389,7 +399,7 @@ function initialize_category( $calling_page = 'category' )
|
|||
$search['mode'] = 'OR';
|
||||
}
|
||||
|
||||
$search_tokens = explode(';', $tokens[0]);
|
||||
$search_tokens = explode('--', $tokens[0]);
|
||||
foreach ($search_tokens as $search_token)
|
||||
{
|
||||
$tokens = explode(':', $search_token);
|
||||
|
|
|
@ -403,8 +403,7 @@ function get_html_menu_category($categories)
|
|||
{
|
||||
$menu.= '
|
||||
<span class="menuInfoCat"
|
||||
title="'.$category['nb_images'].'
|
||||
'.$lang['images_available'].'">
|
||||
title="'.$category['nb_images'].' '.$lang['images_available'].'">
|
||||
['.$category['nb_images'].']
|
||||
</span>
|
||||
'.get_icon($category['date_last']);
|
||||
|
|
|
@ -233,26 +233,42 @@ function check_user_favorites()
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// retrieving images allowed : belonging to at least one authorized
|
||||
// category
|
||||
$query = '
|
||||
SELECT f.image_id
|
||||
SELECT DISTINCT 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'].')
|
||||
AND ic.category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
$elements = array();
|
||||
$authorizeds = array();
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
array_push($elements, $row['image_id']);
|
||||
array_push($authorizeds, $row['image_id']);
|
||||
}
|
||||
|
||||
if (count($elements) > 0)
|
||||
$query = '
|
||||
SELECT image_id
|
||||
FROM '.FAVORITES_TABLE.'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
$favorites = array();
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
array_push($favorites, $row['image_id']);
|
||||
}
|
||||
|
||||
$to_deletes = array_diff($favorites, $authorizeds);
|
||||
|
||||
if (count($to_deletes) > 0)
|
||||
{
|
||||
$query = '
|
||||
DELETE FROM '.FAVORITES_TABLE.'
|
||||
WHERE image_id IN ('.implode(',', $elements).')
|
||||
WHERE image_id IN ('.implode(',', $to_deletes).')
|
||||
AND user_id = '.$user['id'].'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
|
|
@ -28,7 +28,7 @@ $template->set_filenames(array('tail'=>'footer.tpl'));
|
|||
|
||||
$template->assign_vars(
|
||||
array(
|
||||
'VERSION' => PHPWG_VERSION,
|
||||
'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
|
||||
'MAIL'=>$conf['mail_webmaster'],
|
||||
|
||||
'L_GEN_TIME' => $lang['generation_time'],
|
||||
|
|
|
@ -31,6 +31,12 @@ define('PHPWG_ROOT_PATH','./');
|
|||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
//-------------------------------------------------- access authorization check
|
||||
check_cat_id( $_GET['cat'] );
|
||||
|
||||
if (!isset($page['cat']))
|
||||
{
|
||||
die($lang['access_forbiden']);
|
||||
}
|
||||
|
||||
check_login_authorization();
|
||||
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ if (isset($_POST['submit']))
|
|||
}
|
||||
array_push($tokens, $token);
|
||||
}
|
||||
$search_string.= implode(';', $tokens);
|
||||
$search_string.= implode('--', $tokens);
|
||||
if (count($tokens) > 1)
|
||||
{
|
||||
$search_string.= '|AND';
|
||||
|
@ -204,6 +204,7 @@ include(PHPWG_ROOT_PATH.'include/page_header.php');
|
|||
|
||||
$template->set_filenames( array('search'=>'search.tpl') );
|
||||
$template->assign_vars(array(
|
||||
'L_RETURN_HINT' => $lang['home_hint'],
|
||||
'L_SEARCH_TITLE' => $lang['search_title'],
|
||||
'L_SEARCH_OPTIONS' => $lang['search_options'],
|
||||
'L_RETURN' => $lang['home'],
|
||||
|
|
|
@ -42,7 +42,7 @@ $conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF');
|
|||
|
||||
// $conf['version'] is used to verify the compatibility of the generated
|
||||
// listing.xml file and the PhpWebGallery version you're running
|
||||
$conf['version'] = '1.4.0RC3';
|
||||
$conf['version'] = '1.4.1';
|
||||
|
||||
// $conf['use_exif'] set to true if you want to use Exif Date as "creation
|
||||
// date" for the element, otherwise, set to false
|
||||
|
|
Loading…
Reference in a new issue