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.

257 lines
9.7KB

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