Allow PHP in Posts and Pages - Version 2.0.0.RC1

Version Description

  • Addition of Code Snippets function to the plugin
    • Minor Bug Fixes
    • New Options Pages
    • TinyMCE editor button
    • allow shortcodes in text widgets by default

=

Download this release

Release Info

Developer Hit Reach
Plugin Icon wp plugin Allow PHP in Posts and Pages
Version 2.0.0.RC1
Comparing to
See all releases

Code changes from version 1.2.3 to 2.0.0.RC1

Files changed (6) hide show
  1. AP.js +29 -0
  2. README.txt +16 -5
  3. allowphp.php +469 -118
  4. alter.php +46 -0
  5. ap.png +0 -0
  6. twitter.gif +0 -0
AP.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ tinymce.create('tinymce.plugins.allowPHP', {
3
+ init : function(ed, url) {
4
+ ed.addButton('allowPHP', {
5
+ title : 'Allow PHP',
6
+ image : url+'/ap.png',
7
+ onclick : function() {
8
+ var functionId = prompt("Function ID: ");
9
+ if (functionId != null && functionId != '0')
10
+ ed.execCommand('mceInsertContent', false, ' [php function='+functionId+'] ');
11
+ else
12
+ return;
13
+ }
14
+ });
15
+ },
16
+ createControl : function(n, cm) {
17
+ return null;
18
+ },
19
+ getInfo : function() {
20
+ return {
21
+ longname : "Allow PHP button code",
22
+ author : 'Hit Reach',
23
+ authorurl : 'http://www.hireach.co.uk/',
24
+ version : "1.0"
25
+ };
26
+ }
27
+ });
28
+ tinymce.PluginManager.add('allowPHP', tinymce.plugins.allowPHP);
29
+ })();
README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:
4
  Tags: post, pages, posts, code, php, shortcode,
5
  Requires at least: 2.5
6
  Tested up to: 3.0.1
7
- Stable tag: 1.2.3
8
 
9
  Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages
10
 
@@ -53,6 +53,11 @@ Will result in the output:
53
  if($user_ID == 1){
54
  echo "Hello World"
55
  }
 
 
 
 
 
56
 
57
 
58
  == Some Important Notes ==
@@ -83,13 +88,19 @@ Version: 1.0 <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-p
83
 
84
  == Change log ==
85
  = 1.0 =
86
- * Initial Release
87
  = 1.1 =
88
- * Bug fix for the conversion of the right square bracket
89
  = 1.2 =
90
- * Character Conversion Fixes
91
  = 1.2.3 =
92
- * Fixed major issue with 1.2.2
 
 
 
 
 
 
93
 
94
  == Frequently Asked Questions ==
95
  = What Tags Are Automatically Removed? =
4
  Tags: post, pages, posts, code, php, shortcode,
5
  Requires at least: 2.5
6
  Tested up to: 3.0.1
7
+ Stable tag: 2.0.0.RC1
8
 
9
  Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages
10
 
53
  if($user_ID == 1){
54
  echo "Hello World"
55
  }
56
+
57
+ To use the new saved code parts, just add a function=xxx where xxx is the id to the APIP shortcode.
58
+
59
+
60
+ [php function=1]
61
 
62
 
63
  == Some Important Notes ==
88
 
89
  == Change log ==
90
  = 1.0 =
91
+ * Initial Release
92
  = 1.1 =
93
+ * Bug fix for the conversion of the right square bracket
94
  = 1.2 =
95
+ * Character Conversion Fixes
96
  = 1.2.3 =
97
+ * Fixed major issue with 1.2.2
98
+ = 2.0.0.RC1 =
99
+ * Addition of Code Snippets function to the plugin
100
+ * Minor Bug Fixes
101
+ * New Options Pages
102
+ * TinyMCE editor button
103
+ * allow shortcodes in text widgets by default
104
 
105
  == Frequently Asked Questions ==
106
  = What Tags Are Automatically Removed? =
allowphp.php CHANGED
@@ -1,145 +1,496 @@
1
  <?php
2
  /*
3
  Plugin Name: Allow PHP in posts and pages
4
- version: 1.2.3
5
  Plugin URI: http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/
6
  Description: Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages whilst still retaining HTML tags
7
  Author: Hit Reach
8
  Author URI: http://www.hitreach.co.uk/
9
  */
10
  add_shortcode('php','php_handler');
 
 
 
11
  add_action('admin_menu', 'allow_php_menu');
 
 
 
 
 
 
12
 
13
  function php_handler($args, $content=null){
14
- define("ALLOWPHPVERSION","1.2.3");
15
  global $is_comment;
 
16
  if($is_comment){return "";}
17
- extract( shortcode_atts(array('debug' => 0), $args));
18
- if($args['debug'] != 1){
19
- error_reporting(E_NONE);
 
20
  }
21
-
22
- $content =(htmlspecialchars($content,ENT_QUOTES));
23
- $content = str_replace("&amp;#8217;","'",$content);
24
- $content = str_replace("&amp;#8216;","'",$content);
25
- $content = str_replace("&amp;#8242;","'",$content);
26
- $content = str_replace("&amp;#8220;","\"",$content);
27
- $content = str_replace("&amp;#8221;","\"",$content);
28
- $content = str_replace("&amp;#8243;","\"",$content);
29
- $content = str_replace("&amp;#039;","'",$content);
30
- $content = str_replace("&#039;","'",$content);
31
- $content = str_replace("&amp;#038;","&",$content);
32
- $content = str_replace("&amp;lt;br /&amp;gt;"," ", $content);
33
- $content = htmlspecialchars_decode($content);
34
- $content = str_replace("<br />"," ",$content);
35
- $content = str_replace("<p>"," ",$content);
36
- $content = str_replace("</p>"," ",$content);
37
-
38
- #line break
39
- $content = str_replace("[br/]","<br/>",$content);
40
- #other tags
41
- $content = str_replace("\\[","&#91;",$content);
42
- $content = str_replace("\\]","&#93;",$content);
43
- $content = str_replace("[","<",$content);
44
- $content = str_replace("]",">",$content);
45
- $content = str_replace("&#91;",'[',$content);
46
- $content = str_replace("&#93;",']',$content);
47
- $content = str_replace("&gt;",'>',$content);
48
- $content = str_replace("&lt;",'<',$content);
49
- ob_start();
50
- eval ($content);
51
- if($args['debug'] == 1){
52
- $content =(htmlspecialchars($content,ENT_QUOTES));
53
- echo ("<pre>".$content."</pre>");
54
  }
 
 
 
 
 
 
55
  $returned = ob_get_clean();
56
  return $returned;
57
  }
