Example #1
0
 public function testGetValue()
 {
     $expectedValue = 'some value';
     $path = 'some path';
     $configData = $this->getConfigDataMock('getValue');
     $configData->expects($this->once())->method('getValue')->with($this->equalTo($path))->will($this->returnValue($expectedValue));
     $this->sectionPool->expects($this->once())->method('getScope')->with($this->equalTo('default'), $this->isNull())->will($this->returnValue($configData));
     $this->assertEquals($expectedValue, $this->model->getValue($path));
 }
Example #2
0
 /**
  * Set up class properties etc.
  */
 private function Setup()
 {
     // place for additional sets
     // e.g. $this->aConfig[ section_key ][ value_key ] = value
     $sAppConfigIni = DOCROOT . $this->oConfig->getValue(sprintf('applications.%s.config_file', $this->oRouter->getApplicationName()));
     $this->oConfig->loadIniFile($sAppConfigIni);
     $this->sLogsDirectory = $this->getConfig('General.Logs_directory', DOCROOT . 'logs/');
     $this->sLogsDirectory .= date('Y-m-d') . '/';
     // set main framework path
     $this->addPath('Lithium');
     // set application path received from config file
     if ($sAppPath = $this->getConfig('General.App_path')) {
         $this->addPath($sAppPath);
         Loader::addPath(DOCROOT . $sAppPath);
     }
     // add path for external classes
     Loader::addPath(DOCROOT);
     // set language
     if ($sLanguage = $this->getConfig('Locale.Language')) {
         $this->sLanguage = $sLanguage;
     }
     Core_Model::setLithium($this);
     Core_Module::setLithium($this);
     Database_Driver::setLithium($this);
     // initialize router
     $this->oRouter->init();
     View::setRouter($this->oRouter);
     Module_Sorter::setRouter($this->oRouter);
     Module_Pagination::setRouter($this->oRouter);
 }
Example #3
0
 /**
  * Crear un nuevo usuario en la BBDD con los datos de LDAP.
  * Esta función crea los usuarios de LDAP en la BBDD para almacenar infomación del mismo
  * y utilizarlo en caso de fallo de LDAP
  *
  * @param User $User
  * @return bool
  */
 public static function newUserLDAP(User $User)
 {
     $passdata = UserPass::makeUserPassHash($User->getUserPass());
     $groupId = Config::getValue('ldap_defaultgroup', 0);
     $profileId = Config::getValue('ldap_defaultprofile', 0);
     $query = 'INSERT INTO usrData SET ' . 'user_name = :name,' . 'user_groupId = :groupId,' . 'user_login = :login,' . 'user_pass = :pass,' . 'user_hashSalt = :hashSalt,' . 'user_email = :email,' . 'user_notes = :notes,' . 'user_profileId = :profileId,' . 'user_isLdap = 1,' . 'user_isDisabled = :isDisabled';
     $data['name'] = $User->getUserName();
     $data['login'] = $User->getUserLogin();
     $data['pass'] = $passdata['pass'];
     $data['hashSalt'] = $passdata['salt'];
     $data['email'] = $User->getUserEmail();
     $data['notes'] = _('Usuario de LDAP');
     $data['groupId'] = $groupId;
     $data['profileId'] = $profileId;
     $data['isDisabled'] = $groupId === 0 || $profileId === 0 ? 1 : 0;
     if (DB::getQuery($query, __FUNCTION__, $data) === false) {
         return false;
     }
     if (!$groupId || !$profileId) {
         $Log = new Log(_('Activación Cuenta'));
         $Log->addDescription(_('Su cuenta está pendiente de activación.'));
         $Log->addDescription(_('En breve recibirá un email de confirmación.'));
         $Log->writeLog();
         Email::sendEmail($Log, $User->getUserEmail(), false);
     }
     Log::writeNewLogAndEmail(_('Nuevo usuario de LDAP'), sprintf("%s (%s)", $User->getUserName(), $User->getUserLogin()));
     return true;
 }
Example #4
0
 /**
  * Parse current request url
  */
 protected function parseURL()
 {
     $aUrlParts = explode('/', $this->getCurrentPath());
     $iUrlPos = 1;
     if ($this->bUrlContainsAppName) {
         // in first pos we have app name so we switch to controller name
         $iUrlPos++;
     }
     $this->sControllerName = sprintf('Controller_%s', ucfirst(strtolower($this->oConfig->getValue('router.default_controller', 'index'))));
     $this->sFunctionName = sprintf('%sAction', strtolower($this->oConfig->getValue('router.default_function', 'index')));
     // Check if we should use different then default controller
     if (!empty($aUrlParts[$iUrlPos])) {
         $this->sControllerName = 'Controller_' . ucfirst($aUrlParts[$iUrlPos]);
         // Function name
         $iUrlPos++;
         if (!empty($aUrlParts[$iUrlPos])) {
             $this->sFunctionName = strtolower($aUrlParts[$iUrlPos]) . 'Action';
             //params pos
             $iUrlPos++;
             if (!empty($aUrlParts[$iUrlPos])) {
                 for ($i = $iUrlPos; $i < count($aUrlParts); $i++) {
                     $this->aParams[] = $aUrlParts[$i];
                 }
             }
         }
         // if function
     }
     // if controller
 }
