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 8.7KB

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