58
 
59
  function allow_php_menu(){
60
- add_submenu_page('options-general.php','Allow PHP in posts and pages', 'Allow PHP in posts', 'edit_posts', 'allow-php-admin', 'allow_php_options');
 
 
61
  }
62
- function allow_php_options(){
 
63
  ?>
64
- <h2>Allow PHP in posts and pages</h2>
65
- <div style='float:right; display:inline; margin-left:25px; margin-bottom:10px; margin-right:15px; padding:5px; background-color:#ffffcc; border:1px solid #ddddaa;'>
66
- <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Developed by <a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'>Hit Reach</a></span>
67
- <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Check out our other <a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'>Wordpress Plugins</a></span>
68
- <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Version: 1.2.3 <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>Support, Comments &amp; questions</a></span></div>
69
-
70
- <p>Allow PHP in posts and pages adds the functionality to include PHP in wordpress posts and pages by adding a simple shortcode <span style='color:green'>[php]</span><em>.code.</em><span style='color:green'>[/php]</span></p>
71
- <p>This plugin strips away the automatically generated wordpress &lt;p&gt; and &lt;br/&gt; tags but still allows the addition of your own &lt;p&gt; and &lt;br/&gt; tags
72
- <h3>Usage</h3>
73
- <p>To add the PHP code to your post or page simply place any PHP code inside the shortcode tags.<p>
74
- <em>For example: </em>If you wanted to add content that is visible to a particular user id:<br/>
75
- <pre>
76
- [php]
77
- global $user_ID;
78
- if($user_ID == 1){
79
- echo "Hello World";
80
- }
81
- [/php]
82
- </pre>
83
- <p>This code will output Hello World to only user id #1, and no one else</p>
84
- <p>in addition, should this code not be working (for example a missing ";") simply just change the [php] to be [php debug=1]</p>
85
- <pre>
86
- [php debug=1]
87
- global $user_ID;
88
- if($user_ID == 1){
89
- echo "Hello World"
90
- }
91
- [/php]
92
- </pre>
93
- <p>Will result in the output:
94
- <pre>
95
- Parse error: syntax error, unexpected '}', expecting ',' or ';' in XXX : eval()'d code on line 5
96
- global $user_ID;
97
- if($user_ID == 1){
98
- echo "Hello World"
99
- }
100
- </pre></p>
101
- <h3>Some Important Notes</h3>
102
- This plugin strips away all instances of &lt;p&gt; and &lt;br /&gt; therefore code has been added so that if you wish to use tags in your output (e.g.):
103
- <pre>
104
- [php]
105
- echo "hello &lt;br /&gt; world";
106
- [/php]
107
- </pre>
108
- the &lt; and &gt; tags will need to be swapped for [ and ] respectively so &lt;p&gt; becomes [p] and &lt;/p&gt; becomes [/p] which is converted back to &lt;p&gt; at runtime. these [ ] work for all tags (p, strong, em etc.).
109
- <pre>
110
- [php]
111
- echo "hello [br /] world";
112
- [/php]
113
- </pre>
114
- <h3>Tag list</h3>
115
- <table cellpadding="5" cellspacing="1" style='border:1px #ddd solid' width='60%'>
116
-
117
- <tr>
118
- <th align="left" style="padding:5px; background:#ffffcc">For</th>
119
- <th align="left" style="padding:5px; background:#ffffcc">Write as</th>
120
- </tr>
121
- <tr>
122
- <td align="left" style="padding:5px; background:#ffffcc">&lt;p&gt; ... &lt;/p&gt;</td>
123
- <td align="left" style="padding:5px; background:#ffffcc">[p] ... [/p]</td>
124
- </tr>
125
- <tr>
126
- <td align="left" style="padding:5px; background:#ffffcc">&lt;em&gt;...&lt;/em&gt;</td>
127
- <td align="left" style="padding:5px; background:#ffffcc">[em]...[/em]</td>
128
- </tr>
129
- <tr>
130
- <td align="left" style="padding:5px; background:#ffffcc">&lt;p style=''&gt; ... &lt;/p&gt;</td>
131
- <td align="left" style="padding:5px; background:#ffffcc">[p style=''] ... [/p]</td>
132
- </tr>
133
- <tr>
134
- <td align="left" style="padding:5px; background:#ffffcc">&lt;u&gt; ... &lt;/u&gt;</td>
135
- <td align="left" style="padding:5px; background:#ffffcc">[u] ... [/u]</td>
136
- </tr>
137
- <tr>
138
- <td align="left" style="padding:5px; background:#ffffcc">&lt;br /&gt;</td>
139
- <td align="left" style="padding:5px; background:#ffffcc">[br /]</td>
140
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  <?php
144
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Allow PHP in posts and pages
4
+ version: 2.0.0.RC1
5
  Plugin URI: http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/
6
  Description: Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages whilst still retaining HTML tags
7
  Author: Hit Reach
8
  Author URI: http://www.hitreach.co.uk/
9
  */
10
  add_shortcode('php','php_handler');
11
+ add_shortcode('PHP','php_handler');
12
+ add_shortcode('allowphp','php_handler');
13
+ add_shortcode('ALLOWPHP','php_handler');
14
  add_action('admin_menu', 'allow_php_menu');
15
+ add_filter('widget_text', 'do_shortcode');
16
+ register_activation_hook(__FILE__, 'allowPHP_activate');
17
+ global $dbVersion; $dbVersion = "1.0.0";
18
+ define("ALLOWPHPVERSION","2.0.0.RC1");
19
+ define("APIP_URL", WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)));
20
+
21
 
22
  function php_handler($args, $content=null){
 
23
  global $is_comment;
24
+ global $wpdb;
25
  if($is_comment){return "";}
26
+ extract( shortcode_atts(array('debug' => 0, 'function' => -1), $args));
27
+ if($args['debug'] == 1){error_reporting(E_ALL);ini_set("display_errors","1");}
28
+ if($args['function'] == -1){
29
+ $content =(htmlspecialchars($content,ENT_QUOTES));$content = str_replace("&amp;#8217;","'",$content);$content = str_replace("&amp;#8216;","'",$content);$content = str_replace("&amp;#8242;","'",$content);$content = str_replace("&amp;#8220;","\"",$content);$content = str_replace("&amp;#8221;","\"",$content);$content = str_replace("&amp;#8243;","\"",$content);$content = str_replace("&amp;#039;","'",$content);$content = str_replace("&#039;","'",$content);$content = str_replace("&amp;#038;","&",$content);$content = str_replace("&amp;lt;br /&amp;gt;"," ", $content);$content = htmlspecialchars_decode($content);$content = str_replace("<br />"," ",$content);$content = str_replace("<p>"," ",$content);$content = str_replace("</p>"," ",$content);$content = str_replace("[br/]","<br/>",$content);$content = str_replace("\\[","&#91;",$content);$content = str_replace("\\]","&#93;",$content);$content = str_replace("[","<",$content);$content = str_replace("]",">",$content);$content = str_replace("&#91;",'[',$content);$content = str_replace("&#93;",']',$content);$content = str_replace("&gt;",'>',$content);$content = str_replace("&lt;",'<',$content);
30
  }
31
+ else{
32
+ $options = get_option("allowPHP_options");
33
+ $show404 = $options['show404'];
34
+ $fourohfourmsg = $options['fourohfourmsg'];
35
+ if($fourohfourmsg != 0){
36
+ $fourohfourmsg = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."allowPHP_functions WHERE id = '".$fourohfourmsg."';");
37
+ $fourohfourmsg = $fourohfourmsg[0]->function;
38
+ }
39
+ else{
40
+ $fourohfourmsg = '<span style="font-weight:bold; color:red">Error 404: Function Not Found</span>';
41
+ }
42
+ $id = $args['function'];
43
+ $sql = "SELECT function FROM ".$wpdb->prefix."allowPHP_functions WHERE id='".$id."'";
44
+ $res = $wpdb->get_results($wpdb->prepare($sql));
45
+ if(sizeof($res) == 0){ if($show404 == 1){$content = $fourohfourmsg;}}
46
+ else{$content = $res[0]->function;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
48
+ ob_start();
49
+ eval ($content);
50
+ if($args['debug'] == 1){
51
+ $content =(htmlspecialchars($content,ENT_QUOTES));
52
+ echo ("<pre>".$content."</pre>");
53
+ }
54
  $returned = ob_get_clean();
55
  return $returned;
56
  }
57
 
58
  function allow_php_menu(){
59
+ add_menu_page( "Allow PHP in posts and pages", "Allow PHP in posts", "manage_options", "allow-php-menu", "allowPHP_functions");
60
+ add_submenu_page('allow-php-menu','Information', 'Information', 'manage_options', 'allow-php-information', 'allow_php_information');
61
+ add_submenu_page('allow-php-menu','Information', 'Information', 'manage_options', 'allow-php-information', 'allow_php_information');
62
  }
63
+
64
+ function allow_php_information(){
65
  ?>
66
+ <h1>Allow PHP in Posts and Pages</h1>
67
+ <div style='width:1145px;'>
68
+ <div style='width:500px; float:right;'>
69
+ <div style='float:right; display:inline; width:450px; margin-left:25px; margin-bottom:10px; margin-right:15px; padding:10px; -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;-webkit-box-shadow: #666 2px 2px 5px;-moz-box-shadow: #666 2px 2px 5px;box-shadow: #666 2px 2px 5px;background: #ffff00;background: -webkit-gradient(linear, 0 0, 0 bottom, from(#ffff00), to(#ffffcc));background: -moz-linear-gradient(#ffff00, #ffffcc);background: linear-gradient(#ffff00, #ffffcc);'>
70
+ <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'><strong>Developed by <a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'>Hit Reach</a></strong><a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'></a></span>
71
+ <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'><strong>Check out our other <a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'>Wordpress Plugins</a></strong><a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'></a></span>
72
+ <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'><strong>Version: 2.0.0 <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>Support, Comments &amp; Questions</a></strong></span>
73
+ <hr/>
74
+ <h2>Please help! We need your support...</h2>
75
+ <p>If this plugin has helped you, your clients or customers then please take a moment to 'say thanks'. </p>
76
+ <p>By spreading the word you help increase awareness of us and our plugins which makes it easier to justify the time we spend on this project.</p>
77
+ <p>Please <strong>help us keep this plugin free</strong> to use and allow us to provide on-going updates and support.</p>
78
+ <p>Here are some quick, easy and free things you can do which all help and we would really appreciate.</p>
79
+ <ol>
80
+ <li>
81
+ <strong>Promote this plugin on Twitter</strong><br/>
82
+ <a href="http://twitter.com/home?status=I'm using the Allow PHP in Posts and Pages WordPress plugin by @hitreach and it rocks! You can download it here: http://bit.ly/e2Q4Az" target="_blank">
83
+ <img src='<?php echo APIP_URL;?>/twitter.gif' border="0" width='55' height='20'/>
84
+ </a><br/><br/>
85
+ </li>
86
+ <li>
87
+ <strong>Link to us</strong><br/>
88
+ By linking to <a href='http://www.hitreach.co.uk' target="_blank">www.hitreach.co.uk</a> from your site or blog it means you can help others find the plugin on our site and also let Google know we are trust and link worthy which helps our profile.<br/><br/>
89
+ </li>
90
+ <li>
91
+ <strong>Like us on Facebook</strong><br/>
92
+ Just visit <a href='http://www.facebook.com/webdesigndundee' target="_blank">www.facebook.com/webdesigndundee</a> and hit the 'Like!' button!<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.facebook.com/webdesigndundee" send="true" width="450" show_faces="false" action="like" font="verdana"></fb:like><br/><br/>
93
+ </li>
94
+ <li>
95
+ <strong>Share this plugin on Facebook</strong><br/>
96
+ <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages" send="true" width="450" show_faces="false" action="recommend" font="verdana"></fb:like>
97
+ Share a link to the plugin page with your friends on Facebook<br/><br/>
98
+ </li>
99
+ <li>
100
+ <strong>Make A Donation</strong><br/>
101
+ Ok this one isn't really free but hopefully it's still a lot cheaper than if you'd had to buy the plugin or pay for it to be made for your project. Any amount is appreciated
102
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
103
+ <input type="hidden" name="cmd" value="_donations">
104
+ <input type="hidden" name="business" value="admin@hitreach.co.uk">
105
+ <input type="hidden" name="lc" value="GB">
106
+ <input type="hidden" name="item_name" value="Hit Reach">
107
+ <input type="hidden" name="item_number" value="APIP-Plugin">
108
+ <input type="hidden" name="no_note" value="0">
109
+ <input type="hidden" name="currency_code" value="GBP">
110
+ <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
111
+ <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
112
+ <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
113
+ </form>
114
+ </li>
115
+ </ol>
116
+ </div>
117
+ </div>
118
+ <script type="text/javascript">
119
+ var APIP_current = "APIP_general";
120
+ var APIP_currentTab = "APIP_generalTab";
121
+ function APIP_changeTab(APIP_new, APIP_newTab){
122
+ document.getElementById(APIP_current).style.display="none";
123
+ document.getElementById(APIP_currentTab).className="APIP_tab";
124
+ document.getElementById(APIP_new).style.display="block";
125
+ document.getElementById(APIP_newTab).className="APIP_currentTab";
126
+ APIP_current = APIP_new;
127
+ APIP_currentTab = APIP_newTab;
128
+ }
129
+ </script>
130
+ <style type="text/css">
131
+ #APIP_navigation{font-size:12px; line-height:25px;}
132
+ #APIP_navigation a.APIP_currentTab, #APIP_navigation a.APIP_tab{padding:5px; border:1px #ddd solid;border-bottom:none; line-height:25px;cursor:pointer;}
133
+ #APIP_navigation a.APIP_currentTab{border:1px #666 solid; border-bottom:1px white solid; background-color:white;}
134
+ #APIP_usage,#APIP_notes,#APIP_tags{display:none;}
135
+ #APIP_navigation, #APIP_container{width:98%; margin:0 auto;}
136
+ #APIP_container{border:1px #ddd solid; background:white; padding:15px;}
137
+ </style>
138
+ <div style='width:630px; float:left;'>
139
+ <div id='APIP_navigation'>
140
+ <a onclick="APIP_changeTab('APIP_general','APIP_generalTab')" name='APIP_generalTab' id='APIP_generalTab' class='APIP_currentTab'>General Information</a>
141
+ <a onclick="APIP_changeTab('APIP_usage','APIP_usageTab')" name='APIP_usageTab' id='APIP_usageTab' class='APIP_tab'>Usage</a>
142
+ <a onclick="APIP_changeTab('APIP_notes','APIP_notesTab')" name='APIP_notesTab' id='APIP_notesTab' class='APIP_tab'>Important Information</a>
143
+ <a onclick="APIP_changeTab('APIP_tags','APIP_tagsTab')" name='APIP_tagsTab' id='APIP_tagsTab' class='APIP_tab'>Tag List</a>
144
+ <a href="?page=allow-php-menu" name='APIP_optionsTab' id='APIP_optionsTab' class='APIP_tab'>Plugin Options</a>
145
+ </div>
146
+ <div id='APIP_container'>
147
+ <div id='APIP_general'>
148
+ <h2>General Information</h2>
149
+ <p>Allow PHP in posts and pages adds the functionality to include PHP in your WordPress posts and pages by adding a simple shortcode <span style='color:green'>[php]</span> <em>your code</em> <span style='color:green'>[/php]</span></p>
150
+ <p>This plugin strips away the automatically generated wordpress &lt;p&gt; and &lt;br/&gt; tags but still allows the addition of your own &lt;p&gt; and &lt;br/&gt; tags using a tag replacement system.</p>
151
+ <p>Also, you can now save your most used PHP codes as &quot;snippets&quot; which you can insert into multiple pages at once.</p>
152
+ </div>
153
+ <div id='APIP_usage'>
154
+ <h2>Usage</h2>
155
+ <p>To add the PHP code to your post or page simply place any PHP code inside the shortcode tags.</p>
156
+ <em>For example: </em>If you wanted to add content that is visible to a particular user id:</p>
157
+ <blockquote>
158
+ [php]<br/>
159
+ &nbsp;&nbsp;&nbsp;global $user_ID;<br/>
160
+ &nbsp;&nbsp;&nbsp;if($user_ID == 1){<br/>
161
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "Hello World";<br/>
162
+ &nbsp;&nbsp;&nbsp;}<br/>
163
+ [/php]
164
+ </blockquote>
165
+ <p><em>This code will output Hello World to only user id #1, and no one else</em></p>
166
+ <p>In addition, should this code not be working (for example a missing ";") simply just change the [php] to be [php debug=1]</p>
167
+ <blockquote>
168
+ [php debug=1]<br/>
169
+ &nbsp;&nbsp;&nbsp;global $user_ID;<br/>
170
+ &nbsp;&nbsp;&nbsp;if($user_ID == 1){<br/>
171
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "Hello World"<br/>
172
+ &nbsp;&nbsp;&nbsp;}<br/>
173
+ [/php]
174
+ </blockquote>
175
+ <p><em>Will result in the output:</em></p>
176
+ <blockquote>
177
+ &nbsp;&nbsp;&nbsp;Parse error: syntax error, unexpected '}', expecting ',' or ';' in XXX : eval()'d code on line 5<br/>
178
+ &nbsp;&nbsp;&nbsp;global $user_ID; <br/>
179
+ &nbsp;&nbsp;&nbsp;if($user_ID == 1){ <br/>
180
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "Hello World" <br/>
181
+ &nbsp;&nbsp;&nbsp;}
182
+ </blockquote>
183
+ </div>
184
+ <div id='APIP_notes'>
185
+ <h2>Some Important Notes</h2>
186
+ <p>This plugin strips away all instances of &lt;p&gt; and &lt;br /&gt; therefore code has been added so that if you wish to use tags in your output (e.g.):</p>
187
+ <blockquote>
188
+ [php]<br/>
189
+ &nbsp;&nbsp;&nbsp;echo "hello &lt;br /&gt; world";<br/>
190
+ [/php]
191
+ </blockquote>
192
+ <p>The &lt; and &gt; tags will need to be swapped for [ and ] respectively so &lt;p&gt; becomes [p] and &lt;/p&gt; becomes [/p] which is converted back to &lt;p&gt; at runtime. these [ ] work for all tags (p, strong, em etc.).</p>
193
+ <blockquote>
194
+ [php]<br/>
195
+ &nbsp;&nbsp;&nbsp;echo "hello [br /] world";<br/>
196
+ [/php]
197
+ </blockquote>
198
+ </div>
199
+ <div id='APIP_tags'>
200
+ <h2>Tag list</h2>
201
+ <table cellpadding="5" cellspacing="1" style='border:1px #ddd solid' width='60%'>
202
+
203
+ <tr>
204
+ <th align="left" style="padding:5px; background:#ffffcc">For</th>
205
+ <th align="left" style="padding:5px; background:#ffffcc">Write as</th>
206
+ </tr>
207
+ <tr>
208
+ <td align="left" style="padding:5px; background:#ffffcc">&lt;p&gt; ... &lt;/p&gt;</td>
209
+ <td align="left" style="padding:5px; background:#ffffcc">[p] ... [/p]</td>
210
+ </tr>
211
+ <tr>
212
+ <td align="left" style="padding:5px; background:#ffffcc">&lt;em&gt;...&lt;/em&gt;</td>
213
+ <td align="left" style="padding:5px; background:#ffffcc">[em]...[/em]</td>
214
+ </tr>
215
+ <tr>
216
+ <td align="left" style="padding:5px; background:#ffffcc">&lt;p style=''&gt; ... &lt;/p&gt;</td>
217
+ <td align="left" style="padding:5px; background:#ffffcc">[p style=''] ... [/p]</td>
218
+ </tr>
219
+ <tr>
220
+ <td align="left" style="padding:5px; background:#ffffcc">&lt;u&gt; ... &lt;/u&gt;</td>
221
+ <td align="left" style="padding:5px; background:#ffffcc">[u] ... [/u]</td>
222
+ </tr>
223
+ <tr>
224
+ <td align="left" style="padding:5px; background:#ffffcc">&lt;br /&gt;</td>
225
+ <td align="left" style="padding:5px; background:#ffffcc">[br /]</td>
226
+ </tr>
227
+
228
+ </table>
229
+ </div>
230
+ </div>
231
+ </div>
232
+ <?php
233
+ }
234
+
235
+ function allowPHP_functions(){
236
+ $options = get_option("allowPHP_options");
237
+ $show404 = $options['show404'];
238
+ global $wpdb;
239
+ $fourohfourmsg = $options['fourohfourmsg'];
240
+ $fourohfourmsg_id = $options['fourohfourmsg'];
241
+ if($fourohfourmsg != 0){
242
+ $fourohfourmsg = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."allowPHP_functions WHERE id = '".$fourohfourmsg."';"));
243
+ $fourohfourmsg = $fourohfourmsg[0]->function;
244
+ }
245
+ else{$fourohfourmsg = '<span style="font-weight:bold; color:red">Error 404: Function Not Found</span>';}
246
 
247
+ $sql = "SELECT * FROM ".$wpdb->prefix."allowPHP_functions";
248
+ $results = $wpdb->get_results($wpdb->prepare($sql));
249
+ ?>
250
+ <script type="text/javascript">
251
+ function confirmMod(id){
252
+ return confirm("Are you sure you want to modify row id: "+id+"?");
253
+ }
254
+ function confirmDel(id){
255
+ return confirm("Are you sure you want to delete row id: "+id+"?");
256
+ }
257
+ </script>
258
+ <h1>Allow PHP in Posts and Pages</h1>
259
+ <div style='width:1145px;'>
260
+ <div style='width:500px; float:right;'>
261
+ <div style='float:right; display:inline;width:450px; margin-left:25px; margin-bottom:10px; margin-right:15px; padding:10px; -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;-webkit-box-shadow: #666 2px 2px 5px;-moz-box-shadow: #666 2px 2px 5px;box-shadow: #666 2px 2px 5px;background: #ffff00;background: -webkit-gradient(linear, 0 0, 0 bottom, from(#ffff00), to(#ffffcc));background: -moz-linear-gradient(#ffff00, #ffffcc);background: linear-gradient(#ffff00, #ffffcc);'>
262
+ <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'><strong>Developed by <a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'>Hit Reach</a></strong><a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'></a></span>
263
+ <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'><strong>Check out our other <a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'>Wordpress Plugins</a></strong><a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'></a></span>
264
+ <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'><strong>Version: 2.0.0 <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>Support, Comments &amp; Questions</a></strong></span>
265
+ <hr/>
266
+ <h2>Please help! We need your support...</h2>
267
+ <p>If this plugin has helped you, your clients or customers then please take a moment to 'say thanks'. </p>
268
+ <p>By spreading the word you help increase awareness of us and our plugins which makes it easier to justify the time we spend on this project.</p>
269
+ <p>Please <strong>help us keep this plugin free</strong> to use and allow us to provide on-going updates and support.</p>
270
+ <p>Here are some quick, easy and free things you can do which all help and we would really appreciate.</p>
271
+ <ol>
272
+ <li>
273
+ <strong>Promote this plugin on Twitter</strong><br/>
274
+ <a href="http://twitter.com/home?status=I'm using the Allow PHP in Posts and Pages WordPress plugin by @hitreach and it rocks! You can download it here: http://bit.ly/e2Q4Az" target="_blank">
275
+ <img src='<?php echo APIP_URL;?>/twitter.gif' border="0" width='55' height='20'/>
276
+ </a><br/><br/>
277
+ </li>
278
+ <li>
279
+ <strong>Link to us</strong><br/>
280
+ By linking to <a href='http://www.hitreach.co.uk' target="_blank">www.hitreach.co.uk</a> from your site or blog it means you can help others find the plugin on our site and also let Google know we are trust and link worthy which helps our profile.<br/><br/>
281
+ </li>
282
+ <li>
283
+ <strong>Like us on Facebook</strong><br/>
284
+ Just visit <a href='http://www.facebook.com/webdesigndundee' target="_blank">www.facebook.com/webdesigndundee</a> and hit the 'Like!' button!<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.facebook.com/webdesigndundee" send="true" width="450" show_faces="false" action="like" font="verdana"></fb:like><br/><br/>
285
+ </li>
286
+ <li>
287
+ <strong>Share this plugin on Facebook</strong><br/>
288
+ <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages" send="true" width="450" show_faces="false" action="recommend" font="verdana"></fb:like>
289
+ Share a link to the plugin page with your friends on Facebook<br/><br/>
290
+ </li>
291
+ <li>
292
+ <strong>Make A Donation</strong><br/>
293
+ Ok this one isn't really free but hopefully it's still a lot cheaper than if you'd had to buy the plugin or pay for it to be made for your project. Any amount is appreciated
294
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
295
+ <input type="hidden" name="cmd" value="_donations">
296
+ <input type="hidden" name="business" value="admin@hitreach.co.uk">
297
+ <input type="hidden" name="lc" value="GB">
298
+ <input type="hidden" name="item_name" value="Hit Reach">
299
+ <input type="hidden" name="item_number" value="APIP-Plugin">
300
+ <input type="hidden" name="no_note" value="0">
301
+ <input type="hidden" name="currency_code" value="GBP">
302
+ <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
303
+ <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
304
+ <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
305
+ </form>
306
+ </li>
307
+ </ol>
308
+ </div>
309
+ </div>
310
+ <script type="text/javascript">
311
+ var APIP_current = "APIP_general";
312
+ var APIP_currentTab = "APIP_generalTab";
313
+ function APIP_changeTab(APIP_new, APIP_newTab){
314
+ document.getElementById(APIP_current).style.display="none";
315
+ document.getElementById(APIP_currentTab).className="APIP_tab";
316
+ document.getElementById(APIP_new).style.display="block";
317
+ document.getElementById(APIP_newTab).className="APIP_currentTab";
318
+ APIP_current = APIP_new;
319
+ APIP_currentTab = APIP_newTab;
320
+ }
321
+ </script>
322
+ <style type="text/css">
323
+ #APIP_navigation{font-size:12px; line-height:25px;}
324
+ #APIP_navigation a.APIP_currentTab, #APIP_navigation a.APIP_tab{padding:5px; border:1px #ddd solid;border-bottom:none; line-height:25px;cursor:pointer;}
325
+ #APIP_navigation a.APIP_currentTab{border:1px #666 solid; border-bottom:1px white solid; background-color:white;}
326
+ #APIP_usage,#APIP_notes,#APIP_tags{display:none;}
327
+ #APIP_navigation, #APIP_container{width:98%; margin:0 auto;}
328
+ #APIP_container{border:1px #ddd solid; background:white; padding:15px;}
329
+ </style>
330
+ <div style='width:630px; float:left;'>
331
+ <div id='APIP_navigation'>
332
+ <a onclick="APIP_changeTab('APIP_general','APIP_generalTab')" name='APIP_generalTab' id='APIP_generalTab' class='APIP_currentTab'>Plugin Options</a>
333
+ <a onclick="APIP_changeTab('APIP_usage','APIP_usageTab')" name='APIP_usageTab' id='APIP_usageTab' class='APIP_tab'>Code Snippets</a>
334
+ <a href='?page=allow-php-information' name='APIP_notesTab' id='APIP_notesTab' class='APIP_tab'>Plugin Information</a>
335
+ </div>
336
+ <div id='APIP_container'>
337
+ <div id='APIP_general'>
338
+ <h2>Plugin Options</h2>
339
+ <form action='<?php echo WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/';?>alter.php' method="post">
340
+ <?php wp_nonce_field( plugin_basename(__FILE__), 'allowPHPNonce' ); ?>
341
+ <input type="hidden" name='action' value='options' />
342
+ <input type="hidden" name="id" value="0" />
343
+ <p>Current 404 message: <?php echo htmlentities($fourohfourmsg);?></p>
344
+ <label for="show404">Show the snippet not found message?: </label><input type='checkbox' name='option_show404' value='1' <?php if($show404 == 1)echo "checked='checked'";?> /><br/>
345
+ <label for="fourohfourmsg">Custom 404 message to be displayed: </label>
346
+ <select name='option_404msg'>
347
+ <option value='0'> - Default Message - </option>
348
+ <?php
349
+ $res = "SELECT * FROM ".$wpdb->prefix."allowPHP_functions";
350
+ $res = $wpdb->get_results($res);
351
+ foreach($res as $row){
352
+ echo "<option value='".$row->id."'";
353
+ if($row->id == $fourohfourmsg_id){echo "selected='selected'";}
354
+ echo"> - Snippet ID: ".$row->id." - </option>";
355
+ }
356
+ ?>
357
+ </select>
358
+ <br/>
359
+ <input type='submit' class='button-primary' value='Save Plugin Options' />
360
+ </form>
361
+ </div>
362
+ <div id='APIP_usage'>
363
+ <h2>Code Snippets</h2>
364
+ <p><em>All snippets begin with a <span style='color:red'>&lt;?php</span> and end with a <span style='color:red'>?&gt;</span>So if you wish to use html only you will need to close the php tag, then re-open it at the end.</em></p>
365
+ <table cellpadding='5' cellspacing='0' width="600">
366
+ <?php if(sizeof($results) != 0){?>
367
+ <tr>
368
+ <th width='35' style='border-right:1px #ddd solid;'>ID</th>
369
+ <th width="15"></th>
370
+ <th width="475" align="left">Snippet</th>
371
+ <th width="75" align="right">&nbsp;</th>
372
+ </tr>
373
+ <tr>
374
+ <td style='border-right:1px #ddd solid;' height="10"></td>
375
+ <td colspan='3'></td>
376
+ </tr>
377
+ <?php foreach($results as $row){ ?>
378
+ <tr>
379
+ <th align='center' valign="top" scope="row" style='border-right:1px #ddd solid;'>
380
+ <?php echo $row->id; ?>
381
+ </th>
382
+ <td></td>
383
+ <td align="left" valign="top">
384
+ <form action='<?php echo WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/';?>alter.php' method="post" onsubmit="return confirmMod(<?php echo $row->id; ?>)">
385
+ <?php wp_nonce_field( plugin_basename(__FILE__), 'allowPHPNonce' ); ?>
386
+ <input type='submit' value='Modify' class='button-secondary' style='float:right;' />
387
+ <input type='hidden' name='action' value='modify' />
388
+ <input type='hidden' name='id' value='<?php echo $row->id; ?>' />
389
+ <strong>Name:</strong>
390
+ <input type='text' name='name' value='<?php echo $row->name;?>' onblur="javascript:this.style.textDecoration='none'; this.style.cursor='pointer'" onclick="javascript:this.style.textDecoration='underline'; this.style.cursor='text';" title="Click to edit" maxlength="99" style='width:370px; border:0px white solid !important;cursor:pointer; background:none !important;'/><br/>
391
+ <span style='color:red; vertical-align:top;'>&lt;?php</span><textarea style="width:475px" rows="2" name='function'><?php echo $row->function; ?></textarea><span style='color:red'>?&gt;</span>
392
+ <br/>
393
+
394
+ </form>
395
+ </td>
396
+ <td align="left" valign="top">
397
+ <form action='<?php echo WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/';?>alter.php' method="post" onsubmit="return confirmDel(<?php echo $row->id; ?>)">
398
+ <?php wp_nonce_field( plugin_basename(__FILE__), 'allowPHPNonce' ); ?>
399
+ <input type='hidden' name='action' value='delete' />
400
+ <input type='hidden' name='id' value='<?php echo $row->id; ?>' />
401
+ &nbsp;|&nbsp;<input type='submit' value='Delete' class='button-secondary' />
402
+ </form>
403
+
404
+ </td>
405
+ </tr>
406
+ <tr><td style='border-right:1px #ddd solid;' height="20"></td><td colspan='3'></td></tr>
407
+
408
+ <?php
409
+ }}else{?>
410
+ <tr><td style='border-right:1px #ddd solid;'></td>
411
+ <td colspan='3' align="center"><em>No Snippets Found</em></td></tr>
412
+ <tr><td style='border-right:1px #ddd solid;' height="20"></td><td colspan='3'></td></tr>
413
+ <?php }?>
414
+ <tr><td style='border-right:1px #ddd solid;' height="20"></td><td colspan='3' style='border-top:1px #ddd solid;'></td></tr>
415
+ <tr>
416
+ <th width="35" style='border-right:1px #ddd solid;'>&nbsp;</th><th width="15"></th>
417
+ <th width="475" align="left"><h3>Add A New Snippet</h3></th>
418
+ <th width="75" align="right">&nbsp;</th></tr>
419
+ <tr><td height="123" style='border-right:1px #ddd solid;'></td><td></td><td colspan="2" >
420
+ <form action='<?php echo WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/';?>alter.php' method="post">
421
+ <?php wp_nonce_field( plugin_basename(__FILE__), 'allowPHPNonce' ); ?>
422
+ <input type='hidden' name='action' value='add' />
423
+ <input type='hidden' name='id' value='0' />
424
+ <input type='submit' value='Save Snippet' class='button-primary' style='float:right;' />
425
+ <strong>Name: </strong><input type='text' name='name' id='name' style='width:405px;' maxlength="100" />
426
+ <br/>
427
+ <span style='color:red;vertical-align:top;'>&lt;?php</span><textarea style='width:550px' rows='3' name='function'></textarea><span style='color:red'>?&gt;</span><br/>
428
+ </form></td></tr>
429
+ </table>
430
+ </div>
431
+ </div>
432
+ </div>
433
+ </div>
434
  <?php
