function register_local_fans($page_id) { $data_return = array('has_local_fans' => false); $local_fans_last_date = get_local_fans_last_date($page_id); if (!empty($local_fans_last_date)) { //Get page's data $query = 'SELECT id_page, parent, fb_id, name, username, is_verified, likes, likes_grow_7, talking_about, category_id, sub_category_id FROM ' . DB_RESULTS_PREFIX . 'facebook_pages WHERE id_page = $10;'; $que_pages = db_query_table_results($query, array($page_id)); $page = mysql_fetch_assoc($que_pages); //Get local fans $query = 'SELECT * FROM ' . DB_FACEBOOK_PREFIX . 'page_local_fans_country WHERE id_page = $1 AND date = \'$2\';'; $que_local_fans = db_query($query, array($page_id, $local_fans_last_date)); if (mysql_num_rows($que_local_fans) > 0) { $data_return['has_local_fans'] = true; $data_return['date'] = $local_fans_last_date; $data_return['items'] = array(); //Controlamos que no se duplique $local_fans_exist_in_result = false; $query = 'SELECT id_page FROM ' . DB_RESULTS_PREFIX . 'facebook_pages_local_fans WHERE id_page = $10 LIMIT 1;'; $result = db_query_table_results($query, array($page_id)); if (mysql_num_rows($result) > 0) { $local_fans_exist_in_result = true; } while ($local_fans = mysql_fetch_assoc($que_local_fans)) { $data_return['items'][] = array('c' => $local_fans['id_country'], 'l' => $local_fans['likes']); if (!$local_fans_exist_in_result) { $country = get_country_data($local_fans['id_country']); $country_code = $country['code']; $country_name = $country['name']; $country_slug = $country['slug']; $likes = $local_fans['likes']; //Insert into result's table $query = "INSERT INTO " . DB_RESULTS_PREFIX . "facebook_pages_local_fans VALUES(NULL, \$10, \$11, \$12, '\$13', '\$14', \$15, \$16, \$17, \$18, \$19, \$20, '\$21', '\$22', '\$23', \$24, NOW());"; $values = array($page['id_page'], $page['parent'], $page['fb_id'], $page['username'], $page['name'], $page['is_verified'], $page['likes'], !empty($page['likes_grow_7']) ? $page['likes_grow_7'] : 'NULL', $page['talking_about'], !empty($page['category_id']) ? $page['category_id'] : 'NULL', !empty($page['sub_category_id']) ? $page['sub_category_id'] : 'NULL', $country_code, $country_name, $country_slug, $likes); $res = db_query_table_results($query, $values, 1); } } } } return $data_return; }
$sql = "SELECT id_city, total_user, cambio\n FROM record_city_grow_temp\n WHERE period = 90\n ORDER BY 3 DESC, 2 ASC;\n "; $que = mysql_query($sql) or die(mysql_error()); if ($fila = mysql_fetch_assoc($que)) { if ($fila['cambio'] > 0) { $_name_city = get_city_data($fila['id_city'], 'name'); $hh_city_mayor_crec_3_meses = array('id_city' => $fila['id_city'], 'ciudad' => substr($_name_city, 0, strpos($_name_city, ',')), 'country' => get_country_data(get_city_data($fila['id_city'], 'id_country'), 'name'), 'pais' => get_country_data(get_city_data($fila['id_city'], 'id_country'), 'nombre'), 'cambio' => $fila['cambio'], 'cambio_number' => $fila['cambio'], 'total_user' => $fila['total_user']); } } //Imprimimos la ciudad con el mayor decremento en los últimos 90 días //La consulta anterior se ordena en forma descendente por su cantidad de crecimiento de usuario, por tanto, el último registro contiene al país que sufrió el mayor DECREMENTO (en caso de que sea negativo). //Nos posicionamos al último registro mysql_data_seek($que, mysql_num_rows($que) - 1); if ($fila = mysql_fetch_assoc($que)) { if ($fila['cambio'] < 0) { $_name_city = get_city_data($fila['id_city'], 'name'); $hh_city_mayor_decrec_3_meses = array('id_city' => $fila['id_city'], 'ciudad' => substr($_name_city, 0, strpos($_name_city, ',')), 'country' => get_country_data(get_city_data($fila['id_city'], 'id_country'), 'name'), 'pais' => get_country_data(get_city_data($fila['id_city'], 'id_country'), 'nombre'), 'cambio' => $fila['cambio'] * -1, 'cambio_number' => $fila['cambio'] * -1, 'total_user' => $fila['total_user']); } } /************************************************ FIN ULTIMOS 30 DIAS *********************************************************/ //Estadísticas de Habla Hispana //Por mes if ($hh_city_mayor_crec_mes['ciudad'] != '') { $hh_city_mayor_crec_mes['ciudad'] = '<a href="' . URL_ROOT . 'facebook-stats/cities/' . convert_to_url_string($hh_city_mayor_crec_mes['country']) . '/" title="Estadísticas de Facebook en ' . $hh_city_mayor_crec_mes['pais'] . '">' . $hh_city_mayor_crec_mes['ciudad'] . '</a>'; $hh_city_mayor_crec_mes['cambio'] = owloo_number_format($hh_city_mayor_crec_mes['cambio']); } else { $hh_city_mayor_crec_mes['ciudad'] = '<span>sin cambio</span>'; $hh_city_mayor_crec_mes['cambio'] = '<span>0</span>'; } if ($hh_city_mayor_decrec_mes['ciudad'] != '') { $hh_city_mayor_decrec_mes['ciudad'] = '<a href="' . URL_ROOT . 'facebook-stats/cities/' . convert_to_url_string($hh_city_mayor_decrec_mes['country']) . '/" title="Estadísticas de Facebook en ' . $hh_city_mayor_decrec_mes['pais'] . '">' . $hh_city_mayor_decrec_mes['ciudad'] . '</a>'; $hh_city_mayor_decrec_mes['cambio'] = owloo_number_format($hh_city_mayor_decrec_mes['cambio']);
echo owloo_number_format($page_data['talking_about']); ?> </strong>. </p> <p> El país con más fans de <?php echo $page_data['name']; ?> es <?php echo get_country_data($page_data['first_local_fans_country'], 'nombre'); ?> y se posiciona al puesto <?php echo $ranking_position; ?> en el ranking de páginas de <?php echo get_country_data(!empty($page_data['location']) ? $page_data['location'] : $page_data['first_local_fans_country'], 'nombre'); ?> . </p> <?php if (!empty($page_data['about'])) { ?> <p class="owloo_fb_page_about"> <em><?php echo $page_data['about']; ?> </em> </p> <?php } ?>
/** * Create all local groups */ function create_local_groups() { // first, creates country groups $countrygroup_guid = array(); $options["type"] = 'group'; $options["limit"] = NULL; $options["metadata_name_value_pairs"][] = array("name" => 'grouptype', "value" => 'local'); $options["metadata_name_value_pairs"][] = array("name" => 'localtype', "value" => 'national'); $existing_countrygroups = elgg_get_entities_from_metadata($options); $country_data = get_country_data(); foreach ($country_data as $country) { if (!is_group_name_existing($country, $existing_countrygroups)) { $group = new ElggGroup(); $group->name = $country; $group->description = ""; $group->grouptype = 'local'; $group->localtype = 'national'; $group->membership = ACCESS_PUBLIC; $group->access_id = ACCESS_LOGGED_IN; $group->save(); $countrygroup_guid[$country] = $group->guid; } } // then, creates departement groups $depgroup_guids = array(); $options["type"] = 'group'; $options["limit"] = NULL; $options["metadata_name_value_pairs"][] = array("name" => 'grouptype', "value" => 'local'); $options["metadata_name_value_pairs"][] = array("name" => 'localtype', "value" => 'departemental'); $existing_depgroups = elgg_get_entities_from_metadata($options); $departements_data = get_departement_data(); foreach ($departements_data as $num => $name) { $groupname = $num . " - " . $name; if (!is_group_name_existing($groupname, $existing_depgroups)) { $group = new ElggGroup(); $group->name = $groupname; $group->description = ""; $group->grouptype = 'local'; $group->localtype = 'departemental'; $group->membership = ACCESS_PUBLIC; $group->access_id = ACCESS_LOGGED_IN; $group->save(); $depgroup_guids[$num] = $group->guid; } } // finally, creates region groups $options["metadata_name_value_pairs"] = array(array('name' => 'grouptype', 'value' => 'local', 'operand' => '=', 'case_sensitive' => TRUE), array('name' => 'localtype', 'value' => 'regional', 'operand' => '=', 'case_sensitive' => TRUE)); $existing_region_groups = elgg_get_entities_from_metadata($options); $regions_data = get_region_data(); foreach ($regions_data as $name => $dep_nums) { if (!is_group_name_existing($name, $existing_region_groups)) { $group = new ElggGroup(); $group->name = $name; $group->grouptype = 'local'; $group->localtype = 'regional'; $group->membership = ACCESS_PUBLIC; $group->access_id = ACCESS_LOGGED_IN; $group->save(); //add relationship with departement groups foreach ($dep_nums as $num) { $depgroup = get_entity($depgroup_guids[$num]); if ($depgroup) { $group->addRelationship($depgroup->guid, 'child'); $depgroup->addRelationship($group->guid, 'parent'); $depgroup->save(); } } // add relationship with country group $countrygroup = get_entity($countrygroup_guid['France']); if ($countrygroup) { $countrygroup->addRelationship($group->guid, 'child'); $group->addRelationship($countrygroup->guid, 'parent'); $countrygroup->save(); } $group->save(); } } }
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); require_once "lib/spyc.php"; require_once "lib/howtobuy.php"; require_once "config.php"; $currentcountry = isset($_REQUEST['country']) ? $_REQUEST['country'] : null; if ($currentcountry === null || strlen($currentcountry) != 2) { unset($currentcountry); } $countrynames = get_country_data(); $serviceData = get_service_data(); $coins = get_coin_data(); ?> <?php echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="google-site-verification" content="9knoXHCRFNvyZR1PYMcB5zZ9VgdDJm8hE-DncAg_u3U" /> <title>How to Buy Bitcoins<?php if (isset($currentcountry)) { echo " in " . $countrynames[$currentcountry]; } ?> </title> <meta name="description" content="List of places to buy bitcoins in your country. Payments by bank transfer, PayPal and phone, as well as many other methods.">