我有客户要求他将他的站点从开发服务器移动到生产服务器。
他想在完全上线之前做一些测试和其他事情。所以他想要的是让网站只对他可见(使用一些身份验证)。
一旦他尝试访问站点的任何 url,他应该被重定向到一个登录页面。这个登录页面与覆盖整个屏幕的 magento 登录页面不同,所以在他登录之前网站内容不应该是可见的。(那里应该没有注册设施,这是用户特定的登录)
只有在使用指定的密码和用户名登录后,他才能看到网站内容。
我在我的 index.php 中尝试过这样的事情
$basePath=getcwd();
需要一次 $basePath.'/app/Mage.php'; 法师::init();
$currentUrl = Mage::helper('core/url')->getCurrentUrl(); //echo $currentUrl."
";//退出;
if(strpos($currentUrl,"?k=1") ) { $validation=1;
} 其他 { $validation=0; }
//出口; if($validation==0 ) {
// echo "
In if validation 0";
包括'Loginform.php';} 其他 {
回声“ddd”;/退出;/
/**
* Error reporting
*/
error_reporting(E_ALL | E_STRICT);
/**
* Compilation includes configuration file
*/
define('MAGENTO_ROOT', getcwd());
$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
include $compilerConfig;
}
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
if (is_dir('downloader')) {
header("Location: downloader");
} else {
echo $mageFilename." was not found";
}
exit;
}
if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);
我在包含内容的基本目录中创建了一个文件 Loginform.php 。
<?php
$basePath=getcwd();
require_once $basePath.'/app/Mage.php';
Mage::init();
$cust=Mage::getModel('customer/customer')->getCollection();
foreach($cust as $customer)
{
//echo $customer->getEmail();
}
// echo "<br/>";
// echo $_POST['username'];
$email=$_POST['username'];
echo "<br/>";
//echo $_POST['password'];
//echo md5($_POST['password']);
$password=$_POST['password'];
echo "<br/>";
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
try
{
if($customer->authenticate($email,$password))
{
//echo 'success<br/>';
$url=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); //exit;
$url=$url.'index.php'.'?k=1';
//echo $url;
//Mage::app()->getResponse()->setRedirect($url); //Redirecting to base url
//Mage::app()->getFrontController()->getResponse()->setRedirect($url);
header("Location:$url");
}
}
catch (Mage_Core_Exception $e )
{
echo $e->getMessage();
}
?>
<html>
<head>
</head>
<body>
<form method="post" action="Loginform.php">
User Name<input type="text" name="username"/>
Password<input type="password" name="password"/>
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>
但是使用这种逻辑我面临很多问题。请提出一些解决方案。