function pugpig_get_attachments($post)
{
    $output = "";
    $featured_image_id = get_post_thumbnail_id($post->ID);
    if (isset($featured_image_id) && !empty($featured_image_id)) {
        $output .= "# Featured image\n";
        $output .= pugpig_strip_domain(wp_get_attachment_url($featured_image_id)) . "\n";
        $output .= "\n";
    }
    $added = array();
    $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID);
    $attachments = get_posts($args);
    $output .= "# Post Attachments (" . count($attachments) . " original files, maybe not all used)\n";
    $post_body = $post->post_content;
    $post_body = apply_filters('the_content', $post_body);
    foreach ($attachments as $attachment) {
        if (wp_attachment_is_image($attachment->ID)) {
            // For each attachment, we find all the possible sizes
            // Then we parse the body and include all those that are used
            $output .= "# Checking: " . pugpig_strip_domain(wp_get_attachment_url($attachment->ID)) . "\n";
            $image_urls = array();
            foreach (array('thumbnail', 'medium', 'large', 'full') as $size) {
                $image_info = wp_get_attachment_image_src($attachment->ID, $size);
                $image_urls[] = $image_info[0];
            }
            $found_image = false;
            foreach (array_unique($image_urls) as $img) {
                if (strstr($post_body, $img)) {
                    $output .= "# Image found in body text\n";
                    $output .= pugpig_get_inline_image_urls(pugpig_strip_domain($img)) . "\n";
                    $added[] = pugpig_get_inline_image_urls(pugpig_strip_domain($img));
                    $found_image = true;
                }
            }
        } else {
            // Not an image. Just include it
            $output .= pugpig_strip_domain(wp_get_attachment_url($attachment->ID)) . "\n";
        }
    }
    // Find any image URLS in the main body that are from
    // our domain but not in the manifest
    $image_urls = pugpig_get_image_urls($post_body);
    $base = pugpig_get_current_base_url();
    foreach ($image_urls as $i) {
        if (startsWith($i, $base) && !in_array(pugpig_strip_domain($i), $added)) {
            $output .= "# Extra absolute on our domain in markup " . pugpig_get_inline_image_urls($i) . "\n";
            $output .= pugpig_get_inline_image_urls(pugpig_strip_domain($i)) . "\n";
        } elseif (startsWith($i, "/")) {
            $output .= "# Extra relative in markup " . $i . "\n";
            $output .= pugpig_get_inline_image_urls($i) . "\n";
        } else {
            $output .= "# Rejecting: " . pugpig_get_inline_image_urls($i) . "\n";
        }
    }
    return $output;
}
 * Pugpig Standalone Configuration
 * $iTunesSecret - Get this value from your iTunes Connect account. It is used to verify receipts with iTunes.
 * $subscriptionPrefix -All iTunes Connect products starting with this prefix will be treated as subscription products. For example com.pugpig.subscription.
 * $pugpigCredsSecret -  This is the secret used to generate and decode edition credentials. It needs to be used in the env config settings for the Varnish config if this is being used.
 */
