Location: PHPKode > projects > Spacemarc News > spacemarc-news/autore.php
<?php

/*****************************************************************
*  Spacemarc News
*  Version: 1.2.0
*  Author and copyright (C): Marcello Vitagliano
*  Web site: http://www.spacemarc.it
*  License: GNU General Public License
*
*  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 3
*  of the License, or (at your option) any later version.
*
*  Current file: autore.php
*****************************************************************/
header('Content-type: text/html; charset=ISO-8859-1');

//includo i file di configurazione
require_once (dirname(__FILE__) . '/config.php');

// apro la connessione a mysql
$db = mysql_connect($db_host, $db_user, $db_password) or die("Impossibile connettersi a MySQL<br />Numero errore: " . mysql_errno() . "<br />Tipo di errore: " . mysql_error());
mysql_select_db($db_name, $db) or die("Impossibile selezionare il database $db_name<br />Numero errore: " . mysql_errno() . "<br />Tipo di errore: " . mysql_error());

//se non viene inviato l'id dell'autore oppure non è valido

if (!isset($_GET['user_id']) || !preg_match('/^[0-9]{1,4}$/', $_GET['user_id'])) {
    die("Autore inesistente");
}
else {
    $user_id = intval($_GET['user_id']);
    $result = mysql_query("SELECT user_id, nome_cognome, email, nome_livello, email_nascosta, sito, im, im_num, data_nascita, citta, occupazione, hobby, mostra_link, (SELECT COUNT($tab_news.id) FROM $tab_news WHERE $tab_news.user_id=$user_id) AS TotaleNews FROM $tab_utenti WHERE user_id=$user_id LIMIT 1");
    $row = @mysql_fetch_array($result);
    
    if ($row['mostra_link'] != 'profilo') {
        die("Profilo non disponibile");
    }
    $sito = ($row['sito'] == '' || $row['sito'] == 'http://') ? 'Non disponibile' : "<a href=\"" . $row['sito'] . "\" target=\"blank\">" . $row['sito'] . "</a> <img src=\"$img_path/nw.gif\" alt=\"\" title=\"\" />";
    $im_num = ($row['im'] == 'scegli' || $row['im_num'] == '') ? NULL : $row['im_num'];
    
    switch ($row['im']) {
        case 'msn':
            $im_link = "<img src=\"$img_path/msn.gif\" alt=\"msn\" /> <a href=\"msnim:chat?contact=$im_num\" title=\"MSN Messenger\">$im_num</a>";
        break;
        case 'icq':
            $im_link = "<img src=\"http://status.icq.com/online.gif?icq=$im_num&amp;img=5\" alt=\"icq\" /> <a href=\"http://www.icq.com/people/cmd.php?uin=$im_num&amp;action=message\" type=\"application/x-icq\" title=\"ICQ\">$im_num</a>";
        break;
        case 'y!m':
            $im_link = "<img src=\"$img_path/yim.gif\" alt=\"y!m\" /> <a href=\"ymsgr:sendIM?$im_num\" title=\"Yahoo! Messenger\">$im_num</a>";
        break;
        case 'skype':
            $im_link = "<img src=\"http://mystatus.skype.com/smallicon/$im_num\" alt=\"skype\" /> <a href=\"skype:$im_num?call\" title=\"Skype\">$im_num</a>";
        break;
        case 'gtalk':
            $im_link = "<img src=\"$img_path/gtalk.gif\" alt=\"gtalk\" /> <a href=\"gtalk:chat?jid=$im_num\" title=\"GTalk\">$im_num</a>";
        break;
        case 'scegli':
            $im_link = "Non disponibile";
        break;
    }
    $data_nascita = ($row['data_nascita'] == NULL) ? 'Non disponibile' : $row['data_nascita'];
    $citta = ($row['citta'] == '') ? 'Non disponibile' : $row['citta'];
    $occupazione = ($row['occupazione'] == '') ? 'Non disponibile' : $row['occupazione'];
    $hobby = ($row['hobby'] == '') ? 'Non disponibile' : $row['hobby'];
    mysql_close($db);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">  
  <head>    
    <title>Profilo autore     
    </title>    
    <link rel="stylesheet" href="style.css" type="text/css" />  
  </head>  
  <body>    
    <div align="center">      
      <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">        
        <tr>          
          <td align="right" class="text" bgcolor="#F1F1F1" width="38%">            
            <img src="<?php echo $img_path; ?>/profilo.png" alt="Profilo" /></td>          
          <td class="text" bgcolor="#F1F1F1" align="left"><b>              
              <?php echo $row['nome_cognome']; ?></b></td>        
        </tr>        
        <tr>          
          <td align="right" class="text" bgcolor="#DEE3E7"><b>Livello</b></td>          
          <td class="text" bgcolor="#EEEEEE" align="left">            
            <?php echo $row['nome_livello']; ?></td>        
        </tr>        
        <tr>             
          <td align="right" class="text" bgcolor="#DEE3E7"><b>News inserite</b></td>          
          <td bgcolor="#EEEEEE" class="text" align="left">            
            <?php echo $row['TotaleNews']; ?>:              
            <a href="javascript:opener.location=('archivio.php?autore=<?php echo $row['user_id']; ?>'); self.close();">visualizzale</a></td>        
        </tr>        
        <tr>             
          <td align="right" class="text" bgcolor="#DEE3E7"><b>Indirizzo email</b></td>          
          <td class="text" bgcolor="#EEEEEE" align="left">   
<?php

if ($row['email_nascosta'] == 1) {
    echo 'Non disponibile';
}
else {
    $chars_email = array(
        "@",
        "."
    );
    $chars_email_replace = array(
        " <b>at</b> ",
        " <b>dot</b> "
    );
    echo str_replace($chars_email, $chars_email_replace, $row['email']);
}
?></td>        
        </tr>        
        <tr>             
          <td align="right" class="text" bgcolor="#DEE3E7"><b>Sito web</b></td>          
          <td bgcolor="#EEEEEE" class="text" align="left">            
            <?php echo $sito; ?></td>        
        </tr>        
        <tr>             
          <td align="right" valign="top" class="text" bgcolor="#DEE3E7"><b>Instant messaging</b></td>          
          <td bgcolor="#EEEEEE" class="text" align="left">            
            <?php echo $im_link; ?></td>        
        </tr>        
        <tr>          
          <td align="right" class="text" bgcolor="#DEE3E7"><b>Data di nascita</b></td>          
          <td bgcolor="#EEEEEE" class="text" align="left">            
            <?php echo $data_nascita; ?></td>        
        </tr>        
        <tr>             
          <td align="right" class="text" bgcolor="#DEE3E7"><b>Citt&agrave;</b></td>          
          <td bgcolor="#EEEEEE" class="text" align="left">            
            <?php echo $citta; ?></td>        
        </tr>        
        <tr>             
          <td align="right" valign="top" class="text" bgcolor="#DEE3E7"><b>Occupazione</b></td>          
          <td bgcolor="#EEEEEE" class="text" align="left">            
            <?php echo $occupazione; ?></td>        
        </tr>        
        <tr>          
          <td align="right" class="text" bgcolor="#DEE3E7" valign="top"><b>Interessi</b></td>          
          <td bgcolor="#EEEEEE" class="text" align="left">            
            <?php echo nl2br($hobby); ?></td>        
        </tr>      
      </table>    
    </div>  
  </body>
</html>
Return current item: Spacemarc News