From 99b7fc8dc08da090bb7f00c2882e1daeec4434ba Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 22 Jun 2018 08:54:54 +0200 Subject: Revert "use safer it:: variants of file funcs" This reverts commit 05e7ceefa1f0a29c665381b54ac882f260ae6c22. --- it.class | 16 ++++++++-------- it_cache.class | 2 +- it_dbi.class | 4 ++-- it_debug.class | 2 +- it_html.class | 2 +- it_mail.class | 2 +- it_pipe.class | 4 ++-- it_text.class | 4 ++-- it_url.class | 8 ++++---- itjs.class | 2 +- itjs/error.gif | 4 ++-- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/it.class b/it.class index 82789a4..8b443dc 100644 --- a/it.class +++ b/it.class @@ -105,7 +105,7 @@ static function log_line($name, $line) @symlink($fullfn, $basefn); } - it::file_put_contents($fullfn, $line . "\n", FILE_APPEND); + file_put_contents($fullfn, $line . "\n", FILE_APPEND); } } @@ -167,7 +167,7 @@ static function error($p = array()) else $url = $_SERVER['SCRIPT_NAME'] . " " . join(" ", array_slice($GLOBALS['argv'], 1)) . " (pwd " . $_SERVER['PWD'] . ")"; - $gods = strtr(trim(@it::file_get_contents($GLOBALS['ULTRAHOME'] . "/.diffnotice")), array("\n"=>', ')); + $gods = strtr(trim(@file_get_contents($GLOBALS['ULTRAHOME'] . "/.diffnotice")), array("\n"=>', ')); if (!$p['to']) unset($p['to']); # allow defaults to kick in $p += array( @@ -192,8 +192,8 @@ static function error($p = array()) if ($p['okstate']) { list($okfn, $okstatus) = explode("=", "/tmp/alertdata/okstate_" . $p['okstate']); - $failcount = $okstatus ? 0 : (int)@it::file_get_contents($okfn) + 1; - it::file_put_contents($okfn, "$failcount\n"); + $failcount = $okstatus ? 0 : (int)@file_get_contents($okfn) + 1; + file_put_contents($okfn, "$failcount\n"); if ($failcount != $p['failcount'] && $failcount != $p['failcount'] * 2) return; } @@ -243,7 +243,7 @@ static function error($p = array()) $p['body'] = is_string($p['body']) || !array_key_exists('body', $p) ? $p['body'] : var_export($p['body'], true); if (strlen($p['body']) > 500000) { - it::file_put_contents($datafn = "/tmp/alertdata/error-" . substr(md5($p['body']), 0, 2), $p['body']); + file_put_contents($datafn = "/tmp/alertdata/error-" . substr(md5($p['body']), 0, 2), $p['body']); $p['body'] = "Body: " . getenv('HOSTNAME') . ":$datafn"; } @@ -738,7 +738,7 @@ static function imageconvert($p) { if (!(($imagetype = @exif_imagetype($p['in'])) && ($type = image_type_to_extension($imagetype, false)))) { - if (@get_class(it_xml::create(it::fopen($p['in'], "r"), array('prefix' => "_imageconvert_", 'safety' => 0))) == "_imageconvert_svg") + if (@get_class(it_xml::create(fopen($p['in'], "r"), array('prefix' => "_imageconvert_", 'safety' => 0))) == "_imageconvert_svg") $type = "svg"; # Accept SVG files if they are valid XML and root tag is svg else list(, $type) = explode(' ', strtolower(it::exec('identify 2>/dev/null {in}', $p))); # for things like eps @@ -921,7 +921,7 @@ static function _stdin_next() if ($result = $GLOBALS['it_stdin']['args']) { $GLOBALS['it_stdin']['filename'] = array_shift($GLOBALS['it_stdin']['args']); - $GLOBALS['it_stdin']['fd'] = ($GLOBALS['it_stdin']['filename'] == "-") ? STDIN : @it::fopen($GLOBALS['it_stdin']['filename'], "r"); + $GLOBALS['it_stdin']['fd'] = ($GLOBALS['it_stdin']['filename'] == "-") ? STDIN : @fopen($GLOBALS['it_stdin']['filename'], "r"); $GLOBALS['it_stdin']['line'] = 0; } @@ -1102,7 +1102,7 @@ static function file_put($filename, $data, $p = array()) @mkdir(dirname($filename)); $tmpfile = dirname($filename) . "/.it_put." . basename($filename) . "." . getmypid(); - if (($result = it::file_put_contents($filename == "-" ? "php://stdout" : $tmpfile, $data)) !== false && $filename != "-") + if (($result = file_put_contents($filename == "-" ? "php://stdout" : $tmpfile, $data)) !== false && $filename != "-") $result = rename($tmpfile, $filename); return $result; diff --git a/it_cache.class b/it_cache.class index 1e6df1e..08bc8a5 100644 --- a/it_cache.class +++ b/it_cache.class @@ -101,7 +101,7 @@ static function _get_memcache($p) { $memcache = new Memcached; - foreach (array_filter(it::replace(array('[#\s].*' => ""), it::file($p['hostsfile']))) as $host) + foreach (array_filter(it::replace(array('[#\s].*' => ""), file($p['hostsfile']))) as $host) $reachable += intval(@$memcache->addServer($host, 11211)); $GLOBALS[$memcache_id] = $reachable ? $memcache : false; diff --git a/it_dbi.class b/it_dbi.class index 79a56b2..7ea446f 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -500,8 +500,8 @@ function query($query, $p = array()) $this->_p['server'] = $p['server'] = $p['server_update']; unset($this->_p['server_update'], $p['server_update'], $this->_link); } - else if ($p['server'] == "localhost" && $p['db'] == $GLOBALS['ULTRADB'] && preg_grep('/replicate-do/', (array)@it::file($GLOBALS['ULTRAHOME'] . "/etc/my.cnf"))) - if (($t = @it::file($GLOBALS['ULTRAHOME'] . "/doc/machines.txt")) && preg_grep("/^" . gethostname() . "/", array_slice($t, 2))) + else if ($p['server'] == "localhost" && $p['db'] == $GLOBALS['ULTRADB'] && preg_grep('/replicate-do/', (array)@file($GLOBALS['ULTRAHOME'] . "/etc/my.cnf"))) + if (($t = @file($GLOBALS['ULTRAHOME'] . "/doc/machines.txt")) && preg_grep("/^" . gethostname() . "/", array_slice($t, 2))) it::error("local mysql write on a replication slave machine?"); } diff --git a/it_debug.class b/it_debug.class index d2aeb04..b53a192 100644 --- a/it_debug.class +++ b/it_debug.class @@ -62,7 +62,7 @@ static function srcline($stackoffs = 0) $file = $stack[1 + $stackoffs]['file']; if (!isset($GLOBALS['it_debug::dump source'][$file])) - $GLOBALS['it_debug::dump source'][$file] = @it::file($file); + $GLOBALS['it_debug::dump source'][$file] = @file($file); return $GLOBALS['it_debug::dump source'][$file][$line-1]; } diff --git a/it_html.class b/it_html.class index bca1689..f433e14 100644 --- a/it_html.class +++ b/it_html.class @@ -597,7 +597,7 @@ function _itjs($files, $mode) $jsfile = ""; foreach ($filenames as $file) - $jsfile .= @it::file_get_contents($file); + $jsfile .= @file_get_contents($file); $result .= itjs::strip($jsfile); } diff --git a/it_mail.class b/it_mail.class index a407e54..26ba883 100644 --- a/it_mail.class +++ b/it_mail.class @@ -172,7 +172,7 @@ function add_file($filename, $p = array(), $legacy_name = null) if (!is_array($p)) # legacy mode: two scalars mime type / name $p = array('mimetype' => $p) + ($legacy_name ? array('name' => $legacy_name) : array()); - return $this->add_attachment(it::file_get_contents($filename), $p + array('name' => basename($filename))); + return $this->add_attachment(file_get_contents($filename), $p + array('name' => basename($filename))); } diff --git a/it_pipe.class b/it_pipe.class index ea3010d..77ef565 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -21,7 +21,7 @@ function __construct($p = array()) $this->lines = strlen($data = it::exec($p['cmd'], $p['args'])) ? explode("\n", rtrim($data, "\n")) : array(); else foreach ((array)($p['fn'] ? $p['fn'] : "php://stdin") as $fn) - $this->lines = array_merge((array)$this->lines, ($t = it::file($fn, FILE_IGNORE_NEW_LINES)) === false ? array() : $t); + $this->lines = array_merge((array)$this->lines, ($t = file($fn, FILE_IGNORE_NEW_LINES)) === false ? array() : $t); } /** @@ -250,7 +250,7 @@ function pipe($cmd) */ function write($fn = null, $append = false) { - it::file_put_contents($fn === null ? "php://stdout" : $fn, $this->lines ? join("\n", $this->lines) . "\n" : "", $append ? FILE_APPEND : 0); + file_put_contents($fn === null ? "php://stdout" : $fn, $this->lines ? join("\n", $this->lines) . "\n" : "", $append ? FILE_APPEND : 0); return $this; } diff --git a/it_text.class b/it_text.class index 5b43ea6..a8782ce 100644 --- a/it_text.class +++ b/it_text.class @@ -34,7 +34,7 @@ class it_text * @param $p['fallbacklanguage'] optional language to use for undefined texts (useful for partially translated projects) * @param $p['forcelanguage'] optional language to use instead of user's preferred language * @param $p['global'] store text object in global it_text for global functions (default: true) - * @param $p['phpfile'] optional texts it::file(s), default: all texts.php in include path + * @param $p['phpfile'] optional texts file(s), default: all texts.php in include path * @param $p['phpfiles'] text files to load in addition to $p['phpfile'] (Note: $p['phpfile'] defaults to all texts.php files in include path) * @param $p['transmogrifiers'] comma separated functions that may be called by using {foo:bar} (foo will be called with bar as argument) in T() */ @@ -273,7 +273,7 @@ function dump_php() $this->statictext = array_merge(array('_' => $this->statictext['_']), $this->statictext); $oldmask = umask(002); - if ((count($this->p['phpfiles']) == 1) && ($f = it::fopen($this->p['phpfiles'][0], 'w'))) + if ((count($this->p['phpfiles']) == 1) && ($f = fopen($this->p['phpfiles'][0], 'w'))) { $result = (fputs($f, 'statictext, true), array("=> \n array (" => "=> array(", "array (\n '_'" => "array(\n'_'", "\n ),\n " => "\n),\n", "\n ),\n" => "\n),\n", "\r" => "")) . ";\n?>\n") !== false); fclose($f); diff --git a/it_url.class b/it_url.class index d3aa6df..8a78075 100644 --- a/it_url.class +++ b/it_url.class @@ -447,7 +447,7 @@ function get_cache($p = array()) { $newfile = it_url::_atomicwrite($path, $result); if ($p['returnheaders']) - it::file_put_contents("$path.headers", 'headers, true) . ";\n"); + file_put_contents("$path.headers", 'headers, true) . ";\n"); } else if ($p['keepfailed']) $result = $fileexists; @@ -541,7 +541,7 @@ function get_cache($p = array()) */ function get_cache_contents($p) { - return ($fn = self::get_cache($p)) ? it::file_get_contents($fn) : it::error((array)$p['it_error'] + ['title' => $p['safety'] == 0 ? false : "failed getting " . it_url::absolute($p['url']), 'body' => $p]); + return ($fn = self::get_cache($p)) ? file_get_contents($fn) : it::error((array)$p['it_error'] + ['title' => $p['safety'] == 0 ? false : "failed getting " . it_url::absolute($p['url']), 'body' => $p]); } /** @@ -573,7 +573,7 @@ static function _expired($path, $maxage) static function _lock($path) { $force = EDC('nocache') || (($mtime = @filemtime("$path.lock")) && (time() - $mtime > 30)); # expire forgotten locks - return @it::fopen("$path.lock", $force ? "w" : "x"); + return @fopen("$path.lock", $force ? "w" : "x"); } /** @@ -625,7 +625,7 @@ static function _atomicwrite($path, $data) else if ($data !== false) { $tmpname = tempnam(dirname($path), "writetmp"); - fputs($cachetmp = it::fopen($tmpname, "w"), $data); + fputs($cachetmp = fopen($tmpname, "w"), $data); fclose($cachetmp); chmod($tmpname, 0664); $result = rename($tmpname, $path); diff --git a/itjs.class b/itjs.class index ddb9866..171199b 100644 --- a/itjs.class +++ b/itjs.class @@ -159,7 +159,7 @@ static function filecontents($filenames) list($filename, $paramstr) = explode("?", $filename); if ($paramstr) parse_str($paramstr, $_GET); - $result .= it::replace(array('^1$' => ""), it::match('\.(js|css|htc)$', $filename) ? include_once($filename) : (file_exists($filename) ? it::file_get_contents($filename) : it_url::get($filename)), array('utf8' => false)); + $result .= it::replace(array('^1$' => ""), it::match('\.(js|css|htc)$', $filename) ? include_once($filename) : (file_exists($filename) ? file_get_contents($filename) : it_url::get($filename)), array('utf8' => false)); $_GET = $origget; } $result .= ob_get_clean(); diff --git a/itjs/error.gif b/itjs/error.gif index 8291976..d743ef1 100644 --- a/itjs/error.gif +++ b/itjs/error.gif @@ -4,8 +4,8 @@ if ($_POST) { $data = "