strtoupper() static public method

strtoupper function for utf8 string
static public strtoupper ( $str ) : upper
$str string
return upper case string
Example #1
0
function checkOne($name, $tab = "")
{
    global $cmd;
    if (empty($tab)) {
        $tab = Toolbox::strtoupper("LANG{$name}");
    }
    $old = getcwd();
    if (is_dir($name . "/trunk/locales") && is_file($name . "/trunk/locales/fr_FR.php")) {
        echo "+ ----- {$name} -----\n";
        $dir = opendir($name . "/trunk/locales");
        while (($file = readdir($dir)) !== false) {
            if (strpos($file, ".php") && $file != "fr_FR.php") {
                passthru("php {$cmd} {$name}/trunk/locales/fr_FR.php {$name}/trunk/locales/{$file} {$tab}\n");
            }
        }
        closedir($dir);
    } else {
        echo "no {$name}/trunk/locales/fr_FR.php\n";
    }
    chdir($old);
}
 /**
  * Get the attributes needed for processing the rules
  *
  * @see RuleCollection::prepareInputDataForProcess()
  *
  * @param $input  input datas
  * @param $params extra parameters given
  *
  * @return an array of attributes
  **/
 function prepareInputDataForProcess($input, $params)
 {
     $rule_parameters = array();
     //LDAP type method
     if ($params["type"] == "LDAP") {
         //Get all the field to retrieve to be able to process rule matching
         $rule_fields = $this->getFieldsToLookFor();
         //Get all the datas we need from ldap to process the rules
         $sz = @ldap_read($params["connection"], $params["userdn"], "objectClass=*", $rule_fields);
         $rule_input = AuthLDAP::get_entries_clean($params["connection"], $sz);
         if (count($rule_input)) {
             if (isset($input)) {
                 $groups = $input;
             } else {
                 $groups = array();
             }
             $rule_input = $rule_input[0];
             //Get all the ldap fields
             $fields = $this->getFieldsForQuery();
             foreach ($fields as $field) {
                 switch (Toolbox::strtoupper($field)) {
                     case "LDAP_SERVER":
                         $rule_parameters["LDAP_SERVER"] = $params["ldap_server"];
                         break;
                     case "GROUPS":
                         foreach ($groups as $group) {
                             $rule_parameters["GROUPS"][] = $group;
                         }
                         break;
                     default:
                         if (isset($rule_input[$field])) {
                             if (!is_array($rule_input[$field])) {
                                 $rule_parameters[$field] = $rule_input[$field];
                             } else {
                                 if (count($rule_input[$field])) {
                                     foreach ($rule_input[$field] as $key => $val) {
                                         if ($key !== 'count') {
                                             $rule_parameters[$field][] = $val;
                                         }
                                     }
                                 }
                             }
                         }
                 }
             }
             return $rule_parameters;
         }
         return $rule_input;
     } else {
         if ($params["type"] == "SSO") {
             $rule_parameters["MAIL_EMAIL"] = $params["email"];
             $rule_parameters["LOGIN"] = $params["login"];
             return $rule_parameters;
         }
     }
     //IMAP/POP login method
     $rule_parameters["MAIL_SERVER"] = $params["mail_server"];
     $rule_parameters["MAIL_EMAIL"] = $params["email"];
     return $rule_parameters;
 }