Example #5
0
 private function __construct()
 {
     try {
         $databaseHost = Config::getValue('mysql/host');
         $databaseName = Config::getValue('mysql/db');
         $databaseUsername = Config::getValue('mysql/username');
         $databasePassword = Config::getValue('mysql/password');
         $this->_pdo = new PDO('mysql:host=' . $databaseHost . ';dbname=' . $databaseName, $databaseUsername, $databasePassword, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
     } catch (PDOException $e) {
         die($e->getMessage());
     }
 }
Example #6
0
 /**
  * Generates a connect string to use when creating a PDO object.
  * @param Config $config
  * @return string PDO connect string
  */
 public static function getConnectString($config)
 {
     //set default db type to mysql if not set
     $db_type = $config->getValue('db_type');
     if (!$db_type) {
         $db_type = 'mysql';
     }
     $db_socket = $config->getValue('db_socket');
     if (!$db_socket) {
         $db_port = $config->getValue('db_port');
         if (!$db_port) {
             $db_socket = '';
         } else {
             $db_socket = ";port=" . $config->getValue('db_port');
         }
     } else {
         $db_socket = ";unix_socket=" . $db_socket;
     }
     $db_string = sprintf("%s:dbname=%s;host=%s%s", $db_type, $config->getValue('db_name'), $config->getValue('db_host'), $db_socket);
     return $db_string;
 }
Example #7
0
 /**
  * Establece el lenguaje de la aplicación.
  * Esta función establece el lenguaje según esté definido en la configuración o en el navegador.
  */
 private function getGlobalLang()
 {
     $browserLang = $this->getBrowserLang();
     $configLang = Config::getValue('sitelang');
     // Establecer a en_US si no existe la traducción o no es español
     if (!$configLang && !$this->checkLangFile($browserLang) && !preg_match('/^es_.*/i', $browserLang)) {
         $lang = 'en_US';
     } else {
         $lang = $configLang ? $configLang : $browserLang;
     }
     return $lang;
 }
 public function update($id, $request)
 {
     $config = new Config(CONFIG . 'app.json');
     $config->parseFile();
     $data = $request->getParameters();
     if (isset($data['userRankSubmit'])) {
         if (User::exists($id)) {
             $user = User::find($id);
             $data['ranks'][$config->getValue('rankAdmin')] = ['Administrateur', 'danger'];
             $data['ranks'][$config->getValue('rankModo')] = ['Modérateur', 'warning'];
             $data['ranks'][$config->getValue('rankTeam')] = ['Equipe', 'success'];
             $data['ranks'][$config->getValue('rankContributor')] = ['Contributeur', 'info'];
             $data['ranks'][$config->getValue('rankUser')] = ['Utilisateur', 'primary'];
             $user->rank = $data['rank'];
             $user->save();
             $data['user'] = $user;
             $r = new ViewResponse("admin/settings/edit_user", $data);
             $r->addMessage(ViewMessage::success($user->username . " désormais {$data['ranks'][$user->rank][0]}"));
             return $r;
         }
     }
 }
Example #9
0
 /**
  *
  * Connect to database using PDO
  * @return PDO
  */
 private function connect()
 {
     $db_string = sprintf("mysql:dbname=%s;host=%s", $this->config->getValue('db_name'), $this->config->getValue('db_host'));
     if ($this->DEBUG) {
         echo "DEBUG: Connecting to {$db_string}\n";
     }
     $db_socket = $this->config->getValue('db_socket');
     if ($db_socket) {
         $db_string .= ";unix_socket=" . $db_socket;
     }
     $pdo = new PDO($db_string, $this->config->getValue('db_user'), $this->config->getValue('db_password'));
     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return $pdo;
 }
Example #10
0
 /**
  *
  * Connect to database using PDO
  * @return PDO
  */
 private function connect()
 {
     $db_string = sprintf("mysql:dbname=test;host=localhost");
     /*
     if ($this->DEBUG) {
         echo "DEBUG: Connecting to $db_string\n";
     }
     */
     $db_socket = $this->config->getValue('db_socket');
     if ($db_socket) {
         $db_string .= ";unix_socket=" . $db_socket;
     }
     $pdo = new PDO($db_string, 'root', '');
     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return $pdo;
 }
Example #11
0
 public static function init()
 {
     if (!Config::getValue('php')) {
         return;
     }
     // debug
     if (Config::getValue('php', 'debug')) {
         error_reporting(E_ALL);
         ini_set('display_errors', 'On');
         ini_set('display_startup_errors', 'On');
     }
     // session
     if (Config::getValue('php', 'session')) {
         session_cache_limiter(false);
         session_start();
         if ($tmp = Config::getValue('php', 'session_lifetime')) {
             ini_set("session.cookie_lifetime", $tmp);
         }
     }
     // cas
     if ($tmp = Config::getValue('php', 'timezone', 'Europe/Prague')) {
         date_default_timezone_set($tmp);
     }
     // locales
     if ($locality = Config::getValue('php', 'locality')) {
         if (in_array(explode('.', $locality, 2)[0], Config::getValue('php', 'locales_available'))) {
             // Set language
             putenv('LC_ALL=' . $locality);
             setlocale(LC_ALL, $locality);
             setlocale(LC_MESSAGES, $locality);
             // Specify the location of the translation tables
             if ($localization_name = Config::getValue('php', 'localization_name')) {
                 bindtextdomain($localization_name, './locales');
                 bind_textdomain_codeset($localization_name, 'UTF-8');
                 textdomain($localization_name);
             }
         } else {
             error_log("Unsupported locales" . $locales);
         }
     }
 }
Example #12
0
 /**
  * Buscar al usuario en un grupo.
  *
  * @param string $userLogin con el login del usuario
  * @throws \Exception
  * @return bool
  */
 public static function searchADUserInGroup($userLogin)
 {
     if (Ldap::$_isADS === false) {
         return false;
     }
     $log = new Log(__FUNCTION__);
     $ldapGroup = Config::getValue('ldap_group');
     // El filtro de grupo no está establecido
     if (empty($ldapGroup)) {
         return true;
     }
     // Obtenemos el DN del grupo
     if (!($groupDN = Ldap::searchGroupDN())) {
         return false;
     }
     $filter = '(memberof:1.2.840.113556.1.4.1941:=' . $groupDN . ')';
     $filterAttr = array("sAMAccountName");
     $searchRes = @ldap_search(Ldap::$_ldapConn, Ldap::$_searchBase, $filter, $filterAttr);
     if (!$searchRes) {
         $log->addDescription(_('Error al buscar el grupo de usuarios'));
         $log->addDescription('LDAP ERROR: ' . ldap_error(Ldap::$_ldapConn) . '(' . ldap_errno(Ldap::$_ldapConn) . ')');
         $log->addDescription('LDAP FILTER: ' . $filter);
         $log->writeLog();
         throw new \Exception(_('Error al buscar el grupo de usuarios'));
     }
     if (@ldap_count_entries(Ldap::$_ldapConn, $searchRes) === 0) {
         $log->addDescription(_('No se encontró el grupo con ese nombre'));
         $log->addDescription('LDAP ERROR: ' . ldap_error(Ldap::$_ldapConn) . '(' . ldap_errno(Ldap::$_ldapConn) . ')');
         $log->addDescription('LDAP FILTER: ' . $filter);
         $log->writeLog();
         throw new \Exception(_('No se encontró el grupo con ese nombre'));
     }
     foreach (ldap_get_entries(Ldap::$_ldapConn, $searchRes) as $entry) {
         if ($userLogin === $entry['samaccountname'][0]) {
             return true;
         }
     }
     return false;
 }
 /**
  * Realizar la conexión con la BBDD.
  * Esta función utiliza PDO para conectar con la base de datos.
  * @return PDO
  * @throws \Exception
  */
 public function getConnection()
 {
     if (!$this->_db) {
         $dbhost = Config::getValue('dbhost');
         $dbuser = Config::getValue('dbuser');
         $dbpass = Config::getValue('dbpass');
         $dbname = Config::getValue('dbname');
         $dbport = Config::getValue('dbport', 3306);
         if (empty($dbhost) || empty($dbuser) || empty($dbpass) || empty($dbname)) {
             throw new \Exception(_('No es posible conectar con la BD'), 1);
         }
         try {
             $dsn = 'mysql:host=' . $dbhost . ';port=' . $dbport . ';dbname=' . $dbname . ';charset=utf8';
             //                $this->db = new PDO($dsn, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true));
             $this->_db = new PDO($dsn, $dbuser, $dbpass);
         } catch (\Exception $e) {
             throw $e;
         }
     }
     $this->_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
     $this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return $this->_db;
 }
Example #14
0
 /**
  * Constructor
  */
 function __construct()
 {
     $userResultsPerPage = Session::getUserPreferences()->getResultsPerPage();
     $this->setLimitCount($userResultsPerPage > 0 ? $userResultsPerPage : Config::getValue('account_count'));
     $this->setSortViews(Session::getUserPreferences()->isSortViews());
 }
Example #15
0
 /**
  * Inicializar la clase PHPMailer.
  *
  * @param string $mailTo con la dirección del destinatario
  * @param string $action con la acción realizada
  * @return false|\PHPMailer
  */
 private static function getEmailObject($mailTo, $action)
 {
     $appName = Util::getAppInfo('appname');
     $mailFrom = Config::getValue('mail_from');
     $mailServer = Config::getValue('mail_server');
     $mailPort = Config::getValue('mail_port', 25);
     $mailAuth = Config::getValue('mail_authenabled', FALSE);
     if ($mailAuth) {
         $mailUser = Config::getValue('mail_user');
         $mailPass = Config::getValue('mail_pass');
     }
     if (!$mailServer) {
         return false;
     }
     if (empty($mailTo)) {
         $mailTo = $mailFrom;
     }
     require_once EXTENSIONS_PATH . '/phpmailer/class.phpmailer.php';
     require_once EXTENSIONS_PATH . '/phpmailer/class.smtp.php';
     $mail = new \PHPMailer();
     $mail->isSMTP();
     $mail->CharSet = 'utf-8';
     $mail->Host = $mailServer;
     $mail->Port = $mailPort;
     if ($mailAuth) {
         $mail->SMTPAuth = $mailAuth;
         $mail->Username = $mailUser;
         $mail->Password = $mailPass;
     }
     $mail->SMTPSecure = strtolower(Config::getValue('mail_security'));
     //$mail->SMTPDebug = 2;
     //$mail->Debugoutput = 'error_log';
     $mail->setFrom($mailFrom, $appName);
     $mail->addAddress($mailTo);
     $mail->addReplyTo($mailFrom, $appName);
     $mail->WordWrap = 100;
     $mail->Subject = $appName . ' (' . _('Aviso') . ') - ' . $action;
     return $mail;
 }
Example #16
0
    $form["Abilit"] = 5;
    $form["Access"] = 0;
    $form["Login"] = "";
    $form["Password"] = "";
    $form["confpass"] = "";
}

