# content-protector/4.1.4/inc/class-ps-helper.php

Passster – Password Protect Pages and Content, version 4.1.4. 47 lines.

- Page: https://pluginprobe.com/plugins/content-protector/4.1.4/code/inc/class-ps-helper.php
- Raw: https://pluginprobe.com/plugins/content-protector/4.1.4/raw/inc/class-ps-helper.php
- Modified: 2023-05-31T10:07:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/content-protector/4.1.4/code/inc/class-ps-helper.php#L10-L20`.

```php
<?php

namespace passster;

class PS_Helper
{
    /**
     * Get string between two strings.
     *
     * @param string $string string to find.
     * @param string $start start string.
     * @param string $end end string.
     *
     * @return string
     */
    public static function get_string_between( string $string, string $start, string $end ) : string
    {
        $string = ' ' . $string;
        $ini = strpos( $string, $start );
        if ( $ini == 0 ) {
            return '';
        }
        $ini += strlen( $start );
        $len = strpos( $string, $end, $ini ) - $ini;
        return substr( $string, $ini, $len );
    }
    
    /**
     * Preg matches shortcode and return cleaned output.
     *
     * @param string $content given content.
     *
     * @return string
     */
    public static function get_shortcode_content( string $content, $password ) : string
    {
        preg_match( '/\\[passster.*password="' . $password . '".*?\\]/', $content, $matches );
        $string = '';
        if ( isset( $matches ) && !empty($matches) ) {
            foreach ( $matches as $match ) {
                $string = self::get_string_between( $content, $match, '[/passster]' );
            }
        }
        return $string;
    }

}
```
