<?php
// prevenir invocacion directa del script
defined('PRONTUS') OR exit('');

# CONFIGURACION DESDE PRONTUS NEXT
$config_path = "$document_root/$prontus_id/cpan/$prontus_id-redes.cfg";

if (file_exists($config_path)) {
    $config_vars = file_get_contents($config_path);
    if (preg_match("/TT_ID\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('TWITTER_ID', $match[1]);
    }
    if (preg_match("/TT_AUTH_TOKEN\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('OAUTH_TOKEN', $match[1]);
    }
    if (preg_match("/TT_AUTH_TOKEN_SECRET\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('OAUTH_TOKEN_SECRET', $match[1]);
    }
    if (preg_match("/TT_CONSUMER_KEY\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('CONSUMER_KEY', $match[1]);
    }
    if (preg_match("/TT_CONSUMER_SECRET\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('CONSUMER_SECRET', $match[1]);
    }
    if (preg_match("/TT_GOOGL_KEY\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('GOOGL_KEY', $match[1]);
    }
    if (preg_match("/TT_GOOGL_USER\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('GOOGL_USER', $match[1]);
    }
    if (preg_match("/TT_BITLY_USER\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('BITLY_USER', $match[1]);
    }
    if (preg_match("/TT_BITLY_KEY\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('BITLY_KEY', $match[1]);
    }
    if (preg_match("/TT_PICTURE_WALL\s*=\s*['](.+?)[']/", $config_vars, $match)){
        define('PICTURE_WALL', $match[1]);
    }

    define('OAUTH_CALLBACK', '');

} else {
    echo "Error en la lectura de configuraciones de posting a Twitter";
    exit;
}
