<?php


define('_IN_JOHNCMS', 1);

require_once('../incfiles/core.php');
$textl = 'Установка цен';
require_once('../incfiles/head.php');


if ($rights ==9 and $user_id){
echo '<div class="phdr" style="color:#fff;"><a href="/shop/" style="color:#fff;">'.str_replace('http://', '',$set['homeurl']).' do\'koni</a> | Narxlarni o\'rnatish</div>';

switch ($act) {
case 'price':
if (isset($_POST['submit'])) {
    // Принимаем данные

    $pr2 = isset($_POST['login']) ? abs(intval($_POST['login'])) : '';
    $pr5 = isset($_POST['amail']) ? abs(intval($_POST['amail'])) : '';
    $pr6 = isset($_POST['cnick']) ? abs(intval($_POST['cnick'])) : '';
    $pr7 = isset($_POST['cstat']) ? abs(intval($_POST['cstat'])) : '';
    $error = false;

    // Провереряем данные цена
    if (empty($pr2) || empty($pr5) || empty($pr6) || empty($pr7))
        $error = $error . 'Narx kiritilmadi!<br />';

    if (preg_match('/[^\d]+/', $pr2) || preg_match('/[^\d]+/', $pr5) || preg_match('/[^\d]+/', $pr6) || preg_match('/[^\d]+/', $pr7))
        $error = $error . 'Narxda ta\'qiqlangan belgilar!<br />';

    // Заносим данные в БД
    if (empty($error)) {

    mysql_query("UPDATE `shop` SET `price` = CASE WHEN `id` = 2 THEN '$pr2' WHEN `id` = 10 THEN '$pr5' WHEN `id` = 11 THEN '$pr6' WHEN `id` = 12 THEN '$pr7' END WHERE `id` IN('2', '10', '11', '12')");

        echo '<div class="gmenu">Narxlar o\'rnatildi!</div>';
    } else {
        echo '<div class="rmenu"><p><b>XATO!</b><br />' . $error . '</p></div>';
    }
       }
     // запросы на цены
    $price_sql = mysql_query("SELECT `price` FROM `shop` WHERE `id` IN('2','10', '11', '12')");
    $i = 1;
    $arr = array(1 => "Nikni almashtirish:", "Anonim xabar:","Rangli nik","Rangli status:");
    $arr2 = array(1 => "login","amail","cnick","cstat");
    $arr3 = array(1 =>
    "Nik almashtirish narxi",
    "Anonim xabar yuborish narxi",
	"Nik rangini o'zgartirish narxi",
    "Status rangini o'zgartirish narxi");

    echo '<div class="list2">admin, Siz bu yerda xizmatlarga narx qo\'ya olasiz.</div>';
    echo '<form action="adm.php?act=price" method="post">';

    while ($price = mysql_fetch_assoc($price_sql)) {
    echo $i % 2 ? '<div class="list2">' : '<div class="list1">';

    echo '<p><b>'.$arr[''.$i.''].'</b><br/><input type="text" name="'.$arr2[''.$i.''].'" maxlength="15" value="' . $price['price'] . '" /><br/><small>'.$arr3[''.$i.''].'</small></p>';

    echo '</div>';
    ++$i;
    }

    echo '<div class="list2"><input type="submit" name="submit" value="Narxlarni o\'rnatish"/></div></form>';
    break;

case 'balans':
    if (isset($_POST['submit'])) {
    // Принимаем данные
    $mn1 = isset($_POST['bonus']) ? abs(intval($_POST['bonus'])) : '';
    $mn2 = isset($_POST['fpost']) ? abs(intval($_POST['fpost'])) : '';
    $mn3 = isset($_POST['nt']) ? abs(intval($_POST['nt'])) : '';
    $mn4 = isset($_POST['gpost']) ? abs(intval($_POST['gpost'])) : '';
    $mn5 = isset($_POST['komm']) ? abs(intval($_POST['komm'])) : '';
    $mn6 = isset($_POST['reg']) ? abs(intval($_POST['reg'])) : '';
    $error = false;


    // Провереряем данные
    if (empty($mn1) || empty($mn2) || empty($mn3) || empty($mn4) || empty($mn5) || empty($mn6))
    $error = $error . 'Ball miqdori kiritilmadi!<br />';

    if (preg_match('/[^\d]+/', $mn1) || preg_match('/[^\d]+/', $mn2) || preg_match('/[^\d]+/', $mn3) || preg_match('/[^\d]+/', $mn4) || preg_match('/[^\d]+/', $mn5) || preg_match('/[^\d]+/', $mn6))
    $error = $error . 'Ta\'qiqlangan belgilar!<br />';

    // Заносим данные в БД
    if (empty($error)) {
        mysql_query("UPDATE `shop` SET `price` = CASE WHEN `id` = 5 THEN '$mn1' WHEN `id` = 6 THEN '$mn2' WHEN `id` = 7 THEN '$mn3' WHEN `id` = 8 THEN '$mn4' WHEN `id` = 9 THEN '$mn5' WHEN `id` = 13 THEN '$mn6' END WHERE `id` IN('5', '6', '7', '8', '9', '13')");
        echo '<div class="gmenu">Narxlar o\'rnatildi!</div>';
    } else {
        echo '<div class="rmenu"><p><b>XATO!</b><br />' . $error . '</p></div>';
    }
       }

    // запрос на цены
    $price_sql = mysql_query("SELECT `price` FROM `shop` WHERE `id` IN('5', '6', '7', '8', '9', '13')");

    $i = 1;

    $arr = array(1 => "Kundalik bonus:","Forumdagi psot:","Yangi mavzu:","Mehmonxonadagi post:","Fikrlar:","Ro'yxatdan o'tish:");
    $arr2 = array(1 => "bonus","fpost","nt","gpost","komm","reg");
    $arr3 = array(1 =>
    "Foydalanuvchilarning kundalik bonusi",
    "Forumdagi psot uchun",
    "Yangi mavzu uchun",
    "Mehmonxonadagi post uchun",
    "Fikrlar uchun",
    "Saytdan ro'yxatdan o'tganda");

    echo '<div class="list2">Admin siz bu yerda foydalanuvchi post qoldirganda unga ma\'lum miqdorda tanga o\'tkaza olasiz<br/>Kundalik bonus ham belgilay olasiz.</div>';
    echo '<form action="adm.php?act=balans" method="post">';

    while ($price = mysql_fetch_assoc($price_sql)) {
        echo $i % 2 ? '<div class="list2">' : '<div class="list1">';

        echo '<p><b>'.$arr[''.$i.''].'</b><br/><input type="text" name="'.$arr2[''.$i.''].'" maxlength="15" value="' . $price['price'] . '" /><br/><small>'.$arr3[''.$i.''].'</small></p>';

        echo '</div>';
        ++$i;
    }

    echo '<div class="list2"><input type="submit" name="submit" value="Narxlarni o\'rnatish"/></div></form>';
    break;

default:
echo '<div class="gmenu">Admin siz nu yerda do\'kondagi xizmatlarga narx o\'rnata olasiz<br/>Va foydalanuvchilar posti uchun beriladigan ball miqdorini belgilay olasiz.<br/>Yana kundalik bonus miqdorini belgilay olasiz.</div>';
echo '<div class="list1"><a href="adm.php?act=price">Xizmatlarga narxlar</a></div>';
echo '<div class="list2"><a href="adm.php?act=balans">Bonus / Postlar uchun ballar</a></div>';
      }
}

require_once('../incfiles/end.php');
?>