Plugin Directory

Changeset 2226072


Ignore:
Timestamp:
01/12/2020 01:14:11 PM (6 years ago)
Author:
khaledsaikat
Message:

Update 2.0 on trunk

Location:
user-meta/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • user-meta/trunk/controllers/AdminAjaxController.php

    r2221892 r2226072  
    5050
    5151        if (! empty($_POST['field_type'])) {
    52             $arg = $_POST;
     52            $arg = $this->sanitizeInputs($_POST);
    5353            $arg['is_new'] = true;
    5454            $fieldBuilder = new FieldBuilder($arg);
     
    8686            }
    8787        } elseif (! empty($_POST['field_type'])) {
    88             $arg = $_POST;
     88            $arg = $this->sanitizeInputs($_POST);
    8989            $arg['is_new'] = true;
    9090            $fieldBuilder = new FieldBuilder($arg);
     
    102102
    103103        if (isset($_POST['field_type']) && isset($_POST['id']) && $_POST['editor']) {
    104             $field = $_POST;
     104            $field = $this->sanitizeInputs($_POST);
    105105            $fieldBuilder = new FieldBuilder($field);
    106106            $fieldBuilder->setEditor(sanitize_key($_POST['editor']));
     
    117117
    118118        $fields = array();
    119         if (isset($_POST['fields']))
     119        if (isset($_POST['fields'])) {
    120120            $fields = $userMeta->arrayRemoveEmptyValue($_POST['fields']);
     121        }
    121122
    122123        $formBuilder = new FormBuilder();
     
    223224
    224225        $fields = $formBuilder->getSharedFields();
    225 
    226         $form = $_POST;
    227226
    228227        $form = stripslashes_deep($_POST);
     
    288287        die();
    289288    }
     289
     290    /**
     291     * Sanitize Inputs
     292     *
     293     * @todo Refactor and move to utils
     294     * @param array $inputs
     295     * @return array
     296     */
     297    private function sanitizeInputs($inputs = [])
     298    {
     299        $sanitizeCallbacks = [
     300            'id' => 'sanitize_key',
     301            'field_type' => 'sanitize_key'
     302        ];
     303        $data = [];
     304        foreach ($inputs as $key => $value) {
     305            if (is_array($value)) {
     306                $sanitizedValue = $this->sanitizeInputs($value);
     307            } else {
     308                if (! empty($sanitizeCallbacks[$key])) {
     309                    $sanitizedValue = call_user_func($sanitizeCallbacks[$key], $value);
     310                }
     311                $sanitizedValue = sanitize_text_field($value);
     312            }
     313            $data[sanitize_key($key)] = $sanitizedValue;
     314        }
     315
     316        return $data;
     317    }
    290318}
  • user-meta/trunk/controllers/PreloadsController.php

    r2218746 r2226072  
    9494                'checkForUpdate'
    9595            ));
    96         } else {
    97             add_action('user_meta_schedule_event', [
    98                 $this,
    99                 'retrievePromotionalMessages'
    100             ]);
    101             add_action('user_meta_admin_notices', [
    102                 $this,
    103                 'showPromotionalMessage'
    104             ]);
    10596        }
    10697    }
     
    177168
    178169    /**
    179      * Showing offer for lite version as admin_notice
    180      */
    181     public function showPromotionalMessage()
    182     {
    183         $messages = getRemoteMessages();
    184         if (! empty($messages['promotional_message_lite'])) {
    185             echo adminNotice($messages['promotional_message_lite'], 'info');
    186         }
    187     }
    188 
    189     /**
    190      * Retrieve promotional messages by user_meta_schedule_event
    191      */
    192     public function retrievePromotionalMessages()
    193     {
    194         retrieveRemoteMessages();
    195     }
    196 
    197     /**
    198170     * Run on the plugin activation
    199171     */
     
    240212
    241213        // Call method when need to trigger. Store process status to $userMeta->process_status for further showing message.
    242         $methodName = $_POST['method_name'];
     214        $methodName = sanitize_key($_POST['method_name']);
    243215        $postMethodName = 'post' . ucwords($methodName);
    244216        // $userMeta->um_post_method_status->$methodName = $userMeta->$postMethodName();
  • user-meta/trunk/helpers/functions.php

    r2218746 r2226072  
    222222    }
    223223}
    224 
    225 /**
    226  * Get messages from transient originated https://user-meta.com
    227  *
    228  * @return array
    229  */
    230 function getRemoteMessages()
    231 {
    232     return get_site_transient('user_meta_remote_messages');
    233 }
    234 
    235 /**
    236  * Retrieve messages from https://user-meta.com
    237  */
    238 function retrieveRemoteMessages()
    239 {
    240     global $userMeta;
    241     try {
    242         $url = $userMeta->website . '/wp-json/api/v1/promotional-message/';
    243         $offer = wp_remote_retrieve_body(wp_remote_get($url));
    244         $offer = json_decode($offer, true);
    245         if ($offer)
    246             set_site_transient('user_meta_remote_messages', $offer, 60 * 60 * 24);
    247     } catch (\Exception $e) {}
    248 }
  • user-meta/trunk/lib/models/LibWPSupportsModel.php

    r2218746 r2226072  
    2121            die('Security check: empty nonce');
    2222
    23         $nonce = $_REQUEST['pf_nonce'];
     23        $nonce = sanitize_text_field($_REQUEST['pf_nonce']);
    2424        $nonceText = $pfInstance->settingsArray('nonce');
    2525        if (! wp_verify_nonce($nonce, $nonceText))
     
    6363            die('Security check: empty nonce');
    6464
    65         $nonce = $_REQUEST['_wpnonce'];
     65        $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
    6666        $nonceText = 'pf' . ucwords(str_replace('ajax', '', $methodName));
    6767
     
    226226            return new \WP_Error('no_field', __('No file upload field found!', $pfInstance->name));
    227227
    228         $file = $_FILES[$fieldName];
     228        $file = sanitize_text_field($_FILES[$fieldName]);
    229229
    230230        $size = $file['size'];
  • user-meta/trunk/models/AjaxModel.php

    r2218746 r2226072  
    7575            }
    7676
    77             $response[] = $_REQUEST['fieldId'];
     77            $response[] = sanitize_key($_REQUEST['fieldId']);
    7878            $response[] = isset($status) ? $status : true;
    7979            $response[] = isset($msg) ? esc_html($msg) : null;
  • user-meta/trunk/models/classes/File.php

    r2218746 r2226072  
    283283            if (file_exists(WP_CONTENT_DIR . '/uploads' . $fileSubPath)) {
    284284                $file['path'] = WP_CONTENT_DIR . '/uploads' . $fileSubPath;
    285                 $file['url'] = trailingslashit($siteurl) . 'wp-content/uploads' . $fileSubPath;
     285                $file['url'] = WP_CONTENT_URL . '/uploads' . $fileSubPath;
    286286                return $file;
    287287            }
     
    291291                if (file_exists(WP_CONTENT_DIR . "/blogs.dir/{$blogId}/files" . $fileSubPath)) {
    292292                    $file['path'] = WP_CONTENT_DIR . "/blogs.dir/{$blogId}/files" . $fileSubPath;
    293                     $file['url'] = trailingslashit($siteurl) . "wp-content/blogs.dir/{$blogId}/files" . $fileSubPath;
     293                    $file['url'] = WP_CONTENT_URL . "/blogs.dir/{$blogId}/files" . $fileSubPath;
    294294                    return $file;
    295295                }
  • user-meta/trunk/models/classes/Login.php

    r2218746 r2226072  
    251251                    $user = apply_filters('wp_login_errors', $user, ''); // $errors = $user, $redirect_to = ''
    252252                }
    253                
     253
    254254                $reloadCaptchaJs = '';
    255255                if (function_exists('\UserMeta\reloadCaptcha')) {
    256256                    $reloadCaptchaJs = reloadCaptcha();
    257257                }
    258                
     258
    259259                $output = $userMeta->showError($user->get_error_message() . $reloadCaptchaJs, false);
    260260            }
     
    284284
    285285        if (empty($creds['user_pass'])) {
    286             if (isset($_REQUEST['pwd']))
    287                 $userPass = $_REQUEST['pwd'];
    288             elseif (isset($_REQUEST['user_pass']))
    289                 $userPass = $_REQUEST['user_pass'];
     286            if (isset($_POST['pwd']))
     287                $userPass = $_POST['pwd'];
     288            elseif (isset($_POST['user_pass']))
     289                $userPass = $_POST['user_pass'];
    290290        } else
    291291            $userPass = $creds['user_pass'];
    292292
    293         $remember = ! empty($creds['remember']) ? $creds['remember'] : @$_REQUEST['rememberme'];
     293        $remember = ! empty($creds['remember']) ? $creds['remember'] : @$_POST['rememberme'];
    294294
    295295        $user = wp_authenticate($userName, $userPass);
     
    373373            $redirect_to = $userMeta->getRedirectionUrl($redirect_to, 'login', $role);
    374374
    375             if ($userMeta->isHookEnable('login_redirect')) {
    376                 $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to'])
    377                     ? esc_url_raw($_REQUEST['redirect_to']) : '', $user);
    378             }
    379            
     375        if ($userMeta->isHookEnable('login_redirect')) {
     376            $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? esc_url_raw($_REQUEST['redirect_to']) : '', $user);
     377        }
    380378
    381379        $user->redirect_to = $redirect_to;
     
    394392            $userLogin = sanitize_user($_REQUEST['log']);
    395393        elseif (isset($_REQUEST['user_login']))
    396         $userLogin = sanitize_user($_REQUEST['user_login']);
     394            $userLogin = sanitize_user($_REQUEST['user_login']);
    397395        elseif (isset($_REQUEST['user_email']))
    398         $userLogin = sanitize_email($_REQUEST['user_email']);
     396            $userLogin = sanitize_email($_REQUEST['user_email']);
    399397
    400398        if ($loginBy == 'user_login_or_email') {
  • user-meta/trunk/models/classes/RouteResponse.php

    r2218746 r2226072  
    9292            die(__('Security check: Empty nonce', 'user-meta'));
    9393
    94         $nonce = $_REQUEST['_wpnonce'];
     94        $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
    9595        if (! wp_verify_nonce($nonce, $this->nonceAction($nonceText)))
    9696            die(__('Security check: Nonce missmatch', 'user-meta'));
  • user-meta/trunk/models/classes/builder/FieldBuilder.php

    r2221892 r2226072  
    289289            'v2_site_key'     => [
    290290                'label' => __('Site Key (V2)', $userMeta->name),
    291                 'info'  => __('reCAPTCHA site key is required for using Captcha validation. Get keys for free from the Captcha Link',
     291                'info'  => __('reCAPTCHA site key is required for using Captcha validation. Get keys for free from the Captcha Link below',
    292292                    $userMeta->name)
    293293            ],
    294294            'v2_secret_key'   => [
    295295                'label' => __('Secret Key (V2)', $userMeta->name),
    296                 'info'  => __('reCAPTCHA secret key is required for using Captcha validation. Get keys for free from the Captcha Link',
     296                'info'  => __('reCAPTCHA secret key is required for using Captcha validation. Get keys for free from the Captcha Link below',
    297297                    $userMeta->name)
    298298            ],
    299299            'v3_site_key'     => [
    300300                'label' => __('Site Key (V3)', $userMeta->name),
    301                 'info'  => __('reCAPTCHA site key is required for using Captcha validation. Get keys for free from the Captcha Link',
     301                'info'  => __('reCAPTCHA site key is required for using Captcha validation. Get keys for free from the Captcha Link below',
    302302                    $userMeta->name)
    303303            ],
    304304            'v3_secret_key'   => [
    305305                'label' => __('Secret Key (V3)', $userMeta->name),
    306                 'info'  => __('reCAPTCHA secret key is required for using Captcha validation. Get keys for free from the Captcha Link',
     306                'info'  => __('reCAPTCHA secret key is required for using Captcha validation. Get keys for free from the Captcha Link below',
    307307                    $userMeta->name)
    308308            ],
     
    327327                'placeholder' => __('(e.g. en) Leave blank for auto detection', $userMeta->name),
    328328                'info'        => __('(e.g. en) Leave blank for auto detection', $userMeta->name)
     329            ],
     330            'captcha_signup' => [
     331                'type'    => 'button',
     332                'label'   => __('Get reCaptcha Keys', $userMeta->name),
     333                'value'   => __('Captcha Sign Up / Dashboard', $userMeta->name),
     334                'onclick' => "(function(){ window.open('https://www.google.com/recaptcha/admin', '_blank'); return false; }) (); return false;",
     335                'info'    => __('User Meta Pro uses reCAPTCHA as Captcha field. reCAPTCHA site key and secret key are required for using Captcha validation.Get these keys for free.',
     336                    $userMeta->name)
    329337            ],
    330338            'resize_image'    => array(
     
    12221230                        'captcha_theme',
    12231231                        'captcha_type',
    1224                         'captcha_lang'
     1232                        'captcha_lang',
     1233                        'captcha_signup'
    12251234                    ), array(
    12261235                        array(
  • user-meta/trunk/models/classes/generate/FormGenerate.php

    r2218746 r2226072  
    135135            if (empty($userMeta->showDataFromDB)) {
    136136                if (isset($_POST[$fieldName]))
    137                     $fieldValue = $_POST[$fieldName];
     137                    $fieldValue = sanitize_text_field($_POST[$fieldName]);
    138138            }
    139139
  • user-meta/trunk/user-meta.php

    r2221036 r2226072  
    44 * Plugin URI: https://user-meta.com
    55 * Description: A well designed, features reached and easy to use user management plugin.
    6  * Version: 2.0rc1
     6 * Version: 2.0
    77 * Requires at least: 4.7
    88 * Requires PHP: 5.6.0
  • user-meta/trunk/vendor/autoload.php

    r2221892 r2226072  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit6851ead06e36f02ee523b4b57c12c7f3::getLoader();
     7return ComposerAutoloaderInita5f9f1d5b7e0671492c6ae833c41d13a::getLoader();
  • user-meta/trunk/vendor/composer/autoload_real.php

    r2221892 r2226072  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit6851ead06e36f02ee523b4b57c12c7f3
     5class ComposerAutoloaderInita5f9f1d5b7e0671492c6ae833c41d13a
    66{
    77    private static $loader;
     
    2020        }
    2121
    22         spl_autoload_register(array('ComposerAutoloaderInit6851ead06e36f02ee523b4b57c12c7f3', 'loadClassLoader'), true, true);
     22        spl_autoload_register(array('ComposerAutoloaderInita5f9f1d5b7e0671492c6ae833c41d13a', 'loadClassLoader'), true, true);
    2323        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInit6851ead06e36f02ee523b4b57c12c7f3', 'loadClassLoader'));
     24        spl_autoload_unregister(array('ComposerAutoloaderInita5f9f1d5b7e0671492c6ae833c41d13a', 'loadClassLoader'));
    2525
    2626        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    2828            require_once __DIR__ . '/autoload_static.php';
    2929
    30             call_user_func(\Composer\Autoload\ComposerStaticInit6851ead06e36f02ee523b4b57c12c7f3::getInitializer($loader));
     30            call_user_func(\Composer\Autoload\ComposerStaticInita5f9f1d5b7e0671492c6ae833c41d13a::getInitializer($loader));
    3131        } else {
    3232            $map = require __DIR__ . '/autoload_namespaces.php';
     
    4949
    5050        if ($useStaticLoader) {
    51             $includeFiles = Composer\Autoload\ComposerStaticInit6851ead06e36f02ee523b4b57c12c7f3::$files;
     51            $includeFiles = Composer\Autoload\ComposerStaticInita5f9f1d5b7e0671492c6ae833c41d13a::$files;
    5252        } else {
    5353            $includeFiles = require __DIR__ . '/autoload_files.php';
    5454        }
    5555        foreach ($includeFiles as $fileIdentifier => $file) {
    56             composerRequire6851ead06e36f02ee523b4b57c12c7f3($fileIdentifier, $file);
     56            composerRequirea5f9f1d5b7e0671492c6ae833c41d13a($fileIdentifier, $file);
    5757        }
    5858
     
    6161}
    6262
    63 function composerRequire6851ead06e36f02ee523b4b57c12c7f3($fileIdentifier, $file)
     63function composerRequirea5f9f1d5b7e0671492c6ae833c41d13a($fileIdentifier, $file)
    6464{
    6565    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • user-meta/trunk/vendor/composer/autoload_static.php

    r2221892 r2226072  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit6851ead06e36f02ee523b4b57c12c7f3
     7class ComposerStaticInita5f9f1d5b7e0671492c6ae833c41d13a
    88{
    99    public static $files = array (
     
    4343    {
    4444        return \Closure::bind(function () use ($loader) {
    45             $loader->prefixLengthsPsr4 = ComposerStaticInit6851ead06e36f02ee523b4b57c12c7f3::$prefixLengthsPsr4;
    46             $loader->prefixDirsPsr4 = ComposerStaticInit6851ead06e36f02ee523b4b57c12c7f3::$prefixDirsPsr4;
     45            $loader->prefixLengthsPsr4 = ComposerStaticInita5f9f1d5b7e0671492c6ae833c41d13a::$prefixLengthsPsr4;
     46            $loader->prefixDirsPsr4 = ComposerStaticInita5f9f1d5b7e0671492c6ae833c41d13a::$prefixDirsPsr4;
    4747
    4848        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.