Guest User

auction

a guest
Sep 16th, 2013
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.65 KB | None | 0 0
  1. <style>
  2. body {
  3.     margin: 0;
  4.     background:#ddd;
  5. }
  6. h2 {
  7.     margin:5px;
  8. }
  9. table {
  10.     border-collapse:collapse;
  11.     background:#333;
  12.     color:#BBB;
  13. }
  14. th {
  15.     border-left:1px solid #000;
  16.     border-right:1px solid #000;
  17.     border-bottom:1px solid #000;
  18.     color:#fe5;
  19. }
  20. #border {
  21.     border-left:1px solid #000;
  22.     border-right:1px solid #000;
  23.     border-bottom:1px solid #000;
  24. }
  25. #border td {
  26.     border-left:1px solid #000;
  27.     border-right:1px solid #000;   
  28. }
  29. .pages {
  30.     width:600px;
  31.     text-align:center;
  32. }
  33. .paginate {
  34. font-family:Arial, Helvetica, sans-serif;
  35.     padding: 3px;
  36.     margin: 3px;
  37. }
  38.  
  39. .paginate a {
  40.     padding:2px 5px 2px 5px;
  41.     margin:2px;
  42.     border:1px solid #999;
  43.     text-decoration:none;
  44.     color: #666;
  45. }
  46. .paginate a:hover, .paginate a:active {
  47.     border: 1px solid #999;
  48.     color: #000;
  49. }
  50. .paginate span.current {
  51.     margin: 2px;
  52.     padding: 2px 5px 2px 5px;
  53.     border: 1px solid #999;
  54.     font-weight: bold;
  55.     background-color: #999;
  56.     color: #FFF;
  57. }
  58. .paginate span.disabled {
  59.     padding:2px 5px 2px 5px;
  60.     margin:2px;
  61.     border:1px solid #eee;
  62.     color:#BBB;
  63. }
  64. td a:link {
  65.     color:#BBB;
  66. }
  67. td a:hover {
  68.     color:#BBB;
  69.     text-decoration:none;
  70. }
  71. td a:active {
  72.     color:#BBB;
  73. }
  74. td a:visited {
  75.     color:#BBB;
  76. }
  77. </style>
  78. <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script>
  79. <script type="text/javascript">
  80. var a = document.getElementsByTagName("a")
  81. for( i=0; i<a.length; i++ ){
  82. if( a[i].href.indexOf("http://" + document.domain + "/click.php?http://") != -1 )
  83. {a[i].href = "http://" + a[i].href.substring(a[i].href.lastIndexOf("http://")+7)}
  84. }
  85. </script>
  86. <?php
  87. $host = 'localhost';
  88. $user = 'root';
  89. $pass = '';
  90. $cdb = 'characters';
  91. $wdb = 'world';
  92. $targetpage = "auction.php"; // Ссылка на эту страницу
  93. $limit = 10; // Сколько выводить результатов на страницу
  94.  
  95. $connect = mysql_connect($host,$user,$pass) or die('Нет подключения к базе данных');
  96. mysql_select_db ($cdb, $connect) or die(mysql_error());
  97. print "<h2 align=\"center\">Аукцион</h2>
  98. <table cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"900\"><tr>
  99. <th width=\"30\">№</th>
  100. <th width=\"120\">Продавец</th>
  101. <th>Итем</th>
  102. <th width=\"90\">Количество</th>
  103. <th width=\"120\">Ставка</th>
  104. <th width=\"120\">Выкуп</th>
  105. <th width=\"120\">Добавлено</th>
  106. </tr></table>";
  107.  
  108. $query = "SELECT COUNT(*) as num FROM `auctionhouse`";
  109. $total_pages = mysql_fetch_array(mysql_query($query));
  110. $total_pages = $total_pages[num];
  111.  
  112. $stages = 3;
  113. $page = mysql_escape_string(intval($_GET['page']));
  114. if($page){
  115.     $start = ($page - 1) * $limit;
  116. }else{
  117.     $start = 0;
  118.     }  
  119.  
  120. $sql = mysql_query("SET NAMES cp1251");
  121. $sql = mysql_query("SELECT * FROM `auctionhouse` ORDER BY `time` DESC LIMIT $start, $limit", $connect) or die(mysql_error());
  122.  
  123. if ($page == 0){$page = 1;}
  124. $prev = $page - 1;
  125. $next = $page + 1;
  126. $lastpage = ceil($total_pages/$limit);
  127. $LastPagem1 = $lastpage - 1;                    
  128.  
  129. $paginate = '';
  130. if($lastpage > 1)
  131. {  
  132.  
  133.     $paginate .= "<div class='paginate'>";
  134.     if ($page > 1){
  135.         $paginate.= "<a href='$targetpage?page=$prev'>Назад</a>";
  136.     }else{
  137.         $paginate.= "<span class='disabled'>Назад</span>"; }
  138.  
  139.     if ($lastpage < 7 + ($stages * 2))  
  140.     {
  141.         for ($counter = 1; $counter <= $lastpage; $counter++)
  142.         {
  143.             if ($counter == $page){
  144.                 $paginate.= "<span class='current'>$counter</span>";
  145.             }else{
  146.                 $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
  147.         }
  148.     }
  149.     elseif($lastpage > 5 + ($stages * 2))    
  150.     {
  151.         if($page < 1 + ($stages * 2))
  152.         {
  153.             for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
  154.             {
  155.                 if ($counter == $page){
  156.                     $paginate.= "<span class='current'>$counter</span>";
  157.                 }else{
  158.                     $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
  159.             }
  160.             $paginate.= "...";
  161.             $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
  162.             $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
  163.         }
  164.         elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
  165.         {
  166.             $paginate.= "<a href='$targetpage?page=1'>1</a>";
  167.             $paginate.= "<a href='$targetpage?page=2'>2</a>";
  168.             $paginate.= "...";
  169.             for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
  170.             {
  171.                 if ($counter == $page){
  172.                     $paginate.= "<span class='current'>$counter</span>";
  173.                 }else{
  174.                     $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
  175.             }
  176.             $paginate.= "...";
  177.             $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
  178.             $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
  179.         }
  180.         else
  181.         {
  182.             $paginate.= "<a href='$targetpage?page=1'>1</a>";
  183.             $paginate.= "<a href='$targetpage?page=2'>2</a>";
  184.             $paginate.= "...";
  185.             for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
  186.             {
  187.                 if ($counter == $page){
  188.                     $paginate.= "<span class='current'>$counter</span>";
  189.                 }else{
  190.                     $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
  191.             }
  192.         }
  193.     }
  194.  
  195.     if ($page < $counter - 1){
  196.         $paginate.= "<a href='$targetpage?page=$next'>Далее</a>";
  197.     }else{
  198.         $paginate.= "<span class='disabled'>Далее</span>";
  199.         }
  200.  
  201.     $paginate.= "</div>";      
  202.  
  203. }
  204. $id = 1;
  205. if ($_GET['page'] != 1)
  206.     $id = $start + 1;
  207. while ($result = mysql_fetch_array($sql)){
  208.     $guid = $result['itemowner'];
  209.     $buyprice = $result['buyoutprice'];
  210.     $item_guid = $result['itemguid'];
  211.     $time = date("H:i:s d.m.Y", $result['time']);
  212.     $gold = (int)($buyprice / 10000);
  213.     $total = $buyprice - ($gold * 10000);
  214.     $silver = (int)($total / 100);
  215.     $cooper = $total - ($silver * 100);
  216.     if ($result['lastbid'] == 0 || $result['lastbid'] == $result['startbid'])
  217.         $bid = $result['startbid'];
  218.     else
  219.         $bid = $result['lastbid']; 
  220.     $gold_bid = (int)($bid / 10000);
  221.     $total_bid = $bid - ($gold_bid* 10000);
  222.     $silver_bid = (int)($total_bid / 100);
  223.     $cooper_bid = $total_bid - ($silver_bid * 100);
  224.     $sql_item = mysql_query("SELECT `itemEntry`, `count` FROM `item_instance` WHERE `guid` = $item_guid", $connect) or die(mysql_error());
  225.     $result_item = mysql_fetch_array($sql_item);
  226.     $item = $result_item['itemEntry'];
  227.     $item_count = $result_item['count'];
  228.     $sql_char = mysql_query("SET NAMES cp1251");
  229.     $sql_char = mysql_query("SELECT `name` FROM `characters` WHERE `guid` = $guid", $connect) or die(mysql_error());
  230.     $result_char = mysql_fetch_array($sql_char);
  231.     $name = $result_char['name'];
  232.     $sql_item_name = mysql_query("SET NAMES cp1251");
  233.     mysql_select_db($wdb, $connect) or die(mysql_error());
  234.     $sql_item_name = mysql_query("SELECT `name_loc8` FROM `locales_item` WHERE `entry` = $item", $connect) or die(mysql_error());
  235.     $result_item_name = mysql_fetch_array($sql_item_name);
  236.     $item_name = $result_item_name['name_loc8'];
  237.     mysql_select_db($cdb, $connect) or die(mysql_error());
  238.        
  239.     print "<table cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"900\" id=\"border\"><tr>
  240.     <td align=\"center\" width=\"30\">$id</td>
  241.     <td align=\"center\" width=\"120\">$name</td>
  242.     <td align=\"center\"><a href=\"http://ru.wowhead.com/item=$item\">$item_name</a></td>
  243.     <td align=\"center\" width=\"90\">$item_count</td>
  244.     <td align=\"center\" width=\"120\"><font color=\"gold\">$gold_bid г.</font> <font color=\"silver\">$silver_bid с.</font> <font color=\"coral\">$cooper_bid м.</font></td>
  245.     <td align=\"center\" width=\"120\"><font color=\"gold\">$gold г.</font> <font color=\"silver\">$silver с.</font> <font color=\"coral\">$cooper м.</font></td>
  246.     <td align=\"center\" width=\"120\">$time</td>
  247.     </tr></table>";
  248.     $id++; 
  249. }
  250. print "<br><center>$paginate</center>";
  251. mysql_close($connect);
  252. ?>
Advertisement
Add Comment
Please, Sign In to add comment