Просмотр файла katrinka.ru/admin/upd_posts.php

Размер файла: 820B
<?php
  include '../wap/config.php';
	$xtime=mktime(0,0,0,6,3,2003);
  if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) {
    echo ("пЫЙВЛБ РПДЛМАЮЕОЙС Л вд!\n");
	exit;
  }
	$res=pg_query($conn, "select id,posts from users where moder=0 order by id;");
	$rows=pg_numrows($res);
	for ($i=0; $i<$rows; $i++) {
		$aposts=0;
		$id=pg_result($res,$i,0);
		$posts=pg_result($res,$i,1);
		$resp=pg_query($conn,"select count(*) from chat where fr_u='$id' and time < '$xtime';");
		if (pg_numrows($resp)) {
			$aposts=pg_result($resp,0,0);
			$posts=$posts+$aposts;
		}
		if ($aposts) pg_query($conn,"update users set posts='$posts' where id='$id';");
		pg_query($conn,"delete from chat where fr_u='$id' and time < '$xtime';");
		print $id;
	}
	pg_close($conn);
	print "Ok";
?>