*** empty log message ***

git-svn-id: http://piwigo.org/svn/trunk@12 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
z0rglub 2003-05-17 11:01:12 +00:00
parent 9f9efb71f2
commit f96563b9e8
2 changed files with 244 additions and 172 deletions

View file

@ -1,9 +1,9 @@
<?php <?php
/*************************************************************************** /***************************************************************************
* functions.php is a part of PhpWebGallery * * functions.php *
* ------------------- * * ------------------- *
* last update : Tuesday, September 26, 2002 * * application : PhpWebGallery 1.3 *
* email : pierrick@z0rglub.com * * author : Pierrick LE GALL <pierrick@z0rglub.com> *
* * * *
*************************************************************************** ***************************************************************************
@ -15,180 +15,203 @@
* * * *
***************************************************************************/ ***************************************************************************/
$tab_ext = array ( 'jpg', 'gif', 'JPG','GIF','png','PNG' ); $tab_ext_create_TN = array ( 'jpg', 'png' );
$tab_ext_create_TN = array ( 'jpg', 'JPG','png','PNG' );
function get_extension( $filename ) function is_image( $filename, $create_thumbnail = false )
{ {
return substr ( strrchr($filename,"."), 1, strlen ( $filename ) ); global $tab_ext_create_TN, $conf;
}
function is_image( $filename, $create_thumbnail = false ) $is_image = false;
{
global $tab_ext, $tab_ext_create_TN;
$is_image = false;
if ( is_file ( $filename ) )
{
$size = getimagesize( $filename );
// $size[2] == 1 means GIF
// $size[2] == 2 means JPG
// $size[2] == 3 means PNG
if ( !$create_thumbnail )
{
if ( in_array ( get_extension( $filename ), $tab_ext ) && ( $size[2] == 1 || $size[2] == 2 || $size[2] == 3 ) )
{
$is_image = true;
}
}
else
{
if ( in_array ( get_extension( $filename ), $tab_ext_create_TN ) && ( $size[2] == 2 || $size[2] == 3 ) )
{
$is_image = true;
}
}
}
return $is_image;
}
function TN_exist ( $dir, $file ) if ( is_file ( $filename ) )
{ {
global $tab_ext, $conf; $size = getimagesize( $filename );
$titre = substr ( $file, 0, strrpos ( $file, ".") ); // $size[2] == 1 means GIF
for ( $i = 0; $i < sizeof ( $tab_ext ); $i++ ) // $size[2] == 2 means JPG
{ // $size[2] == 3 means PNG
$test = $dir."/thumbnail/".$conf['prefixe_thumbnail'].$titre.".".$tab_ext[$i]; if ( !$create_thumbnail )
if ( is_file ( $test ) ) {
{ if ( in_array( get_extension( $filename ), $conf['picture_ext'] )
return $tab_ext[$i]; and ( $size[2] == 1 or $size[2] == 2 or $size[2] == 3 ) )
} {
} $is_image = true;
return false; }
} }
else
{
if ( in_array( get_extension( $filename ), $tab_ext_create_TN )
and ( $size[2] == 2 or $size[2] == 3 ) )
{
$is_image = true;
}
}
}
return $is_image;
}
// The function delete_site deletes a site function TN_exists( $dir, $file )
// and call the function delete_category for each primary category of the site {
function delete_site( $id ) global $conf;
{
global $prefixeTable;
// destruction of the categories of the site $filename = get_filename_wo_extension( $file );
$query = "select id from $prefixeTable"."categories where site_id = $id;"; foreach ( $conf['picture_ext'] as $ext ) {
$result = mysql_query( $query ); $test = $dir.'/thumbnail/'.$conf['prefixe_thumbnail'].$filename.'.'.$ext;
while ( $row = mysql_fetch_array( $result ) ) if ( is_file ( $test ) )
{ {
delete_category( $row['id'] ); return $ext;
} }
}
return false;
}
// destruction of the site // The function delete_site deletes a site
$query = "delete from $prefixeTable"."sites where id = $id;"; // and call the function delete_category for each primary category of the site
mysql_query( $query ); function delete_site( $id )
} {
// destruction of the categories of the site
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'categories';
$query.= ' WHERE site_id = '.$id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
delete_category( $row['id'] );
}
// The function delete_category deletes the category identified by the $id // destruction of the site
// It also deletes (in the database) : $query = 'DELETE FROM '.PREFIX_TABLE.'sites';
// - all the images of the images (thanks to delete_image, see further) $query.= ' WHERE id = '.$id;
// - all the restrictions linked to the category $query.= ';';
// The function works recursively. mysql_query( $query );
function delete_category( $id ) }
{
global $prefixeTable;
// destruction of all the related images // The function delete_category deletes the category identified by the $id
$query = "select id from $prefixeTable"."images where cat_id = '".$id."';"; // It also deletes (in the database) :
$result = mysql_query( $query ); // - all the images of the images (thanks to delete_image, see further)
while ( $row = mysql_fetch_array( $result ) ) // - all the restrictions linked to the category
{ // The function works recursively.
delete_image( $row['id'] ); function delete_category( $id )
} {
// destruction of all the related images
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= ' WHERE cat_id = '.$id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
delete_image( $row['id'] );
}
// destruction of the restrictions linked to the category // destruction of the restrictions linked to the category
$query = "delete from $prefixeTable"."restrictions where cat_id = '".$id."';"; $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions';
mysql_query( $query ); $query.= ' WHERE cat_id = '.$id;
$query.= ';';
mysql_query( $query );
// destruction of the sub-categories // destruction of the sub-categories
$query = "select id from $prefixeTable"."categories where id_uppercat = '$id';"; $query = 'SELECT id';
$result = mysql_query( $query ); $query.= ' FROM '.PREFIX_TABLE.'categories';
while( $row = mysql_fetch_array( $result ) ) $query.= ' WHERE id_uppercat = '.$id;
{ $query.= ';';
delete_category( $row['id'] ); $result = mysql_query( $query );
} while( $row = mysql_fetch_array( $result ) )
{
delete_category( $row['id'] );
}
// destruction of the category // destruction of the category
$query = "delete from $prefixeTable"."categories where id = '$id';"; $query = 'DELETE FROM '.PREFIX_TABLE.'categories';
mysql_query( $query ); $query.= ' WHERE id = '.$id;
} $query.= ';';
mysql_query( $query );
}
// The function delete_image deletes the image identified by the $id // The function delete_image deletes the image identified by the $id
// It also deletes (in the database) : // It also deletes (in the database) :
// - all the comments related to the image // - all the comments related to the image
// - all the favorites associated to the image // - all the favorites associated to the image
function delete_image( $id ) function delete_image( $id )
{ {
global $prefixeTable,$count_deleted; global $count_deleted;
// destruction of the comments on the image // destruction of the comments on the image
$query = "delete from $prefixeTable"."comments where image_id = $id;"; $query = 'DELETE FROM '.PREFIX_TABLE.'comments';
mysql_query( $query ); $query.= ' WHERE image_id = '.$id;
$query.= ';';
mysql_query( $query );
// destruction of the favorites associated with the picture // destruction of the favorites associated with the picture
$query = "delete from $prefixeTable"."favorites where image_id = $id;"; $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
mysql_query( $query ); $query.= ' WHERE image_id = '.$id;
$query.= ';';
mysql_query( $query );
// destruction of the image // destruction of the image
$query = "delete from $prefixeTable"."images where id = $id;"; $query = 'DELETE FROM '.PREFIX_TABLE.'images';
mysql_query( $query ); $query.= ' WHERE id = '.$id;
$count_deleted++; $query.= ';';
} mysql_query( $query );
$count_deleted++;
}
// The delete_user function delete a user identified by the $user_id // The delete_user function delete a user identified by the $user_id
// It also deletes : // It also deletes :
// - all the restrictions linked to this user // - all the restrictions linked to this user
// - all the favorites linked to this user // - all the favorites linked to this user
function delete_user( $user_id ) function delete_user( $user_id )
{ {
global $prefixeTable; // destruction of the restrictions linked to the user
$query = 'DELETE FROM '.PREFIX_TABLE.'restrictions';
$query.= ' WHERE user_id = '.$user_id;
$query.= ';';
mysql_query( $query );
// destruction of the restrictions linked to the user // destruction of the favorites associated with the user
$query = "delete from $prefixeTable"."restrictions where user_id = $user_id;"; $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
mysql_query( $query ); $query.= ' WHERE user_id = '.$user_id;
$query.= ';';
mysql_query( $query );
// destruction of the favorites associated with the user // destruction of the user
$query = "delete from $prefixeTable"."favorites where user_id = $user_id;"; $query = 'DELETE FROM '.PREFIX_TABLE.'users';
mysql_query( $query ); $query.= ' WHERE id = '.$user_id;
$query.= ';';
mysql_query( $query );
}
// destruction of the user // The check_favorites function deletes all the favorites of a user if he is
$query = "delete from $prefixeTable"."users where id = $user_id;"; // not allowed to see them (the category or an upper category is restricted
mysql_query( $query ); // or invisible)
} function check_favorites( $user_id )
{
// The check_favorites function deletes all the favorites of a user if he is not allowed to see them $query = 'SELECT status';
// (the category or an upper category is restricted or invisible) $query.= ' FROM '.PREFIX_TABLE.'users';
function check_favorites( $user_id ) $query.= ' WHERE id = '.$user_id;
{ $query.= ';';
global $prefixeTable; $row = mysql_fetch_array( mysql_query( $query ) );
$status = $row['status'];
$row = mysql_fetch_array( mysql_query( "select status from $prefixeTable"."users where id = $user_id;" ) ); // retrieving all the restricted categories for this user
$status = $row['status']; $restricted_cat = get_all_restrictions( $user_id, $status );
// retrieving all the restricted categories for this user // retrieving all the favorites for this user and comparing their
$restricted_cat = get_all_restrictions( $user_id, $status ); // categories to the restricted categories
// retrieving all the favorites for this user and comparing their categories to the restricted categories $query = 'SELECT image_id, cat_id';
$query = "select image_id, cat_id"; $query.= ' FROM '.PREFIX_TABLE.'favorites, '.PREFIX_TABLE.'images';
$query.= " from $prefixeTable"."favorites, $prefixeTable"."images"; $query.= ' WHERE user_id = '.$user_id;
$query.= " where user_id = $user_id"; $query.= ' AND id = image_id';
$query.= " and id = image_id"; $query.= ';';
$query.= ";"; $result = mysql_query ( $query );
$result = mysql_query ( $query ); while ( $row = mysql_fetch_array( $result ) )
while ( $row = mysql_fetch_array( $result ) ) {
{ if ( in_array( $row['cat_id'], $restricted_cat ) )
if ( in_array( $row['cat_id'], $restricted_cat ) ) {
{ $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
$query = "delete from $prefixeTable"."favorites"; $query.= ' WHERE image_id = '.$row['image_id'];
$query.= " where image_id = ".$row['image_id']; $query.= ' AND user_id = '.$user_id;
$query.= " and user_id = $user_id"; $query.= ';';
$query.= ";"; mysql_query( $query );
mysql_query( $query ); }
} }
} }
}
?> ?>

