<commit_before><?php
require_once("include/datetime.php");


function ping_init(&$a) {

	header("Content-type: text/xml");
	
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
		<result>";

	$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";

	if(local_user()){

		// Different login session than the page that is calling us. 

		if(intval($_GET['uid']) && intval($_GET['uid']) != local_user()) {
			echo '<invalid>1</invalid></result>';
			killme();
		}

		$firehose = intval(get_pconfig(local_user(),'system','notify_full'));

		$t = q("select count(*) as total from notify where uid = %d and seen = 0",
			intval(local_user())
		);
		if($t && intval($t[0]['total']) > 49) {
			$z = q("select * from notify where uid = %d
				and seen = 0 order by date desc limit 0, 50",
				intval(local_user())
			);
			$sysnotify = $t[0]['total'];
		}
		else {
			$z1 = q("select * from notify where uid = %d
				and seen = 0 order by date desc limit 0, 50",
				intval(local_user())
			);

			$z2 = q("select * from notify where uid = %d
				and seen = 1 order by date desc limit 0, %d",
				intval(local_user()),
				intval(50 - intval($t[0]['total']))
			);
			$z = array_merge($z1,$z2);
			$sysnotify = 0; // we will update this in a moment
		}



		$tags = array();
		$comments = array();
		$likes = array();
		$dislikes = array();
		$friends = array();
		$posts = array();

		$home = 0;
		$network = 0;

		$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`, 
				`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, 
				`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` 
				FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
				WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
				 `item`.`deleted` = 0 AND `item`.`uid` = %d 
				ORDER BY `item`.`created` DESC",
			intval(local_user())
		);

		if(count($r)) {		

			foreach ($r as $it) {

				if($it['wall'])
					$home ++;
				else
					$network ++;
<commit_msg>network_ping hook for next generation "page"/"forums" plugin<commit_after><?php
require_once("include/datetime.php");


function ping_init(&$a) {

	header("Content-type: text/xml");
	
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
		<result>";

	$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";

	if(local_user()){

		// Different login session than the page that is calling us. 

		if(intval($_GET['uid']) && intval($_GET['uid']) != local_user()) {
			echo '<invalid>1</invalid></result>';
			killme();
		}

		$firehose = intval(get_pconfig(local_user(),'system','notify_full'));

		$t = q("select count(*) as total from notify where uid = %d and seen = 0",
			intval(local_user())
		);
		if($t && intval($t[0]['total']) > 49) {
			$z = q("select * from notify where uid = %d
				and seen = 0 order by date desc limit 0, 50",
				intval(local_user())
			);
			$sysnotify = $t[0]['total'];
		}
		else {
			$z1 = q("select * from notify where uid = %d
				and seen = 0 order by date desc limit 0, 50",
				intval(local_user())
			);

			$z2 = q("select * from notify where uid = %d
				and seen = 1 order by date desc limit 0, %d",
				intval(local_user()),
				intval(50 - intval($t[0]['total']))
			);
			$z = array_merge($z1,$z2);
			$sysnotify = 0; // we will update this in a moment
		}



		$tags = array();
		$comments = array();
		$likes = array();
		$dislikes = array();
		$friends = array();
		$posts = array();

		$home = 0;
		$network = 0;

		$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`, 
				`item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, 
				`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` 
				FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
				WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
				 `item`.`deleted` = 0 AND `item`.`uid` = %d 
				ORDER BY `item`.`created` DESC",
			intval(local_user())
		);

		if(count($r)) {		

			call_hooks('network_ping', array('items' => $r));

			foreach ($r as $it) {

				if($it['wall'])
					$home ++;
				else
					$network ++;

{'fraction_non_alphanumeric': 0.22044804575786464, 'fraction_numerical': 0.016682554814108675, 'mean_word_length': 3.3046153846153845, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 4, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5163279', 'n_tokens_mistral': 1848, 'n_tokens_neox': 1547, 'n_words': 384}