author | Dan |
Thu, 12 Jul 2007 01:04:01 -0400 | |
changeset 2 | a8a21e1c7afa |
parent 0 | f9ffdbd96607 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/*********************************************************************** |
|
3 |
||
4 |
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) |
|
5 |
||
6 |
This file is part of PunBB. |
|
7 |
||
8 |
PunBB is free software; you can redistribute it and/or modify it |
|
9 |
under the terms of the GNU General Public License as published |
|
10 |
by the Free Software Foundation; either version 2 of the License, |
|
11 |
or (at your option) any later version. |
|
12 |
||
13 |
PunBB is distributed in the hope that it will be useful, but |
|
14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
21 |
MA 02111-1307 USA |
|
22 |
||
23 |
************************************************************************/ |
|
24 |
||
25 |
## |
|
26 |
## |
|
27 |
## A few notes of interest for aspiring plugin authors: |
|
28 |
## |
|
29 |
## 1. If you want to display a message via the message() function, you |
|
30 |
## must do so before calling generate_admin_menu($plugin). |
|
31 |
## |
|
32 |
## 2. Plugins are loaded by admin_loader.php and must not be |
|
33 |
## terminated (e.g. by calling exit()). After the plugin script has |
|
34 |
## finished, the loader script displays the footer, so don't worry |
|
35 |
## about that. Please note that terminating a plugin by calling |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
36 |
## message() or pun_redirect() is fine though. |
0 | 37 |
## |
38 |
## 3. The action attribute of any and all <form> tags and the target |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
39 |
## URL for the pun_redirect() function must be set to the value of |
0 | 40 |
## $_SERVER['REQUEST_URI']. This URL can however be extended to |
41 |
## include extra variables (like the addition of &foo=bar in |
|
42 |
## the form of this example plugin). |
|
43 |
## |
|
44 |
## 4. If your plugin is for administrators only, the filename must |
|
45 |
## have the prefix "AP_". If it is for both administrators and |
|
46 |
## moderators, use the prefix "AMP_". This example plugin has the |
|
47 |
## prefix "AMP_" and is therefore available for both admins and |
|
48 |
## moderators in the navigation menu. |
|
49 |
## |
|
50 |
## 5. Use _ instead of spaces in the file name. |
|
51 |
## |
|
52 |
## 6. Since plugin scripts are included from the PunBB script |
|
53 |
## admin_loader.php, you have access to all PunBB functions and |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
54 |
## global variables (e.g. $pun_db, $pun_config, $pun_user etc). |
0 | 55 |
## |
56 |
## 7. Do your best to keep the look and feel of your plugins' user |
|
57 |
## interface similar to the rest of the admin scripts. Feel free to |
|
58 |
## borrow markup and code from the admin scripts to use in your |
|
59 |
## plugins. If you create your own styles they need to be added to |
|
60 |
## the "base_admin" style sheet. |
|
61 |
## |
|
62 |
## 8. Plugins must be released under the GNU General Public License or |
|
63 |
## a GPL compatible license. Copy the GPL preamble at the top of |
|
64 |
## this file into your plugin script and alter the copyright notice |
|
65 |
## to refrect the author of the plugin (i.e. you). |
|
66 |
## |
|
67 |
## |
|
68 |
||
69 |
||
70 |
// Make sure no one attempts to run this script "directly" |
|
71 |
if (!defined('PUN')) |
|
72 |
exit; |
|
73 |
||
74 |
// Tell admin_loader.php that this is indeed a plugin and that it is loaded |
|
75 |
define('PUN_PLUGIN_LOADED', 1); |
|
76 |
||
77 |
// |
|
78 |
// The rest is up to you! |
|
79 |
// |
|
80 |
||
81 |
// If the "Show text" button was clicked |
|
82 |
if (isset($_POST['show_text'])) |
|
83 |
{ |
|
84 |
// Make sure something something was entered |
|
85 |
if (trim($_POST['text_to_show']) == '') |
|
86 |
message('You didn\'t enter anything!'); |
|
87 |
||
88 |
// Display the admin navigation menu |
|
89 |
generate_admin_menu($plugin); |
|
90 |
||
91 |
?> |
|
92 |
<div class="block"> |
|
93 |
<h2><span>Example plugin</span></h2> |
|
94 |
<div class="box"> |
|
95 |
<div class="inbox"> |
|
96 |
<p>You said "<?php echo pun_htmlspecialchars($_POST['text_to_show']) ?>". Great stuff.</p> |
|
97 |
<p><a href="javascript: history.go(-1)">Go back</a></p> |
|
98 |
</div> |
|
99 |
</div> |
|
100 |
</div> |
|
101 |
<?php |
|
102 |
||
103 |
} |
|
104 |
else // If not, we show the "Show text" form |
|
105 |
{ |
|
106 |
// Display the admin navigation menu |
|
107 |
generate_admin_menu($plugin); |
|
108 |
||
109 |
?> |
|
110 |
<div id="exampleplugin" class="blockform"> |
|
111 |
<h2><span>Example plugin</span></h2> |
|
112 |
<div class="box"> |
|
113 |
<div class="inbox"> |
|
114 |
<p>This plugin doesn't do anything useful. Hence the name "Example".</p> |
|
115 |
<p>This would be a good spot to talk a little about your plugin. Describe what it does and how it should be used. Be brief, but informative.</p> |
|
116 |
</div> |
|
117 |
</div> |
|
118 |
||
119 |
<h2 class="block2"><span>An example form</span></h2> |
|
120 |
<div class="box"> |
|
121 |
<form id="example" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>&foo=bar"> |
|
122 |
<div class="inform"> |
|
123 |
<fieldset> |
|
124 |
<legend>Enter a piece of text and hit "Show text"!</legend> |
|
125 |
<div class="infldset"> |
|
126 |
<table class="aligntop" cellspacing="0"> |
|
127 |
<tr> |
|
128 |
<th scope="row">Text to show<div><input type="submit" name="show_text" value="Show text" tabindex="2" /></div></th> |
|
129 |
<td> |
|
130 |
<input type="text" name="text_to_show" size="25" tabindex="1" /> |
|
131 |
<span>The text you want to display.</span> |
|
132 |
</td> |
|
133 |
</tr> |
|
134 |
</table> |
|
135 |
</div> |
|
136 |
</fieldset> |
|
137 |
</div> |
|
138 |
</form> |
|
139 |
</div> |
|
140 |
</div> |
|
141 |
<?php |
|
142 |
||
143 |
} |
|
144 |
||
145 |
// Note that the script just ends here. The footer will be included by admin_loader.php. |