PageRenderTime 34ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/public/myartisan.php

https://gitlab.com/pedramkousari/soratjalase
PHP | 110 lines | 105 code | 5 blank | 0 comment | 15 complexity | 01c5a798b321f9c7edfe2ad9a9928bfa MD5 | raw file
  1. <?php
  2. if (@$_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') {
  3. chdir('..');
  4. putenv("COMPOSER_HOME=/var/www/html/Application/laravel2/.composer");
  5. if(strpos($_REQUEST['command'], 'composer') === 0) {
  6. ini_set("memory_limit", "-1");
  7. set_time_limit(0);
  8. $res = shell_exec("/usr/bin/php -dmemory_limit=2048M /usr/bin/" . @$_REQUEST['command'] . ' 2>&1');
  9. } elseif(strpos($_REQUEST['command'], 'artisan') === 0) {
  10. $res = shell_exec('/usr/bin/php -dmemory_limit=2048M ' . @$_REQUEST['command'] . ' 2>&1');
  11. } else {
  12. $res = false;
  13. }
  14. if (!$res)
  15. die("<div style='background: #402626;margin: 2px 0;color: #E8BF6A;'>Invalid Command.</div>");
  16. else
  17. die(nl2br(htmlspecialchars($res)));
  18. }
  19. ?>
  20. <!doctype html>
  21. <!--[if lt IE 7]> <html lang="en-us" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  22. <!--[if IE 7]> <html lang="en-us" class="no-js lt-ie9 lt-ie8"> <![endif]-->
  23. <!--[if IE 8]> <html lang="en-us" class="no-js lt-ie9"> <![endif]-->
  24. <!--[if gt IE 8]><!--> <html lang="en-us" class="no-js"> <!--<![endif]-->
  25. <head>
  26. <title>My Artisan</title>
  27. </head>
  28. <body style="margin: 0; padding: 0;">
  29. <div>
  30. <pre class="result" style="width: 99%; background: #2b2b2b; color: #3F6; padding: 5px; margin:0; overflow-y: scroll;">
  31. </pre>
  32. <div style="position: relative;">
  33. <input class="input-command" value="" type="text" style="width: 98.2%; background: #2b2b2b; color: #fff; padding: 5px 5px 5px 15px;" autofocus="autofocus" />
  34. <pre style="position: absolute; left: 5px; top: 6px; color: #aaa; margin:0; padding:0;">$ </pre>
  35. </div>
  36. </div>
  37. <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
  38. <script>
  39. jQuery(function() {
  40. jQuery('.result').height(jQuery(window).height() - jQuery('.input-command').height() - 30);
  41. jQuery('.result').width(jQuery(window).width() - 10);
  42. jQuery(window).resize(function() {
  43. jQuery('.result').width(jQuery(window).width() - 10);
  44. jQuery('.result').height(jQuery(window).height() - jQuery('.input-command').height() - 30)
  45. });
  46. setTimeout(function() {
  47. jQuery('.input-command').focus();
  48. }, 1);
  49. var commandList = [];
  50. var currentIndex = 0;
  51. jQuery('.input-command').on('keyup', function(e) {
  52. switch (e.keyCode) {
  53. case 13:
  54. if (e.keyCode == 13 && jQuery('.input-command').val()) {
  55. var val = $('.input-command').val().trim();
  56. if (!val) {
  57. return;
  58. }
  59. commandList.push(val);
  60. currentIndex = commandList.length;
  61. $('.result').append("<div style='margin-top: 12px; color: #CCC;'>$ " + val + "</div>");
  62. if (jQuery('.input-command').val().toLowerCase() == 'clear') {
  63. jQuery('.result').html('');
  64. jQuery('.input-command').val('')
  65. return false;
  66. }
  67. jQuery.ajax({
  68. type: "POST",
  69. cache: false,
  70. data: {'command' : val},
  71. url: document.location.href,
  72. dataType: "html",
  73. success: function (res) {
  74. $('.result').append("<div>" + res + "</div>");
  75. $('.result').scrollTop(10000000);
  76. },
  77. error: function (xhr, ajaxOptions, thrownError) {
  78. $('.result').append("<div style='color: #E8BF6A;background: #402626;margin: 2px 0;'>Error sending command, Please check your connection and try again.</div>");
  79. }
  80. });
  81. $('.input-command').val('');
  82. }
  83. break;
  84. case 38:
  85. if (commandList && currentIndex > 0) {
  86. currentIndex--;
  87. $('.input-command').val(commandList[currentIndex]);
  88. }
  89. break;
  90. case 40:
  91. if (commandList && currentIndex < commandList.length) {
  92. currentIndex++;
  93. $('.input-command').val(commandList[currentIndex]);
  94. }
  95. break;
  96. case 27:
  97. $('.input-command').val('');
  98. currentIndex = commandList.length;
  99. break;
  100. }
  101. });
  102. });
  103. </script>
  104. </body>
  105. </html>