示例#1
0
 /**
  * Shows a list of all blogs in the system using a given template
  * ordered by  number, name, shortname or description
  * in ascending or descending order
  */
 function showBlogList($template, $bnametype, $orderby, $direction)
 {
     global $CONF, $manager;
     switch ($orderby) {
         case 'number':
             $orderby = 'bnumber';
             break;
         case 'name':
             $orderby = 'bname';
             break;
         case 'shortname':
             $orderby = 'bshortname';
             break;
         case 'description':
             $orderby = 'bdesc';
             break;
         default:
             $orderby = 'bnumber';
             break;
     }
     $direction = strtolower($direction);
     switch ($direction) {
         case 'asc':
             $direction = 'ASC';
             break;
         case 'desc':
             $direction = 'DESC';
             break;
         default:
             $direction = 'ASC';
             break;
     }
     $template =& $manager->getTemplate($template);
     echo TEMPLATE::fill(isset($template['BLOGLIST_HEADER']) ? $template['BLOGLIST_HEADER'] : null, array('sitename' => $CONF['SiteName'], 'siteurl' => $CONF['IndexURL']));
     $query = 'SELECT bnumber, bname, bshortname, bdesc, burl FROM ' . sql_table('blog') . ' ORDER BY ' . $orderby . ' ' . $direction;
     $res = sql_query($query);
     while ($data = sql_fetch_assoc($res)) {
         $list = array();
         //			$list['bloglink'] = createLink('blog', array('blogid' => $data['bnumber']));
         $list['bloglink'] = createBlogidLink($data['bnumber']);
         $list['blogdesc'] = $data['bdesc'];
         $list['blogurl'] = $data['burl'];
         if ($bnametype == 'shortname') {
             $list['blogname'] = $data['bshortname'];
         } else {
             // all other cases
             $list['blogname'] = $data['bname'];
         }
         $manager->notify('PreBlogListItem', array('listitem' => &$list));
         echo TEMPLATE::fill(isset($template['BLOGLIST_LISTITEM']) ? $template['BLOGLIST_LISTITEM'] : null, $list);
     }
     sql_free_result($res);
     echo TEMPLATE::fill(isset($template['BLOGLIST_FOOTER']) ? $template['BLOGLIST_FOOTER'] : null, array('sitename' => $CONF['SiteName'], 'siteurl' => $CONF['IndexURL']));
 }
 function doAction($type = '')
 {
     global $CONF, $manager;
     if (!$type) {
         $type = 'google';
     }
     if ($type !== 'google' && $type !== 'yahoo') {
         return;
     }
     $sitemap = array();
     $blog_res = sql_query('SELECT * FROM ' . sql_table('blog'));
     while ($blog = sql_fetch_array($blog_res)) {
         if ($this->getBlogOption($blog['bnumber'], 'IncludeSitemap') == 'yes') {
             if ($blog['bnumber'] != $CONF['DefaultBlog']) {
                 $sitemap[] = array('loc' => $this->_prepareLink($blog['bnumber'], createBlogidLink($blog['bnumber'])), 'priority' => '1.0', 'changefreq' => 'daily');
             } else {
                 $sitemap[] = array('loc' => $blog['burl'], 'priority' => '1.0', 'changefreq' => 'daily');
             }
             $params = array(sql_table('category'), $blog['bnumber']);
             $cat_res = sql_query(vsprintf('SELECT * FROM %s WHERE cblog=%s ORDER BY catid', $params));
             while ($cat = sql_fetch_array($cat_res)) {
                 $sitemap[] = array('loc' => $this->_prepareLink($blog['bnumber'], createCategoryLink($cat['catid'])), 'priority' => '1.0', 'changefreq' => 'daily');
             }
             $b =& $manager->getBlog($blog['bnumber']);
             $item_res = sql_query('
                 SELECT 
                     *,
                     UNIX_TIMESTAMP(itime) AS timestamp
                 FROM 
                     ' . sql_table('item') . ' 
                 WHERE
                     iblog = ' . $blog['bnumber'] . ' AND
                     idraft = 0
                     AND itime <= ' . mysqldate($b->getCorrectTime()) . '
                 ORDER BY 
                     inumber DESC
             ');
             $now = $_SERVER['HTTP_REQUEST_TIME'];
             while ($item = sql_fetch_array($item_res)) {
                 $tz = date('O', $item['timestamp']);
                 $tz = substr($tz, 0, 3) . ':' . substr($tz, 3, 2);
                 $pasttime = $now - $item['timestamp'];
                 if ($pasttime < 86400 * 2) {
                     $fq = 'hourly';
                 } elseif ($pasttime < 86400 * 14) {
                     $fq = 'daily';
                 } elseif ($pasttime < 86400 * 62) {
                     $fq = 'weekly';
                 } else {
                     $fq = 'monthly';
                 }
                 $sitemap[] = array('loc' => $this->_prepareLink($blog['bnumber'], createItemLink($item['inumber'])), 'lastmod' => gmdate('Y-m-d\\TH:i:s', $item['timestamp']) . $tz, 'priority' => '1.0', 'changefreq' => $fq);
             }
         }
     }
     $eventdata = array('sitemap' => &$sitemap);
     $manager->notify('SiteMap', $eventdata);
     if ($type == 'google') {
         header("Content-type: application/xml");
         echo "<?xml version='1.0' encoding='UTF-8'?>\n\n";
         echo "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' ";
         echo "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' ";
         echo "xsi:schemaLocation='http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd'>\n";
         $tpl = "\t\t<%s>%s</%s>\n";
         foreach ($sitemap as $url) {
             echo "\t<url>\n";
             foreach ($url as $key => $value) {
                 echo sprintf($tpl, $key, htmlspecialchars($value, ENT_QUOTES, _CHARSET), $key);
             }
             echo "\t</url>\n";
         }
         echo "</urlset>\n";
     } else {
         header("Content-type: text/plain");
         foreach ($sitemap as $url) {
             echo $url['loc'] . "\n";
         }
     }
     exit;
 }
示例#3
0
 function creatTagLink($tag, $narrowMode = 0, $ready = '', $sep = '')
 {
     global $manager, $CONF, $blogid, $catid;
     //, $subcatid;
     $linkparams = array();
     if (is_numeric($blogid)) {
         $blogid = intval($blogid);
     } else {
         $blogid = intval(getBlogIDFromName($blogid));
     }
     if (!$blogid) {
         $blogid = $CONF['DefaultBlog'];
     }
     $b =& $manager->getBlog($blogid);
     if ($narrowMode == 2) {
         if ($catid) {
             $linkparams['catid'] = intval($catid);
         }
         if ($manager->pluginInstalled('NP_MultipleCategories')) {
             $mcategories =& $manager->getPlugin('NP_MultipleCategories');
             if (method_exists($mcategories, 'getRequestName')) {
                 $subrequest = $mcategories->getRequestName();
             } else {
                 $subrequest = 'subcatid';
             }
             $mcategories->event_PreSkinParse(array());
             global $subcatid;
             if ($subcatid) {
                 $linkparams[$subrequest] = intval($subcatid);
             }
         }
     }
     if (!empty($ready)) {
         $ready = rawurldecode($ready);
         $requestTagsArray = $this->splitRequestTags($ready);
         foreach ($requestTagsArray['and'] as $key => $val) {
             if (!$this->_isValidTag($val)) {
                 $trush = array_splice($requestTagsArray['and'], $key, 1);
             }
         }
         $reqAnd = implode('+', $requestTagsArray['and']);
         if (!empty($requestTagsArray['or'])) {
             foreach ($requestTagsArray['or'] as $key => $val) {
                 if (!$this->_isValidTag($val)) {
                     $trush = array_splice($requestTagsArray['and'], $key, 1);
                 }
             }
             $reqOr = ':' . implode(':', $requestTagsArray['or']);
         }
         $ready = $reqAnd . $reqOr;
     }
     if (!$ready) {
         $sep = '';
     }
     $linkparams['tag'] = $ready . $sep . $tag;
     $uri = createBlogidLink($blogid, $linkparams);
     if (strstr($uri, '//')) {
         $uri = preg_replace("@([^:])//@", "\$1/", $uri);
     }
     return $uri;
 }
示例#4
0
 function event_ParseURL($data)
 {
     global $CONF, $manager, $curl_blogid, $blogid, $itemid, $catid;
     global $memberid, $archivelist, $archive, $query;
     // initialize
     $info = $data['info'];
     $complete =& $data['complete'];
     if ($complete) {
         return;
     }
     $useCustomURL = $this->getAllBlogOptions('use_customurl');
     // Use NP_MultipleCategories ?
     $mcategories = $this->pluginCheck('MultipleCategories');
     if ($mcategories) {
         $param = array();
         $mcategories->event_PreSkinParse($param);
         global $subcatid;
         if (method_exists($mcategories, 'getRequestName')) {
             $subrequest = $mcategories->getRequestName();
         } else {
             $subrequest = 'subcatid';
         }
     }
     // initialize and sanitize '$blogid'
     if (!$blogid) {
         if (getVar('blogid')) {
             if (is_numeric(getVar('blogid'))) {
                 $blogid = intval(getVar('blogid'));
             } else {
                 $blogid = intval(getBlogIDFromName(getVar('blogid')));
             }
         } elseif ($curl_blogid) {
             $blogid = intval($curl_blogid);
         } elseif ($itemid > 0) {
             //2008-09-19 Cacher
             $blogid = getBlogIDFromItemID($itemid);
         } else {
             $blogid = $CONF['DefaultBlog'];
         }
         //2008-09-19 Cacher
     } else {
         if (is_numeric($blogid)) {
             $blogid = intval($blogid);
         } else {
             $blogid = intval(getBlogIDFromName($blogid));
         }
     }
     if (!$info) {
         if (serverVar('PATH_INFO')) {
             $info = serverVar('PATH_INFO');
         } elseif (getNucleusVersion() < 330) {
             if (getVar('virtualpath')) {
                 $info = getVar('virtualpath');
             }
         } else {
             if (getVar('query')) {
                 $info = serverVar('REQUEST_URI');
             } else {
                 return;
             }
             //by nekonosippo 2008-04-06 http://japan.nucleuscms.org/bb/viewtopic.php?p=22351#22351
         }
     }
     // Sanitize 'PATH_INFO'
     $info = trim($info, '/');
     $v_path = explode("/", $info);
     foreach ($v_path as $key => $value) {
         $value = urlencode($value);
         $value = preg_replace('|[^a-zA-Z0-9-~+_.?#=&;,/:@%]|i', '', $value);
         $v_path[$key] = $value;
     }
     if (phpversion() >= '4.1.0') {
         $_SERVER['PATH_INFO'] = implode('/', $v_path);
     }
     global $HTTP_SERVER_VARS;
     $HTTP_SERVER_VARS['PATH_INFO'] = implode('/', $v_path);
     // Admin area check
     $tmpURL = sprintf("%s%s%s", "http://", serverVar("HTTP_HOST"), serverVar("SCRIPT_NAME"));
     $uri = str_replace('/', '\\/', $tmpURL);
     $plug_url = str_replace('/', '\\/', $CONF['PluginURL']);
     $u_plugAction = getVar('action') == 'plugin' && getVar('name');
     $UsingPlugAdmin = FALSE;
     if (strpos($uri, $plug_url) === 0 || $u_plugAction) {
         $UsingPlugAdmin = TRUE;
     }
     // get real blogid
     $blink = FALSE;
     if (empty($info)) {
         $bLink = TRUE;
     }
     $linkObj = array('bid' => 0, 'name' => reset($v_path), 'linkparam' => 'blog');
     $blog_id = $this->getRequestPathInfo($linkObj);
     if ($blog_id) {
         $blogid = $blog_id;
         $trush = array_shift($v_path);
         $bLink = TURE;
     }
     if ($useCustomURL[$blogid] == 'no') {
         return;
     }
     // redirect to other URL style
     $useCustomURLyes = $useCustomURL[$blogid] == 'yes';
     if ($useCustomURLyes && !$UsingPlugAdmin && !$CONF['UsingAdminArea']) {
         // Search query redirection
         // 301 permanent ? or 302 temporary ?
         $queryURL = strpos(serverVar('REQUEST_URI'), 'query=') !== FALSE;
         $search_q = getVar('query') || $queryURL;
         $redirectSerch = $this->getBlogOption($blogid, 'redirect_search') == 'yes';
         if ($redirectSerch) {
             if ($search_q) {
                 $que_str = getVar('query');
                 $que_str = $this->hsc($que_str);
                 if (extension_loaded('mbstring')) {
                     $que_str = str_replace('/', md5('/'), $que_str);
                     $que_str = str_replace("'", md5("'"), $que_str);
                     $que_str = str_replace('&', md5('&'), $que_str);
                 } else {
                     $que_str = str_replace('/', md5('/'), $que_str);
                     $que_str = str_replace("'", md5("'"), $que_str);
                     $que_str = str_replace('&', md5('&'), $que_str);
                 }
                 $que_str = urlencode($que_str);
                 $search_path = 'search/' . $que_str;
                 $b_url = createBlogidLink($blogid);
                 $redurl = sprintf("%s%s", $b_url, $search_path);
                 redirect($redurl);
                 // 302 Moved temporary
                 exit;
             }
         }
         $exLink = FALSE;
         if (!$redirectSerch && $search_q) {
             $exLink = TRUE;
         }
         // redirection nomal URL to FancyURL
         $temp_req = explode('?', serverVar('REQUEST_URI'));
         $reqPath = trim(end($temp_req), '/');
         $indexrdf = $reqPath == 'xml-rss1.php';
         $atomfeed = $reqPath == 'atom.php';
         $rss2feed = $reqPath == 'xml-rss2.php';
         $feeds = $indexrdf || $atomfeed || $rss2feed;
         $redirectNormal = $this->getBlogOption($blogid, 'redirect_normal') == 'yes';
         if ($redirectNormal && serverVar('QUERY_STRING') && !$feeds && !$exLink) {
             $temp = explode('&', serverVar('QUERY_STRING'));
             foreach ($temp as $k => $val) {
                 if (preg_match('/^virtualpath/', $val)) {
                     unset($temp[$k]);
                 }
             }
             if (!empty($temp)) {
                 $p_arr = array();
                 foreach ($temp as $key => $value) {
                     $p_key = explode('=', $value);
                     switch (reset($p_key)) {
                         case 'blogid':
                             $p_arr[] = $CONF['BlogKey'] . '/' . intGetVar('blogid');
                             unset($temp[$key]);
                             break;
                         case 'catid':
                             $p_arr[] = $CONF['CategoryKey'] . '/' . intGetVar('catid');
                             unset($temp[$key]);
                             break;
                         case $subrequest:
                             $p_arr[] = $subrequest . '/' . intGetVar($subrequest);
                             unset($temp[$key]);
                             break;
                         case 'itemid':
                             $p_arr[] = $CONF['ItemKey'] . '/' . intGetVar('itemid');
                             unset($temp[$key]);
                             break;
                         case 'memberid':
                             $p_arr[] = $CONF['MemberKey'] . '/' . intGetVar('memberid');
                             unset($temp[$key]);
                             break;
                         case 'archivelist':
                             $p_arr[] = $CONF['ArchivesKey'] . '/' . $blogid;
                             unset($temp[$key]);
                             break;
                         case 'archive':
                             $p_arr[] = $CONF['ArchiveKey'] . '/' . $blogid . '/' . getVar('archive');
                             unset($temp[$key]);
                             break;
                         default:
                             break;
                     }
                 }
                 if (!empty($temp)) {
                     $queryTemp = '/?' . implode('&', $temp);
                 }
                 if (reset($p_arr)) {
                     $b_url = createBlogidLink($blogid);
                     $red_path = '/' . implode('/', $p_arr);
                     if (substr($b_url, -1) == '/') {
                         $b_url = rtrim($b_url, '/');
                     }
                     $redurl = sprintf("%s%s", $b_url, $red_path) . $queryTemp;
                     // HTTP status 301 "Moved Permanentry"
                     header('HTTP/1.1 301 Moved Permanently');
                     header('Location: ' . $redurl);
                     exit;
                 }
             }
         } elseif ($redirectNormal && $feeds) {
             $b_url = rtrim(createBlogidLink($blogid), '/');
             switch ($reqPath) {
                 case 'xml-rss1.php':
                     $feed_code = '/index.rdf';
                     break;
                 case 'xml-rss2.php':
                     $feed_code = '/rss2.xml';
                     break;
                 case 'atom.php':
                     $feed_code = '/atom.xml';
                     break;
                 default:
                     break;
             }
             // HTTP status 301 "Moved Permanentry"
             header('HTTP/1.1 301 Moved Permanently');
             header('Location: ' . $b_url . $feed_code);
             exit;
         }
     }
     // decode path_info
     // decode unofficial Page switch '/page_2.html'
     /*		foreach($v_path as $pathName) {
     			if (preg_match('/^page_/', $pathName)) {
     				$temp_info    = explode('page_', $pathName);
     				$_GET['page'] = intval($temp_info[1]);
     				$page         = array_pop($v_path);
     			}
     		}*/
     // decode TrackBack URL shorten ver.
     $tail = end($v_path);
     if (substr($tail, -10, 10) == '.trackback') {
         $v_pathName = substr($tail, 0, -10);
         if (is_numeric($v_pathName) || substr($v_pathName, -5) == '.html') {
             $this->_trackback($blogid, $v_pathName);
         } else {
             $this->_trackback($blogid, $v_pathName . '.html');
         }
         return;
     }
     // decode other type URL
     //		$bLink = $cLink = $iLink = $exLink = FALSE;
     $cLink = $iLink = $exLink = FALSE;
     $i = 1;
     $NP_ExtraSkinJPFlag = FALSE;
     $redURI = NULL;
     $sc = NULL;
     foreach ($v_path as $pathName) {
         switch ($pathName) {
             // decode FancyURLs and redirection to Customized URL
             // for blogsgetAllBlogOptions($name)
             case $CONF['BlogKey']:
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[intval($v_path[$i])] != 'yes') {
                         $blogid = intval($v_path[$i]);
                         $bLink = TRUE;
                     } else {
                         $redURI = createBlogidLink(intval($v_path[$i]));
                     }
                 }
                 break;
                 // for items
             // for items
             case $CONF['ItemKey']:
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $itemid = intval($v_path[$i]);
                         $iLink = TRUE;
                     } else {
                         $redURI = createItemLink(intval($v_path[$i]));
                     }
                 }
                 break;
                 // for categories
             // for categories
             case $CONF['CategoryKey']:
             case 'catid':
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $catid = intval($v_path[$i]);
                         $cLink = TRUE;
                     } else {
                         $redURI = createCategoryLink(intval($v_path[$i]));
                     }
                 }
                 break;
                 // for subcategories
             // for subcategories
             case $subrequest:
                 $c = $i - 2;
                 $subCat = isset($v_path[$i]) && is_numeric($v_path[$i]);
                 if ($mcategories && $subCat && $i >= 3 && is_numeric($v_path[$c])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $subcatid = intval($v_path[$i]);
                         $catid = intval($v_path[$c]);
                         $cLink = TRUE;
                     } else {
                         $subcat_id = intval($v_path[$i]);
                         $catid = intval($v_path[$c]);
                         $linkParam = array($subrequest => $subcat_id);
                         $redURI = createCategoryLink($catid, $linkParam);
                     }
                 }
                 break;
                 // for archives
             // for archives
             case $CONF['ArchivesKey']:
             case $this->getOption('customurl_archives'):
                 // FancyURL
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[intval($v_path[$i])] != 'yes') {
                         $archivelist = intval($v_path[$i]);
                         $blogid = $archivelist;
                         $exLink = TRUE;
                     } else {
                         $redURI = createArchiveListLink(intval($v_path[$i]));
                     }
                     // Customized URL
                 } elseif (isset($v_path[$i]) && strpos($v_path[$i], 'page') === FALSE) {
                     $archivelist = $blogid;
                     $redURI = createArchiveListLink($archivelist);
                 } else {
                     $archivelist = $blogid;
                     $exLink = TRUE;
                 }
                 break;
                 // for archive
             // for archive
             case $CONF['ArchiveKey']:
             case $this->getOption('customurl_archive'):
                 $y = $m = $d = '';
                 $ar = $i + 1;
                 if (isset($v_path[$i])) {
                     $darc = preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/', $v_path[$i]);
                     $marc = preg_match('/([0-9]{4})-([0-9]{1,2})/', $v_path[$i]);
                     $yarc = preg_match('/([0-9]{4})/', $v_path[$i]);
                     if (isset($v_path[$ar])) {
                         $adarc = preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/', $v_path[$ar]);
                         $amarc = preg_match('/([0-9]{4})-([0-9]{1,2})/', $v_path[$ar]);
                         $ayarc = preg_match('/([0-9]{4})/', $v_path[$ar]);
                     } else {
                         $adarc = $amarc = $ayarc = NULL;
                     }
                     $arc = !$darc && !$marc && !$yarc;
                     $aarc = $adarc || $amarc || $ayarc;
                     $carc = $darc || $marc || $yarc;
                     // FancyURL
                     if (is_numeric($v_path[$i]) && $arc && isset($v_path[$ar]) && $aarc) {
                         sscanf($v_path[$ar], '%d-%d-%d', $y, $m, $d);
                         if (!empty($d)) {
                             $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
                         } elseif (!empty($m)) {
                             $archive = sprintf('%04d-%02d', $y, $m);
                         } else {
                             $archive = sprintf('%04d', $y);
                         }
                         if ($useCustomURL[intval($v_path[$i])] != 'yes') {
                             $blogid = intval($v_path[$i]);
                             $exLink = TRUE;
                         } else {
                             $blogid = intval($v_path[$i]);
                             $redURI = createArchiveLink($blogid, $archive);
                         }
                         // Customized URL
                     } elseif ($carc) {
                         sscanf($v_path[$i], '%d-%d-%d', $y, $m, $d);
                         if (!empty($d)) {
                             $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
                         } elseif (!empty($m)) {
                             $archive = sprintf('%04d-%02d', $y, $m);
                         } else {
                             $archive = sprintf('%04d', $y);
                         }
                         $exLink = TRUE;
                     } else {
                         $redURI = createArchiveListLink($blogid);
                     }
                 } else {
                     $redURI = createArchiveListLink($blogid);
                 }
                 break;
                 // for member
             // for member
             case $CONF['MemberKey']:
             case $this->getOption('customurl_member'):
                 // Customized URL
                 $customMemberURL = substr($v_path[$i], -5, 5) == '.html';
                 if (isset($v_path[$i]) && $customMemberURL) {
                     $memberInfo = array('linkparam' => 'member', 'bid' => 0, 'name' => $v_path[$i]);
                     $member_id = $this->getRequestPathInfo($memberInfo);
                     $memberid = intval($member_id);
                     $exLink = TRUE;
                     // FancyURL
                 } elseif (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $memberid = intval($v_path[$i]);
                         $exLink = TRUE;
                     } else {
                         $redURI = createMemberLink(intval($v_path[$i]));
                     }
                 } else {
                     $redURI = createBlogidLink($blogid);
                 }
                 break;
                 // for tag
                 // for pageswitch
             // for tag
             // for pageswitch
             case 'tag':
                 //					if ($this->pluginCheck(TagEx)) $exLink = true;
                 if ($this->pluginCheck(TagEX)) {
                     $exLink = true;
                 }
                 break;
                 //2008-07-28 http://japan.nucleuscms.org/bb/viewtopic.php?p=23175#23175
             //2008-07-28 http://japan.nucleuscms.org/bb/viewtopic.php?p=23175#23175
             case 'page':
                 $exLink = TRUE;
                 break;
                 // for ExtraSkinJP
             // for ExtraSkinJP
             case 'extra':
                 $ExtraSkinJP = $this->pluginCheck('ExtraSkinJP');
                 if ($ExtraSkinJP) {
                     $NP_ExtraSkinJPFlag = TRUE;
                 }
                 break;
                 // for search query
             // for search query
             case 'search':
                 $redirectSerch = $this->getBlogOption($blogid, 'redirect_search') == 'yes';
                 if ($redirectSerch) {
                     $que_str = urldecode($v_path[$i]);
                     if (extension_loaded('mbstring')) {
                         $que_str = str_ireplace(md5('/'), '/', $que_str);
                         $que_str = str_ireplace(md5("'"), "'", $que_str);
                         $que_str = str_ireplace(md5('&'), '&', $que_str);
                     } else {
                         $que_str = str_ireplace(md5('/'), '/', $que_str);
                         $que_str = str_ireplace(md5("'"), "'", $que_str);
                         $que_str = str_ireplace(md5('&'), '&', $que_str);
                     }
                     $que_str = htmlspecialchars_decode($que_str);
                     $_GET['query'] = $que_str;
                     $query = $que_str;
                     $exLink = TRUE;
                 }
                 break;
                 // for tDiarySkin
             // for tDiarySkin
             case 'tdiarydate':
             case 'categorylist':
             case 'monthlimit':
                 $tDiaryPlugin = $this->pluginCheck('tDiarySkin');
                 if ($tDiaryPlugin && isset($v_path[$i])) {
                     $_GET[$pathName] = $v_path[$i];
                     $exLink = TRUE;
                 }
                 break;
             case 'special':
             case $CONF['SpecialskinKey']:
                 if (isset($v_path[$i]) && is_string($v_path[$i])) {
                     $_REQUEST['special'] = $v_path[$i];
                     $exLink = TRUE;
                 }
                 break;
                 // for trackback
             // for trackback
             case 'trackback':
                 if (isset($v_path[$i]) && is_string($v_path[$i])) {
                     $this->_trackback($blogid, $v_path[$i]);
                 }
                 return;
                 break;
                 // decode Customized URL
             // decode Customized URL
             default:
                 // initialyze
                 $linkObj = array('bid' => $blogid, 'name' => $pathName);
                 $comp = FALSE;
                 $isItem = substr($pathName, -5) == '.html';
                 // category ?
                 if (!$comp && !$cLink && !$iLink && !$isItem && !$exLink) {
                     //2007-10-06 http://japan.nucleuscms.org/bb/viewtopic.php?p=20641#20641
                     $linkObj['linkparam'] = 'category';
                     $cat_id = $this->getRequestPathInfo($linkObj);
                     if (!empty($cat_id)) {
                         $catid = intval($cat_id);
                         $cLink = TRUE;
                         $comp = TRUE;
                     }
                 }
                 // subcategory ?
                 if (!$comp && $cLink && !$iLink && $mcategories && !$isItem && !$exLink) {
                     //2007-10-06 http://japan.nucleuscms.org/bb/viewtopic.php?p=20641#20641
                     $linkObj['linkparam'] = 'subcategory';
                     $linkObj['bid'] = $catid;
                     $subcat_id = $this->getRequestPathInfo($linkObj);
                     if (!empty($subcat_id)) {
                         $_REQUEST[$subrequest] = intval($subcat_id);
                         $subcatid = intval($subcat_id);
                         $sc = $i;
                         $comp = TRUE;
                     }
                 }
                 // item ?
                 if ($isItem) {
                     $linkObj['linkparam'] = 'item';
                     $item_id = $this->getRequestPathInfo($linkObj);
                     if (!empty($item_id)) {
                         $itemid = intval($item_id);
                         $iLink = TRUE;
                     }
                     if (preg_match('/^page_/', $pathName)) {
                         $iLink = TRUE;
                     }
                     //var_dump($linkObj);
                 }
                 break;
         }
         if (preg_match('/^[0-9page]$/', $pathName)) {
             $exLink = $pathName;
         }
         $i++;
     }
     if ($NP_ExtraSkinJPFlag) {
         $this->goNP_ExtraSkinJP();
     }
     // FancyURL redirect to Customized URL if use it
     // HTTP status 301 "Moved Permanentry"
     if ($redURI) {
         if (strpos(serverVar('REQUEST_URI'), '?') !== FALSE) {
             list($trush, $tempQueryString) = explode('?', serverVar('REQUEST_URI'), 2);
         }
         if ($tempQueryString) {
             $temp = explode('&', $tempQueryString);
             foreach ($temp as $k => $val) {
                 if (preg_match('/^virtualpath/', $val)) {
                     unset($temp[$k]);
                 }
             }
             if (!empty($temp)) {
                 $tempQueryString = '?' . implode('&', $temp);
             }
         }
         header('HTTP/1.1 301 Moved Permanently');
         header('Location: ' . $redURI . $tempQueryString);
         exit;
     }
     $feedurl = array('rss1.xml', 'index.rdf', 'rss2.xml', 'atom.xml');
     $siteMapPlugin = $this->pluginCheck('GoogleSitemap');
     if (!$siteMapPlugin) {
         $siteMapPlugin = $this->pluginCheck('SEOSitemaps');
     }
     if ($siteMapPlugin) {
         $pcSitemaps = $siteMapPlugin->getAllBlogOptions('PcSitemap');
         foreach ($pcSitemaps as $pCsitemap) {
             if ($pCsitemap) {
                 $feedurl[] = $pCsitemap;
             }
         }
         $mobSitemaps = $siteMapPlugin->getAllBlogOptions('MobileSitemap');
         foreach ($mobSitemaps as $mobSitemap) {
             if ($mobSitemap) {
                 $feedurl[] = $mobSitemap;
             }
         }
     }
     $feedurl = array_unique($feedurl);
     $request_path = end($v_path);
     $feeds = in_array($request_path, $feedurl, true);
     // finish decode
     if (!$exLink && !$feeds) {
         // URL Not Found
         if (substr(end($v_path), -5) == '.html' && !$iLink) {
             $notFound = TRUE;
             if (!empty($subcatid)) {
                 $linkParam = array($subrequest => $subcatid);
                 $uri = createCategoryLink($catid, $linkParam);
             } elseif (!empty($catid)) {
                 $uri = createCategoryLink($catid);
             } else {
                 $uri = createBlogidLink($blogid);
             }
         } elseif (count($v_path) > $sc && !empty($subcatid) && !$iLink) {
             $notFound = TRUE;
             $linkParam = array($subrequest => $subcatid);
             $uri = createCategoryLink($catid, $linkParam);
         } elseif (count($v_path) >= 2 && !$subcatid && !$iLink) {
             $notFound = TRUE;
             if (isset($catid)) {
                 $uri = createCategoryLink($catid);
             } else {
                 $uri = createBlogidLink($blogid);
             }
         } elseif (reset($v_path) && !$catid && !$subcatid && !$iLink) {
             $notFound = TRUE;
             $uri = createBlogidLink($blogid);
         } else {
             // Found
             // setting $CONF['Self'] for other plugins
             $uri = createBlogidLink($blogid);
             $CONF['Self'] = rtrim($uri, '/');
             $CONF['BlogURL'] = rtrim($uri, '/');
             $CONF['ItemURL'] = rtrim($uri, '/');
             $CONF['CategoryURL'] = rtrim($uri, '/');
             $CONF['ArchiveURL'] = rtrim($uri, '/');
             $CONF['ArchiveListURL'] = rtrim($uri, '/');
             $complete = TRUE;
             return;
         }
     } else {
         $uri = createBlogidLink($blogid);
         $CONF['Self'] = rtrim($uri, '/');
         $CONF['BlogURL'] = rtrim($uri, '/');
         $CONF['ItemURL'] = rtrim($uri, '/');
         $CONF['CategoryURL'] = rtrim($uri, '/');
         $CONF['ArchiveURL'] = rtrim($uri, '/');
         $CONF['ArchiveListURL'] = rtrim($uri, '/');
         $complete = TRUE;
         return;
     }
     // Behavior Not Found
     if ($notFound) {
         if (substr($uri, -1) != '/') {
             $uri .= '/';
         }
         if ($this->getOption('customurl_notfound') == '404') {
             header('HTTP/1.1 404 Not Found');
             doError(_NO_SUCH_URI);
             exit;
         } else {
             header('HTTP/1.1 303 See Other');
             header('Location: ' . $uri);
             exit;
         }
     }
 }
示例#5
0
 /**
  *	Parse skinvar todaylink
  *	A link to the today page (depending on selected blog, etc...)
  */
 function parse_todaylink($linktext = '')
 {
     global $blog, $CONF;
     if ($blog) {
         echo $this->_link(createBlogidLink($blog->getID(), $this->linkparams), $linktext);
     } else {
         echo $this->_link($CONF['SiteUrl'], $linktext);
     }
 }