Source Code Documentation


s2member-pro\includes\classes\gateways\paypal\paypal-responses.inc.php


  1. <?php
  2. /**
  3. * PayPal® Pro Form responses.
  4. *
  5. * Copyright: © 2009-2011
  6. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  7. * ( coded in the USA )
  8. *
  9. * This WordPress® plugin ( s2Member Pro ) is comprised of two parts:
  10. *
  11. * o (1) Its PHP code is licensed under the GPL license, as is WordPress®.
  12. * You should have received a copy of the GNU General Public License,
  13. * along with this software. In the main directory, see: /licensing/
  14. * If not, see: {@link http://www.gnu.org/licenses/}.
  15. *
  16. * o (2) All other parts of ( s2Member Pro ); including, but not limited to:
  17. * the CSS code, some JavaScript code, images, and design;
  18. * are licensed according to the license purchased.
  19. * See: {@link http://www.s2member.com/prices/}
  20. *
  21. * Unless you have our prior written consent, you must NOT directly or indirectly license,
  22. * sub-license, sell, resell, or provide for free; part (2) of the s2Member Pro Module;
  23. * or make an offer to do any of these things. All of these things are strictly
  24. * prohibited with part (2) of the s2Member Pro Module.
  25. *
  26. * Your purchase of s2Member Pro includes free lifetime upgrades via s2Member.com
  27. * ( i.e. new features, bug fixes, updates, improvements ); along with full access
  28. * to our video tutorial library: {@link http://www.s2member.com/videos/}
  29. *
  30. * @package s2Member\PayPal
  31. * @since 1.5
  32. */
  33. if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
  34. exit("Do not access this file directly.");
  35. /**/
  36. if(!class_exists("c_ws_plugin__s2member_pro_paypal_responses"))
  37. {
  38. /**
  39. * PayPal® Pro Form responses.
  40. *
  41. * @package s2Member\PayPal
  42. * @since 1.5
  43. */
  44. class c_ws_plugin__s2member_pro_paypal_responses
  45. {
  46. /**
  47. * Creates response divs after Cancellation processing.
  48. *
  49. * @package s2Member\PayPal
  50. * @since 1.5
  51. *
  52. * @param array $attr An array of Pro Form Attributes.
  53. * @return array An array of response details.
  54. */
  55. public static function paypal_cancellation_response($attr = FALSE)
  56. {
  57. $_response = $GLOBALS["ws_plugin__s2member_pro_paypal_cancellation_response"];
  58. /**/
  59. $_response = (!$_response) ? c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($attr) : $_response;
  60. /**/
  61. if($_response && ($error = $_response["error"])) /* Error reporting. */
  62. {
  63. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-error s2member-pro-paypal-cancellation-form-response-error">';
  64. $response .= $_response["response"];
  65. $response .= '</div>';
  66. }
  67. else if($_response) /* Otherwise, we treat this as an informational response. */
  68. {
  69. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-info s2member-pro-paypal-cancellation-form-response-info">';
  70. $response .= $_response["response"];
  71. $response .= '</div>';
  72. }
  73. /**/
  74. return array("response" => $response, "error" => $error);
  75. }
  76. /**
  77. * Creates response divs after Update processing.
  78. *
  79. * @package s2Member\PayPal
  80. * @since 1.5
  81. *
  82. * @param array $attr An array of Pro Form Attributes.
  83. * @return array An array of response details.
  84. */
  85. public static function paypal_update_response($attr = FALSE)
  86. {
  87. $_response = $GLOBALS["ws_plugin__s2member_pro_paypal_update_response"];
  88. /**/
  89. $_response = (!$_response) ? c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($attr) : $_response;
  90. /**/
  91. if($_response && ($error = $_response["error"])) /* Error reporting. */
  92. {
  93. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-error s2member-pro-paypal-update-form-response-error">';
  94. $response .= $_response["response"];
  95. $response .= '</div>';
  96. }
  97. else if($_response) /* Otherwise, we treat this as an informational response. */
  98. {
  99. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-info s2member-pro-paypal-update-form-response-info">';
  100. $response .= $_response["response"];
  101. $response .= '</div>';
  102. }
  103. /**/
  104. return array("response" => $response, "error" => $error);
  105. }
  106. /**
  107. * Creates response divs after Registration processing.
  108. *
  109. * @package s2Member\PayPal
  110. * @since 1.5
  111. *
  112. * @param array $attr An array of Pro Form Attributes.
  113. * @return array An array of response details.
  114. */
  115. public static function paypal_registration_response($attr = FALSE)
  116. {
  117. $_response = $GLOBALS["ws_plugin__s2member_pro_paypal_registration_response"];
  118. /**/
  119. $_response = (!$_response) ? c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($attr) : $_response;
  120. /**/
  121. if($_response && ($error = $_response["error"])) /* Error reporting. */
  122. {
  123. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-error s2member-pro-paypal-registration-form-response-error">';
  124. $response .= $_response["response"];
  125. $response .= '</div>';
  126. }
  127. else if($_response) /* Otherwise, we treat this as an informational response. */
  128. {
  129. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-info s2member-pro-paypal-registration-form-response-info">';
  130. $response .= $_response["response"];
  131. $response .= '</div>';
  132. }
  133. /**/
  134. return array("response" => $response, "error" => $error);
  135. }
  136. /**
  137. * Creates response divs after Specific Post/Page checkout processing.
  138. *
  139. * @package s2Member\PayPal
  140. * @since 1.5
  141. *
  142. * @param array $attr An array of Pro Form Attributes.
  143. * @return array An array of response details.
  144. */
  145. public static function paypal_sp_checkout_response($attr = FALSE)
  146. {
  147. $_response = $GLOBALS["ws_plugin__s2member_pro_paypal_sp_checkout_response"];
  148. /**/
  149. $_response = (!$_response) ? c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($attr) : $_response;
  150. /**/
  151. if($_response && ($error = $_response["error"])) /* Error reporting. */
  152. {
  153. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-error s2member-pro-paypal-sp-checkout-form-response-error">';
  154. $response .= $_response["response"];
  155. $response .= '</div>';
  156. }
  157. else if($_response) /* Otherwise, we treat this as an informational response. */
  158. {
  159. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-info s2member-pro-paypal-sp-checkout-form-response-info">';
  160. $response .= $_response["response"];
  161. $response .= '</div>';
  162. }
  163. /**/
  164. return array("response" => $response, "error" => $error);
  165. }
  166. /**
  167. * Creates response divs after Membership checkout processing.
  168. *
  169. * @package s2Member\PayPal
  170. * @since 1.5
  171. *
  172. * @param array $attr An array of Pro Form Attributes.
  173. * @return array An array of response details.
  174. */
  175. public static function paypal_checkout_response($attr = FALSE)
  176. {
  177. $_response = $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"];
  178. /**/
  179. $_response = (!$_response) ? c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($attr) : $_response;
  180. /**/
  181. if($_response && ($error = $_response["error"])) /* Error reporting. */
  182. {
  183. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-error s2member-pro-paypal-checkout-form-response-error">';
  184. $response .= $_response["response"];
  185. $response .= '</div>';
  186. }
  187. else if($_response) /* Otherwise, we treat this as an informational response. */
  188. {
  189. $response = '<div id="s2member-pro-paypal-form-response" class="s2member-pro-paypal-form-response-info s2member-pro-paypal-checkout-form-response-info">';
  190. $response .= $_response["response"];
  191. $response .= '</div>';
  192. }
  193. /**/
  194. return array("response" => $response, "error" => $error);
  195. }
  196. /**
  197. * Validates the configuration of API Credentials.
  198. *
  199. * Free Registration Forms do NOT require API Credentials.
  200. *
  201. * @package s2Member\PayPal
  202. * @since 1.5
  203. *
  204. * @param array $attr An array of Pro Form Attributes.
  205. * @return null|array Null if there are no errors, else a response array.
  206. */
  207. public static function paypal_form_api_validation_errors($attr = FALSE)
  208. {
  209. if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])
  210. $response = array("response" => _x('PayPal® configuration error. Please configure your PayPal® Email Address.', "s2member-admin", "s2member"), "error" => true);
  211. /**/
  212. else if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"])
  213. $response = array("response" => _x('PayPal® configuration error. Your PayPal® API Username is not yet configured.', "s2member-admin", "s2member"), "error" => true);
  214. /**/
  215. else if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"])
  216. $response = array("response" => _x('PayPal® configuration error. Your PayPal® API Password is not yet configured.', "s2member-admin", "s2member"), "error" => true);
  217. /**/
  218. else if(!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"])
  219. $response = array("response" => _x('PayPal® configuration error. Your PayPal® API Signature is not yet configured.', "s2member-admin", "s2member"), "error" => true);
  220. /**/
  221. return (empty($response) || !empty($attr["register"])) ? null : $response;
  222. }
  223. /**
  224. * Validates the configuration of the current form.
  225. *
  226. * Free Registration Forms do NOT require API Credentials.
  227. *
  228. * @package s2Member\PayPal
  229. * @since 1.5
  230. *
  231. * @param array $attr An array of Pro Form Attributes.
  232. * @return null|array Null if there are no errors, else a response array.
  233. */
  234. public static function paypal_form_attr_validation_errors($attr = FALSE)
  235. {
  236. if(!($response = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_api_validation_errors($attr)) || !empty($attr["register"]))
  237. {
  238. if($attr["cancel"]) /* Special form for Cancellations. User/Member must be logged in. */
  239. {
  240. if(!is_user_logged_in())
  241. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to cancel your account.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  242. /**/
  243. else if(!is_object($user = wp_get_current_user()) || !($user_id = $user->ID) || !($subscr_id = get_user_option("s2member_subscr_id", $user_id)))
  244. $response = array("response" => _x('Nothing to cancel. You\'re NOT a paid Member.', "s2member-front", "s2member"), "error" => true);
  245. /**/
  246. else if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"])
  247. {
  248. if(!($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($subscr_id)))
  249. $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
  250. /**/
  251. else if(preg_match("/^(Pending|PendingProfile)$/i", $paypal["STATUS"]))
  252. $response = array("response" => _x('<strong>Unable to cancel at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
  253. /**/
  254. else if(!preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)$/i", $paypal["STATUS"]))
  255. $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
  256. }
  257. /**/
  258. else if(is_array($paypal = array("PROFILEID" => $subscr_id, "METHOD" => "GetRecurringPaymentsProfileDetails")))
  259. {
  260. if(!($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) || !empty($paypal["__error"]))
  261. {
  262. if($paypal && !empty($paypal["__error"]) && $paypal["L_ERRORCODE0"] === "11592") /* Subscription Profile? */
  263. $response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal®</a> to cancel your Subscription.', "s2member-front", "s2member"), esc_attr("https://".(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")."/cgi-bin/webscr?cmd=_subscr-find&amp;alias=".urlencode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]))), "error" => true);
  264. /**/
  265. else /* Else there was no Recurring Profile on record. */
  266. $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
  267. }
  268. /**/
  269. else if(preg_match("/^(Pending|PendingProfile)$/i", $paypal["STATUS"]))
  270. $response = array("response" => _x('<strong>Unable to cancel at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
  271. /**/
  272. else if(!preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)$/i", $paypal["STATUS"]))
  273. $response = array("response" => _x('Nothing to cancel. You have NO recurring fees.', "s2member-front", "s2member"), "error" => true);
  274. }
  275. }
  276. /**/
  277. else if($attr["update"]) /* Special form for Updates. User/Member must be logged in. */
  278. {
  279. if(!is_user_logged_in())
  280. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to update your billing information.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  281. /**/
  282. else if(!is_object($user = wp_get_current_user()) || !($user_id = $user->ID) || !($subscr_id = get_user_option("s2member_subscr_id", $user_id)))
  283. $response = array("response" => _x('Nothing to update. You\'re NOT a paid Member.', "s2member-front", "s2member"), "error" => true);
  284. /**/
  285. else if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"])
  286. {
  287. if(!($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($subscr_id)))
  288. $response = array("response" => _x('Nothing to update. You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
  289. /**/
  290. else if(strtoupper($paypal["TENDER"]) === "P")
  291. $response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal®</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://".(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")."/")), "error" => true);
  292. /**/
  293. else if(preg_match("/^(Pending|PendingProfile)$/i", $paypal["STATUS"]))
  294. $response = array("response" => _x('<strong>Unable to update at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
  295. /**/
  296. else if(!preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)$/i", $paypal["STATUS"]))
  297. $response = array("response" => _x('Nothing to update. You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
  298. }
  299. /**/
  300. else if(is_array($paypal = array("PROFILEID" => $subscr_id, "METHOD" => "GetRecurringPaymentsProfileDetails")))
  301. {
  302. if(!($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) || !empty($paypal["__error"]) || strlen($paypal["ACCT"]) !== 4)
  303. {
  304. if($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) !== 4) /* It's NOT associated with a credit card; they used PayPal®. */
  305. $response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal®</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://".(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")."/")), "error" => true);
  306. /**/
  307. else if($paypal && !empty($paypal["__error"]) && $paypal["L_ERRORCODE0"] === "11592") /* Subscription Profile? */
  308. $response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal®</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://".(($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")."/")), "error" => true);
  309. /**/
  310. else /* Else there was no Recurring Profile on record. */
  311. $response = array("response" => _x('Nothing to update. You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
  312. }
  313. /**/
  314. else if(preg_match("/^(Pending|PendingProfile)$/i", $paypal["STATUS"]))
  315. $response = array("response" => _x('<strong>Unable to update at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
  316. /**/
  317. else if(!preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)$/i", $paypal["STATUS"]))
  318. $response = array("response" => _x('Nothing to update. You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
  319. }
  320. }
  321. /**/
  322. else if($attr["register"]) /* Free Registration does not require attr validation. */
  323. {
  324. if(!is_string($attr["level"]) || !is_numeric($attr["level"]))
  325. $response = array("response" => sprintf(_x('Invalid form configuration. Missing "level" attribute. Membership Level. Must be numeric [0-%s].', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
  326. /**/
  327. else if($attr["level"] < 0 || $attr["level"] > $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])
  328. $response = array("response" => sprintf(_x('Invalid form configuration. Invalid "level" attribute. Membership Level. Must be numeric [0-%s].', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
  329. /**/
  330. else if($attr["ccaps"] && (!is_string($attr["ccaps"]) || (preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $attr["ccaps"])) && !preg_match("/^([a-z_0-9,]+)$/", preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $attr["ccaps"]))))))
  331. $response = array("response" => _x('Invalid form configuration. Invalid "ccaps" attribute. Custom Capabilities. When provided, must be all lowercase [a-z_0-9,]. A preceding `-all,` directive is also acceptable.', "s2member-admin", "s2member"), "error" => true);
  332. /**/
  333. else if($attr["tp"] && (!is_string($attr["tp"]) || !is_numeric($attr["tp"])))
  334. $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
  335. /**/
  336. else if($attr["tp"] && $attr["tp"] < 1)
  337. $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be >= 1.', "s2member-admin", "s2member"), "error" => true);
  338. /**/
  339. else if($attr["tp"] && (!$attr["tt"] || !is_string($attr["tt"])))
  340. $response = array("response" => _x('Invalid form configuration. Missing "tt" attribute. The Trial Term. When "tp" is provided, "tt" ( Trial Term ) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
  341. /**/
  342. else if($attr["tp"] && !preg_match("/[DWMY]/", $attr["tt"]))
  343. $response = array("response" => _x('Invalid form configuration. Invalid "tt" attribute. The Trial Term. When "tp" is provided, "tt" ( Trial Term ) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
  344. /**/
  345. else if($attr["custom"] && (!is_string($attr["custom"]) || !preg_match("/^".preg_quote(preg_replace("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/")."/i", $attr["custom"])))
  346. $response = array("response" => _x('Invalid form configuration. Invalid "custom" attribute. When provided, must start with your domain name.', "s2member-admin", "s2member-admin"), "error" => true);
  347. }
  348. /**/
  349. else if($attr["sp"]) /* Validation routines for Specific Post/Page checkout forms. */
  350. {
  351. if(!$attr["ids"] || !is_string($attr["ids"]))
  352. $response = array("response" => _x('Invalid form configuration. Missing "ids" attribute. Must contain comma-delimited Post/Page IDs.', "s2member-admin", "s2member"), "error" => true);
  353. /**/
  354. else if(!preg_match("/^([0-9,]+)$/", $attr["ids"]))
  355. $response = array("response" => _x('Invalid form configuration. Invalid "ids" attribute. Must contain comma-delimited Post/Page IDs. Must contain [0-9,] only.', "s2member-admin", "s2member"), "error" => true);
  356. /**/
  357. else if(!$attr["exp"] || !is_string($attr["exp"]))
  358. $response = array("response" => _x('Invalid form configuration. Missing "exp" attribute. Specific Post/Page Expiration ( in hours ). Must be numeric.', "s2member-admin", "s2member"), "error" => true);
  359. /**/
  360. else if(!is_numeric($attr["exp"]))
  361. $response = array("response" => _x('Invalid form configuration. Invalid "exp" attribute. Specific Post/Page Expiration ( in hours ). Must be numeric.', "s2member-admin", "s2member"), "error" => true);
  362. /**/
  363. else if($attr["exp"] < 1)
  364. $response = array("response" => _x('Invalid form configuration. Invalid "exp" attribute. Specific Post/Page Expiration ( in hours ). Must be >= 1.', "s2member-admin", "s2member"), "error" => true);
  365. /**/
  366. else if($attr["exp"] > 43800)
  367. $response = array("response" => _x('Invalid form configuration. Invalid "exp" attribute. Specific Post/Page Expiration ( in hours ). Must be <= 43800.', "s2member-admin", "s2member"), "error" => true);
  368. /**/
  369. else if(!$attr["sp_ids_exp"] || !is_string($attr["sp_ids_exp"]))
  370. $response = array("response" => _x('Invalid form configuration. Missing "sp_ids_exp" internal attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
  371. /**/
  372. else if(!preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $attr["sp_ids_exp"]))
  373. $response = array("response" => _x('Invalid form configuration. Invalid "sp_ids_exp" internal attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
  374. /**/
  375. else if(!$attr["desc"] || !is_string($attr["desc"]))
  376. $response = array("response" => _x('Invalid form configuration. Missing "desc" attribute. Please provide a Description for this form.', "s2member-admin", "s2member"), "error" => true);
  377. /**/
  378. else if(strlen($attr["desc"]) > 100) /* Actually, this can be 127 chars; but we need plenty of room for s2Member's coupon info. */
  379. $response = array("response" => _x('Invalid form configuration. Your "desc" ( Description ) attribute must be <= 100 characters long.', "s2member-admin", "s2member"), "error" => true);
  380. /**/
  381. else if(!$attr["custom"] || !is_string($attr["custom"]))
  382. $response = array("response" => _x('Invalid form configuration. Missing "custom" attribute. Must start with your domain name.', "s2member-admin", "s2member"), "error" => true);
  383. /**/
  384. else if(!preg_match("/^".preg_quote(preg_replace("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/")."/i", $attr["custom"]))
  385. $response = array("response" => _x('Invalid form configuration. Invalid "custom" attribute. Must start with your domain name.', "s2member-admin", "s2member"), "error" => true);
  386. /**/
  387. else if(!$attr["cc"] || !is_string($attr["cc"]))
  388. $response = array("response" => _x('Invalid form configuration. Missing "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
  389. /**/
  390. else if(strlen($attr["cc"]) !== 3)
  391. $response = array("response" => _x('Invalid form configuration. Invalid "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
  392. /**/
  393. else if(!strlen($attr["dg"]) || !is_string($attr["dg"]))
  394. $response = array("response" => _x('Invalid form configuration. Missing "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
  395. /**/
  396. else if($attr["dg"] < 0 || $attr["dg"] > 1)
  397. $response = array("response" => _x('Invalid form configuration. Invalid "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
  398. /**/
  399. else if(!strlen($attr["ns"]) || !is_string($attr["ns"]))
  400. $response = array("response" => _x('Invalid form configuration. Missing "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
  401. /**/
  402. else if($attr["ns"] < 0 || $attr["ns"] > 2)
  403. $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
  404. /**/
  405. else if($attr["dg"] && $attr["ns"] !== "1")
  406. $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be 1 with "dg" ( digital ) items.', "s2member-admin", "s2member"), "error" => true);
  407. /**/
  408. else if($attr["lc"] && strlen($attr["lc"]) !== 2)
  409. $response = array("response" => _x('Invalid form configuration. Invalid "lc" attribute. Locale Code. When provided, must be a 2 character country code.', "s2member-admin", "s2member"), "error" => true);
  410. /**/
  411. else if(!$attr["ra"] || !is_string($attr["ra"]))
  412. $response = array("response" => _x('Invalid form configuration. Missing "ra" attribute. The Regular Amount. Must be >= 0.01.', "s2member-admin", "s2member"), "error" => true);
  413. /**/
  414. else if(!is_numeric($attr["ra"]))
  415. $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be numeric.', "s2member-admin", "s2member"), "error" => true);
  416. /**/
  417. else if($attr["ra"] < 0.01)
  418. $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be >= 0.01.', "s2member-admin", "s2member"), "error" => true);
  419. /**/
  420. else if($attr["ra"] > 10000.00)
  421. $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be <= 10000.00.', "s2member-admin", "s2member"), "error" => true);
  422. }
  423. /**/
  424. else /* Validation routines for Member Level checkout forms. This is the default functionality. */
  425. {
  426. if($attr["modify"] && !is_user_logged_in()) /* Must be logged in before a modification can take place. */
  427. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">login</a> to update your billing plan.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  428. /**/
  429. else if($attr["level"] === "*" && !is_user_logged_in()) /* Must be logged in before purchasing. */
  430. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">login</a> before making this purchase.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  431. /**/
  432. else if((!$attr["level"] || !is_string($attr["level"]) || !is_numeric($attr["level"])) && $attr["level"] !== "*")
  433. $response = array("response" => sprintf(_x('Invalid form configuration. Missing "level" attribute. Membership Level. Must be numeric [1-%s], or an asterisk (*).', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
  434. /**/
  435. else if(($attr["level"] < 1 || $attr["level"] > $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) && $attr["level"] !== "*")
  436. $response = array("response" => sprintf(_x('Invalid form configuration. Invalid "level" attribute. Membership Level. Must be numeric [1-%s], or an asterisk (*).', "s2member-admin", "s2member"), esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"])), "error" => true);
  437. /**/
  438. else if($attr["ccaps"] && (!is_string($attr["ccaps"]) || (preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $attr["ccaps"])) && !preg_match("/^([a-z_0-9,]+)$/", preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $attr["ccaps"]))))))
  439. $response = array("response" => _x('Invalid form configuration. Invalid "ccaps" attribute. Custom Capabilities. When provided, must be all lowercase [a-z_0-9,]. A preceding `-all,` directive is also acceptable.', "s2member-admin", "s2member"), "error" => true);
  440. /**/
  441. else if($attr["level"] === "*" && (!is_string($attr["ccaps"]) || !preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $attr["ccaps"])) || !preg_match("/^([a-z_0-9,]+)$/", preg_replace("/^-all[\r\n\t\s;,]*/", "", str_replace("+", "", $attr["ccaps"])))))
  442. $response = array("response" => _x('Invalid form configuration. Missing or invalid "ccaps" attribute. When "level" is "*" for ( Independent Custom Capabilities ), "ccaps" is required. All lowercase [a-z_0-9,]. A preceding `-all,` directive is also acceptable.', "s2member-admin", "s2member"), "error" => true);
  443. /**/
  444. else if(!$attr["desc"] || !is_string($attr["desc"]))
  445. $response = array("response" => _x('Invalid form configuration. Missing "desc" attribute. Please provide a Description for this form.', "s2member-admin", "s2member"), "error" => true);
  446. /**/
  447. else if(strlen($attr["desc"]) > 100) /* Actually, this can be 127 chars; but we need plenty of room for s2Member's coupon info. */
  448. $response = array("response" => _x('Invalid form configuration. Your "desc" ( Description ) attribute must be <= 100 characters long.', "s2member-admin", "s2member"), "error" => true);
  449. /**/
  450. else if(!$attr["custom"] || !is_string($attr["custom"]))
  451. $response = array("response" => _x('Invalid form configuration. Missing "custom" attribute. Must start with your domain name.', "s2member-admin", "s2member"), "error" => true);
  452. /**/
  453. else if(!preg_match("/^".preg_quote(preg_replace("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/")."/i", $attr["custom"]))
  454. $response = array("response" => _x('Invalid form configuration. Invalid "custom" attribute. Must start with matching domain.', "s2member-admin", "s2member"), "error" => true);
  455. /**/
  456. else if(!$attr["cc"] || !is_string($attr["cc"]))
  457. $response = array("response" => _x('Invalid form configuration. Missing "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
  458. /**/
  459. else if(strlen($attr["cc"]) !== 3)
  460. $response = array("response" => _x('Invalid form configuration. Invalid "cc" attribute. Must be a 3 character Currency Code.', "s2member-admin", "s2member"), "error" => true);
  461. /**/
  462. else if(!strlen($attr["dg"]) || !is_string($attr["dg"]))
  463. $response = array("response" => _x('Invalid form configuration. Missing "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
  464. /**/
  465. else if($attr["dg"] < 0 || $attr["dg"] > 1)
  466. $response = array("response" => _x('Invalid form configuration. Invalid "dg" attribute. Digital indicator. Must be numeric [0-1].', "s2member-admin", "s2member"), "error" => true);
  467. /**/
  468. else if(!strlen($attr["ns"]) || !is_string($attr["ns"]))
  469. $response = array("response" => _x('Invalid form configuration. Missing "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
  470. /**/
  471. else if($attr["ns"] < 0 || $attr["ns"] > 2)
  472. $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be numeric [0-2].', "s2member-admin", "s2member"), "error" => true);
  473. /**/
  474. else if($attr["dg"] && $attr["ns"] !== "1")
  475. $response = array("response" => _x('Invalid form configuration. Invalid "ns" attribute. Shipping configuration. Must be 1 with "dg" ( digital ) items.', "s2member-admin", "s2member"), "error" => true);
  476. /**/
  477. else if($attr["lc"] && strlen($attr["lc"]) !== 2)
  478. $response = array("response" => _x('Invalid form configuration. Invalid "lc" attribute. Locale Code. When provided, must be a 2 character country code.', "s2member-admin", "s2member"), "error" => true);
  479. /**/
  480. else if($attr["tp"] && (!is_string($attr["tp"]) || !is_numeric($attr["tp"])))
  481. $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
  482. /**/
  483. else if($attr["tp"] && $attr["tp"] < 1)
  484. $response = array("response" => _x('Invalid form configuration. Invalid "tp" attribute. The Trial Period. When provided, must be >= 1.', "s2member-admin", "s2member"), "error" => true);
  485. /**/
  486. else if($attr["tp"] && (!$attr["tt"] || !is_string($attr["tt"])))
  487. $response = array("response" => _x('Invalid form configuration. Missing "tt" attribute. The Trial Term. When "tp" is provided, "tt" ( Trial Term ) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
  488. /**/
  489. else if($attr["tp"] && !preg_match("/[DWMY]/", $attr["tt"]))
  490. $response = array("response" => _x('Invalid form configuration. Invalid "tt" attribute. The Trial Term. When "tp" is provided, "tt" ( Trial Term ) must be one of D,W,M,Y.', "s2member-admin", "s2member"), "error" => true);
  491. /**/
  492. else if($attr["tp"] && $attr["ta"] && !is_numeric($attr["ta"]))
  493. $response = array("response" => _x('Invalid form configuration. Invalid "ta" attribute. The Trial Amount. When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
  494. /**/
  495. else if($attr["tp"] && $attr["ta"] && $attr["ta"] < 0.00)
  496. $response = array("response" => _x('Invalid form configuration. Invalid "ta" attribute. The Trial Amount. When provided, must be >= 0.00.', "s2member-admin", "s2member"), "error" => true);
  497. /**/
  498. else if($attr["tp"] && $attr["ta"] && $attr["ta"] > 10000.00)
  499. $response = array("response" => _x('Invalid form configuration. Invalid "ta" attribute. The Trial Amount. When provided, must be <= 10000.00.', "s2member-admin", "s2member"), "error" => true);
  500. /**/
  501. else if(!$attr["rp"] || !is_string($attr["rp"]))
  502. $response = array("response" => _x('Invalid form configuration. Missing "rp" attribute. The Regular Period. Must be >= 1.', "s2member-admin", "s2member"), "error" => true);
  503. /**/
  504. else if(!is_numeric($attr["rp"]))
  505. $response = array("response" => _x('Invalid form configuration. Invalid "rp" attribute. The Regular Period. Must be numeric.', "s2member-admin", "s2member"), "error" => true);
  506. /**/
  507. else if($attr["rp"] < 1)
  508. $response = array("response" => _x('Invalid form configuration. Invalid "rp" attribute. The Regular Period. Must be >= 1.', "s2member-admin", "s2member"), "error" => true);
  509. /**/
  510. else if(!$attr["rt"] || !is_string($attr["rt"]))
  511. $response = array("response" => _x('Invalid form configuration. Missing "rt" attribute. The Regular Term. Must be one of D,W,M,Y,L.', "s2member-admin", "s2member"), "error" => true);
  512. /**/
  513. else if(!preg_match("/[DWMYL]/", $attr["rt"]))
  514. $response = array("response" => _x('Invalid form configuration. Invalid "rt" attribute. The Regular Term. Must be one of D,W,M,Y,L.', "s2member-admin", "s2member"), "error" => true);
  515. /**/
  516. else if($attr["rt"] === "D" && $attr["rp"] > 365 && $attr["rr"] !== "BN")
  517. $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" ( Regular Term ) attribute is "D", "rp" ( Regular Period ) > 365, and "rr" is not "BN" ( Buy Now ).', "s2member-admin", "s2member"), "error" => true);
  518. /**/
  519. else if($attr["rt"] === "W" && $attr["rp"] > 52 && $attr["rr"] !== "BN")
  520. $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" ( Regular Term ) attribute is "W", "rp" ( Regular Period ) > 52, and "rr" is not "BN" ( Buy Now ).', "s2member-admin", "s2member"), "error" => true);
  521. /**/
  522. else if($attr["rt"] === "M" && $attr["rp"] > 12 && $attr["rr"] !== "BN")
  523. $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" ( Regular Term ) attribute is "M", "rp" ( Regular Period ) > 12, and "rr" is not "BN" ( Buy Now ).', "s2member-admin", "s2member"), "error" => true);
  524. /**/
  525. else if($attr["rr"] !== "BN" && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_payflow_api_username"] && !in_array($attr["rp"]."-".$attr["rt"], array("1-W", "2-W", "1-M", "3-M", "6-M", "1-Y"), TRUE))
  526. $response = array("response" => _x('Invalid Payflow® form configuration. Invalid "rt, rp, rr" attributes. Payflow® supports a specific set of recurring intervals. Pro Forms can be configured to charge: weekly, bi-weekly, monthly, quarterly, every six months, or yearly. Any other combination results in this error. This is a Payflow® limitation. Note that Payflow® does NOT support daily and/or bi-monthly billing.', "s2member-admin", "s2member"), "error" => true);
  527. /**/
  528. else if($attr["rt"] === "Y" && $attr["rp"] > 5 && $attr["rr"] !== "BN")
  529. $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" ( Regular Term ) attribute is "Y", "rp" ( Regular Period ) > 5, and "rr" is not "BN" ( Buy Now ).', "s2member-admin", "s2member"), "error" => true);
  530. /**/
  531. else if($attr["rt"] === "Y" && $attr["rp"] > 1 && $attr["rr"] !== "BN")
  532. $response = array("response" => _x('Invalid form configuration. Invalid "rt, rp, rr" attributes. The "rt" ( Regular Term ) attribute is "Y", "rp" ( Regular Period ) > 1, and "rr" is not "BN" ( Buy Now ).', "s2member-admin", "s2member"), "error" => true);
  533. /**/
  534. else if($attr["rt"] === "L" && $attr["rp"] > 1)
  535. $response = array("response" => _x('Invalid form configuration. Invalid "rp, rt" attributes. The "rt" ( Regular Term ) attribute is "L" ( Lifetime ), and "rp" ( Regular Period ) > 1.', "s2member-admin", "s2member"), "error" => true);
  536. /**/
  537. else if($attr["rt"] === "L" && $attr["rr"] !== "BN")
  538. $response = array("response" => _x('Invalid form configuration. Invalid "rt, rr" attributes. The "rt" ( Regular Term ) attribute is "L" ( Lifetime ), and "rr" is not "BN" ( Buy Now ).', "s2member-admin", "s2member"), "error" => true);
  539. /**/
  540. else if(!$attr["level_ccaps_eotper"] || !is_string($attr["level_ccaps_eotper"]))
  541. $response = array("response" => _x('Invalid form configuration. Missing "level_ccaps_eotper" attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
  542. /**/
  543. else if($attr["level"] !== "*" && !preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $attr["level_ccaps_eotper"]))
  544. $response = array("response" => _x('Invalid form configuration. Invalid "level_ccaps_eotper" attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
  545. /**/
  546. else if($attr["level"] === "*" && !preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_wo_level_regex"], $attr["level_ccaps_eotper"]))
  547. $response = array("response" => _x('Invalid form configuration. Invalid "level_ccaps_eotper" attribute. Please check Shortcode Attributes.', "s2member-admin", "s2member"), "error" => true);
  548. /**/
  549. else if(!$attr["ra"] || !is_string($attr["ra"]))
  550. $response = array("response" => _x('Invalid form configuration. Missing "ra" attribute. The Regular Amount. Must be >= 0.01.', "s2member-admin", "s2member"), "error" => true);
  551. /**/
  552. else if(!is_numeric($attr["ra"]))
  553. $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be numeric.', "s2member-admin", "s2member"), "error" => true);
  554. /**/
  555. else if($attr["ra"] < 0.01)
  556. $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be >= 0.01.', "s2member-admin", "s2member"), "error" => true);
  557. /**/
  558. else if($attr["ra"] > 10000.00)
  559. $response = array("response" => _x('Invalid form configuration. Invalid "ra" attribute. The Regular Amount. Must be <= 10000.00.', "s2member-admin", "s2member"), "error" => true);
  560. /**/
  561. else if($attr["rr"] && (!is_string($attr["rr"]) || !preg_match("/^([0-1]|BN)$/", $attr["rr"])))
  562. $response = array("response" => _x('Invalid form configuration. Invalid "rr" attribute. Regular Recurring. When provided, must be 0, 1, or BN.', "s2member-admin", "s2member"), "error" => true);
  563. /**/
  564. else if($attr["rr"] === "BN" && $attr["tp"])
  565. $response = array("response" => _x('Invalid form configuration. Invalid "rr, tp" attributes. The "rr" ( Regular Recurring ) attribute is "BN" ( Buy Now ), and "tp" ( Trial Period ) is not "0".', "s2member-admin", "s2member"), "error" => true);
  566. /**/
  567. else if($attr["level"] === "*" && $attr["rr"] !== "BN")
  568. $response = array("response" => _x('Invalid form configuration. Invalid "level, rr" attributes. The "level" ( Level ) attribute is "*" for ( Independent Custom Capabilities ), and "rr" is not "BN" ( Buy Now ).', "s2member-admin", "s2member"), "error" => true);
  569. /**/
  570. else if($attr["ta"] === $attr["ra"] && $attr["tp"] === $attr["rp"] && $attr["tt"] === $attr["rt"])
  571. $response = array("response" => _x('Invalid form configuration. Invalid "ta, tp, tt" attributes. Trial Period. When provided, these cannot be exactly the same as your "ra, rp, rt" attributes.', "s2member-admin", "s2member"), "error" => true);
  572. /**/
  573. else if($attr["rrt"] && (!is_string($attr["rrt"]) || !is_numeric($attr["rrt"])))
  574. $response = array("response" => _x('Invalid form configuration. Invalid "rrt" attribute. Recurring Times ( fixed ). When provided, must be numeric.', "s2member-admin", "s2member"), "error" => true);
  575. /**/
  576. else if($attr["rrt"] && $attr["rrt"] < 1)
  577. $response = array("response" => _x('Invalid form configuration. Invalid "rrt" attribute. Recurring Times ( fixed ). When provided, must be >= 1.', "s2member-admin", "s2member"), "error" => true);
  578. /**/
  579. else if($attr["rrt"] && $attr["rr"] !== "1")
  580. $response = array("response" => _x('Invalid form configuration. Invalid "rr, rrt" attributes. When "rrt" ( Recurring Times ) is provided, "rr" ( Regular Recurring ) must be 1.', "s2member-admin", "s2member"), "error" => true);
  581. /****/
  582. else if(($attr["rr"] === "0" || $attr["rr"] === "1") && (!is_string($attr["rra"]) || !is_numeric($attr["rra"])))
  583. $response = array("response" => _x('Invalid form configuration. Invalid "rr, rra" attributes. When "rr" ( Regular Recurring ) is 0 or 1, "rra" ( Recurring Retry Attempts ) must be numeric.', "s2member-admin", "s2member"), "error" => true);
  584. /**/
  585. else if(($attr["rr"] === "0" || $attr["rr"] === "1") && $attr["rra"] < 0)
  586. $response = array("response" => _x('Invalid form configuration. Invalid "rr, rra" attributes. When "rr" ( Regular Recurring ) is 0 or 1, "rra" ( Recurring Retry Attempts ) must be >= 0.', "s2member-admin", "s2member"), "error" => true);
  587. }
  588. }
  589. /**/
  590. return (empty($response)) ? null : $response;
  591. }
  592. /**
  593. * Validates different kinds of form submissions.
  594. *
  595. * Free Registration Forms do NOT require API Credentials.
  596. *
  597. * @package s2Member\PayPal
  598. * @since 1.5
  599. *
  600. * @param str $form The type of Pro Form being submitted.
  601. * @param array $s An array of data submitted through the Pro Form.
  602. * @return null|array Null if there are no errors, else a response array.
  603. */
  604. public static function paypal_form_submission_validation_errors($form = FALSE, $s = FALSE)
  605. {
  606. if($form === "registration" || !($response = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_api_validation_errors()))
  607. {
  608. if($form === "cancellation") /* Special form for Cancellations. User/Member must be logged in. */
  609. {
  610. if(!is_user_logged_in())
  611. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to cancel your account.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  612. /* ----------------------------------------------------------------------------------------------------------------- */
  613. else if($s["attr"]["captcha"] && (!$s["recaptcha_challenge_field"] || !$s["recaptcha_response_field"] || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"])))
  614. $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  615. /* ----------------------------------------------------------------------------------------------------------------- */
  616. else if(is_object($user = wp_get_current_user()) && $user->ID && $user->has_cap("administrator")) /* NOT for Administrators. */
  617. $response = array("response" => _x('Unable to process. You are an Administrator. Stopping here for security. Otherwise, an Administrator could lose access.', "s2member-admin", "s2member"), "error" => true);
  618. }
  619. /**/
  620. else if($form === "update") /* Special form for Updates. User/Member must be logged in. */
  621. {
  622. if(!is_user_logged_in())
  623. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to update your billing information.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  624. /* ----------------------------------------------------------------------------------------------------------------- */
  625. else if(is_object($user = wp_get_current_user()) && $user->ID && $user->has_cap("administrator")) /* NOT for Administrators. */
  626. $response = array("response" => _x('Unable to process. You are an Administrator. Stopping here for security. Otherwise, an Administrator could lose access.', "s2member-admin", "s2member"), "error" => true);
  627. /* ----------------------------------------------------------------------------------------------------------------- */
  628. else if(!$s["card_type"] || !is_string($s["card_type"]))
  629. $response = array("response" => _x('Missing Card Type ( Billing Method ). Please try again.', "s2member-front", "s2member"), "error" => true);
  630. /**/
  631. else if(!in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal")) || !is_array($s["attr"]["accept"]) || !in_array(strtolower($s["card_type"]), $s["attr"]["accept"]))
  632. $response = array("response" => _x('Invalid Card Type ( Billing Method ). Please try again.', "s2member-front", "s2member"), "error" => true);
  633. /**/
  634. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_number"] || !is_string($s["card_number"])))
  635. $response = array("response" => _x('Missing Card Number. Please try again.', "s2member-front", "s2member"), "error" => true);
  636. /**/
  637. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_expiration"] || !is_string($s["card_expiration"])))
  638. $response = array("response" => _x('Missing Card Expiration Date ( mm/yyyy ). Please try again.', "s2member-front", "s2member"), "error" => true);
  639. /**/
  640. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && !preg_match("/^[0-9]{2}\/[0-9]{4}$/", $s["card_expiration"]))
  641. $response = array("response" => _x('Invalid Card Expiration Date. Must be in this format ( mm/yyyy ). Please try again.', "s2member-front", "s2member"), "error" => true);
  642. /**/
  643. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_verification"] || !is_string($s["card_verification"])))
  644. $response = array("response" => _x('Missing Card Verification Code. It\'s on the back of your Card. 3-4 digits. Please try again.', "s2member-front", "s2member"), "error" => true);
  645. /**/
  646. else if(in_array($s["card_type"], array("Maestro", "Solo")) && (!$s["card_start_date_issue_number"] || !is_string($s["card_start_date_issue_number"])))
  647. $response = array("response" => _x('Missing Card Start Date, or Issue #. Required for Maestro/Solo. Please try again.', "s2member-front", "s2member"), "error" => true);
  648. /* ----------------------------------------------------------------------------------------------------------------- */
  649. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["street"] || !is_string($s["street"])))
  650. $response = array("response" => _x('Missing Street Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  651. /**/
  652. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["city"] || !is_string($s["city"])))
  653. $response = array("response" => _x('Missing City/Town. Please try again.', "s2member-front", "s2member"), "error" => true);
  654. /**/
  655. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["state"] || !is_string($s["state"])))
  656. $response = array("response" => _x('Missing State/Province. Please try again.', "s2member-front", "s2member"), "error" => true);
  657. /**/
  658. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["country"] || !is_string($s["country"])))
  659. $response = array("response" => _x('Missing Country. Please try again.', "s2member-front", "s2member"), "error" => true);
  660. /**/
  661. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["zip"] || !is_string($s["zip"])))
  662. $response = array("response" => _x('Missing Postal/Zip Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  663. /* ----------------------------------------------------------------------------------------------------------------- */
  664. else if($s["attr"]["captcha"] && (!$s["recaptcha_challenge_field"] || !$s["recaptcha_response_field"] || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"])))
  665. $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  666. }
  667. /**/
  668. else if($form === "registration") /* Validation routines for free Registration forms. */
  669. {
  670. if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && (!$s["first_name"] || !is_string($s["first_name"])))
  671. $response = array("response" => _x('Missing First Name. Please try again.', "s2member-front", "s2member"), "error" => true);
  672. /**/
  673. else if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && (!$s["last_name"] || !is_string($s["last_name"])))
  674. $response = array("response" => _x('Missing Last Name. Please try again.', "s2member-front", "s2member"), "error" => true);
  675. /**/
  676. else if(!$s["email"] || !is_string($s["email"]))
  677. $response = array("response" => _x('Missing or invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  678. /**/
  679. else if(!is_email($s["email"]))
  680. $response = array("response" => _x('Invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  681. /**/
  682. else if(email_exists($s["email"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"])))
  683. $response = array("response" => _x('That Email Address is already in use. Please try again.', "s2member-front", "s2member"), "error" => true);
  684. /**/
  685. else if(!$s["username"] || !is_string($s["username"]))
  686. $response = array("response" => _x('Missing or invalid Username. Please try again.', "s2member-front", "s2member"), "error" => true);
  687. /**/
  688. else if(!validate_username($s["username"]))
  689. $response = array("response" => _x('Invalid Username. Please try again. Use ONLY lowercase alphanumerics.', "s2member-front", "s2member"), "error" => true);
  690. /**/
  691. else if(username_exists($s["username"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"])))
  692. $response = array("response" => _x('That Username is already in use. Please try again.', "s2member-front", "s2member"), "error" => true);
  693. /**/
  694. else if(is_multisite() && !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"]) && ($_response = wpmu_validate_user_signup($s["username"], $s["email"])) && is_wp_error($_errors = $_response["errors"]) && $_errors->get_error_message())
  695. $response = array("response" => $_errors->get_error_message(), "error" => true);
  696. /**/
  697. else if((!$s["password1"] || !is_string($s["password1"])) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  698. $response = array("response" => _x('Missing Password. Please try again.', "s2member-front", "s2member"), "error" => true);
  699. /**/
  700. else if(strlen($s["password1"]) < 6 && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  701. $response = array("response" => _x('Invalid Password. Must be at least 6 characters. Please try again.', "s2member-front", "s2member"), "error" => true);
  702. /**/
  703. else if(strlen($s["password1"]) > 20 && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  704. $response = array("response" => _x('Invalid Password. Max length is 20 characters. Please try again.', "s2member-front", "s2member"), "error" => true);
  705. /**/
  706. else if($s["password2"] !== $s["password1"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  707. $response = array("response" => _x('Password fields do NOT match. Please try again.', "s2member-front", "s2member"), "error" => true);
  708. /* ----------------------------------------------------------------------------------------------------------------- */
  709. else if($s["attr"]["captcha"] && (!$s["recaptcha_challenge_field"] || !$s["recaptcha_response_field"] || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"])))
  710. $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  711. }
  712. /**/
  713. else if($form === "sp-checkout") /* Validation routines for Specific Post/Page checkout forms. */
  714. {
  715. if(!$s["first_name"] || !is_string($s["first_name"]))
  716. $response = array("response" => _x('Missing First Name. Please try again.', "s2member-front", "s2member"), "error" => true);
  717. /**/
  718. else if(!$s["last_name"] || !is_string($s["last_name"]))
  719. $response = array("response" => _x('Missing Last Name. Please try again.', "s2member-front", "s2member"), "error" => true);
  720. /**/
  721. else if(!$s["email"] || !is_string($s["email"]))
  722. $response = array("response" => _x('Missing or invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  723. /**/
  724. else if(!is_email($s["email"]))
  725. $response = array("response" => _x('Invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  726. /* ----------------------------------------------------------------------------------------------------------------- */
  727. else if(!$s["card_type"] || !is_string($s["card_type"]))
  728. $response = array("response" => _x('Missing Card Type ( Billing Method ). Please try again.', "s2member-front", "s2member"), "error" => true);
  729. /**/
  730. else if(!in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal")) || !is_array($s["attr"]["accept"]) || !in_array(strtolower($s["card_type"]), $s["attr"]["accept"]))
  731. $response = array("response" => _x('Invalid Card Type ( Billing Method ). Please try again.', "s2member-front", "s2member"), "error" => true);
  732. /**/
  733. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_number"] || !is_string($s["card_number"])))
  734. $response = array("response" => _x('Missing Card Number. Please try again.', "s2member-front", "s2member"), "error" => true);
  735. /**/
  736. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_expiration"] || !is_string($s["card_expiration"])))
  737. $response = array("response" => _x('Missing Card Expiration Date ( mm/yyyy ). Please try again.', "s2member-front", "s2member"), "error" => true);
  738. /**/
  739. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && !preg_match("/^[0-9]{2}\/[0-9]{4}$/", $s["card_expiration"]))
  740. $response = array("response" => _x('Invalid Card Expiration Date. Must be in this format ( mm/yyyy ). Please try again.', "s2member-front", "s2member"), "error" => true);
  741. /**/
  742. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_verification"] || !is_string($s["card_verification"])))
  743. $response = array("response" => _x('Missing Card Verification Code. It\'s on the back of your Card. 3-4 digits. Please try again.', "s2member-front", "s2member"), "error" => true);
  744. /**/
  745. else if(in_array($s["card_type"], array("Maestro", "Solo")) && (!$s["card_start_date_issue_number"] || !is_string($s["card_start_date_issue_number"])))
  746. $response = array("response" => _x('Missing Card Start Date, or Issue #. Required for Maestro/Solo. Please try again.', "s2member-front", "s2member"), "error" => true);
  747. /* ----------------------------------------------------------------------------------------------------------------- */
  748. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["street"] || !is_string($s["street"])))
  749. $response = array("response" => _x('Missing Street Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  750. /**/
  751. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["city"] || !is_string($s["city"])))
  752. $response = array("response" => _x('Missing City/Town. Please try again.', "s2member-front", "s2member"), "error" => true);
  753. /**/
  754. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["state"] || !is_string($s["state"])))
  755. $response = array("response" => _x('Missing State/Province. Please try again.', "s2member-front", "s2member"), "error" => true);
  756. /**/
  757. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["country"] || !is_string($s["country"])))
  758. $response = array("response" => _x('Missing Country. Please try again.', "s2member-front", "s2member"), "error" => true);
  759. /**/
  760. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["zip"] || !is_string($s["zip"])))
  761. $response = array("response" => _x('Missing Postal/Zip Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  762. /* ----------------------------------------------------------------------------------------------------------------- */
  763. else if($s["attr"]["captcha"] && (!$s["recaptcha_challenge_field"] || !$s["recaptcha_response_field"] || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"])))
  764. $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  765. }
  766. /**/
  767. else if($form === "checkout") /* Validation routines for Member Level checkout forms. This is the default functionality. */
  768. {
  769. if($s["attr"]["modify"] && !is_user_logged_in())
  770. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> to modify your billing plan.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  771. /* ----------------------------------------------------------------------------------------------------------------- */
  772. else if($s["attr"]["level"] === "*" && !is_user_logged_in())
  773. $response = array("response" => sprintf(_x('You must <a href="%s" rel="nofollow">log in</a> before making this purchase.', "s2member-front", "s2member"), esc_attr(wp_login_url($_SERVER["REQUEST_URI"]))), "error" => true);
  774. /* ----------------------------------------------------------------------------------------------------------------- */
  775. else if(is_user_logged_in() && is_object($user = wp_get_current_user()) && $user->ID && $user->has_cap("administrator")) /* NOT for Administrators. */
  776. $response = array("response" => _x('Unable to process. You are an Administrator. Stopping here for security. Otherwise, an Administrator could lose access.', "s2member-admin", "s2member"), "error" => true);
  777. /* ----------------------------------------------------------------------------------------------------------------- */
  778. else if(!$s["first_name"] || !is_string($s["first_name"]))
  779. $response = array("response" => _x('Missing First Name. Please try again.', "s2member-front", "s2member"), "error" => true);
  780. /**/
  781. else if(!$s["last_name"] || !is_string($s["last_name"]))
  782. $response = array("response" => _x('Missing Last Name. Please try again.', "s2member-front", "s2member"), "error" => true);
  783. /**/
  784. else if(!is_user_logged_in() && (!$s["email"] || !is_string($s["email"])))
  785. $response = array("response" => _x('Missing or invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  786. /**/
  787. else if(!is_user_logged_in() && !is_email($s["email"]))
  788. $response = array("response" => _x('Invalid Email Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  789. /**/
  790. else if(!is_user_logged_in() && email_exists($s["email"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"])))
  791. $response = array("response" => _x('That Email Address is already in use. Please try again.', "s2member-front", "s2member"), "error" => true);
  792. /**/
  793. else if(!is_user_logged_in() && (!$s["username"] || !is_string($s["username"])))
  794. $response = array("response" => _x('Missing or invalid Username. Please try again.', "s2member-front", "s2member"), "error" => true);
  795. /**/
  796. else if(!is_user_logged_in() && !validate_username($s["username"]))
  797. $response = array("response" => _x('Invalid Username. Please try again. Use ONLY lowercase alphanumerics.', "s2member-front", "s2member"), "error" => true);
  798. /**/
  799. else if(!is_user_logged_in() && username_exists($s["username"]) && (!is_multisite() || !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"])))
  800. $response = array("response" => _x('That Username is already in use. Please try again.', "s2member-front", "s2member"), "error" => true);
  801. /**/
  802. else if(!is_user_logged_in() && is_multisite() && !c_ws_plugin__s2member_utils_users::ms_user_login_email_can_join_blog($s["username"], $s["email"]) && ($_response = wpmu_validate_user_signup($s["username"], $s["email"])) && is_wp_error($_errors = $_response["errors"]) && $_errors->get_error_message())
  803. $response = array("response" => $_errors->get_error_message(), "error" => true);
  804. /**/
  805. else if(!is_user_logged_in() && (!$s["password1"] || !is_string($s["password1"])) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  806. $response = array("response" => _x('Missing Password. Please try again.', "s2member-front", "s2member"), "error" => true);
  807. /**/
  808. else if(!is_user_logged_in() && strlen($s["password1"]) < 6 && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  809. $response = array("response" => _x('Invalid Password. Must be at least 6 characters. Please try again.', "s2member-front", "s2member"), "error" => true);
  810. /**/
  811. else if(!is_user_logged_in() && strlen($s["password1"]) > 20 && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  812. $response = array("response" => _x('Invalid Password. Max length is 20 characters. Please try again.', "s2member-front", "s2member"), "error" => true);
  813. /**/
  814. else if(!is_user_logged_in() && $s["password2"] !== $s["password1"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
  815. $response = array("response" => _x('Password fields do NOT match. Please try again.', "s2member-front", "s2member"), "error" => true);
  816. /* ----------------------------------------------------------------------------------------------------------------- */
  817. else if(!$s["card_type"] || !is_string($s["card_type"]))
  818. $response = array("response" => _x('Missing Card Type ( Billing Method ). Please try again.', "s2member-front", "s2member"), "error" => true);
  819. /**/
  820. else if(!in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo", "PayPal")) || !is_array($s["attr"]["accept"]) || !in_array(strtolower($s["card_type"]), $s["attr"]["accept"]))
  821. $response = array("response" => _x('Invalid Card Type ( Billing Method ). Please try again.', "s2member-front", "s2member"), "error" => true);
  822. /**/
  823. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_number"] || !is_string($s["card_number"])))
  824. $response = array("response" => _x('Missing Card Number. Please try again.', "s2member-front", "s2member"), "error" => true);
  825. /**/
  826. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_expiration"] || !is_string($s["card_expiration"])))
  827. $response = array("response" => _x('Missing Card Expiration Date ( mm/yyyy ). Please try again.', "s2member-front", "s2member"), "error" => true);
  828. /**/
  829. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && !preg_match("/^[0-9]{2}\/[0-9]{4}$/", $s["card_expiration"]))
  830. $response = array("response" => _x('Invalid Card Expiration Date. Must be in this format ( mm/yyyy ). Please try again.', "s2member-front", "s2member"), "error" => true);
  831. /**/
  832. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["card_verification"] || !is_string($s["card_verification"])))
  833. $response = array("response" => _x('Missing Card Verification Code. It\'s on the back of your Card. 3-4 digits. Please try again.', "s2member-front", "s2member"), "error" => true);
  834. /**/
  835. else if(in_array($s["card_type"], array("Maestro", "Solo")) && (!$s["card_start_date_issue_number"] || !is_string($s["card_start_date_issue_number"])))
  836. $response = array("response" => _x('Missing Card Start Date, or Issue #. Required for Maestro/Solo. Please try again.', "s2member-front", "s2member"), "error" => true);
  837. /* ----------------------------------------------------------------------------------------------------------------- */
  838. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["street"] || !is_string($s["street"])))
  839. $response = array("response" => _x('Missing Street Address. Please try again.', "s2member-front", "s2member"), "error" => true);
  840. /**/
  841. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["city"] || !is_string($s["city"])))
  842. $response = array("response" => _x('Missing City/Town. Please try again.', "s2member-front", "s2member"), "error" => true);
  843. /**/
  844. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["state"] || !is_string($s["state"])))
  845. $response = array("response" => _x('Missing State/Province. Please try again.', "s2member-front", "s2member"), "error" => true);
  846. /**/
  847. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["country"] || !is_string($s["country"])))
  848. $response = array("response" => _x('Missing Country. Please try again.', "s2member-front", "s2member"), "error" => true);
  849. /**/
  850. else if(in_array($s["card_type"], array("Visa", "MasterCard", "Discover", "Amex", "Maestro", "Solo")) && (!$s["zip"] || !is_string($s["zip"])))
  851. $response = array("response" => _x('Missing Postal/Zip Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  852. /* ----------------------------------------------------------------------------------------------------------------- */
  853. else if($s["attr"]["captcha"] && (!$s["recaptcha_challenge_field"] || !$s["recaptcha_response_field"] || !c_ws_plugin__s2member_utils_captchas::recaptcha_code_validates($s["recaptcha_challenge_field"], $s["recaptcha_response_field"])))
  854. $response = array("response" => _x('Missing or invalid Security Code. Please try again.', "s2member-front", "s2member"), "error" => true);
  855. }
  856. else /* Else we are dealing with an unknown form submission type. */
  857. $response = array("response" => _x('Unknown form submission type. Please contact Support.', "s2member-front", "s2member"), "error" => true);
  858. }
  859. /**/
  860. return (empty($response)) ? null : $response;
  861. }
  862. }
  863. }
  864. ?>

s2member-pro\includes\classes\gateways\paypal\paypal-responses.inc.php

Source Code Documentation