PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /home/trave494/live2news.com/wp-content/plugins/RSSPoster_PRO/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : /home/trave494/live2news.com/wp-content/plugins/RSSPoster_PRO/RSSPoster_PingFM.php |
<?php /* * Plugin Name: RSS Poster PRO Version - Ping.fm Module * Plugin URI: http://www.wprssposter.com/blog/ * Description: RSS Poster PRO Version - Ping.fm Module * Version: 0.2 * Author: RSS Poster Admin * Author URI: http://www.wprssposter.com/ */ define('RPUR_DEVELOPER_KEY','6e48010489e954d7b42c6e018d15d0fb'); add_action('publish_post', 'rpur_pingfm_post_info'); add_action('admin_menu', 'rpur_pingfm_menu'); //register_deactivation_hook(__FILE__, 'rpur_pingfm_deactive'); register_activation_hook(__FILE__, 'rpur__pingfm_activate'); function rpur_pingfm_deactive() { delete_option('rpur_pingfm'); } function rpur__pingfm_activate() { $rpur_pingfm = get_option('rpur_pingfm'); if (empty($rpur_pingfm)) { $rpur_pingfm['account'][] = array('user_app_key' => 'Put your user app key here','method' => 'Micro-blogging', 'enable' => true ); $rpur_pingfm['account'][] = array('user_app_key' => 'Put your user app key here','method' => 'Micro-blogging', 'enable' => false ); $rpur_pingfm['account'][] = array('user_app_key' => 'Put your user app key here','method' => 'Micro-blogging', 'enable' => false ); $service = array( 'tinyurl' => array( 'api'=>'http://tinyurl.com/api-create.php?url=[url]', ), 'isgd' => array( 'api'=>'http://is.gd/api.php?longurl=[url]', ), 'bitly' => array( 'api' => 'http://api.bit.ly/v3/shorten?login=[user]&apiKey=[key]&longUrl=[url]&format=txt', 'user' => '', 'key' => '', ), 'jmp' => array( 'api' => 'http://api.j.mp/v3/shorten?login=[user]&apiKey=[key]&longUrl=[url]&format=txt', 'user' => '', 'key' => '', ), 'cligs' => array( 'api' => 'http://cli.gs/api/v1/cligs/create?url=[url]&key=[key]&appid=ftsplugin', 'key' => '', ) ); $rpur_pingfm['char_count'] = 500; $rpur_pingfm['service'] = $service; $rpur_pingfm['active_service'] = 'tinyurl'; $rpur_pingfm['spam_protection'] = true; add_option('rpur_pingfm', $rpur_pingfm); } } function rpur_pingfm_menu() { if (!is_plugin_active('RSSPoster_PRO/index.php')) { echo '<div id="notice" class="error"><p>'; printf( '<b>Ping.fm Module:</b> Please Activate RSS Poster PRO Version to use Ping.fm module. ' ); echo '</p></div>'. "\n"; } else add_menu_page('Ping.fm Module', 'Ping.fm Module', 8, 'rpur_pingfm_page', 'rpur_pingfm_page'); } function rpur_pingfm_page() { $rpur_pingfm = get_option('rpur_pingfm'); if ($_POST['rpur_pingfm_update'] == 'rpur_pingfm_update') { $rpur_pingfm['active_service'] = $_POST['active_service']; unset($_POST['active_service']); $rpur_pingfm['service']['bitly']['user'] = $_POST['apiuser_bitly']; $rpur_pingfm['service']['bitly']['key'] = $_POST['apikey_bitly']; unset($_POST['apiuser_bitly']); unset($_POST['apikey_bitly']); $rpur_pingfm['service']['jmp']['key'] = $_POST['apikey_jmp']; $rpur_pingfm['service']['jmp']['user'] = $_POST['apiuser_jmp']; unset($_POST['apikey_jmp']); unset($_POST['apiuser_jmp']); $rpur_pingfm['service']['cligs']['key'] = $_POST['apikey_cligs']; unset($_POST['apikey_cligs']); $rpur_pingfm['char_count'] = absint($_POST['rpur_pingfm_char_count']); unset($_POST['rpur_pingfm_char_count']); $rpur_pingfm['spam_protection'] = ($_POST['spam_protection'])?true:false; unset($_POST['spam_protection']); unset($_POST['rpur_pingfm_update']); unset($_POST['save']); foreach ($_POST as $k => $v) { $acct=explode('-',$k); $rpur_pingfm['account'][$acct[0]][$acct[1]] = $v; } update_option('rpur_pingfm', $rpur_pingfm); echo '<div id="message" class="updated fade"><p>Saved!</p></div>'; } ?> <div class="wrapper"> <h2>RSS Poster PRO Version - Ping.fm Module Settings</h2> <h3>Don't spam Ping.fm, or your Application Key will be suspended!</h3> <form method="post" action=""> <table style="margin-top: 1em;" class="widefat"> <thead><tr><th scope="col">Ping.fm Account Settings</th></tr></thead> <tbody> <tr> <td scope="col"> <p><i>Application Key No.1</i> <input type="text" size="50" name="0-user_app_key" value="<?php echo $rpur_pingfm['account'][0]['user_app_key']; ?>" /> <select name="0-method"><?php echo rpur_pingfm_print_method($rpur_pingfm['account'][0]['method']);?></select> Enable <input type="checkbox" name="0-enable" <?php if ($rpur_pingfm['account'][0]['enable']) echo ' checked="yes" '; echo ' /></p>'; ?> </td> </tr> <tr> <td scope="col"> <p><i>Application Key No.2</i> <input type="text" size="50" name="1-user_app_key" value="<?php echo $rpur_pingfm['account'][1]['user_app_key']; ?>" /> <select name="1-method"><?php echo rpur_pingfm_print_method($rpur_pingfm['account'][1]['method']);?></select> Enable <input type="checkbox" name="1-enable" <?php if ($rpur_pingfm['account'][1]['enable']) echo ' checked="yes" '; echo ' /></p>'; ?> </td> </tr> <tr> <td scope="col"> <p><i>Application Key No.3</i> <input type="text" size="50" name="2-user_app_key" value="<?php echo $rpur_pingfm['account'][2]['user_app_key']; ?>" /> <select name="2-method"><?php echo rpur_pingfm_print_method($rpur_pingfm['account'][2]['method']);?></select> Enable <input type="checkbox" name="2-enable" <?php if ($rpur_pingfm['account'][2]['enable']) echo ' checked="yes" '; echo ' /></p>'; ?> </td> </tr> </tbody> </table> <h3>URL Shorten Services</h3> <p>If choose Micro-blogging or Status updates, you need to select one url shorten service.</p> <table style="margin-top: 1em;" class="widefat"> <thead> <tr> <th scope="col" id="sr" class="manage-column">Select</th> <th scope="col" id="ss" class="manage-column">Services</th> <th scope="col" id="sc" class="manage-column"><span class="csc">Configuration</span></th> </tr> </thead> <tbody> <tr> <?php echo rpur_pingfm_print_url_shorten_service($rpur_pingfm['active_service']); ?> </tr> </tbody> </table> <table style="margin-top: 1em;" class="widefat"> <h3>Blogging Settings</h3> <p>If choose Blogging, you need to input the char count. Your network of ping.fm will be updated with a post like this:</p> <p>You can only see <?php echo $rpur_pingfm['char_count'];?> characters in here. Read the full content of <a href="http://yourblog.com/the-title/">the tile</a>.</p> <thead><tr><th scope="col"></th></tr></thead> <tbody> <tr> <td scope="col"> <p>Char count: <input type="text" name="rpur_pingfm_char_count" value="<?php echo $rpur_pingfm['char_count'];?>" size=10></input></p> <em>0 means full content!</em> </td> </tr> </tbody> </table> <table style="margin-top: 1em;" class="widefat"> <h3>Spam Protection</h3> <p>If this option enabled, Ping.fm Module will randomly choose to update your ping.fm when a post published.</p> <thead><tr><th scope="col"></th></tr></thead> <tbody> <tr> <td scope="col"> <p>Spam Protection: <input type="checkbox" name="spam_protection" <?php if($rpur_pingfm['spam_protection']) echo ' checked="yes" '; echo ' /></p>'; ?> </td> </tr> </tbody> </table> <p><input type="hidden" name="rpur_pingfm_update" value="rpur_pingfm_update" /></p> <p><input class="button-primary" type="submit" name="save" value="Save" /></p> </form> </div> <?php } function rpur_pingfm_print_method($opt='') { $method=array('Micro-blogging', 'Status updates', 'Blogging'); foreach ($method as $s) { $option = "<option value='". $s . "'"; if($opt == $s ) $option .= " selected='selected' "; $option .= '>'; $option .= $s; $option .= '</option>'; $results.=$option; } return $results; } function rpur_pingfm_print_url_shorten_service($opt = '') { $rpur_pingfm = get_option('rpur_pingfm'); $service = array('tinyurl', 'isgd', 'bitly', 'jmp', 'cligs'); $results = ''; foreach ($service as $s) { $option= '<tr><th><input type="radio" name="active_service" value="' . $s . '"'; if ($opt == $s) $option .= " checked"; $option .= '/></th><td>'. $s.'</td>'; switch ($s) { case 'bitly': $option .= '<td><div id="userkey_bitly">API/Key:<input type="text" name="apikey_bitly" value="'.$rpur_pingfm['service']['bitly']['key'].'" />User/ID: <input type="text" name="apiuser_bitly" value="'.$rpur_pingfm['service']['bitly']['user'].'" /></div></td>'; break; case 'jmp': $option .= '<td><div id="userkey_jmp">API/Key:<input type="text" name="apikey_jmp" value="'.$rpur_pingfm['service']['jmp']['key'].'" />User/ID: <input type="text" name="apiuser_jmp" value="'.$rpur_pingfm['service']['jmp']['user'].'" /></div></td>'; break; case 'cligs': $option .= '<td><div id="userkey_cligs">API/Key:<input type="text" name="apikey_cligs" id="apikey_cligs" value="'.$rpur_pingfm['service']['cligs']['key'].'" /></div></td>'; break; default: $option .= '<td></td>'; break; } $option .= '</tr>'; $results .= $option; } return $results; } function rpur_pingfm_post_info($id) { $rpur_pingfm = get_option('rpur_pingfm'); if ($rpur_pingfm['spam_protection'] && (1 != rand(0,5))) { rpur_log("Decide not to update ping.fm for spam protection"); return; } if ($_POST['action'] != "autosave" && $_POST['post_status'] != "draft") { $mypost = get_post($id); $title = strip_tags($mypost->post_title); $content = strip_tags($mypost->post_content); $postlink = get_permalink($id); rpur_log("Begin to update pingfm."); foreach ($rpur_pingfm['account'] as $acct) { if ($acct['enable']) { if ($acct['method'] === 'Micro-blogging') rpur_pingfm_micro_update($acct['user_app_key'], $title, $postlink); elseif ($acct['method'] === 'Status updates') rpur_pingfm_status_update($acct['user_app_key'], $title, $postlink); elseif ($acct['method'] === 'Blogging') rpur_pingfm_blogging_update($acct['user_app_key'], $title, $content, $postlink); } } } } function rpur_pingfm_micro_update($user_app_key='', $title='',$postlink='') { if (!$title || !$postlink || !$user_app_key) return; $url_contents = rpur_pingfm_create_short_link($postlink); $title_length = rpur_pingfm_str_len($title); $url_length = rpur_pingfm_str_len($url_contents); $temp_length = $title_length + $url_length; if ($temp_length > 140) { $remaining_chars = 134 - $url_length; $title = rpur_pingfm_cut_str($title, 0, $remaining_chars); $title .= "..."; } $message = $title . " - " . $url_contents; rpur_pingfm_post( $user_app_key, "microblog", $message ); } function rpur_pingfm_status_update($user_app_key='', $title='', $postlink='') { if (!$title || !$postlink || !$user_app_key) return; $url_contents = rpur_pingfm_create_short_link($postlink); $title_length = rpur_pingfm_str_len($title); $url_length = rpur_pingfm_str_len($url_contents); $temp_length = $title_length + $url_length; if( $temp_length > 200 ) { $remaining_chars = 194 - $url_length; $title = rpur_pingfm_cut_str($title, 0, $remaining_chars); $title .= "..."; } $message = $title . " - " . $url_contents; rpur_pingfm_post( $user_app_key, "status", $message ); } function rpur_pingfm_blogging_update($user_app_key, $title='', $content='', $postlink='') { if (!$title || !$content || !$postlink || !$user_app_key) return; $rpur_pingfm = get_option('rpur_pingfm'); $char_count = $rpur_pingfm['char_count']; if ($char_count > 0 ) $content = rpur_pingfm_cut_str($content, 0, $char_count); $content .= "... Read the full content of <a href=\"$postlink\">$title</a>"; rpur_pingfm_post( $user_app_key, 'blog', $content, $title ); } function rpur_pingfm_create_short_link($postlink) { $rpur_pingfm = get_option('rpur_pingfm'); $service = $rpur_pingfm['service'][$rpur_pingfm['active_service']]; $api = str_replace( array('[url]','[user]','[key]'), array($postlink,$service['user'],$service['key']) , $service['api'] ); $shortlink = rpur_get_file($api); if (false === strpos($shortlink, '://')) { rpur_log("Fail to creat short link: " . $shortlink); $shortlink = $postlink; } return $shortlink; } function rpur_pingfm_str_len($str) { $length = strlen(preg_replace('/[\x00-\x7F]/', '', $str)); if ($length) return strlen($str) - $length + intval($length / 3); else return strlen($str); } function rpur_pingfm_cut_str($str, $len) { if (isset($str[$len])) { if (seems_utf8($str[$len-1])) $str = substr($str, 0, $len); else { if (seems_utf8($str[$len-3] . $str[$len-2] . $str[$len-1])) $str = substr($str, 0, $len-3) . $str[$len-3] . $str[$len-2] . $str[$len-1]; elseif (seems_utf8($str[$len-2] . $str[$len-1] . $str[$len])) $str = substr($str, 0, $len-2) . $str[$len-2] . $str[$len-1] . $str[$len]; elseif (seems_utf8($str[$len-1] . $str[$len] . $str[$len+1]) ) $str = substr($str, 0, $len-1) . $str[$len-1] . $str[$len] . $str[$len+1]; else $str = substr($str, 0, $len); } } return $str; } function rpur_pingfm_send($user_app_key,$post_fields=array()){ $ch = curl_init(); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, array_merge( $post_fields, array('user_app_key' => $user_app_key, 'api_key' => RPUR_DEVELOPER_KEY) )); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_USERAGENT, 'RSS Poster Plugin' ); curl_setopt( $ch, CURLOPT_URL, 'http://api.ping.fm/v1/user.post'); $xml = simplexml_load_string( curl_exec( $ch ) ); curl_close( $ch ); $status = ($xml['status'] == 'OK'); return array('status' => $status, 'response' => $xml->message); } function rpur_pingfm_post( $user_app_key, $post_method, $body, $title = '', $debug = 0 ) { $result = rpur_pingfm_send($user_app_key, array( 'body' => base64_encode($body), 'post_method' => $post_method, 'title' => base64_encode($title), 'debug' => $debug, 'encoding' => 'base64' ) ); if ($result['status']) rpur_log('<b>' . ($title ? $title : $body) . '</b>' . ' has been updated to the ping.fm ' . $user_app_key); else rpur_log('<b>Error</b>: '. $user_app_key . ' ' . $result['response']); } ?>