Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -85,6 +85,10 @@ class _seo extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$tabs['metatags'] = 'seo_tab_metatags';
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'seo_furls' ) )
|
||||
{
|
||||
$tabs['robotstxt'] = 'seo_tab_robotstxt';
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if ( $activeTabContents )
|
||||
@@ -126,6 +130,103 @@ class _seo extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage robots.txt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _manageRobotstxt()
|
||||
{
|
||||
$value = \IPS\Settings::i()->robots_txt;
|
||||
if ( ! \in_array( \IPS\Settings::i()->robots_txt, ['off', 'default'] ) )
|
||||
{
|
||||
$value = 'custom';
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
if ( isset( \IPS\Request::i()->_saved ) )
|
||||
{
|
||||
/* Do we have an existing robots.txt file in the community directory? */
|
||||
$dir = trim( str_replace( \IPS\CP_DIRECTORY . '/index.php', '', $_SERVER['PHP_SELF'] ), '/' );
|
||||
|
||||
/* Oh, the community is in a directory, so we need the user to download the file and manually upload it to root */
|
||||
if ( $dir )
|
||||
{
|
||||
$rootUrl = trim( str_replace( $dir, '', (string) \IPS\Http\Url::baseUrl() ), '/' );
|
||||
if ( \IPS\Settings::i()->robots_txt === 'off' )
|
||||
{
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'use_robotstxt_warning_off', FALSE, ['sprintf' => [$rootUrl]] ), 'ipsMessage ipsMessage_warning' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'use_robotstxt_warning_download', FALSE, ['sprintf' => [$rootUrl]] ), 'ipsMessage ipsMessage_warning' );
|
||||
}
|
||||
}
|
||||
else if ( ! \IPS\CIC2 AND file_exists( \IPS\ROOT_PATH . '/robots.txt' ) )
|
||||
{
|
||||
if ( \IPS\Settings::i()->robots_txt === 'off' )
|
||||
{
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'use_robotstxt_warning_existing_off', FALSE, ['sprintf' => [ rtrim( \IPS\Http\Url::baseUrl(), '/' ) ] ] ), 'ipsMessage ipsMessage_warning' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'use_robotstxt_warning_existing_download', FALSE, ['sprintf' => [ rtrim( \IPS\Http\Url::baseUrl(), '/' ) ] ] ), 'ipsMessage ipsMessage_warning' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'use_robotstxt', $value, FALSE, [
|
||||
'options' => [
|
||||
'off' => 'use_robotstxt_off',
|
||||
'default' => 'use_robotstxt_default',
|
||||
'custom' => 'use_robotstxt_custom'
|
||||
],
|
||||
'toggles' => [
|
||||
'custom' => [ 'use_robotstxt_custom_editor' ]
|
||||
]
|
||||
], NULL, NULL, NULL, 'use_robotstxt' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Codemirror( 'use_robotstxt_custom_editor', ( $value === 'custom' ? \IPS\Settings::i()->robots_txt : '' ), FALSE, [], NULL, NULL, NULL, 'use_robotstxt_custom_editor' ) );
|
||||
|
||||
/* Are we saving? */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$value = $values['use_robotstxt'];
|
||||
|
||||
if ( $values['use_robotstxt'] === 'custom' )
|
||||
{
|
||||
$value = $values['use_robotstxt_custom_editor'];
|
||||
}
|
||||
|
||||
$form->saveAsSettings( [ 'robots_txt' => $value ] );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=promotion&controller=seo&tab=robotstxt&_saved=1" ) );
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads the robots.txt file
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function downloadRobotstxt()
|
||||
{
|
||||
if ( \IPS\Settings::i()->robots_txt != 'off' )
|
||||
{
|
||||
if ( \IPS\Settings::i()->robots_txt == 'default' )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Dispatcher\Front::robotsTxtRules(), 200, 'application/x-robotstxt', array( 'Content-Disposition' => 'attachment; filename=robots.txt' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Settings::i()->robots_txt, 200, 'application/x-robotstxt', array( 'Content-Disposition' => 'attachment; filename=robots.txt' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage FURL definitions
|
||||
*
|
||||
@@ -526,7 +627,7 @@ Options -MultiViews
|
||||
RewriteEngine On
|
||||
RewriteBase {$dir}
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule \\.(js|css|jpeg|jpg|gif|png|ico|map)(\\?|$) {$dir}404error.php [L,NC]
|
||||
RewriteRule \\.(js|css|jpeg|jpg|gif|png|ico|map|webp)(\\?|$) {$dir}404error.php [L,NC]
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
Reference in new issue
Block a user