<div class="content_box">
<div class="content_box_header">
<div class="title">New Pages</div>
</div>
<!-- Available NOTES 
Page Submitted (Page Title)
Page Accepted
Page status changed
Page rank (Daily, Weekly, Monthly)
Custom page notes
-->

<?php 
$res = mysql_query ("SELECT p.Id AS pid, p.PageId, p.Link, p.Title, p.Public, u.Username, ups.UserId as uid 
	FROM page AS p 
	LEFT OUTER JOIN user_page_submission AS ups ON p.Id = ups.PageId 
	LEFT OUTER JOIN user AS u ON ups.UserId = u.Id 
	WHERE p.Verified = 0  
	GROUP BY p.Id ORDER BY Updated DESC LIMIT 0,5 ") or die ("error");
$nr = mysql_num_rows ($res);

while ($nr>0) {
	$row = mysql_fetch_array ($res);
	extract ($row);

	$url = 'http://graph.facebook.com/';
	$pageUrl = "" . $url . $PageId . "";
	// create curl resource
	$ch = curl_init();
	// set url
	curl_setopt($ch, CURLOPT_URL, $pageUrl);
	curl_setopt($ch,CURLOPT_HTTPHEADER,array ("Content-Type: text/xml; charset=utf-8"));
	//return the transfer as a string
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

	// $output contains the output string
	$output = curl_exec($ch);
	//$output = utf8_encode($output);
	//echo $output . "<br />";

	$param = json_decode($output, true);
	
	$Link = $param['link'];
	$Title = $param['name'];
	$Image = $param['picture'];
	$Fans = $param['fan_count'];
	$Category = str_replace('_', ' ', $param['category']);
	
	if ($Public != '1') { ?>
    <div class="private_content_box">
    <?php } ?>
    <div class="content_box_item">
    
	<div class="avatar"><a href="?page=page_non&id=<?php echo $pid;?>"><img src="<?php echo $Image; ?>" alt="<?php echo $Title; ?>" width="50" height="50" /></a></div>
	
    <div class="description">
	<div class="title"><?php echo $Title; ?><a href="<?php echo $Link;?>">- Visit page</a></div>
    <div class="category">Submitted by: <?php echo $Username; ?></div>	
    </div>
    
    </div>
	<?php if ($Public != '1') { ?>
    </div>
    <?php } ?>
	<?php
    $nr--;	
}
?>

<div class="content_box_footer">
<a href="?page=pages_non">View All</a>
</div>

</div>

