-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
skywalker512
committed
Jun 30, 2018
1 parent
92e94b3
commit 649ca3b
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
if (!defined("IN_ESOTALK")) exit; | ||
|
||
ET::$pluginInfo["BanEmail"] = array( | ||
"name" => "禁止电子邮件地址", | ||
"description" => "禁止用户使用某些电子邮件服务", | ||
"version" => "1.0.1", | ||
"author" => "saturngod", | ||
"authorEmail" => "[email protected]", | ||
"authorURL" => "http://github.com/saturngod", | ||
"license" => "MIT" | ||
); | ||
|
||
class ETPlugin_BanEmail extends ETPlugin { | ||
public function handler_userController_initJoin($controller, $form) | ||
{ | ||
|
||
$form->addField("BanEmail", "BanEmail", function($form) {},function($form, $key, &$data) | ||
{ | ||
|
||
$email = $form->getValue("email"); | ||
|
||
$found = false; | ||
$error = ""; | ||
|
||
$lists = trim(C("plugin.BanEmail.emails")); | ||
|
||
if($lists == "") { | ||
return; | ||
} | ||
|
||
$ban_emails = explode(",",$lists); | ||
|
||
foreach ($ban_emails as $search_mail) { | ||
|
||
$address = "@".trim($search_mail); | ||
|
||
$pos = strpos($email,$address); | ||
if ($pos !== false) { | ||
$found = true; | ||
$error = $search_mail . " is not allow to register."; | ||
break; | ||
} | ||
} | ||
if($found) { | ||
$form->error("email",$error); | ||
} | ||
|
||
|
||
}); | ||
} | ||
|
||
/** | ||
* Construct and process the settings form for this skin, and return the path to the view that should be | ||
* rendered. | ||
* | ||
* @param ETController $sender The page controller. | ||
* @return string The path to the settings view to render. | ||
*/ | ||
public function settings($sender) | ||
{ | ||
// Set up the settings form. | ||
$form = ETFactory::make("form"); | ||
$form->action = URL("admin/plugins/settings/BanEmail"); | ||
$form->setValue("emails", C("plugin.BanEmail.emails")); | ||
|
||
// If the form was submitted... | ||
if ($form->validPostBack("BanEmailSave")) { | ||
|
||
// Construct an array of config options to write. | ||
$config = array(); | ||
$config["plugin.BanEmail.emails"] = $form->getValue("emails"); | ||
|
||
if (!$form->errorCount()) { | ||
|
||
// Write the config file. | ||
ET::writeConfig($config); | ||
|
||
$sender->message(T("message.changesSaved"), "success autoDismiss"); | ||
$sender->redirect(URL("admin/plugins")); | ||
|
||
} | ||
} | ||
|
||
$sender->data("BanemailSettingsForm", $form); | ||
return $this->view("settings"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
// Copyright 2011 Toby Zerner, Simon Zerner | ||
// This file is part of esoTalk. Please see the included license file for usage information. | ||
|
||
if (!defined("IN_ESOTALK")) exit; | ||
|
||
/** | ||
* Displays the settings form for the Proto skin. | ||
* | ||
* @package esoTalk | ||
*/ | ||
|
||
$form = $data["BanemailSettingsForm"]; | ||
?> | ||
<?php echo $form->open(); ?> | ||
|
||
<div class='section'> | ||
|
||
<ul class='form'> | ||
|
||
<li> | ||
<label><?php echo T("Email Address"); ?></label> | ||
<?php echo $form->input("emails", "text"); ?><br/> | ||
使用 <b>英文逗号 (,)</b>来分隔电子邮件地址<br/> | ||
如 : 163.com,qq.com,189.cn | ||
</li> | ||
|
||
</ul> | ||
|
||
</div> | ||
|
||
<div class='buttons'> | ||
<?php echo $form->saveButton("BanEmailSave"); ?> | ||
</div> | ||
|
||
<?php echo $form->close(); ?> |