setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $con -> setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES utf8"); $con -> exec("SET CHARACTER SET utf8"); // return all sql requests as UTF-8 } catch (PDOException $err) { echo "harmless error message if the connection fails"; $err -> getMessage() . "
"; file_put_contents('PDOErrors.txt', $err, FILE_APPEND); // write some details to an error-log outside public_html die(); // terminate connection } $sql = 'SELECT ID, post_content, post_title, guid, UNIX_TIMESTAMP(post_date) as date, post_name FROM wp_video2posts WHERE post_status="publish" AND post_type="projects" ORDER BY post_date ASC;'; $qry = $con -> prepare($sql); $qry -> execute(); $get = $qry -> fetchAll(); include ("universal_feed_generator/FeedWriter.php"); $theFeed = new FeedWriter(RSS2); //Setting the channel elements //Use wrapper functions for common channel elements $theFeed -> setTitle('Liebenzell TV Videos'); $theFeed -> setLink('http://www.liebenzell.tv'); $theFeed -> setDescription('Videofilme von Liebenzell.tv'); //Image title and link must match with the 'title' and 'link' channel elements for RSS 2.0 // $theFeed->setImage('Testing the RSS writer class','http://www.ajaxray.com/projects/rss','http://www.rightbrainsolution.com/images/logo.gif'); $theFeed -> setChannelElement('language', 'de'); $theFeed -> setChannelElement('pubDate', date(DATE_RSS, time())); foreach ($get as $video) { if (preg_match("~[\"'](?http:\/\/[^\"']*youtube[^\"']+\/(?[0-9a-z]{8,})(\?[^\"']*|))[\"']~i", $video["post_content"], $match) !== 1) { continue; } else { $_videoURL = $match["link"]; $_youTubeID = $match["id"]; } $_title = $video["post_title"]; $_date = $video["date"]; $_id = $video["ID"]; $_guid = $video["guid"]; $_buyLink = "http://liebenzell.tv/" . $video["post_name"]; // http://img.youtube.com/vi/3cKKE32feI4/0.jpg $_tumbURLBig = "http://img.youtube.com/vi/{$_youTubeID}/0.jpg"; $_thumbURLSmall = "http://img.youtube.com/vi/{$_youTubeID}/1.jpg"; // // echo "Title: {$_title}
"; // echo "Date: {$_date}
"; // echo "URL: {$_videoURL}
"; // echo "ID: {$_id}
"; // echo "

"; //Create an empty FeedItem $newItem = $theFeed -> createNewItem(); //Add elements to the feed item //Use wrapper functions to add common feed elements $newItem -> setTitle($_title); $newItem -> setLink($_buyLink); //The parameter is a timestamp for setDate() function $newItem -> setDate($_date); $newItem -> setDescription($_title); $newItem -> setEncloser($_videoURL, '', 'video/mpeg'); /* $newItem -> addElement('media:content', '', array( 'url' => $_videoURL, "type" => "video/mpeg" )); */ $newItem -> addElement('media:thumbnail', '', array('url' => "{$_tumbURLBig}", 'width' => '360', 'height' => '480', 'time' => '00:00:00.0')); //Use core addElement() function for other supported optional elements // $newItem -> addElement('author', 'admin@ajaxray.com (Anis uddin Ahmad)'); //Attributes have to passed as array in 3rd parameter $newItem -> addElement('guid', $_buyLink, array('isPermaLink' => 'true')); //Now add the feed item $theFeed -> addItem($newItem); } $theFeed -> genarateFeed(); ?>