function mcs_paypal_form($price, $currency, $discount_rate, $discounts, $discount, $quantity)
{
    if (!get_option('mcs_paypal_merchant_id')) {
        $form = "<p class='warning'>" . __('PayPal account is not configured.', 'my-calendar-submissions') . "</p>";
    } else {
        $use_sandbox = get_option('mcs_use_sandbox');
        $button = get_option('mcs_button');
        $form = "\n\t\t<form action='" . ($use_sandbox != 'true' ? "https://www.paypal.com/cgi-bin/webscr" : "https://www.sandbox.paypal.com/cgi-bin/webscr") . "' method='POST'>\n\t\t<input type='hidden' name='cmd' value='_xclick' />\n\t\t<input type='hidden' name='business' value='" . get_option('mcs_paypal_merchant_id') . "' />\n\t\t<input type='hidden' name='item_name' value='" . sprintf(__('%s Event Submission', 'my-calendar-submissions'), get_option('blogname')) . "' />\n\t\t<input type='hidden' name='item_number' value='1' />\n\t\t<input type='hidden' name='amount' value='{$price}' />\n\t\t<input type='hidden' name='no_shipping' value='1' />\n\t\t<input type='hidden' name='no_note' value='1' />\n\t\t<input type='hidden' name='currency_code' value='{$currency}' />";
        $search = "http";
        $replace = "https";
        $form .= "\n\t\t<input type='hidden' name='notify_url' value='" . mcs_replace_http(add_query_arg('mcsipn', 'true', home_url())) . "' />\n\t\t<input type='hidden' name='return' value='" . mcs_replace_http(add_query_arg('response_code', 'thanks', mc_get_current_url())) . "' />\n\t\t<input type='hidden' name='cancel_return' value='" . mcs_replace_http(add_query_arg('response_code', 'cancel', mc_get_current_url())) . "' />";
        if ($discount == true && $discount_rate > 0) {
            $form .= "\n\t\t\t<input type='hidden' name='discount_rate' value='{$discount_rate}' />";
            if ($quantity == 'true') {
                $form .= "\n\t\t\t\t<input type='hidden' name='discount_rate2' value='{$discount_rate}' />";
            }
        }
        if ($button != '' && mc_is_url($button)) {
            $form .= "<input type='image' src='{$button}' name='submit' class='button' alt='" . __('Buy a payment key', 'my-calendar-submissions') . "' />";
        } else {
            $form .= "<input type='submit' name='submit' class='button' value='" . __('Buy a payment key', 'my-calendar-submissions') . "' />";
        }
        if ($quantity == 'true') {
            $form .= "\n\t\t\t<p><label for='quantity'>" . __('Quantity', 'my-calendar-submissions') . "</label> <input type='number' name='quantity' value='1' id='quantity' size='3' /></p>";
        }
        $form .= apply_filters('mcs_paypal_form', '', $price, $currency, $discount_rate, $discounts, $discount);
        $form .= "</form>";
    }
    return $form;
}
Esempio n. 2
0
function mc_format_rss($events)
{
    $template = "\n<item>\n\t\t<title>{rss_title}</title>\n\t\t<link>{details_link}</link>\n\t\t<pubDate>{rssdate}</pubDate>\n\t\t<dc:creator>{author}</dc:creator>  \t\n\t\t<description><![CDATA[{rss_description}]]></description>\n\t\t<date>{dtstart}</date>\n\t\t<dateSubmitted>{rssdate}</dateSubmitted>\n\t\t<content:encoded><![CDATA[<div class='vevent'>\n\t\t<h1 class='summary'>{rss_title}</h1>\n\t\t<div class='description'>{rss_description}</div>\n\t\t<p class='dtstart' title='{ical_start}'>Begins: {time} on {date}</p>\n\t\t<p class='dtend' title='{ical_end}'>Ends: {endtime} on {enddate}</p>\t\n\t\t<p>Recurrance: {recurs}</p>\n\t\t<p>Repetition: {repeats} times</p>\n\t\t<div class='location'>{rss_hcard}</div>\n\t\t{rss_link_title}\n\t\t</div>]]></content:encoded>\n\t\t<dc:format xmlns:dc='http://purl.org/dc/elements/1.1/'>text/html</dc:format>\n\t\t<dc:source xmlns:dc='http://purl.org/dc/elements/1.1/'>" . home_url() . "</dc:source>\t\n\t\t{guid}\n\t  </item>\n";
    $charset = get_bloginfo('charset');
    $output = '<?xml version="1.0" encoding="' . $charset . '"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"
		xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		>
	<channel>
	  <title>' . get_bloginfo('name') . ' Calendar</title>
	  <link>' . home_url() . '</link>
	  <description>' . get_bloginfo('description') . ': My Calendar Events</description>
	  <language>' . get_bloginfo('language') . '</language>
	  <managingEditor>' . get_bloginfo('admin_email') . ' (' . get_bloginfo('name') . ' Admin)</managingEditor>
	  <generator>My Calendar WordPress Plugin http://www.joedolson.com/articles/my-calendar/</generator>
	  <lastBuildDate>' . mysql2date('D, d M Y H:i:s +0000', current_time('timestamp')) . '</lastBuildDate>
	  <atom:link href="' . htmlentities(add_query_arg($_GET, mc_get_current_url())) . '" rel="self" type="application/rss+xml" />';
    foreach ($events as $date) {
        foreach (array_keys($date) as $key) {
            $event =& $date[$key];
            $array = mc_create_tags($event);
            $output .= jd_draw_template($array, $template, 'rss');
        }
    }
    $output .= '</channel>
	</rss>';
    return mc_strip_to_xml($output);
}
Esempio n. 3
0
function my_calendar_locations_list($show = 'list', $type = 'saved', $datatype = 'name', $group = 'single')
{
    global $wpdb;
    $mcdb = $wpdb;
    if (get_option('mc_remote') == 'true' && function_exists('mc_remote_db')) {
        $mcdb = mc_remote_db();
    }
    $output = '';
    if (isset($_GET['mc_id'])) {
        return;
    }
    if ($type == 'saved') {
        switch ($datatype) {
            case "name":
                $data = "location_label";
                break;
            case "city":
                $data = "location_city";
                break;
            case "state":
                $data = "location_state";
                break;
            case "zip":
                $data = "location_postcode";
                break;
            case "country":
                $data = "location_country";
                break;
            case "region":
                $data = "location_region";
                break;
            default:
                $data = "location_label";
        }
    } else {
        $data = $datatype;
    }
    $current_url = mc_get_current_url();
    if ($type == 'saved') {
        $locations = $mcdb->get_results("SELECT DISTINCT {$data} FROM " . MY_CALENDAR_LOCATIONS_TABLE . " ORDER BY {$data} ASC", ARRAY_A);
    } else {
        $data = get_option('mc_user_settings');
        $locations = $data['my_calendar_location_default']['values'];
        $datatype = str_replace('event_', '', get_option('mc_location_type'));
        $datatype = $datatype == 'label' ? 'name' : $datatype;
        $datatype = $datatype == 'postcode' ? 'zip' : $datatype;
    }
    if (count($locations) > 1) {
        if ($show == 'list') {
            $url = mc_build_url(array('loc' => 'all', 'ltype' => 'all'), array());
            $output .= "<ul id='mc-locations-list'>\n\t\t\t<li><a href='{$url}'>" . __('Show all', 'my-calendar') . "</a></li>\n";
        } else {
            $ltype = !isset($_GET['ltype']) ? $datatype : $_GET['ltype'];
            $output .= "<div id='mc_locations'>";
            $output .= $group == 'single' ? "\n\t\t<form action='" . $current_url . "' method='get'>\n\t\t<div>" : '';
            $output .= "<input type='hidden' name='ltype' value='{$ltype}' />";
            if ($group == 'single') {
                $qsa = array();
                parse_str($_SERVER['QUERY_STRING'], $qsa);
                if (!isset($_GET['cid'])) {
                    $output .= '<input type="hidden" name="cid" value="all" />';
                }
                foreach ($qsa as $name => $argument) {
                    $name = esc_attr(strip_tags($name));
                    $argument = esc_attr(strip_tags($argument));
                    if ($name != 'loc' && $name != 'ltype') {
                        $output .= "\n\t\t" . '<input type="hidden" name="' . $name . '" value="' . $argument . '" />';
                    }
                }
            }
            $output .= "\n\t\t\t<label for='mc-locations-list'>" . __('Location', 'my-calendar') . "</label>\n\t\t\t<select name='loc' id='mc-locations-list'>\n\t\t\t<option value='all'>" . __('Show all', 'my-calendar') . "</option>\n";
        }
        foreach ($locations as $key => $location) {
            if ($type == 'saved') {
                foreach ($location as $key => $value) {
                    $vt = urlencode(trim($value));
                    $value = stripcslashes($value);
                    if ($value == '') {
                        continue;
                    }
                    if (empty($_GET['loc'])) {
                        $loc = '';
                    } else {
                        $loc = $_GET['loc'];
                    }
                    if ($show == 'list') {
                        $selected = $vt == $loc ? " class='selected'" : '';
                        $this_url = mc_build_url(array('loc' => $vt, 'ltype' => $datatype), array());
                        $output .= "\t\t\t<li{$selected}><a rel='nofollow' href='{$this_url}'>{$value}</a></li>\n";
                    } else {
                        $selected = $vt == $loc ? " selected='selected'" : '';
                        if ($value != '') {
                            $output .= "\t\t\t<option value='{$vt}'{$selected}>{$value}</option>\n";
                        }
                    }
                }
            } else {
                $vk = urlencode(trim($key));
                $location = trim($location);
                if ($location == '') {
                    continue;
                }
                if ($show == 'list') {
                    $selected = $vk == $_GET['loc'] ? " class='selected'" : '';
                    $this_url = mc_build_url(array('loc' => $vk, 'ltype' => $datatype), array());
                    $output .= "\t\t\t<li{$selected}><a rel='nofollow' href='{$this_url}'>{$location}</a></li>\n";
                } else {
                    $selected = $vk == $_GET['loc'] ? " selected='selected'" : '';
                    $output .= "\t\t\t<option value='{$vk}'{$selected}>{$location}</option>\n";
                }
            }
        }
        if ($show == 'list') {
            $output .= "</ul>";
        } else {
            $output .= "</select>";
            $output .= $group == 'single' ? "<input type='submit' value=" . __('Submit', 'my-calendar') . " />\n\t\t\t\t\t</div>\n\t\t\t\t</form>" : '';
            $output .= "\n\t\t\t</div>";
        }
        $output = apply_filters('mc_location_selector', $output, $locations);
        return $output;
    } else {
        return;
    }
}