summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Burschka2013-12-30 23:55:09 +0100
committerChristoph Burschka2013-12-30 23:55:09 +0100
commitb443a7381c0e3dcacd9a508253504a85a306a194 (patch)
tree96f41106cea39a923d2bbde9214318f618a6e011
parentWarning about support and maintenance. (diff)
downloadejabberd-auth-php-b443a7381c0e3dcacd9a508253504a85a306a194.tar.gz
Use STD* constants instead of opening new streams.
PHP provides STDIN, STDOUT and STDERR constants in CLI mode.
-rw-r--r--core/EjabberdAuth.php10
1 files changed, 4 insertions, 6 deletions
diff --git a/core/EjabberdAuth.php b/core/EjabberdAuth.php
index d9b9776..f83f1b6 100644
--- a/core/EjabberdAuth.php
+++ b/core/EjabberdAuth.php
@@ -8,14 +8,12 @@ class EjabberdAuth {
var $running;
function __construct($config, EjabberdAuthBridge $bridge) {
- $this->stdin = fopen('php://stdin', 'r');
- $this->stdout = fopen('php://stdout', 'w');
$this->bridge = $bridge;
if (!empty($config['log_path']) && is_dir($config['log_path']) && is_writable($config['log_path'])) {
$this->logfile = fopen($config['log_path'] . 'activity-' . date('Y-m-d') . '.log', 'a');
}
else {
- $this->logfile = fopen('php://stderr', 'w');
+ $this->logfile = STDERR;
}
$this->log('Starting...');
$this->running = TRUE;
@@ -38,7 +36,7 @@ class EjabberdAuth {
}
function read() {
- $input = fread($this->stdin, 2);
+ $input = fread(STDIN, 2);
if (!$input) {
return $this->stop();
}
@@ -47,14 +45,14 @@ class EjabberdAuth {
$length = $input[1];
if($length > 0) {
$this->log("Reading $length bytes...");
- $data = fread($this->stdin, $length);
+ $data = fread(STDIN, $length);
return $data;
}
}
function write($data) {
$this->log("OUT: $data");
- fwrite($this->stdout, pack("nn", 2, $data));
+ fwrite(STDOUT, pack("nn", 2, $data));
}
function log($data) {