/wp-content/plugins/wp-shopping-cart/display-ecommerce-subs.php

https://github.com/alx/barceloneta · PHP · 43 lines · 40 code · 1 blank · 2 comment · 4 complexity · fa6a3c569b2950cc88f35b1bc680cafe MD5 · raw file

  1. <?php
  2. global $wpdb;
  3. $results = $wpdb->get_results('SELECT DISTINCT user_id FROM '.$wpdb->prefix.'wpsc_logged_subscriptions', ARRAY_A);
  4. //echo "<pre>".print_r($results)."</pre>";
  5. echo "<div class='wrap'>";
  6. echo "<h2>e-Commerce Subscribers</h2>";
  7. echo "<table class='widefat'>";
  8. echo "<tr>";
  9. echo "<th>".TXT_WPSC_USERID."</th><th>".TXT_WPSC_NAME."</th><th>".TXT_WPSC_EMAIL."</th><th>".TXT_WPSC_REGISTEREDDATE."</th><th>".TXT_WPSC_SUSPEND."/".TXT_WPSC_ACTIVATE."</th>";
  10. echo "</tr>";
  11. if ($results != NULL){
  12. $now = time();
  13. foreach ($results as $user){
  14. $user_info = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'users WHERE id='.$user['user_id'], ARRAY_A);
  15. $user_subscription = $wpdb->get_results('SELECT active FROM '.$wpdb->prefix.'wpsc_logged_subscriptions WHERE user_id='.$user['user_id'].' AND start_time < '.$now.' AND (start_time+length) > '.$now.'',ARRAY_A);
  16. //echo "<pre>".print_r($user_info,true)."</pre>";
  17. echo "<tr>";
  18. echo "<td>";
  19. echo $user_info[0]['ID'];
  20. echo "</td>";
  21. echo "<td>";
  22. echo $user_info[0]['display_name'];
  23. echo "</td>";
  24. echo "<td>";
  25. echo $user_info[0]['user_email'];
  26. echo "</td>";
  27. echo "<td>";
  28. echo $user_info[0]['user_registered'];
  29. echo "</td>";
  30. echo "<td>";
  31. if ($user_subscription[0]['active']==1) {
  32. echo "<input type='checkbox' checked='true' id='suspend_subs".$user_info[0]['ID']."' value='1' onclick='suspendsubs(".$user_info[0]['ID'].")' />";
  33. } else {
  34. echo "<input type='checkbox' id='suspend_subs".$user_info[0]['ID']."' value='1' onclick='suspendsubs(".$user_info[0]['ID'].")' />";
  35. }
  36. echo "</td>";
  37. echo "</tr>";
  38. }
  39. }
  40. echo "</table>";
  41. echo "</div>";
  42. ?>