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

Source for file sync_reg_tab.postgres.php

Documentation is available at sync_reg_tab.postgres.php

  1. <?php
  2. /**
  3.  * Sono presenti in questo file le procedure per inizializzare, inserire e eliminare le informazioni
  4.  * sulle tabelle nel registro di VFront per tenerlo allineato con l'information_schema del database.
  5.  * Questo file è la versione per Postgres
  6.  * 
  7.  * @desc Procedure di manutenzione del registro per Postgres
  8.  * @package VFront
  9.  * @subpackage Administration
  10.  * @author M.Marcello Verona
  11.  * @copyright 2007 M.Marcello Verona
  12.  * @version 0.90
  13.  * @license http://www.gnu.org/licenses/gpl.html GNU Public License
  14.  * @see sync_reg_tab.mysql.php
  15.  */
  16.  
  17.  
  18. require_once("../inc/conn.php");
  19. require_once("../inc/layouts.php");
  20. require_once("../inc/func.comuni.php");
  21. require_once("../inc/func.frontend.php");
  22.  
  23.  proteggi(3);
  24.  
  25. ##############################################
  26. #
  27. #    PROCEDURA AGGIORNAMENTO DEI CAMPI DELLE TABELLE
  28. #
  29. #
  30.  
  31. if(isset($_POST['aggiorna'])){
  32.  
  33.     
  34.     $ar_campi=$_POST['campo_aggiorna'];
  35.     
  36.     
  37. //    print_r($ar_campi);
  38.     
  39.     require_once("./gestione_registro.inc.php");
  40.     
  41.     for($i=0;$i<count($ar_campi);$i++){
  42.         
  43.         list($tabella,$campo,$operazioneexplode(";",$ar_campi[$i]);
  44.         
  45.         $feed[aggiorna_campo($tabella,$campo,$operazione);
  46.         
  47.     }
  48.     
  49.     
  50.     header("Location: ".$_SERVER['PHP_SELF']."?diff=".$tabella);
  51.     exit;
  52.     
  53. }
  54.  
  55. ##############################################
  56. #
  57. #    PROCEDURA ELIMINAZIONE TABELLE OBSOLETE
  58. #
  59. #
  60.  
  61. if(isset($_POST['elimina_obsolete'])){
  62.     
  63.     $tabelle=explode(",",$_POST['obsolete']);
  64.     
  65.     if(is_array($tabelle)){
  66.     
  67.         // inizia la transazione
  68.         vmsql_begin($link);
  69.         
  70.         $ok_del=0;
  71.         $c=0;
  72.         
  73.         for($d=0;$d<count($tabelle);$d++){
  74.             
  75.             $sql_del="DELETE FROM {$db1['frontend']}.registro_tab WHERE table_name='".$tabelle[$d]."'";
  76.             
  77.             $q_del=vmsql_query($sql_del,$link,true);
  78.             
  79.             if(vmsql_affected_rows($link,$q_del)>0){
  80.                 $ok_del++;
  81.             }
  82.             
  83.             $c++;
  84.         }
  85.         
  86. //        echo $c."<br/>$ok_del";
  87.         
  88.         // FEEDBACK
  89.         if($ok_del==$c){
  90.             vmsql_commit($link);
  91.             header("Location: ".$_SERVER['PHP_SELF']."?feed=ok_del");    
  92.         }
  93.         else{
  94.             vmsql_rollback($link);
  95.             header("Location: ".$_SERVER['PHP_SELF']."?feed=ko_del");    
  96.         }
  97.             
  98.     
  99.     }
  100.     else{
  101.         
  102.         header("Location: ".$_SERVER['PHP_SELF']."?feed=ko_del");    
  103.     }
  104.     
  105.  
  106.     exit;
  107. }
  108.  
  109. #
  110. #    --fine tabelle obsolete
  111. #
  112. ################################################################################à
  113.  
  114.  
  115.  
  116. ##############################################
  117. #
  118. #    PROCEDURA INSERIMENTO TABELLE NUOVE
  119. #
  120. if(isset($_POST['sincronizza_nuove'])){
  121.  
  122.     
  123.     $tabelle=explode(",",$_POST['nuove']);
  124.     
  125.     if(is_array($tabelle)){
  126.         
  127.         require_once("./gestione_registro.inc.php");
  128.         
  129.         
  130.         // PRENDI GRUPPI
  131.         $qg=vmsql_query("SELECT gid FROM {$db1['frontend']}.gruppo",$link);
  132.         
  133.         list($gruppi)=vmsql_fetch_row_all($qg,true);
  134.         
  135.         
  136.         
  137.         
  138.         /*
  139.             Anche se ho a disposizione il nome delle tabelle le prendo di nuovo,
  140.             perchè mi servono anche i commenti
  141.         */
  142.         
  143.         // PRENDI nomi tabelle e commenti
  144.         $sql_info="SELECT t.table_name, t.table_type, obj_description(c.oid, 'pg_class'::name) AS table_comment 
  145.                             FROM information_schema.tables AS t,  pg_catalog.pg_class AS c, pg_namespace AS ns
  146.                             WHERE t.table_name IN ('".implode("','",$tabelle)."')
  147.                             AND t.table_schema='{$db1['dbname']}'
  148.                             AND ns.nspname = t.table_schema
  149.                             AND  t.table_name=c.relname ";
  150.         
  151.         $q_info=vmsql_query($sql_info,$link);
  152.         
  153.         vmsql_begin($link);
  154.         
  155.         // PER OGNI TABELLA...
  156.         while($info_tab=vmsql_fetch_assoc($q_info)){
  157.             
  158.             // PER OGNI GRUPPO
  159.             for($g=0;$g<count($gruppi);$g++){
  160.                 
  161.                 inserisci_registro($info_tab,$gruppi[$g]);
  162.             }
  163.             
  164.         }
  165.         
  166.         
  167.         
  168.         vmsql_commit($link);
  169.         
  170.         header("Location: ".$_SERVER['PHP_SELF']."?feed=ok_nuove");
  171.         
  172.     }
  173.     else{
  174.         
  175.         
  176.         header("Location: ".$_SERVER['PHP_SELF']."?feed=ko_nuove");
  177.     }
  178.     
  179.     
  180.     
  181.     
  182.     exit;
  183.     
  184. }
  185.     
  186.     
  187. #
  188. #    --fine nuove tabelle
  189. #
  190. ################################################################################à    
  191.     
  192.  
  193.  
  194.  
  195.  
  196. ##############################################
  197. #
  198. #    PROCEDURA RIPRISTIONO TABELLA
  199. #
  200. if(isset($_GET['azzera'])){
  201.  
  202.     $tabella=trim($_GET['azzera']);
  203.     
  204.     if(is_tabella($tabella)){
  205.     
  206.         
  207.         // ELIMINA LE IMPOSTAZIONI DI TABELLA NEL FRONTEND
  208.         $sql_del="DELETE FROM {$db1['frontend']}.registro_tab WHERE table_name='".$tabella."'";
  209.         
  210.         vmsql_begin($link);
  211.         
  212.         $q_del=vmsql_query($sql_del,$link,true);
  213.         
  214.         if(vmsql_affected_rows($link,$sql_del)>0){
  215.             
  216.             vmsql_commit($link);
  217.         }
  218.         else{
  219.             vmsql_rollback($link);
  220.             header("Location: ".$_SERVER['PHP_SELF']."?feed=ko_azzera1");
  221.             exit;
  222.         }
  223.         
  224.     
  225.         require_once("./gestione_registro.inc.php");
  226.         
  227.         
  228.         
  229.         // PRENDI GRUPPI
  230.         $qg=vmsql_query("SELECT gid FROM {$db1['frontend']}.gruppo",$link);
  231.         
  232.         list($gruppi)=vmsql_fetch_row_all($qg,true);
  233.         
  234.         /*
  235.             Anche se ho a disposizione il nome delle tabelle le prendo di nuovo,
  236.             perchè mi servono anche i commenti
  237.         */
  238.         
  239.         // PRENDI nomi tabelle e commenti
  240.         $sql_info="SELECT t.table_namet.table_typeobj_description(c.oid, 'pg_class'::nameAS table_comment 
  241.                             FROM information_schema.tables AS tpg_catalog.pg_class AS c
  242.                             WHERE t.table_name='$tabella'
  243.                             AND t.table_schema='{$db1['dbname']}
  244.                             AND  t.table_name=c.relname
  245.                             LIMIT 1";
  246.         
  247.         rpc_debug($sql_info);
  248.         
  249.         $q_info=vmsql_query($sql_info,$link);
  250.         
  251.         vmsql_begin($link);
  252.         
  253.         // PER OGNI TABELLA...
  254.         $info_tab=vmsql_fetch_assoc($q_info);
  255.             
  256.             // PER OGNI GRUPPO
  257.             for($g=0;$g<count($gruppi);$g++){
  258.                 
  259.                 inserisci_registro($info_tab,$gruppi[$g]);
  260.             }
  261.             
  262.         
  263.         
  264.         vmsql_commit($link);
  265.         
  266.         header("Location: ".$_SERVER['PHP_SELF']."?feed=ok_azzera");
  267.         
  268.     }
  269.     else{
  270.         
  271.         
  272.         header("Location: ".$_SERVER['PHP_SELF']."?feed=ko_azzera2");
  273.     }
  274.     
  275.     
  276.     
  277.     
  278.     exit;
  279.     
  280. }
  281.     
  282.     
  283. #
  284. #    --fine procedura ripristino tabella
  285. #
  286. ################################################################################
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293. ##############################################
  294. #
  295. #    PROCEDURA VISUALIZZAZIONE DIFFERENZE
  296. #
  297. if(isset($_GET['diff'])){
  298.  
  299.     $tabella=trim($_GET['diff']);
  300.     
  301.     if(is_tabella($tabella)){
  302.     
  303.         
  304.         $colonne1=array();
  305.         $colonne2=array();
  306.         
  307.     
  308.         // INFO COLONNE DALL' information_schema
  309.             $SQL_confronto_colonne1 "
  310.         SELECT column_name,udt_name as column_type,data_type,is_nullable
  311.         FROM information_schema.columns
  312.         WHERE table_name='$tabella'
  313.         AND table_schema='{$db1['dbname']}'
  314.         ORDER BY ordinal_position,column_name";
  315.             
  316.             $q_conf1=vmsql_query($SQL_confronto_colonne1,$link);
  317.             
  318.             while($RSc1=vmsql_fetch_assoc($q_conf1)){
  319.                 
  320.                 $colonne1[$RSc1['column_name']]=$RSc1;
  321.                 
  322.                 $colonne[$RSc1['column_name']]=1;
  323.             }
  324.             
  325.         
  326.         // INFO COLONNE DAL frontend
  327.             $SQL_confronto_colonne2="
  328.         SELECT column_name,column_type,data_type,is_nullable
  329.         FROM {$db1['frontend']}.registro_col c, {$db1['frontend']}.registro_tab t
  330.         WHERE t.id_table=c.id_table
  331.         AND c.gid=0
  332.         AND t.table_name='$tabella'
  333.         ORDER BY ordinal_position,column_name
  334.             ";
  335.         
  336.         $q_conf2=vmsql_query($SQL_confronto_colonne2,$link);
  337.         
  338.         while($RSc2=vmsql_fetch_assoc($q_conf2)){
  339.             
  340.             $colonne2[$RSc2['column_name']]=$RSc2;
  341.             
  342.             $colonne[$RSc2['column_name']]=1;
  343.         }
  344.         
  345.         
  346.         
  347.         
  348.         
  349.         if($colonne1!=$colonne2){
  350.             
  351.             $TESTO"<table id=\"diff-tab\" summary=\"differenze tra le tabelle\" border=\"1\">";
  352.             
  353.                     
  354.             $TESTO.= "
  355.                 <tr >
  356.                       <th>column_name A</th><th>column_type A</th><th>data_type A</th><th>is_nullable A</th>
  357.                       <th style=\"background-color:#444;\" rowspan=\"".(count($colonne)+1."\">&nbsp;</th>
  358.                       <th>column_name B</th><th>column_type B</th><th>data_type B</th><th>is_nullable B</th>
  359.                       
  360.                 </tr>\n";
  361.             
  362.             
  363.             foreach($colonne as $campo=>$val){
  364.                 
  365.                 
  366.                 if($colonne1[$campo]!=$colonne2[$campo]){
  367.                     
  368.                     $class="evidenza";
  369.                                         
  370.                     // tipo di differenza:
  371.                     if($colonne1[$campo]['column_name']==''){
  372.                         
  373.                         $campi_diversi[]=array($campo,"DELETE";
  374.                         
  375.                         $TESTO.= "
  376.                         <tr class=\"$class\">
  377.                               ".str_repeat("<td>&nbsp;</td>",4)."
  378.                               
  379.                               <td>".implode("</td>\t\n<td>"(array) $colonne2[$campo])."</td>
  380.                         </tr>\n";
  381.                         
  382.                     }
  383.                     elseif($colonne2[$campo]['column_name']==''){
  384.                         
  385.                         $campi_diversi[]=array($campo,"INSERT";
  386.                         
  387.                         $TESTO.= "
  388.                         <tr class=\"$class\">
  389.                               <td>".implode("</td>\t\n<td>",(array) $colonne1[$campo])."</td>
  390.                               
  391.                               ".str_repeat("<td>&nbsp;</td>",4)."
  392.                         </tr>\n";
  393.                         
  394.                         
  395.                     }
  396.                     else{
  397.                         
  398.                         $campi_diversi[]=array($campo,"UPDATE";
  399.                         
  400.                         $TESTO.= "
  401.                         <tr class=\"$class\">
  402.                               <td>".implode("</td>\t\n<td>",(array) $colonne1[$campo])."</td>
  403.                               
  404.                               <td>".implode("</td>\t\n<td>"(array) $colonne2[$campo])."</td>
  405.                         </tr>\n";
  406.                         
  407.                     }
  408.                     
  409.                     
  410.                 }
  411.                 else{
  412.                     
  413.                     $class="null";
  414.                     
  415.                     $TESTO.= "
  416.                         <tr class=\"$class\">
  417.                               <td>".implode("</td>\t\n<td>",(array) $colonne1[$campo])."</td>
  418.                               
  419.                               <td>".implode("</td>\t\n<td>"(array) $colonne2[$campo])."</td>
  420.                         </tr>\n";
  421.                 }
  422.                 
  423.                 
  424.                 
  425.             }
  426.             
  427.             
  428.         
  429.             $TESTO.= "</table>";    
  430.             
  431.             $TESTO.="<p><strong>A</strong>: information_schema<br /><strong>B</strong>: db vfront</p>\n";
  432.             
  433.             
  434.             $differenza=true;
  435.             
  436.             
  437.             
  438.         }
  439.         
  440.         else{
  441.         
  442.             $TESTO="Non sembra ci siano incongruenze in questa tabella";
  443.             
  444.             $differenza=false;
  445.         
  446.         }
  447.  
  448.         
  449.     }else{
  450.         
  451.         header("Location: ".$_SERVER['PHP_SELF']);
  452.     }
  453.  
  454.     
  455.     $files=array("sty/admin.css","sty/log.css","sty/tabelle.css");
  456.     
  457.     echo openLayout1("Sincronizzazione database/frontend",$files);
  458.     
  459.      echo "<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> &raquo; <a href=\"".basename($_SERVER['PHP_SELF'])."\">sincronizzazione db/frontend</a> &raquodifferenze per la tabella $tabella</div>";
  460.  
  461.     echo "<h1>Differenze di impostazione per la tabella <span class=\"var\">$tabella</span></h1>\n";
  462.     
  463.     echo $TESTO;
  464.     
  465.     if($differenza){
  466.         
  467.         echo "<form action=\"".$_SERVER['PHP_SELF']."?aggiorna_campi\" method=\"post\">\n";
  468.         
  469.         foreach($campi_diversi as $k=>$v){
  470.             
  471.             echo "<input type=\"hidden\" name=\"campo_aggiorna[]\" value=\"$tabella;{$v[0]};{$v[1]}\" />\n";
  472.             
  473.         }
  474.         
  475.         echo "<input type=\"submit\" name=\"aggiorna\" value=\" Sincronizza campi \" />\n";
  476.         
  477.         echo "</form>\n";
  478.     }
  479.     
  480.     echo closeLayout1();
  481.     
  482.     exit;
  483.     
  484. }
  485.     
  486.     
  487. #
  488. #    --fine procedura visualizzazione differneze
  489. #
  490. ################################################################################à    
  491.  
  492.  
  493.  
  494.     
  495.  
  496. $files=array("sty/admin.css","sty/tabelle.css","sty/linguette.css");
  497.  
  498. echo openLayout1("Sincronizzazione database",$files);
  499.  
  500.  
  501.     echo "    
  502.     <script type=\"text/javascript\">
  503.     
  504.         var divs = new Array('integrita','manuale');
  505.     
  506.     
  507.         function eti(ido){
  508.             
  509.             for (var i in divs){
  510.                 document.getElementById('cont-eti-'+divs[i]).style.display='none';
  511.                 document.getElementById('li-'+divs[i]).className='disattiva';
  512.             }
  513.             
  514.             // attiva il selezionato
  515.             document.getElementById('cont-eti-'+ido).style.display='';
  516.             document.getElementById('li-'+ido).className='attiva';
  517.             
  518.         }
  519.     
  520.     
  521.     </script>
  522.     ";
  523.  
  524.  
  525.     $OUT="<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> &raquo; sincronizzazione db/frontend</div>";
  526.  
  527.     $OUT.="<h1>Sincronizzazione database/frontend</h1>\n";
  528.     
  529.     $OUT.="<img src=\"../img/registri.gif\" class=\"img-float\" alt=\"impostazioni registri\" />\n";
  530.     
  531.     echo $OUT;
  532.             
  533.  
  534.     // FEEDBACK 
  535.         if(isset($_GET['feed'])){
  536.             
  537.             if($_GET['feed']=='ok_nuove')
  538.                 echo "<div class=\"feed-mod-ok\">Nuove tabelle impostate correttamente</div><br />";
  539.             
  540.             elseif($_GET['feed']=='ko_nuove')
  541.                 echo "<div class=\"feed-mod-ko\">Nessuna nuova tabella impostata: eccezione della procedura</div><br />";
  542.             
  543.             elseif($_GET['feed']=='ok_del')
  544.                 echo "<div class=\"feed-mod-ok\">Impostazioni tabelle eliminate correttamente</div><br />";    
  545.                 
  546.             elseif($_GET['feed']=='ko_del')
  547.                     echo "<div class=\"feed-mod-ko\">Nessuna impostazione tabella eliminata: eccezione della procedura.</div><br />";    
  548.                     
  549.             elseif($_GET['feed']=='ko_azzera1')
  550.                 echo "<div class=\"feed-mod-ko\">Nessuna modifica effettuata sul registro della tabella: eccezione della procedura</div><br />";
  551.             
  552.             elseif($_GET['feed']=='ko_azzera2')
  553.                     echo "<div class=\"feed-mod-ko\">Nessuna modifica effettuata sul registro della tabella: eccezione della procedura</div><br />";
  554.             
  555.             elseif($_GET['feed']=='ok_azzera')
  556.                     echo "<div class=\"feed-mod-ok\">Impostazioni della tabella riconfigurate correttamente.</div><br />";
  557.                 
  558.         }
  559.     
  560.     
  561.     echo "<p>In questa pagina sono presenti funzioni per la manutenzione del frontend e la sincronizzazione con il database<br /><br />
  562.             <strong>Nota bene!</strong> Nessuna delle operazioni sotto elencate modifica la struttura del database!<br />
  563.             Ogni operazione sar&agrave; solo sul contenuto del frontend.
  564.             </p><br />\n";
  565.     
  566.     echo "    
  567. <div id=\"contenitore-variabili\">
  568.     <div id=\"box-etichette\">
  569.         
  570.         <ul class=\"eti-var-gr\">
  571.  
  572.         
  573.             <li onclick=\"eti('integrita');\" id=\"li-integrita\" class=\"attiva\">Integrit&agrave; frontend</li>
  574.             <li onclick=\"eti('manuale');\" id=\"li-manuale\" class=\"disattiva\">Ripristino manuale</li>
  575.  
  576.         </ul>
  577.     
  578.     </div>";
  579.  
  580.     
  581.     
  582.     // TEST 1 DB->FRONTEND
  583.     
  584.     $sql1="SELECT t.table_name , obj_description(c.oid, 'pg_class'::nameAS table_comment 
  585.                     FROM information_schema.tables t
  586.                     INNER JOIN pg_catalog.pg_class AS c ON t.table_name=c.relname
  587.                     INNER JOIN pg_namespace AS ns ON ns.oid=c.relnamespace
  588.                     LEFT OUTER JOIN  {$db1['frontend']}.registro_tab r ON t.table_name=r.table_name
  589.                     WHERE t.table_schema='{$db1['dbname']}'
  590.                     AND ns.nspname = t.table_schema
  591.                     AND (t.table_type='BASE TABLEOR t.table_type='VIEW') 
  592.                     AND t.table_name NOT IN (SELECT r.table_name FROM {$db1['frontend']}.registro_tab r)";
  593.     
  594.     $q1=vmsql_query($sql1,$link);
  595.     
  596.  
  597.     
  598.     
  599.     $n_row_t1=vmsql_num_rows($q1);
  600.     
  601.     if($n_row_t1>0){
  602.         
  603.         $test1=false;
  604.         $matrice_t1 vmsql_fetch_assoc_all($q1);
  605.     }
  606.     else{
  607.         
  608.         $test1=true;
  609.     }
  610.     
  611.     
  612.     
  613.     
  614.     // TEST 2 FRONTEND->DB
  615.     $sql2="SELECT r.id_tabler.table_namer.commento
  616.                     FROM {$db1['frontend']}.registro_tab r
  617.                     WHERE r.table_name NOT IN (
  618.                         SELECT t.table_name FROM information_schema.tables t
  619.                         WHERE t.table_schema='{$db1['dbname']}AND (t.table_type='BASE TABLEOR t.table_type='VIEW'))
  620.                     AND gid=0";
  621.     
  622.     $q2=vmsql_query($sql2,$link);
  623.     
  624.     
  625.     $n_row_t2=vmsql_num_rows($q2);
  626.     
  627.     if($n_row_t2>0){
  628.         
  629.         $test2=false;
  630.         $matrice_t2 vmsql_fetch_assoc_all($q2);
  631.     }
  632.     else{
  633.         
  634.         $test2=true;
  635.     }
  636.     
  637.     
  638. ###########################################################################
  639. #
  640. #    CONTROLLO CAMPI TABELLE
  641. #
  642. #
  643.     // prendi le tabelle dal frontend
  644.     
  645.         
  646.     $q_tabelle=vmsql_query("SELECT table_name FROM {$db1['frontend']}.registro_tab WHERE gid=0 ORDER BY table_name",$link);
  647.     
  648.     list($tabelle_presentivmsql_fetch_row_all($q_tabelle,true);
  649.     
  650.     
  651.     $uguali true;
  652.     
  653.     for($i=0;$i<count($tabelle_presenti);$i++){
  654.     
  655.         $colonne1=array();
  656.         $colonne2=array();
  657.         
  658.     
  659.         // INFO COLONNE DALL' information_schema
  660.         $SQL_confronto_colonne1 "
  661.         SELECT column_name,data_type,is_nullable
  662.         FROM information_schema.columns
  663.         WHERE table_name='{$tabelle_presenti[$i]}'
  664.         AND table_schema='{$db1['dbname']}'
  665.         ORDER BY ordinal_position,column_name";
  666.             
  667.             $q_conf1=vmsql_query($SQL_confronto_colonne1,$link);
  668.             
  669.             while($RSc1=vmsql_fetch_assoc($q_conf1)){
  670.                 
  671.                 $colonne1[$RSc1['column_name']]=$RSc1;
  672.             }
  673.         
  674.         
  675.         // INFO COLONNE DAL frontend
  676.         $SQL_confronto_colonne2="
  677.         SELECT column_name,data_type,is_nullable
  678.         FROM {$db1['frontend']}.registro_col c, {$db1['frontend']}.registro_tab t
  679.         WHERE t.id_table=c.id_table
  680.         AND c.gid=0
  681.         AND t.table_name='{$tabelle_presenti[$i]}'
  682.         ORDER BY ordinal_position,column_name
  683.             ";
  684.         
  685.         $q_conf2=vmsql_query($SQL_confronto_colonne2,$link);
  686.         
  687.         while($RSc2=vmsql_fetch_assoc($q_conf2)){
  688.             
  689.             $colonne2[$RSc2['column_name']]=$RSc2;
  690.         }
  691.         
  692.         
  693.         
  694.         if($colonne1!=$colonne2){
  695.             
  696.             $diversi[$tabelle_presenti[$i]]=array($colonne1,$colonne2);
  697.             $tab_diverse[]=$tabelle_presenti[$i];
  698.             $uguali=false;
  699.     
  700.         
  701.         
  702.         }
  703.  
  704.         
  705.         
  706.     }
  707.     
  708. #
  709. #
  710. ################################################
  711.  
  712.     $OUT_TEST='';
  713.     
  714.     
  715.     if($test1 && $test2 && $uguali){
  716.         
  717.         $OUT_TEST.="<p class=\"verde\"><strong>Tutto bene!</strong><br />Il database &egrave; sincronizzato con il frontend</p>\n";
  718.         $TAB_SYNC1="";
  719.         $TAB_SYNC2="";
  720.     }
  721.     elseif(!$test1 && $test2){
  722.         $OUT_TEST.="<p><strong class=\"var\">Attenzione!</strong><br />
  723.         Ci sono <strong>nuove tabelle</strong> nel database da sincronizzare con il frontend</p>\n";
  724.     }
  725.     elseif($test1 && !$test2){
  726.         $OUT_TEST.="<p><strong class=\"var\">Attenzione!</strong><br />
  727.         Ci sono <strong>tabelle obsolete</strong> nel frontend da eliminare (non pi&ugrave; presenti in database)</p>\n";
  728.     }
  729.     elseif(!$test1 && !$test2){
  730.         $OUT_TEST.="<p><strong class=\"var\">Attenzione!</strong><br />
  731.         Ci sono <strong>nuove tabelle</strong> nel database da sincronizzare <br />
  732.         e <strong>tabelle obsolete</strong> nel frontend da eliminare (non pi&ugrave; presenti in database)</p>\n";
  733.     }
  734.     
  735.     if(!$uguali){
  736.         $OUT_TEST.="<p><strong class=\"var\">Attenzione!</strong><br />
  737.         Ci sono <strong>campi impostati diversamente</strong> nel database e nel frontend</p>\n";
  738.         
  739.         $tab_string="";
  740.         
  741.         for($k=0;$k<count($tab_diverse);$k++){
  742.                 
  743.                 $tab_string.="<a class=\"rosso\" href=\"".$_SERVER['PHP_SELF']."?diff=".$tab_diverse[$k]."\">".$tab_diverse[$k]."</a>, <br />\n";
  744.         }
  745.         
  746.         if(count($tab_diverse)>1){
  747.             
  748.             
  749.             
  750.             $OUT_TEST.="<p>Le tabelle da sincronizzare sono <br /> $tab_string </p>";
  751.         }
  752.         else{    
  753.             $OUT_TEST.="<p>La tabella da sincronizzare &egrave$tab_string </p>";
  754.         }
  755.         
  756.     }
  757.     
  758.     
  759.     
  760. // TABELLE NUOVE DA SINCRONIZZARE
  761.     if(!$test1){
  762.         
  763.         $TAB_SYNC1="<table class=\"tab-color\" summary=\"Tabelle da sincronizzare\">\n\t<tbody>\n";
  764.         
  765.         $TAB_SYNC1.="
  766.         
  767.             <tr>
  768.                 <th>nuova tabella</th>
  769.                 <th>commento</th>
  770.             </tr>
  771.         ";
  772.         
  773.         $VAL1="";
  774.         
  775.         for($i=0;$i<count($matrice_t1);$i++){
  776.             
  777.             $VAL1.=$matrice_t1[$i]['table_name'].",";
  778.             
  779.             $TAB_SYNC1.="
  780.             <tr>
  781.                 <td>".$matrice_t1[$i]['table_name']."</td>
  782.                 <td>".$matrice_t1[$i]['table_comment']."</td>
  783.             </tr>
  784.             ";
  785.         }
  786.  
  787.         $TAB_SYNC1.="\t</tbody>\n</table>
  788.         
  789.         <form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
  790.             <input type=\"hidden\" name=\"nuove\" value=\"".substr($VAL1,0,-1)."\" />
  791.             
  792.             <input type=\"submit\" name=\"sincronizza_nuove\" value=\"Inserisci tabelle nel frontend\" />
  793.             <br /><br /><br />
  794.         </form>\n";
  795.         
  796.     }
  797.     
  798.     
  799. // TABELLE OBSOLETE DA ELIMINARE
  800.     if(!$test2){
  801.         
  802.         $TAB_SYNC2="<table class=\"tab-color\" summary=\"Tabelle da sincronizzare\">\n\t<tbody>\n";
  803.         
  804.         $TAB_SYNC2.="
  805.         
  806.             <tr>
  807.                 <th class=\"arancio\">tabella obsoleta</th>
  808.                 <th class=\"arancio\">commento</th>
  809.             </tr>
  810.         ";
  811.         
  812.         $VAL2="";
  813.         
  814.         for($i=0;$i<count($matrice_t2);$i++){
  815.             
  816.             $VAL2.=$matrice_t2[$i]['table_name'].",";
  817.             
  818.             $TAB_SYNC2.="
  819.             <tr>
  820.                 <td>".$matrice_t2[$i]['table_name']."</td>
  821.                 <td>".$matrice_t2[$i]['commento']."</td>
  822.             </tr>
  823.             ";
  824.         }
  825.  
  826.         $TAB_SYNC2.="\t</tbody>\n</table>
  827.         
  828.         <form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
  829.             <input type=\"hidden\" name=\"obsolete\" value=\"".substr($VAL2,0,-1)."\" />
  830.             
  831.             <input type=\"submit\" name=\"elimina_obsolete\" value=\"Elimina tabelle obsolete\" />
  832.             <br /><br /><br />
  833.         </form>\n";
  834.     }
  835.     
  836.     
  837.     
  838.     
  839.     
  840.     
  841.     
  842.     
  843.     
  844.     
  845.     
  846.     // CONTENITORE TEST INTEGRITA'
  847.     echo "
  848.     <div class=\"cont-eti\" id=\"cont-eti-integrita\">
  849.     
  850.         $OUT_TEST
  851.         $TAB_SYNC1
  852.         $TAB_SYNC2
  853.     </div>
  854.     ";
  855.     
  856.     
  857.     // PRENDI TUTTE LE TABELLE DAL FRONTEND
  858.     
  859.     $q_front=vmsql_query("SELECT table_name,data_modifica,commento FROM {$db1['frontend']}.registro_tab
  860.                          GROUP BY table_name,data_modifica,commento
  861.                          ORDER BY table_name",$link);
  862.         
  863.     $matrice_front=vmsql_fetch_assoc_all($q_front);
  864.     
  865.     
  866.     $TAB_FRONT="<table class=\"tab-color\" summary=\"Tabelle del frontend\">\n\t<tbody>\n";
  867.     
  868.     
  869.     $TAB_FRONT.="
  870.         
  871.             <tr>
  872.                 <th class=\"arancio\">tabella</th>
  873.                 <th class=\"arancio\">commento</th>
  874.                 <th class=\"arancio\">data configurazione</th>
  875.                 <th class=\"arancio\">ripristina configurazione</th>
  876.             </tr>
  877.         ";
  878.         
  879.         
  880.         for($i=0;$i<count($matrice_front);$i++){
  881.             
  882.             $data_config (intval($matrice_front[$i]['data_modifica'])>0date("d/m/Y H:i",$matrice_front[$i]['data_modifica']"-";
  883.             
  884.             $TAB_FRONT.="
  885.             <tr>
  886.                 <td>".$matrice_front[$i]['table_name']."</td>
  887.                 <td>".$matrice_front[$i]['commento']."</td>
  888.                 <td>".$data_config."</td>
  889.                 <td><a href=\"".$_SERVER['PHP_SELF']."?azzera=".$matrice_front[$i]['table_name']."\">ripristina</a></td>
  890.             </tr>
  891.             ";
  892.         }
  893.     
  894.     
  895.     
  896.         $TAB_FRONT.="\t</tbody>\n</table>";
  897.     
  898.     
  899.     
  900.     
  901.     echo "
  902.     <div class=\"cont-eti\" id=\"cont-eti-manuale\" style=\"display:none;\">
  903.     
  904.             <p><strong>Attenzione!</strong><br />
  905.             Se si ripristina la configurazione di una tabella si annulleranno tutte le impostazioni finora definite per quella tabella per tutti i gruppi,<br />
  906.             comprese le impostazioni per le sottomaschereUsare questa funzione con cautela.</p>
  907.  
  908.     $TAB_FRONT
  909.     
  910.     </div>
  911. </div>
  912.  
  913.     ";
  914.  
  915.     
  916.     
  917. echo closeLayout1();
  918. ?>

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