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