<?php
/* Include Files ***************************/
require_once('../db-config.php');
require_once('../inc/lib-compat-class.php');
require_once('../inc/lib-db-class.php');
require_once('../inc/lib-login-class.php');
/*******************************************/
global $rSdb;

$user	= new userManagement();
if(  !$user->_logged_in  )
	die(__('Access denied.','recipeshelf'));

if( ! check_ajax_referer('dbinfo', false) )
	die(__('Security Alert: Direct access not permitted!','recipeshelf'));

$noR = $rSdb->fetchVal("SELECT COUNT(name) FROM {$rSdb->DBrecipes}");
$noI = $rSdb->fetchVal("SELECT COUNT(DISTINCT(object)) FROM {$rSdb->DBobjects} WHERE type = '1'");
$noD = $rSdb->fetchVal("SELECT COUNT(object) FROM {$rSdb->DBobjects} WHERE type = '1'");

$tags= $rSdb->fetchArr("SELECT tags FROM {$rSdb->DBrecipes};");
$allT = array();
$tmpT = array();
foreach( $tags as $t ){
    $tmpT = explode(',',$t->tags);
    $allT = array_merge($allT,$tmpT);
}

echo '<p><span class="rs-dbinfo">'.__('Number of recipes:','recipeshelf').'</span> '.(int)$noR.'</p>';
echo '<p><span class="rs-dbinfo">'.__('Number of tags:','recipeshelf').'</span> '.count($allT).'</p>';
echo '<p><span class="rs-dbinfo">'.__('Number of different ingredients used:','recipeshelf').'</span> '.(int)$noI.'</p>';
?>