function wpsc_user_purchases()
{
    global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields, $purchase_log, $col_count, $nzshpcrt_gateways;
    $i = 0;
    $subtotal = 0;
    do_action('wpsc_pre_purchase_logs');
    foreach ((array) $purchase_log as $purchase) {
        $status_state = "expand";
        $status_style = "display:none;";
        $alternate = "";
        $i++;
        if ($i % 2 != 0) {
            $alternate = "alt";
        }
        echo "<tr class='{$alternate}'>\n\r";
        echo " <td class='status processed'>";
        echo "<a href=\"#\" onclick=\"return show_details_box('status_box_" . $purchase['id'] . "','log_expander_icon_" . $purchase['id'] . "');\">";
        if (!empty($_GET['id']) && $_GET['id'] == $purchase['id']) {
            $status_state = "collapse";
            $status_style = "style='display: block;'";
        }
        echo "<img class=\"log_expander_icon\" id=\"log_expander_icon_" . $purchase['id'] . "\" src=\"" . WPSC_CORE_IMAGES_URL . "/icon_window_{$status_state}.gif\" alt=\"\" title=\"\" />";
        echo "<span id='form_group_" . $purchase['id'] . "_text'>" . __('Details', 'wpsc') . "</span>";
        echo "</a>";
        echo " </td>\n\r";
        echo " <td class='date'>";
        echo date("jS M Y", $purchase['date']);
        echo " </td>\n\r";
        echo " <td class='price'>";
        $country = get_option('country_form_field');
        if ($purchase['shipping_country'] != '') {
            $billing_country = $purchase['billing_country'];
            $shipping_country = $purchase['shipping_country'];
        } elseif (!empty($country)) {
            $country_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = %d LIMIT 1", $purchase['id'], get_option('country_form_field'));
            $country_data = $wpdb->get_results($country_sql, ARRAY_A);
            $billing_country = $country_data[0]['value'];
            $shipping_country = $country_data[0]['value'];
        }
        echo wpsc_currency_display($purchase['totalprice'], array('display_as_html' => false));
        $subtotal += $purchase['totalprice'];
        echo " </td>\n\r";
        if (get_option('payment_method') == 2) {
            echo " <td class='payment_method'>";
            $gateway_name = '';
            foreach ((array) $nzshpcrt_gateways as $gateway) {
                if ($purchase['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purchase['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = __("Manual Payment", 'wpsc');
                }
            }
            echo $gateway_name;
            echo " </td>\n\r";
        }
        echo "</tr>\n\r";
        echo "<tr>\n\r";
        echo " <td colspan='{$col_count}' class='details'>\n\r";
        echo "  <div id='status_box_" . $purchase['id'] . "' class='order_status' style=\"{$status_style}\">\n\r";
        echo "  <div>\n\r";
        //order status code lies here
        //check what $purchase['processed'] reflects in the $wpsc_purchlog_statuses array
        $status_name = wpsc_find_purchlog_status_name($purchase['processed']);
        echo "  <strong class='form_group'>" . __('Order Status', 'wpsc') . ":</strong>\n\r";
        echo $status_name . "<br /><br />";
        do_action('wpsc_user_log_after_order_status', $purchase);
        //written by allen
        $usps_id = get_option('usps_user_id');
        if ($usps_id != null) {
            $XML1 = "<TrackFieldRequest USERID=\"{$usps_id}\"><TrackID ID=\"" . $purchase['track_id'] . "\"></TrackID></TrackFieldRequest>";
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "http://secure.shippingapis.com/ShippingAPITest.dll?");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            $postdata = "API=TrackV2&XML=" . $XML1;
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
            $parser = new xml2array();
            $parsed = $parser->parse($result);
            $parsed = $parsed[0]['children'][0]['children'];
            if ($purchase['track_id'] != null) {
                echo "<br /><br />";
                echo " <strong class='form_group'>" . __('Shipping Address', 'wpsc') . "</strong>\n\r";
                echo "<table>";
                foreach ((array) $parsed as $parse) {
                    if ($parse['name'] == "TRACKSUMMARY") {
                        foreach ((array) $parse['children'] as $attrs) {
                            if ($attrs['name'] != "EVENT") {
                                $attrs['name'] = str_replace("EVENT", "", $attrs['name']);
                            }
                            $bar = ucfirst(strtolower($attrs['name']));
                            echo "<tr><td>" . $bar . "</td><td>" . $attrs['tagData'] . "</td></tr>";
                        }
                    }
                }
                echo "</table>";
            }
            echo "<br /><br />";
        }
        //end of written by allen
        //cart contents display starts here;
        echo "  <strong class='form_group'>" . __('Order Details', 'wpsc') . ":</strong>\n\r";
        $cartsql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`= %d", $purchase['id']);
        $cart_log = $wpdb->get_results($cartsql, ARRAY_A);
        $j = 0;
        // /*
        if ($cart_log != null) {
            echo "<table class='logdisplay'>";
            echo "<tr class='toprow2'>";
            echo " <th class='details_name'>";
            _e('Name', 'wpsc');
            echo " </th>";
            echo " <th class='details_quantity'>";
            _e('Quantity', 'wpsc');
            echo " </th>";
            echo " <th class='details_price'>";
            _e('Price', 'wpsc');
            echo " </th>";
            echo " <th class='details_tax'>";
            _e('GST', 'wpsc');
            echo " </th>";
            echo " <th class='details_shipping'>";
            _e('Shipping', 'wpsc');
            echo " </th>";
            echo " <th class='details_total'>";
            _e('Total', 'wpsc');
            echo " </th>";
            echo "</tr>";
            $gsttotal = false;
            $endtotal = $total_shipping = 0;
            foreach ((array) $cart_log as $cart_row) {
                $alternate = "";
                $j++;
                if ($j % 2 != 0) {
                    $alternate = "alt";
                }
                $variation_list = '';
                $billing_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : '';
                $shipping_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : '';
                $shipping = $cart_row['pnp'];
                $total_shipping += $shipping;
                echo "<tr class='{$alternate}'>";
                echo " <td class='details_name'>";
                echo apply_filters('the_title', $cart_row['name']);
                echo $variation_list;
                echo " </td>";
                echo " <td class='details_quantity'>";
                echo $cart_row['quantity'];
                echo " </td>";
                echo " <td class='details_price'>";
                $price = $cart_row['price'] * $cart_row['quantity'];
                echo wpsc_currency_display($price);
                echo " </td>";
                echo " <td class='details_tax'>";
                $gst = $cart_row['tax_charged'];
                if ($gst > 0) {
                    $gsttotal += $gst;
                }
                echo wpsc_currency_display($gst, array('display_as_html' => false));
                echo " </td>";
                echo " <td class='details_shipping'>";
                echo wpsc_currency_display($shipping, array('display_as_html' => false));
                echo " </td>";
                echo " <td class='details_total'>";
                $endtotal += $price;
                echo wpsc_currency_display($shipping + $price, array('display_as_html' => false));
                echo " </td>";
                echo '</tr>';
            }
            echo "<tr>";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " <td>";
            echo " </td>";
            echo " </td>";
            echo " <td class='details_totals_labels'>";
            echo "<strong>" . __('Total Shipping', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Total Tax', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Final Total', 'wpsc') . ":</strong>";
            echo " </td>";
            echo " <td class='details_totals_labels'>";
            $total_shipping += $purchase['base_shipping'];
            $endtotal += $total_shipping;
            $endtotal += $purchase['wpec_taxes_total'];
            echo wpsc_currency_display($total_shipping, array('display_as_html' => false)) . "<br />";
            if ($gsttotal) {
                //if false then must be exclusive.. doesnt seem too reliable needs more testing
                echo wpsc_currency_display($gsttotal, array('display_as_html' => false)) . "<br />";
            } else {
                echo wpsc_currency_display($purchase['wpec_taxes_total'], array('display_as_html' => false)) . "<br />";
            }
            echo wpsc_currency_display($endtotal, array('display_as_html' => false));
            echo " </td>";
            echo '</tr>';
            echo "</table>";
            echo "<br />";
            echo "<strong>" . __('Customer Details', 'wpsc') . ":</strong>";
            echo "<table class='customer_details'>";
            $usersql = $wpdb->prepare("SELECT `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.value, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.* FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` ON `" . WPSC_TABLE_CHECKOUT_FORMS . "`.id = `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.`form_id` WHERE `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.log_id = %d OR `" . WPSC_TABLE_CHECKOUT_FORMS . "`.type = 'heading' ORDER BY `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`checkout_set`, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`checkout_order`", $purchase['id']);
            $formfields = $wpdb->get_results($usersql, ARRAY_A);
            if (!empty($formfields)) {
                foreach ((array) $formfields as $form_field) {
                    // If its a heading display the Name otherwise continue on
                    if ('heading' == $form_field['type']) {
                        echo "  <tr><td colspan='2'>" . esc_html($form_field['name']) . ":</td></tr>";
                        continue;
                    }
                    switch ($form_field['unique_name']) {
                        case 'shippingcountry':
                        case 'billingcountry':
                            $country = maybe_unserialize($form_field['value']);
                            if (is_array($country)) {
                                $country = $country[0];
                            } else {
                                $country = $form_field['value'];
                            }
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($country) . "</td></tr>";
                            break;
                        case 'billingstate':
                        case 'shippingstate':
                            if (is_numeric($form_field['value'])) {
                                $state = wpsc_get_state_by_id($form_field['value'], 'name');
                            } else {
                                $state = $form_field['value'];
                            }
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($state) . "</td></tr>";
                            break;
                        default:
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($form_field['value']) . "</td></tr>";
                    }
                }
            }
            $payment_gateway_names = '';
            $payment_gateway_names = get_option('payment_gateway_names');
            foreach ((array) $payment_gateway_names as $gatewayname) {
                //if the gateway has a custom name
                if (!empty($gatewayname)) {
                    $display_name = $payment_gateway_names[$purchase_log[0]['gateway']];
                } else {
                    //if not fall back on default name
                    foreach ((array) $nzshpcrt_gateways as $gateway) {
                        if ($gateway['internalname'] == $purchase['gateway']) {
                            $display_name = $gateway['name'];
                        }
                    }
                }
            }
            echo "  <tr><td>" . __('Payment Method', 'wpsc') . ":</td><td>" . $display_name . "</td></tr>";
            echo "  <tr><td>" . __('Purchase #', 'wpsc') . ":</td><td>" . $purchase['id'] . "</td></tr>";
            if ($purchase['transactid'] != '') {
                echo "  <tr><td>" . __('Transaction Id', 'wpsc') . ":</td><td>" . $purchase['transactid'] . "</td></tr>";
            }
            echo "</table>";
        }
        echo "  </div>\n\r";
        echo "  </div>\n\r";
        echo " </td>\n\r";
        echo "</tr>\n\r";
    }
}
Beispiel #2
0
 function _parseXml($doc)
 {
     $parser = new xml2array($doc);
     $result = $parser->parse();
     if (!is_array($result)) {
         return debugError(4, $result);
     } else {
         // vi gider ikke have SOAP:ENVELOPE med...
         $this->result = $result[0]["children"];
         return null;
     }
 }
