Plugin Directory

Changeset 2182261


Ignore:
Timestamp:
10/29/2019 12:54:32 PM (6 years ago)
Author:
xamoom1
Message:

encode uri correctly, handle secpackage content

Location:
xamoom/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • xamoom/trunk/public/class-xamoom-public.php

    r2168056 r2182261  
    114114        $style = false;
    115115        $custom_map_marker = false;
    116         if($content['data']['relationships']['system']['data']['id']) {
     116
     117        // HANDLE ERROR
     118        if(array_key_exists('errors', $content) && $content['errors']) {
     119            $errCode = $content['errors'][0]['code'];
     120            if ($errCode == 92 || $errCode == 93) { // password protected or spot only
     121                $html = '<div class="not-available-content"><i class="fa fa-lock"></i><span>This content is password protected<span></div>';
     122                return $html;
     123            } else { // any other error
     124                return '';
     125            }
     126        }
     127
     128        if(array_key_exists('data', $content) && $content['data']['relationships']['system']['data']['id']) {
    117129            $styles = $this->call_api($this->api_endpoint . "styles/" . $content['data']['relationships']['system']['data']['id']);
    118130
     
    401413            //get spot map
    402414            $cursor = "";
     415            $total_num_results = 0;
    403416            $has_more = true;
    404417            $spot_map = array('items' => array());
    405418            while($has_more){
    406                 $spot_map_response = $this->call_api($this->api_endpoint . "spots?filter[tags]=[\"" . implode("\",\"", $block['spot-map-tags']) . "\"]&page[cursor]=" . $cursor . "&filter[has-location]=true&&page[size]=100&lang=" . $lang);
     419                $api = $this->encodeURI($this->api_endpoint . "spots?filter[tags]=[\"" . implode("\",\"", $block['spot-map-tags']) . "\"]&page[cursor]=" . $cursor . "&filter[has-location]=true&page[size]=100&lang=" . $lang);
     420                $spot_map_response = $this->call_api($api);
    407421                $resp = json_decode($spot_map_response, true);
    408                 $spot_map['items'] = array_merge($spot_map['items'], $resp['data']);
    409 
     422                if ($resp['data']) {
     423                    $spot_map['items'] = array_merge($spot_map['items'], $resp['data']);
     424                }
     425                $total_num_results = $resp['meta']['total'];
    410426                $cursor = $resp['meta']['cursor'];
    411427                $has_more = $resp['meta']['has-more'];
     
    435451
    436452            //render marker script
    437             for($j = 0; $j < count($spot_map['items']); $j++){
     453            for($j = 0; $j < $total_num_results; $j++){
    438454                $marker = $spot_map['items'][$j]['attributes'];
    439455 
     
    532548     */
    533549    public function call_api($url){
     550        $header = array('headers' => array( 'ApiKey' => get_option('xamoom_api_key'), 'X-Reason' => 2, 'user-agent' => 'xamoom wordpress plugin' ));
    534551        $result = wp_remote_get( $url , array('headers' => array( 'ApiKey' => get_option('xamoom_api_key'), 'X-Reason' => 2, 'user-agent' => 'xamoom wordpress plugin' ) ));
    535552        return wp_remote_retrieve_body($result);
    536553    }
    537554
     555    /**
     556     * encodes special characters in uri
     557     */
     558    public function encodeURI($uri)
     559{
     560    return preg_replace_callback("{[^0-9a-z_.!~*'();,/?:@&=+$#-]}i", function ($m) {
     561        return sprintf('%%%02X', ord($m[0]));
     562    }, $uri);
    538563}
     564
     565}
  • xamoom/trunk/public/css/xamoom-public.css

    r2168056 r2182261  
    213213    height: 20px;
    214214}
     215
     216.not-available-content {
     217    font-size: 24px;
     218    text-align: center;
     219    color: #888888;
     220    margin: 70px 0px 70px 0px !important;
     221}
     222
     223.not-available-content i {
     224    margin-right: 10px;
     225}
  • xamoom/trunk/readme.txt

    r2168056 r2182261  
    33Tags: CMS, Location Based Service, Mobile Marketing, NFC, QR, iBeacon
    44Requires at least: 4.5
    5 Tested up to: 5.1.1
     5Tested up to: 5.2.4
    66Requires PHP: 5.2.4
    7 Stable tag: 3.0.1
     7Stable tag: 3.1.0
    88
    99The connection between the xamoom CMS and WordPress. Use your great mobile content also on the desktop.
     
    4343
    4444== Changelog ==
     45= 3.1 =
     46* Fixed rare issue involving maps not loading.
     47* Content using security package is now better visualized.
     48
    4549= 3.0 =
    4650*Added new download type GPX.
  • xamoom/trunk/xamoom.php

    r2168056 r2182261  
    3737 * Plugin URI:        http://xamoom.com
    3838 * Description:       This plugin allows you to sync xamoom pages to Wordpress
    39  * Version:           3.0.1
     39 * Version:           3.1.0
    4040 * Author:            xamoom GmbH
    4141 * Author URI:        http://xamoom.com/
Note: See TracChangeset for help on using the changeset viewer.