phpDocumentor VFront
Administration
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file export_sql.php

Documentation is available at export_sql.php

  1. <?php
  2. /**
  3.  * @desc Utility per l'esportazione dell'SQL (DUMP)
  4.  * @package VFront
  5.  * @subpackage Administration
  6.  * @author M.Marcello Verona
  7.  * @copyright 2007 M.Marcello Verona
  8.  * @version 0.90
  9.  * @license http://www.gnu.org/licenses/gpl.html GNU Public License
  10.  */
  11.  
  12.  
  13. include("../inc/conn.php");
  14. include("../inc/layouts.php");
  15. include("../inc/func.comuni.php");
  16.  
  17.  proteggi(3);
  18.  
  19.  
  20.  
  21.     ########################################################################
  22.     #
  23.     #
  24.     #    ESPORTAZIONE REGISTRI
  25.     
  26.     $IS_UNIX (eregi('WIN',$_ENV['OS'])) 0:1;
  27.     
  28.     if(isset($_POST['exp_dati'])){
  29.  
  30.             
  31.         if($IS_UNIX){
  32.             $zippa="| gzip -c ";
  33.             $estensione_zip=".gz";
  34.         }
  35.         else {
  36.             $zippa ="";
  37.             $estensione_zip="";
  38.         }
  39.         
  40.         
  41.         // tipo di dati richiesti
  42.         
  43.         if($_GET['exp']=='registri'){
  44.             $DB $db1['frontend'];
  45.         }
  46.         else{
  47.             $DB $db1['dbname'];
  48.         }
  49.             
  50.         // opzioni dati/schema
  51.         
  52.         if($_POST['schema_only']=='1'){
  53.             $opzioni "--no-data ";
  54.         }
  55.  
  56.         else{
  57.             $opzioni "";
  58.         }
  59.         
  60.             $nome_file FRONT_REALPATH."/html/$DB.sql{$estensione_zip}";    
  61.         
  62.             if($db1['dbtype']=='mysql'){
  63.             
  64.                 $bat=     _PATH_MYSQLDUMP.
  65.                         " --add-drop-table --force ".
  66.                         "-u{$db1['user']} ".
  67.                            "-p{$db1['passw']} ".
  68.                            "-P {$db1['port']} ".
  69.                            "-h {$db1['host']} ".
  70.                            "$opzioni ".
  71.                            "{$DB} ".
  72.                            "$zippa ".
  73.                            ">$nome_file";
  74.             }
  75.             elseif ($db1['dbtype']=='postgres'){
  76.                 
  77.                 /*$bat=     _PATH_PG_DUMP.
  78.                         " -n $DB".
  79.                         "-U{$db1['user']} ".
  80.                            "-p{$db1['passw']} ".
  81.                            "-p {$db1['port']} ".
  82.                            "-h {$db1['host']} ".
  83.                            "$opzioni ".
  84.                            "{$db1['postgres_dbname']} ".
  85.                            "$zippa ".
  86.                            ">$nome_file";*/
  87.                 
  88.                 die("DUMP su Postgres non ancora supportato!");
  89.             }
  90.                        
  91.             $exec passthru($bat);
  92.                        
  93. //            var_dump($exec);
  94.  
  95.             
  96.  
  97.             if(is_file($nome_file)){
  98.                header('Pragma: anytextexeptno-cache'true);
  99.                header('Content-type: application/x-gzip');
  100.                header('Content-Transfer-Encoding: Binary');
  101.                header('Content-length: '.filesize($nome_file));
  102.                header('Content-disposition: attachment; filename='.basename($nome_file));
  103.                readfile($nome_file);
  104.             }
  105.             
  106.         unlink($nome_file);
  107.             
  108.         exit;
  109.     }
  110.     
  111.     
  112.     #
  113.     #
  114.     ########################################################################
  115.     
  116.  
  117.  
  118.  echo openLayout1("Esportazione Database"array("sty/admin.css"));
  119.  
  120.  
  121.  echo "<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> &raquo; amministrazione database</div>\n";
  122.  
  123.  echo "<h1>Esportazione Database</h1>
  124.  
  125.      <img src=\"../img/db_export.gif\" class=\"img-float\" alt=\"impostazioni registri\" />
  126.  
  127.      <div class=\"box-db\">
  128.         <h2>Esportazione Database dati (<span class=\"var\">{$db1['dbname']}</span>)</h2>
  129.         <form action=\"".$_SERVER['PHP_SELF']."?exp=dati\" method=\"post\">
  130.         
  131.             <br />
  132.         
  133.             <input type=\"radio\" name=\"schema_only\" id=\"schemaonly_1\" value=\"1\" checked=\"checked\"/><label for=\"schemaonly_1\">Solo schema</label><br />
  134.             <input type=\"radio\" name=\"schema_only\" id=\"schemaonly_2\" value=\"2\" /><label for=\"schemaonly_2\">Dati e schema</label><br />
  135.         
  136.             <br />
  137.             
  138.             <input type=\"submit\" name=\"exp_dati\" value=\"Esporta\" />
  139.             
  140.         </form>
  141.         
  142.     </div>    
  143.     
  144.  
  145.      <div class=\"box-db\">
  146.         <h2>Esportazione Database Registri (<span class=\"var\">{$db1['frontend']}</span>)</h2>
  147.             
  148.         <form action=\"".$_SERVER['PHP_SELF']."?exp=registri\" method=\"post\">
  149.         
  150.             <br />
  151.         
  152.             <input type=\"radio\" name=\"schema_only\" id=\"schema_reg_only_1\" value=\"1\" checked=\"checked\"/><label for=\"schema_reg_only_1\">Solo schema</label><br />
  153.             <input type=\"radio\" name=\"schema_only\" id=\"schema_reg_only_2\" value=\"2\" /><label for=\"schema_reg_only_2\">Dati e schema</label><br />
  154.         
  155.             <br />
  156.             
  157.             <input type=\"submit\" name=\"exp_dati\" value=\"Esporta\" />
  158.             
  159.         </form>
  160.     </div>    \n";
  161.  
  162.  
  163.  echo closeLayout1();
  164.  
  165. ?>

Documentation generated on Sat, 22 Sep 2007 11:50:02 +0200 by phpDocumentor 1.4.0a2