<?php

/**
 *
 *  Library of functions about management of players
 *
 * @author flabadens
 * @version 1.0
 * @see none
 * @todo favorite team of a player
 * 
 *
 */

if ($versionmobile){
    include_once("../config.php3");
    $RACINE_DIR="../";
    $CORE = "";
}
else {
    include_once("config.php3");
    $RACINE_DIR="";
}

//include_once($RACINE_DIR.$MOBILE_DIR."configMobile.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_db.php3");
include_once($RACINE_DIR.$BIB_DIR_FROM_RACINE."bib_generic.php3");


/**
 * Return the current session of pronos
 * 
 * @return array assoc
 */
function getCurrentSession () {

    $now = date( "Y-m-d H:i:s" );
    $rows = main_db_query( "SELECT * FROM Tours WHERE ShowTime <= '".$now."' AND EndTime >= '".$now."'" );
    return db_fetch_assoc( $rows );
    
}


/**
 * Return the number of players connected atm
 * 
 * @return int
 */
function getConnectedNumber () {
    
    $requ_connexion = "select count(Id) FROM Sessions WHERE MemberId>-1";
    $rows = main_db_query( $requ_connexion );
    $row = db_fetch_row( $rows );
    return $row[0];

}


/**
 * Return the favorite team of a player
 *
 * @param int $id
 * @return array representative of the favorite team
 */
function getTeamById ( $id ) {
    return db_fetch_assoc( main_db_query("SELECT * FROM Teams WHERE Id='".$id."'") );
}

/**
 * Return the mobile of the user
 *
 * @return String type of mobile or false if it's a desktop browser
 * @see http://detectmobilebrowsers.mobi/
 * 
 */
function isOnMobile () {
    require_once('mobile_device_detect.php');
    return mobile_device_detect();
}


?>
