Gorilla.php
author Dan
Sun, 05 Jul 2009 00:27:56 -0400
changeset 4 58780df3147b
parent 3 6fe9c484bb26
child 5 7977508aeda3
permissions -rw-r--r--
Fixed stupid syntax error that threw off the whole submit routine
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,
4
58780df3147b Fixed stupid syntax error that threw off the whole submit routine
Dan
parents: 3
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;
3
6fe9c484bb26 Fixed deletions not working
Dan
parents: 2
diff changeset
   554
  $hash = gorilla_sign($paste_id, $paste_text);
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   555
  if ( $paste_flags & PASTE_PRIVATE )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   556
  {
3
6fe9c484bb26 Fixed deletions not working
Dan
parents: 2
diff changeset
   557
    $localhash = $hash;
1
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
  
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   560
  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
   561
  {
3
6fe9c484bb26 Fixed deletions not working
Dan
parents: 2
diff changeset
   562
    if ( @$_GET['hash'] !== $hash )
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   563
    {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   564
      // 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
   565
      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
   566
      {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   567
        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
   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
  }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   571
  
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   572
  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
   573
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   574
    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
   575
    {
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 'text':
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   577
      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
   578
        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
   579
        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
   580
        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
   581
        break;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   582
      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
   583
        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
   584
        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
   585
        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
   586
        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
   587
        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
   588
        break;
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
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   592
  $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
   593
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   594
  $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
   595
  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
   596
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   597
    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
   598
    {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   599
      $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
   600
      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
   601
        $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
   602
      
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   603
      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
   604
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   605
    else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   606
    {
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   607
      $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
   608
      ?>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   609
      <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
   610
        <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
   611
        <p>
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('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
   613
          <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
   614
        </p>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   615
      </form>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   616
      <?php
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   617
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   618
    $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
   619
    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
   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
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   622
  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
   623
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   624
    // 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
   625
    $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
   626
    $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
   627
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   628
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   629
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   630
    // anonymous
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   631
    $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
   632
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   633
  $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
   634
  $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
   635
  
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 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
   637
  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
   638
          ' . $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
   639
          /
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   640
          <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
   641
          /
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   642
          <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
   643
          
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   644
  if ( $paste_parent )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   645
  {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   646
    // pull flags of parent
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   647
    $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
   648
    if ( !$q )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   649
      $db->_die();
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   650
    
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   651
    if ( $db->numrows() > 0 )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   652
    {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   653
      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
   654
      $parenthash = false;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   655
      if ( $parent_flags & PASTE_PRIVATE )
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   656
      {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   657
        $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
   658
      }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   659
      
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   660
      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
   661
          '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
   662
          '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
   663
          'parent_id' => $paste_parent
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
    }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   666
    $db->free_result($q);
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   667
  }
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   668
          
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   669
  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
   670
  {
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   671
    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
   672
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   673
  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
   674
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   675
    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
   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
  
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 '</div>';
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 $pasteinfo;
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   680
  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
   681
  
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   682
  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
   683
  {
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   684
    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
   685
    // 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
   686
    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
   687
    $output->footer();
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   688
    return;
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   689
  }
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   690
  
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   691
  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
   692
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   693
    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
   694
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   695
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   696
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   697
    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
   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
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   700
  $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
   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
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   703
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
   704
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   705
  $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
   706
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   707
  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
   708
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   709
    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
   710
      $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
   711
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   712
    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
   713
    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
   714
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   715
    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
   716
    
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 = 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
   718
    $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
   719
    $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
   720
    $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
   721
    $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
   722
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   723
    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
   724
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   725
  else
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   726
  {
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 '<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
   728
    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
   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
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   732
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
   733
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   734
  $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
   735
  $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
   736
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   737
  // 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
   738
  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
   739
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   740
    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
   741
    
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   742
    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
   743
    $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
   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
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   746
  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
   747
  {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   748
    $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
   749
    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
   750
    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
   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
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   753
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   754
function gorilla_sign($id, $text)
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   755
{
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   756
  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
   757
}
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   758
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   759
// 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
   760
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
   761
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   762
  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
   763
  
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   764
  $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
   765
  $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
   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
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   768
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
   769
2
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   770
// Search handler
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   771
$plugins->attachHook('session_started', 'gorilla_attach_search();');
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   772
function gorilla_attach_search()
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   773
{
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   774
  global $lang;
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   775
  register_search_handler(array(
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   776
    'table' => 'pastes',
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   777
    'titlecolumn' => 'paste_title',
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   778
    'datacolumn' => 'paste_text',
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   779
    'uniqueid' => 'ns=Paste;cid={paste_id}',
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   780
    'additionalcolumns' => array('paste_id', 'paste_language'),
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   781
    'resultnote' => $lang->get('gorilla_lbl_search_tag'),
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   782
    'linkformat' => array(
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   783
        'page_id' => '{paste_id}',
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   784
        'namespace' => 'Paste'
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   785
      ),
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   786
    'additionalwhere' => 'AND (paste_flags & ' . PASTE_PRIVATE . ') = 0',
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   787
  ));
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   788
}
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   789
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   790
/**!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
   791
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
   792
  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
   793
  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
   794
  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
   795
  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
   796
  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
   797
  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
   798
  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
   799
  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
   800
  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
   801
  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
   802
  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
   803
  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
   804
) 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
   805
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   806
**!*/
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   807
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   808
/**!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
   809
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
   810
**!*/
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   811
0
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   812
/**!uninstall **
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   813
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
   814
**!*/
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   815
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   816
/**!language**
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   817
<code>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   818
{
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   819
  eng: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   820
    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
   821
    strings: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   822
      meta: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   823
        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
   824
      },
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   825
      gorilla: {
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   826
        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
   827
        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
   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
        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
   830
        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
   831
        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
   832
        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
   833
        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
   834
        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
   835
        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
   836
        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
   837
        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
   838
        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
   839
        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
   840
        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
   841
        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
   842
        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
   843
        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
   844
        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
   845
        lbl_ttl_forever: 'forever',
1
f2ceea4fabe8 Added support for replying and fixed a few security holes. TODO: search integration
Dan
parents: 0
diff changeset
   846
        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
   847
        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
   848
        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
   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_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
   851
        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
   852
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   853
        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
   854
        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
   855
        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
   856
        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
   857
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   858
        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
   859
        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
   860
        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
   861
        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
   862
        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
   863
        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
   864
        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
   865
        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
   866
        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
   867
        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
   868
        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
   869
        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
   870
        
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   871
        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
   872
        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
   873
        btn_delete_confirm: 'Delete',
2
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   874
        
b6178b40aa09 Pastes are now searchable, privacy settings respected.
Dan
parents: 1
diff changeset
   875
        lbl_search_tag: '[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
   876
      }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   877
    }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   878
  }
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   879
}
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   880
</code>
cac93de16379 First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff changeset
   881
**!*/