function nm_get_url($query = false) { global $PRETTYURLS, $NMPAGEURL, $NMPRETTYURLS; $str = ''; $url = find_url($NMPAGEURL, nm_get_parent()); if ($query) { switch ($query) { case 'post': $query = NMPARAMPOST; break; case 'page': $query = NMPARAMPAGE; break; case 'tag': $query = NMPARAMTAG; break; case 'archive': $query = NMPARAMARCHIVE; break; } if ($PRETTYURLS == 1 && $NMPRETTYURLS == 'Y') { if ($query == NMPARAMPOST && defined('NMNOPARAMPOST') && NMNOPARAMPOST) { $str = ''; } else { $str = $query . '/'; } if (substr($url, -1) != '/') { $str = '/' . $str; } } else { $str = strpos($url, '?') === false ? '?' : '&'; $str .= $query . '='; } } return $url . $str; }
function nm_generate_htaccess() { global $NMPAGEURL, $PERMALINK; $path = tsl(suggest_site_path(true)); $prefix = ''; $page = ''; # format prefix and page directions if ($NMPAGEURL != 'index') { if (nm_get_parent() != '' && ($PERMALINK == '' || strpos($PERMALINK, '%parent%') !== false)) { $prefix = nm_get_parent() . '/' . $NMPAGEURL . '/'; } else { $prefix = $NMPAGEURL . '/'; } $page = 'id=' . $NMPAGEURL . '&'; } # generate .htaccess contents $htaccess = file_get_contents(GSPLUGINPATH . 'news_manager/temp.htaccess'); $htaccess = str_replace('**PATH**', $path, $htaccess); $htaccess = str_replace('**PREFIX**', $prefix, $htaccess); $htaccess = str_replace('**PAGE**', $page, $htaccess); $htaccess = htmlentities($htaccess, ENT_QUOTES, 'UTF-8'); # show .htaccess include NMTEMPLATEPATH . 'htaccess.php'; }