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.1KB

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