Файл: __system/pages/siteStatistics.php
Строк: 111
<?
if(user('access') == 5)
{
if(isset($_GET['editSite']))
{
if(isset($_POST['confirmed']))
{
$error = '';
if((mb_strlen($_POST['link'], 'utf-8')<3) or (mb_strlen($_POST['link'], 'utf-8')>100))
# проверяем на количество символов
{
$error .= '<i>Адрес сайта</i> должен быть не менее 3 символов и не более 100<br>';
}
if((mb_strlen($_POST['siteName'], 'utf-8')<3) or (mb_strlen($_POST['siteName'], 'utf-8')>25))
# проверяем на количество символов
{
$error .= '<i>Название</i> должен быть не менее 3 символов и не более 20<br>';
}
if((mb_strlen($_POST['siteAbout'], 'utf-8')<3) or (mb_strlen($_POST['siteAbout'], 'utf-8')>80))
# проверяем на количество символов
{
$error .= '<i>Описание</i> должен быть не менее 3 символов и не более 80<br>';
}
if(empty($_POST['category']))
{
$error .= 'Выберите <i>категорию</i><br>';
}
if(empty($error))
{
$_POST['link'] = trim(str_replace("http://","",$_POST['link']));
$_POST['link'] = trim(str_replace("www.","",$_POST['link']));
$s = $db->exec
("
UPDATE `site` SET `name` = ".$db->quote($_POST['siteName'])." ,
`about` = ".$db->quote($_POST['siteAbout'])." , `url` = ".$db->quote($_POST['link'])." ,
`imageBig` = '".filtration::int($_POST['imageBig'])."' , `imageSmall` = '".filtration::int($_POST['imageSmall'])."' ,
`category` = '".filtration::int($_POST['category'])."'
WHERE `id` = '".filtration::int($_GET['id'])."'
");
Header('Location: /siteStatistics/'.$_GET['id'].'/');
}
}
}
if(isset($_GET['status']))
{ $site = $db -> query
("
SELECT * FROM `site` WHERE `id` = '".filtration::int($_GET['id'])."' LIMIT 1
");
if($site -> rowCount() == 1)
{
$s = $site->fetch(PDO::FETCH_ASSOC);
if($s['status'] == 3)
{
$site = $db->exec("UPDATE `site` SET `status` = '1' WHERE `id` = '".filtration::int($_GET['id'])."' LIMIT 1 ");
}
else
if($s['status'] == 1)
{
$site = $db->exec("UPDATE `site` SET `status` = '3' WHERE `id` = '".filtration::int($_GET['id'])."' LIMIT 1 ");
}
}
}
if(isset($_GET['delete']))
{
$site = $db -> query
("
SELECT * FROM `site` WHERE `id` = '".filtration::int($_GET['id'])."' LIMIT 1
");
if($site -> rowCount() == 1)
{
$s = $site->fetch(PDO::FETCH_ASSOC);
$site = $db->exec("DELETE FROM `site` WHERE `id` = '".filtration::int($_GET['id'])."' LIMIT 1 ");
}
}
}
$site = $db -> query
("
SELECT * FROM `site` WHERE `id` = '".filtration::int($_GET['id'])."' LIMIT 1
");
if($site -> rowCount() > 0)
{
$s = $site -> fetch(PDO::FETCH_ASSOC);
DEFINE('TITLE' , ''.$s['name'].''); # фиксируем титул
}
else
{
DEFINE('TITLE' , 'Ошибка'); # фиксируем титул
}
head();
if(isset($_GET['editSite']) and user('access') == 5)
{
echo '<div class="main">';
$site = $db -> query
("
SELECT * FROM `site` WHERE `id` = '".filtration::int($_GET['id'])."'
");
$s = $site -> fetch(PDO::FETCH_ASSOC);
echo '<form action="/siteStatistics/'.$_GET['id'].'/editSite/" method="post">
<b>Адрес сайта:</b><br/>
<input type="text" name="link" value="'.$s['url'].'" size="50" maxlength="100"/>
<br />Без http://,www<br />
<br/>
<b>Название:</b><br/>
<input type="text" name="siteName" value="'.$s['name'].'" maxlength="25" size="50"/>
<br />короткое название сайта (25 символов)<br />
<br/>
<b>Описание:</b><br/>
<input type="text" name="siteAbout" value="'.$s['about'].'" maxlength="80" size="50"/>
<br />полное описание сайта (80 символов)<br />
<br/><b>Категория:</b><br/>';
$site_category = $db -> query
("
SELECT * FROM `site_category` ORDER BY `name` ASC
");
if($site_category -> rowCount() > 0)
{
echo"<select size='1' name='category'>";
while($sc = $site_category -> fetch(PDO::FETCH_ASSOC))
{
$selected = ($s['category'] == $sc['id']) ? ' selected="selected"' : '';
echo '<option value="'.$sc['id'].'" '.$selected.'>'.$sc['name'].'</option>';
}
}
echo '</select><br>';
echo '<br /><input name="confirmed" type="submit" value="Редактировать"/> </form>';
echo '</div>';
echo '<div class="main">'.url('/siteStatistics/'.$_GET['id'].'/','Вернуться','','').'</div>';
foot();
exit;
}
$site = $db -> query
("
SELECT * FROM `site` WHERE `id` = '".filtration::int($_GET['id'])."' LIMIT 1
");
if($site -> rowCount() > 0)
{
$s = $site -> fetch(PDO::FETCH_ASSOC);
echo '<div class="title2">Статистика сайта '.url('/out/'.$s['id'].'/',$s['name'],'','_blanc').' (ID: '.$_GET['id'].')</div>';
if(user('access') == 5)
{
echo '<div class="title2">';
if($s['status'] == 3)
{ echo '['.url('/siteStatistics/'.$s['id'].'/status/','Разблокировать','','').']';
}
else
{ echo '['.url('/siteStatistics/'.$s['id'].'/status/','Заблокировать','','').']';
}
echo '['.url('/siteStatistics/'.$s['id'].'/editSite/','Изменить','','').']';
echo '['.url('/siteStatistics/'.$s['id'].'/delete/','Удалить','','').']';
echo'</div>';
}
$site_category = $db -> query
("
SELECT * FROM `site_category` WHERE `id` = '".filtration::int($s['category'])."' LIMIT 1
");
$s_category = $site_category -> fetch(PDO::FETCH_ASSOC);
echo '
<div class = "main">
Название: '.$s['name'].'<br />
Адрес: '.url('/out/'.$s['id'].'/',$s['url'],'','_blanc').'<br />
Категория: '.url('/sitelist/'.$s_category['id'].'/',$s_category['name'],'','').'<br />
Описание: '.$s['about'].'<br />';
echo 'Статус: ';
if($s['status'] == 2)
{
echo 'На модерации';
}
if($s['status'] == 1)
{
echo 'Активен';
}
if($s['status'] == 3)
{
echo 'Заблокирован';
}
echo'</div>
';
$site_statistic_mounth = $db -> query
("
SELECT `host`,`hits`,`in`,`out` FROM `site_statistic` WHERE `siteID` = '".filtration::int($s['id'])."'
and `date` > '".date("Y-m-d",(time()-2592000))."' and `date` <= '".date("Y-m-d",time())."'
");
$host = 0;
$hits = 0;
$in = 0;
$out = 0;
while($scm = $site_statistic_mounth -> fetch(PDO::FETCH_ASSOC))
{ $host = $host + $scm['host'];
$hits = $hits + $scm['hits'];
$in = $in + $scm['in'];
$out = $out + $scm['out'];
}
$site_statistic_today = $db -> query
("
SELECT * FROM `site_statistic` WHERE `siteID` = '".filtration::int($s['id'])."'
and `date` = '".date("Y-m-d",time())."' LIMIT 1
");
$sct = $site_statistic_today -> fetch(PDO::FETCH_ASSOC);
$site_statistic_yesterday = $db -> query
("
SELECT * FROM `site_statistic` WHERE `siteID` = '".filtration::int($s['id'])."'
and `date` = '".date("Y-m-d",(time()-86400))."' LIMIT 1
");
$scy = $site_statistic_yesterday -> fetch(PDO::FETCH_ASSOC);
if($site_statistic_today -> rowCount() > 0)
{
echo '<div id="content"><table class="stats">
<tr class="tabl2"><th colspan="2">Сегодня</th></tr>
<tr class="tabl"><td>Хосты:</td> <td>'.$sct['host'].'</td></tr>
<tr class="tabl"><td>Хиты:</td> <td>'.$sct['hits'].'</td> </tr>
<tr class="tabl"><td>В топ:</td> <td>'.$sct['in'].'</td> </tr>
<tr class="tabl"><td>Из топа:</td> <td>'.$sct['out'].'</td> </tr>';
}
else
{ echo '<div id="content"><table class="stats">
<tr class="tabl2"><th colspan="2">Сегодня</th></tr>
<tr class="tabl"><td>Хосты:</td> <td>0</td></tr>
<tr class="tabl"><td>Хиты:</td> <td>0</td> </tr>
<tr class="tabl"><td>В топ:</td> <td>0</td> </tr>
<tr class="tabl"><td>Из топа:</td> <td>0</td> </tr>';
}
if($site_statistic_yesterday -> rowCount() > 0)
{
echo '<tr class="tabl2"><th colspan="2">Вчера</th></tr>
<tr class="tabl"><td>Хосты:</td> <td>'.$scy['host'].'</td></tr>
<tr class="tabl"><td>Хиты:</td> <td>'.$scy['hits'].'</td> </tr>
<tr class="tabl"><td>В топ:</td> <td>'.$scy['in'].'</td> </tr>
<tr class="tabl"><td>Из топа:</td> <td>'.$scy['out'].'</td> </tr>';
}
else
{ echo '<tr class="tabl2"><th colspan="2">Вчера</th></tr>
<tr class="tabl"><td>Хосты:</td> <td>0</td></tr>
<tr class="tabl"><td>Хиты:</td> <td>0</td> </tr>
<tr class="tabl"><td>В топ:</td> <td>0</td> </tr>
<tr class="tabl"><td>Из топа:</td> <td>0</td> </tr>';
}
echo '<tr class=tabl2><th colspan="2">За месяц</th></tr></tr><tr>
<tr class="tabl"><td>Хосты:</td> <td>'.$host.'</td></tr>
<tr class="tabl"><td>Хиты:</td> <td>'.$hits.'</td> </tr>
<tr class="tabl"><td>В топ:</td> <td>'.$in.'</td> </tr>
<tr class="tabl"><td>Из топа:</td> <td>'.$out.'</td> </tr>';
echo '<tr class=tabl2><th colspan="2">Всего</th></tr></tr><tr>
<tr class="tabl"><td>Хосты:</td> <td>'.$s['allHost'].'</td></tr>
<tr class="tabl"><td>Хиты:</td> <td>'.$s['allHits'].'</td> </tr>
<tr class="tabl"><td>В топ:</td> <td>'.$s['allIn'].'</td> </tr>
<tr class="tabl"><td>Из топа:</td> <td>'.$s['allOut'].'</td> </tr></table></div>';
}
foot();