Jump to content
php.lv forumi

Linka counteris !


GB.

Recommended Posts

haha, es tač jau no paša sākuma teicu, ka viņam vajag gatavu :P

<?php
function arg($k) {return isset($_POST[$k]) ? $_POST[$k] : (isset($_GET[$k]) ? $_GET[$k] : null);}  // web applikācijas arguments - izdod attiecīgā post/get parametra vērtību
function ugo($sU) {header('Location: ' . $sU); exit;}  // uri go - redirekto uz doto uri
function udl($sP, $sMime = '') {  // uri download - nosūta Content-Disposition headeri, lai izraisītu "save as"
header('Content-Disposition: attachment; filename="' . basename($sP) . '"');
if ($sMime) header('Content-Type: ' . $sMime);
readfile($sP); exit;
}

function qs($s) {  // sagatavo stringu for mysql query
return is_null($s) ? 'NULL' : "'" . mysql_real_escape_string($s) . "'";
}
function go($sSql) {  // mysql query ar error reportingu
$h = mysql_query($sSql) or die('<b>mysql error ' . mysql_errno() . ':</b> ' . mysql_error() . '<br /><b>query:</b> ' . substr($sSql, 0, 1000));
return $h;
}

function inst() {  // izveido tabulas, kur glabāsies linki & faili un to statistika (clicks)
go('DROP TABLE IF EXISTS Lnk');
go('CREATE TABLE Lnk (Uri varchar(100) NOT NULL, Clk int NOT NULL, PRIMARY KEY (Uri)) ENGINE=MyISAM');
go('INSERT Lnk (Uri, Clk) VALUES ' .
	'(' . qs('http://tvnet.lv') . ', 0),' .
	'(' . qs('http://delfi.lv') . ', 0)'
);

go('DROP TABLE IF EXISTS File');
go('CREATE TABLE File (Path varchar(100) NOT NULL, Mime varchar(50), Clk int NOT NULL, PRIMARY KEY (Path)) ENGINE=MyISAM');
go('INSERT File (Path, Mime, Clk) VALUES ' .
	'(' . qs('file/lalala.mp3') . ', ' . qs('audio/mpeg') . ', 0),' .
	'(' . qs('file/xxx.mpg') . ', ' . qs('video/mpeg') . ', 0)'
);
}

function lnkClkInc($sUri) {go('UPDATE Lnk SET Clk = Clk + 1 WHERE Uri = ' . qs($sUri));}
function fileSel($sPath) {return mysql_fetch_object(go('SELECT * FROM File WHERE Path = ' . qs($sPath)));}
function fileClkInc($sPath) {go('UPDATE File SET Clk = Clk + 1 WHERE Path = ' . qs($sPath));}

function statInfo() {
$s = 'stats:<br />';
$h = go('SELECT * FROM Lnk');
while ($r = mysql_fetch_object($h)) $s .= $r->Uri . ' (' . $r->Clk . ')<br />';

$s .= '<br />';
$h = go('SELECT * FROM File');
while ($r = mysql_fetch_object($h)) $s .= $r->Path . ' (' . $r->Clk . ')<br />';
return $s;
}

inst();  // izpilda 1x, tipa instalācija (pēc tam aizkomentē)

if (arg('go')) {
lnkClkInc(arg('go'));
ugo(arg('go'));
}
if (arg('dl'))
if ($r = fileSel(arg('dl'))) {
	fileClkInc(arg('dl'));
	udl($r->Path, $r->Mime);
}
else die('file not found!');
?>
<a href="?go=http://tvnet.lv">tvnet<a>
<a href="?go=http://delfi.lv">delfi<a><br />
<a href="?dl=file/lalala.mp3">lalala<a>
<a href="?dl=file/xxx.mpg">xxx<a><br /><br />
<?= statInfo() ?>

stat_1262790555.png

 

Piemeram ir fails - links ! P : www.manalapa.lv/faili/hardporn.mp3

hahaha porn iekš mp3!!! tipa labāk neskatīties :D:D:D

Edited by 2easy
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...