Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 297
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 285
Total: 285

Author Topic: Multiple code for a single smiley  (Read 3785 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Multiple code for a single smiley
« on: March 15, 2016, 09:42:06 pm »
I'd like to use multiple codes to represent a single smiley.

For example, (see image)



I know the function that handles it in 1.x is:

Code: [Select]
// Parse smileys in the passed message.
function parsesmileys(&$message)
{
global $modSettings, $db_prefix, $txt, $user_info, $context;
static $smileyfromcache = array(), $smileytocache = array();

// No smiley set at all?!
if ($user_info['smiley_set'] == 'none')
return;

// If the smiley array hasn't been set, do it now.
if (empty($smileyfromcache))
{
// Use the default smileys if it is disabled. (better for "portability" of smileys.)
if (empty($modSettings['smiley_enable']))
{
$smileysfrom = array('>:D', ':D', '::)', '>:(', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
$smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
$smileysdescs = array('', $txt[289], $txt[450], $txt[288], $txt[287], $txt[292], $txt[293], $txt[291], $txt[294], $txt[295], $txt[451], $txt[296], $txt[526], $txt[527], $txt[529], $txt[530], $txt[528], '', '', '', '');
}
else
{
// Load the smileys in reverse order by length so they don't get parsed wrong.
if (($temp = cache_get_data('parsing_smileys', 480)) == null)
{
$result = db_query("
SELECT code, filename, description
FROM {$db_prefix}smileys", __FILE__, __LINE__);
$smileysfrom = array();
$smileysto = array();
$smileysdescs = array();
while ($row = mysql_fetch_assoc($result))
{
$smileysfrom[] = $row['code'];
$smileysto[] = $row['filename'];
$smileysdescs[] = $row['description'];
}
mysql_free_result($result);

cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
}
else
list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
}

// The non-breaking-space is a complex thing...
$non_breaking_space = $context['utf8'] ? ($context['server']['complex_preg_chars'] ? '\x{A0}' : pack('C*', 0xC2, 0xA0)) : '\xA0';

// This smiley regex makes sure it doesn't parse smileys within code tags (so [url=mailto:David@bla.com] doesn't parse the :D smiley)
for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
{

$smileyfromcache[] = '/(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . preg_quote($smileysfrom[$i], '/') . '|' . preg_quote(htmlspecialchars($smileysfrom[$i], ENT_QUOTES), '/') . ')(?=[^[:alpha:]0-9]|$)/i' . ($context['utf8'] ? 'u' : '');
// Escape a bunch of smiley-related characters in the description so it doesn't get a double dose :P.
$smileytocache[] = '<img src="' . htmlspecialchars($modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i]) . '" alt="' . strtr(htmlspecialchars($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" border="0" style="vertical-align: top;" />';
}
}

// Replace away!
// !!! There must be a way to speed this up.
$message = preg_replace($smileyfromcache, $smileytocache, $message);
}

How can I pull this off?
« Last Edit: March 15, 2016, 09:43:51 pm by shuban »

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Multiple code for a single smiley
« Reply #1 on: March 16, 2016, 12:10:25 pm »
Weird, I uploaded something and it's not showing as a thumbnail.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Multiple code for a single smiley
« Reply #2 on: March 16, 2016, 12:15:50 pm »
Currently only members in the customers groups can see attachments.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Multiple code for a single smiley
« Reply #3 on: March 16, 2016, 12:33:04 pm »
Currently only members in the customers groups can see attachments.

You should create an exception for this board :P

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
8293 Views
Last post October 12, 2006, 12:20:12 pm
by xface
6 Replies
8002 Views
Last post December 13, 2006, 11:48:07 am
by Burninglotus
2 Replies
4552 Views
Last post September 16, 2010, 05:28:34 pm
by endomorph
2 Replies
4791 Views
Last post December 04, 2013, 11:56:23 am
by CWVRV
0 Replies
3888 Views
Last post March 13, 2016, 10:11:34 pm
by SMFHacks

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal