Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/sys_import.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

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, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

echo '<div class="detail supergroup">';

echo '<h2>';
myecho('Import data');
echo '</h2>';

if($_FILES['odb_file']['size']>0)
{
  $filename=$_FILES['odb_file']['name'];
  $file_path=cfg_data_path.'/temp/files/'.date('Y-m-d-H-i-s').'-'.rand(1000,9999).'-'.$filename;
  addpath(cfg_data_path.'/temp/files');
  if(move_uploaded_file($_FILES['odb_file']['tmp_name'], $file_path))
  {
    $result=import_data($file_path,get('config'));

    if($result)
    {
      echo('<div class="supergroup" style="width:260px;">');
      myecho('File was successfully uploaded.');
    
      echo '<br /><br /><a href="index.php?odb_search=Import '.$result.'">';
      myecho('Show imported data');
      echo '</a>';
      echo '</div>';
    }
    else
    {
      echo('<div class="supergroup" style="width:260px;">');
      myecho('Cannot import file');
      echo '</div>';
    }
  }
}
else
{
  echo '<form enctype="multipart/form-data" action="index.php" method="POST">';
    echo('<div class="supergroup" style="width:260px;"><input name="odb_sys" type="hidden" value="import"></input>');
    echo('<input type="hidden" name="MAX_FILE_SIZE" value="25000000" />');
    myecho('Choose the file');
    echo '<br /><input name="odb_file" type="file"></input>';
    echo '<br /><select name="odb_config">';
    addpath(cfg_data_path.'/config/structure/');
    $res=opendir(cfg_data_path.'/config/structure/');
    while($fl = readdir($res))
      if(substr($fl,0,4)=='grp_')
      {
        echo '<option>'.substr($fl,4,-4).'</option>';
      }
    closedir($res);
    echo '</select>';
    echo('<p class="bbutton"><input name="odb_import" type="submit" value="Upload"></input></p></div>');
  echo '</form>';
}
echo '</div>';

echo('<div class="clearer"></div>');

?>
Return current item: OpenBizMap