View file

@ -0,0 +1,49 @@
<table style="width:100%;">
<!--VTP_introduction-->
<tr>
<th>{#update_default_title}</th>
</tr>
<tr>
<td>
<div class="retrait">
<img src="./images/puce.gif" alt="&gt;" />
<a href="{#only_cat:url}">{#update_only_cat}</a>
<br /><img src="./images/puce.gif" alt="&gt;" />
<a href="{#all:url}">{#update_all}</a>
</div>
</td>
</tr>
<!--/VTP_introduction-->
<!--VTP_local_update-->
<tr>
<th>{#update_part_research}</th>
</tr>
<tr>
<td>
<div class="retrait">
<span style="font-weight:bold;color:navy;">{#url}</span><br /><br />
<!-- update.php generates itself HTML code for categories -->
{#categories}
<br /><span style="color:blue;">{#count_new} {#update_research_conclusion}</span>
<br /><span style="color:red;">{#count_deleted} {#update_deletion_conclusion}</span>
</div>
</td>
</tr>
<!--/VTP_local_update-->
<!--VTP_remote_update-->
<tr>
<th>{#remote_site}</th>
</tr>
<tr>
<td>
<div class="retrait">
<span style="font-weight:bold;color:navy;">{#url}</span><br /><br />
<!-- update.php generates itself HTML code for categories -->
{#categories}
<br /><span style="color:blue;">{#count_new} {#update_research_conclusion}</span>
<br /><span style="color:red;">{#count_deleted} {#update_deletion_conclusion}</span>
</div>
</td>
</tr>
<!--/VTP_remote_update-->
</table>