Beispiel #1
1
function fetch_keywords_list($threadinfo, $pagetext = '')
{
    global $vbphrase, $vbulletin;
    require_once DIR . '/includes/functions_search.php';
    require_once DIR . '/includes/class_taggablecontent.php';
    $keywords = vB_Taggable_Content_Item::filter_tag_list($threadinfo['taglist'], $errors, false);
    if (!empty($threadinfo['prefixid'])) {
        $prefix = $vbphrase["prefix_{$threadinfo['prefixid']}_title_plain"];
        $keywords[] = trim($prefix);
    }
    if (!empty($pagetext)) {
        // title has already been htmlspecialchar'd, pagetext has not
        $words = fetch_postindex_text(unhtmlspecialchars($threadinfo['title']) . ' ' . $pagetext);
        $wordarray = split_string($words);
        $sorted_counts = array_count_values($wordarray);
        arsort($sorted_counts);
        require DIR . '/includes/searchwords.php';
        // get the stop word list; allow multiple requires
        $badwords = array_merge($badwords, preg_split('/\\s+/s', $vbulletin->options['badwords'], -1, PREG_SPLIT_NO_EMPTY));
        foreach ($sorted_counts as $word => $count) {
            $word = trim($word);
            if (in_array(vbstrtolower($word), $badwords)) {
                continue;
            }
            if (vbstrlen($word) <= $vbulletin->options['minsearchlength'] and !in_array(vbstrtolower($word), $goodwords)) {
                continue;
            }
            $word = htmlspecialchars_uni($word);
            if (!in_array($word, $keywords)) {
                $keywords[] = $word;
            }
            if (sizeof($keywords) >= 50) {
                break;
            }
        }
    }
    return implode(', ', $keywords);
}
Beispiel #2
0
                 } else {
                     $remove['approvals']["{$userid}"] = $userid;
                 }
             }
         }
     } else {
         // IGNORE LIST
         $vbulletin->GPC['userlist'] = 'ignore';
         if (!empty($clean_lists['ignore_original'])) {
             $remove['ignore'] = array_merge($remove['ignore'], array_diff($clean_lists['ignore_original'], is_array($clean_lists['ignore']) ? $clean_lists['ignore'] : array()));
         }
         if (!empty($vbulletin->GPC['username'])) {
             if ($vbulletin->GPC['ajax']) {
                 $vbulletin->GPC['username'] = convert_urlencoded_unicode($vbulletin->GPC['username']);
             }
             if ($userinfo = $db->query_first("\n\t\t\t\tSELECT userid, username, usergroupid, membergroupids\n\t\t\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\t\t\tWHERE username = '******'username'])) . "'\n\t\t\t")) {
                 $uglist = $userinfo['usergroupid'] . iif(trim($userinfo['membergroupids']), ",{$userinfo['membergroupids']}");
                 if (!$vbulletin->options['ignoremods'] and can_moderate(0, '', $userinfo['userid'], $uglist) and !($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])) {
                     eval(standard_error(fetch_error('listignoreuser', $userinfo['username'])));
                 } else {
                     if ($vbulletin->userinfo['userid'] == $userinfo['userid']) {
                         eval(standard_error(fetch_error('cantlistself_ignore')));
                     }
                 }
                 $add['ignore']["{$userinfo['userid']}"] = $userinfo;
             } else {
                 eval(standard_error(fetch_error('listbaduser', $vbulletin->GPC['username'], $vbulletin->session->vars['sessionurl_q'])));
             }
         }
     }
 }
Beispiel #3
0
/**
 * Capitalizes the first letter of each sentence, provided it is within a-z. Lower-cases the entire string first
 * Ignores locales
 *
 * @param	string	Text to capitalize
 *
 * @return	string
 */
