我有客户要求他将他的网站从开发服务器移到生产服务器。如何让网站对特定用户可见?
他想在完全投入使用之前做一些测试和其他工作。 所以他想要的只是使他的网站可见(使用一些身份验证)。
只要他试图访问任何网站的网址,他应该被重定向到一个登录页面。这个登录页面不同于覆盖整个屏幕的magento登录页面,所以网站内容应该是可见的,直到他登录。(应该没有注册工具,这是一个用户特定的登录)
只有指定的用户名和密码登录后,他将被允许看到的网站内容。
我尝试一些像这样的事情在我的index.php
$basePath=getcwd();
require_once $基本路径 '/应用程序/ Mage.php'。 Mage :: init();
$ CURRENTURL =法师::助手( '核心/ URL') - > getCurrentUrl(); // echo $ currentUrl。“
”; // exit; (strpos($ currentUrl,“?k = 1”)) { $ validation = 1;
if
} 别的 { $验证= 0; }
// exit; 如果($验证== 0){
//回声 “
在如果验证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>
但是使用这种逻辑我面临着很多问题。请提出一些解决方案。
感谢您的帮助。您的解决方案很简单,易于实施。 – Muk 2013-03-06 12:37:04
我们可以在我们的个人计算机上使用本地主机吗?如果是,在哪里运行命令?谢谢 – Muk 2013-03-15 11:07:29