Plugin Directory

Changeset 2298283


Ignore:
Timestamp:
05/05/2020 08:20:51 AM (6 years ago)
Author:
Uncategorized Creations
Message:

Version 1.5.6

Location:
wp-appkit/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-appkit/trunk/lib/apps/build.php

    r2197382 r2298283  
    835835            }
    836836
    837             $index_content = preg_replace( '/<head>(\s*?)<link/is', "<head>$1". $app_title_html ."$1". $app_description_html ."$1". $manifest_html ."$1". $base_html ."$1". $theme_color ."$1<link", $index_content );
     837            $index_content = preg_replace( '/<meta charset="([^"]*)">(\s*?)<link/is', "<meta charset=\"$1\">$2". $app_title_html ."$2". $app_description_html ."$2". $manifest_html ."$2". $base_html ."$2". $theme_color ."$2<link", $index_content );
    838838
    839839            //Remove script used only for app simulation in web browser:
  • wp-appkit/trunk/lib/simulator/config-file.php

    r2127247 r2298283  
    3838
    3939                    if ( WpakApps::get_app_simulation_is_secured( $app_id ) && !current_user_can( $capability ) ) {
    40                         wp_nonce_ays( $action );
     40                        wp_nonce_ays('');
    4141                    }
    4242
  • wp-appkit/trunk/lib/user-permissions/auth-engines/rsa-public-private-auth.php

    r2127247 r2298283  
    88
    99    public function settings_meta_box_content( $post, $current_box ) {
     10
     11        //Include theme and addons php files so that authentication hooks are applied
     12        WpakThemes::include_app_theme_php( $post->ID );
     13        WpakAddons::require_app_addons_php_files( $post->ID );
    1014
    1115        $auth_settings = $this->get_authentication_settings( $post->ID );
     
    6064
    6165        if ( !empty( $auth_settings['private_key'] ) ) {
    62             ?><h4><?php _e( 'User connections', WpAppKit::i18n_domain ) ?></h4><?php
     66            ?><h4><?php _e( 'User connections', WpAppKit::i18n_domain ) ?></h4>
     67            <?php
    6368            $current_connections = $this->get_current_connections( $post->ID );
    6469            ?>
     
    8085                        <th style="width:25%"><?php _e( 'Login time', WpAppKit::i18n_domain ) ?></th>
    8186                        <th style="width:25%"><?php _e( 'Last access time', WpAppKit::i18n_domain ) ?></th>
     87                        <th style="width:25%"><?php _e( 'Validity', WpAppKit::i18n_domain ) ?></th>
     88                        <th style="width:25%"><?php _e( 'Expiration time', WpAppKit::i18n_domain ) ?></th>
    8289                    </tr>
    8390                </thead>
     
    109116                            </table>
    110117                        </td>
     118                        <td>
     119                            <?php
     120                                $user_last_time = $this->get_user_last_time( $user_id, $post->ID );
     121                                if ( $user_last_time ) {
     122                                    $expiration_type = $this->get_expiration_type($user_id, $post->ID);
     123                                    $validity_duration = $this->get_expiration_time($user_id, $post->ID);
     124                                    echo human_time_diff( 0, $validity_duration ) .' ';
     125                                    echo $expiration_type == 'last_access_time' ? __( 'from last access time', WpAppKit::i18n_domain ) : __( 'from login time', WpAppKit::i18n_domain );
     126                                }
     127                            ?>
     128                        </td>
     129                        <td>
     130                            <?php
     131                                if ( $user_last_time ) {
     132                                    echo get_date_from_gmt( date( 'Y-m-d H:i:s', $user_last_time + $validity_duration ) );
     133                                }
     134                            ?>
     135                        </td>
    111136                    </tr>
    112137                    <?php
     
    133158        $current_connections = [];
    134159        $current_connections_raw = $wpdb->get_results( "SELECT user_id, meta_value FROM {$wpdb->prefix}usermeta WHERE meta_key = '$user_meta'", ARRAY_A );
    135         //$current_connections_raw
    136160        if ( !empty( $current_connections_raw ) ) {
    137161            foreach( $current_connections_raw as $current_connection ) {
     
    755779            }
    756780
    757             $purge_time = apply_filters( 'wpak_auth_purge_time', 30*24*3600, $user_id, $app_id ); //1 month by default
    758 
    759781            $expiration_type = $this->get_expiration_type( $user_id, $app_id );
    760782            $expiration_time = $this->get_expiration_time( $user_id, $app_id );
     783
     784            //Purge time. 1 month by default :
     785            $purge_time = apply_filters( 'wpak_auth_purge_time', 30*24*3600, $user_id, $app_id );
     786            if ( $purge_time < $expiration_time ) {
     787                $purge_time = $expiration_time; //Purge time must be >= to expiration time
     788            }
    761789
    762790            $time = time();
     
    769797                    $changed = true;
    770798                }
     799                //Check if all devices have expired
    771800                if ( $time - $auth_data[$expiration_type] < $expiration_time ) {
    772                     unset( $user_auth_data[$device_id] );
    773801                    $all_expired = false;
    774802                }
     
    832860        $connection_validity = 0;
    833861
     862        $user_last_time = $this->get_user_last_time( $user_id, $app_id );
     863        if ( $user_last_time ) {
     864
     865            $expiration_time = $this->get_expiration_time( $user_id, $app_id );
     866
     867            if ( $expiration_time === -1 ) {
     868                $connection_validity = 1;
     869            } else {
     870                $connection_validity = ( ( time() - $user_last_time ) <= $expiration_time ) ? 1 : -1;
     871            }
     872        }
     873
     874        return $connection_validity;
     875    }
     876
     877    /**
     878     * Get the given user last login or access time (according to expiration_type)
     879     *
     880     * @param int  $user_id              User id
     881     * @param int  $app_id               App id
     882     * @return int $user_last_time       Timestamp or 0 if no valid last time found
     883     */
     884    protected function get_user_last_time( $user_id, $app_id ) {
     885        $user_last_time = 0;
     886
    834887        $user_meta = '_wpak_auth_'. $app_id;
    835888
     
    869922
    870923            if ( $expiration_type === 'login_time' ) {
    871                 $user_secret_time = $last_login_time;
     924                $user_last_time = $last_login_time;
    872925            } else if ( $expiration_type === 'last_access_time' ) {
    873                 $user_secret_time = $last_access_time;
    874             }
    875 
    876             $expiration_time = $this->get_expiration_time( $user_id, $app_id );
    877 
    878             if ( $expiration_time === -1 ) {
    879                 $connection_validity = 1;
    880             } else {
    881                 $connection_validity = ( ( time() - $user_secret_time ) <= $expiration_time ) ? 1 : -1;
    882             }
    883 
    884         }
    885 
    886         return $connection_validity;
     926                $user_last_time = $last_access_time;
     927            }
     928
     929        }
     930
     931        return $user_last_time;
    887932    }
    888933
  • wp-appkit/trunk/readme.txt

    r2197382 r2298283  
    33Tags: pwa, mobile app, android, ios, progressive web app, phonegap build
    44Requires at least: 4.0
    5 Tested up to: 5.3
    6 Stable tag: 1.5.5
     5Tested up to: 5.4.1
     6Stable tag: 1.5.6
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    122122
    123123Also see [changelog on github](https://github.com/uncatcrea/wp-appkit/blob/master/CHANGELOG.md) for full details.
     124
     125= 1.5.6 (2020-05-05) =
     126
     127*Fixes*
     128
     129- Fix PWA: manifest.json not linked properly
     130- User authentication: fix purge time when long expiration time
     131- User authentication: fix old connections cleanup
     132- Fix PHP notice when accessing preview for private app
     133
     134*Features*
     135
     136- User authentication: add expiration time info
    124137
    125138= 1.5.5 (2019-11-20) =
  • wp-appkit/trunk/wp-appkit.php

    r2197382 r2298283  
    44Plugin URI:  https://github.com/uncatcrea/wp-appkit
    55Description: Build mobile apps and PWA based on your WordPress content.
    6 Version:     1.5.5
     6Version:     1.5.6
    77Author:      Uncategorized Creations
    88Author URI:  http://getwpappkit.com
     
    2121    class WpAppKit {
    2222
    23         const resources_version = '1.5.5';
     23        const resources_version = '1.5.6';
    2424        const i18n_domain = 'wp-appkit';
    2525
Note: See TracChangeset for help on using the changeset viewer.