}
        }
        $cont++;
    }
    return array('series_data' => implode(',', $seriesData), 'series_data_min' => $seriesDataMin, 'series_data_max' => $seriesDataMax, 'x_axis' => implode(',', $xAxisCategories));
}
//Países
$countries = array();
$query = 'SELECT id_country, code, nombre, name, idiom FROM ' . DB_FACEBOOK_PREFIX . 'country_3_1 ORDER BY 1;';
$que = db_query($query, array());
while ($fila = mysql_fetch_assoc($que)) {
    $countries[$fila['id_country']] = array('code' => $fila['code'], 'name' => $fila['nombre'], 'name_en' => $fila['name'], 'idiom' => $fila['idiom']);
}
$query = "SELECT id_city, name, slug, id_country FROM " . DB_FACEBOOK_PREFIX . "city_3_1 WHERE active_fb_get_data = 1 AND active = 1;";
$que_cities = db_query($query, array());
$cities_last_update = get_city_date_last_update(mysql_num_rows($que_cities));
while ($city = mysql_fetch_assoc($que_cities)) {
    $id_city = $city['id_city'];
    $name = $city['name'];
    $slug = $city['slug'];
    $country_code = $countries[$city['id_country']]['code'];
    $idiom = !empty($countries[$city['id_country']]['idiom']) ? $countries[$city['id_country']]['idiom'] : 'NULL';
    $country_code = $countries[$city['id_country']]['code'];
    $grow_90 = getCrecimiento($id_city, $cities_last_update, 90);
    $query = "SELECT total_user, total_female, total_male FROM " . DB_FACEBOOK_PREFIX . "record_city_3_1 WHERE id_city = \$1 AND date = '\$2';";
    $que_audience = db_query($query, array($city['id_city'], $cities_last_update));
    if ($audience = mysql_fetch_assoc($que_audience)) {
        $total_user = $audience['total_user'];
        $total_female = $audience['total_female'];
        $total_male = $audience['total_male'];
    }
<?php

$page = 1;
if (isset($_POST['page']) && is_numeric($_POST['page'])) {
    if ($_POST['page'] < 1) {
        $page = 1;
    } elseif ($_POST['page'] > ceil(MAX_LIST_CITY_COUNT / PAGER_PP)) {
        $page = ceil(MAX_LIST_CITY_COUNT / PAGER_PP);
    } else {
        $page = $_POST['page'];
    }
}
$ultimas_12_semanas = get_city_date_last_update(5 + 8);
//SQL para obtener el ranking de países de la última fecha
$sql = "SELECT fc.id_city id_city, fc.name nombre, total_user, total_female, total_male, c.id_country, c.code code, c.name name, c.nombre countryName\n\t\t\t\t\tFROM record_city rc \n\t\t\t\t\t\tJOIN facebook_city fc \n\t\t\t\t\t\t\tON rc.id_city = fc.id_city \n\t\t\t\t\t\tJOIN country c \n\t\t\t\t\t\t\tON fc.id_country = c.id_country \n\t\t\t\t\tWHERE date = STR_TO_DATE('" . CITY_DATE_LAST_UPDATE . "','%Y-%m-%d') \n\t\t\t\t\tORDER BY 3 DESC\n\t\t\t\t\tLIMIT " . PAGER_PP * ($page - 1) . ", " . PAGER_PP . ";\n\t\t\t\t";
$res = mysql_query($sql) or die(mysql_error());
$cont = 1 + PAGER_PP * ($page - 1);
while ($fila = mysql_fetch_assoc($res)) {
    $crecimiento = $fila['total_user'] - get_city_total_audience_for_date($fila['id_city'], $ultimas_12_semanas);
    $class_crecimiento = '';
    if ($crecimiento > 0) {
        $class_crecimiento = 'owloo_arrow_up';
    } else {
        if ($crecimiento < 0) {
            $crecimiento *= -1;
            $class_crecimiento = 'owloo_arrow_down';
        }
    }
    ?>
                <div class="owloo_ranking_item">
                    <div class="owloo_rank"><?php 
{
    return 71;
}
function get_fb_page_total_rows_count($hispanic = '')
{
    return 1738;
}
function get_country_data($id_country, $columna)
{
    return 'MX';
}
function get_city_date_last_update($numSemanas = 1)
{
    return '2014-03-17';
}
define('CITY_DATE_LAST_UPDATE', get_city_date_last_update());
function get_city_top($countryCode, $count)
{
    return json_decode('
[{"id_city":"2001","nombre":"New Delhi","total_user":"******","total_female":"1700000","total_male":"4600000"},{"id_city":"2002","nombre":"Mumbai","total_user":"******","total_female":"1760000","total_male":"4200000"},{"id_city":"2003","nombre":"Bangalore","total_user":"******","total_female":"1240000","total_male":"3200000"},{"id_city":"2004","nombre":"Hyderabad","total_user":"******","total_female":"1000000","total_male":"3000000"},{"id_city":"2005","nombre":"Chennai","total_user":"******","total_female":"940000","total_male":"2800000"}]', true);
}
function get_owloo_ads($size)
{
    switch ($size) {
        case '728x90':
            return '
                    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                    <!-- Owloo 728x90 -->
                    <ins class="adsbygoogle"
                         style="display:inline-block;width:728px;height:90px"
                         data-ad-client="ca-pub-2178667345797931"
<?php

require_once '../owloo_config.php';
/************************************************ ULTIMOS 30 DIAS *********************************************************/
$ultimos30Dias = get_city_date_last_update(5);
//Obtenemos todos los países de Hispoamérica
$_hh_countries = array();
$sql = "SELECT id_country\n                FROM `country`\n                WHERE `habla_hispana` =1;\n                ";
$que = mysql_query($sql) or die(mysql_error());
while ($fila = mysql_fetch_assoc($que)) {
    $_hh_countries[] = $fila['id_country'];
}
//Obtenemos todas las ciudades de Hispoamérica
$_hh_cities = array();
$sql = "SELECT id_city \n                FROM `facebook_city` \n                WHERE id_country IN(" . implode(',', $_hh_countries) . ");\n                ";
$que = mysql_query($sql) or die(mysql_error());
while ($fila = mysql_fetch_assoc($que)) {
    $_hh_cities[] = $fila['id_city'];
}
//Vaciamos la tala auxiliar
$sql = "TRUNCATE TABLE record_city_grow_temp;\n                ";
$que = mysql_query($sql) or die(mysql_error());
//Registramos el crecimiento de los últimos 30 días de las ciudades de Hispanoamérica
$sql = "INSERT INTO record_city_grow_temp (id_city, period, date_start, date_end, total_user, cambio) SELECT DISTINCT id_city, 30, date, STR_TO_DATE('" . $ultimos30Dias . "','%Y-%m-%d'), total_user, (total_user - (\n                            SELECT total_user \n                            FROM record_city \n                            WHERE date = STR_TO_DATE('" . $ultimos30Dias . "','%Y-%m-%d') \n                                AND id_city = rc1.id_city\n                    )) cambio\n                FROM record_city rc1\n                WHERE date = STR_TO_DATE('" . CITY_DATE_LAST_UPDATE . "','%Y-%m-%d')\n                    AND id_city IN(" . implode(',', $_hh_cities) . ")\n                ORDER BY 6 DESC, 5 ASC;\n                ";
$que = mysql_query($sql) or die(mysql_error());
$ultimos90Dias = get_city_date_last_update(5 + 8);
//Registramos el crecimiento de los últimos 90 días de las ciudades de Hispanoamérica
$sql = "INSERT INTO record_city_grow_temp (id_city, period, date_start, date_end, total_user, cambio) SELECT DISTINCT id_city, 90, date, STR_TO_DATE('" . $ultimos90Dias . "','%Y-%m-%d'), total_user, (total_user - (\n                            SELECT total_user \n                            FROM record_city \n                            WHERE date = STR_TO_DATE('" . $ultimos90Dias . "','%Y-%m-%d') \n                                AND id_city = rc1.id_city\n                    )) cambio\n                FROM record_city rc1\n                WHERE date = STR_TO_DATE('" . CITY_DATE_LAST_UPDATE . "','%Y-%m-%d')\n                    AND id_city IN(" . implode(',', $_hh_cities) . ")\n                ORDER BY 6 DESC, 5 ASC;\n                ";
$que = mysql_query($sql) or die(mysql_error());