Exemplo n.º 1
0
/**
 * Return the Lang object initialized the language wanted
 * If the language wanted doesn't exist, we use the default language
 *
 * @param string $culture The i18n code of the language
 * @return Lang the Lang object initialized the language wanted
 */
function getLang($culture)
{
    $filename = dirname(__FILE__) . '/lang/' . $culture . '.php';
    if (file_exists($filename) === false) {
        $filename = dirname(__FILE__) . '/lang/' . Config::getLanguage() . '.php';
    }
    require_once $filename;
    return new Lang();
}
Exemplo n.º 2
0
 /**
  * Function that try to load from the SSO server the user information...
  *
  * @since version 0.84
  **/
 function getFromSSO()
 {
     global $DB, $CFG_GLPI;
     $a_field = array();
     foreach ($CFG_GLPI as $key => $value) {
         if (!is_array($value) && !empty($value) && strstr($key, "_ssofield")) {
             $key = str_replace('_ssofield', '', $key);
             $a_field[$key] = $value;
         }
     }
     if (count($a_field) == 0) {
         return true;
     }
     $this->fields['_ruleright_process'] = true;
     foreach ($a_field as $field => $value) {
         if (!isset($_SERVER[$value]) || empty($_SERVER[$value])) {
             switch ($field) {
                 case "title":
                     $this->fields['usertitles_id'] = 0;
                     break;
                 case "category":
                     $this->fields['usercategories_id'] = 0;
                     break;
                 default:
                     $this->fields[$field] = "";
             }
         } else {
             switch ($field) {
                 case "email1":
                 case "email2":
                 case "email3":
                 case "email4":
                     // Manage multivaluable fields
                     if (!preg_match('/count/', $_SERVER[$value])) {
                         $this->fields["_emails"][] = addslashes($_SERVER[$value]);
                     }
                     // Only get them once if duplicated
                     $this->fields["_emails"] = array_unique($this->fields["_emails"]);
                     break;
                 case "language":
                     $language = Config::getLanguage($_SERVER[$value]);
                     if ($language != '') {
                         $this->fields[$field] = $language;
                     }
                     break;
                 case "title":
                     $this->fields['usertitles_id'] = Dropdown::importExternal('UserTitle', addslashes($_SERVER[$value]));
                     break;
                 case "category":
                     $this->fields['usercategories_id'] = Dropdown::importExternal('UserCategory', addslashes($_SERVER[$value]));
                     break;
                 default:
                     $this->fields[$field] = $_SERVER[$value];
                     break;
             }
         }
     }
     ///Only process rules if working on the master database
     if (!$DB->isSlave()) {
         //Instanciate the affectation's rule
         $rule = new RuleRightCollection();
         $this->fields = $rule->processAllRules(array(), Toolbox::stripslashes_deep($this->fields), array('type' => 'SSO', 'email' => $this->fields["_emails"], 'login' => $this->fields["name"]));
         //If rule  action is ignore import
         if (isset($this->fields["_stop_import"])) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 3
0
    $limit = $_GET['limit'];
    if ($limit <= 0 || $limit > $last + 1) {
        $limit = $last + 1;
    }
} else {
    $limit = $last + 1;
}
$end = $last - $limit;
// Obtain the strips
$list = array();
for ($i = $last; $i > $end; $i--) {
    $list[$i] = Cache::getStrip($i);
}
// Obtain the language
if (isset($_GET['lang'])) {
    $lang = $_GET['lang'];
} else {
    $lang = Config::getLanguage();
}
$lang = getLang($lang);
// Navigation
$nav_img = Config::getUrl() . '/' . Config::getIndex() . '?id=';
// If necessary, obtain the forum data
$wotd = '';
if (Config::getUseFluxbb() === true) {
    $wotd = Forum::getWotdRss($lang);
}
// show the template
header('Content-Type: application/rss+xml');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
include_once Config::getTemplateFolder() . '/' . Config::getTemplateRss() . '/template.rss';
Exemplo n.º 4
0
 /**
  * Function that try to load from LDAP the user information...
  *
  * @param $ldap_connection ldap connection descriptor
  * @param $ldap_method LDAP method
  * @param $userdn Basedn of the user
  * @param $login User Login
  *
  * @return String : basedn of the user / false if not founded
  **/
 function getFromLDAP($ldap_connection, $ldap_method, $userdn, $login)
 {
     global $DB, $CFG_GLPI;
     // we prevent some delay...
     if (empty($ldap_method["host"])) {
         return false;
     }
     if ($ldap_connection) {
         //Set all the search fields
         $this->fields['password'] = "";
         $fields = AuthLDAP::getSyncFields($ldap_method);
         $fields = array_filter($fields);
         $f = array_values($fields);
         $sr = @ldap_read($ldap_connection, $userdn, "objectClass=*", $f);
         $v = ldap_get_entries_clean($ldap_connection, $sr);
         if (!is_array($v) || count($v) == 0 || empty($v[0][$fields['name']][0])) {
             return false;
         }
         //Store user's dn
         $this->fields['user_dn'] = addslashes($userdn);
         //Store date_sync
         $this->fields['date_sync'] = $_SESSION['glpi_currenttime'];
         foreach ($fields as $k => $e) {
             if (empty($v[0][$e][0])) {
                 switch ($k) {
                     case "language":
                         // Not set value : managed but user class
                         break;
                     case "usertitles_id":
                     case "usercategories_id":
                         $this->fields[$k] = 0;
                         break;
                     default:
                         $this->fields[$k] = "";
                 }
             } else {
                 switch ($k) {
                     case "language":
                         $language = Config::getLanguage($v[0][$e][0]);
                         if ($language != '') {
                             $this->fields[$k] = $language;
                         }
                         break;
                     case "usertitles_id":
                         $this->fields[$k] = Dropdown::importExternal('UserTitle', addslashes($v[0][$e][0]));
                         break;
                     case "usercategories_id":
                         $this->fields[$k] = Dropdown::importExternal('UserCategory', addslashes($v[0][$e][0]));
                         break;
                     default:
                         if (!empty($v[0][$e][0])) {
                             $this->fields[$k] = addslashes($v[0][$e][0]);
                         } else {
                             $this->fields[$k] = "";
                         }
                 }
             }
         }
         // Empty array to ensure than syncLdapGroups will be done
         $this->fields["_groups"] = array();
         ///The groups are retrieved by looking into an ldap user object
         if ($ldap_method["group_search_type"] == 0 || $ldap_method["group_search_type"] == 2) {
             $this->getFromLDAPGroupVirtual($ldap_connection, $ldap_method, $userdn, $login);
         }
         ///The groups are retrived by looking into an ldap group object
         if ($ldap_method["group_search_type"] == 1 || $ldap_method["group_search_type"] == 2) {
             $this->getFromLDAPGroupDiscret($ldap_connection, $ldap_method, $userdn, $login);
         }
         ///Only process rules if working on the master database
         if (!$DB->isSlave()) {
             //Instanciate the affectation's rule
             $rule = new RuleRightCollection();
             //Process affectation rules :
             //we don't care about the function's return because all
             //the datas are stored in session temporary
             if (isset($this->fields["_groups"])) {
                 $groups = $this->fields["_groups"];
             } else {
                 $groups = array();
             }
             $this->fields = $rule->processAllRules($groups, $this->fields, array('type' => 'LDAP', 'ldap_server' => $ldap_method["id"], 'connection' => $ldap_connection, 'userdn' => $userdn));
             $this->fields['_ruleright_process'] = true;
             //If rule  action is ignore import
             if (isset($this->fields["_stop_import"])) {
                 return false;
             }
             //or no rights found & do not import users with no rights
             if (!$CFG_GLPI["use_noright_users_add"]) {
                 $ok = false;
                 if (isset($this->fields["_ldap_rules"]) && count($this->fields["_ldap_rules"])) {
                     if (isset($this->fields["_ldap_rules"]["rules_entities_rights"]) && count($this->fields["_ldap_rules"]["rules_entities_rights"])) {
                         $ok = true;
                     }
                     if (!$ok) {
                         $entity_count = 0;
                         $right_count = 0;
                         if (Profile::getDefault()) {
                             $right_count++;
                         }
                         if (isset($this->fields["_ldap_rules"]["rules_entities"])) {
                             $entity_count += count($this->fields["_ldap_rules"]["rules_entities"]);
                         }
                         if (isset($this->input["_ldap_rules"]["rules_rights"])) {
                             $right_count += count($this->fields["_ldap_rules"]["rules_rights"]);
                         }
                         if ($entity_count && $right_count) {
                             $ok = true;
                         }
                     }
                 }
                 if (!$ok) {
                     $this->fields["_stop_import"] = true;
                     return false;
                 }
             }
             //Hook to retrieve more informations for ldap
             $this->fields = doHookFunction("retrieve_more_data_from_ldap", $this->fields);
         }
         return true;
     }
     return false;
 }