summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2018-06-27 15:13:03 +0200
committerUrban Müller2018-06-27 15:13:03 +0200
commit84fe0c2eaa7deb0681cfc8746434044a2fae53c6 (patch)
treef42b265a85d66262da30be905fa0d3e7d310a6e1
parent3fc0d00f21b44d44ee1cf0513235e1b51340a290 (diff)
downloaditools-84fe0c2eaa7deb0681cfc8746434044a2fae53c6.tar.gz
itools-84fe0c2eaa7deb0681cfc8746434044a2fae53c6.tar.bz2
itools-84fe0c2eaa7deb0681cfc8746434044a2fae53c6.zip
reapply "use safer it:: variants of file funcs", was not the culprit in jussi downtimes
This reverts commit 99b7fc8dc08da090bb7f00c2882e1daeec4434ba.
-rw-r--r--it.class16
-rw-r--r--it_cache.class2
-rw-r--r--it_dbi.class4
-rw-r--r--it_debug.class2
-rw-r--r--it_html.class2
-rw-r--r--it_mail.class2
-rw-r--r--it_pipe.class4
-rw-r--r--it_text.class4
-rw-r--r--it_url.class8
-rw-r--r--itjs.class2
-rw-r--r--itjs/error.gif4
11 files changed, 25 insertions, 25 deletions
diff --git a/it.class b/it.class
index 8ca960d..502c554 100644
--- a/it.class
+++ b/it.class
@@ -105,7 +105,7 @@ static function log_line($name, $line)
@symlink($fullfn, $basefn);
}
- file_put_contents($fullfn, $line . "\n", FILE_APPEND);
+ it::file_put_contents($fullfn, $line . "\n", FILE_APPEND);
}
}
@@ -171,7 +171,7 @@ static function error($p = array())
else
$url = $_SERVER['SCRIPT_NAME'] . " " . join(" ", array_slice($GLOBALS['argv'], 1)) . " (pwd " . $_SERVER['PWD'] . ")";
- $gods = strtr(trim(@file_get_contents($GLOBALS['ULTRAHOME'] . "/.diffnotice")), array("\n"=>', '));
+ $gods = strtr(trim(@it::file_get_contents($GLOBALS['ULTRAHOME'] . "/.diffnotice")), array("\n"=>', '));
if (!$p['to'])
unset($p['to']); # allow defaults to kick in
$p += array(
@@ -196,8 +196,8 @@ static function error($p = array())
if ($p['okstate'])
{
list($okfn, $okstatus) = explode("=", "/tmp/alertdata/okstate_" . $p['okstate']);
- $failcount = $okstatus ? 0 : (int)@file_get_contents($okfn) + 1;
- file_put_contents($okfn, "$failcount\n");
+ $failcount = $okstatus ? 0 : (int)@it::file_get_contents($okfn) + 1;
+ it::file_put_contents($okfn, "$failcount\n");
if ($failcount != $p['failcount'] && $failcount != $p['failcount'] * 2)
return;
}
@@ -247,7 +247,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)
{
- file_put_contents($datafn = "/tmp/alertdata/error-" . substr(md5($p['body']), 0, 2), $p['body']);
+ it::file_put_contents($datafn = "/tmp/alertdata/error-" . substr(md5($p['body']), 0, 2), $p['body']);
$p['body'] = "Body: " . getenv('HOSTNAME') . ":$datafn";
}
@@ -742,7 +742,7 @@ static function imageconvert($p)
{
if (!(($imagetype = @exif_imagetype($p['in'])) && ($type = image_type_to_extension($imagetype, false))))
{
- if (@get_class(it_xml::create(fopen($p['in'], "r"), array('prefix' => "_imageconvert_", 'safety' => 0))) == "_imageconvert_svg")
+ if (@get_class(it_xml::create(it::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
@@ -925,7 +925,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 : @fopen($GLOBALS['it_stdin']['filename'], "r");
+ $GLOBALS['it_stdin']['fd'] = ($GLOBALS['it_stdin']['filename'] == "-") ? STDIN : @it::fopen($GLOBALS['it_stdin']['filename'], "r");
$GLOBALS['it_stdin']['line'] = 0;
}
@@ -1106,7 +1106,7 @@ static function file_put($filename, $data, $p = array())
@mkdir(dirname($filename));
$tmpfile = dirname($filename) . "/.it_put." . basename($filename) . "." . getmypid();
- if (($result = file_put_contents($filename == "-" ? "php://stdout" : $tmpfile, $data)) !== false && $filename != "-")
+ if (($result = it::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 08bc8a5..1e6df1e 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].*' => ""), file($p['hostsfile']))) as $host)
+ foreach (array_filter(it::replace(array('[#\s].*' => ""), it::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 7ea446f..79a56b2 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)@file($GLOBALS['ULTRAHOME'] . "/etc/my.cnf")))
- if (($t = @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)@it::file($GLOBALS['ULTRAHOME'] . "/etc/my.cnf")))
+ if (($t = @it::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 b53a192..d2aeb04 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] = @file($file);
+ $GLOBALS['it_debug::dump source'][$file] = @it::file($file);
return $GLOBALS['it_debug::dump source'][$file][$line-1];
}
diff --git a/it_html.class b/it_html.class
index f433e14..bca1689 100644
--- a/it_html.class
+++ b/it_html.class
@@ -597,7 +597,7 @@ function _itjs($files, $mode)
$jsfile = "";
foreach ($filenames as $file)
- $jsfile .= @file_get_contents($file);
+ $jsfile .= @it::file_get_contents($file);
$result .= itjs::strip($jsfile);
}
diff --git a/it_mail.class b/it_mail.class
index 26ba883..a407e54 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(file_get_contents($filename), $p + array('name' => basename($filename)));
+ return $this->add_attachment(it::file_get_contents($filename), $p + array('name' => basename($filename)));
}
diff --git a/it_pipe.class b/it_pipe.class
index 77ef565..ea3010d 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 = file($fn, FILE_IGNORE_NEW_LINES)) === false ? array() : $t);
+ $this->lines = array_merge((array)$this->lines, ($t = it::file($fn, FILE_IGNORE_NEW_LINES)) === false ? array() : $t);
}
/**
@@ -250,7 +250,7 @@ function pipe($cmd)
*/
function write($fn = null, $append = false)
{
- file_put_contents($fn === null ? "php://stdout" : $fn, $this->lines ? join("\n", $this->lines) . "\n" : "", $append ? FILE_APPEND : 0);
+ it::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 a8782ce..5b43ea6 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 file(s), default: all texts.php in include path
+ * @param $p['phpfile'] optional texts it::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 = fopen($this->p['phpfiles'][0], 'w')))
+ if ((count($this->p['phpfiles']) == 1) && ($f = it::fopen($this->p['phpfiles'][0], 'w')))
{
$result = (fputs($f, '<?php return ' . strtr(var_export($this->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 8a78075..d3aa6df 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'])
- file_put_contents("$path.headers", '<?php return ' . var_export($url->headers, true) . ";\n");
+ it::file_put_contents("$path.headers", '<?php return ' . var_export($url->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)) ? 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)) ? 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]);
}
/**
@@ -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 @fopen("$path.lock", $force ? "w" : "x");
+ return @it::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 = fopen($tmpname, "w"), $data);
+ fputs($cachetmp = it::fopen($tmpname, "w"), $data);
fclose($cachetmp);
chmod($tmpname, 0664);
$result = rename($tmpname, $path);
diff --git a/itjs.class b/itjs.class
index 171199b..ddb9866 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) ? 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) ? it::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 d743ef1..8291976 100644
--- a/itjs/error.gif
+++ b/itjs/error.gif
@@ -4,8 +4,8 @@ if ($_POST)
{
$data = "<?php return " . var_export($_POST, true) . ";\n";
@mkdir("/tmp/itjs");
- file_put_contents("/tmp/itjs/error-" . date("YmdHis"), $data);
+ it::file_put_contents("/tmp/itjs/error-" . date("YmdHis"), $data);
}
header("Content-Type: image/gif");
-readfile(dirname($_SERVER['SCRIPT_FILENAME']) . "/itjs/0.gif");
+it::readfile(dirname($_SERVER['SCRIPT_FILENAME']) . "/itjs/0.gif");