function fetch_sentence_case($text)
{
    return preg_replace_callback('#(^|\\.\\s+|\\:\\s+|\\!\\s+|\\?\\s+)[a-z]#', create_function('$matches', 'return strtoupper($matches[0]);'), vbstrtolower($text));
}
 /**
  *	Converts synomyns to canonical tags
  *
  * If a tag is converted a message will be added to the error array to alert the user
  * Does not handle removing duplicates created by the coversion process
  *
  * @param array array of tags to convert
  * @param array array of errors (in/out param)
  *
  *	@return array the new list of tags
  */
 protected static function convert_synonyms($tags, &$errors)
 {
     //throw new Exception('Function needs to be converted to use assertor or new API');
     if (empty($tags)) {
         return array();
     }
     //global $vbulletin;
     //$escaped_tags = array_map(array(&$vbulletin->db, 'escape_string'), $tags);
     /*$set = $vbulletin->db->query_read("
     		  SELECT t.tagtext, p.tagtext as canonicaltagtext
     			FROM " . TABLE_PREFIX . "tag t JOIN
     				" . TABLE_PREFIX . "tag p ON t.canonicaltagid = p.tagid
     			WHERE t.tagtext IN ('" . implode ("', '", $escaped_tags) . "')
     		");*/
     $set = vB::getDbAssertor()->assertQuery('vBForum:getTagsBySynonym', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'tags' => $tags));
     $map = array();
     //while ($row = $vbulletin->db->fetch_array($set))
     if ($set and $set->valid()) {
         foreach ($set as $row) {
             $map[vbstrtolower($row['tagtext'])] = $row['canonicaltagtext'];
         }
     }
     //$vbulletin->db->free_result($set);
     $new_tags = array();
     foreach ($tags as $key => $tag) {
         $tag_lower = vbstrtolower($tag);
         if (array_key_exists($tag_lower, $map)) {
             $errors["{$tag_lower}-convert"] = array('tag_x_converted_to_y', $tag, $map[$tag_lower]);
             $new_tags[] = $map[$tag_lower];
         } else {
             $new_tags[] = $tag;
         }
     }
     return $new_tags;
 }
