Esempio n. 1
0
 public static function decodeObject($str, $assoc = false, $loadEbayClasses = false)
 {
     // load eBay classes if required
     if ($loadEbayClasses) {
         EbayController::loadEbayClasses();
     }
     if ($str == '') {
         return false;
     }
     if (is_object($str) || is_array($str)) {
         return $str;
     }
     // json_decode
     $obj = json_decode($str, $assoc);
     // WPLE()->logger->info('json_decode: '.print_r($obj,1));
     if (is_object($obj) || is_array($obj)) {
         return $obj;
     }
     // unserialize fallback
     $obj = maybe_unserialize($str);
     // WPLE()->logger->info('unserialize: '.print_r($obj,1));
     if (is_object($obj) || is_array($obj)) {
         return $obj;
     }
     // mb_unserialize fallback
     $obj = self::mb_unserialize($str);
     // WPLE()->logger->info('mb_unserialize: '.print_r($obj,1));
     if (is_object($obj) || is_array($obj)) {
         return $obj;
     }
     // log error
     $e = new Exception();
     WPLE()->logger->error('backtrace: ' . $e->getTraceAsString());
     WPLE()->logger->error('mb_unserialize returned: ' . print_r($obj, 1));
     WPLE()->logger->error('decodeObject() - not an valid object: ' . $str);
     return $str;
 }
Esempio n. 2
0
 public function ajax_handle_ebay_notify()
 {
     // require_once WPLISTER_PATH . '/includes/EbatNs/' . 'EbatNs_NotificationClient.php';
     // require_once WPLISTER_PATH . '/includes/EbatNs/' . 'EbatNs_ResponseError.php';
     // load eBay classes
     EbayController::loadEbayClasses();
     $handler = new EbatNs_NotificationClient();
     $body = file_get_contents('php://input');
     $res = $handler->getResponse($body);
     WPLE()->logger->info('handle_ebay_notify() - time: ' . date('Y-m-d H:i:s'));
     //WPLE()->logger->info('POST:  '.print_r($_POST,1));
     WPLE()->logger->info('REQUEST: ' . print_r($_REQUEST, 1));
     WPLE()->logger->info('SERVER:  ' . print_r($_SERVER, 1));
     $headers = getallheaders();
     WPLE()->logger->info('headers: ' . print_r($headers, 1));
     WPLE()->logger->info('body:    ' . print_r($body, 1));
     WPLE()->logger->info('response:' . print_r($res, 1));
     // log to db
     $this->dblogger = new WPL_EbatNs_Logger();
     $this->dblogger->updateLog(array('callname' => 'handle_ebay_notify', 'request_url' => 'platform notification', 'request' => $body . "\n\n" . print_r($_REQUEST, 1) . "\n\n" . print_r($_SERVER, 1), 'response' => json_encode($res), 'success' => 'Success'));
     // send email (for debugging only)
     $msg = 'A notification was received at ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n\n";
     $msg .= 'Body:     ' . print_r($body, 1) . "\n\n";
     $msg .= 'Response: ' . print_r($res, 1) . "\n";
     $msg .= 'REQUEST:  ' . print_r($_REQUEST, 1) . "\n";
     $msg .= 'SERVER:   ' . print_r($_SERVER, 1) . "\n";
     $msg .= 'Headers:  ' . print_r($headers, 1) . "\n";
     // $to = get_option('admin_email', '*****@*****.**');
     $to = '*****@*****.**';
     $subject = 'New WPLE platform notification (debug info)';
     wp_mail($to, $subject, $msg);
     echo 'ACK';
     exit;
 }
Esempio n. 3
0
 public function onDisplayEbayOrdersPage()
 {
     $this->check_wplister_setup();
     // handle update ALL from eBay action
     if ($this->requestAction() == 'update_orders') {
         // regard update options
         $days = is_numeric($_REQUEST['wpl_number_of_days']) ? $_REQUEST['wpl_number_of_days'] : false;
         $accounts = WPLE_eBayAccount::getAll(false, true);
         // sort by id
         $msg = '';
         // loop each active account
         $processed_accounts = array();
         foreach ($accounts as $account) {
             // make sure we don't process the same account twice
             if (in_array($account->user_name, $processed_accounts)) {
                 WPLE()->logger->info("skipping account {$account->id} - user name {$account->user_name} was already processed");
                 continue;
             }
             $this->initEC($account->id);
             $tm = $this->EC->updateEbayOrders($days);
             $this->EC->updateListings();
             $this->EC->closeEbay();
             $processed_accounts[] = $account->user_name;
             // show ebay_order report
             $msg .= sprintf(__('%s order(s) found on eBay for account %s.', 'wplister'), $tm->count_total, $account->title) . '<br>';
             $msg .= __('Timespan', 'wplister') . ': ' . $tm->getHtmlTimespan() . '&nbsp;&nbsp;';
             $msg .= '<a href="#" onclick="jQuery(\'.ebay_order_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>';
             $msg .= $tm->getHtmlReport();
             $msg .= '<hr>';
         }
         $this->showMessage($msg);
     }
     // handle update from eBay action
     if ($this->requestAction() == 'update') {
         if (isset($_REQUEST['ebay_order'])) {
             // use account_id of first item (todo: group items by account)
             $om = new EbayOrdersModel();
             $order = $om->getItem($_REQUEST['ebay_order'][0]);
             $account_id = $order['account_id'];
             $this->initEC($account_id);
             $tm = $this->EC->updateEbayOrders(false, $_REQUEST['ebay_order']);
             $this->EC->updateListings();
             $this->EC->closeEbay();
             // $this->showMessage( __('Selected orders were updated from eBay.','wplister') );
             // show ebay_order report
             $msg = $tm->count_total . ' ' . __('orders were updated from eBay.', 'wplister') . '<!br>' . '&nbsp;&nbsp;';
             $msg .= '<a href="#" onclick="jQuery(\'.ebay_order_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>';
             $msg .= $tm->getHtmlReport();
             $this->showMessage($msg);
         } else {
             $this->showMessage(__('You need to select at least one item from the list below in order to use bulk actions.', 'wplister'), 1);
         }
     }
     // handle wpl_delete_order action
     if ($this->requestAction() == 'wpl_delete_order') {
         if (isset($_REQUEST['ebay_order'])) {
             $tm = new EbayOrdersModel();
             $ebay_orders = is_array($_REQUEST['ebay_order']) ? $_REQUEST['ebay_order'] : array($_REQUEST['ebay_order']);
             foreach ($ebay_orders as $id) {
                 $tm->deleteItem($id);
             }
             $this->showMessage(__('Selected items were removed.', 'wplister'));
         } else {
             $this->showMessage(__('You need to select at least one item from the list below in order to use bulk actions.', 'wplister'), 1);
         }
     }
     // show warning if duplicate orders found
     $this->checkForDuplicates();
     //Create an instance of our package class...
     $ordersTable = new EbayOrdersTable();
     //Fetch, prepare, sort, and filter our data...
     $ordersTable->prepare_items();
     // load eBay classes to decode details in table
     EbayController::loadEbayClasses();
     $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'ordersTable' => $ordersTable, 'preview_html' => isset($preview_html) ? $preview_html : '', 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-orders');
     $this->display('orders_page', $aData);
 }