/**
  * This is a pre_save method that only applies to the subclasses that have post
  * fields as their members (ie, not _Thread). Likely only called in those class's
  * pre_save methods.
  *
  * @return	bool	True on success, false on failure
  */
 function pre_save_post($doquery = true)
 {
     if ($this->info['forum']['podcast'] and $this->info['podcasturl'] and empty($this->info['podcastsize'])) {
         require_once DIR . '/includes/class_upload.php';
         $upload = new vB_Upload_Abstract($this->registry);
         if (!($this->info['podcastsize'] = intval($upload->fetch_remote_filesize($this->info['podcasturl'])))) {
             $this->error('invalid_podcasturl');
             return false;
         }
     }
     if (!$this->condition) {
         if ($this->fetch_field('userid', 'post') == 0 and $this->fetch_field('username', 'post') == '') {
             $this->error('nousername');
             return false;
         }
         if ($this->fetch_field('dateline', 'post') === null) {
             $this->set('dateline', TIMENOW);
         }
         if ($this->fetch_field('ipaddress', 'post') === null) {
             $this->set('ipaddress', $this->registry->options['logip'] ? IPADDRESS : '');
         }
         // flood check
         if ($this->registry->options['floodchecktime'] > 0 and empty($this->info['preview']) and empty($this->info['is_automated']) and $this->fetch_field('userid', 'post')) {
             if (!$this->info['user']) {
                 $this->info['user'] = fetch_userinfo($this->fetch_field('userid', 'post'));
             }
             $user =& $this->info['user'];
             if ($user['lastpost'] <= TIMENOW and !can_moderate($this->info['forum']['forumid'], '', $user['userid'], $user['usergroupid'] . (trim($user['membergroupids']) ? ",{$user['membergroupids']}" : ''))) {
                 if (!class_exists('vB_FloodCheck')) {
                     require_once DIR . '/includes/class_floodcheck.php';
                 }
                 $this->floodcheck =& new vB_FloodCheck($this->registry, 'user', 'lastpost');
                 $this->floodcheck->commit_key($this->registry->userinfo['userid'], TIMENOW, TIMENOW - $this->registry->options['floodchecktime']);
                 if ($this->floodcheck->is_flooding()) {
                     $this->error('postfloodcheck', $this->registry->options['floodchecktime'], $this->floodcheck->flood_wait());
                     return false;
                 }
                 if ($this->errors) {
                     // if we already have errors, the save won't happen, so rollback now...
                     $this->floodcheck->rollback();
                 } else {
                     // ...or, in case we have a new error
                     $this->set_failure_callback(array(&$this->floodcheck, 'rollback'));
                 }
             }
         }
     }
     if (!$this->verify_image_count('pagetext', 'allowsmilie', $this->info['forum']['forumid'], 'post')) {
         return false;
     }
     if ($this->info['posthash']) {
         $this->info['newattach'] = $this->fetch_attachment_count($this->info['posthash'], $this->fetch_field('userid', 'post'));
         $this->set('attach', intval($this->fetch_field('attach')) + $this->info['newattach']);
     }
     // New posts that aren't automated and are visible should be scanned
     if (!$this->condition and !empty($this->registry->options['vb_antispam_key']) and empty($this->info['is_automated']) and $this->fetch_field('visible') == 1 and (!$this->registry->options['vb_antispam_posts'] or $this->registry->userinfo['posts'] < $this->registry->options['vb_antispam_posts']) and !can_moderate()) {
         require_once DIR . '/includes/class_akismet.php';
         $akismet = new vB_Akismet($this->registry);
         $akismet->akismet_board = $this->registry->options['bburl'];
         $akismet->akismet_key = $this->registry->options['vb_antispam_key'];
         if ($akismet->verify_text(array('user_ip' => IPADDRESS, 'user_agent' => USER_AGENT, 'comment_type' => 'post', 'comment_author' => $this->registry->userinfo['userid'] ? $this->registry->userinfo['username'] : $this->fetch_field('username', 'post'), 'comment_author_email' => $this->registry->userinfo['email'], 'comment_author_url' => $this->registry->userinfo['homepage'], 'comment_content' => $this->fetch_field('pagetext', 'post'))) === 'spam') {
             $this->set('visible', 0);
             $this->spamlog_insert = true;
         }
     }
     return true;
 }
