Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: IP script

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    379

    IP script

    conoscete uno scritp che fa visualizzare l'ip del atuale utente?? mi serve per bannare degli utenti che non si colportano in modo adeguato. insomma ho trovato lo script per bannare nel quale ce anche lo script che cerco solo che non riesco ad estrapolarlo facendolo funzionare in una tabella, per farvi capire il tutto un po meglio vi passo il materiale sperando in una maggiore riuscita.

    ecco lo script dv devo estrapolare la parte del IP
    Codice PHP:
    <?php 
    session_start
    ();
    $domain GetHostByName($REMOTE_ADDR); // GET YOUR IP ADDRESS
    include "inc.php"// INCLUDE THIS FILE FOR PASSWORD
    // IF LOG OUT IS REQUESTED THEN THE SESSION WILL UNSET BELOW
    if ($action == 'logout') { 
    session_unset();
    echo 
    "Logged out !!";
    exit();
    }
    // CHECK TO SEE IF YOUR LOGGED IN
    if ($_POST['Login'] == 'Login') { 
    if (
    $pass != $password) {$msg "You must type in the correct password";}
    if (
    $pass == $password
    {
    $_SESSION['logged'] = 'true';
    $action '';}


    if (!
    $_SESSION['logged'] == 'true') { 
    echo 
    $_SESSION['logged'];
    echo 
    "<link href='IPstyle.css' rel='stylesheet' type='text/css'>
    <div align='center'>
      

    PHP - AGTC IP Ban v1.0a </p>
      <table width='50%'  border='0'>
      <tr>
        <th scope='col'><form action='' method='post' name='form1'>
      <div align='center'>Enter The Admin Password

        <input name='pass' type='password' size='30' maxlength='30'>
        <input name='Login' type='submit' value='Login'>
      </div>
    </form>    </th>
      </tr>
    </table></div>"

    }
    // THIS IS WHERE WE CHECK BEFORE WE WRITE NEW BANNED IP TO FILE ip.txt
    if($_SESSION['logged']) {
    if (isset(
    $_POST['Submit'])) {
    $addip $_POST['ipadd'];
    $filename 'ip.txt';
    $content "$addip\n";

    // DOES IT EXIST, IF SO PREPARE TO APPEND
    if (is_writable($filename)) {
          if (!
    $handle fopen($filename'a')) {
             echo 
    "Cannot open file ($filename)";
             exit;
       }

       
    // WRITE $content TO $ip.txt
       
    if (fwrite($handle$content) === FALSE) {
           echo 
    "Cannot write to file ($filename)";
           exit;
       }
       
       
    $msg "Success, wrote $content to IP ban database";
       
       
    fclose($handle);

    } else {
       
    $msg "The file $filename is not writable";
    }
    }
    ?>

    <link href="IPstyle.css" rel="stylesheet" type="text/css">
    <div align="center">
      

    PHP - AGTC IP Ban v1.0a </p>
      

    Your IP address is <?php echo $domain?> </p>
      <table width="50%"  border="0">
      <tr>
        <th scope="col"><form action="" method="post" name="form1">
      <div align="center">Enter the IP address you wish to ban

        <input name="ipadd" type="text" size="30" maxlength="30">
        <input name="Submit" type="submit" value="Submit">
      </div>
    </form>    </th>
      </tr>
    </table>
      

    [url="?action=logout"]LOG OUT [/url]</p>
      

    <?php echo $msg?></p>
    </div>
     
    <div align="center">
      

    </p>
      <table width="30%"  border="0" cellspacing="2" cellpadding="2">
      <tr><th><span class="style1">List of banned IP's</span></th>
      
      </tr>  
          <?php $theFile file_get_contents('ip.txt');
    $lines = array();
    $lines explode("\n"$theFile);
    $lineCount count($lines);
    for (
    $i 0$i $lineCount$i++){ ?>
    <tr> <th scope="col"><div align="left"><span class="style1"><?php echo $lines[$i];}?>  
      </span></div></th>
        </tr>
      </table>
      

    </p>
    </div>
    <?php } echo "<center>$copyright</center>"?>
    per farmi spiegare ora devo inserirlo in quasta tabella:
    Codice PHP:
    <table width="664" border="0" cellpadding="0" cellspacing="0">
      
      <tr> 
        <td width="22%" height="22" bgcolor="#000000"><div align="center">[url="<?php"]><font color="#FFFFFF">Username</font>[/url]</div></td>
        
    <td width="196" valign="top" bgcolor="#333333"><div align="center"><a href=<?php 
        
    echo "\"admin.php?begin=$begin&amp;sortby=mailadres&amp;direction=";
        if (
    $sortby == "mailadres" && $direction=="ASC"){echo "DESC\"";}
        else {echo 
    "ASC\"";}
        
    ?>>Autorit&agrave;</div></td>
        <td width="143" valign="top" bgcolor="#000000"><div align="center"><a href=<?php 
        
    echo "\"admin.php?begin=$begin&amp;sortby=actnum&amp;direction=";
        if (
    $sortby == "actnum" && $direction=="ASC"){echo "DESC\"";}
        else {echo 
    "ASC\"";}
        
    ?>><font color="#FFFFFF">Ultimo login</font></div></td>
        <td width="146" valign="top" bgcolor="#333333"><div align="center"><font color="#FFFFFF">Data 
            di registrazione</font></div></td>
      </tr>
      <?PHP 
    // set the color switcher to zero
    $bgcolorswithcer 0;
    // make an query to retrieve al members
    $query "Select * from ".$DBprefix."signup ORDER BY '$sortby$direction LIMIT $begin, 50 ";  
    $result mysql_query($query); 
    // use a while loop to print al the results
    while($row mysql_fetch_array($result)){
    ?>
      <tr> 
        <td height="18" bgcolor="<?PHP  
    // a simple script to change the value of the bgcolor atribuut of the TD tag.    
    if ($bgcolorswithcer == 0) {
    echo 
    "#000099";
     }
    else
    {
    echo 
    "#000066";
    ?>"><div align="center"><font color="#FFFFFF"> 
            <?PHP  
            
    // print the usename retrieved from the database
            
    echo htmlspecialchars($row["username"],ENT_QUOTES); ?>
            </font></div></td>
        <td valign="top" bgcolor="<?PHP  if ($bgcolorswithcer == 0) {
    echo 
    "#003399";
     }
    else
    {
    echo 
    "#003366";
    ?>"><div align="center"><font color="#FFFFFF"> 
            <?PHP 
        
    //echo if the user is an admin.
        
    if ($row["userlevel"] < 0) {echo "ADMIN";}
        else{echo 
    $row["userlevel"];}?>
            </font></div></td>
        <td valign="top" bgcolor="<?PHP  if ($bgcolorswithcer == 0) {
    echo 
    "#000099";
     }
    else
    {
    echo 
    "#000066";
    ?>"> <div align="center"><font color="#FFFFFF"> 
            <?PHP
        
    //echo the date of the last login
        
    echo $row["lastlogin"]; ?>
            </font></div></td>
        <td valign="top" bgcolor="<?PHP  if ($bgcolorswithcer == 0) {
    echo 
    "#003399";
    $bgcolorswithcer 1;
     }
    else
    {
    echo 
    "#003366";
    $bgcolorswithcer 0;
    ?>"><div align="center"> 
            <?PHP 
        
    //echo the date the user signed up
        
    echo $row["signupdate"]; ?>
          </div></td>
      </tr>
      <tr> 
        <td height="0"></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <?php
      
    // and very important end the while loop
       
    }
       
    ?>
    </table>
       </body>
    </html>


    so che sembra una cosa lunghissima ma alla fine forse anzi almeno spero si potra spiegare in poche parole


  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    240

    getenv

    prova

    $ip = getenv("REMOTE_ADDR");

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    379
    mi disp ma non funziona o non riesco a farlo funzionare

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    379
    scusate mi sono spiegato malissimo a riguardo... intendevo domandare se fosse possibile creare uno script capace di registrare per ogni utente l' indirizzo IP che poi nella lista cioè quella tabella [contenente tutti gli utenti] ha la funzione di, come dire di riportare l'IP di ogni utente... nn so se mi siego ora?? sorry

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    379
    nn ce proprio nessuno che puo aiutarmi??

  6. #6
    Per prendere l'ip puoi usare
    Codice PHP:
    $ip $_SERVER['REMOTE_ADDR']; 
    Poi te lo inserisci in un campo del db

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    379
    come in un campo del database intendi che devo fare una tabella??

  8. #8
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    379
    scusate un unica domanda ancora a tutti voi... ma l'ip cambia tutti i gg??

  9. #9
    Dicevi che volevi apparisse nella tabella contenente gli utenti, dove sono? in un db no?
    Per il cambio ip, dipende, ci sono ip statici e dinamici, ovviamente quelli dinamici cambiano, quindi c'è la possibilità che il ban del ip non sia efficace, non so come è strutturato il tuo sito, bannare il nickname?

  10. #10
    io direi ke dovresti aggiungere alla tabella degli utenti il campo ip. nel login mettici anke una query update ip con la variabile ricavata da come t ha detto cubalibre.
    così avrai ip sempre aggiornati e proprio nei campi di un utente.

    poi ci fai tutti gli scripts ke vuoi...
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.