Файл: views.php
Строк: 94
<?
session_start();
include "admin/config/config.php";
include "admin/config/secur.php";
$ids = (int) $_GET['i'];
$s=0;
$res = mysql_query("SELECT types FROM `reqlinks` WHERE id='$ids' limit 1");
$cr=mysql_fetch_assoc($res);
$ST = $cr['types'];
$_SESSION['SID']=0;
$res = mysql_query("SELECT url,id,domen FROM links where type='$ST'");
if(mysql_num_rows($res)>0)
{
while ($cr=mysql_fetch_assoc($res))
{
$id=$cr['id'];
if($_SESSION['larray'][$id]!=1)
{
$_SESSION['SURL']=$cr['url'];
$_SESSION['SDOMEN']=$cr['domen'];
$_SESSION['SID'] =$cr['id'];
}
}
}
if ($_SESSION['SID']>0)
{
$_SESSION['larray'][$_SESSION['SID']]=1;
$_SESSION['END']="NO";
$domen = $_SESSION['SDOMEN'];
/////////////////////////////////////
$res2 = mysql_query("SELECT * FROM stats where domen='".$domen."'");
if(mysql_num_rows($res2)>0)
{
mysql_query("UPDATE stats set visits=visits+'1' where domen='".$domen."'");
$cr=mysql_fetch_assoc($res2);
$vis=$cr['visits']+1;
mysql_query("UPDATE links set visits='$vis' where domen='".$domen."'");
}
if(mysql_num_rows($res2)==0)
{
mysql_query("INSERT INTO `stats` (`id` ,`domen` ,`visits`)
VALUES (NULL , '$domen', '1');");
}
//////////////////////////////////////
}
if ($_SESSION['END']=="YES")
{
$res = mysql_query("SELECT url,domen,types FROM reqlinks where id='$ids'");
$cr=mysql_fetch_assoc($res);
$url = $cr['url'];
$domen = $cr['domen'];
$type = $cr['types'];
$res = mysql_query("SELECT id FROM links where domen='$domen' and type='$ST' limit 1");
$res2 = mysql_query("SELECT rid FROM links where type='$ST' ORDER BY rid DESC");
if(mysql_num_rows($res2)>0)
{
$cr2=mysql_fetch_assoc($res2);
$rid=$cr2['rid'];
$did = $rid-($ST-2);
$nid = $rid+1;
mysql_query("DELETE FROM links where rid<$did and type='$ST'");
}
if(mysql_num_rows($res)==0)
{
mysql_query("INSERT INTO `links` (`id` ,`url` ,`domen` ,`type`, `rid` )
VALUES (NULL , '$url', '$domen', '$type', '$nid');");
}
$s=1;
$_SESSION=array();
}
if ($_SESSION['SID']==0)
{
$_SESSION['END']="YES";
//$_SESSION['SURL']=" - - - ";
}
$next="Следующий URL:<a href='".$_SESSION['SURL']."' target='_blank'>".$_SESSION['SURL']."</a>";
if(($_SESSION['SURL']==$_SESSION['TURL']) or $_SESSION['SURL']=="" or !isset($_SESSION['SURL']))$next="";
?>
<html>
<head>
<title>Система обмена показами.</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><style type="text/css">
<!--
body {
background-color: #FFF;
}
-->
</style>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<style type="text/css">
<!--
.timer {
background:transparent;
border-width:0;
color:#000000;
font-size: 40px;
text-align:center;
width:45px;
}
-->
</style>
<body text="000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="center">
<form name="d">
текущий URL: <a href='<?=$_SESSION['TURL']?>' target="_blank"><?=$_SESSION['TURL']?></a><br>
<input maxlength="2" type="text" class="timer" size="1" name="d2">
<br>
<?=$next?></form>
<noindex>
<noindex>
</td>
</tr>
</table>
<SCRIPT language="javascript">
<!--
var seconds=<?=$SEC?>;
document.d.d2.value='0';
<? if ($s==1) print "top.location.href='index.php?e=$ids';";?>
function display()
{
if (seconds<2)
{
<?
if ($s==0)print "top.location.href='show.php?i=$ids'";
?>
}
seconds-=1;
document.d.d2.value=seconds;
setTimeout("display()",1000);
}
display();
//-->
</SCRIPT>
</body>
</html>