<?php

/**
* @package     JohnCMS
* @link        http://johncms.com
* @copyright   Copyright (C) 2008-2011 JohnCMS Community
* @license     LICENSE.txt (see attached file)
* @version     VERSION.txt (see attached file)
* @author      http://johncms.com/about
*/

defined('_IN_JOHNADM') or die('Error: restricted access');

// Проверяем права доступа
if ($rights < 9) {
    header('Location: http://johncms.com/?err');
    exit;
}
echo '<div class="phdr"><a href="index.php"><b>' . $lng['admin_panel'] . '</b></a> | Настройка начислений</div>';
if (isset($_POST['submit'])) {
    /*
    -----------------------------------------------------------------
    Сохраняем настройки системы
    -----------------------------------------------------------------
    */
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['them']) . "' WHERE `key` = 'them'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['post']) . "' WHERE `key` = 'post'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['min']) . "' WHERE `key` = 'min'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['reg']) . "' WHERE `key` = 'reg'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . intval($_POST['platact']) . "' WHERE `key` = 'platact'");
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['minobm']) . "' WHERE `key` = 'minobm'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['minrub']) . "' WHERE `key` = 'minrub'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['ballc']) . "' WHERE `key` = 'ballc'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['ballc2']) . "' WHERE `key` = 'ballc2'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['okwmc']) . "' WHERE `key` = 'okwmc'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['okqc']) . "' WHERE `key` = 'okqc'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['deltopic']) . "' WHERE `key` = 'deltopic'"); 

    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['upc']) . "' WHERE `key` = 'upc'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['rday']) . "' WHERE `key` = 'rday'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['rcolor']) . "' WHERE `key` = 'rcolor'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['rb']) . "' WHERE `key` = 'rb'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['ru']) . "' WHERE `key` = 'ru'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['ri']) . "' WHERE `key` = 'ri'"); 
     
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['rp1']) . "' WHERE `key` = 'rp1'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['rp2']) . "' WHERE `key` = 'rp2'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['rindex']) . "' WHERE `key` = 'rindex'"); 
    mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['rall']) . "' WHERE `key` = 'rall'"); 
       
	   
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['topcost']) . "' WHERE `key` = 'topcost'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['toppl']) . "' WHERE `key` = 'toppl'");
	mysql_query("UPDATE `cms_settings` SET `val`='" . functions::check($_POST['delpost']) . "' WHERE `key` = 'delpost'");        
	$req = mysql_query("SELECT * FROM `cms_settings`");
    $set = array ();
    while ($res = mysql_fetch_row($req)) $set[$res[0]] = $res[1];
    echo '<div class="rmenu">' . $lng['settings_saved'] . '</div>';
}
/*
-----------------------------------------------------------------
Форма ввода параметров системы
-----------------------------------------------------------------
*/
echo '<form action="index.php?act=cena" method="post"><div class="menu">';
// Общие настройки
echo '<p>' .
    '<h3>Цена за посты</h3>' .
    'Цена за созданную тему <input type="text" name="them" value="' . htmlentities($set['them']) . '"/><br />' .
    '<br />Цена за пост на форуму <input type="text" name="post" value="' . htmlentities($set['post']) . '"/><br />' .
	'<br />Минималка на вывод: <input type="text" name="min" value="' . htmlentities($set['min']) . '"/><br />' .
    '<br />Баллов за регистрацию: <input type="text" name="reg" value="' . htmlentities($set['reg']) . '"/><br />' .
	'<br />Минимальная сумма обмена баллов: <input type="text" name="minobm" value="' . htmlentities($set['minobm']) . '"/><br />' .
    '<br />Минимальная сумма обмена рублей: <input type="text" name="minrub" value="' . htmlentities($set['minrub']) . '"/><br />' .
    '<br />Обмен баллов на рубли: <input type="text" name="ballc" value="' . htmlentities($set['ballc']) . '"/><br />' .
    '<br />Обмен рублей на баллы: <input type="text" name="ballc2" value="' . htmlentities($set['ballc2']) . '"/><br />' .
    '<br />Подтверждение WMR кошелька: <input type="text" name="okwmc" value="' . htmlentities($set['okwmc']) . '"/><br />' .
    '<br />Подтверждение QIWI кошелька: <input type="text" name="okqc" value="' . htmlentities($set['okqc']) . '"/><br />' .
    
	'<br />Поднятие темы: <input type="text" name="upc" value="' . htmlentities($set['upc']) . '"/><br />' .
    '<br />День рекламы: <input type="text" name="rday" value="' . htmlentities($set['rday']) . '"/><br />' .
    '<br />Цвет рекламной ссылки: <input type="text" name="rcolor" value="' . htmlentities($set['rcolor']) . '"/><br />' .
    
	'<br />Расположение под меню: <input type="text" name="rp1" value="' . htmlentities($set['rp1']) . '"/><br />' .
    '<br />Расположение  над счетчиками: <input type="text" name="rp2" value="' . htmlentities($set['rp2']) . '"/><br />' .
    '<br />Размещение на всех страницах: <input type="text" name="rall" value="' . htmlentities($set['rall']) . '"/><br />' .
    '<br />Размещение только на главной: <input type="text" name="rindex" value="' . htmlentities($set['rindex']) . '"/><br />' .
    
	
	'<br />Рекламная ссылка [b] [/b]: <input type="text" name="rb" value="' . htmlentities($set['rb']) . '"/><br />' .
    '<br />Рекламная ссылка [i] [/i]: <input type="text" name="ri" value="' . htmlentities($set['ri']) . '"/><br />' .
    '<br />Рекламная ссылка [u] [/u]: <input type="text" name="ru" value="' . htmlentities($set['ru']) . '"/><br />' .

 '<br />Закрепление в топ: <input type="text" name="topcost" value="' . htmlentities($set['topcost']) . '"/><br />' .
 '<br />Рекламных мест: <input type="text" name="toppl" value="' . htmlentities($set['toppl']) . '"/><br />' .
 '<br />Снимать за удаление поста: <input type="text" name="delpost" value="' . htmlentities($set['delpost']) . '"/><br />' .
 '<br />Снимать за удаление темы: <input type="text" name="deltopic" value="' . htmlentities($set['deltopic']) . '"/><br />' .


	'</p>';
	echo 'Выплаты:<br />' .
        '<input type="radio" value="1" name="platact" ' . ($set['platact'] == '1' ? 'checked="checked"' : '') . '/>&#160;Включены<br />' .
        '<input type="radio" value="0" name="platact" ' . ($set['platact'] == '0' ? 'checked="checked"' : '') . '/>&#160;Отключены' .
        '</p>';
    echo '</p><p><input type="submit" name="submit" value="' . $lng['save'] . '"/></p></div></form>' .
    '<div class="phdr">&#160;</div>' .
    '<p><a href="index.php">' . $lng['admin_panel'] . '</a></p>';
?>