Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
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.

main.php 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. if (isset($page['post']['codecss'])) {
  3. echo '<style type="text/css">'."\n";
  4. echo $page['post']['codecss'];
  5. echo '</style>'."\n";}
  6. ?>
  7. <?php
  8. // Show errors
  9. if (count($pastebin->errors)) {
  10. echo '<div class="alert alert-error">';
  11. foreach($pastebin->errors as $err) { echo '<i class="icon-exclamation-sign"></i> ' . $err . ' </div>'; }
  12. $page['post']['editcode']=$_POST['code'];
  13. $page['current_format']=$_POST['format'];
  14. $page['expiry']=$_POST['expiry'];
  15. if ($_POST['password'] != 'EMPTY') { $page['post']['password']=$_POST['password']; }
  16. $page['title']="";
  17. if(isset($_POST['title'])){ $page['title']=$_POST['title']; }
  18. }
  19. // Show a paste
  20. function showMe() {
  21. global $sep;
  22. global $page;
  23. global $post;
  24. global $followups;
  25. global $CONF;
  26. ?>
  27. <div class="container">
  28. <?php
  29. if (strlen($page['post']['posttitle'])) { echo '<div class="alert alert-info">' . $page['post']['posttitle'] . ' - Format: ' . ($page['post']['format']) . '';
  30. if ($page['post']['parent_pid']>0) {
  31. echo ' - This is a modified post titled "<a href="' . $page['post']['parent_url'] . '" title="View original post">' . $page['post']['parent_title'] . '</a>".';
  32. }
  33. $followups=count($page['post']['followups']);
  34. if ($followups) {
  35. echo ' - See newer version(s) of this paste titled ';
  36. $sep="";
  37. foreach($page['post']['followups'] as $idx=>$followup) {
  38. echo $sep . '<a title="Posted on ' . $followup['postfmt'] . '" href="' . $followup['followup_url'] . '">"' . $followup['title'] . '"</a>';
  39. $sep=($idx<($followups-2))?", ":" and ";
  40. }
  41. }
  42. ?>
  43. </div>
  44. <div class="row">
  45. <div class="col-md-12">
  46. <ul class="nav nav-pills">
  47. <li><a href="<?php echo $page['post']['downloadurl'] ?>"><span class="glyphicon glyphicon-download-alt"></span> Download</a></li>
  48. <li><a href="javascript:togglev();" title="Show/Hide line numbers"><span class="glyphicon glyphicon-list"></span> Hide Lines</a></li>
  49. </ul>
  50. </div>
  51. </div>
  52. <?php } // End post title ?>
  53. <div class="row">
  54. <div class="col-md-12">
  55. <?php if (isset($page['post']['pid'])) { ?>
  56. <div class="well" style="background-color: #FFF;" id="code">
  57. <?php echo $page['post']['codefmt'];?>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <?php }
  63. } // End showing of a paste
  64. // Check for a password
  65. $postPass = null;
  66. if(isset($_POST['password'])){ $postPass = $_POST['password']; }
  67. if (isset($pid) && $pid >0) {
  68. global $pid;
  69. $result = $pastebin->getPaste($pid);
  70. $pass = $result['password'];
  71. if (isset($pass) && ($pass != "EMPTY")) { if (!isset($postPass)) { ?>
  72. <div class="container">
  73. <div class="row text-center">
  74. <div class="col-sm-6 col-sm-offset-3">
  75. <form class="form-inline" method="post" action="">
  76. <h3><span class="glyphicon glyphicon-warning-sign"></span> This paste is password protected.</h3>
  77. <div class="well no-padding">
  78. <div class="form-group">
  79. <input class="form-control" type="password" name="password" placeholder="Password">
  80. </div>
  81. <button class="btn btn-primary" type="submit">Show</button>
  82. </div>
  83. </form>
  84. </div>
  85. </div>
  86. </div>
  87. <?php } else if (sha1($postPass) == $pass) { showMe(); } else { ?>
  88. <div class="container">
  89. <div class="row text-center">
  90. <div class="col-sm-6 col-sm-offset-3">
  91. <div class="alert alert-danger">
  92. <span class="glyphicon glyphicon-warning-sign"></span> The password you entered was incorrect, <a href="#tryagain" onClick="history.go(-1); return false;">Try again.</a></i>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <?php }
  98. } else { showMe(); }
  99. }; // End password page
  100. if (!(isset($pass) && (sha1($postPass) !== $pass)) || $pass == "EMPTY") {?>
  101. <!-- Paste area -->
  102. <div class="container">
  103. <div class="row">
  104. <div class="col-md-8">
  105. <form class="form-horizontal" name="editor" method="post" action="index.php">
  106. <input type="hidden" name="parent_pid" value="<?php if(isset($page['post']['pid'])){echo $page['post']['pid'];} ?>"/>
  107. <div class="top-bar"><h3><i class="icon-edit"></i> New Paste</h3></div>
  108. <div class="well">
  109. <div class="form-group">
  110. <div class="col-sm-12">
  111. <select id="id_select" name="format" class="selectpicker" data-live-search="true">
  112. <optgroup label="Popular Formats">
  113. <?php // Show popular GeSHi formats
  114. foreach ($CONF['geshiformats'] as $code=>$name)
  115. {
  116. if (in_array($code, $CONF['popular_formats']))
  117. {
  118. $sel=($code==$page['current_format'])?'selected="selected"':' ';
  119. echo '<option ' . $sel . 'value="' . $code . '">' . $name . '</option>';
  120. }
  121. }
  122. echo '</optgroup><optgroup label="All Formats">';
  123. // Show all GeSHi formats.
  124. foreach ($CONF['geshiformats'] as $code=>$name)
  125. {
  126. $sel=($code==$page['current_format'])?'selected="selected"':' ';
  127. if (in_array($code, $CONF['popular_formats']))
  128. $sel="";
  129. echo '<option ' . $sel . 'value="' . $code . '">' . $name . '</option>';
  130. }
  131. ?>
  132. </optgroup>
  133. </select>
  134. </div>
  135. </div>
  136. <div class="form-group">
  137. <div class="col-sm-12">
  138. <textarea class="form-control" rows="15" id="code" name="code" onkeydown="return catchTab(this,event)"><?php if(isset($page['post']['editcode'])){
  139. echo htmlspecialchars($page['post']['editcode']);
  140. } ?></textarea>
  141. </div>
  142. </div>
  143. </div>
  144. <!-- Options -->
  145. <div class="top-bar"><h3><i class="icon-gear"></i> Paste Options</h3></div>
  146. <div class="well no-padding">
  147. <div class="form-group">
  148. <label for="title" class="col-sm-3 control-label">Paste Title</label>
  149. <div class="col-sm-9">
  150. <input class="form-control" type="text" maxlength="30" id="title" name="title" value="<?php
  151. $page['title']="";
  152. if(isset($_POST['title'])){ $page['title']=$_POST['title']; }
  153. echo $page['title'] ?>">
  154. </div>
  155. </div>
  156. <div class="form-group">
  157. <label for="password" class="col-sm-3 control-label">Password</label>
  158. <div class="col-sm-9">
  159. <input class="form-control" type="password" id="password" value="<?php if (strcmp($postPass,'EMPTY') != 0) { echo $postPass; } else { echo ''; } ?>" name="password">
  160. </div>
  161. </div>
  162. <div class="form-group">
  163. <label for="expire_select" class="col-sm-3 control-label">Paste Expiration</label>
  164. <div class="col-sm-9">
  165. <select class="selectpicker" id="expire_select" name="expiry" tabindex="1">
  166. <option id="expiry_forever" value="f" <?php if ($page['expiry']=='f') echo 'selected="selected"'; ?>>None</option>
  167. <option id="expiry_day" value="d" <?php if ($page['expiry']=='d') echo 'selected="selected"'; ?>>One Day</option>
  168. <option id="expiry_month" value="m" <?php if ($page['expiry']=='m') echo 'selected="selected"'; ?>>One Month</option>
  169. </select>
  170. </div>
  171. </div>
  172. <div class="form-group">
  173. <div class="col-sm-9 col-sm-offset-3">
  174. <button class="btn btn-primary" type="submit" name="paste">Submit</button>
  175. </div>
  176. </div>
  177. </form>
  178. </div>
  179. </div>
  180. <!-- Recent Pastes -->
  181. <div class="col-md-4">
  182. <div class="top-bar"><h3><i class="icon-pencil"></i> Recent Pastes</h3></div>
  183. <div class="well no-padding" id="pagination-activity">
  184. <div class="list-widget pagination-content">
  185. <?php foreach($page['recent'] as $idx=>$entry) {
  186. if (isset($pid) && $entry['pid']==$pid) $cls="background-color: #e0e0e0;";
  187. else $cls="";?>
  188. <div class="item" style="display: block; <?php echo $cls;?>">
  189. <small class="pull-right"><?php echo $entry['agefmt'];?></small>
  190. <p class="no-margin"><i class="icon-code"></i>
  191. <?php if ( $mod_rewrite == true ) {
  192. echo '<a href="'. get_page_url('p', $CONF) . '/' . $entry['pid'] . '">' . $entry['title'] . '</a>'; } else {
  193. echo '<a href="'. get_page_url('p', $CONF) . '/' .'?paste='. $entry['pid'].'">' . $entry['title'] . '</a>'; } ?>
  194. </p>
  195. </div>
  196. <?php } ?>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <?php } ?>
  203. <p class="text-center">
  204. Tools: <a href="http://git.teknik.io/Teknikode/Tools/src/master/Paste">Paste Scripts and Utilities</a>
  205. </p>