Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
help to rewrite a function
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2021-06-12 07:36:14
Hello,
I can't rewrite my function which is deprecated

$s = preg_replace("/\[youtube\]([^\s'\"<>]+?)\[\/youtube\]/ie", 'handleyoutube("$1")', $s);

I know that I have to replace with
"preg_replace_callback"

but afterwards I don't know

Thank you
2021-06-12 10:54:20
Hi SLy, this is my part of that and that works on my server right now:


//[youtube=https://www.youtube.com]
$s = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", "<iframe width=\"720\" height=\"480\" class=\"poster2\" src=\"//www.youtube.com/embed/$2\" allowfullscreen></iframe>", $s);

really hope that help to you


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
Last edited by Botanicar on 2021-06-12 11:01:03
2021-06-12 11:08:53
thank you
but,does not work
Last edited by SLy on 2021-06-13 04:48:53
2021-06-12 13:47:50
does this help any? I just pulled this from some code I have
$s = preg_replace("/\[youtube\]\bhttps?:\/\/www\.youtube\.com\/watch\?v=([\w\d-]+?)\[\/youtube\]/i", $s);

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2021-06-12 13:48:25
2021-06-12 16:42:15
here is my code in full:

#### shout ####
function handleyoutube($com){
if (!empty($com)){
$link = $com;
$link = str_replace('https://www.youtube.com/watch?v=','',$link);
$yt_code = $link;

$yt_code = '<a href="trailer.php?yt_code='.$yt_code.'" onclick="return hs.htmlExpand(this, { objectType: \'iframe\', width: 620, height: 420, align: \'center\', dimmingOpacity: 0.8 } )"><img src="js/shout/images/play_yout.gif" alt="Regarder dans un Popup" /> '.T_("YOUTUBE_A_NEW_VIDEO_HAS_ADDED").'</a>';
}else{$yt_code = "";}

return $yt_code;
}
#########End


$s = preg_replace("/\[youtube\]([^\s'\"<>]+?)\[\/youtube\]/ie", 'handleyoutube("$1")', $s);


Error:

Deprecated:  preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
2021-06-12 17:38:04
None of this is correct. Let me in on this in an hour when I am at the keyboard.  :thumb
2021-06-12 17:39:41
you could try remove the e

$s = preg_replace("/\[youtube\]([^\s'\"<>]+?)\[\/youtube\]/i", 'handleyoutube("$1")', $s);


or

$s = preg_replace("/\[youtube\]([^\s'\"<>]+?)\[\/youtube\]/Usi", 'handleyoutube("$1")', $s);
2021-06-12 17:42:30
Even so, I have a friend who is university educated on regex and patterns, and can have regex doing anything you want.

For example, I have regex (preg_match_all) searching inside image files for injected PHP code (malicious exploits), and it works perfectly after about 7 different trials on a specific expression and parser trick, with 4 different PNG exploits.

Regex is powerful.
2021-06-12 21:57:44
$s = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtu.be\/([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", "<a href=\"trailer.php?yt_code=$1\" onclick=\"return hs.htmlExpand(this, { objectType: \'iframe\', width: 620, height: 420, align: \'center\', dimmingOpacity: 0.8 } )\"><img src=\"js/shout/images/play_yout.gif\" alt=\"Regarder dans un Popup\" />YOUTUBE_A_NEW_VIDEO_HAS_ADDED</a>", $row['youtube']);
2021-06-13 06:57:58
Hello,
I'm sorry, no code is working for me
2021-06-13 18:39:57
Where is description coming in from? Check $row[‘descr’]
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728