Skip to content

Instantly share code, notes, and snippets.

@MatthewZaso
Created January 18, 2013 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewZaso/4567269 to your computer and use it in GitHub Desktop.
Save MatthewZaso/4567269 to your computer and use it in GitHub Desktop.
This example is of some PHP that I wrote for my Content Management System project. It is a set of functions focused around parsing local RSS/XML files using a separate class
<?php
class P2_Utils
{
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create the page doctype and initiate the body and wrapper tags
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function page_header($title="Untitled", $style=""){
$string=<<<END
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>$title</title>
<link type="text/css" rel="stylesheet" href="$style" />
</head>
<body>
<div id="wrapper">\n
END;
return $string;
}
/*
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create a div with the ad banner inside
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function ad_banner(){
// Read in file
$bannerArray = file('banners.txt');
// Create an array of all of the banner views
$bannerViewArray = array();
// Create a for loop to take out banner urls and view count
for($c=0;$c<count($bannerArray);$c++){
$tempArray = explode(",",$bannerArray[$c]);
$banner = $tempArray[0];
$bannerView = (int)$tempArray[1];
// Create MultiDimensional array with banner urls and view counts
$bannerViewArray[] = array('banner' => $banner, 'viewCount' => $bannerView);
}
// Create new key arry from banner array to sort by
foreach($bannerViewArray as $k=>$v){
$viewCount[$k] = $v['viewCount'];
}
// Sort the banner view array
array_multisort($viewCount, SORT_ASC, $bannerViewArray);
// Get banner to use
$bannerToUse = $bannerViewArray[0]['banner'];
// Display the lowest viewed banner
$string=<<<END
<div id="banner">
<img class="logo" src="logo.png" />
<img src="$bannerToUse" width="1280" height="80" />
</div><!--banner-->\n
END;
// Increment the banner count to update it
$bannerViewArray[0]['viewCount'] += 1;
// Open file to write
$fileToWrite = fopen('banners.txt', 'w') or die('Error opening file.');
$data = "";
// Put the array data back into a string
foreach($bannerViewArray as $v){
$data .= $v['banner'];
$data .= ",";
$data .= $v['viewCount'];
$data .= "\n";
}
// Write and close the file
fwrite($fileToWrite, $data);
fclose($fileToWrite);
return $string;
}*/
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create a div with the ad banner inside
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function ad_banner(){
// Read in file
$dom = new DomDocument();
$dom->load('banners.xml');
$bannerViewArray = array();
$banners = $dom->getElementsByTagName('banner');
foreach($banners as $ban){
$banner = $ban->getElementsByTagName('url')->item(0)->nodeValue;
$bannerView = $ban->getAttribute('views');
$tempArray = array('banner' => $banner, 'viewCount' => $bannerView);
array_push($bannerViewArray,$tempArray);
}
// Create new key arry from banner array to sort by
foreach($bannerViewArray as $k=>$v){
$viewCount[$k] = $v['viewCount'];
}
// Sort the banner view array
array_multisort($viewCount, SORT_ASC, $bannerViewArray);
// Get banner to use
$bannerToUse = $bannerViewArray[0]['banner'];
// Display the lowest viewed banner
$string=<<<END
<div id="banner">
<img class="logo" src="logo.png" />
<img src="$bannerToUse" width="1280" height="80" />
</div><!--banner-->\n
END;
// Increment the banner count to update it
$bannerViewArray[0]['viewCount'] += 1;
$bannersNode = $dom->getElementsByTagName('banners')->item(0);
$dom->removeChild($bannersNode);
$newBanners = $dom->createElement('banners');
// Put the array data back into a string
foreach($bannerViewArray as $v){
$tempBanner = $dom->createElement('banner');
$tempBanner->setAttribute('views',$v['viewCount']);
$newurl = $dom->createElement('url',$v['banner']);
$tempBanner->appendChild($newurl);
$newBanners->appendChild($tempBanner);
}
$dom->appendChild($newBanners);
$dom->save('banners.xml');
return $string;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Nav links
//+++++++++++++++++++++++++++++++++++++++++++++++++++
public function nav_menu(){
// Create an array of the nav links
$nav = array(
'Admin' => 'admin.php',
'Home' => 'index.php',
'News' => 'news.php',
'Services' => 'services.php');
$string="<div id='nav'>\n<ul>\n";
// Loop through the navigation array and return links
foreach($nav as $k=>$v){
$string .= "<li><a href='$v'>$k</a></li>\n";
}
// Close the nav div
$string .= "</ul>\n</div><!--nav-->\n";
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create the closing tags and page footer
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function page_footer(){
$string="</div><!--wrapper-->\n</body>\n</html>\n";
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Get IP and Browser Info
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function ipInfo(){
$ipAddress = $_SERVER['REMOTE_ADDR'];
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if ( strpos($userAgent, 'Gecko') ){
if ( strpos($userAgent, 'Chrome') ){
$browser = 'Chrome';
}
else if ( strpos($userAgent, 'Firefox') ){
$browser = 'Firefox';
}else{
$browser = 'Mozilla';
}
}
else if ( strpos($userAgent, 'MSIE') ){
if ( strpos($userAgent, 'Opera') ){
$browser = 'Opera';
}else{
$browser = 'Internet Explorer';
}
}else{
$browser = 'an unknown browser';
}
if ( strpos($userAgent, 'Mac') ){
$os = 'Mac';
}
else if ( strpos($userAgent, 'Linux') ){
$os = 'Linux Computer';
}
else if ( strpos($userAgent, 'Windows') ){
$os = 'PC';
}else{
$os = 'unknown computer';
}
$string=<<<END
<div id="ipInfo">
Hello, IP Address $ipAddress. You are using
$browser to currently view this site on
a $os. Thanks for visiting!
</div><!--ipInfo-->
END;
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Get Blog Items
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function blogItems(){
/*
// Get blog file
$blogFile = file('blog.txt');
// Sort blog file array
while(count($blogFile)>$counter){
// Take three elements out of the array (title, date, post) and add it
// to new array
$blogArray[$counter] = array_slice($blogFile, $counter, 3);
$counter += 3;
}
// Reverse the array to put the newest blog items first
$blogArray = array_reverse($blogArray);
*/
$counter=0;
$dom = new DomDocument();
$dom->load('project2.rss');
while($dom->getElementsByTagName("item")->length>$counter){
$item = $dom->getElementsByTagName("item")->item($counter);
$title = $item->getElementsByTagName("title")->item(0)->nodeValue;
$desc = $item->getElementsByTagName("description")->item(0)->nodeValue;
$pubDate = $item->getElementsByTagName("pubDate")->item(0)->nodeValue;
$blogArray[$counter]=Array($title,$pubDate,$desc);
$counter += 1;
}
$blogArray = array_reverse($blogArray);
return $blogArray;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Get Blog Items By Post
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function blogItemsByPost($posts=0){
$blogArray = $this->blogItems();
if(array_key_exists($posts, $blogArray)){
$blog = $blogArray[$posts];
return $blog;
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Take page request and split it into html
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function blogItemsHTML($numOfPosts=5,$page=1){
$num = $numOfPosts;
// Get Select Number of Posts
$string = '';
$posts = ($page - 1) * $num;
for($c=0;$c<$num;$c++){
$count = $posts + $c;
$blogPostArray = $this->blogItemsByPost($count);
if(isset($blogPostArray)){
$blogArray = $this->blogItemsByPost($count);
$url = 'perm.php?page='.$page.'&'.'thepost='.$c;
// Print posts out on page
$string .=<<<END
<div class="post">
<div class="postHeader">
<a href='$url'><h1 class="postTitle">$blogArray[0]</h1></a>
<p class="date">$blogArray[1]</p>
</div><!--postHeader-->
<p class="postContent">
$blogArray[2]
</p>
</div><!--post-->
END;
}
}
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create the forward and backward links
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function postLinks(){
$string="";
$numOfPosts = count($this->blogItems());
$numOfPages = ceil($numOfPosts / 5);
$string .= "<div id='postnav'>";
$string .= "<ul>\n";
// Check to make sure user isn't on page one, if not, show back
if(array_key_exists('newPage', $_GET)){
if($_GET['newPage'] != 1){
$newPageNum = $_GET['newPage'] - 1;
$string .= "<li><a href='news.php?newPage=$newPageNum'>&#60;&#60;</a></li>\n";
}
}
// Show Pages
for($c=1;$c<$numOfPages + 1;$c++){
$string .= "<li><a href='news.php?newPage=$c'>$c</a></li>\n";
}
// If user isn't on last page, show forward
if(array_key_exists('newPage', $_GET)){
if($numOfPages > $_GET['newPage']){
$newPageNum = $_GET['newPage'] + 1;
$string .= "<li><a href='news.php?newPage=$newPageNum'>&#62;&#62;</a></li>\n";
}
} else {
if($numOfPages > 1){
$string .= "<li><a href='news.php?newPage=2'>&#62;&#62;</a></li>\n";
}
}
//write the rest of the elements
$string .= "</ul>\n</div><!--postNav-->\n";
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Check Page
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function checkPage(){
$pageNum = 1;
// if the page has a newPage value, update it
if(array_key_exists('newPage', $_GET)){
$pageNum = $_GET['newPage'];
}
return $pageNum;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Editor Forms
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function adminFormEditor(){
$string='';
$editortext = file_get_contents('editor.txt') or die('Error retreiving file.');
$string .=<<<END
<h1>Edit the Letter to the Editor Page here</h1>
<form action = 'admin.php' method='POST'>
<textarea name="editorial" rows="10" cols="80">
$editortext
</textarea><br />
<strong>Password: </strong><input type='password' name='password' size='20' /><br />
<input type="reset" value="Reset Form" />
<input type="submit" name="submit" value="Submit Form" />
</form>
END;
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Selection Form
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function createSelection(){
$string='';
$string .=<<<END
<h1>Choose Newsfeeds To Follow</h1>
<form action='admin.php' method='POST'>
<strong>Password: </strong><input type='password' name='password3' size='20' /><br />
<select name='add'>
END;
$dom = new DomDocument();
$dom->load('rss_class.xml');
$news = $dom->getElementsByTagName('news')->item(0);
$students = $news->getElementsByTagName('student');
foreach($students as $stu){
if($stu->getAttribute("selected") == 'no'){
$first = $stu->getElementsByTagName('first')->item(0)->nodeValue;
$last = $stu->getElementsByTagName('last')->item(0)->nodeValue;
$name = $first . ' ' . $last;
$string .="<option value='$name'>$name</option>\n\n";
}
}
$string .="</select><button type='submit' name=''>add</button>\n</form>\n";
$string .="<br />\n<br />\n";
$string .="<form action='admin.php' method='POST'>\n";
$string .="<strong>Password: </strong><input type='password' name='password3' size='20' />\n";
foreach($students as $stu){
if($stu->getAttribute("selected") == 'yes'){
$first = $stu->getElementsByTagName('first')->item(0)->nodeValue;
$last = $stu->getElementsByTagName('last')->item(0)->nodeValue;
$name = $first . ' ' . $last;
$string .="<p>$name<button type='submit' value='$name' name='remove'>remove</button></p>\n";
}
}
$string .=<<<END
</form>
END;
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Student Feed
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function createStudentFeed($num='2'){
$string = '';
$newsArray = array();
$dom = new DomDocument();
$dom->load('rss_class.xml');
$news = $dom->getElementsByTagName('news')->item(0);
$students = $news->getElementsByTagName('student');
//for each student, check to see if their name matches the changed one
foreach($students as $stu){
if($stu->getAttribute('selected') == 'yes'){
$firstName = $stu->getElementsByTagName('first')->item(0)->nodeValue;
$lastName = $stu->getElementsByTagName('last')->item(0)->nodeValue;
$name = $firstName . ' ' . $lastName;
$url = $stu->getElementsByTagName('url')->item(0)->nodeValue;
$dom2 = new DomDocument();
if($this->getStatusCode($url)=='200'){
$dom2 = new DomDocument();
$dom2->load($url);
$items = $dom2->getElementsByTagName('item');
foreach($items as $item){
$title = $item->getElementsByTagName('title')->item(0)->nodeValue;
$desc = $item->getElementsByTagName('description')->item(0)->nodeValue;
$pub = $item->getElementsByTagName('pubDate')->item(0)->nodeValue;
$tempArray = array($title,$pub,$desc);
array_push($newsArray,$tempArray);
}
} else {
echo "<h3>$name's Feed Does Not Exist</h3>\n";
}
}
}
for($c=0;$c<$num;$c++){
$thisTitle = $newsArray[$c][0];
$thisDate = $newsArray[$c][1];
$thisDes = $newsArray[$c][2];
$string .=<<<END
<h1>$thisTitle</h1>
<p>$thisDate</p>
<p>$thisDes</p>
END;
}
$string .="\n\n\n\n";
$string .="<a href='project2.rss'>View My RSS File Here</a>";
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Get Status code
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function getStatusCode($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $status_code;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Selection Form
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function createServices(){
$string='';
$string .=<<<END
<h1>Choose Services to Follow</h1>
<form action='admin.php' method='POST'>
END;
$dom = new DomDocument();
$dom->load('rss_class.xml');
$web = $dom->getElementsByTagName('web')->item(0);
$choices = $web->getElementsByTagName('choice');
foreach($choices as $choice){
$name = $choice->getElementsByTagName('name')->item(0)->nodeValue;
$checked = $choice->getAttribute('selected');
$string .= "<input type='checkbox' name='$name' value='$name' ";
if($checked == 'yes'){
$string .= "checked ";
}
$string .= "/>$name<br />\n";
}
$string .=<<<END
<strong>Password: </strong><input type='password' name='password4' size='20' /><br />
<input type="reset" value="Reset Form" />
<input type="submit" name="feeds" value="Follow" />
</form>
END;
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Check Services Form
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function checkServices(){
if (isset($_POST['password4'])){
$password = sanitize($_POST['password4']);
if ($password == PASSWORD){
if(isset($_POST['feeds'])){
$dom = new DomDocument();
$dom->load('rss_class.xml');
$web = $dom->getElementsByTagName('web')->item(0);
$choices = $web->getElementsByTagName('choice');
foreach($choices as $choice){
$name = $choice->getElementsByTagName('name')->item(0)->nodeValue;
if(isset($_POST[$name])){
$choice->setAttribute('selected','yes');
} else {
$choice->setAttribute('selected','no');
}
}
//save the file
$dom->save('rss_class.xml');
}
} else {
echo "Please Enter the Correct Password";
}
} else {
echo "Please enter valid input";
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Switch Selected People
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function switchSelected(){
if (isset($_POST['password3'])){
$password = sanitize($_POST['password3']);
if ($password == PASSWORD){
if (isset($_POST['add']) || isset($_POST['remove'])){
foreach($_POST as $k=>$v){
if ($k == 'remove' || $k == 'add'){
//Split the name into two
$pieces = explode(' ',$v,2);
$first = $pieces[0];
$last = $pieces[1];
//load the xml file
$dom = new DomDocument();
$dom->load('rss_class.xml');
$news = $dom->getElementsByTagName('news')->item(0);
$students = $news->getElementsByTagName('student');
//for each student, check to see if their name matches the changed one
foreach($students as $stu){
$firstName = $stu->getElementsByTagName('first')->item(0)->nodeValue;
$lastName = $stu->getElementsByTagName('last')->item(0)->nodeValue;
$parent = $stu->parentNode;
//if it does, swap its value
if($first == $firstName && $last == $lastName){
if($stu->getAttribute("selected") == 'yes'){
$stu->setAttribute("selected",'no');
} else {
$stu->setAttribute("selected",'yes');
}
//save the file
$dom->save('rss_class.xml');
}
}
}
}
} else {
echo "Please Enter the Correct Password";
}
} else {
echo "Please enter valid input";
}
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Check the editor form
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function checkEditorForm(){
define('PASSWORD','password');
if (array_key_exists('submit', $_POST)){
if (isset($_POST['password']) && isset($_POST['editorial'])){
$password = sanitize($_POST['password']);
$editorial = $_POST['editorial'];
if ($password == PASSWORD && strlen($editorial) > 0){
// Open file to write
$fileToWrite = fopen('editor.txt', 'w') or die('Error opening file.');
// Write and close the file
fwrite($fileToWrite, $editorial);
fclose($fileToWrite);
} else {
echo "Please Enter the Correct Password";
}
} else {
echo "Please enter valid input";
}
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Check the post form
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function checkPostForm(){
/*
if (array_key_exists('submit2', $_POST)){
if (isset($_POST['password2'])){
$password = sanitize($_POST['password2']);
$subject = sanitize($_POST['subject']);
$mypost = sanitize($_POST['mypost']);
$mypost = str_replace ("\r\n"," ",$mypost);
$time=time();
$date = date("F j, Y, g:i a", $time);
if ($password == PASSWORD && strlen($subject) > 0 && strlen($mypost) > 0){
$data = "";
$data .= $subject . "\n";
$data .= $date . "\n";
$data .= $mypost . "\n";
$data = str_replace ("'","&#39;",$data);
file_put_contents("blog.txt",$data,FILE_APPEND);
$confirmation = "Post Added!";
return $confirmation;
} else {
echo "Please Enter the Correct Password";
}
} else {
echo "Please enter valid input";
}
*/
include('RSSFeed.class.php');
if (array_key_exists('submit2', $_POST)){
if (isset($_POST['password2'])){
$password = sanitize($_POST['password2']);
$subject = sanitize($_POST['subject']);
$mypost = sanitize($_POST['mypost']);
$mypost = str_replace ("\r\n"," ",$mypost);
$time=time();
$date = date("F j, Y, g:i a", $time);
if ($password == PASSWORD && strlen($subject) > 0 && strlen($mypost) > 0){
$newRSS = new RSSFeed();
$newRSS->saveRSS($subject,$mypost,$date);
} else {
echo "Please Enter the Correct Password";
}
} else {
echo "Please enter valid input";
}
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Sanatize the string
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function sanitize($var){
$var = trim($var);
$var = stripslashes($var);
$var = htmlentities($var);
$var = strip_tags($var);
return $var;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Post Form
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function adminFormPost(){
$string='';
$string .=<<<END
<h1>Add a new post here</h1>
<form action = 'admin.php' method='POST'>
<strong>Subject: </strong><input type='text' name='subject' size='80' /><br />
<textarea name="mypost" rows="10" cols="80">
</textarea><br />
<strong>Password: </strong><input type='password' name='password2' size='20' /><br />
<input type="reset" value="Reset Form" />
<input type="submit" name="submit2" value="Submit Form" />
</form>
END;
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Preview Section
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function previewSection(){
$string = "<div id='preview'>\n";
$string .="<h1 id='previewHeader'>Preview</h1>\n";
$string .= file_get_contents('editor.txt') or die('Error opening file.');
$string .="\n</div><!--preview-->\n";
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Letter To the Editor Section
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function getLetterToEditor(){
$string="<div id='editor'>\n";
$string .= "<img class='editorPic' src='editor.png' />\n";
$string .= file_get_contents('editor.txt') or die('Error opening file.');
$string .= "\n</div><!--editor-->\n";
return $string;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// Create Services Section
// +++++++++++++++++++++++++++++++++++++++++++++++++++
public function getServices(){
$string="<div id='services'>\n";
$counter=0;
$dom = new DomDocument();
$dom->load('rss_class.xml');
$webTag = $dom->getElementsByTagName("web")->item(0);
while($webTag->getElementsByTagName("choice")->length>$counter){
$choice = $webTag->getElementsByTagName("choice")->item($counter);
$url = $choice->getElementsByTagName("url")->item(0)->nodeValue;
if($choice->getAttribute("selected") == 'yes'){
$dom2 = new DomDocument();
$dom2->load($url);
$item = $dom2->getElementsByTagName("item")->item(0);
$name = $choice->getElementsByTagName("name")->item(0)->nodeValue;
$title = $item->getElementsByTagName("title")->item(0)->nodeValue;
$desc = $item->getElementsByTagName("description")->item(0)->nodeValue;
$link = $item->getElementsByTagName("link")->item(0)->nodeValue;
$string .="<h1>$name</h1>";
$string .="<h2><a href='$link'>$title</a></h2>";
$string .= $desc;
}
$counter += 1;
}
$string .= "\n</div><!--editor-->\n";
return $string;
}
}
?>
<?php
class RSSFeed{
function saveRSS($subject,$mypost,$date){
// Create Nodes
$dom= new DomDocument();
$dom->load('project2.rss');
$dom->formatOutput = true;
$channel = $dom->getElementsByTagName('channel')->item(0);
$newItem = $dom->createElement('item');
$newTitle = $dom->createElement('title',$subject);
$newPost = $dom->createElement('description');
$newDate = $dom->createElement('pubDate',$date);
$cdata = $dom->createCDATASection($mypost);
// Append Items
$newItem->appendChild($newTitle);
$newPost->appendChild($cdata);
$newItem->appendChild($newPost);
$newItem->appendChild($newDate);
$channel->appendChild($newItem);
// Save Item
$dom->save('project2.rss');
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment