|
1 <?php |
|
2 // +--------------------------------------------------------------------+ |
|
3 // | PowerAdmin | |
|
4 // +--------------------------------------------------------------------+ |
|
5 // | Copyright (c) 1997-2002 The PowerAdmin Team | |
|
6 // +--------------------------------------------------------------------+ |
|
7 // | This source file is subject to the license carried by the overal | |
|
8 // | program PowerAdmin as found on http://poweradmin.sf.net | |
|
9 // | The PowerAdmin program falls under the QPL License: | |
|
10 // | http://www.trolltech.com/developer/licensing/qpl.html | |
|
11 // +--------------------------------------------------------------------+ |
|
12 // | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl> | |
|
13 // | Sjeemz <sjeemz <AT> sjeemz <DOT> nl> | |
|
14 // +--------------------------------------------------------------------+ |
|
15 // |
|
16 // File: seq_update.php |
|
17 // Description: synches your database after manual insertions. |
|
18 // Doesnt do much, just searches the highest record_id and updates the seq table with this |
|
19 |
|
20 require_once("inc/toolkit.inc.php"); |
|
21 require_once("inc/header.inc.php"); |
|
22 |
|
23 // Ok we have to synch it all. |
|
24 // What to do? Find the MAX(id) on each table and set it to the _seq table. |
|
25 |
|
26 echo "<P><B>Synching databases. This is useful if you did manual insertions (in case you havent been here yet)</B></P>"; |
|
27 |
|
28 if(!level(10)) |
|
29 { |
|
30 error(ERR_LEVEL_10); |
|
31 } |
|
32 |
|
33 function seq_update(&$item) |
|
34 { |
|
35 global $db; |
|
36 $number_u = $db->getOne("SELECT MAX(id) FROM $item"); |
|
37 if($number_u > 1) |
|
38 { |
|
39 echo $number_u; |
|
40 $number_u_seq = $db->getOne("SELECT id FROM " . $item . "_seq"); |
|
41 if($number_u_seq < $number_u) |
|
42 { |
|
43 $number_u += 1; |
|
44 $db->query("UPDATE " . $item . "_seq SET id='$number_u'"); |
|
45 } |
|
46 } |
|
47 } |
|
48 |
|
49 $tables = array('users', 'zones', 'records', 'domains'); |
|
50 |
|
51 array_walk($tables, 'seq_update'); |
|
52 |
|
53 message("All tables are successfully synchronized."); |
|
54 |
|
55 php?> |