Dhillon Posted June 29, 2018 Share Posted June 29, 2018 I need help converting this function. This is the function- function &fetch_full_ameinfo($findonly = false, $refresh = false) { global $db, $vbulletin, $vbphrase, $stylevar; static $ameinfo = array(); static $inied, $lastfind; if ($refresh) { $inied = false; } if ($lastfind && !$findonly) { $inied = false; $ameinfo = array(); } if (!$inied) { if (!$refresh AND $vbulletin->options['automediaembed_cache']) { $path = $vbulletin->options['automediaembed_cache_path']; if (file_exists($path . "findonly.php")); { if ($findonly) { include($path . "findonly.php"); } else { include($path . "ameinfo.php"); } $inied = true; $lastfind = $findonly; return $ameinfo; } } if ($vbulletin->options['automediaembed_resolve']) { $embed = ",IF(extraction=1 AND embedregexp!= '', embedregexp, '') as embedregexp, IF(extraction=1 AND validation!= '', validation, '') as validation"; $embedwhere = " AND ((extraction = 0 AND embedregexp = '') OR (extraction = 1)) "; } else { $embedwhere = " AND embedregexp = ''"; } $sql = "SELECT findcode" . (!$findonly ? ", replacecode,title,container,ameid" : ",extraction$embed") . " FROM " . TABLE_PREFIX . "automediaembed WHERE status=1 $embedwhere ORDER BY displayorder, title ASC"; $results = $db->query_read_slave($sql); while ($result = $db->fetch_array($results)) { if ($result['findcode']) { if (!$findonly) { $ameinfo['find'][] = "~($result[findcode])~ie"; $ameinfo['replace'][] = 'ame_match_bbcode($param1, $param2, \'' . $result['ameid'] . '\', \'' . ame_slasher($result['title']) . '\', ' . $result['container'] . ', \'' . ame_slasher($result['replacecode']) . '\', \'\\1\', \'\\2\', \'\\3\', \'\\4\', \'\\5\', \'\\6\')'; } else { $ameinfo['find'][] = "~(\[url\]$result[findcode]\[/url\])~ie"; $ameinfo['find'][] = "~(\[url=\"?$result[findcode]\"?\](.*?)\[/url\])~ie"; $ameinfo['replace'][] = 'ame_match("\1", "", ' . intval($result['extraction']) .', "' . ($result['embedregexp'] ? "~" . ame_slasher($result['embedregexp']) . "~sim" : "") . '", "' . ($result['validation'] ? "~" . ame_slasher($result['validation']) . "~sim" : "") . '",$ameinfo)'; $ameinfo['replace'][] = 'ame_match("\1", "\2", ' . intval($result['extraction']) .', "' . ($result['embedregexp'] ? "~" . ame_slasher($result['embedregexp']) . "~sim" : "") . '", "' . ($result['validation'] ? "~" . ame_slasher($result['validation']) . "~sim" : "") . '", $ameinfo)'; } } } $inied = true; } $lastfind = $findonly; return $ameinfo; } Called here- function ame_process_bbcode(&$parser, &$param1, $param2 = '') { if (class_exists('vB_BbCodeParser_Wysiwyg') AND is_a($parser, 'vB_BbCodeParser_Wysiwyg')) { return $text; } else { global $vbulletin; ($hook = vBulletinHook::fetch_hook('automediaembed_parse_bbcode_start')) ? eval($hook) : false; $ameinfo = fetch_full_ameinfo(); $text = preg_replace($ameinfo['find'], $ameinfo['replace'], ($param2 ? $param2 : $param1), 1); ($hook = vBulletinHook::fetch_hook('automediaembed_parse_bbcode_end')) ? eval($hook) : false; return $text; } } full script: https://codeshare.io/5Dnk6Z Quote Link to comment Share on other sites More sharing options...
requinix Posted June 29, 2018 Share Posted June 29, 2018 What have you tried so far and how has it not worked? Quote Link to comment Share on other sites More sharing options...
Dhillon Posted June 29, 2018 Author Share Posted June 29, 2018 I tried the solution provided here but didn't work: https://stackoverflow.com/questions/44855629/the-e-modifier-is-deprecated-use-preg-replace-callback-instead-of-preg-replace This is what the script is: https://www.vbulletin.org/forum/showthread.php?t=202476 As you can tell I am not a coder, So any pointers will be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted June 29, 2018 Share Posted June 29, 2018 Converting it to what? What do you want it to do? What is it not doing? Quote Link to comment Share on other sites More sharing options...
Dhillon Posted June 29, 2018 Author Share Posted June 29, 2018 ^The code is throwing deprecated message on php 5.6 and not working at all on php 7. Quote Link to comment Share on other sites More sharing options...
Barand Posted June 29, 2018 Share Posted June 29, 2018 Have you tried Googling the error message? Quote Link to comment Share on other sites More sharing options...
requinix Posted June 30, 2018 Share Posted June 30, 2018 According to that StackOverflow thread, you have been told what to do. So what's the problem you're having with it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.