Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(10000);
- switch($_GET['type']) {
- case 'packets':
- $packets = e::app('money')->list_packets();
- // What to output for packet list
- $o_packets = array();
- // Loop through packets
- foreach($packets as $packet) {
- if(!is_object($packet->owner()))
- v($packet->owner());
- $o_packet = array('site' => e::$site->name, 'project' => null, 'charity' => null, 'team' => null);
- $arr = $packet->model->get_array();
- foreach($arr as $key => $value) {
- if($key == 'photo' || $key == 'logo')
- continue;
- $o_packet[$key] = $value;
- }
- $dest = $packet->destination_module();
- $o_packet['to_type'] = $packet->destination_type();
- switch($dest->module_name) {
- case 'charity':
- $o_packet['charity'] = array('id' => $dest->id, 'name' => $dest->name);
- break;
- case 'project':
- $o_packet['project'] = array('id' => $dest->id, 'name' => $dest->name);
- $dest = $dest->charity();
- if(is_object($dest))
- $o_packet['charity'] = array('id' => $dest->id, 'name' => $dest->name);
- break;
- case 'team':
- $o_packet['team'] = array('id' => $dest->id, 'name' => $dest->name);
- $dest = $dest->project();
- if(is_object($dest))
- $o_packet['project'] = array('id' => $dest->id, 'name' => $dest->name);
- $dest = $dest->charity();
- if(is_object($dest))
- $o_packet['charity'] = array('id' => $dest->id, 'name' => $dest->name);
- break;
- }
- $o_packets[] = $o_packet;
- }
- echo (serialize($o_packets));
- die;
- break;
- case 'transactions':
- $x = e::app('money')->list_transactions();
- $o_transactions = array();
- //v(count($x));
- if(isset($_GET['page']))
- $page = (int) $_GET['page'];
- else
- $page = 1;
- if($page <= 1)
- $page = 1;
- $length = 100000;
- $max = 100000;
- $i = 0;
- foreach($x as $tran) {
- $i++;
- if($i <= ($page - 1) * $length)
- continue;
- if($i > $page * $length)
- break;//echo " $i";
- if(!$max--) break;
- $o_tran = array();
- $arr = $tran->model->get_array();
- $member = $tran->owner();
- foreach($arr as $key => $value) {
- if($key == 'photo' || $key == 'logo')
- continue;
- $o_tran[$key] = $value;
- }
- $o_tran['member'] = array('name' => is_object($member) && !($member instanceof stdClass) ? $member->name() : 'No Member');
- $b2 = array();
- $goodmember = explode(' ', 'location name zip last email city state country address address2 first_name last_name id zip_code phone_home phone_work phone_cell');
- if(is_object($member) && !($member instanceof stdClass)) {
- foreach($member->model->get_array() as $key => $value) {
- if(in_array($key, $goodmember)) {
- $o_tran['member'][$key] = $value;
- }
- }
- }
- $billing = null;
- if(is_object($member) && !($member instanceof stdClass))
- $billing = $tran->billing_info();
- if(!is_array($billing))
- $billing = $o_tran['member'];
- else {
- foreach($billing as $key => $value) {
- if(!in_array($key, $goodmember)) {
- unset($billing[$key]);
- }
- }
- }
- $o_tran['billing'] = $billing;
- $o_transactions[] = $o_tran;
- }
- echo (serialize($o_transactions));
- die;
- break;
- }
- die('nothing exported');
Add Comment
Please, Sign In to add comment