source: trunk/admin/include/functions.php @ 593

Last change on this file since 593 was 593, checked in by z0rglub, 19 years ago

update headers to comply with GPL

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2004 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-11-06 21:12:59 +0000 (Sat, 06 Nov 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 593 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28include(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php');
29
30$tab_ext_create_TN = array ( 'jpg', 'png', 'JPG', 'PNG' );
31
32// is_image returns true if the given $filename (including the path) is a
33// picture according to its format and its extension.
34// As GD library can only generate pictures from jpeg and png files, if you
35// ask if the filename is an image for thumbnail creation (second parameter
36// set to true), the only authorized formats are jpeg and png.
37function is_image( $filename, $create_thumbnail = false )
38{
39  global $conf, $tab_ext_create_TN;
40
41  if ( is_file( $filename ) )
42  {
43    $size = getimagesize( $filename );
44    // $size[2] == 1 means GIF
45    // $size[2] == 2 means JPG
46    // $size[2] == 3 means PNG
47    if ( !$create_thumbnail )
48    {
49      if ( in_array( get_extension( $filename ), $conf['picture_ext'] )
50           and ( $size[2] == 1 or $size[2] == 2 or $size[2] == 3 ) )
51      {
52        return true;
53      }
54    }
55    else
56    {
57      if ( in_array( get_extension( $filename ), $tab_ext_create_TN )
58           and ( $size[2] == 2 or $size[2] == 3 ) )
59      {
60        return true;
61      }
62    }
63  }
64  return false;
65}
66
67/**
68 * returns an array with all picture files according to $conf['file_ext']
69 *
70 * @param string $dir
71 * @return array
72 */
73function get_pwg_files($dir)
74{
75  global $conf;
76
77  $pictures = array();
78  if ($opendir = opendir($dir))
79  {
80    while ($file = readdir($opendir))
81    {
82      if (in_array(get_extension($file), $conf['file_ext']))
83      {
84        array_push($pictures, $file);
85      }
86    }
87  }
88  return $pictures;
89}
90
91/**
92 * returns an array with all thumbnails according to $conf['picture_ext']
93 * and $conf['prefix_thumbnail']
94 *
95 * @param string $dir
96 * @return array
97 */
98function get_thumb_files($dir)
99{
100  global $conf;
101
102  $prefix_length = strlen($conf['prefix_thumbnail']);
103 
104  $thumbnails = array();
105  if ($opendir = @opendir($dir.'/thumbnail'))
106  {
107    while ($file = readdir($opendir))
108    {
109      if (in_array(get_extension($file), $conf['picture_ext'])
110          and substr($file, 0, $prefix_length) == $conf['prefix_thumbnail'])
111      {
112        array_push($thumbnails, $file);
113      }
114    }
115  }
116  return $thumbnails;
117}
118
119/**
120 * returns an array with representative picture files of a directory
121 * according to $conf['picture_ext']
122 *
123 * @param string $dir
124 * @return array
125 */
126function get_representative_files($dir)
127{
128  global $conf;
129
130  $pictures = array();
131  if ($opendir = @opendir($dir.'/pwg_representative'))
132  {
133    while ($file = readdir($opendir))
134    {
135      if (in_array(get_extension($file), $conf['picture_ext']))
136      {
137        array_push($pictures, $file);
138      }
139    }
140  }
141  return $pictures;
142}
143
144function TN_exists( $dir, $file )
145{
146  global $conf;
147
148  $filename = get_filename_wo_extension( $file );
149  foreach ( $conf['picture_ext'] as $ext ) {
150    $test = $dir.'/thumbnail/'.$conf['prefix_thumbnail'].$filename.'.'.$ext;
151    if ( is_file ( $test ) )
152    {
153      return $ext;
154    }
155  }
156  return false;
157}
158       
159
160// The function delete_site deletes a site and call the function
161// delete_categories for each primary category of the site
162function delete_site( $id )
163{
164  // destruction of the categories of the site
165  $query = '
166SELECT id
167  FROM '.CATEGORIES_TABLE.'
168  WHERE site_id = '.$id.'
169;';
170  $result = pwg_query($query);
171  $category_ids = array();
172  while ($row = mysql_fetch_array($result))
173  {
174    array_push($category_ids, $row['id']);
175  }
176  delete_categories($category_ids);
177               
178  // destruction of the site
179  $query = '
180DELETE FROM '.SITES_TABLE.'
181  WHERE id = '.$id.'
182;';
183  pwg_query($query);
184}
185       
186
187// The function delete_categories deletes the categories identified by the
188// (numeric) key of the array $ids. It also deletes (in the database) :
189//    - all the elements of the category (delete_elements, see further)
190//    - all the links between elements and this category
191//    - all the restrictions linked to the category
192// The function works recursively.
193function delete_categories($ids)
194{
195  global $counts;
196
197  if (count($ids) == 0)
198  {
199    return;
200  }
201 
202  // destruction of all the related elements
203  $query = '
204SELECT id
205  FROM '.IMAGES_TABLE.'
206  WHERE storage_category_id IN ('.implode(',', $ids).')
207;';
208  $result = pwg_query($query);
209  $element_ids = array();
210  while ($row = mysql_fetch_array($result))
211  {
212    array_push($element_ids, $row['id']);
213  }
214  delete_elements($element_ids);
215
216  // destruction of the links between images and this category
217  $query = '
218DELETE FROM '.IMAGE_CATEGORY_TABLE.'
219  WHERE category_id IN ('.implode(',', $ids).')
220;';
221  pwg_query($query);
222
223  // destruction of the access linked to the category
224  $query = '
225DELETE FROM '.USER_ACCESS_TABLE.'
226  WHERE cat_id IN ('.implode(',', $ids).')
227;';
228  pwg_query($query);
229  $query = '
230DELETE FROM '.GROUP_ACCESS_TABLE.'
231  WHERE cat_id IN ('.implode(',', $ids).')
232;';
233  pwg_query($query);
234
235  // destruction of the sub-categories
236  $query = '
237SELECT id
238  FROM '.CATEGORIES_TABLE.'
239  WHERE id_uppercat IN ('.implode(',', $ids).')
240;';
241  $result = pwg_query($query);
242  $subcat_ids = array();
243  while($row = mysql_fetch_array($result))
244  {
245    array_push($subcat_ids, $row['id']);
246  }
247  if (count($subcat_ids) > 0)
248  {
249    delete_categories($subcat_ids);
250  }
251
252  // destruction of the category
253  $query = '
254DELETE FROM '.CATEGORIES_TABLE.'
255  WHERE id IN ('.implode(',', $ids).')
256;';
257  pwg_query($query);
258
259  if (isset($counts['del_categories']))
260  {
261    $counts['del_categories']+= count($ids);
262  }
263}
264
265// The function delete_elements deletes the elements identified by the
266// (numeric) values of the array $ids. It also deletes (in the database) :
267//    - all the comments related to elements
268//    - all the links between categories and elements
269//    - all the favorites associated to elements
270function delete_elements($ids)
271{
272  global $counts;
273
274  if (count($ids) == 0)
275  {
276    return;
277  }
278 
279  // destruction of the comments on the image
280  $query = '
281DELETE FROM '.COMMENTS_TABLE.'
282  WHERE image_id IN (
283'.wordwrap(implode(', ', $ids), 80, "\n").')
284;';
285  pwg_query($query);
286
287  // destruction of the links between images and this category
288  $query = '
289DELETE FROM '.IMAGE_CATEGORY_TABLE.'
290  WHERE image_id IN (
291'.wordwrap(implode(', ', $ids), 80, "\n").')
292;';
293  pwg_query($query);
294
295  // destruction of the favorites associated with the picture
296  $query = '
297DELETE FROM '.FAVORITES_TABLE.'
298  WHERE image_id IN (
299'.wordwrap(implode(', ', $ids), 80, "\n").')
300;';
301  pwg_query($query);
302
303  // destruction of the rates associated to this element
304  $query = '
305DELETE FROM '.RATE_TABLE.'
306  WHERE element_id IN (
307'.wordwrap(implode(', ', $ids), 80, "\n").')
308;';
309  pwg_query($query);
310               
311  // destruction of the image
312  $query = '
313DELETE FROM '.IMAGES_TABLE.'
314  WHERE id IN (
315'.wordwrap(implode(', ', $ids), 80, "\n").')
316;';
317  pwg_query($query);
318
319  if (isset($counts['del_elements']))
320  {
321    $counts['del_elements']+= count($ids);
322  }
323}
324
325// The delete_user function delete a user identified by the $user_id
326// It also deletes :
327//     - all the access linked to this user
328//     - all the links to any group
329//     - all the favorites linked to this user
330//     - all sessions linked to this user
331//     - all categories informations linked to this user
332function delete_user( $user_id )
333{
334  // destruction of the access linked to the user
335  $query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
336  $query.= ' WHERE user_id = '.$user_id;
337  $query.= ';';
338  pwg_query( $query );
339
340  // destruction of the group links for this user
341  $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
342  $query.= ' WHERE user_id = '.$user_id;
343  $query.= ';';
344  pwg_query( $query );
345
346  // destruction of the favorites associated with the user
347  $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
348  $query.= ' WHERE user_id = '.$user_id;
349  $query.= ';';
350  pwg_query( $query );
351
352  // destruction of the sessions linked with the user
353  $query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
354  $query.= ' WHERE user_id = '.$user_id;
355  $query.= ';';
356  pwg_query( $query );
357
358  // destruction of the user
359  $query = 'DELETE FROM '.USERS_TABLE;
360  $query.= ' WHERE id = '.$user_id;
361  $query.= ';';
362  pwg_query( $query );
363}
364
365// delete_group deletes a group identified by its $group_id.
366// It also deletes :
367//     - all the access linked to this group
368//     - all the links between this group and any user
369function delete_group( $group_id )
370{
371  // destruction of the access linked to the group
372  $query = 'DELETE FROM '.PREFIX_TABLE.'group_access';
373  $query.= ' WHERE group_id = '.$group_id;
374  $query.= ';';
375  pwg_query( $query );
376
377  // synchronize all users linked to the group
378  synchronize_group( $group_id );
379
380  // destruction of the users links for this group
381  $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
382  $query.= ' WHERE group_id = '.$group_id;
383  $query.= ';';
384  pwg_query( $query );
385
386  // destruction of the group
387  $query = 'DELETE FROM '.PREFIX_TABLE.'groups';
388  $query.= ' WHERE id = '.$group_id;
389  $query.= ';';
390  pwg_query( $query );
391}
392
393// The check_favorites function deletes all the favorites of a user if he is
394// not allowed to see them (the category or an upper category is restricted
395// or invisible)
396function check_favorites( $user_id )
397{
398  $query = 'SELECT status,forbidden_categories';
399  $query.= ' FROM '.USERS_TABLE;
400  $query.= ' WHERE id = '.$user_id;
401  $query.= ';';
402  $row = mysql_fetch_array( pwg_query( $query ) );
403  $status = $row['status'];
404  // retrieving all the restricted categories for this user
405  if ( isset( $row['forbidden_categories'] ) )
406    $restricted_cat = explode( ',', $row['forbidden_categories'] );
407  else
408    $restricted_cat = array();
409  // retrieving all the favorites for this user and comparing their
410  // categories to the restricted categories
411  $query = 'SELECT image_id';
412  $query.= ' FROM '.PREFIX_TABLE.'favorites';
413  $query.= ' WHERE user_id = '.$user_id;
414  $query.= ';';
415  $result = pwg_query ( $query );
416  while ( $row = mysql_fetch_array( $result ) )
417  {
418    // for each picture, we have to check all the categories it belongs
419    // to. Indeed if a picture belongs to category_1 and category_2 and that
420    // category_2 is not restricted to the user, he can have the picture as
421    // favorite.
422    $query = 'SELECT DISTINCT(category_id) as category_id';
423    $query.= ' FROM '.PREFIX_TABLE.'image_category';
424    $query.= ' WHERE image_id = '.$row['image_id'];
425    $query.= ';';
426    $picture_result = pwg_query( $query );
427    $picture_cat = array();
428    while ( $picture_row = mysql_fetch_array( $picture_result ) )
429    {
430      array_push( $picture_cat, $picture_row['category_id'] );
431    }
432    if ( count( array_diff( $picture_cat, $restricted_cat ) ) == 0 )
433    {
434      $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
435      $query.= ' WHERE image_id = '.$row['image_id'];
436      $query.= ' AND user_id = '.$user_id;
437      $query.= ';';
438      pwg_query( $query );
439    }
440  }
441}
442
443/**
444 * updates calculated informations about a category : date_last and
445 * nb_images. It also verifies that the representative picture is really
446 * linked to the category. Recursive.
447 *
448 * @param mixed category id
449 * @returns void
450 */
451function update_category($id = 'all')
452{
453  $cat_ids = array();
454 
455  $query = '
456SELECT category_id, COUNT(image_id) AS count, max(date_available) AS date_last
457  FROM '.IMAGES_TABLE.'
458    INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id';
459  if (is_numeric($id))
460  {
461    $query.= '
462  WHERE uppercats REGEXP \'(^|,)'.$id.'(,|$)\'';
463  }
464  $query.= '
465  GROUP BY category_id
466;';
467  $result = pwg_query( $query );
468  while ( $row = mysql_fetch_array( $result ) )
469  {
470    array_push($cat_ids, $row['category_id']);
471    $query = '
472UPDATE '.CATEGORIES_TABLE.'
473  SET date_last = \''.$row['date_last'].'\'
474    , nb_images = '.$row['count'].'
475  WHERE id = '.$row['category_id'].'
476;';
477    pwg_query($query);
478  }
479
480  if (count($cat_ids) > 0)
481  {
482    $query = '
483SELECT id, representative_picture_id
484  FROM '.CATEGORIES_TABLE.'
485  WHERE representative_picture_id IS NOT NULL
486    AND id IN ('.implode(',', $cat_ids).')
487;';
488    $result = pwg_query( $query );
489    while ( $row = mysql_fetch_array( $result ) )
490    {
491      $query = '
492SELECT image_id
493  FROM '.IMAGE_CATEGORY_TABLE.'
494  WHERE category_id = '.$row['id'].'
495    AND image_id = '.$row['representative_picture_id'].'
496;';
497      $result = pwg_query( $query );
498      if (mysql_num_rows($result) == 0)
499      {
500        $query = '
501UPDATE '.CATEGORIES_TABLE.'
502  SET representative_picture_id = NULL
503  WHERE id = '.$row['id'].'
504;';
505        pwg_query( $query );
506      }
507    }
508  }
509}
510
511function check_date_format( $date )
512{
513  // date arrives at this format : DD/MM/YYYY
514  @list($day,$month,$year) = explode( '/', $date );
515  return @checkdate( $month, $day, $year );
516}
517
518function date_convert( $date )
519{
520  // date arrives at this format : DD/MM/YYYY
521  // It must be transformed in YYYY-MM-DD
522  list($day,$month,$year) = explode( '/', $date );
523  return $year.'-'.$month.'-'.$day;
524}
525
526function date_convert_back( $date )
527{
528  // date arrives at this format : YYYY-MM-DD
529  // It must be transformed in DD/MM/YYYY
530  if ( $date != '' )
531  {
532    list($year,$month,$day) = explode( '-', $date );
533    return $day.'/'.$month.'/'.$year;
534  }
535  else
536  {
537    return '';
538  }
539}
540
541// get_keywords returns an array with relevant keywords found in the string
542// given in argument. Keywords must be separated by comma in this string.
543// keywords must :
544//   - be longer or equal to 3 characters
545//   - not contain ', " or blank characters
546//   - unique in the string ("test,test" -> "test")
547function get_keywords( $keywords_string )
548{
549  $keywords = array();
550
551  $candidates = explode( ',', $keywords_string );
552  foreach ( $candidates as $candidate ) {
553    if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
554      array_push( $keywords, $candidate );
555  }
556
557  return array_unique( $keywords );
558}
559
560function display_categories( $categories, $indent,
561                             $selected = -1, $forbidden = -1 )
562{
563  global $vtp,$sub;
564
565  foreach ( $categories as $category ) {
566    if ( $category['id'] != $forbidden )
567    {
568      $vtp->addSession( $sub, 'associate_cat' );
569      $vtp->setVar( $sub, 'associate_cat.value',   $category['id'] );
570      $content = $indent.'- '.$category['name'];
571      $vtp->setVar( $sub, 'associate_cat.content', $content );
572      if ( $category['id'] == $selected )
573        $vtp->setVar( $sub, 'associate_cat.selected', ' selected="selected"' );
574      $vtp->closeSession( $sub, 'associate_cat' );
575      display_categories( $category['subcats'], $indent.str_repeat('&nbsp;',3),
576                          $selected, $forbidden );
577    }
578  }
579}
580
581/**
582 * returns an array with the ids of the restricted categories for the user
583 *
584 * Returns an array with the ids of the restricted categories for the
585 * user. If the $check_invisible parameter is set to true, invisible
586 * categorie are added to the restricted one in the array.
587 *
588 * @param int $user_id
589 * @param string $user_status
590 * @param bool $check_invisible
591 * @param bool $use_groups
592 * @return array
593 */
594function get_user_restrictions( $user_id, $user_status,
595                                $check_invisible, $use_groups = true )
596{
597  // 1. retrieving ids of private categories
598  $query = 'SELECT id FROM '.CATEGORIES_TABLE;
599  $query.= " WHERE status = 'private'";
600  $query.= ';';
601  $result = pwg_query( $query );
602  $privates = array();
603  while ( $row = mysql_fetch_array( $result ) )
604  {
605    array_push( $privates, $row['id'] );
606  }
607  // 2. retrieving all authorized categories for the user
608  $authorized = array();
609  // 2.1. retrieving authorized categories thanks to personnal user
610  //      authorization
611  $query = 'SELECT cat_id FROM '.USER_ACCESS_TABLE;
612  $query.= ' WHERE user_id = '.$user_id;
613  $query.= ';';
614  $result = pwg_query( $query );
615  while ( $row = mysql_fetch_array( $result ) )
616  {
617    array_push( $authorized, $row['cat_id'] );
618  }
619  // 2.2. retrieving authorized categories thanks to group authorization to
620  //      which the user is a member
621  if ( $use_groups )
622  {
623    $query = 'SELECT ga.cat_id';
624    $query.= ' FROM '.USER_GROUP_TABLE.' as ug';
625    $query.= ', '.GROUP_ACCESS_TABLE.' as ga';
626    $query.= ' WHERE ug.group_id = ga.group_id';
627    $query.= ' AND ug.user_id = '.$user_id;
628    $query.= ';';
629    $result = pwg_query( $query );
630    while ( $row = mysql_fetch_array( $result ) )
631    {
632      array_push( $authorized, $row['cat_id'] );
633    }
634    $authorized = array_unique( $authorized );
635  }
636
637  $forbidden = array();
638  foreach ( $privates as $private ) {
639    if ( !in_array( $private, $authorized ) )
640    {
641      array_push( $forbidden, $private );
642    }
643  }
644
645  if ( $check_invisible )
646  {
647    // 3. adding to the restricted categories, the invisible ones
648    if ( $user_status != 'admin' )
649    {
650      $query = 'SELECT id FROM '.CATEGORIES_TABLE;
651      $query.= " WHERE visible = 'false';";
652      $result = pwg_query( $query );
653      while ( $row = mysql_fetch_array( $result ) )
654      {
655        array_push( $forbidden, $row['id'] );
656      }
657    }
658  }
659  return array_unique( $forbidden );
660}
661
662/**
663 * updates the calculated data users.forbidden_categories, it includes
664 * sub-categories of the direct forbidden categories
665 *
666 * @param nt $user_id
667 * @return array
668 */
669function update_user_restrictions( $user_id )
670{
671  $restrictions = get_user_all_restrictions( $user_id );
672
673  // update the users.forbidden_categories in database
674  $query = 'UPDATE '.USERS_TABLE;
675  $query.= ' SET forbidden_categories = ';
676  if ( count( $restrictions ) > 0 )
677    $query.= "'".implode( ',', $restrictions )."'";
678  else
679    $query.= 'NULL';
680  $query .= ' WHERE id = '.$user_id;
681  $query.= ';';
682  pwg_query( $query );
683
684  return $restrictions;
685}
686
687/**
688 * returns all the restricted categories ids including sub-categories
689 *
690 * @param int $user_id
691 * @return array
692 */
693function get_user_all_restrictions( $user_id )
694{
695  global $page;
696 
697  $query = 'SELECT status';
698  $query.= ' FROM '.USERS_TABLE;
699  $query.= ' WHERE id = '.$user_id;
700  $query.= ';';
701  $row = mysql_fetch_array( pwg_query( $query ) );
702 
703  $base_restrictions=get_user_restrictions($user_id,$row['status'],true,true);
704
705  $restrictions = $base_restrictions;
706  foreach ( $base_restrictions as $category_id ) {
707    echo $category_id.' is forbidden to user '.$user_id.'<br />';
708    $restrictions =
709      array_merge( $restrictions,
710                   $page['plain_structure'][$category_id]['all_subcats_ids'] );
711  }
712
713  return array_unique( $restrictions );
714}
715
716// The function is_user_allowed returns :
717//      - 0 : if the category is allowed with this $restrictions array
718//      - 1 : if this category is not allowed
719//      - 2 : if an uppercat category is not allowed
720// Note : the restrictions array must represent ONLY direct forbidden
721// categories, not all forbidden categories
722function is_user_allowed( $category_id, $restrictions )
723{
724  if ( in_array( $category_id, $restrictions ) ) return 1;
725
726  $query = 'SELECT uppercats';
727  $query.= ' FROM '.CATEGORIES_TABLE;
728  $query.= ' WHERE id = '.$category_id;
729  $query.= ';';
730  $row = mysql_fetch_array( pwg_query( $query ) );
731  $uppercats = explode( ',', $row['uppercats'] );
732  foreach ( $uppercats as $category_id ) {
733    if ( in_array( $category_id, $restrictions ) ) return 2;
734  }
735
736  // no restriction found : the user is allowed to access this category
737  return 0;
738}
739
740/**
741 * returns an array containing sub-directories which can be a category
742 *
743 * directories nammed "thumbnail", "pwg_high" or "pwg_representative" are
744 * omitted
745 *
746 * @param string $basedir
747 * @return array
748 */
749function get_category_directories( $basedir )
750{
751  $sub_dirs = array();
752
753  if ( $opendir = opendir( $basedir ) )
754  {
755    while ( $file = readdir( $opendir ) )
756    {
757      if ($file != '.'
758          and $file != '..'
759          and $file != 'thumbnail'
760          and $file != 'pwg_high'
761          and $file != 'pwg_representative'
762          and is_dir($basedir.'/'.$file))
763      {
764        array_push( $sub_dirs, $file );
765      }
766    }
767  }
768  return $sub_dirs;
769}
770
771// my_error returns (or send to standard output) the message concerning the
772// error occured for the last mysql query.
773function my_error($header, $echo = true)
774{
775  $error = $header.'<span style="font-weight:bold;">N°= '.mysql_errno();
776  $error.= ' -->> '.mysql_error()."</span><br /><br />\n";
777  if ($echo)
778  {
779    echo $error;
780  }
781  else
782  {
783    return $error;
784  }
785}
786?>
Note: See TracBrowser for help on using the repository browser.