author | Dan |
Sat, 30 May 2009 02:52:13 -0400 | |
changeset 0 | cac93de16379 |
child 1 | f2ceea4fabe8 |
permissions | -rw-r--r-- |
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.™ 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", |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
8 |
"Version" : "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
|
9 |
"Author URI" : "http://enanocms.org/" |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
10 |
} |
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 |
// 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
|
14 |
$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
|
15 |
// 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
|
16 |
$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
|
17 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
18 |
// constants |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
19 |
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
|
20 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
21 |
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
|
22 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
23 |
// 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
|
24 |
$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
|
25 |
$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
|
26 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
27 |
// 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
|
28 |
/** |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
29 |
* @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
|
30 |
* @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
|
31 |
* @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
|
32 |
* @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
|
33 |
* @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
|
34 |
*/ |
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 |
$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
|
37 |
$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
|
38 |
$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
|
39 |
$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
|
40 |
$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
|
41 |
$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
|
42 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
43 |
$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
|
44 |
$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
|
45 |
} |
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 |
// 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
|
48 |
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
|
49 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
50 |
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
|
51 |
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
|
52 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
53 |
$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
|
54 |
$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
|
55 |
$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
|
56 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
57 |
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
|
58 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
} |
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 |
$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
|
65 |
$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
|
66 |
$text = ''; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
67 |
$title = ''; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
68 |
$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
|
69 |
$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
|
70 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
71 |
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
|
72 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
73 |
$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
|
74 |
$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
|
75 |
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
|
76 |
$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
|
77 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
78 |
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
|
79 |
$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
|
80 |
$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
|
81 |
$copy_from = $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
|
82 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
83 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
84 |
$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
|
85 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
86 |
?> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
87 |
<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
|
88 |
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
|
89 |
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
|
90 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
91 |
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
|
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 |
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
|
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 |
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
|
96 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
97 |
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
|
98 |
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
|
99 |
}, 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
|
100 |
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
|
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
103 |
try |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
104 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
105 |
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
|
106 |
$('#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
|
107 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
108 |
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
|
109 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
title: $('#gorilla_title').val(), |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
116 |
ttl: parseInt($('.gorilla_ttl:checked').val()) |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
117 |
}; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
118 |
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
|
119 |
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
|
120 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
121 |
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
|
122 |
{ |
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 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
|
124 |
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
|
125 |
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
|
126 |
else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
127 |
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
|
128 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
129 |
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
|
130 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
131 |
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
|
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 |
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
|
134 |
$('#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
|
135 |
}, 1250); |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
136 |
} |
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 |
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
|
139 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
140 |
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
|
141 |
{} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
142 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
143 |
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
|
144 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
145 |
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
|
146 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
147 |
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
|
148 |
}); |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
149 |
</script> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
150 |
<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
|
151 |
<?php |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
152 |
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
|
153 |
?> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
154 |
</div> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
155 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
156 |
<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
|
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 |
<?php |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
159 |
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
|
160 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
161 |
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
|
162 |
} |
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
165 |
<!-- private --> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
166 |
<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
|
167 |
<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
|
168 |
<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
|
169 |
<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
|
170 |
</label> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
171 |
</div> |
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 |
<!-- highlighting --> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
174 |
<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
|
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 |
<?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
|
177 |
<?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
|
178 |
<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
|
179 |
<?php |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
180 |
// 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
|
181 |
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
|
182 |
$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
|
183 |
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
|
184 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
185 |
// $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
|
186 |
// 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
|
187 |
// $string = $_; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
188 |
// else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
189 |
$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
|
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 |
$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
|
192 |
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
|
193 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
194 |
?> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
195 |
</select> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
196 |
<?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
|
197 |
<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
|
198 |
<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
|
199 |
<?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
|
200 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
201 |
</div> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
202 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
203 |
<!-- 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
|
204 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
205 |
<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
|
206 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
207 |
<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
|
208 |
<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
|
209 |
<div> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
210 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
211 |
<!-- title --> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
212 |
<p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
213 |
<?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
|
214 |
<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
|
215 |
</p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
216 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
217 |
<!-- nick --> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
218 |
<p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
219 |
<?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
|
220 |
<?php |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
221 |
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
|
222 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
223 |
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
|
224 |
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
|
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 |
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
|
227 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
228 |
$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
|
229 |
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
|
230 |
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
|
231 |
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
|
232 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
233 |
else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
234 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
235 |
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
|
236 |
} |
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 |
</p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
239 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
240 |
<!-- ttl --> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
241 |
<p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
242 |
<?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
|
243 |
<em> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
244 |
<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
|
245 |
<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
|
246 |
<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
|
247 |
<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
|
248 |
</em> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
249 |
</p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
250 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
251 |
</div> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
252 |
</fieldset> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
253 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
254 |
<!-- 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
|
255 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
256 |
<?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
|
257 |
<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
|
258 |
<?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
|
259 |
</div> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
260 |
<?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
|
261 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
262 |
<!-- submit --> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
263 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
264 |
<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
|
265 |
</form> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
266 |
<?php |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
267 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
268 |
$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
|
269 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
270 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
271 |
// 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
|
272 |
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
|
273 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
274 |
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
|
275 |
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
|
276 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
277 |
$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
|
278 |
'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
|
279 |
'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
|
280 |
'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
|
281 |
'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
|
282 |
'title' => 'string', |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
283 |
'ttl' => 'integer' |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
284 |
); |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
285 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
286 |
$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
|
287 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
288 |
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
|
289 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
290 |
try |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
291 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
292 |
$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
|
293 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
294 |
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
|
295 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
296 |
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
|
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 |
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
|
299 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
305 |
$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
|
306 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
307 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
308 |
else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
309 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
310 |
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
|
311 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
312 |
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
|
313 |
return ''; |
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 |
'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
|
317 |
'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
|
318 |
'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
|
319 |
'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
|
320 |
'title' => $_POST['title'], |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
321 |
'ttl' => intval($_POST['ttl']) |
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 |
} |
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 |
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
|
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 |
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
|
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
330 |
// 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
|
331 |
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
|
332 |
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
|
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 |
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
|
335 |
$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
|
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 |
$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
|
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
342 |
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
|
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_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
|
345 |
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
|
346 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
347 |
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
|
348 |
$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
|
349 |
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
|
350 |
$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
|
351 |
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
|
352 |
$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
|
353 |
else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
354 |
$item = "''"; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
355 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
356 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
357 |
$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
|
358 |
$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
|
359 |
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
|
360 |
$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
|
361 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
362 |
$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 ) VALUES\n" |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
363 |
. " ( {$info_db['title']}, {$info_db['text']}, $session->user_id, {$info_db['nick']}, '{$_SERVER['REMOTE_ADDR']}', {$info_db['highlight']}, $now, {$info_db['ttl']}, $flags );"; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
364 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
365 |
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
|
366 |
( $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
|
367 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
368 |
// 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
|
369 |
$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
|
370 |
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
|
371 |
( $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
|
372 |
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
|
373 |
$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
|
374 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
375 |
$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
|
376 |
if ( $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
|
377 |
$params = 'hash=' . hmac_sha1($paste_id, sha1($info['text'])); |
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 |
$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
|
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 |
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
|
382 |
. '<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
|
383 |
. '<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
|
384 |
} |
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 |
############################################################################### |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
387 |
## 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
|
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
390 |
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
|
391 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
392 |
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
|
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 |
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
|
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 |
$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
|
397 |
$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
|
398 |
$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
|
399 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
400 |
$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
|
401 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
402 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
403 |
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
|
404 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
405 |
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
|
406 |
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
|
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 |
$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
|
409 |
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
|
410 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
411 |
$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
|
412 |
. " 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
|
413 |
. " 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
|
414 |
. " 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
|
415 |
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
|
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 |
$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
|
418 |
$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
|
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 |
$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
|
421 |
} |
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 ( $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
|
423 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
424 |
$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
|
425 |
'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
|
426 |
'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
|
427 |
'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
|
428 |
'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
|
429 |
'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
|
430 |
'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
|
431 |
'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
|
432 |
'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
|
433 |
'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
|
434 |
'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
|
435 |
'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
|
436 |
'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
|
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 |
else |
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 |
$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
|
442 |
'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
|
443 |
'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
|
444 |
'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
|
445 |
'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
|
446 |
'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
|
447 |
'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
|
448 |
'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
|
449 |
'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
|
450 |
'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
|
451 |
'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
|
452 |
'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
|
453 |
'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
|
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 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
456 |
$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
|
457 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
458 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
459 |
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
|
460 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
461 |
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
|
462 |
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
|
463 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
464 |
$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
|
465 |
$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
|
466 |
.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
|
467 |
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
|
468 |
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
|
469 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
470 |
</style> |
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
473 |
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
|
474 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
475 |
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
|
476 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
477 |
else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
478 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
479 |
$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
|
480 |
$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
|
481 |
$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
|
482 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
483 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
484 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
485 |
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
|
486 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
487 |
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
|
488 |
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
|
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
492 |
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
|
493 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
494 |
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
|
495 |
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
|
496 |
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
|
497 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
498 |
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
|
499 |
$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
|
500 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
501 |
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
|
502 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
503 |
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
|
504 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
505 |
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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
break; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
511 |
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
|
512 |
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
|
513 |
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
|
514 |
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
|
515 |
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
|
516 |
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
|
517 |
break; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
518 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
519 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
520 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
521 |
if ( $paste_flags & PASTE_PRIVATE || isset($_GET['delete']) ) |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
522 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
523 |
if ( @$_GET['hash'] !== hmac_sha1($paste_id, sha1($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
|
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 |
die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('gorilla_msg_wrong_hash') . '</p>'); |
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 |
} |
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 |
$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
|
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 |
$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
|
532 |
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
|
533 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
534 |
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
|
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 |
$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
|
537 |
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
|
538 |
$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
|
539 |
|
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_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
|
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 |
else |
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 |
$submit_url = makeUrlNS('Paste', $paste_id, 'delete&hash=' . hmac_sha1($paste_id, sha1($paste_text)), true); |
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 |
<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
|
547 |
<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
|
548 |
<p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
549 |
<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
|
550 |
<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
|
551 |
</p> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
552 |
</form> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
553 |
<?php |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
554 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
555 |
$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
|
556 |
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
|
557 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
558 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
559 |
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
|
560 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
561 |
// 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
|
562 |
$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
|
563 |
$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
|
564 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
565 |
else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
566 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
567 |
// anonymous |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
568 |
$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
|
569 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
570 |
$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
|
571 |
$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
|
572 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
573 |
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
|
574 |
echo '<div style="float: right;"> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
575 |
' . $lang->get('gorilla_msg_other_formats', array('plain_link' => makeUrlNS('Paste', $paste_id, 'format=text', true), 'download_link' => makeUrlNS('Paste', $paste_id, 'format=download', true))) . ' |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
576 |
/ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
577 |
<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
|
578 |
/ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
579 |
<a title="' . $lang->get('gorilla_tip_copy_from_this') . '" href="' . makeUrlNS('Special', 'NewPaste/Copy=' . $paste_id) . '">' . $lang->get('gorilla_btn_copy_from_this') . '</a>'; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
580 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
581 |
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
|
582 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
583 |
echo ' / <a title="' . $lang->get('gorilla_tip_delete') . '" href="' . makeUrlNS('Paste', $paste_id, 'delete&hash=' . hmac_sha1($paste_id, sha1($paste_text)), true) . '">' . $lang->get('gorilla_btn_delete') . '</a>'; |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
584 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
585 |
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
|
586 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
587 |
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
|
588 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
589 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
590 |
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
|
591 |
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
|
592 |
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
|
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 |
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
|
595 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
596 |
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
|
597 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
598 |
else |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
599 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
600 |
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
|
601 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
602 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
603 |
$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
|
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 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
606 |
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
|
607 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
608 |
$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
|
609 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
610 |
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
|
611 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
612 |
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
|
613 |
$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
|
614 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
615 |
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
|
616 |
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
|
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 |
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
|
619 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
620 |
$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
|
621 |
$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
|
622 |
$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
|
623 |
$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
|
624 |
$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
|
625 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
626 |
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
|
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 |
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
|
631 |
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
|
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 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
634 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
635 |
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
|
636 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
637 |
$sections = preg_split('/^## .*$/m', $text); |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
638 |
$headingcount = preg_match_all('/^## (.+?)(?: \[([a-z_-]+)\])? *$/m', $text, $matches); |
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 |
// 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
|
641 |
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
|
642 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
643 |
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
|
644 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
645 |
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
|
646 |
$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
|
647 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
648 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
649 |
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
|
650 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
651 |
$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
|
652 |
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
|
653 |
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
|
654 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
655 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
656 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
657 |
// 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
|
658 |
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
|
659 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
660 |
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
|
661 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
662 |
$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
|
663 |
$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
|
664 |
} |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
665 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
666 |
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
|
667 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
668 |
/**!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
|
669 |
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
|
670 |
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
|
671 |
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
|
672 |
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
|
673 |
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
|
674 |
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
|
675 |
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
|
676 |
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
|
677 |
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
|
678 |
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
|
679 |
paste_flags int(8) 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
|
680 |
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
|
681 |
) 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
|
682 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
683 |
**!*/ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
684 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
685 |
/**!uninstall ** |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
686 |
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
|
687 |
**!*/ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
688 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
689 |
/**!language** |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
690 |
<code> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
691 |
{ |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
692 |
eng: { |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
693 |
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
|
694 |
strings: { |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
695 |
meta: { |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
696 |
gorilla: 'Gorilla', |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
697 |
}, |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
698 |
gorilla: { |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
699 |
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
|
700 |
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
|
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 |
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
|
703 |
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
|
704 |
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
|
705 |
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
|
706 |
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
|
707 |
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
|
708 |
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
|
709 |
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
|
710 |
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
|
711 |
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
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
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
|
716 |
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
|
717 |
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
|
718 |
lbl_ttl_forever: 'forever', |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
719 |
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
|
720 |
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
|
721 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
722 |
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
|
723 |
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
|
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 |
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
|
726 |
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
|
727 |
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
|
728 |
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
|
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 |
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
|
731 |
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
|
732 |
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
|
733 |
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
|
734 |
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
|
735 |
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
|
736 |
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
|
737 |
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
|
738 |
tip_paste_ip: 'IP address of 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
|
739 |
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
|
740 |
|
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
741 |
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
|
742 |
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
|
743 |
btn_delete_confirm: 'Delete', |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
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 |
} |
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 |
</code> |
cac93de16379
First commit. Works great. TODO: add ability to reply to other pastes and provide some primitive threaded structure.
Dan
parents:
diff
changeset
|
749 |
**!*/ |