Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mode = $_GET['mode'];
- $data = "";
- $regex = "";
- $replace = "";
- if($mode == "exec") {
- $data = stripslashes($_POST['data']);
- // Workaround to replace an e which could cause php to execute a command
- $regex = stripslashes(str_replace("e", "x", $_POST['regex']));
- $replace = stripslashes($_POST['replace']);
- setcookie("data", addslashes($data));
- setcookie("regex", addslashes($regex));
- setcookie("replace", addslashes($replace));
- $_COOKIE["data"] = $data;
- $_COOKIE["regex"] = $regex;
- $_COOKIE["replace"] = $replace;
- }
- echo('<?xml version="1.0" encoding="UTF-8"?>'."\n");
- ?>
- <html>
- <head>
- <title>Regex Ausgabe</title>
- </head>
- <body>
- <h2>Regex Ausgabe</h2>
- <p>
- <?php
- if($mode == "exec") {
- $output = preg_replace($regex, $replace, $data);
- echo(nl2br(htmlspecialchars($output)));
- ?>
- </p>
- <hr />
- <?php
- echo('<h2>Eingegebene Daten</h2>');
- echo("\n<p>\n");
- echo("<b>Regex : </b>".htmlspecialchars($regex)."<br />\n");
- echo("<b>Replace : </b>".htmlspecialchars($replace)."<br />\n");
- echo("<b>Daten : </b><br />\n".nl2br(htmlspecialchars($data)));
- echo("\n</p>\n");
- }
- ?>
- <hr />
- <h2>Eingabe</h2>
- <p>
- <form method="post" action="index.php?mode=exec">
- <label for="data">Daten</label>
- <br />
- <textarea name="data" id="data" rows="20" cols="80">
- <?php echo($_COOKIE['data']); ?>
- </textarea>
- <br />
- <label for="regex">Regulärer Ausdruck</label>
- <br />
- <input type="text" name="regex" id="regex" size="40" value="<?php echo(htmlspecialchars($_COOKIE['regex'])); ?>" />
- <br />
- <label for="replace">Ersetzungstext</label>
- <br />
- <input type="text" name="replace" id="replace" size="40" value="<?php echo(htmlspecialchars($_COOKIE['replace'])); ?>" />
- <br />
- <input type="submit" value="Regulären Ausdruck anwenden" />
- </form>
- </p>
- <hr />
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement