[Release] Stoke Market for All Webs

Status
Not open for further replies.

dota-sdso

Well-Known Member
Joined
Apr 30, 2014
Messages
590
Reaction score
822
От неизвестен автор, ползвайте със здраве

PHP:
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////                                                     / | \                    //
///  uSELEss MaRkET}    ///                                                    /  |  \                   //
///    BY r00tme        ///                                                  //       \\                 //
///   04'05'2015        ///                                                ///        \\\                //
///http://napipai-go.com///                                                   /      \                   //
///  I love Дриско  !   ///                                                  /        \                  //
///////////////////////////                                            ///////////\\\\\\\\\\             //
//                                                                    //////////////\\\\\\\\\\\\         //
//                                                                  ////////////////\\\\\\\\\\\\\\       //
//                                                                   ^недей три пидирас.. ще ядеш^       //
//                                                                                                       //
//Главен конфиг на модула -> може да се изведе там някъде                                                //    
//Конфигурация на стоката +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    $stock_market['price']        = 1;                       // Изискване за Jewel of Creation 1=да 0-не
    $stock_market['multiplier']   = 1; 	                     // Вкл-Изкл->1-0 Множител на кредити
    $stock_market['multiplier_x'] = 1.2;                     // Коефициент   	
    $stock_market['max_credits']  = 500;                     // Максимум кредити за продаване
    $stock_market['max_rena']     = 2000;                    // Максимална рена за продажба 
    $stock_market['max_zen']      = 2000000000;              // Максимален зен за продажба
    $stock_market['max_stone']    = 2000;                    // Максимални камъни за продажба
	// Каква е аджаба таблицата за рена                  
	$rena_table_name              = '[StoneRena]';           // Наименование на Рена Таблицата
	$rena_column                  = '[Rena]';                // Наименование на Рена колонката
	$rena_user_column             = '[acc]';                 // Наименование на Рена акаунт
	// Каква е аджаба таблицата за стоне
	$stone_table_name             = '[DPWeb_JewelDeposit]';  // Наименование на Стоне Таблицата
	$stone_column                 = '[stone]';               // Наименование на Стоне колонката 
	$stone_user_column            = '[memb___id]';           // Наименование на Стоне акаунт 
	// Каква е аджаба таблицата за зенче
	$zen_table_name               = '[Bank]'  ;              // Наименование на Зен Таблицата
	$zen_column                   = '[Zen]';                 // Наименование на Зен колонката
	$zen_user_column              = '[memb___id]';           // Наименование на Зен акаунт 
	// Каква е аджаба таблицата за кредити
	$credits_table_name           = '[Memb_Credits]' ;       // Наименование на Кредити Таблицата
	$credits_column               = '[Credits]' ;            // Наименование на Кредити колонката
	$credits_user_column          = '[memb___id]';           // Наименование на Кредити акаунт 
	// Каква е джаба таблицата на джевелите
	$creation_table_name          = '[DPWeb_JewelDeposit]';  // Наименование на Jewels of Creation Таблицата
	$creation_column              = '[creation]';            // Наименование на Jewels of Creation колонката
	$creation_user_column         = '[memb___id]';           // Наименование на Jewels of Creation акаунт 
?>

<?
//Лукчета
function stoke_logs($file_name, $content)
{
	$file_date = date('d_m_Y', time());
    $log_date = date('h:i:s', time());
	$log_content='Date: '.$log_date .' | ' . $content . "\r\n";
	file_put_contents('market_logs/StockMarket/'.$file_name.'['.$file_date.'].log', $log_content, FILE_APPEND);
}


?>


<?php


// Има ли прокси или не?
if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
}
$ip = filter_var($ip, FILTER_VALIDATE_IP);
$ip = ($ip === false) ? '0.0.0.0' : $ip;
$time = date("dM H:i:s");
$link = $_SERVER["REQUEST_URI"];
$category_str = "cat_id=" . $category;
$username = $_SESSION['dt_username'];

// Едно дивче да гледаме по-налгедно грешките ми
echo "<div class='nadpis newnadspi'>";

//Ивзеждане на ресурсите на акаунта от таблиците в Сток Маркет
$is_rena = mssql_fetch_row(mssql_query("Select ".$rena_column." From  ".$rena_table_name." Where  ".$rena_user_column."='{$_SESSION['dt_username']}'"));
$is_zen = mssql_fetch_row(mssql_query("Select  ".$zen_column." From  ".$zen_table_name." Where ".$zen_user_column."   ='{$_SESSION['dt_username']}'"));
$is_credits = mssql_fetch_row(mssql_query("Select ".$credits_column."  From ".$credits_table_name." Where  ".$credits_user_column."='{$_SESSION['dt_username']}'"));
$is_stone = mssql_fetch_row(mssql_query("Select ".$stone_column ." From  ".$stone_table_name." Where ".$stone_user_column."  ='{$_SESSION['dt_username']}'"));
$is_jewel = mssql_fetch_row(mssql_query("Select ".$creation_column ."  From ".$creation_table_name." Where ".$creation_user_column."  ='{$_SESSION['dt_username']}'"));

