Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* Plugin Name: DSGVO Patron Plugin URI: https://wpliftup.de/ Descriptio..

Decoded Output download

<?php 
 
/* 
 
Plugin Name: DSGVO Patron 
 
Plugin URI: https://wpliftup.de/ 
 
Description: Mit diesem WordPress Plugin werden externe Ressourcen auf dem eigenen Webspace zwischengespeichert, regelmig im Hintergrund aktualisiert und von dem eigenen Webspace in die WordPress Seite eingebunden. So wird umgangen, dass der Seiten-Besucher Ihrer Webseite die Inhalte unwissentlich von einem Drittanbieter ldt und die IP des Seitenbesuchers an den Drittanbieter bertragen wird. 
 
Version: 1.0.4 
 
Author: wpLiftup <[email protected]> 
 
Author URI: https://wpliftup.de/ 
 
License: Copyright 2018 wpLiftup 
 
*/ 
 
if (!defined('ABSPATH')) return; class gdprpatron { private static $ignoreLocal = false; private static $cfgStd = array( 'dnsPrefetch' => 1, 'preconnect' => 1, 'css' => 1, 'js' => 1, 'cache' => 86400, 'emoji' => 1, 'gravatar' => 1, 'commentIp' => 1, 'socialYt' => 0, 'socialYtThumb' => '' ); static function init() { $config = get_option( 'gdprpatronCfg' ); add_filter( 'pre_set_site_transient_update_plugins', array( 'gdprpatron', 'inject_update' ) ); add_filter( 'plugins_api', array( 'gdprpatron', 'get_info' ), 10, 3 ); $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); $sVersion = get_option( 'gdprpatronVersion' ); if( $sVersion === false ) { self::_activate(); } elseif ( version_compare( $sVersion, $aPluginversion['Version'] ) < 0 ) { self::_activate(); } add_action( 'admin_notices', array( 'gdprpatron', 'admin_notices' ) ); add_action( 'admin_bar_menu', array( 'gdprpatron', 'onAdminBarMenu' ), 90 ); add_action( 'admin_menu', array( 'gdprpatron', 'admin_menu' ) ); if ( !self::_check() ) { set_transient( 'gdprpatronInfo', array( 'msg' => __( 'Keine aktive Lizenz hinterlegt.', 'gdprpatron' ) ), 300 ); return; } add_action( 'shutdown', array( 'gdprpatron', 'post' ), 99999 ); add_action( 'wp_ajax_gdprpatronClearCache', array( 'gdprpatron', 'clear_cache_callback' ) ); add_action( 'wp_ajax_nopriv_gdprpatronClearCache', array( 'gdprpatron', 'clear_cache_callback' ) ); if( isset( $config['emoji'] ) && $config['emoji'] == '1' ) { remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_action( 'embed_head', 'print_emoji_detection_script' ); add_filter( 'tiny_mce_plugins', function( $aPlugs ) { return is_array( $aPlugs ) ? array_diff( $aPlugs, array( 'wpemoji' ) ) : array(); } ); } if( isset( $config['dnsPrefetch'] ) && $config['dnsPrefetch'] == '1' ) { add_filter( 'wp_resource_hints', function( $aUrls, $sRelation ) { return $sRelation == 'dns-prefetch' ? array() : $aUrls; } , 10, 2 ); } if( isset( $config['css'] ) && $config['css'] == '1' ) { add_filter( 'editor_stylesheets', array( 'gdprpatron', 'editor_stylesheets' ) ); } if( isset( $config['gravatar'] ) && $config['gravatar'] == '1' ) { add_filter( 'get_avatar', function( $sAvatar) { return preg_match( '#gravatar\.com#si', $sAvatar ) ? '' : $sAvatar; }, 10, 1 ); } if( isset( $config['commentIp'] ) && (int)$config['commentIp'] > 0 ) { add_filter( 'pre_comment_user_ip', array( 'gdprpatron', 'pre_comment_user_ip' ) ); } add_shortcode( 'yt', array( 'gdprpatron', 'shortcode_yt' ) ); } public static function shortcode_yt( $args, $sContent ) { $config = get_option( 'gdprpatronCfg' ); $args = shortcode_atts( array( 'v' => '', 'width' => '560', 'height' => '315', 'autoplay' => '1', 'args' => '', 'thumb' => '' ), $args ); if( empty( $args['v'] ) ) { return '<!--gdprpatron:error:3-->'; } if( $args['thumb'] == '' ) { if( $config !== false && isset( $config['socialYt'] ) ) { $args['thumb'] = $config['socialYt']; } else{ $args['thumb'] = '2'; } } if( !preg_match( '#^[a-z0-9_-]+$#Usi', $args['v'] ) && ( $aUrl = wp_parse_url( $args['v'] ) ) !== false ) { if( !isset( $aUrl['query'] ) ) { return '<!--gdprpatron:error:1-->'; } parse_str( $aUrl['query'], $aParams ); if( !isset( $aParams['v'] ) ) { return '<!--gdprpatron:error:2-->'; } $args['v'] = $aParams['v']; } switch( $args['thumb'] ) { case '1': $sThumbUrl = 'https://img.youtube.com/vi/' . $args['v'] . '/hqdefault.jpg'; $sFilename = gdprpatron::url2path( $sThumbUrl ) . '.jpg'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( !is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) || filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) <= strtotime( '-' . isset( $config['cache'] ) ? (int)$config['cache'] : (int)self::$cfgStd['cache'] . ' seconds' ) ) { $oReturn = wp_remote_get( $sThumbUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { $sBackgroundUrl = ( isset( $config['socialYtThumb'] ) && $config['socialYtThumb'] != '' ) ? $config['socialYtThumb'] : ''; } else{ $sBackgroundUrl = content_url( 'gdprpatron/' . $sFilename ); } } else{ $sBackgroundUrl = content_url( 'gdprpatron/' . $sFilename ); } break; case '2': default: $sBackgroundUrl = ( isset( $config['socialYtThumb'] ) && $config['socialYtThumb'] != '' ) ? $config['socialYtThumb'] : ''; } $sWidth = is_numeric( $args['width'] ) ? (int)$args['width'] . 'px' : esc_attr( $args['width'] ); $sHeight = is_numeric( $args['height'] ) ? (int)$args['height'] . 'px' : esc_attr( $args['height'] ); $sReturn = '<span style="display: flex;'; if( !empty( $sBackgroundUrl ) ) { $sReturn .= 'background-image: url(\'' . $sBackgroundUrl . '\');'; } $sReturn .= 'cursor: pointer; width: ' . $sWidth . '; height: ' . $sHeight . '; align-content: center; background-position: center; background-size: cover;" onclick="this.innerHTML = \'<iframe src=\\'https://www.youtube-nocookie.com/embed/' . urlencode( $args['v'] ) .'?autoplay=' . (int)$args['autoplay'] . ( !empty( $args['args'] ) ? '&amp;' . $args['args'] : '' ) . '\\' width=\\'' . esc_attr( $sWidth ) .'\\' height=\\'' . esc_attr( $sHeight ) . '\\' frameborder=\\'0\\'></iframe>\';"><img src="' . plugins_url( 'gfx/playbt.png', __FILE__ ) . '" style="width: 50px; height: 50px; margin: auto;" width="50" height="50" alt=""></span>'; return $sReturn; } static function _activate() { $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); $sOldVersion = get_option( 'gdprpatronVersion' ); if( $sOldVersion !== false ) { update_option( 'gdprpatronVersion', $aPluginversion['Version'] ); } else { add_option( 'gdprpatronVersion', $aPluginversion['Version'], '', false ); } $config = get_option ( 'gdprpatronCfg' ); if( $config === false ) { add_option( 'gdprpatronCfg', self::$cfgStd ); } } static function update_settings() { return true; } static function options_page() { echo '<div class="wrap"><h1>' . __( 'DSGVO Patron fr externe Ressourcen', 'gdprpatron' ) . '</h1>'; echo '<p>Mit dem DSGVO Patron Plugin werden die aufgefhrten externen Ressourcen zwischengespeichert, im Hintergrund aktualisiert und von dem eigenen Webspace in die WordPress-Seite eingebunden. So soll umgangen werden, dass der Webseiten-Besucher Ihrer Webseite die Inhalte unwissentlich von einem Drittanbieter ldt und die IP an den Drittanbieter bertragen wird.<br><br>Bitte beachten Sie unsere <a href="https://wpliftup.de/faq/ " target="_blank">FAQ</a>.</p>'; echo '<form method="post" action="options.php">'; settings_fields( 'gdprpatron-options' ); do_settings_sections( 'gdprpatron-options' ); $aCachingplugins = self::_has_caching(); if( count( $aCachingplugins ) > 0) { echo '<h3>' . __( 'Erkannte Cache-Plugins', 'gdprpatron' ) . '</h3><table class="form-table"><tbody>'; foreach( $aCachingplugins AS $sPlugin => $aFunc ) { echo '<tr><th scope="row">' . sprintf( __( '%s-Cache leeren', 'gdprpatron' ), esc_html( $sPlugin ) ) . ':</th><td><input type="checkbox" name="gdprpatron_clear[' . esc_attr( $sPlugin ) . ']" id="gdprpatron_clear[' . esc_attr( $sPlugin ) . ']" value="1" checked="checked"><p class="description" id="gdprpatroncfg-clear-' . strtolower( esc_attr( $sPlugin ) ) . '-description"><strong>' . __( 'Empfohlen', 'gdprpatron' ) . ':</strong> ' . sprintf( __( 'Cache des Plugins <b>%s</b> beim Speichern automatisch leeren.', 'gdprpatron' ), esc_html( $sPlugin ) ) . '</p></td></tr>'; } echo '</tbody></table>'; } echo '<h3>' . __( 'Hinweis', 'gdprpatron' ) . '</h3><table class="form-table"><tbody>'; echo '<tr><td scope="row" colspan="2"><p>Sollten Sie ein Cache-Plugin nutzen, lschen Sie bitte nach dem Speichern der nderungen den angelegten Cache. Bitte Testen Sie nach dem Sie nderungen speichern geklickt haben, ob die gewnschten Funktionen ausgefhrt werden. Schreiben Sie z.B. einen Test-Kommentar im ausgeloggten Zustand.<br><br>Bitte lschen Sie den Cache immer, wenn Sie etwas an den Einstellungen verndern.</p></td></tr>'; echo '</tbody></table>'; submit_button(); echo '</form></div>'; echo '<hr>'; echo '<h2>Zur Verfgung stehende Shortcodes</h2>'; echo '<h3>YouTube-Videos</h3>'; echo '<p><a href="https://wpliftup.de/faq/#YouTube-Video_einbinden_eigene_Videos" target="_blank">Wann / Warum sollte ich einen Shortcode verwenden?</a></p>'; echo '<p><b>ShortCode:</b> [yt v="https://www.youtube.com/watch?v=MK6TXMsvgQg" width="560" height="315" autoplay="1" thumb="2" args=""]</p>'; echo '<p><b>Parameter:</b></p>'; echo '<ul><li><b>v</b> die Video-ID / direkte URL von YouTube (Pflichtangabe)</li><li><b>width</b> die Breite des Videos (optional)</li><li><b>height</b> die Hhe des Videos (optional)</li><li><b>autoplay</b> mit Wert "1" wenn das Video nach dem ersten Klick abgespielt werden soll oder Wert "0" wenn ein zweiter Klick das Video starten soll. (optional)</li><li><b>thumb</b> Mgliche Werte: "1" um die Vorschau lokal zu speichern und anzuzeigen oder "2" um die eingestellte Standard-Vorschau anzuzeigen. (optional)</li><li><b>args</b> Experteneinstellung um weitere Parameter zu bergeben. Siehe <a href="https://developers.google.com/youtube/player_parameters?hl=de#Parameters" target="_blank">YouTube Player-Parameter</a> direkt in der YouTube Hilfe. (optional)</li></ul>'; } static function sanitize_settings( $setting ) { $config = get_option( 'gdprpatronCfg' ); foreach( self::$cfgStd AS $key => $val ) { if( !isset( $setting[$key] ) ) { $setting[$key] = ''; } } $setting['licenseKey'] = trim( $setting['licenseKey'] ); if( $setting['licenseKey'] != '* Lizenz gltig *' && !empty( $setting['licenseKey'] ) ) { if( self::_cleanup( $setting['licenseKey'] ) === false ) { add_settings_error( 'gdprpatron-options', esc_attr( 'settings_updated' ), __( 'Die angegebene Lizenz konnte nicht validiert werden und wurde daher nicht gespeichert!', 'gdprpatron' ), 'error' ); if( $config !== false && isset( $config['licenseKey'] ) ) { $setting['licenseKey'] = $config['licenseKey']; } else{ $setting['licenseKey'] = ''; } } } else{ $setting['licenseKey'] = $config['licenseKey']; } if( isset( $_POST['gdprpatron_clear'] ) ) { $aCachingplugins = self::_has_caching(); if( count( $aCachingplugins ) > 0 ) { foreach( $aCachingplugins AS $sPlugin => $aFunc ) { if( isset( $_POST['gdprpatron_clear'][$sPlugin] ) ) { call_user_func( $aFunc ); } } } } return $setting; } static function admin_menu() { $hook = add_options_page( __( 'DSGVO Patron', 'gdprpatron' ), __( 'DSGVO Patron', 'gdprpatron' ), 'manage_options', 'gdprpatron-options', array( 'gdprpatron', 'options_page' ) ); add_action( 'load-'.$hook, array( 'gdprpatron', 'update_settings' ) ); register_setting( 'gdprpatron-options', 'gdprpatronCfg', array( 'gdprpatron', 'sanitize_settings' ) ); add_settings_section( 'gdprpatron-options', __( 'Einstellungen', 'gdprpatron' ), array( 'gdprpatron', 'render_header' ), 'gdprpatron-options' ); add_settings_field( 'licenseKey', __( 'Lizenz', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'licenseKey' ) ); add_settings_field( 'css', __( 'CSS + Fonts lokal speichern', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'css' ) ); add_settings_field( 'js', __( 'JavaScripte lokal speichern', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'js' ) ); add_settings_field( 'cache', __( 'Lokale Dateien gltig fr', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'cache' ) ); add_settings_field( 'emoji', __( 'Externe Emoji-Datenbank nicht laden', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'emoji' ) ); add_settings_field( 'gravatar', __( 'Gravatar.com entfernen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'gravatar' ) ); add_settings_field( 'commentIp', __( 'IP aus Kommentaren krzen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'commentIp' ) ); add_settings_field( 'dnsPrefetch', __( 'DNS-Prefetch entfernen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'dnsPrefetch' ) ); add_settings_field( 'preconnect', __( '"preconnect" entfernen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'preconnect' ) ); add_settings_field( 'socialYt', __( 'YouTube-Sicherung', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'socialYt' ) ); add_settings_field( 'socialYtThumb', __( 'YouTube Standard-Vorschau', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'socialYtThumb' ) ); } static function render_field( $aArgs ) { $config = get_option( 'gdprpatronCfg' ); if (!isset($config[$aArgs['field']])) { switch($aArgs['field']) { default: $config[$aArgs['field']] = ''; } } switch($aArgs['field']) { case 'licenseKey': echo '<input type="text" style="width: 30em;" name="gdprpatronCfg[licenseKey]" id="gdprpatronCfg[licenseKey]" value="'; if( self::_check() ) { echo '* Lizenz gltig *'; } echo '" />'; if( self::_check() ) { $info = get_transient( 'gdprpatronInfo' ); echo '<p class="description" id="gdprpatroncfg-licenseKey-description">Identifikator: ' . $info['key'] . '</p>'; } break; case 'dnsPrefetch': echo '<input type="checkbox" name="gdprpatronCfg[dnsPrefetch]" id="gdprpatronCfg[dnsPrefetch]" '; checked( (int)$config['dnsPrefetch'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-dnsprefetch-description">Sogenannte "DNS-Prefetch" Meta-Angaben sorgen dafr, dass vom Browser DNS-Anfragen fr Domains erzeugt werden, welche eventuell verlinkt sind. Bei Aktivierung dieser Option werden diese DNS-Abfragen erst bei Klick auf einen Link erzeugt, was die Ladezeit der externen Seite um wenige Millisekunden verzgern kann.</p>'; break; case 'preconnect': echo '<input type="checkbox" name="gdprpatronCfg[preconnect]" id="gdprpatronCfg[preconnect]" '; checked( (int)$config['preconnect'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-preconnect-description">Sogenannte "preconnect" Meta-Angaben sorgen dafr, dass vom Browser Serververbindungen fr Domains erzeugt werden, welche eventuell verlinkt sind und fr ausgefhrte Scripte erst spter bentigt werden. Bei Aktivierung dieser Option werden diese Verbindungsaufforderungen entfernt, was die Ladezeit der externen Domain um wenige Millisekunden verzgern kann.</p>'; break; case 'css': echo '<input type="checkbox" name="gdprpatronCfg[css]" id="gdprpatronCfg[css]" '; checked( (int)$config['css'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-css-description">Es werden externe und interne CSS-Dateien die direkt im Theme eingebunden sind, zwischengespeichert um eine Verbindung zum Laden der Ressourcen von anderen Servern zu unterbinden. z. B.: Google Fonts</p>'; break; case 'socialYt': echo '<select name="gdprpatronCfg[socialYt]" id="gdprpatronCfg[socialYt]">'; echo '<option value="0"' . selected( $config['socialYt'], '0', false ) . '>' . __( 'ignorieren', 'gdprpatron' ) . '</option>'; echo '<option value="1"' . selected( $config['socialYt'], '1', false ) . '>' . __( 'sichern und Vorschau zwischenspeichern', 'gdprpatron' ) . '</option>'; echo '<option value="2"' . selected( $config['socialYt'], '2', false ) . '>' . __( 'sichern und Standard-Vorschau anzeigen', 'gdprpatron' ) . '</option>'; echo '</select>'; echo '<p class="description" id="gdprpatroncfg-socialyt-description">Eingebettete YouTube-Videos bermitteln eventuell diverse Daten, dies kann verhindert werden indem eine Schlatflche zum Abspielen vorgeschaltet, und damit die bermittlung gesichert wird. Der Besucher entscheidet dann per Klick auf die "Abspielen" Schaltflche selbst, ob und wann Daten an YouTube bermittelt werden. Die Vorschau zwischen zu speichern kann Urheberrechtsprobleme nach sich ziehen, die Verantwortung dies zu prfen unterliegt Ihnen als Plattformbetreiber.</p>'; break; case 'socialYtThumb': echo '<input type="text" style="width: 30em;" name="gdprpatronCfg[socialYtThumb]" id="gdprpatronCfg[socialYtThumb]" value="' . ( isset( $config['socialYtThumb'] ) ? esc_attr( $config['socialYtThumb'] ) : '' ) . '" />'; echo '<input type="button" name="gdprpatron-upload-btn" id="gdprpatron-upload-btn" data-for="gdprpatronCfg[socialYtThumb]" class="gdprpatron-upload-btn button-secondary" value="' . __( 'Select' ) . '">'; echo '<p class="description" id="gdprpatroncfg-socialyt-description">Dieses Bild wird als Vorschaubild gezeigt, wennn die Vorschau eines YouTube-Videos nicht geladen werden konnte oder die Anzeige erzwungen wird.</p>'; break; case 'js': echo '<input type="checkbox" name="gdprpatronCfg[js]" id="gdprpatronCfg[js]" '; checked( (int)$config['js'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-js-description">Wie bei den CSS-Dateien werden die JavasScript-Dateien lokal zwischengespeichert um eine Verbindung zum Laden der Ressourcen von anderen Servern zu unterbinden. z. B.: jQuery</p>'; break; case 'emoji': echo '<input type="checkbox" name="gdprpatronCfg[emoji]" id="gdprpatronCfg[emoji]" '; checked( (int)$config['emoji'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-emoji-description">WordPress ldt im Standard eine Emoji-Datenbank, die aus Textzeichen kleine Emojis wandelt und anzeigt. Diese kleinen Bilddateien der Emojis (Smilies) werden von einem externen Server geladen zu dem die IP-Adresse bertragen wird.</p>'; break; case 'cache': echo '<select name="gdprpatronCfg[cache]" id="gdprpatronCfg[cache]">'; echo '<option value="86400"' . selected( $config['cache'], 86400, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 1, 'gdprpatron' ), 1 ) . '</option>'; echo '<option value="172800"' . selected( $config['cache'], 172800, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 2, 'gdprpatron' ), 2 ) . '</option>'; echo '<option value="259200"' . selected( $config['cache'], 259200, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 3, 'gdprpatron' ), 3 ) . '</option>'; echo '<option value="345600"' . selected( $config['cache'], 345600, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 4, 'gdprpatron' ), 4 ) . '</option>'; echo '<option value="432000"' . selected( $config['cache'], 432000, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 5, 'gdprpatron' ), 5 ) . '</option>'; echo '<option value="518400"' . selected( $config['cache'], 518400, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 6, 'gdprpatron' ), 6 ) . '</option>'; echo '<option value="604800"' . selected( $config['cache'], 604800, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 7, 'gdprpatron' ), 7 ) . '</option>'; echo '<option value="1209600"' . selected( $config['cache'], 1209600, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 14, 'gdprpatron' ), 14 ) . '</option>'; echo '<option value="2419200"' . selected( $config['cache'], 2419200, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 28, 'gdprpatron' ), 28 ) . '</option>'; echo '</select>'; break; case 'gravatar': echo '<input type="checkbox" name="gdprpatronCfg[gravatar]" id="gdprpatronCfg[gravatar]" '; checked( (int)$config['gravatar'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-gravatar-description">Wer Kommentare in seiner Seite aktiviert hat, kennt die Gravartar-Bilder der Kommentierenden. Hat der Kommentar-Schreiber einen Gravatar-Account, wird sein Bild vom Gravatar-Server geladen und eingebunden (Hotlinking). Diese Einstellung verhindert die bermittlung der Daten an die gravatar.com Server.</p>'; break; case 'commentIp': echo '<select name="gdprpatronCfg[commentIp]" id="gdprpatronCfg[commentIp]">'; echo '<option value="0"' . selected( (int)$config['commentIp'], 0, false ) . '>' . sprintf( __( 'Nicht krzen (%s)', 'gdprpatron' ), $_SERVER['REMOTE_ADDR'] ) . '</option>'; echo '<option value="1"' . selected( (int)$config['commentIp'], 1, false ) . '>' . sprintf( __( 'Standard (%s)', 'gdprpatron' ), self::pre_comment_user_ip( $_SERVER['REMOTE_ADDR'], 1 ) ) . '</option>'; echo '<option value="2"' . selected( (int)$config['commentIp'], 2, false ) . '>' . sprintf( __( 'Stark (%s)', 'gdprpatron' ), self::pre_comment_user_ip( $_SERVER['REMOTE_ADDR'], 2 ) ) . '</option>'; echo '<option value="3"' . selected( (int)$config['commentIp'], 3, false ) . '>' . sprintf( __( 'Anonymisieren (%s)', 'gdprpatron' ), self::pre_comment_user_ip( $_SERVER['REMOTE_ADDR'], 3 ) ) . '</option>'; echo '</select>'; echo '<p class="description" id="gdprpatroncfg-commentip-description">Beim Absenden eines Kommentars wird die IP-Adresse durch einen gekrzten oder anonymisierten Inhalt ersetzt.</p>'; break; } } static function render_header( $args ) { if ( $args['id'] != 'gdprpatron-options' ) { return; } wp_enqueue_script( 'gdprpatron-lib', plugins_url( 'gfx/lib.js', __FILE__ ), array( 'jquery' ), false, true ); wp_enqueue_media(); } static function admin_notices() { if (!is_dir(ABSPATH.'wp-content/gdprpatron')) { $iMask = umask(0); if (!is_writable(ABSPATH.'wp-content') || mkdir(ABSPATH.'wp-content/gdprpatron', 0757, true) === false) { gdprpatron::setAdminNotice('error', 'Cacheverzeichnis kann nicht erstellt werden!<br />Es gibt 2 mgliche Lsungen:<br/><ol><li>Sie setzen das Verzeichnis '.ABSPATH.'wp-content fr Wordpress auf beschreibbar (z.B. per CHMOD 757)</li><li>oder Sie legen das Verzeichnis '.ABSPATH.'wp-content/gdprpatron an und setzen nur dieses fr Wordpress auf beschreibbar (z.B. per CHMOD 757).</li></ol>'); } umask( $iMask ); } elseif (!is_writable(ABSPATH.'wp-content/gdprpatron')) { gdprpatron::setAdminNotice('error', 'Das Cacheverzeichnis '.ABSPATH.'wp-content/gdprpatron muss fr Wordpress beschreibbar sein (z.B. CHMOD 757)!<br /><small>Dies gilt auch fr alle darin enthaltene Dateien und Verzeichnisse.</small>'); } $info = get_transient('gdprpatronInfo'); if ($info !== false && !empty($info['msg'])) { echo '<div class="notice notice-error"><p><a href="' . get_admin_url( null, 'admin.php?page=gdprpatron-options' ) . '">' . __( 'DSGVO Patron', 'gdprpatron' ) . '</a>: ' . esc_html($info['msg']) . '</p></div>'; } } static function setAdminNotice($sType, $sMessage) { echo '<div class="'.$sType.'"><p><b>Plugin DSGVO Patron:</b> '.$sMessage.'</p></div>'; } static function onDeactivation() { self::rmdirRecursive(ABSPATH.'wp-content/gdprpatron'); } static function rmdirRecursive($sDir) { if ( substr( $sDir, 0, strlen( ABSPATH.'wp-content/gdprpatron' ) ) != ABSPATH.'wp-content/gdprpatron' || substr_count( $sDir, '..' ) > 0 ) { return false; } if (($dh = @opendir($sDir)) === false) { return false; } while(($sObj = @readdir($dh)) !== false) { if ($sObj == '.' || $sObj == '..') { continue; } if (@is_dir($sDir.'/'.$sObj)) { gdprpatron::rmdirRecursive($sDir.'/'.$sObj); } else { @unlink($sDir.'/'.$sObj); } } return @rmdir($sDir); } static function onAdminBarMenu($wp_admin_bar) { if (!is_admin_bar_showing()) { return; } echo '<style>#wp-admin-bar-gdprpatron{display:list-item !important} #wp-admin-bar-gdprpatron .ab-icon{margin:0} #wp-admin-bar-gdprpatron .ab-icon:before{content:"182";top:.15rem;}</style>'; $wp_admin_bar->add_menu( array( 'id' => 'gdprpatron', 'href' => '#', 'parent' => 'top-secondary', 'title' => '<span class="ab-icon dashicons"></span>', 'meta' => array( 'title' => esc_html__('DSGVO Patron-Cache leeren', 'gdprpatron'), 'onclick' => 'jQuery(document).ready(function($) { var data = { "action": "gdprpatronClearCache", "security": "' . wp_create_nonce( 'gdprpatronCC' . date('Ym') ) . '" }; jQuery.post(ajaxurl, data, function(response) { alert(response); }); }); return false;' ) ) ); } static function parse($sBuffer) { $config = get_option( 'gdprpatronCfg' ); $return = ''; if( $config !== false && isset( $config['css'] ) && $config['css'] == '1' ) { $sBuffer = gdprpatron::localizeCss($sBuffer); $sBuffer = gdprpatron::localizeInlineCss($sBuffer); } if( $config !== false && isset( $config['js'] ) && $config['js'] == '1' ) { $sBuffer = gdprpatron::localizeScripts($sBuffer); } if( $config !== false && isset( $config['preconnect'] ) && $config['preconnect'] == '1' ) { if( ( $iCount = preg_match_all('#<link[^>]+rel=["\']preconnect["\']>#Umsi', $sBuffer, $aMatches ) ) > 0 ) { for( $i = 0; $i < $iCount; $i++ ) { $sBuffer = str_replace( $aMatches[0], '', $sBuffer ); } } } if( $config !== false && isset( $config['socialYt'] ) && $config['socialYt'] != '0') { if( ( $iCount = preg_match_all( '#<iframe[^>]+src=["\'](https?:)?//(www\.)?youtube(\-nocookie)?\.com/embed/([a-z0-9_-]+)(\?([^"]*))?".+</iframe>#Umsi', $sBuffer, $aMatches ) ) > 0 ) { for( $i = 0; $i < $iCount; $i++ ) { $sX = '[yt v="' . esc_attr( $aMatches[4][$i] ) . '"'; if( preg_match( '#width=["\']?([^\s"\']+)["\']?#si', $aMatches[0][$i], $aWidth ) ) { $sX .= ' width="' . esc_attr( $aWidth[1] ) . '"'; } if( preg_match( '#height=["\']?([^\s"\']+)["\']?#si', $aMatches[0][$i], $aHeight ) ) { $sX .= ' height="' . esc_attr( $aHeight[1] ) . '"'; } if( !empty( $aMatches[6][$i] ) ) { $sX .= ' args="' . urldecode( $aMatches[6][$i] ) . '"'; } $sX .= ']'; $sBuffer .= '<!-- ' . $sX . ' -->'; $sBuffer = str_replace( $aMatches[0][$i], do_shortcode( $sX ), $sBuffer ); } } } return (empty($return)) ? $sBuffer : $return; } static function localizeScripts($sBuffer) { $config = get_option( 'gdprpatronCfg' ); $return = ''; if(($iCount = preg_match_all('#<script[^>]+src=["\'](.+)["\']#Umsi', $sBuffer, $matches ) ) > 0 ) { $aScripts = array_unique( $matches[1] ); for( $i = 0; $i < count( $aScripts ); $i++ ) { if ( substr( $aScripts[$i], 0, 5 ) == 'data:' ) { continue; } if ( preg_match( '#(https?:)?//.+#si', $aScripts[$i], $aMatches ) ) { if( !isset( $aMatches[1] ) ) { $sUrl = 'http' . ( is_ssl() ? 's' : '' ) . ':' . $aScripts[$i]; } else { $sUrl = $aScripts[$i]; } if( gdprpatron::isLocalUrl( $sUrl ) ) { continue; } $sFilename = gdprpatron::url2path( $sUrl ) . '.js'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-' . isset( $config['cache'] ) ? (int)$config['cache'] : (int)self::$cfgStd['cache'] . ' seconds' ) ) { $sBuffer = str_replace( $aScripts[$i], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } else{ $oReturn = wp_remote_get( $aScripts[$i], array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { continue; } $sBuffer = str_replace( $aScripts[$i], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } } } } return (empty($return)) ? trim($sBuffer) : $return; } static function pre() { global $pagenow; if ( is_admin() || in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ) ) ) { return; } ob_start( array( 'gdprpatron', 'obcallback' ) ); } static function obcallback($sBuffer, $iPhase = 0) { $gz = false; if( strpos( $sBuffer, "" ) === 0 ) { $gz = true; $sBuffer = gzdecode( $sBuffer ); } $sBuffer = gdprpatron::parse( $sBuffer ); return $gz ? gzencode( $sBuffer ) : $sBuffer; } static function post() { } static function url2path( $sUrl ) { $aParsed = wp_parse_url( $sUrl ); $sReturn = ''; $sReturn .= ( isset( $aParsed['scheme'] ) && !empty( $aParsed['scheme'] ) ? $aParsed['scheme'] . '/' : '' ); $sReturn .= ( isset( $aParsed['host'] ) && !empty( $aParsed['host'] ) ? $aParsed['host'] . '/' : '' ); $sReturn .= ( isset( $aParsed['path'] ) && !empty( $aParsed['path'] ) ? substr( preg_replace( '#[^\w\d/]+#si', '_', $aParsed['path'] ), 1 ) : '' ); if( isset( $aParsed['query'] ) && !empty( $aParsed['query'] ) ) { $sReturn .= '_' . preg_replace( '#\W+#si', '_', $aParsed['query'] ); } return $sReturn; } static function isLocalUrl( $sUrl ) { return ( self::$ignoreLocal === true && substr( $sUrl, 0, strlen( home_url() ) ) == home_url() ); } static function localizeInlineCss($sBuffer) { global $wp; if (!is_dir(ABSPATH.'/wp-content/gdprpatron') || !is_writable(ABSPATH.'/wp-content/gdprpatron')) { return $sBuffer; } $return = ''; if ( preg_match_all('#<style[^>]*>(.+)</style>#Umsi', $sBuffer, $matches) > 0) { for( $iEntry=0; $iEntry < count( $matches[1] ); $iEntry++ ) { $sFilename = 'inline-' . crc32( get_site_url() ) . '-' . crc32( $matches[1][$iEntry] ) . '.css'; if( is_file( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-24 hours' ) ) { $sBuffer = str_replace( $matches[1][$iEntry], file_get_contents( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ), $sBuffer ); } else{ file_put_contents( ABSPATH . '/wp-content/gdprpatron/' . $sFilename, $matches[1][$iEntry] ); self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, get_permalink() ); $sBuffer = str_replace( $matches[1][$iEntry], file_get_contents( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ), $sBuffer ); } } } return $sBuffer; } static function editor_stylesheets( $aStylesheets ) { global $wp; if (!is_dir(ABSPATH.'/wp-content/gdprpatron') || !is_writable(ABSPATH.'/wp-content/gdprpatron')) { return $sBuffer; } for( $iEntry = 0; $iEntry < count( $aStylesheets ); $iEntry++ ) { if( preg_match( '#(https?:)?//.+#si', $aStylesheets[$iEntry], $aMatches ) ) { if( !isset( $aMatches[1] ) ) { $sUrl = 'http' . ( is_ssl() ? 's' : '' ) . ':' . $aStylesheets[$iEntry]; } else { $sUrl = $aStylesheets[$iEntry]; } if( gdprpatron::isLocalUrl( $sUrl ) ) { continue; } $sFilename = gdprpatron::url2path( $sUrl ) . '.css'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-24 hours' ) ) { $aStylesheets[$iEntry] = content_url( 'gdprpatron/' . $sFilename ); } else{ $oReturn = wp_remote_get( $sUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { continue; } self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, $sUrl ); $aStylesheets[$iEntry] = content_url( 'gdprpatron/' . $sFilename ); } } } return $aStylesheets; } static function localizeCss($sBuffer) { global $wp; if (!is_dir(ABSPATH.'/wp-content/gdprpatron') || !is_writable(ABSPATH.'/wp-content/gdprpatron')) { return $sBuffer; } $return = ''; if ( preg_match_all('#(<link\s[^>]*rel=["\']?stylesheet["\']?[^>]*>)#Umsi', $sBuffer, $matches) > 0) { for($i=0;$i<count($matches[0]);$i++) { if (($iCount = preg_match_all('#href=["\']?([^"\']+)["\']?#msi', $matches[0][$i], $matches2)) > 0) { for( $iEntry = 0; $iEntry < $iCount; $iEntry++ ) { if ( substr( $matches2[1][$iEntry], 0, 5 ) == 'data:' ) { continue; } if( preg_match( '#(https?:)?//.+#si', $matches2[1][$iEntry], $aMatches ) ) { if( !isset( $aMatches[1] ) ) { $sUrl = 'http' . ( is_ssl() ? 's' : '' ) . ':' . $matches2[1][$iEntry]; } else { $sUrl = $matches2[1][$iEntry]; } if( gdprpatron::isLocalUrl( $sUrl ) ) { continue; } $sFilename = gdprpatron::url2path( $sUrl ) . '.css'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-24 hours' ) ) { $sBuffer = str_replace( $matches2[1][$iEntry], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } else{ $oReturn = wp_remote_get( $sUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { continue; } self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, $sUrl ); $sBuffer = str_replace( $matches2[1][$iEntry], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } } } } } } $return = ''; return (!empty($return)) ? $return : $sBuffer; } static function localizeCssUrls( $sPath, $sBase ) { if ( !( $sBuffer = file_get_contents( $sPath ) ) ) { return false; } $changed = false; if ( $iCount = preg_match_all( '#(@import[^;]+)?url\s*\(["\']?([^\)"\']+)["\']?\)#Usi', $sBuffer, $aMatches ) ) { for( $iEntry = 0; $iEntry < $iCount; $iEntry++ ) { $sUrl = ''; if ( substr( $aMatches[2][$iEntry], 0, 5 ) == 'data:' ) { continue; } if( preg_match( '#(https?:)?//.+#si', $aMatches[2][$iEntry], $aMatches2 ) ) { if( !isset( $aMatches2[1] ) ) { $sUrl = 'http' . ( substr( $sBase, 4, 1 ) == 's' ? 's' : '' ) . ':' . $aMatches[2][$iEntry]; } else { $sUrl = $aMatches[2][$iEntry]; } } else { $sUrl = WP_Http::make_absolute_url($aMatches[2][$iEntry], $sBase); } $sExt = pathinfo( $sUrl, PATHINFO_EXTENSION ); if( empty( $sUrl) || gdprpatron::isLocalUrl( $sUrl ) || in_array( $sExt, array( 'php', 'pl', 'cgi', 'exe', 'zip', 'apk' ) ) ) { $sBuffer = str_replace( $aMatches[2][$iEntry], $sUrl, $sBuffer ); $changed = true; continue; } if( empty( $sExt) && substr( trim( $aMatches[1][$iEntry] ), 0, 7 ) == '@import' ) { $sExt = 'css'; } $sFilename = gdprpatron::url2path( $sUrl ) . '.' . $sExt; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } $oReturn = wp_remote_get( $sUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { $sBuffer = str_replace( $aMatches[2][$iEntry], $sUrl, $sBuffer ); $changed = true; continue; } $sBuffer = str_replace( $aMatches[2][$iEntry], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); if( !empty( $aMatches[1][$iEntry] ) ) { self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, $sUrl ); } $changed = true; } } if ( $changed === true ) { file_put_contents( $sPath, $sBuffer ); } return true; } static function plugins_loaded() { if( !self::_check() ) { return; } $aCachingplugins = self::_has_caching(); if( isset( $aCachingplugins['Cachify'] ) ) { add_action( 'template_redirect', array( 'gdprpatron', 'pre' ), 1 ); } else { self::pre(); } } public static function inject_update($transient) { if ( empty( $transient->checked ) ) { return $transient; } $obj = self::get_update_info(); $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); if ( $obj !== false && isset( $obj->new_version ) && version_compare( $aPluginversion['Version'], $obj->new_version, '<' ) ) { $oInject = new stdClass; $oInject->id = -1; $oInject->slug = 'gdpr-patron'; $oInject->plugin = 'gdpr-patron/gdpr-patron.php'; $oInject->new_version = ( isset( $obj->new_version ) ? $obj->new_version : false ); $oInject->url = 'https://wpliftup.de/'; $oInject->package = ( isset( $obj->download_link ) ? $obj->download_link : false ); $oInject->tested = ( isset( $obj->tested ) ? $obj->tested : false ); $oInject->compatibility = new stdClass; $oInject->compatibility->scalar = new stdClass; $oInject->compatibility->scalar->scalar = ''; $transient->response['gdpr-patron/gdpr-patron.php'] = $oInject; } return $transient; } public static function get_info($false, $action, $arg) { if ( isset( $arg->slug ) && $arg->slug == 'gdpr-patron' ) { return self::get_update_info(); } return false; } public static function get_update_info() { $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); $request = wp_remote_get( 'https://api.hinrichs-medien.de/wp/gdpr-patron/?version=' . $aPluginversion['Version'] ); if ( !is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) === 200 ) { return unserialize( $request['body'] ); } return false; } public static function clear_cache_callback() { if ( !check_ajax_referer( 'gdprpatronCC' . date('Ym'), 'security', false ) ) { echo __( 'Security mistake. Please the reload the page and try again. ', 'gdprpatron' ); wp_die(); } self::rmdirRecursive( ABSPATH . 'wp-content/gdprpatron' ); echo __( 'Cache successfully cleared', 'gdprpatron' ); wp_die(); } public static function pre_comment_user_ip( $sIp, $override = false ) { $config = get_option( 'gdprpatronCfg' ); if( $override !== false ) { $config['commentIp'] = (int)$override; } $sReturn = ''; if( preg_match( '#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#si', $sIp, $aMatches ) ) { switch( (int)$config['commentIp'] ) { case 1: $sReturn = $aMatches[1] . '.' . $aMatches[2] . '.' . $aMatches[3] . '.0'; break; case 2: $sReturn = $aMatches[1] . '.0.0.0'; break; case 3: $sReturn = '127.0.0.1'; break; } } elseif( ( (int)$config['commentIp'] == 1 && preg_match( '#^(([0-9a-f]+:){1,3}).+$#si', $sIp, $aMatches ) ) || ( (int)$config['commentIp'] == 2 && preg_match( '#^(([0-9a-f]+:){1,2}).+$#si', $sIp, $aMatches ) ) || ( (int)$config['commentIp'] == 3 && preg_match( '#^(([0-9a-f]+:){1}).+$#si', $sIp, $aMatches ) ) ) { $sReturn = $aMatches[1] . ':1'; } return $sReturn; } static function _has_caching() { $aPlugins = array(); if( class_exists( 'Cachify' ) && method_exists( 'Cachify', 'flush_total_cache' ) ) { $aPlugins['Cachify'] = array( 'Cachify', 'flush_total_cache' ); } return $aPlugins; } static function _cleanup( $m2 = false ) { $k0=get_file_data(__FILE__,array('Version' =>'Version'),false);$i1=get_option('gdprpatronCfg');if((!isset($i1['licenseKey'])||empty($i1['licenseKey']))&&$m2===false){delete_transient('gdprpatronInfo');return false;}$h3=wp_remote_get('https://api.hinrichs-medien.de/wp/gdpr-patron/license/?version='.urlencode($k0['Version']).'&licenseKey='.urlencode($m2!==false?$m2:$i1['licenseKey']).'&url='.urlencode(get_site_url()));if(is_wp_error($h3)){if($m2===false){set_transient('gdprpatronInfo',array('key' =>'','msg' =>'Lizenzabgleich fehlgeschlagen (Abruf fehlgeschlagen).'),300);}return false;}if(empty($h3['body'])||($k4=@json_decode($h3['body'],true))===false){if($m2===false){set_transient('gdprpatronInfo',array('key' =>'','msg' =>'Lizenzabgleich fehlgeschlagen (unerwartete Antwort).'),300);}return false;}if(empty($k4['key'])){if($m2===false){set_transient('gdprpatronInfo',$k4,3600);}return false;}set_transient('gdprpatronInfo',$k4,648000);return true; } static function _check($g3 = true) { $b0=get_option('gdprpatronCfg');if(!isset($b0['licenseKey'])||empty($b0['licenseKey'])){return false;}$q1=get_option('_transient_timeout_gdprpatronInfo');if($q1!==false &&((int)$q1>time()+658000 ||(int)$q1<=time())){delete_transient('gdprpatronInfo');}$c2=get_transient('gdprpatronInfo');if($c2===false){self::_cleanup();if($g3===true){return self::_check(false);}return false;}if(empty($c2['key'])){return false;}if($c2['key']!=md5(trim($b0['licenseKey']).'ifno')){set_transient('gdprpatronInfo',array('key' =>false,'msg' =>'Lizenz ungltig.'),7200);return false;}return true; } } add_action( 'plugins_loaded', array( 'gdprpatron', 'plugins_loaded' ), 0 ); add_action( 'init', array( 'gdprpatron', 'init' ) ); register_deactivation_hook( __FILE__, array( 'gdprpatron', 'onDeactivation' ) ); ?>

Did this file decode correctly?

Original Code

<?php

/*

Plugin Name: DSGVO Patron

Plugin URI: https://wpliftup.de/

Description: Mit diesem WordPress Plugin werden externe Ressourcen auf dem eigenen Webspace zwischengespeichert, regelmig im Hintergrund aktualisiert und von dem eigenen Webspace in die WordPress Seite eingebunden. So wird umgangen, dass der Seiten-Besucher Ihrer Webseite die Inhalte unwissentlich von einem Drittanbieter ldt und die IP des Seitenbesuchers an den Drittanbieter bertragen wird.

Version: 1.0.4

Author: wpLiftup <[email protected]>

Author URI: https://wpliftup.de/

License: Copyright 2018 wpLiftup

*/

if (!defined('ABSPATH')) return; class gdprpatron { private static $ignoreLocal = false; private static $cfgStd = array( 'dnsPrefetch' => 1, 'preconnect' => 1, 'css' => 1, 'js' => 1, 'cache' => 86400, 'emoji' => 1, 'gravatar' => 1, 'commentIp' => 1, 'socialYt' => 0, 'socialYtThumb' => '' ); static function init() { $config = get_option( 'gdprpatronCfg' ); add_filter( 'pre_set_site_transient_update_plugins', array( 'gdprpatron', 'inject_update' ) ); add_filter( 'plugins_api', array( 'gdprpatron', 'get_info' ), 10, 3 ); $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); $sVersion = get_option( 'gdprpatronVersion' ); if( $sVersion === false ) { self::_activate(); } elseif ( version_compare( $sVersion, $aPluginversion['Version'] ) < 0 ) { self::_activate(); } add_action( 'admin_notices', array( 'gdprpatron', 'admin_notices' ) ); add_action( 'admin_bar_menu', array( 'gdprpatron', 'onAdminBarMenu' ), 90 ); add_action( 'admin_menu', array( 'gdprpatron', 'admin_menu' ) ); if ( !self::_check() ) { set_transient( 'gdprpatronInfo', array( 'msg' => __( 'Keine aktive Lizenz hinterlegt.', 'gdprpatron' ) ), 300 ); return; } add_action( 'shutdown', array( 'gdprpatron', 'post' ), 99999 ); add_action( 'wp_ajax_gdprpatronClearCache', array( 'gdprpatron', 'clear_cache_callback' ) ); add_action( 'wp_ajax_nopriv_gdprpatronClearCache', array( 'gdprpatron', 'clear_cache_callback' ) ); if( isset( $config['emoji'] ) && $config['emoji'] == '1' ) { remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_action( 'embed_head', 'print_emoji_detection_script' ); add_filter( 'tiny_mce_plugins', function( $aPlugs ) { return is_array( $aPlugs ) ? array_diff( $aPlugs, array( 'wpemoji' ) ) : array(); } ); } if( isset( $config['dnsPrefetch'] ) && $config['dnsPrefetch'] == '1' ) { add_filter( 'wp_resource_hints', function( $aUrls, $sRelation ) { return $sRelation == 'dns-prefetch' ? array() : $aUrls; } , 10, 2 ); } if( isset( $config['css'] ) && $config['css'] == '1' ) { add_filter( 'editor_stylesheets', array( 'gdprpatron', 'editor_stylesheets' ) ); } if( isset( $config['gravatar'] ) && $config['gravatar'] == '1' ) { add_filter( 'get_avatar', function( $sAvatar) { return preg_match( '#gravatar\.com#si', $sAvatar ) ? '' : $sAvatar; }, 10, 1 ); } if( isset( $config['commentIp'] ) && (int)$config['commentIp'] > 0 ) { add_filter( 'pre_comment_user_ip', array( 'gdprpatron', 'pre_comment_user_ip' ) ); } add_shortcode( 'yt', array( 'gdprpatron', 'shortcode_yt' ) ); } public static function shortcode_yt( $args, $sContent ) { $config = get_option( 'gdprpatronCfg' ); $args = shortcode_atts( array( 'v' => '', 'width' => '560', 'height' => '315', 'autoplay' => '1', 'args' => '', 'thumb' => '' ), $args ); if( empty( $args['v'] ) ) { return '<!--gdprpatron:error:3-->'; } if( $args['thumb'] == '' ) { if( $config !== false && isset( $config['socialYt'] ) ) { $args['thumb'] = $config['socialYt']; } else{ $args['thumb'] = '2'; } } if( !preg_match( '#^[a-z0-9_-]+$#Usi', $args['v'] ) && ( $aUrl = wp_parse_url( $args['v'] ) ) !== false ) { if( !isset( $aUrl['query'] ) ) { return '<!--gdprpatron:error:1-->'; } parse_str( $aUrl['query'], $aParams ); if( !isset( $aParams['v'] ) ) { return '<!--gdprpatron:error:2-->'; } $args['v'] = $aParams['v']; } switch( $args['thumb'] ) { case '1': $sThumbUrl = 'https://img.youtube.com/vi/' . $args['v'] . '/hqdefault.jpg'; $sFilename = gdprpatron::url2path( $sThumbUrl ) . '.jpg'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( !is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) || filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) <= strtotime( '-' . isset( $config['cache'] ) ? (int)$config['cache'] : (int)self::$cfgStd['cache'] . ' seconds' ) ) { $oReturn = wp_remote_get( $sThumbUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { $sBackgroundUrl = ( isset( $config['socialYtThumb'] ) && $config['socialYtThumb'] != '' ) ? $config['socialYtThumb'] : ''; } else{ $sBackgroundUrl = content_url( 'gdprpatron/' . $sFilename ); } } else{ $sBackgroundUrl = content_url( 'gdprpatron/' . $sFilename ); } break; case '2': default: $sBackgroundUrl = ( isset( $config['socialYtThumb'] ) && $config['socialYtThumb'] != '' ) ? $config['socialYtThumb'] : ''; } $sWidth = is_numeric( $args['width'] ) ? (int)$args['width'] . 'px' : esc_attr( $args['width'] ); $sHeight = is_numeric( $args['height'] ) ? (int)$args['height'] . 'px' : esc_attr( $args['height'] ); $sReturn = '<span style="display: flex;'; if( !empty( $sBackgroundUrl ) ) { $sReturn .= 'background-image: url(\'' . $sBackgroundUrl . '\');'; } $sReturn .= 'cursor: pointer; width: ' . $sWidth . '; height: ' . $sHeight . '; align-content: center; background-position: center; background-size: cover;" onclick="this.innerHTML = \'<iframe src=\\\'https://www.youtube-nocookie.com/embed/' . urlencode( $args['v'] ) .'?autoplay=' . (int)$args['autoplay'] . ( !empty( $args['args'] ) ? '&amp;' . $args['args'] : '' ) . '\\\' width=\\\'' . esc_attr( $sWidth ) .'\\\' height=\\\'' . esc_attr( $sHeight ) . '\\\' frameborder=\\\'0\\\'></iframe>\';"><img src="' . plugins_url( 'gfx/playbt.png', __FILE__ ) . '" style="width: 50px; height: 50px; margin: auto;" width="50" height="50" alt=""></span>'; return $sReturn; } static function _activate() { $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); $sOldVersion = get_option( 'gdprpatronVersion' ); if( $sOldVersion !== false ) { update_option( 'gdprpatronVersion', $aPluginversion['Version'] ); } else { add_option( 'gdprpatronVersion', $aPluginversion['Version'], '', false ); } $config = get_option ( 'gdprpatronCfg' ); if( $config === false ) { add_option( 'gdprpatronCfg', self::$cfgStd ); } } static function update_settings() { return true; } static function options_page() { echo '<div class="wrap"><h1>' . __( 'DSGVO Patron fr externe Ressourcen', 'gdprpatron' ) . '</h1>'; echo '<p>Mit dem DSGVO Patron Plugin werden die aufgefhrten externen Ressourcen zwischengespeichert, im Hintergrund aktualisiert und von dem eigenen Webspace in die WordPress-Seite eingebunden. So soll umgangen werden, dass der Webseiten-Besucher Ihrer Webseite die Inhalte unwissentlich von einem Drittanbieter ldt und die IP an den Drittanbieter bertragen wird.<br><br>Bitte beachten Sie unsere <a href="https://wpliftup.de/faq/ " target="_blank">FAQ</a>.</p>'; echo '<form method="post" action="options.php">'; settings_fields( 'gdprpatron-options' ); do_settings_sections( 'gdprpatron-options' ); $aCachingplugins = self::_has_caching(); if( count( $aCachingplugins ) > 0) { echo '<h3>' . __( 'Erkannte Cache-Plugins', 'gdprpatron' ) . '</h3><table class="form-table"><tbody>'; foreach( $aCachingplugins AS $sPlugin => $aFunc ) { echo '<tr><th scope="row">' . sprintf( __( '%s-Cache leeren', 'gdprpatron' ), esc_html( $sPlugin ) ) . ':</th><td><input type="checkbox" name="gdprpatron_clear[' . esc_attr( $sPlugin ) . ']" id="gdprpatron_clear[' . esc_attr( $sPlugin ) . ']" value="1" checked="checked"><p class="description" id="gdprpatroncfg-clear-' . strtolower( esc_attr( $sPlugin ) ) . '-description"><strong>' . __( 'Empfohlen', 'gdprpatron' ) . ':</strong> ' . sprintf( __( 'Cache des Plugins <b>%s</b> beim Speichern automatisch leeren.', 'gdprpatron' ), esc_html( $sPlugin ) ) . '</p></td></tr>'; } echo '</tbody></table>'; } echo '<h3>' . __( 'Hinweis', 'gdprpatron' ) . '</h3><table class="form-table"><tbody>'; echo '<tr><td scope="row" colspan="2"><p>Sollten Sie ein Cache-Plugin nutzen, lschen Sie bitte nach dem Speichern der nderungen den angelegten Cache. Bitte Testen Sie nach dem Sie nderungen speichern geklickt haben, ob die gewnschten Funktionen ausgefhrt werden. Schreiben Sie z.B. einen Test-Kommentar im ausgeloggten Zustand.<br><br>Bitte lschen Sie den Cache immer, wenn Sie etwas an den Einstellungen verndern.</p></td></tr>'; echo '</tbody></table>'; submit_button(); echo '</form></div>'; echo '<hr>'; echo '<h2>Zur Verfgung stehende Shortcodes</h2>'; echo '<h3>YouTube-Videos</h3>'; echo '<p><a href="https://wpliftup.de/faq/#YouTube-Video_einbinden_eigene_Videos" target="_blank">Wann / Warum sollte ich einen Shortcode verwenden?</a></p>'; echo '<p><b>ShortCode:</b> [yt v="https://www.youtube.com/watch?v=MK6TXMsvgQg" width="560" height="315" autoplay="1" thumb="2" args=""]</p>'; echo '<p><b>Parameter:</b></p>'; echo '<ul><li><b>v</b> die Video-ID / direkte URL von YouTube (Pflichtangabe)</li><li><b>width</b> die Breite des Videos (optional)</li><li><b>height</b> die Hhe des Videos (optional)</li><li><b>autoplay</b> mit Wert "1" wenn das Video nach dem ersten Klick abgespielt werden soll oder Wert "0" wenn ein zweiter Klick das Video starten soll. (optional)</li><li><b>thumb</b> Mgliche Werte: "1" um die Vorschau lokal zu speichern und anzuzeigen oder "2" um die eingestellte Standard-Vorschau anzuzeigen. (optional)</li><li><b>args</b> Experteneinstellung um weitere Parameter zu bergeben. Siehe <a href="https://developers.google.com/youtube/player_parameters?hl=de#Parameters" target="_blank">YouTube Player-Parameter</a> direkt in der YouTube Hilfe. (optional)</li></ul>'; } static function sanitize_settings( $setting ) { $config = get_option( 'gdprpatronCfg' ); foreach( self::$cfgStd AS $key => $val ) { if( !isset( $setting[$key] ) ) { $setting[$key] = ''; } } $setting['licenseKey'] = trim( $setting['licenseKey'] ); if( $setting['licenseKey'] != '* Lizenz gltig *' && !empty( $setting['licenseKey'] ) ) { if( self::_cleanup( $setting['licenseKey'] ) === false ) { add_settings_error( 'gdprpatron-options', esc_attr( 'settings_updated' ), __( 'Die angegebene Lizenz konnte nicht validiert werden und wurde daher nicht gespeichert!', 'gdprpatron' ), 'error' ); if( $config !== false && isset( $config['licenseKey'] ) ) { $setting['licenseKey'] = $config['licenseKey']; } else{ $setting['licenseKey'] = ''; } } } else{ $setting['licenseKey'] = $config['licenseKey']; } if( isset( $_POST['gdprpatron_clear'] ) ) { $aCachingplugins = self::_has_caching(); if( count( $aCachingplugins ) > 0 ) { foreach( $aCachingplugins AS $sPlugin => $aFunc ) { if( isset( $_POST['gdprpatron_clear'][$sPlugin] ) ) { call_user_func( $aFunc ); } } } } return $setting; } static function admin_menu() { $hook = add_options_page( __( 'DSGVO Patron', 'gdprpatron' ), __( 'DSGVO Patron', 'gdprpatron' ), 'manage_options', 'gdprpatron-options', array( 'gdprpatron', 'options_page' ) ); add_action( 'load-'.$hook, array( 'gdprpatron', 'update_settings' ) ); register_setting( 'gdprpatron-options', 'gdprpatronCfg', array( 'gdprpatron', 'sanitize_settings' ) ); add_settings_section( 'gdprpatron-options', __( 'Einstellungen', 'gdprpatron' ), array( 'gdprpatron', 'render_header' ), 'gdprpatron-options' ); add_settings_field( 'licenseKey', __( 'Lizenz', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'licenseKey' ) ); add_settings_field( 'css', __( 'CSS + Fonts lokal speichern', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'css' ) ); add_settings_field( 'js', __( 'JavaScripte lokal speichern', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'js' ) ); add_settings_field( 'cache', __( 'Lokale Dateien gltig fr', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'cache' ) ); add_settings_field( 'emoji', __( 'Externe Emoji-Datenbank nicht laden', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'emoji' ) ); add_settings_field( 'gravatar', __( 'Gravatar.com entfernen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'gravatar' ) ); add_settings_field( 'commentIp', __( 'IP aus Kommentaren krzen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'commentIp' ) ); add_settings_field( 'dnsPrefetch', __( 'DNS-Prefetch entfernen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'dnsPrefetch' ) ); add_settings_field( 'preconnect', __( '"preconnect" entfernen', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'preconnect' ) ); add_settings_field( 'socialYt', __( 'YouTube-Sicherung', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'socialYt' ) ); add_settings_field( 'socialYtThumb', __( 'YouTube Standard-Vorschau', 'gdprpatron' ) . ':', array( 'gdprpatron', 'render_field' ), 'gdprpatron-options', 'gdprpatron-options', array( 'field' => 'socialYtThumb' ) ); } static function render_field( $aArgs ) { $config = get_option( 'gdprpatronCfg' ); if (!isset($config[$aArgs['field']])) { switch($aArgs['field']) { default: $config[$aArgs['field']] = ''; } } switch($aArgs['field']) { case 'licenseKey': echo '<input type="text" style="width: 30em;" name="gdprpatronCfg[licenseKey]" id="gdprpatronCfg[licenseKey]" value="'; if( self::_check() ) { echo '* Lizenz gltig *'; } echo '" />'; if( self::_check() ) { $info = get_transient( 'gdprpatronInfo' ); echo '<p class="description" id="gdprpatroncfg-licenseKey-description">Identifikator: ' . $info['key'] . '</p>'; } break; case 'dnsPrefetch': echo '<input type="checkbox" name="gdprpatronCfg[dnsPrefetch]" id="gdprpatronCfg[dnsPrefetch]" '; checked( (int)$config['dnsPrefetch'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-dnsprefetch-description">Sogenannte "DNS-Prefetch" Meta-Angaben sorgen dafr, dass vom Browser DNS-Anfragen fr Domains erzeugt werden, welche eventuell verlinkt sind. Bei Aktivierung dieser Option werden diese DNS-Abfragen erst bei Klick auf einen Link erzeugt, was die Ladezeit der externen Seite um wenige Millisekunden verzgern kann.</p>'; break; case 'preconnect': echo '<input type="checkbox" name="gdprpatronCfg[preconnect]" id="gdprpatronCfg[preconnect]" '; checked( (int)$config['preconnect'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-preconnect-description">Sogenannte "preconnect" Meta-Angaben sorgen dafr, dass vom Browser Serververbindungen fr Domains erzeugt werden, welche eventuell verlinkt sind und fr ausgefhrte Scripte erst spter bentigt werden. Bei Aktivierung dieser Option werden diese Verbindungsaufforderungen entfernt, was die Ladezeit der externen Domain um wenige Millisekunden verzgern kann.</p>'; break; case 'css': echo '<input type="checkbox" name="gdprpatronCfg[css]" id="gdprpatronCfg[css]" '; checked( (int)$config['css'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-css-description">Es werden externe und interne CSS-Dateien die direkt im Theme eingebunden sind, zwischengespeichert um eine Verbindung zum Laden der Ressourcen von anderen Servern zu unterbinden. z. B.: Google Fonts</p>'; break; case 'socialYt': echo '<select name="gdprpatronCfg[socialYt]" id="gdprpatronCfg[socialYt]">'; echo '<option value="0"' . selected( $config['socialYt'], '0', false ) . '>' . __( 'ignorieren', 'gdprpatron' ) . '</option>'; echo '<option value="1"' . selected( $config['socialYt'], '1', false ) . '>' . __( 'sichern und Vorschau zwischenspeichern', 'gdprpatron' ) . '</option>'; echo '<option value="2"' . selected( $config['socialYt'], '2', false ) . '>' . __( 'sichern und Standard-Vorschau anzeigen', 'gdprpatron' ) . '</option>'; echo '</select>'; echo '<p class="description" id="gdprpatroncfg-socialyt-description">Eingebettete YouTube-Videos bermitteln eventuell diverse Daten, dies kann verhindert werden indem eine Schlatflche zum Abspielen vorgeschaltet, und damit die bermittlung gesichert wird. Der Besucher entscheidet dann per Klick auf die "Abspielen" Schaltflche selbst, ob und wann Daten an YouTube bermittelt werden. Die Vorschau zwischen zu speichern kann Urheberrechtsprobleme nach sich ziehen, die Verantwortung dies zu prfen unterliegt Ihnen als Plattformbetreiber.</p>'; break; case 'socialYtThumb': echo '<input type="text" style="width: 30em;" name="gdprpatronCfg[socialYtThumb]" id="gdprpatronCfg[socialYtThumb]" value="' . ( isset( $config['socialYtThumb'] ) ? esc_attr( $config['socialYtThumb'] ) : '' ) . '" />'; echo '<input type="button" name="gdprpatron-upload-btn" id="gdprpatron-upload-btn" data-for="gdprpatronCfg[socialYtThumb]" class="gdprpatron-upload-btn button-secondary" value="' . __( 'Select' ) . '">'; echo '<p class="description" id="gdprpatroncfg-socialyt-description">Dieses Bild wird als Vorschaubild gezeigt, wennn die Vorschau eines YouTube-Videos nicht geladen werden konnte oder die Anzeige erzwungen wird.</p>'; break; case 'js': echo '<input type="checkbox" name="gdprpatronCfg[js]" id="gdprpatronCfg[js]" '; checked( (int)$config['js'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-js-description">Wie bei den CSS-Dateien werden die JavasScript-Dateien lokal zwischengespeichert um eine Verbindung zum Laden der Ressourcen von anderen Servern zu unterbinden. z. B.: jQuery</p>'; break; case 'emoji': echo '<input type="checkbox" name="gdprpatronCfg[emoji]" id="gdprpatronCfg[emoji]" '; checked( (int)$config['emoji'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-emoji-description">WordPress ldt im Standard eine Emoji-Datenbank, die aus Textzeichen kleine Emojis wandelt und anzeigt. Diese kleinen Bilddateien der Emojis (Smilies) werden von einem externen Server geladen zu dem die IP-Adresse bertragen wird.</p>'; break; case 'cache': echo '<select name="gdprpatronCfg[cache]" id="gdprpatronCfg[cache]">'; echo '<option value="86400"' . selected( $config['cache'], 86400, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 1, 'gdprpatron' ), 1 ) . '</option>'; echo '<option value="172800"' . selected( $config['cache'], 172800, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 2, 'gdprpatron' ), 2 ) . '</option>'; echo '<option value="259200"' . selected( $config['cache'], 259200, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 3, 'gdprpatron' ), 3 ) . '</option>'; echo '<option value="345600"' . selected( $config['cache'], 345600, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 4, 'gdprpatron' ), 4 ) . '</option>'; echo '<option value="432000"' . selected( $config['cache'], 432000, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 5, 'gdprpatron' ), 5 ) . '</option>'; echo '<option value="518400"' . selected( $config['cache'], 518400, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 6, 'gdprpatron' ), 6 ) . '</option>'; echo '<option value="604800"' . selected( $config['cache'], 604800, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 7, 'gdprpatron' ), 7 ) . '</option>'; echo '<option value="1209600"' . selected( $config['cache'], 1209600, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 14, 'gdprpatron' ), 14 ) . '</option>'; echo '<option value="2419200"' . selected( $config['cache'], 2419200, false ) . '>' . sprintf( _n( '%s Tag', '%s Tage', 28, 'gdprpatron' ), 28 ) . '</option>'; echo '</select>'; break; case 'gravatar': echo '<input type="checkbox" name="gdprpatronCfg[gravatar]" id="gdprpatronCfg[gravatar]" '; checked( (int)$config['gravatar'], 1, true ); echo ' value="1" />'; echo '<p class="description" id="gdprpatroncfg-gravatar-description">Wer Kommentare in seiner Seite aktiviert hat, kennt die Gravartar-Bilder der Kommentierenden. Hat der Kommentar-Schreiber einen Gravatar-Account, wird sein Bild vom Gravatar-Server geladen und eingebunden (Hotlinking). Diese Einstellung verhindert die bermittlung der Daten an die gravatar.com Server.</p>'; break; case 'commentIp': echo '<select name="gdprpatronCfg[commentIp]" id="gdprpatronCfg[commentIp]">'; echo '<option value="0"' . selected( (int)$config['commentIp'], 0, false ) . '>' . sprintf( __( 'Nicht krzen (%s)', 'gdprpatron' ), $_SERVER['REMOTE_ADDR'] ) . '</option>'; echo '<option value="1"' . selected( (int)$config['commentIp'], 1, false ) . '>' . sprintf( __( 'Standard (%s)', 'gdprpatron' ), self::pre_comment_user_ip( $_SERVER['REMOTE_ADDR'], 1 ) ) . '</option>'; echo '<option value="2"' . selected( (int)$config['commentIp'], 2, false ) . '>' . sprintf( __( 'Stark (%s)', 'gdprpatron' ), self::pre_comment_user_ip( $_SERVER['REMOTE_ADDR'], 2 ) ) . '</option>'; echo '<option value="3"' . selected( (int)$config['commentIp'], 3, false ) . '>' . sprintf( __( 'Anonymisieren (%s)', 'gdprpatron' ), self::pre_comment_user_ip( $_SERVER['REMOTE_ADDR'], 3 ) ) . '</option>'; echo '</select>'; echo '<p class="description" id="gdprpatroncfg-commentip-description">Beim Absenden eines Kommentars wird die IP-Adresse durch einen gekrzten oder anonymisierten Inhalt ersetzt.</p>'; break; } } static function render_header( $args ) { if ( $args['id'] != 'gdprpatron-options' ) { return; } wp_enqueue_script( 'gdprpatron-lib', plugins_url( 'gfx/lib.js', __FILE__ ), array( 'jquery' ), false, true ); wp_enqueue_media(); } static function admin_notices() { if (!is_dir(ABSPATH.'wp-content/gdprpatron')) { $iMask = umask(0); if (!is_writable(ABSPATH.'wp-content') || mkdir(ABSPATH.'wp-content/gdprpatron', 0757, true) === false) { gdprpatron::setAdminNotice('error', 'Cacheverzeichnis kann nicht erstellt werden!<br />Es gibt 2 mgliche Lsungen:<br/><ol><li>Sie setzen das Verzeichnis '.ABSPATH.'wp-content fr Wordpress auf beschreibbar (z.B. per CHMOD 757)</li><li>oder Sie legen das Verzeichnis '.ABSPATH.'wp-content/gdprpatron an und setzen nur dieses fr Wordpress auf beschreibbar (z.B. per CHMOD 757).</li></ol>'); } umask( $iMask ); } elseif (!is_writable(ABSPATH.'wp-content/gdprpatron')) { gdprpatron::setAdminNotice('error', 'Das Cacheverzeichnis '.ABSPATH.'wp-content/gdprpatron muss fr Wordpress beschreibbar sein (z.B. CHMOD 757)!<br /><small>Dies gilt auch fr alle darin enthaltene Dateien und Verzeichnisse.</small>'); } $info = get_transient('gdprpatronInfo'); if ($info !== false && !empty($info['msg'])) { echo '<div class="notice notice-error"><p><a href="' . get_admin_url( null, 'admin.php?page=gdprpatron-options' ) . '">' . __( 'DSGVO Patron', 'gdprpatron' ) . '</a>: ' . esc_html($info['msg']) . '</p></div>'; } } static function setAdminNotice($sType, $sMessage) { echo '<div class="'.$sType.'"><p><b>Plugin DSGVO Patron:</b> '.$sMessage.'</p></div>'; } static function onDeactivation() { self::rmdirRecursive(ABSPATH.'wp-content/gdprpatron'); } static function rmdirRecursive($sDir) { if ( substr( $sDir, 0, strlen( ABSPATH.'wp-content/gdprpatron' ) ) != ABSPATH.'wp-content/gdprpatron' || substr_count( $sDir, '..' ) > 0 ) { return false; } if (($dh = @opendir($sDir)) === false) { return false; } while(($sObj = @readdir($dh)) !== false) { if ($sObj == '.' || $sObj == '..') { continue; } if (@is_dir($sDir.'/'.$sObj)) { gdprpatron::rmdirRecursive($sDir.'/'.$sObj); } else { @unlink($sDir.'/'.$sObj); } } return @rmdir($sDir); } static function onAdminBarMenu($wp_admin_bar) { if (!is_admin_bar_showing()) { return; } echo '<style>#wp-admin-bar-gdprpatron{display:list-item !important} #wp-admin-bar-gdprpatron .ab-icon{margin:0} #wp-admin-bar-gdprpatron .ab-icon:before{content:"\f182";top:.15rem;}</style>'; $wp_admin_bar->add_menu( array( 'id' => 'gdprpatron', 'href' => '#', 'parent' => 'top-secondary', 'title' => '<span class="ab-icon dashicons"></span>', 'meta' => array( 'title' => esc_html__('DSGVO Patron-Cache leeren', 'gdprpatron'), 'onclick' => 'jQuery(document).ready(function($) { var data = { "action": "gdprpatronClearCache", "security": "' . wp_create_nonce( 'gdprpatronCC' . date('Ym') ) . '" }; jQuery.post(ajaxurl, data, function(response) { alert(response); }); }); return false;' ) ) ); } static function parse($sBuffer) { $config = get_option( 'gdprpatronCfg' ); $return = ''; if( $config !== false && isset( $config['css'] ) && $config['css'] == '1' ) { $sBuffer = gdprpatron::localizeCss($sBuffer); $sBuffer = gdprpatron::localizeInlineCss($sBuffer); } if( $config !== false && isset( $config['js'] ) && $config['js'] == '1' ) { $sBuffer = gdprpatron::localizeScripts($sBuffer); } if( $config !== false && isset( $config['preconnect'] ) && $config['preconnect'] == '1' ) { if( ( $iCount = preg_match_all('#<link[^>]+rel=["\']preconnect["\']>#Umsi', $sBuffer, $aMatches ) ) > 0 ) { for( $i = 0; $i < $iCount; $i++ ) { $sBuffer = str_replace( $aMatches[0], '', $sBuffer ); } } } if( $config !== false && isset( $config['socialYt'] ) && $config['socialYt'] != '0') { if( ( $iCount = preg_match_all( '#<iframe[^>]+src=["\'](https?:)?//(www\.)?youtube(\-nocookie)?\.com/embed/([a-z0-9_-]+)(\?([^"]*))?".+</iframe>#Umsi', $sBuffer, $aMatches ) ) > 0 ) { for( $i = 0; $i < $iCount; $i++ ) { $sX = '[yt v="' . esc_attr( $aMatches[4][$i] ) . '"'; if( preg_match( '#width=["\']?([^\s"\']+)["\']?#si', $aMatches[0][$i], $aWidth ) ) { $sX .= ' width="' . esc_attr( $aWidth[1] ) . '"'; } if( preg_match( '#height=["\']?([^\s"\']+)["\']?#si', $aMatches[0][$i], $aHeight ) ) { $sX .= ' height="' . esc_attr( $aHeight[1] ) . '"'; } if( !empty( $aMatches[6][$i] ) ) { $sX .= ' args="' . urldecode( $aMatches[6][$i] ) . '"'; } $sX .= ']'; $sBuffer .= '<!-- ' . $sX . ' -->'; $sBuffer = str_replace( $aMatches[0][$i], do_shortcode( $sX ), $sBuffer ); } } } return (empty($return)) ? $sBuffer : $return; } static function localizeScripts($sBuffer) { $config = get_option( 'gdprpatronCfg' ); $return = ''; if(($iCount = preg_match_all('#<script[^>]+src=["\'](.+)["\']#Umsi', $sBuffer, $matches ) ) > 0 ) { $aScripts = array_unique( $matches[1] ); for( $i = 0; $i < count( $aScripts ); $i++ ) { if ( substr( $aScripts[$i], 0, 5 ) == 'data:' ) { continue; } if ( preg_match( '#(https?:)?//.+#si', $aScripts[$i], $aMatches ) ) { if( !isset( $aMatches[1] ) ) { $sUrl = 'http' . ( is_ssl() ? 's' : '' ) . ':' . $aScripts[$i]; } else { $sUrl = $aScripts[$i]; } if( gdprpatron::isLocalUrl( $sUrl ) ) { continue; } $sFilename = gdprpatron::url2path( $sUrl ) . '.js'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-' . isset( $config['cache'] ) ? (int)$config['cache'] : (int)self::$cfgStd['cache'] . ' seconds' ) ) { $sBuffer = str_replace( $aScripts[$i], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } else{ $oReturn = wp_remote_get( $aScripts[$i], array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { continue; } $sBuffer = str_replace( $aScripts[$i], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } } } } return (empty($return)) ? trim($sBuffer) : $return; } static function pre() { global $pagenow; if ( is_admin() || in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ) ) ) { return; } ob_start( array( 'gdprpatron', 'obcallback' ) ); } static function obcallback($sBuffer, $iPhase = 0) { $gz = false; if( strpos( $sBuffer, "\x1f\x8b\x08" ) === 0 ) { $gz = true; $sBuffer = gzdecode( $sBuffer ); } $sBuffer = gdprpatron::parse( $sBuffer ); return $gz ? gzencode( $sBuffer ) : $sBuffer; } static function post() { } static function url2path( $sUrl ) { $aParsed = wp_parse_url( $sUrl ); $sReturn = ''; $sReturn .= ( isset( $aParsed['scheme'] ) && !empty( $aParsed['scheme'] ) ? $aParsed['scheme'] . '/' : '' ); $sReturn .= ( isset( $aParsed['host'] ) && !empty( $aParsed['host'] ) ? $aParsed['host'] . '/' : '' ); $sReturn .= ( isset( $aParsed['path'] ) && !empty( $aParsed['path'] ) ? substr( preg_replace( '#[^\w\d/]+#si', '_', $aParsed['path'] ), 1 ) : '' ); if( isset( $aParsed['query'] ) && !empty( $aParsed['query'] ) ) { $sReturn .= '_' . preg_replace( '#\W+#si', '_', $aParsed['query'] ); } return $sReturn; } static function isLocalUrl( $sUrl ) { return ( self::$ignoreLocal === true && substr( $sUrl, 0, strlen( home_url() ) ) == home_url() ); } static function localizeInlineCss($sBuffer) { global $wp; if (!is_dir(ABSPATH.'/wp-content/gdprpatron') || !is_writable(ABSPATH.'/wp-content/gdprpatron')) { return $sBuffer; } $return = ''; if ( preg_match_all('#<style[^>]*>(.+)</style>#Umsi', $sBuffer, $matches) > 0) { for( $iEntry=0; $iEntry < count( $matches[1] ); $iEntry++ ) { $sFilename = 'inline-' . crc32( get_site_url() ) . '-' . crc32( $matches[1][$iEntry] ) . '.css'; if( is_file( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-24 hours' ) ) { $sBuffer = str_replace( $matches[1][$iEntry], file_get_contents( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ), $sBuffer ); } else{ file_put_contents( ABSPATH . '/wp-content/gdprpatron/' . $sFilename, $matches[1][$iEntry] ); self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, get_permalink() ); $sBuffer = str_replace( $matches[1][$iEntry], file_get_contents( ABSPATH . '/wp-content/gdprpatron/' . $sFilename ), $sBuffer ); } } } return $sBuffer; } static function editor_stylesheets( $aStylesheets ) { global $wp; if (!is_dir(ABSPATH.'/wp-content/gdprpatron') || !is_writable(ABSPATH.'/wp-content/gdprpatron')) { return $sBuffer; } for( $iEntry = 0; $iEntry < count( $aStylesheets ); $iEntry++ ) { if( preg_match( '#(https?:)?//.+#si', $aStylesheets[$iEntry], $aMatches ) ) { if( !isset( $aMatches[1] ) ) { $sUrl = 'http' . ( is_ssl() ? 's' : '' ) . ':' . $aStylesheets[$iEntry]; } else { $sUrl = $aStylesheets[$iEntry]; } if( gdprpatron::isLocalUrl( $sUrl ) ) { continue; } $sFilename = gdprpatron::url2path( $sUrl ) . '.css'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-24 hours' ) ) { $aStylesheets[$iEntry] = content_url( 'gdprpatron/' . $sFilename ); } else{ $oReturn = wp_remote_get( $sUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { continue; } self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, $sUrl ); $aStylesheets[$iEntry] = content_url( 'gdprpatron/' . $sFilename ); } } } return $aStylesheets; } static function localizeCss($sBuffer) { global $wp; if (!is_dir(ABSPATH.'/wp-content/gdprpatron') || !is_writable(ABSPATH.'/wp-content/gdprpatron')) { return $sBuffer; } $return = ''; if ( preg_match_all('#(<link\s[^>]*rel=["\']?stylesheet["\']?[^>]*>)#Umsi', $sBuffer, $matches) > 0) { for($i=0;$i<count($matches[0]);$i++) { if (($iCount = preg_match_all('#href=["\']?([^"\']+)["\']?#msi', $matches[0][$i], $matches2)) > 0) { for( $iEntry = 0; $iEntry < $iCount; $iEntry++ ) { if ( substr( $matches2[1][$iEntry], 0, 5 ) == 'data:' ) { continue; } if( preg_match( '#(https?:)?//.+#si', $matches2[1][$iEntry], $aMatches ) ) { if( !isset( $aMatches[1] ) ) { $sUrl = 'http' . ( is_ssl() ? 's' : '' ) . ':' . $matches2[1][$iEntry]; } else { $sUrl = $matches2[1][$iEntry]; } if( gdprpatron::isLocalUrl( $sUrl ) ) { continue; } $sFilename = gdprpatron::url2path( $sUrl ) . '.css'; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } if( is_file( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) && filemtime( ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) > strtotime( '-24 hours' ) ) { $sBuffer = str_replace( $matches2[1][$iEntry], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } else{ $oReturn = wp_remote_get( $sUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { continue; } self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, $sUrl ); $sBuffer = str_replace( $matches2[1][$iEntry], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); } } } } } } $return = ''; return (!empty($return)) ? $return : $sBuffer; } static function localizeCssUrls( $sPath, $sBase ) { if ( !( $sBuffer = file_get_contents( $sPath ) ) ) { return false; } $changed = false; if ( $iCount = preg_match_all( '#(@import[^;]+)?url\s*\(["\']?([^\)"\']+)["\']?\)#Usi', $sBuffer, $aMatches ) ) { for( $iEntry = 0; $iEntry < $iCount; $iEntry++ ) { $sUrl = ''; if ( substr( $aMatches[2][$iEntry], 0, 5 ) == 'data:' ) { continue; } if( preg_match( '#(https?:)?//.+#si', $aMatches[2][$iEntry], $aMatches2 ) ) { if( !isset( $aMatches2[1] ) ) { $sUrl = 'http' . ( substr( $sBase, 4, 1 ) == 's' ? 's' : '' ) . ':' . $aMatches[2][$iEntry]; } else { $sUrl = $aMatches[2][$iEntry]; } } else { $sUrl = WP_Http::make_absolute_url($aMatches[2][$iEntry], $sBase); } $sExt = pathinfo( $sUrl, PATHINFO_EXTENSION ); if( empty( $sUrl) || gdprpatron::isLocalUrl( $sUrl ) || in_array( $sExt, array( 'php', 'pl', 'cgi', 'exe', 'zip', 'apk' ) ) ) { $sBuffer = str_replace( $aMatches[2][$iEntry], $sUrl, $sBuffer ); $changed = true; continue; } if( empty( $sExt) && substr( trim( $aMatches[1][$iEntry] ), 0, 7 ) == '@import' ) { $sExt = 'css'; } $sFilename = gdprpatron::url2path( $sUrl ) . '.' . $sExt; if( !is_dir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ) ) ) { $iMask = umask(0); mkdir( ABSPATH . 'wp-content/gdprpatron/' . dirname( $sFilename ), 0757, true ); umask( $iMask ); } $oReturn = wp_remote_get( $sUrl, array( 'stream' => true, 'filename' => ABSPATH.'/wp-content/gdprpatron/' . $sFilename ) ); if( is_wp_error( $oReturn ) ) { $sBuffer = str_replace( $aMatches[2][$iEntry], $sUrl, $sBuffer ); $changed = true; continue; } $sBuffer = str_replace( $aMatches[2][$iEntry], content_url( 'gdprpatron/' . $sFilename ), $sBuffer ); if( !empty( $aMatches[1][$iEntry] ) ) { self::localizeCssUrls( ABSPATH.'/wp-content/gdprpatron/' . $sFilename, $sUrl ); } $changed = true; } } if ( $changed === true ) { file_put_contents( $sPath, $sBuffer ); } return true; } static function plugins_loaded() { if( !self::_check() ) { return; } $aCachingplugins = self::_has_caching(); if( isset( $aCachingplugins['Cachify'] ) ) { add_action( 'template_redirect', array( 'gdprpatron', 'pre' ), 1 ); } else { self::pre(); } } public static function inject_update($transient) { if ( empty( $transient->checked ) ) { return $transient; } $obj = self::get_update_info(); $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); if ( $obj !== false && isset( $obj->new_version ) && version_compare( $aPluginversion['Version'], $obj->new_version, '<' ) ) { $oInject = new stdClass; $oInject->id = -1; $oInject->slug = 'gdpr-patron'; $oInject->plugin = 'gdpr-patron/gdpr-patron.php'; $oInject->new_version = ( isset( $obj->new_version ) ? $obj->new_version : false ); $oInject->url = 'https://wpliftup.de/'; $oInject->package = ( isset( $obj->download_link ) ? $obj->download_link : false ); $oInject->tested = ( isset( $obj->tested ) ? $obj->tested : false ); $oInject->compatibility = new stdClass; $oInject->compatibility->scalar = new stdClass; $oInject->compatibility->scalar->scalar = ''; $transient->response['gdpr-patron/gdpr-patron.php'] = $oInject; } return $transient; } public static function get_info($false, $action, $arg) { if ( isset( $arg->slug ) && $arg->slug == 'gdpr-patron' ) { return self::get_update_info(); } return false; } public static function get_update_info() { $aPluginversion = get_file_data( __FILE__, array( 'Version' => 'Version' ), false ); $request = wp_remote_get( 'https://api.hinrichs-medien.de/wp/gdpr-patron/?version=' . $aPluginversion['Version'] ); if ( !is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) === 200 ) { return unserialize( $request['body'] ); } return false; } public static function clear_cache_callback() { if ( !check_ajax_referer( 'gdprpatronCC' . date('Ym'), 'security', false ) ) { echo __( 'Security mistake. Please the reload the page and try again. ', 'gdprpatron' ); wp_die(); } self::rmdirRecursive( ABSPATH . 'wp-content/gdprpatron' ); echo __( 'Cache successfully cleared', 'gdprpatron' ); wp_die(); } public static function pre_comment_user_ip( $sIp, $override = false ) { $config = get_option( 'gdprpatronCfg' ); if( $override !== false ) { $config['commentIp'] = (int)$override; } $sReturn = ''; if( preg_match( '#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#si', $sIp, $aMatches ) ) { switch( (int)$config['commentIp'] ) { case 1: $sReturn = $aMatches[1] . '.' . $aMatches[2] . '.' . $aMatches[3] . '.0'; break; case 2: $sReturn = $aMatches[1] . '.0.0.0'; break; case 3: $sReturn = '127.0.0.1'; break; } } elseif( ( (int)$config['commentIp'] == 1 && preg_match( '#^(([0-9a-f]+:){1,3}).+$#si', $sIp, $aMatches ) ) || ( (int)$config['commentIp'] == 2 && preg_match( '#^(([0-9a-f]+:){1,2}).+$#si', $sIp, $aMatches ) ) || ( (int)$config['commentIp'] == 3 && preg_match( '#^(([0-9a-f]+:){1}).+$#si', $sIp, $aMatches ) ) ) { $sReturn = $aMatches[1] . ':1'; } return $sReturn; } static function _has_caching() { $aPlugins = array(); if( class_exists( 'Cachify' ) && method_exists( 'Cachify', 'flush_total_cache' ) ) { $aPlugins['Cachify'] = array( 'Cachify', 'flush_total_cache' ); } return $aPlugins; } static function _cleanup( $m2 = false ) { $k0=get_file_data(__FILE__,array('Version' =>'Version'),false);$i1=get_option('gdprpatronCfg');if((!isset($i1['licenseKey'])||empty($i1['licenseKey']))&&$m2===false){delete_transient('gdprpatronInfo');return false;}$h3=wp_remote_get('https://api.hinrichs-medien.de/wp/gdpr-patron/license/?version='.urlencode($k0['Version']).'&licenseKey='.urlencode($m2!==false?$m2:$i1['licenseKey']).'&url='.urlencode(get_site_url()));if(is_wp_error($h3)){if($m2===false){set_transient('gdprpatronInfo',array('key' =>'','msg' =>'Lizenzabgleich fehlgeschlagen (Abruf fehlgeschlagen).'),300);}return false;}if(empty($h3['body'])||($k4=@json_decode($h3['body'],true))===false){if($m2===false){set_transient('gdprpatronInfo',array('key' =>'','msg' =>'Lizenzabgleich fehlgeschlagen (unerwartete Antwort).'),300);}return false;}if(empty($k4['key'])){if($m2===false){set_transient('gdprpatronInfo',$k4,3600);}return false;}set_transient('gdprpatronInfo',$k4,648000);return true; } static function _check($g3 = true) { $b0=get_option('gdprpatronCfg');if(!isset($b0['licenseKey'])||empty($b0['licenseKey'])){return false;}$q1=get_option('_transient_timeout_gdprpatronInfo');if($q1!==false &&((int)$q1>time()+658000 ||(int)$q1<=time())){delete_transient('gdprpatronInfo');}$c2=get_transient('gdprpatronInfo');if($c2===false){self::_cleanup();if($g3===true){return self::_check(false);}return false;}if(empty($c2['key'])){return false;}if($c2['key']!=md5(trim($b0['licenseKey']).'ifno')){set_transient('gdprpatronInfo',array('key' =>false,'msg' =>'Lizenz ungltig.'),7200);return false;}return true; } } add_action( 'plugins_loaded', array( 'gdprpatron', 'plugins_loaded' ), 0 ); add_action( 'init', array( 'gdprpatron', 'init' ) ); register_deactivation_hook( __FILE__, array( 'gdprpatron', 'onDeactivation' ) );

Function Calls

defined 1

Variables

None

Stats

MD5 5182638324ab1eeb5369ed58c86abf3b
Eval Count 0
Decode Time 364 ms