/app_old/membershipincludes/classes/class.wizard.php

  1. <?php 
  2. if(!class_exists('M_Wizard')) { 
  3.  
  4. class M_Wizard { 
  5.  
  6. var $tables = array('membership_levels', 'membership_rules', 'subscriptions', 'subscriptions_levels', 'membership_relationships', 'membermeta', 'communications', 'urlgroups', 'ping_history', 'pings'); 
  7.  
  8. var $membership_levels; 
  9. var $membership_rules; 
  10. var $membership_relationships; 
  11. var $subscriptions; 
  12. var $subscriptions_levels; 
  13. var $membermeta; 
  14. var $communications; 
  15. var $urlgroups; 
  16. var $ping_history; 
  17. var $pings; 
  18.  
  19. function __construct( ) { 
  20.  
  21. global $wpdb; 
  22.  
  23. $this->db =& $wpdb; 
  24.  
  25. foreach($this->tables as $table) { 
  26. $this->$table = membership_db_prefix($this->db, $table); 
  27.  
  28. // if logged in: 
  29. add_action( 'wp_ajax_processwizard', array(&$this, 'ajax_process_wizard') ); 
  30. add_action( 'admin_init', array(&$this, 'process_visibility') ); 
  31.  
  32. function M_Wizard( ) { 
  33. $this->__construct(); 
  34.  
  35. function ajax_process_wizard() { 
  36.  
  37. global $page, $action, $step; 
  38.  
  39. wp_reset_vars( array('action', 'page', 'step') ); 
  40.  
  41. switch( $_POST['from']) { 
  42. case 'stepone': if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  43. switch($_POST['wizardtype']) { 
  44. case 'normal': echo $this->show_normal_wizard_step( "admin.php?page=membership&step=3" ); 
  45. break; 
  46.  
  47. case 'dripped': echo $this->show_dripped_wizard_step( "admin.php?page=membership&step=3" ); 
  48. break; 
  49.  
  50. case 'advanced': // Skips wizard and goes to pointer tutorial 
  51. $this->hide_wizard(); 
  52. echo "clear"; 
  53. break; 
  54. break; 
  55.  
  56. case 'steptwo': 
  57. if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  58. switch($_POST['wizardtype']) { 
  59. case 'normal': echo $this->process_normal_wizard_step(); 
  60. break; 
  61.  
  62. case 'dripped': echo $this->process_dripped_wizard_step(); 
  63. break; 
  64. // Show the thank you message 
  65. echo $this->page_end(); 
  66. break; 
  67. exit; 
  68.  
  69. function process_visibility() { 
  70.  
  71. if(isset($_GET['action']) && $_GET['action'] == 'deactivatewelcome') { 
  72.  
  73. check_admin_referer('deactivate-welcome'); 
  74.  
  75. $this->hide_wizard(); 
  76.  
  77. wp_safe_redirect( remove_query_arg( 'action', remove_query_arg( '_wpnonce') ) ); 
  78.  
  79.  
  80. function wizard_visible() { 
  81. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  82. if(function_exists('get_blog_option')) { 
  83. if(function_exists('switch_to_blog')) { 
  84. switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); 
  85. $wizard_visible = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_wizard_visible', 'yes'); 
  86. if(function_exists('restore_current_blog')) { 
  87. restore_current_blog(); 
  88. } else { 
  89. $wizard_visible = get_option('membership_wizard_visible', 'yes'); 
  90. } else { 
  91. $wizard_visible = get_option('membership_wizard_visible', 'yes'); 
  92.  
  93. return $wizard_visible; 
  94.  
  95. function hide_wizard() { 
  96. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  97. if(function_exists('update_blog_option')) { 
  98. update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_wizard_visible', 'no'); 
  99. } else { 
  100. update_option('membership_wizard_visible', 'no'); 
  101. } else { 
  102. update_option('membership_wizard_visible', 'no'); 
  103.  
  104. function conditional_show() { 
  105.  
  106. global $page, $action, $step; 
  107.  
  108. wp_reset_vars( array('action', 'page', 'step') ); 
  109.  
  110. // carry on and see if we should display the wizard and then what we should display 
  111. if($this->wizard_visible() != 'no') { 
  112.  
  113. if(isset($_GET['step'])) { 
  114. $current_step = (int) $_GET['step']; 
  115. } else { 
  116. $current_step = 1; 
  117.  
  118. switch($current_step) { 
  119.  
  120. case 1: $step2 = "admin.php?page=" . $page. "&step=2"; 
  121. $this->show_with_wrap( $this->page_one( $step2 ) ); 
  122. break; 
  123.  
  124. case 2: if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  125. switch($_POST['wizardtype']) { 
  126. case 'normal': $step3 = "admin.php?page=membership&step=3"; 
  127. echo $this->show_normal_wizard_step( $step3 ); 
  128. break; 
  129.  
  130. case 'dripped': $step3 = "admin.php?page=membership&step=3"; 
  131. echo $this->show_dripped_wizard_step( $step3 ); 
  132. break; 
  133.  
  134. case 'advanced': // Skips wizard and goes to pointer tutorial 
  135. $this->hide_wizard(); 
  136. echo ""; 
  137. break; 
  138. break; 
  139.  
  140. case 3: // Do the processing and then show an end message 
  141. if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  142. switch($_POST['wizardtype']) { 
  143. case 'normal': echo $this->process_normal_wizard_step(); 
  144. break; 
  145.  
  146. case 'dripped': echo $this->process_dripped_wizard_step(); 
  147. break; 
  148. // Show the thank you message 
  149. echo $this->page_end(); 
  150. break; 
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158. function show_with_wrap( $content ) { 
  159.  
  160. global $page, $action, $step; 
  161.  
  162. $deactivateurl = wp_nonce_url("admin.php?page=" . $page. "&action=deactivatewelcome", 'deactivate-welcome'); 
  163. ?> 
  164. <div class="welcome-panel" id="welcome-panel"> 
  165. <a href="<?php echo $deactivateurl; ?>" class="welcome-panel-close"><?php _e('Dismiss', 'membership'); ?></a> 
  166.  
  167. <div class="welcome-panel-content"> 
  168. <?php 
  169. echo $content; 
  170. ?> 
  171. <p class="welcome-panel-dismiss"><?php _e('Already know what you\'re doing?', 'membership'); ?> <a href="<?php echo $deactivateurl; ?>"><?php _e('Dismiss this message', 'membership'); ?></a>.</p> 
  172. </div> 
  173.  
  174. </div> 
  175. <?php 
  176.  
  177. function page_one( $nextsteplink = false ) { 
  178.  
  179. ob_start(); 
  180. ?> 
  181. <h3><?php _e('Welcome to Membership', 'membership'); ?></h3> 
  182. <p class="about-description"> 
  183. <?php 
  184. if ( !defined('WPMUDEV_REMOVE_BRANDING') ) { 
  185. _e('If you need help getting started, check out our documentation over on <a href="http://premium.wpmudev.org/project/membership">WPMUDEV</a>. ', 'membership'); 
  186. _e('You can use the Help tabs in the upper right corner to get information on how to use your current screen. ', 'membership'); 
  187. _e('If you would like us to set up some basic things for you then choose an option below.', 'membership'); 
  188. ?> 
  189. </p> 
  190. <form action='<?php echo $nextsteplink; ?>' method='post' name='wizardform' id='wizardform'> 
  191. <input type='hidden' name='action' value='processwizard' /> 
  192. <input type='hidden' name='from' value='stepone' /> 
  193. <input type='hidden' name='nonce' value='<?php echo wp_create_nonce('membership_wizard'); ?>' /> 
  194. <ul class='wizardoptions'> 
  195. <li><input type='radio' name='wizardtype' value='normal' checked='checked' /> <?php _e('Standard membership site.', 'membership'); ?></li> 
  196. <li><input type='radio' name='wizardtype' value='dripped' /> <?php _e('Dripped content site.', 'membership'); ?></li> 
  197. <li><input type='radio' name='wizardtype' value='advanced' /> <?php _e('Advanced.', 'membership'); ?></li> 
  198. </ul> 
  199. <p class="about-description"> 
  200. <input type='submit' name='submit' class='button-primary alignright' value='<?php _e('Next Step »', 'membership'); ?>' /> 
  201. </p> 
  202. </form> 
  203.  
  204. <?php 
  205. return ob_get_clean(); 
  206.  
  207. function show_normal_wizard_step( $nextsteplink = false ) { 
  208.  
  209. global $page, $action, $step; 
  210.  
  211. $deactivateurl = wp_nonce_url("admin.php?page=" . $page. "&action=deactivatewelcome", 'deactivate-welcome'); 
  212. ob_start(); 
  213. ?> 
  214. <h3><?php _e('Create your levels', 'membership'); ?></h3> 
  215. <p class="about-description"> 
  216. <?php 
  217. _e('A level controls what parts of your website a user has access to, so we will need to set some initial ones up. ', 'membership'); 
  218. _e('Select the number of levels you think you will need to get started (you can add or remove them later).', 'membership'); 
  219. ?> 
  220. </p> 
  221. <form action='<?php echo $nextsteplink; ?>' method='post' name='wizardform' id='wizardform'> 
  222. <input type='hidden' name='action' value='processwizard' /> 
  223. <input type='hidden' name='from' value='steptwo' /> 
  224. <input type='hidden' name='nonce' value='<?php echo wp_create_nonce('membership_wizard'); ?>' /> 
  225. <input type='hidden' name='wizardtype' value='normal' /> 
  226. <p class="about-description createsteps"> 
  227. <?php _e('Create ', 'membership'); ?> 
  228. <select name='numberoflevels' id='wizardnumberoflevels'> 
  229. <?php 
  230. for($n=1; $n <= 2; $n++) { 
  231. if($n == 2) { 
  232. ?> 
  233. <option value='<?php echo $n; ?>' selected='selected'><?php echo $n; ?></option> 
  234. <?php 
  235. } else { 
  236. ?> 
  237. <option value='<?php echo $n; ?>'><?php echo $n; ?></option> 
  238. <?php 
  239. ?> 
  240. </select> 
  241. <?php _e(' levels and give them the following names:', 'membership'); ?> 
  242. </p> 
  243. <ul class='wizardlevelnames'> 
  244. <li><input type='text' name='levelname[]' placeholder='<?php _e('Level 1', 'membership'); ?>' class='wizardlevelname' /></li> 
  245. <li><input type='text' name='levelname[]' placeholder='<?php _e('Level 2', 'membership'); ?>' class='wizardlevelname' /></li> 
  246. </ul> 
  247. <p class="about-description createsteps"> 
  248. <input type='checkbox' name='creatavisitorlevel' value='yes' checked='checked' /> <?php _e('also create a level to control what non-members can see?', 'membership'); ?> 
  249. <br/><br/> 
  250. <?php _e('Finally, I would like to use the ', 'membership'); ?> 
  251. <select name='wizardgateway' > 
  252. <option value=''><?php _e('Select a gateway...', 'membership'); ?></option> 
  253. <?php $gateways = get_membership_gateways(); 
  254. if(!empty($gateways)) { 
  255. foreach($gateways as $key => $gateway) { 
  256. $default_headers = array( 
  257. 'Name' => 'Addon Name',  
  258. 'Author' => 'Author',  
  259. 'Description' => 'Description',  
  260. 'AuthorURI' => 'Author URI',  
  261. 'gateway_id' => 'Gateway ID' 
  262. ); 
  263.  
  264. $gateway_data = get_file_data( membership_dir('membershipincludes/gateways/' . $gateway), $default_headers, 'plugin' ); 
  265.  
  266. if(empty($gateway_data['Name'])) { 
  267. continue; 
  268. ?> 
  269. <option value='<?php echo $gateway_data['gateway_id']; ?>'><?php echo $gateway_data['Name']; ?></option> 
  270. <?php 
  271.  
  272. ?> 
  273. </select> 
  274. <?php _e(' gateway to receive payments.', 'membership'); ?> 
  275. </p> 
  276. <p class="about-description"> 
  277. <input type='submit' name='submit' class='button-primary alignright' value='<?php _e('Finish', 'membership'); ?>' /> 
  278. </p> 
  279. </form> 
  280.  
  281. <p class="welcome-panel-dismiss"><?php _e('Already know what you\'re doing?', 'membership'); ?> <a href="<?php echo $deactivateurl; ?>"><?php _e('Dismiss this message', 'membership'); ?></a>.</p> 
  282.  
  283. <?php 
  284. return ob_get_clean(); 
  285.  
  286.  
  287. function show_dripped_wizard_step( $nextsteplink = false ) { 
  288.  
  289. global $page, $action, $step; 
  290.  
  291. $deactivateurl = wp_nonce_url("admin.php?page=" . $page. "&action=deactivatewelcome", 'deactivate-welcome'); 
  292. ob_start(); 
  293. ?> 
  294. <h3><?php _e('Create your levels', 'membership'); ?></h3> 
  295. <p class="about-description"> 
  296. <?php 
  297. _e('A level controls what parts of your website a user has access to, so we will need to set some initial ones up. ', 'membership'); 
  298. _e('Select the number of levels you think you will need to get started (you can add or remove them later).', 'membership'); 
  299. ?> 
  300. </p> 
  301. <form action='<?php echo $nextsteplink; ?>' method='post' name='wizardform' id='wizardform'> 
  302. <input type='hidden' name='action' value='processwizard' /> 
  303. <input type='hidden' name='from' value='steptwo' /> 
  304. <input type='hidden' name='nonce' value='<?php echo wp_create_nonce('membership_wizard'); ?>' /> 
  305. <input type='hidden' name='wizardtype' value='dripped' /> 
  306. <p class="about-description createsteps"> 
  307. <?php _e('Create ', 'membership'); ?> 
  308. <select name='numberoflevels' id='wizardnumberoflevels'> 
  309. <?php 
  310. for($n=1; $n <= 2; $n++) { 
  311. if($n == 2) { 
  312. ?> 
  313. <option value='<?php echo $n; ?>' selected='selected'><?php echo $n; ?></option> 
  314. <?php 
  315. } else { 
  316. ?> 
  317. <option value='<?php echo $n; ?>'><?php echo $n; ?></option> 
  318. <?php 
  319. ?> 
  320. </select> 
  321. <?php _e(' levels and give them the following names:', 'membership'); ?> 
  322. </p> 
  323. <ul class='wizardlevelnames'> 
  324. <li><input type='text' name='levelname[]' value='<?php _e('Level 1', 'membership'); ?>' class='wizardlevelname' /></li> 
  325. <li><input type='text' name='levelname[]' value='<?php _e('Level 2', 'membership'); ?>' class='wizardlevelname' /></li> 
  326. </ul> 
  327. <p class="about-description createsteps"> 
  328. <input type='checkbox' name='creatavisitorlevel' value='yes' checked='checked' /> <?php _e('also create a level to control what non-members can see?', 'membership'); ?> 
  329. <br/><br/> 
  330. <?php _e('Finally, I would like to use the ', 'membership'); ?> 
  331. <select name='wizardgateway' > 
  332. <option value=''><?php _e('Select a gateway...', 'membership'); ?></option> 
  333. <?php $gateways = get_membership_gateways(); 
  334. if(!empty($gateways)) { 
  335. foreach($gateways as $key => $gateway) { 
  336. $default_headers = array( 
  337. 'Name' => 'Addon Name',  
  338. 'Author' => 'Author',  
  339. 'Description' => 'Description',  
  340. 'AuthorURI' => 'Author URI',  
  341. 'gateway_id' => 'Gateway ID' 
  342. ); 
  343.  
  344. $gateway_data = get_file_data( membership_dir('membershipincludes/gateways/' . $gateway), $default_headers, 'plugin' ); 
  345.  
  346. if(empty($gateway_data['Name'])) { 
  347. continue; 
  348. ?> 
  349. <option value='<?php echo $gateway_data['gateway_id']; ?>'><?php echo $gateway_data['Name']; ?></option> 
  350. <?php 
  351.  
  352. ?> 
  353. </select> 
  354. <?php _e(' gateway to receive payments.', 'membership'); ?> 
  355. </p> 
  356. <p class="about-description"> 
  357. <input type='submit' name='submit' class='button-primary alignright' value='<?php _e('Finish', 'membership'); ?>' /> 
  358. </p> 
  359. </form> 
  360.  
  361. <p class="welcome-panel-dismiss"><?php _e('Already know what you\'re doing?', 'membership'); ?> <a href="<?php echo $deactivateurl; ?>"><?php _e('Dismiss this message', 'membership'); ?></a>.</p> 
  362.  
  363. <?php 
  364. return ob_get_clean(); 
  365.  
  366.  
  367. function process_normal_wizard_step() { 
  368. // This function sets up the normal wizard 
  369.  
  370. if(isset($_POST['levelname'])) { 
  371. foreach($_POST['levelname'] as $key => $value) { 
  372. if(empty($value)) { 
  373. $value = __('Level ', 'membership') . ((int) $key + 1); 
  374. // Create a level 
  375. $level_id = $this->create_level( $value ); 
  376. // Create a subscription with that level 
  377. $sub_id = $this->create_subscription( $value ); 
  378. // Add the level to the subscription 
  379. $this->add_level_to_subscription( $level_id, $sub_id ); 
  380.  
  381. // Activate and make public the levels and subscriptions 
  382. $sub = new M_Subscription( $sub_id ); 
  383. $sub->toggleactivation(); 
  384. $sub->togglepublic(); 
  385. $level = new M_Level( $level_id ); 
  386. $level->toggleactivation(); 
  387.  
  388. // Create a visitor level and set it in the options 
  389. if(isset($_POST['creatavisitorlevel']) && $_POST['creatavisitorlevel'] == 'yes') { 
  390. $level_id = $this->create_level( __('Visitors', 'membership') ); 
  391. $level = new M_Level( $level_id ); 
  392. $level->toggleactivation(); 
  393.  
  394. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  395. if(function_exists('get_blog_option')) { 
  396. if(function_exists('switch_to_blog')) { 
  397. switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); 
  398.  
  399. $M_options = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', array()); 
  400. } else { 
  401. $M_options = get_option('membership_options', array()); 
  402. } else { 
  403. $M_options = get_option('membership_options', array()); 
  404.  
  405. $M_options['strangerlevel'] = (int) $level_id; 
  406.  
  407. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  408. if(function_exists('update_blog_option')) { 
  409. update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', $M_options); 
  410. } else { 
  411. update_option('membership_options', $M_options); 
  412. } else { 
  413. update_option('membership_options', $M_options); 
  414.  
  415. // Activate the relevant gateway if it's set 
  416. if(isset($_POST['wizardgateway'])) { 
  417. $active = get_option('membership_activated_gateways', array()); 
  418. if(!in_array($_POST['wizardgateway'], $active)) { 
  419. $active[] = $_POST['wizardgateway']; 
  420. update_option('membership_activated_gateways', array_unique($active)); 
  421.  
  422.  
  423.  
  424. function process_dripped_wizard_step() { 
  425.  
  426. if(isset($_POST['levelname'])) { 
  427. // Create an initial subscription 
  428. $sub_id = $this->create_subscription( __('Dripped Subscription', 'membership') ); 
  429. $sub = new M_Subscription( $sub_id ); 
  430. $sub->toggleactivation(); 
  431. $sub->togglepublic(); 
  432.  
  433. foreach($_POST['levelname'] as $key => $value) { 
  434. if(empty($value)) { 
  435. $value = __('Level ', 'membership') . ((int) $key + 1); 
  436. // Create a level 
  437. $level_id = $this->create_level( $value ); 
  438. // Add the level to the subscription 
  439. $this->add_level_to_subscription( $level_id, $sub_id, 'finite' ); 
  440. // Activate and make public the levels and subscriptions 
  441. $level = new M_Level( $level_id ); 
  442. $level->toggleactivation(); 
  443. // Create a visitor level and set it in the options 
  444. if(isset($_POST['creatavisitorlevel']) && $_POST['creatavisitorlevel'] == 'yes') { 
  445. $level_id = $this->create_level( __('Visitors', 'membership') ); 
  446. $level = new M_Level( $level_id ); 
  447. $level->toggleactivation(); 
  448.  
  449. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  450. if(function_exists('get_blog_option')) { 
  451. if(function_exists('switch_to_blog')) { 
  452. switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); 
  453.  
  454. $M_options = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', array()); 
  455. } else { 
  456. $M_options = get_option('membership_options', array()); 
  457. } else { 
  458. $M_options = get_option('membership_options', array()); 
  459.  
  460. $M_options['strangerlevel'] = (int) $level_id; 
  461.  
  462. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  463. if(function_exists('update_blog_option')) { 
  464. update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', $M_options); 
  465. } else { 
  466. update_option('membership_options', $M_options); 
  467. } else { 
  468. update_option('membership_options', $M_options); 
  469.  
  470. // Activate the relevant gateway if it's set 
  471. if(isset($_POST['wizardgateway'])) { 
  472. $active = get_option('membership_activated_gateways', array()); 
  473. if(!in_array($_POST['wizardgateway'], $active)) { 
  474. $active[] = $_POST['wizardgateway']; 
  475. update_option('membership_activated_gateways', array_unique($active)); 
  476.  
  477.  
  478. function page_end( $nextsteplink = false ) { 
  479.  
  480. global $M_options, $page, $action, $step; 
  481.  
  482. ob_start(); 
  483. ?> 
  484. <h3><?php _e('Thank you', 'membership'); ?></h3> 
  485. <p class="about-description"> 
  486. <?php 
  487.  
  488. $deactivateurl = wp_nonce_url("admin.php?page=membership&action=deactivatewelcome", 'deactivate-welcome'); 
  489.  
  490. _e('Thank you, we have now set up some of the initial Membership options. ', 'membership'); 
  491. _e('If you would like more tips on using the system then you can now follow the tutorial pointers we have included, or check out the help guides at the top of every page.', 'membership'); 
  492.  
  493. ?> 
  494. <br/> 
  495. <a href='<?php echo $deactivateurl; ?>' class='button-primary alignright'><?php _e('Close this wizard', 'membership'); ?></a> 
  496. </p> 
  497.  
  498. <?php 
  499. return ob_get_clean(); 
  500.  
  501. // Helper functions 
  502. function create_level( $title = false ) { 
  503.  
  504. $return = $this->db->insert($this->membership_levels, array('level_title' => $title, 'level_slug' => sanitize_title($title))); 
  505.  
  506. return $this->db->insert_id; 
  507.  
  508.  
  509. function create_subscription( $title = false ) { 
  510.  
  511. $return = $this->db->insert($this->subscriptions, array('sub_name' => $title, 'sub_description' => '', 'sub_pricetext' => '')); 
  512.  
  513. return $this->db->insert_id; 
  514.  
  515.  
  516. function add_level_to_subscription( $level_id, $sub_id, $type = 'serial' ) { 
  517.  
  518. $max = $this->db->get_var( "SELECT max(level_order) FROM {$this->subscriptions_levels} WHERE sub_id = " . $sub_id ); 
  519.  
  520. if(empty($max)) $max = 0; 
  521.  
  522. $this->db->insert($this->subscriptions_levels, array( "sub_id" => $sub_id,  
  523. "level_period" => 20,  
  524. "sub_type" => $type,  
  525. "level_price" => 0,  
  526. "level_currency" => 'USD',  
  527. "level_order" => ++$max,  
  528. "level_id" => $level_id,  
  529. "level_period_unit" => 'd' 
  530. )); 
  531.  
  532. function activate_gateway( $gateway = false ) { 
  533.  
  534.  
  535.  
  536. ?> 
.