0
我有一個Joomla網站,並被要求在其中包含一個應用程序。該應用程序有其自己的index.php,htaccess,數據庫等。只需添加應用程序文件併合並兩個index.php剎車站點和應用程序。應用程序的index.php設置了它的工作原理,如果沒有它,它就不能運行。有沒有一種可靠的方式來合併它們而不相互接觸?在Joomla中引入一個Web應用程序
的index.php(應用程序)
<?php
session_start();
$all_url = explode('?', $_SERVER['REQUEST_URI']);
$url = explode('/', $all_url[0]);
//Homepage
if (empty($url[1])) {
$url[1] = '/frontpage';
}
$tpl = 'home';
$config = array(
'host' => 'xxx', //CHANGE THIS, DB SERVER
'user' => 'xxx', //CHANGE THIS, DB USER
'password' => 'xxx', //CHANGE THIS, DB PASSWORD
'database' => 'xxx' //CHANGE THIS, DB NAME
);
$DB = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'], $config['user'], $config['password']);
$DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$DB->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$DB->exec("SET names utf8");
if (file_exists('controller/' . $url[1] . '.php')) {
$gtpl = 'main';
$restricted = array('cart');
if (!isset($_SESSION['firstVisit']) && $url[1]!='frontpage') {
$_SESSION['firstVisit'] = false; //ensures we never enter this clause again
require 'controller/frontpage.php';
}else if (empty($_SESSION['uid']) && in_array($url[1], $restricted)) {
//not logged in, but trying to access restricted page.
require 'controller/login.php';
}else{
require 'controller/' . $url[1] . '.php';
}
$path = (empty($_GET["custom"])) ? 'view/' . $gtpl . '.php' : $gtpl;
require $path;
} else {
echo 'ERROR - File not found!!!';
}
可能是一個開始開發導入應用程序的小組件的想法。 – Lodder