PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/remove.php

https://bitbucket.org/d3bugg3r/shiftsystem
PHP | 24 lines | 23 code | 0 blank | 1 comment | 5 complexity | 11902a78858a8a1982f35b57bee32d3c MD5 | raw file
  1. <? if ($_SESSION['logged_in'] != true) {
  2. echo "There has been an error, please go back and try again";
  3. die();
  4. }
  5. $return = escape($_POST['return']);
  6. $id = escape($_POST['id']);
  7. $c_user = escape($_POST['c_id']);
  8. //Security measure, ensure logged in user is the same as the user's shift being edited or that an admin is editing
  9. $r = mysql_query("SELECT * FROM hours WHERE id='$id' AND worker='$c_user'");
  10. if (mysql_num_rows($r) == 0) { //no such shift
  11. echo "There has been an error, please go back and try again";
  12. die();
  13. }
  14. $r = mysql_fetch_array($r);
  15. $str = "$r[3]-$r[2]-$r[1]"; //get the date of the shift
  16. $shift_date = strtotime($str);
  17. if (time() > $shift_date) {
  18. echo "You cannot edit shifts that are in the past, redirecting...";
  19. echo "$str <br /> $shift_date <br />". time();
  20. echo "<META HTTP-EQUIV='Refresh' Content='1; URL=index.php?page=cal&$return'>";
  21. die();
  22. }
  23. mysql_query("UPDATE hours SET worker='0' WHERE id='$id'");
  24. echo "<META HTTP-EQUIV='Refresh' Content='0; URL=index.php?page=cal&$return'>";