KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 9.0KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?php
  2. include_once("geshi.php");
  3. if (file_exists("/var/www/kxstudio/paste/")) {
  4. $server_dir = "/paste/";
  5. $base_dir = "/var/www/kxstudio/paste/";
  6. } else {
  7. $server_dir = "/paste/";
  8. $base_dir = "/home/groups/k/kx/kxstudio/htdocs/paste/";
  9. }
  10. $show_paste = FALSE;
  11. $show_numbers = FALSE;
  12. $is_error = FALSE;
  13. if (! empty($_GET["id"]))
  14. {
  15. $paste_id = htmlspecialchars($_GET["id"]);
  16. $show_paste = TRUE;
  17. $paste_file = $base_dir . "repo/" . $paste_id;
  18. if (! file_exists($paste_file)) {
  19. $is_error = TRUE;
  20. }
  21. $paste_info = $base_dir . "repo/" . $paste_id . ".inc";
  22. // default values
  23. $paste_name = "";
  24. $paste_format = "";
  25. $paste_numbers = "";
  26. if (file_exists($paste_info)) {
  27. include_once($paste_info);
  28. }
  29. $show_numbers = ($paste_numbers == "Yes");
  30. }
  31. else if (! empty($_POST["paste_text"]))
  32. {
  33. if ($_POST["paste_misc"]) {
  34. die("Spam bot detected, get out of here!");
  35. }
  36. $paste_code = $_POST["paste_text"];
  37. $paste_format = $_POST["paste_format"];
  38. $paste_name = htmlspecialchars($_POST["paste_title"]);
  39. if (array_key_exists("paste_numbers", $_POST)) {
  40. $paste_numbers = $_POST["paste_numbers"];
  41. } else {
  42. $paste_numbers = "No";
  43. }
  44. $paste_id = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',5)),0,5);
  45. $paste_file = $base_dir . "repo/" . $paste_id;
  46. while (file_exists($paste_file)) {
  47. $paste_id = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',5)),0,5);
  48. $paste_file = $base_dir . "repo/" . $paste_id;
  49. }
  50. $fp = fopen($paste_file, 'w');
  51. if ($fp) {
  52. fwrite($fp, $paste_code);
  53. fclose($fp);
  54. } else {
  55. $paste_file = "_error";
  56. $is_error = TRUE;
  57. }
  58. $paste_info = $base_dir . "repo/" . $paste_id . ".inc";
  59. $paste_info_content = "<?php\n";
  60. $paste_info_content .= "\$paste_name = \"$paste_name\";\n";
  61. $paste_info_content .= "\$paste_format = \"$paste_format\";\n";
  62. $paste_info_content .= "\$paste_numbers = \"$paste_numbers\";\n";
  63. $paste_info_content .= "?>\n";
  64. $fp = fopen($paste_info, 'w');
  65. if ($fp) {
  66. fwrite($fp, $paste_info_content);
  67. fclose($fp);
  68. }
  69. $show_paste = TRUE;
  70. $show_numbers = ($paste_numbers == "Yes");
  71. header("Location: " . $server_dir . $paste_id);
  72. }
  73. $PAGE_TITLE = "KXStudio Paste";
  74. $PAGE_TYPE = "PASTE";
  75. if (! empty($paste_name))
  76. $PAGE_TITLE = "KXStudio Paste - " . $paste_name;
  77. $PAGE_SOURCE_1 = ARRAY("/paste");
  78. $PAGE_SOURCE_2 = ARRAY("Paste");
  79. include_once("../includes/header.php");
  80. ?>
  81. <?php
  82. if ($show_paste)
  83. {
  84. $file_path = $base_dir . "repo/" . $paste_id;
  85. if (file_exists($file_path))
  86. {
  87. if ($is_error) {
  88. $paste_data = file_get_contents($file_path);
  89. } else {
  90. $geshi = new GeSHi(file_get_contents($file_path), $paste_format);
  91. $geshi->enable_classes();
  92. $geshi->set_header_type(GESHI_HEADER_NONE);
  93. if ($show_numbers)
  94. $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
  95. $paste_data = $geshi->parse_code();
  96. }
  97. ?>
  98. <p><?php echo $paste_data; ?></p>
  99. <?php
  100. }
  101. else
  102. {
  103. ?>
  104. <p style="color: #CF2525; font-size: 20px;">Invalid Paste ID</p><br/>
  105. <?php
  106. }
  107. }
  108. else // $show_paste
  109. {
  110. ?>
  111. <form enctype="multipart/form-data" method="post" action="" onsubmit="document.getElementById('paste_submit').disabled=true;document.getElementById('paste_submit').value='Please wait...';">
  112. <div class="paste_textarea_border">
  113. <textarea name="paste_text" id="paste_text" rows="1" cols="1"></textarea>
  114. </div>
  115. <br/>
  116. <table>
  117. <tr><td align="right">Syntax Highlighting:</td><td>
  118. <select name="paste_format" id="paste_format">
  119. <option value="none" selected="selected">None</option>
  120. <option value="6502acme">6502 ACME Cross Assembler</option>
  121. <option value="6502kickass">6502 Kick Assembler</option>
  122. <option value="6502tasm">6502 TASM/64TASS</option>
  123. <option value="abap">ABAP</option>
  124. <option value="actionscript">ActionScript</option>
  125. <option value="ada">Ada</option>
  126. <option value="apache">Apache Log</option>
  127. <option value="asm">ASM (NASM)</option>
  128. <option value="asp">ASP</option>
  129. <option value="bash">Bash</option>
  130. <option value="bf">BrainFuck</option>
  131. <option value="c">C</option>
  132. <option value="c_mac">C for Macs</option>
  133. <option value="csharp">C#</option>
  134. <option value="cpp">C++</option>
  135. <option value="caddcl">CAD DCL</option>
  136. <option value="cadlisp">CAD Lisp</option>
  137. <option value="cfdg">CFDG</option>
  138. <option value="klonec">Clone C</option>
  139. <option value="klonecpp">Clone C++</option>
  140. <option value="css">CSS</option>
  141. <option value="d">D</option>
  142. <option value="delphi">Delphi</option>
  143. <option value="diff">Diff</option>
  144. <option value="gdb">GDB</option>
  145. <option value="genero">Genero</option>
  146. <option value="gettext">GetText</option>
  147. <option value="groovy">Groovy</option>
  148. <option value="haskell">Haskell</option>
  149. <option value="html4strict">HTML</option>
  150. <option value="java">Java</option>
  151. <option value="javascript">JavaScript</option>
  152. <option value="jquery">jQuery</option>
  153. <option value="latex">Latex</option>
  154. <option value="lisp">Lisp</option>
  155. <option value="lua">Lua</option>
  156. <option value="matlab">MatLab</option>
  157. <option value="mpasm">MPASM</option>
  158. <option value="mysql">MySQL</option>
  159. <option value="nsis">NullSoft Installer</option>
  160. <option value="objc">Objective C</option>
  161. <option value="oobas">Openoffice BASIC</option>
  162. <option value="oracle8">Oracle 8</option>
  163. <option value="oracle10">Oracle 10</option>
  164. <option value="pascal">Pascal</option>
  165. <option value="perl">Perl</option>
  166. <option value="php">PHP</option>
  167. <option value="povray">POV-Ray</option>
  168. <option value="prolog">Prolog</option>
  169. <option value="providex">ProvideX</option>
  170. <option value="python">Python</option>
  171. <option value="qbasic">QBasic</option>
  172. <option value="reg">REG</option>
  173. <option value="ruby">Ruby</option>
  174. <option value="sas">SAS</option>
  175. <option value="scala">Scala</option>
  176. <option value="scheme">Scheme</option>
  177. <option value="scilab">Scilab</option>
  178. <option value="sdlbasic">SdlBasic</option>
  179. <option value="smalltalk">Smalltalk</option>
  180. <option value="smarty">Smarty</option>
  181. <option value="tcl">TCL</option>
  182. <option value="vbnet">VB.NET</option>
  183. <option value="vb">VisualBasic</option>
  184. <option value="whitespace">WhiteSpace</option>
  185. <option value="xml">XML</option>
  186. <option value="z80">Z80 Assembler</option>
  187. </select>
  188. </td></tr>
  189. <tr><td align="right">Paste Name / Title:</td><td>
  190. <input type="text" name="paste_title" id="paste_title" />
  191. <input type="text" name="paste_misc" id="paste_misc" style="visibility: hidden;" />
  192. </td></tr>
  193. <tr><td align="right">
  194. <input type="checkbox" name="paste_numbers" id="paste_numbers" value="Yes"/>
  195. </td><td>
  196. Show line numbers
  197. </td></tr>
  198. <tr><td></td><td>
  199. <input type="submit" name="paste_submit" id="paste_submit" value="Submit" />
  200. </td></tr>
  201. </table>
  202. </form>
  203. <br/>
  204. <?php
  205. } // $show_paste
  206. ?>
  207. <?php
  208. include_once("../includes/footer.php");
  209. ?>