Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Analytics
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 03 Nov 2016
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\promotion;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytics
|
||||
*/
|
||||
class _analytics extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'analytics_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytics Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$providers = array(
|
||||
'none' => 'analytics_provider_none',
|
||||
'ga' => 'analytics_provider_ga',
|
||||
'piwik' => 'analytics_provider_piwik',
|
||||
'custom' => 'analytics_provider_custom'
|
||||
);
|
||||
|
||||
$toggles = array(
|
||||
'ga' => array('analytics_ga'),
|
||||
'piwik' => array('analytics_piwik'),
|
||||
'custom' => array('analytics_custom', 'ipbseo_ga_paginatecode')
|
||||
);
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->addMessage('analytics_description');
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'ipbseo_ga_provider', \IPS\Settings::i()->ipbseo_ga_provider, FALSE, array( 'options' => $providers, 'toggles' => $toggles ) ) );
|
||||
|
||||
/* Add a CodeMirror element for each supported provider */
|
||||
foreach( $providers as $key => $provider )
|
||||
{
|
||||
if( $key == 'none' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Codemirror( 'analytics_' . $key, \IPS\Settings::i()->ipbseo_ga_provider == $key ? \IPS\Settings::i()->ipseo_ga : '', FALSE, array('height' => 150, 'mode' => 'javascript'), NULL, NULL, NULL, 'analytics_' . $key ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Codemirror( 'ipbseo_ga_paginatecode', \IPS\Settings::i()->ipbseo_ga_paginatecode, FALSE, array('height' => 150, 'mode' => 'javascript'), NULL, NULL, NULL, 'ipbseo_ga_paginatecode' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Fix up values to ensure the correct snippet is saved */
|
||||
if ( !isset( $providers[ $values['ipbseo_ga_provider'] ] ) || $values['ipbseo_ga_provider'] == 'none' )
|
||||
{
|
||||
$values['ipbseo_ga_enabled'] = FALSE;
|
||||
$values['ipseo_ga'] = '';
|
||||
$values['ipbseo_ga_paginatecode'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$values['ipbseo_ga_enabled'] = TRUE;
|
||||
$values['ipseo_ga'] = $values['analytics_' . $values['ipbseo_ga_provider'] ];
|
||||
}
|
||||
|
||||
foreach( $providers as $key => $provider )
|
||||
{
|
||||
unset( $values['analytics_' . $key ] );
|
||||
}
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__analytics_edited' );
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_promotion_analytics');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'analytics', $form );
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class _promote extends \IPS\Dispatcher\Controller
|
||||
$output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( \IPS\Member::loggedIn()->language()->addToStack( 'promote_acp_blurb' ) );
|
||||
|
||||
/* Put up a little warning about permissions */
|
||||
$enabledServices = \IPS\Db::i()->select( 'count(*)', 'core_social_promote_sharers', array( 'sharer_enabled=1' ) );
|
||||
$enabledServices = \IPS\Db::i()->select( 'count(*)', 'core_social_promote_sharers', array( 'sharer_enabled=1' ) )->first();
|
||||
|
||||
if ( $enabledServices and ! \IPS\core\Promote::canPromote() )
|
||||
{
|
||||
@@ -464,13 +464,13 @@ class _promote extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach( $pages as $id => $data )
|
||||
{
|
||||
$options[ 'p_' . $id ] = \IPS\Member::loggedIn()->language()->addToStack( 'promote_facebook_page_prefix', NULL, array( 'sprintf' => array( $data[0] ) ) );
|
||||
$options[ 'p_' . $id ] = \IPS\Member::loggedIn()->language()->addToStack( 'promote_facebook_page_prefix', FALSE, array( 'sprintf' => array( $data[0] ) ) );
|
||||
}
|
||||
|
||||
$groups = $facebook->getGroups( \IPS\Member::loggedIn() );
|
||||
foreach( $groups as $id => $data )
|
||||
{
|
||||
$options[ 'g_' . $id ] = \IPS\Member::loggedIn()->language()->addToStack( 'promote_facebook_group_prefix', NULL, array( 'sprintf' => array( $data[0] ) ) );
|
||||
$options[ 'g_' . $id ] = \IPS\Member::loggedIn()->language()->addToStack( 'promote_facebook_group_prefix', FALSE, array( 'sprintf' => array( $data[0] ) ) );
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
@@ -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