Advertisement
Guest User

Admin pocetna

a guest
Dec 2nd, 2016
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.23 KB | None | 0 0
  1. <?php
  2.  
  3. include("header.php");
  4.  
  5.  
  6. // Login
  7. if (isset($_POST['login'])) {
  8.     $username = htmlspecialchars(mysql_real_escape_string(addslashes($_POST['username'])));
  9.     $password = htmlspecialchars(mysql_real_escape_string(addslashes($_POST['password'])));
  10.     $cpass = md5($password);
  11.     $kveri = mysqli_query($con,"SELECT * FROM users WHERE username='$username' AND password='$cpass' AND rank='1'");
  12.  
  13.     if (mysqli_num_rows($kveri)) {
  14.         $user = mysqli_fetch_array($kveri);
  15.         $_SESSION['userid'] = $user['userid'];
  16.         $_SESSION['username'] = $user['username'];
  17.         $mesec = 24*60*60*31; // mesec dana
  18.         $user_ip = $_SERVER['REMOTE_ADDR'];
  19.        
  20.         $time = time();
  21.        
  22.         $sesija = md5($user['username'] . $cpass);
  23.        
  24.         setcookie("userid", $_SESSION['user_id'], time()+ $mesec);
  25.         setcookie("username", $_SESSION['username'], time()+ $mesec);
  26.         setcookie("sesija", $sesija, time() + $mesec);
  27.        
  28.         $_SESSION['ok'] = "Uspesno ste se ulogovali!";
  29.         header("Location: index.php");
  30.         die();
  31.        
  32.     } else {
  33.         $_SESSION['error'] = "Doslo je do greske!";
  34.         header("location: index.php");
  35.         die();
  36.     }
  37. }
  38.  
  39. ?>
  40.  
  41. <div class="row">
  42.     <div class="col-md-12">
  43.    
  44.         <h1><i class="fa fa-lock" aria-hidden="true"></i> ADMIN PANEL </h1>
  45.  
  46.         <?php if($_SESSION['userid'] == "") { ?>
  47.        
  48.             <p class="lead"> Dobrodosli u <b>AdminPanel</b>
  49.                 <br /> Morate se ulogovati kako bi pristupili punom sadrzaju sajta! <br />
  50.             </p>
  51.        
  52.         <?php }
  53.  
  54.             if ($user['rank'] == "1") {
  55.  
  56.         ?>
  57.    
  58.         Dobrodosao nazad, <b><?php echo $user['ime']; ?></b>
  59.        
  60.         <hr />
  61.        
  62.         <h3>Aktivnosti</h3>
  63.        
  64.         <table style="width:100%;" class="table table-striped">
  65.             <tbody>
  66.            
  67.                 <th></th>
  68.                 <th></th>
  69.                 <th>Dodato pre</th>
  70.                 <th>Datum</th>
  71.                 <th>IP Korisnika</th>
  72.        
  73.                 <?php
  74.  
  75.                     $rec_page=20; // Number of records to be displayed on a page
  76.              
  77.                     if (isset($_GET["page"])) {
  78.                         $page = $_GET["page"];
  79.                     }  else {
  80.                         $page=1;  
  81.                     }
  82.              
  83.                     $start = ($page-1) * $rec_page;        
  84.                    
  85.                     $sql = "SELECT * FROM serveri ORDER by id DESC LIMIT $start, $rec_page";
  86.  
  87.                     $kveri = mysqli_query($con,$sql);
  88.                    
  89.                     $provera = mysqli_num_rows($kveri);
  90.                    
  91.                     if($provera < 1) {
  92.                         echo "Nema rezultata...";
  93.                     }
  94.  
  95.                     while($red = mysqli_fetch_array($kveri)) {
  96.                        
  97.                         $ip = $red['ip'];
  98.                         $number++;
  99.                            
  100.                         $igra = ServerInfo($ip,'game');      
  101.                        
  102.                         if($igra) {
  103.                             switch($igra) {
  104.                                 case "Counter Strike 1.6":
  105.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-cs.png'>";
  106.                                     break;
  107.                                 case "San Andreas Multiplayer":
  108.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-samp.png'>";
  109.                                     break;
  110.                                 case "Counter Strike Source":
  111.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-css.png'>";
  112.                                     break;             
  113.                                 case "Counter Strike Global Offensive":
  114.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-csgo.png'>";
  115.                                     break;             
  116.                                 case "Call of Duty 2":
  117.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-cod2.png'>";
  118.                                     break;                                                 
  119.                                 case "Call of Duty 4":
  120.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-cod4.png'>";
  121.                                     break;
  122.                                 case "Minecraft":
  123.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-minecraft.png'>";
  124.                                     break;
  125.                                 case "Team Fortress 2":
  126.                                     $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-tf2.png'>";
  127.                                     break;
  128.                            
  129.                             }
  130.                         }
  131.                     ?>
  132.  
  133.                         <tr>
  134.                             <td style="font-size:16px;"><b><?php echo $number; ?>.</b> </td>
  135.                             <td>Server <strong> <?php echo $igra; ?>  <?php echo '<img style="width:18px;" src="'.ServerInfo($ip, 'country_flag').'" />'; ?>   <?php echo ServerInfo($ip,'name'); ?></strong> je dodat.</td>
  136.                             <td><?php echo time_ago($red['vreme']); ?></td>
  137.                             <td><?php echo $red['datum']; ?></td>
  138.                             <td><?php echo $red['ip_pc']; ?></td>
  139.                             <td> <a href="manage.php?id=<?php echo $red['id']; ?>"><i class="fa fa-edit"></i> Manage </a> </td>
  140.                             <td> <a href="delete.php?id=<?php echo $red['id']; ?>"><span class="fa fa-trash"></span> Delete </a> </td> 
  141.                         </tr>
  142.  
  143.                     <?php } ?>
  144.             </tbody>       
  145.         </table>   
  146.        
  147.         <ul class="pagination">
  148.  
  149.             <?php
  150.  
  151.                 $sql = "SELECT * FROM serveri";
  152.  
  153.                 $djoxi = mysqli_query($con,$sql);
  154.  
  155.                 $total_recs = mysqli_num_rows($djoxi); //count number of records
  156.                 $total_pages = ceil($total_recs / $rec_page);
  157.  
  158.                 echo "
  159.                     <li>
  160.                         <a href='?page=1' aria-label='Previous'>
  161.                             <span aria-hidden='true'>&laquo;</span>
  162.                         </a>
  163.                     </li>      
  164.                 "; // For 1st page
  165.  
  166.                 for ($i=1; $i<=$total_pages; $i++) {
  167.                     echo "<li><a href='?page=".$i."'>". $i. "</a></li> ";
  168.                 }
  169.  
  170.                 echo "
  171.                     <li>
  172.                         <a href='?page=$total_pages' aria-label='Next'>
  173.                         <span aria-hidden='true'>&raquo;</span>
  174.                         </a>
  175.                     </li>      
  176.                 ";
  177.             ?> 
  178.  
  179.         </ul>
  180.  
  181.         <h3>Istaknuti serveri</h3>
  182.    
  183.         <table style="width:100%;" class="table table-striped">
  184.             <tbody>
  185.                
  186.                 <th></th>
  187.                 <th></th>
  188.                 <th>Dodato pre</th>
  189.                 <th>Datum</th>
  190.                 <th>IP Korisnika</th>
  191.                
  192.             <?php
  193.  
  194.                 $rec_page=20; // Number of records to be displayed on a page
  195.          
  196.                 if (isset($_GET["page"])) {
  197.                     $page = $_GET["page"];
  198.                 } else {
  199.                     $page=1;  
  200.                 }
  201.          
  202.                 $start = ($page-1) * $rec_page;        
  203.                
  204.                 $sql = "SELECT * FROM serveri WHERE istaknuto='1' ORDER by id DESC LIMIT $start, $rec_page";
  205.  
  206.                 $kveri = mysqli_query($con,$sql);
  207.                
  208.                 $provera = mysqli_num_rows($kveri);
  209.                
  210.                 if($provera < 1) {
  211.                    
  212.                     echo "Nema rezultata...";
  213.                    
  214.                 }
  215.  
  216.                 while($red = mysqli_fetch_array($kveri)) {
  217.                    
  218.                     $ip = $red['ip'];
  219.                     $number2++;
  220.  
  221.                     $igra = ServerInfo($ip,'game');      
  222.                     if($igra) {
  223.                         switch($igra) {
  224.                             case "Counter Strike 1.6":
  225.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-cs.png'>";
  226.                                 break;
  227.                             case "San Andreas Multiplayer":
  228.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-samp.png'>";
  229.                                 break;
  230.                             case "Counter Strike Source":
  231.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-css.png'>";
  232.                                 break;             
  233.                             case "Counter Strike Global Offensive":
  234.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-csgo.png'>";
  235.                                 break;             
  236.                             case "Call of Duty 2":
  237.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-cod2.png'>";
  238.                                 break;                                                 
  239.                             case "Call of Duty 4":
  240.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-cod4.png'>";
  241.                                 break;
  242.                             case "Minecraft":
  243.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-minecraft.png'>";
  244.                                 break;
  245.                             case "Team Fortress 2":
  246.                                 $igra = "<img style='width:12px;' src='http://static.gametracker.rs/images/game-tf2.png'>";
  247.                                 break;
  248.                                
  249.                         }
  250.                     } ?>
  251.  
  252.                         <tr>
  253.                             <td style="font-size:16px;"><b><?php echo $number2; ?>.</b> </td>
  254.                             <td><strong> <?php echo $igra; ?>  <?php echo '<img style="width:18px;" src="'.ServerInfo($ip, 'country_flag').'" />'; ?>   <?php echo ServerInfo($ip,'name'); ?></strong> </td>
  255.                             <td><?php echo time_ago($red['vreme']); ?></td>
  256.                             <td><?php echo $red['datum']; ?></td>
  257.                             <td><?php echo $red['ip_pc']; ?></td>
  258.                             <td> <a href="manage.php?id=<?php echo $red['id']; ?>"><i class="fa fa-edit"></i> Manage </a> </td>
  259.                             <td> <a href="delete.php?id=<?php echo $red['id']; ?>"><span class="fa fa-trash"></span> Delete </a> </td> 
  260.                         </tr>
  261.  
  262.                 <?php } ?>
  263.  
  264.             </tbody>       
  265.         </table>   
  266.        
  267.         <ul class="pagination">
  268.  
  269.             <?php
  270.  
  271.                 $sql = "SELECT * FROM serveri WHERE istaknuto='1'";
  272.  
  273.                 $djoxi = mysqli_query($con,$sql);
  274.  
  275.                 $total_recs = mysqli_num_rows($djoxi); //count number of records
  276.                 $total_pages = ceil($total_recs / $rec_page);
  277.  
  278.                 echo "
  279.                     <li>
  280.                         <a href='?page=1' aria-label='Previous'>
  281.                             <span aria-hidden='true'>&laquo;</span>
  282.                         </a>
  283.                     </li>      
  284.                 "; // For 1st page
  285.  
  286.                 for ($i=1; $i<=$total_pages; $i++) {
  287.                     echo "<li><a href='?page=".$i."'>". $i. "</a></li> ";
  288.                 }
  289.  
  290.                 echo "
  291.                     <li>
  292.                         <a href='?page=$total_pages' aria-label='Next'>
  293.                             <span aria-hidden='true'>&raquo;</span>
  294.                         </a>
  295.                     </li>      
  296.                 ";
  297.  
  298.             ?>
  299.  
  300.         </ul>      
  301.    
  302.     </div>
  303.    
  304. </div> <!-- ROW kraj -->
  305.  
  306. <?php } ?>
  307.  
  308. <?php if($_SESSION['userid'] == "") { ?>
  309.  
  310.     <form action="" method="POST">
  311.    
  312.         <input type="text" class="form-control" name="username" placeholder="Username..." /> <br />
  313.         <input type="password" class="form-control" name="password" placeholder="Password..." /> <br />
  314.         <input type="submit"  name="login" value="Login" /> <br /> <br />
  315.    
  316.     </form>
  317.  
  318. <?php } // Provera za pristup ?>
  319.  
  320. <?php include("footer.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement