hier der code von pagepressapp.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | <?php /* Plugin Name: PagePressApp.com Auto Wall Post Plugin URI: http://www.pagepressapp.com Description: This plugin will help to publish your blog's post to your Facebook fanpage's wall on auto-pilot. This way, it will keep your fanpage's wall fresh with regular content and keep your readers updated with the latest blog post. To use this feature at no cost, please register with PagePressApp.com so that you can configure your Fanpage details and enable the Auto Wall Post option. Register now for free at http://www.pagepressapp.com Author: PagePressApp Version: 1.70 Author URI: http://www.PagePressApp.com */ /* Copyright 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * Guess the wp-content and plugin urls/paths */ // Pre-2.6 compatibility if ( ! defined( 'WP_CONTENT_URL' ) ) define( 'WP_CONTENT_URL' , get_option( 'siteurl' ) . '/wp-content' ); if ( ! defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR' , ABSPATH . 'wp-content' ); if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL' , WP_CONTENT_URL. '/plugins' ); if ( ! defined( 'WP_PLUGIN_DIR' ) ) define( 'WP_PLUGIN_DIR' , WP_CONTENT_DIR . '/plugins' ); if (! class_exists ( 'cwp_ppa' )) { class cwp_ppa { //This is where the class variables go, don't forget to use @var to tell what they're for /** * @var string The options string name for this plugin */ var $optionsName = 'cwp_ppa_options' ; /** * @var string $localizationDomain Domain used for localization */ var $localizationDomain = "cwp_ppa" ; /** * @var string $pluginurl The path to this plugin */ var $thispluginurl = '' ; /** * @var string $pluginurlpath The path to this plugin */ var $thispluginpath = '' ; /** * @var array $options Stores the options for this plugin */ var $options = array (); //Class Functions /** * PHP 4 Compatible Constructor */ function cwp_ppa(){ $this ->__construct();} /** * PHP 5 Constructor */ function __construct(){ //Language Setup /*$locale = get_locale(); $mo = dirname(__FILE__) . "/languages/" . $this->localizationDomain . "-".$locale.".mo"; load_textdomain($this->localizationDomain, $mo);*/ //"Constants" setup $this ->thispluginurl = PLUGIN_URL . '/' . dirname(plugin_basename( __FILE__ )). '/' ; $this ->thispluginpath = PLUGIN_PATH . '/' . dirname(plugin_basename( __FILE__ )). '/' ; //Initialize the options //This is REQUIRED to initialize the options when the plugin is loaded! $this ->getOptions(); //Actions //add_action("admin_menu", array(&$this,"admin_menu_link")); /* add_action("wp_head", array(&$this,"add_css")); add_action('wp_print_scripts', array(&$this, 'add_js')); */ //Filters /* add_filter('the_content', array(&$this, 'filter_content'), 0); */ add_filter( "publish_post" , array (& $this , "publish_post" )); } function publish_post( $post_ID ) { global $wpdb ; //Check if this is fresh new published post, not edited one if (true) { $post = $wpdb ->get_row( $wpdb ->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d" , $post_ID ) ); $post_data = array ( 'source' => get_permalink( $post_ID ), 'title' => $post ->post_title, 'body' => $post ->post_content, 'wpurl' => get_bloginfo( 'wpurl' ), 'published' => $post ->post_date, 'feed_title' => get_bloginfo( 'name' ), 'feed_url' => get_bloginfo( 'rss2_url' ) ); $result = $this ->post_request( 'http://www.pagepressapp.com/wp_notify' , $post_data , get_bloginfo( 'wpurl' )); if ( $result [ 'status' ] == 'ok' ){ } else { } } } /** * Retrieves the plugin options from the database. * @return array */ function getOptions() { //Don't forget to set up the default options if (! $theOptions = get_option( $this ->optionsName)) { $theOptions = array ( 'default' => 'options' ); update_option( $this ->optionsName, $theOptions ); } $this ->options = $theOptions ; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //There is no return here, because you should use the $this->options variable!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } /** * Saves the admin options to the database. */ function saveAdminOptions(){ return update_option( $this ->optionsName, $this ->options); } /** * @desc Adds the options subpanel */ function admin_menu_link() { //If you change this from add_options_page, MAKE SURE you change the filter_plugin_actions function (below) to //reflect the page filename (ie - options-general.php) of the page your plugin is under! //add_options_page('PagePressApp.com', 'PagePressApp.com', 10, basename(__FILE__), array(&$this,'admin_options_page')); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array (& $this , 'filter_plugin_actions' ), 10, 2 ); } /** * @desc Adds the Settings link to the plugin activate/deactivate page */ function filter_plugin_actions( $links , $file ) { //If your plugin is under a different top-level menu than Settiongs (IE - you changed the function above to something other than add_options_page) //Then you're going to want to change options-general.php below to the name of your top-level page $settings_link = '<a href="options-general.php?page=' . basename ( __FILE__ ) . '">' . __( 'Settings' ) . '</a>' ; array_unshift ( $links , $settings_link ); // before other links return $links ; } /** * Adds settings/options page */ function admin_options_page() { if ( $_POST [ 'cwp_ppa_save' ]){ if (! wp_verify_nonce( $_POST [ '_wpnonce' ], 'cwp_ppa-update-options' ) ) die ( 'Whoops! There was a problem with the data you posted. Please go back and try again.' ); $this ->options[ 'cwp_ppa_path' ] = $_POST [ 'cwp_ppa_path' ]; $this ->options[ 'cwp_ppa_allowed_groups' ] = $_POST [ 'cwp_ppa_allowed_groups' ]; $this ->options[ 'cwp_ppa_enabled' ] = ( $_POST [ 'cwp_ppa_enabled' ]== 'on' )?true:false; $this ->saveAdminOptions(); echo '<div class="updated"><p>Success! Your changes were sucessfully saved!</p></div>' ; } ?> <div class = "wrap" > <h2>PagePressApp.com Auto Wall Post</h2> <form method= "post" id= "cwp_ppa_options" > <?php wp_nonce_field( 'cwp_ppa-update-options' ); ?> <table width= "100%" cellspacing= "2" cellpadding= "5" class = "form-table" > <tr valign= "top" > <th width= "33%" scope= "row" ><?php _e( 'Option 1:' , $this ->localizationDomain); ?></th> <td><input name= "cwp_ppa_path" type= "text" id= "cwp_ppa_path" size= "45" value= "<?php echo $this->options['cwp_ppa_path'] ;?>" /> </td> </tr> <tr valign= "top" > <th width= "33%" scope= "row" ><?php _e( 'Option 2:' , $this ->localizationDomain); ?></th> <td><input name= "cwp_ppa_allowed_groups" type= "text" id= "cwp_ppa_allowed_groups" value= "<?php echo $this->options['cwp_ppa_allowed_groups'] ;?>" /> </td> </tr> <tr valign= "top" > <th><label for = "cwp_ppa_enabled" ><?php _e( 'CheckBox #1:' , $this ->localizationDomain); ?></label></th><td><input type= "checkbox" id= "cwp_ppa_enabled" name= "cwp_ppa_enabled" <?=( $this ->options[ 'cwp_ppa_enabled' ]==true)? 'checked="checked"' : '' ?>></td> </tr> <tr> <th colspan=2><input type= "submit" name= "cwp_ppa_save" value= "Save" /></th> </tr> </table> </form> <?php } function post_request( $url , $data , $referer = '' ) { // Convert the data array into URL Parameters like a=b&foo=bar etc. $data = http_build_query( $data ); // parse the given URL $url = parse_url ( $url ); if ( $url [ 'scheme' ] != 'http' ) { die ( 'Error: Only HTTP request are supported !' ); } // extract host and path: $host = $url [ 'host' ]; $path = $url [ 'path' ]; // open a socket connection on port 80 - timeout: 30 sec $fp = fsockopen ( $host , 80, $errno , $errstr , 30); if ( $fp ){ // send the request headers: fputs ( $fp , "POST $path HTTP/1.1\r\n" ); fputs ( $fp , "Host: $host\r\n" ); if ( $referer != '' ) fputs ( $fp , "Referer: $referer\r\n" ); fputs ( $fp , "Content-type: application/x-www-form-urlencoded\r\n" ); fputs ( $fp , "Content-length: " . strlen ( $data ) . "\r\n" ); fputs ( $fp , "Connection: close\r\n\r\n" ); fputs ( $fp , $data ); $result = '' ; while (! feof ( $fp )) { // receive the results of the request $result .= fgets ( $fp , 128); } } else { return array ( 'status' => 'err' , 'error' => "$errstr ($errno)" ); } // close the socket connection: fclose( $fp ); // split the result header from the content $result = explode ( "\r\n\r\n" , $result , 2); $header = isset( $result [0]) ? $result [0] : '' ; $content = isset( $result [1]) ? $result [1] : '' ; // return as structured array: return array ( 'status' => 'ok' , 'header' => $header , 'content' => $content ); } } //End Class } //End if class exists statement //instantiate the class if ( class_exists ( 'cwp_ppa' )) { $cwp_ppa_var = new cwp_ppa(); } ?> |
verwendete ilchClan Version: 1.1
betroffene Homepage: facecom.funpic.de