Location: PHPKode > scripts > MyVideoBlog LITE - Automatic Wordpress Video Blogs! > myvideoblog-lite-automatic-wordpress-video-blogs/myvideoblog/mvb_newfeed.php
<?php
$table_name = $wpdb->prefix . "myvideoblog";
$server_url = $_SERVER['REQUEST_URI'];
$server_name = $_SERVER['SERVER_NAME']; 
$url_back = "http://$server_name$server_url";
$cleanub = strstr($url_back, "&");
$url_back = str_replace($cleanub, "", $url_back);
$tv = $_REQUEST['tv'];
$tf = $_REQUEST['tf'];
$siteurl = get_option('siteurl');
?>
<div class=wrap>
<table width="100%"><tr><td>
<a href="http://www.phpmyvideoblog.com" target="_blank" title="PHPMyVideoBlog.com"><img src="<?php echo $siteurl?>/wp-content/plugins/myvideoblog/includes/mvb.gif" border="0" alt="PHPMyVideoBlog.com"></a>
</td><td>
[<a href="admin.php?page=myvideoblog/mvb_main.php">My Feeds</a>]
[<a href="admin.php?page=MVB_Add_New_Feed">Add New Feed</a>]
[<a href="admin.php?page=MVB_Settings">MVB Settings</a>]
[<a href="admin.php?page=MVB_Auto-Updates_Settings">Auto-Updates Settings</a>]
</td></tr></table>
<h2>Add New Feed</h2>
<?php
if ($_REQUEST['action'] == "savefeed") {

if (($_REQUEST['feedsource'] == "youtube") and ($_REQUEST['ytthetype'] == "byuser") and (!$_REQUEST['feedusername']))  { echo "<font color=red>Please put the YouTube username.</font><br>";}
else if ((!$_REQUEST['feedkeywords']) and (!$_REQUEST['feedurl'])) { echo "<font color=red>Please put the keywords or put a specific Feed URL.</font><br>";}
else if (!$_REQUEST['days']) {echo "<font color=red>Please select the weekdays to update this Feed!</font><br>";}
else if (!$_REQUEST['feedcategory']) {echo "<font color=red>Please select the categories to save your videos.</font><br>";}
else if (!$_REQUEST['feedsource']) {echo "<font color=red>Please select the feed source!</font><br>";}
else { $maxvideos = $_REQUEST['maxvideos'];
if (!$maxvideos) { $maxvideos = "1";}
if ($maxvideos == "0") { $maxvideos = "1";}

$days = $_REQUEST['days'];
foreach ($days as $weekday) {
if ($weekday == "everyday") { $everyday = "yes";}
if ($weekday == "sunday") { $sunday = "yes";}
if ($weekday == "monday") { $monday = "yes";}
if ($weekday == "tuesday") { $tuesday = "yes";}
if ($weekday == "wednesday") { $wednesday = "yes";}
if ($weekday == "thursday") { $thursday = "yes";}
if ($weekday == "friday") { $friday = "yes";}
if ($weekday == "saturday") { $saturday = "yes";}
}

$mytags = strtolower($_REQUEST['feedkeywords']);
$feedsource = $_REQUEST['feedsource'];
$poststatus = $_REQUEST['poststatus'];
$commentstatus = $_REQUEST['commentstatus'];
$pingstatus = $_REQUEST['pingstatus'];
$ytcats = $_REQUEST['ytcats'];
$postauthor = $_REQUEST['author'];
$ytlang = $_REQUEST['ytlang'];

if($ytlang == "any") {
$bylang = "";
} else {
$bylang = "&lr=".$ytlang."";
}


if (($feedsource == "youtube") OR ($feedsource == "mvblite")) {
if ($_REQUEST['ytthetype'] == "byuser") {
$usefeed = "http://gdata.youtube.com/feeds/api/users/".$_REQUEST['feedusername']."/uploads?max-results=50".$bylang."&alt=atom&v=2&orderby=published";
} else {
$mytags = str_replace(', ', "/", $mytags);
$mytags = str_replace(',', "/", $mytags);
$mytags = str_replace(' ', "/", $mytags);
$usefeed = "http://gdata.youtube.com/feeds/api/videos/-/".$ytcats."".$mytags."?max-results=50".$bylang."&alt=atom&v=2&orderby=published";
}
}

$feedurl = $_REQUEST['feedurl'];
$feedurl = str_replace("gdata.youtube.com/feeds/base/", "gdata.youtube.com/feeds/api/", $feedurl);
$feedurl = str_replace("alt=rss", "alt=atom", $feedurl);
$feedurl = str_replace("alt=json", "alt=atom", $feedurl);
$feedurl = str_replace("alt=json-in-script", "alt=atom", $feedurl);
if ($feedurl) {
$usefeed = $feedurl;
}
$feedcategory = serialize($_REQUEST['feedcategory']);

if ($_REQUEST['blocktags'] == "example|keyword1|keyword2") {
$getblocktags == "";
} else {
$getblocktags = strtolower($_REQUEST['blocktags']);
}

$blocktags = explode("|", $getblocktags);
$blocktags = serialize($blocktags);

$blockwhere = $_REQUEST['blockwhere'];
if (is_array($blockwhere)) {
foreach ($blockwhere as $block_in) {
if ($block_in == "title") { $checktitle = "yes";}
if ($block_in == "desc") { $checkdesc = "yes";}
if ($block_in == "tags") { $checktags = "yes";}
}
}

$wpdb->query("INSERT INTO $table_name (fid, feed, category, active, maxvideos, poststatus, sunday, monday, tuesday, wednesday, thursday, friday, saturday, commentstatus, pingstatus, blocktags, checktitle, checkdesc, checktags, postauthor)
	VALUES ('', '$usefeed', '$feedcategory', 'yes', '$maxvideos', '$poststatus', '$sunday', '$monday', '$tuesday', '$wednesday', '$thursday', '$friday', '$saturday', '$commentstatus', '$pingstatus', '$blocktags', '$checktitle', '$checkdesc', '$checktags', '$postauthor')");
echo "<center><font color=green>Feed Added!</font></center>";
}
}
?>


<table class="widefat" width="100%" cellspacing="1">
<tr><td>
<form action="admin.php?page=MVB_Add_New_Feed" method="post" name="myform">
<input type="hidden" name="action" value="savefeed">
<table width="100%" cellspacing="0">
<tr><td>
<div style="float:left;width=100px;padding-right:3px">
<div><b>Source:</b></div>
<div>
<select name="feedsource" onchange="showsources(this.value)">
<option value="youtube">YouTube</option>
<option value="dailymotion">Dailymotion</option>
<option value="metacafe">Metacafe</option>
<option value="kewego">Kewego</option>
<option value="yahoo">Yahoo! Video</option>
<option value="break">Break</option>
<option value="viddler">Viddler&#185;</option>
<option value="sevenload">SevenLoad&#185;</option>
<option value="">-- Adult Videos: --</option>
<option value="megaporn">MegaPorn</option>
<option value="shufuni">Shufuni</option>
<option value="pornhub">PornHub</option>
<option value="xvideos">Xvideos</option>
<option value="redtube">RedTube</option>
<option value="deviantclip">DeviantClip</option>
<option value="keezmovies">KeezMovies</option>
</select>
</div>
</div>
<div id="yttype" style="float:left;display:block;padding-right:3px">
<div><b>Type:</b></div>
<div>
<select name="ytthetype" onchange="ytchangetype(this.value)" id="yttypes">
<option value="bytags">Tags</option>
<option value="byuser">Channel/User</option>
</select>
</div>
</div>
<div id="ytdiv" style="float:left;display:block;padding-right:3px">
<div><b>Source Category:</b></div>
<div>
<select name="ytcats">
<option value="">-Any-</option>
<option value="Autos/">Autos & Vehicles</option>
<option value="Comedy/">Comedy</option>
<option value="Education/">Education</option>
<option value="Entertainment/">Entertainment</option>
<option value="Film/">Film & Animation</option>
<option value="Gaming/">Gaming</option>
<option value="Howto/">Howto & Style</option>
<option value="Music/">Music</option>
<option value="News/">News & Politics</option>
<option value="Nonprofits/">Nonprofits & Activism</option>
<option value="People/">People & Blogs</option>
<option value="Pets/">Pets & Animals</option>
<option value="Science/">Science & Technology</option>
<option value="Sports/">Sports</option>
<option value="Travel/">Travel & Events</option>
</select>
</div>
</div>
<div id="ytlangdiv" style="float:left;display:block;padding-right:3px">
<div><b>Language:</b></div>
<div>
<select name="ytlang">
<option value="any">-Any Language-</option>
<option value="ar">Arabic</option>
<option value="bg">Bulgarian</option>
<option value="ca">Catalan</option>
<option value="zh-Hans">Chinese (Simplified)</option>
<option value="zh-Hant">Chinese (Traditional)</option>
<option value="hr">Croatian</option>
<option value="cs">Czech</option>
<option value="da">Danish</option>
<option value="nl">Dutch</option>
<option value="en">English</option>
<option value="et">Estonian</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="er">Greek</option>
<option value="iw">Hebrew</option>
<option value="hu">Hungarian</option>
<option value="is">Icelandic</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="lv">Latvian</option>
<option value="lt">Lithuanian</option>
<option value="no">Norwegian</option>
<option value="pl">Polish</option>
<option value="pt">Portuguese</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="sr">Serbian</option>
<option value="sk">Slovak</option>
<option value="sl">Slovenian</option>
<option value="es">Spanish</option>
<option value="sv">Swedish</option>
<option value="tr">Turkish</option>
</select>
</div>
</div>
<div id="prodiv" style="float:left;display:none;padding-right:3px">
<div><b><br></b></div>
<div>
Not available in Lite Version. Buy Pro Version <a href="http://www.phpmyvideoblog.com" target="_blank">here</a>.
</div>
</div>
</td></tr>
<tr><td>
<div id="keydiv" style="float:left;display:block;padding-right:3px">
<div><b>Keywords:</b> (no spaces)</div>
<div>
<input type="text" name="feedkeywords" value="example,tag,tag" size="35" onfocus="this.value='';return false;">
</div>
</div>
<div id="userdiv" style="float:left;display:none;padding-right:3px">
<div><b>Username:</b></div>
<div>
<input type="text" name="feedusername" value="user" size="35" onfocus="this.value='';return false;">
</div>
</div>
<div id="mvdiv" style="width:100px;float:left;display:block;padding-right:3px">
<div><b>Max Videos:</b></div>
<div>
<input style="font-size:10px;" type="text" name="maxvideos" maxlength="2" size="2" value="5">
</div>
</div>
</td></tr></table>
<br>
<div id="clicksf" style="display:block";padding-right:3px";>
<a href="#" onclick="specificfeed();return false;">&nbsp; Click here to add a specific feed url&sup1;</a>
</div>
<div id="showsf" style="display:none";>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Specific Feed URL<font color="brow">&sup1;</font>:</td></tr>
<tr><td bgcolor="#FFF3E0">
<input type="text" name="feedurl" size="50">
</td></tr>
</table><br>
</div>

<table width="100%" cellspacing="0">
<tr><td>
<div style="float:left;width=100px;padding-right:3px;">
<div><b>Categories:</b></div>
<div>
<table width="100%" cellspacing="4">
<tr>
<?php
$boxcount=0;
$getcats = $wpdb->get_results("SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_taxonomy_id DESC");
foreach ($getcats as $thecats) {
$taxocat_id = $thecats->term_id;
$showcat_name = $wpdb->get_var("SELECT name FROM $wpdb->terms WHERE term_id = '$taxocat_id'");
if($taxocat_id == $_REQUEST['feedcategory']) {
echo "<td><input value=\"$taxocat_id\" type=\"checkbox\" name=\"feedcategory[]\" checked>$showcat_name</td>";
} else {
echo "<td><input value=\"$taxocat_id\" type=\"checkbox\" name=\"feedcategory[]\">$showcat_name</td>";
}
$boxcount++;
if ($boxcount == "5") {
echo "</tr><tr>";
$boxcount=0;
}
}
?>
</table>
</div>
</div>
</td></tr></table><br>
<table width="100%" cellspacing="0">
<tr><td>
<b>*Skip videos with the following keywords:</b> (separate by | )
<br>
<input type="text" name="blocktags" value="example|keyword1|keyword2" size="80" onfocus="this.value='';return false;" disabled>
<br><br>
<b>*Check for blocked keywords in:</b>
<br>
<input value="title" type="checkbox" name="blockwhere[]" disabled>Video Title<br>
<input value="desc" type="checkbox" name="blockwhere[]" disabled>Video Description<br>
<input value="tags" type="checkbox" name="blockwhere[]" disabled>Video Tags<br>
<br> <b>*</b>Not available in Lite Version. Buy Pro Version <a href="http://www.phpmyvideoblog.com" target="_blank">here</a>.
</td></tr>
</table>
<br>
<table cellpadding="0" border="0"><tr>
<td>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Publish Status:</b></td></tr>
<tr><td bgcolor="#FFF3E0">
<input value="publish" type="radio" name="poststatus"  onClick="hideschedule();" checked>Publish
<input value="pending" type="radio" name="poststatus" onClick="hideschedule();">Pending
<input value="draft" type="radio" name="poststatus" onClick="hideschedule();">Draft
<input value="future" type="radio" name="poststatus" onClick="showschedule();" disabled>Schedule*
</td></tr>
</table>
<div id="schedulediv" style="float:left;display:block;padding-right:3px">

</div>
</td><td>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Allow Comments:</b></td></tr>
<tr><td bgcolor="#FFF3E0"><input value="open" type="radio" name="commentstatus" checked>Yes	
<input value="closed" type="radio" name="commentstatus">No
</td></tr>
</table>
</td><td>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Allow Pings:</td></tr>
<tr><td bgcolor="#FFF3E0">
<input value="open" type="radio" name="pingstatus" checked>Yes	
<input value="closed" type="radio" name="pingstatus">No
</td></tr>
</table>
</td><td>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Post Author:</td></tr>
<tr><td bgcolor="#FFF3E0">
<select name="author">
<?php
$getauthors = $wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID");
foreach ($getauthors as $theauts) {
$author_id = $theauts->ID;
$author_name = $theauts->display_name;
echo "<option value=\"$author_id\">$author_name</option>";
}
?>
</select>
</td></tr>
</table>
</td></tr></table>
<br>
<div id="comments_div" style="display:block;">
<table cellpadding="0" border="0"><tr>
<td>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Grab YouTube comments? *</b></td></tr>
<tr><td bgcolor="#FFF3E0"><input value="yes" type="radio" name="grab_comments" checked disabled>Yes	
<input value="no" type="radio" name="grab_comments" disabled>No
</td></tr>
</table>
</td>
<td>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Max comments per video: *</b></td></tr>
<tr><td bgcolor="#FFF3E0">
<input style="font-size:10px;" type="text" name="max_comments" maxlength="2" size="2" value="20" disabled>
</td></tr>
</table>
</td><td>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Auto aprove these comments? *</td></tr>
<tr><td bgcolor="#FFF3E0">
<input value="yes" type="radio" name="aprove_comments" checked disabled>Yes	
<input value="no" type="radio" name="aprove_comments" disabled>No
</td></tr>
</table>
</td></tr></table><br>
</div>
<b>*</b>Not available in Lite Version. Buy Pro Version <a href="http://www.phpmyvideoblog.com" target="_blank">here</a>.<br>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9">
<tr><td bgcolor="#E4F2FD"><b>Update Weekdays:</td></tr>
<tr><td bgcolor="#FFF3E0">
<input value="everyday" type="checkbox" name="days[]" onClick="Check(this)"><b>Everyday</b>
 <input value="sunday" type="checkbox" name="days[]">Sunday
 <input value="monday" type="checkbox" name="days[]">Monday
 <input value="tuesday" type="checkbox" name="days[]">Tuesday
 <input value="wednesday" type="checkbox" name="days[]">Wednesday
 <input value="thursday" type="checkbox" name="days[]">Thursday
 <input value="friday" type="checkbox" name="days[]">Friday
 <input value="saturday" type="checkbox" name="days[]">Saturday
</td></tr>
</table>
<br><center><input type="submit" name="submit" class="button" value="ADD FEED!"></center></form>
</td></tr></table>
<br><br>
<font color="brow">&sup1;</font><font size=1><b>Some sites like dailymotion can be used several types of feeds, by tags, by user, by search, by category. If you type some url here, this is the url that will be used and not the keywords box/source box. The keyword/source box uses feeds by tags!</b></font>

</div>

<?php
MyVideoBlog_showfooter();
?>
Return current item: MyVideoBlog LITE - Automatic Wordpress Video Blogs!