Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <textarea id="area" cols="70" rows="30"></textarea>
- <button id="submit">Submit</button>
- <script>
- $('#submit').click(function (e) {
- e.preventDefault();
- var info = $('#area').val();
- $.ajax({
- type: "POST",
- url: 'pages/assignments/response.php',
- data: {area: info},
- success: function (response) {
- console.log(response);
- }
- });
- });
- </script>
- <?php
- if (!empty($_POST['area'])) {
- runEval($_POST['area']);
- };
- function runEval($data)
- {
- // $data = preg_replace('/s+/', '', $data); doesn't seem to work at all with it)
- $characters = '[a-zA-Z0-9]*';
- $functions = '';
- $operators = '[w-><$(){}|_+=":;!&*%$]';
- $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*/
- if (preg_match($regexp, $data)) {
- eval('$result = ' . $data . ';');
- echo $result;
- } else {
- $data = false;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment