Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,36 +11,55 @@
|
||||
namespace IPS\core\modules\front\contact;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Captcha;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Helpers\Form\Email;
|
||||
use IPS\Email as EmailClass;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact Form
|
||||
*/
|
||||
class _contact extends \IPS\Dispatcher\Controller
|
||||
class contact extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Is this for displaying "content"? Affects if advertisements may be shown
|
||||
*/
|
||||
public $isContentPage = FALSE;
|
||||
public bool $isContentPage = FALSE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->canUseContactUs() )
|
||||
if ( !Member::loggedIn()->canUseContactUs() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2S333/1', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '2S333/1', 403, '' );
|
||||
}
|
||||
|
||||
/* Execute */
|
||||
return parent::execute();
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,33 +67,33 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Get extensions */
|
||||
$extensions = \IPS\Application::allExtensions( 'core', 'ContactUs', FALSE, 'core', 'InternalEmail', TRUE );
|
||||
$extensions = Application::allExtensions( 'core', 'ContactUs', FALSE, 'core', 'InternalEmail', TRUE );
|
||||
|
||||
/* Don't let robots index this page, it has no value */
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'contact', 'send' );
|
||||
$form->hiddenValues['contact_referrer'] = (string) \IPS\Request::i()->referrer();
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form = new Form( 'contact', 'send' );
|
||||
$form->hiddenValues['contact_referrer'] = (string) Request::i()->referrer();
|
||||
$form->class = 'ipsForm--vertical ipsForm--contact';
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'contact_text', NULL, TRUE, array(
|
||||
$form->add( new Editor( 'contact_text', NULL, TRUE, array(
|
||||
'app' => 'core',
|
||||
'key' => 'Contact',
|
||||
'autoSaveKey' => 'contact-' . \IPS\Member::loggedIn()->member_id,
|
||||
'autoSaveKey' => 'contact-' . Member::loggedIn()->member_id,
|
||||
) ) );
|
||||
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
if ( !Member::loggedIn()->member_id )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'contact_name', NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'email_address', NULL, TRUE, array( 'bypassProfanity' => \IPS\Helpers\Form\Text::BYPASS_PROFANITY_ALL ) ) );
|
||||
if ( \IPS\Settings::i()->bot_antispam_type !== 'none' )
|
||||
$form->add( new Text( 'contact_name', NULL, TRUE ) );
|
||||
$form->add( new Email( 'email_address', NULL, TRUE, array( 'bypassProfanity' => Text::BYPASS_PROFANITY_ALL ) ) );
|
||||
if ( Settings::i()->bot_antispam_type !== 'none' and Settings::i()->guest_captcha )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Captcha );
|
||||
$form->add( new Captcha );
|
||||
}
|
||||
}
|
||||
foreach ( $extensions as $k => $class )
|
||||
@@ -84,25 +103,25 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->member_id AND \IPS\Settings::i()->contact_email_verify )
|
||||
if ( ! Member::loggedIn()->member_id AND Settings::i()->contact_email_verify )
|
||||
{
|
||||
$key = \IPS\Login::generateRandomString( 32 );
|
||||
\IPS\Db::i()->insert( 'core_contact_verify', array(
|
||||
$key = Login::generateRandomString( 32 );
|
||||
Db::i()->insert( 'core_contact_verify', array(
|
||||
'email_address' => $values['email_address'],
|
||||
'contact_data' => json_encode( $values ),
|
||||
'verify_key' => $key
|
||||
), TRUE );
|
||||
|
||||
$email = \IPS\Email::buildFromTemplate( 'core', 'contact_verify', array( $values['email_address'], $key ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
$email = EmailClass::buildFromTemplate( 'core', 'contact_verify', array( $values['email_address'], $key ), EmailClass::TYPE_TRANSACTIONAL );
|
||||
$email->send( $values['email_address'] );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( 'OK' );
|
||||
Output::i()->json( 'OK' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'contact_verify' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->contactVerify();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'contact_verify' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'system' )->contactVerify();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,18 +133,18 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( 'OK' );
|
||||
Output::i()->json( 'OK' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'message_sent' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->contactDone();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'message_sent' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'system' )->contactDone();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'contact' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->contact( $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'contact' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'system' )->contact( $form );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,36 +153,36 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function confirm()
|
||||
protected function confirm() : void
|
||||
{
|
||||
/* Show interstitial page to prevent email clients from auto-verifying. */
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'form', NULL );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->actionButtons[] = \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->button( 'contact_click_to_verify', 'submit', null, 'ipsButton ipsButton_primary ipsButton_fullWidth', array( 'tabindex' => '2', 'accesskey' => 's' ) );
|
||||
$form->hiddenValues['email'] = \IPS\Request::i()->email;
|
||||
$form->hiddenValues['key'] = \IPS\Request::i()->key;
|
||||
$form = new Form( 'form', NULL );
|
||||
$form->class = 'ipsForm--vertical ipsForm--contact-confirm';
|
||||
$form->actionButtons[] = Theme::i()->getTemplate( 'forms', 'core', 'global' )->button( 'contact_click_to_verify', 'submit', null, 'ipsButton ipsButton_primary ipsButton_fullWidth', array( 'tabindex' => '2', 'accesskey' => 's' ) );
|
||||
$form->hiddenValues['email'] = Request::i()->email;
|
||||
$form->hiddenValues['key'] = Request::i()->key;
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$verify = \IPS\Db::i()->select( '*', 'core_contact_verify', array( "email_address=?", $values['email'] ) )->first();
|
||||
$verify = Db::i()->select( '*', 'core_contact_verify', array( "email_address=?", $values['email'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException )
|
||||
catch( UnderflowException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C435/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C435/1', 404, '' );
|
||||
}
|
||||
|
||||
if ( \IPS\Login::compareHashes( $verify['verify_key'], $values['key'] ) === FALSE )
|
||||
if ( Login::compareHashes( $verify['verify_key'], $values['key'] ) === FALSE )
|
||||
{
|
||||
\IPS\Output::i()->error( 'contact_verify_key_mismatch', '2C435/2', 403, '' );
|
||||
Output::i()->error( 'contact_verify_key_mismatch', '2C435/2', 403, '' );
|
||||
}
|
||||
|
||||
/* Send it */
|
||||
$extensions = \IPS\Application::allExtensions( 'core', 'ContactUs', FALSE, 'core', 'InternalEmail', TRUE );
|
||||
$extensions = Application::allExtensions( 'core', 'ContactUs', FALSE, 'core', 'InternalEmail', TRUE );
|
||||
|
||||
foreach( $extensions AS $k => $extension )
|
||||
{
|
||||
@@ -173,16 +192,16 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_contact_verify', array( "email_address=?", $values['email'] ) );
|
||||
Db::i()->delete( 'core_contact_verify', array( "email_address=?", $values['email'] ) );
|
||||
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'message_sent' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->contactDone();
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'message_sent' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'system' )->contactDone();
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'contact_verify' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->contactConfirmVerify( $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'contact_verify' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'system' )->contactConfirmVerify( $form );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user