435
  }
436
+
437
+ function allowPHP_activate(){
438
+ global $wpdb;
439
+ global $dbVersion;
440
+ $options = get_option("allowPHP_options");
441
+ $installedVersion = $options['dbVersion'];
442
+ $show404 = 1;
443
+ $fourohfourmsg = 0;
444
+ if(isset($options['show404'])){
445
+ $show404 = $options['show404'];
446
+ }
447
+ if(isset($options['fourohfourmsg'])){
448
+ $fourohfourmsg = $options['fourohfourmsg'];
449
+ }
450
+ if($installedVersion != $dbVersion){
451
+ $sql = "CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."allowPHP_functions(
452
+ id int NOT NULL AUTO_INCREMENT,
453
+ name varchar(100) NOT NULL,
454
+ function text NOT NULL,
455
+ PRIMARY KEY(id)
456
+ );";
457
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
458
+ dbDelta($sql);
459
+ }
460
+
461
+ $options = array("show404" => $show404,"fourohfourmsg" => $fourohfourmsg, "dbVersion" => $dbVersion);
462
+ update_option("allowPHP_options", $options);
463
+ }
464
+
465
+
466
+
467
+ function add_APIP_button() {
468
+ if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ){
469
+ return;
470
+ }
471
+ if ( get_user_option('rich_editing') == 'true') {
472
+ add_filter('mce_external_plugins', 'add_APIP_tinymce_plugin');
473
+ add_filter('mce_buttons', 'register_APIP_button');
474
+ }
475
+ }
476
+
477
+ define( "APIP_PLUGIN_DIR", "allow-php-in-posts-and-pages" );
478
+ define( "APIP_PLUGIN_URL", get_bloginfo('url')."/wp-content/plugins/" . APIP_PLUGIN_DIR );
479
+
480
+ function register_APIP_button($buttons) {
481
+ array_push($buttons, "|", "allowPHP");
482
+ return $buttons;
483
+ }
484
+ function add_APIP_tinymce_plugin($plugin_array) {
485
+ $plugin_array['allowPHP'] = APIP_PLUGIN_URL . '/AP.js';
486
+ return $plugin_array;
487
+ }
488
+
489
+ function APIP_my_refresh_mce($ver) {
490
+ $ver += 2;
491
+ return $ver;
492
+ }
493
+ add_action('init', 'add_APIP_button');
494
+ add_filter( 'tiny_mce_version', 'APIP_my_refresh_mce');
495
+
496
  ?>