if (isset($_POST['Submit'])) {
    //controllo i campi
    if (empty($form["Cognome"]))
        $msg .= "1+";
    if (empty($form["Login"]))
        $msg .= "2+";
    if (empty($form["Password"]))
        $msg .= "3+";
    if (strlen($form["Password"]) < $config->getValue('psw_min_length'))
        $msg .= "4+";
    if ($form["Password"] != $form["confpass"] )
        $msg .= "5+";
    if ($form["Abilit"] > $user_data["Abilit"] )
        $msg .= "6+";
    if (! empty($_FILES['userfile']['name'])) {
        if (!( $_FILES['userfile']['type'] == "image/jpeg" || $_FILES['userfile']['type'] == "image/pjpeg"))
            $msg .= "7+";
            // controllo che il file non sia pi&ugrave; grande di 10kb
        if ( $_FILES['userfile']['size'] > 10999)
            $msg .= "8+";
    }
    if ($form["Abilit"] < 9) {
        $ricerca=$form["Login"];
        $rs_utente = gaz_dbi_dyn_query("*", $gTables['admin'], "Login <> '$ricerca' and Abilit ='9'", "Login",0,1);
Example #17
0
/**
 * Makes sure that the config file is properly setup.
 */
function check_config($config_file)
{
    # Read in config_default.php
    require_once LIBDIR . 'config_default.php';
    # Make sure their PHP version is current enough
    if (strcmp(phpversion(), REQUIRED_PHP_VERSION) < 0) {
        system_message(array('title' => _('Incorrect version of PHP'), 'body' => sprintf('phpLDAPadmin requires PHP version %s or greater.<br /><small>(You are using %s)</small>', REQUIRED_PHP_VERSION, phpversion()), 'type' => 'error'));
    }
    $config = new Config();
    if (file_exists(LIBDIR . 'config_custom.php') && is_readable(LIBDIR . 'config_custom.php')) {
        include LIBDIR . 'config_custom.php';
    }
    ob_start();
    require $config_file;
    $str = '';
    if (ob_get_level()) {
        $str = ob_get_contents();
        ob_end_clean();
    }
    if ($str) {
        $str = strip_tags($str);
        $matches = array();
        preg_match('/(.*):\\s+(.*):.*\\s+on line (\\d+)/', $str, $matches);
        if (isset($matches[1]) && isset($matches[2]) && isset($matches[3])) {
            $error_type = $matches[1];
            $error = $matches[2];
            $line_num = $matches[3];
            $file = file($config_file);
            $body = '<h3 class="title">Config file ERROR</h3>';
            $body .= sprintf('<h3 class="subtitle">%s (%s) on line %s</h3>', $error_type, $error, $line_num);
            $body .= '<center>';
            $body .= sprintf('Looks like your config file has an ERROR on line %s.<br />', $line_num);
            $body .= 'Here is a snippet around that line <br />';
            $body .= '<br />' . "\n";
            $body .= '<div style="text-align: left; font-family: monospace; margin-left: 80px; margin-right: 80px; border: 1px solid black; padding: 10px;">';
            for ($i = $line_num - 9; $i < $line_num + 5; $i++) {
                if ($i + 1 == $line_num) {
                    $body .= '<div style="color:red;background:#fdd">';
                }
                if ($i < 0) {
                    continue;
                }
                $body .= sprintf('<b>%s</b>: %s<br />', $i + 1, $file[$i]);
                if ($i + 1 == $line_num) {
                    $body .= '</div>';
                }
            }
            $body .= '</div>';
            $body .= '<br />';
            $body .= 'Hint: Sometimes these errors are caused by lines <b>preceding</b> the line reported.';
            $body .= '</center>';
            $block = new block();
            $block->SetBody($body);
            $www['page'] = new page();
            $www['page']->block_add('body', $block);
            $www['page']->display();
            die;
        }
    }
    # Check for server definitions.
    if (!isset($servers) || count($servers->GetServerList()) == 0) {
        error(_('Your config.php is missing Server Definitions. Please see the sample file config/config.php.example.'), 'error', 'index.php', true);
    }
    $config->setServers($servers);
    # Check the memory limit parameter.
    if (ini_get('memory_limit') > -1 && ini_get('memory_limit') < $config->getValue('session', 'memorylimit')) {
        system_message(array('title' => _('Memory Limit low.'), 'body' => sprintf('Your php memory limit is low - currently %s, you should increase it to atleast %s. This is normally controlled in /etc/php.ini.', ini_get('memory_limit'), $config->getValue('session', 'memorylimit')), 'type' => 'error'));
    }
    return $config;
}
Example #18
0
 /**
  * Comprobar que la base de datos existe.
  *
  * @return bool
  * @throws SPException
  */
 public static function checkDatabaseExist()
 {
     try {
         $db = DBConnectionFactory::getFactory()->getConnection();
         $query = 'SELECT COUNT(*) ' . 'FROM information_schema.tables ' . 'WHERE table_schema=\'' . Config::getValue("dbname") . '\' ' . 'AND table_name = \'usrData\'';
         if ($db->query($query)->fetchColumn() !== 0) {
             return true;
         }
     } catch (\Exception $e) {
         throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), $e->getCode());
     }
     return false;
 }
Example #19
0
 /**
  * Obtener datos desde una URL usando CURL
  *
  * @param $url string La URL
  * @return bool|string
  */
 public static function getDataFromUrl($url)
 {
     if (!self::curlIsAvailable()) {
         return false;
     }
     $ch = curl_init($url);
     if (Config::getValue('proxy_enabled')) {
         curl_setopt($ch, CURLOPT_PROXY, Config::getValue('proxy_server'));
         curl_setopt($ch, CURLOPT_PROXYPORT, Config::getValue('proxy_port'));
         curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
         $proxyUser = Config::getValue('proxy_user');
         if ($proxyUser) {
             $proxyAuth = $proxyUser . ':' . Config::getValue('proxy_pass');
             curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
         }
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_USERAGENT, "sysPass-App");
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
     $data = curl_exec($ch);
     if ($data === false) {
         Log::writeNewLog(__FUNCTION__, curl_error($ch));
         return false;
     }
     return $data;
 }
Example #20
0
 /**
  * available categories are stored in codev_config_table.
  * @return string[] (id => name)
  */
 public function getCategoryList()
 {
     if (NULL == $this->categoryList) {
         $this->categoryList = Config::getValue(Config::id_blogCategories);
         ksort($this->categoryList);
     }
     return $this->categoryList;
 }
