Nucleus CMS日本語版SVNをgit-svnしたもの。リポジトリの変換作業用
Revision | 954d99f2b9d7271c07206b1693ea4ca7d86a0840 (tree) |
---|---|
Zeit | 2009-04-16 15:20:23 |
Autor | shizuki <shizuki@1ca2...> |
Commiter | shizuki |
fix: item link after doKarma
fix: 文字化け
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk/utf8@999 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -178,7 +178,7 @@ define('_BOOKMARKLET_ERROR_COULDNTNEWCAT', ' | ||
178 | 178 | |
179 | 179 | // BAN |
180 | 180 | define('_BAN_EXAMPLE_TITLE', '例'); |
181 | -define('_BAN_EXAMPLE_TEXT', ': "134.58.253.193"と入力した場合は、このIPアドレスを持つPC1台だけをブロックします。"134.58.253"と入力した場合は、"134.58.235.0潤オ134.58.235.255"の範囲の256個のIPアドレスを持つPCを全てブロックします。これは、前者のIPアドレス(134.58.253.193)を含みます。'); | |
181 | +define('_BAN_EXAMPLE_TEXT', ': "134.58.253.193"と入力した場合は、このIPアドレスを持つPC1台だけをブロックします。"134.58.253"と入力した場合は、"134.58.235.0〜134.58.235.255"の範囲の256個のIPアドレスを持つPCを全てブロックします。これは、前者のIPアドレス(134.58.253.193)を含みます。'); | |
182 | 182 | define('_BAN_IP_CUSTOM', 'ブロック指定: '); |
183 | 183 | define('_BAN_BANBLOGNAME', '%s のみ'); |
184 | 184 |
@@ -18,401 +18,410 @@ | ||
18 | 18 | * @version $Id$ |
19 | 19 | * $NucleusJP: ACTION.php,v 1.10 2007/05/31 07:23:39 kimitake Exp $ |
20 | 20 | */ |
21 | -class ACTION | |
22 | -{ | |
23 | - /** | |
24 | - * Constructor for an new ACTION object | |
25 | - */ | |
26 | - function ACTION() | |
27 | - { | |
28 | - // do nothing | |
29 | - } | |
30 | - | |
31 | - /** | |
32 | - * Calls functions that handle an action called from action.php | |
33 | - */ | |
34 | - function doAction($action) | |
35 | - { | |
36 | - switch($action) { | |
37 | - case 'autodraft': | |
38 | - return $this->autoDraft(); | |
39 | - break; | |
40 | - case 'updateticket': | |
41 | - return $this->updateTicket(); | |
42 | - break; | |
43 | - case 'addcomment': | |
44 | - return $this->addComment(); | |
45 | - break; | |
46 | - case 'sendmessage': | |
47 | - return $this->sendMessage(); | |
48 | - break; | |
49 | - case 'createaccount': | |
50 | - return $this->createAccount(); | |
51 | - break; | |
52 | - case 'forgotpassword': | |
53 | - return $this->forgotPassword(); | |
54 | - break; | |
55 | - case 'votepositive': | |
56 | - return $this->doKarma('pos'); | |
57 | - break; | |
58 | - case 'votenegative': | |
59 | - return $this->doKarma('neg'); | |
60 | - break; | |
61 | - case 'plugin': | |
62 | - return $this->callPlugin(); | |
63 | - break; | |
64 | - default: | |
65 | - doError(_ERROR_BADACTION); | |
66 | - } | |
67 | - } | |
68 | - | |
69 | - /** | |
70 | - * Adds a new comment to an item (if IP isn't banned) | |
71 | - */ | |
72 | - function addComment() { | |
73 | - global $CONF, $errormessage, $manager; | |
74 | - | |
75 | - $post['itemid'] = intPostVar('itemid'); | |
76 | - $post['user'] = postVar('user'); | |
77 | - $post['userid'] = postVar('userid'); | |
78 | - $post['email'] = postVar('email'); | |
79 | - $post['body'] = postVar('body'); | |
80 | - | |
81 | - // set cookies when required | |
82 | - $remember = intPostVar('remember'); | |
83 | - if ($remember == 1) { | |
84 | - $lifetime = time()+2592000; | |
85 | - setcookie($CONF['CookiePrefix'] . 'comment_user',$post['user'],$lifetime,'/','',0); | |
86 | - setcookie($CONF['CookiePrefix'] . 'comment_userid', $post['userid'],$lifetime,'/','',0); | |
87 | - setcookie($CONF['CookiePrefix'] . 'comment_email', $post['email'], $lifetime,'/','',0); | |
88 | - } | |
89 | - | |
90 | - $comments = new COMMENTS($post['itemid']); | |
91 | - | |
92 | - $blogid = getBlogIDFromItemID($post['itemid']); | |
93 | - $this->checkban($blogid); | |
94 | - $blog =& $manager->getBlog($blogid); | |
95 | - | |
96 | - // note: PreAddComment and PostAddComment gets called somewhere inside addComment | |
97 | - $errormessage = $comments->addComment($blog->getCorrectTime(),$post); | |
98 | - | |
99 | - if ($errormessage == '1') { | |
100 | - // redirect when adding comments succeeded | |
101 | - if (postVar('url')) { | |
102 | - redirect(postVar('url')); | |
103 | - } else { | |
104 | - $url = createItemLink($post['itemid']); | |
105 | - redirect($url); | |
106 | - } | |
107 | - } else { | |
108 | - // else, show error message using default skin for blog | |
109 | - return array( | |
110 | - 'message' => $errormessage, | |
111 | - 'skinid' => $blog->getDefaultSkin() | |
112 | - ); | |
113 | - } | |
114 | - | |
115 | - exit; | |
116 | - } | |
117 | - | |
118 | - /** | |
119 | - * Sends a message from the current member to the member given as argument | |
120 | - */ | |
121 | - function sendMessage() { | |
122 | - global $CONF, $member; | |
123 | - | |
124 | - $error = $this->validateMessage(); | |
125 | - if ($error != '') | |
126 | - return array('message' => $error); | |
127 | - | |
128 | - if (!$member->isLoggedIn()) { | |
129 | - $fromMail = postVar('frommail'); | |
130 | - $fromName = _MMAIL_FROMANON; | |
131 | - } else { | |
132 | - $fromMail = $member->getEmail(); | |
133 | - $fromName = $member->getDisplayName(); | |
134 | - } | |
135 | - | |
136 | - $tomem = new MEMBER(); | |
137 | - $tomem->readFromId(postVar('memberid')); | |
138 | - | |
139 | - $message = _MMAIL_MSG . ' ' . $fromName . "\n" | |
140 | - . '(' . _MMAIL_FROMNUC. ' ' . $CONF['IndexURL'] .") \n\n" | |
141 | - . _MMAIL_MAIL . " \n\n" | |
142 | - . postVar('message'); | |
143 | - $message .= getMailFooter(); | |
144 | - | |
145 | - $title = _MMAIL_TITLE . ' ' . $fromName; | |
146 | - mb_language('ja'); | |
147 | - mb_internal_encoding(_CHARSET); | |
148 | - @mb_send_mail($tomem->getEmail(), $title, $message, "From: ". $fromMail); | |
149 | - | |
150 | - if (postVar('url')) { | |
151 | - redirect(postVar('url')); | |
152 | - } else { | |
153 | - $CONF['MemberURL'] = $CONF['IndexURL']; | |
154 | - if ($CONF['URLMode'] == 'pathinfo') | |
155 | - { | |
156 | - $url = createLink('member', array('memberid' => $tomem->getID(), 'name' => $tomem->getDisplayName())); | |
157 | - } | |
158 | - else | |
159 | - { | |
160 | - $url = $CONF['IndexURL'] . createMemberLink($tomem->getID()); | |
161 | - } | |
162 | - redirect($url); | |
163 | - } | |
164 | - exit; | |
165 | - } | |
166 | - | |
167 | - /** | |
168 | - * Checks if a mail to a member is allowed | |
169 | - * Returns a string with the error message if the mail is disallowed | |
170 | - */ | |
171 | - function validateMessage() { | |
172 | - global $CONF, $member, $manager; | |
173 | - | |
174 | - if (!$CONF['AllowMemberMail']) | |
175 | - return _ERROR_MEMBERMAILDISABLED; | |
176 | - | |
177 | - if (!$member->isLoggedIn() && !$CONF['NonmemberMail']) | |
178 | - return _ERROR_DISALLOWED; | |
179 | - | |
180 | - if (!$member->isLoggedIn() && (!isValidMailAddress(postVar('frommail')))) | |
181 | - return _ERROR_BADMAILADDRESS; | |
182 | - | |
183 | - // let plugins do verification (any plugin which thinks the comment is invalid | |
184 | - // can change 'error' to something other than '') | |
185 | - $result = ''; | |
186 | - $manager->notify('ValidateForm', array('type' => 'membermail', 'error' => &$result)); | |
187 | - | |
188 | - return $result; | |
189 | - | |
190 | - } | |
191 | - | |
192 | - /** | |
193 | - * Creates a new user account | |
194 | - */ | |
195 | - function createAccount() { | |
196 | - global $CONF, $manager; | |
197 | - | |
198 | - if (!$CONF['AllowMemberCreate']) | |
199 | - doError(_ERROR_MEMBERCREATEDISABLED); | |
200 | - | |
201 | - // evaluate content from FormExtra | |
202 | - $result = 1; | |
203 | - $data = array('type' => 'membermail', 'error' => &$result); | |
204 | - $manager->notify('ValidateForm', &$data); | |
205 | - | |
206 | - if ($result!=1) { | |
207 | - return $result; | |
208 | - } | |
209 | - else { | |
210 | - | |
211 | - // even though the member can not log in, set some random initial password. One never knows. | |
212 | - srand((double)microtime()*1000000); | |
213 | - $initialPwd = md5(uniqid(rand(), true)); | |
214 | - | |
215 | - // create member (non admin/can not login/no notes/random string as password) | |
216 | - $name = shorten(postVar('name'),16,''); | |
217 | - $r = MEMBER::create($name, postVar('realname'), $initialPwd, postVar('email'), postVar('url'), 0, 0, ''); | |
218 | - | |
219 | - if ($r != 1) { | |
220 | - return $r; | |
221 | - } | |
222 | - | |
223 | - // send message containing password. | |
224 | - $newmem = new MEMBER(); | |
225 | - $newmem->readFromName($name); | |
226 | - $newmem->sendActivationLink('register'); | |
227 | - | |
228 | - $manager->notify('PostRegister',array('member' => &$newmem)); | |
229 | - | |
230 | - if (postVar('desturl')) { | |
231 | - redirect(postVar('desturl')); | |
232 | - } else { | |
233 | - // header has been already sent, so deleted the line below | |
234 | - //header ("Content-Type: text/html; charset="._CHARSET); | |
235 | - echo _MSG_ACTIVATION_SENT; | |
236 | - } | |
237 | - exit; | |
238 | - } | |
239 | - } | |
240 | - | |
241 | - /** | |
242 | - * Sends a new password | |
243 | - */ | |
244 | - function forgotPassword() { | |
245 | - $membername = trim(postVar('name')); | |
246 | - | |
247 | - if (!MEMBER::exists($membername)) | |
248 | - doError(_ERROR_NOSUCHMEMBER); | |
249 | - $mem = MEMBER::createFromName($membername); | |
250 | - | |
251 | - if (!$mem->canLogin()) | |
252 | - doError(_ERROR_NOLOGON_NOACTIVATE); | |
253 | - | |
254 | - // check if e-mail address is correct | |
255 | - if (!($mem->getEmail() == postVar('email'))) | |
256 | - doError(_ERROR_INCORRECTEMAIL); | |
257 | - | |
258 | - // send activation link | |
259 | - $mem->sendActivationLink('forgot'); | |
260 | - | |
261 | - if (postVar('url')) { | |
262 | - redirect(postVar('url')); | |
263 | - } else { | |
264 | - header ("Content-Type: text/html; charset="._CHARSET); | |
265 | - echo _MSG_ACTIVATION_SENT; | |
266 | - } | |
267 | - exit; | |
268 | - } | |
269 | - | |
270 | - /** | |
271 | - * Handle karma votes | |
272 | - */ | |
273 | - function doKarma($type) { | |
274 | - global $itemid, $member, $CONF, $manager; | |
275 | - | |
276 | - // check if itemid exists | |
277 | - if (!$manager->existsItem($itemid,0,0)) | |
278 | - doError(_ERROR_NOSUCHITEM); | |
279 | - | |
280 | - $blogid = getBlogIDFromItemID($itemid); | |
281 | - $this->checkban($blogid); | |
282 | - | |
283 | - $karma =& $manager->getKarma($itemid); | |
284 | - | |
285 | - // check if not already voted | |
286 | - if (!$karma->isVoteAllowed(serverVar('REMOTE_ADDR'))) | |
287 | - doError(_ERROR_VOTEDBEFORE); | |
288 | - | |
289 | - // check if item does allow voting | |
290 | - $item =& $manager->getItem($itemid,0,0); | |
291 | - if ($item['closed']) | |
292 | - doError(_ERROR_ITEMCLOSED); | |
293 | - | |
294 | - switch($type) { | |
295 | - case 'pos': | |
296 | - $karma->votePositive(); | |
297 | - break; | |
298 | - case 'neg': | |
299 | - $karma->voteNegative(); | |
300 | - break; | |
301 | - } | |
302 | - | |
303 | - $blogid = getBlogIDFromItemID($itemid); | |
304 | - $blog =& $manager->getBlog($blogid); | |
305 | - | |
306 | - // send email to notification address, if any | |
307 | - if ($blog->getNotifyAddress() && $blog->notifyOnVote()) { | |
308 | - | |
309 | - $mailto_msg = _NOTIFY_KV_MSG . ' ' . $itemid . "\n"; | |
310 | - $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n"; | |
311 | - if ($member->isLoggedIn()) { | |
312 | - $mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n"; | |
313 | - } | |
314 | - $mailto_msg .= _NOTIFY_IP . ' ' . serverVar('REMOTE_ADDR') . "\n"; | |
315 | - $mailto_msg .= _NOTIFY_HOST . ' ' . gethostbyaddr(serverVar('REMOTE_ADDR')) . "\n"; | |
316 | - $mailto_msg .= _NOTIFY_VOTE . "\n " . $type . "\n"; | |
317 | - $mailto_msg .= getMailFooter(); | |
318 | - | |
319 | - $mailto_title = _NOTIFY_KV_TITLE . ' ' . strip_tags($item['title']) . ' (' . $itemid . ')'; | |
320 | - | |
321 | - $frommail = $member->getNotifyFromMailAddress(); | |
322 | - | |
323 | - $notify = new NOTIFICATION($blog->getNotifyAddress()); | |
324 | - $notify->notify($mailto_title, $mailto_msg , $frommail); | |
325 | - } | |
326 | - | |
327 | - | |
328 | - $refererUrl = serverVar('HTTP_REFERER'); | |
329 | - if ($refererUrl) | |
330 | - $url = $refererUrl; | |
331 | - else | |
332 | - $url = $CONF['IndexURL'] . 'index.php?itemid=' . $itemid; | |
333 | - | |
334 | - redirect($url); | |
335 | - exit; | |
336 | - } | |
337 | - | |
338 | - /** | |
339 | - * Calls a plugin action | |
340 | - */ | |
341 | - function callPlugin() { | |
342 | - global $manager; | |
343 | - | |
344 | - $pluginName = 'NP_' . requestVar('name'); | |
345 | - $actionType = requestVar('type'); | |
346 | - | |
347 | - // 1: check if plugin is installed | |
348 | - if (!$manager->pluginInstalled($pluginName)) | |
349 | - doError(_ERROR_NOSUCHPLUGIN); | |
350 | - | |
351 | - // 2: call plugin | |
352 | - $pluginObject =& $manager->getPlugin($pluginName); | |
353 | - if ($pluginObject) | |
354 | - $error = $pluginObject->doAction($actionType); | |
355 | - else | |
356 | - $error = 'Could not load plugin (see actionlog)'; | |
357 | - | |
358 | - // doAction returns error when: | |
359 | - // - an error occurred (duh) | |
360 | - // - no actions are allowed (doAction is not implemented) | |
361 | - if ($error) | |
362 | - doError($error); | |
363 | - | |
364 | - exit; | |
365 | - | |
366 | - } | |
367 | - | |
368 | - /** | |
369 | - * Checks if an IP or IP range is banned | |
370 | - */ | |
371 | - function checkban($blogid) { | |
372 | - // check if banned | |
373 | - $ban = BAN::isBanned($blogid, serverVar('REMOTE_ADDR')); | |
374 | - if ($ban != 0) { | |
375 | - doError(_ERROR_BANNED1 . $ban->iprange . _ERROR_BANNED2 . $ban->message . _ERROR_BANNED3); | |
376 | - } | |
377 | - | |
378 | - } | |
379 | - | |
380 | - /** | |
381 | - * Gets a new ticket | |
382 | - */ | |
383 | - function updateTicket() { | |
384 | - global $manager; | |
385 | - if ($manager->checkTicket()) { | |
386 | - echo $manager->getNewTicket(); | |
387 | - } | |
388 | - else { | |
389 | - echo 'err:' . _ERROR_BADTICKET; | |
390 | - } | |
391 | - return false; | |
392 | - } | |
393 | - | |
394 | - /** | |
395 | - * Handles AutoSaveDraft | |
396 | - */ | |
397 | - function autoDraft() { | |
398 | - global $manager; | |
399 | - if ($manager->checkTicket()) { | |
400 | - $manager->loadClass('ITEM'); | |
401 | - $info = ITEM::createDraftFromRequest(); | |
402 | - if ($info['status'] == 'error') { | |
403 | - echo $info['message']; | |
404 | - } | |
405 | - else { | |
406 | - echo $info['draftid']; | |
407 | - } | |
408 | - } | |
409 | - else { | |
410 | - echo 'err:' . _ERROR_BADTICKET; | |
411 | - } | |
412 | - return false; | |
413 | - } | |
414 | - | |
415 | - | |
416 | -} | |
417 | - | |
21 | +class ACTION | |
22 | +{ | |
23 | + /** | |
24 | + * Constructor for an new ACTION object | |
25 | + */ | |
26 | + function ACTION() | |
27 | + { | |
28 | + // do nothing | |
29 | + } | |
30 | + | |
31 | + /** | |
32 | + * Calls functions that handle an action called from action.php | |
33 | + */ | |
34 | + function doAction($action) | |
35 | + { | |
36 | + switch($action) { | |
37 | + case 'autodraft': | |
38 | + return $this->autoDraft(); | |
39 | + break; | |
40 | + case 'updateticket': | |
41 | + return $this->updateTicket(); | |
42 | + break; | |
43 | + case 'addcomment': | |
44 | + return $this->addComment(); | |
45 | + break; | |
46 | + case 'sendmessage': | |
47 | + return $this->sendMessage(); | |
48 | + break; | |
49 | + case 'createaccount': | |
50 | + return $this->createAccount(); | |
51 | + break; | |
52 | + case 'forgotpassword': | |
53 | + return $this->forgotPassword(); | |
54 | + break; | |
55 | + case 'votepositive': | |
56 | + return $this->doKarma('pos'); | |
57 | + break; | |
58 | + case 'votenegative': | |
59 | + return $this->doKarma('neg'); | |
60 | + break; | |
61 | + case 'plugin': | |
62 | + return $this->callPlugin(); | |
63 | + break; | |
64 | + default: | |
65 | + doError(_ERROR_BADACTION); | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + /** | |
70 | + * Adds a new comment to an item (if IP isn't banned) | |
71 | + */ | |
72 | + function addComment() { | |
73 | + global $CONF, $errormessage, $manager; | |
74 | + | |
75 | + $post['itemid'] = intPostVar('itemid'); | |
76 | + $post['user'] = postVar('user'); | |
77 | + $post['userid'] = postVar('userid'); | |
78 | + $post['email'] = postVar('email'); | |
79 | + $post['body'] = postVar('body'); | |
80 | + | |
81 | + // set cookies when required | |
82 | + $remember = intPostVar('remember'); | |
83 | + if ($remember == 1) { | |
84 | + $lifetime = time()+2592000; | |
85 | + setcookie($CONF['CookiePrefix'] . 'comment_user',$post['user'],$lifetime,'/','',0); | |
86 | + setcookie($CONF['CookiePrefix'] . 'comment_userid', $post['userid'],$lifetime,'/','',0); | |
87 | + setcookie($CONF['CookiePrefix'] . 'comment_email', $post['email'], $lifetime,'/','',0); | |
88 | + } | |
89 | + | |
90 | + $comments = new COMMENTS($post['itemid']); | |
91 | + | |
92 | + $blogid = getBlogIDFromItemID($post['itemid']); | |
93 | + $this->checkban($blogid); | |
94 | + $blog =& $manager->getBlog($blogid); | |
95 | + | |
96 | + // note: PreAddComment and PostAddComment gets called somewhere inside addComment | |
97 | + $errormessage = $comments->addComment($blog->getCorrectTime(),$post); | |
98 | + | |
99 | + if ($errormessage == '1') { | |
100 | + // redirect when adding comments succeeded | |
101 | + if (postVar('url')) { | |
102 | + redirect(postVar('url')); | |
103 | + } else { | |
104 | + $url = createItemLink($post['itemid']); | |
105 | + redirect($url); | |
106 | + } | |
107 | + } else { | |
108 | + // else, show error message using default skin for blog | |
109 | + return array( | |
110 | + 'message' => $errormessage, | |
111 | + 'skinid' => $blog->getDefaultSkin() | |
112 | + ); | |
113 | + } | |
114 | + | |
115 | + exit; | |
116 | + } | |
117 | + | |
118 | + /** | |
119 | + * Sends a message from the current member to the member given as argument | |
120 | + */ | |
121 | + function sendMessage() { | |
122 | + global $CONF, $member; | |
123 | + | |
124 | + $error = $this->validateMessage(); | |
125 | + if ($error != '') | |
126 | + return array('message' => $error); | |
127 | + | |
128 | + if (!$member->isLoggedIn()) { | |
129 | + $fromMail = postVar('frommail'); | |
130 | + $fromName = _MMAIL_FROMANON; | |
131 | + } else { | |
132 | + $fromMail = $member->getEmail(); | |
133 | + $fromName = $member->getDisplayName(); | |
134 | + } | |
135 | + | |
136 | + $tomem = new MEMBER(); | |
137 | + $tomem->readFromId(postVar('memberid')); | |
138 | + | |
139 | + $message = _MMAIL_MSG . ' ' . $fromName . "\n" | |
140 | + . '(' . _MMAIL_FROMNUC. ' ' . $CONF['IndexURL'] .") \n\n" | |
141 | + . _MMAIL_MAIL . " \n\n" | |
142 | + . postVar('message'); | |
143 | + $message .= getMailFooter(); | |
144 | + | |
145 | + $title = _MMAIL_TITLE . ' ' . $fromName; | |
146 | + mb_language('ja'); | |
147 | + mb_internal_encoding(_CHARSET); | |
148 | + @mb_send_mail($tomem->getEmail(), $title, $message, "From: ". $fromMail); | |
149 | + | |
150 | + if (postVar('url')) { | |
151 | + redirect(postVar('url')); | |
152 | + } else { | |
153 | + $CONF['MemberURL'] = $CONF['IndexURL']; | |
154 | + if ($CONF['URLMode'] == 'pathinfo') | |
155 | + { | |
156 | + $url = createLink('member', array('memberid' => $tomem->getID(), 'name' => $tomem->getDisplayName())); | |
157 | + } | |
158 | + else | |
159 | + { | |
160 | + $url = $CONF['IndexURL'] . createMemberLink($tomem->getID()); | |
161 | + } | |
162 | + redirect($url); | |
163 | + } | |
164 | + exit; | |
165 | + } | |
166 | + | |
167 | + /** | |
168 | + * Checks if a mail to a member is allowed | |
169 | + * Returns a string with the error message if the mail is disallowed | |
170 | + */ | |
171 | + function validateMessage() { | |
172 | + global $CONF, $member, $manager; | |
173 | + | |
174 | + if (!$CONF['AllowMemberMail']) | |
175 | + return _ERROR_MEMBERMAILDISABLED; | |
176 | + | |
177 | + if (!$member->isLoggedIn() && !$CONF['NonmemberMail']) | |
178 | + return _ERROR_DISALLOWED; | |
179 | + | |
180 | + if (!$member->isLoggedIn() && (!isValidMailAddress(postVar('frommail')))) | |
181 | + return _ERROR_BADMAILADDRESS; | |
182 | + | |
183 | + // let plugins do verification (any plugin which thinks the comment is invalid | |
184 | + // can change 'error' to something other than '') | |
185 | + $result = ''; | |
186 | + $manager->notify('ValidateForm', array('type' => 'membermail', 'error' => &$result)); | |
187 | + | |
188 | + return $result; | |
189 | + | |
190 | + } | |
191 | + | |
192 | + /** | |
193 | + * Creates a new user account | |
194 | + */ | |
195 | + function createAccount() { | |
196 | + global $CONF, $manager; | |
197 | + | |
198 | + if (!$CONF['AllowMemberCreate']) | |
199 | + doError(_ERROR_MEMBERCREATEDISABLED); | |
200 | + | |
201 | + // evaluate content from FormExtra | |
202 | + $result = 1; | |
203 | + $data = array('type' => 'membermail', 'error' => &$result); | |
204 | + $manager->notify('ValidateForm', &$data); | |
205 | + | |
206 | + if ($result!=1) { | |
207 | + return $result; | |
208 | + } | |
209 | + else { | |
210 | + | |
211 | + // even though the member can not log in, set some random initial password. One never knows. | |
212 | + srand((double)microtime()*1000000); | |
213 | + $initialPwd = md5(uniqid(rand(), true)); | |
214 | + | |
215 | + // create member (non admin/can not login/no notes/random string as password) | |
216 | + $name = shorten(postVar('name'),16,''); | |
217 | + $r = MEMBER::create($name, postVar('realname'), $initialPwd, postVar('email'), postVar('url'), 0, 0, ''); | |
218 | + | |
219 | + if ($r != 1) { | |
220 | + return $r; | |
221 | + } | |
222 | + | |
223 | + // send message containing password. | |
224 | + $newmem = new MEMBER(); | |
225 | + $newmem->readFromName($name); | |
226 | + $newmem->sendActivationLink('register'); | |
227 | + | |
228 | + $manager->notify('PostRegister',array('member' => &$newmem)); | |
229 | + | |
230 | + if (postVar('desturl')) { | |
231 | + redirect(postVar('desturl')); | |
232 | + } else { | |
233 | + // header has been already sent, so deleted the line below | |
234 | + //header ("Content-Type: text/html; charset="._CHARSET); | |
235 | + echo _MSG_ACTIVATION_SENT; | |
236 | + echo "\n</body>\n</html>"; | |
237 | + } | |
238 | + exit; | |
239 | + } | |
240 | + } | |
241 | + | |
242 | + /** | |
243 | + * Sends a new password | |
244 | + */ | |
245 | + function forgotPassword() { | |
246 | + $membername = trim(postVar('name')); | |
247 | + | |
248 | + if (!MEMBER::exists($membername)) | |
249 | + doError(_ERROR_NOSUCHMEMBER); | |
250 | + $mem = MEMBER::createFromName($membername); | |
251 | + | |
252 | + if (!$mem->canLogin()) | |
253 | + doError(_ERROR_NOLOGON_NOACTIVATE); | |
254 | + | |
255 | + // check if e-mail address is correct | |
256 | + if (!($mem->getEmail() == postVar('email'))) | |
257 | + doError(_ERROR_INCORRECTEMAIL); | |
258 | + | |
259 | + // send activation link | |
260 | + $mem->sendActivationLink('forgot'); | |
261 | + | |
262 | + if (postVar('url')) { | |
263 | + redirect(postVar('url')); | |
264 | + } else { | |
265 | + header ("Content-Type: text/html; charset="._CHARSET); | |
266 | + echo _MSG_ACTIVATION_SENT; | |
267 | + } | |
268 | + exit; | |
269 | + } | |
270 | + | |
271 | + /** | |
272 | + * Handle karma votes | |
273 | + */ | |
274 | + function doKarma($type) { | |
275 | + global $itemid, $member, $CONF, $manager; | |
276 | + | |
277 | + // check if itemid exists | |
278 | + if (!$manager->existsItem($itemid,0,0)) | |
279 | + doError(_ERROR_NOSUCHITEM); | |
280 | + | |
281 | + $blogid = getBlogIDFromItemID($itemid); | |
282 | + $this->checkban($blogid); | |
283 | + | |
284 | + $karma =& $manager->getKarma($itemid); | |
285 | + | |
286 | + // check if not already voted | |
287 | + if (!$karma->isVoteAllowed(serverVar('REMOTE_ADDR'))) | |
288 | + doError(_ERROR_VOTEDBEFORE); | |
289 | + | |
290 | + // check if item does allow voting | |
291 | + $item =& $manager->getItem($itemid,0,0); | |
292 | + if ($item['closed']) | |
293 | + doError(_ERROR_ITEMCLOSED); | |
294 | + | |
295 | + switch($type) { | |
296 | + case 'pos': | |
297 | + $karma->votePositive(); | |
298 | + break; | |
299 | + case 'neg': | |
300 | + $karma->voteNegative(); | |
301 | + break; | |
302 | + } | |
303 | + | |
304 | + $blogid = getBlogIDFromItemID($itemid); | |
305 | + $blog =& $manager->getBlog($blogid); | |
306 | + | |
307 | + // send email to notification address, if any | |
308 | + if ($blog->getNotifyAddress() && $blog->notifyOnVote()) { | |
309 | + | |
310 | + $mailto_msg = _NOTIFY_KV_MSG . ' ' . $itemid . "\n"; | |
311 | + if ($CONF['URLMode'] == 'pathinfo') { | |
312 | + $itemLink = createItemLink(intval($itemid)); | |
313 | + } else { | |
314 | + $itemLink = $CONF['IndexURL'] . createItemLink(intval($itemid)); | |
315 | + } | |
316 | +// $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n"; | |
317 | + $mailto_msg .= $itemLink; | |
318 | + if ($member->isLoggedIn()) { | |
319 | + $mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n"; | |
320 | + } | |
321 | + $mailto_msg .= _NOTIFY_IP . ' ' . serverVar('REMOTE_ADDR') . "\n"; | |
322 | + $mailto_msg .= _NOTIFY_HOST . ' ' . gethostbyaddr(serverVar('REMOTE_ADDR')) . "\n"; | |
323 | + $mailto_msg .= _NOTIFY_VOTE . "\n " . $type . "\n"; | |
324 | + $mailto_msg .= getMailFooter(); | |
325 | + | |
326 | + $mailto_title = _NOTIFY_KV_TITLE . ' ' . strip_tags($item['title']) . ' (' . $itemid . ')'; | |
327 | + | |
328 | + $frommail = $member->getNotifyFromMailAddress(); | |
329 | + | |
330 | + $notify = new NOTIFICATION($blog->getNotifyAddress()); | |
331 | + $notify->notify($mailto_title, $mailto_msg , $frommail); | |
332 | + } | |
333 | + | |
334 | + | |
335 | + $refererUrl = serverVar('HTTP_REFERER'); | |
336 | + if ($refererUrl) { | |
337 | + $url = $refererUrl; | |
338 | + } else { | |
339 | +// $url = $CONF['IndexURL'] . 'index.php?itemid=' . $itemid; | |
340 | + $url = $itemLink; | |
341 | + } | |
342 | + | |
343 | + redirect($url); | |
344 | + exit; | |
345 | + } | |
346 | + | |
347 | + /** | |
348 | + * Calls a plugin action | |
349 | + */ | |
350 | + function callPlugin() { | |
351 | + global $manager; | |
352 | + | |
353 | + $pluginName = 'NP_' . requestVar('name'); | |
354 | + $actionType = requestVar('type'); | |
355 | + | |
356 | + // 1: check if plugin is installed | |
357 | + if (!$manager->pluginInstalled($pluginName)) | |
358 | + doError(_ERROR_NOSUCHPLUGIN); | |
359 | + | |
360 | + // 2: call plugin | |
361 | + $pluginObject =& $manager->getPlugin($pluginName); | |
362 | + if ($pluginObject) | |
363 | + $error = $pluginObject->doAction($actionType); | |
364 | + else | |
365 | + $error = 'Could not load plugin (see actionlog)'; | |
366 | + | |
367 | + // doAction returns error when: | |
368 | + // - an error occurred (duh) | |
369 | + // - no actions are allowed (doAction is not implemented) | |
370 | + if ($error) | |
371 | + doError($error); | |
372 | + | |
373 | + exit; | |
374 | + | |
375 | + } | |
376 | + | |
377 | + /** | |
378 | + * Checks if an IP or IP range is banned | |
379 | + */ | |
380 | + function checkban($blogid) { | |
381 | + // check if banned | |
382 | + $ban = BAN::isBanned($blogid, serverVar('REMOTE_ADDR')); | |
383 | + if ($ban != 0) { | |
384 | + doError(_ERROR_BANNED1 . $ban->iprange . _ERROR_BANNED2 . $ban->message . _ERROR_BANNED3); | |
385 | + } | |
386 | + | |
387 | + } | |
388 | + | |
389 | + /** | |
390 | + * Gets a new ticket | |
391 | + */ | |
392 | + function updateTicket() { | |
393 | + global $manager; | |
394 | + if ($manager->checkTicket()) { | |
395 | + echo $manager->getNewTicket(); | |
396 | + } | |
397 | + else { | |
398 | + echo 'err:' . _ERROR_BADTICKET; | |
399 | + } | |
400 | + return false; | |
401 | + } | |
402 | + | |
403 | + /** | |
404 | + * Handles AutoSaveDraft | |
405 | + */ | |
406 | + function autoDraft() { | |
407 | + global $manager; | |
408 | + if ($manager->checkTicket()) { | |
409 | + $manager->loadClass('ITEM'); | |
410 | + $info = ITEM::createDraftFromRequest(); | |
411 | + if ($info['status'] == 'error') { | |
412 | + echo $info['message']; | |
413 | + } | |
414 | + else { | |
415 | + echo $info['draftid']; | |
416 | + } | |
417 | + } | |
418 | + else { | |
419 | + echo 'err:' . _ERROR_BADTICKET; | |
420 | + } | |
421 | + return false; | |
422 | + } | |
423 | + | |
424 | + | |
425 | +} | |
426 | + | |
418 | 427 | ?> |
\ No newline at end of file |