GeRik Posted June 29, 2009 Report Share Posted June 29, 2009 Pienemsim ja man ir datubaze ar shadiem laukiem id un kodara un ja lietotajs atrodas pienemsim Galvenaja lapa piemeram localhost/index.php Un ja tas butu ierakstits tabula ka id 0 un pie kodara Lasa Jaunumus (uzraksts) ka man to izpildit lai uzraditu ? ja sapratat ko es domaju Quote Link to comment Share on other sites More sharing options...
Turecky Posted June 29, 2009 Report Share Posted June 29, 2009 Ja gribi, lai ierakstās datu bāzē visi linki, kas ir spiesti, tad paskaties, kā taisa vienkāršu HIT COUNTER, tad arī sapratīsi, kā to dabūt gatavu. Ja pareizi atceros, lai noteiktu, kāds skripts šobrīd strādā iekš PHP to varēja izdarīt ar $_SERVER['SCRIPT_NAME']. Quote Link to comment Share on other sites More sharing options...
GeRik Posted June 29, 2009 Author Report Share Posted June 29, 2009 (edited) <?$type = 1; //Function to get user ip (stolen from phpskills.com :) function get_user_ip(){ $ipParts = explode(".", $_SERVER['REMOTE_ADDR']); if ($ipParts[0] == "165" && $ipParts[1] == "21") { if (getenv("HTTP_CLIENT_IP")) { $ip = getenv("HTTP_CLIENT_IP"); } elseif (getenv("HTTP_X_FORWARDED_FOR")) { $ip = getenv("HTTP_X_FORWARDED_FOR"); } elseif (getenv("REMOTE_ADDR")) { $ip = getenv("REMOTE_ADDR"); } } else { return $_SERVER['REMOTE_ADDR']; } return $ip; } // Use this to check that the ip was already entered into the database (no entry is made) $match = false; $user_ip = get_user_ip(); $get_user = @mysql_query("SELECT * FROM ips WHERE `ip`='$user_ip'"); if(@mysql_num_rows($get_user) > 0){ $match = true; } else { $insert_ip = @mysql_query("INSERT INTO ips (`ip`) VALUES ('$user_ip')"); } // Check Type Kind if($type == 2 || ($type == 1 && $match == false)){ $get_last_hit = @mysql_fetch_array(@mysql_query("SELECT * FROM myhits WHERE `name`='frontpage'")); $get_last_hit[1]++; $update_count = @mysql_query("UPDATE myhits SET hits='$get_last_hit[1]' WHERE name='frontpage'"); } else { $get_last_hit = @mysql_fetch_array(@mysql_query("SELECT * FROM myhits WHERE `name`='frontpage'")); } // It is safe to change these information to your needs if($type == 2){ echo 'Page\'s Total hits: ' . $get_last_hit[1]; } else { echo 'This Page Has: ' . $get_last_hit[1] . ' Unique hits!'; } ?> Apskatijos sho te bet vari ieteikt ar ko sakt izmainit un ko nodzest Edited June 29, 2009 by GeRik Quote Link to comment Share on other sites More sharing options...
ezis Posted June 29, 2009 Report Share Posted June 29, 2009 manai lapelei arī kas tāds ir.. :) ja ir lietotājs ielogojies, tad man ieraksta db vinju un vinja atrasanās vietu.. tad es uzaisīju funkciju, kas atrod linkā lapusi un tadattiecīgi nosaukumu ierakstu.. tādējādi man rādās atrašanās vieta.:) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.