Subversion Repositories php_utils

Compare Revisions

Regard whitespace Rev 23 → Rev 24

/trunk/VtsBrowserDownload.class.php
33,6 → 33,10
 
private static function getMimeType($file_extension) {
$file_extension = strtolower($file_extension);
if (!class_exists('VtsFileTypeDetect')) {
// https://github.com/danielmarschall/fileformats
throw new Exception("Require 'fileformats' package");
}
return VtsFileTypeDetect::getMimeType('dummy.'.$file_extension);
}
 
/trunk/VtsLDAPUtils.class.php
25,10 → 25,18
private static function _L($str, ...$sprintfArgs) {
if (function_exists('_L')) {
return _L($str, $sprintfArgs);
} else if (function_exists('my_vsprintf')) {
return my_vsprintf($str, $sprintfArgs);
} else {
return my_vsprintf($str, $sprintfArgs);
$n = 1;
foreach ($sprintfArgs as $val) {
$str = str_replace("%$n", $val, $str);
$n++;
}
$str = str_replace("%%", "%", $str);
return $str;
}
}
 
public static function getString($ldap_userinfo, $attributeName) {
$ary = self::getArray($ldap_userinfo, $attributeName);
/trunk/git_utils.inc.php
127,6 → 127,7
// Find the exact object number
fseek($fp, $fanout_offset + 4*256 + 20*$object_no);
$object_no--;
$pack_offset = -1; // avoid that phpstan complains
do {
$object_no++;
if ($version == 1) {
/trunk/ip_functions.inc.php
2,8 → 2,8
 
/*
* IP functions
* Copyright 2015 Daniel Marschall, ViaThinkSoft
* Version 2015-10-27
* Copyright 2015-2022 Daniel Marschall, ViaThinkSoft
* Version 2021-01-07
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
18,11 → 18,12
* limitations under the License.
*/
 
function get_real_ip() {
// Attention in re $allow_proxy: It is not secure to use these, since they are not validated: http://www.thespanner.co.uk/2007/12/02/faking-the-unexpected/
function get_real_ip($allow_proxy=false) {
/* Eindeutige IP Adresse erhalten, auch bei Proxies und (neu:) von SSH connections im CLI modus */
// http://lists.phpbar.de/pipermail/php/Week-of-Mon-20040322/007749.html
// Modificated by VTS
// Version: 2015-10-27
// Version: 2021-01-07
 
// TODO: ipv6
 
29,12 → 30,8
if (isset($_SERVER['SSH_CLIENT'])) { $ary = explode(' ', $_SERVER['SSH_CLIENT']); return $ary[0]; }
if (isset($_SERVER['SSH_CONNECTION'])) { $ary = explode(' ', $_SERVER['SSH_CONNECTION']); return $ary[0]; }
 
$client_ip = (isset($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : '';
 
// It is not secure to use these, since they are not validated: http://www.thespanner.co.uk/2007/12/02/faking-the-unexpected/
// $x_forwarded_for = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$x_forwarded_for = '';
 
$client_ip = ($allow_proxy && isset($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : '';
$x_forwarded_for = ($allow_proxy && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$remote_addr = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '';
 
if (!empty($client_ip)) {
/trunk/ipresolution.inc.php
79,7 → 79,7
}
}
 
# VTS-Modified: IP4+IP6 merged
# VTS-Modified: Output IP4+IP6 merged instead of giving only IPv6 or IPv4
$merged = array_merge($ip4, $ip6);
if (count($merged) < 1) {
return false;
86,7 → 86,7
} else {
return $merged;
}
 
/*
if (count($ip6) < 1) {
if ($try_a == true) {
if (count($ip4) < 1) {
100,4 → 100,5
} else {
return $ip6;
}
*/
}
/trunk/last_weekday_date.inc.php
20,7 → 20,7
 
function get_last_weekday_date($dow) {
for ($i=0; $i<=6; $i++) {
$d = ftime()-$i*86400;
$d = time()-$i*86400;
$e = date('N', $d);
if ($e == $dow) {
return date('d.m.Y', $d);
/trunk/oid_utils.inc.php
3,7 → 3,7
/*
* OID-Utilities for PHP
* Copyright 2011-2022 Daniel Marschall, ViaThinkSoft
* Version 2022-01-06
* Version 2022-01-07
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
333,14 → 333,15
* @version 2015-08-17
* @param string $oid<br/>
* An OID in dot notation.
* @param boolean $leading_dot<br/>
* @param mixed $leading_dot<br/>
* true: The OID is valid, if it contains a leading dot.<br/>
* false (default): The OID is valid, if it does not contain a leading dot.
* 'auto: Allow both
* @return string|false The OID without leading dots, or <code>false</code> if the OID is syntactically wrong.
**/
$oid_sanitize_cache = array();
function sanitizeOID($oid, $leading_dot=false) {
static $oid_sanitize_cache = array();
 
if ($leading_dot) $leading_dot = substr($oid,0,1) == '.';
 
// We are using a cache, since this function is used very often by OIDplus
/trunk/x_509_utils.inc.php
121,9 → 121,8
}
 
 
// TODO: Needs caching, otherwise the page is too slow
function x_509_ocsp_check_chain($infile, $CApath) {
return '(Skipped)'; # TODO: we need caching, otherwise the page is too slow
 
$x = x_509_chain($infile, $CApath);
 
if ($x === false) {