Ejemplo n.º 1
0
function getAccessToken_function()
{
    $access_token = array();
    $accounts = cassandra_query('SELECT email, pass, accountid, pageid, pagename FROM facebook_access_token_account;');
    foreach ($accounts as $fila) {
        $accounts_tokens = cassandra_query("SELECT access_token, accountid, date_out FROM facebook_access_token WHERE accountid = '" . $fila['accountid'] . "';");
        foreach ($accounts_tokens as $fila2) {
            if ($fila2['date_out'] - date('U') > 0) {
                $access_token[] = array('access_token' => $fila2['access_token'], 'accountId' => $fila2['accountid'], 'pageId' => $fila['pageid'], 'pageName' => $fila['pagename']);
            }
        }
    }
    if (count($access_token) > 0) {
        return $access_token;
    }
    return false;
}
<?php

set_time_limit(0);
if (!is_numeric($_SERVER['argv'][1]) || strlen($_SERVER['argv'][2]) != 2 || !is_numeric($_SERVER['argv'][3]) || $_SERVER['argv'][4] != 'c45a5f3b2cfa74ac94bd5bbfb2c5d6a5') {
    die;
}
require_once '../config.php';
$folder_path = __DIR__ . '/';
$log_path = $folder_path . 'logs/';
//Audiencia por edad
$ages = cassandra_query('SELECT id_age, min, max FROM facebook_age WHERE active_fb_get_data = 1;');
$total_age = count($ages);
foreach ($ages as $fila) {
    exec('php-cli ' . $folder_path . 'record_country_age.php ' . $_SERVER['argv'][1] . ' ' . $_SERVER['argv'][2] . ' ' . $_SERVER['argv'][3] * $total_age . ' ' . $fila['id_age'] . ' ' . $fila['min'] . ' ' . $fila['max'] . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'record_country_age.log 2>&1 &');
}
<?php

set_time_limit(0);
if (!is_numeric($_SERVER['argv'][1]) || strlen($_SERVER['argv'][2]) != 2 || !is_numeric($_SERVER['argv'][3]) || $_SERVER['argv'][4] != 'c45a5f3b2cfa74ac94bd5bbfb2c5d6a5') {
    die;
}
require_once '../config.php';
$folder_path = __DIR__ . '/';
$log_path = $folder_path . 'logs/';
//Audiencia por situación sentimental
$relationships = cassandra_query('SELECT id_relationship, key_relationship FROM facebook_relationship WHERE active_fb_get_data = 1;');
$total_relationship = count($relationships);
foreach ($relationships as $fila) {
    exec('php-cli ' . $folder_path . 'record_country_relationship.php ' . $_SERVER['argv'][1] . ' ' . $_SERVER['argv'][2] . ' ' . $_SERVER['argv'][3] * $total_relationship . ' ' . $fila['id_relationship'] . ' ' . $fila['key_relationship'] . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'record_country_relationship.log 2>&1 &');
}
<?php