Example #3
0
 /**
  * Private function : Recursivly get attached documents
  *
  * @param $mid          message id
  * @param $path         temporary path
  * @param $maxsize      of document to be retrieved
  * @param $structure    of the message or part
  * @param $part         part for recursive
  *
  * Result is stored in $this->files
  **/
 function getRecursiveAttached($mid, $path, $maxsize, $structure, $part = "")
 {
     if ($structure->type == 1) {
         // multipart
         reset($structure->parts);
         while (list($index, $sub) = each($structure->parts)) {
             $this->getRecursiveAttached($mid, $path, $maxsize, $sub, $part ? $part . "." . ($index + 1) : $index + 1);
         }
     } else {
         $filename = '';
         if ($structure->ifdparameters) {
             // get filename of attachment if present
             // if there are any dparameters present in this part
             if (count($structure->dparameters) > 0) {
                 foreach ($structure->dparameters as $dparam) {
                     if (Toolbox::strtoupper($dparam->attribute) == 'NAME' || Toolbox::strtoupper($dparam->attribute) == 'FILENAME') {
                         $filename = $dparam->value;
                     }
                 }
             }
         }
         //if no filename found
         if (empty($filename) && $structure->ifparameters) {
             // if there are any parameters present in this part
             if (count($structure->parameters) > 0) {
                 foreach ($structure->parameters as $param) {
                     if (Toolbox::strtoupper($param->attribute) == 'NAME' || Toolbox::strtoupper($param->attribute) == 'FILENAME') {
                         $filename = $param->value;
                     }
                 }
             }
         }
         if (empty($filename) && $structure->type == 5 && $structure->subtype) {
             // Embeded image come without filename - generate trivial one
             $filename = "image_{$part}." . $structure->subtype;
         }
         // if no filename found, ignore this part
         if (empty($filename)) {
             return false;
         }
         //try to avoid conflict between inline image and attachment
         $i = 2;
         while (in_array($filename, $this->files)) {
             //replace filename with name_(num).EXT by name_(num+1).EXT
             $new_filename = preg_replace("/(.*)_([0-9])*(\\.[a-zA-Z0-9]*)\$/", "\$1_" . $i . "\$3", $filename);
             if ($new_filename !== $filename) {
                 $filename = $new_filename;
             } else {
                 //the previous regex didn't found _num pattern, so add it with this one
                 $filename = preg_replace("/(.*)(\\.[a-zA-Z0-9]*)\$/", "\$1_" . $i . "\$2", $filename);
             }
             $i++;
         }
         $filename = $this->decodeMimeString($filename);
         if ($structure->bytes > $maxsize) {
             $this->addtobody .= "\n\n" . sprintf(__('%1$s: %2$s'), __('Too large attached file'), sprintf(__('%1$s (%2$s)'), $filename, Toolbox::getSize($structure->bytes)));
             return false;
         }
         if (!Document::isValidDoc($filename)) {
             //TRANS: %1$s is the filename and %2$s its mime type
             $this->addtobody .= "\n\n" . sprintf(__('%1$s: %2$s'), __('Invalid attached file'), sprintf(__('%1$s (%2$s)'), $filename, $this->get_mime_type($structure)));
             return false;
         }
         if ($message = imap_fetchbody($this->marubox, $mid, $part)) {
             switch ($structure->encoding) {
                 case 1:
                     $message = imap_8bit($message);
                     break;
                 case 2:
                     $message = imap_binary($message);
                     break;
                 case 3:
                     $message = imap_base64($message);
                     break;
                 case 4:
                     $message = quoted_printable_decode($message);
                     break;
             }
             if (file_put_contents($path . $filename, $message)) {
                 $this->files[$filename] = $filename;
                 // If embeded image, we add a tag
                 if ($structure->type == 5 && $structure->subtype) {
                     end($this->files);
                     $tag = Rule::getUuid();
                     $this->tags[$filename] = $tag;
                     // Link file based on id
                     if (isset($structure->id)) {
                         $clean = array('<' => '', '>' => '');
                         $this->altfiles[strtr($structure->id, $clean)] = $filename;
                     }
                 }
             }
         }
         // fetchbody
     }
     // Single part
 }
 /**
  * Is this file a valid file ? check based on file extension
  *
  * @param $filename filename to clean
  **/
 static function isValidDoc($filename)
 {
     global $DB;
     $splitter = explode(".", $filename);
     $ext = end($splitter);
     $query = "SELECT *\n              FROM `glpi_documenttypes`\n              WHERE `ext` LIKE '{$ext}'\n                    AND `is_uploadable`='1'";
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result) > 0) {
             return Toolbox::strtoupper($ext);
         }
     }
     // Not found try with regex one
     $query = "SELECT *\n                FROM `glpi_documenttypes`\n                WHERE `ext` LIKE '/%/'\n                      AND `is_uploadable` = '1'";
     foreach ($DB->request($query) as $data) {
         if (preg_match(Toolbox::unclean_cross_side_scripting_deep($data['ext']) . "i", $ext, $results) > 0) {
             return Toolbox::strtoupper($ext);
         }
     }
     return "";
 }
Example #5
0
/**
 * @see inc/RuleCollection::prepareInputDataForProcess()
 * @since 0.84
 * @param $params           input data
 * @return an array of criteria value to add for processing
 **/
