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

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. ########################################################################
  3. #
  4. #     This file is part of VFront.
  5. #
  6. #    VFront is free software; you can redistribute it and/or modify
  7. #    it under the terms of the GNU General Public License as published by
  8. #    the Free Software Foundation; either version 2 of the License, or
  9. #    any later version.
  10. #
  11. #    VFront is distributed in the hope that it will be useful,
  12. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #    GNU General Public License for more details.
  15. #
  16. #    You should have received a copy of the GNU General Public License
  17. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19.  
  20. /**
  21. * File di index di VFront.
  22. * Questo file viene richiamato per fare il login e|o come Home per l'utente
  23. * Il file di index mostra il login qualora non ci fosse una sessione valida.
  24. @package VFront
  25. @author Mario Marcello Verona <marcelloverona@gmail.com>
  26. @copyright 2007 Mario Marcello Verona
  27. @version 0.90
  28. @license http://www.gnu.org/licenses/gpl.html GNU Public License
  29. */
  30.  
  31.  
  32.  
  33. require_once("./inc/conn.php");
  34. require_once("./inc/layouts.php");
  35. require_once("./inc/func.comuni.php");
  36.  
  37.  
  38.  
  39. $INPUTS="";
  40.  
  41.  
  42.  
  43. if(isset($_GET['login'])){
  44.     
  45.     require("./inc/auth.php");
  46.     
  47.     $_dati pulisci_dom($_POST);
  48.     
  49.     $LOGIN new auth($_dati['nick'],$_dati['passw']);
  50.     
  51.     exit;
  52. }
  53. elseif(isset($_GET['logout'])){
  54.     
  55.     $_SESSION=array();
  56.     
  57.     header("Location: ".FRONT_DOCROOT."/index.php");
  58.  
  59.     exit;
  60. }
  61. elseif(isset($_GET['nolog'])){
  62.     
  63.     $_SESSION=array();
  64.     
  65.     mostra_login();
  66.  
  67.     exit;
  68. }
  69. elseif (isset($_SESSION['user']&& is_array($_SESSION['user'])){
  70.     
  71.  
  72.     mostra_loggato();
  73.     
  74.     
  75. }
  76. else{
  77.  
  78.     mostra_login();
  79. }
  80.  
  81.  
  82.  
  83.  
  84. ##########################################################################################################
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. /**
  100.  * Questa funzione genera la pagina di login nel caso il file index sia stato richiamato senza
  101.  * la presenza di una sessione valida.
  102.  * Puņ presentare il link per il recupero della password se l'opzione č stata definita tra le variabili
  103.  * di VFront e se l'autenticazione non avviene mediante strumenti esterni.
  104.  *
  105.  */
  106. function mostra_login(){
  107.     
  108.     global $conf_auth;
  109.     
  110.     // MODULO PRINCIPALE
  111.     
  112.     $aperturastr_replace("<body>","<body onload=\"document.getElementById('nick').focus();\">",openLayout1(_NOME_PROJ));
  113.     echo $apertura;
  114.     
  115.     if(isset($_GET['nolog'])){
  116.         echo "<div id=\"nologin\"><p>Errore di nome utente o password, prego verificare</p></div>\n";
  117.     }
  118.     
  119.     if(!isset($GLOBALS['_VARIABILI'])){
  120.         
  121.         require_once("./inc/func.var_frontend.php");
  122.         var_frontend();
  123.         
  124.         
  125.     }
  126.     
  127.     if(isset($GLOBALS['_VARIABILI']['recupero_password']
  128.           && $GLOBALS['_VARIABILI']['recupero_password']==
  129.           && $conf_auth['tipo_external_auth']==null){
  130.         
  131.         $PASSW_RECOVER="<p><a href=\"password_recover.php\">Ho dimenticato la password</a></p>";
  132.     }
  133.     else{
  134.         $PASSW_RECOVER='';
  135.     }
  136.     
  137.     echo "
  138.         <div id=\"login\" align=\"center\">
  139.             <form method=\"post\" action=\"".$_SERVER['PHP_SELF']."?login\" >
  140.                 <fieldset>
  141.     
  142.                     <legend>Accesso al sistema</legend>
  143.                     <br />        
  144.                     <label for=\"nick\">E-mail</label><br />
  145.                     <input type=\"text\" name=\"nick\" size=\"30\" maxlength=\"200\" id=\"nick\" /><br /><br />
  146.                     <label for=\"passw\">Password</label><br />
  147.                     <input type=\"password\" name=\"passw\" size=\"30\" maxlength=\"100\" id=\"passw\" /><br /><br />
  148.                     <input type=\"submit\" name=\"accedi\" value=\"  Accedi  \" id=\"accedi\" />
  149.                     $PASSW_RECOVER
  150.                 </fieldset>
  151.     
  152.             </form>
  153.         </div>
  154.         ";
  155.     
  156.     
  157.     
  158.     
  159.     echo closeLayout1();
  160.     
  161.     exit;
  162. }
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. /**
  170.  * Funzione che genera il codice per produrre la home page.
  171.  * Qualora non ci fosse una sessione valida viene invece creata la pagina di login,
  172.  * mediante la funzione mostra_login()
  173.  * @see function mostra_login
  174.  *
  175.  */
  176. function mostra_loggato(){
  177.     
  178.     global $link,$db1;
  179.     
  180.     proteggi(1);
  181.     
  182.     echo openLayout1(_NOME_PROJ);
  183.         
  184.  
  185.     
  186.     echo "<h1 style=\"padding-left:4px;\">Menu principale</h1>\n";
  187.     
  188.     if($_SESSION['gid']==0){
  189.         
  190.         echo "<div class=\"info\"><strong>Attenzione!</strong><br />
  191.         Si sta facendo un login mediante il <strong>gruppo predefinito</strong>.
  192.         <!--Si tratta di un livello di accesso in <em>sola lettura</em>, senza possibilit&agrave; di operare sui record.-->
  193.         Se si &egrave; fatto il login per la prima volta, questo &egrave; normale;
  194.         &egrave; necessario contattare il proprio referente informatico
  195.         per farsi attribuire i diritti d'uso corretti.</div>\n";
  196.     
  197.     }
  198.  
  199. ######################################################################################################################
  200.     
  201.     // RECUPERO LE TABELLE
  202.     $sql_tab="SELECT * 
  203.               FROM {$db1['frontend']}.registro_tab 
  204.               WHERE gid='".$_SESSION['gid']."'
  205.               AND visibile=1
  206.               AND table_type='BASE TABLE'
  207.               ORDER BY table_name
  208.               ";
  209.     $q_tab vmsql_query($sql_tab,$link);
  210.     
  211.     $matrice_tab vmsql_fetch_assoc_all($q_tab);
  212.     
  213.     
  214.     // RECUPERO LE VISTE
  215.     $sql_view="SELECT * 
  216.               FROM {$db1['frontend']}.registro_tab 
  217.               WHERE gid='".$_SESSION['gid']."'
  218.               AND visibile=1
  219.               AND table_type='VIEW'
  220.               ORDER BY table_name
  221.               ";
  222.     $q_view vmsql_query($sql_view,$link);
  223.     
  224.     $matrice_view vmsql_fetch_assoc_all($q_view);
  225.     
  226.     
  227.     $LI1 "";
  228.         
  229.         for($i=0;$i<count($matrice_tab);$i++){
  230.             
  231.             $LI1.= "
  232.             <li>
  233.                 <a href=\"scheda.php?oid=".$matrice_tab[$i]['id_table']."\">".$matrice_tab[$i]['table_name']."</a>
  234.                 <div class=\"desc-tab\">".htmlentities(utf8_decode($matrice_tab[$i]['commento']),ENT_QUOTES)."</div>
  235.             </li>\n";
  236.         }
  237.         
  238.     $LI2 "";
  239.         
  240.         for($i=0;$i<count($matrice_view);$i++){
  241.             
  242.             $LI2.= "
  243.             <li>
  244.                 <a href=\"scheda.php?oid=".$matrice_view[$i]['id_table']."\">".$matrice_view[$i]['table_name']."</a>
  245.                 <div class=\"desc-tab\">&nbsp;</div>
  246.             </li>\n";
  247.         }
  248.         
  249. ######################################################################################################################
  250.  
  251.     
  252.  
  253.     
  254.     
  255.     echo "
  256.         <div id=\"box-tabelle\" class=\"box-home\">
  257.         
  258.             <div class=\"box-home-txt\">
  259.                 <h2>Tabelle disponibili</h2>
  260.                 <ul class=\"lista-tabelle\">
  261.                     $LI1
  262.                 </ul>
  263.             </div>
  264.         </div>    
  265.             ";
  266.             
  267.     if(count($matrice_view)>0){
  268.     
  269.         echo "
  270.             <div id=\"box-viste\" class=\"box-home\">
  271.             
  272.                 <div class=\"box-home-txt\">
  273.                     <h2>Viste sui dati</h2>
  274.                     <ul class=\"lista-tabelle\">
  275.                         $LI2
  276.                     </ul>
  277.                 </div>
  278.             </div>    
  279.                 ";
  280.     }
  281.     
  282.     echo "
  283.     <p style=\"clear:both;\">&nbsp;</p>
  284.         <div id=\"box-info\" class=\"box-home\">
  285.     
  286.             <div class=\"box-home-txt\">
  287.                 <h2>Informazioni e domande frequenti</h2>
  288.                 <p><a href=\"helpdocs.php\">Documenti utili</a></p>
  289.                 <p><a href=\"credits.php\">Crediti</a></p>
  290.             </div>
  291.     
  292.         </div>
  293.             
  294.         <p style=\"clear:both;\">&nbsp;</p>
  295.         ";
  296.         
  297.     
  298.     
  299.     echo closeLayout1();
  300.     
  301.     
  302. }
  303.  
  304.  
  305.  
  306. ?>

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