Gorilla.php
author Dan
Sun, 31 May 2009 00:38:09 -0400
changeset 1 f2ceea4fabe8
parent 0 cac93de16379
child 2 b6178b40aa09
permissions -rw-r--r--
Added support for replying and fixed a few security holes. TODO: search integration
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
     1
<?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
     2
/**!info**
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
     3
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
     4
  "Plugin Name"  : "Gorilla Paste",
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
     5
  "Plugin URI"   : "http://enanocms.org/plugin/gorilla",
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
     6
  "Description"  : "For The Toughest Pasting Jobs On Earth.&trade; The pastebin, Enano style. <a href=\"http://enanocms.org/plugin/geshi\" onclick=\"window.open(this.href); return false;\">GeSHi plugin</a> highly recommended.",
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
     7
  "Author"       : "Dan Fuhry",
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
     8
  "Version"      : "0.1.1",
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
     9
  "Author URI"   : "http://enanocms.org/",
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    10
  "Version list" : ['0.1', '0.1.1']
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    11
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    12
**!*/
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    13
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    14
// Register namespace and ACLs
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    15
$plugins->attachHook('acl_rule_init', 'gorilla_setupcore($this, $session);');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    16
// Add our special page
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    17
$plugins->attachHook('session_started', 'register_special_page(\'NewPaste\', \'gorilla_page_create\', true);');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    18
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    19
// constants
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    20
define('PASTE_PRIVATE', 1);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    21
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    22
function gorilla_setupcore(&$paths, &$session)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    23
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    24
  // register our paste namespace
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    25
  $nssep = substr($paths->nslist['Special'], -1);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    26
  $paths->create_namespace('Paste', 'Paste' . $nssep);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    27
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    28
  // create our ACLs
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    29
  /**
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    30
   * @param string $acl_type An identifier for this field
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    31
   * @param int $default_perm Whether permission should be granted or not if it's not specified in the ACLs.
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    32
   * @param string $desc A human readable name for the permission type
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    33
   * @param array $deps The list of dependencies - this should be an array of ACL types
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    34
   * @param string $scope Which namespaces this field should apply to. This should be either a pipe-delimited list of namespace IDs or just "All".
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    35
   */
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    36
   
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    37
  $session->acl_extend_scope('read', 'Paste', $paths);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    38
  $session->acl_extend_scope('post_comments', 'Paste', $paths);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    39
  $session->acl_extend_scope('edit_comments', 'Paste', $paths);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    40
  $session->acl_extend_scope('mod_comments', 'Paste', $paths);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    41
  $session->acl_extend_scope('create_page', 'Paste', $paths);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    42
  $session->acl_extend_scope('mod_misc', 'Paste', $paths);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    43
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    44
  $session->register_acl_type('delete_paste_own', AUTH_ALLOW, 'gorilla_acl_delete_paste_own', array(), 'Paste');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    45
  $session->register_acl_type('delete_paste_others', AUTH_DISALLOW, 'gorilla_acl_delete_paste_others', array(), 'Paste');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    46
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    47
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    48
// Our paste creation page
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    49
function page_Special_NewPaste()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    50
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    51
  global $db, $session, $paths, $template, $plugins; // Common objects
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    52
  global $lang, $output;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    53
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    54
  $have_geshi = isset($GLOBALS['geshi_supported_formats']);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    55
  $perms = $session->fetch_page_acl('0', 'Paste');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    56
  $have_permission = $perms->get_permissions('create_page');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    57
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    58
  if ( $paths->getParam(0) === 'ajaxsubmit' )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    59
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    60
    header('Content-type: text/plain');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    61
    echo gorilla_process_post($have_geshi, $have_permission, true);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    62
    return true;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    63
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    64
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    65
  $private = false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    66
  $highlight = isset($_COOKIE['g_highlight']) ? $_COOKIE['g_highlight'] : 'plaintext';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    67
  $text = '';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    68
  $title = '';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    69
  $ttl = 3600;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    70
  $copy_from = false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    71
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    72
  if ( preg_match('/^Copy=([0-9]+)$/', $paths->getParam(0), $match) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    73
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    74
    $paste_id = intval($match[1]);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    75
    $q = $db->sql_query('SELECT paste_flags, paste_language, paste_text, paste_title, paste_ttl FROM ' . table_prefix . "pastes WHERE paste_id = $paste_id;");
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    76
    if ( !$q )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    77
      $db->_die();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    78
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    79
    list($flags, $highlight, $text, $title, $ttl) = $db->fetchrow_num();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    80
    $db->free_result();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    81
    $private = $flags & PASTE_PRIVATE ? true : false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    82
    $copy_from = $paste_id;
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    83
    
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    84
    if ( $flags & PASTE_PRIVATE )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    85
    {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    86
      if ( @$_GET['hash'] !== gorilla_sign($paste_id, $text) )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    87
      {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    88
        die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('gorilla_msg_wrong_hash') . '</p>');
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    89
      }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
    90
    }
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    91
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    92
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    93
  $output->header();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    94
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    95
  ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    96
  <script type="text/javascript">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    97
  var gorilla_have_permission = <?php echo $have_permission ? 'true' : 'false'; ?>;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    98
  function gorilla_create_submit()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
    99
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   100
    if ( !window.gorilla_have_permission && user_level < USER_LEVEL_MEMBER )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   101
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   102
      load_component('login');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   103
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   104
      ajaxLogonInit(function(k, response)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   105
        {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   106
          window.gorilla_have_permission = true;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   107
          document.forms['gorilla_create'].submit();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   108
        }, USER_LEVEL_MEMBER);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   109
      return false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   110
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   111
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   112
    try
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   113
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   114
      load_component(['jquery', 'jquery-ui']);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   115
      $('#gorilla_submit_result').empty().hide();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   116
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   117
      var whitey = whiteOutElement(document.forms['gorilla_create']);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   118
      
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   119
      var parent = parseInt($('#gorilla_parent').val());
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   120
      if ( isNaN(parent) )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   121
        parent = 0;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   122
      
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   123
      var json_packet = {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   124
        highlight: $('#gorilla_highlight').val(),
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   125
        text: $('#gorilla_create_text').val(),
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   126
        is_private: $('#gorilla_private:checked').val() ? true : false,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   127
        nick: $('#gorilla_nick').val(),
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   128
        title: $('#gorilla_title').val(),
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   129
        ttl: parseInt($('.gorilla_ttl:checked').val()),
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   130
        parent: parent,
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   131
        hash: $('#gorilla_hash').val();
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   132
      };
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   133
      json_packet = ajaxEscape(toJSONString(json_packet));
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   134
      ajaxPost(makeUrlNS('Special', 'NewPaste/ajaxsubmit'), 'r=' + json_packet, function(ajax)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   135
        {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   136
          if ( ajax.readyState == 4 && ajax.status == 200 )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   137
          {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   138
            var failed = parseInt((String(ajax.responseText)).substr(0, 1));
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   139
            if ( failed == 1 )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   140
              whiteOutReportFailure(whitey);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   141
            else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   142
              whiteOutReportSuccess(whitey);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   143
              
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   144
            var response = (String(ajax.responseText)).substr(2);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   145
            
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   146
            setTimeout(function()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   147
              {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   148
                window.scroll(0, 0);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   149
                $('#gorilla_submit_result').html(response).show('blind', 150);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   150
              }, 1250);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   151
          }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   152
        });
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   153
      return false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   154
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   155
    catch(e)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   156
    {}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   157
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   158
    return true;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   159
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   160
  addOnloadHook(function()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   161
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   162
      load_component('expander');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   163
    });
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   164
  </script>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   165
  <div id="gorilla_submit_result">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   166
  <?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   167
    echo substr(gorilla_process_post($have_geshi, $have_permission), 2);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   168
  ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   169
  </div>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   170
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   171
  <form action="<?php echo makeUrlNS('Special', 'NewPaste'); ?>" method="post" name="gorilla_create" onsubmit="return gorilla_create_submit();">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   172
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   173
    <?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   174
    if ( $copy_from )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   175
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   176
      echo '<p style="float: left;">' . $lang->get('gorilla_msg_copying_from', array('paste_id' => $copy_from, 'paste_url' => makeUrlNS('Paste', $copy_from, false, true))) . '</p>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   177
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   178
    ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   179
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   180
    <!-- private -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   181
    <div style="float: right; margin: 10px 1%;">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   182
      <label title="<?php echo $lang->get('gorilla_lbl_private_hint'); ?>">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   183
        <input type="checkbox" name="is_private" id="gorilla_private" <?php if ( $private ) echo 'checked="checked"'; ?> />
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   184
        <img alt="<?php echo $lang->get('gorilla_lbl_private'); ?>" src="<?php echo cdnPath; ?>/images/lock16.png" />
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   185
      </label>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   186
    </div>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   187
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   188
    <!-- highlighting -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   189
    <div style="float: right; margin: 10px;">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   190
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   191
    <?php echo $lang->get('gorilla_lbl_highlight'); ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   192
    <?php if ( $have_geshi ): ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   193
      <select name="highlight" id="gorilla_highlight">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   194
        <?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   195
        // print out options for each GeSHi format
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   196
        global $geshi_supported_formats;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   197
        $formats = array_merge(array('plaintext'), $geshi_supported_formats);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   198
        foreach ( $formats as $format )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   199
        {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   200
          // $string = str_replace('-', '_', "geshi_lang_$format");
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   201
          // if ( ($_ = $lang->get($string)) !== $string )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   202
          //   $string = $_;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   203
          // else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   204
            $string = $format;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   205
            
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   206
          $sel = ( $format == $highlight ) ? ' selected="selected"' : '';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   207
          echo '<option value="' . $format . '"' . $sel . '>' . $string . '</option>' . "\n          ";
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   208
        }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   209
        ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   210
      </select>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   211
    <?php else: ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   212
      <span style="color: #808080;"><?php echo $lang->get('gorilla_msg_no_geshi'); ?></span>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   213
      <input type="hidden" name="highlight_type" id="gorilla_highlight" value="plaintext" />
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   214
    <?php endif; ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   215
                   
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   216
    </div>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   217
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   218
    <!-- text box -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   219
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   220
    <textarea id="gorilla_create_text" name="text" rows="30" cols="80" style="width: 98%; display: block; margin: 10px auto; clear: both;"><?php echo htmlspecialchars($text); ?></textarea>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   221
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   222
    <fieldset enano:expand="closed" style="margin-bottom: 10px;">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   223
      <legend><?php echo $lang->get('gorilla_btn_advanced_options'); ?></legend>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   224
      <div>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   225
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   226
      <!-- title -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   227
      <p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   228
        <?php echo $lang->get('gorilla_lbl_title'); ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   229
        <input type="text" name="title" id="gorilla_title" size="40" value="<?php echo htmlspecialchars($title); ?>" />
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   230
      </p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   231
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   232
      <!-- nick -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   233
      <p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   234
        <?php echo $lang->get('gorilla_lbl_nick'); ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   235
        <?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   236
        if ( !$have_permission && !$session->user_logged_in )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   237
        {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   238
          echo '<em>' . $lang->get('gorilla_msg_using_login_nick') . '</em>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   239
          echo '<input type="hidden" name="nick" id="gorilla_nick" value="" />';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   240
        }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   241
        else if ( $session->user_logged_in )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   242
        {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   243
          $rankinfo = $session->get_user_rank($session->user_id);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   244
          echo '<em>' . $lang->get('gorilla_msg_using_logged_in_nick') . '</em> ';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   245
          echo '<span style="' . $rankinfo['rank_style'] . '">' . $session->username . '</span>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   246
          echo '<input type="hidden" name="nick" id="gorilla_nick" value="" />';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   247
        }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   248
        else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   249
        {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   250
          echo '<input type="text" name="nick" id="gorilla_nick" value="' . $lang->get('gorilla_nick_anonymous') . '" />';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   251
        }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   252
        ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   253
      </p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   254
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   255
      <!-- ttl -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   256
      <p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   257
        <?php echo $lang->get('gorilla_lbl_ttl'); ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   258
        <em>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   259
        <label><input<?php if ( !in_array($ttl, array(0, 86400, 2592000)) ) echo ' checked="checked"'; ?> class="gorilla_ttl" type="radio" name="ttl" value="3600" /> <?php echo $lang->get('gorilla_lbl_ttl_hour'); ?></label>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   260
        <label><input<?php if ( $ttl == 86400                             ) echo ' checked="checked"'; ?> class="gorilla_ttl" type="radio" name="ttl" value="86400" /> <?php echo $lang->get('gorilla_lbl_ttl_day'); ?></label>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   261
        <label><input<?php if ( $ttl == 2592000                           ) echo ' checked="checked"'; ?> class="gorilla_ttl" type="radio" name="ttl" value="2592000" /> <?php echo $lang->get('gorilla_lbl_ttl_month'); ?></label>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   262
        <label><input<?php if ( $ttl == 0                                 ) echo ' checked="checked"'; ?> class="gorilla_ttl" type="radio" name="ttl" value="0" /> <?php echo $lang->get('gorilla_lbl_ttl_forever'); ?></label>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   263
        </em>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   264
      </p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   265
      
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   266
      <!-- reply -->
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   267
      <p>
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   268
        <?php echo $lang->get('gorilla_lbl_reply'); ?><input id="gorilla_parent" name="parent" size="8" value="<?php echo $copy_from ? strval($copy_from) : ''; ?>" />
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   269
      </p>
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   270
      
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   271
      </div>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   272
    </fieldset>
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   273
    
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   274
    <!-- hash -->
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   275
    <?php if ( $private && $copy_from ): ?>
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   276
    <input type="hidden" name="hash" id="gorilla_hash" value="<?php echo gorilla_sign($paste_id, $text); ?>" />
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   277
    <?php else: ?>
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   278
    <input type="hidden" name="hash" id="gorilla_hash" value="" />
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   279
    <?php endif; ?>
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   280
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   281
    <!-- login notice -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   282
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   283
    <?php if ( !$have_permission && !$session->user_logged_in ): ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   284
    <div class="info-box-mini">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   285
      <?php echo $lang->get('gorilla_msg_will_prompt_for_login'); ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   286
    </div>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   287
    <?php endif; ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   288
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   289
    <!-- submit -->
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   290
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   291
    <input type="submit" style="font-size: x-large;" value="<?php echo $lang->get('gorilla_btn_submit'); ?>" />
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   292
  </form>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   293
  <?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   294
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   295
  $output->footer();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   296
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   297
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   298
// actual processing for submitted pastes
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   299
function gorilla_process_post($have_geshi, $have_permission, $is_ajax = false)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   300
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   301
  global $db, $session, $paths, $template, $plugins; // Common objects
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   302
  global $lang;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   303
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   304
  $fields = array(
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   305
      'highlight' => 'string',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   306
      'text' => 'string',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   307
      'is_private' => 'boolean',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   308
      'nick' => 'string',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   309
      'title' => 'string',
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   310
      'ttl' => 'integer',
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   311
      'parent' => 'integer',
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   312
      'hash' => 'string'
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   313
    );
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   314
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   315
  $info = array();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   316
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   317
  if ( $is_ajax )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   318
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   319
    try
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   320
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   321
      $request = enano_json_decode(@$_POST['r']);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   322
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   323
    catch ( Exception $e )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   324
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   325
      return '1;No JSON request given';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   326
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   327
    foreach ( $fields as $field => $type )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   328
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   329
      if ( !isset($request[$field]) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   330
        return "1;Field \"$field\" not provided";
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   331
      if ( ($ftype = gettype($request[$field])) !== $type )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   332
        return "1;Field \"$field\": expected $type, got $ftype";
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   333
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   334
      $info[$field] = $request[$field];
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   335
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   336
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   337
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   338
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   339
    foreach ( $fields as $field => $type )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   340
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   341
      if ( !isset($_POST[$field]) && $field != 'is_private' )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   342
        return '';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   343
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   344
    $info = array(
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   345
        'highlight' => $_POST['highlight'],
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   346
        'text' => $_POST['text'],
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   347
        'is_private' => isset($_POST['is_private']),
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   348
        'nick' => $_POST['nick'],
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   349
        'title' => $_POST['title'],
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   350
        'ttl' => intval($_POST['ttl']),
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   351
        'parent' => intval($_POST['parent']),
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   352
        'hash' => $_POST['hash']
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   353
      );
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   354
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   355
  
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   356
  if ( $info['parent'] )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   357
  {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   358
    // make sure we have the right hash
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   359
    $q = $db->sql_query('SELECT paste_text FROM ' . table_prefix . "pastes WHERE paste_id = {$info['parent']};");
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   360
    if ( !$q )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   361
      $db->_die();
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   362
    
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   363
    if ( $db->numrows() > 0 )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   364
    {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   365
      list($old_text) = $db->fetchrow_num();
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   366
      if ( $info['hash'] !== gorilla_sign($info['parent'], $old_text) )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   367
      {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   368
        $info['parent'] = 0;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   369
      }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   370
    }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   371
    else
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   372
    {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   373
      $info['parent'] = 0;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   374
    }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   375
  }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   376
  
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   377
  if ( !$have_permission )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   378
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   379
    return '1;<div class="error-box-mini">' . $lang->get('etc_access_denied') . '</div>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   380
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   381
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   382
  // validate highlight scheme
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   383
  global $geshi_supported_formats;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   384
  if ( is_array($geshi_supported_formats) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   385
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   386
    if ( !in_array($info['highlight'], $geshi_supported_formats) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   387
      $info['highlight'] = 'plaintext';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   388
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   389
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   390
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   391
    $info['highlight'] = 'plaintext';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   392
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   393
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   394
  setcookie('g_highlight', $info['highlight'], time() + 365 * 24 * 60 * 60);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   395
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   396
  $info_db = $info;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   397
  foreach ( $info_db as &$item )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   398
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   399
    if ( is_string($item) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   400
      $item = "'" . $db->escape($item) . "'";
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   401
    else if ( is_bool($item) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   402
      $item = $item ? '1' : '0';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   403
    else if ( is_int($item) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   404
      $item = strval($item);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   405
    else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   406
      $item = "''";
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   407
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   408
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   409
  $now = time();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   410
  $flags = 0;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   411
  if ( $info['is_private'] )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   412
    $flags |= PASTE_PRIVATE;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   413
  
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   414
  $sql = 'INSERT INTO ' . table_prefix . "pastes( paste_title, paste_text, paste_author, paste_author_name, paste_author_ip, paste_language, paste_timestamp, paste_ttl, paste_flags, paste_parent ) VALUES\n"
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   415
  . "  ( {$info_db['title']}, {$info_db['text']}, $session->user_id, {$info_db['nick']}, '{$_SERVER['REMOTE_ADDR']}', {$info_db['highlight']}, $now, {$info_db['ttl']}, $flags, {$info_db['parent']} );";
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   416
       
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   417
  if ( !$db->sql_query($sql) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   418
    ( $is_ajax ) ? $db->die_json() : $db->_die();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   419
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   420
  // avoid insert_id
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   421
  $q = $db->sql_query('SELECT paste_id FROM ' . table_prefix . "pastes WHERE paste_timestamp = $now ORDER BY paste_id DESC LIMIT 1;");
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   422
  if ( !$q )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   423
    ( $is_ajax ) ? $db->die_json() : $db->_die();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   424
  list($paste_id) = $db->fetchrow_num();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   425
  $db->free_result();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   426
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   427
  $params = false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   428
  if ( $flags & PASTE_PRIVATE )
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   429
    $params = 'hash=' . gorilla_sign($paste_id, $info['text']);
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   430
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   431
  $paste_url = makeUrlComplete('Paste', $paste_id, $params, true);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   432
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   433
  return '0;'
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   434
           . '<div class="info-box-mini">' . $lang->get('gorilla_msg_created') . '</div>'
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   435
           . '<div style="font-size: larger; text-align: center; margin: 30px 0;">' . $lang->get('gorilla_msg_paste_url') . '<br /><input onfocus="this.select()" readonly="readonly" type="text" size="50" style="font-size: larger; text-align: center;" value="' . $paste_url . '" /></div>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   436
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   437
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   438
###############################################################################
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   439
## PASTE DISPLAY
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   440
###############################################################################
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   441
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   442
class Namespace_Paste extends Namespace_Default
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   443
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   444
  protected $paste_data = false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   445
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   446
  public function __construct($page_id, $namespace, $revid = 0)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   447
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   448
    $this->page_id = $page_id;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   449
    $this->namespace = $namespace;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   450
    $this->revision_id = 0;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   451
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   452
    $this->build_cdata();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   453
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   454
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   455
  public function build_cdata()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   456
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   457
    global $db, $session, $paths, $template, $plugins; // Common objects
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   458
    global $lang;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   459
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   460
    $this->exists = false;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   461
    if ( ctype_digit($this->page_id) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   462
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   463
      $q = $db->sql_query('SELECT p.*, u.username FROM ' . table_prefix . "pastes AS p\n"
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   464
                        . "  LEFT JOIN " . table_prefix . "users AS u\n"
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   465
                        . "    ON ( u.user_id = p.paste_author )\n"
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   466
                        . "  WHERE p.paste_id = $this->page_id;");
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   467
      if ( $db->numrows() > 0 )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   468
      {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   469
        $this->exists = true;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   470
        $this->paste_data = $db->fetchrow();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   471
      }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   472
      $db->free_result();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   473
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   474
    if ( $this->exists )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   475
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   476
      $this->cdata = array(
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   477
        'name' => empty($this->paste_data['paste_title']) ? $lang->get('gorilla_untitled_paste') : $this->paste_data['paste_title'],
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   478
        'urlname' => $this->page_id,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   479
        'namespace' => $this->namespace,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   480
        'special' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   481
        'visible' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   482
        'comments_on' => 1,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   483
        'protected' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   484
        'delvotes' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   485
        'delvote_ips' => '',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   486
        'wiki_mode' => 2,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   487
        'page_exists' => true,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   488
        'page_format' => getConfig('default_page_format', 'wikitext')
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   489
      );
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   490
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   491
    else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   492
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   493
      $this->cdata = array(
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   494
        'name' => $lang->get('gorilla_title_404'),
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   495
        'urlname' => $this->page_id,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   496
        'namespace' => $this->namespace,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   497
        'special' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   498
        'visible' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   499
        'comments_on' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   500
        'protected' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   501
        'delvotes' => 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   502
        'delvote_ips' => '',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   503
        'wiki_mode' => 2,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   504
        'page_exists' => false,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   505
        'page_format' => getConfig('default_page_format', 'wikitext')
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   506
      );
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   507
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   508
    $this->cdata = Namespace_Default::bake_cdata($this->cdata);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   509
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   510
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   511
  public function send()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   512
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   513
    global $db, $session, $paths, $template, $plugins; // Common objects
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   514
    global $output, $lang;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   515
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   516
    $plugins->attachHook('page_type_string_set', '$this->namespace_string = $lang->get(\'gorilla_template_ns_string\');');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   517
    $template->add_header('<style type="text/css">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   518
      .geshi_highlighted a {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   519
        background-image: none !important;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   520
        padding-right: 0 !important;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   521
      }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   522
      </style>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   523
      ');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   524
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   525
    if ( $this->exists )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   526
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   527
      gorilla_display_paste($this->paste_data);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   528
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   529
    else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   530
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   531
      $output->header();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   532
      $this->error_404();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   533
      $output->footer();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   534
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   535
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   536
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   537
  public function error_404()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   538
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   539
    global $lang;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   540
    echo '<p>' . $lang->get('gorilla_msg_paste_not_found', array('create_link' => makeUrlNS('Special', 'NewPaste'))) . '</p>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   541
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   542
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   543
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   544
function gorilla_display_paste($data)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   545
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   546
  global $db, $session, $paths, $template, $plugins; // Common objects
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   547
  global $lang;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   548
  global $output;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   549
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   550
  extract($data);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   551
  $perms = $session->fetch_page_acl($paste_id, 'Paste');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   552
  
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   553
  $localhash = false;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   554
  if ( $paste_flags & PASTE_PRIVATE )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   555
  {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   556
    $localhash = gorilla_sign($paste_id, $paste_text);
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   557
  }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   558
  
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   559
  if ( $paste_flags & PASTE_PRIVATE || isset($_GET['delete']) )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   560
  {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   561
    if ( @$_GET['hash'] !== $localhash )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   562
    {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   563
      // allow viewing regardless if mod or admin
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   564
      if ( !($session->user_level >= USER_LEVEL_MOD && !isset($_GET['delete'])) )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   565
      {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   566
        die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('gorilla_msg_wrong_hash') . '</p>');
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   567
      }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   568
    }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   569
  }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   570
  
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   571
  if ( isset($_GET['format']) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   572
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   573
    switch($_GET['format'])
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   574
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   575
      case 'text':
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   576
      case 'plain':
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   577
        header('Content-type: text/plain');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   578
        echo $paste_text;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   579
        return true;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   580
        break;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   581
      case 'download':
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   582
        header('Content-type: text/plain');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   583
        header('Content-disposition: attachment; filename="paste' . $paste_id . '.txt"');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   584
        header('Content-length: ' . strlen($paste_text));
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   585
        echo $paste_text;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   586
        return true;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   587
        break;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   588
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   589
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   590
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   591
  $output->header();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   592
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   593
  $perm = $paste_author == $session->user_id ? 'delete_paste_own' : 'delete_paste_others';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   594
  if ( isset($_GET['delete']) && !isset($_POST['cancel']) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   595
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   596
    if ( isset($_POST['delete_confirm']) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   597
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   598
      $q = $db->sql_query('DELETE FROM ' . table_prefix . "pastes WHERE paste_id = $paste_id;");
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   599
      if ( !$q )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   600
        $db->_die();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   601
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   602
      echo '<p>' . $lang->get('gorilla_msg_paste_deleted') . '</p>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   603
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   604
    else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   605
    {
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   606
      $submit_url = makeUrlNS('Paste', $paste_id, 'delete&hash=' . gorilla_sign($paste_id, $paste_text), true);
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   607
      ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   608
      <form action="<?php echo $submit_url; ?>" method="post">
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   609
        <p><?php echo $lang->get('gorilla_msg_delete_confirm'); ?></p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   610
        <p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   611
          <input type="submit" value="<?php echo $lang->get('gorilla_btn_delete_confirm'); ?>" name="delete_confirm" style="font-weight: bold;" />
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   612
          <input type="submit" value="<?php echo $lang->get('etc_cancel'); ?>" name="cancel" />
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   613
        </p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   614
      </form>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   615
      <?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   616
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   617
    $output->footer();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   618
    return true;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   619
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   620
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   621
  if ( $paste_author > 1 )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   622
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   623
    // logged-in user
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   624
    $rank_info = $session->get_user_rank($paste_author);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   625
    $user_link = '<a href="' . makeUrlNS('User', $username, false, true) . '" style="' . $rank_info['rank_style'] . '">' . htmlspecialchars($username) . '</a>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   626
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   627
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   628
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   629
    // anonymous
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   630
    $user_link = '<b>' . htmlspecialchars($paste_author_name) . '</b>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   631
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   632
  $date = enano_date('D, j M Y H:i:s', $paste_timestamp);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   633
  $pasteinfo = $lang->get('gorilla_msg_paste_info', array('user_link' => $user_link, 'date' => $date));
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   634
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   635
  echo '<div class="mdg-infobox" style="margin: 10px 0;">';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   636
  echo '<div style="float: right;">
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   637
          ' . $lang->get('gorilla_msg_other_formats', array('plain_link' => makeUrlNS('Paste', $paste_id, 'format=text' .  ( $localhash ? "&hash=$localhash" : '' ), true), 'download_link' => makeUrlNS('Paste', $paste_id, 'format=download' .  ( $localhash ? "&hash=$localhash" : '' ), true))) . '
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   638
          /
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   639
          <a title="' . $lang->get('gorilla_tip_new_paste') . '" href="' . makeUrlNS('Special', 'NewPaste') . '">' . $lang->get('gorilla_btn_new_paste') . '</a>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   640
          /
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   641
          <a title="' . $lang->get('gorilla_tip_copy_from_this') . '" href="' . makeUrlNS('Special', 'NewPaste/Copy=' . $paste_id, ( $paste_flags & PASTE_PRIVATE ? 'hash=' . gorilla_sign($paste_id, $paste_text) : false ), true) . '">' . $lang->get('gorilla_btn_copy_from_this') . '</a>';
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   642
          
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   643
  if ( $paste_parent )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   644
  {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   645
    // pull flags of parent
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   646
    $q = $db->sql_query('SELECT paste_text, paste_flags FROM ' . table_prefix . "pastes WHERE paste_id = $paste_parent;");
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   647
    if ( !$q )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   648
      $db->_die();
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   649
    
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   650
    if ( $db->numrows() > 0 )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   651
    {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   652
      list($parent_text, $parent_flags) = $db->fetchrow_num();
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   653
      $parenthash = false;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   654
      if ( $parent_flags & PASTE_PRIVATE )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   655
      {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   656
        $parenthash = gorilla_sign($paste_parent, $parent_text);
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   657
      }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   658
      
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   659
      echo ' / ' . $lang->get('gorilla_msg_reply_to', array(
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   660
          'parent_link' => makeUrlNS('Paste', $paste_parent, ( $parenthash ? "hash=$parenthash" : '' ), true),
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   661
          'diff_link' => makeUrlNS('Paste', $paste_id, 'diff_parent' .  ( $localhash ? "&hash=$localhash" : '' ), true),
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   662
          'parent_id' => $paste_parent
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   663
        ));
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   664
    }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   665
    $db->free_result($q);
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   666
  }
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   667
          
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   668
  if ( $perms->get_permissions($perm) && $session->user_logged_in )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   669
  {
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   670
    echo ' / <a title="' . $lang->get('gorilla_tip_delete') . '" href="' . makeUrlNS('Paste', $paste_id, 'delete&hash=' . gorilla_sign($paste_id, $paste_text), true) . '">' . $lang->get('gorilla_btn_delete') . '</a>';
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   671
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   672
  if ( $perms->get_permissions('mod_misc') )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   673
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   674
    echo ' / <span title="' . $lang->get('gorilla_tip_paste_ip') . '">' . $paste_author_ip . '</span>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   675
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   676
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   677
  echo '</div>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   678
  echo $pasteinfo;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   679
  echo '</div>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   680
  
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   681
  if ( isset($_GET['diff_parent']) && isset($parent_text) )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   682
  {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   683
    echo '<p>' . $lang->get('gorilla_btn_view_normal', array('orig_url' => makeUrlNS('Paste', $paste_id, ( $localhash ? "hash=$localhash" : '' ), true))) . '</p>';
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   684
    // convert to unix newlines to avoid confusing the diff engine (seen on Chromium on Linux)
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   685
    echo RenderMan::diff(str_replace("\r\n", "\n", $parent_text), str_replace("\r\n", "\n", $paste_text));
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   686
    $output->footer();
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   687
    return;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   688
  }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   689
  
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   690
  if ( preg_match('/^## /m', $paste_text) )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   691
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   692
    gorilla_show_text_multi($paste_text, $paste_language);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   693
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   694
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   695
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   696
    gorilla_show_text($paste_text, $paste_language);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   697
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   698
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   699
  $output->footer();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   700
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   701
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   702
function gorilla_show_text($text, $lang)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   703
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   704
  $have_geshi = isset($GLOBALS['geshi_supported_formats']);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   705
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   706
  if ( $have_geshi )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   707
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   708
    if ( $lang == 'plaintext' )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   709
      $lang = 'text';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   710
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   711
    if ( !defined('GESHI_ROOT') )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   712
    define('GESHI_ROOT', ENANO_ROOT . '/plugins/geshi/');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   713
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   714
    require_once ( GESHI_ROOT . 'base.php' );
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   715
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   716
    $geshi = new GeSHi($text, $lang, null);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   717
    $geshi->set_header_type(GESHI_HEADER_DIV);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   718
    $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   719
    $geshi->set_overall_class('geshi_highlighted');
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   720
    $parsed = $geshi->parse_code();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   721
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   722
    echo $parsed;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   723
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   724
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   725
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   726
    echo '<h3>FIXME: WRITE REAL PLAINTEXT FORMATTER</h3>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   727
    echo '<pre>' . htmlspecialchars($text) . '</pre>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   728
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   729
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   730
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   731
function gorilla_show_text_multi($text, $lang)
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   732
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   733
  $sections = preg_split('/^## .*$/m', $text);
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   734
  $headingcount = preg_match_all('/^## (.+?)(?: \[([a-z_-]+)\])? *\r?$/m', $text, $matches);
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   735
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   736
  // if we have one heading less than the number of sections, print the first section
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   737
  while ( count($sections) > $headingcount )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   738
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   739
    gorilla_show_text(trim($sections[0], "\r\n"), $lang);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   740
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   741
    unset($sections[0]);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   742
    $sections = array_values($sections);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   743
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   744
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   745
  foreach ( $matches[0] as $i => $_ )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   746
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   747
    $clang = !empty($matches[2][$i]) ? $matches[2][$i] : $lang;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   748
    echo '<h2>' . htmlspecialchars(trim($matches[1][$i])) . '</h2>';
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   749
    gorilla_show_text(trim($sections[$i], "\r\n"), $clang);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   750
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   751
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   752
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   753
function gorilla_sign($id, $text)
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   754
{
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   755
  return hmac_sha1($id, sha1($text));
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   756
}
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   757
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   758
// make sure pastes are pruned on a regular basis
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   759
function gorilla_prune_expired()
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   760
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   761
  global $db, $session, $paths, $template, $plugins; // Common objects
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   762
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   763
  $now = time();
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   764
  $q = $db->sql_query('DELETE FROM ' . table_prefix . "pastes WHERE paste_timestamp + paste_ttl < $now AND paste_ttl > 0;");
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   765
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   766
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   767
register_cron_task('gorilla_prune_expired', 1);
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   768
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   769
/**!install dbms="mysql"; **
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   770
CREATE TABLE {{TABLE_PREFIX}}pastes(
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   771
  paste_id int(18) NOT NULL auto_increment,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   772
  paste_title text DEFAULT NULL,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   773
  paste_text text NOT NULL DEFAULT '',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   774
  paste_author int(12) NOT NULL DEFAULT 1,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   775
  paste_author_name varchar(255) NOT NULL DEFAULT 'Anonymous',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   776
  paste_author_ip varchar(39) NOT NULL,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   777
  paste_language varchar(32) NOT NULL DEFAULT 'plaintext',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   778
  paste_timestamp int(12) NOT NULL DEFAULT 0,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   779
  paste_ttl int(12) NOT NULL DEFAULT 86400,
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   780
  paste_flags int(8) NOT NULL DEFAULT 0,
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   781
  paste_parent int(18) NOT NULL DEFAULT 0,
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   782
  PRIMARY KEY ( paste_id )
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   783
) ENGINE=`MyISAM` CHARSET=`UTF8` COLLATE=`utf8_bin`;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   784
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   785
**!*/
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   786
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   787
/**!upgrade from="0.1"; to="0.1.1"; dbms="mysql"; **
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   788
ALTER TABLE {{TABLE_PREFIX}}pastes ADD COLUMN paste_parent int(18) NOT NULL DEFAULT 0;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   789
**!*/
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   790
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   791
/**!uninstall **
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   792
DROP TABLE {{TABLE_PREFIX}}pastes;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   793
**!*/
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   794
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   795
/**!language**
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   796
<code>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   797
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   798
  eng: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   799
    categories: ['meta', 'gorilla'],
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   800
    strings: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   801
      meta: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   802
        gorilla: 'Gorilla',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   803
      },
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   804
      gorilla: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   805
        acl_delete_paste_own: 'Delete own pastes',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   806
        acl_delete_paste_others: 'Delete others\' pastes',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   807
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   808
        page_create: 'Create paste',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   809
        msg_copying_from: 'Copying from <a href="%paste_url%">paste #%paste_id%</a>.',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   810
        lbl_highlight: 'Language:',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   811
        msg_no_geshi: 'Not supported',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   812
        btn_advanced_options: 'Advanced options',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   813
        lbl_private: 'Private paste',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   814
        lbl_private_hint: 'Don\'t list this paste or allow it to be included in searches',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   815
        lbl_title: 'Title:',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   816
        lbl_nick: 'Nickname:',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   817
        nick_anonymous: 'Anonymous',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   818
        msg_using_login_nick: 'Using username provided during login',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   819
        msg_using_logged_in_nick: 'Logged in; using nickname:',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   820
        lbl_ttl: 'Keep it for:',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   821
        lbl_ttl_hour: '1 hour',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   822
        lbl_ttl_day: '1 day',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   823
        lbl_ttl_month: '1 month',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   824
        lbl_ttl_forever: 'forever',
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   825
        lbl_reply: 'Reply to paste: #',
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   826
        msg_will_prompt_for_login: 'You are not logged in. You will be asked to log in when you click the submit button below.',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   827
        btn_submit: 'Paste it!',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   828
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   829
        msg_created: 'Paste created.',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   830
        msg_paste_url: 'Share this paste using the following URL:',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   831
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   832
        untitled_paste: 'Untitled paste',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   833
        title_404: 'Paste not found',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   834
        msg_paste_not_found: 'This paste cannot be found or has been deleted. <a href="%create_link%">Create a new paste</a>',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   835
        msg_wrong_hash: 'Either you are trying to view a private paste which requires a hash in the URL or you were linked to this page from an outside source and the CSRF protection kicked in.',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   836
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   837
        msg_paste_info: 'By %user_link%, pasted on %date%',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   838
        msg_other_formats: '<a title="View as plain text" href="%plain_link%" onclick="window.open(this.href, \'gorillaplaintext\', \'address=no,status=no,toolbar=no,menus=no,scroll=yes,width=640,height=480\'); return false;">raw</a> / <a title="Download paste" href="%download_link%">dl</a>',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   839
        btn_new_paste: 'new',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   840
        tip_new_paste: 'Create a new paste',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   841
        btn_copy_from_this: 'cp',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   842
        tip_copy_from_this: 'Create a new paste, copying this one into the form',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   843
        btn_delete: 'rm',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   844
        tip_delete: 'Delete this paste',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   845
        tip_paste_ip: 'IP address of paste author',
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   846
        msg_reply_to: 'parent: <a href="%parent_link%">#%parent_id%</a> (<a href="%diff_link%">diff</a>)',
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   847
        btn_view_normal: '<b>Difference from parent</b> (<a href="%orig_url%">back to paste</a>)',
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   848
        template_ns_string: 'paste',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   849
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   850
        msg_paste_deleted: 'Paste deleted.',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   851
        msg_delete_confirm: 'Really delete this paste?',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   852
        btn_delete_confirm: 'Delete',
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   853
      }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   854
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   855
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   856
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   857
</code>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   858
**!*/