function plugin_ocsinventoryng_ruleCollectionPrepareInputDataForProcess($params)
{
    global $PluginOcsinventoryngDBocs;
    switch ($params['rule_itemtype']) {
        case 'RuleImportEntity':
        case 'RuleImportComputer':
            if ($params['rule_itemtype'] == 'RuleImportEntity') {
                $ocsservers_id = $params['values']['input']['ocsservers_id'];
            } else {
                $ocsservers_id = $params['values']['params']['plugin_ocsinventoryng_ocsservers_id'];
            }
            $tables = plugin_ocsinventoryng_getTablesForQuery();
            $fields = plugin_ocsinventoryng_getFieldsForQuery();
            $rule_parameters = array('ocsservers_id' => $ocsservers_id);
            $select_sql = "";
            if (isset($params['values']['params']['ocsid'])) {
                $ocsid = $params['values']['params']['ocsid'];
            } else {
                if ($params['values']['input']['id']) {
                    $ocsid = $params['values']['input']['id'];
                }
            }
            //Get information about network ports
            $query = "SELECT *\n                   FROM `networks`\n                   WHERE `HARDWARE_ID` = '{$ocsid}'";
            $ipblacklist = Blacklist::getIPs();
            $macblacklist = Blacklist::getMACs();
            foreach ($PluginOcsinventoryngDBocs->request($query) as $data) {
                if (isset($data['IPSUBNET'])) {
                    $rule_parameters['IPSUBNET'][] = $data['IPSUBNET'];
                }
                if (isset($data['MACADDR']) && !in_array($data['MACADDR'], $macblacklist)) {
                    $rule_parameters['MACADDRESS'][] = $data['MACADDR'];
                }
                if (isset($data['IPADDRESS']) && !in_array($data['IPADDRESS'], $ipblacklist)) {
                    $rule_parameters['IPADDRESS'][] = $data['IPADDRESS'];
                }
            }
            //Build the select request
            foreach ($fields as $field) {
                switch (Toolbox::strtoupper($field)) {
                    //OCS server ID is provided by extra_params -> get the configuration associated with the ocs server
                    case "OCS_SERVER":
                        $rule_parameters["OCS_SERVER"] = $ocsservers_id;
                        break;
                        //TAG and DOMAIN should come from the OCS DB
                    //TAG and DOMAIN should come from the OCS DB
                    default:
                        $select_sql .= ($select_sql != "" ? " , " : "") . $field;
                }
            }
            //Build the FROM part of the request
            //Remove all the non duplicated table names
            $from_sql = "FROM `hardware` ";
            foreach ($tables as $table => $linkfield) {
                if ($table != 'hardware' && !empty($linkfield)) {
                    $from_sql .= " LEFT JOIN `{$table}` ON (`{$table}`.`{$linkfield}` = `hardware`.`ID`)";
                }
            }
            if ($select_sql != "") {
                //Build the all request
                $sql = "SELECT {$select_sql}\n                    {$from_sql}\n                    WHERE `hardware`.`ID` = '{$ocsid}'";
                PluginOcsinventoryngOcsServer::checkOCSconnection($ocsservers_id);
                $result = $PluginOcsinventoryngDBocs->query($sql);
                $ocs_data = array();
                $fields = plugin_ocsinventoryng_getFieldsForQuery(1);
                //May have more than one line : for example in case of multiple network cards
                if ($PluginOcsinventoryngDBocs->numrows($result) > 0) {
                    while ($datas = $PluginOcsinventoryngDBocs->fetch_assoc($result)) {
                        foreach ($fields as $field) {
                            if ($field != "OCS_SERVER" && isset($datas[$field])) {
                                $ocs_data[$field][] = $datas[$field];
                            }
                        }
                    }
                }
                //This cas should never happend but...
                //Sometimes OCS can't find network ports but fill the right ip in hardware table...
                //So let's use the ip to proceed rules (if IP is a criteria of course)
                if (in_array("IPADDRESS", $fields) && !isset($ocs_data['IPADDRESS'])) {
                    $ocs_data['IPADDRESS'] = PluginOcsinventoryngOcsServer::getGeneralIpAddress($ocsservers_id, $ocsid);
                }
                return array_merge($rule_parameters, $ocs_data);
            }
            return $rule_parameters;
    }
    return array();
}
Example #6
0
 function _beginpage($orientation)
 {
     $this->page++;
     $this->pages[$this->page] = '';
     $this->state = 2;
     $this->x = $this->lMargin;
     $this->y = $this->tMargin;
     $this->FontFamily = '';
     //Page orientation
     if (!$orientation) {
         $orientation = $this->DefOrientation;
     } else {
         $orientation = Toolbox::strtoupper($orientation[0]);
         if ($orientation != $this->DefOrientation) {
             $this->OrientationChanges[$this->page] = true;
         }
     }
     if ($orientation != $this->CurOrientation) {
         //Change orientation
         if ($orientation == 'P') {
             $this->wPt = $this->fwPt;
             $this->hPt = $this->fhPt;
             $this->w = $this->fw;
             $this->h = $this->fh;
         } else {
             $this->wPt = $this->fhPt;
             $this->hPt = $this->fwPt;
             $this->w = $this->fh;
             $this->h = $this->fw;
         }
         $this->PageBreakTrigger = $this->h - $this->bMargin;
         $this->CurOrientation = $orientation;
     }
 }