* 
  * 
  * 
  * sleep(30);

error_log(date('d m Y H:i:s'));
*/
/****** END - INTEREST *****/
/****** COMPORTAMIENTO *****/
if ($_SERVER['argv'][1] == 'country_comportamiento') {
    $query = 'SELECT count(*) cantidad FROM `facebook_comportamiento_3_1` WHERE active_fb_get_data = 1;';
    $result = db_query($query, array());
    if ($fila = mysql_fetch_assoc($result)) {
        $total_comportamiento = $fila['cantidad'];
    }
    $query = 'SELECT id_country id, code FROM `facebook_country_3_1` WHERE id_country NOT IN(' . get_data_for_sql_in('comportamiento', $total_comportamiento) . ') AND active_fb_get_data = 1 ORDER BY 1;';
    $que = db_query($query, array());
    $count = 1;
    error_log('record_country_comportamiento (i - aux): ' . date('d m Y H:i:s'));
    while ($country = mysql_fetch_assoc($que)) {
        $query = "SELECT id_comportamiento id, key_comportamiento 'key' FROM `facebook_comportamiento_3_1` WHERE active_fb_get_data = 1 AND id_comportamiento NOT IN(" . get_data_id_secundary_for_sql_in($country['id'], 'comportamiento') . ") ORDER BY 1;";
        $result = db_query($query, array());
        $comportamientos = array();
        while ($fila = mysql_fetch_assoc($result)) {
            $comportamientos[] = $fila;
        }
        $comportamientos = json_encode($comportamientos);
        //Audiencia por comportamientos (12:00 min)
        exec('php-cli ' . $folder_path . 'call_record_country_comportamiento.php ' . $country['id'] . ' ' . $country['code'] . ' ' . $total_country . ' ' . urlencode($comportamientos) . ' ' . $total_comportamiento . ' 1 c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'call_record_country_comportamiento.log 2>&1 &');
        usleep(rand(0, 100000));
        if ($count++ % 7 == 0) {
        usleep(rand(0, 100000));
        if ($count++ % 100 == 0) {
            sleep(20);
        }
    }
    error_log('record_region_interest (f): ' . date('d m Y H:i:s'));
}
/***** END - INTEREST *****/
/***** COMPORTAMIENTO *****/
if ($_SERVER['argv'][1] == 'region_comportamiento') {
    $query = 'SELECT count(*) cantidad FROM `facebook_mobile_os_city_3_1`;';
    $result = db_query($query, array());
    if ($fila = mysql_fetch_assoc($result)) {
        $total_comportamiento = $fila['cantidad'];
    }
    $query = 'SELECT id_region id, region_key code, id_country FROM `facebook_region_3_1` WHERE id_region NOT IN(' . get_data_for_sql_in('comportamiento', $total_comportamiento) . ') AND active_fb_get_data = 1 ORDER BY 1;';
    $que = db_query($query, array());
    $count = 1;
    error_log('record_region_comportamiento (i): ' . date('d m Y H:i:s'));
    while ($region = mysql_fetch_assoc($que)) {
        $query = "SELECT id_comportamiento id, key_comportamiento 'key' FROM `facebook_comportamiento_3_1` WHERE id_comportamiento IN(SELECT id_comportamiento FROM facebook_mobile_os_city_3_1) AND active_fb_get_data = 1 AND id_comportamiento NOT IN(" . get_data_id_secundary_for_sql_in($region['id'], 'comportamiento') . ") ORDER BY 1;";
        $result = db_query($query, array());
        $comportamientos = array();
        while ($fila = mysql_fetch_assoc($result)) {
            $comportamientos[] = $fila;
        }
        $comportamientos = json_encode($comportamientos);
        exec('php-cli ' . $folder_path . 'call_record_region_comportamiento.php ' . $region['id'] . ' ' . $region['code'] . ' ' . $total_region . ' ' . urlencode($comportamientos) . ' ' . $total_comportamiento . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'call_record_region_comportamiento.log 2>&1 &');
        usleep(rand(0, 100000));
        if ($count++ % 100 == 0) {
            sleep(20);
{
    $query = 'SELECT id_$1 id FROM `facebook_record_city_$1_3_1` WHERE id_city = $2 AND date = DATE(NOW())';
    $result = db_query($query, array($column, $id_city));
    $data = array();
    $data[] = 0;
    while ($fila = mysql_fetch_assoc($result)) {
        $data[] = $fila['id'];
    }
    return implode(',', $data);
}
require_once __DIR__ . '/../config.php';
$folder_path = __DIR__ . '/';
$log_path = $folder_path . 'logs/';
//Ciudades
$table = str_replace('call_', '', str_replace('record_', '', $_SERVER['argv'][3]));
$query = 'SELECT id_city, key_city FROM `facebook_city_3_1` WHERE id_city IN(' . get_data_for_sql_in($_SERVER['argv'][1], $table, $_SERVER['argv'][4]) . ') AND active_fb_get_data = 1 ORDER BY 1;';
$que = db_query($query, array());
$total_city = $_SERVER['argv'][2];
while ($fila = mysql_fetch_assoc($que)) {
    $data = array();
    switch ($table) {
        case 'city_age':
            $query = 'SELECT id_age id, min, max FROM `facebook_age_3_1` WHERE active_fb_get_data = 1 AND id_age NOT IN(' . get_data_id_secundary_for_sql_in($fila['id_city'], 'age') . ') ORDER BY 1;';
            break;
        case 'city_interest':
            $query = "SELECT id_interest id, key_interest 'key' FROM `facebook_interest_3_1` WHERE id_interest IN(SELECT id_interest FROM facebook_interest_city_3_1 WHERE id_country = " . $_SERVER['argv'][1] . ") AND id_interest NOT IN(" . get_data_id_secundary_for_sql_in($fila['id_city'], 'interest') . ") AND active_fb_get_data = 1 ORDER BY 1;";
            break;
        case 'city_comportamiento':
            $query = "SELECT id_comportamiento id, key_comportamiento 'key' FROM `facebook_comportamiento_3_1` WHERE id_comportamiento IN(SELECT id_comportamiento FROM facebook_mobile_os_city_3_1) AND active_fb_get_data = 1 AND id_comportamiento NOT IN(" . get_data_id_secundary_for_sql_in($fila['id_city'], 'comportamiento') . ") ORDER BY 1;";
            break;
        case 'city_relationship':
Esempio n. 4
0
    $data = array();
    $data[] = 0;
    while ($fila = mysql_fetch_assoc($result)) {
        $data[] = $fila[$column];
    }
    return implode(',', $data);
}
define('INSTAGRAM_CLIENT_ID', '04e770ce699e44eb80bcf26cf929aa5a');
define('INSTAGRAM_COUNT_DATA', 100);
function instagram_user_data($user_id)
{
    $data = get_url_content("https://api.instagram.com/v1/users/{$user_id}/?client_id=" . INSTAGRAM_CLIENT_ID);
    return json_decode($data, true);
}
$query = 'SELECT id_profile, instagram_id FROM `instagram_profiles`';
$que = db_query($query, array());
$total_profile = mysql_num_rows($que);
$query = 'SELECT id_profile, instagram_id FROM `instagram_profiles` WHERE id_profile NOT IN(' . get_data_for_sql_in('SELECT id_profile FROM `instagram_record` WHERE `date` = DATE(NOW())', 'id_profile') . ') ORDER BY 1';
$que = db_query($query, array());
$total_profile_before = mysql_num_rows($que);
while ($fila = mysql_fetch_assoc($que)) {
    $user_data = instagram_user_data($fila['instagram_id']);
    if ($user_data['meta']['code'] == 200) {
        $query = 'INSERT INTO instagram_record VALUES($1, $2, $3, $4, NOW());';
        $row = db_query($query, array($fila['id_profile'], $user_data['data']['counts']['media'], $user_data['data']['counts']['followed_by'], $user_data['data']['counts']['follows']), 1);
    }
}
$query = 'SELECT id_profile, instagram_id FROM `instagram_profiles` WHERE id_profile NOT IN(' . get_data_for_sql_in('SELECT id_profile FROM `instagram_record` WHERE `date` = DATE(NOW())', 'id_profile') . ') ORDER BY 1';
$que = db_query($query, array());
$total_profile_after = mysql_num_rows($que);
enviar_informe($total_profile, $total_profile_before, $total_profile_after);
            sleep(20);
        }
    }
    error_log('record_city_comportamiento (f - aux): ' . date('d m Y H:i:s'));
}
/****** END - COMPORTAMIENTO *****/
/****** RELATIONSHIP *****/
if ($_SERVER['argv'][1] == 'city_relationship') {
    $query = "SELECT count(*) cantidad FROM `facebook_relationship_3_1` WHERE active_fb_get_data = 1 ORDER BY 1;";
    $result = db_query($query, array());
    $total_relationship = null;
    if ($fila = mysql_fetch_assoc($result)) {
        $total_relationship = $fila['cantidad'];
    }
    $countries = array();
    $query = 'SELECT id_country id FROM facebook_country_3_1 WHERE supports_city = 1 AND id_country IN (' . get_data_for_sql_in('relationship', $total_relationship) . ') AND active_fb_get_data = 1 ORDER BY 1;';
    $que = db_query($query, array());
    $count = 1;
    error_log('record_city_relationship (i - aux): ' . date('d m Y H:i:s'));
    while ($country = mysql_fetch_assoc($que)) {
        // (20:00 min)
        exec('php-cli ' . $folder_path . 'call_record_city_aux.php ' . $country['id'] . ' ' . $total_city . ' call_record_city_relationship ' . $total_relationship . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'call_record_city_aux.log 2>&1 &');
        usleep(rand(0, 100000));
        if ($count++ % 1 == 0) {
            sleep(40);
        }
    }
    error_log('record_city_relationship (f - aux): ' . date('d m Y H:i:s'));
}
/****** END - RELATIONSHIP *****/
die;