/*

Licence:
==============================================================================
(c) 2011, Kaldor Holdings Ltd
This module is released under the GNU General Public License.
See COPYRIGHT.txt and LICENSE.txt
*/
/***** SETTINGS FOR ITUNES RECEIPT VALIDATION *****/
$iTunesSecret = 'YOUR_ITUNES_SECRET_HERE';
/***** SETTINGS FOR AMAZON STORE VALIDATION *****/
$settings_amazon = array('base_url' => 'http://appstore-sdk.amazon.com', 'secret' => 'my_amazon_secret', 'rvs_version' => '2.0');
$settings_google = array('base_url' => 'https://www.googleapis.com/androidpublisher/v1/applications/com.kaldorgroup.poc/', 'public_key' => 'my_public_google_key');
/***** SETTINGS EDITION CREDENTIAL VALIDATION *****/
$subscriptionPrefix = 'com.mycompany.subscription';
$pugpigCredsSecret = 'MY_TOP_SECRET_PUGPIG_CREDS';
// $iTunesSubscriptionPrefix = 'com.mycompany.subscription.itunes'; // don't set if you want to use $subscriptionPrefix
/***** SETTINGS FOR DEBUG (OR RESTRICTED OUTBOUND ACCESS) *****/
$proxy_server = '';
$proxy_port = '';
/***** SETTINGS FOR AUTH TEST FORM *****/
$title = "My Subscription Test Form";
$urls["base"] = pugpig_get_current_base_url() . "/mysubssystem/";
$auth_test_default_product_id = 'com.pugpig.test.issue12345';
$params = array("username", "password");
$test_users = array(array("state" => "ACTIVE", "username" => "gooduser", "password" => "password"), array("state" => "INACTIVE", "username" => "lapseduser", "password" => "password"), array("state" => "UNKNOWN", "username" => "rubbish", "password" => "rubbish"));
Пример #3
0
function _dovetail_test_form($url, $clientRef, $brandRefList, $test_user_string = '')
{
    // https://staging-dovetailrestfulservice.subscribeonline.co.uk/fulfillment-integration/sign-in?sourceSystem=MASS&clientRef=XXX&brandRef=YYY&webId=12345
    $title = "Dovetail Test Form (Client: {$clientRef}, Brands: {$brandRefList})";
    $urls["sign_in"] = pugpig_get_current_base_url() . "/dovetail_sign_in/";
    $urls["verify_subscription"] = pugpig_get_current_base_url() . "/dovetail_verify_subscription/";
    $urls["edition_credentials"] = pugpig_get_current_base_url() . "/dovetail_edition_credentials/";
    $params = array("webId");
    $test_users = pugpig_subs_get_test_user_array($params, $test_user_string);
    pugpig_subs_test_form($title, $urls, $params, $test_users);
    exit;
    // Don't do the usual Drupal caching headers etc when completing the request
}
function pugpig_self_link()
{
    $serverrequri = pugpig_request_uri();
    if (!isset($serverrequri)) {
        $serverrequri = $_SERVER['PHP_SELF'];
    }
    return pugpig_get_current_base_url() . $serverrequri;
}
<?php

/**
 * @file
 * Pugpig Auth Test Form
 */
/*

Licence:
==============================================================================
(c) 2011, Kaldor Holdings Ltd
This module is released under the GNU General Public License.
See COPYRIGHT.txt and LICENSE.txt
*/
include_once "auth_test_inc.php";
//$active = patcf_flip_is_active($seconds_left);
//print "SECONDS: $seconds_left<br />";
$title = "Generic Test Stub";
$v["issue_prefix"] = "com.pugpig.edition";
$v["issue_start"] = 1;
$v["issue_end"] = 100;
$base = pugpig_get_current_base_url() . $_SERVER["SCRIPT_NAME"] . "?" . http_build_query($v);
$urls["sign_in"] = str_replace("test_form", "sign_in", $base);
$urls["verify_subscription"] = str_replace("test_form", "verify_subscription", $base);
$urls["edition_credentials"] = str_replace("test_form", "edition_credentials", $base);
$urls["renew_token"] = str_replace("test_form", "renew_token", $base);
$urls["sign_out"] = str_replace("test_form", "sign_out", $base);
$params = array("username", "password");
$test_users = patcf_get_test_users($all_users);
$helptext = "Users of the form XXX-XXX-XXX will return the status code XXX specified for the three calls in the given order (Sign In, Verify, Edition Creds). 000 means return a 200 with rubbish. ZZZ returns a 200 but takes 60 seconds. Peter is the only user requiring a password.<br/> Issues listed below may be free, empty or broken. Users with names ending in global set global auth creds. Please check your OPDS feed to make sure the issues function correctly.";
pugpig_subs_test_form($title, $urls, $params, $test_users, $helptext);