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.

254 lines
9.5KB

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