Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revision | 88a3753657ee759f6ab2ee877a448e73b8afa470 (tree) |
---|---|
Time | 2006-11-29 14:53:32 |
Author | shizuki <shizuki@1ca2...> |
Commiter | shizuki |
fix linkParamArr is empty
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@500 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -1,2419 +1,5 @@ | ||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!function_exists('sql_table')) { | |
4 | - function sql_table($name) | |
5 | - { | |
6 | - return 'nucleus_' . $name; | |
7 | - } | |
8 | -} | |
9 | - | |
10 | -if (!function_exists('htmlspecialchars_decode')) { | |
11 | - function htmlspecialchars_decode($text) | |
12 | - { | |
13 | - return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); | |
14 | - } | |
15 | -} | |
16 | - | |
17 | -if (!defined('_CUSTOMURL_TABLE_DEFINED')) { | |
18 | - define('_CUSTOMURL_TABLE_DEFINED', 1); | |
19 | - define('_CUSTOMURL_TABLE', sql_table('plug_customurl')); | |
20 | - define('_C_SUBCAT_TABLE', sql_table('plug_multiple_categories_sub')); | |
21 | -} | |
22 | - | |
23 | -class NP_CustomURL extends NucleusPlugin | |
24 | - { | |
25 | - | |
26 | - function getMinNucleusVersion() | |
27 | - { | |
28 | - return '322'; | |
29 | - } | |
30 | - | |
31 | - function getName() | |
32 | - { | |
33 | - return 'Customized URL'; | |
34 | - } | |
35 | - | |
36 | - function getAuthor() | |
37 | - { | |
38 | - return 'shizuki'; | |
39 | - } | |
40 | - | |
41 | - function getURL() | |
42 | - { | |
43 | - return 'http://shizuki.kinezumi.net/NucleusCMS/Plugins/NP_CustomURL/NP_CustomURL.html'; | |
44 | - } | |
45 | - | |
46 | - function getVersion() | |
47 | - { | |
48 | - return '0.3.2c'; | |
49 | - } | |
50 | - | |
51 | - function getDescription() | |
52 | - { | |
53 | - return _DESCRIPTION; | |
54 | - } | |
55 | - | |
56 | - function supportsFeature($what) | |
57 | - { | |
58 | - switch($what) { | |
59 | - case 'SqlTablePrefix': | |
60 | - return 1; | |
61 | - case 'HelpPage': | |
62 | - return 1; | |
63 | - default: | |
64 | - return 0; | |
65 | - } | |
66 | - } | |
67 | - | |
68 | - function hasAdminArea() | |
69 | - { | |
70 | - return 1; | |
71 | - } | |
72 | - | |
73 | - function event_QuickMenu(&$data) | |
74 | - { | |
75 | - global $member; | |
76 | - $quickLink = ($this->getOption( 'customurl_quicklink') == 'yes'); | |
77 | - $memberCheck = ($member->isLoggedIn() && $member->isAdmin()); | |
78 | - if (!$quickLink || !$memberCheck) { | |
79 | - return; | |
80 | - } | |
81 | - array_push( | |
82 | - $data['options'], | |
83 | - array( | |
84 | - 'title' => _ADMIN_TITLE, | |
85 | - 'url' => $this->getAdminURL(), | |
86 | - 'tooltip' => _QUICK_TIPS | |
87 | - ) | |
88 | - ); | |
89 | - } | |
90 | - | |
91 | - function getTableList() | |
92 | - { | |
93 | - return array( | |
94 | - _CUSTOMURL_TABLE | |
95 | - ); | |
96 | - } | |
97 | - | |
98 | - function getEventList() | |
99 | - { | |
100 | - return array( | |
101 | - 'QuickMenu', | |
102 | -// 'AdminPrePageHead', | |
103 | - 'ParseURL', | |
104 | - 'GenerateURL', | |
105 | - 'PostAddBlog', | |
106 | - 'PostAddItem', | |
107 | - 'PostUpdateItem', | |
108 | - 'PostRegister', | |
109 | - 'PostAddCategory', | |
110 | - 'PostDeleteBlog', | |
111 | - 'PostDeleteItem', | |
112 | - 'PostDeleteMember', | |
113 | - 'PostDeleteCategory', | |
114 | - 'PrePluginOptionsUpdate', | |
115 | - 'PreItem', | |
116 | - 'PostItem', | |
117 | - 'PreSkinParse', | |
118 | - 'AddItemFormExtras', | |
119 | - 'EditItemFormExtras', | |
120 | - 'PostMoveCategory', | |
121 | - 'PostMoveItem', | |
122 | -// 'PreSendContentType', | |
123 | - 'InitSkinParse', | |
124 | - ); | |
125 | - } | |
126 | - | |
127 | -// function event_AdminPrePageHead($data) | |
128 | -// { | |
129 | -// if ($data['action'] == 'pluginhelp' && intGetVar('plugid') == $this->getID()) { | |
130 | -// $data['extrahead'] = '<link rel="stylesheet" title="NP_CustomURL HELP"' | |
131 | -// . ' type="text/css"' | |
132 | -// . "\n" | |
133 | -// . "\t\t\t" | |
134 | -// . ' href="' . $this->getAdminURL() | |
135 | -// . 'helpstyle.css" />' . "\n"; | |
136 | -// } | |
137 | -// } | |
138 | - | |
139 | - function install() | |
140 | - { | |
141 | - global $manager, $CONF; | |
142 | -// Keys initialize | |
143 | - if (empty($CONF['ArchiveKey'])) { | |
144 | - $CONF['ArchiveKey'] = 'archive'; | |
145 | - } | |
146 | - if (empty($CONF['ArchivesKey'])) { | |
147 | - $CONF['ArchivesKey'] = 'archives'; | |
148 | - } | |
149 | - if (empty($CONF['MemberKey'])) { | |
150 | - $CONF['MemberKey'] = 'member'; | |
151 | - } | |
152 | - if (empty($CONF['ItemKey'])) { | |
153 | - $CONF['ItemKey'] = 'item'; | |
154 | - } | |
155 | - if (empty($CONF['CategoryKey'])) { | |
156 | - $CONF['CategoryKey'] = 'category'; | |
157 | - } | |
158 | - | |
159 | -//Plugins sort | |
160 | - $myid = intval($this->getID()); | |
161 | - $res = sql_query('SELECT pid, porder FROM '.sql_table('plugin')); | |
162 | - while($p = mysql_fetch_array($res)) { | |
163 | - $updateQuery = 'UPDATE %s SET porder = %d WHERE pid = %d'; | |
164 | - if (intval($p['pid']) == $myid) { | |
165 | - sql_query(sprintf($updateQuery, sql_table('plugin'), 1, $myid)); | |
166 | - } else { | |
167 | - sql_query(sprintf($updateQuery, sql_table('plugin'), $p['porder']+1, $p['pid'])); | |
168 | - } | |
169 | - } | |
170 | - | |
171 | -//create plugin's options and set default value | |
172 | - $this->createOption('customurl_archive', _OP_ARCHIVE_DIR_NAME, | |
173 | - 'text', $CONF['ArchiveKey']); | |
174 | - $this->createOption('customurl_archives', _OP_ARCHIVES_DIR_NAME, | |
175 | - 'text', $CONF['ArchivesKey']); | |
176 | - $this->createOption('customurl_member', _OP_MEMBER_DIR_NAME, | |
177 | - 'text', $CONF['MemberKey']); | |
178 | - $this->createOption('customurl_dfitem', _OP_DEF_ITEM_KEY, | |
179 | - 'text', $CONF['ItemKey']); | |
180 | - $this->createOption('customurl_dfcat', _OP_DEF_CAT_KEY, | |
181 | - 'text', $CONF['CategoryKey']); | |
182 | - $this->createOption('customurl_dfscat', _OP_DEF_SCAT_KEY, | |
183 | - 'text', 'subcategory'); | |
184 | - $this->createOption('customurl_tabledel', _OP_TABLE_DELETE, | |
185 | - 'yesno', 'no'); | |
186 | - $this->createOption('customurl_quicklink', _OP_QUICK_LINK, | |
187 | - 'yesno', 'yes'); | |
188 | - $this->createOption('customurl_notfound', _OP_NOT_FOUND, | |
189 | - 'select', '404', | |
190 | - '404 Not Found|404|303 See Other|303'); | |
191 | - $this->createBlogOption( 'use_customurl', _OP_USE_CURL, | |
192 | - 'yesno', 'yes'); | |
193 | - $this->createBlogOption( 'redirect_normal', _OP_RED_NORM, | |
194 | - 'yesno', 'yes'); | |
195 | - $this->createBlogOption( 'redirect_search', _OP_RED_SEARCH, | |
196 | - 'yesno', 'yes'); | |
197 | - $this->createBlogOption( 'customurl_bname', _OP_BLOG_PATH, | |
198 | - 'text'); | |
199 | -// $this->createItemOption( 'customurl_iname', _OP_ITEM_PATH, | |
200 | -// 'text', $CONF['ItemKey']); | |
201 | - $this->createMemberOption( 'customurl_mname', _OP_MEMBER_PATH, | |
202 | - 'text'); | |
203 | - $this->createCategoryOption('customurl_cname', _OP_CATEGORY_PATH, | |
204 | - 'text'); | |
205 | - | |
206 | - //default archive directory name | |
207 | - $this->setOption('customurl_archive', $CONF['ArchiveKey']); | |
208 | - //default archives directory name | |
209 | - $this->setOption('customurl_archives', $CONF['ArchivesKey']); | |
210 | - //default member directory name | |
211 | - $this->setOption('customurl_member', $CONF['MemberKey']); | |
212 | - //default itemkey_template | |
213 | - $this->setOption('customurl_dfitem', $CONF['ItemKey']); | |
214 | - //default categorykey_template | |
215 | - $this->setOption('customurl_dfcat', $CONF['CategoryKey']); | |
216 | - //default subcategorykey_template | |
217 | - $this->setOption('customurl_dfscat', 'subcategory'); | |
218 | - | |
219 | -//create data table | |
220 | - $sql = 'CREATE TABLE IF NOT EXISTS ' . _CUSTOMURL_TABLE . ' (' | |
221 | - . ' `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ' | |
222 | - . ' `obj_param` VARCHAR(15) NOT NULL, ' | |
223 | - . ' `obj_name` VARCHAR(128) NOT NULL, ' | |
224 | - . ' `obj_id` INT(11) NOT NULL, ' | |
225 | - . ' `obj_bid` INT(11) NOT NULL,' | |
226 | - . ' INDEX (`obj_name`)' | |
227 | - . ' )'; | |
228 | - sql_query($sql); | |
229 | - | |
230 | -//setting default aliases | |
231 | - $this->_createNewPath('blog', 'blog', 'bnumber', 'bshortname'); | |
232 | - $this->_createNewPath('item', 'item', 'inumber', 'iblog'); | |
233 | - $this->_createNewPath('category', 'category', 'catid', 'cblog'); | |
234 | - $this->_createNewPath('member', 'member', 'mnumber', 'mname'); | |
235 | - | |
236 | - if ($this->pluginCheck('MultipleCategories')) { | |
237 | - $this->_createNewPath('subcategory', 'plug_multiple_categories_sub', 'scatid', 'catid'); | |
238 | - } | |
239 | - | |
240 | - } | |
241 | - | |
242 | - function _createNewPath($type, $n_table, $id, $bids) | |
243 | - { | |
244 | - $tmpTable = sql_table('plug_customurl_temp'); | |
245 | - $createQuery = 'CREATE TABLE %s SELECT obj_id, obj_param FROM %s' | |
246 | - . ' WHERE obj_param = "%s"'; | |
247 | - sql_query(sprintf($createQuery, $tmpTable, _CUSTOMURL_TABLE, $type)); | |
248 | - $TmpQuery = 'SELECT %s, %s FROM %s LEFT JOIN %s ON %s.%s = %s.obj_id' | |
249 | - . ' WHERE %s.obj_id is null'; | |
250 | - $table = sql_table($n_table); | |
251 | - $temp = sql_query(sprintf($TmpQuery, $id, $bids, $table, $tmpTable, $table, $id, $tmpTable, $tmpTable)); | |
252 | - if ($temp) { | |
253 | - while ($row=mysql_fetch_array($temp)) { | |
254 | - switch ($type) { | |
255 | - case 'blog': | |
256 | - //set access by BlogshortName/ | |
257 | - $newPath = $row[$bids]; | |
258 | - $blgid = 0; | |
259 | - break; | |
260 | - case 'item': | |
261 | - //set access by (itemkey_template)_itemid.html | |
262 | - $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
263 | - $itime = quickQuery( sprintf($tque ,sql_table('item'), intval($row[$id]) ) ); | |
264 | - $y = $m = $d = ''; | |
265 | - sscanf($itime,'%d-%d-%d %s',$y,$m,$d,$temp); | |
266 | - $ikey = TEMPLATE::fill($this->getOption('customurl_dfitem'), | |
267 | - array ('year' => $y, | |
268 | - 'month' => $m, | |
269 | - 'day' => $d) | |
270 | - ); | |
271 | - $newPath = $ikey . '_' . $row[$id] . '.html'; | |
272 | - $blgid = $row[$bids]; | |
273 | - break; | |
274 | - case 'category': | |
275 | - //set access by (categorykey_template)_categoryid/ | |
276 | - $newPath = $this->getOption('customurl_dfcat') . '_' . $row[$id]; | |
277 | - $blgid = $row[$bids]; | |
278 | - break; | |
279 | - case 'member': | |
280 | - //set access by loginName.html | |
281 | - $newPath = $row[$bids] . '.html'; | |
282 | - $blgid = 0; | |
283 | - break; | |
284 | - case 'subcategory': | |
285 | - //set access by (subcategorykey_template)_subcategoryid/ | |
286 | - $newPath = $this->getOption('customurl_dfscat') . '_' . $row[$id]; | |
287 | - $blgid = $row[$bids]; | |
288 | - break; | |
289 | - default: | |
290 | - break; | |
291 | - } | |
292 | - $insertQuery = 'INSERT INTO %s (obj_param, obj_id, obj_name, obj_bid)' | |
293 | - . ' VALUES ("%s", %d, "%s", %d)'; | |
294 | - $row[$id] = intval($row[$id]); | |
295 | - $blgid = intval($blgid); | |
296 | - sql_query(sprintf($insertQuery, _CUSTOMURL_TABLE, $type, $row[$id], $newPath, $blgid)); | |
297 | - } | |
298 | - } | |
299 | - $query = 'SELECT obj_id, obj_name FROM %s WHERE obj_param = "%s"'; | |
300 | - $temp = sql_query(sprintf($query, _CUSTOMURL_TABLE, $type)); | |
301 | - while ($row = mysql_fetch_array($temp)) { | |
302 | - $name = $row['obj_name']; | |
303 | - $id = intval($row['obj_id']); | |
304 | - switch ($type) { | |
305 | - case 'blog': | |
306 | - $this->setBlogOption($id, 'customurl_bname', $name); | |
307 | - break; | |
308 | - case 'category': | |
309 | - $this->setCategoryOption($id, 'customurl_cname', $name); | |
310 | - break; | |
311 | - case 'member': | |
312 | - $obj_name = substr($name, 0, -5); | |
313 | - $this->setMemberOption($id, 'customurl_mname', $obj_name); | |
314 | - break; | |
315 | - default: | |
316 | - break; | |
317 | - } | |
318 | - } | |
319 | - | |
320 | - sql_query('DROP TABLE IF EXISTS ' . $tmpTable); | |
321 | - } | |
322 | - | |
323 | - function init() | |
324 | - { | |
325 | - global $admin; | |
326 | - $language = ereg_replace( '[\\|/]', '', getLanguageName()); | |
327 | - if (file_exists($this->getDirectory() . 'language/' . $language . '.php')) { | |
328 | - include_once($this->getDirectory() . 'language/' . $language . '.php'); | |
329 | - } else { | |
330 | - include_once($this->getDirectory() . 'language/english.php'); | |
331 | - } | |
332 | - } | |
333 | - | |
334 | - function pluginCheck($pluginName) | |
335 | - { | |
336 | - global $manager; | |
337 | - if (!$manager->pluginInstalled('NP_' . $pluginName)) { | |
338 | - return; | |
339 | - } | |
340 | - $plugin =& $manager->getPlugin('NP_' . $pluginName); | |
341 | - return $plugin; | |
342 | - } | |
343 | - | |
344 | - function unInstall() | |
345 | - { | |
346 | - if ($this->getOption('customurl_tabledel') == 'yes') { | |
347 | - sql_query("DROP TABLE "._CUSTOMURL_TABLE); | |
348 | - } | |
349 | - $this->deleteOption('customurl_archive'); | |
350 | - $this->deleteOption('customurl_archives'); | |
351 | - $this->deleteOption('customurl_member'); | |
352 | - $this->deleteOption('customurl_dfitem'); | |
353 | - $this->deleteOption('customurl_dfcat'); | |
354 | - $this->deleteOption('customurl_dfscat'); | |
355 | - $this->deleteOption('customurl_notfound'); | |
356 | - $this->deleteOption('customurl_tabledel'); | |
357 | - $this->deleteOption('customurl_quicklink'); | |
358 | - $this->deleteBlogOption('use_customurl'); | |
359 | - $this->deleteBlogOption('redirect_normal'); | |
360 | - $this->deleteBlogOption('redirect_search'); | |
361 | - $this->deleteBlogOption('customurl_bname'); | |
362 | -// $this->deleteItemOption('customurl_iname'); | |
363 | - $this->deleteMemberOption('customurl_mname'); | |
364 | - $this->deleteCategoryOption('customurl_cname'); | |
365 | - } | |
366 | - | |
367 | - function event_ParseURL($data) | |
368 | - { | |
369 | - global $CONF, $manager, $curl_blogid, $blogid, $itemid, $catid; | |
370 | - global $memberid, $archivelist, $archive, $query; | |
371 | -// initialize | |
372 | - $info = $data['info']; | |
373 | - $complete =& $data['complete']; | |
374 | - if ($complete) return; | |
375 | - $useCustomURL = $this->getAllBlogOptions('use_customurl'); | |
376 | - | |
377 | -// Use NP_MultipleCategories ? | |
378 | - $mcategories = $this->pluginCheck('MultipleCategories'); | |
379 | - if ($mcategories) { | |
380 | - if (method_exists($mcategories, "getRequestName")) { | |
381 | - $mcategories->event_PreSkinParse(array()); | |
382 | - global $subcatid; | |
383 | - $subrequest = $mcategories->getRequestName(); | |
384 | - } | |
385 | - } | |
386 | - if (!$subrequest) { | |
387 | - $subrequest = 'subcatid'; | |
388 | - } | |
389 | - | |
390 | -// initialize and sanitize '$blogid' | |
391 | - if (!$blogid) { | |
392 | - if ( getVar('blogid') ) { | |
393 | - if ( is_numeric(getVar('blogid')) ) { | |
394 | - $blogid = intval(getVar('blogid')); | |
395 | - } else { | |
396 | - $blogid = intval(getBlogIDFromName(getVar('blogid'))); | |
397 | - } | |
398 | - } elseif ($curl_blogid) { | |
399 | - $blogid = intval($curl_blogid); | |
400 | - } else { | |
401 | - $blogid = $CONF['DefaultBlog']; | |
402 | - } | |
403 | - } else { | |
404 | - if (is_numeric($blogid)) { | |
405 | - $blogid = intval($blogid); | |
406 | - } else { | |
407 | - $blogid = intval(getBlogIDFromName($blogid)); | |
408 | - } | |
409 | - } | |
410 | - | |
411 | - if (!$info) { | |
412 | - if (serverVar('PATH_INFO')) { | |
413 | - $info = serverVar('PATH_INFO'); | |
414 | - } elseif (getNucleusVersion() < 330) { | |
415 | - if (getVar('virtualpath')) { | |
416 | - $info = getVar('virtualpath'); | |
417 | - } | |
418 | - } else { | |
419 | - return; | |
420 | - } | |
421 | - } | |
422 | - | |
423 | -// Sanitize 'PATH_INFO' | |
424 | - $info = trim($info, '/'); | |
425 | - $v_path = explode("/", $info); | |
426 | - foreach($v_path as $key => $value) { | |
427 | - $value = urlencode($value); | |
428 | - $value = preg_replace('|[^a-zA-Z0-9-~+_.?#=&;,/:@%]|i', '', $value); | |
429 | - $v_path[$key] = $value; | |
430 | - } | |
431 | - if (phpversion() >= '4.1.0') { | |
432 | - $_SERVER['PATH_INFO'] = implode('/', $v_path); | |
433 | - } | |
434 | - global $HTTP_SERVER_VARS; | |
435 | - $HTTP_SERVER_VARS['PATH_INFO'] = implode('/', $v_path); | |
436 | - | |
437 | -// Admin area check | |
438 | - $tmpURL = sprintf("%s%s%s", "http://", serverVar("HTTP_HOST"), serverVar("SCRIPT_NAME")); | |
439 | - $uri = str_replace('/', '\/', $tmpURL); | |
440 | - $plug_url = str_replace('/', '\/', $CONF['PluginURL']); | |
441 | - $u_plugAction = (getVar('action') == 'plugin' && getVar('name')); | |
442 | - if (strpos($uri, $plug_url) === 0 || $u_plugAction) { | |
443 | - $UsingPlugAdmin = TRUE; | |
444 | - } | |
445 | - | |
446 | -// redirect to other URL style | |
447 | - $useCustomURLyes = ($useCustomURL[$blogid] == 'yes'); | |
448 | - if ($useCustomURLyes && !$UsingPlugAdmin && !$CONF['UsingAdminArea']) { | |
449 | -// Search query redirection | |
450 | -// 301 permanent ? or 302 temporary ? | |
451 | - $queryURL = (strpos(serverVar('REQUEST_URI'), 'query=') !== FALSE); | |
452 | - $search_q = (getVar('query') || $queryURL); | |
453 | - $redirectSerch = ($this->getBlogOption($blogid, 'redirect_search') == 'yes'); | |
454 | - if ($redirectSerch) { | |
455 | - if ($search_q) { | |
456 | - $que_str = getVar('query'); | |
457 | - $que_str = htmlspecialchars($que_str); | |
458 | - $que_str = mb_eregi_replace('/', 'ssslllaaassshhh', $que_str); | |
459 | - $que_str = mb_eregi_replace("'", 'qqquuuooottt', $que_str); | |
460 | - $que_str = mb_eregi_replace('&', 'aaammmppp', $que_str); | |
461 | - $que_str = urlencode($que_str); | |
462 | - $search_path = '/search/' . $que_str; | |
463 | - $b_url = createBlogidLink($blogid); | |
464 | - $redurl = sprintf("%s%s", $b_url, $search_path); | |
465 | - redirect($redurl); // 302 Moved temporary | |
466 | - exit; | |
467 | - } | |
468 | - } | |
469 | - if (!$redirectSerch && $search_q) { | |
470 | - $exLink = TRUE; | |
471 | - } | |
472 | - | |
473 | -// redirection nomal URL to FancyURL | |
474 | - $temp_req = explode('?', serverVar('REQUEST_URI')); | |
475 | - $reqPath = trim(end($temp_req), '/'); | |
476 | - $indexrdf = ($reqPath == 'xml-rss1.php'); | |
477 | - $atomfeed = ($reqPath == 'atom.php'); | |
478 | - $rss2feed = ($reqPath == 'xml-rss2.php'); | |
479 | - $feeds = ($indexrdf || $atomfeed || $rss2feed); | |
480 | - $redirectNormal = ($this->getBlogOption($blogid, 'redirect_normal') == 'yes'); | |
481 | - if ($redirectNormal && serverVar('QUERY_STRING') && !$feeds && !$exLink) { | |
482 | - $temp = explode('&', serverVar('QUERY_STRING')); | |
483 | - foreach ($temp as $k => $val) { | |
484 | - if (preg_match('/^virtualpath/', $val)) { | |
485 | - unset($temp[$k]); | |
486 | - } | |
487 | - } | |
488 | - if (!empty($temp)) { | |
489 | - $p_arr = array(); | |
490 | - foreach ($temp as $key => $value) { | |
491 | - $p_key = explode('=', $value); | |
492 | - switch (reset($p_key)) { | |
493 | - case 'blogid'; | |
494 | - $p_arr[] = $CONF['BlogKey'] . '/' | |
495 | - . intGetVar('blogid'); | |
496 | - unset($temp[$key]); | |
497 | - break; | |
498 | - case 'catid'; | |
499 | - $p_arr[] = $CONF['CategoryKey'] . '/' | |
500 | - . intGetVar('catid'); | |
501 | - unset($temp[$key]); | |
502 | - break; | |
503 | - case $subrequest; | |
504 | - $p_arr[] = $subrequest . '/' | |
505 | - . intGetVar($subrequest); | |
506 | - unset($temp[$key]); | |
507 | - break; | |
508 | - case 'itemid'; | |
509 | - $p_arr[] = $CONF['ItemKey'] . '/' | |
510 | - . intGetVar('itemid'); | |
511 | - unset($temp[$key]); | |
512 | - break; | |
513 | - case 'memberid'; | |
514 | - $p_arr[] = $CONF['MemberKey'] . '/' | |
515 | - . intGetVar('memberid'); | |
516 | - unset($temp[$key]); | |
517 | - break; | |
518 | - case 'archivelist'; | |
519 | - $p_arr[] = $CONF['ArchivesKey'] . '/' | |
520 | - . $blogid; | |
521 | - unset($temp[$key]); | |
522 | - break; | |
523 | - case 'archive'; | |
524 | - $p_arr[] = $CONF['ArchiveKey'] . '/' | |
525 | - . $blogid . '/' . getVar('archive'); | |
526 | - unset($temp[$key]); | |
527 | - break; | |
528 | - default: | |
529 | - break; | |
530 | - } | |
531 | - } | |
532 | - if (reset($p_arr)) { | |
533 | - $b_url = createBlogidLink($blogid); | |
534 | - $red_path = '/' . implode('/', $p_arr); | |
535 | - if (substr($b_url, -1) == '/') { | |
536 | - $b_url = rtrim($b_url, '/'); | |
537 | - } | |
538 | - $redurl = sprintf("%s%s", $b_url, $red_path); | |
539 | - // HTTP status 301 "Moved Permanentry" | |
540 | - header( "HTTP/1.1 301 Moved Permanently" ); | |
541 | - header('Location: ' . $redurl); | |
542 | - exit; | |
543 | - } | |
544 | - } | |
545 | - } elseif ($redirectNormal && $feeds) { | |
546 | - $b_url = rtrim(createBlogidLink($blogid), '/'); | |
547 | - switch ($reqPath) { | |
548 | - case 'xml-rss1.php': | |
549 | - $feed_code = '/index.rdf'; | |
550 | - break; | |
551 | - case 'xml-rss2.php': | |
552 | - $feed_code = '/rss2.xml'; | |
553 | - break; | |
554 | - case 'atom.php': | |
555 | - $feed_code = '/atom.xml'; | |
556 | - break; | |
557 | - default: | |
558 | - break; | |
559 | - } | |
560 | - // HTTP status 301 "Moved Permanentry" | |
561 | - header('HTTP/1.1 301 Moved Permanently'); | |
562 | - header('Location: ' . $b_url . $feed_code); | |
563 | - exit; | |
564 | - } | |
565 | - } | |
566 | -// decode path_info | |
567 | - | |
568 | -// decode unofficial Page switch '/page_2.html' | |
569 | - foreach($v_path as $pathName) { | |
570 | - if (preg_match('/^page_/', $pathName)) { | |
571 | - $temp_info = explode('page_', $pathName); | |
572 | - $_GET['page'] = intval($temp_info[1]); | |
573 | - $page = array_pop($v_path); | |
574 | - } | |
575 | - } | |
576 | - | |
577 | -// decode TrackBack URL shorten ver. | |
578 | - $tail = end($v_path); | |
579 | - if (substr($tail, -10, 10) == '.trackback') { | |
580 | - $v_pathName = substr($tail, 0, -10); | |
581 | -// echo $v_pathName; | |
582 | - if (is_numeric($v_pathName)) { | |
583 | - $this->_trackback($blogid, $v_pathName); | |
584 | - } else { | |
585 | - $this->_trackback($blogid, $v_pathName . '.html'); | |
586 | - } | |
587 | - return; | |
588 | - } | |
589 | - | |
590 | -// decode other type URL | |
591 | - $bLink = $cLink = $iLink = $exLink = FALSE; | |
592 | - if (empty($info)) { | |
593 | - $bLink = TRUE; | |
594 | - } | |
595 | - $linkObj = array ( | |
596 | - 'bid' => 0, | |
597 | - 'name' => reset($v_path), | |
598 | - 'linkparam' => 'blog' | |
599 | - ); | |
600 | - $blog_id = $this->getRequestPathInfo($linkObj); | |
601 | - if ($blog_id) { | |
602 | - $blogid = $blog_id; | |
603 | - $trush = array_shift($v_path); | |
604 | - $bLink = TURE; | |
605 | - } | |
606 | - if ($useCustomURL[$blogid] == 'no') { | |
607 | - return; | |
608 | - } | |
609 | - $i = 1; | |
610 | - foreach($v_path as $pathName) { | |
611 | - switch ($pathName) { | |
612 | -// decode FancyURLs and redirection to Customized URL | |
613 | - // for blogsgetAllBlogOptions($name) | |
614 | - case $CONF['BlogKey']: | |
615 | - if (isset($v_path[$i]) && is_numeric($v_path[$i])) { | |
616 | - if ($useCustomURL[intval($v_path[$i])] != 'yes') { | |
617 | - $blogid = intval($v_path[$i]); | |
618 | - $bLink = TRUE; | |
619 | - } else { | |
620 | - $redURI = createBlogidLink(intval($v_path[$i])); | |
621 | - } | |
622 | - } | |
623 | - break; | |
624 | - // for items | |
625 | - case $CONF['ItemKey']: | |
626 | - if (isset($v_path[$i]) && is_numeric($v_path[$i])) { | |
627 | - if ($useCustomURL[$blogid] != 'yes') { | |
628 | - $itemid = intval($v_path[$i]); | |
629 | - $iLink = TRUE; | |
630 | - } else { | |
631 | - $redURI = createItemLink(intval($v_path[$i])); | |
632 | - } | |
633 | - } | |
634 | - break; | |
635 | - // for categories | |
636 | - case $CONF['CategoryKey']: | |
637 | - case 'catid': | |
638 | - if (isset($v_path[$i]) && is_numeric($v_path[$i])) { | |
639 | - if ($useCustomURL[$blogid] != 'yes') { | |
640 | - $catid = intval($v_path[$i]); | |
641 | - $cLink = TRUE; | |
642 | - } else { | |
643 | - $redURI = createCategoryLink(intval($v_path[$i])); | |
644 | - } | |
645 | - } | |
646 | - break; | |
647 | - // for subcategories | |
648 | - case $subrequest: | |
649 | - $c = $i - 2; | |
650 | - $subCat = (isset($v_path[$i]) && is_numeric($v_path[$i])); | |
651 | - if ($mcategories && $subCat && $i >= 3 && is_numeric($v_path[$c])) { | |
652 | - if ($useCustomURL[$blogid] != 'yes') { | |
653 | - $subcatid = intval($v_path[$i]); | |
654 | - $catid = intval($v_path[$c]); | |
655 | - $cLink = TRUE; | |
656 | - } else { | |
657 | - $subcat_id = intval($v_path[$i]); | |
658 | - $catid = intval($v_path[$c]); | |
659 | - $linkParam = array($subrequest => $subcat_id); | |
660 | - $redURI = createCategoryLink($catid, $linkParam); | |
661 | - } | |
662 | - } | |
663 | - break; | |
664 | - // for archives | |
665 | - case $CONF['ArchivesKey']: | |
666 | - case $this->getOption('customurl_archives'): | |
667 | - // FancyURL | |
668 | - if (isset($v_path[$i]) && is_numeric($v_path[$i])) { | |
669 | - if ($useCustomURL[intval($v_path[$i])] != 'yes') { | |
670 | - $archivelist = intval($v_path[$i]); | |
671 | - $blogid = $archivelist; | |
672 | - $exLink = TRUE; | |
673 | - } else { | |
674 | - $redURI = createArchiveListLink(intval($v_path[$i])); | |
675 | - } | |
676 | - // Customized URL | |
677 | - } elseif (isset($v_path[$i])) { | |
678 | - $archivelist = $blogid; | |
679 | - $redURI = createArchiveListLink($archivelist); | |
680 | - } else { | |
681 | - $archivelist = $blogid; | |
682 | - $exLink = TRUE; | |
683 | - } | |
684 | - break; | |
685 | - // for archive | |
686 | - case $CONF['ArchiveKey']: | |
687 | - case $this->getOption('customurl_archive'): | |
688 | - $y = $m = $d = ''; | |
689 | - $ar = $i + 1; | |
690 | - if (isset($v_path[$i])) { | |
691 | - $darc = (ereg('([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})', $v_path[$i])); | |
692 | - $marc = (ereg('([0-9]{4})-([0-9]{1,2})', $v_path[$i])); | |
693 | - $yarc = (ereg('([0-9]{4})', $v_path[$i])); | |
694 | - $adarc = (ereg('([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})', $v_path[$ar])); | |
695 | - $amarc = (ereg('([0-9]{4})-([0-9]{1,2})', $v_path[$ar])); | |
696 | - $ayarc = (ereg('([0-9]{4})', $v_path[$ar])); | |
697 | - $arc = (!$darc && !$marc && !$yarc); | |
698 | - $aarc = ($adarc || $amarc || $ayarc); | |
699 | - $carc = ($darc || $marc || $yarc); | |
700 | - // FancyURL | |
701 | -// if (is_numeric($v_path[$i]) && !$darc && !$marc && !$yarc && isset($v_path[$ar]) && ($adarc || $amarc || $ayarc)) { | |
702 | - if (is_numeric($v_path[$i]) && $arc && isset($v_path[$ar]) && $aarc) { | |
703 | - sscanf($v_path[$ar], '%d-%d-%d', $y, $m, $d); | |
704 | - if (!empty($d)) { | |
705 | - $archive = sprintf('%04d-%02d-%02d', $y, $m, $d); | |
706 | - } elseif (!empty($m)) { | |
707 | - $archive = sprintf('%04d-%02d', $y, $m); | |
708 | - } else { | |
709 | - $archive = sprintf('%04d', $y); | |
710 | - } | |
711 | - if ($useCustomURL[intval($v_path[$i])] != 'yes') { | |
712 | - $blogid = intval($v_path[$i]); | |
713 | - $exLink = TRUE; | |
714 | - } else { | |
715 | - $blogid = intval($v_path[$i]); | |
716 | - $redURI = createArchiveLink($blogid, $archive); | |
717 | - } | |
718 | - // Customized URL | |
719 | -// } elseif ($darc || $marc || $yarc) { | |
720 | - } elseif ($carc) { | |
721 | - sscanf($v_path[$i], '%d-%d-%d', $y, $m, $d); | |
722 | - if (isset($d)) { | |
723 | - $archive = sprintf('%04d-%02d-%02d', $y, $m, $d); | |
724 | - } elseif (!empty($m)) { | |
725 | - $archive = sprintf('%04d-%02d', $y, $m); | |
726 | - } else { | |
727 | - $archive = sprintf('%04d', $y); | |
728 | - } | |
729 | - $exLink = TRUE; | |
730 | - } else { | |
731 | - $redURI = createArchiveListLink($blogid); | |
732 | - } | |
733 | - } else { | |
734 | - $redURI = createArchiveListLink($blogid); | |
735 | - } | |
736 | - break; | |
737 | - // for member | |
738 | - case $CONF['MemberKey']: | |
739 | - case $this->getOption('customurl_member'): | |
740 | - // Customized URL | |
741 | - $customMemberURL = (substr($v_path[$i], -5, 5) == '.html'); | |
742 | - if (isset($v_path[$i]) && $customMemberURL) { | |
743 | - $memberInfo = array('linkparam' => 'member', | |
744 | - 'bid' => 0, | |
745 | - 'name' => $v_path[$i]); | |
746 | - $member_id = $this->getRequestPathInfo($memberInfo); | |
747 | - $memberid = intval($member_id); | |
748 | - $exLink = TRUE; | |
749 | - // FancyURL | |
750 | - } elseif (isset($v_path[$i]) && is_numeric($v_path[$i])) { | |
751 | - if ($useCustomURL[$blogid] != 'yes') { | |
752 | - $memberid = intval($v_path[$i]); | |
753 | - $exLink = TRUE; | |
754 | - } else { | |
755 | - $redURI = createMemberLink(intval($v_path[$i])); | |
756 | - } | |
757 | - } else { | |
758 | - $redURI = createBlogidLink($blogid); | |
759 | - } | |
760 | - break; | |
761 | - // for tag | |
762 | - case 'tag': | |
763 | - if (isset($v_path[$i]) && is_string($v_path[$i])) { | |
764 | - $_REQUEST['tag'] = $v_path[$i]; | |
765 | - $exLink = TRUE; | |
766 | - } | |
767 | - break; | |
768 | - // for ExtraSkinJP | |
769 | - case 'extra': | |
770 | - $ExtraSkinJP = $this->pluginCheck('ExtraSkinJP'); | |
771 | - if ($ExtraSkinJP) { | |
772 | - // under v3.2 needs this | |
773 | - if ($CONF['DisableSite'] && !$member->isAdmin()) { | |
774 | - header('Location: ' . $CONF['DisableSiteURL']); | |
775 | - exit; | |
776 | - } | |
777 | - $extraParams = explode("/", serverVar('PATH_INFO')); | |
778 | - array_shift ($extraParams); | |
779 | - | |
780 | - if (isset($extraParams[1]) && preg_match("/^([1-9]+[0-9]*)(\?.*)?$/", $extraParams[1], $matches)) { | |
781 | - $extraParams[1] = $matches[1]; | |
782 | - } | |
783 | - | |
784 | - $ExtraSkinJP->extra_selector($extraParams); | |
785 | - exit; | |
786 | - } | |
787 | - break; | |
788 | - // for search query | |
789 | - case 'search': | |
790 | - $redirectSerch = ($this->getBlogOption($blogid, 'redirect_search') == 'yes'); | |
791 | - if ($redirectSerch) { | |
792 | - $que_str = urldecode($v_path[$i]); | |
793 | - $que_str = mb_eregi_replace('ssslllaaassshhh', '/', $que_str); | |
794 | - $que_str = mb_eregi_replace('qqquuuooottt', "'", $que_str); | |
795 | - $que_str = mb_eregi_replace('aaammmppp', '&', $que_str); | |
796 | - $que_str = htmlspecialchars_decode($que_str); | |
797 | - $_GET['query'] = $que_str; | |
798 | - $query = $que_str; | |
799 | - $exLink = TRUE; | |
800 | - } | |
801 | - break; | |
802 | - // for pageswitch | |
803 | - case 'page': | |
804 | - if (isset($v_path[$i]) && is_numeric($v_path[$i])) { | |
805 | - $_GET['page'] = intval($v_path[$i]); | |
806 | - $exLink = TRUE; | |
807 | - } | |
808 | - break; | |
809 | - // for tDiarySkin | |
810 | - case 'tdiarydate': | |
811 | - case 'categorylist': | |
812 | - case 'monthlimit': | |
813 | - $tDiaryPlugin = $this->pluginCheck('tDiarySkin'); | |
814 | - if ($tDiaryPlugin && isset($v_path[$i])) { | |
815 | -// sscanf($v_path[$i], '%d-%d', $m, $d); | |
816 | -// $linkDate = sprintf('%02d-%02d', $m, $d); | |
817 | -// $_GET['linkdate'] = $linkDate; | |
818 | - $_GET[$pathName] = $v_path[$i]; | |
819 | - $exLink = TRUE; | |
820 | - } | |
821 | - break; | |
822 | - // for trackback | |
823 | - case 'trackback': | |
824 | - if (isset($v_path[$i]) && is_string($v_path[$i])) { | |
825 | - $this->_trackback($blogid, $v_path[$i]); | |
826 | - } | |
827 | - return; | |
828 | - break; | |
829 | - | |
830 | -// decode Customized URL | |
831 | - default: | |
832 | - // initialyze | |
833 | - $linkObj = array ('bid' => $blogid, | |
834 | - 'name' => $pathName | |
835 | - ); | |
836 | - $comp = FALSE; | |
837 | - $isItem = (substr($pathName, -5) == '.html'); | |
838 | - // category ? | |
839 | - if (!$comp && !$cLink && !$iLink && !$isItem) { | |
840 | - $linkObj['linkparam'] = 'category'; | |
841 | - $cat_id = $this->getRequestPathInfo($linkObj); | |
842 | - if (!empty($cat_id)) { | |
843 | - $catid = intval($cat_id); | |
844 | - $cLink = TURE; | |
845 | - $comp = TRUE; | |
846 | - } | |
847 | - } | |
848 | - // subcategory ? | |
849 | - if (!$comp && $cLink && !$iLink && $mcategories && !$isItem) { | |
850 | - $linkObj['linkparam'] = 'subcategory'; | |
851 | - $linkObj['bid'] = $catid; | |
852 | - $subcat_id = $this->getRequestPathInfo($linkObj); | |
853 | - if (!empty($subcat_id)) { | |
854 | - $_REQUEST[$subrequest] = intval($subcat_id); | |
855 | - $subcatid = intval($subcat_id); | |
856 | - $sc = $i; | |
857 | - $comp = TRUE; | |
858 | - } | |
859 | - } | |
860 | - // item ? | |
861 | - if ($isItem) { | |
862 | - $linkObj['linkparam'] = 'item'; | |
863 | - $item_id = $this->getRequestPathInfo($linkObj); | |
864 | - if (!empty($item_id)) { | |
865 | - $itemid = intval($item_id); | |
866 | - $iLink = TRUE; | |
867 | - } | |
868 | - } | |
869 | - break; | |
870 | - } | |
871 | - if (preg_match('/^[0-9page]$/', $pathName)) { | |
872 | - $exLink = $pathName; | |
873 | - } | |
874 | - $i++; | |
875 | - } | |
876 | - | |
877 | -// FancyURL redirect to Customized URL if use it | |
878 | -// HTTP status 301 "Moved Permanentry" | |
879 | - if ($redURI) { | |
880 | - header('HTTP/1.1 301 Moved Permanently'); | |
881 | - header('Location: ' . $redURI); | |
882 | - exit; | |
883 | - } | |
884 | - | |
885 | - $feedurl = array( | |
886 | - 'rss1.xml', | |
887 | - 'index.rdf', | |
888 | - 'rss2.xml', | |
889 | - 'atom.xml', | |
890 | - ); | |
891 | - $siteMapPlugin = $this->pluginCheck('GoogleSitemap'); | |
892 | - if ($siteMapPlugin) { | |
893 | - $pcSitemaps = $siteMapPlugin->getAllBlogOptions('PcSitemap'); | |
894 | - foreach ($pcSitemaps as $pCsitemap) { | |
895 | - if ($pCsitemap) { | |
896 | - $feedurl[] = $pCsitemap; | |
897 | - } | |
898 | - } | |
899 | - $mobSitemaps = $siteMapPlugin->getAllBlogOptions('MobileSitemap'); | |
900 | - foreach ($mobSitemaps as $mobSitemap) { | |
901 | - if ($mobSitemap) { | |
902 | - $feedurl[] = $mobSitemap; | |
903 | - } | |
904 | - } | |
905 | - } | |
906 | - $feedurl = array_unique($feedurl); | |
907 | - $request_path = end($v_path); | |
908 | - $feeds = in_array($request_path, $feedurl, true); | |
909 | - | |
910 | -// finish decode | |
911 | - if (!$exLink && !$feeds) { | |
912 | -// URL Not Found | |
913 | - if (substr(end($v_path), -5) == '.html' && !$iLink) { | |
914 | - $notFound = TRUE; | |
915 | - if (!empty($subcatid)) { | |
916 | - $linkParam = array($subrequest => $subcatid); | |
917 | - $uri = createCategoryLink($catid, $linkParam); | |
918 | - } elseif (!empty($catid)) { | |
919 | - $uri = createCategoryLink($catid); | |
920 | - } else { | |
921 | - $uri = createBlogidLink($blogid); | |
922 | - } | |
923 | - } elseif (count($v_path) > $sc && !empty($subcatid) && !$iLink) { | |
924 | - $notFound = TRUE; | |
925 | - $linkParam = array($subrequest => $subcatid); | |
926 | - $uri = createCategoryLink($catid, $linkParam); | |
927 | - } elseif (count($v_path) >= 2 && !$subcatid && !$iLink) { | |
928 | - $notFound = TRUE; | |
929 | - if (isset($catid)) { | |
930 | - $uri = createCategoryLink($catid); | |
931 | - } else { | |
932 | - $uri = createBlogidLink($blogid); | |
933 | - } | |
934 | - } elseif (reset($v_path) && !$catid && !$subcatid && !$iLink) { | |
935 | - $notFound = TRUE; | |
936 | - $uri = createBlogidLink($blogid); | |
937 | - } else { | |
938 | -// Found | |
939 | -// setting $CONF['Self'] for other plugins | |
940 | - $uri = createBlogidLink($blogid); | |
941 | - $CONF['Self'] = rtrim($uri, '/'); | |
942 | - $complete = TRUE; | |
943 | - return ; | |
944 | - } | |
945 | - } else { | |
946 | - $uri = createBlogidLink($blogid); | |
947 | - $CONF['Self'] = rtrim($uri, '/'); | |
948 | - $complete = TRUE; | |
949 | - return ; | |
950 | - } | |
951 | -// Behavior Not Found | |
952 | - if ($notFound) { | |
953 | - if (substr($uri, -1) != '/') $uri .= '/'; | |
954 | - if ($this->getOption('customurl_notfound') == '404') { | |
955 | - header('HTTP/1.1 404 Not Found'); | |
956 | - doError(_NO_SUCH_URI); | |
957 | - exit; | |
958 | - } else { | |
959 | - header('HTTP/1.1 303 See Other'); | |
960 | - header('Location: ' . $uri); | |
961 | - exit; | |
962 | - } | |
963 | - } | |
964 | - } | |
965 | - | |
966 | -// decode 'path name' to 'id' | |
967 | - function getRequestPathInfo($linkObj) | |
968 | - { | |
969 | - $query = 'SELECT obj_id as result FROM %s' | |
970 | - . ' WHERE obj_name = "%s"' | |
971 | - . ' AND obj_bid = %d AND obj_param = "%s"'; | |
972 | - $name = $this->quote_smart($linkObj['name']); | |
973 | - $bid = $this->quote_smart($linkObj['bid']); | |
974 | - $linkparam = $this->quote_smart($linkObj['linkparam']); | |
975 | - $ObjID = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $name, $bid, $linkparam)); | |
976 | - if (!$ObjID) { | |
977 | - return; | |
978 | - } else { | |
979 | - return intval($ObjID); | |
980 | - } | |
981 | - } | |
982 | - | |
983 | -// Receive TrackBack ping | |
984 | - function _trackback($bid, $path) | |
985 | - { | |
986 | - $blog_id = intval($bid); | |
987 | - $TrackBack = $this->pluginCheck('TrackBack'); | |
988 | - if ($TrackBack) { | |
989 | - if (substr($path, -5, 5) == '.html') { | |
990 | - $linkObj = array ('linkparam' => 'item', | |
991 | - 'bid' => $blog_id, | |
992 | - 'name' => $path); | |
993 | - $item_id = $this->getRequestPathInfo($linkObj); | |
994 | - if ($item_id) { | |
995 | - $tb_id = intval($item_id); | |
996 | - } else { | |
997 | - doError(_NO_SUCH_URI); | |
998 | - } | |
999 | - } else { | |
1000 | - $tb_id = intval($path); | |
1001 | - } | |
1002 | - | |
1003 | - $errorMsg = $TrackBack->handlePing($tb_id); | |
1004 | - if ($errorMsg != '') { | |
1005 | - $TrackBack->xmlResponse($errorMsg); | |
1006 | - } else { | |
1007 | - $TrackBack->xmlResponse(); | |
1008 | - } | |
1009 | - } | |
1010 | - exit; | |
1011 | - } | |
1012 | - | |
1013 | - function event_GenerateURL($data) | |
1014 | - { | |
1015 | - global $CONF, $manager, $blogid; | |
1016 | - if ($data['completed']) { | |
1017 | - return; | |
1018 | - } | |
1019 | - | |
1020 | - if (is_numeric($blogid)) { | |
1021 | - $blogid = intval($blogid); | |
1022 | - } else { | |
1023 | - $blogid = intval(getBlogIDFromName($blogid)); | |
1024 | - } | |
1025 | - $mcategories = $this->pluginCheck('MultipleCategories'); | |
1026 | - if ($mcategories) { | |
1027 | - if (method_exists($mcategories, 'getRequestName')) { | |
1028 | - $mcategories->event_PreSkinParse(array()); | |
1029 | - global $subcatid; | |
1030 | - $subrequest = $mcategories->getRequestName(); | |
1031 | - } | |
1032 | - } | |
1033 | - if ($subcatid) { | |
1034 | - $subcatid = intval($subcatid); | |
1035 | - } | |
1036 | - $OP_ArchiveKey = $this->getOption('customurl_archive'); | |
1037 | - $OP_ArchivesKey = $this->getOption('customurl_archives'); | |
1038 | - $OP_MemberKey = $this->getOption('customurl_member'); | |
1039 | - $params = $data['params']; | |
1040 | - $catParam = $params['extra']['catid']; | |
1041 | -// echo $catParam; | |
1042 | - $subcatParam = $params['extra'][$subrequest]; | |
1043 | - $useCustomURL = $this->getAllBlogOptions('use_customurl'); | |
1044 | - switch ($data['type']) { | |
1045 | - case 'item': | |
1046 | - if (!is_numeric($params['itemid'])) { | |
1047 | - return; | |
1048 | - } | |
1049 | - $item_id = intval($params['itemid']); | |
1050 | - $bid = intval(getBlogIDFromItemID($item_id)); | |
1051 | - if ($useCustomURL[$bid] == 'no') { | |
1052 | - return; | |
1053 | - } | |
1054 | - $query = 'SELECT obj_name as result FROM %s' | |
1055 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
1056 | - $path = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $item_id)); | |
1057 | - if ($path) { | |
1058 | - $objPath = $path; | |
1059 | - } else { | |
1060 | - if (!$this->_isValid(array('item', 'inumber', $item_id))) { | |
1061 | - $objPath = _NOT_VALID_ITEM; | |
1062 | - } else { | |
1063 | - $y = $m = $d = $temp = ''; | |
1064 | - $table = sql_table('item'); | |
1065 | - $tque = 'SELECT itime as result FROM %s' | |
1066 | - . ' WHERE inumber = %d'; | |
1067 | - $itime = quickQuery(sprintf($tque ,$table, $item_id)); | |
1068 | - sscanf($itime,'%d-%d-%d %s', $y, $m, $d, $temp); | |
1069 | - $defItem = $this->getOption('customurl_dfitem'); | |
1070 | - $tempParam = array('year' => $Y, | |
1071 | - 'month' => $m, | |
1072 | - 'day' => $d); | |
1073 | - $ikey = TEMPLATE::fill($defItem, $tempParam); | |
1074 | - $ipath = $ikey . '_' . $item_id; | |
1075 | - $query = 'SELECT ititle as result FROM %s' | |
1076 | - . ' WHERE inumber = %d'; | |
1077 | - $iname = quickQuery(sprintf($query, $table, $item_id)); | |
1078 | - $this->RegistPath($item_id, $ipath, $bid, 'item', $iname, TRUE); | |
1079 | - $objPath = $ipath . '.html'; | |
1080 | - } | |
1081 | - } | |
1082 | -// if ($catParam && $subcatid && !$subcatParam) { | |
1083 | -// $params['extra'][$subrequest] = $subcatid; | |
1084 | -// } | |
1085 | - if ($bid != $blogid) { | |
1086 | - $burl = $this->_generateBlogLink($bid); | |
1087 | - } else { | |
1088 | - $burl = $this->_generateBlogLink($blogid); | |
1089 | - } | |
1090 | - break; | |
1091 | - case 'member': | |
1092 | - if (!is_numeric($params['memberid']) || $useCustomURL[$blogid] =='no') { | |
1093 | - return; | |
1094 | - } | |
1095 | - $memberID = intval($params['memberid']); | |
1096 | - $path = $this->getMemberOption($memberID, 'customurl_mname'); | |
1097 | - if ($path) { | |
1098 | - $data['url'] = $this->_generateBlogLink($blogid) . '/' | |
1099 | - . $OP_MemberKey . '/' . $path . '.html'; | |
1100 | - $data['completed'] = TRUE; | |
1101 | - return; | |
1102 | - } else { | |
1103 | - if (!$this->_isValid(array('member', 'mnumber', $memberID))) { | |
1104 | - $data['url'] = $this->_generateBlogLink($blogid) . '/' | |
1105 | - . _NOT_VALID_MEMBER; | |
1106 | - $data['completed'] = TRUE; | |
1107 | - return; | |
1108 | - } else { | |
1109 | - $query = 'SELECT mname as result FROM %s' | |
1110 | - . ' WHERE mnumber = %d'; | |
1111 | - $table = sql_table('member'); | |
1112 | - $mname = quickQuery(sprintf($query, $table, $memberID)); | |
1113 | - $this->RegistPath($memberID, $mname, 0, 'member', $mname, TRUE); | |
1114 | - $data['url'] = $this->_generateBlogLink($blogid) . '/' | |
1115 | - . $OP_MemberKey . '/' . $mname . '.html'; | |
1116 | - $data['completed'] = TRUE; | |
1117 | - return; | |
1118 | - } | |
1119 | - } | |
1120 | - break; | |
1121 | - case 'category': | |
1122 | - if (!is_numeric($params['catid'])) { | |
1123 | - return; | |
1124 | - } | |
1125 | - $cat_id = intval($params['catid']); | |
1126 | - $bid = intval(getBlogidFromCatID($cat_id)); | |
1127 | - if ($useCustomURL[$bid] == 'no') { | |
1128 | - return; | |
1129 | - } | |
1130 | - $objPath = $this->_generateCategoryLink($cat_id); | |
1131 | - if ($bid != $blogid) { | |
1132 | - $burl = $this->_generateBlogLink($bid); | |
1133 | - } | |
1134 | - break; | |
1135 | - case 'archivelist': | |
1136 | - if ($useCustomURL[$blogid] == 'no') { | |
1137 | - return; | |
1138 | - } | |
1139 | - $objPath = $OP_ArchivesKey . '/'; | |
1140 | - $bid = $blogid; | |
1141 | -// if ($catParam && $subcatid && !$subcatParam) { | |
1142 | -// $params['extra'][$subrequest] = $subcatid; | |
1143 | -// } | |
1144 | - break; | |
1145 | - case 'archive': | |
1146 | - if ($useCustomURL[$blogid] == 'no') { | |
1147 | - return; | |
1148 | - } | |
1149 | - sscanf($params['archive'], '%d-%d-%d', $y, $m, $d); | |
1150 | - if ($d) { | |
1151 | - $arc = sprintf('%04d-%02d-%02d', $y, $m, $d); | |
1152 | - } elseif ($m) { | |
1153 | - $arc = sprintf('%04d-%02d', $y, $m); | |
1154 | - } else { | |
1155 | - $arc = sprintf('%04d', $y); | |
1156 | - } | |
1157 | - $objPath = $OP_ArchiveKey . '/' . $arc . '/'; | |
1158 | - $bid = $blogid; | |
1159 | -// if ($catParam && $subcatid && !$subcatParam) { | |
1160 | -// $params['extra'][$subrequest] = $subcatid; | |
1161 | -// } | |
1162 | - break; | |
1163 | - case 'blog': | |
1164 | - if (!is_numeric($params['blogid'])) { | |
1165 | - return; | |
1166 | - } | |
1167 | - $bid = intval($params['blogid']); | |
1168 | - $burl = $this->_generateBlogLink($bid); | |
1169 | - break; | |
1170 | - default: | |
1171 | - return; | |
1172 | - } | |
1173 | - if (!$burl) { | |
1174 | - $burl = $this->_generateBlogLink($blogid); | |
1175 | - } | |
1176 | - | |
1177 | - //NP_Analyze AdminArea check | |
1178 | - $aplugin = $this->pluginCheck('Analyze'); | |
1179 | - if ($aplugin) { | |
1180 | - $aadmin = str_replace('/', '\/', $aplugin->getAdminURL()); | |
1181 | - $p_arr = explode('/', serverVar('SCRIPT_NAME')); | |
1182 | - $tmp = array_pop($p_arr); | |
1183 | - $p_info = implode('\/', $p_arr); | |
1184 | - } | |
1185 | - if ($p_info) { | |
1186 | - if (strpos($aadmin, $p_info)) { | |
1187 | - $CONF['UsingAdminArea'] = TRUE; | |
1188 | - } | |
1189 | - } | |
1190 | - //NP_Analyze AdminArea check end | |
1191 | - | |
1192 | - if (getVar('virtualpath')) { | |
1193 | - $info = preg_replace('|[^a-zA-Z0-9-~+_.?#=&;,/:@%]|i', '', getVar('virtualpath')); | |
1194 | - } elseif (serverVar('PATH_INFO')) { | |
1195 | - $info = preg_replace('|[^a-zA-Z0-9-~+_.?#=&;,/:@%]|i', '', serverVar('PATH_INFO')); | |
1196 | - } | |
1197 | - $v_path = explode('/', $info); | |
1198 | - | |
1199 | - $feedurl = array(); | |
1200 | - $SiteMapP = $this->pluginCheck('GoogleSitemap'); | |
1201 | - if ($SiteMapP) { | |
1202 | - $PcSitemaps = $SiteMapP->getAllBlogOptions('PcSitemap'); | |
1203 | - foreach ($PcSitemaps as $PCsitemap) { | |
1204 | - if ($PCsitemap) { | |
1205 | - $feedurl[] = $PCsitemap; | |
1206 | - } | |
1207 | - } | |
1208 | - $MobSitemaps = $SiteMapP->getAllBlogOptions('MobileSitemap'); | |
1209 | - foreach ($MobSitemaps as $Mobsitemap) { | |
1210 | - if ($Mobsitemap) { | |
1211 | - $feedurl[] = $Mobsitemap; | |
1212 | - } | |
1213 | - } | |
1214 | - } | |
1215 | - $feedurl = array_unique($feedurl); | |
1216 | - $request_path = end($v_path); | |
1217 | - $feeds = in_array($request_path, $feedurl, true); | |
1218 | - | |
1219 | - if (!$feeds && $bid != $blogid && !$CONF['UsingAdminArea']) { | |
1220 | - $params['extra'] = array(); | |
1221 | - } | |
1222 | - if ($objPath || $data['type'] == 'blog') { | |
1223 | - $LinkURI = $this->_addLinkParams($objPath, $params['extra']); | |
1224 | - if ($LinkURI) { | |
1225 | - $data['url'] = $burl . '/' . $LinkURI; | |
1226 | - } else { | |
1227 | - $data['url'] = $burl; | |
1228 | - } | |
1229 | - $arcTmp = (preg_match('/' . $OP_ArchivesKey . '/', $data['url'])); | |
1230 | - $arcsTmp = (preg_match('/' . $OP_ArchiveKey . '/', $data['url'])); | |
1231 | - $isArchives = ($arcTmp || $arcsTmp); | |
1232 | - $isItem = (substr($data['url'], -5, 5) == '.html'); | |
1233 | - $isDirectory = (substr($data['url'], -1) == '/'); | |
1234 | - $puri = parse_url($data['url']); | |
1235 | - if ($isArchives && !$isItem && !$isDirectory && !$puri['query']) { | |
1236 | - $data['url'] .= '/'; | |
1237 | - } | |
1238 | - $data['completed'] = TRUE; | |
1239 | - if (strstr ($data['url'], '//')) { | |
1240 | - $link = preg_replace("/([^:])\/\//", "$1/", $data['url']); | |
1241 | - } | |
1242 | - return $data; | |
1243 | - } | |
1244 | - } | |
1245 | - | |
1246 | - function _createSubCategoryLink($scid) | |
1247 | - { | |
1248 | - $scids = $this->getParents(intval($scid)); | |
1249 | - $subcatids = explode('/', $scids); | |
1250 | - $eachPath = array(); | |
1251 | - foreach ($subcatids as $sid) { | |
1252 | - $subcat_id = intval($sid); | |
1253 | - $query = 'SELECT obj_name as result FROM %s' | |
1254 | - . ' WHERE obj_id = %d AND obj_param = "%s"'; | |
1255 | - $path = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $subcat_id, 'subcategory')); | |
1256 | - if ($path) { | |
1257 | - $eachPath[] = $path; | |
1258 | - } else { | |
1259 | - $tempParam = array('plug_multiple_categories_sub', | |
1260 | - 'scatid', | |
1261 | - $subcat_id); | |
1262 | - if (!$this->_isValid($tempParam)) { | |
1263 | - return $url = _NOT_VALID_SUBCAT; | |
1264 | - } else { | |
1265 | - $scpath = $this->getOption('customurl_dfscat') . '_' . $subcat_id; | |
1266 | - $query = 'SELECT catid as result FROM %s WHERE scatid = %d'; | |
1267 | - $cid= quickQuery(sprintf($query, _C_SUBCAT_TABLE, $subcat_id)); | |
1268 | - if (!$cid) return 'no_such_subcat=' . $subcat_id . '/'; | |
1269 | - $this->RegistPath($subcat_id, $scpath, $cid, 'subcategory', 'subcat_' . $subcat_id, TRUE); | |
1270 | - $eachPath[] = $scpath; | |
1271 | - } | |
1272 | - } | |
1273 | - } | |
1274 | - $subcatPath = @join('/', $eachPath); | |
1275 | - return $subcatPath . '/'; | |
1276 | - } | |
1277 | - | |
1278 | - function getParents($subid) | |
1279 | - { | |
1280 | - $subcat_id = intval($subid); | |
1281 | - $query = 'SELECT scatid, parentid FROM %s WHERE scatid = %d'; | |
1282 | - $res = sql_query(sprintf($query, _C_SUBCAT_TABLE, $subcat_id)); | |
1283 | - list($sid, $parent) = mysql_fetch_row($res); | |
1284 | - if ($parent != 0) { | |
1285 | - $r = $this->getParents($parent) . '/' . $sid; | |
1286 | - } else { | |
1287 | - $r = $sid; | |
1288 | - } | |
1289 | - return $r; | |
1290 | - } | |
1291 | - | |
1292 | - function _generateCategoryLink($cid) | |
1293 | - { | |
1294 | - global $CONF; | |
1295 | - $cat_id = intval($cid); | |
1296 | - $path = $this->getCategoryOption($cat_id, 'customurl_cname'); | |
1297 | - if ($path) { | |
1298 | - return $path . '/'; | |
1299 | - } else { | |
1300 | - if (!$this->_isValid(array('category', 'catid', $cat_id))) { | |
1301 | - return $url = _NOT_VALID_CAT; | |
1302 | - } else { | |
1303 | - $cpath = $this->getOption('customurl_dfcat') . '_' . $cat_id; | |
1304 | - $blog_id = intval(getBlogIDFromCatID($cat_id)); | |
1305 | - $catname = 'catid_' . $cat_id; | |
1306 | - $this->RegistPath($cat_id, $cpath, $blog_id, 'category', $catname, TRUE); | |
1307 | - return $cpath . '/'; | |
1308 | - } | |
1309 | - } | |
1310 | - } | |
1311 | - | |
1312 | - function _generateBlogLink($bid) | |
1313 | - { | |
1314 | - global $manager, $CONF; | |
1315 | - $blog_id = intval($bid); | |
1316 | - if ($this->getBlogOption($blog_id, 'use_customurl') == 'no') { | |
1317 | - $b =& $manager->getBlog($blog_id); | |
1318 | - $burl = $b->getURL(); | |
1319 | - } else { | |
1320 | - if ($blog_id == $CONF['DefaultBlog']) { | |
1321 | - $burl = trim($CONF['IndexURL'], '/'); | |
1322 | - } else { | |
1323 | - $query = 'SELECT burl as result FROM %s WHERE bnumber = %d'; | |
1324 | - $burl = quickQuery(sprintf($query, sql_table('blog'), $blog_id)); | |
1325 | - if ($burl) { | |
1326 | - if (substr($burl, -4, 4) == '.php') { | |
1327 | - $path = $this->getBlogOption($blog_id, 'customurl_bname'); | |
1328 | - if ($path) { | |
1329 | - $burl = $CONF['IndexURL'] . $path; | |
1330 | - } else { | |
1331 | - $query = 'SELECT bshortname as result FROM %s' | |
1332 | - . ' WHERE bnumber = %d'; | |
1333 | - $bpath = quickQuery(sprintf($query, sql_table('blog'), $blog_id)); | |
1334 | - $this->RegistPath($blog_id, $bpath, 0, 'blog', $bpath, TRUE); | |
1335 | - $burl = $CONF['IndexURL'] . $bpath; | |
1336 | - } | |
1337 | - $burl_update = 'UPDATE %s SET burl = "%s" WHERE bnumber = %d'; | |
1338 | - sql_query(sprintf($burl_update, sql_table('blog'), $this->quote_smart($burl), $blog_id)); | |
1339 | - } | |
1340 | - } else { | |
1341 | - $burl = _NOT_VALID_BLOG; | |
1342 | - } | |
1343 | - } | |
1344 | - } | |
1345 | - return trim($burl, '/'); | |
1346 | - } | |
1347 | - | |
1348 | - function _addLinkParams($link, $params) | |
1349 | - { | |
1350 | - global $CONF, $manager, $catid; | |
1351 | - $arcTmp = (preg_match('/' . $this->getOption('customurl_archives') . '/', $link)); | |
1352 | - $arcsTmp = (preg_match('/' . $this->getOption('customurl_archive') . '/', $link)); | |
1353 | - $isArchives = ($arcTmp || $arcsTmp); | |
1354 | - $mcategories = $this->pluginCheck('MultipleCategories'); | |
1355 | - if ($mcategories) { | |
1356 | - if (method_exists($mcategories,"getRequestName")) { | |
1357 | - $mcategories->event_PreSkinParse(array()); | |
1358 | - global $subcatid; | |
1359 | - $subrequest = $mcategories->getRequestName(); | |
1360 | - } else { | |
1361 | - $subrequest = 'subcatid'; | |
1362 | - } | |
1363 | - } | |
1364 | - if (is_array($params)) { | |
1365 | - if ($params['archives']) { | |
1366 | - $linkExtra = $this->getOption('customurl_archives') . '/'; | |
1367 | - unset($params['archives']); | |
1368 | - } elseif ($params['archivelist']) { | |
1369 | - $linkExtra = $this->getOption('customurl_archives') . '/'; | |
1370 | - unset($params['archivelist']); | |
1371 | - } elseif ($params['archive']) { | |
1372 | - sscanf($params['archive'], '%d-%d-%d', $y, $m, $d); | |
1373 | - if ($d) { | |
1374 | - $arc = sprintf('%04d-%02d-%02d', $y, $m, $d); | |
1375 | - } elseif ($m) { | |
1376 | - $arc = sprintf('%04d-%02d', $y, $m); | |
1377 | - } else { | |
1378 | - $arc = sprintf('%04d', $y); | |
1379 | - } | |
1380 | - $linkExtra = $this->getOption('customurl_archive') . '/' . $arc; | |
1381 | - unset($params['archive']); | |
1382 | - } | |
1383 | - $paramlink = array(); | |
1384 | - foreach ($params as $param => $value) { | |
1385 | - switch ($param) { | |
1386 | - case 'catid': | |
1387 | - case $CONF['CategoryKey']: | |
1388 | - $paramlink[] = $this->_generateCategoryLink(intval($value)); | |
1389 | - break; | |
1390 | - case $subrequest: | |
1391 | - if ($mcategories) { | |
1392 | - $paramlink[] = $this->_createSubCategoryLink(intval($value)); | |
1393 | - } | |
1394 | - break; | |
1395 | - default: | |
1396 | - $paramlink[] = $param . '/' . $value . '/'; | |
1397 | - break; | |
1398 | - } | |
1399 | - } | |
1400 | -// $tagparam = (preg_match('/^tag\//', $link)); | |
1401 | - if (substr($link, -5, 5) == '.html' || $isArchives) { | |
1402 | -// $link = $catlink . $sublink . $link; | |
1403 | - $link = implode('', $paramlink) . $link; | |
1404 | - } else { | |
1405 | -// $link .= $catlink . $sublink; | |
1406 | - $link .= implode('', $paramlink); | |
1407 | - } | |
1408 | - } | |
1409 | -// if ($params['tag']) { | |
1410 | -// $link .= 'tag/' . $params['tag'] . '/'; | |
1411 | -// } | |
1412 | - if ($linkExtra) { | |
1413 | - $link .= $linkExtra; | |
1414 | - } | |
1415 | - if (requestVar('skinid')) { | |
1416 | - if (strpos('?', $link)) { | |
1417 | - $link .= '&skinid=' . htmlspecialchars(requestVar('skinid')); | |
1418 | - } else { | |
1419 | - if (substr($link, -1) != '/' && !empty($link)) { | |
1420 | - $link .= '/?skinid=' . htmlspecialchars(requestVar('skinid')); | |
1421 | - } else { | |
1422 | - $link .= '?skinid=' . htmlspecialchars(requestVar('skinid')); | |
1423 | - } | |
1424 | - } | |
1425 | - } | |
1426 | - if (strstr ($link, '//')) { | |
1427 | - $link = preg_replace("/([^:])\/\//", "$1/", $link); | |
1428 | - } | |
1429 | - return $link; | |
1430 | - } | |
1431 | - | |
1432 | - function _convertAlphabettoXHTMLCharacterEntity($text) //add shizuki | |
1433 | - { | |
1434 | - $alphabetKey = array ( | |
1435 | - '/', | |
1436 | - '@', | |
1437 | - 'A', | |
1438 | - 'B', | |
1439 | - 'C', | |
1440 | - 'D', | |
1441 | - 'E', | |
1442 | - 'F', | |
1443 | - 'G', | |
1444 | - 'H', | |
1445 | - 'I', | |
1446 | - 'J', | |
1447 | - 'K', | |
1448 | - 'L', | |
1449 | - 'M', | |
1450 | - 'N', | |
1451 | - 'O', | |
1452 | - 'P', | |
1453 | - 'Q', | |
1454 | - 'R', | |
1455 | - 'S', | |
1456 | - 'T', | |
1457 | - 'U', | |
1458 | - 'V', | |
1459 | - 'W', | |
1460 | - 'X', | |
1461 | - 'Y', | |
1462 | - 'Z', | |
1463 | - 'a', | |
1464 | - 'b', | |
1465 | - 'c', | |
1466 | - 'd', | |
1467 | - 'e', | |
1468 | - 'f', | |
1469 | - 'g', | |
1470 | - 'h', | |
1471 | - 'i', | |
1472 | - 'j', | |
1473 | - 'k', | |
1474 | - 'l', | |
1475 | - 'm', | |
1476 | - 'n', | |
1477 | - 'o', | |
1478 | - 'p', | |
1479 | - 'q', | |
1480 | - 'r', | |
1481 | - 's', | |
1482 | - 't', | |
1483 | - 'u', | |
1484 | - 'v', | |
1485 | - 'w', | |
1486 | - 'x', | |
1487 | - 'y', | |
1488 | - 'z', | |
1489 | - '&&' | |
1490 | - ); | |
1491 | - $alphabetVal = array ( | |
1492 | - '/', | |
1493 | - '@', | |
1494 | - 'A', | |
1495 | - 'B', | |
1496 | - 'C', | |
1497 | - 'D', | |
1498 | - 'E', | |
1499 | - 'F', | |
1500 | - 'G', | |
1501 | - 'H', | |
1502 | - 'I', | |
1503 | - 'J', | |
1504 | - 'K', | |
1505 | - 'L', | |
1506 | - 'M', | |
1507 | - 'N', | |
1508 | - 'O', | |
1509 | - 'P', | |
1510 | - 'Q', | |
1511 | - 'R', | |
1512 | - 'S', | |
1513 | - 'T', | |
1514 | - 'U', | |
1515 | - 'V', | |
1516 | - 'W', | |
1517 | - 'X', | |
1518 | - 'Y', | |
1519 | - 'Z', | |
1520 | - 'a', | |
1521 | - 'b', | |
1522 | - 'c', | |
1523 | - 'd', | |
1524 | - 'e', | |
1525 | - 'f', | |
1526 | - 'g', | |
1527 | - 'h', | |
1528 | - 'i', | |
1529 | - 'j', | |
1530 | - 'k', | |
1531 | - 'l', | |
1532 | - 'm', | |
1533 | - 'n', | |
1534 | - 'o', | |
1535 | - 'p', | |
1536 | - 'q', | |
1537 | - 'r', | |
1538 | - 's', | |
1539 | - 't', | |
1540 | - 'u', | |
1541 | - 'v', | |
1542 | - 'w', | |
1543 | - 'x', | |
1544 | - 'y', | |
1545 | - 'z', | |
1546 | - '&&' | |
1547 | - ); | |
1548 | - $retData = str_replace($alphabetKey, $alphabetVal, $text); | |
1549 | - return $retData; | |
1550 | - } | |
1551 | - | |
1552 | - function doSkinVar($skinType, $link_type = '', $target = '', $title = '') | |
1553 | - { | |
1554 | - global $blogid; | |
1555 | - if ($skinType == 'item' && $link_type == 'trackback') { | |
1556 | - global $itemid, $CONF; | |
1557 | - if ($this->getBlogOption($blogid, 'use_customurl') == 'yes') { | |
1558 | - $que = 'SELECT obj_name as result FROM %s' | |
1559 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
1560 | - $itempath = quickQuery(sprintf($que, _CUSTOMURL_TABLE, $itemid)); | |
1561 | - $uri = $CONF['BlogURL'] . '/trackback/' . $itempath; | |
1562 | -// /item_123.trackback | |
1563 | -// $itempath = substr($itempath, 0, -5) . '.trackback'; | |
1564 | -// $uri = $CONF['BlogURL'] . '/' . $itempath; | |
1565 | - } else { | |
1566 | - $uri = $CONF['ActionURL'] | |
1567 | - . '?action=plugin&name=TrackBack&tb_id=' . $itemid; | |
1568 | - } | |
1569 | - echo $this->_convertAlphabettoXHTMLCharacterEntity($uri); | |
1570 | - return; | |
1571 | - } | |
1572 | - // $data == type / id || name / 'i'd || 'n'ame | |
1573 | - // ex. => [(b)log / blogid [|| shortname / 'i'd || 'n'ame]] | |
1574 | - // (c)at / catid [|| cname / 'i'd || 'n'ame] | |
1575 | - // (s)cat / subcatid [|| sname / 'i'd || 'n'ame] | |
1576 | - // [(i)tem /] itemid [/ 'path'] | |
1577 | - // (m)ember / mnumber [|| mname / 'i'd || 'n'ame] | |
1578 | - // | |
1579 | - // if second param is null, third param is id | |
1580 | - // if param is null, generate blog link | |
1581 | - if (!$link_type) { | |
1582 | - $link_params = '0, b/' . intval($blogid) . '/i,' | |
1583 | - . $target . ',' . $title; | |
1584 | - } else { | |
1585 | - $l_params = explode("/", $link_type); | |
1586 | - if (count($l_params) == 1) { | |
1587 | - $link_params = array(0, 'b/' . intval($link_type) . '/i,' | |
1588 | - . $target . ',' . $title); | |
1589 | - } else { | |
1590 | - $link_params = array(0, | |
1591 | - $link_type . ',' . $target . ',' . $title); | |
1592 | - } | |
1593 | - } | |
1594 | - echo $this->URL_Callback($link_params); | |
1595 | - } | |
1596 | - | |
1597 | - function doTemplateVar(&$item, $link_type = '', $target = '', $title = '') | |
1598 | - { | |
1599 | - $item_id = intval($item->itemid); | |
1600 | - if ($link_type == 'trackback') { | |
1601 | - global $CONF; | |
1602 | - $blog_id = intval(getBlogIDFromItemID($item_id)); | |
1603 | - if ($this->getBlogOption($blog_id, 'use_customurl') == 'yes') { | |
1604 | - $que = 'SELECT obj_name as result FROM %s' | |
1605 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
1606 | - $itempath = quickQuery(sprintf($que, _CUSTOMURL_TABLE, $item_id)); | |
1607 | - $uri = $CONF['BlogURL'] . '/trackback/' . $itempath; | |
1608 | -// /item_123.trackback | |
1609 | -// $itempath = substr($itempath, 0, -5) . '.trackback'; | |
1610 | -// $uri = $CONF['BlogURL'] . '/' . $itempath; | |
1611 | - } else { | |
1612 | - $uri = $CONF['ActionURL'] | |
1613 | - . '?action=plugin&name=TrackBack&tb_id=' . $item_id; | |
1614 | - } | |
1615 | - echo $this->_convertAlphabettoXHTMLCharacterEntity($uri); | |
1616 | - return; | |
1617 | - } | |
1618 | - if (!$link_type) { | |
1619 | - $link_params = array(0, | |
1620 | - 'i/' . $item_id . '/i,' . $target . ',' . $title); | |
1621 | - } elseif ($link_type == 'path') { | |
1622 | - $link_params = array(0, | |
1623 | - 'i/' . $item_id . '/path,' . $target . ',' . $title); | |
1624 | - } else { | |
1625 | - $link_params = array(0, | |
1626 | - $link_type . ',' . $target . ',' . $title); | |
1627 | - } | |
1628 | - echo $this->URL_Callback($link_params); | |
1629 | - } | |
1630 | - | |
1631 | - function URL_Callback($data) | |
1632 | - { | |
1633 | - $l_data = explode(",", $data[1]); | |
1634 | - $l_type = $l_data[0]; | |
1635 | - $target = $l_data[1]; | |
1636 | - $title = $l_data[2]; | |
1637 | - $item_id = intval($this->currentItem->itemid); | |
1638 | - if (!$l_type) { | |
1639 | - $link_params = array ('i', | |
1640 | - $item_id, | |
1641 | - 'i'); | |
1642 | - } else { | |
1643 | - $link_data = explode("/", $l_type); | |
1644 | - if (count($link_data) == 1) { | |
1645 | - $link_params = array ('i', | |
1646 | - intval($l_type), | |
1647 | - 'i'); | |
1648 | - } elseif (count($link_data) == 2) { | |
1649 | - if ($link_data[1] == 'path') { | |
1650 | - $link_params = array ('i', | |
1651 | - $link_data[0], | |
1652 | - 'path'); | |
1653 | - } else { | |
1654 | - $link_params = array ($link_data[0], | |
1655 | - intval($link_data[1]), | |
1656 | - 'i'); | |
1657 | - } | |
1658 | - } else { | |
1659 | - $link_params = array ($link_data[0], | |
1660 | - $link_data[1], | |
1661 | - $link_data[2]); | |
1662 | - } | |
1663 | - } | |
1664 | - $url = $this->_genarateObjectLink($link_params); | |
1665 | - if ($target) { | |
1666 | - if ($title) { | |
1667 | - $ObjLink = '<a href="' . htmlspecialchars($url) . '" ' | |
1668 | - . 'title="' . htmlspecialchars($title) . '">' | |
1669 | - . htmlspecialchars($target) . '</a>'; | |
1670 | - } else { | |
1671 | - $ObjLink = '<a href="' . htmlspecialchars($url) . '" ' | |
1672 | - . 'title="' . htmlspecialchars($target) . '">' | |
1673 | - . htmlspecialchars($target) . '</a>'; | |
1674 | - } | |
1675 | - } else { | |
1676 | - $ObjLink = htmlspecialchars($url); | |
1677 | - } | |
1678 | - return $ObjLink; | |
1679 | - } | |
1680 | - | |
1681 | - function _isValid($data) | |
1682 | - { | |
1683 | - $query = 'SELECT * FROM %s WHERE %s = %d'; | |
1684 | - $data[2] = $this->quote_smart($data[2]); | |
1685 | - $res = sql_query(sprintf($query, sql_table($data[0]), $data[1], $data[2])); | |
1686 | - return (mysql_num_rows($res) != 0); | |
1687 | - } | |
1688 | - | |
1689 | - function _genarateObjectLink($data) | |
1690 | - { | |
1691 | - global $CONF, $manager, $blog; | |
1692 | - $ext = substr(serverVar('REQUEST_URI'), -4); | |
1693 | - if ($ext == '.rdf' || $ext == '.xml') { | |
1694 | - $CONF['URLMode'] = 'pathinfo'; | |
1695 | - } | |
1696 | - if ($CONF['URLMode'] != 'pathinfo') { | |
1697 | - return; | |
1698 | - } | |
1699 | - $query = 'SELECT %s as result FROM %s WHERE %s = "%s"'; | |
1700 | - switch ($data[0]) { | |
1701 | - case 'b': | |
1702 | - if ($data[2] == 'n') { | |
1703 | - $bid = getBlogIDFromName($data[1]); | |
1704 | - } else { | |
1705 | - $bid = $data[1]; | |
1706 | - } | |
1707 | - $blog_id = intval($bid); | |
1708 | - $param = array('blog', | |
1709 | - 'bnumber', | |
1710 | - $blog_id); | |
1711 | - if (!$this->_isValid($param)) { | |
1712 | - $url = _NOT_VALID_BLOG; | |
1713 | - } else { | |
1714 | - $url = $this->_generateBlogLink($blog_id) . '/'; | |
1715 | - } | |
1716 | - break; | |
1717 | - case 'c': | |
1718 | - if ($data[2] == 'n') { | |
1719 | - $cid = getCatIDFromName($data[1]); | |
1720 | - } else { | |
1721 | - $cid = $data[1]; | |
1722 | - } | |
1723 | - $cat_id = intval($cid); | |
1724 | - $param = array('category', | |
1725 | - 'catid', | |
1726 | - $cat_id); | |
1727 | - if (!$this->_isValid($param)) { | |
1728 | - $url = _NOT_VALID_CAT; | |
1729 | - } else { | |
1730 | -// $bid = intval(getBlogIDFromCatID($cat_id)); | |
1731 | -// $blink = $this->_generateBlogLink(intval($bid)); | |
1732 | -// $url = $blink . '/' . $this->_generateCategoryLink($cat_id, ''); | |
1733 | - $url = createCategoryLink($cat_id); | |
1734 | - } | |
1735 | - break; | |
1736 | - case 's': | |
1737 | - $mcategories = $this->pluginCheck('MultipleCategories'); | |
1738 | - if ($mcategories) { | |
1739 | - if (method_exists($mcategories, "getRequestName")) { | |
1740 | - if ($data[2] == 'n') { | |
1741 | - $temp = $this->quote_smart($data[1]); | |
1742 | - $scid = quickQuery(sprintf($query, 'scatid', _C_SUBCAT_TABLE, 'sname', $temp)); | |
1743 | - } else { | |
1744 | - $scid = $data[1]; | |
1745 | - } | |
1746 | - $sub_id = intval($scid); | |
1747 | - $param = array('plug_multiple_categories_sub', | |
1748 | - 'scatid', | |
1749 | - $sub_id); | |
1750 | - if (!$this->_isValid($param)) { | |
1751 | - $url = _NOT_VALID_SUBCAT; | |
1752 | - } else { | |
1753 | - $cid = quickQuery(sprintf($query, 'catid', _C_SUBCAT_TABLE, 'scatid', $sub_id)); | |
1754 | - $cid = intval($cid); | |
1755 | - $subrequest = $mcategories->getRequestName(); | |
1756 | - if (!$subrequest) { | |
1757 | - $subrequest = 'subcatid'; | |
1758 | - } | |
1759 | - $linkParam = array($subrequest => $sub_id); | |
1760 | - $url = createCategoryLink($cid, $linkParam); | |
1761 | - } | |
1762 | - } | |
1763 | - } | |
1764 | - break; | |
1765 | - case 'i': | |
1766 | - $param = array('item', | |
1767 | - 'inumber', | |
1768 | - intval($data[1])); | |
1769 | - if (!$this->_isValid($param)) { | |
1770 | - $url = _NOT_VALID_ITEM; | |
1771 | - } else { | |
1772 | - $blink = $this->_generateBlogLink(getBlogIDFromItemID(intval($data[1]))); | |
1773 | - $i_query = 'SELECT obj_name as result FROM %s' | |
1774 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
1775 | - $path = quickQuery(sprintf($i_query, _CUSTOMURL_TABLE, intval($data[1]))); | |
1776 | - if ($path) { | |
1777 | - if ($data[2] == 'path') { | |
1778 | - $url = $path; | |
1779 | - } else { | |
1780 | - $url = $blink . '/' . $path; | |
1781 | - } | |
1782 | - } else { | |
1783 | - if ($data[2] == 'path') { | |
1784 | - $url = $CONF['ItemKey'] . '/' | |
1785 | - . intval($data[1]); | |
1786 | - } else { | |
1787 | - $url = $blink . '/' . $CONF['ItemKey'] . '/' | |
1788 | - . intval($data[1]); | |
1789 | - } | |
1790 | - } | |
1791 | - } | |
1792 | - break; | |
1793 | - case 'm': | |
1794 | - if ($data[2] == 'n') { | |
1795 | - $data[1] = $this->quote_smart($data[1]); | |
1796 | - $mid = quickQuery(sprintf($query, 'mnumber', sql_table('member'), 'mname', $data[1])); | |
1797 | - } else { | |
1798 | - $mid = $data[1]; | |
1799 | - } | |
1800 | - $member_id = intval($mid); | |
1801 | - $param = array('member', | |
1802 | - 'mnumber', | |
1803 | - $member_id); | |
1804 | - if (!$this->_isValid($param)) { | |
1805 | - $url = _NOT_VALID_MEMBER; | |
1806 | - } else { | |
1807 | - $url = createMemberLink($member_id); | |
1808 | - } | |
1809 | - break; | |
1810 | - } | |
1811 | - return $url; | |
1812 | - } | |
1813 | - | |
1814 | -/* function event_PreSendContentType($data) | |
1815 | - { | |
1816 | - global $blogid, $CONF; | |
1817 | - | |
1818 | - $ext = substr(serverVar('REQUEST_URI'), -4); | |
1819 | - if ($ext == '.rdf' || $ext == '.xml') { | |
1820 | - $p_info = trim(serverVar('PATH_INFO'), '/'); | |
1821 | - $path_arr = explode('/', $p_info); | |
1822 | - switch (end($path_arr)) { | |
1823 | - case 'rss1.xml': | |
1824 | - case 'index.rdf': | |
1825 | - case 'rss2.xml': | |
1826 | - case 'atom.xml': | |
1827 | - $data['contentType'] = 'application/xml'; | |
1828 | - break; | |
1829 | - default: | |
1830 | - break; | |
1831 | - } | |
1832 | - } | |
1833 | - }*/ | |
1834 | - | |
1835 | - function event_InitSkinParse($data) | |
1836 | - { | |
1837 | - global $blogid, $CONF, $manager; | |
1838 | - $feedurl = array( | |
1839 | - 'rss1.xml', | |
1840 | - 'index.rdf', | |
1841 | - 'rss2.xml', | |
1842 | - 'atom.xml', | |
1843 | - ); | |
1844 | - $reqPaths = explode('/', serverVar('PATH_INFO')); | |
1845 | - $reqPath = end($reqPaths); | |
1846 | - $feeds = in_array($reqPath, $feedurl, true); | |
1847 | - if (!$feeds) { | |
1848 | - return; | |
1849 | - } else { | |
1850 | - $p_info = trim(serverVar('PATH_INFO'), '/'); | |
1851 | - $path_arr = explode('/', $p_info); | |
1852 | - switch (end($path_arr)) { | |
1853 | - case 'rss1.xml': | |
1854 | - case 'index.rdf': | |
1855 | - $skinName = 'feeds/rss10'; | |
1856 | - break; | |
1857 | - case 'rss2.xml': | |
1858 | - $skinName = 'feeds/rss20'; | |
1859 | - break; | |
1860 | - case 'atom.xml': | |
1861 | - $skinName = 'feeds/atom'; | |
1862 | - break; | |
1863 | - } | |
1864 | - if (SKIN::exists($skinName)) { | |
1865 | - $skin =& SKIN::createFromName($skinName); | |
1866 | - $data['skin']->SKIN($skin->getID()); | |
1867 | - $skinData =& $data['skin']; | |
1868 | - $pageType = $data['type']; | |
1869 | - if (!$CONF['DisableSite']) { | |
1870 | - ob_start(); | |
1871 | - | |
1872 | - $skinID = $skinData->id; | |
1873 | - $contents = $this->getSkinContent($pageType, $skinID); | |
1874 | - $actions = SKIN::getAllowedActionsForType($pageType); | |
1875 | - $dataArray = array('skin' => &$skinData, | |
1876 | - 'type' => $pageType, | |
1877 | - 'contents' => &$contents); | |
1878 | - $manager->notify('PreSkinParse', $dataArray); | |
1879 | - PARSER::setProperty('IncludeMode', SKIN::getIncludeMode()); | |
1880 | - PARSER::setProperty('IncludePrefix', SKIN::getIncludePrefix()); | |
1881 | - $handler =& new ACTIONS($pageType, $skinData); | |
1882 | - $parser =& new PARSER($actions, $handler); | |
1883 | - $handler->setParser($parser); | |
1884 | - $handler->setSkin($skinData); | |
1885 | - $parser->parse($contents); | |
1886 | - $dataArray = array('skin' => &$skinData, | |
1887 | - 'type' => $pageType); | |
1888 | - $manager->notify('PostSkinParse', $dataArray); | |
1889 | - | |
1890 | - $feed = ob_get_contents(); | |
1891 | - | |
1892 | - ob_end_clean(); | |
1893 | - $eTag = '"' . md5($feed) . '"'; | |
1894 | - header('Etag: ' . $eTag); | |
1895 | - if ($eTag == serverVar('HTTP_IF_NONE_MATCH')) { | |
1896 | - header("HTTP/1.0 304 Not Modified"); | |
1897 | - header('Content-Length: 0'); | |
1898 | - } else { | |
1899 | - $feed = mb_convert_encoding($feed, 'UTF-8', _CHARSET); | |
1900 | - header("Content-Type: application/xml"); | |
1901 | - header('Generator: Nucleus CMS ' . $nucleus['version']); | |
1902 | - // dump feed | |
1903 | - echo $feed; | |
1904 | - } | |
1905 | - } else { | |
1906 | - echo '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . '>'; | |
1907 | -?> | |
1908 | -<rss version="2.0"> | |
1909 | - <channel> | |
1910 | - <title><?php echo htmlspecialchars($CONF['SiteName'])?></title> | |
1911 | - <link><?php echo htmlspecialchars($CONF['IndexURL'])?></link> | |
1912 | - <description></description> | |
1913 | - <docs>http://backend.userland.com/rss</docs> | |
1914 | - </channel> | |
1915 | -</rss> | |
1916 | -<?php | |
1917 | - } | |
1918 | - } | |
1919 | - exit; | |
1920 | - } | |
1921 | - } | |
1922 | - | |
1923 | - function getSkinContent($pageType, $skinID) | |
1924 | - { | |
1925 | - $skinID = intval($skinID); | |
1926 | - $pageType = addslashes($pageType); | |
1927 | - $query = 'SELECT scontent FROM %s WHERE sdesc = %d AND stype = %d'; | |
1928 | - $res = sql_query(sprintf($query, sql_table('skin'), $skinID, $pageType)); | |
1929 | - | |
1930 | - if (mysql_num_rows($res) == 0) | |
1931 | - return ''; | |
1932 | - else | |
1933 | - return mysql_result($res, 0, 0); | |
1934 | - } | |
1935 | - | |
1936 | - | |
1937 | -// merge NP_RightURL | |
1938 | - function event_PreSkinParse($data) | |
1939 | - { | |
1940 | - global $CONF, $manager, $blog, $catid, $itemid, $subcatid; | |
1941 | - global $memberid; | |
1942 | - if (!$blog) { | |
1943 | - $b =& $manager->getBlog($CONF['DefaultBlog']); | |
1944 | - } else { | |
1945 | - $b =& $blog; | |
1946 | - } | |
1947 | - $blogurl = $b->getURL(); | |
1948 | - | |
1949 | - if (!$blogurl) { | |
1950 | - if($blog) { | |
1951 | - $b_tmp =& $manager->getBlog($CONF['DefaultBlog']); | |
1952 | - $blogurl = $b_tmp->getURL(); | |
1953 | - } | |
1954 | - if (!$blogurl) { | |
1955 | - $blogurl = $CONF['IndexURL']; | |
1956 | - if ($CONF['URLMode'] != 'pathinfo'){ | |
1957 | - if ($data['type'] == 'pageparser') { | |
1958 | - $blogurl .= 'index.php'; | |
1959 | - } else { | |
1960 | - $blogurl = $CONF['Self']; | |
1961 | - } | |
1962 | - } | |
1963 | - } | |
1964 | - } | |
1965 | - if ($CONF['URLMode'] == 'pathinfo'){ | |
1966 | - if (substr($blogurl, -1) == '/') { | |
1967 | - $blogurl = substr($blogurl, 0, -1); | |
1968 | - } | |
1969 | - } | |
1970 | - $CONF['BlogURL'] = $blogurl; | |
1971 | - $CONF['ItemURL'] = $blogurl; | |
1972 | - $CONF['CategoryURL'] = $blogurl; | |
1973 | - $CONF['ArchiveURL'] = $blogurl; | |
1974 | - $CONF['ArchiveListURL'] = $blogurl; | |
1975 | - $CONF['SearchURL'] = $blogurl; | |
1976 | -// $CONF['MemberURL'] = $blogurl; | |
1977 | - } | |
1978 | - | |
1979 | - function event_PreItem($data) | |
1980 | - { | |
1981 | - global $CONF, $manager; | |
1982 | - | |
1983 | - $this->currentItem = &$data['item']; | |
1984 | - $pattern = '/<%CustomURL\((.*)\)%>/'; | |
1985 | - $data['item']->body = preg_replace_callback($pattern, array(&$this, 'URL_Callback'), $data['item']->body); | |
1986 | - if ($data['item']->more) { | |
1987 | - $data['item']->more = preg_replace_callback($pattern, array(&$this, 'URL_Callback'), $data['item']->more); | |
1988 | - } | |
1989 | - | |
1990 | - $itemid = intval($data['item']->itemid); | |
1991 | - $itemblog =& $manager->getBlog(getBlogIDFromItemID($itemid)); | |
1992 | - $blogurl = $itemblog->getURL(); | |
1993 | - if (!$blogurl) { | |
1994 | - $b =& $manager->getBlog($CONF['DefaultBlog']); | |
1995 | - if (!($blogurl = $b->getURL())) { | |
1996 | - $blogurl = $CONF['IndexURL']; | |
1997 | - if ($CONF['URLMode'] != 'pathinfo'){ | |
1998 | - if ($data['type'] == 'pageparser') { | |
1999 | - $blogurl .= 'index.php'; | |
2000 | - } else { | |
2001 | - $blogurl = $CONF['Self']; | |
2002 | - } | |
2003 | - } | |
2004 | - } | |
2005 | - } | |
2006 | - if ($CONF['URLMode'] == 'pathinfo'){ | |
2007 | - if (substr($blogurl, -1) == '/') { | |
2008 | - $blogurl = substr($blogurl, 0, -1); | |
2009 | - } | |
2010 | - } | |
2011 | - $CONF['BlogURL'] = $blogurl; | |
2012 | - $CONF['ItemURL'] = $blogurl; | |
2013 | - $CONF['CategoryURL'] = $blogurl; | |
2014 | - $CONF['ArchiveURL'] = $blogurl; | |
2015 | - $CONF['ArchiveListURL'] = $blogurl; | |
2016 | -// $CONF['MemberURL'] = $blogurl; | |
2017 | - } | |
2018 | - | |
2019 | - function event_PostItem($data) | |
2020 | - { | |
2021 | - global $CONF, $manager, $blog; | |
2022 | - if (!$blog) { | |
2023 | - $b =& $manager->getBlog($CONF['DefaultBlog']); | |
2024 | - } else { | |
2025 | - $b =& $blog; | |
2026 | - } | |
2027 | - $blogurl = $b->getURL(); | |
2028 | - if (!$blogurl) { | |
2029 | - if($blog) { | |
2030 | - $b_tmp =& $manager->getBlog($CONF['DefaultBlog']); | |
2031 | - $blogurl = $b_tmp->getURL(); | |
2032 | - } | |
2033 | - if (!$blogurl) { | |
2034 | - $blogurl = $CONF['IndexURL']; | |
2035 | - if ($CONF['URLMode'] != 'pathinfo'){ | |
2036 | - if ($data['type'] == 'pageparser') { | |
2037 | - $blogurl .= 'index.php'; | |
2038 | - } else { | |
2039 | - $blogurl = $CONF['Self']; | |
2040 | - } | |
2041 | - } | |
2042 | - } | |
2043 | - } | |
2044 | - if ($CONF['URLMode'] == 'pathinfo'){ | |
2045 | - if (substr($blogurl, -1) == '/') { | |
2046 | - $blogurl = substr($blogurl, 0, -1); | |
2047 | - } | |
2048 | - } | |
2049 | - $CONF['BlogURL'] = $blogurl; | |
2050 | - $CONF['ItemURL'] = $blogurl; | |
2051 | - $CONF['CategoryURL'] = $blogurl; | |
2052 | - $CONF['ArchiveURL'] = $blogurl; | |
2053 | - $CONF['ArchiveListURL'] = $blogurl; | |
2054 | -// $CONF['MemberURL'] = $CONF['Self']; | |
2055 | - } | |
2056 | -// merge NP_RightURL end | |
2057 | - | |
2058 | - function event_PostDeleteBlog ($data) | |
2059 | - { | |
2060 | - $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2061 | - $pquery = 'DELETE FROM %s WHERE obj_bid = %d AND obj_param= "%s"'; | |
2062 | - $blogid = intval($data['blogid']); | |
2063 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $blogid, 'blog')); | |
2064 | - sql_query(sprintf($pquery, _CUSTOMURL_TABLE, $blogid, 'item')); | |
2065 | - $cnmquery = 'SELECT catid FROM %s WHERE cblog = %d'; | |
2066 | - $table = sql_table('category'); | |
2067 | - $cnm = sql_query(sprintf($cnmquery, $table, $blogid)); | |
2068 | - while ($c = mysql_fetch_object($cnm)) { | |
2069 | - $catid = intval($c->catid); | |
2070 | - sql_query(sprintf($pquery, _CUSTOMURL_TABLE, $catid, 'subcategory')); | |
2071 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $catid, 'category')); | |
2072 | - } | |
2073 | - } | |
2074 | - | |
2075 | - function event_PostDeleteCategory ($data) | |
2076 | - { | |
2077 | - $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2078 | - $squery = 'DELETE FROM %s WHERE obj_bid = %d AND obj_param = "%s"'; | |
2079 | - $catid = intval($data['catid']); | |
2080 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $catid, 'category')); | |
2081 | - sql_query(sprintf($squery, _CUSTOMURL_TABLE, $catid, 'subcategory')); | |
2082 | - } | |
2083 | - | |
2084 | - function event_PostDeleteItem ($data) | |
2085 | - { | |
2086 | - $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2087 | - $itemid = intval($data['itemid']); | |
2088 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $itemid, 'item')); | |
2089 | - } | |
2090 | - | |
2091 | - function event_PostDeleteMember ($data) | |
2092 | - { | |
2093 | - $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2094 | - $memberid = intval($data['member']->id); | |
2095 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $memberid, 'member')); | |
2096 | - } | |
2097 | - | |
2098 | - function event_PostAddBlog ($data) | |
2099 | - { | |
2100 | - $blog_id = intval($data['blog']->blogid); | |
2101 | - $bshortname = $data['blog']->settings['bshortname']; | |
2102 | - $this->RegistPath($blog_id, $bshortname, 0, 'blog', $bshortname, TRUE); | |
2103 | - $this->setBlogOption($blog_id, 'customurl_bname', $bshortname); | |
2104 | - } | |
2105 | - | |
2106 | - function event_PostAddCategory ($data) | |
2107 | - { | |
2108 | - global $CONF; | |
2109 | - $cat_id = intval($data['catid']); | |
2110 | - if (!$data['blog']->blogid) { | |
2111 | - $query = 'SELECT cblog as result FROM %s WHERE catid = %d'; | |
2112 | - $bid = quickQuery(sprintf($query, sql_table('category'), $cat_id)); | |
2113 | - } else { | |
2114 | - $bid = $data['blog']->blogid; | |
2115 | - } | |
2116 | - if (!$data['name']) { | |
2117 | - $query = 'SELECT cname as result FROM %s WHERE catid = %d'; | |
2118 | - $name = quickQuery(sprintf($query, sql_table('category'), $cat_id)); | |
2119 | - } else { | |
2120 | - $name = $data['name']; | |
2121 | - } | |
2122 | - $bid = intval($bid); | |
2123 | - $dfcat = $this->getOption('customurl_dfcat'); | |
2124 | - $catpsth = $dfcat . '_' . $cat_id; | |
2125 | - $this->RegistPath($cat_id, $catpsth, $bid, 'category', $name, TRUE); | |
2126 | - $this->setCategoryOption($cat_id, 'customurl_cname', $catpsth); | |
2127 | - } | |
2128 | - | |
2129 | - function event_PostAddItem ($data) | |
2130 | - { | |
2131 | - $item_id = intval($data['itemid']); | |
2132 | -// $item_id = $data['itemid']; | |
2133 | - $tpath = requestVar('plug_custom_url_path'); | |
2134 | - $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
2135 | - $itime = quickQuery(sprintf($tque, sql_table('item'), $item_id)); | |
2136 | - echo 'itemid='.$item_id.'<br>idate='.$itime; | |
2137 | - $y = $m = $d = $temp = ''; | |
2138 | - sscanf($itime, '%d-%d-%d %s', $y, $m, $d, $temp); | |
2139 | - $param = array ('year' => $y, | |
2140 | - 'month' => $m, | |
2141 | - 'day' => $d); | |
2142 | - $ipath = TEMPLATE::fill($tpath, $param); | |
2143 | - $query = 'SELECT ititle as result FROM %s WHERE inumber = %d'; | |
2144 | - $iname = quickQuery(sprintf($query, sql_table('item'), $item_id)); | |
2145 | - $blog_id = intval(getBlogIDFromItemID($item_id)); | |
2146 | - $this->RegistPath($item_id, $ipath, $blog_id, 'item', $iname, TRUE); | |
2147 | - } | |
2148 | - | |
2149 | - function event_PostRegister ($data) | |
2150 | - { | |
2151 | - $memberID = intval($data['member']->id); | |
2152 | - $dispName = $data['member']->displayname; | |
2153 | - $this->RegistPath($memberID, $dispName, 0, 'member', $dispName, TRUE); | |
2154 | - $this->setMemberOption($memberID, 'customurl_mname', $dispName); | |
2155 | - } | |
2156 | - | |
2157 | - function event_AddItemFormExtras(&$data) | |
2158 | - { | |
2159 | - $this->createItemForm(); | |
2160 | - } | |
2161 | - | |
2162 | - function event_EditItemFormExtras(&$data) | |
2163 | - { | |
2164 | - $this->createItemForm(intval($data['itemid'])); | |
2165 | - } | |
2166 | - | |
2167 | - function event_PostUpdateItem($data) | |
2168 | - { | |
2169 | - $tpath = requestVar('plug_custom_url_path'); | |
2170 | - $item_id = intval($data['itemid']); | |
2171 | - $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
2172 | - $itime = quickQuery(sprintf($tque ,sql_table('item'), $item_id)); | |
2173 | -// $itimestamp = strtotime($itime); | |
2174 | -// $tt = explode(',', date('Y,m,d', $itimestamp)); | |
2175 | - $y = $m = $d = $temp = ''; | |
2176 | - sscanf($itime, '%d-%d-%d %s', $y, $m, $d, $temp); | |
2177 | - $param = array ('year' => $y, | |
2178 | - 'month' => $m, | |
2179 | - 'day' => $d); | |
2180 | - $ipath = TEMPLATE::fill($tpath, $param); | |
2181 | - $query = 'SELECT ititle as result FROM %s WHERE inumber = %d'; | |
2182 | - $iname = quickQuery(sprintf($query, sql_table('item'), $item_id)); | |
2183 | - $blog_id = intval(getBlogIDFromItemID($item_id)); | |
2184 | - $this->RegistPath($item_id, $ipath, $blog_id, 'item', $iname); | |
2185 | - } | |
2186 | - | |
2187 | - function createItemForm($item_id = 0) | |
2188 | - { | |
2189 | - global $CONF; | |
2190 | - if ($item_id) { | |
2191 | - $query = 'SELECT obj_name as result FROM %s' | |
2192 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
2193 | - $item_id = intval($item_id); | |
2194 | - $res = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $item_id)); | |
2195 | - $ipath = substr($res, 0, strlen($res)-5); | |
2196 | - } else { | |
2197 | - $ipath = $this->getOption('customurl_dfitem'); | |
2198 | - } | |
2199 | - echo <<<OUTPUT | |
2200 | -<h3>Custom URL</h3> | |
2201 | -<p> | |
2202 | -<label for="plug_custom_url">Custom Path:</label> | |
2203 | -<input id="plug_custom_url" name="plug_custom_url_path" value="{$ipath}" /> | |
2204 | -</p> | |
2205 | -OUTPUT; | |
2206 | - } | |
2207 | - | |
2208 | - function event_PrePluginOptionsUpdate($data) | |
2209 | - { | |
2210 | - $blog_option = ($data['optionname'] == 'customurl_bname'); | |
2211 | - $cate_option = ($data['optionname'] == 'customurl_cname'); | |
2212 | - $memb_option = ($data['optionname'] == 'customurl_mname'); | |
2213 | - $arch_option = ($data['optionname'] == 'customurl_archive'); | |
2214 | - $arvs_option = ($data['optionname'] == 'customurl_archives'); | |
2215 | - $memd_option = ($data['optionname'] == 'customurl_member'); | |
2216 | - $contextid = intval($data['contextid']); | |
2217 | - $context = $data['context']; | |
2218 | - if ($blog_option || $cate_option || $memb_option) { | |
2219 | - if ($context == 'member' ) { | |
2220 | - $blogid = 0; | |
2221 | - $query = 'SELECT mname as result FROM %s WHERE mnumber = %d'; | |
2222 | - $table = sql_table('member'); | |
2223 | - $name = quickQuery(sprintf($query, $table, $contextid)); | |
2224 | - } elseif (context == 'category') { | |
2225 | - $blogid = getBlogIDFromCatID($contextid); | |
2226 | - $query = 'SELECT cname as result FROM %s WHERE catid = %d'; | |
2227 | - $table = sql_table('category'); | |
2228 | - $name = quickQuery(sprintf($query, $table, $contextid)); | |
2229 | - } else { | |
2230 | - $blogid = 0; | |
2231 | - $query = 'SELECT bname as result FROM %s WHERE bnumber = %d'; | |
2232 | - $table = sql_table('blog'); | |
2233 | - $name = quickQuery(sprintf($query, $table, $contextid)); | |
2234 | - } | |
2235 | - $blogid = intval($blogid); | |
2236 | - $msg = $this->RegistPath($contextid, $data['value'], $blogid, $context, $name); | |
2237 | - if ($msg) { | |
2238 | - $this->error($msg); | |
2239 | - exit; | |
2240 | - } | |
2241 | - } elseif ($arch_option || $arvs_option || $memd_option) { | |
2242 | - if (!ereg("^[-_a-zA-Z0-9]+$", $data['value'])) { | |
2243 | - $name = substr($data['optionname'], 8); | |
2244 | - $msg = array (1, _INVALID_ERROR, $name, _INVALID_MSG); | |
2245 | - $this->error($msg); | |
2246 | - exit; | |
2247 | - } else { | |
2248 | - return; | |
2249 | - } | |
2250 | - } | |
2251 | - return; | |
2252 | - } | |
2253 | - | |
2254 | - function event_PostMoveItem($data) | |
2255 | - { | |
2256 | - $query = 'UPDATE %s SET obj_bid = %d' | |
2257 | - . ' WHERE obj_param = "%s" AND obj_id = %d'; | |
2258 | - $destblogid = intval($data['destblogid']); | |
2259 | - $item_id = intval($data['itemid']); | |
2260 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $destblogid, 'item', $item_id)); | |
2261 | - } | |
2262 | - | |
2263 | - function event_PostMoveCategory($data) | |
2264 | - { | |
2265 | - $query = 'UPDATE %s SET obj_bid = %d' | |
2266 | - . ' WHERE obj_param = "%s" AND obj_id = %d'; | |
2267 | - $destblogid = intval($data['destblog']->blogid); | |
2268 | - $cat_id = intval($data['catid']); | |
2269 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $destblogid, 'category', $cat_id)); | |
2270 | - } | |
2271 | - | |
2272 | - function RegistPath($objID, $path, $bid, $oParam, $name, $new = FALSE ) | |
2273 | - { | |
2274 | - global $CONF; | |
2275 | - switch($oParam) { | |
2276 | - case 'item': | |
2277 | - case 'member': | |
2278 | - if (preg_match('/.html$/', $path)) | |
2279 | - $path = substr($path, 0, -5); | |
2280 | - break; | |
2281 | - case 'blog': | |
2282 | - case 'category': | |
2283 | - case 'subcategory': | |
2284 | - break; | |
2285 | - default : | |
2286 | - return; | |
2287 | - break; | |
2288 | - } | |
2289 | - $bid = intval($bid); | |
2290 | - $objID = intval($objID); | |
2291 | - $name = rawurlencode($name); | |
2292 | - | |
2293 | - if ($new && $oParam == 'item') { | |
2294 | - $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
2295 | - $itime = quickQuery(sprintf($tque ,sql_table('item'), $objID)); | |
2296 | -// $itimestamp = strtotime($itime); | |
2297 | -// $tt = explode(',', date('Y,m,d', $itimestamp)); | |
2298 | - $y = $m = $d = $temp = ''; | |
2299 | - sscanf($itime, '%d-%d-%d %s', $y, $m, $d, $temp); | |
2300 | - $template = $this->getOption('customurl_dfitem'); | |
2301 | - $param = array ('year' => $y, | |
2302 | - 'month' => $m, | |
2303 | - 'day' => $d); | |
2304 | - $ikey = TEMPLATE::fill($template, $param); | |
2305 | - if ($path == $ikey) { | |
2306 | - $path = $ikey . '_' . $objID; | |
2307 | - } | |
2308 | - } elseif (!$new && strlen($path) == 0) { | |
2309 | - $del_que = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2310 | - sql_query(sprintf($del_que, _CUSTOMURL_TABLE, $objID, $oParam)); | |
2311 | - $msg = array (0, _DELETE_PATH, $name, _DELETE_MSG); | |
2312 | - return $msg; | |
2313 | - exit; | |
2314 | - } | |
2315 | - | |
2316 | - $dotslash = array ('.', '/'); | |
2317 | - $path = str_replace ($dotslash, '_', $path); | |
2318 | - if (!ereg("^[-_a-zA-Z0-9]+$", $path)) { | |
2319 | - $msg = array (1, _INVALID_ERROR, $name, _INVALID_MSG); | |
2320 | - return $msg; | |
2321 | - exit; | |
2322 | - } | |
2323 | - | |
2324 | - $tempPath = $path; | |
2325 | - if ($oParam == 'item' || $oParam == 'member') $tempPath .= '.html'; | |
2326 | - $conf_que = 'SELECT obj_id FROM %s' | |
2327 | - . ' WHERE obj_name = "%s"' | |
2328 | - . ' AND obj_bid = %d' | |
2329 | - . ' AND obj_param = "%s"' | |
2330 | - . ' AND obj_id != %d'; | |
2331 | - $res = sql_query(sprintf($conf_que, _CUSTOMURL_TABLE, $tempPath, $bid, $oParam, $objID)); | |
2332 | - if ($res && mysql_num_rows($res)) { | |
2333 | - $msg = array (0, _CONFLICT_ERROR, $name, _CONFLICT_MSG); | |
2334 | - $path .= '_'.$objID; | |
2335 | - } | |
2336 | - if ($oParam == 'category' && !$msg) { | |
2337 | - $conf_cat = 'SELECT obj_id FROM %s WHERE obj_name = "%s"' | |
2338 | - . ' AND obj_param = "blog"'; | |
2339 | - $res = sql_query(sprintf($conf_cat, _CUSTOMURL_TABLE, $tempPath)); | |
2340 | - if ($res && mysql_num_rows($res)) { | |
2341 | - $msg = array (0, _CONFLICT_ERROR, $name, _CONFLICT_MSG); | |
2342 | - $path .= '_'.$objID; | |
2343 | - } | |
2344 | - } | |
2345 | - if ($oParam == 'blog' && !$msg) { | |
2346 | - $conf_blg = 'SELECT obj_id FROM %s WHERE obj_name = "%s"' | |
2347 | - . ' AND obj_param = "category"'; | |
2348 | - $res = sql_query(sprintf($conf_blg, _CUSTOMURL_TABLE, $tempPath)); | |
2349 | - if ($res && mysql_num_rows($res)) { | |
2350 | - $msg = array (0, _CONFLICT_ERROR, $name, _CONFLICT_MSG); | |
2351 | - $path .= '_'.$objID; | |
2352 | - } | |
2353 | - } | |
2354 | - | |
2355 | - $newPath = $path; | |
2356 | - if ($oParam == 'item' || $oParam == 'member') $newPath .= '.html'; | |
2357 | - $query = 'SELECT * FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2358 | - $res = sql_query(sprintf($query, _CUSTOMURL_TABLE, $objID, $oParam)); | |
2359 | - $row = mysql_fetch_object($res); | |
2360 | - $pathID = $row->id; | |
2361 | - if ($pathID) { | |
2362 | - $query = 'UPDATE %s SET obj_name = "%s" WHERE id = %d'; | |
2363 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $newPath, $pathID)); | |
2364 | - } else { | |
2365 | - $query = 'INSERT INTO %s (obj_param, obj_name, obj_id, obj_bid)' | |
2366 | - . ' VALUES ("%s", "%s", %d, %d)'; | |
2367 | - sql_query(sprintf($query, _CUSTOMURL_TABLE, $oParam, $newPath, $objID, $bid)); | |
2368 | - } | |
2369 | - switch($oParam) { | |
2370 | - case 'blog': | |
2371 | - $this->setBlogOption($objID, 'customurl_bname', $path); | |
2372 | - break; | |
2373 | - case 'category': | |
2374 | - $this->setCategoryOption($objID, 'customurl_cname', $path); | |
2375 | - break; | |
2376 | - case 'member': | |
2377 | - $this->setMemberOption($objID, 'customurl_mname', $path); | |
2378 | - break; | |
2379 | - default : | |
2380 | - break; | |
2381 | - } | |
2382 | - return $msg; | |
2383 | - } | |
2384 | - | |
2385 | - function error($msg = '') | |
2386 | - { | |
2387 | - global $admin; | |
2388 | - | |
2389 | - $admin->pagehead(); | |
2390 | - echo $msg[1].' : '.$msg[2].'<br />'; | |
2391 | - echo $msg[3].'<br />'; | |
2392 | - echo '<a href="index.php" onclick="history.back()">'._BACK.'</a>'; | |
2393 | - $admin->pagefoot(); | |
2394 | - return; | |
2395 | - } | |
2396 | - | |
2397 | - function quote_smart($value) | |
2398 | - { | |
2399 | - if (get_magic_quotes_gpc()) $value = stripslashes($value); | |
2400 | - if (!is_numeric($value)) { | |
2401 | - $value = mysql_real_escape_string($value); | |
2402 | - } elseif (is_numeric($value)) { | |
2403 | - $value = intval($value); | |
2404 | - } | |
2405 | - return $value; | |
2406 | - } | |
2407 | -} | |
2408 | -?><?php | |
2409 | - | |
2410 | -if (!function_exists('sql_table')) { | |
2411 | - function sql_table($name) | |
2412 | - { | |
2413 | - return 'nucleus_' . $name; | |
2414 | - } | |
2415 | -} | |
2416 | - | |
2417 | 3 | if (!function_exists('htmlspecialchars_decode')) { |
2418 | 4 | function htmlspecialchars_decode($text) |
2419 | 5 | { |
@@ -2422,13 +8,13 @@ if (!function_exists('htmlspecialchars_decode')) { | ||
2422 | 8 | } |
2423 | 9 | |
2424 | 10 | if (!defined('_CUSTOMURL_TABLE_DEFINED')) { |
2425 | - define('_CUSTOMURL_TABLE_DEFINED', 1); | |
2426 | - define('_CUSTOMURL_TABLE', sql_table('plug_customurl')); | |
2427 | - define('_C_SUBCAT_TABLE', sql_table('plug_multiple_categories_sub')); | |
11 | + define('_CUSTOMURL_TABLE_DEFINED', 1); | |
12 | + define('_CUSTOMURL_TABLE', sql_table('plug_customurl')); | |
13 | + define('_C_SUBCAT_TABLE', sql_table('plug_multiple_categories_sub')); | |
2428 | 14 | } |
2429 | 15 | |
2430 | 16 | class NP_CustomURL extends NucleusPlugin |
2431 | - { | |
17 | +{ | |
2432 | 18 | |
2433 | 19 | function getMinNucleusVersion() |
2434 | 20 | { |
@@ -2447,12 +33,12 @@ class NP_CustomURL extends NucleusPlugin | ||
2447 | 33 | |
2448 | 34 | function getURL() |
2449 | 35 | { |
2450 | - return 'http://shizuki.kinezumi.net/NucleusCMS/Plugins/NP_CustomURL/NP_CustomURL.html'; | |
36 | + return 'http://japan.nucleuscms.org/wiki/plugins:customurl'; | |
2451 | 37 | } |
2452 | 38 | |
2453 | 39 | function getVersion() |
2454 | 40 | { |
2455 | - return '0.3.2c'; | |
41 | + return '0.3.2e'; | |
2456 | 42 | } |
2457 | 43 | |
2458 | 44 | function getDescription() |
@@ -2462,7 +48,7 @@ class NP_CustomURL extends NucleusPlugin | ||
2462 | 48 | |
2463 | 49 | function supportsFeature($what) |
2464 | 50 | { |
2465 | - switch($what) { | |
51 | + switch ($what) { | |
2466 | 52 | case 'SqlTablePrefix': |
2467 | 53 | return 1; |
2468 | 54 | case 'HelpPage': |
@@ -2488,9 +74,9 @@ class NP_CustomURL extends NucleusPlugin | ||
2488 | 74 | array_push( |
2489 | 75 | $data['options'], |
2490 | 76 | array( |
2491 | - 'title' => _ADMIN_TITLE, | |
2492 | - 'url' => $this->getAdminURL(), | |
2493 | - 'tooltip' => _QUICK_TIPS | |
77 | + 'title' => _ADMIN_TITLE, | |
78 | + 'url' => $this->getAdminURL(), | |
79 | + 'tooltip' => _QUICK_TIPS | |
2494 | 80 | ) |
2495 | 81 | ); |
2496 | 82 | } |
@@ -2498,51 +84,37 @@ class NP_CustomURL extends NucleusPlugin | ||
2498 | 84 | function getTableList() |
2499 | 85 | { |
2500 | 86 | return array( |
2501 | - _CUSTOMURL_TABLE | |
2502 | - ); | |
87 | + _CUSTOMURL_TABLE | |
88 | + ); | |
2503 | 89 | } |
2504 | 90 | |
2505 | 91 | function getEventList() |
2506 | 92 | { |
2507 | 93 | return array( |
2508 | - 'QuickMenu', | |
2509 | -// 'AdminPrePageHead', | |
2510 | - 'ParseURL', | |
2511 | - 'GenerateURL', | |
2512 | - 'PostAddBlog', | |
2513 | - 'PostAddItem', | |
2514 | - 'PostUpdateItem', | |
2515 | - 'PostRegister', | |
2516 | - 'PostAddCategory', | |
2517 | - 'PostDeleteBlog', | |
2518 | - 'PostDeleteItem', | |
2519 | - 'PostDeleteMember', | |
2520 | - 'PostDeleteCategory', | |
2521 | - 'PrePluginOptionsUpdate', | |
2522 | - 'PreItem', | |
2523 | - 'PostItem', | |
2524 | - 'PreSkinParse', | |
2525 | - 'AddItemFormExtras', | |
2526 | - 'EditItemFormExtras', | |
2527 | - 'PostMoveCategory', | |
2528 | - 'PostMoveItem', | |
2529 | -// 'PreSendContentType', | |
2530 | - 'InitSkinParse', | |
2531 | - ); | |
94 | + 'QuickMenu', | |
95 | + 'ParseURL', | |
96 | + 'GenerateURL', | |
97 | + 'PostAddBlog', | |
98 | + 'PostAddItem', | |
99 | + 'PostUpdateItem', | |
100 | + 'PostRegister', | |
101 | + 'PostAddCategory', | |
102 | + 'PostDeleteBlog', | |
103 | + 'PostDeleteItem', | |
104 | + 'PostDeleteMember', | |
105 | + 'PostDeleteCategory', | |
106 | + 'PrePluginOptionsUpdate', | |
107 | + 'PreItem', | |
108 | + 'PostItem', | |
109 | + 'PreSkinParse', | |
110 | + 'AddItemFormExtras', | |
111 | + 'EditItemFormExtras', | |
112 | + 'PostMoveCategory', | |
113 | + 'PostMoveItem', | |
114 | + 'InitSkinParse', | |
115 | + ); | |
2532 | 116 | } |
2533 | 117 | |
2534 | -// function event_AdminPrePageHead($data) | |
2535 | -// { | |
2536 | -// if ($data['action'] == 'pluginhelp' && intGetVar('plugid') == $this->getID()) { | |
2537 | -// $data['extrahead'] = '<link rel="stylesheet" title="NP_CustomURL HELP"' | |
2538 | -// . ' type="text/css"' | |
2539 | -// . "\n" | |
2540 | -// . "\t\t\t" | |
2541 | -// . ' href="' . $this->getAdminURL() | |
2542 | -// . 'helpstyle.css" />' . "\n"; | |
2543 | -// } | |
2544 | -// } | |
2545 | - | |
2546 | 118 | function install() |
2547 | 119 | { |
2548 | 120 | global $manager, $CONF; |
@@ -2564,64 +136,70 @@ class NP_CustomURL extends NucleusPlugin | ||
2564 | 136 | } |
2565 | 137 | |
2566 | 138 | //Plugins sort |
2567 | - $myid = intval($this->getID()); | |
2568 | - $res = sql_query('SELECT pid, porder FROM '.sql_table('plugin')); | |
2569 | - while($p = mysql_fetch_array($res)) { | |
2570 | - $updateQuery = 'UPDATE %s SET porder = %d WHERE pid = %d'; | |
2571 | - if (intval($p['pid']) == $myid) { | |
2572 | - sql_query(sprintf($updateQuery, sql_table('plugin'), 1, $myid)); | |
139 | + $plugTable = sql_table('plugin'); | |
140 | + $myid = intval($this->getID()); | |
141 | + $res = sql_query('SELECT pid, porder FROM ' . $plugTable); | |
142 | + while ($p = mysql_fetch_array($res)) { | |
143 | + $updateQuery = 'UPDATE %s ' | |
144 | + . 'SET porder = %d ' | |
145 | + . 'WHERE pid = %d'; | |
146 | + if (($pid = intval($p['pid'])) == $myid) { | |
147 | + $q = sprintf($updateQuery, $plugTable, 1, $myid); | |
148 | + sql_query($q); | |
2573 | 149 | } else { |
2574 | - sql_query(sprintf($updateQuery, sql_table('plugin'), $p['porder']+1, $p['pid'])); | |
150 | + $porder = intval($p['porder']); | |
151 | + $q = sprintf($updateQuery, $plugTable, $porder + 1, $pid); | |
152 | + sql_query($q); | |
2575 | 153 | } |
2576 | 154 | } |
2577 | 155 | |
2578 | 156 | //create plugin's options and set default value |
2579 | - $this->createOption('customurl_archive', _OP_ARCHIVE_DIR_NAME, | |
2580 | - 'text', $CONF['ArchiveKey']); | |
2581 | - $this->createOption('customurl_archives', _OP_ARCHIVES_DIR_NAME, | |
2582 | - 'text', $CONF['ArchivesKey']); | |
2583 | - $this->createOption('customurl_member', _OP_MEMBER_DIR_NAME, | |
2584 | - 'text', $CONF['MemberKey']); | |
2585 | - $this->createOption('customurl_dfitem', _OP_DEF_ITEM_KEY, | |
2586 | - 'text', $CONF['ItemKey']); | |
2587 | - $this->createOption('customurl_dfcat', _OP_DEF_CAT_KEY, | |
2588 | - 'text', $CONF['CategoryKey']); | |
2589 | - $this->createOption('customurl_dfscat', _OP_DEF_SCAT_KEY, | |
2590 | - 'text', 'subcategory'); | |
2591 | - $this->createOption('customurl_tabledel', _OP_TABLE_DELETE, | |
2592 | - 'yesno', 'no'); | |
2593 | - $this->createOption('customurl_quicklink', _OP_QUICK_LINK, | |
2594 | - 'yesno', 'yes'); | |
2595 | - $this->createOption('customurl_notfound', _OP_NOT_FOUND, | |
2596 | - 'select', '404', | |
157 | + $this->createOption('customurl_archive', _OP_ARCHIVE_DIR_NAME, | |
158 | + 'text', $CONF['ArchiveKey']); | |
159 | + $this->createOption('customurl_archives', _OP_ARCHIVES_DIR_NAME, | |
160 | + 'text', $CONF['ArchivesKey']); | |
161 | + $this->createOption('customurl_member', _OP_MEMBER_DIR_NAME, | |
162 | + 'text', $CONF['MemberKey']); | |
163 | + $this->createOption('customurl_dfitem', _OP_DEF_ITEM_KEY, | |
164 | + 'text', $CONF['ItemKey']); | |
165 | + $this->createOption('customurl_dfcat', _OP_DEF_CAT_KEY, | |
166 | + 'text', $CONF['CategoryKey']); | |
167 | + $this->createOption('customurl_dfscat', _OP_DEF_SCAT_KEY, | |
168 | + 'text', 'subcategory'); | |
169 | + $this->createOption('customurl_tabledel', _OP_TABLE_DELETE, | |
170 | + 'yesno', 'no'); | |
171 | + $this->createOption('customurl_quicklink', _OP_QUICK_LINK, | |
172 | + 'yesno', 'yes'); | |
173 | + $this->createOption('customurl_notfound', _OP_NOT_FOUND, | |
174 | + 'select', '404', | |
2597 | 175 | '404 Not Found|404|303 See Other|303'); |
2598 | - $this->createBlogOption( 'use_customurl', _OP_USE_CURL, | |
2599 | - 'yesno', 'yes'); | |
2600 | - $this->createBlogOption( 'redirect_normal', _OP_RED_NORM, | |
2601 | - 'yesno', 'yes'); | |
2602 | - $this->createBlogOption( 'redirect_search', _OP_RED_SEARCH, | |
2603 | - 'yesno', 'yes'); | |
2604 | - $this->createBlogOption( 'customurl_bname', _OP_BLOG_PATH, | |
176 | + $this->createBlogOption( 'use_customurl', _OP_USE_CURL, | |
177 | + 'yesno', 'yes'); | |
178 | + $this->createBlogOption( 'redirect_normal', _OP_RED_NORM, | |
179 | + 'yesno', 'yes'); | |
180 | + $this->createBlogOption( 'redirect_search', _OP_RED_SEARCH, | |
181 | + 'yesno', 'yes'); | |
182 | + $this->createBlogOption( 'customurl_bname', _OP_BLOG_PATH, | |
2605 | 183 | 'text'); |
2606 | -// $this->createItemOption( 'customurl_iname', _OP_ITEM_PATH, | |
2607 | -// 'text', $CONF['ItemKey']); | |
2608 | - $this->createMemberOption( 'customurl_mname', _OP_MEMBER_PATH, | |
184 | +// $this->createItemOption( 'customurl_iname', _OP_ITEM_PATH, | |
185 | +// 'text', $CONF['ItemKey']); | |
186 | + $this->createMemberOption( 'customurl_mname', _OP_MEMBER_PATH, | |
2609 | 187 | 'text'); |
2610 | - $this->createCategoryOption('customurl_cname', _OP_CATEGORY_PATH, | |
188 | + $this->createCategoryOption('customurl_cname', _OP_CATEGORY_PATH, | |
2611 | 189 | 'text'); |
2612 | 190 | |
2613 | 191 | //default archive directory name |
2614 | - $this->setOption('customurl_archive', $CONF['ArchiveKey']); | |
192 | + $this->setOption('customurl_archive', $CONF['ArchiveKey']); | |
2615 | 193 | //default archives directory name |
2616 | - $this->setOption('customurl_archives', $CONF['ArchivesKey']); | |
194 | + $this->setOption('customurl_archives', $CONF['ArchivesKey']); | |
2617 | 195 | //default member directory name |
2618 | - $this->setOption('customurl_member', $CONF['MemberKey']); | |
196 | + $this->setOption('customurl_member', $CONF['MemberKey']); | |
2619 | 197 | //default itemkey_template |
2620 | - $this->setOption('customurl_dfitem', $CONF['ItemKey']); | |
198 | + $this->setOption('customurl_dfitem', $CONF['ItemKey']); | |
2621 | 199 | //default categorykey_template |
2622 | - $this->setOption('customurl_dfcat', $CONF['CategoryKey']); | |
200 | + $this->setOption('customurl_dfcat', $CONF['CategoryKey']); | |
2623 | 201 | //default subcategorykey_template |
2624 | - $this->setOption('customurl_dfscat', 'subcategory'); | |
202 | + $this->setOption('customurl_dfscat', 'subcategory'); | |
2625 | 203 | |
2626 | 204 | //create data table |
2627 | 205 | $sql = 'CREATE TABLE IF NOT EXISTS ' . _CUSTOMURL_TABLE . ' (' |
@@ -2635,76 +213,92 @@ class NP_CustomURL extends NucleusPlugin | ||
2635 | 213 | sql_query($sql); |
2636 | 214 | |
2637 | 215 | //setting default aliases |
2638 | - $this->_createNewPath('blog', 'blog', 'bnumber', 'bshortname'); | |
2639 | - $this->_createNewPath('item', 'item', 'inumber', 'iblog'); | |
2640 | - $this->_createNewPath('category', 'category', 'catid', 'cblog'); | |
2641 | - $this->_createNewPath('member', 'member', 'mnumber', 'mname'); | |
216 | + $this->_createNewPath('blog', 'blog', 'bnumber', 'bshortname'); | |
217 | + $this->_createNewPath('item', 'item', 'inumber', 'iblog'); | |
218 | + $this->_createNewPath('category', 'category', 'catid', 'cblog'); | |
219 | + $this->_createNewPath('member', 'member', 'mnumber', 'mname'); | |
2642 | 220 | |
2643 | 221 | if ($this->pluginCheck('MultipleCategories')) { |
2644 | - $this->_createNewPath('subcategory', 'plug_multiple_categories_sub', 'scatid', 'catid'); | |
222 | + $scatTableName = 'plug_multiple_categories_sub'; | |
223 | + $this->_createNewPath('subcategory', $scatTableName, 'scatid', 'catid'); | |
2645 | 224 | } |
2646 | 225 | |
2647 | 226 | } |
2648 | 227 | |
2649 | 228 | function _createNewPath($type, $n_table, $id, $bids) |
2650 | 229 | { |
2651 | - $tmpTable = sql_table('plug_customurl_temp'); | |
2652 | - $createQuery = 'CREATE TABLE %s SELECT obj_id, obj_param FROM %s' | |
2653 | - . ' WHERE obj_param = "%s"'; | |
230 | + $tmpTable = sql_table('plug_customurl_temp'); | |
231 | + $createQuery = 'CREATE TABLE %s ' | |
232 | + . 'SELECT obj_id, obj_param ' | |
233 | + . 'FROM %s ' | |
234 | + . 'WHERE obj_param = "%s"'; | |
2654 | 235 | sql_query(sprintf($createQuery, $tmpTable, _CUSTOMURL_TABLE, $type)); |
2655 | - $TmpQuery = 'SELECT %s, %s FROM %s LEFT JOIN %s ON %s.%s = %s.obj_id' | |
2656 | - . ' WHERE %s.obj_id is null'; | |
2657 | - $table = sql_table($n_table); | |
2658 | - $temp = sql_query(sprintf($TmpQuery, $id, $bids, $table, $tmpTable, $table, $id, $tmpTable, $tmpTable)); | |
236 | + $TmpQuery = 'SELECT %s, %s ' | |
237 | + . 'FROM %s as ttb' | |
238 | + . 'LEFT JOIN %s as tcu' | |
239 | + . 'ON ttb.%s = tcu.obj_id ' | |
240 | + . 'WHERE tcu.obj_id is null'; | |
241 | + $table = sql_table($n_table); | |
242 | + $TmpQuery = sprintf($TmpQuery, $id, $bids, $table, $tmpTable, $id); | |
243 | + $temp = sql_query($TmpQuery); | |
2659 | 244 | if ($temp) { |
2660 | 245 | while ($row=mysql_fetch_array($temp)) { |
2661 | 246 | switch ($type) { |
2662 | 247 | case 'blog': |
2663 | 248 | //set access by BlogshortName/ |
2664 | 249 | $newPath = $row[$bids]; |
2665 | - $blgid = 0; | |
250 | + $blgid = 0; | |
2666 | 251 | break; |
2667 | 252 | case 'item': |
2668 | 253 | //set access by (itemkey_template)_itemid.html |
2669 | - $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
2670 | - $itime = quickQuery( sprintf($tque ,sql_table('item'), intval($row[$id]) ) ); | |
2671 | - $y = $m = $d = ''; | |
2672 | - sscanf($itime,'%d-%d-%d %s',$y,$m,$d,$temp); | |
2673 | - $ikey = TEMPLATE::fill($this->getOption('customurl_dfitem'), | |
2674 | - array ('year' => $y, | |
2675 | - 'month' => $m, | |
2676 | - 'day' => $d) | |
2677 | - ); | |
254 | + $tque = 'SELECT ' | |
255 | + . 'itime as result ' | |
256 | + . 'FROM %s ' | |
257 | + . 'WHERE inumber = %d'; | |
258 | + $tque = sprintf($tque, $table, intval($row[$id])); | |
259 | + $itime = quickQuery($tque); | |
260 | + $y = $m = $d = $temp = ''; | |
261 | + sscanf($itime, '%d-%d-%d %s', $y, $m, $d, $temp); | |
262 | + $itime = array( | |
263 | + 'year' => $y, | |
264 | + 'month' => $m, | |
265 | + 'day' => $d | |
266 | + ); | |
267 | + $itplt = $this->getOption('customurl_dfitem'); | |
268 | + $ikey = TEMPLATE::fill($itplt, $itime); | |
2678 | 269 | $newPath = $ikey . '_' . $row[$id] . '.html'; |
2679 | - $blgid = $row[$bids]; | |
270 | + $blgid = $row[$bids]; | |
2680 | 271 | break; |
2681 | 272 | case 'category': |
2682 | 273 | //set access by (categorykey_template)_categoryid/ |
2683 | 274 | $newPath = $this->getOption('customurl_dfcat') . '_' . $row[$id]; |
2684 | - $blgid = $row[$bids]; | |
275 | + $blgid = $row[$bids]; | |
2685 | 276 | break; |
2686 | 277 | case 'member': |
2687 | 278 | //set access by loginName.html |
2688 | 279 | $newPath = $row[$bids] . '.html'; |
2689 | - $blgid = 0; | |
280 | + $blgid = 0; | |
2690 | 281 | break; |
2691 | 282 | case 'subcategory': |
2692 | 283 | //set access by (subcategorykey_template)_subcategoryid/ |
2693 | 284 | $newPath = $this->getOption('customurl_dfscat') . '_' . $row[$id]; |
2694 | - $blgid = $row[$bids]; | |
285 | + $blgid = $row[$bids]; | |
2695 | 286 | break; |
2696 | 287 | default: |
2697 | 288 | break; |
2698 | 289 | } |
2699 | - $insertQuery = 'INSERT INTO %s (obj_param, obj_id, obj_name, obj_bid)' | |
2700 | - . ' VALUES ("%s", %d, "%s", %d)'; | |
2701 | - $row[$id] = intval($row[$id]); | |
2702 | - $blgid = intval($blgid); | |
290 | + $insertQuery = 'INSERT INTO %s ' | |
291 | + . '(obj_param, obj_id, obj_name, obj_bid) ' | |
292 | + . 'VALUES ("%s", %d, "%s", %d)'; | |
293 | + $row[$id] = intval($row[$id]); | |
294 | + $blgid = intval($blgid); | |
2703 | 295 | sql_query(sprintf($insertQuery, _CUSTOMURL_TABLE, $type, $row[$id], $newPath, $blgid)); |
2704 | 296 | } |
2705 | 297 | } |
2706 | - $query = 'SELECT obj_id, obj_name FROM %s WHERE obj_param = "%s"'; | |
2707 | - $temp = sql_query(sprintf($query, _CUSTOMURL_TABLE, $type)); | |
298 | + $query = 'SELECT obj_id, obj_name ' | |
299 | + . 'FROM %s ' | |
300 | + . 'WHERE obj_param = "%s"'; | |
301 | + $temp = sql_query(sprintf($query, _CUSTOMURL_TABLE, $type)); | |
2708 | 302 | while ($row = mysql_fetch_array($temp)) { |
2709 | 303 | $name = $row['obj_name']; |
2710 | 304 | $id = intval($row['obj_id']); |
@@ -2778,21 +372,22 @@ class NP_CustomURL extends NucleusPlugin | ||
2778 | 372 | // initialize |
2779 | 373 | $info = $data['info']; |
2780 | 374 | $complete =& $data['complete']; |
2781 | - if ($complete) return; | |
375 | + if ($complete) { | |
376 | + return; | |
377 | + } | |
2782 | 378 | $useCustomURL = $this->getAllBlogOptions('use_customurl'); |
2783 | 379 | |
2784 | 380 | // Use NP_MultipleCategories ? |
2785 | - $mcategories = $this->pluginCheck('MultipleCategories'); | |
381 | + $mcategories = $this->pluginCheck('MultipleCategories'); | |
2786 | 382 | if ($mcategories) { |
2787 | - if (method_exists($mcategories, "getRequestName")) { | |
2788 | - $mcategories->event_PreSkinParse(array()); | |
2789 | - global $subcatid; | |
383 | + $mcategories->event_PreSkinParse(array()); | |
384 | + global $subcatid; | |
385 | + if (method_exists($mcategories, 'getRequestName')) { | |
2790 | 386 | $subrequest = $mcategories->getRequestName(); |
387 | + } else { | |
388 | + $subrequest = 'subcatid'; | |
2791 | 389 | } |
2792 | 390 | } |
2793 | - if (!$subrequest) { | |
2794 | - $subrequest = 'subcatid'; | |
2795 | - } | |
2796 | 391 | |
2797 | 392 | // initialize and sanitize '$blogid' |
2798 | 393 | if (!$blogid) { |
@@ -2828,7 +423,7 @@ class NP_CustomURL extends NucleusPlugin | ||
2828 | 423 | } |
2829 | 424 | |
2830 | 425 | // Sanitize 'PATH_INFO' |
2831 | - $info = trim($info, '/'); | |
426 | + $info = trim($info, '/'); | |
2832 | 427 | $v_path = explode("/", $info); |
2833 | 428 | foreach($v_path as $key => $value) { |
2834 | 429 | $value = urlencode($value); |
@@ -2842,9 +437,9 @@ class NP_CustomURL extends NucleusPlugin | ||
2842 | 437 | $HTTP_SERVER_VARS['PATH_INFO'] = implode('/', $v_path); |
2843 | 438 | |
2844 | 439 | // Admin area check |
2845 | - $tmpURL = sprintf("%s%s%s", "http://", serverVar("HTTP_HOST"), serverVar("SCRIPT_NAME")); | |
2846 | - $uri = str_replace('/', '\/', $tmpURL); | |
2847 | - $plug_url = str_replace('/', '\/', $CONF['PluginURL']); | |
440 | + $tmpURL = sprintf("%s%s%s", "http://", serverVar("HTTP_HOST"), serverVar("SCRIPT_NAME")); | |
441 | + $uri = str_replace('/', '\/', $tmpURL); | |
442 | + $plug_url = str_replace('/', '\/', $CONF['PluginURL']); | |
2848 | 443 | $u_plugAction = (getVar('action') == 'plugin' && getVar('name')); |
2849 | 444 | if (strpos($uri, $plug_url) === 0 || $u_plugAction) { |
2850 | 445 | $UsingPlugAdmin = TRUE; |
@@ -2860,15 +455,15 @@ class NP_CustomURL extends NucleusPlugin | ||
2860 | 455 | $redirectSerch = ($this->getBlogOption($blogid, 'redirect_search') == 'yes'); |
2861 | 456 | if ($redirectSerch) { |
2862 | 457 | if ($search_q) { |
2863 | - $que_str = getVar('query'); | |
2864 | - $que_str = htmlspecialchars($que_str); | |
2865 | - $que_str = mb_eregi_replace('/', 'ssslllaaassshhh', $que_str); | |
2866 | - $que_str = mb_eregi_replace("'", 'qqquuuooottt', $que_str); | |
2867 | - $que_str = mb_eregi_replace('&', 'aaammmppp', $que_str); | |
2868 | - $que_str = urlencode($que_str); | |
458 | + $que_str = getVar('query'); | |
459 | + $que_str = htmlspecialchars($que_str); | |
460 | + $que_str = mb_eregi_replace('/', 'ssslllaaassshhh', $que_str); | |
461 | + $que_str = mb_eregi_replace("'", 'qqquuuooottt', $que_str); | |
462 | + $que_str = mb_eregi_replace('&', 'aaammmppp', $que_str); | |
463 | + $que_str = urlencode($que_str); | |
2869 | 464 | $search_path = '/search/' . $que_str; |
2870 | - $b_url = createBlogidLink($blogid); | |
2871 | - $redurl = sprintf("%s%s", $b_url, $search_path); | |
465 | + $b_url = createBlogidLink($blogid); | |
466 | + $redurl = sprintf("%s%s", $b_url, $search_path); | |
2872 | 467 | redirect($redurl); // 302 Moved temporary |
2873 | 468 | exit; |
2874 | 469 | } |
@@ -2878,12 +473,12 @@ class NP_CustomURL extends NucleusPlugin | ||
2878 | 473 | } |
2879 | 474 | |
2880 | 475 | // redirection nomal URL to FancyURL |
2881 | - $temp_req = explode('?', serverVar('REQUEST_URI')); | |
2882 | - $reqPath = trim(end($temp_req), '/'); | |
2883 | - $indexrdf = ($reqPath == 'xml-rss1.php'); | |
2884 | - $atomfeed = ($reqPath == 'atom.php'); | |
2885 | - $rss2feed = ($reqPath == 'xml-rss2.php'); | |
2886 | - $feeds = ($indexrdf || $atomfeed || $rss2feed); | |
476 | + $temp_req = explode('?', serverVar('REQUEST_URI')); | |
477 | + $reqPath = trim(end($temp_req), '/'); | |
478 | + $indexrdf = ($reqPath == 'xml-rss1.php'); | |
479 | + $atomfeed = ($reqPath == 'atom.php'); | |
480 | + $rss2feed = ($reqPath == 'xml-rss2.php'); | |
481 | + $feeds = ($indexrdf || $atomfeed || $rss2feed); | |
2887 | 482 | $redirectNormal = ($this->getBlogOption($blogid, 'redirect_normal') == 'yes'); |
2888 | 483 | if ($redirectNormal && serverVar('QUERY_STRING') && !$feeds && !$exLink) { |
2889 | 484 | $temp = explode('&', serverVar('QUERY_STRING')); |
@@ -2937,14 +532,14 @@ class NP_CustomURL extends NucleusPlugin | ||
2937 | 532 | } |
2938 | 533 | } |
2939 | 534 | if (reset($p_arr)) { |
2940 | - $b_url = createBlogidLink($blogid); | |
535 | + $b_url = createBlogidLink($blogid); | |
2941 | 536 | $red_path = '/' . implode('/', $p_arr); |
2942 | 537 | if (substr($b_url, -1) == '/') { |
2943 | 538 | $b_url = rtrim($b_url, '/'); |
2944 | 539 | } |
2945 | 540 | $redurl = sprintf("%s%s", $b_url, $red_path); |
2946 | 541 | // HTTP status 301 "Moved Permanentry" |
2947 | - header( "HTTP/1.1 301 Moved Permanently" ); | |
542 | + header('HTTP/1.1 301 Moved Permanently'); | |
2948 | 543 | header('Location: ' . $redurl); |
2949 | 544 | exit; |
2950 | 545 | } |
@@ -2975,9 +570,9 @@ class NP_CustomURL extends NucleusPlugin | ||
2975 | 570 | // decode unofficial Page switch '/page_2.html' |
2976 | 571 | foreach($v_path as $pathName) { |
2977 | 572 | if (preg_match('/^page_/', $pathName)) { |
2978 | - $temp_info = explode('page_', $pathName); | |
573 | + $temp_info = explode('page_', $pathName); | |
2979 | 574 | $_GET['page'] = intval($temp_info[1]); |
2980 | - $page = array_pop($v_path); | |
575 | + $page = array_pop($v_path); | |
2981 | 576 | } |
2982 | 577 | } |
2983 | 578 |
@@ -2986,7 +581,7 @@ class NP_CustomURL extends NucleusPlugin | ||
2986 | 581 | if (substr($tail, -10, 10) == '.trackback') { |
2987 | 582 | $v_pathName = substr($tail, 0, -10); |
2988 | 583 | // echo $v_pathName; |
2989 | - if (is_numeric($v_pathName)) { | |
584 | + if (is_numeric($v_pathName) || substr($v_pathName, -5) == '.html') { | |
2990 | 585 | $this->_trackback($blogid, $v_pathName); |
2991 | 586 | } else { |
2992 | 587 | $this->_trackback($blogid, $v_pathName . '.html'); |
@@ -3000,15 +595,15 @@ class NP_CustomURL extends NucleusPlugin | ||
3000 | 595 | $bLink = TRUE; |
3001 | 596 | } |
3002 | 597 | $linkObj = array ( |
3003 | - 'bid' => 0, | |
3004 | - 'name' => reset($v_path), | |
3005 | - 'linkparam' => 'blog' | |
3006 | - ); | |
598 | + 'bid' => 0, | |
599 | + 'name' => reset($v_path), | |
600 | + 'linkparam' => 'blog' | |
601 | + ); | |
3007 | 602 | $blog_id = $this->getRequestPathInfo($linkObj); |
3008 | 603 | if ($blog_id) { |
3009 | 604 | $blogid = $blog_id; |
3010 | - $trush = array_shift($v_path); | |
3011 | - $bLink = TURE; | |
605 | + $trush = array_shift($v_path); | |
606 | + $bLink = TURE; | |
3012 | 607 | } |
3013 | 608 | if ($useCustomURL[$blogid] == 'no') { |
3014 | 609 | return; |
@@ -3022,7 +617,7 @@ class NP_CustomURL extends NucleusPlugin | ||
3022 | 617 | if (isset($v_path[$i]) && is_numeric($v_path[$i])) { |
3023 | 618 | if ($useCustomURL[intval($v_path[$i])] != 'yes') { |
3024 | 619 | $blogid = intval($v_path[$i]); |
3025 | - $bLink = TRUE; | |
620 | + $bLink = TRUE; | |
3026 | 621 | } else { |
3027 | 622 | $redURI = createBlogidLink(intval($v_path[$i])); |
3028 | 623 | } |
@@ -3033,7 +628,7 @@ class NP_CustomURL extends NucleusPlugin | ||
3033 | 628 | if (isset($v_path[$i]) && is_numeric($v_path[$i])) { |
3034 | 629 | if ($useCustomURL[$blogid] != 'yes') { |
3035 | 630 | $itemid = intval($v_path[$i]); |
3036 | - $iLink = TRUE; | |
631 | + $iLink = TRUE; | |
3037 | 632 | } else { |
3038 | 633 | $redURI = createItemLink(intval($v_path[$i])); |
3039 | 634 | } |
@@ -3044,8 +639,8 @@ class NP_CustomURL extends NucleusPlugin | ||
3044 | 639 | case 'catid': |
3045 | 640 | if (isset($v_path[$i]) && is_numeric($v_path[$i])) { |
3046 | 641 | if ($useCustomURL[$blogid] != 'yes') { |
3047 | - $catid = intval($v_path[$i]); | |
3048 | - $cLink = TRUE; | |
642 | + $catid = intval($v_path[$i]); | |
643 | + $cLink = TRUE; | |
3049 | 644 | } else { |
3050 | 645 | $redURI = createCategoryLink(intval($v_path[$i])); |
3051 | 646 | } |
@@ -3057,14 +652,14 @@ class NP_CustomURL extends NucleusPlugin | ||
3057 | 652 | $subCat = (isset($v_path[$i]) && is_numeric($v_path[$i])); |
3058 | 653 | if ($mcategories && $subCat && $i >= 3 && is_numeric($v_path[$c])) { |
3059 | 654 | if ($useCustomURL[$blogid] != 'yes') { |
3060 | - $subcatid = intval($v_path[$i]); | |
3061 | - $catid = intval($v_path[$c]); | |
3062 | - $cLink = TRUE; | |
655 | + $subcatid = intval($v_path[$i]); | |
656 | + $catid = intval($v_path[$c]); | |
657 | + $cLink = TRUE; | |
3063 | 658 | } else { |
3064 | 659 | $subcat_id = intval($v_path[$i]); |
3065 | 660 | $catid = intval($v_path[$c]); |
3066 | 661 | $linkParam = array($subrequest => $subcat_id); |
3067 | - $redURI = createCategoryLink($catid, $linkParam); | |
662 | + $redURI = createCategoryLink($catid, $linkParam); | |
3068 | 663 | } |
3069 | 664 | } |
3070 | 665 | break; |
@@ -3075,18 +670,18 @@ class NP_CustomURL extends NucleusPlugin | ||
3075 | 670 | if (isset($v_path[$i]) && is_numeric($v_path[$i])) { |
3076 | 671 | if ($useCustomURL[intval($v_path[$i])] != 'yes') { |
3077 | 672 | $archivelist = intval($v_path[$i]); |
3078 | - $blogid = $archivelist; | |
3079 | - $exLink = TRUE; | |
673 | + $blogid = $archivelist; | |
674 | + $exLink = TRUE; | |
3080 | 675 | } else { |
3081 | - $redURI = createArchiveListLink(intval($v_path[$i])); | |
676 | + $redURI = createArchiveListLink(intval($v_path[$i])); | |
3082 | 677 | } |
3083 | 678 | // Customized URL |
3084 | 679 | } elseif (isset($v_path[$i])) { |
3085 | 680 | $archivelist = $blogid; |
3086 | - $redURI = createArchiveListLink($archivelist); | |
681 | + $redURI = createArchiveListLink($archivelist); | |
3087 | 682 | } else { |
3088 | 683 | $archivelist = $blogid; |
3089 | - $exLink = TRUE; | |
684 | + $exLink = TRUE; | |
3090 | 685 | } |
3091 | 686 | break; |
3092 | 687 | // for archive |
@@ -3111,9 +706,9 @@ class NP_CustomURL extends NucleusPlugin | ||
3111 | 706 | if (!empty($d)) { |
3112 | 707 | $archive = sprintf('%04d-%02d-%02d', $y, $m, $d); |
3113 | 708 | } elseif (!empty($m)) { |
3114 | - $archive = sprintf('%04d-%02d', $y, $m); | |
709 | + $archive = sprintf('%04d-%02d', $y, $m); | |
3115 | 710 | } else { |
3116 | - $archive = sprintf('%04d', $y); | |
711 | + $archive = sprintf('%04d', $y); | |
3117 | 712 | } |
3118 | 713 | if ($useCustomURL[intval($v_path[$i])] != 'yes') { |
3119 | 714 | $blogid = intval($v_path[$i]); |
@@ -3126,12 +721,12 @@ class NP_CustomURL extends NucleusPlugin | ||
3126 | 721 | // } elseif ($darc || $marc || $yarc) { |
3127 | 722 | } elseif ($carc) { |
3128 | 723 | sscanf($v_path[$i], '%d-%d-%d', $y, $m, $d); |
3129 | - if (isset($d)) { | |
724 | + if (!empty($d)) { | |
3130 | 725 | $archive = sprintf('%04d-%02d-%02d', $y, $m, $d); |
3131 | 726 | } elseif (!empty($m)) { |
3132 | - $archive = sprintf('%04d-%02d', $y, $m); | |
727 | + $archive = sprintf('%04d-%02d', $y, $m); | |
3133 | 728 | } else { |
3134 | - $archive = sprintf('%04d', $y); | |
729 | + $archive = sprintf('%04d', $y); | |
3135 | 730 | } |
3136 | 731 | $exLink = TRUE; |
3137 | 732 | } else { |
@@ -3147,12 +742,14 @@ class NP_CustomURL extends NucleusPlugin | ||
3147 | 742 | // Customized URL |
3148 | 743 | $customMemberURL = (substr($v_path[$i], -5, 5) == '.html'); |
3149 | 744 | if (isset($v_path[$i]) && $customMemberURL) { |
3150 | - $memberInfo = array('linkparam' => 'member', | |
3151 | - 'bid' => 0, | |
3152 | - 'name' => $v_path[$i]); | |
3153 | - $member_id = $this->getRequestPathInfo($memberInfo); | |
3154 | - $memberid = intval($member_id); | |
3155 | - $exLink = TRUE; | |
745 | + $memberInfo = array( | |
746 | + 'linkparam' => 'member', | |
747 | + 'bid' => 0, | |
748 | + 'name' => $v_path[$i] | |
749 | + ); | |
750 | + $member_id = $this->getRequestPathInfo($memberInfo); | |
751 | + $memberid = intval($member_id); | |
752 | + $exLink = TRUE; | |
3156 | 753 | // FancyURL |
3157 | 754 | } elseif (isset($v_path[$i]) && is_numeric($v_path[$i])) { |
3158 | 755 | if ($useCustomURL[$blogid] != 'yes') { |
@@ -3169,7 +766,7 @@ class NP_CustomURL extends NucleusPlugin | ||
3169 | 766 | case 'tag': |
3170 | 767 | if (isset($v_path[$i]) && is_string($v_path[$i])) { |
3171 | 768 | $_REQUEST['tag'] = $v_path[$i]; |
3172 | - $exLink = TRUE; | |
769 | + $exLink = TRUE; | |
3173 | 770 | } |
3174 | 771 | break; |
3175 | 772 | // for ExtraSkinJP |
@@ -3196,21 +793,21 @@ class NP_CustomURL extends NucleusPlugin | ||
3196 | 793 | case 'search': |
3197 | 794 | $redirectSerch = ($this->getBlogOption($blogid, 'redirect_search') == 'yes'); |
3198 | 795 | if ($redirectSerch) { |
3199 | - $que_str = urldecode($v_path[$i]); | |
3200 | - $que_str = mb_eregi_replace('ssslllaaassshhh', '/', $que_str); | |
3201 | - $que_str = mb_eregi_replace('qqquuuooottt', "'", $que_str); | |
3202 | - $que_str = mb_eregi_replace('aaammmppp', '&', $que_str); | |
3203 | - $que_str = htmlspecialchars_decode($que_str); | |
796 | + $que_str = urldecode($v_path[$i]); | |
797 | + $que_str = mb_eregi_replace('ssslllaaassshhh', '/', $que_str); | |
798 | + $que_str = mb_eregi_replace('qqquuuooottt', "'", $que_str); | |
799 | + $que_str = mb_eregi_replace('aaammmppp', '&', $que_str); | |
800 | + $que_str = htmlspecialchars_decode($que_str); | |
3204 | 801 | $_GET['query'] = $que_str; |
3205 | - $query = $que_str; | |
3206 | - $exLink = TRUE; | |
802 | + $query = $que_str; | |
803 | + $exLink = TRUE; | |
3207 | 804 | } |
3208 | 805 | break; |
3209 | 806 | // for pageswitch |
3210 | 807 | case 'page': |
3211 | 808 | if (isset($v_path[$i]) && is_numeric($v_path[$i])) { |
3212 | 809 | $_GET['page'] = intval($v_path[$i]); |
3213 | - $exLink = TRUE; | |
810 | + $exLink = TRUE; | |
3214 | 811 | } |
3215 | 812 | break; |
3216 | 813 | // for tDiarySkin |
@@ -3219,11 +816,8 @@ class NP_CustomURL extends NucleusPlugin | ||
3219 | 816 | case 'monthlimit': |
3220 | 817 | $tDiaryPlugin = $this->pluginCheck('tDiarySkin'); |
3221 | 818 | if ($tDiaryPlugin && isset($v_path[$i])) { |
3222 | -// sscanf($v_path[$i], '%d-%d', $m, $d); | |
3223 | -// $linkDate = sprintf('%02d-%02d', $m, $d); | |
3224 | -// $_GET['linkdate'] = $linkDate; | |
3225 | 819 | $_GET[$pathName] = $v_path[$i]; |
3226 | - $exLink = TRUE; | |
820 | + $exLink = TRUE; | |
3227 | 821 | } |
3228 | 822 | break; |
3229 | 823 | // for trackback |
@@ -3237,15 +831,16 @@ class NP_CustomURL extends NucleusPlugin | ||
3237 | 831 | // decode Customized URL |
3238 | 832 | default: |
3239 | 833 | // initialyze |
3240 | - $linkObj = array ('bid' => $blogid, | |
834 | + $linkObj = array ( | |
835 | + 'bid' => $blogid, | |
3241 | 836 | 'name' => $pathName |
3242 | 837 | ); |
3243 | - $comp = FALSE; | |
838 | + $comp = FALSE; | |
3244 | 839 | $isItem = (substr($pathName, -5) == '.html'); |
3245 | 840 | // category ? |
3246 | 841 | if (!$comp && !$cLink && !$iLink && !$isItem) { |
3247 | 842 | $linkObj['linkparam'] = 'category'; |
3248 | - $cat_id = $this->getRequestPathInfo($linkObj); | |
843 | + $cat_id = $this->getRequestPathInfo($linkObj); | |
3249 | 844 | if (!empty($cat_id)) { |
3250 | 845 | $catid = intval($cat_id); |
3251 | 846 | $cLink = TURE; |
@@ -3256,18 +851,18 @@ class NP_CustomURL extends NucleusPlugin | ||
3256 | 851 | if (!$comp && $cLink && !$iLink && $mcategories && !$isItem) { |
3257 | 852 | $linkObj['linkparam'] = 'subcategory'; |
3258 | 853 | $linkObj['bid'] = $catid; |
3259 | - $subcat_id = $this->getRequestPathInfo($linkObj); | |
854 | + $subcat_id = $this->getRequestPathInfo($linkObj); | |
3260 | 855 | if (!empty($subcat_id)) { |
3261 | 856 | $_REQUEST[$subrequest] = intval($subcat_id); |
3262 | - $subcatid = intval($subcat_id); | |
3263 | - $sc = $i; | |
3264 | - $comp = TRUE; | |
857 | + $subcatid = intval($subcat_id); | |
858 | + $sc = $i; | |
859 | + $comp = TRUE; | |
3265 | 860 | } |
3266 | 861 | } |
3267 | 862 | // item ? |
3268 | 863 | if ($isItem) { |
3269 | 864 | $linkObj['linkparam'] = 'item'; |
3270 | - $item_id = $this->getRequestPathInfo($linkObj); | |
865 | + $item_id = $this->getRequestPathInfo($linkObj); | |
3271 | 866 | if (!empty($item_id)) { |
3272 | 867 | $itemid = intval($item_id); |
3273 | 868 | $iLink = TRUE; |
@@ -3290,10 +885,10 @@ class NP_CustomURL extends NucleusPlugin | ||
3290 | 885 | } |
3291 | 886 | |
3292 | 887 | $feedurl = array( |
3293 | - 'rss1.xml', | |
3294 | - 'index.rdf', | |
3295 | - 'rss2.xml', | |
3296 | - 'atom.xml', | |
888 | + 'rss1.xml', | |
889 | + 'index.rdf', | |
890 | + 'rss2.xml', | |
891 | + 'atom.xml', | |
3297 | 892 | ); |
3298 | 893 | $siteMapPlugin = $this->pluginCheck('GoogleSitemap'); |
3299 | 894 | if ($siteMapPlugin) { |
@@ -3310,9 +905,9 @@ class NP_CustomURL extends NucleusPlugin | ||
3310 | 905 | } |
3311 | 906 | } |
3312 | 907 | } |
3313 | - $feedurl = array_unique($feedurl); | |
908 | + $feedurl = array_unique($feedurl); | |
3314 | 909 | $request_path = end($v_path); |
3315 | - $feeds = in_array($request_path, $feedurl, true); | |
910 | + $feeds = in_array($request_path, $feedurl, true); | |
3316 | 911 | |
3317 | 912 | // finish decode |
3318 | 913 | if (!$exLink && !$feeds) { |
@@ -3320,17 +915,21 @@ class NP_CustomURL extends NucleusPlugin | ||
3320 | 915 | if (substr(end($v_path), -5) == '.html' && !$iLink) { |
3321 | 916 | $notFound = TRUE; |
3322 | 917 | if (!empty($subcatid)) { |
3323 | - $linkParam = array($subrequest => $subcatid); | |
3324 | - $uri = createCategoryLink($catid, $linkParam); | |
918 | + $linkParam = array( | |
919 | + $subrequest => $subcatid | |
920 | + ); | |
921 | + $uri = createCategoryLink($catid, $linkParam); | |
3325 | 922 | } elseif (!empty($catid)) { |
3326 | 923 | $uri = createCategoryLink($catid); |
3327 | 924 | } else { |
3328 | 925 | $uri = createBlogidLink($blogid); |
3329 | 926 | } |
3330 | 927 | } elseif (count($v_path) > $sc && !empty($subcatid) && !$iLink) { |
3331 | - $notFound = TRUE; | |
3332 | - $linkParam = array($subrequest => $subcatid); | |
3333 | - $uri = createCategoryLink($catid, $linkParam); | |
928 | + $notFound = TRUE; | |
929 | + $linkParam = array( | |
930 | + $subrequest => $subcatid | |
931 | + ); | |
932 | + $uri = createCategoryLink($catid, $linkParam); | |
3334 | 933 | } elseif (count($v_path) >= 2 && !$subcatid && !$iLink) { |
3335 | 934 | $notFound = TRUE; |
3336 | 935 | if (isset($catid)) { |
@@ -3340,24 +939,26 @@ class NP_CustomURL extends NucleusPlugin | ||
3340 | 939 | } |
3341 | 940 | } elseif (reset($v_path) && !$catid && !$subcatid && !$iLink) { |
3342 | 941 | $notFound = TRUE; |
3343 | - $uri = createBlogidLink($blogid); | |
942 | + $uri = createBlogidLink($blogid); | |
3344 | 943 | } else { |
3345 | 944 | // Found |
3346 | 945 | // setting $CONF['Self'] for other plugins |
3347 | - $uri = createBlogidLink($blogid); | |
946 | + $uri = createBlogidLink($blogid); | |
3348 | 947 | $CONF['Self'] = rtrim($uri, '/'); |
3349 | - $complete = TRUE; | |
948 | + $complete = TRUE; | |
3350 | 949 | return ; |
3351 | 950 | } |
3352 | 951 | } else { |
3353 | - $uri = createBlogidLink($blogid); | |
952 | + $uri = createBlogidLink($blogid); | |
3354 | 953 | $CONF['Self'] = rtrim($uri, '/'); |
3355 | - $complete = TRUE; | |
954 | + $complete = TRUE; | |
3356 | 955 | return ; |
3357 | 956 | } |
3358 | 957 | // Behavior Not Found |
3359 | 958 | if ($notFound) { |
3360 | - if (substr($uri, -1) != '/') $uri .= '/'; | |
959 | + if (substr($uri, -1) != '/') { | |
960 | + $uri .= '/'; | |
961 | + } | |
3361 | 962 | if ($this->getOption('customurl_notfound') == '404') { |
3362 | 963 | header('HTTP/1.1 404 Not Found'); |
3363 | 964 | doError(_NO_SUCH_URI); |
@@ -3373,13 +974,16 @@ class NP_CustomURL extends NucleusPlugin | ||
3373 | 974 | // decode 'path name' to 'id' |
3374 | 975 | function getRequestPathInfo($linkObj) |
3375 | 976 | { |
3376 | - $query = 'SELECT obj_id as result FROM %s' | |
3377 | - . ' WHERE obj_name = "%s"' | |
3378 | - . ' AND obj_bid = %d AND obj_param = "%s"'; | |
977 | + $query = 'SELECT obj_id as result' | |
978 | + . ' FROM %s' | |
979 | + . ' WHERE obj_name = "%s"' | |
980 | + . ' AND obj_bid = %d' | |
981 | + . ' AND obj_param = "%s"'; | |
3379 | 982 | $name = $this->quote_smart($linkObj['name']); |
3380 | 983 | $bid = $this->quote_smart($linkObj['bid']); |
3381 | 984 | $linkparam = $this->quote_smart($linkObj['linkparam']); |
3382 | - $ObjID = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $name, $bid, $linkparam)); | |
985 | + $query = sprintf($query, _CUSTOMURL_TABLE, $name, $bid, $linkparam); | |
986 | + $ObjID = quickQuery($query); | |
3383 | 987 | if (!$ObjID) { |
3384 | 988 | return; |
3385 | 989 | } else { |
@@ -3390,13 +994,15 @@ class NP_CustomURL extends NucleusPlugin | ||
3390 | 994 | // Receive TrackBack ping |
3391 | 995 | function _trackback($bid, $path) |
3392 | 996 | { |
3393 | - $blog_id = intval($bid); | |
997 | + $blog_id = intval($bid); | |
3394 | 998 | $TrackBack = $this->pluginCheck('TrackBack'); |
3395 | 999 | if ($TrackBack) { |
3396 | 1000 | if (substr($path, -5, 5) == '.html') { |
3397 | - $linkObj = array ('linkparam' => 'item', | |
3398 | - 'bid' => $blog_id, | |
3399 | - 'name' => $path); | |
1001 | + $linkObj = array ( | |
1002 | + 'linkparam' => 'item', | |
1003 | + 'bid' => $blog_id, | |
1004 | + 'name' => $path | |
1005 | + ); | |
3400 | 1006 | $item_id = $this->getRequestPathInfo($linkObj); |
3401 | 1007 | if ($item_id) { |
3402 | 1008 | $tb_id = intval($item_id); |
@@ -3454,13 +1060,15 @@ class NP_CustomURL extends NucleusPlugin | ||
3454 | 1060 | return; |
3455 | 1061 | } |
3456 | 1062 | $item_id = intval($params['itemid']); |
3457 | - $bid = intval(getBlogIDFromItemID($item_id)); | |
1063 | + $bid = intval(getBlogIDFromItemID($item_id)); | |
3458 | 1064 | if ($useCustomURL[$bid] == 'no') { |
3459 | 1065 | return; |
3460 | 1066 | } |
3461 | - $query = 'SELECT obj_name as result FROM %s' | |
3462 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
3463 | - $path = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $item_id)); | |
1067 | + $query = 'SELECT obj_name as result ' | |
1068 | + . 'FROM %s ' | |
1069 | + . 'WHERE obj_param = "item" ' | |
1070 | + . 'AND obj_id = %d'; | |
1071 | + $path = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $item_id)); | |
3464 | 1072 | if ($path) { |
3465 | 1073 | $objPath = $path; |
3466 | 1074 | } else { |
@@ -3468,22 +1076,27 @@ class NP_CustomURL extends NucleusPlugin | ||
3468 | 1076 | $objPath = _NOT_VALID_ITEM; |
3469 | 1077 | } else { |
3470 | 1078 | $y = $m = $d = $temp = ''; |
3471 | - $table = sql_table('item'); | |
3472 | - $tque = 'SELECT itime as result FROM %s' | |
3473 | - . ' WHERE inumber = %d'; | |
3474 | - $itime = quickQuery(sprintf($tque ,$table, $item_id)); | |
1079 | + $table = sql_table('item'); | |
1080 | + $tque = 'SELECT itime as result ' | |
1081 | + . 'FROM %s ' | |
1082 | + . 'WHERE inumber = %d'; | |
1083 | + $itime = quickQuery(sprintf($tque ,$table, $item_id)); | |
3475 | 1084 | sscanf($itime,'%d-%d-%d %s', $y, $m, $d, $temp); |
3476 | 1085 | $defItem = $this->getOption('customurl_dfitem'); |
3477 | - $tempParam = array('year' => $Y, | |
1086 | + $tempParam = array( | |
1087 | + 'year' => $Y, | |
3478 | 1088 | 'month' => $m, |
3479 | - 'day' => $d); | |
3480 | - $ikey = TEMPLATE::fill($defItem, $tempParam); | |
3481 | - $ipath = $ikey . '_' . $item_id; | |
3482 | - $query = 'SELECT ititle as result FROM %s' | |
3483 | - . ' WHERE inumber = %d'; | |
3484 | - $iname = quickQuery(sprintf($query, $table, $item_id)); | |
1089 | + 'day' => $d | |
1090 | + ); | |
1091 | + $ikey = TEMPLATE::fill($defItem, $tempParam); | |
1092 | + $ipath = $ikey . '_' . $item_id; | |
1093 | + $query = 'SELECT ititle as result ' | |
1094 | + . 'FROM %s ' | |
1095 | + . 'WHERE inumber = %d'; | |
1096 | + $query = sprintf($query, $table, $item_id); | |
1097 | + $iname = quickQuery($query); | |
3485 | 1098 | $this->RegistPath($item_id, $ipath, $bid, 'item', $iname, TRUE); |
3486 | - $objPath = $ipath . '.html'; | |
1099 | + $objPath = $ipath . '.html'; | |
3487 | 1100 | } |
3488 | 1101 | } |
3489 | 1102 | // if ($catParam && $subcatid && !$subcatParam) { |
@@ -3557,12 +1170,12 @@ class NP_CustomURL extends NucleusPlugin | ||
3557 | 1170 | if ($d) { |
3558 | 1171 | $arc = sprintf('%04d-%02d-%02d', $y, $m, $d); |
3559 | 1172 | } elseif ($m) { |
3560 | - $arc = sprintf('%04d-%02d', $y, $m); | |
1173 | + $arc = sprintf('%04d-%02d', $y, $m); | |
3561 | 1174 | } else { |
3562 | - $arc = sprintf('%04d', $y); | |
1175 | + $arc = sprintf('%04d', $y); | |
3563 | 1176 | } |
3564 | 1177 | $objPath = $OP_ArchiveKey . '/' . $arc . '/'; |
3565 | - $bid = $blogid; | |
1178 | + $bid = $blogid; | |
3566 | 1179 | // if ($catParam && $subcatid && !$subcatParam) { |
3567 | 1180 | // $params['extra'][$subrequest] = $subcatid; |
3568 | 1181 | // } |
@@ -3571,7 +1184,7 @@ class NP_CustomURL extends NucleusPlugin | ||
3571 | 1184 | if (!is_numeric($params['blogid'])) { |
3572 | 1185 | return; |
3573 | 1186 | } |
3574 | - $bid = intval($params['blogid']); | |
1187 | + $bid = intval($params['blogid']); | |
3575 | 1188 | $burl = $this->_generateBlogLink($bid); |
3576 | 1189 | break; |
3577 | 1190 | default: |
@@ -3603,7 +1216,7 @@ class NP_CustomURL extends NucleusPlugin | ||
3603 | 1216 | } |
3604 | 1217 | $v_path = explode('/', $info); |
3605 | 1218 | |
3606 | - $feedurl = array(); | |
1219 | + $feedurl = array(); | |
3607 | 1220 | $SiteMapP = $this->pluginCheck('GoogleSitemap'); |
3608 | 1221 | if ($SiteMapP) { |
3609 | 1222 | $PcSitemaps = $SiteMapP->getAllBlogOptions('PcSitemap'); |
@@ -3633,12 +1246,12 @@ class NP_CustomURL extends NucleusPlugin | ||
3633 | 1246 | } else { |
3634 | 1247 | $data['url'] = $burl; |
3635 | 1248 | } |
3636 | - $arcTmp = (preg_match('/' . $OP_ArchivesKey . '/', $data['url'])); | |
3637 | - $arcsTmp = (preg_match('/' . $OP_ArchiveKey . '/', $data['url'])); | |
3638 | - $isArchives = ($arcTmp || $arcsTmp); | |
3639 | - $isItem = (substr($data['url'], -5, 5) == '.html'); | |
1249 | + $arcTmp = (preg_match('/' . $OP_ArchivesKey . '/', $data['url'])); | |
1250 | + $arcsTmp = (preg_match('/' . $OP_ArchiveKey . '/', $data['url'])); | |
1251 | + $isArchives = ($arcTmp || $arcsTmp); | |
1252 | + $isItem = (substr($data['url'], -5, 5) == '.html'); | |
3640 | 1253 | $isDirectory = (substr($data['url'], -1) == '/'); |
3641 | - $puri = parse_url($data['url']); | |
1254 | + $puri = parse_url($data['url']); | |
3642 | 1255 | if ($isArchives && !$isItem && !$isDirectory && !$puri['query']) { |
3643 | 1256 | $data['url'] .= '/'; |
3644 | 1257 | } |
@@ -3652,41 +1265,54 @@ class NP_CustomURL extends NucleusPlugin | ||
3652 | 1265 | |
3653 | 1266 | function _createSubCategoryLink($scid) |
3654 | 1267 | { |
3655 | - $scids = $this->getParents(intval($scid)); | |
1268 | + $scids = $this->getParents(intval($scid)); | |
3656 | 1269 | $subcatids = explode('/', $scids); |
3657 | - $eachPath = array(); | |
1270 | + $eachPath = array(); | |
3658 | 1271 | foreach ($subcatids as $sid) { |
3659 | 1272 | $subcat_id = intval($sid); |
3660 | - $query = 'SELECT obj_name as result FROM %s' | |
3661 | - . ' WHERE obj_id = %d AND obj_param = "%s"'; | |
3662 | - $path = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $subcat_id, 'subcategory')); | |
1273 | + $query = 'SELECT obj_name as result' | |
1274 | + . ' FROM %s' | |
1275 | + . ' WHERE obj_id = %d' | |
1276 | + . ' AND obj_param = "%s"'; | |
1277 | + $query = sprintf($query, _CUSTOMURL_TABLE, $subcat_id, 'subcategory'); | |
1278 | + $path = quickQuery($query); | |
3663 | 1279 | if ($path) { |
3664 | 1280 | $eachPath[] = $path; |
3665 | 1281 | } else { |
3666 | - $tempParam = array('plug_multiple_categories_sub', | |
1282 | + $tempParam = array( | |
1283 | + 'plug_multiple_categories_sub', | |
3667 | 1284 | 'scatid', |
3668 | - $subcat_id); | |
1285 | + $subcat_id | |
1286 | + ); | |
3669 | 1287 | if (!$this->_isValid($tempParam)) { |
3670 | 1288 | return $url = _NOT_VALID_SUBCAT; |
3671 | 1289 | } else { |
3672 | 1290 | $scpath = $this->getOption('customurl_dfscat') . '_' . $subcat_id; |
3673 | - $query = 'SELECT catid as result FROM %s WHERE scatid = %d'; | |
3674 | - $cid= quickQuery(sprintf($query, _C_SUBCAT_TABLE, $subcat_id)); | |
3675 | - if (!$cid) return 'no_such_subcat=' . $subcat_id . '/'; | |
1291 | + $query = 'SELECT catid as result FROM %s WHERE scatid = %d'; | |
1292 | + $query = sprintf($query, _C_SUBCAT_TABLE, $subcat_id); | |
1293 | + $cid = quickQuery($query); | |
1294 | + if (!$cid) { | |
1295 | + return 'no_such_subcat=' . $subcat_id . '/'; | |
1296 | + } | |
3676 | 1297 | $this->RegistPath($subcat_id, $scpath, $cid, 'subcategory', 'subcat_' . $subcat_id, TRUE); |
3677 | 1298 | $eachPath[] = $scpath; |
3678 | 1299 | } |
3679 | 1300 | } |
3680 | 1301 | } |
3681 | - $subcatPath = @join('/', $eachPath); | |
1302 | + $subcatPath = @implode('/', $eachPath); | |
3682 | 1303 | return $subcatPath . '/'; |
3683 | 1304 | } |
3684 | 1305 | |
3685 | 1306 | function getParents($subid) |
3686 | 1307 | { |
3687 | - $subcat_id = intval($subid); | |
3688 | - $query = 'SELECT scatid, parentid FROM %s WHERE scatid = %d'; | |
3689 | - $res = sql_query(sprintf($query, _C_SUBCAT_TABLE, $subcat_id)); | |
1308 | + $subcat_id = intval($subid); | |
1309 | + $query = 'SELECT ' | |
1310 | + . 'scatid, ' | |
1311 | + . 'parentid ' | |
1312 | + . 'FROM %s ' | |
1313 | + . 'WHERE scatid = %d'; | |
1314 | + $query = sprintf($query, _C_SUBCAT_TABLE, $subcat_id); | |
1315 | + $res = sql_query($query); | |
3690 | 1316 | list($sid, $parent) = mysql_fetch_row($res); |
3691 | 1317 | if ($parent != 0) { |
3692 | 1318 | $r = $this->getParents($parent) . '/' . $sid; |
@@ -3700,11 +1326,16 @@ class NP_CustomURL extends NucleusPlugin | ||
3700 | 1326 | { |
3701 | 1327 | global $CONF; |
3702 | 1328 | $cat_id = intval($cid); |
3703 | - $path = $this->getCategoryOption($cat_id, 'customurl_cname'); | |
1329 | + $path = $this->getCategoryOption($cat_id, 'customurl_cname'); | |
3704 | 1330 | if ($path) { |
3705 | 1331 | return $path . '/'; |
3706 | 1332 | } else { |
3707 | - if (!$this->_isValid(array('category', 'catid', $cat_id))) { | |
1333 | + $catData = array( | |
1334 | + 'category', | |
1335 | + 'catid', | |
1336 | + $cat_id | |
1337 | + ); | |
1338 | + if (!$this->_isValid($catData)) { | |
3708 | 1339 | return $url = _NOT_VALID_CAT; |
3709 | 1340 | } else { |
3710 | 1341 | $cpath = $this->getOption('customurl_dfcat') . '_' . $cat_id; |
@@ -3721,28 +1352,37 @@ class NP_CustomURL extends NucleusPlugin | ||
3721 | 1352 | global $manager, $CONF; |
3722 | 1353 | $blog_id = intval($bid); |
3723 | 1354 | if ($this->getBlogOption($blog_id, 'use_customurl') == 'no') { |
3724 | - $b =& $manager->getBlog($blog_id); | |
3725 | - $burl = $b->getURL(); | |
1355 | + $b =& $manager->getBlog($blog_id); | |
1356 | + $burl = $b->getURL(); | |
3726 | 1357 | } else { |
3727 | 1358 | if ($blog_id == $CONF['DefaultBlog']) { |
3728 | 1359 | $burl = trim($CONF['IndexURL'], '/'); |
3729 | 1360 | } else { |
3730 | - $query = 'SELECT burl as result FROM %s WHERE bnumber = %d'; | |
3731 | - $burl = quickQuery(sprintf($query, sql_table('blog'), $blog_id)); | |
1361 | + $query = 'SELECT burl as result ' | |
1362 | + . 'FROM %s ' | |
1363 | + . 'WHERE bnumber = %d'; | |
1364 | + $query = sprintf($query, sql_table('blog'), $blog_id); | |
1365 | + $burl = quickQuery($query); | |
3732 | 1366 | if ($burl) { |
3733 | 1367 | if (substr($burl, -4, 4) == '.php') { |
3734 | 1368 | $path = $this->getBlogOption($blog_id, 'customurl_bname'); |
3735 | 1369 | if ($path) { |
3736 | 1370 | $burl = $CONF['IndexURL'] . $path; |
3737 | 1371 | } else { |
3738 | - $query = 'SELECT bshortname as result FROM %s' | |
1372 | + $query = 'SELECT bshortname as result' | |
1373 | + . ' FROM %s' | |
3739 | 1374 | . ' WHERE bnumber = %d'; |
3740 | - $bpath = quickQuery(sprintf($query, sql_table('blog'), $blog_id)); | |
1375 | + $query = sprintf($query, sql_table('blog'), $blog_id); | |
1376 | + $bpath = quickQuery($query); | |
3741 | 1377 | $this->RegistPath($blog_id, $bpath, 0, 'blog', $bpath, TRUE); |
3742 | - $burl = $CONF['IndexURL'] . $bpath; | |
1378 | + $burl = $CONF['IndexURL'] . $bpath; | |
3743 | 1379 | } |
3744 | - $burl_update = 'UPDATE %s SET burl = "%s" WHERE bnumber = %d'; | |
3745 | - sql_query(sprintf($burl_update, sql_table('blog'), $this->quote_smart($burl), $blog_id)); | |
1380 | + $burl_update = 'UPDATE %s ' | |
1381 | + . 'SET burl = "%s" ' | |
1382 | + . 'WHERE bnumber = %d'; | |
1383 | + $burl = $this->quote_smart($burl); | |
1384 | + $bTable = sql_table('blog'); | |
1385 | + sql_query(sprintf($burl_update, $bTable, $burl, $blog_id)); | |
3746 | 1386 | } |
3747 | 1387 | } else { |
3748 | 1388 | $burl = _NOT_VALID_BLOG; |
@@ -3760,9 +1400,9 @@ class NP_CustomURL extends NucleusPlugin | ||
3760 | 1400 | $isArchives = ($arcTmp || $arcsTmp); |
3761 | 1401 | $mcategories = $this->pluginCheck('MultipleCategories'); |
3762 | 1402 | if ($mcategories) { |
3763 | - if (method_exists($mcategories,"getRequestName")) { | |
3764 | - $mcategories->event_PreSkinParse(array()); | |
3765 | - global $subcatid; | |
1403 | + $mcategories->event_PreSkinParse(array()); | |
1404 | + global $subcatid; | |
1405 | + if (method_exists($mcategories, 'getRequestName')) { | |
3766 | 1406 | $subrequest = $mcategories->getRequestName(); |
3767 | 1407 | } else { |
3768 | 1408 | $subrequest = 'subcatid'; |
@@ -3780,23 +1420,28 @@ class NP_CustomURL extends NucleusPlugin | ||
3780 | 1420 | if ($d) { |
3781 | 1421 | $arc = sprintf('%04d-%02d-%02d', $y, $m, $d); |
3782 | 1422 | } elseif ($m) { |
3783 | - $arc = sprintf('%04d-%02d', $y, $m); | |
1423 | + $arc = sprintf('%04d-%02d', $y, $m); | |
3784 | 1424 | } else { |
3785 | - $arc = sprintf('%04d', $y); | |
1425 | + $arc = sprintf('%04d', $y); | |
3786 | 1426 | } |
3787 | 1427 | $linkExtra = $this->getOption('customurl_archive') . '/' . $arc; |
3788 | 1428 | unset($params['archive']); |
3789 | 1429 | } |
1430 | + if ($params['blogid']) { | |
1431 | + unset($params['blogid']); | |
1432 | + } | |
3790 | 1433 | $paramlink = array(); |
3791 | 1434 | foreach ($params as $param => $value) { |
3792 | 1435 | switch ($param) { |
3793 | 1436 | case 'catid': |
3794 | 1437 | case $CONF['CategoryKey']: |
3795 | - $paramlink[] = $this->_generateCategoryLink(intval($value)); | |
1438 | + $cid = intval($value); | |
1439 | + $paramlink[] = $this->_generateCategoryLink($cid); | |
3796 | 1440 | break; |
3797 | 1441 | case $subrequest: |
3798 | 1442 | if ($mcategories) { |
3799 | - $paramlink[] = $this->_createSubCategoryLink(intval($value)); | |
1443 | + $sid = intval($value); | |
1444 | + $paramlink[] = $this->_createSubCategoryLink($sid); | |
3800 | 1445 | } |
3801 | 1446 | break; |
3802 | 1447 | default: |
@@ -3820,13 +1465,16 @@ class NP_CustomURL extends NucleusPlugin | ||
3820 | 1465 | $link .= $linkExtra; |
3821 | 1466 | } |
3822 | 1467 | if (requestVar('skinid')) { |
3823 | - if (strpos('?', $link)) { | |
3824 | - $link .= '&skinid=' . htmlspecialchars(requestVar('skinid')); | |
1468 | + $skinid = htmlspecialchars(requestVar('skinid'), ENT_QUOTES, _CHARSET); | |
1469 | + if (!$link) { | |
1470 | + $link = '?skinid=' . $skinid; | |
1471 | + } elseif (strpos('?', $link)) { | |
1472 | + $link .= '&skinid=' . $skinid; | |
3825 | 1473 | } else { |
3826 | 1474 | if (substr($link, -1) != '/' && !empty($link)) { |
3827 | - $link .= '/?skinid=' . htmlspecialchars(requestVar('skinid')); | |
1475 | + $link .= '/?skinid=' . $skinid; | |
3828 | 1476 | } else { |
3829 | - $link .= '?skinid=' . htmlspecialchars(requestVar('skinid')); | |
1477 | + $link .= '?skinid=' . $skinid; | |
3830 | 1478 | } |
3831 | 1479 | } |
3832 | 1480 | } |
@@ -3839,117 +1487,34 @@ class NP_CustomURL extends NucleusPlugin | ||
3839 | 1487 | function _convertAlphabettoXHTMLCharacterEntity($text) //add shizuki |
3840 | 1488 | { |
3841 | 1489 | $alphabetKey = array ( |
3842 | - '/', | |
3843 | - '@', | |
3844 | - 'A', | |
3845 | - 'B', | |
3846 | - 'C', | |
3847 | - 'D', | |
3848 | - 'E', | |
3849 | - 'F', | |
3850 | - 'G', | |
3851 | - 'H', | |
3852 | - 'I', | |
3853 | - 'J', | |
3854 | - 'K', | |
3855 | - 'L', | |
3856 | - 'M', | |
3857 | - 'N', | |
3858 | - 'O', | |
3859 | - 'P', | |
3860 | - 'Q', | |
3861 | - 'R', | |
3862 | - 'S', | |
3863 | - 'T', | |
3864 | - 'U', | |
3865 | - 'V', | |
3866 | - 'W', | |
3867 | - 'X', | |
3868 | - 'Y', | |
1490 | + '/', '@', | |
1491 | + 'A', 'B', 'C', 'D', 'E', | |
1492 | + 'F', 'G', 'H', 'I', 'J', | |
1493 | + 'K', 'L', 'M', 'N', 'O', | |
1494 | + 'P', 'Q', 'R', 'S', 'T', | |
1495 | + 'U', 'V', 'W', 'X', 'Y', | |
3869 | 1496 | 'Z', |
3870 | - 'a', | |
3871 | - 'b', | |
3872 | - 'c', | |
3873 | - 'd', | |
3874 | - 'e', | |
3875 | - 'f', | |
3876 | - 'g', | |
3877 | - 'h', | |
3878 | - 'i', | |
3879 | - 'j', | |
3880 | - 'k', | |
3881 | - 'l', | |
3882 | - 'm', | |
3883 | - 'n', | |
3884 | - 'o', | |
3885 | - 'p', | |
3886 | - 'q', | |
3887 | - 'r', | |
3888 | - 's', | |
3889 | - 't', | |
3890 | - 'u', | |
3891 | - 'v', | |
3892 | - 'w', | |
3893 | - 'x', | |
3894 | - 'y', | |
1497 | + 'a', 'b', 'c', 'd', 'e', | |
1498 | + 'f', 'g', 'h', 'i', 'j', | |
1499 | + 'k', 'l', 'm', 'n', 'o', | |
1500 | + 'p', 'q', 'r', 's', 't', | |
1501 | + 'u', 'v', 'w', 'x', 'y', | |
3895 | 1502 | 'z', |
3896 | 1503 | '&&' |
3897 | 1504 | ); |
3898 | 1505 | $alphabetVal = array ( |
3899 | - '/', | |
3900 | - '@', | |
3901 | - 'A', | |
3902 | - 'B', | |
3903 | - 'C', | |
3904 | - 'D', | |
3905 | - 'E', | |
3906 | - 'F', | |
3907 | - 'G', | |
3908 | - 'H', | |
3909 | - 'I', | |
3910 | - 'J', | |
3911 | - 'K', | |
3912 | - 'L', | |
3913 | - 'M', | |
3914 | - 'N', | |
3915 | - 'O', | |
3916 | - 'P', | |
3917 | - 'Q', | |
3918 | - 'R', | |
3919 | - 'S', | |
3920 | - 'T', | |
3921 | - 'U', | |
3922 | - 'V', | |
3923 | - 'W', | |
3924 | - 'X', | |
3925 | - 'Y', | |
3926 | - 'Z', | |
3927 | - 'a', | |
3928 | - 'b', | |
1506 | + '/', '@', 'A', 'B', 'C', | |
1507 | + 'D', 'E', 'F', 'G', 'H', | |
1508 | + 'I', 'J', 'K', 'L', 'M', | |
1509 | + 'N', 'O', 'P', 'Q', 'R', | |
1510 | + 'S', 'T', 'U', 'V', 'W', | |
1511 | + 'X', 'Y', 'Z', 'a', 'b', | |
3929 | 1512 | 'c', |
3930 | - 'd', | |
3931 | - 'e', | |
3932 | - 'f', | |
3933 | - 'g', | |
3934 | - 'h', | |
3935 | - 'i', | |
3936 | - 'j', | |
3937 | - 'k', | |
3938 | - 'l', | |
3939 | - 'm', | |
3940 | - 'n', | |
3941 | - 'o', | |
3942 | - 'p', | |
3943 | - 'q', | |
3944 | - 'r', | |
3945 | - 's', | |
3946 | - 't', | |
3947 | - 'u', | |
3948 | - 'v', | |
3949 | - 'w', | |
3950 | - 'x', | |
3951 | - 'y', | |
3952 | - 'z', | |
1513 | + 'd', 'e', 'f', 'g', 'h', | |
1514 | + 'i', 'j', 'k', 'l', 'm', | |
1515 | + 'n', 'o', 'p', 'q', 'r', | |
1516 | + 's', 't', 'u', 'v', 'w', | |
1517 | + 'x', 'y', 'z', | |
3953 | 1518 | '&&' |
3954 | 1519 | ); |
3955 | 1520 | $retData = str_replace($alphabetKey, $alphabetVal, $text); |
@@ -3962,13 +1527,18 @@ class NP_CustomURL extends NucleusPlugin | ||
3962 | 1527 | if ($skinType == 'item' && $link_type == 'trackback') { |
3963 | 1528 | global $itemid, $CONF; |
3964 | 1529 | if ($this->getBlogOption($blogid, 'use_customurl') == 'yes') { |
3965 | - $que = 'SELECT obj_name as result FROM %s' | |
3966 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
1530 | + $que = 'SELECT obj_name as result ' | |
1531 | + . 'FROM %s ' | |
1532 | + . 'WHERE obj_param = "item" ' | |
1533 | + . 'AND obj_id = %d'; | |
3967 | 1534 | $itempath = quickQuery(sprintf($que, _CUSTOMURL_TABLE, $itemid)); |
3968 | - $uri = $CONF['BlogURL'] . '/trackback/' . $itempath; | |
1535 | + if ($target != 'ext') { | |
1536 | + $uri = $CONF['BlogURL'] . '/trackback/' . $itempath; | |
1537 | + } elseif ($target == 'ext') { | |
3969 | 1538 | // /item_123.trackback |
3970 | -// $itempath = substr($itempath, 0, -5) . '.trackback'; | |
3971 | -// $uri = $CONF['BlogURL'] . '/' . $itempath; | |
1539 | + $itempath = substr($itempath, 0, -5) . '.trackback'; | |
1540 | + $uri = $CONF['BlogURL'] . '/' . $itempath; | |
1541 | + } | |
3972 | 1542 | } else { |
3973 | 1543 | $uri = $CONF['ActionURL'] |
3974 | 1544 | . '?action=plugin&name=TrackBack&tb_id=' . $itemid; |
@@ -4008,13 +1578,18 @@ class NP_CustomURL extends NucleusPlugin | ||
4008 | 1578 | global $CONF; |
4009 | 1579 | $blog_id = intval(getBlogIDFromItemID($item_id)); |
4010 | 1580 | if ($this->getBlogOption($blog_id, 'use_customurl') == 'yes') { |
4011 | - $que = 'SELECT obj_name as result FROM %s' | |
4012 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
1581 | + $que = 'SELECT obj_name as result ' | |
1582 | + . 'FROM %s ' | |
1583 | + . 'WHERE obj_param = "item" ' | |
1584 | + . 'AND obj_id = %d'; | |
4013 | 1585 | $itempath = quickQuery(sprintf($que, _CUSTOMURL_TABLE, $item_id)); |
4014 | - $uri = $CONF['BlogURL'] . '/trackback/' . $itempath; | |
1586 | + if ($target != 'ext') { | |
1587 | + $uri = $CONF['BlogURL'] . '/trackback/' . $itempath; | |
1588 | + } elseif ($target == 'ext') { | |
4015 | 1589 | // /item_123.trackback |
4016 | -// $itempath = substr($itempath, 0, -5) . '.trackback'; | |
4017 | -// $uri = $CONF['BlogURL'] . '/' . $itempath; | |
1590 | + $itempath = substr($itempath, 0, -5) . '.trackback'; | |
1591 | + $uri = $CONF['BlogURL'] . '/' . $itempath; | |
1592 | + } | |
4018 | 1593 | } else { |
4019 | 1594 | $uri = $CONF['ActionURL'] |
4020 | 1595 | . '?action=plugin&name=TrackBack&tb_id=' . $item_id; |
@@ -4037,35 +1612,45 @@ class NP_CustomURL extends NucleusPlugin | ||
4037 | 1612 | |
4038 | 1613 | function URL_Callback($data) |
4039 | 1614 | { |
4040 | - $l_data = explode(",", $data[1]); | |
4041 | - $l_type = $l_data[0]; | |
4042 | - $target = $l_data[1]; | |
4043 | - $title = $l_data[2]; | |
4044 | - $item_id = intval($this->currentItem->itemid); | |
1615 | + $l_data = explode(",", $data[1]); | |
1616 | + $l_type = $l_data[0]; | |
1617 | + $target = $l_data[1]; | |
1618 | + $title = $l_data[2]; | |
1619 | + $item_id = intval($this->currentItem->itemid); | |
4045 | 1620 | if (!$l_type) { |
4046 | - $link_params = array ('i', | |
1621 | + $link_params = array ( | |
1622 | + 'i', | |
4047 | 1623 | $item_id, |
4048 | - 'i'); | |
1624 | + 'i' | |
1625 | + ); | |
4049 | 1626 | } else { |
4050 | 1627 | $link_data = explode("/", $l_type); |
4051 | 1628 | if (count($link_data) == 1) { |
4052 | - $link_params = array ('i', | |
1629 | + $link_params = array ( | |
1630 | + 'i', | |
4053 | 1631 | intval($l_type), |
4054 | - 'i'); | |
1632 | + 'i' | |
1633 | + ); | |
4055 | 1634 | } elseif (count($link_data) == 2) { |
4056 | 1635 | if ($link_data[1] == 'path') { |
4057 | - $link_params = array ('i', | |
1636 | + $link_params = array ( | |
1637 | + 'i', | |
4058 | 1638 | $link_data[0], |
4059 | - 'path'); | |
1639 | + 'path' | |
1640 | + ); | |
4060 | 1641 | } else { |
4061 | - $link_params = array ($link_data[0], | |
1642 | + $link_params = array ( | |
1643 | + $link_data[0], | |
4062 | 1644 | intval($link_data[1]), |
4063 | - 'i'); | |
1645 | + 'i' | |
1646 | + ); | |
4064 | 1647 | } |
4065 | 1648 | } else { |
4066 | - $link_params = array ($link_data[0], | |
1649 | + $link_params = array ( | |
1650 | + $link_data[0], | |
4067 | 1651 | $link_data[1], |
4068 | - $link_data[2]); | |
1652 | + $link_data[2] | |
1653 | + ); | |
4069 | 1654 | } |
4070 | 1655 | } |
4071 | 1656 | $url = $this->_genarateObjectLink($link_params); |
@@ -4087,9 +1672,10 @@ class NP_CustomURL extends NucleusPlugin | ||
4087 | 1672 | |
4088 | 1673 | function _isValid($data) |
4089 | 1674 | { |
4090 | - $query = 'SELECT * FROM %s WHERE %s = %d'; | |
1675 | + $query = 'SELECT * FROM %s WHERE %s = %d'; | |
4091 | 1676 | $data[2] = $this->quote_smart($data[2]); |
4092 | - $res = sql_query(sprintf($query, sql_table($data[0]), $data[1], $data[2])); | |
1677 | + $query = sprintf($query, sql_table($data[0]), $data[1], $data[2]); | |
1678 | + $res = sql_query($query); | |
4093 | 1679 | return (mysql_num_rows($res) != 0); |
4094 | 1680 | } |
4095 | 1681 |
@@ -4098,7 +1684,7 @@ class NP_CustomURL extends NucleusPlugin | ||
4098 | 1684 | global $CONF, $manager, $blog; |
4099 | 1685 | $ext = substr(serverVar('REQUEST_URI'), -4); |
4100 | 1686 | if ($ext == '.rdf' || $ext == '.xml') { |
4101 | - $CONF['URLMode'] = 'pathinfo'; | |
1687 | + $CONF['URLMode'] = 'pathinfo'; | |
4102 | 1688 | } |
4103 | 1689 | if ($CONF['URLMode'] != 'pathinfo') { |
4104 | 1690 | return; |
@@ -4112,9 +1698,11 @@ class NP_CustomURL extends NucleusPlugin | ||
4112 | 1698 | $bid = $data[1]; |
4113 | 1699 | } |
4114 | 1700 | $blog_id = intval($bid); |
4115 | - $param = array('blog', | |
4116 | - 'bnumber', | |
4117 | - $blog_id); | |
1701 | + $param = array( | |
1702 | + 'blog', | |
1703 | + 'bnumber', | |
1704 | + $blog_id | |
1705 | + ); | |
4118 | 1706 | if (!$this->_isValid($param)) { |
4119 | 1707 | $url = _NOT_VALID_BLOG; |
4120 | 1708 | } else { |
@@ -4128,9 +1716,11 @@ class NP_CustomURL extends NucleusPlugin | ||
4128 | 1716 | $cid = $data[1]; |
4129 | 1717 | } |
4130 | 1718 | $cat_id = intval($cid); |
4131 | - $param = array('category', | |
1719 | + $param = array( | |
1720 | + 'category', | |
4132 | 1721 | 'catid', |
4133 | - $cat_id); | |
1722 | + $cat_id | |
1723 | + ); | |
4134 | 1724 | if (!$this->_isValid($param)) { |
4135 | 1725 | $url = _NOT_VALID_CAT; |
4136 | 1726 | } else { |
@@ -4146,40 +1736,51 @@ class NP_CustomURL extends NucleusPlugin | ||
4146 | 1736 | if (method_exists($mcategories, "getRequestName")) { |
4147 | 1737 | if ($data[2] == 'n') { |
4148 | 1738 | $temp = $this->quote_smart($data[1]); |
4149 | - $scid = quickQuery(sprintf($query, 'scatid', _C_SUBCAT_TABLE, 'sname', $temp)); | |
1739 | + $sque = sprintf($query, 'scatid', _C_SUBCAT_TABLE, 'sname', $temp); | |
1740 | + $scid = quickQuery($sque); | |
4150 | 1741 | } else { |
4151 | 1742 | $scid = $data[1]; |
4152 | 1743 | } |
4153 | 1744 | $sub_id = intval($scid); |
4154 | - $param = array('plug_multiple_categories_sub', | |
4155 | - 'scatid', | |
4156 | - $sub_id); | |
1745 | + $param = array( | |
1746 | + 'plug_multiple_categories_sub', | |
1747 | + 'scatid', | |
1748 | + $sub_id | |
1749 | + ); | |
4157 | 1750 | if (!$this->_isValid($param)) { |
4158 | 1751 | $url = _NOT_VALID_SUBCAT; |
4159 | 1752 | } else { |
4160 | - $cid = quickQuery(sprintf($query, 'catid', _C_SUBCAT_TABLE, 'scatid', $sub_id)); | |
4161 | - $cid = intval($cid); | |
1753 | + $cqe = sprintf($query, 'catid', _C_SUBCAT_TABLE, 'scatid', $sub_id); | |
1754 | + $cid = quickQuery($cqe); | |
1755 | + $cid = intval($cid); | |
4162 | 1756 | $subrequest = $mcategories->getRequestName(); |
4163 | 1757 | if (!$subrequest) { |
4164 | 1758 | $subrequest = 'subcatid'; |
4165 | 1759 | } |
4166 | - $linkParam = array($subrequest => $sub_id); | |
4167 | - $url = createCategoryLink($cid, $linkParam); | |
1760 | + $linkParam = array( | |
1761 | + $subrequest => $sub_id | |
1762 | + ); | |
1763 | + $url = createCategoryLink($cid, $linkParam); | |
4168 | 1764 | } |
4169 | 1765 | } |
4170 | 1766 | } |
4171 | 1767 | break; |
4172 | 1768 | case 'i': |
4173 | - $param = array('item', | |
1769 | + $param = array( | |
1770 | + 'item', | |
4174 | 1771 | 'inumber', |
4175 | - intval($data[1])); | |
1772 | + intval($data[1]) | |
1773 | + ); | |
4176 | 1774 | if (!$this->_isValid($param)) { |
4177 | 1775 | $url = _NOT_VALID_ITEM; |
4178 | 1776 | } else { |
4179 | 1777 | $blink = $this->_generateBlogLink(getBlogIDFromItemID(intval($data[1]))); |
4180 | - $i_query = 'SELECT obj_name as result FROM %s' | |
4181 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
4182 | - $path = quickQuery(sprintf($i_query, _CUSTOMURL_TABLE, intval($data[1]))); | |
1778 | + $i_query = 'SELECT obj_name as result ' | |
1779 | + . 'FROM %s ' | |
1780 | + . 'WHERE obj_param = "item" ' | |
1781 | + . 'AND obj_id = %d'; | |
1782 | + $i_query = sprintf($i_query, _CUSTOMURL_TABLE, intval($data[1])); | |
1783 | + $path = quickQuery($i_query); | |
4183 | 1784 | if ($path) { |
4184 | 1785 | if ($data[2] == 'path') { |
4185 | 1786 | $url = $path; |
@@ -4200,14 +1801,17 @@ class NP_CustomURL extends NucleusPlugin | ||
4200 | 1801 | case 'm': |
4201 | 1802 | if ($data[2] == 'n') { |
4202 | 1803 | $data[1] = $this->quote_smart($data[1]); |
4203 | - $mid = quickQuery(sprintf($query, 'mnumber', sql_table('member'), 'mname', $data[1])); | |
1804 | + $mque = sprintf($query, 'mnumber', sql_table('member'), 'mname', $data[1]); | |
1805 | + $mid = quickQuery($mque); | |
4204 | 1806 | } else { |
4205 | 1807 | $mid = $data[1]; |
4206 | 1808 | } |
4207 | 1809 | $member_id = intval($mid); |
4208 | - $param = array('member', | |
1810 | + $param = array( | |
1811 | + 'member', | |
4209 | 1812 | 'mnumber', |
4210 | - $member_id); | |
1813 | + $member_id | |
1814 | + ); | |
4211 | 1815 | if (!$this->_isValid($param)) { |
4212 | 1816 | $url = _NOT_VALID_MEMBER; |
4213 | 1817 | } else { |
@@ -4218,35 +1822,14 @@ class NP_CustomURL extends NucleusPlugin | ||
4218 | 1822 | return $url; |
4219 | 1823 | } |
4220 | 1824 | |
4221 | -/* function event_PreSendContentType($data) | |
4222 | - { | |
4223 | - global $blogid, $CONF; | |
4224 | - | |
4225 | - $ext = substr(serverVar('REQUEST_URI'), -4); | |
4226 | - if ($ext == '.rdf' || $ext == '.xml') { | |
4227 | - $p_info = trim(serverVar('PATH_INFO'), '/'); | |
4228 | - $path_arr = explode('/', $p_info); | |
4229 | - switch (end($path_arr)) { | |
4230 | - case 'rss1.xml': | |
4231 | - case 'index.rdf': | |
4232 | - case 'rss2.xml': | |
4233 | - case 'atom.xml': | |
4234 | - $data['contentType'] = 'application/xml'; | |
4235 | - break; | |
4236 | - default: | |
4237 | - break; | |
4238 | - } | |
4239 | - } | |
4240 | - }*/ | |
4241 | - | |
4242 | 1825 | function event_InitSkinParse($data) |
4243 | 1826 | { |
4244 | - global $blogid, $CONF, $manager; | |
1827 | + global $blogid, $CONF, $manager, $nucleus; | |
4245 | 1828 | $feedurl = array( |
4246 | - 'rss1.xml', | |
4247 | - 'index.rdf', | |
4248 | - 'rss2.xml', | |
4249 | - 'atom.xml', | |
1829 | + 'rss1.xml', | |
1830 | + 'index.rdf', | |
1831 | + 'rss2.xml', | |
1832 | + 'atom.xml', | |
4250 | 1833 | ); |
4251 | 1834 | $reqPaths = explode('/', serverVar('PATH_INFO')); |
4252 | 1835 | $reqPath = end($reqPaths); |
@@ -4279,9 +1862,11 @@ class NP_CustomURL extends NucleusPlugin | ||
4279 | 1862 | $skinID = $skinData->id; |
4280 | 1863 | $contents = $this->getSkinContent($pageType, $skinID); |
4281 | 1864 | $actions = SKIN::getAllowedActionsForType($pageType); |
4282 | - $dataArray = array('skin' => &$skinData, | |
1865 | + $dataArray = array( | |
1866 | + 'skin' => &$skinData, | |
4283 | 1867 | 'type' => $pageType, |
4284 | - 'contents' => &$contents); | |
1868 | + 'contents' => &$contents | |
1869 | + ); | |
4285 | 1870 | $manager->notify('PreSkinParse', $dataArray); |
4286 | 1871 | PARSER::setProperty('IncludeMode', SKIN::getIncludeMode()); |
4287 | 1872 | PARSER::setProperty('IncludePrefix', SKIN::getIncludePrefix()); |
@@ -4290,8 +1875,10 @@ class NP_CustomURL extends NucleusPlugin | ||
4290 | 1875 | $handler->setParser($parser); |
4291 | 1876 | $handler->setSkin($skinData); |
4292 | 1877 | $parser->parse($contents); |
4293 | - $dataArray = array('skin' => &$skinData, | |
4294 | - 'type' => $pageType); | |
1878 | + $dataArray = array( | |
1879 | + 'skin' => &$skinData, | |
1880 | + 'type' => $pageType | |
1881 | + ); | |
4295 | 1882 | $manager->notify('PostSkinParse', $dataArray); |
4296 | 1883 | |
4297 | 1884 | $feed = ob_get_contents(); |
@@ -4300,11 +1887,11 @@ class NP_CustomURL extends NucleusPlugin | ||
4300 | 1887 | $eTag = '"' . md5($feed) . '"'; |
4301 | 1888 | header('Etag: ' . $eTag); |
4302 | 1889 | if ($eTag == serverVar('HTTP_IF_NONE_MATCH')) { |
4303 | - header("HTTP/1.0 304 Not Modified"); | |
1890 | + header('HTTP/1.0 304 Not Modified'); | |
4304 | 1891 | header('Content-Length: 0'); |
4305 | 1892 | } else { |
4306 | 1893 | $feed = mb_convert_encoding($feed, 'UTF-8', _CHARSET); |
4307 | - header("Content-Type: application/xml"); | |
1894 | + header('Content-Type: application/xml'); | |
4308 | 1895 | header('Generator: Nucleus CMS ' . $nucleus['version']); |
4309 | 1896 | // dump feed |
4310 | 1897 | echo $feed; |
@@ -4314,8 +1901,8 @@ class NP_CustomURL extends NucleusPlugin | ||
4314 | 1901 | ?> |
4315 | 1902 | <rss version="2.0"> |
4316 | 1903 | <channel> |
4317 | - <title><?php echo htmlspecialchars($CONF['SiteName'])?></title> | |
4318 | - <link><?php echo htmlspecialchars($CONF['IndexURL'])?></link> | |
1904 | + <title><?php echo htmlspecialchars($CONF['SiteName'], ENT_QUOTES)?></title> | |
1905 | + <link><?php echo htmlspecialchars($CONF['IndexURL'], ENT_QUOTES)?></link> | |
4319 | 1906 | <description></description> |
4320 | 1907 | <docs>http://backend.userland.com/rss</docs> |
4321 | 1908 | </channel> |
@@ -4331,13 +1918,18 @@ class NP_CustomURL extends NucleusPlugin | ||
4331 | 1918 | { |
4332 | 1919 | $skinID = intval($skinID); |
4333 | 1920 | $pageType = addslashes($pageType); |
4334 | - $query = 'SELECT scontent FROM %s WHERE sdesc = %d AND stype = %d'; | |
4335 | - $res = sql_query(sprintf($query, sql_table('skin'), $skinID, $pageType)); | |
4336 | - | |
4337 | - if (mysql_num_rows($res) == 0) | |
1921 | + $query = 'SELECT scontent ' | |
1922 | + . 'FROM %s ' | |
1923 | + . 'WHERE sdesc = %d ' | |
1924 | + . 'AND stype = %d'; | |
1925 | + $query = sprintf($query, sql_table('skin'), $skinID, $pageType); | |
1926 | + $res = sql_query($query); | |
1927 | + | |
1928 | + if (mysql_num_rows($res) == 0) { | |
4338 | 1929 | return ''; |
4339 | - else | |
1930 | + } else { | |
4340 | 1931 | return mysql_result($res, 0, 0); |
1932 | + } | |
4341 | 1933 | } |
4342 | 1934 | |
4343 | 1935 |
@@ -4355,8 +1947,8 @@ class NP_CustomURL extends NucleusPlugin | ||
4355 | 1947 | |
4356 | 1948 | if (!$blogurl) { |
4357 | 1949 | if($blog) { |
4358 | - $b_tmp =& $manager->getBlog($CONF['DefaultBlog']); | |
4359 | - $blogurl = $b_tmp->getURL(); | |
1950 | + $b_tmp =& $manager->getBlog($CONF['DefaultBlog']); | |
1951 | + $blogurl = $b_tmp->getURL(); | |
4360 | 1952 | } |
4361 | 1953 | if (!$blogurl) { |
4362 | 1954 | $blogurl = $CONF['IndexURL']; |
@@ -4364,7 +1956,7 @@ class NP_CustomURL extends NucleusPlugin | ||
4364 | 1956 | if ($data['type'] == 'pageparser') { |
4365 | 1957 | $blogurl .= 'index.php'; |
4366 | 1958 | } else { |
4367 | - $blogurl = $CONF['Self']; | |
1959 | + $blogurl = $CONF['Self']; | |
4368 | 1960 | } |
4369 | 1961 | } |
4370 | 1962 | } |
@@ -4394,9 +1986,9 @@ class NP_CustomURL extends NucleusPlugin | ||
4394 | 1986 | $data['item']->more = preg_replace_callback($pattern, array(&$this, 'URL_Callback'), $data['item']->more); |
4395 | 1987 | } |
4396 | 1988 | |
4397 | - $itemid = intval($data['item']->itemid); | |
1989 | + $itemid = intval($data['item']->itemid); | |
4398 | 1990 | $itemblog =& $manager->getBlog(getBlogIDFromItemID($itemid)); |
4399 | - $blogurl = $itemblog->getURL(); | |
1991 | + $blogurl = $itemblog->getURL(); | |
4400 | 1992 | if (!$blogurl) { |
4401 | 1993 | $b =& $manager->getBlog($CONF['DefaultBlog']); |
4402 | 1994 | if (!($blogurl = $b->getURL())) { |
@@ -4405,7 +1997,7 @@ class NP_CustomURL extends NucleusPlugin | ||
4405 | 1997 | if ($data['type'] == 'pageparser') { |
4406 | 1998 | $blogurl .= 'index.php'; |
4407 | 1999 | } else { |
4408 | - $blogurl = $CONF['Self']; | |
2000 | + $blogurl = $CONF['Self']; | |
4409 | 2001 | } |
4410 | 2002 | } |
4411 | 2003 | } |
@@ -4434,8 +2026,8 @@ class NP_CustomURL extends NucleusPlugin | ||
4434 | 2026 | $blogurl = $b->getURL(); |
4435 | 2027 | if (!$blogurl) { |
4436 | 2028 | if($blog) { |
4437 | - $b_tmp =& $manager->getBlog($CONF['DefaultBlog']); | |
4438 | - $blogurl = $b_tmp->getURL(); | |
2029 | + $b_tmp =& $manager->getBlog($CONF['DefaultBlog']); | |
2030 | + $blogurl = $b_tmp->getURL(); | |
4439 | 2031 | } |
4440 | 2032 | if (!$blogurl) { |
4441 | 2033 | $blogurl = $CONF['IndexURL']; |
@@ -4443,7 +2035,7 @@ class NP_CustomURL extends NucleusPlugin | ||
4443 | 2035 | if ($data['type'] == 'pageparser') { |
4444 | 2036 | $blogurl .= 'index.php'; |
4445 | 2037 | } else { |
4446 | - $blogurl = $CONF['Self']; | |
2038 | + $blogurl = $CONF['Self']; | |
4447 | 2039 | } |
4448 | 2040 | } |
4449 | 2041 | } |
@@ -4464,14 +2056,14 @@ class NP_CustomURL extends NucleusPlugin | ||
4464 | 2056 | |
4465 | 2057 | function event_PostDeleteBlog ($data) |
4466 | 2058 | { |
4467 | - $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
4468 | - $pquery = 'DELETE FROM %s WHERE obj_bid = %d AND obj_param= "%s"'; | |
4469 | - $blogid = intval($data['blogid']); | |
2059 | + $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2060 | + $pquery = 'DELETE FROM %s WHERE obj_bid = %d AND obj_param= "%s"'; | |
2061 | + $blogid = intval($data['blogid']); | |
4470 | 2062 | sql_query(sprintf($query, _CUSTOMURL_TABLE, $blogid, 'blog')); |
4471 | 2063 | sql_query(sprintf($pquery, _CUSTOMURL_TABLE, $blogid, 'item')); |
4472 | 2064 | $cnmquery = 'SELECT catid FROM %s WHERE cblog = %d'; |
4473 | - $table = sql_table('category'); | |
4474 | - $cnm = sql_query(sprintf($cnmquery, $table, $blogid)); | |
2065 | + $table = sql_table('category'); | |
2066 | + $cnm = sql_query(sprintf($cnmquery, $table, $blogid)); | |
4475 | 2067 | while ($c = mysql_fetch_object($cnm)) { |
4476 | 2068 | $catid = intval($c->catid); |
4477 | 2069 | sql_query(sprintf($pquery, _CUSTOMURL_TABLE, $catid, 'subcategory')); |
@@ -4490,14 +2082,14 @@ class NP_CustomURL extends NucleusPlugin | ||
4490 | 2082 | |
4491 | 2083 | function event_PostDeleteItem ($data) |
4492 | 2084 | { |
4493 | - $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2085 | + $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
4494 | 2086 | $itemid = intval($data['itemid']); |
4495 | 2087 | sql_query(sprintf($query, _CUSTOMURL_TABLE, $itemid, 'item')); |
4496 | 2088 | } |
4497 | 2089 | |
4498 | 2090 | function event_PostDeleteMember ($data) |
4499 | 2091 | { |
4500 | - $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
2092 | + $query = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; | |
4501 | 2093 | $memberid = intval($data['member']->id); |
4502 | 2094 | sql_query(sprintf($query, _CUSTOMURL_TABLE, $memberid, 'member')); |
4503 | 2095 | } |
@@ -4516,13 +2108,13 @@ class NP_CustomURL extends NucleusPlugin | ||
4516 | 2108 | $cat_id = intval($data['catid']); |
4517 | 2109 | if (!$data['blog']->blogid) { |
4518 | 2110 | $query = 'SELECT cblog as result FROM %s WHERE catid = %d'; |
4519 | - $bid = quickQuery(sprintf($query, sql_table('category'), $cat_id)); | |
2111 | + $bid = quickQuery(sprintf($query, sql_table('category'), $cat_id)); | |
4520 | 2112 | } else { |
4521 | 2113 | $bid = $data['blog']->blogid; |
4522 | 2114 | } |
4523 | 2115 | if (!$data['name']) { |
4524 | 2116 | $query = 'SELECT cname as result FROM %s WHERE catid = %d'; |
4525 | - $name = quickQuery(sprintf($query, sql_table('category'), $cat_id)); | |
2117 | + $name = quickQuery(sprintf($query, sql_table('category'), $cat_id)); | |
4526 | 2118 | } else { |
4527 | 2119 | $name = $data['name']; |
4528 | 2120 | } |
@@ -4537,18 +2129,19 @@ class NP_CustomURL extends NucleusPlugin | ||
4537 | 2129 | { |
4538 | 2130 | $item_id = intval($data['itemid']); |
4539 | 2131 | // $item_id = $data['itemid']; |
4540 | - $tpath = requestVar('plug_custom_url_path'); | |
4541 | - $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
4542 | - $itime = quickQuery(sprintf($tque, sql_table('item'), $item_id)); | |
4543 | - echo 'itemid='.$item_id.'<br>idate='.$itime; | |
2132 | + $tpath = requestVar('plug_custom_url_path'); | |
2133 | + $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
2134 | + $itime = quickQuery(sprintf($tque, sql_table('item'), $item_id)); | |
4544 | 2135 | $y = $m = $d = $temp = ''; |
4545 | 2136 | sscanf($itime, '%d-%d-%d %s', $y, $m, $d, $temp); |
4546 | - $param = array ('year' => $y, | |
2137 | + $param = array ( | |
2138 | + 'year' => $y, | |
4547 | 2139 | 'month' => $m, |
4548 | - 'day' => $d); | |
4549 | - $ipath = TEMPLATE::fill($tpath, $param); | |
4550 | - $query = 'SELECT ititle as result FROM %s WHERE inumber = %d'; | |
4551 | - $iname = quickQuery(sprintf($query, sql_table('item'), $item_id)); | |
2140 | + 'day' => $d | |
2141 | + ); | |
2142 | + $ipath = TEMPLATE::fill($tpath, $param); | |
2143 | + $query = 'SELECT ititle as result FROM %s WHERE inumber = %d'; | |
2144 | + $iname = quickQuery(sprintf($query, sql_table('item'), $item_id)); | |
4552 | 2145 | $blog_id = intval(getBlogIDFromItemID($item_id)); |
4553 | 2146 | $this->RegistPath($item_id, $ipath, $blog_id, 'item', $iname, TRUE); |
4554 | 2147 | } |
@@ -4573,20 +2166,22 @@ class NP_CustomURL extends NucleusPlugin | ||
4573 | 2166 | |
4574 | 2167 | function event_PostUpdateItem($data) |
4575 | 2168 | { |
4576 | - $tpath = requestVar('plug_custom_url_path'); | |
2169 | + $tpath = requestVar('plug_custom_url_path'); | |
4577 | 2170 | $item_id = intval($data['itemid']); |
4578 | - $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
4579 | - $itime = quickQuery(sprintf($tque ,sql_table('item'), $item_id)); | |
2171 | + $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; | |
2172 | + $itime = quickQuery(sprintf($tque ,sql_table('item'), $item_id)); | |
4580 | 2173 | // $itimestamp = strtotime($itime); |
4581 | 2174 | // $tt = explode(',', date('Y,m,d', $itimestamp)); |
4582 | 2175 | $y = $m = $d = $temp = ''; |
4583 | 2176 | sscanf($itime, '%d-%d-%d %s', $y, $m, $d, $temp); |
4584 | - $param = array ('year' => $y, | |
4585 | - 'month' => $m, | |
4586 | - 'day' => $d); | |
4587 | - $ipath = TEMPLATE::fill($tpath, $param); | |
4588 | - $query = 'SELECT ititle as result FROM %s WHERE inumber = %d'; | |
4589 | - $iname = quickQuery(sprintf($query, sql_table('item'), $item_id)); | |
2177 | + $param = array ( | |
2178 | + 'year' => $y, | |
2179 | + 'month' => $m, | |
2180 | + 'day' => $d | |
2181 | + ); | |
2182 | + $ipath = TEMPLATE::fill($tpath, $param); | |
2183 | + $query = 'SELECT ititle as result FROM %s WHERE inumber = %d'; | |
2184 | + $iname = quickQuery(sprintf($query, sql_table('item'), $item_id)); | |
4590 | 2185 | $blog_id = intval(getBlogIDFromItemID($item_id)); |
4591 | 2186 | $this->RegistPath($item_id, $ipath, $blog_id, 'item', $iname); |
4592 | 2187 | } |
@@ -4595,13 +2190,15 @@ class NP_CustomURL extends NucleusPlugin | ||
4595 | 2190 | { |
4596 | 2191 | global $CONF; |
4597 | 2192 | if ($item_id) { |
4598 | - $query = 'SELECT obj_name as result FROM %s' | |
4599 | - . ' WHERE obj_param = "item" AND obj_id = %d'; | |
2193 | + $query = 'SELECT obj_name as result' | |
2194 | + . ' FROM %s' | |
2195 | + . ' WHERE obj_param = "item"' | |
2196 | + . ' AND obj_id = %d'; | |
4600 | 2197 | $item_id = intval($item_id); |
4601 | - $res = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $item_id)); | |
4602 | - $ipath = substr($res, 0, strlen($res)-5); | |
2198 | + $res = quickQuery(sprintf($query, _CUSTOMURL_TABLE, $item_id)); | |
2199 | + $ipath = substr($res, 0, strlen($res)-5); | |
4603 | 2200 | } else { |
4604 | - $ipath = $this->getOption('customurl_dfitem'); | |
2201 | + $ipath = $this->getOption('customurl_dfitem'); | |
4605 | 2202 | } |
4606 | 2203 | echo <<<OUTPUT |
4607 | 2204 | <h3>Custom URL</h3> |
@@ -4648,7 +2245,7 @@ OUTPUT; | ||
4648 | 2245 | } elseif ($arch_option || $arvs_option || $memd_option) { |
4649 | 2246 | if (!ereg("^[-_a-zA-Z0-9]+$", $data['value'])) { |
4650 | 2247 | $name = substr($data['optionname'], 8); |
4651 | - $msg = array (1, _INVALID_ERROR, $name, _INVALID_MSG); | |
2248 | + $msg = array (1, _INVALID_ERROR, $name, _INVALID_MSG); | |
4652 | 2249 | $this->error($msg); |
4653 | 2250 | exit; |
4654 | 2251 | } else { |
@@ -4705,9 +2302,11 @@ OUTPUT; | ||
4705 | 2302 | $y = $m = $d = $temp = ''; |
4706 | 2303 | sscanf($itime, '%d-%d-%d %s', $y, $m, $d, $temp); |
4707 | 2304 | $template = $this->getOption('customurl_dfitem'); |
4708 | - $param = array ('year' => $y, | |
2305 | + $param = array ( | |
2306 | + 'year' => $y, | |
4709 | 2307 | 'month' => $m, |
4710 | - 'day' => $d); | |
2308 | + 'day' => $d | |
2309 | + ); | |
4711 | 2310 | $ikey = TEMPLATE::fill($template, $param); |
4712 | 2311 | if ($path == $ikey) { |
4713 | 2312 | $path = $ikey . '_' . $objID; |
@@ -4732,9 +2331,9 @@ OUTPUT; | ||
4732 | 2331 | if ($oParam == 'item' || $oParam == 'member') $tempPath .= '.html'; |
4733 | 2332 | $conf_que = 'SELECT obj_id FROM %s' |
4734 | 2333 | . ' WHERE obj_name = "%s"' |
4735 | - . ' AND obj_bid = %d' | |
4736 | - . ' AND obj_param = "%s"' | |
4737 | - . ' AND obj_id != %d'; | |
2334 | + . ' AND obj_bid = %d' | |
2335 | + . ' AND obj_param = "%s"' | |
2336 | + . ' AND obj_id != %d'; | |
4738 | 2337 | $res = sql_query(sprintf($conf_que, _CUSTOMURL_TABLE, $tempPath, $bid, $oParam, $objID)); |
4739 | 2338 | if ($res && mysql_num_rows($res)) { |
4740 | 2339 | $msg = array (0, _CONFLICT_ERROR, $name, _CONFLICT_MSG); |