Ejemplo n.º 1
0
 public function url($params = array(), $base = false)
 {
     $blacklist = $this->params_blacklist();
     $params = array_merge($this->params, $params);
     $url = remove_query_arg($blacklist, $base ? $base : awpcp_current_url());
     $url = add_query_arg(urlencode_deep($params), $url);
     return $url;
 }
 public function render($listing, $config = array())
 {
     $config = wp_parse_args($config, array('current-url' => awpcp_current_url(), 'hidden-params' => array()));
     $actions = apply_filters('awpcp-listing-actions', array(), $listing);
     ob_start();
     include AWPCP_DIR . '/templates/components/listings-actions.tpl.php';
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
Ejemplo n.º 3
0
 public function dispatch()
 {
     global $awpcp, $message;
     $action = awpcp_request_param('action', 'confirm');
     $url = awpcp_current_url();
     $dirname = AWPCPUPLOADDIR;
     if (strcmp($action, 'uninstall') == 0) {
         $awpcp->installer->uninstall();
     }
     $template = AWPCP_DIR . '/admin/templates/admin-panel-uninstall.tpl.php';
     $params = compact('action', 'url', 'dirname');
     echo $this->render($template, $params);
 }
Ejemplo n.º 4
0
/**
 * @since 3.4
 */
function awpcp_display_listings($query, $context, $options)
{
    $options = wp_parse_args($options, array('show_intro_message' => false, 'show_menu_items' => false, 'show_category_selector' => false, 'show_pagination' => false, 'before_content' => '', 'before_pagination' => '', 'before_list' => '', 'after_pagination' => '', 'after_content' => ''));
    if (has_action('awpcp_browse_ads_template_action') || has_filter('awpcp_browse_ads_template_filter')) {
        do_action('awpcp_browse_ads_template_action');
        return apply_filters('awpcp_browse_ads_template_filter');
    }
    $results_per_page = absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10)));
    $results_offset = absint(awpcp_request_param('offset', 0));
    if (empty($query['limit']) && $results_per_page) {
        $query['limit'] = $results_per_page;
    }
    if (empty($query['offset']) && $query['limit']) {
        $query['offset'] = $results_offset;
    }
    $listings_collection = awpcp_listings_collection();
    $listings = $listings_collection->find_enabled_listings_with_query($query);
    $listings_count = $listings_collection->count_enabled_listings_with_query($query);
    $before_content = apply_filters('awpcp-content-before-listings-page', $options['before_content'], $context);
    $before_pagination = array();
    if ($options['show_category_selector']) {
        $before_pagination[15]['category-selector'] = awpcp_render_category_selector(array('required' => false));
    }
    if (is_array($options['before_pagination'])) {
        $before_pagination = awpcp_array_merge_recursive($before_pagination, $options['before_pagination']);
    } else {
        $before_pagination[20]['user-content'] = $options['before_pagination'];
    }
    $before_pagination = apply_filters('awpcp-listings-before-content', $before_pagination, $context);
    ksort($before_pagination);
    $before_pagination = awpcp_flatten_array($before_pagination);
    $before_list = apply_filters('awpcp-display-ads-before-list', $options['before_list'], $context);
    if ($listings_count > 0) {
        $pagination_options = array('results' => $results_per_page, 'offset' => $results_offset, 'total' => $listings_count);
        $pagination = $options['show_pagination'] ? awpcp_pagination($pagination_options, awpcp_current_url()) : '';
        $items = awpcp_render_listings_items($listings, $context);
    } else {
        $pagination = '';
        $items = array();
    }
    $after_pagination = array('user-content' => $options['after_pagination']);
    $after_pagination = apply_filters('awpcp-listings-after-content', $after_pagination, $context);
    $after_content = apply_filters('awpcp-content-after-listings-page', $options['after_content'], $context);
    ob_start();
    include AWPCP_DIR . '/templates/frontend/listings.tpl.php';
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
Ejemplo n.º 5
0
 public function custom_column($value, $column, $user_id)
 {
     switch ($column) {
         case 'balance':
             $balance = awpcp_payments_api()->format_account_balance($user_id);
             $actions = array();
             if (awpcp_current_user_is_admin()) {
                 $url = add_query_arg('action', 'credit', awpcp_current_url());
                 $actions['credit'] = "<a class='credit' href='" . esc_url($url) . "'>" . __('Add Credit', 'AWPCP') . "</a>";
                 $url = add_query_arg('action', 'debit', awpcp_current_url());
                 $actions['debit'] = "<a class='debit' href='" . esc_url($url) . "'>" . __('Remove Credit', 'AWPCP') . "</a>";
             }
             $table = $this->get_table();
             $value = '<span class="balance">' . $balance . '</span>' . $table->row_actions($actions);
     }
     return $value;
 }
Ejemplo n.º 6
0
 protected function _dispatch($default = null)
 {
     $action = $this->get_current_action();
     if (get_awpcp_option('reply-to-ad-requires-registration') && !is_user_logged_in()) {
         $message = __('Only registered users can reply to Ads. If you are already registered, please login below in order to reply to the Ad.', 'AWPCP');
         return $this->render('content', awpcp_login_form($message, awpcp_current_url()));
     }
     $ad = $this->get_ad();
     if (is_null($ad)) {
         $message = __('The specified Ad does not exist.', 'AWPCP');
         return $this->render('content', awpcp_print_error($message));
     }
     switch ($action) {
         case 'contact':
             return $this->contact_step();
         case 'docontact1':
         default:
             return $this->process_contact_form();
     }
 }
 private function force_secure_urls()
 {
     $force_secure_url = false;
     $pages = array('place-ad-page-name', 'subscriptions-page-name', 'renew-ad-page-name');
     foreach ($pages as $page) {
         $page_id = awpcp_get_page_id_by_ref($page);
         if ($page_id && is_page($page_id)) {
             $force_secure_url = true;
             break;
         }
     }
     if (!$force_secure_url) {
         global $post;
         $shortcodes = array('AWPCPPLACEAD', 'AWPCP-BUY-SUBSCRIPTION', 'AWPCP-RENEW-AD', 'AWPCPBUYCREDITS');
         $regexp = '/\\[' . join('\\]|\\[', $shortcodes) . '\\]/';
         if (preg_match($regexp, $post->post_content)) {
             $force_secure_url = true;
         }
     }
     if ($force_secure_url && wp_redirect(set_url_scheme(awpcp_current_url(), 'https'))) {
         exit;
     }
 }
 private function verify_transaction($transaction)
 {
     $errors = array();
     // PayPal can redirect users using a GET request and issuing
     // a POST request in the background. If the transaction was
     // already verified during the POST request the result
     // should be stored in the transaction's verified attribute
     if (!empty($_POST)) {
         $response = $this->verify_received_data($_POST, $errors);
         $verified = strcasecmp($response, 'VERIFIED') === 0;
     } else {
         $verified = $transaction->get('verified', false);
     }
     if (!$verified) {
         $variables = count($_POST);
         $url = awpcp_current_url();
         if ($variables <= 0) {
             $message = __("We haven't received your payment information from PayPal yet and we are unable to verify your transaction. Please reload this page or visit <a href=\"%s\">%s</a> in 30 seconds to continue placing your Ad.", 'AWPCP');
             $errors[] = sprintf($message, $url, $url);
         } else {
             $message = __("PayPal returned the following status from your payment: %s. %d payment variables were posted.", 'AWPCP');
             $errors[] = sprintf($message, $response, count($_POST));
             $errors[] = __("If this status is not COMPLETED or VERIFIED, then you may need to wait a bit before your payment is approved, or contact PayPal directly as to the reason the payment is having a problem.", 'AWPCP');
         }
         $errors[] = __("If you have any further questions, please contact this site administrator.", 'AWPCP');
         if ($variables <= 0) {
             $transaction->errors['verification-get'] = $errors;
         } else {
             $transaction->errors['verification-post'] = $errors;
         }
     } else {
         // clean up previous errors
         unset($transaction->errors['verification-get']);
         unset($transaction->errors['verification-post']);
     }
     $transaction->set('txn-id', awpcp_post_param('txn_id'));
     $transaction->set('verified', $verified);
     return $verified;
 }
