embedded.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <html>
  2. <head>
  3. <?php
  4. include_once '../auth.php';
  5. ?>
  6. </head>
  7. <body>
  8. Initializing Environment...
  9. <?php
  10. $filepath = "";
  11. $filename = "";
  12. if (isset($_GET['filepath'])){
  13. $filepath = str_replace("./","",str_replace("../","",str_replace("\\","/",$_GET['filepath'])));
  14. }
  15. if (isset($_GET['filename'])){
  16. $filename = $_GET['filename'];
  17. }
  18. ?>
  19. <script src="../script/jquery.min.js"></script>
  20. <script src="../script/ao_module.js"></script>
  21. <script>
  22. ao_module_setWindowSize(0,0);
  23. ao_module_setWindowTitle("NotepadA Initializing...");
  24. var instances = ao_module_getProcessID("NotepadA");
  25. var filepath = "<?php echo $filepath;?>";
  26. var filename = "<?php echo $filename;?>";
  27. remove(instances,ao_module_windowID);
  28. if (instances.includes("newWindow")){
  29. remove(instances,"newWindow");
  30. }
  31. if (instances.length == 0){
  32. //Open a new window for the file
  33. console.log("[NotepadA] Opening " + filepath + " in a new floatWindow");
  34. window.location.href = "index.php?filename=" + filename + "&filepath=" + filepath;
  35. }else if (instances.length > 0){
  36. //Open the new page in the first instances in list
  37. var targetWindow = instances[0];
  38. console.log("[NotepadA] Opening " + filepath + " in floatWindo " + targetWindow);
  39. parent.crossFrameFunctionCall(targetWindow,"newEditor('" + filepath + "');");
  40. ao_module_close();
  41. }
  42. function remove(array, element) {
  43. const index = array.indexOf(element);
  44. array.splice(index, 1);
  45. }
  46. </script>
  47. </body>
  48. </html>