ModuleCode: urlrewrite 0.02 [技术论坛 - 模块定制] imag1

正在浏览:   1 名游客




(1) 2 »


ModuleCode: urlrewrite 0.02
Support Team
注册日期:
2006/6/26 10:17
来自 北京
所属群组:
注册会员
Dev+Hack
帖子: 854 | 精华: 5
等级: 26; EXP: 19
HP: 251 / 629
MP: 284 / 2680
离线
ModuleCode: urlrewrite 0.02
ModuleDescription: Url Rewrite
Directory: /modules/urlrewrite/admin
File: /modules/urlrewrite/admin/create.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
xoops_cp_header();
require_once 
XOOPS_ROOT_PATH.'/class/template.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme_blocks.php';
$xoopsThemeFactory =& new xos_opal_ThemeFactory();
$xoTheme =& $xoopsThemeFactory->createInstance();
$xoopsTpl =& $xoTheme->template;
/* @var $xoopsTpl XoopsTpl */
require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
$create_form = new XoopsSimpleForm("""create_form",
    
XOOPS_URL."/modules/urlrewrite/admin/new.php");
$create_form->addElement(new XoopsFormText("""pattern"5050), true);
$create_form->addElement(new XoopsFormText("""target_url"5050), true);
$create_form->addElement(new XoopsFormRadioYN("""enabled"true));
$create_form->addElement(new XoopsFormButton("""submit"_SUBMIT"submit"));
$create_form->assign($xoopsTpl);
$xoopsTpl->display("db:urlrewrite_admin_create.html");
xoops_cp_footer();
?>

File: /modules/urlrewrite/admin/createurl.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
if (
false === isset($_GET["script_url"])) {
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
$script_url $_GET["script_url"];
xoops_cp_header();
require_once 
XOOPS_ROOT_PATH.'/class/template.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme_blocks.php';
$xoopsThemeFactory =& new xos_opal_ThemeFactory();
$xoTheme =& $xoopsThemeFactory->createInstance();
$xoopsTpl =& $xoTheme->template;
/* @var $xoopsTpl XoopsTpl */
$xoopsTpl->assign_by_ref("script_url"$script_url);
require_once 
XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
$create_form = new XoopsSimpleForm("""create_form",
    
XOOPS_URL."/modules/urlrewrite/admin/new.php");
$create_form->addElement(new XoopsFormText("""pattern"5050), true);
$create_form->addElement(new XoopsFormHidden("target_url"$script_url), true);
$create_form->addElement(new XoopsFormRadioYN("""enabled"true));
$create_form->addElement(new XoopsFormButton("""submit"_SUBMIT"submit"));
$create_form->assign($xoopsTpl);
$xoopsTpl->display("db:urlrewrite_admin_createurl.html");
xoops_cp_footer();
?>

File: /modules/urlrewrite/admin/delete.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
if (
false === isset($_GET["id"])) {
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
$urlhandler xoops_getmodulehandler("url""urlrewrite");
/* @var $urlhandler urlrewriteurlhandler */
$url $urlhandler->get($_GET["id"]);
/* @var $url urlrewriteurl */
if (false === isset($url)) {
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
if (
"POST" === $_SERVER['REQUEST_METHOD']) {
    
$urlhandler->delete($url);
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
xoops_cp_header();
require_once 
XOOPS_ROOT_PATH.'/class/template.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme_blocks.php';
$xoopsThemeFactory =& new xos_opal_ThemeFactory();
$xoTheme =& $xoopsThemeFactory->createInstance();
$xoopsTpl =& $xoTheme->template;
/* @var $xoopsTpl XoopsTpl */
$xoopsTpl->assign_by_ref("url"$url);
$xoopsTpl->display("db:urlrewrite_admin_delete.html");
if (
"POST" !== $_SERVER['REQUEST_METHOD']) {
    
xoops_confirm(array(), """Are you sure want to delete?");
}
xoops_cp_footer();
?>

File: /modules/urlrewrite/admin/edit.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
if (
false === isset($_GET["id"])) {
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
$urlhandler xoops_getmodulehandler("url""urlrewrite");
/* @var $urlhandler urlrewriteurlhandler */
$url $urlhandler->get($_GET["id"]);
/* @var $url urlrewriteurl */
if (false === isset($url)) {
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
xoops_cp_header();
require_once 
XOOPS_ROOT_PATH.'/class/template.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme_blocks.php';
$xoopsThemeFactory =& new xos_opal_ThemeFactory();
$xoTheme =& $xoopsThemeFactory->createInstance();
$xoopsTpl =& $xoTheme->template;
/* @var $xoopsTpl XoopsTpl */
$xoopsTpl->assign_by_ref("id"$url->get_primary_key());
require_once 
XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
$edit_form = new XoopsSimpleForm("""edit_form",
    
XOOPS_URL."/modules/urlrewrite/admin/save.php");
$edit_form->addElement(new XoopsFormHidden("id"$url->get_primary_key()));
$edit_form->addElement(
    new 
XoopsFormText("""pattern"5050$url->get_pattern()), true);
$edit_form->addElement(
    new 
XoopsFormText("""target_url"5050$url->get_target_url()), true);
$edit_form->addElement(
    new 
XoopsFormRadioYN("""enabled"$url->get_enabled()));
$edit_form->addElement(new XoopsFormButton("""submit"_SUBMIT"submit"));
$edit_form->assign($xoopsTpl);
$xoopsTpl->display("db:urlrewrite_admin_edit.html");
xoops_cp_footer();
?>

File: /modules/urlrewrite/admin/htaccess.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
$htaccesshandler xoops_getmodulehandler("htaccess""urlrewrite");
/* @var $htaccesshandler urlrewritehtaccesshandler */
if ("POST" === $_SERVER['REQUEST_METHOD']) {
    
$htaccesshandler->save();
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
xoops_cp_header();
require_once 
XOOPS_ROOT_PATH.'/class/template.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme_blocks.php';
$xoopsThemeFactory =& new xos_opal_ThemeFactory();
$xoTheme =& $xoopsThemeFactory->createInstance();
$xoopsTpl =& $xoTheme->template;
/* @var $xoopsTpl XoopsTpl */
$xoopsTpl->assign_by_ref("text"$htaccesshandler->get_text());
$xoopsTpl->assign_by_ref("rows"$htaccesshandler->get_rows());
$xoopsTpl->display("db:urlrewrite_admin_htaccess.html");
xoops_confirm(array(), """Are you sure want to save as '".
    
$htaccesshandler->get_htaccess_path()."'?");
xoops_cp_footer();
?>

File: /modules/urlrewrite/admin/index.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
xoops_cp_header();
$dependencehandler xoops_getmodulehandler("dependence""urlrewrite");
/* @var $dependencehandler urlrewritedependencehandler */
if(false === $dependencehandler->check_url_rewrite()) {
    
xoops_error("The urlrewrite module required apache mod_rewrite.");
}
require_once 
XOOPS_ROOT_PATH.'/class/template.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme_blocks.php';
$xoopsThemeFactory =& new xos_opal_ThemeFactory();
$xoTheme =& $xoopsThemeFactory->createInstance();
$xoopsTpl =& $xoTheme->template;
/* @var $xoopsTpl XoopsTpl */
$urlhandler xoops_getmodulehandler("url""urlrewrite");
/* @var $urlhandler urlrewriteurlhandler */
$xoopsTpl->assign_by_ref("urls"$urlhandler->getObjects());
$xoopsTpl->display("db:urlrewrite_admin_index.html");
xoops_cp_footer();
?>

File: /modules/urlrewrite/admin/menu.php
<?php
if (false === defined('XOOPS_ROOT_PATH')){
    exit();
}
$adminmenu = array();
$i 1;
$adminmenu[$i]["link"] = "admin/index.php";
$adminmenu[$i]["title"] = "URL List";
$i++;
$adminmenu[$i]["link"] = "admin/create.php";
$adminmenu[$i]["title"] = "Create URL";
$i++;
$adminmenu[$i]["link"] = "admin/htaccess.php";
$adminmenu[$i]["title"] = "Generate .htaccess";
$i++;
$adminmenu[$i]["link"] = "admin/smarty.php";
$adminmenu[$i]["title"] = "Smarty Support";
?>

File: /modules/urlrewrite/admin/new.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
$urlhandler xoops_getmodulehandler("url""urlrewrite");
/* @var $urlhandler urlrewriteurlhandler */
$url $urlhandler->create();
/* @var $url urlrewriteurl */
$url->set_pattern($_POST["pattern"]);
$url->set_target_url($_POST["target_url"]);
$url->set_enabled($_POST["enabled"]);
$urlhandler->insert($url);
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
?>

File: /modules/urlrewrite/admin/save.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
if (
false === isset($_POST["id"])) {
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
$urlhandler xoops_getmodulehandler("url""urlrewrite");
/* @var $urlhandler urlrewriteurlhandler */
$url $urlhandler->get($_POST["id"]);
/* @var $url urlrewriteurl */
if (false === isset($url)) {
    
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
}
$url->set_pattern($_POST["pattern"]);
$url->set_target_url($_POST["target_url"]);
$url->set_enabled($_POST["enabled"]);
$urlhandler->insert($url);
redirect_header(XOOPS_URL."/modules/urlrewrite/admin/index.php");
?>

File: /modules/urlrewrite/admin/smarty.php
<?php
include dirname(__FILE__).'/../../../include/cp_header.php';
xoops_cp_header();
$dependencehandler xoops_getmodulehandler("dependence""urlrewrite");
/* @var $dependencehandler urlrewritedependencehandler */
if(false === $dependencehandler->check_htaccess()) {
    
xoops_error("The .htaccess is invalid.");
}
require_once 
XOOPS_ROOT_PATH.'/class/template.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme.php';
require_once 
XOOPS_ROOT_PATH.'/class/theme_blocks.php';
$xoopsThemeFactory =& new xos_opal_ThemeFactory();
$xoTheme =& $xoopsThemeFactory->createInstance();
$xoopsTpl =& $xoTheme->template;
/* @var $xoopsTpl XoopsTpl */
require_once XOOPS_ROOT_PATH."/modules/urlrewrite/include/smarty.php";
$htaccesshandler xoops_getmodulehandler("htaccess""urlrewrite");
/* @var $htaccesshandler urlrewritehtaccesshandler */
$xoopsTpl->assign_by_ref("urls"$htaccesshandler->get_urls());
$xoopsTpl->display("db:urlrewrite_admin_smarty.html");
xoops_cp_footer();
?>

Directory: /modules/urlrewrite/blocks
File: /modules/urlrewrite/blocks/stub.php
<?php
if (false === defined("XOOPS_ROOT_PATH")) {
    exit();
}
function 
b_urlrewrite_stub () {
    
$stubhandler xoops_getmodulehandler("stub""urlrewrite");
    
/* @var $stubhandler urlrewritestubhandler */
    
if (true === $stubhandler->get_in_xoops()) {
        
$block = array();
        
$block["script_url"] = $stubhandler->get_script_url();
        
$block["is_redirect"] = $stubhandler->get_is_redirect();
        
$block["patterns"] = $stubhandler->get_patterns();
        
$block["target_urls"] = $stubhandler->get_target_urls();
        return 
$block;
    } else {
        return 
false;
    }
}
?>

Directory: /modules/urlrewrite/class
File: /modules/urlrewrite/class/dependence.php
<?php
if (false === defined("XOOPS_ROOT_PATH")) {
    exit();
}
final class 
urlrewritedependencehandler {
    
/* override */
    
public function __construct() {
        return;
    }
    private function 
__clone () {
        return;
    }
    
/* operation */
    
public function check_url_rewrite () {
        return 
true === in_array("mod_rewrite"apache_get_modules());
    }
    public function 
check_htaccess () {
        return 
"1" === $_SERVER["XOOPS_URLREWRITE_HTACCESS"];
    }
}
?>

File: /modules/urlrewrite/class/htaccess.php
<?php
if (false === defined("XOOPS_ROOT_PATH")) {
    exit();
}
final class 
urlrewritehtaccesshandler {
    private 
$urls;
    private 
$text;
    private 
$rows;
    
/* override */
    
public function __construct() {
        return;
    }
    private function 
__clone () {
        return;
    }
    
/* cache */
    
private function ensure_urls () {
        if (
true === isset($this->urls)) {
            return;
        }
        
$urlhandler xoops_getmodulehandler("url""urlrewrite");
        
/* @var $urlhandler urlrewriteurlhandler */
        
$criteria = new CriteriaCompo();
        
$criteria->add(new Criteria("enabled"true));
        
$this->urls $urlhandler->getObjects($criteria);
        return;
    }
    private function 
ensure_text () {
        if (
true === isset($this->text)) {
            return;
        }
        
$this->ensure_urls();
        
$this->text "<IfModule rewrite_module>n";
        
$this->text .= "<IfModule env_module>n";
        
$this->text .= "SetEnv XOOPS_URLREWRITE_HTACCESS 1n";
        
$this->text .= "</IfModule>n";
        
$this->text .= "RewriteEngine onn";
        foreach (
$this->urls as $url) {
            
/* @var $url urlrewriteurl */
            
$this->text .= "RewriteRule ^".preg_quote($url->get_pattern())."$ ".
                
$url->get_target_url()." [L,QSA]n";
        }
        
$this->text .= "</IfModule>";
        
$this->rows count(explode("n"$this->text));
        return;
    }
    
/* operation */
    
public function get_urls () {
        
$this->ensure_urls();
        return 
$this->urls;
    }
    public function 
get_text () {
        
$this->ensure_text();
        return 
$this->text;
    }
    public function 
get_rows () {
        
$this->ensure_text();
        return 
$this->rows;
    }
    public function 
get_htaccess_path () {
        return 
XOOPS_ROOT_PATH."/.htaccess";
    }
    public function 
get_target_urls_path () {
        
$cache_dir XOOPS_UPLOAD_PATH."/urlrewrite";
        if (
false === is_dir($cache_dir)) {
            
mkdir($cache_dir);
        }
        return 
$cache_dir."/target_urls.php";
    }
    public function 
save () {
        
$this->ensure_text();
        
file_put_contents($this->get_htaccess_path(), $this->text);
        
$target_urls = array();
        foreach (
$this->urls as $url) {
            
/* @var $url urlrewriteurl */
            
$target_urls[$url->get_target_url()] = $url->get_pattern();
        }
        
$target_urls_content "<?phpnreturn ".var_export($target_urlstrue).
        
";n?>";
        
file_put_contents($this->get_target_urls_path(), $target_urls_content);
        return;
    }
}
?>

File: /modules/urlrewrite/class/stub.php
<?php
if (false === defined("XOOPS_ROOT_PATH")) {
    exit();
}
final class 
urlrewritestubhandler {
    private 
$in_xoops;
    private 
$script_url;
    private 
$is_redirect;
    private 
$patterns;
    private 
$target_urls;
    
/* override */
    
public function __construct() {
        
$parse_xoops_url parse_url(XOOPS_URL);
        
$xoops_url_path $parse_xoops_url["path"];
        
$parse_request_uri parse_url($_SERVER["REQUEST_URI"]);
        
$request_uri_path =$parse_request_uri["path"];
        if (
substr($request_uri_path0strlen($xoops_url_path) + 1) ===
            
$xoops_url_path."/") {
            
$this->in_xoops true;
            
$script_name $_SERVER["SCRIPT_NAME"];
            if (
substr($script_name0strlen($xoops_url_path) + 1) ===
                
$xoops_url_path."/") {
                
$this->script_url =
                    
substr($script_namestrlen($xoops_url_path) + 1);
            } else {
                
$this->script_url "";
            }
            
$target_url substr($request_uri_path,
                
strlen($xoops_url_path) + 1);
            
$urlhandler xoops_getmodulehandler("url""urlrewrite");
            
/* @var $urlhandler urlrewriteurlhandler */
            
if (true === isset($_SERVER["REDIRECT_URL"])) {
                
$this->is_redirect true;
                
$criteria = new CriteriaCompo();
                
$criteria->add(new Criteria("pattern"$target_url));
                
$this->patterns $urlhandler->getObjects($criteria);
            } else {
                
$this->is_redirect false;
                
$criteria = new CriteriaCompo();
                
$criteria->add(new Criteria("target_url"$target_url));
                
$this->target_urls $urlhandler->getObjects($criteria);
            }
        } else {
            
$this->in_xoops false;
        }
        return;
    }
    private function 
__clone () {
        return;
    }
    
/* operation */
    
public function get_in_xoops () {
        return 
$this->in_xoops;
    }
    public function 
get_script_url () {
        return 
$this->script_url;
    }
    public function 
get_is_redirect () {
        return 
$this->is_redirect;
    }
    public function 
get_patterns () {
        return 
$this->patterns;
    }
    public function 
get_target_urls () {
        return 
$this->target_urls;
    }
}
?>

File: /modules/urlrewrite/class/url.php
<?php
if (false === defined("XOOPS_ROOT_PATH")) {
    exit();
}
if (
false === defined("FRAMEWORKS_ART_FUNCTIONS_INI")) {
    require_once 
XOOPS_ROOT_PATH.'/Frameworks/art/functions.ini.php';
}
load_object();
final class 
urlrewriteurl extends ArtObject {
    
/* override */
    
public function __construct() {
        
parent::ArtObject(urlrewriteurlhandler::TABLE);
        
parent::initVar(urlrewriteurlhandler::PRIMARY_KEYXOBJ_DTYPE_INT);
        
parent::initVar("pattern"XOBJ_DTYPE_TXTBOX);
        
parent::initVar("target_url"XOBJ_DTYPE_TXTBOX);
        
parent::initVar("enabled"XOBJ_DTYPE_INT);
        return;
    }
    private function 
__clone () {
        return;
    }
    
/* getter / setter */
    
public function get_primary_key () {
        return 
intval(parent::getVar(urlrewriteurlhandler::PRIMARY_KEY));
    }
    public function 
get_pattern () {
        return 
strval(parent::getVar("pattern"));
    }
    public function 
set_pattern ($pattern) {
        return 
parent::setVar("pattern"strval($pattern));
    }
    public function 
get_target_url () {
        return 
strval(parent::getVar("target_url"));
    }
    public function 
set_target_url ($target_url) {
        return 
parent::setVar("target_url"strval($target_url));
    }
    public function 
get_enabled () {
        
$enabled parent::getVar("enabled");
        
settype($enabled"boolean");
        return 
$enabled;
    }
    public function 
set_enabled ($enabled) {
        
settype($enabled"boolean");
        return 
parent::setVar("enabled"$enabled);
    }
}
final class 
urlrewriteurlhandler extends ArtObjectHandler {
    const 
TABLE "urlrewrite_url";
    const 
PRIMARY_KEY "id";
    
/* override */
    
public function __construct($db) {
        
parent::ArtObjectHandler($dbself::TABLE"urlrewriteurl",
            
self::PRIMARY_KEY);
        return;
    }
    private function 
__clone () {
        return;
    }
    
/* operation */
}
?>

Directory: /modules/urlrewrite/include
File: /modules/urlrewrite/include/smarty.php
<?php
$xoopsTpl
->register_modifier("urlrewrite""smarty_urlrewrite");
if (
true === function_exists("smarty_urlrewrite")) {
    return;
}
function 
smarty_urlrewrite ($value) {
    if (
"1" !== $_SERVER["XOOPS_URLREWRITE_HTACCESS"]) {
        return 
$value;
    }
    static 
$target_urls;
    if (
false === isset($target_urls)) {
        
$target_urls_file XOOPS_UPLOAD_PATH."/urlrewrite/target_urls.php";
        if (
true === is_file($target_urls_file)) {
            
$target_urls = require $target_urls_file;
        } else {
            
$target_urls = array();
        }
    }
    if (array() === 
$target_urls) {
        return 
$value;
    }
    if (
substr($value0strlen(XOOPS_URL) + 1) === XOOPS_URL."/") {
        
$xoops_uri substr($valuestrlen(XOOPS_URL) + 1);
        
$parse_xoops_uri parse_url($xoops_uri);
        
$xoops_uri_path $parse_xoops_uri["path"];
        if (
true === array_key_exists($xoops_uri_path$target_urls)) {
            
$redirect_url XOOPS_URL."/".$target_urls[$xoops_uri_path];
            if (
true === isset($parse_xoops_uri["query"])) {
                
$redirect_url .= "?".$parse_xoops_uri["query"];
            }
            if (
true === isset($parse_xoops_uri["fragment"])) {
                
$redirect_url .= "#".$parse_xoops_uri["fragment"];
            }
            return 
$redirect_url;
        } else {
            return 
$value;
        }
    } else {
        return 
$value;
    }
}
?>

File: /modules/urlrewrite/index.php
<?php
require_once dirname(__FILE__)."/../../mainfile.php";
require_once 
XOOPS_ROOT_PATH."/header.php";
require_once 
XOOPS_ROOT_PATH."/footer.php";
?>

Directory: /modules/urlrewrite/sql
File: /modules/urlrewrite/sql/mysql.sql

CREATE TABLE urlrewrite_url 
(
    
id INT(11UNSIGNED NOT NULL AUTO_INCREMENT,
    
pattern VARCHAR(255NOT NULL DEFAULT '',
    
target_url VARCHAR(255NOT NULL DEFAULT '',
    
enabled INT(1NOT NULL DEFAULT 0,
    
PRIMARY KEY (id)
ENGINE MyISAM;

Directory: /modules/urlrewrite/templates
Directory: /modules/urlrewrite/templates/blocks
File: /modules/urlrewrite/templates/blocks/urlrewrite_block_stub.html

<{strip}>
    <{if 
true === $block.is_redirect}>
        <{if array() === 
$block.patterns}>
            
This page is redirect from "<{$smarty.server.REDIRECT_URL}>" to "<{$smarty.server.SCRIPT_NAME}>".
        <{else}>
            <
table>
                <
tr>
                    <
th>
                        
This page is redirect to
                    
</th>
                    <
th>
                        
Enabled
                    
</th>
                </
tr>
                <{foreach 
from=$block.patterns item="pattern"}>
                    <
tr class="<{cycle values='odd,even'}>">
                        <
td>
                            <
a href="<{$xoops_url}>/modules/urlrewrite/admin/edit.php?id=<{$pattern->get_primary_key()}>" target="_blank">
                                <{
$pattern->get_target_url()}>
                            </
a>
                        </
td>
                        <
td>
                            <{if 
true === $pattern->get_enabled()}>
                                <{
$smarty.const._YES}>
                            <{else}>
                                <{
$smarty.const._NO}>
                            <{/if}>
                        </
td>
                    </
tr>
                <{/foreach}>
            </
table>
        <{/if}>
    <{else}>
        <{if array() === 
$block.target_urls}>
        <{else}>
            <
table>
                <
tr>
                    <
th>
                        
This page is able to redirect from
                    
</th>
                    <
th>
                        
Enabled
                    
</th>
                </
tr>
                <{foreach 
from=$block.target_urls item="target_url"}>
                    <
tr class="<{cycle values='odd,even'}>">
                        <
td>
                            <
a href="<{$xoops_url}>/modules/urlrewrite/admin/edit.php?id=<{$target_url->get_primary_key()}>" target="_blank">
                                <{
$target_url->get_pattern()}>
                            </
a>
                        </
td>
                        <
td>
                            <{if 
true === $target_url->get_enabled()}>
                                <{
$smarty.const._YES}>
                            <{else}>
                                <{
$smarty.const._NO}>
                            <{/if}>
                        </
td>
                    </
tr>
                <{/foreach}>
            </
table>
        <{/if}>
    <{/if}>
    <{if 
"" !== $block.script_url}>
        <
a href="<{$xoops_url}>/modules/urlrewrite/admin/createurl.php?script_url=<{$block.script_url}>" target="_blank">
            
Create redirect to "<{$block.script_url}>".
        </
a>
    <{/if}>
<{/
strip}>

File: /modules/urlrewrite/templates/urlrewrite_admin_create.html

<{strip}>
    <
form name="<{$create_form.name}>" action="<{$create_form.action}>" method="<{$create_form.method}>" <{$create_form.extra}> >
        <{
$create_form.javascript}>
        <
table style="width: 100%;">
            <
tr>
                <
th>
                    
Pattern
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.pattern.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                    
Target URL
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.target_url.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                    
Enabled
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.enabled.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                </
th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.submit.body}>
                </
td>
            </
tr>
        </
table>
    </
form>
<{/
strip}>

File: /modules/urlrewrite/templates/urlrewrite_admin_createurl.html

<{strip}>
    <
form name="<{$create_form.name}>" action="<{$create_form.action}>" method="<{$create_form.method}>" <{$create_form.extra}> >
        <{
$create_form.javascript}>
        <
table style="width: 100%;">
            <
tr>
                <
th>
                    
Pattern
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.pattern.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                    
Target URL
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.target_url.body}>
                    <{
$script_url|escape}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                    
Enabled
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.enabled.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                </
th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$create_form.elements.submit.body}>
                </
td>
            </
tr>
        </
table>
    </
form>
<{/
strip}>

File: /modules/urlrewrite/templates/urlrewrite_admin_delete.html

<{strip}>
    <
table style="width: 100%;">
        <
tr>
            <
th>
                
ID
            
</th>
            <
td class="<{cycle values='even,odd'}>">
                <{
$url->get_primary_key()}>
            </
td>
        </
tr>
        <
tr>
            <
th>
                
Pattern
            
</th>
            <
td class="<{cycle values='even,odd'}>">
                <{
$url->get_pattern()}>
            </
td>
        </
tr>
        <
tr>
            <
th>
                
Target URL
            
</th>
            <
td class="<{cycle values='even,odd'}>">
                <{
$url->get_target_url()}>
            </
td>
        </
tr>
        <
tr>
            <
th>
                
Enabled
            
</th>
            <
td class="<{cycle values='even,odd'}>">
                <{if 
true === $url->get_enabled()}>
                    <{
$smarty.const._YES}>
                <{else}>
                    <{
$smarty.const._NO}>
                <{/if}>
            </
td>
        </
tr>
    </
table>
<{/
strip}>

File: /modules/urlrewrite/templates/urlrewrite_admin_edit.html

<{strip}>
    <
form name="<{$edit_form.name}>" action="<{$edit_form.action}>" method="<{$edit_form.method}>" <{$edit_form.extra}> >
        <{
$edit_form.javascript}>
        <{
$edit_form.elements.id.body}>
        <
table style="width: 100%;">
            <
tr>
                <
th>
                    
ID
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$id}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                    
Pattern
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$edit_form.elements.pattern.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                    
Target URL
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$edit_form.elements.target_url.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                    
Enabled
                
</th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$edit_form.elements.enabled.body}>
                </
td>
            </
tr>
            <
tr>
                <
th>
                </
th>
                <
td class="<{cycle values='even,odd'}>">
                    <{
$edit_form.elements.submit.body}>
                </
td>
            </
tr>
        </
table>
    </
form>
<{/
strip}>

File: /modules/urlrewrite/templates/urlrewrite_admin_htaccess.html

<{strip}>
    <
textarea style="width:100%;" rows="<{$rows}>" readonly>
        <{
$text|escape}>
    </
textarea>
<{/
strip}>

File: /modules/urlrewrite/templates/urlrewrite_admin_index.html

<{strip}>
    <
table style="width: 100%;">
        <
tr>
            <
th>
                
ID
            
</th>
            <
th>
                
Pattern
            
</th>
            <
th>
                
Target URL
            
</th>
            <
th>
                
Enabled
            
</th>
            <
th>
                <{
$smarty.const._EDIT}>
            </
th>
            <
th>
                <{
$smarty.const._DELETE}>
            </
th>
        </
tr>
        <{foreach 
from=$urls item="url"}>
            <
tr class="<{cycle values='even,odd'}>">
                <
td>
                    <{
$url->get_primary_key()}>
                </
td>
                <
td>
                    <
a href="<{$xoops_url}>/<{$url->get_pattern()}>" target="_blank">
                        <{
$url->get_pattern()}>
                    </
a>
                </
td>
                <
td>
                    <
a href="<{$xoops_url}>/<{$url->get_target_url()}>" target="_blank">
                        <{
$url->get_target_url()}>
                    </
a>
                </
td>
                <
td>
                    <{if 
true === $url->get_enabled()}>
                        <{
$smarty.const._YES}>
                    <{else}>
                        <{
$smarty.const._NO}>
                    <{/if}>
                </
td>
                <
td>
                    <
a href="<{$xoops_url}>/modules/urlrewrite/admin/edit.php?id=<{$url->get_primary_key()}>">
                        <{
$smarty.const._EDIT}>
                    </
a>
                </
td>
                <
td>
                    <
a href="<{$xoops_url}>/modules/urlrewrite/admin/delete.php?id=<{$url->get_primary_key()}>">
                        <{
$smarty.const._DELETE}>
                    </
a>
                </
td>
            </
tr>
        <{/foreach}>
    </
table>
<{/
strip}>

File: /modules/urlrewrite/templates/urlrewrite_admin_smarty.html

<{strip}>
    <
fieldset>
        <
legend>
            
Enable URL rewrite in Smarty (Use the code below after $xoopsTpl initialization)
        </
legend>
        require_once 
XOOPS_ROOT_PATH."/modules/urlrewrite/include/smarty.php";
    </
fieldset>
    <
fieldset>
        <
legend>
            
Smarty Rewrite Sample
        
</legend>
        <{if 
count($urls)}>
            <
table style="width: 100%;">
                <{foreach 
from=$urls item="url"}>
                    <
tr>
                        <
th>
                            
ID
                        
</th>
                        <
th>
                            <{
$url->get_primary_key()}>
                        </
th>
                    </
tr>
                    <
tr>
                        <
th>
                            
Pattern
                        
</th>
                        <
td class="<{cycle values='odd,even'}>">
                            <
a href="<{$xoops_url}>/<{$url->get_pattern()}>" target="_blank">
                                <{
$url->get_pattern()}>
                            </
a>
                        </
td>
                    </
tr>
                    <
tr>
                        <
th>
                            
Target URL
                        
</th>
                        <
td class="<{cycle values='odd,even'}>">
                            <
a href="<{$xoops_url}>/<{$url->get_target_url()}>" target="_blank">
                                <{
$url->get_target_url()}>
                            </
a>
                        </
td>
                    </
tr>
                    <
tr>
                        <
th>
                            
Smarty Sample
                        
</th>
                        <
td class="<{cycle values='odd,even'}>">
                            <{
ldelim}>"<{$xoops_url}>/<{$url->get_target_url()}>"|smarty_urlrewrite<{rdelim}>
                        </
td>
                    </
tr>
                    <
tr>
                        <
th>
                            
Smarty Result
                        
</th>
                        <
td class="<{cycle values='odd,even'}>">
                            <{
$xoops_url|cat:"/"|cat:$url->get_target_url()|smarty_urlrewrite|escape}>
                        </
td>
                    </
tr>
                <{/foreach}>
            </
table>
        <{/if}>
    </
fieldset>
<{/
strip}>

File: /modules/urlrewrite/xoops_version.php
<?php
if (false === defined("XOOPS_ROOT_PATH")) {
    exit();
}
$modversion["name"] = "Url Rewrite";
$modversion["version"] = 0.02;
$modversion["description"] = "Url Rewrite";
$modversion["author"] = "Hu Zhenghui http://xoops.org.cn/userinfo.php?uid=8616 QQ: 443089607 QQMail: [email protected] Skype: huzhenghui GMail: [email protected] GTalk: huzhengh";
$modversion['license'] = "All rights reserved.";
$modversion['image'] = "../../images/logo.gif";
$modversion['dirname'] = "urlrewrite";
$modversion['sqlfile']['mysql'] = "sql/mysql.sql";
$modversion['tables'] = array(
    
'urlrewrite_url'
);
$modversion["hasMain"] = 1;
$modversion['hasAdmin'] = 1;
$modversion['adminindex'] = "admin/index.php";
$modversion['adminmenu'] = "admin/menu.php";
$i 1;
$modversion['blocks'][$i]['file'] = "stub.php";
$modversion['blocks'][$i]['name'] = "URL Rewrite Stub";
$modversion['blocks'][$i]['description'] = "URL Rewrite Stub";
$modversion['blocks'][$i]['show_func'] = "b_urlrewrite_stub";
$modversion['blocks'][$i]['template'] = 'urlrewrite_block_stub.html';
$i 1;
$modversion['templates'][$i]['file'] = 'urlrewrite_admin_index.html';
$modversion['templates'][$i]['description'] = '';
$i++;
$modversion['templates'][$i]['file'] = 'urlrewrite_admin_create.html';
$modversion['templates'][$i]['description'] = '';
$i++;
$modversion['templates'][$i]['file'] = 'urlrewrite_admin_createurl.html';
$modversion['templates'][$i]['description'] = '';
$i++;
$modversion['templates'][$i]['file'] = 'urlrewrite_admin_edit.html';
$modversion['templates'][$i]['description'] = '';
$i++;
$modversion['templates'][$i]['file'] = 'urlrewrite_admin_delete.html';
$modversion['templates'][$i]['description'] = '';
$i++;
$modversion['templates'][$i]['file'] = 'urlrewrite_admin_htaccess.html';
$modversion['templates'][$i]['description'] = '';
$i++;
$modversion['templates'][$i]['file'] = 'urlrewrite_admin_smarty.html';
$modversion['templates'][$i]['description'] = '';
?>

附件:


zip urlrewrite.0.02.zip 大小: 14.78 KB; 下载次数: 18

2007/12/2 8:54
_________________
Skype: huzhenghui
QQ: 443089607
QQ Mail: [email protected]
GTalk: huzhengh
GMail: [email protected]
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.01
资深会员
注册日期:
2004/12/26 13:27
来自 济南
所属群组:
注册会员
技术文档组
帖子: 505 | 精华: 1
等级: 20; EXP: 75
HP: 0 / 493
MP: 168 / 4259
离线
对服务器有什么要求么?

2007/12/2 10:24
_________________
泗水信息港Powered By XOOPS
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.01
Support Team
注册日期:
2006/6/26 10:17
来自 北京
所属群组:
注册会员
Dev+Hack
帖子: 854 | 精华: 5
等级: 26; EXP: 19
HP: 251 / 629
MP: 284 / 2680
离线
引文:

sinoer 写道:
对服务器有什么要求么?

Apache,支持.htaccess,支持url_rewrite。功能很简单,就是生成一个简单的.htaccess文件。

2007/12/2 10:32
_________________
Skype: huzhenghui
QQ: 443089607
QQ Mail: [email protected]
GTalk: huzhengh
GMail: [email protected]
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.01
资深会员
注册日期:
2004/12/26 13:27
来自 济南
所属群组:
注册会员
技术文档组
帖子: 505 | 精华: 1
等级: 20; EXP: 75
HP: 0 / 493
MP: 168 / 4259
离线
嗯!

不过俺用的虚拟主机。不支持.htaccess,url_rewrite
用不成了。

2007/12/2 10:36
_________________
泗水信息港Powered By XOOPS
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.01
Support Team
注册日期:
2006/6/26 10:17
来自 北京
所属群组:
注册会员
Dev+Hack
帖子: 854 | 精华: 5
等级: 26; EXP: 19
HP: 251 / 629
MP: 284 / 2680
离线
引文:

sinoer 写道:
嗯!

不过俺用的虚拟主机。不支持.htaccess,url_rewrite
用不成了。

晕死,虚拟主机不支持这两个的话怎么玩啊。

2007/12/2 10:43
_________________
Skype: huzhenghui
QQ: 443089607
QQ Mail: [email protected]
GTalk: huzhengh
GMail: [email protected]
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.01
资深会员
注册日期:
2004/12/26 13:27
来自 济南
所属群组:
注册会员
技术文档组
帖子: 505 | 精华: 1
等级: 20; EXP: 75
HP: 0 / 493
MP: 168 / 4259
离线
引文:

胡争辉 写道:
晕死,虚拟主机不支持这两个的话怎么玩啊。

没办法啊!空奸商说为了提高什么效率禁用了很多函数。

2007/12/2 10:47
_________________
泗水信息港Powered By XOOPS
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.01
Support Team
注册日期:
2006/6/26 10:17
来自 北京
所属群组:
注册会员
Dev+Hack
帖子: 854 | 精华: 5
等级: 26; EXP: 19
HP: 251 / 629
MP: 284 / 2680
离线
引文:

sinoer 写道:
没办法啊!空奸商说为了提高什么效率禁用了很多函数。

换提供商。

2007/12/2 12:12
_________________
Skype: huzhenghui
QQ: 443089607
QQ Mail: [email protected]
GTalk: huzhengh
GMail: [email protected]
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.01
网站管理员
注册日期:
2005/10/29 13:32
来自 北京
所属群组:
网站管理员
注册会员
ComSupp
推广组
帖子: 1931 | 精华: 12
等级: 36; EXP: 47
HP: 532 / 886
MP: 643 / 5470
离线
国内绝大部分虚拟主机都不支持。

2007/12/2 14:32
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.02
资深会员
注册日期:
11/30 20:48
来自 pekin
所属群组:
注册会员
Dev+Hack
帖子: 175 | 精华: 3
等级: 12; EXP: 28
HP: 0 / 282
MP: 58 / 844
离线

添加个图标



顺便问一下,不支持php4吧。

今天 5:09
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: ModuleCode: urlrewrite 0.02
Support Team
注册日期:
2006/6/26 10:17
来自 北京
所属群组:
注册会员
Dev+Hack
帖子: 854 | 精华: 5
等级: 26; EXP: 19
HP: 251 / 629
MP: 284 / 2680
离线
谢谢你的图标,语法兼容问题是因为我最近在2.3上做开发,所以就一直用PHP5的语法了,最近忙,接下来我会把语法改成兼容的。
引文:

ezsky 写道:

添加个图标



顺便问一下,不支持php4吧。

今天 10:19
_________________
Skype: huzhenghui
QQ: 443089607
QQ Mail: [email protected]
GTalk: huzhengh
GMail: [email protected]
工具箱 短消息 Email PDF 书签 打印 举报 回顶部





可以查看帖子。
不可发帖。
不可回复。
不可编辑自己的帖子。
不可删除自己的帖子。
不可发起投票调查。
不可在投票调查中投票。
不可上传附件。
不可不经审核直接发帖。
不可使用主题类别。
不可以使用HTML语法。
不可以使用签名档。

[高级搜索]