Файл: public_html/page/advertise.php
Строк: 814
<?php
if (!defined('BASE_DIR')) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
$obEngine->addTitleHtml('Купить рекламу');
if (isset($_GET['mode']) && $_GET['mode'] == 'banners')
{
$query = $mysqli->query("SELECT * FROM `".PREFIX."_blocks` WHERE `type` = '2'");
$count = $query->num_rows;
$curr_date = date("Y-m-d", TIME - 86400);
$min_price = 1;
$max_price = 1;
$max_hits = 1;
$min_hits = 1;
$max_hosts = 1;
$min_hosts = 1;
$min_tic = 0;
$max_tic = 0;
$min_pr = 0;
$max_pr = 0;
if ($count)
{
while ($row = $query->fetch_assoc())
{
$min_price = $row['sum'] < $min_price ? $row['sum'] : $min_price;
$max_price = $row['sum'] > $max_price ? $row['sum'] : $max_price;
$min_tic = $row['tic'] < $min_tic ? $row['tic'] : $min_tic;
$max_tic = $row['tic'] > $max_tic ? $row['tic'] : $max_tic;
$min_pr = $row['pr'] < $min_pr ? $row['pr'] : $min_pr;
$max_pr = $row['pr'] > $max_pr ? $row['pr'] : $max_pr;
$stats = json_decode($row['stats'], true);
if (isset($stats[$curr_date]))
{
$min_hits = $stats[$curr_date]['view'] < $min_hits ? $stats[$curr_date]['view'] : $min_hits;
$max_hits = $stats[$curr_date]['view'] > $max_hits ? $stats[$curr_date]['view'] : $max_hits;
$min_hosts = $stats[$curr_date]['user'] < $min_hosts ? $stats[$curr_date]['user'] : $min_hosts;
$max_hosts = $stats[$curr_date]['user'] > $max_hosts ? $stats[$curr_date]['user'] : $max_hosts;
}
}
}
if (isset($_POST['selected_topics']))
{
$topic = $_POST['selected_topics'];
}
else if (isset($_POST['hidden_topics']))
{
$topic = explode(",", $_POST['hidden_topics']);
}
else
{
$topic = array(0 => 'All');
}
$url = isset($_POST['url']) ? filter_var($_POST['url'], FILTER_VALIDATE_URL) : '';
$size = isset($_POST['size']) ? filter_var($_POST['size'], FILTER_SANITIZE_STRING) : '468x60';
$weeks = isset($_POST['weeks']) ? (int)$_POST['weeks'] : 1;
$name_file = isset($_POST['img']) ? filter_var($_POST['img'], FILTER_SANITIZE_STRING) : '';
if (!empty($_FILES['file']['name']))
{
if($_FILES['file']['type']=='image/jpeg' || $_FILES['file']['type']=='image/png' || $_FILES['file']['type']=='image/gif')
{
if (is_uploaded_file($_FILES["file"]["tmp_name"]))
{
if ($_FILES["file"]["size"] < 300*1024)
{
$data_img = getimagesize($_FILES['file']['tmp_name']);
$type_img = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
$name_file = md5($_FILES['file']['name'].session_id().HASH_MD5).'.'.$type_img[$data_img[2]];
$new_image = BASE_DIR.'/uploads/'.md5($_FILES['file']['name'].session_id().HASH_MD5).'.'.$type_img[$data_img[2]];
move_uploaded_file($_FILES["file"]["tmp_name"], $new_image);
}
else
{
exit(header('Location: /advertise.php?mode=banners'));
}
}
else
{
exit(header('Location: /advertise.php?mode=banners'));
}
}
else
{
exit(header('Location: /advertise.php?mode=banners'));
}
}
$img = isset($_POST['img']) ? filter_var($_POST['img'], FILTER_SANITIZE_STRING) : $name_file;
$price = isset($_POST['price']) ? explode(';', filter_var($_POST['price'], FILTER_SANITIZE_STRING)) : array('0' => $min_price, '1' => $max_price);
$hits = isset($_POST['hits']) ? explode(';', filter_var($_POST['hits'], FILTER_SANITIZE_STRING)) : array('0' => $min_hits, '1' => $max_hits);
$hosts = isset($_POST['hosts']) ? explode(';', filter_var($_POST['hosts'], FILTER_SANITIZE_STRING)) : array('0' => $min_hosts, '1' => $max_hosts);
$tic = isset($_POST['tic']) ? explode(';', filter_var($_POST['tic'], FILTER_SANITIZE_STRING)) : array('0' => $min_tic, '1' => $max_tic);
$pr = isset($_POST['pr']) ? explode(';', filter_var($_POST['pr'], FILTER_SANITIZE_STRING)) : array('0' => $min_pr, '1' => $max_pr);
?>
<div class="wrapper">
<link rel="stylesheet" href="css/jslider.css" type="text/css">
<link rel="stylesheet" href="css/jslider.blue.css" type="text/css">
<link rel="stylesheet" href="css/jslider.plastic.css" type="text/css">
<link rel="stylesheet" href="css/jslider.round.css" type="text/css">
<link rel="stylesheet" href="css/jslider.round.plastic.css" type="text/css">
<script type="text/javascript" src="js/jshashtable-2.1_src.js"></script>
<script type="text/javascript" src="js/jquery.numberformatter-1.2.3.js"></script>
<script type="text/javascript" src="js/tmpl.js"></script>
<script type="text/javascript" src="js/jquery.dependClass-0.1.js"></script>
<script type="text/javascript" src="js/draggable-0.1.js"></script>
<script type="text/javascript" src="js/jquery.slider.js"></script>
<div class="main">
<div class="m_left">
<div class="mw-ban">
<img src="/img/m_close.png" class="m_close">Не смогли разобраться? Остались вопросы? Изучите <a href="info.php?mode=mb">краткий курс</a> по массовой покупке баннеров!
</div>
<div class="m_title"><a href="advertise.php?mode=links" onclick="clearselection();">Купить ссылки</a> | Купить баннеры</div>
<div class="m_l" style="text-align: justify;">В системе зарегистировано <b><?php echo $count; ?></b> <?php echo getWord($count, array('активное баннерное место', 'активных баннерных места', 'активных баннерных мест')); ?>. Воспользуйтесь поиском для подбора наиболее подходящих:</div>
<script>
var prevurl = "<?php echo $url; ?>";
var previmg = "<?php echo $name_file; ?>";
var prevsize = "<?php echo $size; ?>";
var prevweeks = "<?php echo $weeks; ?>";
</script>
<form name="form1" method="post" action="" enctype="multipart/form-data" onsubmit="return validate1();">
<div class="m_l">
<div class="m_name">Тематика:</div>
<div class="m_pole">
<select id="cat" name="selected_topics[]" style="width:514px; height:auto;" multiple="multiple" size="8">
<option value="All" <?php echo $selected = in_array('All', $topic) ? 'selected' : ''; ?>>Все тематики</option>
<?php
foreach ($obEngine->getConfig('topic') as $key => $val)
{
$selected = in_array($key, $topic) ? 'selected' : '';
?>
<option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Цена за неделю:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider1" type="slider" name="price" value="<?php echo $price[0]; ?>;<?php echo $price[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider1").slider({ from: 0, to: 5000, heterogeneity: ["17.5/10","34/50","50/100","66.6/500","83.7/1000"], scale: ["|", 10, 50, 100, 500, 1000, "|"], limits: false, step: 1, dimension: " руб.", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Показы:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider2" type="slider" name="hits" value="<?php echo $hits[0]; ?>;<?php echo $hits[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider2").slider({ from: 0, to: <?php echo $hits[1]; ?>, heterogeneity: ["12.5/500", "37.5/5000", "62.5/20000", "87.5/60000" ], scale: ["|", 500, "|", 5000, "|", 20000, "|", 60000,"|"], limits: false, step: 10, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Посетители:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider3" type="slider" name="hosts" value="<?php echo $hosts[0]; ?>;<?php echo $hosts[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider3").slider({ from: 0, to: <?php echo $hosts[1]; ?>, heterogeneity: ["12.5/100", "37.5/1000", "62.5/4000", "87.5/10000" ], scale: ["|", 100, "|", 1000, "|", 4000, "|", 10000,"|"], limits: false, step: 10, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Яндекс тИЦ:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider4" type="slider" name="tic" value="<?php echo $tic[0]; ?>;<?php echo $tic[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider4").slider({ from: 0, to: <?php echo $tic[1]; ?>, heterogeneity: ["12.5/320", "37.5/970", "62.5/1610", "87.5/2260" ], scale: ["|", 320, "|", 970, "|", 1610, "|", 2260,"|"], limits: false, step: 10, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Google PR:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider5" type="slider" name="pr" value="<?php echo $pr[0]; ?>;<?php echo $pr[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider5").slider({ from: 0, to: 10, heterogeneity: [], scale: ["|", 1, "|", 3, "|", 5, "|", 7, "|", 9, "|"], limits: false, step: 1, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="130px;"><b>Размер баннера:</b></td>
<td width="234px;">
<select name="size" class="size" style="width:150px;" id="size">
<option value="468x60" <?php echo $select = $size == '468x60' ? 'selected' : ''; ?>>468 x 60</option>
<option value="1000x90" <?php echo $select = $size == '1000x90' ? 'selected' : ''; ?>>1000 x 90</option>
<option value="728x90" <?php echo $select = $size == '728x90' ? 'selected' : ''; ?>>728 x 90</option>
<option value="600x90" <?php echo $select = $size == '600x90' ? 'selected' : ''; ?>>600 x 90</option>
<option value="300x250" <?php echo $select = $size == '300x250' ? 'selected' : ''; ?>>300 x 250</option>
<option value="250x250" <?php echo $select = $size == '250x250' ? 'selected' : ''; ?>>250 x 250</option>
<option value="240x400" <?php echo $select = $size == '240x240' ? 'selected' : ''; ?>>240 x 400</option>
<option value="234x60" <?php echo $select = $size == '234x60' ? 'selected' : ''; ?>>234 x 60</option>
<option value="200x300" <?php echo $select = $size == '200x300' ? 'selected' : ''; ?>>200 x 300</option>
<option value="200x200" <?php echo $select = $size == '200x200' ? 'selected' : ''; ?>>200 x 200</option>
<option value="160x600" <?php echo $select = $size == '160x160' ? 'selected' : ''; ?>>160 x 600</option>
<option value="150x150" <?php echo $select = $size == '150x150' ? 'selected' : ''; ?>>150 x 150</option>
<option value="125x125" <?php echo $select = $size == '125x125' ? 'selected' : ''; ?>>125 x 125</option>
<option value="120x600" <?php echo $select = $size == '120x600' ? 'selected' : ''; ?>>120 x 600</option>
<option value="100x100" <?php echo $select = $size == '100x100' ? 'selected' : ''; ?>>100 x 100</option>
<option value="88x31" <?php echo $select = $size == '88x31' ? 'selected' : ''; ?>>88 x 31</option>
</select>
</td>
<td width="130px;"><b>Срок размещения:</b></td>
<td>
<select name="weeks" style="width:150px" id="weeks">
<option value="1" <?php echo $select = $weeks == 1 ? 'selected' : ''; ?>>1 неделя</option>
<option value="2" <?php echo $select = $weeks == 2 ? 'selected' : ''; ?>>2 недели</option>
<option value="3" <?php echo $select = $weeks == 3 ? 'selected' : ''; ?>>3 недели</option>
<option value="4" <?php echo $select = $weeks == 4 ? 'selected' : ''; ?>>4 недели</option>
</select>
</td>
</tr>
</table>
</div>
<div class="m_l">
<div class="m_name">Адрес ссылки: </div>
<div class="m_pole"><input type="text" id="url" name="url" placeholder="http://website.ru" class="tt" maxlength="255" value="<?php echo $url; ?>"></div>
</div>
<div class="m_l">
<div class="m_name">Файл баннера: </div>
<div style="display: inline-block; position: relative; overflow: hidden; width: 514px; margin-left:10px;">
<div id="upload" style="width: 434px; height: 22px; border: 1px solid #a9a9a9; border-right:none; background:#fff; float: left;line-height:20px;text-align:center;"><?php echo $ufn = $name_file ? 'http://'.$_SERVER['HTTP_HOST'].'/uploads/'.$name_file : 'Выберите баннер с вашего компьютера (468 x 60 пикселей)'; ?></div>
<button style="position: absolute;right:0; width:86px;text-align:center;">Обзор..</button>
<input style="position: absolute; top: 0px; right: 0px; width: 100%; height: 100%; opacity: 0; margin: 0px; padding:0px;cursor:pointer;" type="file" name="file" id="file" >
<?php
if ($img)
{
?>
<input type="hidden" name="img" id="img" value="<?php echo $img; ?>">
<?php
}
?>
</div>
</div>
<div class="m_left"><input type="hidden" name="type" value="search"></div>
<div class="m_l"><button style="float:right;width:86px;text-align:center;">Найти</button></div>
</form>
<?php
if (isset($_POST['type']) && $_POST['type'] == 'search')
{
$w_topic = '';
foreach($topic as $key => $value)
{
if ($value == 'All') { break; }
if ($w_topic) { $w_topic .= ' || '; }
$w_topic .= "`topic` = '".(int)$value."'";
}
if ($w_topic) { $w_topic = 'and ('.$w_topic.')'; }
$query = $mysqli->query("SELECT `id` FROM `".PREFIX."_blocks` WHERE `type` = '2' and `size` = '".$size."' and `sum` >= '".(int)$price[0]."' and `sum` <= '".(int)$price[1]."' and `tic` >= '".(int)$tic[0]."' and `tic` <= '".(int)$tic[1]."' and `pr` >= '".(int)$pr[0]."' and `pr` <= '".(int)$pr[1]."' ".$w_topic."");
$total = $query->num_rows;
$perpage = 100;
if (empty($_POST['page']) || ($_POST['page'] <= 0))
{
$page = 1;
}
else
{
$page = (int)$_POST['page'];
}
$pages_count = ceil($total / $perpage);
if ($page > $pages_count) $page = $pages_count;
$start_pos = ($page - 1) * $perpage;
if ($start_pos < 0) $start_pos = 0;
$query = $mysqli->query("SELECT * FROM `".PREFIX."_blocks` WHERE `type` = '2' and `size` = '".$size."' and `sum` >= '".(int)$price[0]."' and `sum` <= '".(int)$price[1]."' and `tic` >= '".(int)$tic[0]."' and `tic` <= '".(int)$tic[1]."' and `pr` >= '".(int)$pr[0]."' and `pr` <= '".(int)$pr[1]."' ".$w_topic." LIMIT ".$start_pos.", ".$perpage."");
if ($query->num_rows)
{
?>
<table width="600" align="left" border="0" cellspacing="0" cellpadding="0" class="m_table">
<tr>
<td class="a_title"><input type="checkbox" name="selectall" id="sa<?php echo $page; ?>" price="0" style="padding:0; margin:0; margin-left:0;" onclick="selectall();"></td>
<td class="a_title">Адрес сайта</td>
<td class="a_title">тИЦ</td>
<td class="a_title">PR</td>
<td class="a_title">Хиты</td>
<td class="a_title">Хосты</td>
<td class="a_title">Места</td>
<td class="a_title">Цена</td>
<td class="a_title"></td>
</tr>
<?php
while($row = $query->fetch_assoc())
{
$stats = json_decode($row['stats'], true);
$count_free_place = $mysqli->query("SELECT `id` FROM `".PREFIX."_banners` WHERE `ident` = '".$row['id']."' and `status` = '1'")->num_rows;
if ($count_free_place >= $row['slots']) { continue; }
?>
<tr>
<td class="a_mid" ><input type="checkbox" name="multiselect" id="<?php echo $row['id']; ?>" price="<?php echo $row['sum']; ?>" weeks="<?php echo $weeks; ?>" class="checkbox" style="padding:0; margin:0; margin-left: 2px;"></td>
<td class="a_mid" ><div class="cut" style="width: 200px;"><div class="long_link" style="text-align: left;"><a href="<?php echo $row['url']; ?>" title="<?php echo $row['text']; ?>" target="_blank"><?php echo $row['url']; ?></a></div><div class="long_link_hidder hidder_white"> </div></div></td>
<td class="a_mid" ><?php echo $row['tic']; ?></td>
<td class="a_mid" ><?php echo $row['pr']; ?></td>
<td class="a_mid" ><?php echo $s_hits = isset($stats[$curr_date]['view']) ? $stats[$curr_date]['view'] : 0; ?></td>
<td class="a_mid" ><?php echo $s_hosts = isset($stats[$curr_date]['user']) ? $stats[$curr_date]['user'] : 0; ?></td>
<td class="a_mid" ><?php echo $count_free_place; ?>/<?php echo $row['slots']; ?></td>
<td class="a_mid" ><?php echo $row['sum'] * $weeks; ?> руб.</td>
<td class="a_mid" >
<form method="post" action="banner.php?mode=preview&id=<?php echo $row['id']; ?>">
<input type="hidden" name="url" value="<?php echo $url; ?>">
<input type="hidden" name="img" value="<?php echo $img; ?>">
<input type="hidden" name="weeks" value="<?php echo $weeks; ?>">
<input type="submit" title="Перейти к оплате" class="cart" value="">
</form>
</td>
</tr>
<?php
}
?>
</table>
<?php
if ($total >= $perpage)
{
printPageNavBanner($page, $pages_count, $total, $perpage);
}
}
}
?>
</div>
<?php include 'module/user_menu.php'; ?>
</div>
</div>
<?php
$multiprice = isset($_POST['multiprice']) ? (int)$_POST['multiprice'] : 0;
$multiid = isset($_POST['multiid']) ? filter_var($_POST['multiid'], FILTER_SANITIZE_STRING) : '';
$selectallid = isset($_POST['selectallid']) ? filter_var($_POST['selectallid'], FILTER_SANITIZE_STRING) : '';
?>
<script type="text/javascript">
var multiprice = "<?php echo $multiprice; ?>";
var multiid = "<?php echo $multiid; ?>";
var selectallid = "<?php echo $selectallid; ?>";
var upload = false;
function loadselection()
{
if (multiid == null)
return;
if (selectallid == null)
return;
var temp = multiid.split('_');
for (var i in temp)
$('#'+temp[i]).prop("checked", true);
var temp = selectallid.split('_');
for (var i in temp)
$('#'+temp[i]).prop("checked", true);
}
function clearselection()
{
multiprice = 0;
multiid = null;
selectallid = null;
}
function saveselection()
{
$("input:checkbox").each(function()
{
var name= this.getAttribute('name');
var id = this.getAttribute('id');
var price = this.getAttribute('price');
var weeks = this.getAttribute('weeks');
if (this.checked && name == 'multiselect')
{
multiprice = parseFloat(multiprice) + parseFloat(price) * parseFloat(weeks);
multiid = multiid + id + '_';
}
else if (name == 'multiselect')
{
multiprice = parseFloat(multiprice) - parseFloat(price) * parseFloat(weeks);
multiid = multiid.replace(id + '_', '');
}
if (this.checked && name == 'selectall')
selectallid = selectallid + id + '_';
else if (name == 'selectall')
selectallid = selectallid.replace(id + '_', '');
});
}
$(".checkbox").change(function()
{
var name= this.getAttribute('name');
var id = this.getAttribute('id');
var price = this.getAttribute('price');
var weeks = this.getAttribute('weeks');
if (this.checked && name == 'multiselect')
{
multiprice = parseFloat(multiprice) + parseFloat(price) * parseFloat(weeks);
multiid = multiid + id + '_';
}
else if (name == 'multiselect')
{
multiprice = parseFloat(multiprice) - parseFloat(price) * parseFloat(weeks);
multiid = multiid.replace(id + '_', '');
}
showPrice();
});
function transfer()
{
$('input#multiprice').each(function(i)
{
$(this).attr('value', multiprice)
});
$('input#multiid').each(function(i)
{
$(this).attr('value', multiid)
});
$('input#selectallid').each(function(i)
{
$(this).attr('value', selectallid)
});
}
function showPrice ()
{
if (multiprice > 0)
{
$('.top_bar').css('display','block');
Num = multiid.match(/_/g).length + '';
preNum = Num.substr(-2, 1);
lastNum = Num.slice(-1);
if (Num.length == 1)
preNum = 0;
if (lastNum == '1' && preNum !== '1')
{
word1 = 'Выбрана ';
word2 = ' витрина ссылок';
}
else if ((lastNum == '2' || lastNum == '3' || lastNum == '4') && preNum !== '1')
{
word1 = 'Выбрано ';
word2 = ' витрины баннеров';
}
else
{
word1 = 'Выбрано ';
word2 = ' витрин баннеров';
}
$('#price').html(word1 + Num + word2 + ' на сумму ' + multiprice + ' руб. ');
$('#mform').attr('action', 'banner.php?mode=preview');
$("#img2").attr('value', $("#img").val());
$("#url2").attr('value', $("#url").val());
$("#weeks2").attr('value', $("#weeks").val());
$("#ids").attr('value', multiid);
}
else
$('.top_bar').css('display','none');
}
function selectall ()
{
var allCheckboxes = $(".checkbox");
var notChecked = allCheckboxes.not(':checked');
allCheckboxes.removeAttr('checked');
notChecked.attr('checked', 'checked');
saveselection();
showPrice ();
}
loadselection();
showPrice ();
function validate1 ( )
{
valid = true;
temp = $('#upload').text().toLowerCase();
if (temp.indexOf("<?php echo $_SERVER['HTTP_HOST'] ?>/uploads") >= 0)
$('#file').remove();
else
$('#img').remove();
if ((document.form1.url.value == "") && (upload == false))
{
alert ('Не заполнено поле «Адрес ссылки» и не выбран файл баннера');
valid = false;
}
if ((document.form1.url.value == "") && (valid == true))
{
alert ('Не заполнено поле «Адрес ссылки»');
valid = false;
}
if ((document.form1.url.value == "http://website.ru") && (valid == true))
{
alert ('Следует указать адрес рекламируемого сайта вместо «website.ru»');
valid = false;
}
if ((document.form1.url.value.indexOf('http://') == -1) && (document.form1.url.value.indexOf('https://') == -1) && (valid == true))
{
alert ('Адрес ссылки должен начинаться с «http://» или «https://»');
valid = false;
}
if ($('#img').length > 0)
upload = true;
else
progress = true;
if ((upload == false) && (valid == true))
{
alert ('Не выбран файл баннера');
valid = false;
}
if ((progress == true) && (valid == true))
{
$('#upload').text('Подождите, идет загрузка баннера');
$('#upload').addClass('progress');
}
return valid;
}
$('#premium').click(function()
{
if ( $("#premium").prop("checked"))
{
$('.m_color').show();
hide ();
}
else
{
$('.m_color').hide();
hide ();
}
});
if ($("#premium").prop("checked"))
$('.m_color').show();
$("#url").change(function ()
{
if (this.value !== prevurl)
hide ();
});
$("#img").change(function ()
{
if (this.value !== previmg)
hide ();
});
$("#size").change(function ()
{
$('#upload').text('Выберите файл с вашего компьютера (' + this.value + ' пикселей)');
if (this.value !== prevsize)
{
hide ();
}
});
$("#weeks").change(function ()
{
if (this.value !== prevweeks)
hide ();
});
$("#cat").change(function ()
{
hide ();
});
var hidden = 0;
function hide ()
{
if (hidden == 0)
{
hidden = 1;
$('.m_table').hide();
$('.top_bar').hide();
$('.page_selector').hide();
clearselection();
}
}
$('.m_close').click( function()
{
if ($.cookie('info'))
$.cookie('info', $.cookie('info')+'mb_', {expires: 365});
else
$.cookie('info', 'mb_', {expires: 365});
$('.mw-ban').fadeOut(400);
});
if ($.cookie('info'))
{
$.cookie('info', $.cookie('info'), {expires: 365});
if ($.cookie('info').indexOf('mb_') == -1)
$('.mw-ban').show();
}
else
$('.mw-ban').show();
var size = (300*1024);
$("#file").change(function ()
{
$.each(this.files, function(i, file)
{
// Отсеиваем не картинки
if (!file.type.match(/image.*/))
{
alert ('Файл не является изображением');
upload = false;
exit;
}
if (file.size > size)
{
alert ('Максимальный размер изображения ' + (size/1024) +'кб');
upload = false;
exit;
}
$('#upload').text(file.name);
$('#upload').attr('style','width: 434px; height: 22px; border: 1px solid #a9a9a9; border-right:none; background:#fff; float: left;line-height:20px;text-align:center;');
upload = true;
});
});
</script>
<?php
}
else
{
$query = $mysqli->query("SELECT * FROM `".PREFIX."_blocks` WHERE `type` = '1'");
$count = $query->num_rows;
$curr_date = date("Y-m-d", TIME - 86400);
$min_price = 1;
$max_price = 1;
$max_hits = 1;
$min_hits = 1;
$max_hosts = 1;
$min_hosts = 1;
$min_tic = 0;
$max_tic = 0;
$min_pr = 0;
$max_pr = 0;
$min_sumcolor = 1;
$max_sumcolor = 1;
if ($count)
{
while ($row = $query->fetch_assoc())
{
$min_price = $row['sum'] < $min_price ? $row['sum'] : $min_price;
$max_price = $row['sum'] > $max_price ? $row['sum'] : $max_price;
$min_tic = $row['tic'] < $min_tic ? $row['tic'] : $min_tic;
$max_tic = $row['tic'] > $max_tic ? $row['tic'] : $max_tic;
$min_pr = $row['pr'] < $min_pr ? $row['pr'] : $min_pr;
$max_pr = $row['pr'] > $max_pr ? $row['pr'] : $max_pr;
$min_sumcolor = $row['sumcolor'] < $min_sumcolor ? $row['sumcolor'] : $min_sumcolor;
$max_sumcolor = $row['sumcolor'] > $max_sumcolor ? $row['sumcolor'] : $max_sumcolor;
$stats = json_decode($row['stats'], true);
if (isset($stats[$curr_date]))
{
$min_hits = $stats[$curr_date]['view'] < $min_hits ? $stats[$curr_date]['view'] : $min_hits;
$max_hits = $stats[$curr_date]['view'] > $max_hits ? $stats[$curr_date]['view'] : $max_hits;
$min_hosts = $stats[$curr_date]['user'] < $min_hosts ? $stats[$curr_date]['user'] : $min_hosts;
$max_hosts = $stats[$curr_date]['user'] > $max_hosts ? $stats[$curr_date]['user'] : $max_hosts;
}
}
}
if (isset($_POST['selected_topics']))
{
$topic = $_POST['selected_topics'];
}
else if (isset($_POST['hidden_topics']))
{
$topic = explode(",", $_POST['hidden_topics']);
}
else
{
$topic = array(0 => 'All');
}
$url = isset($_POST['url']) ? filter_var($_POST['url'], FILTER_VALIDATE_URL) : '';
$text = isset($_POST['text']) ? filter_var($_POST['text'], FILTER_SANITIZE_STRING) : '';
$dlinlink = mb_strlen($text);
$color = isset($_POST['scolor']) && isValidColor($_POST['scolor']) ? $_POST['scolor'] : '';
$specc = isset($_POST['specc']) ? (int)$_POST['specc'] : '';
$price = isset($_POST['price']) ? explode(';', filter_var($_POST['price'], FILTER_SANITIZE_STRING)) : array('0' => $min_price, '1' => $max_price);
$hits = isset($_POST['hits']) ? explode(';', filter_var($_POST['hits'], FILTER_SANITIZE_STRING)) : array('0' => $min_hits, '1' => $max_hits);
$hosts = isset($_POST['hosts']) ? explode(';', filter_var($_POST['hosts'], FILTER_SANITIZE_STRING)) : array('0' => $min_hosts, '1' => $max_hosts);
$tic = isset($_POST['tic']) ? explode(';', filter_var($_POST['tic'], FILTER_SANITIZE_STRING)) : array('0' => $min_tic, '1' => $max_tic);
$pr = isset($_POST['pr']) ? explode(';', filter_var($_POST['pr'], FILTER_SANITIZE_STRING)) : array('0' => $min_pr, '1' => $max_pr);
?>
<div class="wrapper">
<link rel="stylesheet" href="css/jslider.css" type="text/css">
<link rel="stylesheet" href="css/jslider.blue.css" type="text/css">
<link rel="stylesheet" href="css/jslider.plastic.css" type="text/css">
<link rel="stylesheet" href="css/jslider.round.css" type="text/css">
<link rel="stylesheet" href="css/jslider.round.plastic.css" type="text/css">
<script type="text/javascript" src="js/jshashtable-2.1_src.js"></script>
<script type="text/javascript" src="js/jquery.numberformatter-1.2.3.js"></script>
<script type="text/javascript" src="js/tmpl.js"></script>
<script type="text/javascript" src="js/jquery.dependClass-0.1.js"></script>
<script type="text/javascript" src="js/draggable-0.1.js"></script>
<script type="text/javascript" src="js/jquery.slider.js"></script>
<div class="main">
<div class="m_left">
<div class="mw-lin"> <img src="/img/m_close.png" class="m_close">Не смогли разобраться? Остались вопросы? Изучите <a href="info.php?mode=ml">краткий курс</a> по массовой покупке ссылок!</div>
<div class="m_title">Купить ссылки | <a href="advertise.php?mode=banners" onclick="clearselection();">Купить баннеры</a></div>
<div class="m_l" style="text-align: justify;">
В системе <?php echo getWord($count, array('зарегистрирован', 'зарегистрировано', 'зарегистрировано')); ?> <b><?php echo $count; ?></b> <?php echo getWord($count, array('активный блок', 'активных блока', 'активных блоков')); ?> ссылок. Воспользуйтесь поиском для подбора наиболее подходящих:
</div>
<script>
var prevurl = "<?php echo $url; ?>";
var prevtext = "<?php echo $text; ?>";
var prevcolor = "<?php echo $color; ?>";
var specc = "<?php echo $specc; ?>";
</script>
<form name="form1" method="post" action="" onsubmit="return validate1();">
<div class="m_l">
<div class="m_name">Тематика:</div>
<div class="m_pole">
<select id="cat" name="selected_topics[]" style="width:514px; height:auto;" multiple="multiple" size="8">
<option value="All" <?php echo $selected = in_array('All', $topic) ? 'selected' : ''; ?>>Все тематики</option>
<?php
foreach ($obEngine->getConfig('topic') as $key => $val)
{
$selected = in_array($key, $topic) ? 'selected' : '';
?>
<option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Цена:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider1" type="slider" name="price" value="<?php echo $price[0]; ?>;<?php echo $price[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
<?php
?>
jQuery("#slider1").slider({ from: 1, to: 500, heterogeneity: ["17.5/5","34/10","50/25","66.6/50","83.7/100"], scale: ["|", 5, 10, 25, 50, 100, "|"], limits: false, step: 1, dimension: " руб.", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Показы:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider2" type="slider" name="hits" value="<?php echo $hits[0]; ?>;<?php echo $hits[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider2").slider({ from: <?php echo $min_count = $hits[0] < 10 ? $hits[0] : 10; ?>, to: <?php echo $hits[1]; ?>, heterogeneity: ["12.5/300", "37.5/3000", "62.5/10000", "87.5/40000" ], scale: ["|", 300, "|", 3000, "|", 10000, "|", 40000,"|"], limits: false, step: <?php echo $min_count; ?>, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Посетители:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider3" type="slider" name="hosts" value="<?php echo $hosts[0]; ?>;<?php echo $hosts[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider3").slider({ from: <?php echo $min_count = $hosts[0] < 10 ? $hosts[0] : 10; ?>, to: <?php echo $hosts[1]; ?>, heterogeneity: ["12.5/90", "37.5/900", "62.5/4000", "87.5/10000" ], scale: ["|", 90, "|", 900, "|", 4000, "|", 10000,"|"], limits: false, step: <?php echo $min_count; ?>, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Яндекс тИЦ:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider4" type="slider" name="tic" value="<?php echo $tic[0]; ?>;<?php echo $tic[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider4").slider({ from: <?php echo $tic[0]; ?>, to: <?php echo $tic[1]; ?>, heterogeneity: ["12.5/260", "37.5/770", "62.5/1280", "87.5/1790" ], scale: ["|", 260, "|", 770, "|", 1280, "|", 1790,"|"], limits: false, step: 10, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l" style="padding-top: 10px;">
<div class="m_name">Google PR:</div>
<div class="m_pole">
<div class="layout-slider"><input id="slider5" type="slider" name="pr" value="<?php echo $pr[0]; ?>;<?php echo $pr[1]; ?>" /></div>
<script type="text/javascript" charset="utf-8">
jQuery("#slider5").slider({ from: 0, to: 10, heterogeneity: [], scale: ["|", 1, "|", 3, "|", 5, "|", 7, "|", 9, "|"], limits: false, step: 1, dimension: " ", skin: "round_plastic" });
</script>
</div>
</div>
<div class="m_l">
<div class="m_name">Адрес ссылки: </div>
<div class="m_pole"><input type="text" id="url" name="url" placeholder="http://website.ru" class="tt" maxlength="255" value="<?php echo $url; ?>"></div>
</div>
<div class="m_l">
<div class="m_name">Текст ссылки: </div>
<div class="m_pole"><input type="text" id="text" name="text" placeholder="Пример рекламной ссылки" class="tt" maxlength="500" value="<?php echo $text; ?>"></div>
</div>
<div class="m_l">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="444" height="24"><label><span><b>Выделить ссылку другим цветом</b></span> (+<span style="color: red;"><b><?php echo $min_sumcolor; ?>-<?php echo $max_sumcolor; ?></b> руб.</span>): </label><input id="premium" type="checkbox" <?php echo $check = $specc == 1 ? 'checked' : ''; ?> value="1" name="specc"></td>
<td width="50"><span class="premium"><b>Цвет:</b></span></td>
<td>
<select class="premium" size="1" name="scolor" id="color" style="width:150px;">
<option value="red" <?php echo $select = $color == 'red' ? 'selected' : ''; ?> style="color:red;">Красный</option>
<option value="green" <?php echo $select = $color == 'green' ? 'selected' : ''; ?> style="color: green;">Зеленый</option>
<option value="blue" <?php echo $select = $color == 'blue' ? 'selected' : ''; ?> style="color:blue;">Синий</option>
<option value="orange" <?php echo $select = $color == 'orange' ? 'selected' : ''; ?> style="color:orange;">Оранжевый</option>
<option value="random" <?php echo $select = $color == 'random' ? 'selected' : ''; ?> style="color:black;">Случайно</option>
</select>
</td>
</tr>
</table>
</div>
<div class="m_left"><input type="hidden" name="type" value="search"></div>
<div class="m_l"><button style="float:right;">Найти</button></div>
</form>
<?php
if (isset($_POST['type']) && $_POST['type'] == 'search')
{
$w_topic = '';
foreach($topic as $key => $value)
{
if ($value == 'All') { break; }
if ($w_topic) { $w_topic .= ' || '; }
$w_topic .= "`topic` = '".(int)$value."'";
}
if ($w_topic) { $w_topic = 'and ('.$w_topic.')'; }
$w_color = $specc == 1 && $color != 'random' && isValidColor($color) ? "and `".$color."` = '1'" : '';
$query = $mysqli->query("SELECT `id` FROM `".PREFIX."_blocks` WHERE `type` = '1' and `dlinlink` >= '".(int)$dlinlink."' and `sum` >= '".(int)$price[0]."' and `sum` <= '".(int)$price[1]."' and `tic` >= '".(int)$tic[0]."' and `tic` <= '".(int)$tic[1]."' and `pr` >= '".(int)$pr[0]."' and `pr` <= '".(int)$pr[1]."' ".$w_topic." ".$w_color."");
$total = $query->num_rows;
$perpage = 100;
if (empty($_POST['page']) || ($_POST['page'] <= 0))
{
$page = 1;
}
else
{
$page = (int)$_POST['page'];
}
$pages_count = ceil($total / $perpage);
if ($page > $pages_count) $page = $pages_count;
$start_pos = ($page - 1) * $perpage;
if ($start_pos < 0) $start_pos = 0;
$query = $mysqli->query("SELECT * FROM `".PREFIX."_blocks` WHERE `type` = '1' and `dlinlink` >= '".(int)$dlinlink."' and `sum` >= '".(int)$price[0]."' and `sum` <= '".(int)$price[1]."' and `tic` >= '".(int)$tic[0]."' and `tic` <= '".(int)$tic[1]."' and `pr` >= '".(int)$pr[0]."' and `pr` <= '".(int)$pr[1]."' ".$w_topic." ".$w_color." LIMIT ".$start_pos.", ".$perpage."");
if ($query->num_rows)
{
?>
<table width="600" align="left" border="0" cellspacing="0" cellpadding="0" class="m_table">
<tr>
<td class="a_title"><input type="checkbox" name="selectall" id="sa<?php echo $page; ?>" price="0" style="padding:0; margin:0; margin-left:0;" onclick="selectall();"></td>
<td class="a_title">Адрес сайта</td>
<td class="a_title">тИЦ</td>
<td class="a_title">PR</td>
<td class="a_title">Хиты</td>
<td class="a_title">Хосты</td>
<td class="a_title">Цена</td>
<td class="a_title"></td>
</tr>
<?php
while($row = $query->fetch_assoc())
{
$stats = json_decode($row['stats'], true);
?>
<tr>
<td class="a_mid" ><input type="checkbox" name="multiselect" id="<?php echo $row['id']; ?>" price="<?php echo $row['sum']; ?>" premium="<?php echo $row['sumcolor']; ?>" class="checkbox" style="padding:0; margin:0; margin-left: 2px;"></td>
<td class="a_mid" ><div class="cut" style="width: 200px;"><div class="long_link" style="text-align: left;"><a href="<?php echo $row['url']; ?>" title="<?php echo $row['text']; ?>" target="_blank"><?php echo $row['url']; ?></a></div><div class="long_link_hidder hidder_white"> </div></div></td>
<td class="a_mid" ><?php echo $row['tic']; ?></td>
<td class="a_mid" ><?php echo $row['pr']; ?></td>
<td class="a_mid" ><?php echo $s_hits = isset($stats[$curr_date]['view']) ? $stats[$curr_date]['view'] : 0; ?></td>
<td class="a_mid" ><?php echo $s_hosts = isset($stats[$curr_date]['user']) ? $stats[$curr_date]['user'] : 0; ?></td>
<td class="a_mid" ><?php echo $price_sum = $specc ? $row['sum'] + $row['sumcolor'] : $row['sum']; ?> руб.</td>
<td class="a_mid" >
<form method="post" action="link.php?mode=preview&id=<?php echo $row['id']; ?>">
<input type="hidden" name="url" value="<?php echo $url; ?>">
<input type="hidden" name="text" value="<?php echo $text; ?>">
<input type="hidden" name="specc" value="<?php echo $specc; ?>">
<input type="hidden" name="scolor" value="<?php echo $color; ?>">
<input type="submit" title="Перейти к оплате" class="cart" value="">
</form>
</td>
</tr>
<?php
}
?>
</table>
<?php
if ($total >= $perpage)
{
printPageNavLink($page, $pages_count, $total, $perpage);
}
}
}
?>
</div>
<?php include 'module/user_menu.php'; ?>
</div>
</div>
<?php
$multiprice = isset($_POST['multiprice']) ? (int)$_POST['multiprice'] : 0;
$multiid = @filter_var($_POST['multiid'], FILTER_SANITIZE_STRING);
$selectallid = @filter_var($_POST['selectallid'], FILTER_SANITIZE_STRING);
?>
<script>
var multiprice = "<?php echo $multiprice; ?>";
var multiid = "<?php echo $multiid; ?>";
var selectallid = "<?php echo $selectallid; ?>";
function loadselection()
{
if (multiid == null)
return;
if (selectallid == null)
return;
var temp = multiid.split('_');
for (var i in temp)
$('#'+temp[i]).prop("checked", true);
var temp = selectallid.split('_');
for (var i in temp)
$('#'+temp[i]).prop("checked", true);
}
function clearselection()
{
multiprice = 0;
multiid = "";
selectallid = "";
}
function saveselection()
{
$("input:checkbox").each(function()
{
var name= this.getAttribute('name');
var id = this.getAttribute('id');
var price = this.getAttribute('price');
var premium = this.getAttribute('premium');
if (specc == 0)
premium = 0;
if (this.checked && name == 'multiselect')
{
multiprice = parseFloat(multiprice) + parseFloat(price) + parseFloat(premium);
multiid = multiid + id + '_';
}
else if (name == 'multiselect')
{
multiprice = parseFloat(multiprice) - parseFloat(price) - parseFloat(premium);
multiid = multiid.replace(id + '_', '');
}
if (this.checked && name == 'selectall')
selectallid = selectallid + id + '_';
else if (name == 'selectall')
selectallid = selectallid.replace(id + '_', '');
});
}
$(".checkbox").change(function()
{
var name= this.getAttribute('name');
var id = this.getAttribute('id');
var price = this.getAttribute('price');
var premium = this.getAttribute('premium');
if (specc == 0)
premium = 0;
if (this.checked && name == 'multiselect')
{
multiprice = parseFloat(multiprice) + parseFloat(price) + parseFloat(premium);
multiid = multiid + id + '_';
}
else if (name == 'multiselect')
{
multiprice = parseFloat(multiprice) - parseFloat(price) - parseFloat(premium);
multiid = multiid.replace(id + '_', '');
}
showPrice();
});
function transfer()
{
$('input#multiprice').each(function(i)
{
$(this).attr('value', multiprice)
});
$('input#multiid').each(function(i)
{
$(this).attr('value', multiid)
});
$('input#selectallid').each(function(i)
{
$(this).attr('value', selectallid)
});
}
function showPrice ()
{
if (multiprice > 0)
{
$('.top_bar').css('display','block');
linNum = multiid.match(/_/g).length + '';
preNum = linNum.substr(-2, 1);
lastNum = linNum.slice(-1);
if (linNum.length == 1)
preNum = 0;
if (lastNum == '1' && preNum !== '1')
{
word1 = 'Выбрана ';
word2 = ' витрина ссылок';
}
else if ((lastNum == '2' || lastNum == '3' || lastNum == '4') && preNum !== '1')
{
word1 = 'Выбрано ';
word2 = ' витрины ссылок';
}
else
{
word1 = 'Выбрано ';
word2 = ' витрин ссылок';
}
$('#price').html(word1 + linNum + word2 + ' на сумму ' + multiprice + ' руб. ');
$('#mform').attr('action', 'link.php?mode=preview');
$("#text2").attr('value', $("#text").val());
$("#url2").attr('value', $("#url").val());
$("#ids").attr('value', multiid);
$("#scolor").attr('value', $("#color").val());
$("#specc").attr('value', specc);
}
else
$('.top_bar').css('display','none');
}
function selectall ()
{
var allCheckboxes = $(".checkbox");
var notChecked = allCheckboxes.not(':checked');
allCheckboxes.removeAttr('checked');
notChecked.attr('checked', 'checked');
saveselection();
showPrice ();
}
loadselection();
showPrice ();
function validate1 ( )
{
valid = true;
if ((document.form1.url.value == "") && (document.form1.text.value == ""))
{
alert ('Не заполнены поля «Адрес ссылки» и «Текст ссылки»');
valid = false;
}
if ((document.form1.url.value == "") && (valid == true))
{
alert ('Не заполнено поле «Адрес ссылки»');
valid = false;
}
if ((document.form1.url.value == "http://website.ru") && (valid == true))
{
alert ('Следует указать адрес рекламируемого сайта вместо «website.ru»');
valid = false;
}
if (((document.form1.url.value.toLowerCase().indexOf('http://') == -1) && (document.form1.url.value.toLowerCase().indexOf('https://') == -1)) && (valid == true))
{
alert ('Адрес ссылки должен начинаться с «http://» или «https://»');
valid = false;
}
if ((document.form1.text.value == "") && (valid == true))
{
alert ('Не заполнено поле «Текст ссылки»');
valid = false;
}
return valid;
}
$('#premium').click(function()
{
if ( $("#premium").prop("checked"))
{
$('.premium').show();
hide ();
}
else
{
$('.premium').hide();
hide ();
}
});
if ($("#premium").prop("checked"))
$('.premium').show();
$("#url").keyup(function ()
{
if (this.value !== prevurl)
hide ();
});
$("#text").keyup(function ()
{
if (this.value !== prevtext)
hide ();
});
$("#color").change(function ()
{
if (this.value !== prevcolor)
hide ();
});
$("#cat").change(function ()
{
hide ();
});
var hidden = 0;
function hide ()
{
if (hidden == 0)
{
hidden = 1;
$('.m_table').hide();
$('.top_bar').hide();
$('.page_selector').hide();
clearselection();
}
}
$('.m_close').click( function()
{
if ($.cookie('info'))
$.cookie('info', $.cookie('info')+'ml_', {expires: 365});
else
$.cookie('info', 'ml_', {expires: 365});
$('.mw-lin').fadeOut(400);
});
if ($.cookie('info'))
{
$.cookie('info', $.cookie('info'), {expires: 365});
if ($.cookie('info').indexOf('ml_') == -1)
$('.mw-lin').show();
}
else
$('.mw-lin').show();
</script>
<?php
}