Ejemplo n.º 9
0
?>

<?php 
include AWPCP_DIR . '/admin/templates/admin-panel-header.tpl.php';
?>

			<?php 
awpcp_print_messages();
?>

			<h2 class="nav-tab-wrapper">
			<?php 
foreach ($groups as $g) {
    ?>
				<?php 
    $href = add_query_arg(array('g' => $g->slug), awpcp_current_url());
    ?>
				<?php 
    $active = $group->slug == $g->slug ? 'nav-tab nav-tab-active' : 'nav-tab';
    ?>
				<a href="<?php 
    echo esc_url($href);
    ?>
" class="<?php 
    echo esc_attr($active);
    ?>
"><?php 
    echo $g->name;
    ?>
</a>
			<?php 
Ejemplo n.º 10
0
    $page_id = 'awpcp-admin-debug';
    ?>
	<?php 
    $page_title = awpcp_admin_page_title(__('Debug', 'AWPCP'));
    ?>

	<?php 
    include AWPCP_DIR . '/admin/templates/admin-panel-header.tpl.php';
}
?>

		<?php 
$msg = _x('This information can help AWPCP Developers to debug possible problems. If you are submitting a bug report please <strong><a href="%s">Download the Debug Information</a></strong> and attach it to your bug report or take a minute to copy the information below to <a href="http://fpaste.org" target="_blank">http://fpaste.org</a> and provide the resulting URL in your report.', 'debug page', 'AWPCP');
?>
		<p><?php 
echo sprintf($msg, esc_url(add_query_arg('download', 'debug page', awpcp_current_url())));
?>
</p>

		<?php 
$title_pages = _x('AWPCP Pages', 'debug page', 'AWPCP');
?>
		<?php 
$title_php_info = _x('PHP Info', 'debug page', 'AWPCP');
?>
		<?php 
$title_settings = _x('AWPCP Settings', 'debug page', 'AWPCP');
?>
		<?php 
$title_rules = _x('Rewrite Rules', 'debug page', 'AWPCP');
?>
Ejemplo n.º 11
0
 public function build_return_link()
 {
     $params = array_merge(stripslashes_deep($_REQUEST), array('a' => 'searchads'));
     $href = add_query_arg(urlencode_deep($params), awpcp_current_url());
     $return_link = '<div class="awpcp-return-to-search-link awpcp-clearboth"><a href="<link-url>"><link-text></a></div>';
     $return_link = str_replace('<link-url>', esc_url($href), $return_link);
     $return_link = str_replace('<link-text>', __('Return to Search', 'AWPCP'), $return_link);
     return $return_link;
 }
Ejemplo n.º 12
0
/**
 * Generates HTML to display login form when user is not registered.
 * @tested
 */
function awpcp_login_form($message = null, $redirect = null)
{
    if (is_null($redirect)) {
        $redirect = awpcp_current_url();
    }
    $registration_url = get_awpcp_option('registrationurl');
    if (empty($registration_url)) {
        if (function_exists('wp_registration_url')) {
            $registration_url = wp_registration_url();
        } else {
            $registration_url = site_url('wp-login.php?action=register', 'login');
        }
    }
    $redirect_to = urlencode(add_query_arg('register', true, $redirect));
    $register_url = add_query_arg(array('redirect_to' => $redirect_to), $registration_url);
    $redirect_to = urlencode(add_query_arg('reset', true, $redirect));
    $lost_password_url = add_query_arg(array('redirect_to' => $redirect_to), wp_lostpassword_url());
    ob_start();
    include AWPCP_DIR . '/frontend/templates/login-form.tpl.php';
    $form = ob_get_contents();
    ob_end_clean();
    return $form;
}
Ejemplo n.º 13
0
 public function url($params = array())
 {
     $url = add_query_arg(urlencode_deep($params), awpcp_current_url());
     return $url;
 }