Changeset 61
- Timestamp:
- Aug 30, 2003, 5:54:37 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/admin.php
r57 r61 132 132 $page_valide = true; 133 133 break; 134 case 'picture_modify' : 135 $title = $lang['title_picmod']; 136 $page_valide = true; 137 break; 134 138 default: 135 139 $title = $lang['title_default']; break; -
trunk/admin/comments.php
r57 r61 18 18 ***************************************************************************/ 19 19 include_once( './include/isadmin.inc.php' ); 20 $page['plain_structure'] = get_plain_structure(); 20 21 //------------------------------------------------------------------- functions 21 22 function display_pictures( $mysql_result, $maxtime, $validation_box = false ) … … 29 30 // 2. for each picture, getting informations for displaying thumbnail and 30 31 // link to the full size picture 31 $query = 'SELECT name,file, cat_id,tn_ext';32 $query = 'SELECT name,file,storage_category_id as cat_id,tn_ext'; 32 33 $query.= ' FROM '.PREFIX_TABLE.'images'; 33 34 $query.= ' WHERE id = '.$row['image_id']; … … 38 39 if ( $array_cat_directories[$subrow['cat_id']] == '' ) 39 40 { 41 $array_cat_directories[$subrow['cat_id']] = 42 get_complete_dir( $subrow['cat_id'] ); 40 43 $cat_result = get_cat_info( $subrow['cat_id'] ); 41 $array_cat_directories[$subrow['cat_id']] = $cat_result['dir'];42 44 $array_cat_site_id[$subrow['cat_id']] = $cat_result['site_id']; 43 45 $array_cat_names[$subrow['cat_id']] = … … 84 86 $vtp->addSession( $sub, 'comment' ); 85 87 $vtp->setVar( $sub, 'comment.author', $subrow['author'] ); 86 $displayed_date = $lang['day'][date( "w", $subrow['date'] )]; 87 $displayed_date.= date( " j ", $subrow['date'] ); 88 $displayed_date.= $lang['month'][date( "n", $subrow['date'] )]; 89 $displayed_date.= date( " Y G:i", $subrow['date'] ); 88 $displayed_date = format_date( $subrow['date'], 'unix', true ); 90 89 $vtp->setVar( $sub, 'comment.date', $displayed_date ); 91 90 $vtp->setVar( $sub, 'comment.content', nl2br( $subrow['content'] ) ); … … 184 183 $query.= ' FROM '.PREFIX_TABLE.'comments'; 185 184 $query.= ', '.PREFIX_TABLE.'images as images'; 186 $query.= ', '.PREFIX_TABLE.'categories';187 185 $query.= ' WHERE image_id = images.id'; 188 $query.= ' AND cat_id = images.cat_id';189 186 $query.= ' AND date > '.$maxtime; 190 $query.= ' ORDER BY cat_id ASC,date_available DESC';187 $query.= ' ORDER BY date_available DESC'; 191 188 $query.= ';'; 192 189 $result = mysql_query( $query ); … … 222 219 $query.= ' FROM '.PREFIX_TABLE.'comments as comments'; 223 220 $query.= ', '.PREFIX_TABLE.'images as images'; 224 $query.= ', '.PREFIX_TABLE.'categories';225 221 $query.= ' WHERE image_id = images.id'; 226 $query.= ' AND cat_id = images.cat_id';227 222 $query.= " AND comments.validated = 'false'"; 228 $query.= ' ORDER BY cat_id ASC,date_available DESC';223 $query.= ' ORDER BY date_available DESC'; 229 224 $query.= ';'; 230 225 $result = mysql_query( $query ); -
trunk/admin/configuration.php
r57 r61 260 260 261 261 $tpl = array( 'conf_confirmation','remote_site','delete', 262 'conf_remote_site_delete_info','submit' );262 'conf_remote_site_delete_info','submit','errors_title' ); 263 263 templatize_array( $tpl, 'lang', $sub ); 264 264 //-------------------------------------------------------------- errors display -
trunk/admin/include/functions.php
r57 r61 95 95 // It also deletes (in the database) : 96 96 // - all the images of the images (thanks to delete_image, see further) 97 // - all the links between images and this category 97 98 // - all the restrictions linked to the category 98 99 // The function works recursively. … … 102 103 $query = 'SELECT id'; 103 104 $query.= ' FROM '.PREFIX_TABLE.'images'; 104 $query.= ' WHERE cat_id = '.$id;105 $query.= ' WHERE storage_category_id = '.$id; 105 106 $query.= ';'; 106 107 $result = mysql_query( $query ); … … 109 110 delete_image( $row['id'] ); 110 111 } 112 113 // destruction of the links between images and this category 114 $query = 'DELETE FROM '.PREFIX_TABLE.'image_category'; 115 $query.= ' WHERE category_id = '.$id; 116 $query.= ';'; 117 mysql_query( $query ); 111 118 112 119 // destruction of the access linked to the category … … 141 148 // It also deletes (in the database) : 142 149 // - all the comments related to the image 150 // - all the links between categories and this image 143 151 // - all the favorites associated to the image 144 152 function delete_image( $id ) … … 151 159 $query.= ';'; 152 160 mysql_query( $query ); 153 161 162 // destruction of the links between images and this category 163 $query = 'DELETE FROM '.PREFIX_TABLE.'image_category'; 164 $query.= ' WHERE image_id = '.$id; 165 $query.= ';'; 166 mysql_query( $query ); 167 154 168 // destruction of the favorites associated with the picture 155 169 $query = 'DELETE FROM '.PREFIX_TABLE.'favorites'; … … 245 259 // retrieving all the favorites for this user and comparing their 246 260 // categories to the restricted categories 247 $query = 'SELECT image_id , cat_id';248 $query.= ' FROM '.PREFIX_TABLE.'favorites , '.PREFIX_TABLE.'images';261 $query = 'SELECT image_id'; 262 $query.= ' FROM '.PREFIX_TABLE.'favorites'; 249 263 $query.= ' WHERE user_id = '.$user_id; 250 $query.= ' AND id = image_id';251 264 $query.= ';'; 252 265 $result = mysql_query ( $query ); 253 266 while ( $row = mysql_fetch_array( $result ) ) 254 267 { 255 if ( in_array( $row['cat_id'], $restricted_cat ) ) 268 // for each picture, we have to check all the categories it belongs 269 // to. Indeed if a picture belongs to category_1 and category_2 and that 270 // category_2 is not restricted to the user, he can have the picture as 271 // favorite. 272 $query = 'SELECT DISTINCT(category_id) as category_id'; 273 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 274 $query.= ' WHERE image_id = '.$row['image_id']; 275 $query.= ';'; 276 $picture_result = mysql_query( $query ); 277 $picture_cat = array(); 278 while ( $picture_row = mysql_fetch_array( $picture_result ) ) 279 { 280 array_push( $picture_cat, $picture_row['category_id'] ); 281 } 282 if ( count( array_diff( $picture_cat, $restricted_cat ) ) > 0 ) 256 283 { 257 284 $query = 'DELETE FROM '.PREFIX_TABLE.'favorites'; … … 263 290 } 264 291 } 292 293 // update_category updates calculated informations about a category : 294 // date_last and nb_images 295 function update_category( $id = 'all' ) 296 { 297 if ( $id == 'all' ) 298 { 299 $query = 'SELECT id'; 300 $query.= ' FROM '.PREFIX_TABLE.'categories'; 301 $query.= ';'; 302 $result = mysql_query( $query ); 303 while ( $row = mysql_fetch_array( $result ) ) 304 { 305 // recursive call 306 update_category( $row['id'] ); 307 } 308 } 309 else if ( is_numeric( $id ) ) 310 { 311 // updating the number of pictures 312 $query = 'SELECT COUNT(*) as nb_images'; 313 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 314 $query.= ' WHERE category_id = '.$id; 315 $query.= ';'; 316 $row = mysql_fetch_array( mysql_query( $query ) ); 317 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 318 $query.= ' SET nb_images = '.$row['nb_images']; 319 $query.= ' WHERE id = '.$id; 320 $query.= ';'; 321 mysql_query( $query ); 322 // updating the date_last 323 $query = 'SELECT date_available'; 324 $query.= ' FROM '.PREFIX_TABLE.'images'; 325 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 326 $query.= ' WHERE category_id = '.$id; 327 $query.= ' ORDER BY date_available DESC'; 328 $query.= ' LIMIT 0,1'; 329 $query.= ';'; 330 $row = mysql_fetch_array( mysql_query( $query ) ); 331 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 332 $query.= " SET date_last = '".$row['date_available']."'"; 333 $query.= ' WHERE id = '.$id; 334 $query.= ';'; 335 mysql_query( $query ); 336 } 337 } 338 339 function check_date_format( $date ) 340 { 341 // date arrives at this format : DD/MM/YYYY 342 list($day,$month,$year) = explode( '/', $date ); 343 return checkdate ( $month, $day, $year ); 344 } 345 346 function date_convert( $date ) 347 { 348 // date arrives at this format : DD/MM/YYYY 349 // It must be transformed in YYYY-MM-DD 350 list($day,$month,$year) = explode( '/', $date ); 351 return $year.'-'.$month.'-'.$day; 352 } 353 354 function date_convert_back( $date ) 355 { 356 // date arrives at this format : YYYY-MM-DD 357 // It must be transformed in DD/MM/YYYY 358 if ( $date != '' ) 359 { 360 list($year,$month,$day) = explode( '-', $date ); 361 return $day.'/'.$month.'/'.$year; 362 } 363 else 364 { 365 return ''; 366 } 367 } 368 369 // get_keywords returns an array with relevant keywords found in the string 370 // given in argument. Keywords must be separated by comma in this string. 371 // keywords must : 372 // - be longer or equal to 3 characters 373 // - not contain ', " or blank characters 374 // - unique in the string ("test,test" -> "test") 375 function get_keywords( $keywords_string ) 376 { 377 $keywords = array(); 378 379 $candidates = explode( ',', $keywords_string ); 380 foreach ( $candidates as $candidate ) { 381 if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) ) 382 array_push( $keywords, $candidate ); 383 } 384 385 return array_unique( $keywords ); 386 } 387 388 function display_categories( $categories, $indent ) 389 { 390 global $vtp,$sub; 391 392 foreach ( $categories as $category ) { 393 $vtp->addSession( $sub, 'associate_cat' ); 394 $vtp->setVar( $sub, 'associate_cat.value', $category['id'] ); 395 $content = $indent.'- '.$category['name']; 396 $vtp->setVar( $sub, 'associate_cat.content', $content ); 397 $vtp->closeSession( $sub, 'associate_cat' ); 398 display_categories( $category['subcats'], $indent.str_repeat(' ',3) ); 399 } 400 } 265 401 ?> -
trunk/admin/infos_images.php
r57 r61 20 20 include_once( './include/isadmin.inc.php' ); 21 21 include_once( '../template/'.$user['template'].'/htmlfunctions.inc.php' ); 22 //------------------------------------------------------------------- functions23 function check_date_format( $date )24 {25 // date arrives at this format : DD/MM/YYYY26 list($day,$month,$year) = explode( '/', $date );27 return checkdate ( $month, $day, $year );28 }29 30 function date_convert( $date )31 {32 // date arrives at this format : DD/MM/YYYY33 // It must be transformed in YYYY-MM-DD34 list($day,$month,$year) = explode( '/', $date );35 return $year.'-'.$month.'-'.$day;36 }37 38 function date_convert_back( $date )39 {40 // date arrives at this format : YYYY-MM-DD41 // It must be transformed in DD/MM/YYYY42 if ( $date != '' )43 {44 list($year,$month,$day) = explode( '-', $date );45 return $day.'/'.$month.'/'.$year;46 }47 else48 {49 return '';50 }51 }52 53 // get_keywords returns an array with relevant keywords found in the string54 // given in argument. Keywords must be separated by comma in this string.55 // keywords must :56 // - be longer or equal to 3 characters57 // - not contain ', " or blank characters58 // - unique in the string ("test,test" -> "test")59 function get_keywords( $keywords_string )60 {61 $keywords = array();62 63 $candidates = explode( ',', $keywords_string );64 foreach ( $candidates as $candidate ) {65 if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )66 array_push( $keywords, $candidate );67 }68 69 return array_unique( $keywords );70 }71 22 //-------------------------------------------------------------- initialization 72 23 check_cat_id( $_GET['cat_id'] ); 73 74 24 if ( isset( $page['cat'] ) ) 75 25 { … … 77 27 $query = 'SELECT id,file'; 78 28 $query.= ' FROM '.PREFIX_TABLE.'images'; 79 $query.= ' WHERE cat_id = '.$page['cat']; 29 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 30 $query.= ' WHERE category_id = '.$page['cat']; 80 31 $query.= ';'; 81 32 $result = mysql_query( $query ); … … 122 73 else 123 74 { 124 $query.= '"';75 $query.= "'"; 125 76 foreach ( $keywords_array as $i => $keyword ) { 126 77 if ( $i > 0 ) $query.= ','; 127 78 $query.= $keyword; 128 79 } 129 $query.= '"';80 $query.= "'"; 130 81 } 131 82 … … 134 85 mysql_query( $query ); 135 86 } 136 } 87 // add link to another category 88 if ( $_POST['check-'.$row['id']] == 1 ) 89 { 90 $query = 'INSERT INTO '.PREFIX_TABLE.'image_category'; 91 $query.= ' (image_id,category_id) VALUES'; 92 $query.= ' ('.$row['id'].','.$_POST['associate'].')'; 93 $query.= ';'; 94 mysql_query( $query ); 95 } 96 } 97 update_category( $_POST['associate'] ); 137 98 //------------------------------------------------------ update general options 138 99 if ( $_POST['use_common_author'] == 1 ) 139 100 { 140 $query = 'UPDATE '.PREFIX_TABLE.'images'; 141 if ( $_POST['author_cat'] == '' ) 142 { 143 $query.= ' SET author = NULL'; 144 } 145 else 146 { 147 $query.= ' SET author = '; 148 $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'"; 149 } 150 $query.= ' WHERE cat_id = '.$page['cat']; 151 $query.= ';'; 152 mysql_query( $query ); 101 $query = 'SELECT image_id'; 102 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 103 $query.= ' WHERE category_id = '.$page['cat']; 104 $result = mysql_query( $query ); 105 while ( $row = mysql_fetch_array( $result ) ) 106 { 107 $query = 'UPDATE '.PREFIX_TABLE.'images'; 108 if ( $_POST['author_cat'] == '' ) 109 { 110 $query.= ' SET author = NULL'; 111 } 112 else 113 { 114 $query.= ' SET author = '; 115 $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'"; 116 } 117 $query.= ' WHERE id = '.$row['image_id']; 118 $query.= ';'; 119 mysql_query( $query ); 120 } 153 121 } 154 122 if ( $_POST['use_common_date_creation'] == 1 ) … … 157 125 { 158 126 $date = date_convert( $_POST['date_creation_cat'] ); 159 $query = 'UPDATE '.PREFIX_TABLE.'images'; 160 if ( $_POST['date_creation_cat'] == '' ) 161 { 162 $query.= ' SET date_creation = NULL'; 163 } 164 else 165 { 166 $query.= " SET date_creation = '".$date."'"; 167 } 168 $query.= ' WHERE cat_id = '.$page['cat']; 169 $query.= ';'; 170 mysql_query( $query ); 127 $query = 'SELECT image_id'; 128 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 129 $query.= ' WHERE category_id = '.$page['cat']; 130 $result = mysql_query( $query ); 131 while ( $row = mysql_fetch_array( $result ) ) 132 { 133 $query = 'UPDATE '.PREFIX_TABLE.'images'; 134 if ( $_POST['date_creation_cat'] == '' ) 135 { 136 $query.= ' SET date_creation = NULL'; 137 } 138 else 139 { 140 $query.= " SET date_creation = '".$date."'"; 141 } 142 $query.= ' WHERE id = '.$row['image_id']; 143 $query.= ';'; 144 mysql_query( $query ); 145 } 171 146 } 172 147 else … … 179 154 $query = 'SELECT id,keywords'; 180 155 $query.= ' FROM '.PREFIX_TABLE.'images'; 181 $query.= ' WHERE cat_id = '.$page['cat']; 156 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 157 $query.= ' WHERE category_id = '.$page['cat']; 182 158 $query.= ';'; 183 159 $result = mysql_query( $query ); … … 242 218 } 243 219 // retrieving category information 220 $page['plain_structure'] = get_plain_structure(); 244 221 $result = get_cat_info( $page['cat'] ); 245 $cat['local_dir'] = $result['local_dir'];246 $cat['dir'] = $result['dir'];247 222 $cat['name'] = $result['name']; 248 $cat['site_id'] = $result['site_id'];249 223 $cat['nb_images'] = $result['nb_images']; 250 224 //----------------------------------------------------- template initialization … … 255 229 'infoimage_creation_date','keywords', 256 230 'infoimage_addtoall','infoimage_removefromall', 257 'infoimage_keyword_separation' );231 'infoimage_keyword_separation','infoimage_associate' ); 258 232 templatize_array( $tpl, 'lang', $sub ); 233 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); 259 234 //------------------------------------------------------------------------ form 260 235 $url = './admin.php?page=infos_images&cat_id='.$page['cat']; … … 267 242 $vtp->setVar( $sub, 'cat_name', $cat_name ); 268 243 244 $array_cat_directories = array(); 245 269 246 $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation,keywords'; 247 $query.= ',storage_category_id,category_id'; 270 248 $query.= ' FROM '.PREFIX_TABLE.'images'; 271 $query.= ' WHERE cat_id = '.$page['cat']; 249 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 250 $query.= ' WHERE category_id = '.$page['cat']; 272 251 $query.= $conf['order_by']; 273 252 $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page']; … … 288 267 $vtp->setVar( $sub, 'picture.default_name', $file ); 289 268 // creating url to thumbnail 290 if ( $cat['site_id'] == 1 ) 291 { 292 $thumbnail_url = '../galleries/'.$cat['local_dir'].'/'; 293 } 294 else 295 { 296 $thumbnail_url = $cat['dir']; 269 if ( $array_cat_directories[$row['storage_category_id']] == '' ) 270 { 271 $array_cat_directories[$row['storage_category_id']] = 272 get_complete_dir( $row['storage_category_id'] ); 273 } 274 $thumbnail_url = $array_cat_directories[$row['storage_category_id']]; 275 if ( preg_match( '/^\.\/galleries/', $thumbnail_url ) ) 276 { 277 $thumbnail_url = '.'.$thumbnail_url; 297 278 } 298 279 $thumbnail_url.= 'thumbnail/'; … … 303 284 $vtp->closeSession( $sub, 'picture' ); 304 285 } 286 $structure = create_structure( '', array() ); 287 display_categories( $structure, ' ' ); 305 288 } 306 289 //----------------------------------------------------------- sending html code -
trunk/admin/update.php
r57 r61 31 31 if ( is_numeric( $cat_id ) ) 32 32 { 33 $cat_directory.= '/'.get_local_dir( $cat_id ); 33 34 $result = get_cat_info( $cat_id ); 34 $cat_directory.= '/'.$result['local_dir'];35 35 // 1. display the category name to update 36 36 $src = '../template/'.$user['template'].'/admin/images/puce.gif'; 37 37 $output = '<img src="'.$src.'" alt=">" />'; 38 38 $output.= '<span style="font-weight:bold;">'.$result['name'][0].'</span>'; 39 $output.= ' [ '.$result[' last_dir'].' ]';39 $output.= ' [ '.$result['dir'].' ]'; 40 40 $output.= '<div class="retrait">'; 41 41 42 42 // 2. we search pictures of the category only if the update is for all 43 43 // or a cat_id is specified … … 45 45 { 46 46 $output.= insert_local_image( $cat_directory, $cat_id ); 47 update_cat _info( $cat_id );48 } 49 } 50 47 update_category( $cat_id ); 48 } 49 } 50 51 51 // 3. we have to remove the categories of the database not present anymore 52 52 $query = 'SELECT id'; … … 66 66 { 67 67 // retrieving the directory 68 $rep = '../galleries'; 69 $resultat = get_cat_info( $row['id'] ); 70 $rep.= '/'.$resultat['local_dir']; 71 68 $rep = '../galleries/'.get_local_dir( $row['id'] ); 72 69 // is the directory present ? 73 if ( !is_dir( $rep ) ) 74 { 75 delete_category( $row['id'] ); 76 } 77 } 78 70 if ( !is_dir( $rep ) ) delete_category( $row['id'] ); 71 } 79 72 // 4. retrieving the sub-directories 80 73 $sub_rep = array(); … … 94 87 } 95 88 } 96 97 89 for ( $i = 0; $i < sizeof( $sub_rep ); $i++ ) 98 90 { … … 120 112 $query.= ' (dir,site_id,id_uppercat) VALUES'; 121 113 $query.= " ('".$sub_rep[$i]."','".$site_id."'"; 122 if ( !is_numeric( $cat_id ) ) 123 { 124 $query.= ',NULL'; 125 } 126 else 127 { 128 $query.= ",'".$cat_id."'"; 129 } 114 if ( !is_numeric( $cat_id ) ) $query.= ',NULL'; 115 else $query.= ",'".$cat_id."'"; 130 116 $query.= ');'; 131 117 mysql_query( $query ); … … 159 145 $query = 'SELECT id,file,tn_ext'; 160 146 $query.= ' FROM '.PREFIX_TABLE.'images'; 161 $query.= ' WHERE cat_id = '.$category_id;147 $query.= ' WHERE storage_category_id = '.$category_id; 162 148 $query.= ';'; 163 149 $result = mysql_query( $query ); … … 200 186 $query = 'SELECT id,validated,infos'; 201 187 $query.= ' FROM '.PREFIX_TABLE.'waiting'; 202 $query.= ' WHERE cat _id = '.$category_id;188 $query.= ' WHERE category_id = '.$category_id; 203 189 $query.= " AND file = '".$file."'"; 204 190 $query.= ';'; … … 212 198 $query = 'SELECT id'; 213 199 $query.= ' FROM '.PREFIX_TABLE.'images'; 214 $query.= ' WHERE cat_id = '.$category_id;200 $query.= ' WHERE storage_category_id = '.$category_id; 215 201 $query.= " AND file = '".$file."'"; 216 202 $query.= ';'; … … 267 253 foreach ( $pictures as $picture ) { 268 254 $query = 'INSERT INTO '.PREFIX_TABLE.'images'; 269 $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height'; 255 $query.= ' (file,storage_category_id,date_available,tn_ext'; 256 $query.= ',filesize,width,height'; 270 257 $query.= ',name,author,comment,date_creation)'; 271 258 $query.= ' VALUES '; … … 286 273 mysql_query( $query ); 287 274 $count_new++; 288 275 // retrieving the id of newly inserted picture 276 $query = 'SELECT id'; 277 $query.= ' FROM '.PREFIX_TABLE.'images'; 278 $query.= ' WHERE storage_category_id = '.$category_id; 279 $query.= " AND file = '".$picture['file']."'"; 280 $query.= ';'; 281 list( $image_id ) = mysql_fetch_array( mysql_query( $query ) ); 282 // adding the link between this picture and its storage category 283 $query = 'INSERT INTO '.PREFIX_TABLE.'image_category'; 284 $query.= ' (image_id,category_id) VALUES '; 285 $query.= ' ('.$image_id.','.$category_id.')'; 286 $query.= ';'; 287 mysql_query( $query ); 288 289 289 $output.= $picture['file']; 290 290 $output.= ' <span style="font-weight:bold;">'; … … 295 295 return $output; 296 296 } 297 298 // The function "update_cat_info" updates the information about the last299 // online image and the number of images in the category300 function update_cat_info( $category_id )301 {302 $query = 'SELECT date_available';303 $query.= ' FROM '.PREFIX_TABLE.'images';304 $query.= ' WHERE cat_id = '.$category_id;305 $query.= ' ORDER BY date_available DESC';306 $query.= ' LIMIT 0,1';307 $query.= ';';308 $result = mysql_query( $query );309 $row = mysql_fetch_array( $result );310 $date_last = $row['date_available'];311 312 $query = 'SELECT COUNT(*) as nb_images';313 $query.= ' FROM '.PREFIX_TABLE.'images';314 $query.= ' WHERE cat_id = '.$category_id;315 $result = mysql_query( $query );316 $row = mysql_fetch_array( $result );317 $nb_images = $row['nb_images'];318 319 $query = 'UPDATE '.PREFIX_TABLE.'categories';320 $query.= " SET date_last = '".$date_last."'";321 $query.= ', nb_images = '.$nb_images;322 $query.= ' where id = '.$category_id;323 $query.= ';';324 mysql_query( $query );325 }326 297 327 298 // remote_images verifies if a file named "listing.xml" is present is the … … 342 313 343 314 // 2. is the site already existing ? 344 $query = ' selectid';345 $query.= ' from'.PREFIX_TABLE.'sites';346 $query.= " wheregalleries_url = '".$url."'";315 $query = 'SELECT id'; 316 $query.= ' FROM '.PREFIX_TABLE.'sites'; 317 $query.= " WHERE galleries_url = '".$url."'"; 347 318 $query.= ';'; 348 319 $result = mysql_query( $query ); … … 350 321 { 351 322 // we have to register this site in the database 352 $query = ' insert into'.PREFIX_TABLE.'sites';353 $query.= " (galleries_url) values('".$url."')";323 $query = 'INSERT INTO '.PREFIX_TABLE.'sites'; 324 $query.= " (galleries_url) VALUES ('".$url."')"; 354 325 $query.= ';'; 355 326 mysql_query( $query ); … … 391 362 $output.= '<div class="retrait">'; 392 363 393 $query = ' selectid';394 $query.= ' from'.PREFIX_TABLE.'categories';395 $query.= ' wheresite_id = '.$site_id;396 $query.= " anddir = '".$name."'";364 $query = 'SELECT id'; 365 $query.= ' FROM '.PREFIX_TABLE.'categories'; 366 $query.= ' WHERE site_id = '.$site_id; 367 $query.= " AND dir = '".$name."'"; 397 368 if ( $id_uppercat == 'NULL' ) 398 369 { 399 $query.= ' and id_uppercat isNULL';370 $query.= ' AND id_uppercat IS NULL'; 400 371 } 401 372 else 402 373 { 403 $query.= ' andid_uppercat = '.$id_uppercat;374 $query.= ' AND id_uppercat = '.$id_uppercat; 404 375 } 405 376 $query.= ';'; … … 408 379 { 409 380 // we have to create the category 410 $query = ' insert into'.PREFIX_TABLE.'categories';411 $query.= " (dir,site_id,id_uppercat) values('".$name."',".$site_id;381 $query = 'INSERT INTO '.PREFIX_TABLE.'categories'; 382 $query.= " (dir,site_id,id_uppercat) VALUES ('".$name."',".$site_id; 412 383 if ( !is_numeric( $id_uppercat ) ) 413 384 { … … 429 400 } 430 401 $output.= insert_remote_image( $list_dirs[$i], $category_id ); 431 update_cat _info( $category_id );402 update_category( $category_id ); 432 403 $output.= insert_remote_category( $list_dirs[$i], $site_id, 433 404 $category_id, $level+1 ); … … 436 407 // we have to remove the categories of the database not present in the xml 437 408 // file (ie deleted from the picture storage server) 438 $query = ' selectdir,id';439 $query.= ' from'.PREFIX_TABLE.'categories';440 $query.= ' wheresite_id = '.$site_id;409 $query = 'SELECT dir,id'; 410 $query.= ' FROM '.PREFIX_TABLE.'categories'; 411 $query.= ' WHERE site_id = '.$site_id; 441 412 if ( !is_numeric( $id_uppercat ) ) 442 413 { 443 $query.= ' and id_uppercat isNULL';414 $query.= ' AND id_uppercat IS NULL'; 444 415 } 445 416 else 446 417 { 447 $query.= ' andid_uppercat = '.$id_uppercat;418 $query.= ' AND id_uppercat = '.$id_uppercat; 448 419 } 449 420 $query.= ';'; … … 485 456 486 457 // is the picture already existing in the database ? 487 $query = ' selectid,tn_ext';488 $query.= ' from'.PREFIX_TABLE.'images';489 $query.= ' where cat_id = '.$category_id;490 $query.= " andfile = '".$file."'";458 $query = 'SELECT id,tn_ext'; 459 $query.= ' FROM '.PREFIX_TABLE.'images'; 460 $query.= ' WHERE storage_category_id = '.$category_id; 461 $query.= " AND file = '".$file."'"; 491 462 $query.= ';'; 492 463 $result = mysql_query( $query ); … … 494 465 if ( mysql_num_rows( $result ) == 0 ) 495 466 { 496 $query = 'insert into '.PREFIX_TABLE.'images'; 497 $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height)'; 498 $query.= ' values ('; 467 $query = 'INSERT INTO '.PREFIX_TABLE.'images'; 468 $query.= ' (file,storage_category_id,date_available,tn_ext'; 469 $query.= ',filesize,width,height)'; 470 $query.= ' VALUES ('; 499 471 $query.= "'".$file."'"; 500 472 $query.= ",'".$category_id."'"; … … 506 478 $query.= ')'; 507 479 $query.= ';'; 480 // retrieving the id of newly inserted picture 481 $query = 'SELECT id'; 482 $query.= ' FROM '.PREFIX_TABLE.'images'; 483 $query.= ' WHERE storage_category_id = '.$category_id; 484 $query.= " AND file = '".$file."'"; 485 $query.= ';'; 486 list( $image_id ) = mysql_fetch_array( mysql_query( $query ) ); 487 // adding the link between this picture and its storage category 488 $query = 'INSERT INTO '.PREFIX_TABLE.'image_category'; 489 $query.= ' (image_id,category_id) VALUES '; 490 $query.= ' ('.$image_id.','.$category_id.')'; 491 $query.= ';'; 492 mysql_query( $query ); 508 493 509 494 $output.= $file; … … 520 505 if ( $row['tn_ext'] != $tn_ext ) 521 506 { 522 $query = ' update'.PREFIX_TABLE.'images';523 $query.= ' set';507 $query = 'UPDATE '.PREFIX_TABLE.'images'; 508 $query.= ' SET'; 524 509 $query.= " tn_ext = '".$tn_ext."'"; 525 $query.= ' where cat_id = '.$category_id;526 $query.= " andfile = '".$file."'";510 $query.= ' WHERE storage_category_id = '.$category_id; 511 $query.= " AND file = '".$file."'"; 527 512 $query.= ';'; 528 513 } … … 536 521 // we have to remove the pictures of the database not present in the xml file 537 522 // (ie deleted from the picture storage server) 538 $query = ' selectid,file';539 $query.= ' from'.PREFIX_TABLE.'images';540 $query.= ' where cat_id = '.$category_id;523 $query = 'SELECT id,file'; 524 $query.= ' FROM '.PREFIX_TABLE.'images'; 525 $query.= ' WHERE storage_category_id = '.$category_id; 541 526 $query.= ';'; 542 527 $result = mysql_query( $query ); … … 558 543 templatize_array( $tpl, 'lang', $sub ); 559 544 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); 545 //-------------------------------------------------------- categories structure 546 $page['plain_structure'] = get_plain_structure(); 560 547 //-------------------------------------------- introduction : choices of update 561 548 // Display choice if "update" var is not specified -
trunk/admin/waiting.php
r57 r61 21 21 if ( isset( $_POST['submit'] ) ) 22 22 { 23 $query = 'SELECT id, cat_id,file,tn_ext';23 $query = 'SELECT id,storage_category_id,file,tn_ext'; 24 24 $query.= ' FROM '.PREFIX_TABLE.'waiting'; 25 25 $query.= " WHERE validated = 'false'"; … … 40 40 $query.= ';'; 41 41 mysql_query( $query ); 42 // linking logically the picture to its storage category 43 $query = 'INSERT INTO'; 42 44 } 43 45 else … … 50 52 mysql_query( $query ); 51 53 // deletion of the associated files 52 $ cat = get_cat_info( $row['cat_id'] );53 unlink( '.'.$ cat['dir'].$row['file'] );54 $dir = get_complete_dir( $row['storage_category_id'] ); 55 unlink( '.'.$dir.$row['file'] ); 54 56 if ( $row['tn_ext'] != '' ) 55 57 { … … 57 59 $thumbnail.= get_filename_wo_extension( $row['file'] ); 58 60 $thumbnail.= '.'.$row['tn_ext']; 59 $url = '.'.$ cat['dir'].'thumbnail/'.$thumbnail;61 $url = '.'.$dir.'thumbnail/'.$thumbnail; 60 62 unlink( $url ); 61 63 } … … 71 73 //---------------------------------------------------------------- form display 72 74 $cat_names = array(); 73 $query = 'SELECT id,cat_id,file,username,mail_address,date,tn_ext'; 75 $query = 'SELECT id,storage_category_id,file,username,mail_address'; 76 $query.= ',date,tn_ext'; 74 77 $query.= ' FROM '.PREFIX_TABLE.'waiting'; 75 78 $query.= " WHERE validated = 'false'"; 76 $query.= ' ORDER BY cat_id';79 $query.= ' ORDER BY storage_category_id'; 77 80 $query.= ';'; 78 81 $result = mysql_query( $query ); … … 86 89 $vtp->setVar( $sub, 'picture.class', 'row2' ); 87 90 } 88 if ( !isset( $cat_names[$row[' cat_id']] ) )91 if ( !isset( $cat_names[$row['storage_category_id']] ) ) 89 92 { 90 $cat = get_cat_info( $row['cat_id'] ); 91 $cat_names[$row['cat_id']] = array(); 92 $cat_names[$row['cat_id']]['dir'] = '.'.$cat['dir']; 93 $cat_names[$row['cat_id']]['display_name'] = 93 $cat = get_cat_info( $row['storage_category_id'] ); 94 $cat_names[$row['storage_category_id']] = array(); 95 $cat_names[$row['storage_category_id']]['dir'] = 96 '.'.get_complete_dir( $row['storage_category_id'] ); 97 $cat_names[$row['storage_category_id']]['display_name'] = 94 98 get_cat_display_name( $cat['name'], ' > ', 'font-weight:bold;' ); 95 99 } 96 100 // category name 97 101 $vtp->setVar( $sub, 'picture.cat_name', 98 $cat_names[$row[' cat_id']]['display_name'] );102 $cat_names[$row['storage_category_id']]['display_name'] ); 99 103 // date displayed like this (in English ) : 100 104 // Sunday 15 June 2003 21:29 101 $date = $lang['day'][date( 'w', $row['date'] )]; // Sunday 102 $date.= date( ' j ', $row['date'] ); // 15 103 $date.= $lang['month'][date( 'n', $row['date'] )]; // June 104 $date.= date( ' Y G:i', $row['date'] ); // 2003 21:29 105 $date = format_date( $row['date'], 'unix', true ); 105 106 $vtp->setVar( $sub, 'picture.date', $date ); 106 107 // file preview link 107 $url = $cat_names[$row[' cat_id']]['dir'].$row['file'];108 $url = $cat_names[$row['storage_category_id']]['dir'].$row['file']; 108 109 $vtp->setVar( $sub, 'picture.preview_url', $url ); 109 110 // file name … … 116 117 $thumbnail.= get_filename_wo_extension( $row['file'] ); 117 118 $thumbnail.= '.'.$row['tn_ext']; 118 $url = $cat_names[$row['cat_id']]['dir'].'thumbnail/'.$thumbnail; 119 $url = $cat_names[$row['storage_category_id']]['dir']; 120 $url.= 'thumbnail/'.$thumbnail; 119 121 $vtp->setVar( $sub, 'thumbnail.preview_url', $url ); 120 122 $vtp->setVar( $sub, 'thumbnail.file', $thumbnail ); -
trunk/category.php
r57 r61 232 232 if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 ) 233 233 { 234 if ( is_numeric( $page['cat'] ) ) 235 { 236 $cat_directory = $page['cat_dir']; 237 } 238 else if ( $page['cat'] == 'search' or $page['cat'] == 'fav' ) 239 { 240 $array_cat_directories = array(); 241 } 234 $array_cat_directories = array(); 242 235 243 $query = 'SELECT id,file,date_available,tn_ext,name,filesize,cat_id'; 236 $query = 'SELECT id,file,date_available,tn_ext,name,filesize'; 237 $query.= ',storage_category_id,category_id'; 244 238 $query.= ' FROM '.PREFIX_TABLE.'images'; 239 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 245 240 $query.= $page['where']; 246 241 $query.= $conf['order_by']; 247 242 $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page']; 248 243 $query.= ';'; 249 echo $query;250 244 $result = mysql_query( $query ); 251 245 … … 258 252 while ( $row = mysql_fetch_array( $result ) ) 259 253 { 260 if ( !is_numeric( $page['cat'] ) ) 261 { 262 if ( $array_cat_directories[$row['cat_id']] == '' ) 263 { 264 $cat_result = get_cat_info( $row['cat_id'] ); 265 $array_cat_directories[$row['cat_id']] = $cat_result['dir']; 266 } 267 $cat_directory = $array_cat_directories[$row['cat_id']]; 268 } 254 if ( $array_cat_directories[$row['storage_category_id']] == '' ) 255 { 256 $array_cat_directories[$row['storage_category_id']] = 257 get_complete_dir( $row['storage_category_id'] ); 258 } 259 $cat_directory = $array_cat_directories[$row['storage_category_id']]; 260 269 261 $file = get_filename_wo_extension( $row['file'] ); 270 262 // name of the picture 271 if ( $row['name'] != '' ) 272 { 273 $name = $row['name']; 274 } 275 else 276 { 277 $name = str_replace( '_', ' ', $file ); 278 } 263 if ( $row['name'] != '' ) $name = $row['name']; 264 else $name = str_replace( '_', ' ', $file ); 265 279 266 if ( $page['cat'] == 'search' ) 280 267 { … … 359 346 $i = 0; 360 347 foreach ( $subcats as $subcat_id => $non_empty_id ) { 361 $subcat_infos = get_cat_info( $subcat_id ); 362 $non_empty_infos = get_cat_info( $non_empty_id ); 348 $subcat_infos = get_cat_info( $subcat_id ); 363 349 364 350 $name ='[ <span style="font-weight:bold;">'; 365 351 $name.= $subcat_infos['name'][0]; 366 352 $name.= '</span> ]'; 367 368 $query = 'SELECT file,tn_ext ';353 354 $query = 'SELECT file,tn_ext,storage_category_id'; 369 355 $query.= ' FROM '.PREFIX_TABLE.'images'; 370 $query.= ' WHERE cat_id = '.$non_empty_id; 356 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 357 $query.= ' WHERE category_id = '.$non_empty_id; 371 358 $query.= ' ORDER BY RAND()'; 372 359 $query.= ' LIMIT 0,1'; … … 378 365 379 366 // creating links for thumbnail and associated category 380 $thumbnail_link = $non_empty_infos['dir'];367 $thumbnail_link = get_complete_dir( $image_row['storage_category_id'] ); 381 368 $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail']; 382 369 $thumbnail_link.= $file.'.'.$image_row['tn_ext']; -
trunk/include/functions.inc.php
r57 r61 350 350 } 351 351 } 352 353 function format_date( $date, $type = 'us', $show_time = false ) 354 { 355 global $lang; 356 357 switch ( $type ) 358 { 359 case 'us' : 360 list( $year,$month,$day ) = explode( '-', $date ); 361 $unixdate = mktime(0,0,0,$month,$day,$year); 362 break; 363 case 'unix' : 364 $unixdate = $date; 365 break; 366 } 367 $formated_date = $lang['day'][date( "w", $unixdate )]; 368 $formated_date.= date( " j ", $unixdate ); 369 $formated_date.= $lang['month'][date( "n", $unixdate )]; 370 $formated_date.= date( ' Y', $unixdate ); 371 if ( $show_time ) 372 { 373 $formated_date.= date( ' G:i', $unixdate ); 374 } 375 376 return $formated_date; 377 } 352 378 ?> -
trunk/include/functions_category.inc.php
r57 r61 95 95 { 96 96 $infos = array( 'name','id','date_last','nb_images','dir','id_uppercat', 97 'rank' );97 'rank','site_id'); 98 98 99 99 $query = 'SELECT '; … … 271 271 // $cat['comment'] 272 272 // $cat['dir'] 273 // $cat[' last_dir']273 // $cat['dir'] 274 274 // $cat['name'] is an array : 275 275 // - $cat['name'][0] is the lowest cat name … … 281 281 function get_cat_info( $id ) 282 282 { 283 global $page; 284 283 285 $cat = array(); 284 $cat['name'] = array();285 286 286 287 $query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir'; 287 $query.= ',date_last,uploadable ';288 $query.= ',date_last,uploadable,status,visible'; 288 289 $query.= ' FROM '.PREFIX_TABLE.'categories AS a'; 289 290 $query.= ', '.PREFIX_TABLE.'sites AS b'; … … 295 296 $cat['comment'] = nl2br( $row['comment'] ); 296 297 $cat['nb_images'] = $row['nb_images']; 297 $cat[' last_dir']= $row['dir'];298 $cat['dir'] = $row['dir']; 298 299 $cat['date_last'] = $row['date_last']; 299 300 $cat['uploadable'] = get_boolean( $row['uploadable'] ); 300 $galleries_url = $row['galleries_url']; 301 302 $cat['dir'] = ""; 303 $i = 0; 304 $is_root = false; 305 $row['id_uppercat'] = $id; 306 while ( !$is_root ) 307 { 308 $query = 'SELECT name,dir,id_uppercat'; 309 $query.= ' FROM '.PREFIX_TABLE.'categories'; 310 $query.= ' WHERE id = '.$row['id_uppercat'].';'; 311 $row = mysql_fetch_array( mysql_query( $query ) ); 312 $cat['dir'] = $row['dir'].'/'.$cat['dir']; 313 if ( $row['name'] == "" ) 314 { 315 $cat['name'][$i] = str_replace( "_", " ", $row['dir'] ); 316 } 317 else 318 { 319 $cat['name'][$i] = $row['name']; 320 } 321 if ( $row['id_uppercat'] == "" ) 322 { 323 $is_root = true; 324 } 325 $i++; 326 } 327 $cat['local_dir'] = substr( $cat['dir'], 0 , strlen( $cat['dir'] ) - 1 ); 328 $cat['dir'] = $galleries_url.$cat['dir']; 329 301 $cat['status'] = $row['status']; 302 $cat['visible'] = get_boolean( $row['visible'] ); 303 304 $cat['name'] = array(); 305 array_push( $cat['name'], $page['plain_structure'][$id]['name'] ); 306 while ( $page['plain_structure'][$id]['id_uppercat'] != '' ) 307 { 308 $id = $page['plain_structure'][$id]['id_uppercat']; 309 array_push( $cat['name'], $page['plain_structure'][$id]['name'] ); 310 } 330 311 return $cat; 331 312 } 332 313 314 // get_complete_dir returns the concatenation of get_site_url and 315 // get_local_dir 316 // Example : "pets > rex > 1_year_old" is on the the same site as the 317 // PhpWebGallery files and this category has 22 for identifier 318 // get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/" 319 function get_complete_dir( $category_id ) 320 { 321 return get_site_url( $category_id ).get_local_dir( $category_id ); 322 } 323 324 // get_local_dir returns an array with complete path without the site url 325 // Example : "pets > rex > 1_year_old" is on the the same site as the 326 // PhpWebGallery files and this category has 22 for identifier 327 // get_local_dir(22) returns "pets/rex/1_year_old/" 328 function get_local_dir( $category_id ) 329 { 330 global $page; 331 332 // creating the local path : "root_cat/sub_cat/sub_sub_cat/" 333 $dir = $page['plain_structure'][$category_id]['dir'].'/'; 334 while ( $page['plain_structure'][$category_id]['id_uppercat'] != '' ) 335 { 336 $category_id = $page['plain_structure'][$category_id]['id_uppercat']; 337 $dir = $page['plain_structure'][$category_id]['dir'].'/'.$dir; 338 } 339 return $dir; 340 } 341 342 // retrieving the site url : "http://domain.com/gallery/" or 343 // simply "./galleries/" 344 function get_site_url( $category_id ) 345 { 346 global $page; 347 348 $query = 'SELECT galleries_url'; 349 $query.= ' FROM '.PREFIX_TABLE.'sites'; 350 $query.= ' WHERE id = '.$page['plain_structure'][$category_id]['site_id']; 351 $query.= ';'; 352 $row = mysql_fetch_array( mysql_query( $query ) ); 353 return $row['galleries_url']; 354 } 355 333 356 // The function get_cat_display_name returns a string containing the list 334 357 // of upper categories to the root category from the lowest category shown … … 402 425 $page['cat_uploadable'] = $result['uploadable']; 403 426 $page['title'] = get_cat_display_name( $page['cat_name'], ' - ', '' ); 404 $page['where'] = ' WHERE cat _id = '.$page['cat'];427 $page['where'] = ' WHERE category_id = '.$page['cat']; 405 428 } 406 429 else … … 412 435 $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); 413 436 foreach ( $restricted_cats as $restricted_cat ) { 414 $where_append.= ' AND cat _id != '.$restricted_cat;437 $where_append.= ' AND category_id != '.$restricted_cat; 415 438 } 416 439 } … … 500 523 { 501 524 $page['title'] = $conf['top_number'].' '.$lang['most_visited_cat']; 502 $page['where'] = ' WHERE cat _id != -1'.$where_append;525 $page['where'] = ' WHERE category_id != -1'.$where_append; 503 526 $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; 504 527 $page['cat_nb_images'] = $conf['top_number']; -
trunk/language/francais.php
r48 r61 30 30 $lang['open'] = 'ouvrir'; 31 31 $lang['keywords'] = 'mots-clefs'; 32 $lang['errors_title'] = 'Erreurs'; 33 $lang['default'] = 'défaut'; 32 34 // end version 1.3 33 35 … … 265 267 $lang['title_group_perm'] = 'Modifier les permissions pour le groupe'; 266 268 $lang['title_comments'] = 'Commentaires des visiteurs'; 269 $lang['title_picmod'] = 'Modifier les informations d\'une image'; 267 270 // end version 1.3 268 271 $lang['title_categories'] = 'Gestion des catégories'; … … 512 515 $lang['infoimage_addtoall'] = 'ajouter à tous'; 513 516 $lang['infoimage_removefromall'] = 'retirer à tous'; 517 $lang['infoimage_associate'] = 'Associer à la catégorie'; 514 518 // end version 1.3 515 519 $lang['infoimage_general'] = 'Options générale pour la catégorie'; -
trunk/picture.php
r57 r61 24 24 check_cat_id( $_GET['cat'] ); 25 25 check_login_authorization(); 26 $page['plain_structure'] = get_plain_structure(); 26 27 if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) 27 28 { … … 39 40 //------------------------------------- main picture information initialization 40 41 $query = 'SELECT id,date_available,comment,hit,keywords'; 41 $query.= ',author,name,file,date_creation,filesize,width,height,cat_id'; 42 $query.= ',author,name,file,date_creation,filesize,width,height'; 43 $query.= ',storage_category_id,category_id'; 42 44 $query.= ' FROM '.PREFIX_TABLE.'images'; 45 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 43 46 $query.= $page['where']; 44 47 $query.= ' AND id = '.$_GET['image_id']; … … 58 61 $page['width'] = $row['width']; 59 62 $page['height'] = $row['height']; 60 $page['cat _id'] = $row['cat_id'];63 $page['category_id'] = $row['category_id']; 61 64 $page['keywords'] = $row['keywords']; 65 $page['storage_category_id'] = $row['storage_category_id']; 62 66 // retrieving the number of the picture in its category (in order) 63 67 $query = 'SELECT id'; 64 68 $query.= ' FROM '.PREFIX_TABLE.'images'; 69 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 65 70 $query.= $page['where']; 66 71 $query.= $conf['order_by']; … … 124 129 $query = 'SELECT id'; 125 130 $query.= ' FROM '.PREFIX_TABLE.'images'; 131 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 126 132 $query.= $page['where']; 127 133 $query.= $conf['order_by']; … … 206 212 { 207 213 $prev = $page['num'] - 1; 208 $query = 'SELECT id,name,file,tn_ext, cat_id';214 $query = 'SELECT id,name,file,tn_ext,storage_category_id'; 209 215 $query.= ' FROM '.PREFIX_TABLE.'images'; 216 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 210 217 $query.= $page['where']; 211 218 $query.= $conf['order_by']; … … 215 222 $row = mysql_fetch_array( $result ); 216 223 217 if ( !is_numeric( $page['cat'] ) ) 218 { 219 if ( $array_cat_directories[$row['cat_id']] == '' ) 220 { 221 $cat_result = get_cat_info( $row['cat_id'] ); 222 $array_cat_directories[$row['cat_id']] = $cat_result['dir']; 223 } 224 $cat_directory = $array_cat_directories[$row['cat_id']]; 225 } 226 227 $file = substr ( $row['file'], 0, strrpos ( $row['file'], '.' ) ); 224 if ( $array_cat_directories[$row['storage_category_id']] == '' ) 225 { 226 $array_cat_directories[$row['storage_category_id']] = 227 get_complete_dir( $row['storage_category_id'] ); 228 } 229 $cat_directory = $array_cat_directories[$row['storage_category_id']]; 230 231 $file = substr( $row['file'], 0, strrpos ( $row['file'], '.' ) ); 228 232 $lien_thumbnail = $cat_directory.'/thumbnail/'; 229 233 $lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext']; 230 234 231 235 $prev_title = $lang['previous_image'].' : '; 232 236 $alt_thumbnaill = ''; … … 262 266 else 263 267 { 264 $cat_result = get_cat_info( $page['cat_id'] );265 if ( $array_cat_directories[$page['cat_id']] == "" )266 {267 $array_cat_directories[$page['cat_id']] = $cat_result['dir'];268 }269 $cat_directory = $array_cat_directories[$page['cat_id']];270 268 $intitule_cat = $page['title']; 271 269 } 270 271 if ( $array_cat_directories[$page['storage_category_id']] == '' ) 272 { 273 $array_cat_directories[$page['storage_category_id']] = 274 get_complete_dir( $page['storage_category_id'] ); 275 } 276 $cat_directory = $array_cat_directories[$page['storage_category_id']]; 277 272 278 $n = $page['num'] + 1; 273 279 $intitule_titre = replace_space( $intitule_cat." - " ).$n.'/'. … … 348 354 $vtp->addSession( $handle, 'info_line' ); 349 355 $vtp->setVar( $handle, 'info_line.name', $lang['creation_date'].' : ' ); 350 list( $year,$month,$day ) = explode( '-', $page['date_creation'] );351 356 $vtp->setVar( $handle, 'info_line.content', 352 $day.'/'.$month.'/'.$year);357 format_date( $page['date_creation'] ) ); 353 358 $vtp->closeSession( $handle, 'info_line' ); 354 359 } … … 358 363 list( $year,$month,$day ) = explode( '-', $page['date_available'] ); 359 364 $vtp->setVar( $handle, 'info_line.content', 360 $day.'/'.$month.'/'.$year);365 format_date( $page['date_available'] ) ); 361 366 $vtp->closeSession( $handle, 'info_line' ); 362 367 // size in pixels … … 456 461 { 457 462 $vtp->addSession( $handle, 'modification' ); 458 $url = './admin/admin.php?page=infos_images&cat_id='.$page['cat']; 459 $url.= '&num='.$page['num']; 460 $vtp->setVar( $handle, 'modification.link', 461 add_session_id( $url )."#".$page['id'] ); 463 $url = './admin/admin.php?page=picture_modify&cat_id='.$page['cat']; 464 $url.= '&image_id='.$page['id']; 465 $vtp->setVar( $handle, 'modification.link', add_session_id( $url ) ); 462 466 $vtp->setVar( $handle, 'modification.name', $lang['link_info_image'] ); 463 467 } … … 466 470 { 467 471 $next = $page['num'] + 1; 468 $query = 'SELECT id,name,file,tn_ext, cat_id';472 $query = 'SELECT id,name,file,tn_ext,storage_category_id'; 469 473 $query.= ' FROM '.PREFIX_TABLE.'images'; 474 $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 470 475 $query.= $page['where']; 471 476 $query.= $conf['order_by']; … … 474 479 $result = mysql_query( $query ); 475 480 $row = mysql_fetch_array( $result ); 476 477 if ( !is_numeric( $page['cat'] ) ) 478 { 479 if ( $array_cat_directories[$row['cat_id']] == "" ) 480 { 481 $cat_result = get_cat_info( $row['cat_id'] ); 482 $array_cat_directories[$row['cat_id']] = $cat_result['dir']; 483 } 484 $cat_directory = $array_cat_directories[$row['cat_id']]; 485 } 481 482 if ( $array_cat_directories[$row['storage_category_id']] == '' ) 483 { 484 $array_cat_directories[$row['storage_category_id']] = 485 get_complete_dir( $row['storage_category_id'] ); 486 } 487 $cat_directory = $array_cat_directories[$row['storage_category_id']]; 486 488 487 489 $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); … … 630 632 $vtp->addSession( $handle, 'comment' ); 631 633 $vtp->setVar( $handle, 'comment.author', $row['author'] ); 632 $displayed_date = $lang['day'][date( "w", $row['date'] )]; 633 $displayed_date.= date( " j ", $row['date'] ); 634 $displayed_date.= $lang['month'][date( "n", $row['date'] )]; 635 $displayed_date.= date( ' Y G:i', $row['date'] ); 636 $vtp->setVar( $handle, 'comment.date', $displayed_date ); 634 $vtp->setVar( $handle, 'comment.date', 635 format_date( $row['date'], 'unix', true ) ); 637 636 $vtp->setVar( $handle, 'comment.content', nl2br( $row['content'] ) ); 638 637 if ( $user['status'] == 'admin' ) -
trunk/template/default/admin/configuration.vtp
r55 r61 1 1 <!--VTP_errors--> 2 2 <div class="errors"> 3 <div class="errors_title"> Erreurs</div>3 <div class="errors_title">{#errors_title}</div> 4 4 <ul> 5 5 <!--VTP_li--> -
trunk/template/default/admin/infos_image.vtp
r48 r61 43 43 <table width="100%"> 44 44 <tr> 45 <th colspan=" 6">{#infoimage_detailed}</th>45 <th colspan="7">{#infoimage_detailed}</th> 46 46 </tr> 47 47 <tr> 48 <td colspan=" 6" align="center">{#navigation_bar}</td>48 <td colspan="7" align="center">{#navigation_bar}</td> 49 49 </tr> 50 50 <tr> 51 <td style="width:0px;"> </td> 51 52 <td class="row2" style="text-align:center;">{#thumbnail}</td> 52 53 <td class="row2" style="text-align:center;">{#infoimage_title}</td> … … 58 59 <!--VTP_picture--> 59 60 <tr> 61 <td style="width:0px;"> 62 <div style="margin-left:2px;margin-right:2px;"> 63 <input type="checkbox" name="check-{#id}" value="1" /> 64 </div> 65 </td> 60 66 <td style="text-align:center;"><a name="{#link}" href="{#url}"><img src="{#thumbnail_url}" alt="" class="miniature" title="{#filename}" /></td> 61 67 <td style="text-align:center;">{#default_name}<br /><input type="text" name="name-{#id}" value="{#name}" maxlength="255"/></td> … … 67 73 <!--/VTP_picture--> 68 74 <tr> 75 <td colspan="6"> 76 <img src="../template/{#user_template}/admin/images/arrow_up.gif" alt="<" /> 77 {#infoimage_associate} 78 <select name="associate"> 79 <!--VTP_associate_cat--> 80 <option value="{#value}">{#content}</option> 81 <!--/VTP_associate_cat--> 82 </select> 83 </td> 84 </tr> 85 <tr> 69 86 <td colspan="6" style="text-align:center;"> 70 87 <input type="submit" value="{#submit}" name="submit" /> -
trunk/upload.php
r57 r61 206 206 { 207 207 $query = 'insert into '.PREFIX_TABLE.'waiting'; 208 $query.= ' (cat_id,file,username,mail_address,date,infos) values'; 209 $query.= " (".$page['cat'].",'".$_FILES['picture']['name']."'"; 208 $query.= ' (storage_category_id,file,username,mail_address,date,infos)'; 209 $query.= ' values '; 210 $query.= '('.$page['cat'].",'".$_FILES['picture']['name']."'"; 210 211 $query.= ",'".htmlspecialchars( $_POST['username'], ENT_QUOTES)."'"; 211 212 $query.= ",'".$_POST['mail_address']."',".time().",'".$xml_infos."')";
Note: See TracChangeset
for help on using the changeset viewer.