Beispiel #5
0
function tagdomerge()
{
	global $vbulletin, $vbphrase, $db;

	$taglist = tagcp_fetch_tag_list();
	if (!sizeof($taglist))
	{
		print_cp_header($vbphrase['tag_manager']);
		print_stop_message('no_tags_selected');
	}

	$vbulletin->input->clean_array_gpc('p', array(
		'tagtext' => TYPE_NOHTML
	));

	$tagtext = $vbulletin->GPC['tagtext'];

	$name_changed = false;
	$tagdm = datamanager_init('tag', $vbulletin, ERRTYPE_ARRAY);
	if (!$tagdm->fetch_by_tagtext($tagtext))
	{
		//bail on errors
		if ($tagdm->errors)
		{
			print_cp_header($vbphrase['tag_manager']);
			print_stop_message('generic_error_x', implode('<br /><br />', $tagdm->errors));
		}

		//otherwise create tag
		$errors = array();
		$valid = vB_Taggable_Content_Item::filter_tag_list(array($vbulletin->GPC['tagtext']), $errors);

		if ($errors)
		{
			print_cp_header($vbphrase['tag_manager']);
			print_stop_message('generic_error_x', implode('<br /><br />', $errors));
		}

		if (!empty($valid))
		{
			$tagdm->set('tagtext', $valid[0]);
			$tagdm->set('dateline', TIMENOW);

			if ($tagdm->errors)
			{
				print_cp_header($vbphrase['tag_manager']);
				print_stop_message('generic_error_x', implode('<br /><br />', $tagdm->errors));
			}

			$tagdm->save();
		}
	}
	else
	{
		//if the old tag and new differ only by case, then update
		if ($tagtext != $tagdm->fetch_field('tagtext') AND
			vbstrtolower($tagtext) == vbstrtolower($tagdm->fetch_field('tagtext'))
		)
		{
			$name_changed = true;
			$tagdm->set('tagtext', $tagtext);
			$tagdm->save();
		}
	}

	$targetid = $tagdm->fetch_field('tagid');
	if (!$targetid)
	{
		print_cp_header($vbphrase['tag_manager']);
		print_stop_message('no_changes_made');
	}

	// check if source and targed are the same
	if (sizeof($taglist) == 1 AND in_array($targetid, $taglist))
	{
		if ($name_changed)
		{
			print_cp_header($vbphrase['tag_manager']);
			print_stop_message('tags_edited_successfully');
		}
		else
		{
			print_cp_header($vbphrase['tag_manager']);
		 	print_stop_message('no_changes_made');
		}
	}

	if (false !== ($selected = array_search($targetid, $taglist)))
	{
		// ensure targetid is not in taglist
		unset($taglist[$selected]);
	}


	foreach ($taglist as $mergetagid)
	{
		if ($mergetagid != $targetid)
		{
			$mergetagdm = datamanager_init('tag', $vbulletin, ERRTYPE_ARRAY);
			if ($mergetagdm->fetch_by_id($mergetagid))
			{
				$mergetagdm->make_synonym($targetid);
			}
		}
	}

	// need to invalidate the search and tag cloud caches
	build_datastore('tagcloud', '', 1);
	build_datastore('searchcloud', '', 1);

	setcookie('vbulletin_inlinetag', '', TIMENOW - 3600, '/');
	print_cp_header($vbphrase['tag_manager']);
	print_stop_message('tags_edited_successfully');
}
Beispiel #6
0
 /**
  * Accepts a list of recipients names to create the touserarray field
  *
  * @param	string	Single user name, or semi-colon separated list of user names
  * @param	array	$permissions array for sending user.
  *
  * @return	boolean
  */
 function set_recipients($recipientlist, &$permissions, $type = 'bcc')
 {
     $names = array();
     // names in the recipient list
     $users = array();
     // users from the recipient list found in the user table
     $notfound = array();
     // names from the recipient list NOT found in the user table
     $recipients = array();
     // users to whom the message WILL be sent
     $errors = array();
     $recipientlist = trim($recipientlist);
     $this->info['permissions'] =& $permissions;
     if (!empty($this->info['is_automated'])) {
         $this->overridequota = true;
     }
     // pmboxfull needs $fromusername defined
     if (($fromusername = $this->fetch_field('fromusername')) === null) {
         trigger_error('Set fromusername before calling set_recipients()', E_USER_ERROR);
     }
     if (($fromuserid = $this->fetch_field('fromuserid')) === null) {
         trigger_error('Set fromuserid before calling set_recipients()', E_USER_ERROR);
     }
     $fromuser = fetch_userinfo($fromuserid);
     // check for valid recipient string
     if ($recipientlist == '') {
         return false;
     }
     // split multiple recipients into an array
     if (preg_match('/(?<!&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5});/', $recipientlist)) {
         $recipientlist = preg_split('/(?<!&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5});/', $recipientlist, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($recipientlist as $recipient) {
             $recipient = trim($recipient);
             if ($recipient != '') {
                 $names[] = htmlspecialchars_uni($recipient);
             }
         }
     } else {
         $names[] = htmlspecialchars_uni($recipientlist);
     }
     // check for max allowed recipients
     if ($permissions['pmsendmax'] > 0) {
         $this->info['numusers'] += sizeof($names);
     }
     // query recipients
     $checkusers = $this->dbobject->query_read_slave("\n\t\t\tSELECT usertextfield.*, user.*\n\t\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n\t\t\tWHERE username IN('" . implode('\', \'', array_map(array($this->dbobject, 'escape_string'), $names)) . "')\n\t\t\tORDER BY user.username\n\t\t");
     // build array of checked users
     while ($checkuser = $this->dbobject->fetch_array($checkusers)) {
         $lowname = vbstrtolower($checkuser['username']);
         $checkuserperms = fetch_permissions(0, $checkuser['userid'], $checkuser);
         if ($checkuserperms['pmquota'] < 1 and !$this->overridequota) {
             if ($checkuser['options'] & $this->registry->bf_misc_useroptions['receivepm']) {
                 // This will cause the 'can't receive pms' error below to be triggered
                 $checkuser['options'] -= $this->registry->bf_misc_useroptions['receivepm'];
             }
         }
         $users["{$lowname}"] = $checkuser;
     }
     // check to see if any recipients were not found
     foreach ($names as $name) {
         $lowname = vbstrtolower($name);
         if (!isset($users["{$lowname}"])) {
             $notfound[] = $name;
         }
     }
     if (!empty($notfound)) {
         $this->error('pmrecipientsnotfound', implode("</li>\r\n<li>", $notfound));
         return false;
     }
     // run through recipients to check if we can insert the message
     foreach ($users as $lowname => $user) {
         if (!($user['options'] & $this->registry->bf_misc_useroptions['receivepm']) and !$this->overridequota) {
             // recipient has private messaging disabled
             $this->error('pmrecipturnedoff', $user['username']);
             return false;
         } else {
             if ($user['options'] & $this->registry->bf_misc_useroptions['receivepmbuddies'] and strpos(" {$user['buddylist']} ", " {$fromuser['userid']} ") === false and !can_moderate() and !$this->overridequota) {
                 // recipient receives PMs only from buddies and sender is not on the list and not board staff
                 $this->error('pmrecipturnedoff', $user['username']);
                 return false;
             } else {
                 // don't allow a tachy user to sends pms to anyone other than himself
                 if (in_coventry($fromuser['userid'], true) and $user['userid'] != $fromuser['userid']) {
                     $this->info['tostring']["{$type}"]["{$user['userid']}"] = $user['username'];
                     continue;
                 } else {
                     if (strpos(" {$user['ignorelist']} ", ' ' . $fromuser['userid'] . ' ') !== false and !$this->overridequota) {
                         // recipient is ignoring sender
                         if ($permissions['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
                             $recipients["{$lowname}"] = true;
                             $this->info['tostring']["{$type}"]["{$user['userid']}"] = $user['username'];
                         } else {
                             // bbuser is being ignored by recipient - do not send, but do not error
                             $this->info['tostring']["{$type}"]["{$user['userid']}"] = $user['username'];
                             continue;
                         }
                     } else {
                         cache_permissions($user, false);
                         if ($user['permissions'] < 1) {
                             // recipient has no pm permission
                             $this->error('pmusernotallowed', $user['username']);
                         } else {
                             if ($user['pmtotal'] >= $user['permissions']['pmquota'] and !$this->overridequota) {
                                 // recipient is over their pm quota, is the sender allowed to ignore it?
                                 if ($permissions['pmpermissions'] & $this->registry->bf_ugp_pmpermissions['canignorequota']) {
                                     $recipients["{$lowname}"] = true;
                                     $this->info['tostring']["{$type}"]["{$user['userid']}"] = $user['username'];
                                 } else {
                                     if ($user['usergroupid'] != 3 and $user['usergroupid'] != 4) {
                                         $touserinfo =& $user;
                                         eval(fetch_email_phrases('pmboxfull', $touserinfo['languageid'], '', 'email'));
                                         vbmail($touserinfo['email'], $emailsubject, $emailmessage, true);
                                         $this->error('pmquotaexceeded', $user['username']);
                                     } else {
                                         $this->error('pmquotaexceeded', $user['username']);
                                     }
                                 }
                             } else {
                                 if (!($user['options'] & $this->registry->bf_misc_useroptions['pmboxwarning']) and $user['permissions']['pmquota'] and ($user['pmtotal'] + 1) / $user['permissions']['pmquota'] >= 0.9) {
                                     // Send email about box being almost full
                                     $this->info['pmwarning']["{$user['userid']}"] = true;
                                 }
                                 // okay, send the message!
                                 $recipients["{$lowname}"] = true;
                                 $this->info['tostring']["{$type}"]["{$user['userid']}"] = $user['username'];
                             }
                         }
                     }
                 }
             }
         }
     }
     if (empty($this->errors)) {
         foreach ($recipients as $lowname => $bool) {
             $user =& $users["{$lowname}"];
             $this->info['recipients']["{$user['userid']}"] = $user;
         }
         return true;
     } else {
         return false;
     }
 }
	/**
	* Filters the tag list to exclude invalid tags based on the content item the tags
	* are assigned to.
	*
	*	Calls filter_tag_list internally to handle invalid tags.
	*
	* @param	string|array	List of tags to add (comma delimited, or an array as is).
	*  											If array, ensure there are no commas.
	* @param	array			array of tag limit constraints.  If a limit is not specified a suitable
	*										default will be used (currently unlimited, but a specific default should
	*										not be relied on). Current limits recognized are 'content_limit' which
	*										is the maximum number of tags for a content item and 'user_limit' which
	*										is the maximum number of tags the current user can add to the content item.
	* @param	int				The maximum number of tags the current user can assign to this item (0 is unlimited)
	* @param	boolean		Whether to check the browsing user's create tag perms
	* @param	boolean		Whether to expand the error phrase
	*
	* @return	array			List of valid tags.  If there are too many tags to add, the list will
	*		be truncated first.  An error will be set in this case.
	*/
	public function filter_tag_list_content_limits (
		$taglist,
		$limits,
		&$errors,
		$check_browser_perms = true,
		$evalerrors = true
	)
	{
		$content_tag_limit = isset($limits['content_limit']) ? intval($limits['content_limit']) : 0;
		$user_tag_limit = isset($limits['user_limit']) ? intval($limits['user_limit']) : 0;

		$existing_tag_count = $this->fetch_existing_tag_count();
		if ($content_tag_limit AND $existing_tag_count >= $content_tag_limit)
		{
			$errors['threadmax'] = $evalerrors ? fetch_error('item_has_max_allowed_tags') : 'item_has_max_allowed_tags';
			return array();
		}

		$errors = array();
		$valid_tags = self::filter_tag_list($taglist, $errors, $evalerrors);
		$valid_tags_lower = array_map('vbstrtolower', $valid_tags);

		if ($valid_tags)
		{
			$existing_sql = $this->dbobject->query_read("
				SELECT tag.tagtext, IF(tagcontent.tagid IS NULL, 0, 1) AS tagincontent
				FROM " . TABLE_PREFIX . "tag AS tag
				LEFT JOIN " . TABLE_PREFIX . "tagcontent AS tagcontent ON
					(tag.tagid = tagcontent.tagid AND tagcontent.contenttypeid = " . intval($this->contenttypeid) . " AND
					tagcontent.contentid = " . intval($this->contentid) . ")
				WHERE tag.tagtext IN ('" . implode("','", array_map(array(&$this->dbobject, 'escape_string'), $valid_tags)) . "')
			");

			if ($check_browser_perms AND !$this->registry->check_user_permission('genericpermissions', 'cancreatetag'))
			{
				// can't create tags, need to throw errors about bad ones
				$new_tags = array_flip($valid_tags_lower);

				while ($tag = $this->dbobject->fetch_array($existing_sql))
				{
					unset($new_tags[vbstrtolower($tag['tagtext'])]);
				}

				if ($new_tags)
				{
					// trying to create tags without permissions. Remove and throw an error
					$errors['no_create'] = $evalerrors ? fetch_error('tag_no_create') : 'tag_no_create';

					foreach ($new_tags AS $new_tag => $key)
					{
						// remove those that we can't add from the list
						unset($valid_tags["$key"], $valid_tags_lower["$key"]);
					}
				}
			}

			$this->dbobject->data_seek($existing_sql, 0);

			// determine which tags are already in the thread and just ignore them
			while ($tag = $this->dbobject->fetch_array($existing_sql))
			{
				if ($tag['tagincontent'])
				{
					// tag is in thread, find it and remove
					if (($key = array_search(vbstrtolower($tag['tagtext']), $valid_tags_lower)) !== false)
					{
						unset($valid_tags["$key"], $valid_tags_lower["$key"]);
					}
				}
			}

 			//approximate "unlimited" as PHP_INT_MAX -- makes the min logic cleaner
			$content_tags_remaining = PHP_INT_MAX;
			if ($content_tag_limit)
			{
				$content_tags_remaining = $content_tag_limit - $existing_tag_count - count($valid_tags);

			}

			$user_tags_remaining = PHP_INT_MAX;
			if ($user_tag_limit)
			{
				list($user_tag_count) = $this->dbobject->query_first("
					SELECT COUNT(*) AS count
					FROM " . TABLE_PREFIX . "tagcontent AS tagcontent
					WHERE contenttypeid = " . intval($this->contenttypeid) . "
						AND contentid = " . intval($this->contentid) . "
						AND userid = " . $this->registry->userinfo['userid']
					,
					DBARRAY_NUM
				);
				$user_tags_remaining = $user_tag_limit - $user_tag_count - count($valid_tags);
			}

			$remaining_tags = min($existing_tag_count, $user_tags_remaining);
			if ($remaining_tags < 0)
			{
				$errors['threadmax'] = $evalerrors ?
					fetch_error('number_tags_add_exceeded_x', vb_number_format($remaining_tags * -1)) :
					array('number_tags_add_exceeded_x', vb_number_format($remaining_tags * -1));

				$allowed_tag_count = count($valid_tags) + $remaining_tags;
				if ($allowed_tag_count > 0)
				{
					$valid_tags = array_slice($valid_tags, 0, count($valid_tags) + $remaining_tags);
				}
				else
				{
					$valid_tags = array();
				}
			}
		}
		return $valid_tags;
	}
function fetch_postindex_text($text)
{
	static $find, $replace;
	global $vbulletin;

	// remove all bbcode tags
	$text = strip_bbcode($text);

	// there are no guarantees that any of the words will be delimeted by spaces so lets change that
	$text = implode(' ', split_string($text));

	// make lower case and pad with spaces
	//$text = strtolower(" $text ");
	$text = " $text ";

	if (!is_array($find))
	{
		$find = array(
			'#[()"\'!\#{};<>]|\\\\|:(?!//)#s',			// allow through +- for boolean operators and strip colons that are not part of URLs
			'#([.,?&/_]+)( |\.|\r|\n|\t)#s',			// \?\&\,
			'#\s+(-+|\++)+([^\s]+)#si',					// remove leading +/- characters
			'#(\s?\w*\*\w*)#s',							// remove words containing asterisks
			'#[ \r\n\t]+#s',							// whitespace to space
		);
		$replace = array(
			'',		// allow through +- for boolean operators and strip colons that are not part of URLs
			' ',	// \?\&\,
			' \2',	// remove leading +/- characters
			'',		// remove words containing asterisks
			' ',	// whitespace to space
		);
	}

	$text = strip_tags($text); // clean out HTML as it's probably not going to be indexed well anyway

	// use regular expressions above
	$text = preg_replace($find, $replace, $text);

	return trim(vbstrtolower($text));
}
Beispiel #9
0
function fetch_postindex_text($text)
{
    static $find, $replace;
    global $vbulletin;
    // remove all bbcode tags
    $text = strip_bbcode($text);
    // there are no guarantees that any of the words will be delimeted by spaces so lets change that
    $text = implode(' ', split_string($text));
    // make lower case and pad with spaces
    //$text = strtolower(" $text ");
    $text = " {$text} ";
    if (!is_array($find)) {
        $find = array('#[()"\'!\\#{};<>]|\\\\|:(?!//)#s', '#([.,?&/_]+)( |\\.|\\r|\\n|\\t)#s', '#\\s+(-+|\\++)+([^\\s]+)#si', '#(\\s?\\w*\\*\\w*)#s', '#[ \\r\\n\\t]+#s');
        $replace = array('', ' ', ' \\2', '', ' ');
    }
    $text = strip_tags($text);
    // clean out HTML as it's probably not going to be indexed well anyway
    // use regular expressions above
    $text = preg_replace($find, $replace, $text);
    return trim(vbstrtolower($text));
}
Beispiel #10
0
		if (!empty($clean_lists['ignore_original']))
		{
			$remove['ignore'] = array_merge($remove['ignore'], array_diff($clean_lists['ignore_original'], (is_array($clean_lists['ignore']) ? $clean_lists['ignore'] : array())));
		}

		if (!empty($vbulletin->GPC['username']))
		{
			if ($vbulletin->GPC['ajax'])
			{
				$vbulletin->GPC['username'] = convert_urlencoded_unicode($vbulletin->GPC['username']);
			}

			if ($userinfo = $db->query_first("
				SELECT userid, username, usergroupid, membergroupids
				FROM " . TABLE_PREFIX . "user AS user
				WHERE username = '******'username'])) . "'
			"))
			{
				$uglist = $userinfo['usergroupid'] . iif(trim($userinfo['membergroupids']), ",$userinfo[membergroupids]");
				if (!$vbulletin->options['ignoremods'] AND can_moderate(0, '', $userinfo['userid'], $uglist) AND !($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
				{
					eval(standard_error(fetch_error('listignoreuser', $userinfo['username'])));
				}
				else if ($vbulletin->userinfo['userid'] == $userinfo['userid'])
				{
					eval(standard_error(fetch_error('cantlistself_ignore')));
				}
				$add['ignore']["$userinfo[userid]"] = $userinfo;
			}
			else
			{
Beispiel #11
0
 /**
  * Removes a tag from the issue.
  *
  * @param	string	Tag
  */
 function remove_tag($tag)
 {
     $tag = $this->registry->input->clean($tag, TYPE_NOHTMLCOND);
     $tag_lower = vbstrtolower($tag);
     $this->tag_remove["{$tag_lower}"] = $tag;
     if (isset($this->tag_add["{$tag_lower}"])) {
         // can't add and remove a tag
         unset($this->tag_add["{$tag_lower}"]);
     }
 }
Beispiel #12
0
function BuildExclusionList($thread, $submittedTags)
{
    global $vbulletin;
    $excludedWords = array();
    // Exclude tags already submitted
    if (strlen($thread['taglist']) > 0) {
        $excludedWords = array_merge($submittedTags, $excludedWords);
    }
    // Add configuration specified exclusions
    if (strlen(trim($vbulletin->options['autotag_excluded_words'])) > 0) {
        $configExclusions = split(',', strtolower($vbulletin->options['autotag_excluded_words']));
        $excludedWords = array_merge($excludedWords, $configExclusions);
    }
    if ($vbulletin->options['autotag_exclude_tagbadwords']) {
        if (strlen(trim($vbulletin->options['tagbadwords'])) > 0) {
            $configExclusions = preg_split('/\\s+/s', vbstrtolower($vbulletin->options['tagbadwords']), -1, PREG_SPLIT_NO_EMPTY);
            $excludedWords = array_merge($excludedWords, $configExclusions);
        }
    }
    unset($configExclusions);
    // Trim current exclusions
    for ($x = 0; $x < count($excludedWords); $x++) {
        $excludedWords[$x] = trim($excludedWords[$x]);
    }
    // Exclude search words if configuration allows
    if ($vbulletin->options['autotag_exclude_searchwords']) {
        require DIR . '/includes/searchwords.php';
        $excludedWords = array_merge($excludedWords, $badwords);
    }
    return $excludedWords;
}
Beispiel #13
0
function tagdomerge()
{
    global $vbulletin, $vbphrase, $stop_file, $stop_args;
    $taglist = tagcp_fetch_tag_list();
    if (!sizeof($taglist)) {
        print_cp_header($vbphrase['tag_manager']);
        print_stop_message2('no_tags_selected', $stop_file, $stop_args);
    }
    $vbulletin->input->clean_array_gpc('p', array('tagtext' => vB_Cleaner::TYPE_NOHTML));
    $tagtext = $vbulletin->GPC['tagtext'];
    $name_changed = false;
    $tagExists = vB_Api::instance('Tags')->fetchTagByText($tagtext);
    if (!$tagExists['tag']) {
        //Create tag
        $response = vB_Api::instance('Tags')->insertTags($tagtext);
        if ($response['errors']) {
            print_cp_header($vbphrase['tag_manager']);
            print_stop_message2($response['errors'][0]);
        }
    } else {
        //if the old tag and new differ only by case, then update
        if ($tagtext != $tagExists['tag']['tagtext'] and vbstrtolower($tagtext) == $tagExists['tag']['tagtext']) {
            $name_changed = true;
            $update = vB_Api::instance('Tags')->updateTags($tagtext);
        }
    }
    $tagExists = vB_Api::instance('Tags')->fetchTagByText($tagtext);
    if (!$tagExists['tag']) {
        print_cp_header($vbphrase['tag_manager']);
        print_stop_message2('no_changes_made', $stop_file, $stop_args);
    } else {
        $targetid = $tagExists['tag']['tagid'];
    }
    // check if source and targed are the same
    if (sizeof($taglist) == 1 and in_array($targetid, $taglist)) {
        if ($name_changed) {
            print_cp_header($vbphrase['tag_manager']);
            print_stop_message2('tags_edited_successfully', $stop_file, $stop_args);
        } else {
            print_cp_header($vbphrase['tag_manager']);
            print_stop_message2('no_changes_made', $stop_file, $stop_args);
        }
    }
    if (false !== ($selected = array_search($targetid, $taglist))) {
        // ensure targetid is not in taglist
        unset($taglist[$selected]);
    }
    $synonym = vB_Api::instance('Tags')->createSynonyms($taglist, $targetid);
    if ($synonym['errors']) {
        print_stop_message2($synonym['errors'][0]);
    }
    // need to invalidate the search and tag cloud caches
    build_datastore('tagcloud', '', 1);
    build_datastore('searchcloud', '', 1);
    setcookie('vbulletin_inlinetag', '', TIMENOW - 3600, '/');
    print_cp_header($vbphrase['tag_manager']);
    print_stop_message2('tags_edited_successfully', $stop_file, $stop_args);
}