<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}
if ($acces == 1) {
if($admintest && $adminsecu)  {

$newposdown = $GLOBALS['db']->XMFnum($newposdown);
$pos        = $GLOBALS['db']->XMFnum($pos);
$pid        = $GLOBALS['db']->XMFnum($pid);

  if ($newposup == 0) { return; }
  $result = $GLOBALS['db']->sql_query("SELECT `id` FROM `".TABLE_PLAN."` WHERE `pos`='$newposup' ");
  $row = $GLOBALS['db']->sql_fetchrow($result);
  $id2 = $GLOBALS['db']->XMFnum($row['id']);
  $GLOBALS['db']->sql_query("UPDATE `".TABLE_PLAN."` SET `pos`='$pos' WHERE `id`='$id2' ");
  $GLOBALS['db']->sql_query("UPDATE `".TABLE_PLAN."` SET `pos`='$newposup' WHERE `id`='$pid' ");
  $GLOBALS['db']->sql_query("OPTIMIZE TABLE `".TABLE_PLAN."` ");
  redirect_url("".$admin_file.".php?op=Plan");

}
}else {
	echo "Access Denied";
}