3v4l.org

run code in 300+ PHP versions simultaneously
<?php $token = '20MI'; $token_h = 'https://www.20minutos.es/hombre'; $valid_medios_blacklisted_tokens = array( 'UUEE_234_934_884' => array('telva.com','www.telva.com'), '20MI' => array('www.businessinsider.es') ); $valid_medios_blacklisted_tokens_paths = array( '20MI' => array('www.20minutos.es/mujer/*'), ); if (isset($valid_medios_blacklisted_tokens[$token])) { echo "ALLOW"; } // Está en la lista del dominio en lista negra el referer. // Comprobar si el dominio+path esta en la lista blanca. elseif (isset($valid_medios_blacklisted_tokens_paths[$token])) { $allow = true; if (empty($token_h)) { $allow = false; } else { foreach ($valid_medios_blacklisted_tokens_paths[$token] as $valid) { // Comprobar si contiene if (strpos($valid, '*') !== false) { $valid = rtrim($valid, '*'); $valid = rtrim($valid, '/'); if (strpos($token_h, $valid) !== false) { $allow = true; } else { $allow = false; } } // Comprobar si es igual else { $fixed_token_h = rtrim($token_h, '/'); $fixed_token_h = str_replace(['https://', 'http://'], '', $fixed_token_h); if ($fixed_token_h === $valid) { $allow = true; } else { $allow = false; } } } // Es bueno lo dejamos pasar if (!empty($allow)) { echo "ALLOW"; } else { echo "DISALLOW"; } } } else { echo "DISALLOW"; }
Output for git.master, git.master_jit
ALLOW

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.73 ms | 707 KiB | 4 Q