<?php

require_once XOOPS_TRUST_PATH.'/modules/xdbmigrate/status.php';
require_once XOOPS_TRUST_PATH.'/modules/xdbmigrate/cmd/inc/cmdlib.inc.php';
function get_status() {
  $db = &Database::getInstance();
  $tbl = XOOPS_DB_PREFIX."_xdbmigrate_status";
  $sql = "select * from {$tbl}";
  $ret = $db->queryF($sql);
  if($ret === false)return false;
  return $db->fetchArray($ret);
}

$ret = get_status();
if($ret === FALSE){
  echo "db connect error or xdbmigrate_status table not exist.";
  exit();
}

$lang="english";
if(stristr($_SERVER['HTTP_ACCEPT_CHARSET'], 'utf-8') !== FALSE){
  $lang="ja_utf8";
}
require_once XOOPS_TRUST_PATH.'/modules/xdbmigrate/language/'.$lang.'/admin.php';

$message_array = 
array(
  //Duplicate
  0=>array(
      XDBMIGRATE_START_DUPLICATE => _AM_XDBMIGRATE_START_DUPLICATE,
      XDBMIGRATE_UNIST_INST_XOONIPS => _AM_XDBMIGRATE_UNIST_INST_XOONIPS,
  ),
  //Migrate
  1=>array(
      XDBMIGRATE_START_DUPLICATE => _AM_XDBMIGRATE_START_MIGRATE,
      XDBMIGRATE_MIGRATE_GROUP => _AM_XDBMIGRATE_MIGRATE_GROUP,
      XDBMIGRATE_MIGRATE_ITEM => _AM_XDBMIGRATE_MIGRATE_ITEM,
      XDBMIGRATE_MIGRATE_SEARCH_TEXT => _AM_XDBMIGRATE_MIGRATE_SEARCH_TEXT,
      XDBMIGRATE_MIGRATE_INDEX => _AM_XDBMIGRATE_MIGRATE_INDEX,
      XDBMIGRATE_MIGRATE_OAI_PMH =>_AM_XDBMIGRATE_MIGRATE_OAI_PMH,
      XDBMIGRATE_START_COMPLITE =>_AM_XDBMIGRATE_START_COMPLITE,
      XDBMIGRATE_MIGRATE_EVENT_LOG=>_AM_XDBMIGRATE_MIGRATE_EVENT_LOG
  )
);

if($ret['status'] > 1000){
  echo '<font color="red">';
  echo constant('_AM_XDBMIGRATE_E'.(string)$ret['status']);
  echo "(E{$ret['status']})";
  echo '</font>';
}else{
  echo $message_array[$ret['app_id']][$ret['status']];
}