alter.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once("../../../wp-config.php");
3
+ include_once("../../../wp-load.php");
4
+ include_once("../../../wp-includes/wp-db.php");
5
+ global $wpdb;
6
+ $refer = $_SERVER['HTTP_REFERER'];
7
+ if(!isset($_POST['allowPHPNonce'])){
8
+ if ( !wp_verify_nonce( $_POST['allowPHPNonce'], plugin_basename(__FILE__) )) {header("location:".$refer);}
9
+ }
10
+ else{
11
+ if(!isset($_POST['action']) || !defined ('ABSPATH')){header("location:".$refer);}
12
+ if(isset($_POST['id'])){$id = $_POST['id'];}else{$id='0';}
13
+ if(isset($_POST['function'])){$function = $_POST['function'];}else{$function="";}
14
+ if(isset($_POST['name'])){$name = $_POST['name'];}else{$name="";}
15
+ $action = $_POST['action'];
16
+
17
+ #delete
18
+ if($action == "delete"){
19
+ $sql = "delete from ".$wpdb->prefix."allowPHP_functions WHERE id='".$id."'";
20
+ $wpdb->query($wpdb->prepare($sql));
21
+ header("location:".$refer);
22
+ }
23
+ #add
24
+ elseif($action == "add" && $function != ""){
25
+ $sql = "insert into ".$wpdb->prefix."allowPHP_functions (function,name) values('".$function."','".$name."')";
26
+ $results = $wpdb->get_results($wpdb->prepare($sql));
27
+ header("location:".$refer);
28
+ }
29
+ #modify
30
+ elseif($action == "modify" && $function != ""){
31
+ $sql = "update ".$wpdb->prefix."allowPHP_functions set function='".$function."', name='".$name."' where id = ".$id;
32
+ $results = $wpdb->get_results($wpdb->prepare($sql));
33
+ header("location:".$refer);
34
+ }
35
+ elseif($action == "options" && isset($_POST['option_404msg'])){
36
+ if(isset($_POST["option_show404"])){$show404 = $_POST['option_show404'];}else{$show404 = 0;}
37
+ if(isset($_POST["option_404msg"])){$fourohfourmsg = $_POST['option_404msg'];}else{$show404 = 0;}
38
+ $options = get_option("allowPHP_options");
39
+ $options = unserialize($options);
40
+ $options['show404'] = $show404;
41
+ $options['fourohfourmsg'] = $fourohfourmsg;
42
+ update_option("allowPHP_options", $options);
43
+ }
44
+ }
45
+ header("location:".$refer."&noaction");
46
+ ?>
ap.png ADDED
Binary file
twitter.gif ADDED
Binary file