<commit_before><?

	if ($_GET["debug"]) {
		define('DEFAULT_ERROR_LEVEL', E_ALL);
	} else {
		define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
	}

	require_once 'config.php';
	require_once 'db-prefs.php';
	require_once 'compat.php';

	require_once 'magpierss/rss_utils.inc';

	define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');

	function purge_feed($link, $feed_id, $purge_interval) {

		if (DB_TYPE == "pgsql") {
			db_query($link, "DELETE FROM ttrss_user_entries WHERE
				marked = false AND feed_id = '$feed_id' AND
				(SELECT date_entered FROM ttrss_entries WHERE
					id = ref_id) < NOW() - INTERVAL '$purge_interval days'");
		} else {
			db_query($link, "DELETE FROM ttrss_user_entries WHERE
				marked = false AND feed_id = '$feed_id' AND
				(SELECT date_entered FROM ttrss_entries WHERE 
					id = ref_id) < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
		}
	}

	function global_purge_old_posts($link, $do_output = false) {

		$result = db_query($link, 
			"SELECT id,purge_interval,owner_uid FROM ttrss_feeds");

		while ($line = db_fetch_assoc($result)) {

			$feed_id = $line["id"];
			$purge_interval = $line["purge_interval"];
			$owner_uid = $line["owner_uid"];

			if ($purge_interval == 0) {
			
				$tmp_result = db_query($link, 
					"SELECT value FROM ttrss_user_prefs WHERE
						pref_name = 'PURGE_OLD_DAYS' AND owner_uid = '$owner_uid'");

				if (db_num_rows($tmp_result) != 0) {			
					$purge_interval = db_fetch_result($tmp_result, 0, "value");
				}
			}

			if ($do_output) {
				print "<feed id='$feed_id' p_intl='$purge_interval'/>";
			}

			if ($purge_interval > 0) {
				purge_feed($link, $feed_id, $purge_interval);
			}<commit_msg>change debug output in purge functions<commit_after><?

	if ($_GET["debug"]) {
		define('DEFAULT_ERROR_LEVEL', E_ALL);
	} else {
		define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
	}

	require_once 'config.php';
	require_once 'db-prefs.php';
	require_once 'compat.php';

	require_once 'magpierss/rss_utils.inc';

	define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');

	function purge_feed($link, $feed_id, $purge_interval, $debug = false) {

		$rows = -1;

		if (DB_TYPE == "pgsql") {
			$result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
				marked = false AND feed_id = '$feed_id' AND
				(SELECT date_entered FROM ttrss_entries WHERE
					id = ref_id) < NOW() - INTERVAL '$purge_interval days'");

			$rows = pg_affected_rows($result);
			
		} else {
			$result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
				marked = false AND feed_id = '$feed_id' AND
				(SELECT date_entered FROM ttrss_entries WHERE 
					id = ref_id) < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
			$rows = mysql_affected_rows($link);

		}

		if ($debug) {
			print "Purged feed $feed_id ($purge_interval): deleted $rows articles\n";
		}
	}

	function global_purge_old_posts($link, $do_output = false) {

		$result = db_query($link, 
			"SELECT id,purge_interval,owner_uid FROM ttrss_feeds ORDER BY id");

		while ($line = db_fetch_assoc($result)) {

			$feed_id = $line["id"];
			$purge_interval = $line["purge_interval"];
			$owner_uid = $line["owner_uid"];

			if ($purge_interval == 0) {
			
				$tmp_result = db_query($link, 
					"SELECT value FROM ttrss_user_prefs WHERE
						pref_name = 'PURGE_OLD_DAYS' AND owner_uid = '$owner_uid'");

				if (db_num_rows($tmp_result) != 0) {			
					$purge_interval = db_fetch_result($tmp_result, 0, "value");
				}
			}

			if ($do_output) {
//				print "Feed $feed_id: purge interval = $purge_interval\n";
			}

			if ($purge_interval > 0) {
				purge_feed($link, $feed_id, $purge_interval, $do_output);
			}
{'fraction_non_alphanumeric': 0.14442613948380012, 'fraction_numerical': 0.0030203185063152112, 'mean_word_length': 4.073816155988858, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '709258', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1344, 'n_words': 281}