Файл: system/inc/balance.php
Строк: 686
<?php
/*
=====================================================
DLE BALANCE 1.0
-----------------------------------------------------
Copyright (c) 2009 SOFTER
=====================================================
Данный код защищен авторскими правами
=====================================================
*/
if(!defined('MOZG'))
die('Hacking attempt!');
$action = $_REQUEST['action'];
require_once ENGINE_DIR.'/data/bal_conf.php';
function opentable() {
echo <<<HTML
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
HTML;
}
function closetable() {
echo <<<HTML
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
HTML;
}
function tableheader($value) {
echo <<<HTML
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$value}</div></td>
</tr>
</table>
HTML;
unterline();
}
function unterline()
{
echo <<<HTML
<div class="unterline"></div>
HTML;
}
function rows ($mode) {
if($mode == 1) {
echo '<table width="100%">';
}elseif($mode==0){
echo '</table>';
}
}
function showRow($title="", $description="", $field="")
{
echo"<tr>
<td style="padding:4px" class="option">
<b>$title</b><br /><span class=small>$description</span>
<td width=394 align=middle >
$field
</tr><tr><td background="engine/skins/images/mline.gif" height=1 colspan=2></td></tr>";
$bg = ""; $i++;
}
function makeDropDown($options, $name, $selected)
{
$output = "<select name="$name">rn";
foreach($options as $value=>$description)
{
$output .= "<option value="$value"";
if($selected == $value){ $output .= " selected "; }
$output .= ">$description</option>n";
}
$output .= "</select>";
return $output;
}
if($action == "" OR $action == "main") {
echoheader("","");
opentable();
tableheader("Настройка модуля DLE BALANCE");
rows(1);
echo <<<HTML
<table width="100%">
<tbody>
<tr>
<td width="30%">
<div class="quick">
<a href="$PHP_SELF?mod=balance&action=config"><img src="engine/skins/images/general.png" align="left" border="0"><h3>Конфигурация</h3>Настройка системы.</a>
</div>
</td>
<td width="30%">
<div class="quick">
<a href="$PHP_SELF?mod=balance&action=info"><img src="engine/skins/images/spset.png" align="left" border="0"><h3>Инфо</h3>Инфрмация о DLE BALANCE</a>
</div>
</td>
<td width="30%">
<div class="quick">
<a href="$PHP_SELF?mod=balance&action=banner"><img src="engine/skins/images/ads.png" align="left" border="0"><h3>Баннер</h3>Управление баннерными местами</a>
</div>
</td>
HTML;
rows(0);
closetable();
opentable();
tableheader("Информация о модуле");
echo <<<HTML
<table align="center" width="100%"><tbody><tr><td style="border: 1px dashed rgb(190, 190, 190); padding: 3px;" class="main">
<table width="100%" border="0" cellspacing="3">
<tr>
<td>Модуль</td>
<td><b>DLE BALANCE</b></td>
</tr>
<tr>
<td>Автор</td>
<td><b>SOFTER</b> aka ALWEX</td>
</tr>
<tr>
<td>Версия</td>
<td>1.0</td>
</tr>
<tr>
<td>Цена</td>
<td>35$</td>
</tr>
</table>
</td></tr><tr><td> </td></tr></tbody></table>
HTML;
closetable();
echofooter();
closetable();
}
elseif($action == "config") {
require_once ENGINE_DIR.'/data/bal_conf.php';
echo <<<HTML
<script language='JavaScript' type="text/javascript">
function ChangeOption(selectedOption) {
document.getElementById('general').style.display = "none";
document.getElementById('group').style.display = "none";
document.getElementById('banner').style.display = "none";
document.getElementById('robokassa').style.display = "none";
if(selectedOption == 'general') {document.getElementById('general').style.display = "";}
if(selectedOption == 'group') {document.getElementById('group').style.display = "";}
if(selectedOption == 'banner') {document.getElementById('banner').style.display = "";}
if(selectedOption == 'robokassa') {document.getElementById('robokassa').style.display = "";}
}
</script>
HTML;
echoheader("","");
opentable();
tableheader("Настройка DLE BALANCE");
echo <<<HTML
<table width="100%">
<tr>
<td style="padding:2px;">
<table style="text-align:center;" width="100%" height="35px">
<tr style="vertical-align:middle;" >
<td class=tableborder><a href="javascript:ChangeOption('general');"><img title="Основные настройки" src="engine/skins/images/general.png" border="0"></a>
<td class=tableborder><a href="javascript:ChangeOption('group');"><img title="Настройки перевода в группу" src="engine/skins/images/usersgroup.png" border="0"></a>
<td class=tableborder><a href="javascript:ChangeOption('robokassa');"><img title="Настройка Робокассы" src="engine/skins/images/balance.png" border="0"></a>
<td class=tableborder><a href="javascript:ChangeOption('banner');"><img title="Настройка Баннеров" src="engine/skins/images/folder.png" border="0"></a>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div>
HTML;
echo <<<HTML
<form action="" method="POST">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
HTML;
echo <<<HTML
<tr style='' id="general"><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Основные настройки</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
HTML;
showRow("Статус", "Включение/Выключение Снятия денег", makeDropDown(array("yes"=>"Включена","no"=>"Выключена"), "save_config[money_del]", "{$bal_conf['money_del']}", ""), "");
showRow("Статус", "Включение/Выключение Webmoney при снятии", makeDropDown(array("yes"=>"Включена","no"=>"Выключена"), "save_config[webm]", "{$bal_conf['webm']}", ""), "");
showRow("Статус", "Включение/Выключение Yandex.Money при снятии", makeDropDown(array("yes"=>"Включена","no"=>"Выключена"), "save_config[yanm]", "{$bal_conf['yanm']}", ""), "");
showRow("Статус", "Включение/Выключение PAYPAL при снятии", makeDropDown(array("yes"=>"Включена","no"=>"Выключена"), "save_config[payp]", "{$bal_conf['payp']}", ""), "");
showRow("Статус", "Включение/Выключение RBK.Money при снятии", makeDropDown(array("yes"=>"Включена","no"=>"Выключена"), "save_config[rbk]", "{$bal_conf['rbk']}", ""), "");
echo "</table></td></tr>";
echo <<<HTML
<tr style='display:none' id="group"><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Настройка переноса в группу</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
HTML;
showRow("ID", "ID группы для переноса", "<input class=edit type=text style="text-align: center;" name='save_config[bal_group]' value="{$bal_conf['bal_group']}" size=15>" );
showRow("Группы", "Цена переноса на месяць. Писать в виде: количество дней|цена; Например: 5|2;7|5;", "<textarea style='width: 300px; height: 100px;' class=edit name='save_config[group_price]'>{$bal_conf['group_price']}</textarea>");
showRow("Текст письма", "Текст письма какое будет отправляться при переносе назад в группу. Тег {name} - это имя пользователя", "<textarea style='width: 300px; height: 100px;' class=edit name='save_config[group_mail]'>{$bal_conf['group_mail']}</textarea>");
echo "</table></td></tr>";
echo <<<HTML
<tr style='display:none' id="banner"><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Настройка покупки баннерного места</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
HTML;
showRow("Описание", "Что писать в баннере когда нету кода", "<input class=edit type=text style="text-align: center;" name='save_config[ban_descr]' value="{$bal_conf['ban_descr']}" size=15>" );
echo "</table></td></tr>";
echo <<<HTML
<tr style='display:none' id="robokassa"><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Настройка ROBOKASSA</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
HTML;
showRow("Логин", "Логин в системе Robokassa(robokassa.ru)", "<input class=edit type=text style="text-align: center;" name='save_config[rob_log]' value="{$bal_conf['rob_log']}" size=15>" );
showRow("Пароль", "Пароль #1 в системе Robokassa(robokassa.ru)", "<input class=edit type=text style="text-align: center;" name='save_config[rob_pass]' value="{$bal_conf['rob_pass']}" size=15>" );
showRow("Описание", "Описание заказа. Например: Пополнение счета", "<input class=edit type=text style="text-align: center;" name='save_config[ord_descr]' value="{$bal_conf['ord_descr']}" size=15>" );
echo "</table></td></tr>";
echo <<<HTML
<tr>
<td style="padding-top:10px; padding-bottom:10px;padding-right:10px;">
<input type=hidden name=mod value=balance>
<input type=hidden name=action value=saveit>
<input type=hidden name=savecfg value="savecfg">
<input type="submit" class="buttons" value="Сохранить настройки"></td>
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div></form>
HTML;
echofooter();
closetable();
} elseif($action == "banner") {
echoheader("","");
opentable();
tableheader("Настройка баннерных мест");
$query = $db->query("SELECT * FROM dle_balance");
echo "<table cellpadding="10" border="1" width="100%">";
echo "<tr>";
echo "<td><b>ID</b></td>";
echo "<td><b>Код</b></td>";
echo "<td><b>Тег</b></td>";
echo "<td><b>Дата</b></td>";
echo "<td><b>Действие</b></td>";
echo "</tr>";
while($row = $db->get_row($query)) {
$id = intval($row['id']);
$code = $db->safesql($row['code']);
$date= $row['date'];
if( $date != "" ) $date = date( "Y-m-d H:i:s", $date );
$tag = $row['tag'];
echo "<tr>";
echo "<td>{$id}</td>";
echo "<td>{$code}</td>";
echo "<td>{$tag}</td>";
echo "<td>{$date}</td>";
echo "<td>[ <a href="$PHP_SELF?mod=balance&action=banner_del&id={$id}">-</a> ] [ <a href="$PHP_SELF?mod=balance&action=banner_ed&id={$id}">+</a> ]</td>";
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo "<div align="left"><input type="button" class="bbcodes" value="Добавить" onClick="document.location.href = '$PHP_SELF?mod=balance&action=banner_add'" /> <a href="#" class="hintanchor" onMouseover="showhint('Чтобы поставить баннер в блок нужно в main.tpl вставить {название тега}', this, event, '320px')">[Инфо]</a></div>";
closetable();
echofooter();
} elseif($action == "banner_del") {
$id_del = intval($_GET['id']);
$db->query("DELETE FROM dle_balance WHERE id='$id_del'");
msg('Информация', 'Удалено', 'Баннер успешно удален', "$PHP_SELF?mod=balance");
} elseif($action == "banner_ed") {
echoheader("","");
opentable();
tableheader("Изменение баннера");
$id_ed = intval($_GET['id']);
$row = $db->super_query("SELECT * FROM dle_balance WHERE id='$id_ed'");
if( $row['date'] != "" ) $row['date'] = date( "Y-m-d H:i:s", $row['date'] );
echo <<<HTML
<link rel="stylesheet" type="text/css" media="all" href="engine/skins/calendar-blue.css" title="win2k-cold-1" />
<script type="text/javascript" src="engine/skins/calendar.js"></script>
<script type="text/javascript" src="engine/skins/calendar-en.js"></script>
<script type="text/javascript" src="engine/skins/calendar-setup.js"></script>
<form action="" method="post">
<table cellpadding="4" cellspacing="0" width="100%">
<tr>
<td class="stext" width="20%" style="padding:4px;">Тег баннера:<br />Задать название тега</td>
<td class="stext" style="padding:4px;"><input type="text" class="edit" size="60" name="tag" value="{$row['tag']}" /></td>
</tr>
<tr>
<td class="stext" width="20%" style="padding:4px;">Цена:</td>
<td class="stext" style="padding:4px;"><input type="text" class="edit" size="60" name="money" value="{$row['money']}" /></td>
</tr>
<tr>
<td class="stext" style="padding:4px;">Дата<br />(тут вы задаете дату по какую будет роботать место)</td>
<td class="stext" style="padding:4px;">
<input type="text" name="date" id="date" dir=ltr size="20" class=edit value="{$row['date']}" />
<img src="engine/skins/images/img.gif" align="absmiddle" id="e_trigger_c" style="cursor: pointer; border: 0" />
<script type="text/javascript">
Calendar.setup({
inputField : "date", // id of the input field
ifFormat : "%Y-%m-%d %H:%M:%S", // format of the input field
button : "e_trigger_c", // trigger for the calendar (button ID)
align : "Br", // alignment
singleClick : true
});
</script>
</td>
</tr>
<tr>
<td style="padding:4px;" class="stext" valign="top">Код:<br />(Оставьте поле пустое если хотите чтобы место показало для пользователей)</td>
<td style="padding:4px;" class="stext">
<textarea class="edit" style="width:98%;" rows="14" name="ban_code" id="ban_code" tabindex="9">{$row['code']}</textarea>
</td>
</tr>
<tr>
<td></td>
<td style="padding-left:3px;">
<input type=hidden name=mod value=balance>
<input type=hidden name=action value=banner_edit>
<input type=hidden name=edit value=edit>
<input type="hidden" id="id" name="id" value="{$id_ed}" />
<input type="submit" class="bbcodes" value="Сохранить" />
<input type="button" class="bbcodes" value="Сбросить" onClick="document.location.href = 'admin.php?mod=balance'" />
</td>
</tr>
</form>
</table><br /><br />
HTML;
closetable();
echofooter();
} elseif($action == "banner_edit") {
if($_REQUEST['edit'] == 'edit') {
$tag = $db->safesql($_POST['tag']);
if(empty($_POST['ban_code'])) {
$code = $bal_conf['ban_descr'];
} else {
$code = $db->safesql($_POST['ban_code']);
}
$money = intval($_POST['money']);
$d = strtotime( $_POST['date'] );
$id = intval($_POST['id']);
$db->query("UPDATE dle_balance SET code='$code', tag='$tag', date='$d', money='$money' WHERE id='$id'");
msg('Информация', 'Сохранено', 'Изменение было успешно сохранено', "$PHP_SELF?mod=balance");
}
} elseif($action == "banner_del") {
$id_del = intval($_GET['id']);
$db->query("DELETE FROM dle_balance WHERE id='$id_del'");
msg('Информация', 'Удалено', 'Баннер успешно удален', "$PHP_SELF?mod=balance");
} elseif($action == "banner_add") {
echoheader("","");
opentable();
tableheader("Добавление баннера");
echo <<<HTML
<link rel="stylesheet" type="text/css" media="all" href="engine/skins/calendar-blue.css" title="win2k-cold-1" />
<script type="text/javascript" src="engine/skins/calendar.js"></script>
<script type="text/javascript" src="engine/skins/calendar-en.js"></script>
<script type="text/javascript" src="engine/skins/calendar-setup.js"></script>
<form action="" method="post">
<table cellpadding="4" cellspacing="0" width="100%">
<tr>
<td class="stext" width="20%" style="padding:4px;">Тег баннера:<br />Задать название тега</td>
<td class="stext" style="padding:4px;"><input type="text" class="edit" size="60" name="tag" value="" /></td>
</tr>
<tr>
<td class="stext" width="20%" style="padding:4px;">Цена:</td>
<td class="stext" style="padding:4px;"><input type="text" class="edit" size="60" name="money" value="" /></td>
</tr>
<tr>
<td class="stext" style="padding:4px;">Дата<br />(тут вы задаете дату по какую будет роботать место)</td>
<td class="stext" style="padding:4px;">
<input type="text" name="date" id="date" dir=ltr size="20" class=edit value="" />
<img src="engine/skins/images/img.gif" align="absmiddle" id="e_trigger_c" style="cursor: pointer; border: 0" />
<script type="text/javascript">
Calendar.setup({
inputField : "date", // id of the input field
ifFormat : "%Y-%m-%d %H:%M:%S", // format of the input field
button : "e_trigger_c", // trigger for the calendar (button ID)
align : "Br", // alignment
singleClick : true
});
</script>
</td>
</tr>
<tr>
<td style="padding:4px;" class="stext" valign="top">Код:<br />(Оставьте поле пустое если хотите чтобы место показало для пользователей)</td>
<td style="padding:4px;" class="stext">
<textarea class="edit" style="width:98%;" rows="14" name="ban_code" id="ban_code" tabindex="9"></textarea>
</td>
</tr>
<tr>
<td></td>
<td style="padding-left:3px;">
<input type=hidden name=mod value=balance>
<input type=hidden name=action value=banner_adde>
<input type=hidden name=adde value=adde>
<input type="submit" class="bbcodes" value="Сохранить" />
<input type="button" class="bbcodes" value="Сбросить" onClick="document.location.href = 'admin.php?mod=balance'" />
</td>
</form>
</tr>
</table><br /><br />
HTML;
closetable();
echofooter();
} elseif($action == "banner_adde") {
if($_REQUEST['adde'] == 'adde') {
$tag = $db->safesql($_POST['tag']);
if(empty($_POST['ban_code'])) {
$code = $bal_conf['ban_descr'];
} else {
$code = $db->safesql($_POST['ban_code']);
}
$money = intval($_POST['money']);
$d = strtotime( $_POST['date'] );
$db->query("INSERT INTO dle_balance (code, tag, date, money) VALUES ('$code','$tag', '$d', '$money')");
msg('Информация', 'Сохранено', 'Баннер успешно добавлен', "$PHP_SELF?mod=balance");
}
} elseif ($action == "info") {
echoheader("","");
opentable();
tableheader("Система DLE BALANCE v.".$bal_conf['version']);
echo '<strong>Возможности:</strong><br>
<br>
1. Пополнить баланс <br>
2. Поддержка Robokassa <br>
3. Снять баланс <br>
4. Редактировать баланс в админ-панеле <br>
5. Возможность покупки банерного места <br>
6. Возможность переноса в группу <br>
7. Лог пополнений <br>
8. Админ-панель <br>
9. Защита <br>
10. Вывод баланса в профиле
<br>
<p> </p>
<p><a href="http://x-softer.ru">© 2009 SOFTER</a></p>
';
closetable();
echofooter();
}
//**************************************************
// Сохранение
//**************************************************
elseif ($action == "saveit") {
if ($_REQUEST['savecfg'] != "savecfg")
require_once ENGINE_DIR.'/data/bal_conf.php';
if($_REQUEST['savecfg'] == "savecfg")
{
$find[] = "'r'";
$replace[] = "";
$find[] = "'n'";
$replace[] = "";
$save_con['version'] = "1.0";
$save_config = $save_config + $save_con;
$handler = fopen(ENGINE_DIR.'/data/bal_conf.php', "w");
fwrite($handler, "<?PHPrn$bal_conf = array (rn");
foreach($save_config as $name => $value)
{
$value = stripslashes ($value);
$value = addslashes($value);
$value = preg_replace($find, $replace, $value);
fwrite($handler, "'{$name}' => "{$value}",rn");
}
fwrite($handler, ");rn?>");
fclose($handler);
clear_cache ();
msg("info", "Готово", "Настройки сохранены<br><br><input type='button' value=" Вернуться назад " class='bbcodes' onclick="window.location='$PHP_SELF?mod=balance&action=config'">", "");
}
}
//**************************************************
// END Сохранение
//**************************************************
?>