private function __construct() { // Read general config from INI file global $_INI_FILE; $root = realpath(dirname(__FILE__) . '/../'); self::$ROOT = $root; // Accesible by Apache/PHP self::$BASE_URL = $_INI_FILE['ui']['baseurl']; // Accesible by the browser set_include_path(get_include_path() . PATH_SEPARATOR . $root); self::$TIME_TO_EDIT_ENABLED = self::getConfigBool('timetoedit', 'ui'); self::$DEFAULT_NUM_RESULTS_FROM_TM = $_INI_FILE['mymemory']['numresults']; self::$THRESHOLD_MATCH_TM_NOT_TO_SHOW = $_INI_FILE['mymemory']['matchthreshold']; self::$DB_SERVER = $_INI_FILE['db']['hostname']; self::$DB_DATABASE = $_INI_FILE['db']['database']; self::$DB_USER = $_INI_FILE['db']['username']; self::$DB_PASS = $_INI_FILE['db']['password']; self::$LOG_ENABLED = self::getConfigBool('logenabled', 'ui'); self::$LOG_MAXCHUNKSIZE = isset($_INI_FILE['ui']['logmaxchunksize']) ? $_INI_FILE['ui']['logmaxchunksize'] : 3000; self::$LOG_REPOSITORY = self::$ROOT . "/" . $_INI_FILE['log']['directory']; self::$LOG_FILENAME = $_INI_FILE['log']['filename']; //log download self::$LOG_DOWNLOAD = self::$ROOT . "/" . $_INI_FILE['download_temp']['directory']; self::$TEMPLATE_ROOT = self::$ROOT . "/lib/view"; self::$MODEL_ROOT = self::$ROOT . '/lib/model'; self::$CONTROLLER_ROOT = self::$ROOT . '/lib/controller'; self::$UTILS_ROOT = self::$ROOT . '/lib/utils'; self::$UPLOAD_ROOT = self::$ROOT . "/" . $_INI_FILE['ui']['uploads']; self::$ENABLED_BROWSERS = array('chrome', 'firefox', 'safari'); self::$BUILD_NUMBER = '0.3.0'; // Casmacat customizations self::$ITP_SERVER = self::getConfig('itpserver'); self::$HTR_SERVER = self::getConfig('htrserver'); self::$BICONCOR_SERVER = self::getConfig('biconcorserver'); self::$SOURCE_LANGUAGE = self::getConfig('sourcelanguage'); self::$TARGET_LANGUAGE = self::getConfig('targetlanguage'); self::$ITP_ENABLED = self::getConfigBool('itpenabled'); self::$PEN_ENABLED = self::getConfigBool('penenabled'); self::$ET_ENABLED = self::getConfigBool('etenabled'); self::$SR_ENABLED = self::getConfigBool('srenabled'); self::$BICONCOR_ENABLED = self::getConfigBool('biconcorenabled'); self::$HIDE_CONTRIBUTIONS = self::getConfigBool('hidecontributions'); self::$FLOAT_PREDICTIONS = self::getConfigBool('floatpredictions'); self::$TRANSLATION_OPTIONS = self::getConfigBool('translationoptions'); self::$ALLOW_CHANGE_VISUALIZATION_OPTIONS = self::getConfigBool('allowchangevisualizationoptions'); self::$ITP_DRAFT_ONLY = self::getConfigBool('itpdraftonly'); self::$ET_TYPE = self::getConfig('ettype', "casmacat", 0); self::$DEBUG = self::getConfigBool('debug', "debug"); }
private function __construct() { $root = realpath(dirname(__FILE__) . '/../'); $OAUTH_CONFIG = parse_ini_file(realpath(dirname(__FILE__) . '/oauth_config.ini'), true); self::$OAUTH_CONFIG = $OAUTH_CONFIG['OAUTH_CONFIG']; register_shutdown_function('INIT::fatalErrorHandler'); if (stripos(PHP_SAPI, 'cli') === false) { register_shutdown_function('INIT::sessionClose'); self::$PROTOCOL = isset($_SERVER['HTTPS']) ? "https" : "http"; self::$HTTPHOST = self::$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 } self::$ROOT = $root; // Accesible by Apache/PHP self::$BASEURL = "/"; // Accesible by the browser self::$TIME_TO_EDIT_ENABLED = false; self::$DEFAULT_NUM_RESULTS_FROM_TM = 3; self::$THRESHOLD_MATCH_TM_NOT_TO_SHOW = 50; self::$DB_SERVER = "localhost"; //database server self::$DB_DATABASE = "matecat"; //database name self::$DB_USER = "******"; //database login self::$DB_PASS = "******"; //database password self::$MEMCACHE_SERVERS = array(); //Not Used self::$REDIS_SERVERS = "tcp://localhost:6379"; self::$QUEUE_BROKER_ADDRESS = "tcp://localhost:61613"; self::$QUEUE_DQF_ADDRESS = "tcp://localhost:61613"; self::$QUEUE_JMX_ADDRESS = "http://localhost:8161"; self::$STORAGE_DIR = self::$ROOT . "/storage"; self::$LOG_REPOSITORY = self::$STORAGE_DIR . "/log_archive"; self::$UPLOAD_REPOSITORY = self::$STORAGE_DIR . "/upload"; self::$CONVERSIONERRORS_REPOSITORY = self::$STORAGE_DIR . "/conversion_errors"; self::$CONVERSIONERRORS_REPOSITORY_WEB = self::$BASEURL . "storage/conversion_errors"; self::$TMP_DOWNLOAD = self::$STORAGE_DIR . "/tmp_download"; self::$REFERENCE_REPOSITORY = self::$STORAGE_DIR . "/reference_files"; self::$TEMPLATE_ROOT = self::$ROOT . "/lib/View"; self::$MODEL_ROOT = self::$ROOT . '/lib/Model'; self::$CONTROLLER_ROOT = self::$ROOT . '/lib/Controller'; self::$UTILS_ROOT = self::$ROOT . '/lib/Utils'; $this->_setIncludePath(); spl_autoload_register('INIT::loadClass'); require_once 'Predis/autoload.php'; if (!is_dir(self::$STORAGE_DIR)) { mkdir(self::$STORAGE_DIR, 0755, true); } if (!is_dir(self::$LOG_REPOSITORY)) { mkdir(self::$LOG_REPOSITORY, 0755, true); } if (!is_dir(self::$UPLOAD_REPOSITORY)) { mkdir(self::$UPLOAD_REPOSITORY, 0755, true); } if (!is_dir(self::$CONVERSIONERRORS_REPOSITORY)) { mkdir(self::$CONVERSIONERRORS_REPOSITORY, 0755, true); } //auth sections self::$AUTHSECRET_PATH = self::$ROOT . '/inc/login_secret.dat'; //if secret is set in file if (file_exists(self::$AUTHSECRET_PATH)) { //fetch it self::$AUTHSECRET = file_get_contents(self::$AUTHSECRET_PATH); } else { //try creating the file and the fetch it //generate pass $secret = self::generate_password(512); //put file file_put_contents(self::$AUTHSECRET_PATH, $secret); //if put succeed if (file_exists(self::$AUTHSECRET_PATH)) { //restrict permissions chmod(self::$AUTHSECRET_PATH, 0400); } else { //if couldn't create due to permissions, use default secret self::$AUTHSECRET = 'ScavengerOfHumanSorrow'; } } self::$ENABLED_BROWSERS = array('applewebkit', 'chrome', 'safari'); //, 'firefox'); // sometimes the browser declare to be Mozilla but does not provide a valid Name (e.g. Safari). // This occurs especially in mobile environment. As an example, when you try to open a link from within // the GMail app, it redirect to an internal browser that does not declare a valid user agent // In this case we will show a notice on the top of the page instead of deny the access self::$UNTESTED_BROWSERS = array('mozillageneric'); /** * Matecat open source by default only handles xliff files with a strong focus on sdlxliff * ( xliff produced by SDL Trados ) * * We are not including the file converters into the Matecat code because we haven't find any open source * library that satisfy the required quality and licensing. * * Here you have two options * a) Keep $CONVERSION_ENABLED to false, manually convert your files into xliff using SDL Trados, Okapi or similar * b) Set $CONVERSION_ENABLED to true and implement your own converter * */ self::$CONVERSION_ENABLED = false; self::$ANALYSIS_WORDS_PER_DAYS = 3000; self::$BUILD_NUMBER = '0.5.5'; self::$VOLUME_ANALYSIS_ENABLED = true; self::$SUPPORT_MAIL = 'the owner of this Matecat instance'; //default string is 'the owner of this Matecat instance' self::$AUTHCOOKIENAME = 'matecat_login_v2'; self::$AUTHCOOKIEDURATION = 86400 * 60; self::$FORCE_XLIFF_CONVERSION = false; self::$WARNING_POLLING_INTERVAL = 20; //seconds self::$SEGMENT_QA_CHECK_INTERVAL = 1; //seconds self::$SPELL_CHECK_TRANSPORT_TYPE = 'shell'; self::$SPELL_CHECK_ENABLED = false; self::$SAVE_SHASUM_FOR_FILES_LOADED = true; self::$MAX_UPLOAD_FILE_SIZE = 60 * 1024 * 1024; // bytes self::$MAX_UPLOAD_TMX_FILE_SIZE = 100 * 1024 * 1024; // bytes self::$MAX_NUM_FILES = 100; self::$SUPPORTED_FILE_TYPES = array('Office' => array('doc' => array('', '', 'extdoc'), 'dot' => array('', '', 'extdoc'), 'docx' => array('', '', 'extdoc'), 'dotx' => array('', '', 'extdoc'), 'docm' => array('', '', 'extdoc'), 'dotm' => array('', '', 'extdoc'), 'rtf' => array('', '', 'extdoc'), 'odt' => array('', '', 'extdoc'), 'sxw' => array('', '', 'extdoc'), 'txt' => array('', '', 'exttxt'), 'pdf' => array('', '', 'extpdf'), 'xls' => array('', '', 'extxls'), 'xlt' => array('', '', 'extxls'), 'xlsm' => array('', '', 'extxls'), 'xlsx' => array('', '', 'extxls'), 'xltx' => array('', '', 'extxls'), 'ods' => array('', '', 'extxls'), 'sxc' => array('', '', 'extxls'), 'csv' => array('', '', 'extxls'), 'pot' => array('', '', 'extppt'), 'pps' => array('', '', 'extppt'), 'ppt' => array('', '', 'extppt'), 'potm' => array('', '', 'extppt'), 'potx' => array('', '', 'extppt'), 'ppsm' => array('', '', 'extppt'), 'ppsx' => array('', '', 'extppt'), 'pptm' => array('', '', 'extppt'), 'pptx' => array('', '', 'extppt'), 'odp' => array('', '', 'extppt'), 'sxi' => array('', '', 'extppt'), 'xml' => array('', '', 'extxml')), 'Web' => array('htm' => array('', '', 'exthtm'), 'html' => array('', '', 'exthtm'), 'xhtml' => array('', '', 'exthtm'), 'xml' => array('', '', 'extxml')), "Interchange Formats" => array('xliff' => array('default', '', 'extxif'), 'sdlxliff' => array('default', '', 'extxif'), 'tmx' => array('', '', 'exttmx'), 'ttx' => array('', '', 'extttx'), 'itd' => array('', '', 'extitd'), 'xlf' => array('default', '', 'extxlf')), "Desktop Publishing" => array('mif' => array('', '', 'extmif'), 'inx' => array('', '', 'extidd'), 'idml' => array('', '', 'extidd'), 'icml' => array('', '', 'extidd'), 'xtg' => array('', '', 'extqxp'), 'tag' => array('', '', 'exttag'), 'xml' => array('', '', 'extxml'), 'dita' => array('', '', 'extdit')), "Localization" => array('properties' => array('', '', 'extpro'), 'rc' => array('', '', 'extrcc'), 'resx' => array('', '', 'extres'), 'xml' => array('', '', 'extxml'), 'dita' => array('', '', 'extdit'), 'sgm' => array('', '', 'extsgm'), 'sgml' => array('', '', 'extsgm'), 'Android xml' => array('', '', 'extxml'), 'strings' => array('', '', 'extstr'))); self::$UNSUPPORTED_FILE_TYPES = array('fm' => array('', "Try converting to MIF"), 'indd' => array('', "Try converting to INX")); /** * If you don't have a client id and client secret, please visit * Google Developers Console (https://console.developers.google.com/) * and follow these instructions: * - click "Create Project" button and specify project name * - In the sidebar on the left, select APIs & auth. * - In the displayed list of APIs, make sure "Google+ API" show a status of ON. If it doesn't, enable it. * - In the sidebar on the left, select "Credentials" under "APIs & auth" menu. * - Click "Create new client ID" button * - under APPLICATION TYPE, select "web application" option * - under AUTHORIZED JAVASCRIPT ORIGINS, insert the domain on which you installed MateCat * - under REDIRECT URIs, insert "http://<domain>/oauth/response" , where <domain> is the same that you specified in the previous step * - click "Create client ID" * Your client ID and client secret are now available. * * Edit the file inc/oauth_config.ini.sample with the right parameters obtained in the previous step of this guide. * set: * OAUTH_CLIENT_ID with your client ID * OAUTH_CLIENT_SECRET with your client secret * OAUTH_CLIENT_APP_NAME with your custom app name, if you want, or leave Matecat * * save and rename to oauth_config.ini file. * * Done! */ self::$OAUTH_CLIENT_ID = self::$OAUTH_CONFIG['OAUTH_CLIENT_ID']; self::$OAUTH_CLIENT_SECRET = self::$OAUTH_CONFIG['OAUTH_CLIENT_SECRET']; self::$OAUTH_CLIENT_APP_NAME = self::$OAUTH_CONFIG['OAUTH_CLIENT_APP_NAME']; self::$OAUTH_REDIRECT_URL = self::$HTTPHOST . "/oauth/response"; self::$OAUTH_SCOPES = array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'); self::$CONFIG_VERSION_ERR_MESSAGE = "Your config.inc.php file is not up-to-date."; }