HELP PLEASE: Can I remove the dates from my blog comments like this?
I'm using a plugin called myVideoPoster that pulls Youtube videos from whatever Youtube channel I specify and creates individual posts for each video on my site. It also pulls the comments from Youtube. Great. The problem is that it puts the dates of the comments and I want to remove those dates.
I already went through my theme editor and replaced this:
<?php the_time('F jS, Y') ?>
<!-- <?php the_time('F jS, Y') ?> -->
Below is the code for the myVideoPoster plugin. Could some smart Warrior please show me what to do to modify the code below to NOT include the comment dates its pulling off of Youtube. I'm not a techie but can follow directions if they are in simple English.
Thanks
Steve
Here is the code from myvideoposter/myvideoposter.php
<?php /* Plugin Name: my Video Poster Plugin Script: myvideoposter.php Plugin URI: http://www.cleverplugins.com Description: Automatically post videos on your blog. Version: 1.9.9.2 Author: myWordPress.com Author URI: http://www.cleverplugins.com Min WP Version: 2.7 Max WP Version: 2.9.4 Update Server: http://www.cleverplugins.com == Changelog == = 1.9.9.2 = * NEW: Added a "Delete log" button to clear the log if user wishes it. = 1.9.9.1 = * Bugfix: Problem with duplicate posts persisted = 1.9.9 = * NEW: Now set up individual categories for EACH FEED! * NEW: Excerpt is cropped, no more super-long excerpts! * NEW: When doing a manual run, you can see the time spent by the CRON * Bugfix: Some servers had errors reading and saving images. * Bugfix: Check for embedding failed after previous update (1.9.8) = 1.9.8 = * Fix for duplicate posts. Some specific server settings could result in mayhem duplicate postings! * Automatic Database Update. You will see a warning that the database has been updated automatically. * Posting log. See which videos have been updated. With a link to the post and the direct Youtube url. * Quick Statistics. See a quick overview of when the first video was posted, when the latest video was posted, and how many in total. = 1.9.7 = * Now WordPress MU compatible! * Attemps to trim the default RSS output data, "From: * Views:* Ratings: More in *". * Cleaned up the Settings Page with better explanations and examples. * Seperation of "Niche Researcher" from the Settings. * Now checks up the latest 50 videos from the RSS feed (Maximum setting from Youtube). = 1.9.6 = * FIX: The problem with some blogs not automatically posting. * FIX: Reduced memory usage. = 1.9.5 = * NEW: Comments are now checked for moderation before publishing. * NEW: Notification added to the settings page if the WordPress options are not properly set for comment posting. * FIX: Bug introduced with WordPress 2.8.3 : Posts not publishing properly. * FIX: Tag limitation for tags is now working properly. * NEW: Video Width and Height can now be set in the settings page. * NEW: Publishing a post now triggers hooks associated, such as pinging, XML Sitemap, etc. Depending on which plugins are installed. = 1.9 = * NEW: Built in Niche Researcher. = 1.8.5 = * FIX: Duplicate post bug reappeared and is fixed. = 1.8 = * Interface text changes * Now runs through all RSS feeds untill the target of target posts have been hit, or run out of content to post. = 1.7 = * Checks if embedding is disabled before posting (optional) */ /* Copyright 2009 myWordPress.com (email : contact@mywordpress.com) This plugin locates videos, and creates posts with the embedded code directly on your blog! A small javascript code is used from the FeedStats plugin (by Andrés Nieto), http://bueltge.de/wp-feedstats-de-plugin/171/ */ // ### No direct access to the plugin outside Wordpress if (preg_match('#'.basename(__FILE__) .'#', $_SERVER['PHP_SELF'])) { die('Direct access to this file is not allowed!'); } // ### Simple CURL function to download the central file... function myvideoposter_downloadurl($Url){ if (!function_exists('curl_init')){ die('CURL is not installed!');} $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); return $output; } //### Function strips http:// or https:// function myvideoposter_remove_http($url = ''){ if ($url == 'http://' OR $url == 'https://') { return $url; } $matches = substr($url, 0, 7); if ($matches=='http://') { $url = substr($url, 7); } else { $matches = substr($url, 0, 8); if ($matches=='https://') $url = substr($url, 8); } return $url; } // ### Returns a truncated string based on the parameters function myvideoposter_truncatestring($string, $del) { $len = strlen($string); if ($len > $del) { $new = substr($string,0,$del)."..."; return $new; } else return $string; } // ### Checks for presence of the curl extension. function myvideoposter_iscurlinstalled() { if (in_array ('curl', get_loaded_extensions())) { return true; } else{ return false; } } // ### Returns keywords from Yahoo API based on $content and $subject // ### Returns an array function myvideoposter_returnkeywords($content,$subject) { $response=''; $content=strip_tags($content); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array('appid'=>'myVideoPoster','context'=>$content,'query'=>$subject,'output'=>'php')); $response = curl_exec($ch); $phparray = unserialize($response); curl_close($ch); unset($ch); unset($response); unset($content); return $phparray; } // ### Function returns number of minutes to human understandable format // Reference: http://techjunk.websewak.com/function-to-convert-minutes-to-hours-minutes-format-in-php/ function myvideoposter_to_hour_string($MM) { $Hour=floor($MM/60); $Min=($MM%60); If($Hour>0) { $str = $Hour." hour"; if ($Hour > 1) $str .= "s"; if ($Min > 0) $str .= " ".$Min." minute"; if ($Min > 1) $str .= "s"; } else if ($Min > 0) { $str = " ".$Min." minute"; if ($Min > 1) $str .= "s"; } else { $str = "-"; } return $str; } // ### Base installation function for myVideoPoster function myvideoposter_install () { global $wpdb; // Setting default settings update_option('myvideoposter_postembed','1'); update_option('myvideoposter_postthumbnail','1'); update_option('myvideoposter_createtags','1'); update_option('myvideoposter_limittags','Unlimited'); unset($wpdb); } //Function courtesy Dorphalsig at http://es2.php.net/array_unique function myvideoposter_arrayunique($myArray) { if(!is_array($myArray)) return $myArray; foreach ($myArray as &$myvalue){ $myvalue=serialize($myvalue); } $myArray=array_unique($myArray); foreach ($myArray as &$myvalue){ $myvalue=unserialize($myvalue); } unset($myvalue); return $myArray; } // ### Function returns RSS feeds for Youtube based on a keyword/phrase // Used by "Niche Research"... function myvideoposter_nicheresearch($keyword) { $result=''; $url = "http://www.youtube.com/results?search_type=search_users&search_query=".urlencode($keyword); $file = wp_remote_fopen($url); preg_match_all("/a class=\"hLink\" href=\"\/user\/(.*?)\"/",$file,$match); $resultarray=array(); $resultarray=$match[1]; $resultarray=myvideoposter_arrayunique($resultarray); foreach($resultarray as $v) { $result .= "http://gdata.youtube.com/feeds/base/users/$v/uploads<br>"; } return $result; } // ### Function runs and converts the old format (a textarea containing feeds) to the new (database rows) format. function myvideoposter_convertfeedstonewformat() { global $wpdb, $wp_version,$wp_locale,$current_blog; $blog_id = $current_blog->blog_id; $table_feeds_name = $wpdb->prefix . "myvideoposter_feeds"; $rsslist=get_option('myvideoposter_keywords'); $rssarray = explode("\n", $rsslist); $rssarray=myvideoposter_remove_array_empty_values($rssarray,true); $rssfeedcount=count($rssarray); // total rss feeds in rss array $myvideoposter_category = get_option('myvideoposter_category'); for ( $counter = 0; $counter <= $rssfeedcount; $counter++) { $rssurl=$rssarray[$counter]; $query = "INSERT INTO `$table_feeds_name` (active,id,rssurl,type,targetcategory) VALUES ( '1', '', '".mysql_real_escape_string($rssurl)."', 'Youtube', '$myvideoposter_category' )"; if ($rssurl<>'') { $success = mysql_query($query); } } } // ### The Admin options/settings screen function myvideoposter_admin_options(){ global $wpdb, $wp_version,$wp_locale,$current_blog; $table_name = $wpdb->prefix . "myvideoposter"; $blog_id = $current_blog->blog_id; $table_log_name = $wpdb->prefix . "myvideoposter_log"; $table_feeds_name = $wpdb->prefix . "myvideoposter_feeds"; $blogurl=myvideoposter_remove_http(get_bloginfo('url')); $baseurl=WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/'; //---------------------------------------------- //SAVE RSS FEEDS //---------------------------------------------- if ( ($_POST['action'] == 'saverssfeeds') && $_POST['myvideoposter_rssfeeds'] ) { $savingrss=TRUE; $nonce=$_POST['_myvideoposternonce']; if (! wp_verify_nonce($nonce, 'myvideoposter') ) die("Failed security check"); if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { $postcount=count($_POST['myvideoposter_rssurl']); foreach ($_POST['myvideoposter_rssid'] as &$value) { $rssid=$_POST['myvideoposter_rssid'][$value]; //Let's get the RSS id... $rssfeed=$_POST['myvideoposter_rssurl'][$rssid]; $rsstype=$_POST['myvideoposter_rsstype'][$rssid]; $rssdelete=$_POST['myvideoposter_rssdelete'][$rssid]; $rsscategory=$_POST['myvideoposter_rsscategory'][$rssid]; $query = "REPLACE INTO `$table_feeds_name` SET `active` = '1', `id` = '$rssid', `rssurl` = '".mysql_real_escape_string($rssfeed)."', `type` = '$rsstype', `targetcategory` = '$rsscategory';"; if ($rssdelete<>'') { $query="DELETE FROM `$table_feeds_name` WHERE `id` = '$rssid' LIMIT 1;"; $success = mysql_query($query); $rssfeed=''; //setting it to '' just so we do not run the update query as well.. kindda stupid, eh? :-) } if ($rssfeed<>'') { $success = mysql_query($query); } } $postnowresult = "RSS Source Feeds Settings saved"; if ($postnowresult<>'') echo '<div class="updated fade"><p>' . $postnowresult. '</p></div>'; } } //---------------------------------------------- //POST VIDEO NOW //---------------------------------------------- if ( ($_POST['action'] == 'postvideonow') && $_POST['myvideoposter_research'] ) { $nonce=$_POST['_myvideoposternonce']; $myvideoposter_postvideonow=$_POST['myvideoposter_postvideonow']; if (! wp_verify_nonce($nonce, 'myvideoposter') ) die("Failed security check"); if ( function_exists('current_user_can') && current_user_can('edit_plugins') && ($myvideoposter_postvideonow<>'')) { //$postnowresult=myvideoposter_cron($videourl); $postnowresult = "<strong>Post Video Now</strong> found the following RSS feeds. <br><em>(You should verify their content before copy-pasting to the list of RSS feeds in the settings.)</em><br><br>$myvideoposterresearchlist"; if ($postnowresult<>'') echo '<div class="updated fade"><p>' . $postnowresult. '</p></div>'; } } //---------------------------------------------- //POST NOW //---------------------------------------------- if ( ($_POST['action'] == 'postnow') && $_POST['myvideoposter_postnow'] ) { $nonce=$_POST['_myvideoposternonce']; if (! wp_verify_nonce($nonce, 'myvideoposter') ) die("Failed security check"); if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { $lastcron=get_option('myvideoposter_last_cron'); update_option('myvideoposter_last_cron', ''); $notes=myvideoposter_cron(); //echo $notes."<hr>"; update_option('myvideoposter_last_cron', $lastcron); if ($notes<>'') echo '<div class="updated fade"><p>' . $notes. '</p></div>'; $savingsettings=TRUE; //We set it to true, so the tab will stay open... } } //---------------------------------------------- //CLEAR POSTING LOG //---------------------------------------------- if ( ($_POST['action'] == 'clearlog') && $_POST['myvideoposter_clearlog'] ) { $nonce=$_POST['_myvideoposternonce']; if (! wp_verify_nonce($nonce, 'myvideoposter') ) die("Failed security check"); if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { $wpdb->query ("TRUNCATE `$table_log_name`;"); $notes = "The posting log was emptied."; if ($notes<>'') echo '<div class="updated fade"><p>' . $notes. '</p></div>'; } } //---------------------------------------------- //NICHE RESEARCH //---------------------------------------------- if ( ($_POST['action'] == 'research') && $_POST['myvideoposter_research'] ) { $nonce=$_POST['_myvideoposternonce']; $myvideoposterresearchlist=$_POST['myvideoposter_nichekeyword']; $researchkeyword=$_POST['myvideoposter_nichekeyword']; $myvideoposterresearchlist= myvideoposter_nicheresearch($researchkeyword); if (! wp_verify_nonce($nonce, 'myvideoposter') ) die("Failed security check"); if ( function_exists('current_user_can') && current_user_can('edit_plugins') && ($myvideoposterresearchlist<>'')) { $myvideoposterresearchlist = "<strong>Niche Research</strong> found the following RSS feeds. <br><em>(You should verify their content before copy-pasting to the list of RSS feeds in the settings.)</em><br><br>$myvideoposterresearchlist"; if ($myvideoposterresearchlist<>'') echo '<div class="updated fade"><p>' . $myvideoposterresearchlist. '</p></div>'; } } //---------------------------------------------- //Saving settings //---------------------------------------------- if ( ($_POST['action'] == 'insert') && $_POST['myvideoposter_save'] ) { $savingsettings=TRUE; $nonce=$_POST['_myvideoposternonce']; if (! wp_verify_nonce($nonce, 'myvideoposter') ) die("Failed security check"); if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { update_option('myvideoposter_videowidth',$_POST['myvideoposter_videowidth']); update_option('myvideoposter_videoheight',$_POST['myvideoposter_videoheight']); update_option('myvideoposter_checkfordisabledembedding',$_POST['myvideoposter_checkfordisabledembedding']); update_option('myvideoposter_poststatus',$_POST['myvideoposter_poststatus']); update_option('myvideoposter_isactive',$_POST['myvideoposter_isactive']); update_option('myvideoposter_posteruserid',$_POST['myvideoposter_posteruserid']); update_option('myvideoposter_addcustommetadata',$_POST['myvideoposter_addcustommetadata']); update_option('myvideoposter_custommetadataname',$_POST['myvideoposter_custommetadataname']); update_option('myvideoposter_addcustommetadatavideo',$_POST['myvideoposter_addcustommetadatavideo']); update_option('myvideoposter_custommetadatanamevideo',$_POST['myvideoposter_custommetadatanamevideo']); update_option('myvideoposter_postthumbnail',$_POST['myvideoposter_postthumbnail']); update_option('myvideoposter_postembed',$_POST['myvideoposter_postembed']); update_option('myvideoposter_createtags',$_POST['myvideoposter_createtags']); update_option('myvideoposter_limittags',$_POST['myvideoposter_limittags']); $temp= intval($_POST['myvideoposter_numberofposts']); if (is_int($temp)){ update_option('myvideoposter_numberofposts',$temp); } $temp= intval($_POST['myvideoposter_crondelay']); if (is_int($temp)){ update_option('myvideoposter_crondelay',$temp); } update_option('myvideoposter_postcomments',$_POST['myvideoposter_postcomments']); echo '<div class="updated fade"><p>' . __('The options have been saved!', 'myvideoposter') . '</p></div>'; } else { wp_die('<p>'.__('You do not have sufficient permissions.').'</p>'); } } $errormsg=''; //Loading settings... $myvideoposter_videowidth = get_option('myvideoposter_videowidth'); $myvideoposter_videoheight = get_option('myvideoposter_videoheight'); if ($myvideoposter_videowidth=='') update_option('myvideoposter_videowidth','560'); //default width if ($myvideoposter_videoheight=='') update_option('myvideoposter_videoheight','340'); //default width $myvideoposter_checkfordisabledembedding = get_option('myvideoposter_checkfordisabledembedding'); $myvideoposter_addcustommetadata = get_option('myvideoposter_addcustommetadata'); $myvideoposter_custommetadataname = get_option('myvideoposter_custommetadataname'); $myvideoposter_addcustommetadatavideo = get_option('myvideoposter_addcustommetadatavideo'); $myvideoposter_custommetadatanamevideo = get_option('myvideoposter_custommetadatanamevideo'); $myvideoposter_postthumbnail = get_option('myvideoposter_postthumbnail'); $myvideoposter_postembed = get_option('myvideoposter_postembed'); $myvideoposter_createtags = get_option('myvideoposter_createtags'); $myvideoposter_limittags = get_option('myvideoposter_limittags'); $myvideoposter_poststatus = get_option('myvideoposter_poststatus'); $myvideoposter_isactive= get_option('myvideoposter_isactive'); if (!$myvideoposter_isactive<>'') $errormsg .= '- myVideoPoster is NOT activated<br>'; $myvideoposter_postcomments= get_option('myvideoposter_postcomments'); $myvideoposter_numberofposts= get_option('myvideoposter_numberofposts'); if (!$myvideoposter_numberofposts<>'') $errormsg .= '- You need to choose how many videos to post!<br>'; $myvideoposter_crondelay= get_option('myvideoposter_crondelay'); if (!$myvideoposter_crondelay<>'') $errormsg .= '- You need to choose how often to post!<br>'; // No longer uses the old rss feed storage structure.. $feedcount= $wpdb->get_var("SELECT COUNT(id) from `$table_feeds_name`"); if (!$feedcount>'0') { $errormsg .= '- You need to enter some RSS feeds from Youtube!<br>'; $savingrss=TRUE; } $myvideoposter_posteruserid = get_option('myvideoposter_posteruserid'); if (!$myvideoposter_posteruserid<>'') $errormsg .= '- You need to set which user to post as!<br>'; $pluginfo=get_plugin_data(__FILE__); $version=$pluginfo['Version']; ?> <div class="wrap"> <h2><?php _e("my Video Poster v.$version", 'myvideoposter'); ?> </h2> <br class="clear" /> <p><em>- A clever WordPress Plugin by <a href="http://mywordpress.com">myWordPress.com</a></em></p> <?php if ($errormsg<>'') { _e("<div id='error'><p class='error'>$errormsg</p></div>"); } ?> <?php if (!myvideoposter_iscurlinstalled()) { _e("<div id='error'><p class='error'>The cUrl PHP extension is <strong>not installed</strong>. Please fix this. Before this is fixed, this plugin will not function properly!</p></div>"); } ?> <?php //myvideoposter_convertfeedstonewformat(); // TEMP!! /* <div id="poststuff" class="ui-sortable"> <div class="postbox closed" > <h3><?php _e('Post Single Video', 'myvideoposter'); ?></h3> <div class="inside"> <form name="form3" method="post" action="<?php echo $location; ?>"> <table summary="myvideoposter niche research" class="form-table"> <?php $nonce= wp_create_nonce('myvideoposter');?> <tr valign="top"> <th scope="row"><?php _e('Post Single Video', 'myvideoposter'); ?></th> <p class="submit"> <input type="hidden" name="_myvideoposternonce" value="<?php echo $nonce; ?>" /> <input type="hidden" name="action" value="postvideonow" /> <td><input name="myvideoposter_postvideonow" value='' type="text" class="regular-text"/> <input class="button-secondary" type="submit" name="myvideoposter_research" value="<?php _e('Post Video Now'); ?> »" /> <br /> <?php _e('<p><em>Enter full URL of the video you want to insert.</em></p>', 'myvideoposter'); ?> <?php _e('<em><p>Currently Only Youtube Videos are supported.<br>', 'myvideoposter'); ?> <?php _e('<em>Example: <strong>http://www.youtube.com/watch?v=dMH0bHeiRNg</strong></em>', 'myvideoposter'); ?> </p></center> </td> </tr> </table> </form> </div> </div> </div> */ ?> <div id="poststuff" class="ui-sortable"> <div class="postbox open" > <h3><?php _e("Quick Statistics", 'myvideoposter') ?></h3> <div class="inside"><p> <?php $total = (int) $wpdb->get_var("SELECT COUNT(youtubeid) FROM $table_log_name;"); $firstdate =date_i18n(get_option('date_format') ,strtotime($wpdb->get_var("SELECT time FROM `$table_log_name` order by `time` asc"))); $lastdate =date_i18n(get_option('date_format') ,strtotime($wpdb->get_var("SELECT time FROM `$table_log_name` order by `time` desc"))); if ($total>0) { echo "I published the first video on $firstdate, and most recently on $lastdate. So far I have published <strong>$total</strong> videos."; } else{ echo "No statistics to display yet."; } ?></p> </div> </div> </div> <?php $foldstatus='closed'; if ($savingrss) $foldstatus='open'; ?> <div id="poststuff" class="ui-sortable"> <div class="postbox <?php echo $foldstatus;?>" > <h3><?php _e('Source Feeds', 'myvideoposter') ?></h3> <div class="inside"> <p> Enter your source RSS Feeds and choose target category.</p> <p><em>(Only Youtube is supported at the moment)</em></p> <form name="rssform" method="post" action="<?php echo $location; ?>"> <?php $nonce= wp_create_nonce('myvideoposter'); $sql="SELECT * FROM `$table_feeds_name` ORDER BY id;"; $rssfeeds = $wpdb->get_results($sql, ARRAY_A); ?> <table class="widefat post" cellspacing="0"> <thead> <tr> <th scope="col wide"><?php _e( 'RSS URL' ); ?></th> <th scope="col"><?php _e( 'Feed Type' ); ?></th> <th scope="col"><?php _e( 'Category' ); ?></th> <th scope="col"><?php _e( 'Delete?' ); ?></th> </tr> </thead> <?php if ($rssfeeds){ foreach ($rssfeeds as $feed) { $category=$feed['targetcategory']; $rssurl=$feed['rssurl']; $number=$feed['id']; echo "<tr>"; echo "<td>"; echo "<input name='myvideoposter_rssid[$number]' value='$number' type='hidden' />"; echo "<input name='myvideoposter_rssurl[$number]' size='69' value='$rssurl' type='text' />"; echo "</td>"; echo "<td>"; ?> <select name="myvideoposter_rsstype[<?php echo $number;?>]" id="<?php echo $feed['id']; ?>" class="postform"> <option class="level-0" value="Youtube">Youtube</option> </select> <?php echo "</td>"; echo "<td>"; wp_dropdown_categories("show_count=0&hierarchical=1&hide_empty=0&orderby=name&selected=$category&name=myvideoposter_rsscategory[$number]"); echo "</td>"; echo "<td>"; echo "<input type='checkbox' name='myvideoposter_rssdelete[$number]' value='delete'>"; echo "</td>"; echo "</tr>"; } } $number++; // Empty row at end of table... echo "<tr><td><input name='myvideoposter_rssurl[$number]' size='69' value='' type='text' /></td><td>"; ?> <select name="myvideoposter_rsstype[<?php echo $number;?>]" id="<?php echo $number; ?>" class="postform"> <option class="level-0" value="Youtube">Youtube</option> </select> <?php echo "</td>"; echo "<td>"; echo "<input name='myvideoposter_rssdelete[$number]' value='' type='hidden' />"; echo "<input name='myvideoposter_rssid[$number]' value='$number' type='hidden' />"; wp_dropdown_categories("show_count=0&hierarchical=1&hide_empty=0&orderby=name&selected=$myvideoposter_category&name=myvideoposter_rsscategory[$number]"); echo "</td><td></td></tr>"; echo "</table>"; ?> <p class="submit"> <input type="hidden" name="_myvideoposternonce" value="<?php echo $nonce; ?>" /> <input type="hidden" name="action" value="saverssfeeds" /> <input class="button-primary" type="submit" name="myvideoposter_rssfeeds" value="<?php _e('SAVE FEEDS!', 'myvideoposter'); ?>" <?php if (!$myvideoposter_isactive<>'') echo "disabled"; ?> /> </p> </form> </div> </div> </div> <?php $foldstatus='closed'; if ($savingsettings) $foldstatus='open'; ?> <div id="poststuff" class="ui-sortable"> <div class="postbox <?php echo $foldstatus;?>" > <h3><?php _e('my Video Poster Settings', 'myvideoposter'); ?></h3> <div class="inside"> <form name="form3" method="post" action="<?php echo $location; ?>"> <?php $nonce= wp_create_nonce('myvideoposter');?> <center> <p class="submit"> <input type="hidden" name="_myvideoposternonce" value="<?php echo $nonce; ?>" /> <input type="hidden" name="action" value="postnow" /> <input class="button" type="submit" name="myvideoposter_postnow" value="<?php _e('MANUAL RUN NOW!', 'myvideoposter'); ?>" <?php if (!$myvideoposter_isactive<>'') echo "disabled"; ?> /> </p></center> </form> <table summary="myvideoposter options" class="form-table"> <form name="form2" method="post" action="<?php echo $location; ?>"> <tr valign="top"> <th scope="row"><?php _e('ACTIVE?', 'myvideoposter'); ?></th> <td><input name="myvideoposter_isactive" value='1' <?php if (get_option('myvideoposter_isactive')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>If checked, myVideoPoster is active and runs automatically.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('', 'myvideoposter'); ?></th> <td> ATTEMPT to post <SELECT name="myvideoposter_numberofposts"> <?php for($x = 1; $x <= 5; $x++) { echo "<OPTION VALUE='$x' "; if ($myvideoposter_numberofposts==$x) echo "selected"; echo ">$x</OPTION>"; } ?> </select> NEW videos every <SELECT name="myvideoposter_crondelay"> <?php for($x = 1; $x <= 22; $x++) { $val=$x*30; echo "<OPTION VALUE='$val' "; if ($myvideoposter_crondelay==$val) echo "selected"; echo ">".myvideoposter_to_hour_string($val)."</OPTION>"; } ?> </select> </td> </tr> <tr valign="top"><th><h4>The Individual Post Settings</h4></th></tr> <tr valign="top"> <th scope="row"><?php _e('Check first if video is disabled', 'myvideoposter'); ?></th> <td><input name="myvideoposter_checkfordisabledembedding" value='1' <?php if (get_option('myvideoposter_checkfordisabledembedding')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>If checked, each video is checked if its allowed to be embedded..<br>(Warning: Can take extra processing time, memory and bandwidth to check).</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Post Status', 'myvideoposter'); ?></th> <td> <SELECT name="myvideoposter_poststatus"> <OPTION VALUE='publish'<?php if ($myvideoposter_poststatus=='publish') echo "selected"; ?>>Publish</OPTION> <OPTION VALUE='Draft'<?php if ($myvideoposter_poststatus=='Draft') echo "selected"; ?>>Draft</OPTION> </select> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Post as user', 'myvideoposter'); ?></th> <td> <?php global $current_user, $user_ID; $authors = get_editable_user_ids( $current_user->id ); ?> <?php wp_dropdown_users( array('include' => $authors, 'name' => 'myvideoposter_posteruserid', 'selected' => empty($myvideoposter_posteruserid) ? $user_ID : $myvideoposter_posteruserid )); ?> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Post Video Width', 'myvideoposter'); ?></th> <td><input name="myvideoposter_videowidth" value='<?php echo $myvideoposter_videowidth; ?>' type="text" /><br /><?php _e('<em>Width for the video.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Post Video Height', 'myvideoposter'); ?></th> <td><input name="myvideoposter_videoheight" value='<?php echo $myvideoposter_videoheight; ?>' type="text" /><br /><?php _e('<em>Height for the video.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"><th><h4>Post Comment Settings</h4></th></tr> <tr valign="top"> <th scope="row"><?php _e('Include Thumbnail in Post', 'myvideoposter'); ?></th> <td><input name="myvideoposter_postthumbnail" value='1' <?php if (get_option('myvideoposter_postthumbnail')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>If you want to put a thumbnail of the video into the post.<br>(This does not refer to the Custom Field option below)</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Include Video in Post', 'myvideoposter'); ?></th> <td><input name="myvideoposter_postembed" value='1' <?php if (get_option('myvideoposter_postembed')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>Turned on by default, you can include the actual video in the post or not. This option is practical if you only want to show the video in a Custom Field.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Create comments', 'myvideoposter'); ?></th> <td><input name="myvideoposter_postcomments" value='1' <?php if (get_option('myvideoposter_postcomments')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>If checked, myVideoPoster also reads the latest comments and posts a random amount of them for each video.</em>', 'myvideoposter'); ?><p><em>All comments will undergo your current comment moderation settings (comment moderation, comment blacklist, etc) but you must turn off the "Comment author must have a previously approved comment" otherwise it will not work.</em></p> <p>Current status: White listing is turned <?php $whitelisstatus=get_option('comment_whitelist'); if ($whitelisstatus==1) echo "<strong>ON</strong> (please <a href='/wp-admin/options-discussion.php'>turn it off</a> if you want to post comments)"; else echo '<strong>OFF</strong> (Good, comments can be posted).'; ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Create Tags', 'myvideoposter'); ?></th> <td><input name="myvideoposter_createtags" value='1' <?php if (get_option('myvideoposter_createtags')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>If checked, myVideoPoster finds relevant tags for each blogpost.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Limit to MAX tags', 'myvideoposter'); ?></th> <td> <SELECT name="myvideoposter_limittags"> <OPTION VALUE='Unlimited'<?php if ($myvideoposter_limittags=='Unlimited') echo "selected"; ?>>Unlimited</OPTION> <?php for($x = 1; $x <= 20; $x++) { echo "<OPTION VALUE='$x' "; if ($myvideoposter_limittags==$x) echo "selected"; echo ">$x</OPTION>"; } ?> </select> </td> </tr> <tr valign="top"><th><h4>Thumbnail URL to Custom Field</h4></th></tr> <tr valign="top"> <th scope="row"><?php _e('Add Thumbnail Url', 'myvideoposter'); ?></th> <td><input name="myvideoposter_addcustommetadata" value='1' <?php if (get_option('myvideoposter_addcustommetadata')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>Name of the Custom Field for the thumbnail URL.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Name of Custom Field', 'myvideoposter'); ?></th> <td><input name="myvideoposter_custommetadataname" value='<?php echo $myvideoposter_custommetadataname; ?>' type="text" /><br /><?php _e('<em>Name of the Custom Field for the thumbnail-url.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"><th><h4>Embed Code to Custom Field</h4></th></tr> <tr valign="top"> <th scope="row"><?php _e('Add Embed Code', 'myvideoposter'); ?></th> <td><input name="myvideoposter_addcustommetadatavideo" value='1' <?php if (get_option('myvideoposter_addcustommetadatavideo')=='1') { echo "checked='checked'"; } ?> type="checkbox" /><br /><?php _e('<em>Name of the Custom Field for the embed code.</em>', 'myvideoposter'); ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Name of Custom Field', 'myvideoposter'); ?></th> <td><input name="myvideoposter_custommetadatanamevideo" value='<?php echo $myvideoposter_custommetadatanamevideo; ?>' type="text" /><br /><?php _e('<em>If checked, each post will get an assigned Custom Field with the embed code for the video.</em>', 'myvideoposter'); ?></td> </tr> </table> <?php $nonce= wp_create_nonce('myvideoposter');?> <p class="submit"> <input type="hidden" name="_myvideoposternonce" value="<?php echo $nonce; ?>" /> <input type="hidden" name="action" value="insert" /> <input class="button-primary" type="submit" name="myvideoposter_save" value="<?php _e('Save Settings'); ?> »" /> </p> </form> </div> </div> </div> <div id="poststuff" class="ui-sortable"> <div class="postbox closed" > <h3><?php _e('Niche Researcher', 'myvideoposter'); ?></h3> <div class="inside"> <form name="form3" method="post" action="<?php echo $location; ?>"> <table summary="myvideoposter niche research" class="form-table"> <?php $nonce= wp_create_nonce('myvideoposter');?> <tr valign="top"> <th scope="row"><?php _e('Niche Researcher', 'myvideoposter'); ?></th> <p class="submit"> <input type="hidden" name="_myvideoposternonce" value="<?php echo $nonce; ?>" /> <input type="hidden" name="action" value="research" /> <td><input name="myvideoposter_nichekeyword" value='' type="text" /> <input class="button-secondary" type="submit" name="myvideoposter_research" value="<?php _e('Find channels'); ?> »" /> <br /> <?php _e('<em>Enter a keyword/phrase, and get a list of channel rss feeds for that niche.</em>', 'myvideoposter'); ?> </p></center> </td> </tr> </table> </form> </div> </div> </div> <div id="poststuff" class="ui-sortable"> <div class="postbox closed" > <?php $time= gmdate("H:i:s", time()); ?> <h3><?php _e("Posting log (Last 50)", 'myvideoposter') ?></h3> <div class="inside"><p> <?php $query = "SELECT * FROM `$table_log_name` order by `time` DESC limit 15".$options['limit']; $posthits = $wpdb->get_results($query, ARRAY_A); if ($posthits){ echo '<table class="widefat post" cellspacing="0">'; echo '<tr><td><strong>Date</td><td><strong>Youtube ID</strong></td><td><strong>Postid</strong></td><td><strong>Title</strong></td></tr>'; foreach ($posthits as $hits) { echo "<tr><td>".$hits['time']."</td><td><a href='http://www.youtube.com/watch?v=".$hits['youtubeid']."' target='_blank'>".$hits['youtubeid']."</a></td><td><a href='".get_permalink($hits['postid'])."' target='_blank'>".$hits['postid']."</a></td><td>".get_the_title($hits['postid'])."</td></tr>"; } echo "</table>"; ?> <form name="form4" method="post" action="<?php echo $location; ?>"> <?php $nonce= wp_create_nonce('myvideoposter');?> <center> <p class="submit"> <input type="hidden" name="_myvideoposternonce" value="<?php echo $nonce; ?>" /> <input type="hidden" name="action" value="clearlog" /> <input class="button" class="button-primary" type="submit" name="myvideoposter_clearlog" value="<?php _e('CLEAR POSTING LOG!', 'myvideoposter'); ?>" <?php if (!$myvideoposter_isactive<>'') echo "disabled"; ?> /> </p></center> </form> <?php } ?></p> </div> </div> </div> <div id="poststuff" class="ui-sortable"> <div class="postbox open" > <h3><?php _e('myVideoPoster Credits', 'myvideoposter') ?></h3> <div class="inside"> <?php $baseurl=WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/mywordpresssm.jpg'; ?> <p><?php _e('This Plugin was created by', 'myvideoposter'); ?></p> <p><?php _e("<a href='http://cleverplugins.com' target='_blank'><img src='$baseurl' border=0></a>", 'myvideoposter'); ?></p> </div> </div> </div> <script type="text/javascript"> <!-- <?php if ( version_compare( $wp_version, '2.6.999', '<' ) ) { ?> jQuery('.postbox h3').prepend('<a class="togbox">+</a> '); <?php } ?> jQuery('.postbox h3').click( function() { jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); } ); jQuery('.postbox.close-me').each(function(){ jQuery(this).addClass("closed"); }); //--> </script> </div> <?php } // ### Returns true if the youtube video has already been posted. function myvideoposter_alreadyposted($youtubeid){ global $wpdb,$current_blog; $table_log_name = $wpdb->prefix . "myvideoposter_log"; $query = "SELECT * FROM `$table_log_name` where `youtubeid`='$youtubeid' limit 1;"; $posthits = $wpdb->get_results($query, ARRAY_A); if (!isset($posthits)) return false; if (count($posthits)>0) return true; if ($posthits){ return false; } else { return true; } } // ### Checks and verifies if the video is allowed to embed somewhere else... function myvideoposter_embeddingallowed($vidid){ if (!$vidid<>'') return false; $theurl="http://www.youtube.com/watch?v=$vidid"; $thepage=wp_remote_fopen($theurl); // $thepage=strip_tags($thepage); // If stripping tags, the code is not always found.. $pos=strpos($thepage,'Embedding disabled'); unset($thepage); unset($theurl); if ($pos === false) { return true; } else { return false; } } // ### Adding the admin menu to the WP-Admin interface function myvideoposter_admin_menu() { if (function_exists('add_submenu_page')) { add_options_page('my Video Poster', 'my Video Poster', 8, basename(__FILE__), 'myvideoposter_admin_options'); } } //$youtubeid : unique ID to read comments from //$posturl : the post id to post to... function myvideoposter_readandpostcomments($youtubeid,$posturl) { $numcomments=0; if (!$posturl<>'') return; //Missing necessary parameter if (!$youtubeid<>'') return; //Missing necessary parameter if (get_option('comment_whitelist')==1) return; // No comments are gonna be verified, no need to run at all! $blogurl=get_bloginfo('url'); $randnum=rand(1,19); $commentsurl = "http://gdata.youtube.com/feeds/api/videos/".$youtubeid."/comments?v=2&max-results=".$randnum."&alt=rss"; $time = current_time('mysql', $gmt = 0); $feed = @fetch_rss($commentsurl); // specify feed url $items = @array_slice($feed->items, 0, $randnum); if (function_exists('wpmu_create_blog')) $wpmu=true; if (!empty($items)) : foreach ($items as $item) : $description = $item['description']; $author = $item['author']; $commenttime= strftime("%Y-%m-%d %H:%M:%S", strtotime($item['pubdate'])); $data = array( 'comment_post_ID' => $posturl, 'comment_author' => $author, 'comment_author_email' => '', 'comment_author_url' => $blogurl, 'comment_content' => $description, 'comment_type' => 'comment', 'comment_parent' => 0, 'user_ID' => '0', 'comment_author_IP' => '127.0.0.1', 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', 'comment_date' => $commenttime, 'comment_date_gmt' => $commenttime, 'comment_approved' => 1, ); $verify=''; $verify=check_comment($author, 'no@none.com', $blogurl, $description, '', '', 'comment'); if ($verify==true) { wp_insert_comment($data); $numcomments++; } else { //Debug: Comment failed moderation check for some reason... } endforeach; endif; unset($data); unset($verify); unset($feed); unset($items); return $numcomments; } function myvideoposter_trimstopwords($content) { $stop_words= array("&","a","ii","about","above","according","across","39","actually","ad","adj","ae","af","after","afterwards", "ag","again","against","ai","al","all","almost","alone","along","already","also","although","always","am","among","amongst","an","and","another","any","anyhow","anyone","anything","anywhere","ao","aq","ar","are","aren","aren't","around","arpa","as","at","au","aw","az","b","ba","bb","bd","be","became","because","become","becomes","becoming","been","before","beforehand","begin","beginning","behind","being","below","beside","besides","between","beyond","bf","bg","bh","bi","billion","bj","bm","bn","bo","both","br","bs","bt","but","buy","bv","bw","by","bz","c","ca","can","can't","cannot","caption","cc","cd","cf","cg","ch","ci","ck","cl","click","cm","cn","co","co.","com","copy","could","couldn","couldn't","cr","cs","cu","cv","cx","cy","cz","d","de","did","didn't","dj","dk","dm","do","does","doesn","doesn't","don","don't","down","during","dz","e","each","ec","edu","ee","eg","eh","eight","eighty","either","else","elsewhere","end","ending","enough","er","es","et","etc","even","ever","every","everyone","everything","everywhere","except","f","few","fi","fifty","find","first","five","fj","fk","fm","fo","for","former","formerly","forty","found","four","fr","free","from","further","fx","g","ga","gb","gd","ge","get","gf","gg","gh","gi","gl","gm","gmt","gn","go","gov","gp","gq","gr","gs","gt","gu","gw","gy","h","had","has","hasn","hasn't","have","haven","haven't","he","he'd","he'll","he's","help","hence","her","here","here's","hereafter","hereby","herein","hereupon","hers","herself","him","himself","his","hk","hm","hn","home","homepage","how","however","hr","ht","htm","html","http","hu","hundred","i","i'd","i'll","i'm","i've","i.e.","id","ie","if","il","im","in","inc","inc.","indeed","information","instead","int","into","io","iq","ir","is","isn","isn't","it","it's","its","itself","j","je","jm","jo","join","jp","k","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","l","la","last","later","latter","lb","lc","least","less","let","let's","li","like","likely","lk","ll","lr","ls","lt","ltd","lu","lv","ly","m","ma","made","make","makes","many","maybe","mc","md","me","meantime","meanwhile","mg","mh","microsoft","might","mil","million","miss","mk","ml","mm","mn","mo","more","moreover","most","mostly","mp","mq","mr","mrs","ms","msie","mt","mu","much","must","mv","mw","mx","my","myself","mz","n","na","namely","nc","ne","neither","net","netscape","never","nevertheless","new","next","nf","ng","ni","nine","ninety","nl","no","nobody","none","nonetheless","noone","nor","not","nothing","now","nowhere","np","nr","nu","nz","o","of","off","often","om","on","once","one","one's","only","onto","or","org","other","others","otherwise","our","ours","ourselves","out","over","overall","own","p","pa","page","pe","per","perhaps","pf","pg","ph","pk","pl","pm","pn","pr","pt","pw","py","q","qa","r","rather","re","recent","recently","reserved","ring","ro","ru","rw","s","sa","same","sb","sc","sd","se","seem","seemed","seeming","seven","seventy","several","sg","sh","she","she'd","she'll","she's","should","shouldn","shouldn't","si","since","site","six","sixty","sj","sk","sl","sm","sn","so","some","somehow","someone","something","sometime","sometimes","somewhere","sr","st","still","stop","su","such","sv","sy","sz","t","taking","tc","td","ten","text","tf","tg","test","th","than","that","that'll","that's","the","their","them","themselves","then","thence","there","there'll","there's","thereafter","thereby","therefore","therein","thereupon","these","they","they'd","they'll","they're","they've","thirty","this","those","though","thousand","three","through","throughout","thru","thus","tj","tk","tm","tn","to","together","too","toward","towards","tp","tr","trillion","tt","tv","tw","twenty","two","tz","u","ua","ug","uk","um","under","unless","unlike","unlikely","until","up","upon","us","use","used","using","uy","uz","v","va","vc","ve","very","vg","vi","via","vn","vu","w","wanna","was","wasn","wasn't","we","we'd","we'll","we're","we've","web","webpage","website","welcome","well","were","weren","weren't","wf","what","what'll","what's","whatever","when","whence","whenever","where","whereafter","whereas","whereby","wherein","whereupon","wherever","whether","which","while","whither","who","who'd","who'll","who's","whoever","NULL","whole","whom","whomever","whose","why","will","with","within","without","won","won't","would","wouldn","wouldn't","ws","www","x","y","ye","yes","yet","you","you'd","you'll","you're","you've","your","yours","yourself","yourselves","yt","yu","z","za","zm","zr","10","z","org","inc","width","length"); $post=$content; foreach ($stop_words as $word) { $word = rtrim($word); $post = preg_replace("/\b$word\b/i", "", $post); } unset($stop_words); return $post; } function myvideoposter_array2string($myarray,&$output,&$parentkey){ foreach($myarray as $key=>$value){ if (is_array($value)) { $parentkey .= ""; @myvideoposter_array2string($value,$output,$parentkey); $parentkey = ""; } else { $output .= $value.","; } } } function myvideoposter_microtimefloat() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } /* Credits: Bit Repository URL: http://www.bitrepository.com/web-programming/php/remove-empty-values-from-an-array.html */ function myvideoposter_remove_array_empty_values($array, $remove_null_number = true) { $new_array = array(); $null_exceptions = array(); foreach ($array as $key => $value) { $value = trim($value); if($remove_null_number) { $null_exceptions[] = '0'; } if(!in_array($value, $null_exceptions) && $value != "") { $new_array[] = $value; } } return $new_array; } class myvideoposter_stopwatch { public $total; public $time; public function __construct() { $this->total = $this->time = microtime(true); } public function clock() { return -$this->time + ($this->time = microtime(true)); } public function elapsed() { return microtime(true) - $this->total; } public function reset() { $this->total=$this->time=microtime(true); } } // ### mySEOStatus CRON JOB... (pseudo-cron)... function myvideoposter_cron(){ if (!get_option('myvideoposter_isactive')=='1') return; $myseostatuscrondelay=get_option('myvideoposter_crondelay'); $last = get_option('myvideoposter_last_cron', false); $now= time(); $target= ($last + ($myseostatuscrondelay * 60)); $temp=$target-$now; $last=true; if ($now > $target) { // Ready to run, either via CRON or posting an url. $stopwatch = new myvideoposter_stopwatch(); update_option('myvideoposter_last_cron', time()); global $wpdb, $wp_version,$wp_locale,$wp_roles, $current_user,$current_blog,$allowedposttags; $table_log_name = $wpdb->prefix . "myvideoposter_log"; $table_feeds_name = $wpdb->prefix . "myvideoposter_feeds"; $post_table_name = $wpdb->prefix . "posts"; $postmeta_table_name = $wpdb->prefix . "postmeta"; $blogurl=myvideoposter_remove_http(get_bloginfo('url')); $timestamp = date ("Y-m-d H:i:s", time()); $myvideoposter_videoheight=get_option('myvideoposter_videoheight'); $myvideoposter_videowidth=get_option('myvideoposter_videowidth'); $myvideoposter_whitelisstatus=get_option('comment_whitelist'); $myvideoposter_poststatus = get_option('myvideoposter_poststatus'); $myvideoposter_numberofposts= get_option('myvideoposter_numberofposts'); $myvideoposter_category = get_option('myvideoposter_category'); $myvideoposter_posteruserid = get_option('myvideoposter_posteruserid'); $myvideoposter_addcustommetadata = get_option('myvideoposter_addcustommetadata'); $myvideoposter_custommetadataname = get_option('myvideoposter_custommetadataname'); $myvideoposter_addcustommetadatavideo = get_option('myvideoposter_addcustommetadatavideo'); $myvideoposter_custommetadatanamevideo = get_option('myvideoposter_custommetadatanamevideo'); $myvideoposter_postthumbnail = get_option('myvideoposter_postthumbnail'); $myvideoposter_postembed = get_option('myvideoposter_postembed'); $myvideoposter_createtags = get_option('myvideoposter_createtags'); $myvideoposter_limittags = get_option('myvideoposter_limittags'); $myvideoposter_checkfordisabledembedding = get_option('myvideoposter_checkfordisabledembedding'); include_once(ABSPATH.WPINC.'/rss.php'); // path to include script $sql = "SELECT * FROM `$table_feeds_name`"; $rssarray = $wpdb->get_results($sql, ARRAY_A); @shuffle($rssarray); $rssfeedtrip=0; // the current rss feed processed out of $rssfeedcount=count($rssarray); // total rss feeds in rss array $letsbreak=false; // not sure, in case we wanna break.. $rand_rss = array_rand($rssarray, 1); // For posting under WordPress MU ... Remember to reset at end of script .. $allowedposttags=$oldallowedposttags; $oldallowedposttags=$allowedposttags; // Save it, so we can restore after we've run the cron job. $allowedposttags['embed']['src'] = array(); $allowedposttags['embed']['type'] = array(); $allowedposttags['embed']['wmode'] = array(); $allowedposttags['embed']['width'] = array(); $allowedposttags['embed']['height'] = array(); $allowedposttags['object']['width'] = array(); $allowedposttags['object']['height'] = array(); $allowedposttags['param']['name'] = array(); $allowedposttags['param']['value'] = array(); while (($postedvideos<$myvideoposter_numberofposts) AND ($rssfeedtrip<$rssfeedcount) AND ($letsbreak<>true)) { unset($items); $rssfeed = $rssarray[$rssfeedtrip]["rssurl"]; $rsscategory= $rssarray[$rssfeedtrip]["targetcategory"]; $rsstype= $rssarray[$rssfeedtrip]["type"]; $thequestion=strpos($rssfeed,"?"); $append="&max-results=50"; if ($thequestion===false) $append="?max-results=50"; $fullfeedurl=$rssfeed.$append; $note .= "Looking for new videos in $fullfeedurl<br>"; $feed = @fetch_rss($fullfeedurl); $items = @array_slice($feed->items, 0, 49); $postedvideos=0; //set number of posted videos in this RUN so far to 0.... if (!empty($items)) : foreach ($items as $item) : $url = $item['link']; $title = ucfirst($item['title']); $orgtitle = $item['title']; //Not modified title.. $url = $item['link']; $embedyurl= str_ireplace("http://youtube.com/?v=",'',$url); $embedyurl= str_ireplace("http://www.youtube.com/?v=",'',$embedyurl); $embedyurl= str_ireplace("http://www.youtube.com/watch?v=",'',$embedyurl); $embedyurl= str_ireplace("&feature=youtube_gdata",'',$embedyurl); $embedyurl= str_ireplace("&fea",'',$embedyurl); $slug = sanitize_title(myvideoposter_returnuniquewords(myvideoposter_trimstopwords($item['title']),myvideoposter_returnuniquewords($item['title']))); $alreadyposted=myvideoposter_alreadyposted($embedyurl); //Has it been posted?? //$note .="#D: ('$title') Status for already posted: ($embedyurl) $alreadyposted<br>"; /* // If there was nothing found in the log, we check the post title, just in case. if (!$alreadyposted) { $query = "SELECT * FROM `$post_table_name` WHERE `post_title` LIKE '%". mysql_real_escape_string($orgtitle)."%';"; $posthits = $wpdb->get_results($query, ARRAY_A); if ($posthits){ $alreadyposted=true; } else { $alreadyposted=false; } } */ $isembeddingallowed=false; // Check if embedding is disabled (if we have turned that feature on) if (($myvideoposter_checkfordisabledembedding) && (!$alreadyposted)) { $isembeddingallowed=myvideoposter_embeddingallowed($embedyurl); //$note .="#D: checking for embed. result: '$isembeddingallowed'<br>"; } //$note .="#D: alreadyposted siger: '$alreadyposted'<br>"; if (!$alreadyposted) { // New post!!! // if ((!$alreadyposted) && ($isembeddingallowed<>false)) { // New post!!! ob_flush(); //$note .="#D: posting a new! - '$title'<br>"; //Find thumbnail url if (($myvideoposter_postthumbnail=='1') OR ($myvideoposter_addcustommetadata=='1')){ $imgurl= "http://img.youtube.com/vi/".$embedyurl."/0.jpg"; //$note .="#D: looking for thumbs at $imgurl<br>"; //Save and upload thumbnail // echo "$imgurl<br>"; $data= wp_remote_fopen($imgurl); $filename=sanitize_file_name(myvideoposter_returnuniquewords(myvideoposter_trimstopwords($title))).'.jpg'; $uploadresult=wp_upload_bits( $filename, null, $data, null ); $uploadurl=$uploadresult["url"]; unset($data); unset($filename); } // Lets get the description $desc = $item['description']; // If the description is empty, lets try the atom_content if ($desc=='') $desc = $item['atom_content']; $orgdesc= $desc; $desc = preg_replace('#Author: <a href="(.*?)">(.*?)</a>#Ui','',$desc); $desc = preg_replace('#Added: (.*?) <br>#Ui','',$desc); $desc = preg_replace('#Keywords: (.*?) <br>#Ui','',$desc); $desc= strip_tags($desc); //Trim 'Added: ' $addedpos= strpos($desc,'Added: '); if (is_integer($addedpos)) { $desc = substr($desc,0,$addedpos); } //Create and optimize tags if ($myvideoposter_createtags=='1'){ $tags=''; // $note .="#D: creating/researching tags.<br>"; // First check if there are some keywords in the actual description and then use those if (!$tags<>''){ // Get tags $tags=myvideoposter_returnkeywords($orgdesc,$title); // Convert returned multiarray to string.. @myvideoposter_array2string($tags,$tagstring,$parent); $tags=$tagstring; if (is_array($tags)) $tags = implode(",", $tags); } if ($myvideoposter_limittags<>'Unlimited'){ if ($tags != '') $tags .= ', '; $tags = explode(',',$tags); $showtags = array_slice($tags,0,$myvideoposter_limittags); // just keep the first specified number of tags $taglist=''; foreach ($showtags as $tag) { $taglist .= $tag. ', '; } $tags = rtrim($taglist,', '); } } //Trim 'Keywords: ' $desc= str_ireplace('Keywords: ','',$desc); //Trim other stuff $desc = preg_replace("/From:(.*)?Views(.*)?More in(.*)?/s","",$desc); /* */ $yembed= "<object width='$myvideoposter_videowidth' height='$myvideoposter_videoheight'><param name='movie' value='http://www.youtube.com/v/$embedyurl'></param><embed src='http://www.youtube.com/v/$embedyurl&rel=0' type='application/x-shockwave-flash' width='$myvideoposter_videowidth' height='$myvideoposter_videoheight'></embed></object>"; // Define content $content =''; if ($myvideoposter_postthumbnail=='1') $content .="<img src='$uploadurl' alt='$title' title='$orgtitle'>"; $content .= $desc; if ($myvideoposter_postembed=='1') { $content .="$yembed"; } $video_post = array(); $video_post['post_title'] = $title; $video_post['post_content'] = trim($content); $video_post['post_excerpt'] = myvideoposter_truncatestring(trim($desc),150); $video_post['post_status'] = strtolower($myvideoposter_poststatus); $video_post['tags_input'] = $tags; $video_post['post_name'] = $slug; // THE SLUG!! $video_post['post_author'] = $myvideoposter_posteruserid; $video_post['post_category'] = array($rsscategory); // Check if embedding is disabled (if we have turned that feature on) if ($myvideoposter_checkfordisabledembedding) { $isembeddingallowed=myvideoposter_embeddingallowed($embedyurl); // $note .="#D: checking for embed. result: '$isembeddingallowed'<br>"; } if ($postedvideos<$myvideoposter_numberofposts) { // If checking for disabled is turned on, and we have determined it is allowed, then we post! if (($myvideoposter_checkfordisabledembedding) && ($isembeddingallowed) ){ $postresult=wp_insert_post( $video_post ); } else { } // If we don't care to check if embedding is disabled... if (!$myvideoposter_checkfordisabledembedding) { // switch_to_blog($blog_id); $postresult=wp_insert_post( $video_post ); } } // Reset the values we've used... if ($postresult) { $postedvideos++; wp_publish_post( $postresult ); $time= gmdate("Y-m-d H:i:s", time()); $query= "INSERT INTO `$table_log_name` (time, youtubeid, postid) VALUES ( '$time','$embedyurl','$postresult');"; $success = mysql_query($query); update_post_meta($postresult, 'youtubeurl', $embedyurl); $category=get_cat_name($rsscategory); $categoryurl=get_category_link($rsscategory); $note .="<br>New post: <a href=".get_permalink($postresult)." target='_blank'><strong>$title</strong></a> in the <a href='$categoryurl' target='blank'>'$category'</a> category (PostID #$postresult)<br>"; // Are we adding custom meta data? $myvideoposter_addcustommetadata = get_option('myvideoposter_addcustommetadata'); $myvideoposter_custommetadataname = get_option('myvideoposter_custommetadataname'); $myvideoposter_addcustommetadatavideo = get_option('myvideoposter_addcustommetadatavideo'); $myvideoposter_custommetadatanamevideo = get_option('myvideoposter_custommetadatanamevideo'); if (($myvideoposter_addcustommetadata) && ($myvideoposter_custommetadataname<>'')){ update_post_meta($postresult, $myvideoposter_custommetadataname, $uploadurl); $note .=" - Added the Custom Field, '$myvideoposter_custommetadataname'<br>"; } if (($myvideoposter_addcustommetadatavideo) && ($myvideoposter_custommetadatanamevideo<>'')){ update_post_meta($postresult, $myvideoposter_custommetadatanamevideo, $yembed); $note .=" - Added the Custom Field, '$myvideoposter_custommetadatanamevideo'<br>"; } // update_post_meta($post_id, $meta_key, $meta_value, $prev_value); // Are we making comments?? $myvideoposter_postcomments= get_option('myvideoposter_postcomments'); $myvideoposter_whitelisstatus= get_option('myvideoposter_postcomments'); if ($myvideoposter_postcomments) { $commentnumber=myvideoposter_readandpostcomments($embedyurl,$postresult); if ($commentnumber>0) $note .=" - Added $commentnumber comments to the post.<br><br>"; } } else{ //Something wrong with the posting of videos??? } if ($postedvideos>=$myvideoposter_numberofposts) { $allowedposttags=$oldallowedposttags; //Reset to old values unset($items); unset($feed); unset($rssfeed); unset($video_post); unset($wpdb); unset($wp_version); unset($wp_locale); unset($wp_roles); unset($current_user); unset($current_blog); unset($allowedposttags); $note .= "Total runtime: ".$stopwatch->clock()." seconds<br />"; return $note; } $tags=''; $slug=''; $desc=''; $content=''; $title=''; $uploadurl=''; } endforeach; endif; $rssfeedtrip++; } $allowedposttags=$oldallowedposttags; //Reset to old values unset($items); unset($feed); unset($rssfeed); unset($video_post); unset($wpdb); unset($wp_version); unset($wp_locale); unset($wp_roles); unset($current_user); unset($current_blog); unset($allowedposttags); $note .= "Total runtime: ".$stopwatch->clock()." seconds<br />"; return $note; } } //### This function removes duplicate words from a string function myvideoposter_returnuniquewords($instring){ $word_array = preg_split('/[\s?:;,.]+/', $instring, -1, PREG_SPLIT_NO_EMPTY); $unique_word_array = array_unique($word_array); $unique_str = implode(' ',$unique_word_array); return $unique_str; } // ### Not used as per v. 1.5 .. redundant.. function myvideoposter_get_images($file){ $h1count = preg_match_all('/(<img)\s (src="([a-zA-Z0-9\.;:\/\?&=_|\r|\n]{1,})")/isxmU',$file,$patterns); $res = array(); array_push($res,$patterns[3]); array_push($res,count($patterns[3])); unset($h1count); return $res; } // Add settings link on plugin page function myvideoposter_settings_link($links) { $settings_link = '<a href="options-general.php?page=myvideoposter.php">Settings</a>'; array_unshift($links, $settings_link); return $links; } function myvideoposter_settings_warning() { global $wpdb; $table_log_name = $wpdb->prefix . "myvideoposter_log"; $table_feeds_name = $wpdb->prefix . "myvideoposter_feeds"; if(($wpdb->get_var("show tables like '$table_log_name'") != $table_log_name) OR ($wpdb->get_var("show tables like '$table_feeds_name'") != $table_feeds_name)) { add_action('admin_notices', 'myvideoposter_settings_warning'); if ( file_exists(ABSPATH . 'wp-admin/includes/upgrade.php') ) { require_once(ABSPATH . '/wp-admin/includes/upgrade.php'); } else { // Wordpress <= 2.2 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); } if($wpdb->get_var("show tables like '$table_log_name'") != $table_log_name) { $results = $wpdb->query("CREATE TABLE IF NOT EXISTS `{$table_log_name}` ( `time` datetime NOT NULL default '0000-00-00 00:00:00', `youtubeid` varchar(15) NOT NULL, `postid` varchar(8) NOT NULL, KEY `youtubeid` (`youtubeid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } if($wpdb->get_var("show tables like '$table_feeds_name'") != $table_feeds_name) { $results = $wpdb->query("CREATE TABLE IF NOT EXISTS `{$table_feeds_name}` ( `active` varchar(1) NOT NULL, `id` int(11) NOT NULL auto_increment, `rssurl` varchar(255) NOT NULL, `type` varchar(15) NOT NULL, `targetcategory` int(11) NOT NULL, UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); //Update/move the fields also... myvideoposter_convertfeedstonewformat(); } } echo '<div class="updated fade"><p><strong>myVideoPoster: Automatic update complete!</strong></p></div>'; unset($wpdb); } //AUTOMATIC UPDATE CHECKING. AUTOMATIC UPDATE RUNS IN myvideoposter_settings_warning() global $wpdb; $table_log_name = $wpdb->prefix . "myvideoposter_log"; $table_feeds_name = $wpdb->prefix . "myvideoposter_feeds"; if(($wpdb->get_var("show tables like '$table_log_name'") != $table_log_name) OR ($wpdb->get_var("show tables like '$table_feeds_name'") != $table_feeds_name)) { add_action('admin_notices', 'myvideoposter_settings_warning'); } add_action('wp_footer', 'myvideoposter_cron', 2); // The cron! add_action('admin_menu', 'myvideoposter_admin_menu'); $plugin = plugin_basename(__FILE__); add_filter("plugin_action_links_$plugin", 'myvideoposter_settings_link' ); register_activation_hook(__FILE__,'myvideoposter_install'); ?>
The 2nd Amendment, 1789 - The Original Homeland Security.
Gun control means never having to say, "I missed you."
Web Design & SEO Agency | Serving World Wide from New Delhi, India