2015-03-02, 06:24 PM
Can anybody help me I have this plugin and I am trying to make it so that.
Show error when no tags are entered.
Show error is the tag is less than 3 characters long.
Spend time but can't figure how to.
http://mods.mybb.com/view/tag-system
Show error when no tags are entered.
Show error is the tag is less than 3 characters long.
Spend time but can't figure how to.
function systemtags_insert_tags_thread(&$thread)
{
global $mybb, $db;
if($mybb->input['tags'])
{
$stags = strip_tags($mybb->input['tags']);
$tagsht = htmlspecialchars_uni($stags);
$searchcodes = explode(",", $mybb->input['systemtag_disablecodes']);
$rtags = str_replace($searchcodes, " ", $tagsht);
$rtagsp_br = preg_replace("/\r\n|\r/", " ", $rtags);
$tags = trim($rtagsp_br);
$explode = explode(",", $tags);
$array = array();
foreach($explode as $tag)
{
if(strlen($tag) >= 4)
{
$array[] = $tag;
}
}
$insert = implode(", ",$array);
$insert = $db->escape_string($insert);
$inserttags = array(
"tid" => $thread->tid,
"tags" => $insert
);
$aid = $db->insert_id();
$db->insert_query("tags", $inserttags);
}
else
{
$stags = strip_tags($thread->data['subject']);
$tagsht = htmlspecialchars_uni($stags);
$codes = $mybb->settings['systemtag_disablecodes'];
$searchcodes = explode(" ",$codes);
$rtags = str_replace($searchcodes, " ", $tagsht);
$rtagsp_br = preg_replace("/\r\n|\r/", " ", $rtags);
$tags = trim($rtagsp_br);
$explode = explode(" ", $tags);
$tags = array();
$countags = 0;
foreach($explode as $strlen)
{
if(strlen($strlen) >= 4)
{
$tags[] = $strlen;
++$countags;
}
}
if($countags < 5)
{
$ptags = strip_tags($thread->data['message']);
$tagshtp = htmlspecialchars_uni($ptags);
$codes = $mybb->settings['systemtag_disablecodes'];
$searchcodes = explode(" ",$codes);
$rtagsp = str_replace($searchcodes, " ", $tagshtp);
$rtagsp_br = preg_replace("/\r\n|\r/", " ", $rtagsp);
$tagsmesaage = trim($rtagsp_br);
$explodemessage = explode(" ", $tagsmesaage);
$tagspost = array();
$countagspost = 0;
foreach($explodemessage as $strlenpost)
{
if(strlen($strlenpost) >= 5)
{
$tagspost[] = $strlenpost;
++$countagspost;
}
}
$newcount = 6 - $countags;
$newcount = intval($newcount);
if($newcount > $countagspost)
{
return false;
}
$randomarr = array_rand($tagspost, $newcount);
$countfor = $newcount - 1;
$newtags = array();
for ($i = 0; ; $i++)
{
if ($i > $countfor)
{
break;
}
$newtags[] = $tagspost[$randomarr[$i]];
}
}
$newarrays = array_merge($tags,$newtags);
$implod = implode(", ",$newarrays);
$insert = $db->escape_string($implod);
$inserttags = array(
"tid" => $thread->tid,
"tags" => $insert
);
$aid = $db->insert_id();
$db->insert_query("tags", $inserttags);
}
}
function systemtags_validate_tags(&$thread)
{
global $mybb,$posthandler, $lang;
$lang->load("tags");
if($mybb->input['tags'])
{
$stags = strip_tags($mybb->input['tags']);
$tagsht = htmlspecialchars_uni($stags);
$searchcodes = explode(",", $mybb->settings['systemtag_disablecodes']);
$rtags = str_replace($searchcodes, " ", $tagsht);
$tags = trim($rtags);
$explode = explode(",", $tags);
$tagnum = 0;
foreach($explode as $tag)
{
if(strlen($tag) >= 4)
{
++$tagnum;
}
else
{
$posthandler->set_error($lang->tagsfivecaracters);
return false;
}
}
if($tagnum < 5)
{
$posthandler->set_error($lang->menosfivetags);
return false;
}
}
else
{
if($thread->data['subject'] && $thread->data['message'])
{
$stags = strip_tags($thread->data['subject']);
$tagsht = htmlspecialchars_uni($stags);
$codes = $mybb->settings['systemtag_disablecodes'];
$searchcodes = explode(" ",$codes);
$rtags = str_replace($searchcodes, " ", $tagsht);
$rtagsp_br = preg_replace("/\r\n|\r/", " ", $rtags);
$tags = trim($rtagsp_br);
$explode = explode(" ", $tags);
$tags = array();
$countags = 0;
foreach($explode as $strlen)
{
if(strlen($strlen) >= 4)
{
$tags[] = $strlen;
++$countags;
}
}
if($countags < 5)
{
//count(split("[ ]+", $thread->data['message']))
$ptags = strip_tags($thread->data['message']);
$tagshtp = htmlspecialchars_uni($ptags);
$codes = "{ } [ ] ( ) \" ' < > : ; . , - _ + ! ? = $ % & ¡ ¿ /";
$searchcodes = explode(" ",$codes);
$rtagsp = str_replace($searchcodes, " ", $tagshtp);
$rtagsp_br = preg_replace("/\r\n|\r/", " ", $rtagsp);
$tagsmesaage = trim($rtagsp_br);
$explodemessage = explode(" ", $tagsmesaage);
$tagspost = array();
$countagspost = 0;
foreach($explodemessage as $strlenpost)
{
if(strlen($strlenpost) >= 5)
{
$tagspost[] = $strlenpost;
++$countagspost;
}
}
$newcount = 6 - $countags;
$newcount = intval($newcount);
if($newcount > $countagspost)
{
$posthandler->set_error($lang->errortaggenerateone);
return false;
}
$randomarr = array_rand($tagspost, $newcount);
$countfor = $newcount - 1;
$newtags = array();
for ($i = 0; ; $i++)
{
if ($i > $countfor)
{
break;
}
$newtags[] = $tagspost[$randomarr[$i]];
}
$newarrays = array_merge($tags,$newtags);
$tagnum = 0;
foreach($newarrays as $countnewtags)
{
++$tagnum;
}
if($tagnum < 5)
{
$posthandler->set_error($lang->errorgeneratetagtwo);
return false;
}
}
}
}
}
http://mods.mybb.com/view/tag-system