0 || !empty($url)) { $video_info = null; // A. 优先通过 ID 精准查询 if ($id > 0) { $res = $db->query("SELECT resource_site FROM videos WHERE id = $id LIMIT 1"); if ($res && $res->num_rows > 0) $video_info = $res->fetch_assoc(); } // B. 其次通过 URL 模糊反查 elseif (!empty($url)) { $filename = basename(parse_url($url, PHP_URL_PATH)); if (strlen($filename) > 5) { $safe_name = $db->real_escape_string($filename); $res = $db->query("SELECT resource_site FROM videos WHERE vod_play_url LIKE '%$safe_name%' LIMIT 1"); if ($res && $res->num_rows > 0) $video_info = $res->fetch_assoc(); } } // C. 查询水印规则表 if ($video_info && !empty($video_info['resource_site'])) { $source_key = 'senlin'; $rule = $db->query("SELECT * FROM watermark_rules WHERE source_flag = '$source_key' LIMIT 1")->fetch_assoc(); if ($rule) { // 生成定位样式 $pos_style = ""; switch ($rule['position']) { case 'tl': $pos_style = "top: {$rule['margin_y']}; left: {$rule['margin_x']};"; break; case 'tr': $pos_style = "top: {$rule['margin_y']}; right: {$rule['margin_x']};"; break; case 'bl': $pos_style = "bottom: {$rule['margin_y']}; left: {$rule['margin_x']};"; break; case 'br': $pos_style = "bottom: {$rule['margin_y']}; right: {$rule['margin_x']};"; break; default: $pos_style = "top: 2%; right: 2%;"; } // 生成背景样式 (1=高斯模糊, 2=图片覆盖) $bg_style = ""; if ($rule['mode'] == 1) { $bg_style = "backdrop-filter: blur(12px) saturate(180%); -webkit-backdrop-filter: blur(12px) saturate(180%); background: rgba(255,255,255,0.05); box-shadow: 0 0 10px rgba(0,0,0,0.1) inset;"; } else { $bg_style = "background-image: url('{$rule['cover_img']}'); background-size: contain; background-repeat: no-repeat; background-position: center;"; } // 注入 CSS (z-index: 10 确保在视频之上但在控制栏之下) $mask_css = " #smart-mask { position: absolute; {$pos_style} width: {$rule['width']}; height: {$rule['height']}; z-index: 10; pointer-events: none; /* 让点击穿透,不影响视频操作 */ border-radius: 4px; overflow: hidden; {$bg_style} mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%), linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%); -webkit-mask-image: linear-gradient(black, black); display: block !important; }"; $mask_html = '
'; } } } echo ""; ?>