Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\promotion;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _seo extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* @brief Active tab
*/
@@ -40,7 +45,7 @@ class _seo extends \IPS\Dispatcher\Controller
$this->activeTab = \IPS\Request::i()->tab ?: 'urls';
\IPS\Output::i()->sidebar['actions']['rebuildsitemap'] = array(
'link' => \IPS\Http\Url::internal( 'app=core&module=promotion&controller=seo&do=rebuildSitemap' ),
'link' => \IPS\Http\Url::internal( 'app=core&module=promotion&controller=seo&do=rebuildSitemap' )->csrf(),
'title' => 'rebuild_sitemap',
'icon' => 'history'
);
@@ -56,7 +61,8 @@ class _seo extends \IPS\Dispatcher\Controller
protected function manage()
{
/* Work out output */
$activeTabContents = call_user_func( array( $this, '_manage' . mb_ucfirst( $this->activeTab ) ) );
$methodFunction = '_manage' . mb_ucfirst( $this->activeTab );
$activeTabContents = $this->$methodFunction();
/* If this is an AJAX request, just return it */
if( \IPS\Request::i()->isAjax() )
@@ -83,16 +89,13 @@ class _seo extends \IPS\Dispatcher\Controller
}
/**
* Manage FURL definitions
* Get setting to enable htaccess friendly URLs
*
* @return string
* @param \IPS\Form $form Form to add the setting to
* @return void
*/
protected function _manageUrls()
public static function htaccessSetting( $form )
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\YesNo( 'use_friendly_urls', \IPS\Settings::i()->use_friendly_urls, TRUE, array( 'togglesOn' => array( 'htaccess_mod_rewrite', 'seo_r_on' ), 'togglesOff' => array( 'use_friendly_urls_warning' ) ), NULL, NULL, NULL, 'use_friendly_urls' ) );
$isApache = mb_stripos( $_SERVER['SERVER_SOFTWARE'], 'apache' ) !== FALSE;
$form->add( new \IPS\Helpers\Form\YesNo( 'htaccess_mod_rewrite', \IPS\Settings::i()->htaccess_mod_rewrite, TRUE, array(), NULL, NULL, NULL, 'htaccess_mod_rewrite' ) );
if ( !$isApache )
@@ -105,7 +108,7 @@ class _seo extends \IPS\Dispatcher\Controller
{
$furlDefinition = \IPS\Http\Url::furlDefinition();
$response = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . $furlDefinition['login']['friendly'] )->request( NULL, NULL, FALSE )->get();
if ( !in_array( mb_substr( $response->httpResponseCode, 0, 1 ), array( '2', '3' ) ) and ( \IPS\Settings::i()->site_online OR $response->httpResponseCode != 503 ) )
if ( !\in_array( mb_substr( $response->httpResponseCode, 0, 1 ), array( '2', '3' ) ) and ( \IPS\Settings::i()->site_online OR $response->httpResponseCode != 503 ) )
{
\IPS\Member::loggedIn()->language()->words['htaccess_mod_rewrite_warning'] = \IPS\Member::loggedIn()->language()->get( $isApache ? 'htaccess_mod_rewrite_err' : 'htaccess_mod_rewrite_err_na' );
}
@@ -115,6 +118,20 @@ class _seo extends \IPS\Dispatcher\Controller
\IPS\Member::loggedIn()->language()->words['htaccess_mod_rewrite_warning'] = \IPS\Member::loggedIn()->language()->get( $isApache ? 'htaccess_mod_rewrite_err' : 'htaccess_mod_rewrite_err_na' );
}
}
}
/**
* Manage FURL definitions
*
* @return string
*/
protected function _manageUrls()
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\YesNo( 'use_friendly_urls', \IPS\Settings::i()->use_friendly_urls, TRUE, array( 'togglesOn' => array( 'htaccess_mod_rewrite', 'seo_r_on' ), 'togglesOff' => array( 'use_friendly_urls_warning' ) ), NULL, NULL, NULL, 'use_friendly_urls' ) );
static::htaccessSetting( $form );
$form->add( new \IPS\Helpers\Form\YesNo( 'seo_r_on', \IPS\Settings::i()->seo_r_on, TRUE, array( 'togglesOff' => array( 'seo_r_on_warning' ) ), NULL, NULL, NULL, 'seo_r_on' ) );
@@ -280,7 +297,9 @@ class _seo extends \IPS\Dispatcher\Controller
foreach ( \IPS\Db::i()->select( '*', 'core_seo_meta' ) as $row )
{
$rows[ $row['meta_url'] ] = \IPS\Theme::i()->getTemplate( 'trees' )->row( $url, $row['meta_id'], $row['meta_url'], TRUE, array(
$urlToDisplay = \IPS\Theme::i()->getTemplate( 'promotion' )->metaTagUrl( trim( $row['meta_url'], '/' ) );
$rows[ $row['meta_url'] ] = \IPS\Theme::i()->getTemplate( 'trees' )->row( $url, $row['meta_id'], $urlToDisplay, TRUE, array(
'edit' => array(
'icon' => 'pencil',
'title' => 'seo_meta_manage',
@@ -293,7 +312,7 @@ class _seo extends \IPS\Dispatcher\Controller
'link' => \IPS\Http\Url::internal( "app=core&module=promotion&controller=seo&tab=metatags&delete=" . $row['meta_id'] ),
'data' => array( 'delete' => '' )
)
), "", NULL, NULL );
), "", NULL, NULL, FALSE, NULL, NULL, NULL, TRUE );
}
return $rows;
@@ -330,7 +349,7 @@ class _seo extends \IPS\Dispatcher\Controller
$tags = json_decode( $meta['meta_tags'], TRUE );
$rows = array();
if( is_array( $tags ) )
if( \is_array( $tags ) )
{
foreach ( $tags as $name => $content )
{
@@ -341,7 +360,7 @@ class _seo extends \IPS\Dispatcher\Controller
'link' => \IPS\Http\Url::internal( $url . "&root={$key}&delete={$name}" ),
'data' => array( 'delete' => '' )
)
), $content );
), $content ?? \IPS\Member::loggedIn()->language()->addToStack('meta_tag_acp_deleted') );
}
}
@@ -413,7 +432,7 @@ class _seo extends \IPS\Dispatcher\Controller
'name' => function( $key, $value, $data )
{
return new \IPS\Helpers\Form\Select( $key,
$data['name'],
$data ? $data['name'] : '',
TRUE,
array( 'options' => array( 'keywords' => 'meta_keywords', 'description' => 'meta_description', 'robots' => 'meta_robots', 'other' => 'meta_other' ), 'toggles' => array( 'other' => array( 'other_' . preg_replace( "/[^a-zA-Z0-9\-_]/", "_", $key ) ) ), 'userSuppliedInput' => 'other' ),
NULL,
@@ -424,12 +443,12 @@ class _seo extends \IPS\Dispatcher\Controller
},
'content' => function( $key, $value, $data )
{
return new \IPS\Helpers\Form\TextArea( $key, $data['content'], FALSE );
return new \IPS\Helpers\Form\TextArea( $key, $data ? $data['content'] : '', FALSE, array( 'nullLang' => 'meta_tag_null_acp_form' ) );
},
);
/* Add rows */
if( count( $tags ) )
if( \count( $tags ) )
{
foreach( $tags as $tagName => $tagValue )
{
@@ -448,7 +467,7 @@ class _seo extends \IPS\Dispatcher\Controller
foreach( $values['metatag_tags'] as $index => $data )
{
if( !$data['name'] OR !$data['content'] )
if( !$data['name'] OR $data['content'] === '' )
{
continue;
}
@@ -459,7 +478,7 @@ class _seo extends \IPS\Dispatcher\Controller
\IPS\Db::i()->delete( 'core_seo_meta', array( 'meta_url=?', $url ) );
\IPS\Db::i()->delete( 'core_seo_meta', array( 'meta_url=?', \IPS\Request::i()->original_url ) );
if( $title or count( $tags ) )
if( $title or \count( $tags ) )
{
\IPS\Db::i()->insert( 'core_seo_meta', array( 'meta_url' => $url, 'meta_title' => $title, 'meta_tags' => json_encode( $tags ) ) );
}
@@ -474,6 +493,7 @@ class _seo extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=promotion&controller=seo&tab=metatags" ) );
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'promotion/meta.css', 'core', 'admin' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('seo_meta_add');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'seo_meta_add', $form );
}
@@ -516,6 +536,8 @@ FILE;
*/
protected function rebuildSitemap()
{
\IPS\Session::i()->csrfCheck();
/* truncate sitemap */
\IPS\Db::i()->delete( 'core_sitemap' );