set_time_limit(0);
if (!is_numeric($_SERVER['argv'][1]) || strlen($_SERVER['argv'][2]) != 2 || !is_numeric($_SERVER['argv'][3]) || $_SERVER['argv'][4] != 'c45a5f3b2cfa74ac94bd5bbfb2c5d6a5') {
    die;
}
require_once '../config.php';
$folder_path = __DIR__ . '/';
$log_path = $folder_path . 'logs/';
//Audiencia por generación
$generations = cassandra_query('SELECT id_generation, key_generation FROM facebook_generation WHERE active_fb_get_data = 1;');
$total_generation = count($generations);
foreach ($generations as $fila) {
    exec('php-cli ' . $folder_path . 'record_country_generation.php ' . $_SERVER['argv'][1] . ' ' . $_SERVER['argv'][2] . ' ' . $_SERVER['argv'][2] * $total_generation . ' ' . $fila['id_generation'] . ' ' . $fila['key_generation'] . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'record_country_generation.log 2>&1 &');
}
        while ($ban == 0) {
            //Audiencia total
            $check_audience = false;
            $numAudience = NULL;
            while (!$check_audience) {
                $numAudience = getNumAudience($next_code, $key_language, $accessToken, $accountId, $pageId, $pageName);
                if (!$numAudience) {
                    nextAccessToken();
                } else {
                    $check_audience = true;
                }
            }
            if (is_numeric($numAudience)) {
                cassandra_insert("INSERT INTO facebook_record_country_language(id_country,id_language,total_user,date,date_time) VALUES({$next_id}, {$id_language}, {$numAudience}, {$date}, dateof(NOW()));");
                $ban = 1;
            } else {
                send_email('country_language', 'Owloo ERROR - Pais LANGUAGE - ' . $fila['id_country'], 'ERROR en la captura de datos.', true, 'Captura de datos - Pais LANGUAGE - ID = ' . $_SERVER['argv'][1] . ' => ' . $numAudience);
            }
        }
        /***************************************** FIN GET TOTALES ********************************************************/
        /********************************** Verificación de finalización *************************************************/
        //Cantidad de filas insertadas
        $inserts = cassandra_query("SELECT COUNT(*) FROM facebook_record_country_language WHERE date = {$date};");
        if (count($inserts) > 0) {
            if ($inserts[0]['count'] == $total_language) {
                send_email('country_language', 'Owloo EXITO - Pais LANGUAGE', 'EXITO en la captura de datos.');
            }
        }
        /******************************* FIN - Verificación de finalización **********************************************/
    }
}
        while ($ban == 0) {
            //Audiencia total
            $check_audience = false;
            $numAudience = NULL;
            while (!$check_audience) {
                $numAudience = getNumAudience($next_code, $key_generation, $accessToken, $accountId, $pageId, $pageName);
                if (!$numAudience) {
                    nextAccessToken();
                } else {
                    $check_audience = true;
                }
            }
            if (is_numeric($numAudience)) {
                cassandra_insert("INSERT INTO facebook_record_country_generation(id_country,id_generation,total_user,date,date_time) VALUES({$next_id}, {$id_generation}, {$numAudience}, {$date}, dateof(NOW()));");
                $ban = 1;
            } else {
                send_email('country_generation', 'Owloo ERROR - Pais GENERATION - ' . $next_id, 'ERROR en la captura de datos.', true, 'Captura de datos - Pais GENERATION - ID = ' . $_SERVER['argv'][1] . ' => ' . $numAudience);
            }
        }
        /***************************************** FIN GET TOTALES ********************************************************/
        /********************************** Verificación de finalización *************************************************/
        //Cantidad de filas insertadas
        $inserts = cassandra_query("SELECT COUNT(*) FROM facebook_record_country_generation WHERE date = {$date};");
        if (count($inserts) > 0) {
            if ($inserts[0]['count'] == $total_generation) {
                send_email('country_generation', 'Owloo EXITO - Pais GENERATION', 'EXITO en la captura de datos.');
            }
        }
        /******************************* FIN - Verificación de finalización **********************************************/
    }
}
Ejemplo n.º 7
0
function is_sent_today_error($type)
{
    global $cassandra_db;
    $date = date('Ymd');
    $sent = cassandra_query("SELECT * FROM owloo_cron_error_info WHERE type = '{$type}' AND date = {$date};");
    if (count($sent) > 0) {
        return true;
    }
    return false;
}
function setAccessToken()
{
    $accounts = cassandra_query('SELECT email, accountid, pass FROM facebook_access_token_account;');
    $ban = false;
    foreach ($accounts as $fila) {
        if (file_exists('/home/owloo/public_html/wservice/access_token_cassandra/cookie/cookies.txt')) {
            unlink('/home/owloo/public_html/wservice/access_token_cassandra/cookie/cookies.txt');
        }
        $f = fopen('/home/owloo/public_html/wservice/access_token_cassandra/cookie/cookies.txt', 'w');
        $access_token = getAccessToken_code($fila['email'], $fila['pass']);
        if (!$access_token) {
            $access_token = getAccessToken_code($fila['email'], $fila['pass']);
        }
        if ($access_token) {
            /*if(file_exists('/home/owloo/public_html/wservice/access_token/cookie/cook.txt')) unlink('/home/owloo/public_html/wservice/access_token/cookie/cook.txt');
            		$f = fopen('/home/owloo/public_html/wservice/access_token/cookie/cook.txt', 'w');
            		$access_token_expire = getAccessTokenExpireDate($access_token);
            		if(!$access_token_expire)
            			$access_token_expire = getAccessTokenExpireDate($access_token);*/
            //$sql = "INSERT INTO access_token VALUES (NULL , '".$access_token."', '".$fila['accountId']."', ".date('U').", ".$access_token_expire.");";
            cassandra_insert("INSERT INTO facebook_access_token(access_token,accountid,date_in,date_out,date_add) VALUES('{$access_token}', '" . $fila['accountid'] . "', " . date('U') . ", " . (date('U') + 36000) . ", dateof(now()));");
            $ban = true;
        }
    }
    /*if(!$ban)
    		informarError();*/
}
Ejemplo n.º 9
0
<?php

