start_delimiter=$configuration->start_delimiter; $this->end_delimiter=$configuration->end_delimiter; $this->delimiter_tag_name=$configuration->delimiter_tag_name; $this->paied_users_table = $configuration->paied_users_table; $this->paied_items_table = $configuration->paied_items_table; $this->bonus_posts_table = $configuration->bonus_posts_table; $this->paypal_requests_table = $configuration->paypal_requests_table; $this->paypal_field_types_table = $configuration->paypal_field_types_table; $this->paypal_fields_table = $configuration->paypal_fields_table; $this->users_library_page = $configuration->users_library_page; $this->purchased_posts_list_placeholder=$configuration->purchased_posts_list_placeholder; $this->paypal_url=$configuration->paypal_url; $this->paypal_email = $configuration->paypal_email; //Hook into wordpress add_action('admin_menu', array(&$this,'Are_PayPal_Configuration')); add_filter('the_content', array(&$this,'post_filter')); add_filter('the_content', array(&$this,'purchased_posts')); add_action('wp_head', array(&$this,'add_html_headers')); add_action( 'wp_footer', array(&$this,'put_my_url_to_footer')); $install = new Are_PayPal_Install(); register_activation_hook(__FILE__,array(&$install,'install')); $this->set_templates(); } function put_my_url_to_footer() { ?> _e("This blog is monetized using Are-PayPal WP Plugin");?> } function set_templates(){ $templates= new Are_PayPal_Templates(); $templates->set_templates(); } function show_login_button($url,$urltext){ $templateName=$this->prefix."_LoginButtonTemplate"; $result=stripslashes(get_option($templateName)); $explanation = get_option($this->prefix.'_TextToShowIfNotLogedIn'); $result=str_replace('%EXPLANATION%',$explanation,$result); $result=str_replace('%LOGINURL%',$url,$result); $result=str_replace('%LOGINURLTEXT%',$urltext,$result); return $result; } function purchased_posts($content){ global $wpdb; if (strpos($content,$this->purchased_posts_list_placeholder) === false){ if ( is_page($this->users_library_page)) { $content.= $this->purchased_posts_list_placeholder; } } if (!(strpos($content,$this->purchased_posts_list_placeholder) === false)){ global $current_user, $user_ID; $userID=$user_ID; if ($userID == 0) {$userID = $current_user->id;} $sql = "SELECT DISTINCT posts.post_title,posts.guid, items.post_id FROM $wpdb->posts posts INNER JOIN $this->paied_users_table items ON items.post_id=posts.id WHERE user_id ='$userID' AND $this->post_type_clause"; $purchased_posts = $wpdb->get_results($sql, OBJECT); if ($purchased_posts){ $purchasedPostsList=""; foreach ($purchased_posts as $post){ if ($this->IsPostPurchased($post->post_id,$userID)){ $purchasedPostsList.="
"; } } } $content=str_replace($this->purchased_posts_list_placeholder,$purchasedPostsList,$content); } return $content; } function post_filter($content){ $start_delimiter=$this->start_delimiter; $end_delimiter=$this->end_delimiter; global $current_user, $user_ID,$post_ID,$post,$id; $postID=$post_ID; $userID=$user_ID; if ($userID == 0) {$userID = $current_user->id;} if ($postID == 0) {$postID = $post->id;} if ($postID == 0) {$postID = $id;} $isPostPurchased=$this->IsPostPurchased($postID,$userID); $combination=((!$this->IsGooglebot())&&(($userID == 0) || (!$isPostPurchased))); echo(""); if ((!$this->IsGooglebot())&&(($userID == 0) || (!$isPostPurchased))){ $start = strpos($content, $start_delimiter); $end = strpos($content, $end_delimiter); $pre = substr($content,0,$start); $suf = substr($content,$end,strlen($content)); $delimiterRegex="/\\[$this->delimiter_tag_name\\].*?\\[\/$this->delimiter_tag_name\\]/is"; if (!(($start===FALSE) && ($end===FALSE))){ if ($userID == 0){ $domain = $_SERVER['HTTP_HOST']; $url = "http://" . $domain . $_SERVER['REQUEST_URI']; $LoginButton = $this->show_login_button(get_option ('siteurl')."/wp-login.php?redirect_to=$url",__("Log in")); $content = preg_replace($delimiterRegex,$LoginButton,$content); }else{ global $wpdb; $sql="SELECT posts.ID,posts.post_title, items.* FROM $wpdb->posts posts INNER JOIN $this->paied_items_table items ON items.post_id=posts.id WHERE posts.id='$postID'"; $items = $wpdb->get_results($sql); if($items) { $item=$items[0]; $item_id=$item->ID; $item_title=$item->post_title; $item_amount=$item->amount; $item_currency=$item->currency; $item_name=$item->name; $item_number=$item->number; $item_expire=$this->native_expiration_message($item->expire); $postButton=$this->paypal_buy_now_form($item_name.":".$item_title." ".$item_expire,$item_number,$item_amount,$item_currency,$postID,$userID,$item->expire); } $blog_item_amount=get_option($this->prefix.'_BlogAmount'); if ($blog_item_amount){ $blog_item_amount=get_option($this->prefix.'_BlogAmount'); $blog_item_currency=get_option($this->prefix.'_BlogCurrency'); $blog_item_name=get_option($this->prefix.'_BlogName'); $blog_item_number=get_option($this->prefix.'_BlogNumber'); $blog_item_expire=get_option($this->prefix.'_BlogExpire'); $blog_item_expire=$this->native_expiration_message($blog_item_expire); $blogButton=$this->paypal_buy_now_form($blog_item_name.":".$blog_item_title." ".$blog_item_expire,$blog_item_number,$blog_item_amount,$blog_item_currency,-1,$userID,get_option($this->prefix.'_BlogExpire'));//-1 post id for whole site } if ($blogButton || $postButton){ $content = preg_replace($delimiterRegex,$postButton.$blogButton,$content); } } } } $content= str_replace($start_delimiter,'',$content); $content= str_replace($end_delimiter,'',$content); return $content; } function native_expiration_message($item_expire){ if ($item_expire){ $item_expire=__(" Expires in ").$item_expire.__(" days"); }else{ $item_expire=""; } return $item_expire; } function Are_PayPal_Configuration() { global $wpdb; if ( function_exists('add_submenu_page') ){ add_menu_page(__($this->prefix), __($this->prefix), 10, __FILE__, array(&$this,'Main_Configuration_Page'),'/wp-content/plugins/are-paypal/images/icon_paypal_2Ps_16x14.gif'); add_submenu_page(__FILE__, __($this->prefix.' Configuration 2'), __('Post Prices'), 10,$this->prefix.'_PostSetup' , array(&$this,'Configure_Prices_For_Posts')); add_submenu_page(__FILE__, __($this->prefix.' Configuration 3'), __('Paypal data'), 10,$this->prefix.'_PaypalData' , array(&$this,'View_Payments')); add_submenu_page(__FILE__, __($this->prefix.' Configuration 4'), __('Blog Price'), 10,$this->prefix.'_BlogPrice' , array(&$this,'Blog_Price')); add_submenu_page(__FILE__, __($this->prefix.' Configuration 5'), __('How to use'), 10,$this->prefix.'_HowToUse' , array(&$this,'How_To_Use')); add_submenu_page(__FILE__, __($this->prefix.' Configuration 6'), __('Donate'), 10,$this->prefix.'_Donate' , array(&$this,'Donate')); } } function Main_Configuration_Page() { global $wpdb; check_admin_referer(); if ( isset($_POST['restoretemplatedefaults']) ) { delete_option($this->prefix.'_InstantPaymentTemplate'); delete_option($this->prefix.'_RecurentPaymentTemplate'); delete_option($this->prefix.'_LoginButtonTemplate'); $this->set_templates(); } if ( isset($_POST['submit']) ) { $Value = $_POST['TextToShowIfNotLogedIn']; update_option($this->prefix.'_TextToShowIfNotLogedIn', $Value); $Value = $_POST['PayPal_Email']; update_option($this->prefix.'_PayPal_Email', $Value); $Value = $_POST['test']; update_option($this->prefix.'_test', $Value); $Value = $_POST['TextToShowIfNotPurchased']; update_option($this->prefix.'_TextToShowIfNotPurchased', $Value); $Value = $_POST['InstantPaymentTemplate']; update_option($this->prefix.'_InstantPaymentTemplate', $Value); $Value = $_POST['RecurentPaymentTemplate']; update_option($this->prefix.'_RecurentPaymentTemplate', $Value); $Value = $_POST['LoginButtonTemplate']; update_option($this->prefix.'_LoginButtonTemplate', $Value); $Value = $_POST['Suppress_Notification_Emails']; update_option($this->prefix.'_Suppress_Notification_Emails', $Value); $Value = $_POST['users_library_page']; update_option($this->prefix.'_Users_Library_Page', $Value); $LastAction = __("Updated successfully ..."); } ?>'.$LastAction.'
Aurimas Norkevicius for help with the plugin.')); ?>
_e('Click the button below to donate. Any amount is highly appreciated.')?>
How to hide content and show paypal button?
How to add purchased posts list into any page/post?
How to configure paypal's Instant Payment Notification (IPN)?
'.$LastAction.'
| _e('Back');?> | |||||
| _e('Details');?> | |||||
| =$field->Name;?> | =$field->Value;?> | ?>||||
| _e('Login');?> | =$login[0]->user_login;?> | ||||
| _e('Post title');?> | =$post[0]->post_title;?> | ||||
| _e("Type")?> | _e("Email")?> | _e("Amount")?> | _e("Login")?> | _e("Post Title")?> | _e("Action")?> |
|---|---|---|---|---|---|
| %TYPE% | %EMAIL% | %AMOUNT% | %LOGIN% | %TITLE% | "; foreach($fields as $field) { switch ($field->Name) { case "txn_type": $rowTemplate=str_replace('%TYPE%',$field->Value,$rowTemplate); break; case "payer_email": $rowTemplate=str_replace('%EMAIL%',$field->Value,$rowTemplate); break; case "mc_gross": $rowTemplate=str_replace('%AMOUNT%',$field->Value,$rowTemplate); break; case "mc_amount3": $rowTemplate=str_replace('%AMOUNT%',$field->Value,$rowTemplate); break; case "custom": list($post_id,$user_id) = explode("|",$field->Value); $user_id=mysql_escape_string($user_id); $post_id=mysql_escape_string($post_id); $login=$wpdb->get_results("SELECT user_login FROM $wpdb->users where ID='$user_id'"); $post=$wpdb->get_results("SELECT post_title FROM $wpdb->posts where ID='$post_id'"); $rowTemplate=str_replace('%LOGIN%',$login[0]->user_login,$rowTemplate); $rowTemplate=str_replace('%TITLE%',$post[0]->post_title,$rowTemplate); break; } } $rowTemplate=str_replace('%AMOUNT%','',$rowTemplate); echo($rowTemplate); ?>_e("Details")?> |
'.$LastAction.'
'.$LastAction.'
'.$LastAction.'
'.$LastAction.'
| $item_id | \n"; echo "$item_title | \n"; echo "";
$users = $wpdb->get_results("SELECT user_login FROM $wpdb->users u INNER JOIN $this->paied_users_table up ON up.user_id=u.id and up.post_id=$item_id AND (ADDDATE(up.purchase_date, up.expire) > CURDATE() OR up.expire is null OR up.expire = 0)");
foreach($users as $user) {
echo $user->user_login;
echo " "; } echo " | \n";
echo "$item_name | \n"; echo "$item_number | \n"; echo "$item_amount | \n"; echo "$item_currency | \n"; echo "$item_expire | \n"; ?>if ($item->post_id){ ?>=_e('Clear Priceing')?> | ?>=_e('Edit bonus posts')?> | ?>=_e('Edit purchasers')?> | } ?> =_e('Edit')?> | echo '
| '.__('No Posts Found').' | ||||||||
".__("Purchasing current content you will also get access for posts below")."