Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (!defined('APPLICATION')) exit();
- $PluginInfo['AddRegistrationQuestion'] = array(
- 'Name' => 'Minecraft Premium Register verify',
- 'Description' => 'Verify if user register has a premium Minecraft account.',
- 'Version' => '0.1',
- 'Author' => "unixfox",
- 'MobileFriendly' => TRUE,
- 'SettingsUrl' => '/dashboard/settings/addregistrationquestion',
- );
- class AddRegistrationQuestion extends Gdn_Plugin {
- public function EntryController_RegisterFormBeforeTerms_Handler($Sender) {
- $this->h1ValidateAccount($Sender);
- $this->ChoiceValidation($Sender);
- $this->LoginMinecraft($Sender);
- $this->ValidateServer($Sender);
- }
- public function EntryController_RegisterBeforeTerms_Handler($Sender) {
- $this->h1ValidateAccount($Sender);
- $this->ChoiceValidation($Sender);
- $this->LoginMinecraft($Sender);
- $this->ValidateServer($Sender);
- }
- public function h1ValidateAccount($Sender)
- {
- echo "<h1>Validate your account</h1>";
- echo "<hr>";
- }
- public function ChoiceValidation($Sender)
- {
- $Sender->ChoiceValidate = array(
- 'l' => T('Login with your Minecraft account.'),
- 'c' => T('Connect on a server to verify your account.'),
- );
- echo "<li>";
- echo $Sender->Form->Label('Validate on');
- echo $Sender->Form->RadioList('ChoiceValidate', $Sender->ChoiceValidate, array('default' => 'l'));
- echo "</li>";
- }
- public function LoginMinecraft($Sender)
- {
- echo "<li>";
- echo $Sender->Form->Label('Email login Minecraft');
- echo $Sender->Form->TextBox('McEmail');
- echo "</li>";
- echo "<li>";
- echo $Sender->Form->Label('Minecraft Password');
- echo $Sender->Form->Input('McPassword', 'password');
- echo "</li>";
- }
- public function ValidateServer($Sender)
- {
- echo '<li>';
- echo $Sender->Form->Label('Enter your secret code');
- echo $Sender->Form->TextBox('SecretCode');
- echo '</li>';
- }
- public function AddQuestion($Sender) {
- echo '<li>';
- echo $Sender->Form->Label(C('Plugins.AddRegistrationQuestion.Label','Enter your secret code'), 'SecretCode');
- echo $Sender->Form->TextBox('SecretCode');
- echo '</li>';
- if ($correctanswer == 'N') {
- $Sender->Validation->AddValidationResult('Secretcode', T('Please re-read all questions again and answer again'));
- $Sender->EventArguments['Valid'] = FALSE;
- }
- }
- public function EntryController_Register_Handler($Sender) {
- $this->_AddResources($Sender);
- }
- public function EntryController_RegisterValidation_Handler($Sender) {
- include("MCAuth.class.php");
- $FormValues = $Sender->Form->FormValues();
- $UserCode = $FormValues['SecretCode'];
- $DefaultSecretCode = 'Abc123';
- $SecretCode = (C('Plugins.AddRegistrationQuestion.SecretCode', $DefaultSecretCode));
- $MCAuth = new MCAuth();
- if ($MCAuth->authenticate($FormValues['McEmail'], $FormValues['McPassword']) == FALSE)
- {
- $Sender->Form->AddError('Incorrect authenfication Minecraft account.');
- }
- else
- {
- if ($MCAuth->account['username'] != $FormValues['Name'])
- {
- $Sender->Form->AddError('Your Username is different as your Minecraft account.');
- }
- }
- if (strtolower($UserCode) != strtolower($SecretCode)) {
- $Sender->Form->AddError('Please enter Correct Code.');
- $Sender->Render();
- exit();
- }
- }
- public function SettingsController_AddRegistrationQuestion_Create($Sender) {
- $Sender->Permission('Garden.Settings.Manage');
- $Sender->Form = new Gdn_Form();
- $Validation = new Gdn_Validation();
- $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
- $ConfigurationModel->SetField(array(
- 'Plugins.AddRegistrationQuestion.SecretCode',
- 'Plugins.AddRegistrationQuestion.Label'
- ));
- $Sender->Form->SetModel($ConfigurationModel);
- $Sender->Title('Add Registration Question Plugin Settings');
- $Sender->AddSideMenu('settings/AddRegistrationQuestion');
- if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
- $Sender->Form->SetData($ConfigurationModel->Data);
- } else {
- $Data = $Sender->Form->FormValues();
- if ($Sender->Form->Save() !== FALSE) {
- $Sender->StatusMessage = T('Your settings have been saved.');
- }
- }
- $Sender->Render($this->GetView('arq-settings.php'));
- }
- public function Setup() {
- SaveToConfig('Plugins.AddRegistrationQuestion.SecretCode', 'PeregrineWasHere123');
- SaveToConfig('Plugins.AddRegistrationQuestion.Label', 'Enter Your code');
- }
- private function _AddResources($Sender) {
- $Sender->AddJsFile($this->GetResource('js/switch.js', FALSE, FALSE));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement