FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » FUDforum Suggestions » Maximum smileys
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Maximum smileys [message #13865] Wed, 29 October 2003 16:20 Go to next message
AzaToth is currently offline  AzaToth   Sweden
Messages: 125
Registered: October 2003
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user

Perhaps an impossible suggestion but:

A setting to limit number of smileys per post in relation to the size of the rest of the content; for example: 3 smileys for none extra content and one smiley per 100 char content.
Re: Maximum smileys [message #13867 is a reply to message #13865] Wed, 29 October 2003 16:35 Go to previous messageGo to next message
JamesPicard_007 is currently offline  JamesPicard_007   United States
Messages: 5
Registered: October 2003
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
I think just being able to set how many smilies can be used in a post would be fine. Because I'd like to have this feature as well.
Re: Maximum smileys [message #13868 is a reply to message #13867] Wed, 29 October 2003 16:45 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
I am not really sure it is worth the effort, if you don't want smilies you can turn them off. If 1-2 users abuse the feature you can use permission system to take away that ability from just those users.

Counting smileys is incredibly expensive, it would require traversal of the entire message for every smiley in the following manner:
<?php
$smiley_count
= 0;

foreach (
$smiley as $v) {
      
$p = 0;
      while ((
$p = strpos($msg, $v, $p)) !== false) {
            ++
$p;
            ++
$smiley_count;
      }
}
?>


I just can't justify this sort of performance inhibitor.


FUDforum Core Developer
Re: Maximum smileys [message #13870 is a reply to message #13865] Wed, 29 October 2003 17:02 Go to previous messageGo to next message
AzaToth is currently offline  AzaToth   Sweden
Messages: 125
Registered: October 2003
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user

ok, but perhaps just render 3 smileys and skip render the rest like:
Embarassed Embarassed Embarassed :blush:

so the users realise that a lot of smileys is not necicary Smile

And I'm thinking, why traverse?
why not:
<?php
$smileys = preg_match_all("#:(.*?):#is", $msg);
if($smileys > (3 + (strlen($msg)-$smileys)/$smileys)) {
print "Too many smileys, try again";
}
?>

[Updated on: Wed, 29 October 2003 17:04]

Report message to a moderator

Re: Maximum smileys [message #13872 is a reply to message #13870] Wed, 29 October 2003 17:37 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
AzaToth wrote on Wed, 29 October 2003 17:02

ok, but perhaps just render 3 smileys and skip render the rest like:
Embarassed Embarassed Embarassed :blush:

so the users realise that a lot of smileys is not necicary Smile

And I'm thinking, why traverse?
why not:
<?php
$smileys = preg_match_all("#:(.*?):#is", $msg);
if($smileys > (3 + (strlen($msg)-$smileys)/$smileys)) {
print "Too many smileys, try again";
}
?>



Because preg_match_all() while shorter is actually much much slower. Smileys are rendered by a single strtr() function there is no way to render only 'some' smileys.


FUDforum Core Developer
Re: Maximum smileys [message #13874 is a reply to message #13872] Wed, 29 October 2003 17:42 Go to previous messageGo to next message
AzaToth is currently offline  AzaToth   Sweden
Messages: 125
Registered: October 2003
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user

Ilia wrote on Wed, 29 October 2003 23:37


Because preg_match_all() while shorter is actually much much slower. Smileys are rendered by a single strtr() function there is no way to render only 'some' smileys.

hmm, slower you said, how can it be slower than your example, I just count the number of :smileys: in the text, and then a simple calculation, I'm not doing any traversion in the manner you make.
Re: Maximum smileys [message #13875 is a reply to message #13874] Wed, 29 October 2003 17:46 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
How do you suppose regular expression works? Magically picking out the data you want from text @ instant speed? IT too does plenty of crawling character by character infact following complex rules. strpos() will almost always be faster.

Either way, both ways would be too slow.


FUDforum Core Developer
Re: Maximum smileys [message #13876 is a reply to message #13875] Wed, 29 October 2003 17:49 Go to previous messageGo to next message
AzaToth is currently offline  AzaToth   Sweden
Messages: 125
Registered: October 2003
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user

Ilia wrote on Wed, 29 October 2003 23:46

How do you suppose regular expression works? Magically picking out the data you want from text @ instant speed? IT too does plenty of crawling character by character infact following complex rules. strpos() will almost always be faster.

Either way, both ways would be too slow.

Off course I know Smile, I ment I didn't check for particular smileys, I just checked if there was something like a smiley. and what is the problem if it's a optional feature? and it's only runned when a message is sent.
Re: Maximum smileys [message #13877 is a reply to message #13876] Wed, 29 October 2003 18:01 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Wrong, it has to be done before the message is sent and if >allowed smilies are found prevent form submission.

There are other technical issues here:

1) You suggested making the limit based on number of characters, so what's to say, prevent me from putting 100 spaces to be able to put 10 smilies etc...
Seems like a half hearted attempted, since it is so easy to bypass.

The alternative then is to set a hard limit on the number of smilies that a person may use inside a message. Now we go back to my original argument, why not simply TELL people that they should not use more then X smilies and remove ability to use smilies who blantantly violate this rule?

It'll be a much cleaner solution, and if once in a blue moon you need to go over the limit, you can...


FUDforum Core Developer
Re: Maximum smileys [message #13878 is a reply to message #13877] Wed, 29 October 2003 18:11 Go to previous message
AzaToth is currently offline  AzaToth   Sweden
Messages: 125
Registered: October 2003
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user

Ok, was just a thought Smile
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Disable Tree View
Next Topic: default theme css split
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Dec 11 14:20:00 EST 2017

Total time taken to generate the page: 0.00814 seconds