Example #21
0
 /**
  * Comprobar si el grupo de LDAP está habilitado.
  *
  * @param string $group con el nombre del grupo
  * @return bool
  */
 private static function checkLDAPGroup($group)
 {
     $ldapGroup = strtolower(Config::getValue('ldap_group'));
     $groupName = array();
     preg_match('/^cn=([\\w\\s-]+),.*/i', $group, $groupName);
     if (strtolower($groupName[1]) == $ldapGroup || strtolower($group) == $ldapGroup) {
         return true;
     }
     return false;
 }
Example #22
0
 public static function getTeam($userInFirst = false)
 {
     $order = $userInFirst ? 'id=' . Session::get()->id . ' DESC' : 'id';
     $conf = new Config(CONFIG . 'app.json');
     $conf->parseFile();
     $ranks = ['rankTeam', 'rankModo', 'rankAdmin'];
     foreach ($ranks as $k => $rank) {
         $ranks[$k] = $conf->getValue($rank);
     }
     $ranks_str = implode(' ,', $ranks);
     return self::find('all', ['conditions' => "rank in ({$ranks_str})", 'order' => $order, 'include' => ['details']]);
 }
Example #23
0
 /**
  * get dashboard settings from DB
  * 
  * if user has saved some settings, return them.
  * if none, return team settings.
  * if none, return default settings
  */
 private function getSettings()
 {
     /*
        settings = array (
          'dashboardTitle' => 'dashboard title'
          'displayedPlugins' => array(
             array(
                'pluginClassName' => <pluginClassName>,
                'plugin_attr1' => 'val',
                'plugin_attr2' => 'val',
             )
          )
       )
     */
     if (NULL == $this->settings) {
         // get [team, user] specific settings
         $json = Config::getValue(Config::id_dashboard . $this->id, array($this->userid, 0, $this->teamid, 0, 0, 0), true);
         // if not found, get [team] specific settings
         if (NULL == $json) {
             $json = Config::getValue(Config::id_dashboard . $this->id, array(0, 0, $this->teamid, 0, 0, 0), true);
         }
         // if no specific settings, use default values (from config.ini)
         if (NULL == $json) {
             $defaultPlugins = Constants::$dashboardDefaultPlugins[$this->domain];
             $pluginAttributes = array();
             if ($defaultPlugins) {
                 foreach ($defaultPlugins as $pluginClassName) {
                     $pluginAttributes[] = array('pluginClassName' => $pluginClassName);
                     //self::$logger->error($this->domain." default plugin: ".$pluginClassName);
                 }
             }
             $this->settings = array(self::SETTINGS_DASHBOARD_TITLE => 'Dashboard Title', self::SETTINGS_DISPLAYED_PLUGINS => $pluginAttributes);
         } else {
             // convert json to array
             $this->settings = json_decode($json, true);
             if (is_null($this->settings)) {
                 self::$logger->error("Dashboard settings: json could not be decoded !");
                 $this->settings = array(self::SETTINGS_DASHBOARD_TITLE => 'ERROR on dashboard settings', self::SETTINGS_DISPLAYED_PLUGINS => array());
                 // failover
             }
             // TODO check that expected keys exists ?
             //self::$logger->error("settings= " . var_export($this->settings, true));
         }
     }
     return $this->settings;
 }
Example #24
0
 /**
  * Devolver el tema visual de sysPass desde la configuración
  */
 private function getGlobalTheme()
 {
     self::$theme = Config::getValue('sitetheme', 'material-blue');
     return self::$theme;
 }
Example #25
0
 /**
  *
  * @return array ('checkName' => [0,1] isEnabled)
  */
 public function getGeneralPrefsList()
 {
     if (empty($this->generalPrefsList)) {
         $checkList = Config::getValue(Config::id_teamGeneralPreferences, array(0, 0, $this->id, 0, 0, 0), true);
         // get default checkList if not found
         $this->generalPrefsList = Team::$defaultGeneralPrefsList;
         // update with team specific items
         if ($checkList != NULL && is_array($checkList)) {
             foreach ($checkList as $name => $enabled) {
                 if (!array_key_exists($name, $this->generalPrefsList)) {
                     self::$logger->warn("team {$this->id}: remove unknown/deprecated generalPref: {$name}");
                 } else {
                     $this->generalPrefsList["{$name}"] = $enabled;
                 }
             }
         }
     }
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("team {$this->id} generalPrefsList = " . Tools::doubleImplode(':', ',', $this->generalPrefsList));
     }
     return $this->generalPrefsList;
 }
Example #26
0
        $pdf->SetFont('helvetica','B',8);
        $pdf->Cell($aRiportare['top'][0]['lun'],4,'Totale provvigioni: ',1,0,'R');
        $pdf->Cell($aRiportare['top'][1]['lun'],4,$aRiportare['top'][1]['nam'],1,0,'R');
        $pdf->SetFont('helvetica','',8);
    }
    $agente = getNewAgente($row['id_agente']);
    $item_head['bot']= array(array('lun' => 50,'nam'=>$agente['indspe']),
                              array('lun' => 60,'nam'=>$agente['citspe'].' ('.$agente['prospe'].') '.$agente['telefo']),
                              array('lun' => 37,'nam'=>substr($_GET['datini'],6,2).'.'.substr($_GET['datini'],4,2).'.'.substr($_GET['datini'],0,4).'-'.substr($_GET['datfin'],6,2).'.'.substr($_GET['datfin'],4,2).'.'.substr($_GET['datfin'],0,4))
                          );
    $aRiportare['top'][1]['nam'] = 0;
    $aRiportare['bot'][1]['nam'] = 0;
    $pdf->setRiporti('');
    $pdf->setPageTitle('Agente: '.$agente['ragso1'].' '.$agente['ragso2']);
    $pdf->setItemGroup($item_head);
    $pdf->AddPage('P',$config->getValue('page_format'));
 }
 if ($row['tipdoc'] == 'FNC') {
       $row['quanti'] = -$row['quanti'];
 }
 $row_importo = CalcolaImportoRigo($row['quanti'],$row['prelis'],array($row['scochi'],$row['sconto']));
 $row_provvig = round($row_importo*$row['provvigione']/100,3);
 $tot_prov += $row_provvig;
 $aRiportare['top'][1]['nam'] = gaz_format_number($tot_prov);
 $aRiportare['bot'][1]['nam'] = gaz_format_number($tot_prov);
 if ($ctrlDoc != $row['id_tes']) {
    if ($row['tipdoc'] == 'FAD') {
        $desdoc =  'da '.$strScript['admin_docven.php'][0][$row['tipdoc']].' n.'.$row['numdoc'].' del '.$row['datemi'].' -> Fattura n.'.$row['numfat'].'/'.$row['seziva'].' del '.$row['datfat'].' a '.$row['ragso1'].' '.$row['ragso2'];
    } else {
        $desdoc =  'da '.$strScript['admin_docven.php'][0][$row['tipdoc']].' n.'.$row['numfat'].'/'.$row['seziva'].' del '.$row['datfat'].' a '.$row['ragso1'].' '.$row['ragso2'];
    }
Example #27
0
 public function isPrivate()
 {
     $appConfig = new Config(CONFIG . 'app.json');
     $appConfig->parseFile();
     return Video::exists(array('id' => $this->id, 'visibility' => $appConfig->getValue('vid_visibility_private')));
 }
Example #28
0
 /**
  * Generar una key para su uso con el algoritmo AES
  *
  * @param string $string La cadena de la que deriva la key
  * @param null   $salt   El salt utilizado
  * @return string
  */
 public static function generateAesKey($string, $salt = null)
 {
     if (is_null($salt)) {
         $salt = Config::getValue('passwordsalt');
     }
     $salt = '$2y$07$' . $salt . '$';
     $key = substr(crypt($string, $salt), 7, 32);
     return $key;
 }
Example #29
0
}
require("./lang.".$lang.".php");
$script_transl = $strScript["login_admin.php"];

