Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revisión | 1e427484c0d8ccbb5df9a9e06e096d4adf3ad3ad (tree) |
---|---|
Tiempo | 2010-12-02 23:24:12 |
Autor | hsur <hsur@1ca2...> |
Commiter | hsur |
NP_MetaTags v1.8
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@1065 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -1,429 +1,438 @@ | ||
1 | -<?php | |
2 | -// vim: tabstop=2:shiftwidth=2 | |
3 | - | |
4 | -/** | |
5 | - * NP_MetaTags ($Revision: 1.2 $) | |
6 | - * by hsur ( http://blog.cles.jp/np_cles ) | |
7 | -*/ | |
8 | - | |
9 | -/* | |
10 | - * Copyright (C) 2005-2007 CLES. All rights reserved. | |
11 | - * | |
12 | - * This program is free software; you can redistribute it and/or | |
13 | - * modify it under the terms of the GNU General Public License | |
14 | - * as published by the Free Software Foundation; either version 2 | |
15 | - * of the License, or (at your option) any later version. | |
16 | - * | |
17 | - * This program is distributed in the hope that it will be useful, | |
18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | - * GNU General Public License for more details. | |
21 | - * | |
22 | - * You should have received a copy of the GNU General Public License | |
23 | - * along with this program; if not, write to the Free Software | |
24 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
25 | - * | |
26 | - * In addition, as a special exception, cles( http://blog.cles.jp/np_cles ) gives | |
27 | - * permission to link the code of this program with those files in the PEAR | |
28 | - * library that are licensed under the PHP License (or with modified versions | |
29 | - * of those files that use the same license as those files), and distribute | |
30 | - * linked combinations including the two. You must obey the GNU General Public | |
31 | - * License in all respects for all of the code used other than those files in | |
32 | - * the PEAR library that are licensed under the PHP License. If you modify | |
33 | - * this file, you may extend this exception to your version of the file, | |
34 | - * but you are not obligated to do so. If you do not wish to do so, delete | |
35 | - * this exception statement from your version. | |
36 | -*/ | |
37 | - | |
38 | -require_once(dirname(__FILE__).'/sharedlibs/sharedlibs.php'); | |
39 | -require_once("cles/AsyncHTTP.php"); | |
40 | - | |
41 | -class NP_MetaTags extends NucleusPlugin { | |
42 | - function getName() { | |
43 | - return 'MetaTags'; | |
44 | - } | |
45 | - function getAuthor() { | |
46 | - return 'hsur'; | |
47 | - } | |
48 | - function getURL() { | |
49 | - return 'http://blog.cles.jp/np_cles/category/31/subcatid/4'; | |
50 | - } | |
51 | - function getVersion() { | |
52 | - return '1.7'; | |
53 | - } | |
54 | - function getDescription() { | |
55 | - return '[$Revision: 1.2 $]<br />This plug-in This plug-in inserts a <META> tag (robots, description, keywords), by using <%MetaTags%>'; | |
56 | - } | |
57 | - function getMinNucleusVersion() { | |
58 | - return 320; | |
59 | - } | |
60 | - function supportsFeature($what) { | |
61 | - switch ($what) { | |
62 | - case 'SqlTablePrefix' : | |
63 | - return 1; | |
64 | - default : | |
65 | - return 0; | |
66 | - } | |
67 | - } | |
68 | - | |
69 | - function hasAdminArea() { | |
70 | - return 1; | |
71 | - } | |
72 | - | |
73 | - function getEventList() { | |
74 | - return array ('PostPluginOptionsUpdate'); | |
75 | - } | |
76 | - | |
77 | - function install() { | |
78 | - $this->createOption('yahooAppId', 'Y!API AppId', 'text', ''); | |
79 | - $this->createOption('DescMaxLength', 'Description Max Length', 'text', '80'); | |
80 | - $this->createOption('MaxKeywords', 'Num of Max Keywords', 'text', '6'); | |
81 | - $this->createOption('isRefresh', 'Refresh data ?', 'yesno', 'no'); | |
82 | - $this->createOption('isForceRefresh', 'Force Refresh ?', 'yesno', 'no'); | |
83 | - | |
84 | - $this->createItemOption('robots', 'META Robots', 'select', 'INDEX,FOLLOW', 'INDEX,FOLLOW|INDEX,FOLLOW|NOINDEX,FOLLOW|NOINDEX,FOLLOW|INDEX,NOFOLLOW|INDEX,NOFOLLOW|NOINDEX,NOFOLLOW|NOINDEX,NOFOLLOW'); | |
85 | - $this->createItemOption('description', 'META description', 'textarea', ''); | |
86 | - $this->createItemOption('keywords', 'META keywords', 'textarea', ''); | |
87 | - } | |
88 | - | |
89 | - function doSkinVar($skinType, $mode = 'tags') { | |
90 | - switch( $skinType ){ | |
91 | - case 'item': | |
92 | - global $itemid; | |
93 | - $description = $this->getItemOption($itemid, 'description'); | |
94 | - $keywords = $this->getItemOption($itemid, 'keywords'); | |
95 | - $robots = $this->getItemOption($itemid, 'robots'); | |
96 | - | |
97 | - switch( $mode ){ | |
98 | - case '': | |
99 | - case 'tags': | |
100 | - if (!empty ($robots)) | |
101 | - echo "<meta name=\"robots\" content=\"".htmlspecialchars($robots, ENT_QUOTES)."\" />\n"; | |
102 | - if (!empty ($description)) | |
103 | - echo "<meta name=\"description\" content=\"".htmlspecialchars($description, ENT_QUOTES)."\" />\n"; | |
104 | - if (!empty ($keywords)){ | |
105 | - echo "<meta name=\"keywords\" content=\"".htmlspecialchars($keywords, ENT_QUOTES)."\" />\n"; | |
106 | - } | |
107 | - break; | |
108 | - | |
109 | - case 'robots': | |
110 | - if (!empty ($robots)) | |
111 | - echo "<meta name=\"robots\" content=\"".htmlspecialchars($robots, ENT_QUOTES)."\" />\n"; | |
112 | - break; | |
113 | - case 'description': | |
114 | - if (!empty ($description)) | |
115 | - echo "<meta name=\"description\" content=\"".htmlspecialchars($description, ENT_QUOTES)."\" />\n"; | |
116 | - break; | |
117 | - case 'keywords': | |
118 | - if (!empty ($keywords)) | |
119 | - echo "<meta name=\"keywords\" content=\"".htmlspecialchars($keywords, ENT_QUOTES)."\" />\n"; | |
120 | - break; | |
121 | - | |
122 | - default : | |
123 | - break; | |
124 | - } | |
125 | - break; | |
126 | - | |
127 | - case 'archive': | |
128 | - global $archive, $archivetype; | |
129 | - $now = time(); | |
130 | - $t = 0; | |
131 | - if( $archivetype == _ARCHIVETYPE_DAY ){ | |
132 | - sscanf($archive, '%d-%d-%d', $y, $m, $d); | |
133 | - $t = mktime(0, 0, 0, $m, $d, $y); | |
134 | - } elseif ( $archivetype == _ARCHIVETYPE_MONTH ) { | |
135 | - sscanf($archive, '%d-%d', $y, $m); | |
136 | - $t = mktime(0, 0, 0, $m, 1, $y); | |
137 | - } | |
138 | - | |
139 | - //TODO: remove hard coding. | |
140 | - if( $t > $now || $t < mktime(0, 0, 0, 2, 1, 2004) ) | |
141 | - echo '<meta name="robots" content="NOINDEX,NOFOLLOW" />'."\n"; | |
142 | - else | |
143 | - echo '<meta name="robots" content="INDEX,FOLLOW" />'."\n"; | |
144 | - break; | |
145 | - | |
146 | - default: | |
147 | - break; | |
148 | - } | |
149 | - } | |
150 | - | |
151 | - function event_PostPluginOptionsUpdate(& $data) { | |
152 | - global $manager; | |
153 | - | |
154 | - switch($data['context']){ | |
155 | - case 'global': | |
156 | - $affected = $this->_refreshData(); | |
157 | - break; | |
158 | - case 'item': | |
159 | - $item = $data['item']; | |
160 | - $item['itemid'] = $data['itemid']; | |
161 | - $this->_setData($item); | |
162 | - break; | |
163 | - default: | |
164 | - // nothing | |
165 | - } | |
166 | - } | |
167 | - | |
168 | - function _refreshData(){ | |
169 | - if( $this->getOption('isRefresh') == yes ){ | |
170 | - ACTIONLOG :: add(INFO, 'MetaTags: Invoked refreshData()'); | |
171 | - | |
172 | - $isForce = ($this->getOption('isForceRefresh') == 'yes')? true : false; | |
173 | - $this->setOption('isRefresh','no'); | |
174 | - $this->setOption('isForceRefresh','no'); | |
175 | - | |
176 | - $affected = 0; | |
177 | - $query = 'SELECT inumber, ibody, imore FROM '.sql_table('item').' order by inumber'; | |
178 | - $res = sql_query($query); | |
179 | - if (! @mysql_num_rows($res) ) | |
180 | - return; | |
181 | - while ($assoc = mysql_fetch_assoc($res)) { | |
182 | - // description | |
183 | - if( !$isForce ){ | |
184 | - $description = $this->getItemOption($assoc['inumber'], 'description'); | |
185 | - if (empty($description)) { | |
186 | - $description = $this->_makeDescription($assoc['ibody'].$assoc['imore']); | |
187 | - $this->setItemOption($assoc['inumber'], 'description', $description); | |
188 | - } | |
189 | - } else { | |
190 | - $description = $this->_makeDescription($assoc['ibody'].$assoc['imore']); | |
191 | - $this->setItemOption($assoc['inumber'], 'description', $description); | |
192 | - } | |
193 | - // keywords | |
194 | - if( !$isForce ){ | |
195 | - $keywords = $this->getItemOption($assoc['inumber'], 'keywords'); | |
196 | - if (empty($keywords)) { | |
197 | - $keywords = $this->_getKeywords($assoc['ibody'].$assoc['imore']); | |
198 | - $this->setItemOption($assoc['inumber'], 'keywords', $keywords); | |
199 | - } | |
200 | - } else { | |
201 | - $keywords = $this->_getKeywords($assoc['ibody'].$assoc['imore']); | |
202 | - $this->setItemOption($assoc['inumber'], 'keywords', $keywords); | |
203 | - } | |
204 | - $affected += 1; | |
205 | - } | |
206 | - mysql_free_result($res); | |
207 | - ACTIONLOG :: add(INFO, "MetaTags: Finished refreshData(): affected items [$affected]"); | |
208 | - return $affected; | |
209 | - } | |
210 | - } | |
211 | - | |
212 | - function _setData(& $data) { | |
213 | - $itemid = intval($data['itemid']); | |
214 | - | |
215 | - $this->setItemOption($itemid, 'lastupdate', time()); | |
216 | - | |
217 | - $description = $this->getItemOption($itemid, 'description'); | |
218 | - if (empty ($description)) { | |
219 | - $description = $this->_makeDescription($data['body'].$data['more']); | |
220 | - $this->setItemOption($itemid, 'description', $description); | |
221 | - } | |
222 | - | |
223 | - $keywords = $this->getItemOption($itemid, 'keywords'); | |
224 | - if( strlen($keywords) > 100 ) $keywords = null; | |
225 | - if (empty ($keywords)) { | |
226 | - $keywords = $this->_getKeywords($data['body'].$data['more']); | |
227 | - $this->setItemOption($itemid, 'keywords', $keywords); | |
228 | - } | |
229 | - } | |
230 | - | |
231 | - function _getKeywords($text) { | |
232 | - if ( ! $this->getOption('yahooAppId') ) | |
233 | - return ''; | |
234 | - $maxKeywords = $this->getOption('MaxKeywords'); | |
235 | - $appid = $this->getOption('yahooAppId'); | |
236 | - $tfidf = array(); | |
237 | - | |
238 | - if( _CHARSET != 'UTF-8' ) | |
239 | - $string = mb_convert_encoding($string, 'UTF-8', _CHARSET); | |
240 | - | |
241 | - $text = strip_tags($text); | |
242 | - $text = str_replace("\n", "", $text); | |
243 | - $text = str_replace("\r", "", $text); | |
244 | - | |
245 | - $postData = array(); | |
246 | - $postData['appid'] = $appid; | |
247 | - $postData['results'] = 'uniq'; | |
248 | - $postData['filter'] = '9'; | |
249 | - $postData['response'] = 'surface'; | |
250 | - $postData['sentence'] = $text; | |
251 | - | |
252 | - $ahttp = new cles_AsyncHTTP(); | |
253 | - $ahttp->asyncMode = false; | |
254 | - $ahttp->userAgent = "NP_MetaTags/".$this->getVersion(); | |
255 | - $ahttp->setRequest('http://api.jlp.yahoo.co.jp/MAService/V1/parse', 'POST', '', $postData); | |
256 | - list($data) = $ahttp->getResponses(); | |
257 | - if( !$data ) | |
258 | - ACTIONLOG :: add(WARNING, 'NP_MetaTags: AsyncHTTP Error['.$ahttp->getErrorNo(0).']'.$ahttp->getError(0)); | |
259 | - | |
260 | - if( $data ){ | |
261 | - $p =& new NP_MetaTags_MA_XMLParser(); | |
262 | - $words = $p->parse($data); | |
263 | - if( $p->isError ){ | |
264 | - ACTIONLOG :: add(WARNING, 'NP_MetaTags: Y!API Error( '. (isset($rawtokens[0]) ? $rawtokens[0] : 'Unknown Error -> '.$data) . ' )'); | |
265 | - $words = array(); | |
266 | - } | |
267 | - $p->free(); | |
268 | - $p = null; | |
269 | - | |
270 | - if( $words ){ | |
271 | - arsort($words); | |
272 | - $words = array_slice($words, 0, 20); | |
273 | - | |
274 | - $postData = array(); | |
275 | - $postData['appid'] = $appid; | |
276 | - $postData['results'] = '1'; | |
277 | - $postData['adult_ok'] = '1'; | |
278 | - $postData['similar_ok'] = '1'; | |
279 | - | |
280 | - $ahttp = new cles_AsyncHTTP(); | |
281 | - $ahttp->userAgent = "NP_MetaTags/".$this->getVersion(); | |
282 | - | |
283 | - $requests = array(); | |
284 | - foreach ($words as $word => $count) { | |
285 | - $postData['query'] = $word; | |
286 | - $id = $ahttp->setRequest('http://api.search.yahoo.co.jp/WebSearchService/V1/webSearch', 'POST', '', $postData); | |
287 | - | |
288 | - $requests[$id] = $word; | |
289 | - } | |
290 | - | |
291 | - $responses = $ahttp->getResponses(); | |
292 | - | |
293 | - foreach( $requests as $id => $word ){ | |
294 | - if( $respXml = $responses[$id] ){ | |
295 | - $p =& new NP_MetaTags_WS_XMLParser(); | |
296 | - list($totalResultsAvailable) = $p->parse($respXml); | |
297 | - if( $p->isError ){ | |
298 | - ACTIONLOG :: add(WARNING, 'NP_MetaTags: Y!API Error( '. (isset($totalResultsAvailable) ? $totalResultsAvailable : 'Unknown Error') . ' )'); | |
299 | - $totalResultsAvailable = 0; | |
300 | - } | |
301 | - $p->free(); | |
302 | - $p = null; | |
303 | - | |
304 | - if( $totalResultsAvailable ){ | |
305 | - $tfidf[$word] = $words[$word] * log10(25000000000/$totalResultsAvailable); | |
306 | - } | |
307 | - } else { | |
308 | - ACTIONLOG :: add(WARNING, $this->getName().': AsyncHTTP Error['.$ahttp->getErrorNo($id).']'.$ahttp->getError($id)); | |
309 | - } | |
310 | - } | |
311 | - //var_dump($ahttp); | |
312 | - } | |
313 | - } | |
314 | - //var_dump($tfidf); | |
315 | - | |
316 | - arsort($tfidf); | |
317 | - $tfidf = array_slice($tfidf, 0, $maxKeywords); | |
318 | - $result = ""; | |
319 | - foreach( $tfidf as $word => $score ){ | |
320 | - $result .= $word.','; | |
321 | - } | |
322 | - | |
323 | - if( _CHARSET != 'UTF-8' ) | |
324 | - $result = mb_convert_encoding($result, _CHARSET, 'UTF-8'); | |
325 | - | |
326 | - return mb_substr($result, 0, -1); | |
327 | - } | |
328 | - | |
329 | - function _makeDescription($description) { | |
330 | - $maxLength = $this->getOption('DescMaxLength'); | |
331 | - $description = strip_tags($description); | |
332 | - $description = Str_Replace("\n", "", $description); | |
333 | - $description = Str_Replace("\r", "", $description); | |
334 | - return htmlspecialchars(shorten($description, $maxLength, '')); | |
335 | - } | |
336 | -} | |
337 | - | |
338 | -class NP_MetaTags_Base_XMLParser { | |
339 | - function init(){ | |
340 | - $this->parser = xml_parser_create(); | |
341 | - xml_set_object($this->parser, $this); | |
342 | - xml_set_element_handler($this->parser, "_open", "_close"); | |
343 | - xml_set_character_data_handler($this->parser, "_cdata"); | |
344 | - | |
345 | - $this->isError = false; | |
346 | - $this->inTarget = false; | |
347 | - } | |
348 | - | |
349 | - function parse($data){ | |
350 | - $this->words = array(); | |
351 | - xml_parse($this->parser, $data); | |
352 | - $errcode = xml_get_error_code($this->parser); | |
353 | - if ( $errcode != XML_ERROR_NONE ) { | |
354 | - $this->isError = true; | |
355 | - $this->words = array(); | |
356 | - $this->words[] = 'XML Parse Error: ' . xml_error_string($errcode) . ' in '. xml_get_current_line_number($this->parser); | |
357 | - } | |
358 | - return $this->words; | |
359 | - } | |
360 | - | |
361 | - function free(){ | |
362 | - xml_parser_free($this->parser); | |
363 | - $this->words = null; | |
364 | - } | |
365 | -} | |
366 | - | |
367 | -class NP_MetaTags_MA_XMLParser extends NP_MetaTags_Base_XMLParser { | |
368 | - function NP_MetaTags_MA_XMLParser(){ | |
369 | - $this->init(); | |
370 | - } | |
371 | - | |
372 | - function _open($parser, $name, $attribute){ | |
373 | - switch( $name ){ | |
374 | - case 'WORD': | |
375 | - $this->tmp = array(); | |
376 | - break; | |
377 | - case 'SURFACE': | |
378 | - $this->inTarget = 'SURFACE'; | |
379 | - break; | |
380 | - case 'COUNT': | |
381 | - $this->inTarget = 'COUNT'; | |
382 | - break; | |
383 | - case 'MESSAGE': | |
384 | - $this->inTarget = 'MESSAGE'; | |
385 | - break; | |
386 | - case 'ERROR': | |
387 | - $this->isError = true; | |
388 | - break; | |
389 | - } | |
390 | - } | |
391 | - | |
392 | - function _close($parser, $name){ | |
393 | - switch( $name ){ | |
394 | - case 'WORD': | |
395 | - if( $this->tmp['SURFACE'] && $this->tmp['COUNT'] && !is_numeric($this->tmp['SURFACE']) && mb_strlen($this->tmp['SURFACE']) > 1 ){ | |
396 | - $this->words[$this->tmp['SURFACE']] = $this->tmp['COUNT']; | |
397 | - } | |
398 | - break; | |
399 | - case 'MESSAGE': | |
400 | - $this->words = array(); | |
401 | - $this->words[] = $this->tmp['MESSAGE']; | |
402 | - break; | |
403 | - } | |
404 | - if( $name == $this->inTarget ) $this->inTarget = false; | |
405 | - } | |
406 | - | |
407 | - function _cdata($parser, $data){ | |
408 | - if( $this->inTarget ){ | |
409 | - $this->tmp[$this->inTarget] = trim($data); | |
410 | - } | |
411 | - } | |
412 | -} | |
413 | - | |
414 | -class NP_MetaTags_WS_XMLParser extends NP_MetaTags_Base_XMLParser { | |
415 | - function NP_MetaTags_WS_XMLParser(){ | |
416 | - $this->init(); | |
417 | - } | |
418 | - | |
419 | - function _open($parser, $name, $attribute){ | |
420 | - switch( $name ){ | |
421 | - case 'RESULTSET': | |
422 | - $this->words[] = $attribute['TOTALRESULTSAVAILABLE']; | |
423 | - break; | |
424 | - } | |
425 | - } | |
426 | - | |
427 | - function _close($parser, $name){} | |
428 | - function _cdata($parser, $data){} | |
429 | -} | |
1 | +<?php | |
2 | +// vim: tabstop=2:shiftwidth=2 | |
3 | + | |
4 | +/** | |
5 | + * NP_MetaTags ($Revision: 1.118 $) | |
6 | + * by hsur ( http://blog.cles.jp/np_cles ) | |
7 | +*/ | |
8 | + | |
9 | +/* | |
10 | + * Copyright (C) 2005-2010 CLES. All rights reserved. | |
11 | + * | |
12 | + * This program is free software; you can redistribute it and/or | |
13 | + * modify it under the terms of the GNU General Public License | |
14 | + * as published by the Free Software Foundation; either version 2 | |
15 | + * of the License, or (at your option) any later version. | |
16 | + * | |
17 | + * This program is distributed in the hope that it will be useful, | |
18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | + * GNU General Public License for more details. | |
21 | + * | |
22 | + * You should have received a copy of the GNU General Public License | |
23 | + * along with this program; if not, write to the Free Software | |
24 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
25 | + * | |
26 | + * In addition, as a special exception, cles( http://blog.cles.jp/np_cles ) gives | |
27 | + * permission to link the code of this program with those files in the PEAR | |
28 | + * library that are licensed under the PHP License (or with modified versions | |
29 | + * of those files that use the same license as those files), and distribute | |
30 | + * linked combinations including the two. You must obey the GNU General Public | |
31 | + * License in all respects for all of the code used other than those files in | |
32 | + * the PEAR library that are licensed under the PHP License. If you modify | |
33 | + * this file, you may extend this exception to your version of the file, | |
34 | + * but you are not obligated to do so. If you do not wish to do so, delete | |
35 | + * this exception statement from your version. | |
36 | +*/ | |
37 | + | |
38 | +require_once(dirname(__FILE__).'/sharedlibs/sharedlibs.php'); | |
39 | +require_once("cles/AsyncHTTP.php"); | |
40 | + | |
41 | +class NP_MetaTags extends NucleusPlugin { | |
42 | + function getName() { | |
43 | + return 'MetaTags'; | |
44 | + } | |
45 | + function getAuthor() { | |
46 | + return 'hsur'; | |
47 | + } | |
48 | + function getURL() { | |
49 | + return 'http://blog.cles.jp/np_cles/category/31/subcatid/4'; | |
50 | + } | |
51 | + function getVersion() { | |
52 | + return '1.8'; | |
53 | + } | |
54 | + function getDescription() { | |
55 | + return '[$Revision: 1.118 $]<br />This plug-in This plug-in inserts a <META> tag (robots, description, keywords), by using <%MetaTags%>'; | |
56 | + } | |
57 | + function getMinNucleusVersion() { | |
58 | + return 320; | |
59 | + } | |
60 | + function supportsFeature($what) { | |
61 | + switch ($what) { | |
62 | + case 'SqlTablePrefix' : | |
63 | + return 1; | |
64 | + default : | |
65 | + return 0; | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + function hasAdminArea() { | |
70 | + return 1; | |
71 | + } | |
72 | + | |
73 | + function getEventList() { | |
74 | + return array ('PostPluginOptionsUpdate'); | |
75 | + } | |
76 | + | |
77 | + function install() { | |
78 | + $this->createOption('yahooAppId', 'Y!API AppId', 'text', ''); | |
79 | + $this->createOption('DescMaxLength', 'Description Max Length', 'text', '80'); | |
80 | + $this->createOption('MaxKeywords', 'Num of Max Keywords', 'text', '6'); | |
81 | + $this->createOption('isRefresh', 'Refresh data ?', 'yesno', 'no'); | |
82 | + $this->createOption('isForceRefresh', 'Force Refresh ?', 'yesno', 'no'); | |
83 | + | |
84 | + $this->createItemOption('robots', 'META Robots', 'select', 'INDEX,FOLLOW', 'INDEX,FOLLOW|INDEX,FOLLOW|NOINDEX,FOLLOW|NOINDEX,FOLLOW|INDEX,NOFOLLOW|INDEX,NOFOLLOW|NOINDEX,NOFOLLOW|NOINDEX,NOFOLLOW'); | |
85 | + $this->createItemOption('description', 'META description', 'textarea', ''); | |
86 | + $this->createItemOption('keywords', 'META keywords', 'textarea', ''); | |
87 | + } | |
88 | + | |
89 | + function doSkinVar($skinType, $mode = 'tags') { | |
90 | + switch( $skinType ){ | |
91 | + case 'item': | |
92 | + global $itemid; | |
93 | + $description = $this->getItemOption($itemid, 'description'); | |
94 | + $keywords = $this->getItemOption($itemid, 'keywords'); | |
95 | + $robots = $this->getItemOption($itemid, 'robots'); | |
96 | + | |
97 | + switch( $mode ){ | |
98 | + case '': | |
99 | + case 'tags': | |
100 | + if (!empty ($robots)) | |
101 | + echo "<meta name=\"robots\" content=\"".htmlspecialchars($robots, ENT_QUOTES)."\" />\n"; | |
102 | + if (!empty ($description)) | |
103 | + echo "<meta name=\"description\" content=\"".htmlspecialchars($description, ENT_QUOTES)."\" />\n"; | |
104 | + if (!empty ($keywords)){ | |
105 | + echo "<meta name=\"keywords\" content=\"".htmlspecialchars($keywords, ENT_QUOTES)."\" />\n"; | |
106 | + } | |
107 | + break; | |
108 | + | |
109 | + case 'robots': | |
110 | + if (!empty ($robots)) | |
111 | + echo "<meta name=\"robots\" content=\"".htmlspecialchars($robots, ENT_QUOTES)."\" />\n"; | |
112 | + break; | |
113 | + case 'description': | |
114 | + if (!empty ($description)) | |
115 | + echo "<meta name=\"description\" content=\"".htmlspecialchars($description, ENT_QUOTES)."\" />\n"; | |
116 | + break; | |
117 | + case 'keywords': | |
118 | + if (!empty ($keywords)) | |
119 | + echo "<meta name=\"keywords\" content=\"".htmlspecialchars($keywords, ENT_QUOTES)."\" />\n"; | |
120 | + break; | |
121 | + | |
122 | + default : | |
123 | + break; | |
124 | + } | |
125 | + break; | |
126 | + | |
127 | + case 'archive': | |
128 | + global $archive, $archivetype; | |
129 | + $now = time(); | |
130 | + $t = 0; | |
131 | + if( $archivetype == _ARCHIVETYPE_DAY ){ | |
132 | + sscanf($archive, '%d-%d-%d', $y, $m, $d); | |
133 | + $t = mktime(0, 0, 0, $m, $d, $y); | |
134 | + } elseif ( $archivetype == _ARCHIVETYPE_MONTH ) { | |
135 | + sscanf($archive, '%d-%d', $y, $m); | |
136 | + $t = mktime(0, 0, 0, $m, 1, $y); | |
137 | + } | |
138 | + | |
139 | + //TODO: remove hard coding. | |
140 | + if( $t > $now || $t < mktime(0, 0, 0, 2, 1, 2004) ) | |
141 | + echo '<meta name="robots" content="NOINDEX,NOFOLLOW" />'."\n"; | |
142 | + else | |
143 | + echo '<meta name="robots" content="INDEX,FOLLOW" />'."\n"; | |
144 | + break; | |
145 | + | |
146 | + default: | |
147 | + break; | |
148 | + } | |
149 | + } | |
150 | + | |
151 | + function event_PostPluginOptionsUpdate(& $data) { | |
152 | + global $manager; | |
153 | + | |
154 | + switch($data['context']){ | |
155 | + case 'global': | |
156 | + $affected = $this->_refreshData(); | |
157 | + break; | |
158 | + case 'item': | |
159 | + // var_dump($data); | |
160 | + // core hack needed. | |
161 | + if( $data['item']['draft'] ) break; | |
162 | + | |
163 | + $item = $data['item']; | |
164 | + $item['itemid'] = $data['itemid']; | |
165 | + $this->_setData($item); | |
166 | + break; | |
167 | + default: | |
168 | + // nothing | |
169 | + } | |
170 | + } | |
171 | + | |
172 | + function _refreshData(){ | |
173 | + if( $this->getOption('isRefresh') == yes ){ | |
174 | + ACTIONLOG :: add(INFO, 'MetaTags: Invoked refreshData()'); | |
175 | + | |
176 | + $isForce = ($this->getOption('isForceRefresh') == 'yes')? true : false; | |
177 | + $this->setOption('isRefresh','no'); | |
178 | + $this->setOption('isForceRefresh','no'); | |
179 | + | |
180 | + $affected = 0; | |
181 | + $query = 'SELECT inumber, ibody, imore FROM '.sql_table('item').' order by inumber'; | |
182 | + $res = sql_query($query); | |
183 | + if (! @mysql_num_rows($res) ) | |
184 | + return; | |
185 | + while ($assoc = mysql_fetch_assoc($res)) { | |
186 | + // description | |
187 | + if( !$isForce ){ | |
188 | + $description = $this->getItemOption($assoc['inumber'], 'description'); | |
189 | + if (empty($description)) { | |
190 | + $description = $this->_makeDescription($assoc['ibody'].$assoc['imore']); | |
191 | + $this->setItemOption($assoc['inumber'], 'description', $description); | |
192 | + } | |
193 | + } else { | |
194 | + $description = $this->_makeDescription($assoc['ibody'].$assoc['imore']); | |
195 | + $this->setItemOption($assoc['inumber'], 'description', $description); | |
196 | + } | |
197 | + // keywords | |
198 | + if( !$isForce ){ | |
199 | + $keywords = $this->getItemOption($assoc['inumber'], 'keywords'); | |
200 | + if (empty($keywords)) { | |
201 | + $keywords = $this->_getKeywords($assoc['ibody'].$assoc['imore']); | |
202 | + $this->setItemOption($assoc['inumber'], 'keywords', $keywords); | |
203 | + } | |
204 | + } else { | |
205 | + $keywords = $this->_getKeywords($assoc['ibody'].$assoc['imore']); | |
206 | + $this->setItemOption($assoc['inumber'], 'keywords', $keywords); | |
207 | + } | |
208 | + $affected += 1; | |
209 | + } | |
210 | + mysql_free_result($res); | |
211 | + ACTIONLOG :: add(INFO, "MetaTags: Finished refreshData(): affected items [$affected]"); | |
212 | + return $affected; | |
213 | + } | |
214 | + } | |
215 | + | |
216 | + function _setData(& $data) { | |
217 | + $itemid = intval($data['itemid']); | |
218 | + | |
219 | + $this->setItemOption($itemid, 'lastupdate', time()); | |
220 | + | |
221 | + $description = $this->getItemOption($itemid, 'description'); | |
222 | + if (empty ($description)) { | |
223 | + $description = $this->_makeDescription($data['body'].$data['more']); | |
224 | + $this->setItemOption($itemid, 'description', $description); | |
225 | + } | |
226 | + | |
227 | + $keywords = $this->getItemOption($itemid, 'keywords'); | |
228 | + if( strlen($keywords) > 100 ) $keywords = null; | |
229 | + if (empty ($keywords)) { | |
230 | + $keywords = $this->_getKeywords($data['body'].$data['more']); | |
231 | + $this->setItemOption($itemid, 'keywords', $keywords); | |
232 | + } | |
233 | + } | |
234 | + | |
235 | + function _getKeywords($text) { | |
236 | + if ( ! $this->getOption('yahooAppId') ) | |
237 | + return ''; | |
238 | + $maxKeywords = $this->getOption('MaxKeywords'); | |
239 | + $appid = $this->getOption('yahooAppId'); | |
240 | + $tfidf = array(); | |
241 | + | |
242 | + if( _CHARSET != 'UTF-8' ) | |
243 | + $string = mb_convert_encoding($string, 'UTF-8', _CHARSET); | |
244 | + | |
245 | + $text = strip_tags($text); | |
246 | + $text = str_replace("\n", "", $text); | |
247 | + $text = str_replace("\r", "", $text); | |
248 | + | |
249 | + $postData = array(); | |
250 | + $postData['appid'] = $appid; | |
251 | + $postData['results'] = 'uniq'; | |
252 | + $postData['filter'] = '9'; | |
253 | + $postData['response'] = 'surface'; | |
254 | + $postData['sentence'] = $text; | |
255 | + | |
256 | + $ahttp = new cles_AsyncHTTP(); | |
257 | + $ahttp->asyncMode = false; | |
258 | + $ahttp->userAgent = "NP_MetaTags/".$this->getVersion(); | |
259 | + $ahttp->setRequest('http://jlp.yahooapis.jp/MAService/V1/parse', 'POST', '', $postData); | |
260 | + list($data) = $ahttp->getResponses(); | |
261 | + if( !$data ) | |
262 | + ACTIONLOG :: add(WARNING, 'NP_MetaTags: AsyncHTTP Error['.$ahttp->getErrorNo(0).']'.$ahttp->getError(0)); | |
263 | + | |
264 | + if( $data ){ | |
265 | + $p =& new NP_MetaTags_MA_XMLParser(); | |
266 | + $words = $p->parse($data); | |
267 | + if( $p->isError ){ | |
268 | + ACTIONLOG :: add(WARNING, 'NP_MetaTags: Y!API Error( '. (isset($rawtokens[0]) ? $rawtokens[0] : 'Unknown Error -> '.$data) . ' )'); | |
269 | + $words = array(); | |
270 | + } | |
271 | + $p->free(); | |
272 | + $p = null; | |
273 | + | |
274 | + if( $words ){ | |
275 | + arsort($words); | |
276 | + $words = array_slice($words, 0, 20); | |
277 | + | |
278 | + $postData = array(); | |
279 | + $postData['appid'] = $appid; | |
280 | + $postData['results'] = '1'; | |
281 | + $postData['adult_ok'] = '1'; | |
282 | + $postData['similar_ok'] = '1'; | |
283 | + $ahttp = new cles_AsyncHTTP(); | |
284 | + $ahttp->userAgent = "NP_MetaTags/".$this->getVersion(); | |
285 | + | |
286 | + $requests = array(); | |
287 | + foreach ($words as $word => $count) { | |
288 | + $postData['query'] = $word; | |
289 | + | |
290 | + $qs = array(); | |
291 | + foreach($postData as $k => $v){ | |
292 | + $qs[] = $k."=".urlencode($v); | |
293 | + } | |
294 | + $u = 'http://search.yahooapis.jp/WebSearchService/V2/webSearch?'.implode("&", $qs); | |
295 | + $id = $ahttp->setRequest($u, 'GET'); | |
296 | + | |
297 | + $requests[$id] = $word; | |
298 | + } | |
299 | + | |
300 | + $responses = $ahttp->getResponses(); | |
301 | + | |
302 | + foreach( $requests as $id => $word ){ | |
303 | + if( $respXml = $responses[$id] ){ | |
304 | + $p =& new NP_MetaTags_WS_XMLParser(); | |
305 | + list($totalResultsAvailable) = $p->parse($respXml); | |
306 | + if( $p->isError ){ | |
307 | + ACTIONLOG :: add(WARNING, 'NP_MetaTags: Y!API Error( '. (isset($totalResultsAvailable) ? $totalResultsAvailable : 'Unknown Error') . ' )'); | |
308 | + $totalResultsAvailable = 0; | |
309 | + } | |
310 | + $p->free(); | |
311 | + $p = null; | |
312 | + | |
313 | + if( $totalResultsAvailable ){ | |
314 | + $tfidf[$word] = $words[$word] * log10(30000000000/$totalResultsAvailable); | |
315 | + } | |
316 | + } else { | |
317 | + ACTIONLOG :: add(WARNING, $this->getName().': AsyncHTTP Error['.$ahttp->getErrorNo($id).']'.$ahttp->getError($id)); | |
318 | + } | |
319 | + } | |
320 | + //var_dump($ahttp); | |
321 | + } | |
322 | + } | |
323 | + //var_dump($tfidf); | |
324 | + | |
325 | + arsort($tfidf); | |
326 | + $tfidf = array_slice($tfidf, 0, $maxKeywords); | |
327 | + $result = ""; | |
328 | + foreach( $tfidf as $word => $score ){ | |
329 | + $result .= $word.','; | |
330 | + } | |
331 | + | |
332 | + if( _CHARSET != 'UTF-8' ) | |
333 | + $result = mb_convert_encoding($result, _CHARSET, 'UTF-8'); | |
334 | + | |
335 | + return mb_substr($result, 0, -1); | |
336 | + } | |
337 | + | |
338 | + function _makeDescription($description) { | |
339 | + $maxLength = $this->getOption('DescMaxLength'); | |
340 | + $description = strip_tags($description); | |
341 | + $description = Str_Replace("\n", "", $description); | |
342 | + $description = Str_Replace("\r", "", $description); | |
343 | + return htmlspecialchars(shorten($description, $maxLength, '')); | |
344 | + } | |
345 | +} | |
346 | + | |
347 | +class NP_MetaTags_Base_XMLParser { | |
348 | + function init(){ | |
349 | + $this->parser = xml_parser_create('UTF-8'); | |
350 | + xml_set_object($this->parser, $this); | |
351 | + xml_set_element_handler($this->parser, "_open", "_close"); | |
352 | + xml_set_character_data_handler($this->parser, "_cdata"); | |
353 | + | |
354 | + $this->isError = false; | |
355 | + $this->inTarget = false; | |
356 | + } | |
357 | + | |
358 | + function parse($data){ | |
359 | + $this->words = array(); | |
360 | + xml_parse($this->parser, $data); | |
361 | + $errcode = xml_get_error_code($this->parser); | |
362 | + if ( $errcode != XML_ERROR_NONE ) { | |
363 | + $this->isError = true; | |
364 | + $this->words = array(); | |
365 | + $this->words[] = 'XML Parse Error: ' . xml_error_string($errcode) . ' in '. xml_get_current_line_number($this->parser); | |
366 | + } | |
367 | + return $this->words; | |
368 | + } | |
369 | + | |
370 | + function free(){ | |
371 | + xml_parser_free($this->parser); | |
372 | + $this->words = null; | |
373 | + } | |
374 | +} | |
375 | + | |
376 | +class NP_MetaTags_MA_XMLParser extends NP_MetaTags_Base_XMLParser { | |
377 | + function NP_MetaTags_MA_XMLParser(){ | |
378 | + $this->init(); | |
379 | + } | |
380 | + | |
381 | + function _open($parser, $name, $attribute){ | |
382 | + switch( $name ){ | |
383 | + case 'WORD': | |
384 | + $this->tmp = array(); | |
385 | + break; | |
386 | + case 'SURFACE': | |
387 | + $this->inTarget = 'SURFACE'; | |
388 | + break; | |
389 | + case 'COUNT': | |
390 | + $this->inTarget = 'COUNT'; | |
391 | + break; | |
392 | + case 'MESSAGE': | |
393 | + $this->inTarget = 'MESSAGE'; | |
394 | + break; | |
395 | + case 'ERROR': | |
396 | + $this->isError = true; | |
397 | + break; | |
398 | + } | |
399 | + } | |
400 | + | |
401 | + function _close($parser, $name){ | |
402 | + switch( $name ){ | |
403 | + case 'WORD': | |
404 | + if( $this->tmp['SURFACE'] && $this->tmp['COUNT'] && !is_numeric($this->tmp['SURFACE']) && mb_strlen($this->tmp['SURFACE']) > 1 ){ | |
405 | + $this->words[$this->tmp['SURFACE']] = $this->tmp['COUNT']; | |
406 | + } | |
407 | + break; | |
408 | + case 'MESSAGE': | |
409 | + $this->words = array(); | |
410 | + $this->words[] = $this->tmp['MESSAGE']; | |
411 | + break; | |
412 | + } | |
413 | + if( $name == $this->inTarget ) $this->inTarget = false; | |
414 | + } | |
415 | + | |
416 | + function _cdata($parser, $data){ | |
417 | + if( $this->inTarget ){ | |
418 | + $this->tmp[$this->inTarget] = trim($data); | |
419 | + } | |
420 | + } | |
421 | +} | |
422 | + | |
423 | +class NP_MetaTags_WS_XMLParser extends NP_MetaTags_Base_XMLParser { | |
424 | + function NP_MetaTags_WS_XMLParser(){ | |
425 | + $this->init(); | |
426 | + } | |
427 | + | |
428 | + function _open($parser, $name, $attribute){ | |
429 | + switch( $name ){ | |
430 | + case 'RESULTSET': | |
431 | + $this->words[] = $attribute['TOTALRESULTSAVAILABLE']; | |
432 | + break; | |
433 | + } | |
434 | + } | |
435 | + | |
436 | + function _close($parser, $name){} | |
437 | + function _cdata($parser, $data){} | |
438 | +} |
@@ -0,0 +1,6 @@ | ||
1 | +<!-- $Id: help.html,v 1.4 2010/12/02 14:21:32 hsur Exp $ --> | |
2 | +<h3>バージョン履歴</h3> | |
3 | +<ul> | |
4 | + <li>Version 1.8: (2010/12/02)</li> | |
5 | + <li> [Changed] Yahoo!Japan APIのバージョンアップに対応</li> | |
6 | +</ul> | |
\ No newline at end of file |
@@ -1,101 +1,101 @@ | ||
1 | -<?php | |
2 | -// vim: tabstop=2:shiftwidth=2 | |
3 | - | |
4 | -/** | |
5 | - * index.php ($Revision: 1.1 $) | |
6 | - * | |
7 | - * by hsur ( http://blog.cles.jp/np_cles ) | |
8 | - * $Id: index.php,v 1.1 2007-09-30 13:54:19 hsur Exp $ | |
9 | -*/ | |
10 | - | |
11 | -/* | |
12 | - * Copyright (C) 2004-2006 cles. All rights reserved. | |
13 | - * | |
14 | - * This program is free software; you can redistribute it and/or | |
15 | - * modify it under the terms of the GNU General Public License | |
16 | - * as published by the Free Software Foundation; either version 2 | |
17 | - * of the License, or (at your option) any later version. | |
18 | - * | |
19 | - * This program is distributed in the hope that it will be useful, | |
20 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | - * GNU General Public License for more details. | |
23 | - * | |
24 | - * You should have received a copy of the GNU General Public License | |
25 | - * along with this program; if not, write to the Free Software | |
26 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
27 | - * | |
28 | - * In addition, as a special exception, cles( http://blog.cles.jp/np_cles ) gives | |
29 | - * permission to link the code of this program with those files in the PEAR | |
30 | - * library that are licensed under the PHP License (or with modified versions | |
31 | - * of those files that use the same license as those files), and distribute | |
32 | - * linked combinations including the two. You must obey the GNU General Public | |
33 | - * License in all respects for all of the code used other than those files in | |
34 | - * the PEAR library that are licensed under the PHP License. If you modify | |
35 | - * this file, you may extend this exception to your version of the file, | |
36 | - * but you are not obligated to do so. If you do not wish to do so, delete | |
37 | - * this exception statement from your version. | |
38 | -*/ | |
39 | - | |
40 | -$strRel = '../../../'; | |
41 | -include ($strRel.'config.php'); | |
42 | -include ($DIR_LIBS.'PLUGINADMIN.php'); | |
43 | - | |
44 | -require_once($DIR_PLUGINS . 'sharedlibs/sharedlibs.php'); | |
45 | -require_once('cles/Feedback.php'); | |
46 | - | |
47 | -if ($blogid) { | |
48 | - $isblogadmin = $member->isBlogAdmin($blogid); | |
49 | -} else | |
50 | - $isblogadmin = 0; | |
51 | - | |
52 | -if (!$member->isLoggedIn()) { | |
53 | - $oPluginAdmin = new PluginAdmin('MetaTags'); | |
54 | - $oPluginAdmin->start(); | |
55 | - echo "<p>ログインが必要です</p>"; | |
56 | - $oPluginAdmin->end(); | |
57 | - exit; | |
58 | -} | |
59 | - | |
60 | -if (!($member->isAdmin() || $isblogadmin)) { | |
61 | - $oPluginAdmin = new PluginAdmin('MetaTags'); | |
62 | - $oPluginAdmin->start(); | |
63 | - echo "<p>"._ERROR_DISALLOWED."</p>"; | |
64 | - $oPluginAdmin->end(); | |
65 | - exit; | |
66 | -} | |
67 | - | |
68 | -if (isset ($_GET['page'])) { | |
69 | - $action = getVar('page'); | |
70 | -} | |
71 | -if (isset ($_POST['page'])) { | |
72 | - $action = getVar('page'); | |
73 | -} | |
74 | - | |
75 | -// create the admin area page | |
76 | -$oPluginAdmin = new PluginAdmin('MetaTags'); | |
77 | -$oPluginAdmin->start(); | |
78 | -$fb =& new cles_Feedback($oPluginAdmin); | |
79 | - | |
80 | -// menu | |
81 | -echo "<h2>MetaTags menu</h2>\n"; | |
82 | -echo "<ul>\n"; | |
83 | -echo "<li><a href=\"".serverVar('PHP_SELF')."?page=report\"><span style=\"font-weight:bold; color:red\">" . $fb->getMenuStr() . "</span></a></li>\n"; | |
84 | -echo "</ul>\n"; | |
85 | - | |
86 | -//action | |
87 | -switch ($action) { | |
88 | - case 'report' : | |
89 | - $ahttp = new cles_AsyncHTTP(); | |
90 | - $extra = $ahttp->asyncMode ? 'AsyncMode(true)' : 'AsyncMode(false)'; | |
91 | - | |
92 | - $fb->printForm($extra); | |
93 | - break; | |
94 | - | |
95 | - default : | |
96 | - break; | |
97 | -} | |
98 | - | |
99 | -echo "<br />"; | |
100 | - | |
101 | -$oPluginAdmin->end(); | |
1 | +<?php | |
2 | +// vim: tabstop=2:shiftwidth=2 | |
3 | + | |
4 | +/** | |
5 | + * index.php ($Revision: 1.1 $) | |
6 | + * | |
7 | + * by hsur ( http://blog.cles.jp/np_cles ) | |
8 | + * $Id: index.php,v 1.1 2007/09/23 22:34:33 hsur Exp $ | |
9 | +*/ | |
10 | + | |
11 | +/* | |
12 | + * Copyright (C) 2004-2006 cles. All rights reserved. | |
13 | + * | |
14 | + * This program is free software; you can redistribute it and/or | |
15 | + * modify it under the terms of the GNU General Public License | |
16 | + * as published by the Free Software Foundation; either version 2 | |
17 | + * of the License, or (at your option) any later version. | |
18 | + * | |
19 | + * This program is distributed in the hope that it will be useful, | |
20 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | + * GNU General Public License for more details. | |
23 | + * | |
24 | + * You should have received a copy of the GNU General Public License | |
25 | + * along with this program; if not, write to the Free Software | |
26 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
27 | + * | |
28 | + * In addition, as a special exception, cles( http://blog.cles.jp/np_cles ) gives | |
29 | + * permission to link the code of this program with those files in the PEAR | |
30 | + * library that are licensed under the PHP License (or with modified versions | |
31 | + * of those files that use the same license as those files), and distribute | |
32 | + * linked combinations including the two. You must obey the GNU General Public | |
33 | + * License in all respects for all of the code used other than those files in | |
34 | + * the PEAR library that are licensed under the PHP License. If you modify | |
35 | + * this file, you may extend this exception to your version of the file, | |
36 | + * but you are not obligated to do so. If you do not wish to do so, delete | |
37 | + * this exception statement from your version. | |
38 | +*/ | |
39 | + | |
40 | +$strRel = '../../../'; | |
41 | +include ($strRel.'config.php'); | |
42 | +include ($DIR_LIBS.'PLUGINADMIN.php'); | |
43 | + | |
44 | +require_once($DIR_PLUGINS . 'sharedlibs/sharedlibs.php'); | |
45 | +require_once('cles/Feedback.php'); | |
46 | + | |
47 | +if ($blogid) { | |
48 | + $isblogadmin = $member->isBlogAdmin($blogid); | |
49 | +} else | |
50 | + $isblogadmin = 0; | |
51 | + | |
52 | +if (!$member->isLoggedIn()) { | |
53 | + $oPluginAdmin = new PluginAdmin('MetaTags'); | |
54 | + $oPluginAdmin->start(); | |
55 | + echo "<p>ログインが必要です</p>"; | |
56 | + $oPluginAdmin->end(); | |
57 | + exit; | |
58 | +} | |
59 | + | |
60 | +if (!($member->isAdmin() || $isblogadmin)) { | |
61 | + $oPluginAdmin = new PluginAdmin('MetaTags'); | |
62 | + $oPluginAdmin->start(); | |
63 | + echo "<p>"._ERROR_DISALLOWED."</p>"; | |
64 | + $oPluginAdmin->end(); | |
65 | + exit; | |
66 | +} | |
67 | + | |
68 | +if (isset ($_GET['page'])) { | |
69 | + $action = getVar('page'); | |
70 | +} | |
71 | +if (isset ($_POST['page'])) { | |
72 | + $action = getVar('page'); | |
73 | +} | |
74 | + | |
75 | +// create the admin area page | |
76 | +$oPluginAdmin = new PluginAdmin('MetaTags'); | |
77 | +$oPluginAdmin->start(); | |
78 | +$fb =& new cles_Feedback($oPluginAdmin); | |
79 | + | |
80 | +// menu | |
81 | +echo "<h2>MetaTags menu</h2>\n"; | |
82 | +echo "<ul>\n"; | |
83 | +echo "<li><a href=\"".serverVar('PHP_SELF')."?page=report\"><span style=\"font-weight:bold; color:red\">" . $fb->getMenuStr() . "</span></a></li>\n"; | |
84 | +echo "</ul>\n"; | |
85 | + | |
86 | +//action | |
87 | +switch ($action) { | |
88 | + case 'report' : | |
89 | + $ahttp = new cles_AsyncHTTP(); | |
90 | + $extra = $ahttp->asyncMode ? 'AsyncMode(true)' : 'AsyncMode(false)'; | |
91 | + | |
92 | + $fb->printForm($extra); | |
93 | + break; | |
94 | + | |
95 | + default : | |
96 | + break; | |
97 | +} | |
98 | + | |
99 | +echo "<br />"; | |
100 | + | |
101 | +$oPluginAdmin->end(); |