Beispiel #3
0
 echo "  </form>\n\r";
 //written by allen
 $usps_id = get_option('usps_user_id');
 if ($usps_id != null) {
     $XML1 = "<TrackFieldRequest USERID=\"{$usps_id}\"><TrackID ID=\"" . $purchase['track_id'] . "\"></TrackID></TrackFieldRequest>";
     //eecho cho  "--->".$purchase['track_id'];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, "http://secure.shippingapis.com/ShippingAPITest.dll?");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     $postdata = "API=TrackV2&XML=" . $XML1;
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
     $result = curl_exec($ch);
     $parser = new xml2array();
     $parsed = $parser->parse($result);
     $parsed = $parsed[0]['children'][0]['children'];
     if ($purchase['track_id'] != null) {
         echo "<br /><br />";
         echo " <strong class='form_group'>" . TXT_WPSC_SHIPPING_DETAILS . "</strong>\n\r";
         echo "<table>";
         foreach ((array) $parsed as $parse) {
             if ($parse['name'] == "TRACKSUMMARY") {
                 foreach ((array) $parse['children'] as $attrs) {
                     if ($attrs['name'] != "EVENT") {
                         $attrs['name'] = str_replace("EVENT", "", $attrs['name']);
                     }
                     $bar = ucfirst(strtolower($attrs['name']));
                     echo "<tr><td>" . $bar . "</td><td>" . $attrs['tagData'] . "</td></tr>";
                 }
             }
 function Templates($server_id)
 {
     if (DEBUG_ENABLED) {
         debug_log('%s::__construct(): Entered with ()', 5, get_class($this));
     }
     if ($this->_template = get_cached_item($server_id, 'template', 'all')) {
         if (DEBUG_ENABLED) {
             debug_log('%s::init(): Using CACHED [%s]', 5, get_class($this), 'templates');
         }
     } else {
         $dir = opendir(TMPLDIR);
         $this->template_num = 0;
         while (($file = readdir($dir)) !== false) {
             if (!preg_match('/.xml$/', $file)) {
                 continue;
             }
             $objXML = new xml2array();
             $xmldata = $objXML->parse(TMPLDIR . $file);
             $template_name = preg_replace('/.xml$/', '', $file);
             $this->storeTemplate($template_name, $xmldata);
         }
         masort($this->_template, 'title');
         set_cached_item($server_id, 'template', 'all', $this->_template);
     }
 }
Beispiel #5
0
 function parseXML2Array($xml)
 {
     $xml2array = new xml2array();
     $data = $xml2array->parse($xml);
     return $data;
 }
 function parse_videos_xml($string)
 {
     $xml_parser = new xml2array($string);
     $xml = $xml_parser->parse();
     return $xml;
 }
Beispiel #7
0
    </collection>
    <collection href="http://localhost:8080/alfresco/service/api/path/workspace/SpacesStore/Company%20Home/descendants" cmis:collectionType="root-descendants">
      <atom:title>root collection</atom:title>
    </collection>
    <collection href="http://localhost:8080/alfresco/service/api/checkedout" cmis:collectionType="checkedout">
      <atom:title>checkedout collection</atom:title>
    </collection>
    <collection href="http://localhost:8080/alfresco/service/api/unfiled" cmis:collectionType="unfiled">
      <atom:title>unfiled collection</atom:title>
    </collection>
    <collection href="http://localhost:8080/alfresco/service/api/types" cmis:collectionType="types-children">
      <atom:title>type collection</atom:title>
    </collection>
    <collection href="http://localhost:8080/alfresco/service/api/types" cmis:collectionType="types-descendants">
      <atom:title>type collection</atom:title>
    </collection>
    <collection href="http://localhost:8080/alfresco/service/api/query" cmis:collectionType="query">
      <atom:title>query collection</atom:title>
    </collection>

  </workspace>
</service>
';
$sxml = simplexml_load_string($xml);
$struct = json_decode(json_encode($sxml), true);
echo '<pre>' . htmlentities($xml) . '</pre>';
//echo '<hr /><pre>'.print_r($struct,true).'</pre>';
//echo '<hr /><pre>'.print_r($sxml,true).'</pre>';
//cho '<hr /><pre>'.print_r(xml2array($xml),true).'</pre>';
echo '<hr /><pre>' . print_r(xml2array::parse($xml), true) . '</pre>';
//echo http_get_request_headers();
Beispiel #8
0
function _get_lyric_lyricwiki($artist, $title, $file_name)
{
    $file = get_lyric_filename($artist, $title);
    $fp = fsockopen("lyricwiki.org", 80);
    if (!$fp) {
        $xml = array_to_xml(array("result" => "connectionfailed"));
        return $xml->asXML();
    }
    $out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
    $out .= "<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" ";
    $out .= "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" ";
    $out .= "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ";
    $out .= "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
    $out .= "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" ";
    $out .= "xmlns:tns=\"urn:LyricWiki\">";
    $out .= "<SOAP-ENV:Body><tns:getSong xmlns:tns=\"urn:LyricWiki\">";
    $out .= "<artist xsi:type=\"xsd:string\">";
    $out .= htmlspecialchars($artist);
    $out .= "</artist>";
    $out .= "<song xsi:type=\"xsd:string\">";
    $out .= htmlspecialchars($title);
    $out .= "</song>";
    $out .= "</tns:getSong></SOAP-ENV:Body></SOAP-ENV:Envelope>\r\n";
    $head = "POST /server.php HTTP/1.1\r\n";
    $head .= "Host: lyricwiki.org\r\n";
    $head .= "SOAPAction: urn:LyricWiki#getSong\r\n";
    $head .= "Content-Type: text/xml; charset=UTF-8\r\n";
    $head .= "User-Agent: RemissPitchfork/0.1\r\n";
    $head .= "Content-Length: " . str_byte_count($out) . "\r\n";
    $head .= "Connection: Close\r\n\r\n";
    fwrite($fp, $head . $out);
    $responseHeader = "";
    /* assume everything is dandy */
    do {
        $responseHeader .= fread($fp, 1);
    } while (!preg_match('/\\r\\n\\r\\n$/', $responseHeader));
    $ret = "";
    while (!feof($fp)) {
        $ret .= fgets($fp, 128);
    }
    fclose($fp);
    /* stupid hack to get around wrong xml declearation */
    $qmark = "?";
    if (strpos($ret, "<" . $qmark . "xml version=\"1.0\" encoding=\"ISO-8859-1\"" . $qmark . ">") === 0) {
        $ret = str_replace("<" . $qmark . "xml version=\"1.0\" encoding=\"ISO-8859-1\"" . $qmark . ">", "<" . $qmark . "xml version=\"1.0\" encoding=\"UTF-8\"" . $qmark . ">", $ret);
    }
    /*echo $ret;
    		exit();*/
    $parser = new xml2array();
    $parser->parse($ret);
    $data = find_lyrics($parser->arrOutput);
    // check that data is ok and lyrics exist
    if ($data && isset($data[2]['tagData'])) {
        $res = array();
        foreach ($data as $d) {
            if ($d['name'] == "ARTIST") {
                $res['artist'] = $d['tagData'];
            } else {
                if ($d['name'] == "SONG") {
                    $res['title'] = $d['tagData'];
                } else {
                    if ($d['name'] == "LYRICS") {
                        $res['lyric'] = $d['tagData'];
                    } else {
                        if ($d['name'] == "URL") {
                            $res['url'] = $d['tagData'];
                        }
                    }
                }
            }
        }
        $res['from'] = "lyricwiki.org";
        $res['time'] = time();
        /* this caching thing will have to be extracted if we 
         * put in another lyrics source */
        if (trim($res['lyric']) && trim($res['lyric']) != "Not found") {
            $xml = array_to_xml(array("result" => $res));
            $xml->addChild("file", htmlspecialchars($file_name));
            $res = $xml->asXML();
            @file_put_contents($file, $res);
        } else {
            $out = array("result" => "notfound");
            if (isset($res['url'])) {
                $out['url'] = $res['url'];
            }
            $res = array_to_xml($out);
            $res = $res->asXML();
        }
        return $res;
    }
    return false;
}