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

Source for file sync_reg_tab.mysql.php

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

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