Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- START QUERY 1: AKUN PRIVILEGED YANG SUDAH LAMA TIDAK AKTIF
- SET @stale_login_days := 180;
- SET @stale_editorial_days := 365;
- -- Query 1: enabled privileged accounts with stale login and little recent
- -- editorial evidence. OJS core does not retain enough HTTP history here to
- -- identify who injected a link, the source IP, or the previous field value.
- WITH
- privileged_roles AS (
- SELECT
- uug.user_id,
- GROUP_CONCAT(DISTINCT ug.context_id ORDER BY ug.context_id) AS context_ids,
- GROUP_CONCAT(DISTINCT ug.role_id ORDER BY ug.role_id) AS role_ids
- FROM user_user_groups uug
- JOIN user_groups ug ON ug.user_group_id = uug.user_group_id
- WHERE ug.role_id IN (1, 16, 17, 4097, 2097152)
- GROUP BY uug.user_id
- ),
- stages AS (
- SELECT
- sa.user_id,
- COUNT(*) AS stage_assignments
- FROM stage_assignments sa
- GROUP BY sa.user_id
- ),
- editorial AS (
- SELECT
- el.user_id,
- COUNT(*) AS editorial_events,
- MAX(el.date_logged) AS last_editorial_event
- FROM event_log el
- GROUP BY el.user_id
- )
- SELECT
- u.user_id,
- u.username,
- u.date_registered,
- u.date_last_login,
- TIMESTAMPDIFF(DAY, u.date_last_login, CURRENT_DATE) AS days_since_last_login,
- r.context_ids,
- r.role_ids,
- COALESCE(s.stage_assignments, 0) AS stage_assignments,
- COALESCE(e.editorial_events, 0) AS editorial_events,
- e.last_editorial_event
- FROM users u
- JOIN privileged_roles r ON r.user_id = u.user_id
- LEFT JOIN stages s ON s.user_id = u.user_id
- LEFT JOIN editorial e ON e.user_id = u.user_id
- WHERE u.disabled = 0
- AND u.date_last_login < DATE_SUB(CURRENT_DATE, INTERVAL @stale_login_days DAY)
- AND (
- COALESCE(e.editorial_events, 0) = 0
- OR e.last_editorial_event < DATE_SUB(CURRENT_DATE, INTERVAL @stale_editorial_days DAY)
- )
- ORDER BY days_since_last_login DESC, u.user_id;
- -- END QUERY 1
- -- Query 2: suspicious markers or multiple links still present in public-facing
- -- journal/publication fields. It reports fingerprints, not raw content.
- -- START QUERY 2: KONTEN PUBLIK SAAT INI
- SET @min_links_current_content := 2;
- WITH public_content AS (
- SELECT
- 'journal' AS content_type,
- js.journal_id AS context_id,
- js.journal_id AS object_id,
- j.path AS journal_path,
- js.setting_name,
- js.locale,
- js.setting_value
- FROM journal_settings js
- JOIN journals j ON j.journal_id = js.journal_id
- WHERE js.setting_name IN (
- 'pageFooter',
- 'additionalHomeContent',
- 'customHeaders',
- 'searchDescription',
- 'description'
- )
- UNION ALL
- SELECT
- 'publication' AS content_type,
- s.context_id,
- ps.publication_id AS object_id,
- j.path AS journal_path,
- ps.setting_name,
- ps.locale,
- ps.setting_value
- FROM publication_settings ps
- JOIN publications p ON p.publication_id = ps.publication_id
- JOIN submissions s ON s.submission_id = p.submission_id
- JOIN journals j ON j.journal_id = s.context_id
- WHERE ps.setting_name IN ('abstract', 'title', 'subtitle')
- ),
- signals AS (
- SELECT
- c.*,
- GREATEST(
- 0,
- (
- CHAR_LENGTH(LOWER(COALESCE(c.setting_value, '')))
- - CHAR_LENGTH(REPLACE(LOWER(COALESCE(c.setting_value, '')), 'http', ''))
- ) DIV 4
- ) AS link_count,
- REGEXP_SUBSTR(
- LOWER(COALESCE(c.setting_value, '')),
- 'bermain[[:space:]]+slot|slot[[:space:]]*(gacor|online|deposit|777)|slot[0-9]+|gacor|togel|casino|judi|jackpot|nota[0-9]+|toto[[:space:]]*[0-9a-z]|deposit[[:space:]]*[0-9]+'
- ) AS matched_marker
- FROM public_content c
- )
- SELECT
- content_type,
- context_id,
- object_id,
- journal_path,
- setting_name,
- locale,
- CHAR_LENGTH(COALESCE(setting_value, '')) AS content_chars,
- link_count,
- matched_marker,
- SHA2(COALESCE(setting_value, ''), 256) AS content_fingerprint
- FROM signals
- WHERE matched_marker IS NOT NULL
- OR link_count >= @min_links_current_content
- ORDER BY
- (matched_marker IS NOT NULL) DESC,
- link_count DESC,
- content_type,
- context_id,
- object_id,
- setting_name,
- locale;
- -- END QUERY 2
Advertisement
Add Comment
Please, Sign In to add comment