*
* *
* $Id$
@@ -19,142 +19,162 @@
include_once( './admin/include/isadmin.inc.php' );
//------------------------------------------------------------------- functions
-function insert_local_category( $cat_id )
+function insert_local_category( $id_uppercat )
{
global $conf, $page, $user, $lang;
-
- $site_id = 1;
+
+ $uppercats = '';
+ $output = '';
// 0. retrieving informations on the category to display
$cat_directory = './galleries';
-
- if ( is_numeric( $cat_id ) )
+ if ( is_numeric( $id_uppercat ) )
{
- $cat_directory.= '/'.get_local_dir( $cat_id );
- $result = get_cat_info( $cat_id );
+ $query = 'SELECT name,uppercats,dir';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE id = '.$id_uppercat;
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $uppercats = $row['uppercats'];
+ $name = $row['name'];
+ $dir = $row['dir'];
+
+ $upper_array = explode( ',', $uppercats );
+
+ $local_dir = '';
+
+ $database_dirs = array();
+ $query = 'SELECT id,dir';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE id IN ('.$uppercats.')';
+ $query.= ';';
+ $result = mysql_query( $query );
+ while( $row = mysql_fetch_array( $result ) )
+ {
+ $database_dirs[$row['id']] = $row['dir'];
+ }
+ foreach ( $upper_array as $id ) {
+ $local_dir.= $database_dirs[$id].'/';
+ }
+
+ $cat_directory.= '/'.$local_dir;
+
// 1. display the category name to update
$src = './template/'.$user['template'].'/admin/images/puce.gif';
$output = '
';
- $output.= ''.$result['name'][0].'';
- $output.= ' [ '.$result['dir'].' ]';
+ $output.= ''.$name.'';
+ $output.= ' [ '.$dir.' ]';
$output.= '';
// 2. we search pictures of the category only if the update is for all
// or a cat_id is specified
if ( isset( $page['cat'] ) or $_GET['update'] == 'all' )
{
- $output.= insert_local_image( $cat_directory, $cat_id );
+ $output.= insert_local_image( $cat_directory, $id_uppercat );
}
}
- // 3. we have to remove the categories of the database not present anymore
- $query = 'SELECT id';
+ $sub_dirs = get_category_directories( $cat_directory );
+
+ $sub_category_dirs = array();
+ $query = 'SELECT id,dir';
$query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE site_id = '.$site_id;
- if ( !is_numeric( $cat_id ) )
- {
- $query.= ' AND id_uppercat IS NULL';
- }
- else
- {
- $query.= ' AND id_uppercat = '.$cat_id;
- }
+ $query.= ' WHERE site_id = 1';
+ if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
+ else $query.= ' AND id_uppercat = '.$id_uppercat;
+ $query.= ' AND dir IS NOT NULL'; // virtual categories not taken
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
- // retrieving the directory
- $rep = './galleries/'.get_local_dir( $row['id'] );
- // is the directory present ?
- if ( !is_dir( $rep ) ) delete_category( $row['id'] );
+ $sub_category_dirs[$row['id']] = $row['dir'];
}
- // 4. retrieving the sub-directories
- $subdirs = array();
- $dirs = '';
- if ( $opendir = opendir( $cat_directory ) )
- {
- while ( $file = readdir( $opendir ) )
+
+ // 3. we have to remove the categories of the database not present anymore
+ foreach ( $sub_category_dirs as $id => $dir ) {
+ if ( !in_array( $dir, $sub_dirs ) ) delete_category( $id );
+ }
+
+ // array of new categories to insert
+ $inserts = array();
+
+ foreach ( $sub_dirs as $sub_dir ) {
+ // 5. Is the category already existing ? we create a subcat if not
+ // existing
+ $category_id = array_search( $sub_dir, $sub_category_dirs );
+ if ( !is_numeric( $category_id ) )
{
- if ( $file != '.'
- and $file != '..'
- and is_dir ( $cat_directory.'/'.$file )
- and $file != 'thumbnail' )
+ if ( preg_match( '/^[a-zA-Z0-9-_.]+$/', $sub_dir ) )
{
- if ( preg_match( '/^[a-zA-Z0-9-_.]+$/', $file ) )
- array_push( $subdirs, $file );
- else
- {
- $output.= '"'.$file.'" : ';
- $output.= $lang['update_wrong_dirname'].'
';
- // if the category even exists (from a previous release of
- // PhpWebGallery), we keep it in our $subdirs array
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE site_id = '.$site_id;
- $query.= " AND dir = '".$file."'";
- $query.= ' AND id_uppercat';
- if ( !is_numeric( $cat_id ) ) $query.= ' IS NULL';
- else $query.= ' = '.$cat_id;
- $query.= ';';
- $result = mysql_query( $query );
- if ( mysql_num_rows( $result ) != 0 )
- {
- array_push( $subdirs, $file );
- }
- }
+ $name = str_replace( '_', ' ', $sub_dir );
+
+ $value = "('".$sub_dir."','".$name."',1";
+ if ( !is_numeric( $id_uppercat ) ) $value.= ',NULL';
+ else $value.= ','.$id_uppercat;
+ $value.= ",'undef'";
+ $value.= ')';
+ array_push( $inserts, $value );
+ }
+ else
+ {
+ $output.= '"'.$sub_dir.'" : ';
+ $output.= $lang['update_wrong_dirname'].'
';
}
}
}
- foreach ( $subdirs as $subdir ) {
- // 5. Is the category already existing ? we create a subcat if not
- // existing
- $category_id = '';
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE site_id = '.$site_id;
- $query.= " AND dir = '".$subdir."'";
- $query.= ' AND id_uppercat';
- if ( !is_numeric( $cat_id ) ) $query.= ' IS NULL';
- else $query.= ' = '.$cat_id;
+
+ // we have to create the category
+ if ( count( $inserts ) > 0 )
+ {
+ $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
+ $query.= ' (dir,name,site_id,id_uppercat,uppercats) VALUES ';
+ $query.= implode( ',', $inserts );
$query.= ';';
- $result = mysql_query( $query );
- if ( mysql_num_rows( $result ) == 0 )
- {
- $name = str_replace( '_', ' ', $subdir );
- // we have to create the category
- $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
- $query.= ' (dir,name,site_id,id_uppercat) VALUES';
- $query.= " ('".$subdir."','".$name."','".$site_id."'";
- if ( !is_numeric( $cat_id ) ) $query.= ',NULL';
- else $query.= ",'".$cat_id."'";
- $query.= ');';
- mysql_query( $query );
- $category_id = mysql_insert_id();
- // regeneration of the plain_structure to integrate the new category
- $page['plain_structure'] = get_plain_structure();
- }
- else
- {
- // we get the already registered id
- $row = mysql_fetch_array( $result );
- $category_id = $row['id'];
- }
- // 6. recursive call
- $output.= insert_local_category( $category_id );
+ mysql_query( $query );
+ // updating uppercats field
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= ' SET uppercats = ';
+ if ( $uppercats != '' ) $query.= "CONCAT('".$uppercats."',',',id)";
+ else $query.= 'id';
+ $query.= ' WHERE id_uppercat ';
+ if (!is_numeric($id_uppercat)) $query.= 'IS NULL';
+ else $query.= '= '.$id_uppercat;
+ $query.= ';';
+ mysql_query( $query );
}
-
- if ( is_numeric( $cat_id ) )
+
+ // Recursive call on the sub-categories (not virtual ones)
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE site_id = 1';
+ if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
+ else $query.= ' AND id_uppercat = '.$id_uppercat;
+ $query.= ' AND dir IS NOT NULL'; // virtual categories not taken
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ $output.= insert_local_category( $row['id'] );
+ }
+
+ if ( is_numeric( $id_uppercat ) )
{
$output.= '
';
}
return $output;
}
-
-function insert_local_image( $rep, $category_id )
+
+function insert_local_image( $dir, $category_id )
{
global $lang,$conf,$count_new;
$output = '';
+
+ // fs means filesystem : $fs_pictures contains pictures in the filesystem
+ // found in $dir, $fs_thumbnails contains thumbnails...
+ $fs_pictures = get_picture_files( $dir );
+ $fs_thumbnails = get_thumb_files( $dir.'thumbnail' );
+
// we have to delete all the images from the database that :
// - are not in the directory anymore
// - don't have the associated thumbnail available anymore
@@ -165,157 +185,187 @@ function insert_local_image( $rep, $category_id )
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
- $lien_image = $rep.'/'.$row['file'];
- $lien_thumbnail = $rep.'/thumbnail/'.$conf['prefix_thumbnail'];
- $lien_thumbnail.= get_filename_wo_extension( $row['file'] );
- $lien_thumbnail.= '.'.$row['tn_ext'];
-
- if ( !is_file ( $lien_image ) or !is_file ( $lien_thumbnail ) )
+ $pic_to_delete = false;
+ if ( !in_array( $row['file'], $fs_pictures ) )
{
- if ( !is_file ( $lien_image ) )
- {
- $output.= $row['file'];
- $output.= ' ';
- $output.= $lang['update_disappeared'].'
';
- }
- if ( !is_file ( $lien_thumbnail ) )
- {
- $output.= $row['file'];
- $output.= ' : ';
- $output.= $lang['update_disappeared_tn'].'
';
- }
- // suppression de la base :
- delete_image( $row['id'] );
+ $output.= $row['file'];
+ $output.= ' ';
+ $output.= $lang['update_disappeared'].'
';
+ $pic_to_delete = true;
}
- }
-
- // searching the new images in the directory
- $pictures = array();
- $tn_ext = '';
- if ( $opendir = opendir( $rep ) )
- {
- while ( $file = readdir( $opendir ) )
- {
- if ( is_file( $rep.'/'.$file ) and is_image( $rep.'/'.$file ) )
- {
- // is the picture waiting for validation by an administrator ?
- $query = 'SELECT id,validated,infos';
- $query.= ' FROM '.PREFIX_TABLE.'waiting';
- $query.= ' WHERE storage_category_id = '.$category_id;
- $query.= " AND file = '".$file."'";
- $query.= ';';
- $result = mysql_query( $query );
- $waiting = mysql_fetch_array( $result );
- if (mysql_num_rows( $result ) == 0 or $waiting['validated'] == 'true')
- {
- if ( $tn_ext = TN_exists( $rep, $file ) )
- {
- // is the picture already in the database ?
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE storage_category_id = '.$category_id;
- $query.= " AND file = '".$file."'";
- $query.= ';';
- $result = mysql_query( $query );
- if ( mysql_num_rows( $result ) == 0 )
- {
- // the name of the file must not use acentuated characters or
- // blank space..
- if ( preg_match( '/^[a-zA-Z0-9-_.]+$/', $file ) )
- {
- $picture = array();
- $picture['file'] = $file;
- $picture['tn_ext'] = $tn_ext;
- $picture['date'] = date( 'Y-m-d', filemtime($rep.'/'.$file) );
- $picture['filesize'] = floor( filesize($rep.'/'.$file) / 1024);
- $image_size = @getimagesize( $rep.'/'.$file );
- $picture['width'] = $image_size[0];
- $picture['height'] = $image_size[1];
- if ( $waiting['validated'] == 'true' )
- {
- // retrieving infos from the XML description of
- // $waiting['infos']
- $infos = nl2br( $waiting['infos'] );
- $picture['author'] = getAttribute( $infos, 'author' );
- $picture['comment'] = getAttribute( $infos, 'comment');
- $unixtime = getAttribute( $infos, 'date_creation' );
- $picture['date_creation'] = '';
- if ( $unixtime != '' )
- $picture['date_creation'] = date( 'Y-m-d', $unixtime );
- $picture['name'] = getAttribute( $infos, 'name' );
- // deleting the waiting element
- $query = 'DELETE FROM '.PREFIX_TABLE.'waiting';
- $query.= ' WHERE id = '.$waiting['id'];
- $query.= ';';
- mysql_query( $query );
- }
- array_push( $pictures, $picture );
- }
- else
- {
- $output.= '"'.$file.'" : ';
- $output.= $lang['update_wrong_dirname'].'
';
- }
- }
- }
- else
- {
- $output.= '';
- $output.= $lang['update_missing_tn'].' : '.$file;
- $output.= ' (';
- $output.= $conf['prefix_thumbnail'];
- $output.= get_filename_wo_extension( $file ).'.XXX';
- $output.= ', XXX = ';
- $output.= implode( ', ', $conf['picture_ext'] );
- $output.= ')
';
- }
+ $thumbnail = $conf['prefix_thumbnail'];
+ $thumbnail.= get_filename_wo_extension( $row['file'] );
+ $thumbnail.= '.'.$row['tn_ext'];
+ if ( !in_array( $thumbnail, $fs_thumbnails ) )
+ {
+ $output.= $row['file'];
+ $output.= ' : ';
+ $output.= $lang['update_disappeared_tn'].'
';
+ $pic_to_delete = true;
+ }
+
+ if ( $pic_to_delete ) delete_image( $row['id'] );
+ }
+
+ $registered_pictures = array();
+ $query = 'SELECT file';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ array_push( $registered_pictures, $row['file'] );
+ }
+
+ // validated pictures are picture uploaded by users, validated by an admin
+ // and not registered (visible) yet
+ $validated_pictures = array();
+ $unvalidated_pictures = array();
+
+ $query = 'SELECT file,infos,validated';
+ $query.= ' FROM '.PREFIX_TABLE.'waiting';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ if ( $row['validated'] == 'true' )
+ $validated_pictures[$row['file']] = $row['infos'];
+ else
+ array_push( $unvalidated_pictures, $row['file'] );
+ }
+
+ // we only search among the picture present in the filesystem and not
+ // present in the database yet. If we know that this picture is known as
+ // an uploaded one but not validated, it's not tested neither
+ $unregistered_pictures = array_diff( $fs_pictures
+ ,$registered_pictures
+ ,$unvalidated_pictures );
+
+ $inserts = array();
+
+ foreach ( $unregistered_pictures as $unregistered_picture ) {
+ if ( preg_match( '/^[a-zA-Z0-9-_.]+$/', $unregistered_picture ) )
+ {
+ $file_wo_ext = get_filename_wo_extension( $unregistered_picture );
+ $tn_ext = '';
+ foreach ( $conf['picture_ext'] as $ext ) {
+ $test = $conf['prefix_thumbnail'].$file_wo_ext.'.'.$ext;
+ if ( !in_array( $test, $fs_thumbnails ) ) continue;
+ else { $tn_ext = $ext; break; }
+ }
+ // if we found a thumnbnail corresponding to our picture...
+ if ( $tn_ext != '' )
+ {
+ $image_size = @getimagesize( $dir.$unregistered_picture );
+ // (file, storage_category_id, date_available, tn_ext, filesize,
+ // width, height, name, author, comment, date_creation)'
+ $value = '(';
+ $value.= "'".$unregistered_picture."'";
+ $value.= ','.$category_id;
+ $value.= ",'".date( 'Y-m-d' )."'";
+ $value.= ",'".$tn_ext."'";
+ $value.= ','.floor( filesize( $dir.$unregistered_picture) / 1024 );
+ $value.= ','.$image_size[0];
+ $value.= ','.$image_size[1];
+ if ( isset( $validated_pictures[$unregistered_picture] ) )
+ {
+ // retrieving infos from the XML description from waiting table
+ $infos = nl2br( $validated_pictures[$unregistered_picture] );
+
+ $unixtime = getAttribute( $infos, 'date_creation' );
+ if ($unixtime != '') $date_creation ="'".date('Y-m-d',$unixtime)."'";
+ else $date_creation = 'NULL';
+
+ $value.= ",'".getAttribute( $infos, 'name' )."'";
+ $value.= ",'".getAttribute( $infos, 'author' )."'";
+ $value.= ",'".getAttribute( $infos, 'comment')."'";
+ $value.= ','.$date_creation;
+
+ // deleting the waiting element
+ $query = 'DELETE FROM '.PREFIX_TABLE.'waiting';
+ $query.= " WHERE file = '".$unregistered_picture."'";
+ $query.= ' AND storage_category_id = '.$category_id;
+ $query.= ';';
+ mysql_query( $query );
}
+ else
+ {
+ $value.= ",'','','',NULL";
+ }
+ $value.= ')';
+
+ $count_new++;
+ $output.= $unregistered_picture;
+ $output.= ' ';
+ $output.= $lang['update_research_added'].'';
+ $output.= ' ('.$lang['update_research_tn_ext'].' '.$tn_ext.')';
+ $output.= '
';
+ array_push( $inserts, $value );
+ }
+ else
+ {
+ $output.= '';
+ $output.= $lang['update_missing_tn'].' : '.$unregistered_picture;
+ $output.= ' (';
+ $output.= $conf['prefix_thumbnail'];
+ $output.= get_filename_wo_extension( $unregistered_picture );
+ $output.= '.XXX';
+ $output.= ', XXX = ';
+ $output.= implode( ', ', $conf['picture_ext'] );
+ $output.= ')
';
}
}
+ else
+ {
+ $output.= '"'.$unregistered_picture.'" : ';
+ $output.= $lang['update_wrong_dirname'].'
';
+ }
}
- // inserting the pictures found in the directory
- foreach ( $pictures as $picture ) {
+
+ if ( count( $inserts ) > 0 )
+ {
+ // inserts all found pictures
$query = 'INSERT INTO '.PREFIX_TABLE.'images';
$query.= ' (file,storage_category_id,date_available,tn_ext';
$query.= ',filesize,width,height';
$query.= ',name,author,comment,date_creation)';
$query.= ' VALUES ';
- $query.= "('".$picture['file']."','".$category_id."'";
- $query.= ",'".$picture['date']."','".$picture['tn_ext']."'";
- $query.= ",'".$picture['filesize']."','".$picture['width']."'";
- $query.= ",'".$picture['height']."','".$picture['name']."'";
- $query.= ",'".$picture['author']."','".$picture['comment']."'";
- if ( $picture['date_creation'] != '' )
- {
- $query.= ",'".$picture['date_creation']."'";
- }
- else
- {
- $query.= ',NULL';
- }
- $query.= ');';
- mysql_query( $query );
- $count_new++;
- // retrieving the id of newly inserted picture
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE storage_category_id = '.$category_id;
- $query.= " AND file = '".$picture['file']."'";
- $query.= ';';
- list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
- // adding the link between this picture and its storage category
- $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
- $query.= ' (image_id,category_id) VALUES ';
- $query.= ' ('.$image_id.','.$category_id.')';
+ $query.= implode( ',', $inserts );
$query.= ';';
mysql_query( $query );
- $output.= $picture['file'];
- $output.= ' ';
- $output.= $lang['update_research_added'].'';
- $output.= ' ('.$lang['update_research_tn_ext'].' '.$picture['tn_ext'].')';
- $output.= '
';
+ // what are the ids of the pictures in the $category_id ?
+ $ids = array();
+
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ array_push( $ids, $row['id'] );
+ }
+
+ // recreation of the links between this storage category pictures and
+ // its storage category
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$category_id;
+ $query.= ' AND image_id IN ('.implode( ',', $ids ).')';
+ $query.= ';';
+ mysql_query( $query );
+
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= '(category_id,image_id) VALUES ';
+ foreach ( $ids as $num => $image_id ) {
+ if ( $num > 0 ) $query.= ',';
+ $query.= '('.$category_id.','.$image_id.')';
+ }
+ $query.= ';';
+ mysql_query( $query );
}
return $output;
}
@@ -367,96 +417,131 @@ function remote_images()
// insert the contained categories if the are not in the database yet. The
// function also deletes the categories that are in the database and not in
// the xml_file.
-function insert_remote_category( $xml_dir, $site_id, $id_uppercat, $level )
+function insert_remote_category( $xml_content, $site_id, $id_uppercat, $level )
{
- global $conf,$user;
-
+ global $conf, $page, $user, $lang;
+
+ $uppercats = '';
$output = '';
- $categories = array();
- $list_dirs = getChildren( $xml_dir, 'dir'.$level );
- for ( $i = 0; $i < sizeof( $list_dirs ); $i++ )
+ // 0. retrieving informations on the category to display
+ $cat_directory = '../galleries';
+
+ if ( is_numeric( $id_uppercat ) )
{
- // is the category already existing ?
- $category_id = '';
- $dir = getAttribute( $list_dirs[$i], 'name' );
- $categories[$i] = $dir;
+ $query = 'SELECT name,uppercats,dir';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE id = '.$id_uppercat;
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $uppercats = $row['uppercats'];
+ $name = $row['name'];
+ // 1. display the category name to update
$src = './template/'.$user['template'].'/admin/images/puce.gif';
- $output.= '
';
- $output.= ''.$dir.'';
+ $output = '
';
+ $output.= ''.$name.'';
+ $output.= ' [ '.$row['dir'].' ]';
$output.= '';
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE site_id = '.$site_id;
- $query.= " AND dir = '".$dir."'";
- if ( $id_uppercat == 'NULL' )
- {
- $query.= ' AND id_uppercat IS NULL';
- }
- else
- {
- $query.= ' AND id_uppercat = '.$id_uppercat;
- }
- $query.= ';';
- $result = mysql_query( $query );
- if ( mysql_num_rows( $result ) == 0 )
- {
- $name = str_replace( '_', ' ', $dir );
- // we have to create the category
- $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
- $query.= ' (name,dir,site_id,id_uppercat) VALUES ';
- $query.= "('".$name."','".$dir."',".$site_id;
- if ( !is_numeric( $id_uppercat ) )
- {
- $query.= ',NULL';
- }
- else
- {
- $query.= ','.$id_uppercat;
- }
- $query.= ');';
- mysql_query( $query );
- $category_id = mysql_insert_id();
- }
- else
- {
- // we get the already registered id
- $row = mysql_fetch_array( $result );
- $category_id = $row['id'];
- }
- $output.= insert_remote_image( $list_dirs[$i], $category_id );
- $output.= insert_remote_category( $list_dirs[$i], $site_id,
- $category_id, $level+1 );
- $output.= '
';
+ // 2. we search pictures of the category only if the update is for all
+ // or a cat_id is specified
+ $output.= insert_remote_image( $xml_content, $id_uppercat );
}
- // we have to remove the categories of the database not present in the xml
- // file (ie deleted from the picture storage server)
- $query = 'SELECT dir,id';
+
+ // $xml_dirs contains dir names contained in the xml file for this
+ // id_uppercat
+ $xml_dirs = array();
+ $temp_dirs = getChildren( $xml_content, 'dir'.$level );
+ foreach ( $temp_dirs as $temp_dir ) {
+ array_push( $xml_dirs, getAttribute( $temp_dir, 'name' ) );
+ }
+
+ // $database_dirs contains dir names contained in the database for this
+ // id_uppercat and site_id
+ $database_dirs = array();
+ $query = 'SELECT id,dir';
$query.= ' FROM '.PREFIX_TABLE.'categories';
$query.= ' WHERE site_id = '.$site_id;
- if ( !is_numeric( $id_uppercat ) )
- {
- $query.= ' AND id_uppercat IS NULL';
- }
- else
- {
- $query.= ' AND id_uppercat = '.$id_uppercat;
- }
+ if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
+ else $query.= ' AND id_uppercat = '.$id_uppercat;
+ $query.= ' AND dir IS NOT NULL'; // virtual categories not taken
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
- // is the category in the xml file ?
- if ( !in_array( $row['dir'], $categories ) )
+ $database_dirs[$row['id']] = $row['dir'];
+ }
+
+ // 3. we have to remove the categories of the database not present anymore
+ foreach ( $database_dirs as $id => $dir ) {
+ if ( !in_array( $dir, $xml_dirs ) ) delete_category( $id );
+ }
+
+ // array of new categories to insert
+ $inserts = array();
+
+ foreach ( $xml_dirs as $xml_dir ) {
+ // 5. Is the category already existing ? we create a subcat if not
+ // existing
+ $category_id = array_search( $xml_dir, $database_dirs );
+ if ( !is_numeric( $category_id ) )
{
- delete_category( $row['id'] );
+ $name = str_replace( '_', ' ', $xml_dir );
+
+ $value = "('".$xml_dir."','".$name."',".$site_id;
+ if ( !is_numeric( $id_uppercat ) ) $value.= ',NULL';
+ else $value.= ','.$id_uppercat;
+ $value.= ",'undef'";
+ $value.= ')';
+ array_push( $inserts, $value );
}
}
+ // we have to create the category
+ if ( count( $inserts ) > 0 )
+ {
+ $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
+ $query.= ' (dir,name,site_id,id_uppercat,uppercats) VALUES ';
+ $query.= implode( ',', $inserts );
+ $query.= ';';
+ mysql_query( $query );
+ // updating uppercats field
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= ' SET uppercats = ';
+ if ( $uppercats != '' ) $query.= "CONCAT('".$uppercats."',',',id)";
+ else $query.= 'id';
+ $query.= ' WHERE id_uppercat ';
+ if (!is_numeric($id_uppercat)) $query.= 'IS NULL';
+ else $query.= '= '.$id_uppercat;
+ $query.= ';';
+ mysql_query( $query );
+ }
+
+ // Recursive call on the sub-categories (not virtual ones)
+ $query = 'SELECT id,dir';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE site_id = '.$site_id;
+ if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
+ else $query.= ' AND id_uppercat = '.$id_uppercat;
+ $query.= ' AND dir IS NOT NULL'; // virtual categories not taken
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ $database_dirs[$row['dir']] = $row['id'];
+ }
+ foreach ( $temp_dirs as $temp_dir ) {
+ $dir = getAttribute( $temp_dir, 'name' );
+ $id_uppercat = $database_dirs[$dir];
+ $output.= insert_remote_category( $temp_dir, $site_id,
+ $id_uppercat,$level+1 );
+ }
+
+ if ( is_numeric( $id_uppercat ) ) $output.= '';
+
return $output;
}
-
+
// insert_remote_image searchs the "root" node of the xml_dir given and
// insert the contained pictures if the are not in the database yet.
function insert_remote_image( $xml_dir, $category_id )
@@ -465,88 +550,15 @@ function insert_remote_image( $xml_dir, $category_id )
$output = '';
$root = getChild( $xml_dir, 'root' );
- $pictures = array();
+
+ $fs_pictures = array();
$xml_pictures = getChildren( $root, 'picture' );
- for ( $j = 0; $j < sizeof( $xml_pictures ); $j++ )
- {
- //
- $file = getAttribute( $xml_pictures[$j], 'file' );
- $tn_ext = getAttribute( $xml_pictures[$j], 'tn_ext' );
- $date = getAttribute( $xml_pictures[$j], 'date' );
- $filesize = getAttribute( $xml_pictures[$j], 'filesize' );
- $width = getAttribute( $xml_pictures[$j], 'width' );
- $height = getAttribute( $xml_pictures[$j], 'height' );
-
- $pictures[$j] = $file;
-
- // is the picture already existing in the database ?
- $query = 'SELECT id,tn_ext';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE storage_category_id = '.$category_id;
- $query.= " AND file = '".$file."'";
- $query.= ';';
- $result = mysql_query( $query );
- $query = '';
- if ( mysql_num_rows( $result ) == 0 )
- {
- $query = 'INSERT INTO '.PREFIX_TABLE.'images';
- $query.= ' (file,storage_category_id,date_available,tn_ext';
- $query.= ',filesize,width,height)';
- $query.= ' VALUES (';
- $query.= "'".$file."'";
- $query.= ",'".$category_id."'";
- $query.= ",'".$date."'";
- $query.= ",'".$tn_ext."'";
- $query.= ",'".$filesize."'";
- $query.= ",'".$width."'";
- $query.= ",'".$height."'";
- $query.= ')';
- $query.= ';';
- mysql_query( $query );
- // retrieving the id of newly inserted picture
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE storage_category_id = '.$category_id;
- $query.= " AND file = '".$file."'";
- $query.= ';';
- list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
- // adding the link between this picture and its storage category
- $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
- $query.= ' (image_id,category_id) VALUES ';
- $query.= ' ('.$image_id.','.$category_id.')';
- $query.= ';';
- mysql_query( $query );
-
- $output.= $file;
- $output.= ' ';
- $output.= $lang['update_research_added'].'';
- $output.= ' ('.$lang['update_research_tn_ext'].' '.$tn_ext.')
';
-
- $count_new++;
- }
- else
- {
- // is the tn_ext the same in the xml file and in the database ?
- $row = mysql_fetch_array( $result );
- if ( $row['tn_ext'] != $tn_ext )
- {
- $query = 'UPDATE '.PREFIX_TABLE.'images';
- $query.= ' SET';
- $query.= " tn_ext = '".$tn_ext."'";
- $query.= ' WHERE storage_category_id = '.$category_id;
- $query.= " AND file = '".$file."'";
- $query.= ';';
- }
- }
- // execution of the query
- if ( $query != '' )
- {
- mysql_query( $query );
- }
+ foreach ( $xml_pictures as $xml_picture ) {
+ array_push( $fs_pictures, getAttribute( $xml_picture, 'file' ) );
}
- // we have to remove the pictures of the database not present in the xml file
- // (ie deleted from the picture storage server)
+
+ // we have to delete all the images from the database that are not in the
+ // directory anymore (not in the XML anymore)
$query = 'SELECT id,file';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= ' WHERE storage_category_id = '.$category_id;
@@ -554,12 +566,101 @@ function insert_remote_image( $xml_dir, $category_id )
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
- // is the file in the xml file ?
- if ( !in_array( $row['file'], $pictures ) )
+ if ( !in_array( $row['file'], $fs_pictures ) )
{
+ $output.= $row['file'];
+ $output.= ' ';
+ $output.= $lang['update_disappeared'].'
';
delete_image( $row['id'] );
}
}
+
+ $database_pictures = array();
+ $query = 'SELECT file';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ array_push( $database_pictures, $row['file'] );
+ }
+
+ $inserts = array();
+ $xml_pictures = getChildren( $root, 'picture' );
+ foreach ( $xml_pictures as $xml_picture ) {
+ //
+ $file = getAttribute( $xml_picture, 'file' );
+
+ // is the picture already existing in the database ?
+ if ( !in_array( $file, $database_pictures ) )
+ {
+ $tn_ext = getAttribute( $xml_picture, 'tn_ext' );
+ // (file, storage_category_id, date_available, tn_ext, filesize,
+ // width, height)
+ $value = '(';
+ $value.= "'".$file."'";
+ $value.= ','.$category_id;
+ $value.= ",'".date( 'Y-m-d' )."'";
+ $value.= ",'".$tn_ext."'";
+ $value.= ','.getAttribute( $xml_picture, 'filesize' );
+ $value.= ','.getAttribute( $xml_picture, 'width' );
+ $value.= ','.getAttribute( $xml_picture, 'height' );
+ $value.= ')';
+
+ $count_new++;
+ $output.= $file;
+ $output.= ' ';
+ $output.= $lang['update_research_added'].'';
+ $output.= ' ('.$lang['update_research_tn_ext'].' '.$tn_ext.')';
+ $output.= '
';
+ array_push( $inserts, $value );
+ }
+ }
+
+ if ( count( $inserts ) > 0 )
+ {
+ // inserts all found pictures
+ $query = 'INSERT INTO '.PREFIX_TABLE.'images';
+ $query.= ' (file,storage_category_id,date_available,tn_ext';
+ $query.= ',filesize,width,height)';
+ $query.= ' VALUES ';
+ $query.= implode( ',', $inserts );
+ $query.= ';';
+ mysql_query( $query );
+
+ // what are the ids of the pictures in the $category_id ?
+ $ids = array();
+
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ array_push( $ids, $row['id'] );
+ }
+
+ // recreation of the links between this storage category pictures and
+ // its storage category
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$category_id;
+ $query.= ' AND image_id IN ('.implode( ',', $ids ).')';
+ $query.= ';';
+ mysql_query( $query );
+
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= '(category_id,image_id) VALUES ';
+ foreach ( $ids as $num => $image_id ) {
+ if ( $num > 0 ) $query.= ',';
+ $query.= '('.$category_id.','.$image_id.')';
+ }
+ $query.= ';';
+ mysql_query( $query );
+ }
+
return $output;
}
//----------------------------------------------------- template initialization
@@ -569,15 +670,9 @@ $tpl = array( 'update_default_title', 'update_only_cat', 'update_all',
'remote_site', 'update_part_research' );
templatize_array( $tpl, 'lang', $sub );
$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
-//-------------------------------------------------------- categories structure
-$page['plain_structure'] = get_plain_structure();
//-------------------------------------------- introduction : choices of update
// Display choice if "update" var is not specified
-check_cat_id( $_GET['update'] );
-if ( !isset( $_GET['update'] )
- and !( isset( $page['cat'] )
- or $_GET['update'] == 'cats'
- or $_GET['update'] == 'all' ) )
+if (!isset( $_GET['update'] ))
{
$vtp->addSession( $sub, 'introduction' );
// only update the categories, not the pictures.
@@ -591,6 +686,8 @@ if ( !isset( $_GET['update'] )
//-------------------------------------------------- local update : ./galleries
else
{
+ check_cat_id( $_GET['update'] );
+ $start = get_moment();
$count_new = 0;
$count_deleted = 0;
$vtp->addSession( $sub, 'local_update' );
@@ -602,6 +699,8 @@ else
{
$categories = insert_local_category( 'NULL' );
}
+ $end = get_moment();
+ echo get_elapsed_time( $start, $end ).' for update
';
$vtp->setVar( $sub, 'local_update.categories', $categories );
$vtp->setVar( $sub, 'local_update.count_new', $count_new );
$vtp->setVar( $sub, 'local_update.count_deleted', $count_deleted );
@@ -613,15 +712,32 @@ if ( @is_file( './listing.xml' ) )
$count_new = 0;
$count_deleted = 0;
$vtp->addSession( $sub, 'remote_update' );
-
+
+ $start = get_moment();
remote_images();
+ $end = get_moment();
+ echo get_elapsed_time( $start, $end ).' for remote_images
';
+
$vtp->setVar( $sub, 'remote_update.count_new', $count_new );
$vtp->setVar( $sub, 'remote_update.count_deleted', $count_deleted );
$vtp->closeSession( $sub, 'remote_update' );
}
//---------------------------------------- update informations about categories
-update_category( 'all' );
+if ( isset( $_GET['update'] )
+ or isset( $page['cat'] )
+ or @is_file( './listing.xml' ) )
+{
+ $start = get_moment();
+ update_category( 'all' );
+ $end = get_moment();
+ echo get_elapsed_time( $start, $end ).' for update_category( all )
';
+
+ $start = get_moment();
+ synchronize_all_users();
+ $end = get_moment();
+ echo get_elapsed_time( $start, $end ).' for synchronize_all_users
';
+}
//----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub );
?>
\ No newline at end of file
diff --git a/admin/user_list.php b/admin/user_list.php
index e8b6bb34b..a80d73c3e 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -58,7 +58,7 @@ if ( isset ( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) )
$query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
// confirm user deletion ?
- if ( $_GET['confirm'] != 1 )
+ if ( !isset( $_GET['confirm'] ) )
{
$vtp->addSession( $sub, 'deletion' );
$vtp->setVar( $sub, 'deletion.login', $row['username'] );
@@ -109,7 +109,8 @@ else
$vtp->addSession( $sub, 'add_user' );
$action = './admin.php?'.$_SERVER['QUERY_STRING'];
$vtp->setVar( $sub, 'add_user.form_action', $action );
- $vtp->setVar( $sub, 'add_user.f_username', $_POST['username'] );
+ if (isset( $_POST['username']))
+ $vtp->setVar( $sub, 'add_user.f_username', $_POST['username'] );
$vtp->closeSession( $sub, 'add_user' );
$vtp->addSession( $sub, 'users' );
@@ -149,7 +150,7 @@ else
}
$vtp->addSession( $sub, 'user' );
// checkbox for mail management if the user has a mail address
- if ( $row['mail_address'] != '' and $row['username'] != 'guest' )
+ if ( isset( $row['mail_address'] ) and $row['username'] != 'guest' )
{
$vtp->addSession( $sub, 'checkbox' );
$vtp->setVar( $sub, 'checkbox.name', 'mail-'.$row['id'] );
@@ -229,7 +230,7 @@ else
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
- if ( $_POST['mail-'.$row['id']] == 1 )
+ if ( isset( $_POST['mail-'.$row['id']] ) )
array_push( $mails, $row['mail_address'] );
}
$mail_destination = '';
diff --git a/admin/user_modify.php b/admin/user_modify.php
index e49d3b3b0..cc6486c7a 100644
--- a/admin/user_modify.php
+++ b/admin/user_modify.php
@@ -39,6 +39,7 @@ $query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
$page['username'] = $row['username'];
$page['status'] = $row['status'];
+if ( !isset( $row['mail_address'] ) ) $row['mail_address'] = '';
$page['mail_address'] = $row['mail_address'];
// user is not modifiable if :
// 1. the selected user is the user "guest"
@@ -62,10 +63,7 @@ if ( sizeof( $error ) == 0 and isset( $_POST['submit'] ) )
{
// shall we use a new password and overwrite the old one ?
$use_new_password = false;
- if ( $_POST['use_new_pwd'] == 1)
- {
- $use_new_password = true;
- }
+ if ( isset( $_POST['use_new_pwd'] ) ) $use_new_password = true;
// if we try to update the webmaster infos, we have to set the status to
// 'admin'
if ( $row['username'] == $conf['webmaster'] )
@@ -88,7 +86,7 @@ if ( isset( $_POST['submit'] ) )
while ( $row = mysql_fetch_array( $result ) )
{
$dissociate = 'dissociate-'.$row['id'];
- if ( $_POST[$dissociate] == 1 )
+ if ( isset( $_POST[$dissociate] ) )
{
$query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
$query.= ' WHERE user_id = '.$_GET['user_id'];
@@ -103,6 +101,8 @@ if ( isset( $_POST['submit'] ) )
$query.= ' ('.$_GET['user_id'].','.$_POST['associate'].')';
$query.= ';';
mysql_query( $query );
+ // synchronize category informations for this user
+ synchronize_user( $_GET['user_id'] );
}
//-------------------------------------------------------------- errors display
if ( sizeof( $error ) != 0 )
@@ -124,7 +124,7 @@ if ( sizeof( $error ) == 0 and isset( $_POST['submit'] ) )
$url = add_session_id( './admin.php?page=user_list' );
$vtp->setVar( $sub, 'confirmation.url', $url );
$vtp->closeSession( $sub, 'confirmation' );
- if ( $use_new_pwd )
+ if ( $use_new_password )
{
$vtp->addSession( $sub, 'password_updated' );
$vtp->closeSession( $sub, 'password_updated' );
diff --git a/admin/user_perm.php b/admin/user_perm.php
index d272552ae..19f7e4b6f 100644
--- a/admin/user_perm.php
+++ b/admin/user_perm.php
@@ -52,13 +52,14 @@ if ( isset( $_POST['submit'] ) )
}
}
check_favorites( $_GET['user_id'] );
+ synchronize_user( $_GET['user_id'] );
$vtp->addSession( $sub, 'confirmation' );
$url = './admin.php?page=user_list';
$vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) );
$vtp->closeSession( $sub, 'confirmation' );
}
//---------------------------------------------------------------- form display
-$restrictions = get_restrictions( $_GET['user_id'], $page['user_status'],
+$restrictions = get_user_restrictions( $_GET['user_id'], $page['user_status'],
false, false );
$action = './admin.php?page=user_perm&user_id='.$_GET['user_id'];
$vtp->setVar( $sub, 'action', add_session_id( $action ) );
diff --git a/admin/waiting.php b/admin/waiting.php
index aefb6e9d8..5fc79303e 100644
--- a/admin/waiting.php
+++ b/admin/waiting.php
@@ -116,7 +116,7 @@ while ( $row = mysql_fetch_array( $result ) )
// file name
$vtp->setVar( $sub, 'picture.file', $row['file'] );
// is there an existing associated thumnail ?
- if ( $row['tn_ext'] != '' )
+ if ( isset( $row['tn_ext'] ) and $row['tn_ext'] != '' )
{
$vtp->addSession( $sub, 'thumbnail' );
$thumbnail = $conf['prefix_thumbnail'];
diff --git a/category.php b/category.php
index 1058eb958..0b93e6d06 100644
--- a/category.php
+++ b/category.php
@@ -16,14 +16,13 @@
* the Free Software Foundation; *
* *
***************************************************************************/
-// determine the initial instant to indicate the generation time of this page
-$t1 = explode( ' ', microtime() );
-$t2 = explode( '.', $t1[0] );
-$t2 = $t1[1].'.'.$t2[1];
-//----------------------------------------------------------- personnal include
-include_once( './include/init.inc.php' );
+//----------------------------------------------------------- include
+$phpwg_root_path = './';
+include_once( $phpwg_root_path.'common.php' );
//---------------------------------------------------------------------- logout
-if ( $_GET['act'] == 'logout' and isset( $_COOKIE['id'] ) )
+if ( isset( $_GET['act'] )
+ and $_GET['act'] == 'logout'
+ and isset( $_COOKIE['id'] ) )
{
// cookie deletion if exists
setcookie( 'id', '', 0, cookie_path() );
@@ -34,18 +33,23 @@ if ( $_GET['act'] == 'logout' and isset( $_COOKIE['id'] ) )
exit();
}
//-------------------------------------------------- access authorization check
-// creating the plain structure : array of all the available categories and
-// their relative informations, see the definition of the function
-// get_plain_structure for further details.
-$page['plain_structure'] = get_plain_structure();
-
-check_cat_id( $_GET['cat'] );
+if ( isset( $_GET['cat'] ) ) check_cat_id( $_GET['cat'] );
check_login_authorization();
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
{
check_restrictions( $page['cat'] );
}
//-------------------------------------------------------------- initialization
+// detection of the start picture to display
+if ( !isset( $_GET['start'] )
+ or !is_numeric( $_GET['start'] )
+ or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
+ $page['start'] = 0;
+else
+ $page['start'] = $_GET['start'];
+
+initialize_category();
+
// creation of the array containing the cat ids to expand in the menu
// $page['tab_expand'] contains an array with the category ids
// $page['expand'] contains the string to display in URL with comma
@@ -56,80 +60,83 @@ if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' )
foreach ( $tab_expand as $id ) {
if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id );
}
- if ( is_numeric( $page['cat'] ) )
- {
- // the category displayed (in the URL cat=23) must be seen in the menu ->
- // parent categories must be expanded
- $parent = $page['plain_structure'][$page['cat']]['id_uppercat'];
- while ( $parent != '' )
- {
- array_push( $page['tab_expand'], $parent );
- $parent = $page['plain_structure'][$parent]['id_uppercat'];
- }
- }
- $page['expand'] = implode( ',', $page['tab_expand'] );
}
+if ( isset($page['cat']) && is_numeric( $page['cat'] ) )
+{
+ // the category displayed (in the URL cat=23) must be seen in the menu ->
+ // parent categories must be expanded
+ $uppercats = explode( ',', $page['uppercats'] );
+ foreach ( $uppercats as $uppercat ) {
+ array_push( $page['tab_expand'], $uppercat );
+ }
+}
+$page['tab_expand'] = array_unique( $page['tab_expand'] );
+$page['expand'] = implode( ',', $page['tab_expand'] );
// in case of expanding all authorized cats
// The $page['expand'] equals 'all' and
// $page['tab_expand'] contains all the authorized cat ids
-if ( $user['expand'] or $_GET['expand'] == 'all' )
+if ( $user['expand']
+ or ( isset( $_GET['expand'] ) and $_GET['expand'] == 'all' ) )
{
$page['tab_expand'] = array();
$page['expand'] = 'all';
}
-// detection of the start picture to display
-if ( !isset( $_GET['start'] )
- or !is_numeric( $_GET['start'] )
- or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
-{
- $page['start'] = 0;
-}
-else
-{
- $page['start'] = $_GET['start'];
-}
// Sometimes, a "num" is provided in the URL. It is the number
// of the picture to show. This picture must be in the thumbnails page.
// We have to find the right $page['start'] that show the num picture
// in this category
-if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 )
+if ( isset( $_GET['num'] )
+ and is_numeric( $_GET['num'] )
+ and $_GET['num'] >= 0 )
{
$page['start'] = floor( $_GET['num'] / $user['nb_image_page'] );
$page['start']*= $user['nb_image_page'];
}
// creating the structure of the categories (useful for displaying the menu)
-$page['structure'] = create_structure( '', $user['restrictions'] );
+// creating the plain structure : array of all the available categories and
+// their relative informations, see the definition of the function
+// get_user_plain_structure for further details.
+$page['plain_structure'] = get_user_plain_structure();
+$page['structure'] = create_user_structure( '' );
$page['structure'] = update_structure( $page['structure'] );
-initialize_category();
+
//----------------------------------------------------- template initialization
-$vtp = new VTemplate;
+
+//
+// Start output of page
+//
+$title = $page['title'];
+include('include/page_header.php');
+
$handle = $vtp->Open( './template/'.$user['template'].'/category.vtp' );
initialize_template();
$tpl = array(
'categories','hint_category','sub-cat','images_available','total',
'title_menu','nb_image_category','send_mail','title_send_mail',
- 'generation_time','connected_user','recent_image','days','generation_time',
+ 'connected_user','recent_image','days',
'favorite_cat_hint','favorite_cat','stats','most_visited_cat_hint',
'most_visited_cat','recent_cat','recent_cat_hint','upload_picture',
'comments' );
templatize_array( $tpl, 'lang', $handle );
-$tpl = array( 'mail_webmaster','webmaster','top_number','version','site_url' );
+$tpl = array( 'mail_webmaster','webmaster','top_number');
templatize_array( $tpl, 'conf', $handle );
$tpl = array( 'short_period','long_period','lien_collapsed', 'username' );
templatize_array( $tpl, 'user', $handle );
-$tpl = array( 'title','navigation_bar','cat_comment','cat_nb_images' );
+$tpl = array( 'navigation_bar','cat_comment','cat_nb_images' );
templatize_array( $tpl, 'page', $handle );
// special global template vars
$vtp->setGlobalVar( $handle, 'icon_short', get_icon( time() ) );
$icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) );
$vtp->setGlobalVar( $handle, 'icon_long', $icon_long );
-$nb_total_pictures = count_images( $page['structure'] );
+$nb_total_pictures = count_user_total_images();
$vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures );
+
//------------------------------------------------------------- categories menu
+$vtp->setVar( $handle, 'home_url', add_session_id( 'category.php' ) );
// normal categories
foreach ( $page['structure'] as $category ) {
// display category is a function relative to the template
@@ -143,7 +150,7 @@ if ( !$user['is_the_guest'] )
$vtp->setVar( $handle, 'favorites.url', add_session_id( $url ) );
// searching the number of favorite picture
$query = 'SELECT COUNT(*) AS count';
- $query.= ' FROM '.PREFIX_TABLE.'favorites';
+ $query.= ' FROM '.FAVORITES_TABLE;
$query.= ' WHERE user_id = '.$user['id'].';';
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
@@ -181,9 +188,10 @@ if ( !$user['is_the_guest'] )
$vtp->closeSession( $handle, 'summary' );
// customization link
$vtp->addSession( $handle, 'summary' );
- $url = './profile.php?cat='.$page['cat'];
- $url.= '&expand='.$page['expand'];
- if ( $page['cat'] == 'search' )
+ $url = './profile.php';
+ if (isset($page['cat']) && isset($page['expand']))
+ $url.='?cat='.$page['cat'].'&expand='.$page['expand'];
+ if ( isset($page['cat']) && $page['cat'] == 'search' )
{
$url.= '&search='.$_GET['search'].'&mode='.$_GET['mode'];
}
@@ -253,8 +261,8 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
$query = 'SELECT distinct(id),file,date_available,tn_ext,name,filesize';
$query.= ',storage_category_id';
- $query.= ' FROM '.PREFIX_TABLE.'images AS i';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
+ $query.= ' FROM '.IMAGES_TABLE.' AS i';
+ $query.=' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
@@ -270,7 +278,7 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
while ( $row = mysql_fetch_array( $result ) )
{
// retrieving the storage dir of the picture
- if ( $array_cat_directories[$row['storage_category_id']] == '' )
+ if ( !isset($array_cat_directories[$row['storage_category_id']]))
{
$array_cat_directories[$row['storage_category_id']] =
get_complete_dir( $row['storage_category_id'] );
@@ -279,8 +287,8 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
$file = get_filename_wo_extension( $row['file'] );
// name of the picture
- if ( $row['name'] != '' ) $name = $row['name'];
- else $name = str_replace( '_', ' ', $file );
+ if ( isset( $row['name'] ) and $row['name'] != '' ) $name = $row['name'];
+ else $name = str_replace( '_', ' ', $file );
if ( $page['cat'] == 'search' )
{
@@ -320,8 +328,7 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
{
$vtp->addSession( $handle, 'nb_comments' );
$query = 'SELECT COUNT(*) AS nb_comments';
- $query.= ' FROM '.PREFIX_TABLE.'comments';
- $query.= ' WHERE image_id = '.$row['id'];
+ $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$row['id'];
$query.= " AND validated = 'true'";
$query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
@@ -350,13 +357,16 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
//-------------------------------------------------------------- empty category
elseif ( ( isset( $page['cat'] )
and is_numeric( $page['cat'] )
- and $page['cat_nb_images'] == 0 )
- or $_GET['cat'] == '' )
+ and $page['cat_nb_images'] == 0
+ and $page['plain_structure'][$page['cat']]['nb_sub_categories'] > 0)
+ or (!isset($_GET['cat'])))
{
$vtp->addSession( $handle, 'thumbnails' );
$vtp->addSession( $handle, 'line' );
- $subcats = get_non_empty_subcat_ids( $page['cat'] );
+ $subcats=array();
+ if (isset($page['cat'])) $subcats = get_non_empty_subcat_ids( $page['cat'] );
+ else $subcats = get_non_empty_subcat_ids( '' );
$cell_number = 1;
$i = 0;
foreach ( $subcats as $subcat_id => $non_empty_id ) {
@@ -368,17 +378,17 @@ elseif ( ( isset( $page['cat'] )
// searching the representative picture of the category
$query = 'SELECT representative_picture_id';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE id = '.$non_empty_id;
+ $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$non_empty_id;
+ $query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
$query = 'SELECT file,tn_ext,storage_category_id';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE;
$query.= ' WHERE category_id = '.$non_empty_id;
+ $query.= ' AND id = image_id';
// if the category has a representative picture, this is its thumbnail
- // tha will be displayed !
- if ( $row['representative_picture_id'] != '' )
+ // that will be displayed !
+ if ( isset( $row['representative_picture_id'] ) )
$query.= ' AND id = '.$row['representative_picture_id'];
else
$query.= ' ORDER BY RAND()';
@@ -397,7 +407,7 @@ elseif ( ( isset( $page['cat'] )
$thumbnail_title = $lang['hint_category'];
$url_link = './category.php?cat='.$subcat_id;
- if ( !in_array( $page['cat'], $page['tab_expand'] ) )
+ if ( isset($page['cat'])&& !in_array( $page['cat'], $page['tab_expand'] ) )
{
array_push( $page['tab_expand'], $page['cat'] );
$page['expand'] = implode( ',', $page['tab_expand'] );
@@ -459,30 +469,30 @@ if ( isset ( $page['cat'] ) )
$vtp->setVar( $handle, 'cat_infos.cat_name',
get_cat_display_name( $page['cat_name'], ' - ',
'font-style:italic;' ) );
+ // upload a picture in the category
+ if ( $page['cat_site_id'] == 1
+ and $conf['upload_available']
+ and $page['cat_uploadable'] )
+ {
+ $vtp->addSession( $handle, 'upload' );
+ $url = './upload.php?cat='.$page['cat'].'&expand='.$page['expand'];
+ $vtp->setVar( $handle, 'upload.url', add_session_id( $url ) );
+ $vtp->closeSession( $handle, 'upload' );
+ }
}
else
{
$vtp->setVar( $handle, 'cat_infos.cat_name', $page['title'] );
}
- // upload a picture in the category
- if ( $page['cat_site_id'] == 1
- and $conf['upload_available']
- and $page['cat_uploadable'] )
- {
- $vtp->addSession( $handle, 'upload' );
- $url = './upload.php?cat='.$page['cat'].'&expand='.$page['expand'];
- $vtp->setVar( $handle, 'upload.url', add_session_id( $url ) );
- $vtp->closeSession( $handle, 'upload' );
- }
+
$vtp->closeSession( $handle, 'cat_infos' );
}
//------------------------------------------------------------ log informations
pwg_log( 'category', $page['title'] );
mysql_close();
-//------------------------------------------------------------- generation time
-$time = get_elapsed_time( $t2, get_moment() );
-$vtp->setGlobalVar( $handle, 'time', $time );
//----------------------------------------------------------- html code display
$code = $vtp->Display( $handle, 0 );
echo $code;
+
+include('include/page_tail.php');
?>
\ No newline at end of file
diff --git a/comments.php b/comments.php
index 8ca3ecaeb..650dd10c6 100644
--- a/comments.php
+++ b/comments.php
@@ -17,7 +17,10 @@
* *
***************************************************************************/
-include_once( './include/init.inc.php' );
+//----------------------------------------------------------- include
+$phpwg_root_path = './';
+include_once( $phpwg_root_path.'common.php' );
+
//------------------------------------------------------------------- functions
function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids )
{
@@ -46,7 +49,7 @@ function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids )
$subrow = mysql_fetch_array( mysql_query( $query ) );
$category_id = $subrow['category_id'];
- if ( $array_cat_directories[$category_id] == '' )
+ if ( !isset($array_cat_directories[$category_id]))
{
$array_cat_directories[$category_id] =
get_complete_dir( $category_id );
@@ -133,15 +136,19 @@ function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids )
}
}
//----------------------------------------------------- template initialization
-$vtp = new VTemplate;
+//
+// Start output of page
+//
+$title= $lang['title_comments'];
+include('include/page_header.php');
+
$handle = $vtp->Open( './template/'.$user['template'].'/comments.vtp' );
initialize_template();
$tpl = array( 'title_comments','stats_last_days','search_return_main_page' );
templatize_array( $tpl, 'lang', $handle );
-$vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] );
//--------------------------------------------------- number of days to display
-if ( isset( $_GET['last_days'] ) ) define( "MAX_DAYS", $_GET['last_days'] );
-else define( "MAX_DAYS", 0 );
+if ( isset( $_GET['last_days'] ) ) define( 'MAX_DAYS', $_GET['last_days'] );
+else define( 'MAX_DAYS', 0 );
//----------------------------------------- non specific section initialization
$array_cat_directories = array();
$array_cat_names = array();
@@ -168,22 +175,19 @@ $query.= ' FROM '.PREFIX_TABLE.'comments AS c';
$query.= ', '.PREFIX_TABLE.'image_category AS ic';
$query.= ' WHERE c.image_id = ic.image_id';
$query.= ' AND date > '.$maxtime;
+$query.= " AND validated = 'true'";
// we must not show pictures of a forbidden category
-$restricted_cats = get_all_restrictions( $user['id'],$user['status'] );
-if ( count( $restricted_cats ) > 0 )
+if ( $user['forbidden_categories'] != '' )
{
- $query.= ' AND category_id NOT IN (';
- foreach ( $restricted_cats as $i => $restricted_cat ) {
- if ( $i > 0 ) $query.= ',';
- $query.= $restricted_cat;
- }
- $query.= ')';
+ $query.= ' AND category_id NOT IN ';
+ $query.= '('.$user['forbidden_categories'].')';
}
$query.= ' ORDER BY ic.image_id DESC';
$query.= ';';
$result = mysql_query( $query );
-display_pictures( $result, $maxtime, $restricted_cats );
+display_pictures( $result, $maxtime, $user['restrictions'] );
//----------------------------------------------------------- html code display
$code = $vtp->Display( $handle, 0 );
echo $code;
+include('include/page_tail.php');
?>
\ No newline at end of file
diff --git a/common.php b/common.php
new file mode 100644
index 000000000..017749bae
--- /dev/null
+++ b/common.php
@@ -0,0 +1,205 @@
+ *
+ * author : Pierrick LE GALL *
+ * *
+ * $Id$
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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; *
+ * *
+ ***************************************************************************/
+// 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($HTTP_GET_VARS) )
+ {
+ while( list($k, $v) = each($HTTP_GET_VARS) )
+ {
+ if( is_array($HTTP_GET_VARS[$k]) )
+ {
+ while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) )
+ {
+ $HTTP_GET_VARS[$k][$k2] = addslashes($v2);
+ }
+ @reset($HTTP_GET_VARS[$k]);
+ }
+ else
+ {
+ $HTTP_GET_VARS[$k] = addslashes($v);
+ }
+ }
+ @reset($HTTP_GET_VARS);
+ }
+
+ if( is_array($HTTP_POST_VARS) )
+ {
+ while( list($k, $v) = each($HTTP_POST_VARS) )
+ {
+ if( is_array($HTTP_POST_VARS[$k]) )
+ {
+ while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) )
+ {
+ $HTTP_POST_VARS[$k][$k2] = addslashes($v2);
+ }
+ @reset($HTTP_POST_VARS[$k]);
+ }
+ else
+ {
+ $HTTP_POST_VARS[$k] = addslashes($v);
+ }
+ }
+ @reset($HTTP_POST_VARS);
+ }
+
+ if( is_array($HTTP_COOKIE_VARS) )
+ {
+ while( list($k, $v) = each($HTTP_COOKIE_VARS) )
+ {
+ if( is_array($HTTP_COOKIE_VARS[$k]) )
+ {
+ while( list($k2, $v2) = each($HTTP_COOKIE_VARS[$k]) )
+ {
+ $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2);
+ }
+ @reset($HTTP_COOKIE_VARS[$k]);
+ }
+ else
+ {
+ $HTTP_COOKIE_VARS[$k] = addslashes($v);
+ }
+ }
+ @reset($HTTP_COOKIE_VARS);
+ }
+}
+
+//
+// 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 .'config.php');
+
+if( !defined("PHPWG_INSTALLED") )
+{
+ header("Location: install.php");
+ exit;
+}
+
+include($phpwg_root_path . 'include/constants.php');
+include($phpwg_root_path . 'include/functions.inc.php');
+include($phpwg_root_path . 'include/vtemplate.class.php');
+include($phpwg_root_path . 'include/config.inc.php');
+
+//
+// Database connection
+//
+
+mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
+ or die ( "Could not connect to server" );
+mysql_select_db( $cfgBase )
+ or die ( "Could not connect to database" );
+
+//
+// Obtain and encode users IP
+//
+if( getenv('HTTP_X_FORWARDED_FOR') != '' )
+{
+ $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
+
+ if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip_list) )
+ {
+ $private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10.\.*/', '/^224.\.*/', '/^240.\.*/');
+ $client_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
+ }
+}
+else
+{
+ $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
+}
+//$user_ip = encode_ip($client_ip);
+
+//
+// Setup forum wide options, if this fails
+// then we output a CRITICAL_ERROR since
+// basic forum information is not available
+//
+$sql = "SELECT * FROM " . CONFIG_TABLE;
+if( !($result = mysql_query($sql)) )
+{
+ die("Could not query config information");
+}
+
+$row =mysql_fetch_array($result);
+// rertieving the configuration informations for site
+// $infos array is used to know the fields to retrieve in the table "config"
+// Each field becomes an information of the array $conf.
+// Example :
+// prefix_thumbnail --> $conf['prefix_thumbnail']
+$infos = array( 'prefix_thumbnail', 'webmaster', 'mail_webmaster', 'access',
+ 'session_id_size', 'session_keyword', 'session_time',
+ 'max_user_listbox', 'show_comments', 'nb_comment_page',
+ 'upload_available', 'upload_maxfilesize', 'upload_maxwidth',
+ 'upload_maxheight', 'upload_maxwidth_thumbnail',
+ 'upload_maxheight_thumbnail','log','comments_validation',
+ 'comments_forall','authorize_cookies','mail_notification' );
+// affectation of each field of the table "config" to an information of the
+// array $conf.
+foreach ( $infos as $info ) {
+ if ( isset( $row[$info] ) ) $conf[$info] = $row[$info];
+ else $conf[$info] = '';
+ // If the field is true or false, the variable is transformed into a boolean
+ // value.
+ if ( $conf[$info] == 'true' or $conf[$info] == 'false' )
+ {
+ $conf[$info] = get_boolean( $conf[$info] );
+ }
+}
+
+if (file_exists('install.php') && !DEBUG)
+{
+ die('Please ensure both the install/ and contrib/ directories are deleted');
+}
+
+
+//---------------
+// A partir d'ici il faudra dispatcher le code dans d'autres fichiers
+//---------------
+
+include($phpwg_root_path . 'include/user.inc.php');
+
+// calculation of the number of picture to display per page
+$user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
+
+$isadmin = false;
+if ($user['status'] == 'admin') $isadmin =true;
+include_once( './language/'.$user['language'].'.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'];
+include_once( './template/'.$user['template'].'/htmlfunctions.inc.php' );
+define('PREFIX_TABLE', $table_prefix);
+?>
\ No newline at end of file
diff --git a/config.php b/config.php
new file mode 100644
index 000000000..d3bb0411c
--- /dev/null
+++ b/config.php
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/identification.php b/identification.php
index cf34195dc..27ae3dc3b 100644
--- a/identification.php
+++ b/identification.php
@@ -17,15 +17,17 @@
* *
***************************************************************************/
-//----------------------------------------------------------- personnal include
-include_once( "./include/init.inc.php" );
+//----------------------------------------------------------- include
+$phpwg_root_path = './';
+include_once( $phpwg_root_path.'common.php' );
+
//-------------------------------------------------------------- identification
$errors = array();
if ( isset( $_POST['login'] ) )
{
// retrieving the encrypted password of the login submitted
$query = 'SELECT password';
- $query.= ' FROM '.PREFIX_TABLE.'users';
+ $query.= ' FROM '.USERS_TABLE;
$query.= " WHERE username = '".$_POST['login']."';";
$row = mysql_fetch_array( mysql_query( $query ) );
if( $row['password'] == md5( $_POST['pass'] ) )
@@ -43,10 +45,14 @@ if ( isset( $_POST['login'] ) )
}
}
//----------------------------------------------------- template initialization
-$vtp = new VTemplate;
+//
+// Start output of page
+//
+$title = $lang['ident_page_title'];
+include('include/page_header.php');
+
$handle = $vtp->Open( './template/default/identification.vtp' );
// language
-$vtp->setGlobalVar( $handle, 'ident_page_title', $lang['ident_page_title'] );
$vtp->setGlobalVar( $handle, 'ident_title', $lang['ident_title'] );
$vtp->setGlobalVar( $handle, 'login', $lang['login'] );
$vtp->setGlobalVar( $handle, 'password', $lang['password'] );
@@ -73,7 +79,7 @@ if ( sizeof( $errors ) != 0 )
}
//------------------------------------------------------------------ users list
// retrieving all the users login
-$query = 'select username from '.PREFIX_TABLE.'users;';
+$query = 'select username from '.USERS_TABLE.';';
$result = mysql_query( $query );
if ( mysql_num_rows ( $result ) < $conf['max_user_listbox'] )
{
@@ -109,4 +115,5 @@ if ( $conf['access'] == 'free' )
//----------------------------------------------------------- html code display
$code = $vtp->Display( $handle, 0 );
echo $code;
+include('include/page_tail.php');
?>
\ No newline at end of file
diff --git a/include/config.inc.php b/include/config.inc.php
index ff633f5de..ada80a650 100644
--- a/include/config.inc.php
+++ b/include/config.inc.php
@@ -2,7 +2,7 @@
/***************************************************************************
* config.inc.php *
* ------------------- *
- * application : PhpWebGallery 1.3 *
+ * application : PhpWebGallery 1.4 *
* author : Pierrick LE GALL *
* *
* $Id$
@@ -16,14 +16,6 @@
* the Free Software Foundation; *
* *
***************************************************************************/
-unset( $conf, $page, $user, $lang );
-$conf = array();
-$page = array();
-$user = array();
-$lang = array();
-
-include_once( PREFIX_INCLUDE.'./include/functions.inc.php' );
-include_once( PREFIX_INCLUDE.'./include/vtemplate.class.php' );
// How to change the order of display for images in a category ?
//
// You have to modify $conf['order_by'].
@@ -44,46 +36,13 @@ $conf['nb_image_row'] = array(4,5,6,7,8);
$conf['nb_row_page'] = array(2,3,4,5,6,7,10,20,1000);
$conf['slideshow_period'] = array(2,5,10);
$conf['last_days'] = array(1,2,3,10,30,365);
-$conf['version'] = 'devel';
+$conf['version'] = '1.4 - devel';
$conf['site_url'] = 'http://www.phpwebgallery.net';
$conf['forum_url'] = 'http://forum.phpwebgallery.net';
$conf['picture_ext'] = array('jpg','JPG','gif','GIF','png','PNG');
$conf['document_ext'] = array('doc','pdf','zip');
$conf['top_number'] = 10;
$conf['anti-flood_time'] = 60; // seconds between 2 comments : 0 to disable
+$conf['max_LOV_categories'] = 50;
-database_connection();
-// rertieving the configuration informations for site
-// $infos array is used to know the fields to retrieve in the table "config"
-// Each field becomes an information of the array $conf.
-// Example :
-// prefix_thumbnail --> $conf['prefix_thumbnail']
-$infos = array( 'prefix_thumbnail', 'webmaster', 'mail_webmaster', 'access',
- 'session_id_size', 'session_keyword', 'session_time',
- 'max_user_listbox', 'show_comments', 'nb_comment_page',
- 'upload_available', 'upload_maxfilesize', 'upload_maxwidth',
- 'upload_maxheight', 'upload_maxwidth_thumbnail',
- 'upload_maxheight_thumbnail','log','comments_validation',
- 'comments_forall','authorize_cookies','mail_notification' );
-
-$query = 'SELECT ';
-foreach ( $infos as $i => $info ) {
- if ( $i > 0 ) $query.= ',';
- $query.= $info;
-}
-$query.= ' FROM '.PREFIX_TABLE.'config;';
-
-$row = mysql_fetch_array( mysql_query( $query ) );
-
-// affectation of each field of the table "config" to an information of the
-// array $conf.
-foreach ( $infos as $info ) {
- $conf[$info] = $row[$info];
- // If the field is true or false, the variable is transformed into a boolean
- // value.
- if ( $row[$info] == 'true' or $row[$info] == 'false' )
- {
- $conf[$info] = get_boolean( $row[$info] );
- }
-}
?>
\ No newline at end of file
diff --git a/include/constant.php b/include/constants.php
similarity index 86%
rename from include/constant.php
rename to include/constants.php
index 07d940c3e..d7e8fded7 100644
--- a/include/constant.php
+++ b/include/constants.php
@@ -18,8 +18,22 @@
***************************************************************************/
define( 'PREFIX_INCLUDE', '' );
+
+// Debug Level
+define('DEBUG', 1); // Debugging on
+//define('DEBUG', 0); // Debugging off
+
+// Error codes
+define('GENERAL_MESSAGE', 200);
+define('GENERAL_ERROR', 202);
+define('CRITICAL_MESSAGE', 203);
+define('CRITICAL_ERROR', 204);
+
+// xml tags
+define( 'ATT_REG', '\w+' );
+define( 'VAL_REG', '[^"]*' );
- // Table names
+// Table names
define('CATEGORIES_TABLE', $table_prefix.'categories');
define('COMMENTS_TABLE', $table_prefix.'comments');
define('CONFIG_TABLE', $table_prefix.'config');
diff --git a/include/functions.inc.php b/include/functions.inc.php
index ccfc5fa88..67416291a 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -1,20 +1,21 @@
|
-// | author : Pierrick LE GALL |
-// +-----------------------------------------------------------------------+
-// | file : $RCSfile$
-// | tag : $Name$
-// | last update : $Date$
-// | revision : $Revision$
-// +-----------------------------------------------------------------------+
-// | 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; |
-// +-----------------------------------------------------------------------+
+/***************************************************************************
+ * functions.inc.php *
+ * ------------------- *
+ * application : PhpWebGallery 1.3 *
+ * author : Pierrick LE GALL *
+ * *
+ * $Id$
+ * *
+ ***************************************************************************
+ ***************************************************************************
+ * *
+ * 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; *
+ * *
+ ***************************************************************************/
include( PREFIX_INCLUDE.'./include/functions_user.inc.php' );
include( PREFIX_INCLUDE.'./include/functions_session.inc.php' );
include( PREFIX_INCLUDE.'./include/functions_category.inc.php' );
@@ -166,23 +167,27 @@ function get_filename_wo_extension( $filename )
return substr( $filename, 0, strrpos( $filename, '.' ) );
}
-// get_dirs retourne un tableau contenant tous les sous-répertoires d'un
-// répertoire
-function get_dirs( $rep )
+/**
+ * returns an array contening sub-directories
+ *
+ * @param string $dir
+ * @return array
+ */
+function get_dirs( $directory )
{
- $sub_rep = array();
+ $sub_dirs = array();
- if ( $opendir = opendir ( $rep ) )
+ if ( $opendir = opendir( $directory ) )
{
while ( $file = readdir ( $opendir ) )
{
- if ( $file != '.' and $file != '..' and is_dir ( $rep.$file ) )
+ if ( $file != '.' and $file != '..' and is_dir ( $directory.'/'.$file ) )
{
- array_push( $sub_rep, $file );
+ array_push( $sub_dirs, $file );
}
}
}
- return $sub_rep;
+ return $sub_dirs;
}
// The get_picture_size function return an array containing :
@@ -265,22 +270,6 @@ function get_languages( $rep_language )
return $languages;
}
-// get_themes retourne un tableau contenant tous les "template - couleur"
-function get_themes( $theme_dir )
-{
- $themes = array();
- $main_themes = get_dirs( $theme_dir );
- for ( $i = 0; $i < sizeof( $main_themes ); $i++ )
- {
- $colors = get_dirs( $theme_dir.$main_themes[$i].'/' );
- for ( $j = 0; $j < sizeof( $colors ); $j++ )
- {
- array_push( $themes, $main_themes[$i].' - '.$colors[$j] );
- }
- }
- return $themes;
-}
-
// - add_style replaces the
// $search into $search
// in the given $string.
@@ -324,17 +313,6 @@ function replace_search( $string, $search )
return $string;
}
-function database_connection()
-{
- include( PREFIX_INCLUDE.'./include/mysql.inc.php' );
- define( "PREFIX_TABLE", $prefixeTable );
-
- @mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
- or die ( "Could not connect to server" );
- @mysql_select_db( $cfgBase )
- or die ( "Could not connect to database" );
-}
-
function pwg_log( $file, $category, $picture = '' )
{
global $conf, $user;
@@ -355,6 +333,7 @@ function templatize_array( $array, $global_array_name, $handle )
global $vtp, $lang, $page, $user, $conf;
foreach ( $array as $value ) {
+ if (isset(${$global_array_name}[$value]))
$vtp->setGlobalVar( $handle, $value, ${$global_array_name}[$value] );
}
}
@@ -432,4 +411,47 @@ function notify( $type, $infos = '' )
@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 $count_queries,$queries_time;
+
+ $start = get_moment();
+ $output = '';
+
+ $count_queries++;
+ $output.= '
['.$count_queries.'] '.$query;
+ $result = mysql_query( $query );
+ $time = get_moment() - $start;
+ $queries_time+= $time;
+ $output.= '('.number_format( $time, 3, '.', ' ').' s)';
+ $output.= '('.number_format( $queries_time, 3, '.', ' ').' s)';
+
+ // 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";
+}
?>
\ No newline at end of file
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index a691140d6..311935b49 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -17,31 +17,11 @@
* *
***************************************************************************/
-function get_subcats_id( $cat_id )
-{
- $restricted_cats = array();
-
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE id_uppercat = '.$cat_id;
- $query.= ';';
- $result = mysql_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- array_push( $restricted_cats, $row['id'] );
- $sub_restricted_cats = get_subcats_id( $row['id'] );
- foreach ( $sub_restricted_cats as $sub_restricted_cat ) {
- array_push( $restricted_cats, $sub_restricted_cat );
- }
- }
- return $restricted_cats;
-}
-
function check_restrictions( $category_id )
{
global $user,$lang;
- if ( is_user_allowed( $category_id, $user['restrictions'] ) > 0 )
+ if ( in_array( $category_id, $user['restrictions'] ) )
{
echo '';
exit();
}
-//-------------------------------------------------------------- initialization
-check_cat_id( $_GET['cat'] );
//------------------------------------------------------ update & customization
$infos = array( 'nb_image_line', 'nb_line_page', 'language',
'maxwidth', 'maxheight', 'expand', 'show_nb_comments',
@@ -69,19 +68,12 @@ if ( isset( $_POST['submit'] ) )
}
}
$mail_error = validate_mail_address( $_POST['mail_address'] );
- if ( $mail_error != '' )
- {
- array_push( $errors, $mail_error );
- }
- if ( $_POST['use_new_pwd'] == 1 )
- {
- // password must be the same as its confirmation
- if ( $_POST['password'] != $_POST['passwordConf'] )
- {
- array_push( $errors, $lang['reg_err_pass'] );
- }
- }
-
+ if ( $mail_error != '' ) array_push( $errors, $mail_error );
+ // password must be the same as its confirmation
+ if ( isset( $_POST['use_new_pwd'] )
+ and $_POST['password'] != $_POST['passwordConf'] )
+ array_push( $errors, $lang['reg_err_pass'] );
+
if ( count( $errors ) == 0 )
{
$query = 'UPDATE '.PREFIX_TABLE.'users';
@@ -97,7 +89,7 @@ if ( isset( $_POST['submit'] ) )
$query.= ';';
mysql_query( $query );
- if ( $_POST['use_new_pwd'] == 1 )
+ if ( isset( $_POST['use_new_pwd'] ) )
{
$query = 'UPDATE '.PREFIX_TABLE.'users';
$query.= " SET password = '".md5( $_POST['password'] )."'";
@@ -105,7 +97,7 @@ if ( isset( $_POST['submit'] ) )
$query.= ';';
mysql_query( $query );
}
- if ( $_POST['create_cookie'] == 1 )
+ if ( isset( $_POST['create_cookie'] ) )
{
setcookie( 'id',$page['session_id'],$_POST['cookie_expiration'],
cookie_path() );
@@ -117,12 +109,8 @@ if ( isset( $_POST['submit'] ) )
mysql_query( $query );
}
// redirection
- $url = 'category.php?cat='.$page['cat'].'&expand='.$_GET['expand'];
- if ( $page['cat'] == 'search' )
- {
- $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode'];
- }
- if ( $_POST['create_cookie'] != 1 ) $url = add_session_id( $url, true );
+ $url = 'category.php';
+ if ( !isset($_POST['create_cookie']) ) $url = add_session_id( $url,true );
header( 'Request-URI: '.$url );
header( 'Content-Location: '.$url );
header( 'Location: '.$url );
@@ -130,18 +118,19 @@ if ( isset( $_POST['submit'] ) )
}
}
//----------------------------------------------------- template initialization
-$vtp = new VTemplate;
+//
+// Start output of page
+//
+$title = $lang['customize_page_title'];
+include('include/page_header.php');
+
$handle = $vtp->Open( './template/'.$user['template'].'/profile.vtp' );
initialize_template();
-$tpl = array( 'customize_page_title','customize_title','password','new',
+$tpl = array( 'customize_title','password','new',
'reg_confirm','submit','create_cookie' );
templatize_array( $tpl, 'lang', $handle );
//----------------------------------------------------------------- form action
-$url = './profile.php?cat='.$page['cat'].'&expand='.$page['expand'];
-if ( $page['cat'] == 'search' )
-{
- $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode'];
-}
+$url = './profile.php';
$vtp->setGlobalVar( $handle, 'form_action', add_session_id( $url ) );
//-------------------------------------------------------------- errors display
if ( count( $errors ) != 0 )
@@ -201,7 +190,7 @@ if ( in_array( 'template', $infos ) )
$vtp->setVar( $handle, 'line.name', $lang['customize_template'] );
$vtp->addSession( $handle, 'select' );
$vtp->setVar( $handle, 'select.name', 'template' );
- $option = get_dirs( './template/' );
+ $option = get_dirs( './template' );
for ( $i = 0; $i < sizeof( $option ); $i++ )
{
$vtp->addSession( $handle, 'option' );
@@ -378,4 +367,5 @@ if ( $conf['authorize_cookies'] )
//----------------------------------------------------------- html code display
$code = $vtp->Display( $handle, 0 );
echo $code;
+include('include/page_tail.php');
?>
\ No newline at end of file
diff --git a/register.php b/register.php
index 0f0669926..399e60603 100644
--- a/register.php
+++ b/register.php
@@ -17,8 +17,9 @@
* *
***************************************************************************/
-//----------------------------------------------------------- personnal include
-include_once( './include/init.inc.php' );
+//----------------------------------------------------------- include
+$phpwg_root_path = './';
+include_once( $phpwg_root_path.'common.php' );
//-------------------------------------------------- access authorization check
if ( $conf['access'] == "restricted" )
{
@@ -42,11 +43,14 @@ if ( isset( $_POST['submit'] ) )
}
}
//----------------------------------------------------- template initialization
-$vtp = new VTemplate;
+//
+// Start output of page
+//
+$title= $lang['register_page_title'];
+include('include/page_header.php');
+
$handle = $vtp->Open( './template/'.$user['template'].'/register.vtp' );
// language
-$vtp->setGlobalVar( $handle, 'register_page_title',
- $lang['register_page_title'] );
$vtp->setGlobalVar( $handle, 'register_title', $lang['register_title'] );
$vtp->setGlobalVar( $handle, 'ident_guest_visit',$lang['ident_guest_visit'] );
$vtp->setGlobalVar( $handle, 'submit', $lang['submit'] );
@@ -70,7 +74,8 @@ $vtp->addSession( $handle, 'line' );
$vtp->setVar( $handle, 'line.name', $lang['login'] );
$vtp->addSession( $handle, 'text' );
$vtp->setVar( $handle, 'text.name', 'login' );
-$vtp->setVar( $handle, 'text.value', $_POST['login'] );
+if (isset( $_POST['login']))
+ $vtp->setVar( $handle, 'text.value', $_POST['login'] );
$vtp->closeSession( $handle, 'text' );
$vtp->closeSession( $handle, 'line' );
//-------------------------------------------------------------------- password
@@ -94,10 +99,12 @@ $vtp->addSession( $handle, 'line' );
$vtp->setVar( $handle, 'line.name', $lang['mail_address'] );
$vtp->addSession( $handle, 'text' );
$vtp->setVar( $handle, 'text.name', 'mail_address' );
-$vtp->setVar( $handle, 'text.value', $_POST['mail_address'] );
+if (isset( $_POST['mail_address']))
+ $vtp->setVar( $handle, 'text.value', $_POST['mail_address'] );
$vtp->closeSession( $handle, 'text' );
$vtp->closeSession( $handle, 'line' );
//----------------------------------------------------------- html code display
$code = $vtp->Display( $handle, 0 );
echo $code;
+include('include/page_tail.php');
?>
\ No newline at end of file
diff --git a/search.php b/search.php
index d12e8203a..9d3cd9180 100644
--- a/search.php
+++ b/search.php
@@ -17,8 +17,9 @@
* *
***************************************************************************/
-//----------------------------------------------------------- personnal include
-include_once( './include/init.inc.php' );
+//----------------------------------------------------------- include
+$phpwg_root_path = './';
+include_once( $phpwg_root_path.'common.php' );
//-------------------------------------------------- access authorization check
check_login_authorization();
//----------------------------------------------------------------- redirection
@@ -53,10 +54,14 @@ if ( isset( $_POST['search'] ) )
}
}
//----------------------------------------------------- template initialization
-$vtp = new VTemplate;
+//
+// Start output of page
+//
+$title= $lang['search_title'];
+include('include/page_header.php');
+
$handle = $vtp->Open( './template/'.$user['template'].'/search.vtp' );
initialize_template();
-
$tpl = array( 'search_title','search_return_main_page','submit',
'search_comments' );
templatize_array( $tpl, 'lang', $handle );
@@ -81,6 +86,7 @@ $vtp->setVar( $handle, 'line.name', $lang['search_field_search'].' *' );
$vtp->addSession( $handle, 'text' );
$vtp->setVar( $handle, 'text.size', '40' );
$vtp->setVar( $handle, 'text.name', 'search' );
+if (isset($_POST['search']))
$vtp->setVar( $handle, 'text.value', $_POST['search'] );
$vtp->closeSession( $handle, 'text' );
$vtp->closeSession( $handle, 'line' );
@@ -92,7 +98,7 @@ $vtp->addSession( $handle, 'radio' );
$vtp->setVar( $handle, 'radio.name', 'mode' );
$vtp->setVar( $handle, 'radio.value', 'OR' );
$vtp->setVar( $handle, 'radio.option', $lang['search_mode_or'] );
-if ( $_POST['mode'] == 'OR' or $_POST['mode'] == '' )
+if (!isset($_POST['mode']) || $_POST['mode'] == 'OR' )
{
$vtp->setVar( $handle, 'radio.checked', ' checked="checked"' );
}
@@ -102,7 +108,7 @@ $vtp->addSession( $handle, 'radio' );
$vtp->setVar( $handle, 'radio.name', 'mode' );
$vtp->setVar( $handle, 'radio.value', 'AND' );
$vtp->setVar( $handle, 'radio.option', $lang['search_mode_and'] );
-if ( $_POST['mode'] == 'AND' )
+if ( isset($_POST['mode']) && $_POST['mode'] == 'AND' )
{
$vtp->setVar( $handle, 'radio.checked', ' checked="checked"' );
}
@@ -116,6 +122,7 @@ $vtp->setGlobalVar( $handle, 'back_url', add_session_id( './category.php' ) );
$code = $vtp->Display( $handle, 0 );
echo $code;
//------------------------------------------------------------ log informations
-pwg_log( 'search', $page['title'] );
+pwg_log( 'search', $title );
mysql_close();
+include('include/page_tail.php');
?>
\ No newline at end of file
diff --git a/template/default/about.vtp b/template/default/about.vtp
index 7a0802fef..5b416d1b8 100644
--- a/template/default/about.vtp
+++ b/template/default/about.vtp
@@ -1,11 +1,3 @@
-
-
- {#style}
- {#about_page_title}
-
-
-
- {#header}
- {#footer}
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/template/default/admin/cat_list.vtp b/template/default/admin/cat_list.vtp
index 884b6a937..997f3d1f1 100644
--- a/template/default/admin/cat_list.vtp
+++ b/template/default/admin/cat_list.vtp
@@ -8,26 +8,32 @@
-
-
- |
+
- |
-
+
+
\ No newline at end of file
diff --git a/template/default/comments.vtp b/template/default/comments.vtp
index 133f9578c..1c729ee74 100644
--- a/template/default/comments.vtp
+++ b/template/default/comments.vtp
@@ -1,52 +1,3 @@
-
-
- {#style}
- {#title_comments}
-
-
-
-
-
- {#header}
@@ -72,18 +23,15 @@
- |
+ |
|
-
- {#title}
+ |
+ {#title}
-
|
@@ -113,7 +58,4 @@
{#frame_end}
-
- {#footer}
-
-
\ No newline at end of file
+ |
\ No newline at end of file
diff --git a/template/default/default-admin.css b/template/default/default-admin.css
new file mode 100644
index 000000000..7270c1bb1
--- /dev/null
+++ b/template/default/default-admin.css
@@ -0,0 +1,93 @@
+@import url("default.css");
+
+a, a:hover {
+color:#006699;
+}
+
+body,font,table,input,form,select,textarea {
+font-family:arial,verdana,sans-serif;
+font-size:12px;
+color:#000000;
+text-align:left;
+}
+table
+{
+border-collapse:separate;
+}
+body {
+background-color:#E5E5E5;
+margin:5px;
+}
+
+.table1 {
+border-collapse:collapse;
+background-color:#FFFFFF;
+}
+.contenucellule {
+background-color:#EEEEEE;
+border:2px solid #006699;
+}
+.style1 {
+margin-top:20px;
+}
+th {
+font-weight:bold;
+background-color:#D3DCE3;
+margin-bottom:10px;
+text-align: center;
+}
+td.row1 {
+background-color:#E6E4E4;
+}
+td.row2,td.throw2 {
+background-color:#E8E8E8;
+}
+td.throw2 {
+text-align:center;
+font-weight:bold;
+}
+td.row3 {
+background-color:#eeeeee;
+}
+td.row4 {
+background-color:#cccccc;
+}
+.info {
+color:darkblue;
+text-align:center;
+}
+div.key {
+margin-left : 10px;
+}
+td.choice {
+text-align : center;
+}
+div.install_warning {
+text-align:center;
+color:red;
+margin:20px;
+font-weight:bold;
+}
+
+.tableComment,.cellAuthor,.cellInfo {
+color:#000000;
+border-color:#006699;
+}
+.commentsAuthor,.commentsTitle,.commentsInfos,.commentsContent
+{
+color:#000000;
+}
+.errors {
+ text-align:left;
+ margin:25px;
+ background-color:#ffe1e1;
+ border:1px solid red;
+ color:black;
+}
+.errors_title {
+ margin:5px;
+ font-weight:bold;
+ font-size:120%;
+ text-align:center;
+ color:red;
+}
\ No newline at end of file
diff --git a/template/default/default.css b/template/default/default.css
new file mode 100644
index 000000000..8c7e447f9
--- /dev/null
+++ b/template/default/default.css
@@ -0,0 +1,208 @@
+a {
+ text-decoration:none;
+ color:#E0E0E0;
+}
+a:hover {
+ text-decoration:underline;
+ color:#E0E0E0;
+}
+
+a.back,body {
+ color:#E0E0E0;
+}
+body {
+ font-family:arial, sans-serif;
+ font-size:12px;
+ background-color:#444444;
+ margin:5px;
+}
+table, input {
+ font-family:arial, sans-serif;
+ font-size:12px;
+}
+.imgLink {
+ border:1px solid #E0E0E0;
+}
+.imgLink:hover {
+ text-decoration:none;
+}
+.titrePage,.titreMenu,.menu,.info,.commentsAuthor,.commentsTitle,.commentsInfos,.commentsContent,.commentsNavigationBar {
+ color:lightgray;
+}
+.titreMenu, .menu, .info {
+ margin-bottom:5px;
+ white-space:nowrap;
+}
+.menu, .titrePage, .info {
+ margin-left:2px;
+ margin-right:2px;
+}
+.menuInfoCat {
+ font-family:sans-serif;
+ font-size:11px;
+}
+.totalImages {
+ text-align:center;
+ margin-top:5px;
+ font-family:sans-serif;
+ font-size:11px;
+}
+.titreMenu {
+ font-weight:600;
+ text-align:center;
+}
+.info {
+ text-align:right;
+}
+.titrePage {
+ white-space:nowrap;
+ font-weight:500;
+ font-size:18px;
+ text-align:center;
+}
+.comments, .infoCat, .navigationBar {
+ margin-top:10px;
+ margin-bottom:10px;
+}
+.comments {
+ text-align:justify;
+ font-style:italic;
+}
+.navigationBar {
+ text-align:center;
+}
+.infoCat {
+ text-align:left;
+}
+.thumbnail {
+ font-size:11px;
+ text-align:center;
+}
+.copyright {
+ font-size:11px;
+ text-align:center;
+ font-family:sans-serif;
+ letter-spacing:0.3mm;
+}
+.commentImage {
+ font-weight:bold;
+ text-align:center;
+ font-size:17px;
+}
+.bouton {
+ background:lightgray;
+}
+textarea,input {
+ color:black;
+}
+table {
+ border-collapse:collapse;
+}
+table.thumbnail {
+ border-collapse:separate;
+}
+td {
+ font-family:sans-serif;
+ padding:0px;
+}
+.errors {
+ text-align:left;
+ margin-top:5px;
+ margin-bottom:5px;
+ background-color:red;
+ font-weight:bold;
+ border:1px solid black;
+ color:white;
+}
+div.information {
+ text-align:center;
+ border:2px solid #E0E0E0;
+ margin:10px;
+ padding:5px;
+}
+.commentsAuthor, .commentsTitle, .commentsInfos, .commentsContent, .commentsNavigationBar {
+
+ font-family:arial, sans-Serif;
+ font-size:12px;
+}
+.commentsTitle, .commentsAuthor {
+ text-align:center;
+ font-weight:bold;
+}
+.commentsInfos {
+ padding:3px 3px 3px 10px;
+ font-size:11px;
+ text-align:right;
+}
+.commentsContent {
+ margin:10px;
+}
+.commentsTitle {
+ margin-top:15px;
+}
+.commentsAuthor {
+ margin:5px;
+}
+.commentsNavigationBar {
+ margin:10px;
+}
+.tableComment,.cellAuthor,.cellInfo {
+ border-color:#E0E0E0;
+ border-style:solid;
+}
+.tableComment {
+ width:100%;
+ border-width:2px;
+ text-align:left;
+ padding: 10px;
+}
+.cellAuthor {
+ border-width:0px;
+ border-right-width:1px;
+ width:20%;
+}
+.cellInfo {
+ border-width:0px;
+ border-bottom-width:1px;
+}
+
+ .miniature {
+ border:solid 1px black;
+ }
+ .titretable1 {
+ color:black;
+ background-color:#D3DCE3;
+ text-align:center;
+ border:2px solid #006699;
+ font-weight:bold;
+ border-bottom:0px;
+ }
+ .grostitre {
+ text-align:center;
+ margin:10px 50px 10px 50px;
+ font-size:20px;
+ width:300px;
+ }
+ .plan {
+ margin:10px 10px 10px 2px;
+ white-space:nowrap;
+ }
+ .cat_plan {
+ font-weight:bold;
+ }
+ .retrait {
+ margin:10px;
+ margin-left:30px;
+ margin-top:2px;
+ }
+ .erreur {
+ color:red;
+ text-align:center;
+ }
+ .errors_title {
+ margin:5px;
+ font-weight:bold;
+ font-size:120%;
+ text-align:center;
+ color:red;
+ }
\ No newline at end of file
diff --git a/template/default/footer.vtp b/template/default/footer.vtp
new file mode 100644
index 000000000..1cf62a5d5
--- /dev/null
+++ b/template/default/footer.vtp
@@ -0,0 +1,8 @@
+ {#generation_time} {#time}
+
+
+ {#footer}
+