function ReplaceYoutube($content) { if (is_feed()) { return $content; } // Replace Youtube $pattern1 = '@(?:<p>)*\\s*\\[youtube=\\((.*?)\\)(.*?)\\]\\s*(?:</p>)*@i'; $pattern2 = '@(?:<p>)*\\s*\\<a(.*?)href=[\'|"]http:\\/\\/youtube.com/watch\\?v=(.*?)[\'|"](.*?)\\</a\\>\\s*(?:</p>)*@i'; $pattern3 = '@(?:<p>)*\\s*\\<object([^>]*)>([^>]*)\\<param([^>]*)value=[\'|"]http:\\/\\/www.youtube.com\\/v\\/(.*?)[\'|"]\\>\\<\\/param>([^>]*)\\<param(.*?)\\<\\/object>\\s*(?:</p>)*@is'; $pat_title = '/(.*?)title=[\'|"](.*?)[\'|"]/i'; // $pattern3 = '/\<object([^>]*)>([^>]*)\<param([^>]*)value=[\'|"]http:\/\/www.youtube.com\/v\/(.*?)[\'|"]>\<\/param>([^>]*)\<param([^>]*)>([^>]*)\<\/param>([^>]*)\<embed([^>]*)>([^>]*)\<\/embed>([^>]*)\</object>/is'; if (pt_stripos($content, 'http://youtube.com/watch?v=') !== false) { if (preg_match_all($pattern2, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { if (preg_match($pat_title, $match[0], $mat_title)) { $title = $mat_title[2]; } else { $title = ''; } $thumb = 'http://img.youtube.com/vi/' . $match[2] . '/0.jpg" width="' . get_pt_options('youtube_width') . '" height="' . get_pt_options('youtube_height'); $replacement = SetYoutubeVideo($match[2], $title, $thumb, get_pt_options_all()); $content = str_replace($match[0], $replacement, $content); } } } if (pt_stripos($content, 'http://www.youtube.com/v/') !== false) { if (preg_match_all($pattern3, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { str_replace('<p>' . $match[0] . '</p>', $match[0], $content); if (preg_match($pat_title, $match[0], $mat_title)) { $title = $mat_title[2]; } else { $title = ''; } $ytbID = explode('&', $match[4]); $thumb = 'http://img.youtube.com/vi/' . $ytbID[0] . '/0.jpg" width="' . get_pt_options('youtube_width') . '" height="' . get_pt_options('youtube_height'); $replacement = SetYoutubeVideo($ytbID[0], '', $thumb, get_pt_options_all()); $content = str_replace($match[0], $replacement, $content); } } } if (pt_stripos($content, '[youtube=') !== false) { if (preg_match_all($pattern1, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { str_replace('<p>' . $match[0] . '</p>', $match[0], $content); $thumb = 'http://img.youtube.com/vi/' . $match[1] . '/0.jpg" width="' . get_pt_options('youtube_width') . '" height="' . get_pt_options('youtube_height'); if (preg_match($pat_title, $match[0], $mat_title)) { $title = $mat_title[2]; } else { $title = ''; } $replacement = SetYoutubeVideo($match[1], $title, $thumb, get_pt_options_all()); $content = str_replace($match[0], $replacement, $content); } } } return $content; }
function RecentImages_sub($ListImages, $slice, $offset, $i, $limit) { global $PTRevisited, $PTRLibrary; $attrList = array("src"); // Create a query object to retrieve posts $posts = get_posts('numberposts=' . $slice . '&offset=' . $offset); if (count($posts) < $slice) { $ListImages['endDB'] = true; } foreach ($posts as $post) { if ($i > $limit) { break; } setup_postdata($post); $content = apply_filters('the_content', get_the_content()); // Parse images $pattern = '/<img([^>]*)\\/>/si'; if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // Skip wp smileys if (pt_stripos($match[0], 'class="wp-smiley"')) { continue; } if (pt_stripos($match[0], "class='wp-smiley'")) { continue; } if ($i > $limit) { break; } if (!$PTRLibrary->p_rel) { if (pt_stripos($match[0], 'rel="thumb"') === false && pt_stripos($match[0], "rel='thumb'") === false) { continue; } } else { if (pt_stripos($match[0], 'rel="nothumb"') !== false || pt_stripos($match[0], "rel='nothumb'") !== false) { continue; } } $m = str_replace(array("%", "|", "@", ")", "("), array("\\%", "\\|", "\\@", "\\)", "\\("), $match[0]); $pat = '%<a([^>]*).(jpg|jpeg|png|gif)([^>]*)\\>([^>]*)' . $m . '([^>]*)\\<\\/a>%si'; if (preg_match($pat, $content, $macgee)) { $ListAttr = pt_parseAtributes($macgee[0], array('href', 'title')); $ListImages['pic'][] = array($ListAttr['href'], $ListAttr['title']); $i++; unset($macgee); } else { $ListAttr = pt_parseAtributes($match[1], array('src', 'alt')); $ListImages['pic'][] = array($ListAttr['src'], $ListAttr['alt']); $i++; } } } } return $ListImages; }
function pt_is_flv($file) { return pt_stripos($file, '.flv') !== false; }
function check_stream() { $the_image = ''; // Tag for Youtube if (pt_stripos($this->post->post_content, 'http://youtube.com/watch') !== false || pt_stripos($this->post->post_content, 'http://www.youtube.com/v/') !== false || pt_stripos($this->post->post_content, '[youtube') !== false) { $the_image = PT_URLPATH . 'images/youtube.png'; } elseif (pt_stripos($this->post->post_content, 'http://www.dailymotion.com/swf') !== false || pt_stripos($this->post->post_content, 'http://www.dailymotion.com/video') !== false || pt_stripos($this->post->post_content, '[dailymotion') !== false) { $the_image = PT_URLPATH . '/images/dailymotion.png'; } elseif (pt_stripos($this->post->post_content, 'http://video.google.fr/videoplay') !== false || pt_stripos($this->post->post_content, 'http://video.google.com/videoplay') !== false || pt_stripos($this->post->post_content, '[googlevideo') !== false) { $the_image = PT_URLPATH . '/images/gvideo.png'; } return $the_image; }