// fix norms
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10228 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -31,10 +31,11 @@ class AdminGeneratorControllerCore extends AdminController
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_htFile = dirname(__FILE__).'/../../.htaccess';
|
||||
$this->_rbFile = dirname(__FILE__).'/../../robots.txt';
|
||||
$this->_smFile = dirname(__FILE__).'/../../sitemap.xml';
|
||||
$this->_rbData = $this->_getRobotsContent();
|
||||
$this->ht_file = dirname(__FILE__).'/../../.htaccess';
|
||||
$this->rb_file = dirname(__FILE__).'/../../robots.txt';
|
||||
$this->sm_file = dirname(__FILE__).'/../../sitemap.xml';
|
||||
$this->rb_data = $this->getRobotsContent();
|
||||
|
||||
return parent::__construct();
|
||||
}
|
||||
|
||||
@@ -42,8 +43,8 @@ class AdminGeneratorControllerCore extends AdminController
|
||||
{
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
$this->tpl_option_vars['checkConfiguration_ht'] = $this->_checkConfiguration($this->_htFile);
|
||||
$this->tpl_option_vars['checkConfiguration_rb'] = $this->_checkConfiguration($this->_rbFile);
|
||||
$this->tpl_option_vars['checkConfiguration_ht'] = $this->checkConfiguration($this->ht_file);
|
||||
$this->tpl_option_vars['checkConfiguration_rb'] = $this->checkConfiguration($this->rb_file);
|
||||
$this->tpl_option_vars['ps_htaccess_cache_control'] = Configuration::get('PS_HTACCESS_CACHE_CONTROL');
|
||||
$this->tpl_option_vars['ps_rewriting_settings'] = Configuration::get('PS_REWRITING_SETTINGS');
|
||||
$this->tpl_option_vars['ps_htaccess_disable_multiviews'] = Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
|
||||
@@ -51,25 +52,29 @@ class AdminGeneratorControllerCore extends AdminController
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function _checkConfiguration($file)
|
||||
public function checkConfiguration($file)
|
||||
{
|
||||
if (file_exists($file))
|
||||
return is_writable($file);
|
||||
return is_writable(dirname($file));
|
||||
}
|
||||
|
||||
function postProcess()
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitHtaccess'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
{
|
||||
Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int)Tools::getValue('PS_HTACCESS_CACHE_CONTROL'));
|
||||
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
|
||||
Configuration::updateValue('PS_HTACCESS_DISABLE_MULTIVIEWS', (int)Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'));
|
||||
if (Tools::generateHtaccess($this->_htFile, Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')))
|
||||
if (Tools::generateHtaccess(
|
||||
$this->ht_file,
|
||||
Configuration::get('PS_REWRITING_SETTINGS'),
|
||||
Configuration::get('PS_HTACCESS_CACHE_CONTROL'), '',
|
||||
Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
$this->_errors[] = $this->l('Cannot write into file:').' <b>'.$this->_htFile.'</b><br />'.$this->l('Please check write permissions.');
|
||||
$this->_errors[] = $this->l('Cannot write into file:').' <b>'.$this->ht_file.'</b><br />'.$this->l('Please check write permissions.');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
@@ -79,48 +84,51 @@ class AdminGeneratorControllerCore extends AdminController
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!$writeFd = @fopen($this->_rbFile, 'w'))
|
||||
die ($this->l('Cannot write into file:').' <b>'.$this->_rbFile.'</b><br />'.$this->l('Please check write permissions.'));
|
||||
if (!$write_fd = @fopen($this->rb_file, 'w'))
|
||||
$this->_errors[] = sprintf(Tools::displayError('Cannot write into file: %s. Please check write permissions.'), $this->rb_file);
|
||||
else
|
||||
{
|
||||
// PS Comments
|
||||
fwrite($writeFd, "# robots.txt automaticaly generated by PrestaShop e-commerce open-source solution\n");
|
||||
fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n");
|
||||
fwrite($writeFd, "# This file is to prevent the crawling and indexing of certain parts\n");
|
||||
fwrite($writeFd, "# of your site by web crawlers and spiders run by sites like Yahoo!\n");
|
||||
fwrite($writeFd, "# and Google. By telling these \"robots\" where not to go on your site,\n");
|
||||
fwrite($writeFd, "# you save bandwidth and server resources.\n");
|
||||
fwrite($writeFd, "# For more information about the robots.txt standard, see:\n");
|
||||
fwrite($writeFd, "# http://www.robotstxt.org/wc/robots.html\n");
|
||||
fwrite($write_fd, "# robots.txt automaticaly generated by PrestaShop e-commerce open-source solution\n");
|
||||
fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n");
|
||||
fwrite($write_fd, "# This file is to prevent the crawling and indexing of certain parts\n");
|
||||
fwrite($write_fd, "# of your site by web crawlers and spiders run by sites like Yahoo!\n");
|
||||
fwrite($write_fd, "# and Google. By telling these \"robots\" where not to go on your site,\n");
|
||||
fwrite($write_fd, "# you save bandwidth and server resources.\n");
|
||||
fwrite($write_fd, "# For more information about the robots.txt standard, see:\n");
|
||||
fwrite($write_fd, "# http://www.robotstxt.org/wc/robots.html\n");
|
||||
|
||||
//GoogleBot specific
|
||||
fwrite($writeFd, "# GoogleBot specific\n");
|
||||
fwrite($writeFd, "User-agent: Googlebot\n");
|
||||
foreach ($this->_rbData['GB'] as $GB)
|
||||
fwrite($writeFd, 'Disallow: '.__PS_BASE_URI__.$GB."\n");
|
||||
|
||||
fwrite($write_fd, "# GoogleBot specific\n");
|
||||
fwrite($write_fd, "User-agent: Googlebot\n");
|
||||
foreach ($this->rb_data['GB'] as $gb)
|
||||
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$gb."\n");
|
||||
|
||||
// User-Agent
|
||||
fwrite($writeFd, "# All bots\n");
|
||||
fwrite($writeFd, "User-agent: *\n");
|
||||
fwrite($write_fd, "# All bots\n");
|
||||
fwrite($write_fd, "User-agent: *\n");
|
||||
|
||||
// Directories
|
||||
fwrite($writeFd, "# Directories\n");
|
||||
foreach ($this->_rbData['Directories'] as $dir)
|
||||
fwrite($writeFd, 'Disallow: '.__PS_BASE_URI__.$dir."\n");
|
||||
fwrite($write_fd, "# Directories\n");
|
||||
foreach ($this->rb_data['Directories'] as $dir)
|
||||
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$dir."\n");
|
||||
|
||||
// Files
|
||||
fwrite($writeFd, "# Files\n");
|
||||
foreach ($this->_rbData['Files'] as $file)
|
||||
fwrite($writeFd, 'Disallow: '.__PS_BASE_URI__.$file."\n");
|
||||
fwrite($write_fd, "# Files\n");
|
||||
foreach ($this->rb_data['Files'] as $file)
|
||||
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$file."\n");
|
||||
|
||||
// Sitemap
|
||||
fwrite($writeFd, "# Sitemap\n");
|
||||
if (file_exists($this->_smFile))
|
||||
if (filesize($this->_smFile))
|
||||
fwrite($writeFd, 'Sitemap: '.(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].__PS_BASE_URI__.'sitemap.xml'."\n");
|
||||
fwrite($writeFd, "\n");
|
||||
fwrite($write_fd, "# Sitemap\n");
|
||||
if (file_exists($this->sm_file))
|
||||
if (filesize($this->sm_file))
|
||||
fwrite(
|
||||
$write_fd,
|
||||
'Sitemap: '.(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].__PS_BASE_URI__.'sitemap.xml'."\n"
|
||||
);
|
||||
fwrite($write_fd, "\n");
|
||||
|
||||
fclose($writeFd);
|
||||
fclose($write_fd);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
} else
|
||||
@@ -128,7 +136,7 @@ class AdminGeneratorControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function _getRobotsContent()
|
||||
public function getRobotsContent()
|
||||
{
|
||||
$tab = array();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user