embedded.php 1.5 KB

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