123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <html>
- <head>
- <link href="css/jquery-linedtextarea.css" rel="stylesheet">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
- <script src="js/jquery-linedtextarea.js"></script>
- </head>
- <body>
- <?php
- error_reporting(E_ALL & ~E_NOTICE);
- $path = realpath(dirname("."));
- if (isset($_FILES['srcfile']) && $_FILES['srcfile']['error'] === UPLOAD_ERR_OK) {
- $folder = $_FILES['srcfile']['tmp_name'] ;
- $file = $_FILES['srcfile']['name'];
- echo "folder: $folder<br/>";
- echo "filename: $file<br/>";
- if (isset($file)) {
- $source = file_get_contents($folder);
- $source = str_replace("\r", "", $source);
- $source = str_replace("\n", "\\n", $source);
- unlink ($file);
- }
- }
- $example = $_POST["examples"];
- if (isset($example)) {
- $files = glob($path."/examples/*.tps");
- foreach($files as $filename){
- if(is_file($filename)){
- $basename = basename($filename);
- if ($basename == $example) {
- $source = file_get_contents($filename);
- $source = str_replace("\r", "", $source);
- $source = str_replace("\n", "\\n", $source);
- $file = $basename;
- }
- }
- }
- }
- ?>
- <form method="post" enctype="multipart/form-data">
- <input type="file" name="srcfile"/>
- <button type="submit">load</button>
- </form>
- <form method="post">
- <label for="examples">Examples:</label>
- <select id="examples" name="examples" size="1">
- <?php
- $files = glob($path."/examples/*.tps");
- foreach($files as $filename){
- if(is_file($filename)){
- $basename = basename($filename);
- echo "<option value=\"$basename\">$basename</option>\r\n";
- }
- }
- ?>
- </select>
- <button type="submit">load</button>
- </form>
- <form method="post" action="ass.php" target="_blank">
- Name: <input id="name" name="name">
- <textarea class="lined" rows="20" cols="60" name="source"></textarea>
- <button type="submit">Assemble</button>
- </form>
- <script>
- $(document).ready(function(){
- $(".lined").linedtextarea();
- <?php
- if (isset($source)) {
- echo "\$(\".lined\").val(\"$source\");\r\n";
- }
- if (isset($file)) {
- echo "\$(\"#name\").val(\"$file\");\r\n";
- }
- ?>
- });
- </script>
- </body>
- </html>
|