public function __construct()
 {
     $this->ROOT = realpath(dirname(__FILE__) . '/../../../');
     //imports
     require_once $this->ROOT . '/inc/config.inc.php';
     INIT::obtain();
     $this->db = Database::obtain(INIT::$DB_SERVER, INIT::$DB_USER, INIT::$DB_PASS, INIT::$DB_DATABASE);
     $this->db->connect();
     //init params
     $this->path = $this->ROOT . '/lib/Utils/converter_checker';
     $resultSet = $this->db->fetch_array(self::selectAllNotOffline);
     if (empty($resultSet)) {
         self::_prettyEcho("------------------------------------");
         self::_prettyEcho("************* WARNING **************");
         self::_prettyEcho("------------------------------------");
         $this->alertForEmptyPool();
         die(1);
     }
     foreach ($resultSet as $conv) {
         //            self::$ipLog = $conv[ 'ip_converter' ];
         $this->resultSet[$conv['ip_converter']] = $conv;
         $this->host_machine_map[$conv['ip_converter']] = array('ip_machine_host' => $conv['ip_machine_host'], 'machine_host_user' => $conv['machine_host_user'], 'machine_host_pass' => $conv['machine_host_pass'], 'instance_name' => $conv['instance_name']);
         //            self::_prettyEcho( "Retrieving Processes Info on " . $conv[ 'ip_converter' ] );
         //            $converter_json_top = self::getNodeProcessInfo( $conv[ 'ip_converter' ] );
         //            if ( !empty( $converter_json_top ) ) {
         //                $this->convertersTop[ $conv[ 'ip_converter' ] ] = array(
         //                    'converter_load'     => $converter_json_top[ 0 ],
         //                    'converter_json_top' => $converter_json_top[ 1 ]
         //                );
         //            }
     }
     $this->converterFactory = new FileFormatConverter();
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     if (!class_exists("INIT")) {
         include_once "../../inc/config.inc.php";
         INIT::obtain();
     }
     $this->opt['httpheader'] = array("Content-Type:multipart/form-data;charset=UTF-8");
     $this->lang_handler = Langs_Languages::getInstance();
     $this->conversionObject = new ArrayObject(array('ip_machine' => null, 'ip_client' => null, 'path_name' => null, 'file_name' => null, 'path_backup' => null, 'file_size' => 0, 'direction' => null, 'error_message' => null, 'src_lang' => null, 'trg_lang' => null, 'status' => 'ok', 'conversion_time' => 0), ArrayObject::ARRAY_AS_PROPS);
     $db = Database::obtain();
     $converters = $db->fetch_array("SELECT ip_converter, cpu_weight, ip_storage, segmentation_rule FROM converters WHERE status_active = 1 AND status_offline = 0");
     foreach ($converters as $converter_storage) {
         self::$converters[$converter_storage['ip_converter']] = $converter_storage['cpu_weight'];
         self::$Storage_Lookup_IP_Map[$converter_storage['ip_converter']] = $converter_storage['ip_storage'];
         self::$converter2segmRule[$converter_storage['ip_converter']] = $converter_storage['segmentation_rule'];
     }
     //        self::$converters = array('10.11.0.98' => 1);//for debugging purposes
     //        self::$Storage_Lookup_IP_Map = array('10.11.0.98' => '10.11.0.99');//for debugging purposes
     $this->storage_lookup_map = self::$Storage_Lookup_IP_Map;
 }
Ejemplo n.º 3
0
<?php

/**
 * User: domenico
 * Date: 09/10/13
 * Time: 15.21
 * 
 */
if (!class_exists('INIT', false)) {
    $root = realpath(dirname(__FILE__) . '/../../inc/');
    include $root . '/config.inc.php';
    INIT::obtain();
    set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../'));
}
abstract class Tests_AbstractTest extends PHPUnit_Framework_TestCase
{
    protected $thisTest;
    protected $reflectedClass;
    protected $reflectedMethod;
    public function setUp()
    {
        parent::setUp();
        $this->thisTest = microtime(true);
    }
    public function tearDown()
    {
        parent::tearDown();
        $resultTime = microtime(true) - $this->thisTest;
        echo " " . str_pad($this->getName(false), 35, " ", STR_PAD_RIGHT) . " - Did in " . $resultTime . " seconds.\n";
    }
}
Ejemplo n.º 4
0
 private function __construct()
 {
     self::$CONFIG = parse_ini_file('config.ini', true);
     self::$_ROOT = realpath(dirname(__FILE__) . '/../');
     $OAUTH_CONFIG = parse_ini_file(realpath(dirname(__FILE__) . '/oauth_config.ini'), true);
     register_shutdown_function('Bootstrap::fatalErrorHandler');
     $mv = parse_ini_file('version.ini');
     self::$_INI_VERSION = $mv['version'];
     $this->_setIncludePath();
     spl_autoload_register('Bootstrap::loadClass');
     require_once 'Predis/autoload.php';
     if (stripos(PHP_SAPI, 'cli') === false) {
         register_shutdown_function('Bootstrap::sessionClose');
         INIT::$PROTOCOL = isset($_SERVER['HTTPS']) ? "https" : "http";
         INIT::$HTTPHOST = INIT::$PROTOCOL . "://" . $_SERVER['HTTP_HOST'];
     } else {
         if (INIT::$DEBUG) {
             echo "\nPHP Running in CLI mode.\n\n";
         }
         //Possible CLI configurations. We definitly don't want sessions in our cron scripts
     }
     INIT::$OAUTH_CONFIG = $OAUTH_CONFIG['OAUTH_CONFIG'];
     INIT::obtain();
     INIT::$ROOT = self::$_ROOT;
     // Accesible by Apache/PHP
     INIT::$BASEURL = "/";
     // Accesible by the browser
     INIT::$TIME_TO_EDIT_ENABLED = false;
     INIT::$DEFAULT_NUM_RESULTS_FROM_TM = 3;
     INIT::$THRESHOLD_MATCH_TM_NOT_TO_SHOW = 50;
     //get the environment configuration
     self::getEnvConfig();
     INIT::$LOG_REPOSITORY = INIT::$STORAGE_DIR . "/log_archive";
     INIT::$UPLOAD_REPOSITORY = INIT::$STORAGE_DIR . "/upload";
     INIT::$FILES_REPOSITORY = INIT::$STORAGE_DIR . "/files_storage/files";
     INIT::$CACHE_REPOSITORY = INIT::$STORAGE_DIR . "/files_storage/cache";
     INIT::$CONVERSIONERRORS_REPOSITORY = INIT::$STORAGE_DIR . "/conversion_errors";
     INIT::$CONVERSIONERRORS_REPOSITORY_WEB = INIT::$BASEURL . "storage/conversion_errors";
     INIT::$TMP_DOWNLOAD = INIT::$STORAGE_DIR . "/tmp_download";
     INIT::$REFERENCE_REPOSITORY = INIT::$STORAGE_DIR . "/reference_files";
     INIT::$TEMPLATE_ROOT = INIT::$ROOT . "/lib/View";
     INIT::$MODEL_ROOT = INIT::$ROOT . '/lib/Model';
     INIT::$CONTROLLER_ROOT = INIT::$ROOT . '/lib/Controller';
     INIT::$UTILS_ROOT = INIT::$ROOT . '/lib/Utils';
     if (!is_dir(INIT::$STORAGE_DIR)) {
         mkdir(INIT::$STORAGE_DIR, 0755, true);
     }
     if (!is_dir(INIT::$LOG_REPOSITORY)) {
         mkdir(INIT::$LOG_REPOSITORY, 0755, true);
     }
     if (!is_dir(INIT::$UPLOAD_REPOSITORY)) {
         mkdir(INIT::$UPLOAD_REPOSITORY, 0755, true);
     }
     if (!is_dir(INIT::$FILES_REPOSITORY)) {
         mkdir(INIT::$FILES_REPOSITORY, 0755, true);
     }
     if (!is_dir(INIT::$CACHE_REPOSITORY)) {
         mkdir(INIT::$CACHE_REPOSITORY, 0755, true);
     }
     if (!is_dir(INIT::$CONVERSIONERRORS_REPOSITORY)) {
         mkdir(INIT::$CONVERSIONERRORS_REPOSITORY, 0755, true);
     }
     //auth sections
     INIT::$AUTHSECRET_PATH = INIT::$ROOT . '/inc/login_secret.dat';
     //if secret is set in file
     if (file_exists(INIT::$AUTHSECRET_PATH)) {
         //fetch it
         INIT::$AUTHSECRET = file_get_contents(INIT::$AUTHSECRET_PATH);
     } else {
         //try creating the file and the fetch it
         //generate pass
         $secret = self::generate_password(512);
         //put file
         file_put_contents(INIT::$AUTHSECRET_PATH, $secret);
         //if put succeed
         if (file_exists(INIT::$AUTHSECRET_PATH)) {
             //restrict permissions
             chmod(INIT::$AUTHSECRET_PATH, 0400);
         } else {
             //if couldn't create due to permissions, use default secret
             INIT::$AUTHSECRET = 'ScavengerOfHumanSorrow';
         }
     }
 }