<?
require_once('../connect/connect.php');
mysql_query("UPDATE board SET vip_data='0000-00-00 00:00:00', vip='0', vip_sort='0' WHERE vip_data < NOW()");


$directory='../foto_vip';
$dir = opendir($directory);
while(($file = readdir($dir)))
	{
	if (is_file ($directory."/".$file))
		{
		$a=explode("m", $file);
		$k=intval($a[0]);
		if($k)
		$b[]=$k;
		}
	}
closedir ($dir);

if($b)
	{
	$in=implode(", ",$b);
	//echo $in.'<br>';
		
	$r=mysql_query("SELECT id FROM board WHERE vip != 0 AND id IN (".$in.")");
	while($rr=mysql_fetch_array($r))
		{
		$d[]=$rr['id'];
		}
		
	foreach ($b as $bb)
		{
		if(!($d && in_array($bb, $d)))
			{
			$mid='../foto_vip/'.$bb.'m.jpg';
			//echo $mid.'<br>';
			if (file_exists($mid) && is_file($mid)) unlink($mid);
			}
		}
	}

?> 
