/**
+ * ACTION::validateMessage()
* Checks if a mail to a member is allowed
* Returns a string with the error message if the mail is disallowed
+ *
+ * @param void
+ * @return String Null character string
*/
function validateMessage()
{
global $CONF, $member, $manager;
-
+
if ( !$CONF['AllowMemberMail'] )
{
return _ERROR_MEMBERMAILDISABLED;
}
-
+
if ( !$member->isLoggedIn() && !$CONF['NonmemberMail'] )
{
return _ERROR_DISALLOWED;
}
-
+
if ( !$member->isLoggedIn() && (!isValidMailAddress(postVar('frommail') ) ) )
{
return _ERROR_BADMAILADDRESS;
}
-
+
// let plugins do verification (any plugin which thinks the comment is invalid
// can change 'error' to something other than '')
$result = '';
$manager->notify('ValidateForm', array('type' => 'membermail', 'error' => &$result) );
-
+
return $result;
-
}
-
-
+
/**
* Creates a new user account
*/
/**
- * Handle karma votes
+ * ACTION::doKarma()
+ *
+ * Handle karma votes
+ *
+ * @param String $type pos or neg
+ * @return Void
*/
function doKarma($type)
{
global $itemid, $member, $CONF, $manager;
-
+
// check if itemid exists
if ( !$manager->existsItem($itemid, 0, 0) )
{
doError(_ERROR_NOSUCHITEM);
}
-
+
$blogid = getBlogIDFromItemID($itemid);
$this->checkban($blogid);
-
+
$karma =& $manager->getKarma($itemid);
-
+
// check if not already voted
if ( !$karma->isVoteAllowed(serverVar('REMOTE_ADDR') ) )
{
doError(_ERROR_VOTEDBEFORE);
}
-
+
// check if item does allow voting
$item =& $manager->getItem($itemid, 0, 0);
-
+
if ( $item['closed'] )
{
doError(_ERROR_ITEMCLOSED);
}
-
+
switch ( $type )
{
case 'pos':
$karma->votePositive();
break;
-
+
case 'neg':
$karma->voteNegative();
break;
}
-
+
// $blogid = getBlogIDFromItemID($itemid);
$blog =& $manager->getBlog($blogid);
-
+
// send email to notification address, if any
if ( $blog->getNotifyAddress() && $blog->notifyOnVote() )
{
-
+
$mailto_msg = _NOTIFY_KV_MSG . ' ' . $itemid . "\n";
// if ($CONF['URLMode'] == 'pathinfo') {
// $itemLink = createItemLink(intval($itemid));
// $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n";
$itemLink = createItemLink(intval($itemid) );
$temp = parse_url($itemLink);
-
+
if ( !$temp['scheme'] )
{
$itemLink = $CONF['IndexURL'] . $itemLink;
}
-
+
$mailto_msg .= $itemLink . "\n\n";
-
+
if ( $member->isLoggedIn() )
{
$mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n";
}
-
+
$mailto_msg .= _NOTIFY_IP . ' ' . serverVar('REMOTE_ADDR') . "\n";
$mailto_msg .= _NOTIFY_HOST . ' ' . gethostbyaddr(serverVar('REMOTE_ADDR')) . "\n";
$mailto_msg .= _NOTIFY_VOTE . "\n " . $type . "\n";
$mailto_msg .= getMailFooter();
-
+
$mailto_title = _NOTIFY_KV_TITLE . ' ' . strip_tags($item['title']) . ' (' . $itemid . ')';
-
+
$frommail = $member->getNotifyFromMailAddress();
-
+
$notify = new NOTIFICATION($blog->getNotifyAddress() );
$notify->notify($mailto_title, $mailto_msg, $frommail);
}
-
+
$refererUrl = serverVar('HTTP_REFERER');
-
+
if ( $refererUrl )
{
$url = $refererUrl;
// $url = $CONF['IndexURL'] . 'index.php?itemid=' . $itemid;
$url = $itemLink;
}
-
+
redirect($url);
exit;
}
}
/**
- * @todo document this
+ * ADMIN::action_blogsettingsupdate
+ * Updating blog settings
+ *
+ * @param Void
+ * @return Void
*/
function action_blogsettingsupdate()
{
global $member, $manager;
-
+
$blogid = intRequestVar('blogid');
$member->blogAdminRights($blogid) or $this->disallow();
$manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
$this->action_overview(_MSG_SETTINGSCHANGED);
+ return;
}
/**
}
/**
+ * BLOG::sendNewItemNotification()
* Send a new item notification to the notification list
*
- * @param $itemid
- * ID of the item
- * @param $title
- * title of the item
- * @param $body
- * body of the item
+ * @param String $itemid ID of the item
+ * @param String $title title of the item
+ * @param String $body body of the item
+ * @return Void
*/
- function sendNewItemNotification($itemid, $title, $body) {
+ function sendNewItemNotification($itemid, $title, $body)
+ {
global $CONF, $member;
-
+
// create text version of html post
$ascii = toAscii($body);
-
+
$mailto_msg = _NOTIFY_NI_MSG . " \n";
// $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n";
$temp = parse_url($CONF['Self']);
- if ($temp['scheme']) {
+ if ( $temp['scheme'] )
+ {
$mailto_msg .= createItemLink($itemid) . "\n\n";
- } else {
+ }
+ else
+ {
$tempurl = $this->getURL();
- if (i18n::substr($tempurl, -1) == '/' || i18n::substr($tempurl, -4) == '.php') {
+ if ( i18n::substr($tempurl, -1) == '/' || i18n::substr($tempurl, -4) == '.php' )
+ {
$mailto_msg .= $tempurl . '?itemid=' . $itemid . "\n\n";
- } else {
+ }
+ else
+ {
$mailto_msg .= $tempurl . '/?itemid=' . $itemid . "\n\n";
}
}
$mailto_msg .= _NOTIFY_TITLE . ' ' . strip_tags($title) . "\n";
$mailto_msg .= _NOTIFY_CONTENTS . "\n " . $ascii . "\n";
$mailto_msg .= getMailFooter();
-
+
$mailto_title = $this->getName() . ': ' . _NOTIFY_NI_TITLE;
-
+
$frommail = $member->getNotifyFromMailAddress();
-
+
$notify = new NOTIFICATION($this->getNotifyAddress());
$notify->notify($mailto_title, $mailto_msg , $frommail);
+ return;
}
function setTemplate($template) {
$this->template =& $template;
}
-
- function setCurrentComment(&$comment) {
-
+
+ /**
+ * COMMENTACTIONS::setCurrentComment()
+ * Set $currentcommentid and $currentcommentarray
+ *
+ * @param Array $comment array with comment elements
+ * @return void
+ *
+ */
+ function setCurrentComment(&$comment)
+ {
global $manager;
-
- // begin if: member comment
- if ($comment['memberid'] != 0)
+
+ if ( $comment['memberid'] != 0)
{
$comment['authtext'] = $template['COMMENTS_AUTH'];
-
$mem =& $manager->getMember($comment['memberid']);
$comment['user'] = $mem->getDisplayName();
-
- // begin if: member URL exists, set it as the userid
- if ($mem->getURL() )
+
+ if ( $mem->getURL() )
{
$comment['userid'] = $mem->getURL();
}
- // else: set the email as the userid
else
{
$comment['userid'] = $mem->getEmail();
- } // end if
-
+ }
+
$comment['userlinkraw'] = createLink(
'member',
array(
'extra' => $this->commentsObj->itemActions->linkparams
)
);
-
}
- // else: non-member comment
else
{
-
// create smart links
-
- // begin if: comment userid is not empty
- if (!empty($comment['userid']) )
+ if ( !empty($comment['userid']) )
{
-
- // begin if: comment userid has either "http://" or "https://" at the beginning
if ( (i18n::strpos($comment['userid'], 'http://') === 0) || (i18n::strpos($comment['userid'], 'https://') === 0) )
{
$comment['userlinkraw'] = $comment['userid'];
}
- // else: prepend the "http://" (backwards compatibility before rev 1471)
else
{
$comment['userlinkraw'] = 'http://' . $comment['userid'];
- } // end if
-
+ }
}
- // else if: comment email is valid
- else if (isValidMailAddress($comment['email']) )
+ else if ( isValidMailAddress($comment['email']) )
{
$comment['userlinkraw'] = 'mailto:' . $comment['email'];
}
- // else if: comment userid is a valid email
- else if (isValidMailAddress($comment['userid']) )
+ else if ( isValidMailAddress($comment['userid']) )
{
$comment['userlinkraw'] = 'mailto:' . $comment['userid'];
- } // end if
-
- } // end if
-
+ }
+ }
+
$this->currentComment =& $comment;
global $currentcommentid, $currentcommentarray;
$currentcommentid = $comment['commentid'];
$currentcommentarray = $comment;
+ return;
}
/**
/**
* Parse templatevar excerpt
*/
- function parse_excerpt() {
+ function parse_excerpt()
+ {
echo stringToXML(shorten($this->currentComment['body'], 60, '...'));
}
}
/**
- * Parse templatevar useremail
+ * COMMENTACTIONS::parse_useremail()
+ * Output mail address
+ *
+ * @param void
+ * @return void
*/
function parse_useremail() {
global $manager;
- if ($this->currentComment['memberid'] > 0)
+ if ( $this->currentComment['memberid'] > 0 )
{
$member =& $manager->getMember($this->currentComment['memberid']);
-
- if ($member->email != '')
+
+ if ( $member->email != '' )
+ {
echo $member->email;
+ }
}
else
{
- if (isValidMailAddress($this->currentComment['email']))
+ if ( isValidMailAddress($this->currentComment['email']) )
+ {
echo $this->currentComment['email'];
- elseif (isValidMailAddress($this->currentComment['userid']))
+ }
+ elseif ( isValidMailAddress($this->currentComment['userid']) )
+ {
echo $this->currentComment['userid'];
-// if (!(i18n::strpos($this->currentComment['userlinkraw'], 'mailto:') === false))
-// echo str_replace('mailto:', '', $this->currentComment['userlinkraw']);
+ }
}
+ return;
}
-
+
/**
* Parse templatevar userid
*/
}
/**
+ * COMMENTS::addComment()
* Adds a new comment to the database
+ *
* @param string $timestamp
* @param array $comment
* @return mixed
function addComment($timestamp, $comment)
{
global $CONF, $member, $manager;
-
+
$blogid = getBlogIDFromItemID($this->itemid);
-
+
$settings =& $manager->getBlog($blogid);
$settings->readSettings();
-
+
// begin if: comments disabled
if ( !$settings->commentsEnabled() )
{
return _ERROR_COMMENTS_DISABLED;
- } // end if
-
+ }
+
// begin if: public cannot comment
if ( !$settings->isPublic() && !$member->isLoggedIn() )
{
return _ERROR_COMMENTS_NONPUBLIC;
- } // end if
-
+ }
+
// begin if: comment uses a protected member name
if ( $CONF['ProtectMemNames'] && !$member->isLoggedIn() && MEMBER::isNameProtected($comment['user']) )
{
return _ERROR_COMMENTS_MEMBERNICK;
- } // end if
-
+ }
+
// begin if: email required, but missing (doesn't apply to members)
if ( $settings->emailRequired() && i18n::strlen($comment['email']) == 0 && !$member->isLoggedIn() )
{
return _ERROR_EMAIL_REQUIRED;
- } // end if
+ }
// begin if: commenter's name is too long
if ( i18n::strlen($comment['user']) > 40 )
{
return _ERROR_USER_TOO_LONG;
- } // end if
+ }
// begin if: commenter's email is too long
if ( i18n::strlen($comment['email']) > 100 )
{
return _ERROR_EMAIL_TOO_LONG;
- } // end if
+ }
// begin if: commenter's url is too long
if ( i18n::strlen($comment['userid']) > 100 )
{
return _ERROR_URL_TOO_LONG;
- } // end if
+ }
$comment['timestamp'] = $timestamp;
$comment['host'] = gethostbyaddr(serverVar('REMOTE_ADDR') );
'live' => TRUE,
'return' => $continue
);
-
+
// begin if: member logged in
if ( $member->isLoggedIn() )
{
$spamcheck['author'] = $comment['user'];
$spamcheck['email'] = $comment['email'];
$spamcheck['url'] = $comment['userid'];
- } // end if
-
+ }
+
$manager->notify('SpamCheck', array('spamcheck' => &$spamcheck) );
-
+
if ( !$continue && isset($spamcheck['result']) && $spamcheck['result'] == TRUE )
{
return _ERROR_COMMENTS_SPAM;
}
-
+
// isValidComment returns either "1" or an error message
$isvalid = $this->isValidComment($comment, $spamcheck);
-
+
if ( $isvalid != 1 )
{
return $isvalid;
}
-
+
// begin if: send email to notification address
if ( $settings->getNotifyAddress() && $settings->notifyOnComment() )
{
-
$mailto_msg = _NOTIFY_NC_MSG . ' ' . $this->itemid . "\n";
-// $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $this->itemid . "\n\n";
$temp = parse_url($CONF['Self']);
-
+
if ( $temp['scheme'] )
{
$mailto_msg .= createItemLink($this->itemid) . "\n\n";
else
{
$tempurl = $settings->getURL();
-
+
if ( i18n::substr($tempurl, -1) == '/' || i18n::substr($tempurl, -4) == '.php' )
{
$mailto_msg .= $tempurl . '?itemid=' . $this->itemid . "\n\n";
$mailto_msg .= $tempurl . '/?itemid=' . $this->itemid . "\n\n";
}
}
-
+
if ( $comment['memberid'] == 0 )
{
$mailto_msg .= _NOTIFY_USER . ' ' . $comment['user'] . "\n";
{
$mailto_msg .= _NOTIFY_MEMBER .' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n";
}
-
+
$mailto_msg .= _NOTIFY_HOST . ' ' . $comment['host'] . "\n";
$mailto_msg .= _NOTIFY_COMMENT . "\n " . $comment['body'] . "\n";
$mailto_msg .= getMailFooter();
-
+
$item =& $manager->getItem($this->itemid, 0, 0);
$mailto_title = _NOTIFY_NC_TITLE . ' ' . strip_tags($item['title']) . ' (' . $this->itemid . ')';
-
+
$frommail = $member->getNotifyFromMailAddress($comment['email']);
-
+
$notify = new NOTIFICATION($settings->getNotifyAddress() );
$notify->notify($mailto_title, $mailto_msg , $frommail);
}
-
+
$comment = COMMENT::prepare($comment);
-
+
$manager->notify('PreAddComment', array('comment' => &$comment, 'spamcheck' => &$spamcheck) );
-
+
$name = sql_real_escape_string($comment['user']);
$url = sql_real_escape_string($comment['userid']);
$email = sql_real_escape_string($comment['email']);
$memberid = intval($comment['memberid']);
$timestamp = date('Y-m-d H:i:s', $comment['timestamp']);
$itemid = $this->itemid;
-
+
$qSql = 'SELECT COUNT(*) AS result '
. 'FROM ' . sql_table('comment')
. ' WHERE '
. ' AND citem = "' . $itemid . '"'
. ' AND cblog = "' . $blogid . '"';
$result = (integer) quickQuery($qSql);
-
+
if ( $result > 0 )
{
return _ERROR_BADACTION;
}
-
+
$query = 'INSERT INTO '.sql_table('comment').' (CUSER, CMAIL, CEMAIL, CMEMBER, CBODY, CITEM, CTIME, CHOST, CIP, CBLOG) '
. "VALUES ('$name', '$url', '$email', $memberid, '$body', $itemid, '$timestamp', '$host', '$ip', '$blogid')";
-
+
sql_query($query);
-
+
// post add comment
$commentid = sql_insert_id();
$manager->notify('PostAddComment', array('comment' => &$comment, 'commentid' => &$commentid, 'spamcheck' => &$spamcheck) );
-
+
// succeeded !
return TRUE;
}
/**
+ * COMMENTS::isValidComment()
* Checks if a comment is valid and call plugins
* that can check if the comment is a spam comment
+ *
+ * @param Array $comment array with comment elements
+ * @param Array $spamcheck array with spamcheck elements
*/
- function isValidComment(&$comment, &$spamcheck) {
-
+ function isValidComment(&$comment, &$spamcheck)
+ {
global $member, $manager;
-
+
// check if there exists a item for this date
$item =& $manager->getItem($this->itemid, 0, 0);
-
- if (!$item)
+
+ if ( !$item )
{
return _ERROR_NOSUCHITEM;
}
-
- if ($item['closed'])
+
+ if ( $item['closed'] )
{
return _ERROR_ITEMCLOSED;
}
-
- # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
- # original eregi comparison: eregi('[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}', $comment['body']) != FALSE
-
+
// don't allow words that are too long
- if (preg_match('/[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}/', $comment['body']) != 0)
+ if ( preg_match('/[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}/', $comment['body']) != 0 )
{
return _ERROR_COMMENT_LONGWORD;
}
-
+
// check lengths of comment
- if (i18n::strlen($comment['body']) < 3)
+ if ( i18n::strlen($comment['body']) < 3 )
{
return _ERROR_COMMENT_NOCOMMENT;
}
-
- if (i18n::strlen($comment['body']) > 5000)
+
+ if ( i18n::strlen($comment['body']) > 5000 )
{
return _ERROR_COMMENT_TOOLONG;
}
-
+
// only check username if no member logged in
- if (!$member->isLoggedIn() )
+ if ( !$member->isLoggedIn() && (i18n::strlen($comment['user']) < 2) )
{
-
- if (i18n::strlen($comment['user']) < 2)
- {
- return _ERROR_COMMENT_NOUSERNAME;
- }
-
+ return _ERROR_COMMENT_NOUSERNAME;
}
-
- if ((i18n::strlen($comment['email']) != 0) && !(isValidMailAddress(trim($comment['email']) ) ) )
+
+ if ( (i18n::strlen($comment['email']) != 0) && !isValidMailAddress(trim($comment['email'])) )
{
return _ERROR_BADMAILADDRESS;
}
-
+
// let plugins do verification (any plugin which thinks the comment is invalid
// can change 'error' to something other than '1')
$result = 1;
$manager->notify('ValidateForm', array('type' => 'comment', 'comment' => &$comment, 'error' => &$result, 'spamcheck' => &$spamcheck) );
-
+
return $result;
}
-
}
-
-?>
return;
}
+ /**
+ * MEMBER::sendActivationLink()
+ * Send activation mail
+ *
+ * @param String $type activation type
+ * @param String $extra extra info
+ * @return Void
+ */
public function sendActivationLink($type, $extra='')
{
global $CONF;
- if (!isset($CONF['ActivationDays']))
+ if ( !isset($CONF['ActivationDays']) )
{
$CONF['ActivationDays'] = 2;
}
return $blogs;
}
- /*
+ /**
+ * MEMBER::getNotifyFromMailAddress()
+ *
* Returns an email address from which notification of commenting/karma voting can
* be sent. A suggestion can be given for when the member is not logged in
+ *
+ * @param String $suggest
+ * @return String mail address or suggestion
*/
public function getNotifyFromMailAddress($suggest = "")
{
return MEMBER::exists($name);
}
- /*
+ /**
+ * MEMBER::create()
+ *
* Adds a new member
*
* @static
+ * @param String $name
+ * @param String $realname
+ * @param String $password
+ * @param String $email
+ * @param String $url
+ * @param String $admin
+ * @param String $canlogin
+ * @param String $notes
+ * @return String 1 if success, others if fail
*/
public static function create($name, $realname, $password, $email, $url, $admin, $canlogin, $notes)
{
return _ERROR_PASSWORDMISSING;
}
- // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
- if (!preg_match('#^https?://#', $url) )
+ /*
+ * begin if: sometimes user didn't prefix the URL with http:// or https://,
+ * this cause a malformed URL. Let's fix it.
+ */
+
+ if ( !preg_match('#^https?://#', $url) )
{
$url = 'http://' . $url;
- } // end if
+ }
$name = sql_real_escape_string($name);
$realname = sql_real_escape_string($realname);