<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-type: text/x-json");
ini_set('memory_limit', '-1');
include($_SERVER['DOCUMENT_ROOT'] .'/script/HeaderInc.php');
if('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH'] && 
    ((true === isset($_SESSION['SessionAuth']['SvtAdmin']['reg']) && 1 == $_SESSION['SessionAuth']['SvtAdmin']['reg']))
   ){
  $ObjDbMod = new DbMod($MS_SP, 'dbconfig');
  $ArrSqlConfigIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbconfig']['database'] .'.svtconfig_menu', 'index' => 'menuname_id');
  $ArrSqlConfigIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbconfig']['database'] .'.svtconfig_menu', 'index' => 'template_id');
  $ArrSqlConfigIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbconfig']['database'] .'.svtconfig_menu', 'index' => 'lang_id');
  $ArrSqlConfigIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbconfig']['database'] .'.svtconfig_menuname', 'index' => 'template_id');
  $VarResult = $ObjDbMod->ReIndex($ArrSqlConfigIndex);
  
  $ObjDbMod = new DbMod($MS_SP, 'dbuser');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_cartridge', 'index' => 'svt_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_cartridge', 'index' => 'organiz_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_cartridge', 'index' => 'cartridgetype_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_demands', 'index' => 'svt_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_demands', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_demands', 'index' => 'demands_masterid');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_demands', 'index' => 'sprstatus_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_demands', 'index' => 'demandsclassif_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_demandscomments', 'index' => 'demands_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_demandscomments', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_pass', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_policence', 'index' => 'po_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_policence', 'index' => 'organiz_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_purchase', 'index' => 'structureorganization_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_purchase', 'index' => 'purchasestatus_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_repair', 'index' => 'demands_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_repair', 'index' => 'organiz_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_repair', 'index' => 'repairstatus_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_repair', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svt', 'index' => 'structureorganization_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svt', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svt', 'index' => 'svttype_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svt', 'index' => 'organiz_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_ip', 'index' => 'svt_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtgiveout', 'index' => 'demands_masterid');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtgiveout', 'index' => 'svt_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtgiveout', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtgiveout', 'index' => 'svtgiveoutstatus_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtpo', 'index' => 'svt_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtpo', 'index' => 'po_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtstatusval', 'index' => 'svt_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_svtstatusval', 'index' => 'svtstatus_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_users', 'index' => 'structureorganization_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_usersprefvalue', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_usersprefvalue', 'index' => 'userspref_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_usersservices', 'index' => 'users_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_usersservices', 'index' => 'webservices_id');
  $ArrSqlUserIndex[] = array('table' => $ObjDbMod->SP_DbDsnInfo['dbuser']['database'] .'.svtuser_userssettingsvalue', 'index' => 'users_id');
  
  $VarResult = $ObjDbMod->ReIndex($ArrSqlUserIndex);

  $ArrReturn = array('message' => $MS_SP->Sp_LangMessage['message']['MessCreateIndexSuccess']);
}
else{
  $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrFuncAccessDenied']);
}
echo json_encode($ArrReturn);
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');  
?>