Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.12 KB | None | 0 0
  1. @include('partials.manager-header')
  2. @php
  3.         $file = urldecode($_GET['f']);
  4.         $props = $Page->getProperties($file);
  5.         $mime = $props['mime'];
  6.         $eol = 'unix';
  7.         /**
  8.          * Initially preferred a JS approach, but Chrome interprets
  9.          * data in a textarea as \n even if the spec calls for \r\n
  10.          */
  11.         if (false !== strpos($mime, ' CRLF ')) {
  12.                 $eol = 'windows';
  13.         } else if (false !== strpos($mime, ' CR ')) {
  14.                 $eol = 'mac';
  15.         }
  16.  
  17.         if (strstr($mime, 'text'))
  18.                 $contents = htmlentities($Page->getFileContents($file));
  19.         else if (strstr($mime, 'empty'))
  20.                 $contents = '';
  21.         if ($Page->errors_exist()) return;
  22.         $stats = $Page->statFile($file);
  23.         $mode = $Page->editor_mode();
  24. @endphp
  25.  
  26.         <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.7/ace.js"></script>
  27.         <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.7/ext-modelist.js"></script>
  28.         <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.7/ext-beautify.js" integrity="sha256-XURxU9F6YJl7wYVNfD4/aztOdXJyQ9vZ/03hyUknaOU=" crossorigin="anonymous"></script>
  29. @if (strstr($mime, "text") || strstr($mime, "empty"))
  30. <tr>
  31.         <td class="cell1" colspan="6" align="">
  32.                 <form action="filemanager.php?cwd=<?php print($Page->getCurrentPath()); ?>&editor=<?=$Page->editor_mode()?>"
  33.                      method="POST">
  34.  
  35.  
  36.                        <?php
  37.                        if (!strstr($mime, "text") && !strstr($mime, "empty")):
  38.                                print("<p align='center'>Binary file.  Preview not available</>");
  39.                         else: ?>
  40.                         @if ($stats['can_write'])
  41.                         <h4>Editor Options</h4>
  42.                         <div class="row">
  43.                                 <div class="d-flex form-group form-inline col-12 justify-content-between">
  44.                                         <button type="submit" id='save' name="Save_Changes" class="btn btn-primary">
  45.                                                 Save Changes
  46.                                         </button>
  47.                                         <button type="button" name="editor[<?=$mode == "raw" ? 'rich' : 'raw' ?>]" id="editor"
  48.                                                 class="btn btn-secondary">
  49.                                                 <i class="fa fa-<?=$mode == "raw" ? 'paint-brush' : 'pencil-square-o'?>"></i> Switch
  50.                                                 to <?=$mode == "raw" ? 'WYSIWYG' : 'Basic'?> Editor
  51.                                         </button>
  52.                                         <button type="button" id="btnBeautify" class="btn btn-info">Beautify</button>
  53.                                         <div class="input-group float-right eol-container block-right">
  54.                                                 <div class="btn-group text-right hidden-sm-down">
  55.                                                         <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown"
  56.                                                                aria-haspopup="true" aria-expanded="false">
  57.                                                                 <span class="marker"></span>
  58.                                                                 <span class="sr-only">Toggle Dropdown</span>
  59.                                                         </button>
  60.                                                         <div class="dropdown-menu dropdown-menu-right eol-types">
  61.                                                                 <label class="windows dropdown-item">
  62.                                                                         <input class="radio-inline" type="radio" name="eol" value="windows"/>
  63.                                                                         Win (\r\n)
  64.                                                                 </label>
  65.                                                                 <label class="unix dropdown-item">
  66.                                                                         <input class="radio-inline" type="radio" name="eol" value="unix"/>
  67.                                                                         Unix (\n)
  68.                                                                 </label>
  69.                                                                 <label class="mac dropdown-item">
  70.                                                                         <input class="radio-inline" type="radio" name="eol" value="mac"/>
  71.                                                                         Mac (\r)
  72.                                                                 </label>
  73.                                                                 <div class="dropdown-divider"></div>
  74.                                                                 <small class=" dropdown-item">Detected <span id="EOL"><?=ucwords($eol)?></span></small>
  75.                                                                 <input type="hidden" name="file[eol]" id="eol-original" value="<? print $eol; ?>"/>
  76.                                                         </div>
  77.                                                 </div>
  78.  
  79.                                         </div>
  80.                                 </div>
  81.                         </div>
  82.                         @endif
  83.                        <div class="row">
  84.                             <div class="col-12" id="ceditor" style="min-height:500px"><?php
  85.                                $charset = $props['charset'];
  86.                                if ($charset && strtoupper($charset) !== "UTF-8") {
  87.                                        echo mb_convert_encoding($contents, 'UTF-8', $charset);
  88.                                } else {
  89.                                        echo $contents;
  90.                                }
  91.                                ?></div>
  92.                         </div>
  93.                         <textarea rows="25" cols="100" name="code" id="code" class="form-control d-none" WRAP="OFF"><?php
  94.                                $charset = $props['charset'];
  95.                                if ($charset && strtoupper($charset) !== "UTF-8") {
  96.                                        echo mb_convert_encoding($contents, 'UTF-8', $charset);
  97.                                } else {
  98.                                        echo $contents;
  99.                                }
  100.                                ?></textarea>
  101.  
  102.                         <input type="hidden" name="file[charset]" value="<?php print $charset; ?>"/>
  103.                         <input type="hidden" name="file[name]" value="<?php print $file; ?>"/>
  104.                         <?php endif; ?>
  105.                 </form>
  106.  
  107.         </td>
  108. </tr>
  109. @else
  110.         <tr>
  111.                 <td colspan="6">
  112.                         <p>Mime type: <?=$mime?> </p>
  113.                         <a href="<?=\HTML_Kit::new_page_url_params(null, array('download' => $file))?>" class="btn btn-secondary btn-lg mr-3">
  114.                                 <i class="fa fa-download"></i> Download
  115.                         </a>
  116.                         @if ($Page->isCompressedFile($file))
  117.                                 <a href="<?=\HTML_Kit::new_page_url_params(null, array('co' => $file))?>"
  118.                                    class="btn btn-secondary btn-lg">
  119.                                         <i class="ui-action ui-action-label ui-action-open-archive"></i> Open Archive
  120.                                 </a>
  121.                         @endif
  122.                         </form>
  123.  
  124.                 </td>
  125.         </tr>
  126. @endif
  127.  
  128.     <script>
  129.     $(document).ready(function(){
  130.  
  131.     var aceModes = ace.require("ace/ext/modelist");
  132.     var mode = aceModes.getModeForPath("{{$file}}").mode;
  133.     var editor = ace.edit("ceditor");
  134.     editor.session.setMode(mode);
  135.    // editor.setTheme("ace/theme/monokai");
  136.     var beautify = ace.require("ace/ext/beautify");
  137.     $("#btnBeautify").on("click", function(){
  138.         beautify.beautify(editor.session);
  139.     });
  140.  
  141.     });
  142.  
  143.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement