videofly/zvf_newfeed.php
<?php
$table_name = $wpdb->prefix . "videofly";
$siteurl = get_bloginfo('wpurl');
?>
<div class=wrap>
<table width="100%"><tr><td>
<a href="admin.php?page=videofly/zvf_main.php" title="ZombiePlugins.com"><img src="<?php echo $siteurl?>/wp-content/plugins/videofly/includes/zvflogo.png" border="0" alt="ZombiePlugins.com"></a>
</td><td>
<a href="admin.php?page=videofly/zvf_main.php"><img src="<?php echo $siteurl?>/wp-content/plugins/videofly/includes/sources.png" border="0" alt="Sources"></a>
<a href="admin.php?page=zvf_Add_New_Feed"><img src="<?php echo $siteurl?>/wp-content/plugins/videofly/includes/addvideo.png" border="0" alt="Add Video"></a>
<a href="admin.php?page=zvf_Settings"><img src="<?php echo $siteurl?>/wp-content/plugins/videofly/includes/settings.png" border="0" alt="Settings"></a>
<a href="admin.php?page=zvf_Auto-Updates_Settings"><img src="<?php echo $siteurl?>/wp-content/plugins/videofly/includes/updates.png" border="0" alt="Updates"></a> <a href="admin.php?page=Adfly"><img src="<?php echo $siteurl?>/wp-content/plugins/videofly/includes/adfly.png" border="0" alt="Adfly"></a>
</td></tr></table>
<h2>Add Video Source</h2>
<?php
if ($_REQUEST['action'] == "savefeed") {
if (($_REQUEST['feedsource'] == "youtube") and ($_REQUEST['ytthetype'] == "byuser") and (!$_REQUEST['feedusername']) and (!$_REQUEST['feedurl'])) { 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'];
$scheduletime = $_REQUEST['scheduletime'];
$commentstatus = $_REQUEST['commentstatus'];
$pingstatus = $_REQUEST['pingstatus'];
$shufcats = $_REQUEST['shufcats'];
$phcats = $_REQUEST['phcats'];
$ytcats = $_REQUEST['ytcats'];
$redtubecats = $_REQUEST['redtubecats'];
$postauthor = $_REQUEST['author'];
$grab_comments = $_REQUEST['grab_comments'];
$ytlang = $_REQUEST['ytlang'];
$dm_orderby = $_REQUEST['dm_orderby'];
$dm_lang = $_REQUEST['dm_lang'];
$keepsettings = $_REQUEST['keepsettings'];
$hulucats = $_REQUEST['hulucats'];
$hulu_vidtype = $_REQUEST['hulu_vidtype'];
$hulu_orderby = $_REQUEST['hulu_orderby'];
$megaporncats = $_REQUEST['megaporncats'];
$megavideocats = $_REQUEST['megavideocats'];
if($grab_comments == "no"){
$max_comments = "0";
} else {
$max_comments = $_REQUEST['max_comments'];
}
$aprove_comments = $_REQUEST['aprove_comments'];
if($ytlang == "any") {
$bylang = "";
} else {
$bylang = "&lr=".$ytlang."";
}
if ($feedsource == "youtube") {
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, scheduletime, grab_comments, max_comments, aprove_comments) VALUES ('', '$usefeed', '$feedcategory', 'yes', '$maxvideos', '$poststatus', '$sunday', '$monday', '$tuesday', '$wednesday', '$thursday', '$friday', '$saturday', '$commentstatus', '$pingstatus', '$blocktags', '$checktitle', '$checkdesc', '$checktags', '$postauthor', '$scheduletime', '$grab_comments', '$max_comments', '$aprove_comments')");
echo "<br><center><font color=green>Video Source Added!</font></center>";
}
}
?>
<form action="admin.php?page=zvf_Add_New_Feed" method="post" name="myform">
<input type="hidden" name="action" value="savefeed">
<table class="widefat" style="border-width:0px;border-style:solid;border-spacing:0;width:100%;clear:both;margin:0;-moz-border-radius:0px;-khtml-border-radius:0px;-webkit-border-radius:0px;border-radius:0px;background-color:#F9F9F9"><tr><td valign="top" style="border-bottom-width:0px;">
<table class="widefat" cellspacing="0">
<thead>
<th>
Video Source
</th>
</thead>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;">
<table width="100%" cellspacing="0" style="border-bottom-width:0px;">
<tr><td style="border-bottom-width:0px;">
<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>
</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">Keywords</option>
<option value="byuser">Username</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="en">English</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="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>
</td></tr>
</table>
<table width="100%" cellspacing="0" style="border-bottom-width:0px;">
<tr><td style="border-bottom-width:0px;">
<div id="keydiv" style="float:left;display:block;padding-right:3px">
<div><b>Keywords:</b> (Separated by comma.)</div>
<div>
<input type="text" name="feedkeywords" value="<?php if(($keepsettings) AND ($_REQUEST['feedkeywords'])){echo $_REQUEST['feedkeywords'];} else{echo "example,tag,tag";}?>" size="35">
</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="channel/user" size="35">
</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="3" size="2" value="<?php if(($keepsettings) AND ($_REQUEST['maxvideos'])){echo $_REQUEST['maxvideos'];} else{echo "20";}?>">
</div>
</div>
</td></tr>
</table>
<div id="clicksf" style="display:block";padding-right:3px";>
<br>
</div>
</div>
</div>
<?php
if(($keepsettings) AND ($_REQUEST['feedurl'])) {
echo "<div id=\"showsf\" style=\"display:block\";>";
} else {
echo "<div id=\"showsf\" style=\"display:none\";>";
}
?>
<table cellspacing="1" cellpadding="2" bgcolor="#C6D9E9" style="border-bottom-width:0px;">
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Specific Feed/Page URL:</td></tr>
<tr><td bgcolor="#e3e3e3" style="border-bottom-width:0px;">
<input type="text" name="feedurl" size="50" value="<?php if(($keepsettings) AND ($_REQUEST['feedurl'])){echo $_REQUEST['feedurl'];} else{echo "";}?>">
</td></tr>
</table><br>
</div>
</td></tr></table>
<br>
<table class="widefat" cellspacing="0">
<thead>
<th>
Post Options
</th>
</thead>
<tr><td style="border-bottom-width:0px;">
<table cellspacing="4" cellpadding="4" bgcolor="#C6D9E9" style="border-bottom-width:0px;">
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Publish Status:</b></td>
<td bgcolor="#e3e3e3" style="border-bottom-width:0px;">
<input value="publish" type="radio" name="poststatus" onClick="hideschedule();" <?php if(($keepsettings) AND ($_REQUEST['poststatus'] == "publish")){echo "checked";} else if(!$keepsettings){echo "checked";}?>>Publish
<input value="pending" type="radio" name="poststatus" onClick="hideschedule();" <?php if(($keepsettings) AND ($_REQUEST['poststatus'] == "pending")){echo "checked";}?>>Pending
<input value="draft" type="radio" name="poststatus" onClick="hideschedule();" <?php if(($keepsettings) AND ($_REQUEST['poststatus'] == "draft")){echo "checked";}?>>Draft
<input value="future" type="radio" name="poststatus" onClick="showschedule();" <?php if(($keepsettings) AND ($_REQUEST['poststatus'] == "future")){echo "checked";}?>>Schedule
<input value="private" type="radio" name="poststatus" onClick="hideschedule();" <?php if(($keepsettings) AND ($_REQUEST['poststatus'] == "private")){echo "checked";}?>>Private
<?php
if (($keepsettings) AND ($_REQUEST['poststatus'] == "future")) {
echo "<div id=\"schedulediv\" style=\"float:left;display:block;padding-right:3px\">";
} else {
echo "<div id=\"schedulediv\" style=\"float:left;display:none;padding-right:3px\">";
}
?>
Interval between each post: <input type="text" name="scheduletime" value="<?php if(($keepsettings) AND ($_REQUEST['scheduletime'])){echo $_REQUEST['scheduletime'];}?>" size="3" maxlength="10"> Seconds<br>
300 = 5 minutes, 3600 = 1 hour
</div>
</td></tr>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Allow Comments:</b></td>
<td bgcolor="#e3e3e3" style="border-bottom-width:0px;"><input value="open" type="radio" name="commentstatus" <?php if(($keepsettings) AND ($_REQUEST['commentstatus'] == "open")){echo "checked";} else if(!$keepsettings){echo "checked";}?>>Yes
<input value="closed" type="radio" name="commentstatus" <?php if(($keepsettings) AND ($_REQUEST['commentstatus'] == "closed")){echo "checked";}?>>No
</td></tr>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Allow Pings:</td>
<td bgcolor="#e3e3e3" style="border-bottom-width:0px;">
<input value="open" type="radio" name="pingstatus" <?php if(($keepsettings) AND ($_REQUEST['pingstatus'] == "open")){echo "checked";} else if(!$keepsettings){echo "checked";}?>>Yes
<input value="closed" type="radio" name="pingstatus" <?php if(($keepsettings) AND ($_REQUEST['pingstatus'] == "closed")){echo "checked";}?>>No
</td></tr>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Post Author:</td>
<td bgcolor="#e3e3e3" style="border-bottom-width:0px;">
<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;
if(($keepsettings) AND ($_REQUEST['author'] == $author_id)){
echo "<option value=\"$author_id\" selected>$author_name</option>";
} else {
echo "<option value=\"$author_id\">$author_name</option>";
}
}
?>
</select>
</td></tr>
<div id="comments_div" style="display:block;">
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Grab YouTube comments?</b></td>
<td bgcolor="#e3e3e3" style="border-bottom-width:0px;"><input value="yes" type="radio" name="grab_comments" <?php if(($keepsettings) AND ($_REQUEST['grab_comments'] == "yes")){echo "checked";}?>>Yes
<input value="no" type="radio" name="grab_comments" <?php if(($keepsettings) AND ($_REQUEST['grab_comments'] == "no")){echo "checked";} else if(!$keepsettings){echo "checked";}?>>No
</td></tr>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Max comments per video:</b></td>
<td bgcolor="#e3e3e3" style="border-bottom-width:0px;">
<input style="font-size:10px;" type="text" name="max_comments" maxlength="2" size="2" value="<?php if(($keepsettings) AND ($_REQUEST['max_comments'])){echo $_REQUEST['max_comments'];} else {echo "20";}?>">
</td></tr>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;"><b>Auto aprove these comments?</td>
<td bgcolor="#e3e3e3" style="border-bottom-width:0px;">
<input value="yes" type="radio" name="aprove_comments" <?php if(($keepsettings) AND ($_REQUEST['aprove_comments'] == "yes")){echo "checked";} else if(!$keepsettings){echo "checked";}?>>Yes
<input value="no" type="radio" name="aprove_comments" <?php if(($keepsettings) AND ($_REQUEST['aprove_comments'] == "no")){echo "checked";}?>>No
</td></tr>
</table>
</div>
</td></tr></table>
</td><td width="200" valign="top" style="border-bottom-width:0px;">
<table class="widefat" cellspacing="0">
<thead>
<th>
Days to Update
</th>
</thead>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;">
<input value="everyday" type="checkbox" name="days[]" onClick="Check(this)"><b>Everyday</b>
<br><input value="sunday" type="checkbox" name="days[]" <?php if(($keepsettings) AND ($sunday == "yes")){echo "checked";}?>>Sunday
<br><input value="monday" type="checkbox" name="days[]" <?php if(($keepsettings) AND ($monday == "yes")){echo "checked";}?>>Monday
<br><input value="tuesday" type="checkbox" name="days[]" <?php if(($keepsettings) AND ($tuesday == "yes")){echo "checked";}?>>Tuesday
<br><input value="wednesday" type="checkbox" name="days[]" <?php if(($keepsettings) AND ($wednesday == "yes")){echo "checked";}?>>Wednesday
<br><input value="thursday" type="checkbox" name="days[]" <?php if(($keepsettings) AND ($thursday == "yes")){echo "checked";}?>>Thursday
<br><input value="friday" type="checkbox" name="days[]" <?php if(($keepsettings) AND ($friday == "yes")){echo "checked";}?>>Friday
<br><input value="saturday" type="checkbox" name="days[]" <?php if(($keepsettings) AND ($saturday == "yes")){echo "checked";}?>>Saturday
</td></tr>
</table><br>
<table class="widefat" cellspacing="0">
<thead>
<th>
Categories
</th>
</thead>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;">
<table width="100%" cellspacing="0">
<?php
$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(($keepsettings) AND ($_REQUEST['feedcategory'])) {
foreach ($_REQUEST['feedcategory'] as $thecategory) {
if($taxocat_id == $thecategory) {
$waschecked = 1;
echo "<tr><td style=\"border-bottom-width:0px;\"><input value=\"$taxocat_id\" type=\"checkbox\" name=\"feedcategory[]\" checked>$showcat_name</td></tr>";
}
}
} else if((!$keepsettings) AND ($_REQUEST['feedcategory'])) {
if($taxocat_id == $_REQUEST['feedcategory']) {
$waschecked = 1;
echo "<tr><td style=\"border-bottom-width:0px;\"><input value=\"$taxocat_id\" type=\"checkbox\" name=\"feedcategory[]\" checked>$showcat_name</td></tr>";
}
}
if ($waschecked == "1") {
$waschecked = 0;
continue;
}
echo "<tr><td style=\"border-bottom-width:0px;\"><input value=\"$taxocat_id\" type=\"checkbox\" name=\"feedcategory[]\">$showcat_name</td></tr>";
}
?>
</table>
</td></tr></table>
<br>
<table class="widefat" cellspacing="0">
<thead>
<th>
Finalize
</th>
</thead>
<tr><td bgcolor="#f3f3f3" style="border-bottom-width:0px;">
<table width="100%" cellspacing="0">
<br><center>
<input value="ks_yes" type="checkbox" name="keepsettings" <?php if($keepsettings){echo "checked";}?>> Save As Default<br><br>
<input type="submit" name="submit" class="button-primary" value="SAVE SOURCE">
</center>
</form>
<br>
</td></tr></table>
</td></tr></table>
<?php
VideoFly_showfooter();
?>