// Тука купуваме разни ресурси
if (isset($_POST['buy'])) {
		

    $stock_id = secure($_POST['stock_id']);
    $query_stock = mssql_fetch_row(mssql_query("Select * from Stock_Market where stock_id = '" . $stock_id . "' "));
    $seller = $query_stock[0];
    //---- продава ----//$query
    $рена_продава = $query_stock[4];
    $стоне_продава = $query_stock[2];
    $зен_продава = $query_stock[3];
    $кретити_продава = $query_stock[5];
    //----- купува-----/$query
    $кредити_купува = $query_stock[9];
    $рена_купува = $query_stock[8];
    $стоне_купува = $query_stock[6];
    $зен_купува = $query_stock[7];
    //Малко проста аритметика, че се сърдят заявките и ми писна на кура и не съм bahtidobriq1 ами Дриско 2
    $zenplus      =  $is_zen[0]       + $зен_продава;
    $renaplus     =  $is_rena[0]      + $рена_продава;
    $stoneplus    =  $is_stone[0]     + $стоне_продава;
    $zenminus     =  $is_zen[0]       - $зен_купува;
    $renaminus    =  $is_rena[0]      - $рена_купува;
    $stoneminus   =  $is_stone[0]     - $стоне_купува;
    $creditsminus =  $is_credits[0]   - $кредити_купува;
    if ($seller   == $username) {
		if ($stock_market['multiplier'] == 1){
	    $creditsplusa = $query_stock[5]*$stock_market['multiplier_x'];
		$creditsplus = (ceil($creditsplusa))+($is_credits[0]);
	     }
	    else {
	    $creditsplus  =  $is_credits[0]   + $кретити_продава;
	     }
        // Ако акаунта е продавача връщаме му ресурсите там преди 100 лета
        mssql_query("Update ".$rena_table_name." set ".$rena_column."='"  . $renaplus . "' where ".$rena_user_column."  ='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$zen_table_name." set ".$zen_column."= '" .  $zenplus . "' where  ".$zen_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$credits_table_name." set  ".$credits_column." = '" . $creditsplus . "' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$stone_table_name." set ".$stone_column ."  = '" . $stoneplus . "' where  ".$stone_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Delete from Stock_Market where [stock_id]='" . $stock_id . "'");
        show_msg('<span class="nadpisi">These were your resources and have been added to your Web Bank!</span>');
        header("Refresh:3;");
		} 
		else {
        if ($is_rena[0] < $рена_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Rena!</span>');
            header("Refresh:3;");
        } elseif ($is_zen[0] < $зен_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Zen!</span>');
            header("Refresh:3;");
        } elseif ($is_stone[0] < $стоне_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Stone!</span>');
            header("Refresh:3;");
        } elseif ($is_credits[0] < $кредити_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Credits!</span>');
            header("Refresh:3;");
        } elseif (($зен_продава[0] + $is_zen[0]) > $option['bank_limit']) {
            show_msg('<span class="nadpisi"> Sorry the maximum Zen  you can have in the bank is ' . $option['bank_limit'] .  '!</span>');
            header("Refresh:3;");
        } else {
			$creditsplus  =  $is_credits[0]   + $кретити_продава;
            // Ако акаунта не е продавача правим някви ъпдейти.. не помня вече
            mssql_query("Update ".$rena_table_name."    set  ".$rena_column."    = '" . $renaminus . "' where ".$rena_user_column."  ='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$zen_table_name."     set  ".$zen_column."     = '". $zenminus .   "' where  ".$zen_user_column."='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$credits_table_name." set  ".$credits_column." = '". $creditsminus."' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$stone_table_name."   set  ".$stone_column ."  = '". $stoneminus . "' where  ".$stone_user_column."='{$_SESSION['dt_username']}'");
            // Добавяме закупените ресурси в Банката на брата
            mssql_query("Update ".$rena_table_name."    set  ".$rena_column."='" . $renaplus . "' where ".$rena_user_column."  ='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$zen_table_name."     set  ".$zen_column." = '" . $zenplus . "' where ".$zen_user_column."   ='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$credits_table_name." set  ".$credits_column." = '" . $creditsplus . "' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$stone_table_name."   set  ".$stone_column ." = '" . $stoneplus . "' where ".$stone_user_column  ."='{$_SESSION['dt_username']}'");
            mssql_query("Delete from Stock_Market where [stock_id]='" . $stock_id . "'");
            show_msg('<span class="nadpisi">' . $_SESSION['dt_username'] . ' bought from the Stock Market!</span>');
            header("Refresh:3;");
        }
    }
    //Правим подробен лог в папка /лукчета/StockMarket
    stoke_logs('StockMarket', '| Buyer: ' . $username . ' | Seller: ' .  $seller . ' | Item: ' . $newitem . ' |Buyer IP: ' . $ip . '| 
	Купил:[Rena]=' . $рена_продава . ',[Zen]=' . $зен_продава .  ',[Credits]=' . $кредити_продава . ',[Stone]=' . $стоне_продава . ', 
	За: [Rena]' . $рена_купува . ',[Zen]=' . $зен_купува . ',[Credits]=' . $кредити_купува . ',[Stone]=' . $стоне_купува);
}
////// ++++++  Функция за продаване +++++++ ////////
// Проверка дали е активирана цена за маркета (Jewel of Creation) и сетване на 0 лева стойност, ако не е - "бахтидобрия"
if ($stock_market['price'] == 1) {
    $stock_price = 1;
} else {
    $stock_price = 0;
}
// Ako сме атакували формата изпълнява се целият сркипт отдолу с име: "Аман"
if (isset($_POST['sellstock']) && $_POST['sellstock'] === '1') {
    //Тикаме всички постчета в променливи ... щото ми е кеФ
    $added         = time();
    $expires       = ($added + (86400 * $stock_market['stock_remove_in']));
    $sell_credita  = (int)secure($_POST['sell_credits']);
    $sell_zen      = (int)secure($_POST['sell_zen']);
    $sell_rena     = (int)secure($_POST['sell_rena']);
    $sell_stone    = (int)secure($_POST['sell_stone']);
    $buy_credits   = (int)secure($_POST['buy_credits']);
    $buy_zen       = (int)secure($_POST['buy_zen']);
    $buy_rena      = (int)secure($_POST['buy_rena']);
    $buy_stone     = (int)secure($_POST['buy_stone']);
	// Да видим има ли тарикати да пренасят кредити от акаунт в акаунт. Ако  не искаме да има тарикати им подаваме множителя на bahtidobriq1
	if ($stock_market['multiplier'] == 1){
		$sell_credit    = $sell_credita*$stock_market['multiplier_x'];
		$sell_credits   = ceil($sell_credit);
		$insert_credits = $sell_credita;
		$start1= '<li>If you sell credits you have to pay the credits x '.$stock_market['multiplier_x'].'</li>';
		$spec_message = '<span class="nadpisi">You can not sell ' .  $is_credits[0] . ' credits because you have to pay <font  color="#FF4C4C">' . $sell_credits . '</font>!</span>';
	    $кретити_продава1 = $query_stock[5]*$stock_market['multiplier_x'];
		$кретити_продава = ceil($кретити_продава1);
	}
	else {
		$sell_credits = $sell_credita;
		$insert_credits = $sell_credita;
		$start1= '';
		$spec_message = '<span class="nadpisi">You can not sell ' .  $sell_credits . ' Credits because you have ' . $is_credits[0] .  '!</span>';
	    $кретити_продава = $query_stock[5];
	}
    // Вкарваме в променливи остатъка след продажбата
    $newstone      = $is_stone[0]   - $sell_stone;
    $newcredits    = $is_credits[0] - $sell_credits;
    $newrena       = $is_rena[0]    - $sell_rena;
    $newzen        = $is_zen[0]     - $sell_zen;
    // Проверки за формата, какво се въвежда и дали акаунта има  ресурсите за продаване в наличност - "Аийшстига е.. туй аз ли съм ве?"
    // Проверка дали купуването на зен ще прехвърли лимита на банката сетнат в конфига - "Аийшстига е.. туй аз ли съм ве?"
    if ($is_jewel[0] < $stock_price) {
        show_msg('<span class="nadpisi"> To post item for selling you need to pay one Jewel of Creation!</span>');
        header("Refresh:3;");
    } elseif (($sell_credits > 0) and ($buy_credits > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif (($sell_rena > 0) and ($buy_rena > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif (($sell_zen > 0) and ($buy_zen > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif (($sell_stone > 0) and ($buy_stone > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif ($sell_zen > $is_zen[0]) {
        show_msg('<span class="nadpisi">You can not sell ' .  $sell_zen . ' Zen because you have ' . $is_zen[0] . ' in the Web  Bank!</span>');
        header("Refresh:3;");
    } elseif ($sell_credits > $is_credits[0]) {
        show_msg(''.$spec_message.'');
        header("Refresh:3;");
    } elseif ($sell_rena > $is_rena[0]) {
        show_msg('<span class="nadpisi">You can not sell ' .  $sell_rena . ' Rena because you have ' . $is_rena[0] . ' in the Web  Bank!</span>');
        header("Refresh:3;");
    } elseif ($sell_stone > $is_stone[0]) {
        show_msg('<span class="nadpisi">You can not sell ' .  $sell_stone . ' Stone because you have ' . $is_stone[0] . ' in the Web  Bank!</span>');
        header("Refresh:3;");
    } elseif ($sell_credits < 0 || $credits > $stock_market['max_credits']) {
        show_msg('<span class="nadpisi">Invalid Credits price,  maximum is ' . $stock_market['max_credits'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_rena < 0 || $sell_rena > $stock_market['max_rena']) {
        show_msg('<span class="nadpisi">Invalid Rena price, maximum is ' . $stock_market['max_rena'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_stone < 0 || $sell_stone > $stock_market['max_stone']) {
        show_msg('<span class="nadpisi">Invalid Stone price,  maximum is ' . $stock_market['max_stone'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_zen < 0 || $sell_zen > $stock_market['max_zen']) {
        show_msg('<span sclass="nadpisi">Invalid Zen price, maximum is ' . $stock_market['max_zen'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_credits == 0 && $sell_zen == 0 && $sell_rena == 0 && $sell_stone == 0) {
        show_msg('<span class="nadpisi">Please type what are you selling!</span>');
        header("Refresh:3;");
	} elseif ($sell_credits > 0 and ($buy_credits == 0 &&  $buy_zen == 0 && $buy_rena == 0 && $buy_stone == 0)) {
        show_msg('<span class="nadpisi">Please type what you want  to exchange your '.$sell_credits.' credits for!</span>');
        header("Refresh:3;");
	} elseif ($sell_rena > 0 and ($buy_credits == 0 && $buy_zen == 0 && $buy_stone == 0)) {
        show_msg('<span class="nadpisi">Please type what you want  to exchange your '.$sell_rena.' Rena for!</span>');
        header("Refresh:3;");
	} elseif ($sell_stone > 0 and ($buy_credits == 0 && $buy_zen == 0 && $buy_rena == 0)) {
        show_msg('<span class="nadpisi">Please type what you want  to exchange your '.$sell_stone.' Stone for!</span>');
        header("Refresh:3;");
	} elseif ($sell_zen > 0 and ($buy_credits == 0 && $buy_stone == 0 && $buy_rena == 0)) {
        show_msg('<span class="nadpisi">Please type what you want to exchange your '.$sell_zen.' Zen for!</span>');
        header("Refresh:3;");
    } elseif ($buy_credits == 0 && $buy_zen == 0 && $buy_rena == 0 && $buy_stone == 0) {
        show_msg('<span class="nadpisi">Please type what are you selling for!</span>');
        header("Refresh:3;");
    }
    //Ако япма грешки, изълнява долу ташака
    else {
        mssql_query("Update ".$stone_table_name."    set ".$stone_column  ."    ='" . $newstone . "' where ".$stone_user_column  ."='{$_SESSION['dt_username']}' ");
        mssql_query("Update ".$rena_table_name."     set  ".$rena_column."      ='" . $newrena  . "' where  ".$rena_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$credits_table_name."  set  ".$credits_column."   ='" . $newcredits."' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$zen_table_name."      set ".$zen_column."        ='" . $newzen  . "'  where  ".$zen_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$creation_table_name." set  ".$creation_column ." = ".$creation_column ." - '" . $stock_price."'  where ".$creation_user_column."='" . $username . "'");
        mssql_query("INSERT INTO [Stock_Market](
		account,
		date,
		sell_stone,
		sell_zen,
		sell_rena,
		sell_credits,
		buy_stone,
		buy_zen,
		buy_rena,
		buy_credits)
		VALUES (
		'" . $username . "',
		'" . $added . "',
		'" . $sell_stone . "',
        '" . $sell_zen . "',
        '" . $sell_rena . "',
        '" . $insert_credits . "',
        '" . $buy_stone . "',
        '" . $buy_zen . "',
        '" . $buy_rena . "',
        '" . $buy_credits . "'		
		)");
        show_msg('
		<span class="bahtidobriq1">
		You have successfully listed <font color="#FFDC73"></font> for sell in the Stock Market!</span>', 1);
        header("Refresh:2;");
    }
}
echo "</div>";
// Показваме някви надписи ако ала бала - бала ала
if ($stock_market['price'] == 1) {
    $start = '<li>You must to pay <font  color="purple"><b>1 Jewel of Creation</b></font> to  sell item</li>';
} else {
    $start = '';
}
if ($stock_market['multiplier'] == 1){
$start1= '<li>If you sell credits you will pay the credits x '.$stock_market['multiplier_x'].'</li>';
}else {
	 $start1 = '';
}
?>
<div class="bahtidobriq1"style='margin-left:10px;padding:10px 10px;color:#fff;text-shadow:1px 1px #000;width:550px;'>

           <?=$start;?> 
		   	<?=$start1;?>
           <li>When someone buy your stock the full price (zen,  credits, stone, rena) will be automatically added into your web  bank</li>
	


<div class="bahtidobriq1"style='margin-left:10px;padding:10px 10px;color:#fff;text-shadow:1px 1px #000;width:550px;'>
  <form style="margin-left:50px;"class="new" method="post" action="">
	 <table   align="center" style="padding:10px 10px;margin-left:10px;text-align: center; font-size: 10pt; color: white;">
         <tr class="title">
	          <td colspan="10">Stock Market</td>
           </tr>
        <tr style="padding:10px 10px"class="title-front">
	          <td style="padding:10px 10px ;font-size:12pt;color:#FFFFF2" colspan="10">Sell:</p></td>
          </tr>	
		<tr>
		      <td>Zen</td>
			  <td>Rena</td>				
			  <td>Credits</td>
			  <td>Stones</td>
		  </tr>
		<tr>
			  <td><input type="text" name="sell_zen" maxlength="13"  onkeyup="return isNumber(this)" style="height: 22px;  width:  100px;"/></td>
			  <td><input type="text" size="3" name="sell_rena"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px; text-align: center;"/></td>
			  <td><input type="text" size="3" name="sell_credits"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
			  <td><input type="text" size="3" name="sell_stone"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
		  </tr>
		<tr style="padding:10px 10px"class="title-front">
	<td style="padding:10px 10px ;font-size:12pt;" colspan="10">For:</p></td>
</tr>	
		      <td>Zen</td>
			  <td>Rena</td>				
			  <td>Credits</td>
			  <td>Stones</td>
		  </tr>
		<tr>
			<td><input type="text" name="buy_zen" maxlength="13"  onkeyup="return isNumber(this)" style="height: 22px;  width:  100px;"/></td>
			<td><input type="text" size="3" name="buy_rena"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px; text-align: center;"/></td>
			<td><input type="text" size="3" name="buy_credits"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
			<td><input type="text" size="3" name="buy_stone"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
		</tr>

</table>
    <div style="margin-top:10px;margin-left:180px;">
		<input type="hidden" name="sellstock" value="1" />
		<input type="submit" class="newaa" Value="Sell Resources" /></div>
</form>

<?php
// Вадим информацията (ако има) и я тикаме в хтмл-а на момчето
if (isset($_POST['search_seller'])) {
    $query = mssql_query("Select * from Stock_Market where account ='" . secure($_POST['seller']) . "'");
// Aко са кликнали в/у търсене на всички ресурси от потребителя променя съобщението на "Аман бе Пешо"
    echo "<div class='nadpisi top title'>All Stocks from " . secure($_POST['seller']) . "</div>";
    while ($allmarket = mssql_fetch_row($query)):
        $added_on     = date("d-m-Y H:i", $allmarket[1]);
        $renasell     = $allmarket[4];
        $renabuy      = $allmarket[8];
        $sellcr       = $allmarket[5];
        $buycr        = $allmarket[9];
        $sellzen      = $allmarket[3];
        $buyzen       = $allmarket[7];
        $sellstone    = $allmarket[2];
        $buystone     = $allmarket[6];
// Крием нулеви стойности с одеялото
        if ($renasell == 0) {
            $renasell = '';
        } else {
            $renasell = '<font color="#73DCFF"> ' . $allmarket[4] . ' Rena</font>';
        }
        if ($renabuy == 0) {
            $renabuy = '';
        } else {
            $renabuy = '<font color="#73DCFF"> ' . $allmarket[8] . ' Rena</font>';
        }
        if ($sellcr == 0) {
            $sellcr = '';
        } else {
            $sellcr = '<font color="#FFFF4C"> ' . $allmarket[5] . ' Credits</font>';
        }
        if ($buycr == 0) {
            $buycr = '';
        } else {
            $buycr = '<font color="#FFFF4C"> ' . $allmarket[9] . ' Credits</font>';
        }
        if ($sellzen == 0) {
            $sellzen = '';
        } else {
            $sellzen = '<font color="#FFBF00"> ' . $allmarket[3] . ' Zen</font>';
        }
        if ($buyzen == 0) {
            $buyzen = '';
        } else {
            $buyzen = '<font color="#FFBF00"> ' . $allmarket[7] . ' Zen</font>';
        }
        if ($sellstone == 0) {
            $sellstone = '';
        } else {
            $sellstone = '<font color="#8A8A7B"> ' . $allmarket[2] . ' Stone</font>';
        }
        if ($buystone == 0) {
            $buystone = '';
        } else {
            $buystone = '<font color="#8A8A7B"> ' . $allmarket[6] . ' Stone</font>';
        }
?>
<table class="bahtidobriq1 nasko"align="center" width="500">  
   <form class="new" method='post' action=''>	  
	     <td>
		  <input name='stock_id' type='hidden' value="<?php echo $allmarket[10]; ?>"class="buyimage"/>
	      <input name='buy' type='submit' value="Buy Now"class="buyimage"/>
	         </td>
			    	
	   <td style="text-align:left;font-size:9pt;">
		  <p style="display:inline-table;color:#FFFFF2">Added  on:</p> <p   style="display:inline-table;color:#999;"><?php echo $added_on;  ?></p></p>
	      <p style="display:inline-table;color:#FFFFF2">Sell:     </p><?echo $sellcr?> <?echo $sellzen?> <?echo  $sellstone?> <?echo $renasell?> </p>
		  <p style="display:inline-table;color:#FFFFF2">For:      </p><?echo $buycr?> <?echo $buyzen?> <?echo  $buystone?> <?echo $renabuy?> </p>		
		  <p  style="display:inline-table;color:#FFFFF2">Merchant:</p> <p  style="display:inline-table;color:#999;"><?php echo $allmarket[0];  ?><input name='seller' type='hidden' value='<?php echo  $allmarket[0]; ?>'/></font> 
          <span style="margin-left:3px;">
		  <input class= 'buttons_new' type='submit' name='all_items' value  ='Back to all stock' class='buttons'/></span></p>
              </td> 
       <td>
	      <img width="60px" height="60px"src="./images/mu.png"/>
		      </td>
  
	  </form>					
</table>


<? 
endwhile;
  }
else{
echo "<div class='nadpisi top title'>All Stocks in the Market</div>";
$query = mssql_query("Select * from Stock_market");
while ($allmarket  = mssql_fetch_row($query)):
        $added_on  = date("d-m-Y H:i",$allmarket[1]);
        $renasell  = $allmarket[4];
        $renabuy   = $allmarket[8];
        $sellcr    = $allmarket[5];
        $buycr     = $allmarket[9];
        $sellzen   = $allmarket[3];
        $buyzen    = $allmarket[7];
        $sellstone = $allmarket[2];
        $buystone  = $allmarket[6];
// "Така кажи ве" 
            if ($renasell   == 0) {$renasell  ='';}else {$renasell =  '<font color="#73DCFF"> '.$allmarket[4]. ' Rena</font>';}
            if ($renabuy    == 0) {$renabuy   ='';}else {$renabuy  =  '<font color="#73DCFF"> '.$allmarket[8]. ' Rena</font>';}
            if ($sellcr     == 0) {$sellcr    ='';}else {$sellcr   =  '<font color="#FFFF4C"> '.$allmarket[5]. ' Credits</font>';}
            if ($buycr      == 0) {$buycr     ='';}else {$buycr    =  '<font color="#FFFF4C"> '.$allmarket[9]. ' Credits</font>';}
            if ($sellzen    == 0) {$sellzen   ='';}else {$sellzen  =  '<font color="#FFBF00"> '.$allmarket[3]. ' Zen</font>';}
            if ($buyzen     == 0) {$buyzen    ='';}else {$buyzen   =  '<font color="#FFBF00"> '.$allmarket[7]. ' Zen</font>';}
            if ($sellstone  == 0) {$sellstone ='';}else {$sellstone=  '<font color="#8A8A7B"> '.$allmarket[2]. ' Stone</font>';}
            if ($buystone   == 0) {$buystone  ='';}else {$buystone =  '<font color="#8A8A7B"> '.$allmarket[6]. ' Stone</font>';}

   ?>
<table class="nasko"align="center" width="500">  
	     <td><form action="" method="post">
		 <p><?echo $sellcr?> <?echo $sellzen?> <?echo $sellstone?> <?echo $renasell?></p>
		  <input name='stock_id' type='hidden' value="<?php echo $allmarket[10]; ?>"class="buyimage"/>
	     <p><input name='buy' type='submit' value="Buy Now"class="buyimage"/></p>
	         </td>
			    <form class="new"method='post' action=''></td>
	   <td style="text-align:left;font-size:9pt;">
		  <p style="display:inline-table;color:#FFFFF2">Added  on:</p> <p   style="display:inline-table;color:#999;"><?php echo $added_on;  ?></p></p>
	      <p style="display:inline-table;color:#FFFFF2">Sell:     </p><?echo $sellcr?> <?echo $sellzen?> <?echo  $sellstone?> <?echo $renasell?> </p>
		  <p style="display:inline-table;color:#FFFFF2">For:      </p><?echo $buycr?> <?echo $buyzen?> <?echo  $buystone?> <?echo $renabuy?> </p>		
		  <p  style="display:inline-table;color:#FFFFF2">Merchant:</p> <p  style="display:inline-table;color:#999;"><?php echo $allmarket[0];  ?><input name='seller' type='hidden' value='<?php echo  $allmarket[0]; ?>'/></font> 
          <span style="margin-left:3px;">
		  <input class= 'buttons_new' type='submit' name='search_seller'  value ='All stock from this seller'  class='buttons'/></span></p>
              </td> 
       <td>
	      <img width="60px" height="60px"src="./images/mu.png"/>
		      </td>
  
	  </form>					
</table>


<? 
endwhile;}
?>







<style>
.buyimage {
  color:#ACAC9D;
  cursor:pointer;
  text-shadow:1px 1px #000;
  }
.buyimage:hover {
   color:#FFFFF2;
  cursor:pointer;
  text-shadow:1px 1px #000;
  }
.nasko{ overflow:auto;
line-height:15px;
padding-top:15px;
margin-bottom:10px;
position : relative;
margin-left:25px;
border-radius: 10px 10px 10px 10px;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
border-top: 1px solid #686859;
background-image:url('../images/bgstock.png') ;
background-size:570px 70px;
background-repeat: no-repeat;

}

.nadpisi{
	text-align:center;
	color:fff;
	text-shadow:1px 1px #000;
	font-size:10pt;
}
.top{
	margin-top:20px;
	width:490px;
	margin-left:25px;
}
.newaa:{
	color:444;
	cursor:pointer;
}
.newaa:hover{
	color:fff;
		cursor:pointer;
}
.newnadspi{
	background:#111111;
	width:500px;
	height:20px;
	margin-left:25px;
	border-radius:15px 15px 0px 0px;
	border:1px solid #331818;
}

</style>




SQL

PHP:
USE [MuOnline]
GO

/****** Object:  Table [dbo].[Stock_Market]    Script Date: 8/4/2015 04:07:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Stock_Market](
	[account] [varchar](50) NULL,
	[date] [int] NOT NULL,
	[sell_stone] [int] NOT NULL,
	[sell_zen] [int] NOT NULL,
	[sell_rena] [int] NOT NULL,
	[sell_credits] [int] NOT NULL,
	[buy_stone] [int] NOT NULL,
	[buy_zen] [int] NOT NULL,
	[buy_rena] [int] NOT NULL,
	[buy_credits] [int] NOT NULL,
	[stock_id] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]

GO
 
Last edited:
Малък ъпдейт

Един бърз ъпдейт - Тестван
1.Добавена опция да си променяте кой джевел да е цената за пускане в маркетта (Работи само за на RaFa депозитера, ако си едитнете табличката може да и го напрaвите универсално... чак толкова няма да ви улеснявами да го правя в конфига)
2. Променя динамично надписите при изключена опция (по подразбиране е 1 Jewel of Creation)



PHP:
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////                                                     / | \                    //
///  uSELEss MaRkET}    ///                                                    /  |  \                   //
///    BY bahtidobriq1  ///                                                  //       \\                 //
///   04'05'2015        ///                                                ///        \\\                //
///http://napipai-go.com///                                                   /      \                   //
///  I love Дриско  !   ///                                                  /        \                  //
///////////////////////////                                            ///////////\\\\\\\\\\             //
//                                                                    //////////////\\\\\\\\\\\\         //
//                                                                  ////////////////\\\\\\\\\\\\\\       //
//                                                                   ^недей три пидирас.. ще ядеш^       //
//                                                                                                       //
//Главен конфиг на модула -> може да се изведе там някъде                                                //    
//Конфигурация на стоката +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    $stock_market['price']        = 1;                       // Изискване за Jewel 1=да 0-не	
    $stock_market['RaFa']         = 1;                       // Ако не ползвте RaFa (DPWeb_JewelDeposit), сетвате 0-ла 
	$stock_market['jewel']        = 2;                       // 1=[bless],2=[soul],3=[chaos],4=[life],5=[creation],6=[guardian]	
    $stock_market['multiplier']   = 1; 	                     // Вкл-Изкл->1-0 Множител на кредити
    $stock_market['multiplier_x'] = 1.2;                     // Коефициент   	
    $stock_market['max_credits']  = 500;                     // Максимум кредити за продаване
    $stock_market['max_rena']     = 2000;                    // Максимална рена за продажба 
    $stock_market['max_zen']      = 2000000000;              // Максимален зен за продажба
    $stock_market['max_stone']    = 2000;                    // Максимални камъни за продажба
	// Каква е аджаба таблицата за рена                  
	$rena_table_name              = '[StoneRena]';           // Наименование на Рена Таблицата
	$rena_column                  = '[Rena]';                // Наименование на Рена колонката
	$rena_user_column             = '[acc]';                 // Наименование на Рена акаунт
	// Каква е аджаба таблицата за стоне
	$stone_table_name             = '[DPWeb_JewelDeposit]';  // Наименование на Стоне Таблицата
	$stone_column                 = '[stone]';               // Наименование на Стоне колонката 
	$stone_user_column            = '[memb___id]';           // Наименование на Стоне акаунт 
	// Каква е аджаба таблицата за зенче
	$zen_table_name               = '[Bank]'  ;              // Наименование на Зен Таблицата
	$zen_column                   = '[Zen]';                 // Наименование на Зен колонката
	$zen_user_column              = '[memb___id]';           // Наименование на Зен акаунт 
	// Каква е аджаба таблицата за кредити
	$credits_table_name           = '[Memb_Credits]' ;       // Наименование на Кредити Таблицата
	$credits_column               = '[Credits]' ;            // Наименование на Кредити колонката
	$credits_user_column          = '[memb___id]';           // Наименование на Кредити акаунт 
	// Каква е aджаба таблицата на джевелите
	$jewels_table_name          = '[DPWeb_JewelDeposit]';  // Наименование на Jewels депозит Таблицата
	$jewels_column              = '[creation]';            // Наименование на Jewels депозит колонката
	$jewels_user_column         = '[memb___id]';           // Наименование на Jewels депозит акаунт 
	$jewel_name                 = 'Creations';             // Наименование на Jewela 
	
	if ($stock_market['jewel'] == 1 and $stock_market['price'] == 1 and $stock_market['RaFa'] == 1){
		$jewels_column = '[bless]';
		$jewel_name = 'Bless';
	}       else {$jewels_column = $jewels_column; $jewel_name = $jewel_name;}
		  if ($stock_market['jewel'] == 2 and $stock_market['price'] == 1  and $stock_market['RaFa'] == 1){
		   $jewels_column = '[soul]';
		   $jewel_name = 'Soul';
	}           else {$jewels_column = $jewels_column; $jewel_name = $jewel_name;}
		     if ($stock_market['jewel'] == 3 and $stock_market['price'] == 1  and $stock_market['RaFa'] == 1){
		      $jewels_column = '[chaos]';
			  $jewel_name = 'Chaos';
	}               else {$jewels_column = $jewels_column; $jewel_name = $jewel_name;}
		        if ($stock_market['jewel'] == 4 and $stock_market['price'] == 1  and $stock_market['RaFa'] == 1){
		         $jewels_column = '[life]';
				 $jewel_name = 'Life';
	}                   else {$jewels_column = $jewels_column; $jewel_name = $jewel_name;}
		           if ($stock_market['jewel'] == 5 and $stock_market['price'] == 1  and $stock_market['RaFa'] == 1){
		            $jewels_column = '[creation]';
					$jewel_name = 'Creation';
	}                       else {$jewels_column = $jewels_column; $jewel_name = $jewel_name;}
			           if ($stock_market['jewel'] == 6 and $stock_market['price'] == 1  and $stock_market['RaFa'] == 1){
		                  $jewels_column = '[guardian]';
						  $jewel_name = 'Guardian';
	}                           else {$jewels_column = $jewels_column; $jewel_name = $jewel_name;}


?>

<?
//Лукчета
function stoke_logs($file_name, $content)
{
	$file_date = date('d_m_Y', time());
    $log_date = date('h:i:s', time());
	$log_content='Date: '.$log_date .' | ' . $content . "\r\n";
	file_put_contents('market_logs/StockMarket/'.$file_name.'['.$file_date.'].log', $log_content, FILE_APPEND);
}


?>


<?php


// Има ли прокси или не?
if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
}
$ip = filter_var($ip, FILTER_VALIDATE_IP);
$ip = ($ip === false) ? '0.0.0.0' : $ip;
$time = date("dM H:i:s");
$link = $_SERVER["REQUEST_URI"];
$category_str = "cat_id=" . $category;
$username = $_SESSION['dt_username'];

// Едно дивче да гледате по-налгедно грешките ми
echo "<div class='nadpis newnadspi'>";

//Извеждане на ресурсите на акаунта от таблиците в Сток Маркет
$is_rena = mssql_fetch_row(mssql_query("Select ".$rena_column." From  ".$rena_table_name." Where  ".$rena_user_column."='{$_SESSION['dt_username']}'"));
$is_zen = mssql_fetch_row(mssql_query("Select  ".$zen_column." From  ".$zen_table_name." Where ".$zen_user_column."   ='{$_SESSION['dt_username']}'"));
$is_credits = mssql_fetch_row(mssql_query("Select ".$credits_column."  From ".$credits_table_name." Where  ".$credits_user_column."='{$_SESSION['dt_username']}'"));
$is_stone = mssql_fetch_row(mssql_query("Select ".$stone_column ." From  ".$stone_table_name." Where ".$stone_user_column."  ='{$_SESSION['dt_username']}'"));
$is_jewel = mssql_fetch_row(mssql_query("Select ".$jewels_column ." From  ".$jewels_table_name." Where ".$jewels_user_column."  ='{$_SESSION['dt_username']}'"));

// Тука купуваме разни ресурси
if (isset($_POST['buy'])) {
		

    $stock_id = secure($_POST['stock_id']);
    $query_stock = mssql_fetch_row(mssql_query("Select * from Stock_Market where stock_id = '" . $stock_id . "' "));
    $seller = $query_stock[0];
    //---- продава ----//$query
    $рена_продава = $query_stock[4];
    $стоне_продава = $query_stock[2];
    $зен_продава = $query_stock[3];
    $кретити_продава = $query_stock[5];
    //----- купува-----/$query
    $кредити_купува = $query_stock[9];
    $рена_купува = $query_stock[8];
    $стоне_купува = $query_stock[6];
    $зен_купува = $query_stock[7];
    //Малко проста аритметика, че се сърдят заявките и ми писна на кура и не съм bahtidobriq1 ами Дриско 2
    $zenplus      =  $is_zen[0]       + $зен_продава;
    $renaplus     =  $is_rena[0]      + $рена_продава;
    $stoneplus    =  $is_stone[0]     + $стоне_продава;
    $zenminus     =  $is_zen[0]       - $зен_купува;
    $renaminus    =  $is_rena[0]      - $рена_купува;
    $stoneminus   =  $is_stone[0]     - $стоне_купува;
    $creditsminus =  $is_credits[0]   - $кредити_купува;
    if ($seller   == $username) {
		if ($stock_market['multiplier'] == 1){
	    $creditsplusa = $query_stock[5]*$stock_market['multiplier_x'];
		$creditsplus = (ceil($creditsplusa))+($is_credits[0]);
	     }
	    else {
	    $creditsplus  =  $is_credits[0]   + $кретити_продава;
	     }
        // Ако акаунта е продавача връщаме му ресурсите там преди 100 лета (Васко Кеца)
        mssql_query("Update ".$rena_table_name." set ".$rena_column."='"  . $renaplus . "' where ".$rena_user_column."  ='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$zen_table_name." set ".$zen_column."= '" .  $zenplus . "' where  ".$zen_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$credits_table_name." set  ".$credits_column." = '" . $creditsplus . "' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$stone_table_name." set ".$stone_column ."  = '" . $stoneplus . "' where  ".$stone_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Delete from Stock_Market where [stock_id]='" . $stock_id . "'");
        show_msg('<span class="nadpisi">These were your resources and have been added to your Web Bank!</span>');
        header("Refresh:3;");
		} 
		else {
        if ($is_rena[0] < $рена_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Rena!</span>');
            header("Refresh:3;");
        } elseif ($is_zen[0] < $зен_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Zen!</span>');
            header("Refresh:3;");
        } elseif ($is_stone[0] < $стоне_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Stone!</span>');
            header("Refresh:3;");
        } elseif ($is_credits[0] < $кредити_купува) {
            show_msg('<span class="nadpisi"> Sorry but you do not have enough Credits!</span>');
            header("Refresh:3;");
        } elseif (($зен_продава[0] + $is_zen[0]) > $option['bank_limit']) {
            show_msg('<span class="nadpisi"> Sorry the maximum Zen  you can have in the bank is ' . $option['bank_limit'] .  '!</span>');
            header("Refresh:3;");
        } else {
			$creditsplus  =  $is_credits[0]   + $кретити_продава;
            // Ако акаунта не е продавача правим някви ъпдейти.. не помня вече
            mssql_query("Update ".$rena_table_name."    set  ".$rena_column."    = '" . $renaminus . "' where ".$rena_user_column."  ='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$zen_table_name."     set  ".$zen_column."     = '". $zenminus .   "' where  ".$zen_user_column."='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$credits_table_name." set  ".$credits_column." = '". $creditsminus."' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$stone_table_name."   set  ".$stone_column ."  = '". $stoneminus . "' where  ".$stone_user_column."='{$_SESSION['dt_username']}'");
            // Добавяме закупените ресурси в Банката на брата
            mssql_query("Update ".$rena_table_name."    set  ".$rena_column."='" . $renaplus . "' where ".$rena_user_column."  ='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$zen_table_name."     set  ".$zen_column." = '" . $zenplus . "' where ".$zen_user_column."   ='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$credits_table_name." set  ".$credits_column." = '" . $creditsplus . "' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
            mssql_query("Update ".$stone_table_name."   set  ".$stone_column ." = '" . $stoneplus . "' where ".$stone_user_column  ."='{$_SESSION['dt_username']}'");
            mssql_query("Delete from Stock_Market where [stock_id]='" . $stock_id . "'");
            show_msg('<span class="nadpisi">' . $_SESSION['dt_username'] . ' bought from the Stock Market!</span>');
            header("Refresh:3;");
        }
    }
    //Правим подробен лог в папка /лукчета/StockMarket
    stoke_logs('StockMarket', '| Buyer: ' . $username . ' | Seller: ' .  $seller . ' | Item: ' . $newitem . ' |Buyer IP: ' . $ip . '| 
	Купил:[Rena]=' . $рена_продава . ',[Zen]=' . $зен_продава .  ',[Credits]=' . $кредити_продава . ',[Stone]=' . $стоне_продава . ', 
	За: [Rena]' . $рена_купува . ',[Zen]=' . $зен_купува . ',[Credits]=' . $кредити_купува . ',[Stone]=' . $стоне_купува);
}
////// ++++++  Функция за продаване +++++++ ////////
// Проверка дали е активирана цена за маркета (Jewel of Creation) и сетване на 0 лева стойност, ако не е - "бахтидобрия"
if ($stock_market['price'] == 1) {
    $stock_price = 1;
} else {
    $stock_price = 0;
}
// Ako сме атакували формата изпълнява се целият сркипт отдолу с име: "Аман"
if (isset($_POST['sellstock']) && $_POST['sellstock'] === '1') {
    //Тикаме всички постчета в променливи ... щото ми е кеФ
    $added         = time();
    $expires       = ($added + (86400 * $stock_market['stock_remove_in']));
    $sell_credita  = (int)secure($_POST['sell_credits']);
    $sell_zen      = (int)secure($_POST['sell_zen']);
    $sell_rena     = (int)secure($_POST['sell_rena']);
    $sell_stone    = (int)secure($_POST['sell_stone']);
    $buy_credits   = (int)secure($_POST['buy_credits']);
    $buy_zen       = (int)secure($_POST['buy_zen']);
    $buy_rena      = (int)secure($_POST['buy_rena']);
    $buy_stone     = (int)secure($_POST['buy_stone']);
	// Да видим има ли тарикати да пренасят кредити от акаунт в акаунт. Ако  не искаме да има тарикати им подаваме множителя на bahtidobriq1
	if ($stock_market['multiplier'] == 1){
		$sell_credit    = $sell_credita*$stock_market['multiplier_x'];
		$sell_credits   = ceil($sell_credit);
		$insert_credits = $sell_credita;
		$start1= '<li>If you sell credits you have to pay the credits x '.$stock_market['multiplier_x'].'</li>';
		$spec_message = '<span class="nadpisi">You can not sell ' .  $is_credits[0] . ' credits because you have to pay <font  color="#FF4C4C">' . $sell_credits . '</font>!</span>';
	    $кретити_продава1 = $query_stock[5]*$stock_market['multiplier_x'];
		$кретити_продава = ceil($кретити_продава1);
	}
	else {
		$sell_credits = $sell_credita;
		$insert_credits = $sell_credita;
		$start1= '';
		$spec_message = '<span class="nadpisi">You can not sell ' .  $sell_credits . ' Credits because you have ' . $is_credits[0] .  '!</span>';
	    $кретити_продава = $query_stock[5];
	}
    // Вкарваме в променливи остатъка след продажбата
    $newstone      = $is_stone[0]   - $sell_stone;
    $newcredits    = $is_credits[0] - $sell_credits;
    $newrena       = $is_rena[0]    - $sell_rena;
    $newzen        = $is_zen[0]     - $sell_zen;
    // Проверки за формата, какво се въвежда и дали акаунта има  ресурсите за продаване в наличност - "Аийшстига е.. туй аз ли съм ве?"
    // Проверка дали купуването на зен ще прехвърли лимита на банката сетнат в конфига - "Аийшстига е.. туй аз ли съм ве?"
    if (($is_jewel[0] < $stock_price)) {
        show_msg('<span class="nadpisi"> To post item for selling  you need to pay one Jewel of '.$jewel_name.'!</span>');
        header("Refresh:3;");
    } elseif (($sell_credits > 0) and ($buy_credits > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif (($sell_rena > 0) and ($buy_rena > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif (($sell_zen > 0) and ($buy_zen > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif (($sell_stone > 0) and ($buy_stone > 0)) {
        show_msg('<span class="nadpisi">You can not sell for the same resources!</span>');
        header("Refresh:3;");
    } elseif ($sell_zen > $is_zen[0]) {
        show_msg('<span class="nadpisi">You can not sell ' .  $sell_zen . ' Zen because you have ' . $is_zen[0] . ' in the Web  Bank!</span>');
        header("Refresh:3;");
    } elseif ($sell_credits > $is_credits[0]) {
        show_msg(''.$spec_message.'');
        header("Refresh:3;");
    } elseif ($sell_rena > $is_rena[0]) {
        show_msg('<span class="nadpisi">You can not sell ' .  $sell_rena . ' Rena because you have ' . $is_rena[0] . ' in the Web  Bank!</span>');
        header("Refresh:3;");
    } elseif ($sell_stone > $is_stone[0]) {
        show_msg('<span class="nadpisi">You can not sell ' .  $sell_stone . ' Stone because you have ' . $is_stone[0] . ' in the Web  Bank!</span>');
        header("Refresh:3;");
    } elseif ($sell_credits < 0 || $credits > $stock_market['max_credits']) {
        show_msg('<span class="nadpisi">Invalid Credits price,  maximum is ' . $stock_market['max_credits'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_rena < 0 || $sell_rena > $stock_market['max_rena']) {
        show_msg('<span class="nadpisi">Invalid Rena price, maximum is ' . $stock_market['max_rena'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_stone < 0 || $sell_stone > $stock_market['max_stone']) {
        show_msg('<span class="nadpisi">Invalid Stone price,  maximum is ' . $stock_market['max_stone'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_zen < 0 || $sell_zen > $stock_market['max_zen']) {
        show_msg('<span sclass="nadpisi">Invalid Zen price, maximum is ' . $stock_market['max_zen'] . '!</span>');
        header("Refresh:3;");
    } elseif ($sell_credits == 0 && $sell_zen == 0 && $sell_rena == 0 && $sell_stone == 0) {
        show_msg('<span class="nadpisi">Please type what are you selling!</span>');
        header("Refresh:3;");
	} elseif ($sell_credits > 0 and ($buy_credits == 0 &&  $buy_zen == 0 && $buy_rena == 0 && $buy_stone == 0)) {
        show_msg('<span class="nadpisi">Please type what you want  to exchange your '.$sell_credits.' credits for!</span>');
        header("Refresh:3;");
	} elseif ($sell_rena > 0 and ($buy_credits == 0 && $buy_zen == 0 && $buy_stone == 0)) {
        show_msg('<span class="nadpisi">Please type what you want  to exchange your '.$sell_rena.' Rena for!</span>');
        header("Refresh:3;");
	} elseif ($sell_stone > 0 and ($buy_credits == 0 && $buy_zen == 0 && $buy_rena == 0)) {
        show_msg('<span class="nadpisi">Please type what you want  to exchange your '.$sell_stone.' Stone for!</span>');
        header("Refresh:3;");
	} elseif ($sell_zen > 0 and ($buy_credits == 0 && $buy_stone == 0 && $buy_rena == 0)) {
        show_msg('<span class="nadpisi">Please type what you want to exchange your '.$sell_zen.' Zen for!</span>');
        header("Refresh:3;");
    } elseif ($buy_credits == 0 && $buy_zen == 0 && $buy_rena == 0 && $buy_stone == 0) {
        show_msg('<span class="nadpisi">Please type what are you selling for!</span>');
        header("Refresh:3;");
    }
    //Ако япма грешки, изълнява долу ташака
    else {
        mssql_query("Update ".$stone_table_name."    set ".$stone_column  ."    ='" . $newstone . "' where ".$stone_user_column  ."='{$_SESSION['dt_username']}' ");
        mssql_query("Update ".$rena_table_name."     set  ".$rena_column."      ='" . $newrena  . "' where  ".$rena_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$credits_table_name."  set  ".$credits_column."   ='" . $newcredits."' where  ".$credits_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$zen_table_name."      set ".$zen_column."        ='" . $newzen  . "'  where  ".$zen_user_column."='{$_SESSION['dt_username']}'");
        mssql_query("Update ".$jewels_table_name."   set  ".$jewels_column ."   = ".$jewels_column ." - '" . $stock_price."' where  ".$jewels_user_column."='" . $username . "'");
        mssql_query("INSERT INTO [Stock_Market](
		account,
		date,
		sell_stone,
		sell_zen,
		sell_rena,
		sell_credits,
		buy_stone,
		buy_zen,
		buy_rena,
		buy_credits)
		VALUES (
		'" . $username . "',
		'" . $added . "',
		'" . $sell_stone . "',
        '" . $sell_zen . "',
        '" . $sell_rena . "',
        '" . $insert_credits . "',
        '" . $buy_stone . "',
        '" . $buy_zen . "',
        '" . $buy_rena . "',
        '" . $buy_credits . "'		
		)");
        show_msg('
		<span class="bahtidobriq1">
		You have successfully listed <font color="#FFDC73"></font> for sell in the Stock Market!</span>', 1);
        header("Refresh:2;");
    }
}
echo "</div>";
// Показваме някви надписи ако ала бала - бала ала
if ($stock_market['price'] == 1) {
    $start = '<li>You must to pay <font  color="purple"><b>1 Jewel of  '.$jewel_name.'</b></font> to sell item</li>';
} else {
    $start = '';
}
if ($stock_market['multiplier'] == 1){
$start1= '<li>If you sell credits you will pay the credits x '.$stock_market['multiplier_x'].'</li>';
}else {
	 $start1 = '';
}
?>
<div class="bahtidobriq1"style='margin-left:10px;padding:10px 10px;color:#fff;text-shadow:1px 1px #000;width:550px;'>

           <?=$start;?> 
		   	<?=$start1;?>
           <li>When someone buy your stock the full price (zen,  credits, stone, rena) will be automatically added into your web  bank</li>
	


<div class="bahtidobriq1"style='margin-left:10px;padding:10px 10px;color:#fff;text-shadow:1px 1px #000;width:550px;'>
  <form style="margin-left:50px;"class="new" method="post" action="">
	 <table   align="center" style="padding:10px 10px;margin-left:10px;text-align: center; font-size: 10pt; color: white;">
         <tr class="title">
	          <td colspan="10">Stock Market</td>
           </tr>
        <tr style="padding:10px 10px"class="title-front">
	          <td style="padding:10px 10px ;font-size:12pt;color:#FFFFF2" colspan="10">Sell:</p></td>
          </tr>	
		<tr>
		      <td>Zen</td>
			  <td>Rena</td>				
			  <td>Credits</td>
			  <td>Stones</td>
		  </tr>
		<tr>
			  <td><input type="text" name="sell_zen" maxlength="13"  onkeyup="return isNumber(this)" style="height: 22px;  width:  100px;"/></td>
			  <td><input type="text" size="3" name="sell_rena"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px; text-align: center;"/></td>
			  <td><input type="text" size="3" name="sell_credits"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
			  <td><input type="text" size="3" name="sell_stone"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
		  </tr>
		<tr style="padding:10px 10px"class="title-front">
	<td style="padding:10px 10px ;font-size:12pt;" colspan="10">For:</p></td>
</tr>	
		      <td>Zen</td>
			  <td>Rena</td>				
			  <td>Credits</td>
			  <td>Stones</td>
		  </tr>
		<tr>
			<td><input type="text" name="buy_zen" maxlength="13"  onkeyup="return isNumber(this)" style="height: 22px;  width:  100px;"/></td>
			<td><input type="text" size="3" name="buy_rena"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px; text-align: center;"/></td>
			<td><input type="text" size="3" name="buy_credits"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
			<td><input type="text" size="3" name="buy_stone"  maxlength="3" onkeyup="return isNumber(this)" style="height: 22px;  width:80px;"/></td>
		</tr>

</table>
    <div style="margin-top:10px;margin-left:180px;">
		<input type="hidden" name="sellstock" value="1" />
		<input type="submit" class="newaa" Value="Sell Resources" /></div>
</form>

<?php
// Вадим информацията (ако има) и я тикаме в хтмл-а на момчето
if (isset($_POST['search_seller'])) {
    $query = mssql_query("Select * from Stock_Market where account ='" . secure($_POST['seller']) . "'");
// Aко са кликнали в/у търсене на всички ресурси от потребителя променя съобщението на "Аман бе Пешо"
    echo "<div class='nadpisi top title'>All Stocks from " . secure($_POST['seller']) . "</div>";
    while ($allmarket = mssql_fetch_row($query)):
        $added_on     = date("d-m-Y H:i", $allmarket[1]);
        $renasell     = $allmarket[4];
        $renabuy      = $allmarket[8];
        $sellcr       = $allmarket[5];
        $buycr        = $allmarket[9];
        $sellzen      = $allmarket[3];
        $buyzen       = $allmarket[7];
        $sellstone    = $allmarket[2];
        $buystone     = $allmarket[6];
// Крием нулеви стойности с одеялото
        if ($renasell == 0) {
            $renasell = '';
        } else {
            $renasell = '<font color="#73DCFF"> ' . $allmarket[4] . ' Rena</font>';
        }
        if ($renabuy == 0) {
            $renabuy = '';
        } else {
            $renabuy = '<font color="#73DCFF"> ' . $allmarket[8] . ' Rena</font>';
        }
        if ($sellcr == 0) {
            $sellcr = '';
        } else {
            $sellcr = '<font color="#FFFF4C"> ' . $allmarket[5] . ' Credits</font>';
        }
        if ($buycr == 0) {
            $buycr = '';
        } else {
            $buycr = '<font color="#FFFF4C"> ' . $allmarket[9] . ' Credits</font>';
        }
        if ($sellzen == 0) {
            $sellzen = '';
        } else {
            $sellzen = '<font color="#FFBF00"> ' . $allmarket[3] . ' Zen</font>';
        }
        if ($buyzen == 0) {
            $buyzen = '';
        } else {
            $buyzen = '<font color="#FFBF00"> ' . $allmarket[7] . ' Zen</font>';
        }
        if ($sellstone == 0) {
            $sellstone = '';
        } else {
            $sellstone = '<font color="#8A8A7B"> ' . $allmarket[2] . ' Stone</font>';
        }
        if ($buystone == 0) {
            $buystone = '';
        } else {
            $buystone = '<font color="#8A8A7B"> ' . $allmarket[6] . ' Stone</font>';
        }
?>
<table class="bahtidobriq1 nasko"align="center" width="500">  
   <form class="new" method='post' action=''>	  
	     <td>
		  <input name='stock_id' type='hidden' value="<?php echo $allmarket[10]; ?>"class="buyimage"/>
	      <input name='buy' type='submit' value="Buy Now"class="buyimage"/>
	         </td>
			    	
	   <td style="text-align:left;font-size:9pt;">
		  <p style="display:inline-table;color:#FFFFF2">Added  on:</p> <p   style="display:inline-table;color:#999;"><?php echo $added_on;  ?></p></p>
	      <p style="display:inline-table;color:#FFFFF2">Sell:     </p><?echo $sellcr?> <?echo $sellzen?> <?echo  $sellstone?> <?echo $renasell?> </p>
		  <p style="display:inline-table;color:#FFFFF2">For:      </p><?echo $buycr?> <?echo $buyzen?> <?echo  $buystone?> <?echo $renabuy?> </p>		
		  <p  style="display:inline-table;color:#FFFFF2">Merchant:</p> <p  style="display:inline-table;color:#999;"><?php echo $allmarket[0];  ?><input name='seller' type='hidden' value='<?php echo  $allmarket[0]; ?>'/></font> 
          <span style="margin-left:3px;">
		  <input class= 'buttons_new' type='submit' name='all_items' value  ='Back to all stock' class='buttons'/></span></p>
              </td> 
       <td>
	      <img width="60px" height="60px"src="./images/mu.png"/>
		      </td>
  
	  </form>					
</table>


<? 
endwhile;
  }
else{
echo "<div class='nadpisi top title'>All Stocks in the Market</div>";
$query = mssql_query("Select * from Stock_market");
while ($allmarket  = mssql_fetch_row($query)):
        $added_on  = date("d-m-Y H:i",$allmarket[1]);
        $renasell  = $allmarket[4];
        $renabuy   = $allmarket[8];
        $sellcr    = $allmarket[5];
        $buycr     = $allmarket[9];
        $sellzen   = $allmarket[3];
        $buyzen    = $allmarket[7];
        $sellstone = $allmarket[2];
        $buystone  = $allmarket[6];
// "Така кажи ве" 
            if ($renasell   == 0) {$renasell  ='';}else {$renasell =  '<font color="#73DCFF"> '.$allmarket[4]. ' Rena</font>';}
            if ($renabuy    == 0) {$renabuy   ='';}else {$renabuy  =  '<font color="#73DCFF"> '.$allmarket[8]. ' Rena</font>';}
            if ($sellcr     == 0) {$sellcr    ='';}else {$sellcr   =  '<font color="#FFFF4C"> '.$allmarket[5]. ' Credits</font>';}
            if ($buycr      == 0) {$buycr     ='';}else {$buycr    =  '<font color="#FFFF4C"> '.$allmarket[9]. ' Credits</font>';}
            if ($sellzen    == 0) {$sellzen   ='';}else {$sellzen  =  '<font color="#FFBF00"> '.$allmarket[3]. ' Zen</font>';}
            if ($buyzen     == 0) {$buyzen    ='';}else {$buyzen   =  '<font color="#FFBF00"> '.$allmarket[7]. ' Zen</font>';}
            if ($sellstone  == 0) {$sellstone ='';}else {$sellstone=  '<font color="#8A8A7B"> '.$allmarket[2]. ' Stone</font>';}
            if ($buystone   == 0) {$buystone  ='';}else {$buystone =  '<font color="#8A8A7B"> '.$allmarket[6]. ' Stone</font>';}

   ?>
<table class="nasko"align="center" width="500">  
	     <td><form action="" method="post">
		 <p><?echo $sellcr?> <?echo $sellzen?> <?echo $sellstone?> <?echo $renasell?></p>
		  <input name='stock_id' type='hidden' value="<?php echo $allmarket[10]; ?>"class="buyimage"/>
	     <p><input name='buy' type='submit' value="Buy Now"class="buyimage"/></p>
	         </td>
			    <form class="new"method='post' action=''></td>
	   <td style="text-align:left;font-size:9pt;">
		  <p style="display:inline-table;color:#FFFFF2">Added  on:</p> <p   style="display:inline-table;color:#999;"><?php echo $added_on;  ?></p></p>
	      <p style="display:inline-table;color:#FFFFF2">Sell:     </p><?echo $sellcr?> <?echo $sellzen?> <?echo  $sellstone?> <?echo $renasell?> </p>
		  <p style="display:inline-table;color:#FFFFF2">For:      </p><?echo $buycr?> <?echo $buyzen?> <?echo  $buystone?> <?echo $renabuy?> </p>		
		  <p  style="display:inline-table;color:#FFFFF2">Merchant:</p> <p  style="display:inline-table;color:#999;"><?php echo $allmarket[0];  ?><input name='seller' type='hidden' value='<?php echo  $allmarket[0]; ?>'/></font> 
          <span style="margin-left:3px;">
		  <input class= 'buttons_new' type='submit' name='search_seller'  value ='All stock from this seller'  class='buttons'/></span></p>
              </td> 
       <td>
	      <img width="60px" height="60px"src="./images/mu.png"/>
		      </td>
  
	  </form>					
</table>


<? 
endwhile;}
?>







<style>
.buyimage {
  color:#ACAC9D;
  cursor:pointer;
  text-shadow:1px 1px #000;
  }
.buyimage:hover {
   color:#FFFFF2;
  cursor:pointer;
  text-shadow:1px 1px #000;
  }
.nasko{ overflow:auto;
line-height:15px;
padding-top:15px;
margin-bottom:10px;
position : relative;
margin-left:25px;
border-radius: 10px 10px 10px 10px;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
border-top: 1px solid #686859;
background-image:url('../images/bgstock.png') ;
background-size:570px 70px;
background-repeat: no-repeat;

}

.nadpisi{
	text-align:center;
	color:fff;
	text-shadow:1px 1px #000;
	font-size:10pt;
}
.top{
	margin-top:20px;
	width:490px;
	margin-left:25px;
}
.newaa:{
	color:444;
	cursor:pointer;
}
.newaa:hover{
	color:fff;
		cursor:pointer;
}
.newnadspi{
	background:#111111;
	width:500px;
	height:20px;
	margin-left:25px;
	border-radius:15px 15px 0px 0px;
	border:1px solid #331818;
}

</style>
 
Last edited:
Без функциите за депозит ми изглежда това нещо напълно безполезно.
 
  • Like
Reactions: satanism
Status
Not open for further replies.