Guest User

Untitled

a guest
Jul 22nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. /** files.php **/
  2.  
  3. <?php
  4.  
  5. session_start();
  6.  
  7. if (isset($_SESSION['user'])) {
  8.  
  9. require_once('core/header.inc.php');
  10. require_once('core/menubar.inc.php');
  11. require_once 'connect.php';
  12. include_once 'emailLinks.php';
  13.  
  14. echo "
  15. <div id='files'>
  16. <form name='form' action='' method='POST'>
  17. <input type='submit' name='email' value='Email links'>
  18. ";
  19.  
  20. if (checkUserLvl('2', $dbh)) {
  21. echo "
  22. <input type='submit' name='delete' value='Delete files'>
  23. <input type='submit' name='invoice' value='Create invoice'>
  24. ";
  25. } else {
  26. echo 'Not allowed';
  27. }
  28.  
  29. echo "
  30. <table>
  31. <tr>
  32. <th><input type='checkbox' id='selectall'></th>
  33. <th>
  34. <select name='sel_company' id='sel_company'>
  35. <option value='all'>All</option>
  36. <option value='II'>II</option>
  37. <option value='QI'>QI</option>
  38. </select>
  39. </th>
  40. <th>Date</th>
  41. <th style='width: 200px;'>Address</th>
  42. <th>Size</th>
  43. <th>Job</th>
  44. <th>Link</th>
  45. <th>Invoice</th>
  46. </tr>
  47. <tr></tr>
  48. <div id='filelist'>
  49. </div>
  50. </table>
  51. </form>
  52. </div>
  53. ";
  54.  
  55. require_once('core/footer.inc.php');
  56.  
  57. } else {
  58. header('Location: index.php');
  59. }
  60. ?>
  61.  
  62.  
  63. /** filelist.php **/
  64. <?php
  65.  
  66. if (isset($_POST['company'])) {
  67. require_once 'connect.php';
  68.  
  69. if ($_POST['company'] == 'All') {
  70. $query = $dbh->prepare("SELECT * FROM files ORDER BY company, date");
  71. $query->execute();
  72. } else {
  73. $query = $dbh->prepare("SELECT * FROM files WHERE company=:company ORDER BY date");
  74. $query->bindParam(':company', $_POST['company']);
  75. $query->execute();
  76. }
  77.  
  78. foreach ($query as $row) {
  79.  
  80. $company = $row['company'];
  81. $date = date("d/m/y", strtotime($row['date']));
  82. $address = $row['address'];
  83. $size = $row['size'];
  84. $job = $row['job'];
  85. $md5 = $row['md5'];
  86. $link = 'download.php?id='.$md5;
  87. $invoice = $row['invoice'];
  88.  
  89. echo "
  90. <tr>
  91. <td><input type='checkbox' name='file[]' value='$md5'></td>
  92. <td class='company'>$company</td>
  93. <td>$date</td>
  94. <td>$address</td>
  95. <td>$size</td>
  96. <td>$job</td>
  97. <td><a href='$link'>download</a></td>
  98. <td>$invoice</td>
  99. </tr>
  100. ";
  101. }
  102. }
  103.  
  104. ?>
  105.  
  106.  
  107. /** files.js **/
  108.  
  109.  
  110. $(document).ready(function() {
  111. $('#filelist').load('filestable.php').show();
  112.  
  113. $('#sel_company').change(function() {
  114. var sel_company = $(this).val();
  115. var company = 'company';
  116.  
  117. $.post('filestable.php', { company: sel_company },
  118. function(result) {
  119. $('#filelist').html(result).show();
  120. });
  121. });
  122.  
  123. $('#sel_company').change();
  124. });
Add Comment
Please, Sign In to add comment