set_time_limit(0);
require_once '../config.php';
$folder_path = __DIR__ . '/';
$log_path = $folder_path . 'logs/';
$countries = cassandra_query('SELECT id_country, code FROM facebook_country WHERE active_fb_get_data = 1;');
$total_country = count($countries);
/*foreach ($countries as $country) {
        
        //Audiencia total (8 seg)
        exec('php-cli '.$folder_path.'record_country.php '.$country['id_country'].' '.$country['code'].' '.$total_country.' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > '.$log_path.'record_country.log 2>&1 &');
        
    } sleep(30);
    
    $count = 1;

    foreach ($countries as $country) {
        
        //Audiencia por edad (1:02 min)
        exec('php-cli '.$folder_path.'call_record_country_age.php '.$country['id_country'].' '.$country['code'].' '.$total_country.' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > '.$log_path.'call_record_country_age.log 2>&1 &');
        
        if ($count++ % 125 == 0)
            sleep(40);
        
    } sleep(40);*/
$count = 1;
foreach ($countries as $country) {
    //Audiencia por idioma (<3 min)
    exec('php-cli ' . $folder_path . 'call_record_country_language.php ' . $country['id_country'] . ' ' . $country['code'] . ' ' . $total_country . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'call_record_country_language.log 2>&1 &');
    if ($count++ % 20 == 0) {
<?php

set_time_limit(0);
if (!is_numeric($_SERVER['argv'][1]) || strlen($_SERVER['argv'][2]) != 2 || !is_numeric($_SERVER['argv'][3]) || $_SERVER['argv'][4] != 'c45a5f3b2cfa74ac94bd5bbfb2c5d6a5') {
    die;
}
require_once '../config.php';
$folder_path = __DIR__ . '/';
$log_path = $folder_path . 'logs/';
//Audiencia por idioma
$languages = cassandra_query('SELECT id_language, key_language FROM facebook_language WHERE active_fb_get_data = 1;');
$total_language = count($languages);
foreach ($languages as $fila) {
    exec('php-cli ' . $folder_path . 'record_country_language.php ' . $_SERVER['argv'][1] . ' ' . $_SERVER['argv'][2] . ' ' . $_SERVER['argv'][3] * $total_language . ' ' . $fila['id_language'] . ' ' . $fila['key_language'] . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'record_country_language.log 2>&1 &');
}
<?php

set_time_limit(0);
if (!is_numeric($_SERVER['argv'][1]) || strlen($_SERVER['argv'][2]) != 2 || !is_numeric($_SERVER['argv'][3]) || $_SERVER['argv'][4] != 'c45a5f3b2cfa74ac94bd5bbfb2c5d6a5') {
    die;
}
require_once '../config.php';
$folder_path = __DIR__ . '/';
$log_path = $folder_path . 'logs/';
//Audiencia por interes
$generations = cassandra_query('SELECT id_interest, key_interest FROM facebook_interest WHERE active_fb_get_data = 1;');
$total_interest = count($interests);
foreach ($interests as $fila) {
    exec('php-cli ' . $folder_path . 'record_country_interest.php ' . $_SERVER['argv'][1] . ' ' . $_SERVER['argv'][2] . ' ' . $_SERVER['argv'][2] * $total_interest . ' ' . $fila['id_interest'] . ' ' . $fila['key_interest'] . ' c45a5f3b2cfa74ac94bd5bbfb2c5d6a5 > ' . $log_path . 'record_country_interest.log 2>&1 &');
}
Ejemplo n.º 12
0
            }
            //Audiencia total hombres
            $check_audience = false;
            $numAudienceMale = NULL;
            while (!$check_audience) {
                $numAudienceMale = getNumAudience($next_code, "1", $accessToken, $accountId, $pageId, $pageName);
                if (!$numAudienceMale) {
                    nextAccessToken();
                } else {
                    $check_audience = true;
                }
            }
            if (is_numeric($numAudience) && is_numeric($numAudienceMale) && is_numeric($numAudienceFemale)) {
                cassandra_insert("INSERT INTO facebook_record_country(id_country,total_user,total_female,total_male,date,date_time) VALUES({$next_id}, {$numAudience}, {$numAudienceFemale}, {$numAudienceMale}, {$date}, dateof(NOW()));");
                $ban = 1;
            } else {
                send_email('country', 'Owloo ERROR - Pais - ' . $next_id, 'ERROR en la captura de datos.', true, 'Captura de datos - Pais - ID = ' . $_SERVER['argv'][1] . ' => ' . $numAudience . ' - ' . $numAudienceFemale . ' - ' . $numAudienceMale);
            }
        }
    }
    /***************************************** FIN GET TOTALES ********************************************************/
    /********************************** Verificación de finalización *************************************************/
    //Cantidad de filas insertadas
    $inserts = cassandra_query("SELECT COUNT(*) FROM facebook_record_country WHERE date = {$date} ALLOW FILTERING;");
    if (count($inserts) > 0) {
        if ($inserts[0]['count'] == $total_country) {
            send_email('country', 'Owloo EXITO - Pais', 'EXITO en la captura de datos.');
        }
    }
    /******************************* FIN - Verificación de finalización **********************************************/
}