Guest User

Untitled

a guest
Sep 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <textarea id="area" cols="70" rows="30"></textarea>
  2. <button id="submit">Submit</button>
  3.  
  4. <script>
  5. $('#submit').click(function (e) {
  6. e.preventDefault();
  7.  
  8. var info = $('#area').val();
  9.  
  10. $.ajax({
  11. type: "POST",
  12. url: 'pages/assignments/response.php',
  13. data: {area: info},
  14. success: function (response) {
  15. console.log(response);
  16. }
  17. });
  18. });
  19. </script>
  20.  
  21. <?php
  22. if (!empty($_POST['area'])) {
  23. runEval($_POST['area']);
  24. };
  25.  
  26. function runEval($data)
  27. {
  28. // $data = preg_replace('/s+/', '', $data); doesn't seem to work at all with it)
  29. $characters = '[a-zA-Z0-9]*';
  30. $functions = '';
  31. $operators = '[w-><$(){}|_+=":;!&*%$]';
  32. $regexp = '/^((' . $characters . '|' . $functions . 's*((?1)+)|((?1)+))(?:' . $operators . '(?2))?)+/'; /*honestly we have no idea what it does, because we copied it and changed the $characters,$functions,$operators*/
  33.  
  34. if (preg_match($regexp, $data)) {
  35. eval('$result = ' . $data . ';');
  36. echo $result;
  37. } else {
  38. $data = false;
  39. }
  40. }
  41.  
  42. ?>
Add Comment
Please, Sign In to add comment