|
28 | 28 | * Factory of pictures created |
29 | 29 | */ |
30 | 30 | $videoFactory = new Suico\VideoHandler($xoopsDB); |
31 | | -$url = Request::getUrl('codigo', '', 'POST'); |
| 31 | +$url = Request::getUrl('videourl', '', 'POST'); |
32 | 32 | if (!$GLOBALS['xoopsSecurity']->check()) { |
33 | 33 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_SUICO_TOKENEXPIRED); |
34 | 34 | } |
|
41 | 41 | $newvideo->setVar('uid_owner', (int)$xoopsUser->getVar('uid')); |
42 | 42 | $newvideo->setVar('video_title', Request::getString('title', '', 'POST')); |
43 | 43 | $newvideo->setVar('video_desc', Request::getString('caption', '', 'POST')); |
44 | | -if (11 === mb_strlen($url)) { |
45 | | - $code = $url; |
46 | | -} else { |
47 | | - $position_of_code = mb_strpos($url, 'v='); |
48 | | - $code = mb_substr($url, $position_of_code + 2, 11); |
49 | | -} |
| 44 | + |
| 45 | +//Get youtube video id |
| 46 | +preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match); |
| 47 | +$code = $match[1]; |
| 48 | + |
50 | 49 | $newvideo->setVar('youtube_code', $code); |
51 | 50 | $newvideo->setVar('featured_video', Request::getInt('featured_video', 0, 'POST')); |
52 | 51 | $newvideo->setVar('date_created', \time()); |
|
0 commit comments