if (isset($_POST['actionflag'])) {
    $form['Login']=filter_var(substr($_POST['Login'],0,30),FILTER_SANITIZE_MAGIC_QUOTES);
    // checkUser();
    $result = gaz_dbi_get_row ($gTables['admin'], "Login", $form['Login']);
    if ($result) {
        require("../../library/include/HMAC.php");
        $crypt = new Crypt_HMAC($result["Password"], 'md5');
        $hmacPass = $crypt->hash($_COOKIE[session_name()]);
        if ($hmacPass == $_POST['Password']) {
            cleanMemberSession($result["Abilit"], $result["Login"], $result["Password"], $result["Access"], $result['enterprise_id'],$tp);
            $utspas = mktime(0,0,0, substr($result['datpas'],5,2), substr($result['datpas'],8,2), substr($result['datpas'], 0, 4));
            $utsoggi = mktime(0,0,0,date("m"),date("d"),date("Y")) - $config->getValue('giornipass') * 86400;
            if($utspas < $utsoggi) {
                $message .= $result["Nome"]." ".$result["Cognome"].$script_transl[2];
                if (! isset($_POST['Nuovapass'])) {
                    $_POST['Nuovapass'] = '';
                }
                if (! isset($_POST['Confepass'])) {
                    $_POST['Confepass'] = '';
                }
                if($_POST['Password'] != $_POST['Nuovapass'] and $_POST['Nuovapass'] == $_POST['Confepass'] and  strlen($_POST['Nuovapass']) >= $config->getValue('psw_min_length') ) {
                    gaz_dbi_put_row($gTables['admin'], "Login",$form['Login'],"datpas",date("Y-m-d H:i:s"));
                    gaz_dbi_put_row($gTables['admin'], "Login",$form['Login'],"Password",$_POST['Nuovapass']);
                    cleanMemberSession($result["Abilit"], $result["Login"], $_POST["Nuovapass"], $result["Access"], $result['enterprise_id'],$tp);
                    header("Location: ../root/admin.php");
                    exit;
                } else {
Example #30
0
 /** old style usage with $user_id, $key as params
  * still works but is deprecated
  *
  * @see lib/classes/Config::getValue()
  */
 function getValue($field)
 {
     $args = func_get_args();
     if (count($args) > 1) {
         list($user_id, $key) = $args;
         if ($user_id !== null && $key !== null) {
             $ret = UserConfig::get($user_id)->{$key};
         }
         if ($user_id === null) {
             $ret = parent::getValue($key);
         }
         trigger_error('deprecated use of ' . __METHOD__, E_USER_NOTICE);
         return $ret;
     }
     if (array_key_exists($field, $this->data)) {
         return $this->data[$field];
     }
     return null;
 }