Support MemHT, Vote Now!
MemHT Portal is a Free PHP CMS and Blog
It permit the creation and the management online of websites with few and easy steps.
It's completelly customizable, expandable and suitable for all needs.
     Site demo
Moderators: mem paulo89 adminik
RSSReply
mem mi dai un tuo parere
AuthorText
rocco.mo
Junior Member
Avatar

Posts: 80
Contributes: 4

Gender: _NEUTRAL_
Online: No
Date: 30/09/2007 23:19
mem mi dai un tuo parere
#post2010
ciao mem ascolta lo script che mi hai fatto tu per l user online perche mi da invece dell ip mi da sempre Unknown ti posto lo script
code


<?php

/*
tabella 'useronline'
--------------------
campi:  time (datetime)
                ip (varchar 15 unique)
                url (varchar 255)
*/


$dbhost = "localhost";
$dbuser = "rocco";
$dbpass = "maurizio";
$dbname = "user35512_7777";
$timeoutseconds = 300;

if (getenv("HTTP_CLIENT_IP")) {
        $ip = getenv("HTTP_CLIENT_IP");
} else if (getenv("HTTP_X_FORWARDED_FOR")) {
        $ip = getenv('HTTP_X_FORWARDED_FOR');
} else if (getenv('REMOTE_ADDR')) {
        $ip = getenv('REMOTE_ADDR');
} else {
        $ip = "Unknown";
}

//Mi connetto al database
$db = @mysql_connect($dbhost,$dbuser,$dbpass)
        or die("&error=<b>Database error:</b> Cannot establish connection.");

//Seleziono il database
@mysql_select_db($dbname,$db)
        or die("&error=<b>Database error:</b> Cannot select database.");

//Cancello i "vecchi" visitatori
@mysql_query("DELETE FROM useronline WHERE (time + INTERVAL 5 MINUTE) < NOW()")
        or die("&error=<b>Database error:</b> Cannot insert new data.");

//Inserisco nuovi visitatori
@mysql_query("REPLACE INTO useronline (time,ip,url) VALUES (NOW(),'$ip','".$_SERVER['PHP_SELF']."')")
        or die("&error=<b>Database error:</b> Cannot insert new data.");

$result = mysql_query("SELECT time,ip,url FROM useronline ORDER BY time DESC");
while ($row = mysql_fetch_assoc($result)) {
        echo "&adress=".$row['ip']."&tempo=".$row['time'];
       
       
}
echo "&usersOnLine=".mysql_num_rows(mysql_query("SELECT ip FROM useronline"));




?>


 
adesso io ho aggiunto questo e mi da l ip
code

<?php
echo "&adress=".$_SERVER['REMOTE_ADDR'];
?>
 

pero nel database mi da sempre unkovn secondo te c e qualche problema? grazie
Delete Edit Quote
 
rocco.mo
Junior Member
Avatar

Posts: 80
Contributes: 4

Gender: _NEUTRAL_
Online: No
Date: 30/09/2007 23:36
mem mi dai un tuo parere
#post2011
grazie ti faccio sapere hai dato un occhiata a quello script che ti avevo postato?
Delete Edit Quote
 
rocco.mo
Junior Member
Avatar

Posts: 80
Contributes: 4

Gender: _NEUTRAL_
Online: No
Date: 30/09/2007 23:44
mem mi dai un tuo parere
#post2012
mem perche secondo te ho cercato di dare una sistemata al sito inserendo il form per le email e il mailform.php la quale serve per l invio delle email + inserisce i dati nel db e il config per la connessione li ho inseriti dentr una sotto cartella della root chiamata contatti cioe httpdocs/contatti e qua dentro non mi funziona inoltre secondo te che ci fa se uso per ogni files un files per la connessione al database cioe il nome user e password sarebbe a dire il files dove vengono scritti il nome del database l user e la pass io ne uso uno per ogni script e normale secondo te
Delete Edit Quote
 
rocco.mo
Junior Member
Avatar

Posts: 80
Contributes: 4

Gender: _NEUTRAL_
Online: No
Date: 30/09/2007 23:47
mem mi dai un tuo parere
#post2013
cosi funziona lo script
Delete Edit Quote
 
rocco.mo
Junior Member
Avatar

Posts: 80
Contributes: 4

Gender: _NEUTRAL_
Online: No
Date: 30/09/2007 23:54
mem mi dai un tuo parere
#post2014
un altra cosa nel database mi da sempre unkown
Delete Edit Quote
 
mem
MemHT's Dad
Admin / Developer

Avatar

Posts: 3984
Contributes: 1264

Gender: _MALE_
Online: Yes

Languages: English, Italian, Macedonian, Serbian
Date: 30/09/2007 23:30
mem mi dai un tuo parere
#post2015
Probabilmente non va la funzione getenv, usa questo:
code
if ($_SERVER['HTTP_CLIENT_IP']) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
} else if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if ($_SERVER['REMOTE_ADDR']) {
        $ip = $_SERVER['REMOTE_ADDR'];
} else {
        $ip = "Unknown";
}
Image
MemHT Portal - Free PHP CMS and Blog

"Great works are performed, not by strength, but by perseverance."
Samuel Johnson

READ THIS before posting your support question in the forum!
Delete Edit Quote
 
Reply
Tags Cloud
Advertising
News Archive
Language
Help MemHT Portal
Navigator
Users Block
Hi Guest
IP: 38.103.63.60

Username
Password
New files
MemHT Wiki
Friends
MemHT Portal is a free software released under the GNU/GPL License by Miltenovik Manojlo