Hello
A few weeks ago I showed you how to create your own URL-Shortener. I decide to improve it, creating a simple system to control the number of access
First of all you need to add some tables to your data base:
[code lang=”sql”]CREATE TABLE access (
aid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
urls_uid INTEGER UNSIGNED NOT NULL,
information_iid INTEGER UNSIGNED NOT NULL,
date DATE NULL,
PRIMARY KEY(aid),
INDEX access_FKIndex1(information_iid),
INDEX access_FKIndex2(urls_uid)
);
CREATE TABLE information (
iid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
ip VARCHAR(255) NULL,
PRIMARY KEY(iid)
);[/code]
After this you should do a modification in your function-little-url.php in the function take_url($url):
[code lang=”php”]function take_lurl($lurl) {
global $link;
$q = “SELECT * FROM `urls` WHERE `unique_chars` = ‘”.$lurl.”‘”;
$r = mysql_query($q, $link); // Realiza consulta.
if(mysql_num_rows($r)>0) {
$info = mysql_fetch_array($r);
$url = $info[“url”]; // Pega endereço real
$uid = $info[“uid”]; // Pega ID do endereço
$ip = $_SERVER[‘REMOTE_ADDR’]; // Pega IP do usuário
$qr = “select iid from `information` where ip = ‘”.$ip.”‘” ;
$rr = mysql_query($qr, $link); // Procura se este IP já está no banco de dados
if(mysql_num_rows($rr)>0) { // Caso esteja insere somente um acesso novo proveniente deste IP
$iid = mysql_result($rr,0,”iid”);
mysql_query(“INSERT INTO `access` (urls_uid,information_iid,date) values (“.$uid.”, “.$iid.”, now())”, $link);
} else { // Caso não esteja, cria um registro com este IP e após cria um acesso.
$qr = mysql_query(“INSERT INTO `information` (ip) values (‘”.$ip.”‘)”, $link);
$iid = mysql_insert_id($qr);
mysql_query(“INSERT INTO `access` (urls_uid,information_iid,date) values (“.$uid.”, “.$iid.”, now())”, $link);
}
} else {
echo “Sorry, link not found!”;
}
return $url;
}[/code]
In this System there is a table with IPs that already accessed some URL, when a URL is accessed it verify the IP, if it is on the table just create an access to this IP in the new address. Otherwise, add the IP and create the access to the address.
How to create a URL-Shortener with Statistics
Matheus
[…] Como criar seu próprio tiny url Estatísticas no seu Tiny URL […]
**mitolyn official**
Mitolyn is a carefully developed, plant-based formula created to help support metabolic efficiency and encourage healthy, lasting weight management.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://www.binance.info/ur/register?ref=SZSSS70P
canadian pharmacies top best
canada pharmaceuticals online
canadian discount online pharmacy
foreign online pharmacy
canada prescriptions
medications without prescription
list of canadian pharmacies
reputable online canadian pharmacy
Vavada to znane kasyno online, które działa również w Polsce. Strona przyciąga graczy szeroką ofertą gier, przejrzystymi warunkami i obsługą w PLN (zł). Bonus powitalny oraz intuicyjna obsługa sprawiają, że platforma zdobyła popularność wśród polskich użytkowników.
https://888starz.net.co/
888Starz Colombia es una plataforma de casino online y casa de apuestas que cuenta con mas de 9.500 juegos disponibles, entre los que se incluyen maquinas tragamonedas, ruletas y mesas con croupier real junto a una variada seleccion de disciplinas deportivas que cubre desde la Liga BetPlay hasta la Champions League y esports.
Kasyno vavada systematycznie buduje swoją pozycję wśród polskim graczom, oferując kompletną lokalizację w języku polskim. Vavada casino zapewnia metody płatności dostosowane do lokalnego rynku, a vavada pl umożliwia łatwy dostęp dla graczy z Polski. Oficjalną stronę vavada kasyno odwiedzają głównie doświadczonych graczy, którzy doceniają atrakcyjne bonusy i program lojalnościowy.