Advertisement
Guest User

Untitled

a guest
Jul 14th, 2010
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 63.75 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Secure invitation plugin for Wordpress MU and BuddyPress, "secure_invite"
  4. Description: Stops public signup on your Wordpress MU or BuddyPress site, but allows users to email and invite their friend to join your blog community. This plugin is based on a plugin by kt (Gord), from http://www.ikazoku.com.
  5. Version: 0.9.6
  6. Author: Chris Taylor
  7. Author URI: http://www.stillbreathing.co.uk
  8. Plugin URI: http://www.stillbreathing.co.uk/wordpress/wordpress-mu-secure-invites/
  9. Date: 2010-03-25
  10. */
  11.  
  12. // when the admin menu is built
  13. add_action('admin_menu', 'secure_invites_add_admin');
  14.  
  15. // when the admin head is built
  16. add_action('admin_head', 'secure_invites_add_admin_js');
  17.  
  18. // when a user is registered
  19. add_action('user_register', 'secure_invite_user_registered');
  20.  
  21. // add the template action
  22. add_action('init', 'secure_invite_buddypress_theme_page');
  23.  
  24. // show the right theme page
  25. function secure_invite_buddypress_theme_page() {
  26. if (defined("BP_CORE_DB_VERSION") && strpos($_SERVER["REQUEST_URI"], "/send-secure-invite") !== false) {
  27. get_header();
  28. echo '
  29. <div id="content">
  30. <div class="padder">
  31. <h1>' . __("Invite a friend", "secure_invite") . '</h1>
  32. ';
  33. // if an email has been supplied
  34. if (@$_POST['invite-email'] != "" && is_email($_POST['invite-email'])) {
  35. // if the invite can be sent
  36. if (secure_invite_send()) {
  37. // show the success message
  38. echo '<div id="message" class="updated"><p>' . __("Thanks, your invitation has been sent", "secure_invite") . '</p></div>';
  39. secure_invite_buddypress_form(true, false);
  40. } else {
  41. // show the error message
  42. echo '<div id="message" class="error"></p>' . __("Sorry, your invitation could not be sent. Perhaps this email address is already registered. Please try again.", "secure_invite") . '</p></div>';
  43. secure_invite_buddypress_form(true, true);
  44. }
  45. } else {
  46. echo '<div id="message" class="error"><p>' . __("You must supply a valid email address. Please try again.", "secure_invite") . '</p></div>';
  47. secure_invite_buddypress_form(true, true);
  48. }
  49. echo '
  50. </div><!-- .padder -->
  51. </div><!-- #content -->
  52. ';
  53. locate_template( array( 'sidebar.php' ), true );
  54. get_footer();
  55. exit();
  56. }
  57. }
  58.  
  59. // add actions for Buddypress
  60. function secure_invite_add_buddypress_theme_actions() {
  61. $actionlist = stripslashes( get_site_option("secure_invite_buddypress_theme_actions") );
  62. if ($actionlist != "") {
  63. if (strpos($actionlist, ",") !== false) {
  64. $actions = explode(",", $actionlist);
  65. foreach($actions as $action) {
  66. add_action($action, 'secure_invite_buddypress_form');
  67. }
  68. } else {
  69. add_action($actionlist, 'secure_invite_buddypress_form');
  70. }
  71. add_action("wp_head", "secure_invite_buddypress_head_js");
  72. }
  73. }
  74. secure_invite_add_buddypress_theme_actions();
  75.  
  76. function secure_invite_buddypress_head_js() {
  77. echo '
  78. <script type="text/javascript">
  79. jQuery(document).ready(function(){
  80. jQuery("div.secure_invite_form_wrapper").hide();
  81. jQuery("a.secure_invite_toggler").click(function(){
  82. jQuery(jQuery(this).attr("href")).toggle("normal");
  83. return false;
  84. });
  85. });
  86. </script>
  87. ';
  88. }
  89.  
  90. // when wp-signup.php or another restricted page is requested, and open signup is disabled
  91. if (secure_invite_is_restricted_page() && stripslashes( get_site_option("secure_invite_open_signup") ) != "1")
  92. {
  93. // set the signup request as not valid
  94. $valid = false;
  95.  
  96. // check the email address is a valid invitation
  97. if (isset($_SERVER["QUERY_STRING"]) && (secure_invites_is_valid_email($_SERVER["QUERY_STRING"]) || secure_invites_is_valid_email(trim(@$_POST["user_email"])))) {
  98. $valid = true;
  99. if ($_SERVER["QUERY_STRING"] != "") {
  100. $_POST['user_email'] = $_SERVER["QUERY_STRING"];
  101. }
  102. }
  103.  
  104. // if the signup request is not valid
  105. if (!$valid) {
  106. // show the message
  107. $secure_invite_no_invite_message = stripslashes( get_site_option("secure_invite_no_invite_message") );
  108. if ($secure_invite_no_invite_message == "") { $secure_invite_no_invite_message = secure_invite_default_setting("secure_invite_no_invite_message"); }
  109. // stop processing
  110. wp_die($secure_invite_no_invite_message);
  111. exit();
  112. }
  113. }
  114.  
  115. // when a user is registered
  116. function secure_invite_user_registered($user_id) {
  117.  
  118. // get the email of the new user
  119. $user = get_userdata($user_id);
  120. $email = $user->user_email;
  121.  
  122. // check if this is an invited email address
  123. $invited = secure_invites_is_valid_email($email);
  124. if ($invited) {
  125.  
  126. // get the id of the level 1 inviter
  127. $inviterid_1 = secure_invite_get_inviter_id($email);
  128. // increase the level 1 inviter points by 5
  129. $points_1 = (int)get_usermeta($inviterid_1, "secure_invite_points");
  130. update_usermeta($inviterid_1, "secure_invite_points", ($points_1+5));
  131. // get the inviter 1 email
  132. $inviter_1 = get_userdata($inviterid_1);
  133. $email_1 = $inviter_1->user_email;
  134.  
  135. // get the id of the level 2 inviter
  136. $inviterid_2 = secure_invite_get_inviter_id($email_1);
  137.  
  138. // if they were invited
  139. if ($inviterid_2 != "") {
  140.  
  141. // increase the level 2 inviter points by 2
  142. $points_2 = (int)get_usermeta($inviterid_2, "secure_invite_points");
  143. update_usermeta($inviterid_2, "secure_invite_points", ($points_2+2));
  144. // get the inviter 2 email
  145. $inviter_2 = get_userdata($inviterid_2);
  146. $email_2 = $inviter_2->user_email;
  147.  
  148. // get the id of the level 3 inviter
  149. $inviterid_3 = secure_invite_get_inviter_id($email_2);
  150.  
  151. // if they were invited
  152. if ($inviterid_3 != "") {
  153.  
  154. // increase the level 3 inviter points by 1
  155. $points_3 = (int)get_usermeta($inviterid_3, "secure_invite_points");
  156. update_usermeta($inviterid_3, "secure_invite_points", ($points_3+1));
  157.  
  158. }
  159. }
  160. }
  161. }
  162.  
  163. // get the inviter user id of an email address
  164. function secure_invite_get_inviter_id($email) {
  165. global $wpdb;
  166. $sql = $wpdb->prepare("select user_id from ".$wpdb->base_prefix."invitations where invited_email = '%s';", $email);
  167. return $wpdb->get_var($sql);
  168. }
  169.  
  170. // check if this is a restricted page
  171. function secure_invite_is_restricted_page() {
  172. $secure_invite_signup_page = stripslashes( get_site_option("secure_invite_signup_page") );
  173. if ( $secure_invite_signup_page == "" ) { $secure_invite_signup_page = secure_invite_default_setting("secure_invite_signup_page"); }
  174. if ( strpos( $secure_invite_signup_page, "," ) !== false ) {
  175. $pages = explode( ",", $secure_invite_signup_page );
  176. foreach( $pages as $page ) {
  177. if ( strpos( $_SERVER["REQUEST_URI"], $page ) !== false ) {
  178. return true;
  179. }
  180. }
  181. } else {
  182. if ( strpos( $_SERVER["REQUEST_URI"], $secure_invite_signup_page ) !== false ) {
  183. return true;
  184. }
  185. }
  186. return false;
  187. }
  188.  
  189. // check an email address has been invited
  190. function secure_invites_is_valid_email($email) {
  191. if ($email && is_email($email))
  192. {
  193. $timelimit = stripslashes( get_site_option("secure_invite_signup_time_limit") );
  194. if ($timelimit == "")
  195. {
  196. // default time limit of 3 days
  197. $timelimit = 3;
  198. }
  199. global $wpdb;
  200. $sql = $wpdb->prepare("select count(id) from ".$wpdb->base_prefix."invitations where invited_email = '%s' and UNIX_TIMESTAMP(datestamp) > %d;", $email, (time()-($timelimit*60*60*24)));
  201. $invites = $wpdb->get_var($sql);
  202.  
  203. if ($invites == "0")
  204. {
  205. return false;
  206. } else {
  207. return true;
  208. }
  209. } else {
  210. return false;
  211. }
  212. }
  213.  
  214. // add the admin invitation button
  215. function secure_invites_add_admin() {
  216. $secure_invite_show_admin_link = stripslashes( get_site_option("secure_invite_show_admin_link") );
  217. if ($secure_invite_show_admin_link == "") { $secure_invite_show_admin_link = "yes"; }
  218. // if the user can send invites
  219. if (secure_invite_user_can_invite() && $secure_invite_show_admin_link == "yes")
  220. {
  221. add_submenu_page('index.php', __('Invite friends', "secure_invite"), __('Invite friends', "secure_invite"), 0, 'secure_invite', 'secure_invite_admin');
  222. }
  223. add_submenu_page('wpmu-admin.php', __('Invites', "secure_invite"), __('Invites', "secure_invite"), 10, 'secure_invite_list', 'secure_invite_list');
  224. }
  225.  
  226. function secure_invites_add_admin_js() {
  227. if ($_GET["page"] == "secure_invite_list" && $_GET["view"] == "settings"){
  228. echo '
  229. <script type="text/javascript">
  230. jQuery(document).ready(function(){
  231. jQuery("#secure_invites_custom_settings_form").hide();
  232. jQuery("#secure_invite_preset_1,#secure_invite_preset_2,#secure_invite_preset_3,#secure_invite_preset_4").click(function(){
  233. if (jQuery("#secure_invites_custom_settings_form").is(":visible")) {
  234. jQuery("#secure_invites_custom_settings_form").slideUp("normal");
  235. jQuery("#secure_invite_save_preset").removeAttr("disabled");
  236. }
  237. });
  238. jQuery("#secure_invite_preset_5").click(function(){
  239. jQuery("#secure_invites_custom_settings_form").slideDown("normal");
  240. jQuery("#secure_invite_save_preset").attr("disabled", true);
  241. });
  242. });
  243. </script>
  244. ';
  245. }
  246. }
  247.  
  248. // add the list of invitations
  249. function secure_invite_list()
  250. {
  251. if (@$_GET["view"] == "") {
  252.  
  253. secure_invite_list_page();
  254.  
  255. } else if (@$_GET["view"] == "settings") {
  256.  
  257. secure_invite_settings();
  258.  
  259. } else if (@$_GET["view"] == "users") {
  260.  
  261. secure_invite_users();
  262.  
  263. }
  264.  
  265. secure_invite_wp_plugin_standard_footer( "GBP", "Secure invites", "Chris Taylor", "chris@stillbreathing.co.uk", "http://wordpress.org/extend/plugins/wordpress-mu-secure-invites/" );
  266. echo '</div>';
  267. }
  268.  
  269. // return a default setting
  270. function secure_invite_default_setting($name) {
  271.  
  272. if ($name == "secure_invite_days_after_joining") { return "30"; }
  273.  
  274. if ($name == "secure_invite_signup_page") { return "wp-signup.php,/register"; }
  275.  
  276. if ($name == "secure_invite_registration_page") { return trim(get_bloginfo("wpurl"), '/') . "/wp-signup.php"; }
  277.  
  278. if ($name == "secure_invite_no_invite_message") { return "Sorry, you must be invited to join this community."; }
  279.  
  280. if ($name == "secure_invite_signup_time_limit") { return 3; }
  281.  
  282. if ($name == "secure_invite_invite_limit") { return 0; }
  283.  
  284. if ($name == "secure_invite_show_admin_link") { return "yes"; }
  285.  
  286. if ($name == "secure_invite_default_message") { return "----------------------------------------------------------------------------------------
  287.  
  288. You have been invited to open a free weblog at [sitename]. To open and register for your weblog today, please visit
  289.  
  290. [signuplink]
  291.  
  292. Regards,
  293.  
  294. [name]
  295.  
  296. This invitation will work for the next [timeout] days. After that your invitation will expire and you will have to be invited again.
  297.  
  298. If clicking the links in this message does not work, copy and paste them into the address bar of your browser."; }
  299.  
  300. if ($name == "secure_invite_buddypress_theme_actions") { return "bp_members_directory_member_types"; }
  301.  
  302. }
  303.  
  304. // show the settings for secure invites
  305. function secure_invite_settings()
  306. {
  307. // check the invites table exists
  308. secure_invite_check_table();
  309.  
  310. if (@$_POST && is_array($_POST) && count($_POST) > 0)
  311. {
  312. // if a preset has been chosen
  313. if ($_POST["secure_invite_preset"] != "" && $_POST["secure_invite_preset"] != "5")
  314. {
  315. // general settings
  316. $_POST["secure_invite_days_after_joining"] = secure_invite_default_setting("secure_invite_days_after_joining");
  317. $_POST["secure_invite_signup_page"] = secure_invite_default_setting("secure_invite_signup_page");
  318. $_POST["secure_invite_registration_page"] = secure_invite_default_setting("secure_invite_registration_page");
  319. $_POST["secure_invite_no_invite_message"] = secure_invite_default_setting("secure_invite_no_invite_message");
  320. $_POST["secure_invite_signup_time_limit"] = secure_invite_default_setting("secure_invite_signup_time_limit");
  321. $_POST["secure_invite_default_message"] = secure_invite_default_setting("secure_invite_default_message");
  322. $_POST["secure_invite_open_signup"] = "1";
  323. $_POST["secure_invite_invite_limit"] = secure_invite_default_setting("secure_invite_invite_limit");
  324. $_POST["secure_invite_show_admin_link"] = secure_invite_default_setting("secure_invite_show_admin_link");
  325.  
  326. // preset 1
  327. if ($_POST["secure_invite_preset"] == "1")
  328. {
  329. $_POST["secure_invite_days_after_joining"] = 0;
  330. $_POST["secure_invite_invite_limit"] = 0;
  331. }
  332. // preset 2
  333. if ($_POST["secure_invite_preset"] == "2")
  334. {
  335. $_POST["secure_invite_days_after_joining"] = 0;
  336. $_POST["secure_invite_invite_limit"] = 0;
  337. $_POST["secure_invite_open_signup"] = "";
  338. }
  339. // preset 3
  340. if ($_POST["secure_invite_preset"] == "3")
  341. {
  342. $_POST["secure_invite_days_after_joining"] = 30;
  343. $_POST["secure_invite_invite_limit"] = 0;
  344. $_POST["secure_invite_open_signup"] = "";
  345. }
  346. // preset 4
  347. if ($_POST["secure_invite_preset"] == "4")
  348. {
  349. $_POST["secure_invite_days_after_joining"] = 30;
  350. $_POST["secure_invite_invite_limit"] = 10;
  351. $_POST["secure_invite_open_signup"] = "";
  352. }
  353. }
  354.  
  355. // save the settings
  356. update_site_option("secure_invite_preset", (int)$_POST["secure_invite_preset"]);
  357. update_site_option("secure_invite_days_after_joining", (int)$_POST["secure_invite_days_after_joining"]);
  358. update_site_option("secure_invite_signup_page", $_POST["secure_invite_signup_page"]);
  359. update_site_option("secure_invite_registration_page", $_POST["secure_invite_registration_page"]);
  360. update_site_option("secure_invite_no_invite_message", trim($_POST["secure_invite_no_invite_message"]));
  361. update_site_option("secure_invite_signup_time_limit", trim($_POST["secure_invite_signup_time_limit"]));
  362. update_site_option("secure_invite_default_message", trim($_POST["secure_invite_default_message"]));
  363. update_site_option("secure_invite_open_signup", trim($_POST["secure_invite_open_signup"]));
  364. update_site_option("secure_invite_invite_limit", trim($_POST["secure_invite_invite_limit"]));
  365. update_site_option("secure_invite_show_admin_link", trim($_POST["secure_invite_show_admin_link"]));
  366. if (isset($_POST["secure_invite_buddypress_theme_actions"])) {
  367. $vals = implode(",", $_POST["secure_invite_buddypress_theme_actions"]);
  368. if (strpos($vals, "bp_nowhere") !== false){ $vals = "bp_nowhere"; }
  369. update_site_option("secure_invite_buddypress_theme_actions", $vals);
  370. }
  371.  
  372. echo '<div id="message" class="updated fade"><p><strong>'.__('The settings have been updated', "secure_invite").'</strong></p></div>';
  373. }
  374.  
  375. $secure_invite_preset = stripslashes( get_site_option("secure_invite_preset") );
  376.  
  377. $secure_invite_days_after_joining = stripslashes( get_site_option("secure_invite_days_after_joining") );
  378. if ($secure_invite_days_after_joining == "") { $secure_invite_days_after_joining = secure_invite_default_setting("secure_invite_days_after_joining"); }
  379.  
  380. $secure_invite_open_signup = stripslashes( get_site_option("secure_invite_open_signup") );
  381. $open_signup = "";
  382. if ($secure_invite_open_signup == "1") { $open_signup = ' checked="checked"'; }
  383.  
  384. $secure_invite_signup_page = stripslashes( get_site_option("secure_invite_signup_page") );
  385. if ($secure_invite_signup_page == "") { $secure_invite_signup_page = secure_invite_default_setting("secure_invite_signup_page"); }
  386.  
  387. $secure_invite_registration_page = stripslashes( get_site_option("secure_invite_registration_page") );
  388. if ($secure_invite_registration_page == "") { $secure_invite_registration_page = secure_invite_default_setting("secure_invite_registration_page"); }
  389.  
  390. $secure_invite_no_invite_message = stripslashes( get_site_option("secure_invite_no_invite_message") );
  391. if ($secure_invite_no_invite_message == "") { $secure_invite_no_invite_message = secure_invite_default_setting("secure_invite_no_invite_message"); }
  392.  
  393. $secure_invite_signup_time_limit = stripslashes( get_site_option("secure_invite_signup_time_limit") );
  394. if ($secure_invite_signup_time_limit == "") { $secure_invite_signup_time_limit = secure_invite_default_setting("secure_invite_signup_time_limit"); }
  395.  
  396. $secure_invite_invite_limit = stripslashes( get_site_option("secure_invite_invite_limit") );
  397. if ($secure_invite_invite_limit == "") { $secure_invite_invite_limit = secure_invite_default_setting("secure_invite_invite_limit"); }
  398.  
  399. $secure_invite_show_admin_link = stripslashes( get_site_option("secure_invite_show_admin_link") );
  400. if ($secure_invite_show_admin_link == "") { $secure_invite_show_admin_link = secure_invite_default_setting("secure_invite_show_admin_link"); }
  401.  
  402. $secure_invite_default_message = stripslashes( get_site_option("secure_invite_default_message") );
  403. if ($secure_invite_default_message == "") { $secure_invite_default_message = secure_invite_default_setting("secure_invite_default_message"); }
  404.  
  405. $secure_invite_buddypress_theme_actions = stripslashes( get_site_option("secure_invite_buddypress_theme_actions") );
  406. if ($secure_invite_buddypress_theme_actions == "") { $secure_invite_buddypress_theme_actions = secure_invite_default_setting("secure_invite_buddypress_theme_actions"); }
  407. $secure_invite_buddypress_theme_actions = $secure_invite_buddypress_theme_actions . ",";
  408.  
  409. echo '<div class="wrap">
  410. <h2>' . __("Invitation settings", "secure_invite") . '
  411. <span style="float:right"><a href="wpmu-admin.php?page=secure_invite_list" class="button">' . __("Invitation list", "secure_invite") . '</a> | <a href="wpmu-admin.php?page=secure_invite_list&amp;view=users" class="button">' . __("Special users", "secure_invite") . '</a></span>
  412. </h2>
  413. <h3>' . __("Settings presets", "secure_invite") . '</h3>
  414. <form action="wpmu-admin.php?page=secure_invite_list&amp;view=settings" method="post">
  415. <ul>
  416. <li><input type="radio" name="secure_invite_preset" id="secure_invite_preset_1" value="1"';
  417. if ($secure_invite_preset == "1"){ echo ' checked="checked"'; }
  418. echo ' /> ' . __("Anyone can join with or without an invitation, and all users can invite as many people as they like", "secure_invites") . '</li>
  419. <li><input type="radio" name="secure_invite_preset" id="secure_invite_preset_2" value="2"';
  420. if ($secure_invite_preset == "2"){ echo ' checked="checked"'; }
  421. echo ' /> ' . __("Signup is just for invited people, and all users can invite as many people as they like", "secure_invites") . '</li>
  422. <li><input type="radio" name="secure_invite_preset" id="secure_invite_preset_3" value="3"';
  423. if ($secure_invite_preset == "3"){ echo ' checked="checked"'; }
  424. echo ' /> ' . __("Signup is just for invited people, and all users who have been registered for 30 days or more can invite as many people as they like", "secure_invites") . '</li>
  425. <li><input type="radio" name="secure_invite_preset" id="secure_invite_preset_4" value="4"';
  426. if ($secure_invite_preset == "4"){ echo ' checked="checked"'; }
  427. echo ' /> ' . __("Signup is just for invited people, and all users who have been registered for 30 days or more can invite up to 10 people", "secure_invites") . '</li>
  428. <li><input type="radio" name="secure_invite_preset" id="secure_invite_preset_5" value="5"';
  429. if ($secure_invite_preset == "5"){ echo ' checked="checked"'; }
  430. echo ' /> ' . __("Use custom settings", "secure_invites") . '</li>
  431. </ul>
  432. <p><button type="submit" name="secure_invite_save_settings" id="secure_invite_save_preset" class="button-primary">' . __("Save this preset", "secure_invite") . '</button></p>
  433. </form>
  434. <div id="secure_invites_custom_settings_form';
  435. if ($secure_invite_preset == "5"){ echo '_custom'; }
  436. echo '">
  437. <h3>' . __("Custom settings", "secure_invite") . '</h3>
  438. <p>' . __("Use custom settings for secure invitations here.", "secure_invite") . '</p>
  439. <form action="wpmu-admin.php?page=secure_invite_list&amp;view=settings" method="post">
  440. <fieldset>
  441.  
  442. <p><label for="secure_invite_show_admin_link" style="float:left;width:30%;">' . __("Show admin link", "secure_invite") . '</label>
  443. <select name="secure_invite_show_admin_link" id="secure_invite_show_admin_link">
  444. <option value="yes"';
  445. if ($secure_invite_show_admin_link == "yes"){ echo ' selected="selected"'; }
  446. echo '">'.__("Yes", "secure_invite").'</option>
  447. <option value="no"';
  448. if ($secure_invite_show_admin_link == "no"){ echo ' selected="selected"'; }
  449. echo '">'.__("No", "secure_invite").'</option>
  450. </select> <span class="description">' . __("Show the invite link in the admin area for normal users", "secure_invite") . '</span></p>
  451.  
  452. <h3 style="padding-top:2em">' . __( "User settings", "secure_invite" ) . '</h3>
  453.  
  454. <p><label for="secure_invite_days_after_joining" style="float:left;width:30%;">' . __("Inviting lockdown (days)", "secure_invite") . '</label>
  455. <input type="text" name="secure_invite_days_after_joining" id="secure_invite_days_after_joining" value="'.$secure_invite_days_after_joining.'" style="width:10%" /> <span class="description">' . __("A user must have been registered for how many days before they can invite friends?", "secure_invite") . '</span></p>
  456.  
  457. <p><label for="secure_invite_invite_limit" style="float:left;width:30%;">' . __("Maximum number of invites per person", "secure_invite") . '</label>
  458. <input type="text" name="secure_invite_invite_limit" id="secure_invite_invite_limit" value="'.$secure_invite_invite_limit.'" style="width:10%" /> <span class="description">' . __('How many invites can each user send (<a href="wpmu-admin.php?page=secure_invite_list&view=users">override this for particular users here</a>)? (set as 0 or blank for unlimited)', "secure_invite") . '</span></p>
  459.  
  460. <h3 style="padding-top:2em">' . __( "Security settings", "secure_invite" ) . '</h3>
  461.  
  462. <p><label for="secure_invite_open_signup" style="float:left;width:30%;">' . __("Open signup", "secure_invite") . '</label>
  463. <input type="checkbox" name="secure_invite_open_signup" id="secure_invite_open_signup"' . $open_signup . ' value="1" /> <span class="description">' . __("Allow anyone to sign up? This disables the security on the signup page", "secure_invite") . '</span></p>
  464.  
  465. <p><label for="secure_invite_signup_page" style="float:left;width:30%;">' . __("Signup page", "secure_invite") . '</label>
  466. <input type="text" name="secure_invite_signup_page" id="secure_invite_signup_page" value="'.$secure_invite_signup_page.'" style="width:60%" /></p>
  467. <p>' . __("What is the address of the signup page? (wp-signup.php is the default). You can put multiple addresses here separated by a comma (,). For example, when using Buddypress you will want to add &quot;wp-signup.php,wp-login.php?action=register,/register&quot;", "secure_invite") . '</p>
  468.  
  469. <h3 style="padding-top:2em">' . __( "Signup settings", "secure_invite" ) . '</h3>
  470.  
  471. <p>' . __("What address do you want the invitation emails to send people to? Please add the full URL to the registration page.", "secure_invite") . '</p>
  472. <p><label for="secure_invite_registration_page" style="float:left;width:30%;">' . __("Signup page", "secure_invite") . '</label>
  473. <input type="text" name="secure_invite_registration_page" id="secure_invite_registration_page" value="'.$secure_invite_registration_page.'" style="width:60%" /></p>
  474.  
  475. <p><label for="secure_invite_signup_time_limit" style="float:left;width:30%;">' . __("Time limit for signups (days)", "secure_invite") . '</label>
  476. <input type="text" name="secure_invite_signup_time_limit" id="secure_invite_signup_time_limit" value="'.$secure_invite_signup_time_limit.'" style="width:10%" /> <span class="description">' . __("How many days would you like an invitation to be open for?", "secure_invite") . '</span></p>
  477.  
  478. <h3 style="padding-top:2em">' . __( "Message settings", "secure_invite" ) . '</h3>
  479.  
  480. <p>' . __("What message do you want to show if someone tries to sign up without being invited?", "secure_invite") . '</p>
  481. <p><label for="secure_invite_no_invite_message" style="float:left;width:30%;">' . __("No invitation message", "secure_invite") . '</label>
  482. <input type="text" name="secure_invite_no_invite_message" id="secure_invite_no_invite_message" value="'.$secure_invite_no_invite_message.'" style="width:60%" /></p>
  483.  
  484. <p>' . __("Enter the message you would like to appear below the users personal message in the invite email. There are four special keywords to enter which are automatically changed when the email is sent. Use these keywords:", "secure_invite") . '</p>
  485. <ul>
  486. <li><code>[sitename]</code> ' . __("where you want the name of your site to appear", "secure_invite") . '</li>
  487. <li><code>[signuplink]</code> ' . __("where you want the special link to the signup form to appear", "secure_invite") . '</li>
  488. <li><code>[name]</code> ' . __("where you want the name of the email sender to appear", "secure_invite") . '</li>
  489. <li><code>[timeout]</code> ' . __("where you want the number of days this invitation is valid to appear", "secure_invite") . '</li>
  490. </ul>
  491. <p><label for="secure_invite_default_message" style="float:left;width:30%;>"' . __("Default message for invites", "secure_invite") . '</label>
  492. <textarea name="secure_invite_default_message" id="secure_invite_default_message" style="width:99%" rows="12" cols="30">'.$secure_invite_default_message.'</textarea></p>
  493. ';
  494.  
  495. if (defined("BP_CORE_DB_VERSION")) {
  496. echo '
  497. <h3 style="padding-top:2em">' . __( "BuddyPress theme settings", "secure_invite" ) . '</h3>
  498. <p>' . __("Where would you like the invitation form to how in your Buddypress site? The form will be hidden by default, and can be shown by clicking a button.", "secure_invite") . '</p>
  499. <ul>
  500. <!--li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_before_members_loop"';
  501. if (strpos($secure_invite_buddypress_theme_actions, "bp_before_members_loop,") !== false){ echo ' checked="checked"'; }
  502. echo ' /> ' . __("Before any list of members", "secure_invite") . '</li-->
  503. <!--li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_after_members_loop"';
  504. if (strpos($secure_invite_buddypress_theme_actions, "bp_after_members_loop,") !== false){ echo ' checked="checked"'; }
  505. echo ' /> ' . __("After any list of members", "secure_invite") . '</li-->
  506. <li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_before_container"';
  507. if (strpos($secure_invite_buddypress_theme_actions, "bp_before_container,") !== false){ echo ' checked="checked"'; }
  508. echo ' /> ' . __("At the top of every page", "secure_invite") . '</li>
  509. <li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_before_blog_home"';
  510. if (strpos($secure_invite_buddypress_theme_actions, "bp_before_blog_home,") !== false){ echo ' checked="checked"'; }
  511. echo ' /> ' . __("Before your site homepage", "secure_invite") . '</li>
  512. <li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_after_blog_home"';
  513. if (strpos($secure_invite_buddypress_theme_actions, "bp_after_blog_home,") !== false){ echo ' checked="checked"'; }
  514. echo ' /> ' . __("After your site homepage", "secure_invite") . '</li>
  515. <li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_inside_before_sidebar"';
  516. if (strpos($secure_invite_buddypress_theme_actions, "bp_inside_before_sidebar,") !== false){ echo ' checked="checked"'; }
  517. echo ' /> ' . __("At the top of the default sidebar", "secure_invite") . '</li>
  518. <li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_inside_after_sidebar"';
  519. if (strpos($secure_invite_buddypress_theme_actions, "bp_inside_after_sidebar,") !== false){ echo ' checked="checked"'; }
  520. echo ' /> ' . __("At the bottom of the default sidebar", "secure_invite") . '</li>
  521. <li><input type="checkbox" name="secure_invite_buddypress_theme_actions[]" value="bp_nowhere"';
  522. if (strpos($secure_invite_buddypress_theme_actions, "bp_nowhere,") !== false){ echo ' checked="checked"'; }
  523. echo ' /> ' . __("Don't use automatic BuddyPress integration", "secure_invite") . '</li>
  524. </ul>
  525. ';
  526. }
  527.  
  528. echo '
  529. <p><button type="submit" name="secure_invite_save_settings" class="button-primary">' . __("Save these settings", "secure_invite") . '</button>
  530. <input type="hidden" name="secure_invite_preset" value="5" /></p>
  531.  
  532. </fieldset>
  533. </form>
  534. </div>
  535. ';
  536.  
  537. echo '</div>
  538. ';
  539. }
  540.  
  541. // show the users admin page
  542. function secure_invite_users()
  543. {
  544.  
  545. global $wpdb;
  546.  
  547. echo '<div class="wrap">
  548. <h2>' . __("User invitation settings", "secure_invite") . '
  549. <span style="float:right"><a href="wpmu-admin.php?page=secure_invite_list" class="button">' . __("Invitation list", "secure_invite") . '</a> | <a href="wpmu-admin.php?page=secure_invite_list&amp;view=settings" class="button">' . __("Settings", "secure_invite") . '</a></span>
  550. </h2>';
  551.  
  552. if (@$_POST && is_array($_POST) && count($_POST) > 0)
  553. {
  554.  
  555. // show the user results
  556. if ($_POST["secure_invite_search_users"] != "")
  557. {
  558.  
  559. $q = trim($_POST["secure_invite_search_users"]);
  560. $sql = "select u.ID, u.user_nicename, u.display_name, u.user_email, u.user_login,
  561. (select count(i.invited_email)
  562. from " . $wpdb->base_prefix . "invitations i
  563. inner join " . $wpdb->users . " s on s.user_email = i.invited_email
  564. where i.user_id = u.ID) as signups,
  565. (select count(invited_email) from " . $wpdb->base_prefix . "invitations
  566. where user_id = u.ID) as invitations
  567. from " . $wpdb->users . " u
  568. where u.user_email like '%" . mysql_real_escape_string($q) . "%'
  569. or u.user_nicename like '%" . mysql_real_escape_string($q) . "%'
  570. or u.display_name like '%" . mysql_real_escape_string($q) . "%'
  571. or u.user_login like '%" . mysql_real_escape_string($q) . "%';";
  572. $users = $wpdb->get_results($sql);
  573. if ($users && is_array($users) && count($users) > 0)
  574. {
  575. echo '
  576. <h3>' . __("Choose a user", "secure_invite") . '</h3>
  577. <table class="widefat" cellspacing="0">
  578. <thead>
  579. <tr>
  580. <th>' . __("Username", "secure_invite") . '</th>
  581. <th>' . __("Nice name", "secure_invite") . '</th>
  582. <th>' . __("Display name", "secure_invite") . '</th>
  583. <th>' . __("Email", "secure_invite") . '</th>
  584. <th>' . __("Invites sent", "secure_invite") . '</th>
  585. <th>' . __("Resulting signups", "secure_invite") . '</th>
  586. </tr>
  587. </thead>
  588. <tbody>
  589. ';
  590. foreach($users as $user)
  591. {
  592. echo '
  593. <tr>
  594. <td><a href="wpmu-admin.php?page=secure_invite_list&amp;view=users&amp;id=' . $user->ID . '">' . $user->user_login . '</a></td>
  595. <td><a href="wpmu-admin.php?page=secure_invite_list&amp;view=users&amp;id=' . $user->ID . '">' . $user->user_nicename . '</a></td>
  596. <td><a href="wpmu-admin.php?page=secure_invite_list&amp;view=users&amp;id=' . $user->ID . '">' . $user->display_name . '</a></td>
  597. <td><a href="wpmu-admin.php?page=secure_invite_list&amp;view=users&amp;id=' . $user->ID . '">' . $user->user_email . '</a></td>
  598. <td>' . $user->invitations . '</td>
  599. <td>' . $user->signups . '</td>
  600. </tr>
  601. ';
  602. }
  603. echo '
  604. </tbody>
  605. </table>
  606. ';
  607. } else {
  608. echo '
  609. <div class="error"><p>' . __("No users found, please try again", "secure_invite") . '</p></div>
  610. ';
  611. }
  612.  
  613. } else {
  614.  
  615. // update the details
  616. $can = "no";
  617. if ($_POST["secure_invite_user_can_invite"] == "1") {
  618. $can = "yes";
  619. }
  620. update_usermeta($_GET["id"], "secure_invite_user_can_invite", $can);
  621. update_usermeta($_GET["id"], "secure_invite_user_invite_limit", "_" .$_POST["secure_invite_user_invite_limit"]);
  622.  
  623. echo '
  624. <div class="updated"><p>' . __("The settings for this user have been saved", "secure_invite") . '</p></div>
  625. ';
  626.  
  627. }
  628.  
  629. }
  630.  
  631. // get a user
  632. if (@$_GET && is_array($_GET) && $_GET["id"] != "")
  633. {
  634.  
  635. $user = get_userdata($_GET["id"]);
  636.  
  637. $can_invite = get_usermeta($_GET["id"], "secure_invite_user_can_invite");
  638. if ($can_invite == "no") {
  639. $can_invite = '';
  640. } else {
  641. $can_invite = ' checked="checked"';
  642. }
  643.  
  644. $invite_limit = trim(get_usermeta($_GET["id"], "secure_invite_user_invite_limit"), "_");
  645.  
  646. $remaining = secure_invite_user_invites_remaining($user->ID);
  647. if ($remaining != "") {
  648. $remaining = "<p>" . $remaining . "</p>";
  649. }
  650.  
  651. echo '
  652. <h3>' . __("Set invite settings for this user", "secure_invite") . '</h3>
  653. <p>' . __("Username", "secure_invite") . ': ' . $user->user_login . '</p>
  654. <p>' . __("Invites sent", "secure_invite") . ': ' . secure_invite_user_sent_invites($user->ID) . '</p>
  655. ' . $remaining . '
  656. <p>' . __("Invites accepted", "secure_invite") . ': ' . (int)secure_invite_user_accepted_invites($user->ID) . '</p>
  657. <p>' . __("Invite points", "secure_invite") . ': ' . (int)get_usermeta($user->ID, "secure_invite_points") . '</p>
  658. <form action="wpmu-admin.php?page=secure_invite_list&amp;view=users&amp;id=' . $_GET["id"] . '" method="post">
  659. <fieldset>
  660. <p><label for="secure_invite_user_can_invite" style="float:left;width:15%;">' . __("Can invite", "secure_invite") . '</label>
  661. <input type="checkbox" name="secure_invite_user_can_invite" id="secure_invite_user_can_invite" value="1"' . $can_invite . ' /> <span class="description">' . __("Can this user send invitations?", "secure_invites") . '</span></p>
  662. <p><label for="secure_invite_user_invite_limit" style="float:left;width:15%;">' . __("Invitation limit", "secure_invite") . '</label>
  663. <input type="text" name="secure_invite_user_invite_limit" id="secure_invite_user_invite_limit" value="' . $invite_limit . '" style="width:10%" /> <span class="description">' . __("Number of invitations this user can send (leave blank to use the global default, or 0 for unlimited)", "secure_invites") . '</span></p>
  664. <p><input type="submit" name="save" class="button-primary" value="' . __("Save settings for this user", "secure_invite") . '" /></p>
  665. </fieldset>
  666. </form>
  667. ';
  668.  
  669. }
  670.  
  671. echo '<h3>' . __("Search users", "secure_invite") . '</h3>
  672. <p>' . __("Search for a user to override their invitation settings.", "secure_invite") . '</p>
  673. <form action="wpmu-admin.php?page=secure_invite_list&amp;view=users" method="post">
  674. <fieldset>
  675. <p><label for="secure_invite_search_users" style="float:left;width:15%;">' . __("Search users", "secure_invite") . '</label>
  676. <input type="text" name="secure_invite_search_users" id="secure_invite_search_users" value="'.@$_POST["secure_invite_search_users"].'" style="width:40%" /> <input type="submit" name="search" class="button" value="' . __("Search users", "secure_invite") . '" /></p>
  677. </fieldset>
  678. </form>
  679.  
  680. </div>
  681. ';
  682. }
  683.  
  684. function secure_invite_list_page()
  685. {
  686. global $wpdb;
  687.  
  688. echo '
  689. <div class="wrap">
  690. ';
  691. secure_invite_wp_plugin_standard_header( "GBP", "Secure invites", "Chris Taylor", "chris@stillbreathing.co.uk", "http://wordpress.org/extend/plugins/wordpress-mu-secure-invites/" );
  692. echo '
  693. <h2>' . __("Secure invites admin", "secure_invite") . '
  694. <span style="float:right"><a href="wpmu-admin.php?page=secure_invite_list&amp;view=settings" class="button">' . __("Settings", "secure_invite") . '</a> | <a href="wpmu-admin.php?page=secure_invite_list&amp;view=users" class="button">' . __("Special users", "secure_invite") . '</a></span>
  695. </h2>
  696. ';
  697.  
  698. // if deleting
  699. if ((isset($_GET["delete"]) && $_GET["delete"] != "") || (isset($_POST["delete"]) && @$_POST["delete"] != ""))
  700. {
  701. if (isset($_GET["delete"]) && $_GET["delete"] != "") {
  702. $sql = "delete from ".$wpdb->base_prefix."invitations
  703. where invited_email = '" . str_replace(" ", "+", urldecode($wpdb->escape($_GET["delete"]))) . "';";
  704. if ($wpdb->query($sql)) {
  705. echo '<div id="message" class="updated fade"><p><strong>' . __("The invitation for this email address has been deleted", "secure_invite") . '</strong></p></div>';
  706. } else {
  707. echo '<div id="message" class="updated fade"><p><strong>' . __("The invitation for this email address could not be deleted", "secure_invite") . '</strong></p></div>';
  708. }
  709. } else {
  710. $emails = str_replace(" ", "+", urldecode(implode("','", $_POST["delete"])));
  711. $sql = "delete from ".$wpdb->base_prefix."invitations
  712. where invited_email in ('" . $emails . "');";
  713. if ($wpdb->query($sql)) {
  714. echo '<div id="message" class="updated fade"><p><strong>' . __("The selected invitations have been deleted", "secure_invite") . '</strong></p></div>';
  715. } else {
  716. echo '<div id="message" class="updated fade"><p><strong>' . __("The selected invitations could not be deleted", "secure_invite") . '</strong></p></div>';
  717. }
  718. }
  719. }
  720.  
  721. // check the invites table exists
  722. secure_invite_check_table();
  723.  
  724. // show the number of invites per month
  725. $sql = "select UNIX_TIMESTAMP(i.datestamp) as date,
  726. count(i.invited_email) as invites,
  727. (select count(i2.invited_email)
  728. from ".$wpdb->base_prefix."invitations i2
  729. inner join ".$wpdb->users." u2 on u2.user_email = i2.invited_email
  730. where year(i2.datestamp) = year(i.datestamp)
  731. and month(i2.datestamp) = month(i.datestamp)) as signups
  732. from ".$wpdb->base_prefix."invitations i
  733. group by month(i.datestamp)
  734. order by i.datestamp desc
  735. limit 0, 12;";
  736. $invites_per_month = $wpdb->get_results($sql);
  737. $invites_per_month_num = count($invites_per_month);
  738. echo '
  739. <div style="float:left;width:45%">
  740. <h3>' . __("Invitations per month", "secure_invite") . '</h3>
  741. ';
  742. if ($invites_per_month && $invites_per_month_num > 0)
  743. {
  744. echo '
  745. <table summary="'.__("Invitations per month", "secure_invite").'" class="widefat">
  746. <thead>
  747. <tr>
  748. <th>'.__("Month", "secure_invite").'</th>
  749. <th>'.__("Invites sent", "secure_invite").'</th>
  750. <th>'.__("Resulting signups", "secure_invite").'</th>
  751. </tr>
  752. </thead>
  753. <tbody>
  754. ';
  755. foreach ($invites_per_month as $invite_month)
  756. {
  757. if ($alt == '') { $alt = ' class="alternate"'; } else { $alt = ''; }
  758. echo '
  759. <tr'.$alt.'>
  760. <td>'.__(date("F Y", $invite_month->date)).'</td>
  761. <td>'.__($invite_month->invites).'</td>
  762. <td>'.__($invite_month->signups).'</td>
  763. </tr>
  764. ';
  765. }
  766. echo '
  767. </tbody>
  768. </table>
  769. ';
  770. } else {
  771. echo '
  772. <p>'.__("No invitations sent yet", "secure_invite").'</p>
  773. ';
  774. }
  775. echo '
  776. </div>
  777. ';
  778.  
  779. // get the best inviters by signups
  780. $sql = "select u.user_nicename,
  781. count(i.invited_email) as invites,
  782. (select count(i2.invited_email)
  783. from ".$wpdb->base_prefix."invitations i2
  784. inner join ".$wpdb->users." u2 on u2.user_email = i2.invited_email
  785. where i2.user_id = i.user_id) as signups
  786. from ".$wpdb->base_prefix."invitations i
  787. inner join ".$wpdb->base_prefix."users u on u.id = i.user_id
  788. group by i.user_id
  789. order by count(i.invited_email) desc
  790. limit 0, 6;";
  791. $best_inviters = $wpdb->get_results($sql);
  792. $best_inviters_num = count($best_inviters);
  793. echo '
  794. <div style="float:right;width:45%">
  795. <h3>' . __("Best inviters by signups", "secure_invite") . '</h3>
  796. ';
  797. if ($best_inviters && $best_inviters_num > 0)
  798. {
  799. echo '
  800. <table summary="'.__("Best inviters by signups", "secure_invite").'" class="widefat">
  801. <thead>
  802. <tr>
  803. <th>'.__("Name", "secure_invite").'</th>
  804. <th>'.__("Invites sent", "secure_invite").'</th>
  805. <th>'.__("Resulting signups", "secure_invite").'</th>
  806. </tr>
  807. </thead>
  808. <tbody>
  809. ';
  810. foreach ($best_inviters as $best_inviter)
  811. {
  812. if ($alt == '') { $alt = ' class="alternate"'; } else { $alt = ''; }
  813. echo '
  814. <tr'.$alt.'>
  815. <td>'.__($best_inviter->user_nicename).'</td>
  816. <td>'.__($best_inviter->invites).'</td>
  817. <td>'.__($best_inviter->signups).'</td>
  818. </tr>
  819. ';
  820. }
  821. echo '
  822. </tbody>
  823. </table>
  824. ';
  825. } else {
  826. echo '
  827. <p>'.__("No invitations sent yet", "secure_invite").'</p>
  828. ';
  829. }
  830. echo '
  831. </div>
  832. ';
  833.  
  834. // get the best inviters by points
  835. $sql = "select u.user_nicename,
  836. CAST(m.secure_invite_points AS SIGNED) as secure_invite_points
  837. from ".$wpdb->users." u
  838. inner join ".$wpdb->usermeta." m on m.user_id = u.ID and m.meta_key = 'secure_invite_points'
  839. order by CAST(m.secure_invite_points AS SIGNED) desc
  840. limit 0, 6;";
  841. $best_inviters = $wpdb->get_results($sql);
  842. $best_inviters_num = count($best_inviters);
  843. if ($best_inviters && $best_inviters_num > 0)
  844. {
  845. echo '
  846. <div style="float:right;width:45%">
  847. <h3>' . __("Best inviters by points", "secure_invite") . '</h3>
  848. <table summary="'.__("Best inviters by points", "secure_invite").'" class="widefat">
  849. <thead>
  850. <tr>
  851. <th>'.__("Name", "secure_invite").'</th>
  852. <th>'.__("Points", "secure_invite").'</th>
  853. </tr>
  854. </thead>
  855. <tbody>
  856. ';
  857. foreach ($best_inviters as $best_inviter)
  858. {
  859. if ($alt == '') { $alt = ' class="alternate"'; } else { $alt = ''; }
  860. echo '
  861. <tr'.$alt.'>
  862. <td>'.__($best_inviter->user_nicename).'</td>
  863. <td>'.__($best_inviter->secure_invite_points).'</td>
  864. </tr>
  865. ';
  866. }
  867. echo '
  868. </tbody>
  869. </table>
  870. </div>
  871. ';
  872. }
  873.  
  874. // get the page
  875. $page = @(int)$_GET["p"];
  876. if ($page == "")
  877. {
  878. $page = "1";
  879. }
  880. $start = ($page * 50) -50;
  881. if ($start == "") { $start = 0; }
  882.  
  883. // get the invites
  884. $sql = $wpdb->prepare("select SQL_CALC_FOUND_ROWS i.user_id, i.invited_email, UNIX_TIMESTAMP(i.datestamp) as datestamp, u.user_nicename as inviter, l.user_nicename as signed_up
  885. from ".$wpdb->base_prefix."invitations i
  886. inner join ".$wpdb->users." u on u.id = i.user_id
  887. left outer join ".$wpdb->users." l on l.user_email = i.invited_email
  888. order by i.datestamp desc
  889. limit %d, 50", $start);
  890. $invites = $wpdb->get_results($sql);
  891.  
  892. echo '
  893. <h3 style="clear:both;padding-top:20px">' . __("Invitation list", "secure_invite") . '</h3>
  894. ';
  895.  
  896. $invites_num = count($invites);
  897. $total = $wpdb->get_var( "SELECT found_rows() AS found_rows" );
  898. $invites_pages = ceil($total/50);
  899.  
  900. if ($invites && $invites_num > 0)
  901. {
  902. if ($invites_pages > 1)
  903. {
  904. $thisp = @$_GET["p"];
  905. if ($thisp == "") { $thisp = 1; }
  906. echo '<ul style="list-style: none;">
  907. ';
  908. for ($i = 1; $i <= $invites_pages; $i++)
  909. {
  910. if ($i == $thisp)
  911. {
  912. echo '<li style="display: inline;">'.$i.'</li>
  913. ';
  914. } else {
  915. echo '<li style="display: inline;"><a href="wpmu-admin.php?page=secure_invite_list&amp;p='.$i.'">'.$i.'</a></li>
  916. ';
  917. }
  918. }
  919. echo '</ul>
  920. ';
  921. }
  922. echo '<form action="wpmu-admin.php?page=secure_invite_list" method="post">
  923. <table summary="'.__("Invitations sent by site users", "secure_invite").'" class="widefat">
  924. <thead>
  925. <tr>
  926. <th>'.__("Inviter", "secure_invite").'</th>
  927. <th>'.__("Datestamp", "secure_invite").'</th>
  928. <th>'.__("Invited email", "secure_invite").'</th>
  929. <th>'.__("Signed up name", "secure_invite").'</th>
  930. <th>'.__("Delete invitation", "secure_invite").'</th>
  931. </tr>
  932. </thead>
  933. <tbody>
  934. ';
  935. $alt = '';
  936. foreach ($invites as $invite)
  937. {
  938. if ($alt == '') { $alt = ' class="alternate"'; } else { $alt = ''; }
  939. echo '<tr'.$alt.'>
  940. <td>' . $invite->inviter . '</td>
  941. <td>' . date("F j, Y, g:i a", $invite->datestamp) . '</td>
  942. <td>' . $invite->invited_email . '</td>
  943. <td>' . $invite->signed_up . '</td>';
  944. if ($invite->signed_up == "") {
  945. echo '
  946. <td>
  947. <a href="wpmu-admin.php?page=secure_invite_list&amp;delete='.urlencode($invite->invited_email).'">' . __("Delete", "secure_invite") . '</a>
  948. <input type="checkbox" name="delete[]" value="'.urlencode($invite->invited_email).'" />
  949. </td>
  950. ';
  951. } else {
  952. echo '
  953. <td></td>
  954. ';
  955. }
  956. echo '
  957. </tr>
  958. ';
  959. }
  960. echo '
  961. </tbody>
  962. </table>
  963. <p><input type="submit" name="deleteall" class="button" value="' . __("Delete all checked invitations", "secure_invite") . '" /></p>
  964. </form>
  965. ';
  966. if ($invites_pages > 1)
  967. {
  968. echo '<ul style="list-style: none;">
  969. ';
  970. for ($i = 1; $i <= $invites_pages; $i++)
  971. {
  972. if ($i == $thisp)
  973. {
  974. echo '<li style="display: inline;">'.$i.'</li>
  975. ';
  976. } else {
  977. echo '<li style="display: inline;"><a href="wpmu-admin.php?page=secure_invite_list&amp;p='.$i.'">'.$i.'</a></li>
  978. ';
  979. }
  980. }
  981. echo '</ul>
  982. ';
  983. }
  984. } else {
  985. echo '<p>' . __("No invitations sent yet.", "secure_invite") . '</p>';
  986. }
  987. }
  988.  
  989. // check the invites table exists
  990. function secure_invite_check_table()
  991. {
  992. global $wpdb;
  993. // if the invitations table does not exist
  994. $sql = "select count(id) from ".$wpdb->base_prefix."invitations;";
  995. $exists = $wpdb->get_var($sql);
  996. if($exists == "")
  997. {
  998. require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
  999. // include the file with the required database manipulation functions
  1000. // create the table
  1001. $sql = "CREATE TABLE ".$wpdb->base_prefix."invitations (
  1002. id mediumint(9) NOT NULL AUTO_INCREMENT,
  1003. user_id mediumint(9),
  1004. invited_email varchar(255),
  1005. datestamp datetime,
  1006. PRIMARY KEY (id)
  1007. );";
  1008. dbDelta($sql);
  1009. }
  1010. }
  1011.  
  1012. // show a BuddyPress form
  1013. function secure_invite_buddypress_form($hidelink = false, $usepost = false)
  1014. {
  1015. // if the current user is allowed to send invites
  1016. if (secure_invite_user_can_invite())
  1017. {
  1018. $name = "";
  1019. $email = "";
  1020. $message = "";
  1021. if ($usepost) {
  1022. $name = @$_POST["name"];
  1023. $email = @$_POST["email"];
  1024. $message = @$_POST["personalmessage"];
  1025. }
  1026. $rand = rand(1, 10000);
  1027. $hide = "_visible";
  1028. if (!$hidelink) {
  1029. $hide = "";
  1030. echo '
  1031. <div class="generic-button" style="padding:0 0 0.6em 0"><p><a href="#secure_invite_form_' . $rand . '" title="' . __("Invite a friend", "secure_invite") . '" class="add secure_invite_toggler">' . __("Invite a friend", "secure_invite") . '</a></p></div>
  1032. ';
  1033. }
  1034. $qs = "";
  1035. if ($_SERVER["QUERY_STRING"] != "") {
  1036. $qs = "?" . $_SERVER["QUERY_STRING"];
  1037. }
  1038. echo '
  1039. <div id="secure_invite_form_' . $rand . '" class="secure_invite_form_wrapper' . $hide . '">
  1040. <h3>' . __( "Invite a friend to join", "secure_invite" ) . '</h3>
  1041. <form action="/send-secure-invite?return=' . $_SERVER[ "REQUEST_URI" ] . $qs . '" method="post" class="standard-form">
  1042. <fieldset>
  1043. <p><label for="secure_invite_name_'.$rand.'">' . __("Name of person to invite", "secure_invite") . '</label>
  1044. <input name="invite-name" type="text" id="secure_invite_name_'.$rand.'" value="' . $name . '" /></p>
  1045. <p><label for="secure_invite_email_'.$rand.'">' . __("Email of person to invite", "secure_invite") . '</label>
  1046. <input name="invite-email" type="text" id="secure_invite_email_'.$rand.'" value="' . $email . '" /></p>
  1047. <p><label for="secure_invite_personalmessage_'.$rand.'">' . __("A personal message (optional)", "secure_invite") . '</label>
  1048. <textarea rows="10" cols="50" name="invite-personalmessage" id="secure_invite_personalmessage_'.$rand.'">' . $message . '</textarea></p>
  1049. <p><input type="submit" id="secure_invite_send_'.$rand.'" name="submit" value="' . __("Send Invitation", "secure_invite") . '" /> ' . secure_invite_user_invites_remaining() . '</p>
  1050. ';
  1051. $nonce = wp_nonce_field( 'secure_invite_send_invite', '_wpnonce', true, false );
  1052. $nonce = str_replace('id="_wpnonce"', 'id="_wpnonce_'.$rand.'"', $nonce);
  1053. echo $nonce;
  1054. echo '
  1055. </fieldset>
  1056. </form>
  1057. </div>
  1058. <div style="clear:both"></div>
  1059. ';
  1060. }
  1061. }
  1062.  
  1063. // show an invitation form
  1064. function secure_invite_form($success='Thanks, your invitation has been sent', $error='Sorry, your invitation could not be sent. Perhaps this email address is already registered.')
  1065. {
  1066. // if the current user is allowed to send invites
  1067. if (secure_invite_user_can_invite())
  1068. {
  1069. // if an email has been supplied
  1070. if (@$_POST['invite-email'] != "" && is_email($_POST['invite-email'])) {
  1071. if (secure_invite_send()) {
  1072. // show the success message
  1073. echo '<p class="success">' . __($success, "secure_invite") . '</p>';
  1074. } else {
  1075. // show the error message
  1076. echo '<p class="error">' . __($error, "secure_invite") . '</p>';
  1077. }
  1078. }
  1079. $qs = "";
  1080. if ($_SERVER["QUERY_STRING"] != "")
  1081. {
  1082. $qs = "?" . $_SERVER["QUERY_STRING"];
  1083. }
  1084. // show the form
  1085. echo '
  1086. <form action="' . $_SERVER[ "REQUEST_URI" ] . $qs . '" method="post" class="secure_invite_form">
  1087. <fieldset>
  1088. <p><label for="secure_invite_name">' . __("Name of person to invite", "secure_invite") . '</label>
  1089. <input name="invite-name" type="text" id="secure_invite_name" value="" /></p>
  1090. <p><label for="secure_invite_email">' . __("Email of person to invite", "secure_invite") . '</label>
  1091. <input name="invite-email" type="text" id="secure_invite_email" value="" /></p>
  1092. <p><label for="secure_invite_personalmessage">' . __("A personal message (optional)", "secure_invite") . '</label>
  1093. <textarea rows="10" cols="50" name="invite-personalmessage" id="secure_invite_personalmessage"></textarea></p>
  1094. <p><label for="secure_invite_send">' . __("Send this invitation", "secure_invite") . '</label>
  1095. <input type="submit" id="secure_invite_send" name="submit" value="' . __("Send Invitation", "secure_invite") . '" /> ' . secure_invite_user_invites_remaining() . '</p>
  1096. </fieldset>
  1097. </form>';
  1098. }
  1099. }
  1100.  
  1101. // see if a user can send an invite
  1102. function secure_invite_user_can_invite()
  1103. {
  1104. global $wpdb, $current_user;
  1105. $site_registration = stripslashes( get_site_option( "registration" ) );
  1106. // if the current user exists and is logged in
  1107. if ($current_user && $current_user->id != "")
  1108. {
  1109. // if site registration is allowed
  1110. if ($site_registration == "all" || $site_registration == "user")
  1111. {
  1112. // if the user has not been overridden
  1113. if (get_usermeta($current_user->ID, "secure_invite_user_can_invite") != "no")
  1114. {
  1115. // get the date this user was registered
  1116. $registered = $wpdb->get_var($wpdb->prepare("select UNIX_TIMESTAMP(user_registered) from ".$wpdb->users." where id=%d;", $current_user->id));
  1117.  
  1118. // get how many days after registration invites are locked
  1119. $secure_invite_days_after_joining = (int)stripslashes( get_site_option("secure_invite_days_after_joining") );
  1120. if ($secure_invite_days_after_joining == "") { $secure_invite_days_after_joining = 30; }
  1121.  
  1122. // if the user is not too new, or is a site admin
  1123. if ($registered < (time() - ($secure_invite_days_after_joining * 24 * 60 * 60)) || is_site_admin())
  1124. {
  1125. // get the total number of invites a user is allowed to send
  1126. $secure_invite_invite_limit = stripslashes( get_site_option("secure_invite_invite_limit") );
  1127. if ($secure_invite_invite_limit == "") { $secure_invite_invite_limit = 0; }
  1128.  
  1129. // get the limit for this user
  1130. $user_limit = trim(get_usermeta($current_user->ID, "secure_invite_user_invite_limit"), "_");
  1131. if ($user_limit != "") { $secure_invite_invite_limit = (int)$user_limit; }
  1132.  
  1133. // get the number of invites this user has sent
  1134. $sent = secure_invite_user_sent_invites();
  1135.  
  1136. // if the user has sent less than their limit, or there is no limit
  1137. if ($sent < $secure_invite_invite_limit || $secure_invite_invite_limit == "" || $secure_invite_invite_limit == 0 || $user_limit == 0)
  1138. {
  1139. return true;
  1140. } else {
  1141. add_action('admin_head', 'secure_invites_disallowed_limit');
  1142. add_action('wp_head', 'secure_invites_disallowed_limit');
  1143. return false;
  1144. }
  1145. } else {
  1146. add_action('admin_head', 'secure_invites_disallowed_new');
  1147. add_action('wp_head', 'secure_invites_disallowed_new');
  1148. return false;
  1149. }
  1150. } else {
  1151. add_action('admin_head', 'secure_invites_disallowed_turnedoff');
  1152. add_action('wp_head', 'secure_invites_disallowed_turnedoff');
  1153. return false;
  1154. }
  1155. } else {
  1156. add_action('admin_head', 'secure_invites_disallowed_registration');
  1157. add_action('wp_head', 'secure_invites_disallowed_registration');
  1158. return false;
  1159. }
  1160. } else {
  1161. add_action('admin_head', 'secure_invites_disallowed_login');
  1162. add_action('wp_head', 'secure_invites_disallowed_login');
  1163. return false;
  1164. }
  1165. }
  1166.  
  1167. // the reasons why people are disallowed from sending invites
  1168. function secure_invites_disallowed_limit() {
  1169. echo '<!-- Secure Invites: User cannot send invites because they have sent their limit of invitations -->';
  1170. }
  1171. function secure_invites_disallowed_new() {
  1172. echo '<!-- Secure Invites: User cannot send invites because they have not been registered for long enough -->';
  1173. }
  1174. function secure_invites_disallowed_registration() {
  1175. echo '<!-- Secure Invites: User cannot send invites because the site registration option is not set to "all" or "user" -->';
  1176. }
  1177. function secure_invites_disallowed_login() {
  1178. echo '<!-- Secure Invites: User cannot send invites because they are not logged in -->';
  1179. }
  1180. function secure_invites_disallowed_turnedoff() {
  1181. echo '<!-- Secure Invites: User cannot send invites because their invite rights have been revoked -->';
  1182. }
  1183.  
  1184. // get the number of invites this user has sent
  1185. function secure_invite_user_sent_invites($userid = 0)
  1186. {
  1187. global $wpdb, $current_user;
  1188. if ($userid == 0) { $userid = $current_user->id; }
  1189. return $wpdb->get_var($wpdb->prepare("select count(user_id) from ".$wpdb->base_prefix."invitations where user_id = %d", $userid));
  1190. }
  1191.  
  1192. // get the number of invites this user has sent which have resulted in a non-spam, non-deleted signup
  1193. function secure_invite_user_accepted_invites()
  1194. {
  1195. global $wpdb, $current_user;
  1196. if ($userid == 0) { $userid = $current_user->id; }
  1197. return $wpdb->get_var($wpdb->prepare("select count(u.user_id) from ".$wpdb->users." u inner join ".$wpdb->base_prefix."invitations i on i.invited_email = u.user_email where u.spam = 0 and u.deleted = 0 and i.user_id = %d", $userid));
  1198. }
  1199.  
  1200. // show how many invites this user is allowed to send
  1201. function secure_invite_user_invites_remaining()
  1202. {
  1203. global $current_user;
  1204. // get the total number of invites a user is allowed to send
  1205. $secure_invite_invite_limit = stripslashes( get_site_option("secure_invite_invite_limit") );
  1206. if ($secure_invite_invite_limit == "") { $secure_invite_invite_limit = secure_invite_default_setting("secure_invite_invite_limit"); }
  1207. // get the limit for this user
  1208. $user_limit = trim(get_usermeta($current_user->ID, "secure_invite_user_invite_limit"), "_");
  1209. if ($user_limit != "") { $secure_invite_invite_limit = (int)$user_limit; }
  1210. if ($secure_invite_invite_limit > 0)
  1211. {
  1212. // get the number of invites sent
  1213. $sent = secure_invite_user_sent_invites();
  1214. return __("Number of invites left to send:", "secure_invite") . " " . ($secure_invite_invite_limit - $sent);
  1215. } else {
  1216. return "";
  1217. }
  1218. }
  1219.  
  1220. // check if an email address exists
  1221. function secure_invite_email_exists($email) {
  1222. if( function_exists('email_exists') ) {
  1223. return email_exists( trim( $email ) );
  1224. } else {
  1225. global $wpdb;
  1226. $sql = $wpdb->prepare( "select user_email from " . $wpdb->users . " where user_email = %s;", trim( $email ) );
  1227. $saved_email = $wpdb->get_var( $sql );
  1228. if ( $saved_email == trim( $email ) ) {
  1229. return true;
  1230. } else {
  1231. return false;
  1232. }
  1233. }
  1234. return false;
  1235. }
  1236.  
  1237. // send an invitation
  1238. function secure_invite_send()
  1239. {
  1240. global $current_site, $current_user, $blog_id, $wpdb;
  1241. // check the user can invite
  1242. if (secure_invite_user_can_invite())
  1243. {
  1244. // check this email address isn't already registered
  1245. if ( !secure_invite_email_exists( trim($_POST['invite-email']) ) ) {
  1246. $usernickname = $current_user->display_name;
  1247. $to = trim($_POST['invite-email']);
  1248. $from = $current_user->display_name . ' <' . $current_user->user_email . '>';
  1249. $pname = trim($_POST['invite-name']);
  1250. $site_url = $current_site->domain;
  1251. $site_name = stripslashes( get_site_option("site_name") );
  1252.  
  1253. // save the invitation
  1254. $sql = $wpdb->prepare("insert into ".$wpdb->base_prefix."invitations
  1255. (user_id, invited_email, datestamp)
  1256. values
  1257. (%d, %s, now());", $current_user->id, $to);
  1258. $wpdb->print_error();
  1259. $query = $wpdb->query($sql);
  1260. $query_error = mysql_error();
  1261. // if the invitation could be saved
  1262. if ($query)
  1263. {
  1264. if(!empty($pname)) {
  1265. $subject = $pname.', '.$usernickname.' has invited you to join '.$site_name;
  1266. $message .= "Dear ".$pname.", ";
  1267. }
  1268. else {
  1269. $subject = 'Hi there, '. $usernickname.' has invited you to join '.$site_name;
  1270. $message .= "Hi there, ";
  1271. }
  1272.  
  1273. $secure_invite_signup_time_limit = (int)stripslashes( get_site_option("secure_invite_signup_time_limit") );
  1274. if ($secure_invite_signup_time_limit == "") { $secure_invite_signup_time_limit = secure_invite_default_setting("secure_invite_signup_time_limit"); }
  1275.  
  1276. $secure_invite_signup_page = stripslashes( get_site_option("secure_invite_signup_page") );
  1277. if ($secure_invite_signup_page == "") { $secure_invite_signup_page = secure_invite_default_setting("secure_invite_signup_page"); }
  1278.  
  1279. $secure_invite_registration_page = stripslashes( get_site_option("secure_invite_registration_page") );
  1280. if ($secure_invite_registration_page == "") { $secure_invite_registration_page = secure_invite_default_setting("secure_invite_registration_page"); }
  1281.  
  1282. $secure_invite_default_message = stripslashes( get_site_option("secure_invite_default_message") );
  1283. if ($secure_invite_default_message == "") { $secure_invite_default_message = secure_invite_default_setting("secure_invite_default_message"); }
  1284.  
  1285. $secure_invite_default_message = str_replace("[sitename]", $site_name, $secure_invite_default_message);
  1286. $secure_invite_default_message = str_replace("[signuplink]", $secure_invite_registration_page . "?" . $to, $secure_invite_default_message);
  1287. $secure_invite_default_message = str_replace("[name]", $usernickname, $secure_invite_default_message);
  1288. $secure_invite_default_message = str_replace("[timeout]", $secure_invite_signup_time_limit, $secure_invite_default_message);
  1289.  
  1290. $message = $message . "\n\n" . stripslashes($_POST['invite-personalmessage']) . "\n\n" . $secure_invite_default_message;
  1291.  
  1292. $headers = 'From: '. $from . "\r\n" .
  1293. 'Reply-To: ' . $from;
  1294. wp_mail($to, $subject, $message, $headers);
  1295. return true;
  1296. } else {
  1297. $headers = 'From: '. $from . "\r\n" .
  1298. 'Reply-To: ' . $from;
  1299. wp_mail(stripslashes( get_site_option("admin_email") ), "Secure invite failure for ".$from, "A user just tried to invite someone to join ".$site_name.". The following SQL query could not be completed:\n\n".$sql."\n\nThe error reported was:\n\n".$query_error."\n\nThis is an automatic email sent by the Secure Invites plugin.", $headers);
  1300. }
  1301. }
  1302. }
  1303. return false;
  1304. }
  1305.  
  1306. // add an invitation to the database
  1307. function secure_invite_admin() {
  1308. global $current_site, $current_user, $blog_id, $wpdb;
  1309.  
  1310. $site_url = $current_site->domain;
  1311. $site_name = stripslashes( get_site_option("site_name") );
  1312.  
  1313. // check the invites table exists
  1314. secure_invite_check_table();
  1315.  
  1316. if($_POST['invite-action']=="send")
  1317. {
  1318. // if the email is valid
  1319. if(is_email($_POST['invite-email']))
  1320. {
  1321. // try to send
  1322. if (secure_invite_send())
  1323. {
  1324. echo '<div id="message" class="updated fade"><p><strong>'.__('Your invitation has been successfully sent to', "secure_invite").' '.$_POST['invite-email'].'.</strong></p></div>';
  1325. // the invitation could not be saved, show an error
  1326. } else {
  1327. echo '<div id="message" class="updated fade"><p><strong>'.__('Your invitation could not be sent to', "secure_invite").' '.$_POST['invite-email'].'. '.__('Perhaps this email address is already registered. Please try again. If it fails more than twice please contact the site administrator.', "secure_invite").'</strong></p></div>';
  1328. }
  1329. }
  1330. else
  1331. {
  1332. echo '<div id="message" class="updated fade"><p><strong>'.__('Please enter a valid email address', "secure_invite").'</strong></p></div>';
  1333. } // end error
  1334. } // end if action is send
  1335.  
  1336.  
  1337. echo '<div class="wrap">';
  1338. echo '<h2>' . __("Invite a friend to join", "secure_invite") . ' '.$site_name.'</h2> ';
  1339. echo '<form method="post" action="index.php?page=secure_invite">
  1340. <fieldset>
  1341. <p>
  1342. <label for="name" style="float:left;width:20%;">'.__('Name', "secure_invite").'</label>
  1343. <input name="invite-name" type="text" id="name" value="" style="float:left;width:79%;" />
  1344. </p>
  1345. <p style="clear:both">
  1346. <label for="email" style="float:left;width:20%;">'.__('Email', "secure_invite").'</label>
  1347. <input name="invite-email" type="text" id="email" value="" style="float:left;width:79%;" />
  1348. </p>
  1349. <p style="clear:both">
  1350. <label for="personalmessage" style="display:block">' . __("Your message", "secure_invite") . '</label>
  1351. <textarea rows="10" cols="50" name="invite-personalmessage" id="personalmessage" style="width:99%;height:6em">' . sprintf(__("I've been blogging at %s and thought you might like to try it out.\n\nMy blog is at %s", "secure_invite"), $site_name, get_option('home')) . '</textarea>
  1352. </p>
  1353. <p class="submit" style="clear:both">
  1354. <input type="submit" name="Submit" class="button-primary" tabindex="4" value="' . __("Send Invitation", "secure_invite") . ' &raquo;" /> ';
  1355. echo secure_invite_user_invites_remaining();
  1356. echo '
  1357. <input type="hidden" name="invite-action" value="send" />
  1358. </p>
  1359. </fieldset>
  1360. </form>
  1361. </div>';
  1362. }
  1363.  
  1364. // a standard header for your plugins, offers a PayPal donate button and link to a support page
  1365. function secure_invite_wp_plugin_standard_header( $currency = "", $plugin_name = "", $author_name = "", $paypal_address = "", $bugs_page ) {
  1366. $r = "";
  1367. $option = get_option( $plugin_name . " header" );
  1368. if ( $_GET[ "header" ] != "" || $_GET["thankyou"] == "true" ) {
  1369. update_option( $plugin_name . " header", "hide" );
  1370. $option = "hide";
  1371. }
  1372. if ( $_GET["thankyou"] == "true" ) {
  1373. $r .= '<div class="updated"><p>' . __( "Thank you for donating" ) . '</p></div>';
  1374. }
  1375. if ( $currency != "" && $plugin_name != "" && $_GET[ "header" ] != "hide" && $option != "hide" )
  1376. {
  1377. $r .= '<div class="updated">';
  1378. $pageURL = 'http';
  1379. if ( $_SERVER["HTTPS"] == "on" ) { $pageURL .= "s"; }
  1380. $pageURL .= "://";
  1381. if ( $_SERVER["SERVER_PORT"] != "80" ) {
  1382. $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
  1383. } else {
  1384. $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
  1385. }
  1386. if ( strpos( $pageURL, "?") === false ) {
  1387. $pageURL .= "?";
  1388. } else {
  1389. $pageURL .= "&";
  1390. }
  1391. $pageURL = htmlspecialchars( $pageURL );
  1392. if ( $bugs_page != "" ) {
  1393. $r .= '<p>' . sprintf ( __( 'To report bugs please visit <a href="%s">%s</a>.' ), $bugs_page, $bugs_page ) . '</p>';
  1394. }
  1395. if ( $paypal_address != "" && is_email( $paypal_address ) ) {
  1396. $r .= '
  1397. <form id="wp_plugin_standard_header_donate_form" action="https://www.paypal.com/cgi-bin/webscr" method="post">
  1398. <input type="hidden" name="cmd" value="_donations" />
  1399. <input type="hidden" name="item_name" value="Donation: ' . $plugin_name . '" />
  1400. <input type="hidden" name="business" value="' . $paypal_address . '" />
  1401. <input type="hidden" name="no_note" value="1" />
  1402. <input type="hidden" name="no_shipping" value="1" />
  1403. <input type="hidden" name="rm" value="1" />
  1404. <input type="hidden" name="currency_code" value="' . $currency . '"/>
  1405. <input type="hidden" name="return" value="' . $pageURL . 'thankyou=true" />
  1406. <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" />
  1407. <p>';
  1408. if ( $author_name != "" ) {
  1409. $r .= sprintf( __( 'If you found %1$s useful please consider donating to help %2$s to continue writing free Wordpress plugins.' ), $plugin_name, $author_name );
  1410. } else {
  1411. $r .= sprintf( __( 'If you found %s useful please consider donating.' ), $plugin_name );
  1412. }
  1413. $r .= '
  1414. <p><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="" /></p>
  1415. </form>
  1416. ';
  1417. }
  1418. $r .= '<p><a href="' . $pageURL . 'header=hide" class="button">' . __( "Hide this" ) . '</a></p>';
  1419. $r .= '</div>';
  1420. }
  1421. print $r;
  1422. }
  1423. function secure_invite_wp_plugin_standard_footer( $currency = "", $plugin_name = "", $author_name = "", $paypal_address = "", $bugs_page ) {
  1424. $r = "";
  1425. if ( $currency != "" && $plugin_name != "" )
  1426. {
  1427. $r .= '<form id="wp_plugin_standard_footer_donate_form" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="clear:both;padding-top:50px;"><p>';
  1428. if ( $paypal_address != "" && is_email( $paypal_address ) ) {
  1429. $r .= '
  1430. <input type="hidden" name="cmd" value="_donations" />
  1431. <input type="hidden" name="item_name" value="Donation: ' . $plugin_name . '" />
  1432. <input type="hidden" name="business" value="' . $paypal_address . '" />
  1433. <input type="hidden" name="no_note" value="1" />
  1434. <input type="hidden" name="no_shipping" value="1" />
  1435. <input type="hidden" name="rm" value="1" />
  1436. <input type="hidden" name="currency_code" value="' . $currency . '"/>
  1437. <input type="hidden" name="return" value="' . $pageURL . 'thankyou=true" />
  1438. <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" />
  1439. <input type="submit" name="submit" class="button" value="' . __( "PayPal: Donate" ) . '" />
  1440. ';
  1441. }
  1442. if ( $bugs_page != "" ) {
  1443. $r .= sprintf ( __( '<a href="%s">Bugs</a>' ), $bugs_page );
  1444. }
  1445. $r .= '</p></form>';
  1446. }
  1447. print $r;
  1448. }
  1449. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement