Skip to content
Permalink
Browse files
[plugin:comment,pcomment] add confug "ALLOW_URL_IN_NAME"
名前欄に URL と ドメイン表記の入力を許可する設定を追加しました。デフォルトで "false"(不許可)
になっています。
  • Loading branch information
nao-pon committed Aug 11, 2013
1 parent 22f210c commit 8defb99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
@@ -21,6 +21,9 @@ function plugin_comment_init () {
$this->cont['PLUGIN_COMMENT_FORMAT_NAME'] = '[[$name]]';
$this->cont['PLUGIN_COMMENT_FORMAT_NOW'] = '&new{$now};';
$this->cont['PLUGIN_COMMENT_FORMAT_STRING'] = "\x08MSG\x08 -- \x08NAME\x08 \x08NOW\x08";

// for spam block
$this->cont['PLUGIN_COMMENT_ALLOW_URL_IN_NAME'] = false;

$this->options = array(
'auth' => FALSE,
@@ -53,6 +56,10 @@ function plugin_comment_action()
$comment = str_replace('$msg', $this->root->vars['msg'], $this->cont['PLUGIN_COMMENT_FORMAT_MSG']);
if(isset($this->root->vars['name']) || ($this->root->vars['nodate'] != '1')) {
$_name = (! isset($this->root->vars['name']) || $this->root->vars['name'] == '') ? $this->root->_no_name : $this->root->vars['name'];
// check name
if (empty($this->cont['PLUGIN_COMMENT_ALLOW_URL_IN_NAME']) && preg_match('#https?://|\b[a-z0-9][a-z0-9_-]+\.[a-z]{2,6}\b#i', $_name)) {
return array('msg'=>'', 'body'=>''); // Do nothing
}
// save name to cookie
if ($_name) { $this->func->save_name2cookie($_name); }
$_name = ($_name == '') ? '' : str_replace('$name', $_name, $this->cont['PLUGIN_COMMENT_FORMAT_NAME']);
@@ -38,6 +38,9 @@ function plugin_pcomment_init () {
// Update recording page's timestamp instead of parent's page itself
$this->conf['TIMESTAMP'] = 1;

// for spam block
$this->conf['ALLOW_URL_IN_NAME'] = false;

// Template "default"
$this->conf['FORMAT_NAME']['default'] = '[[$name]]';
$this->conf['FORMAT_MSG']['default'] = '$msg';
@@ -323,6 +326,11 @@ function plugin_pcomment_insert()
$msg = str_replace("\x08" . 'USER_CODE' . "\x08", ($this->root->userinfo['uid']? 'uid:' . $this->root->userinfo['uid'] : 'ucd:' . $this->root->userinfo['ucd']), $msg);
$name = (! isset($this->root->vars['name']) || $this->root->vars['name'] == '') ? $this->root->_no_name : $this->root->vars['name'];

// check name
if (empty($this->conf['ALLOW_URL_IN_NAME']) && preg_match('#https?://|\b[a-z0-9][a-z0-9_-]+\.[a-z]{2,6}\b#i', $name)) {
return array('msg'=>'', 'body'=>''); // Do nothing
}

//$this->twitter_post($refer, $name, $msg, $this->func->get_page_uri($refer, TRUE));
if (! empty($this->root->post['twitter'])) {
$twitter_msg = $msg;

0 comments on commit 8defb99

Please sign in to comment.