Exemplo n.º 2
0
/**
* Verifies that an akismet key is valid
*
* @param	string	The akismet key to check for validity
* @param	string	The URL that the key is going to be used on
* @param	fields	Extra information that should be submitted to akismet
*
* @return	boolean	Returns true if the key is valid else false
*/
function verify_akismet_status($key, $url, $fields = array())
{
	global $vbulletin;

	require_once(DIR . '/includes/class_akismet.php');
	$akismet = new vB_Akismet($vbulletin);

	$akismet->akismet_key = $key;
	$akismet->akismet_board = $url;

	return $akismet->verify_text($fields);
}
Exemplo n.º 3
0
 /**
  * Code to run before saving
  *
  * @param	boolean Do the query?
  *
  * @return	boolean	Whether this code executed correctly
  *
  */
 function pre_save($doquery = true)
 {
     if ($this->presave_called !== null) {
         return $this->presave_called;
     }
     if (!$this->condition) {
         if ($this->fetch_field('state') === null) {
             $this->set('state', 'visible');
         }
         if ($this->fetch_field('dateline') === null) {
             $this->set('dateline', TIMENOW);
         }
         if ($this->fetch_field('ipaddress') === null) {
             $this->set('ipaddress', $this->registry->options['logip'] ? IPADDRESS : '');
         }
         if (!$this->info['preview']) {
             if ($this->registry->options['floodchecktime'] > 0 and empty($this->info['is_automated']) and $this->fetch_field('postuserid') and $this->is_flooding() or $this->is_duplicate()) {
                 return false;
             }
         }
         // Posting to own picture, lets assume we've read it
         if ($this->info['pictureuser']['userid'] and $this->info['pictureuser']['userid'] == $this->registry->userinfo['userid']) {
             $this->set('messageread', true);
         }
     }
     if (!$this->verify_image_count('pagetext', 'allowsmilie', 'socialmessage')) {
         return false;
     }
     // New posts that aren't automated and are visible should be scanned
     if (!$this->condition and !empty($this->registry->options['vb_antispam_key']) and empty($this->info['is_automated']) and $this->fetch_field('state') == 'visible' and (!$this->registry->options['vb_antispam_posts'] or $this->info['user']['posts'] < $this->registry->options['vb_antispam_posts']) and !can_moderate()) {
         require_once DIR . '/includes/class_akismet.php';
         $akismet = new vB_Akismet($this->registry);
         $akismet->akismet_board = $this->registry->options['bburl'];
         $akismet->akismet_key = $this->registry->options['vb_antispam_key'];
         if ($akismet->verify_text(array('user_ip' => IPADDRESS, 'user_agent' => USER_AGENT, 'comment_type' => 'post', 'comment_author' => $this->info['user']['userid'] ? $this->info['user']['username'] : $this->fetch_field('postusername'), 'comment_content' => $this->fetch_field('pagetext'))) === 'spam') {
             $this->set('state', 'moderation');
             $this->spamlog_insert = true;
         }
     }
     if (in_coventry($this->fetch_field('postuserid'), true)) {
         $this->set('messageread', true);
     }
     $return_value = true;
     ($hook = vBulletinHook::fetch_hook('picturecommentdata_presave')) ? eval($hook) : false;
     $this->presave_called = $return_value;
     return $return_value;
 }
Exemplo n.º 4
0
	/**
	 * Pre-Save code for a SG Message
	 *
	 * @param	boolean	Do we actually run the query?
	 *
	 * @return	boolean	Did this function run successfully?
	 */
	function pre_save($doquery = true)
	{
		if ($this->presave_called !== null)
		{
			return $this->presave_called;
		}

		if (!$this->condition)
		{
			if ($this->fetch_field('state') === null)
			{
				$this->set('state', 'visible');
			}

			if ($this->fetch_field('dateline') === null)
			{
				$this->set('dateline', TIMENOW);
			}

			if ($this->fetch_field('ipaddress') === null)
			{
				$this->set('ipaddress', ($this->registry->options['logip'] ? IPADDRESS : ''));
			}

			if (!$this->info['preview'])
			{
				if (($this->registry->options['floodchecktime'] > 0 AND empty($this->info['is_automated']) AND $this->fetch_field('postuserid') AND $this->is_flooding()) OR $this->is_duplicate())
				{
					return false;
				}
			}
		}

		if (!$this->verify_image_count('pagetext', 'allowsmilie', 'socialmessage'))
		{
			return false;
		}

		// New posts that aren't automated and are visible should be scanned
		if (!$this->condition AND !empty($this->registry->options['vb_antispam_key']) AND empty($this->info['is_automated']) AND $this->fetch_field('state') == 'visible' AND (!$this->registry->options['vb_antispam_posts'] OR $this->info['user']['posts'] < $this->registry->options['vb_antispam_posts']) AND !can_moderate())
		{
			require_once(DIR . '/includes/class_akismet.php');
			$akismet = new vB_Akismet($this->registry);
			$akismet->akismet_board = $this->registry->options['bburl'];
			$akismet->akismet_key = $this->registry->options['vb_antispam_key'];
			if ($akismet->verify_text(array('user_ip' => IPADDRESS, 'user_agent' => USER_AGENT, 'comment_type' => 'post', 'comment_author' => ($this->info['user']['userid'] ? $this->info['user']['username'] : $this->fetch_field('postusername')), 'comment_author_email' => $this->info['user']['email'], 'comment_author_url' => $this->info['user']['homepage'], 'comment_content' => $this->fetch_field('pagetext'))) === 'spam')
			{
				$this->set('state', 'moderation');
				$this->spamlog_insert = true;
			}
		}

		$return_value = true;
		($hook = vBulletinHook::fetch_hook('groupmessagedata_presave')) ? eval($hook) : false;

		$this->presave_called = $return_value;
		return $return_value;
	}