Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8" />
- <style>
- .{
- font-family: arial;
- }
- body, h1, p, form{
- margin: 0px;
- padding: 0px;
- }
- h1, p{
- text-align: right;
- padding-right: 10px;
- }
- body{
- background: gray;
- }
- textarea{
- border: 1px solid white;
- background-color: silver;
- }
- form{
- position: absolute;
- top: 60px;
- bottom: 10px;
- left: 10px;
- right: 10px;
- width: auto;
- height: auto;
- display: block;
- }
- input{
- position: absolute;
- bottom: 0px;
- background-color: red;
- border: 4px solid black;
- font-weight: bold;
- font-size: 16px;
- }
- textarea{
- position: absolute;
- top: 0px;
- bottom: 40px;
- height: auto;
- display: block;
- margin: 0px;
- padding: 20px;
- }
- </style>
- </head>
- <body>
- <h1>7D2D recipes sorter</h1>
- <p>Paste the content of your recipes.xml into the left textarea and submit the form. The recipes will be sorted by name in alphabetical order. In the right textarea you will see a list with all recipes craftable.</p>
- <form method="post">
- <input type="submit">
- <textarea name="file" style="left: 0px; width: 70%"><?php
- $lines=array();
- $lines[]='<?xml version="1.0" encoding="UTF-8"?>';
- $lines[]='<recipes>';
- $file = "";
- if (isset($_REQUEST["file"])) $file = $_REQUEST["file"];
- $out = array();
- preg_match_all("/<recipe .*recipe>/simU",$file,$recipes);
- foreach ($recipes[0] as $recipe){
- preg_match("/<recipe name=\"([^\"]+)\"/simU",$recipe,$hit);
- $name = $hit[1];
- if (!isset($out[$name])) $out[$name]="\t";
- $out[$name] .= trim($recipe)."\r\n\t";
- }
- ksort($out);
- $lines[]=implode("\r\n",$out);
- $lines[]='</recipes>';
- echo htmlspecialchars(str_replace(" ","\t",implode($lines,"\r\n")));
- ?></textarea>
- <textarea name="index" style="right: 0px; width: 20%"><?php
- echo implode("\r\n",array_keys($out));
- ?></textarea>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement