当前位置: 首页>>代码示例>>PHP>>正文


PHP fClose函数代码示例

本文整理汇总了PHP中fClose函数的典型用法代码示例。如果您正苦于以下问题:PHP fClose函数的具体用法?PHP fClose怎么用?PHP fClose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fClose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: siemens_push_str

function siemens_push_str($phone_ip, $postdata)
{
    $prov_host = gs_get_conf('GS_PROV_HOST');
    $data = "POST /server_push.html/ServerPush HTTP/1.1\r\n";
    $data .= "User-Agent: Gemeinschaft\r\n";
    $data .= "Host: {$phone_ip}:8085\r\n";
    $data .= "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
    $data .= "Connection: keep-alive\r\n";
    $data .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $data .= "Content-Length: " . strLen($postdata) . "\r\n\r\n";
    $data .= $postdata;
    $socket = @fSockOpen($phone_ip, 8085, $error_no, $error_str, 4);
    if (!$socket) {
        gs_log(GS_LOG_NOTICE, "Siemens: Failed to open socket - IP: {$phone_ip}");
        return 0;
    }
    stream_set_timeout($socket, 4);
    $bytes_written = (int) @fWrite($socket, $data, strLen($data));
    @fFlush($socket);
    $response = @fGetS($socket);
    @fClose($socket);
    if (strPos($response, '200') === false) {
        gs_log(GS_LOG_WARNING, "Siemens: Failed to push to phone {$phone_ip}");
        return 0;
    }
    gs_log(GS_LOG_DEBUG, "Siemens: Pushed {$bytes_written} bytes to phone {$phone_ip}");
    return $bytes_written;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:28,代码来源:siemens-fns.php

示例2: send_sip_packet

function send_sip_packet($ip, $port, $packet, $source_ip = false)
{
    $spoof = $source_ip ? '-s \'' . $source_ip . '\'' : '';
    $p = pOpen('netcat -u -n -p 5060 -w 1 -q 0 ' . $spoof . ' ' . $ip . ' ' . $port . ' >>/dev/null', 'wb');
    fWrite($p, $packet, strLen($packet));
    fClose($p);
}
开发者ID:rkania,项目名称:GS3,代码行数:7,代码来源:sip-desktop-message.php

示例3: InitRecordCall

function InitRecordCall($filename, $index, $comment)
{
    //FIXME
    $user = gs_user_get($_SESSION['sudo_user']['name']);
    $call = "Channel: SIP/" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: vm-rec-multiple\n" . "Extension: webdialrecord\n" . "Callerid: {$comment} <Aufnahme>\n" . "Setvar: __user_id=" . $_SESSION['sudo_user']['info']['id'] . "\n" . "Setvar: __user_name=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: __record_file=" . $filename . "\n";
    $filename = '/tmp/gs-' . $_SESSION['sudo_user']['info']['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
    $cf = @fOpen($filename, 'wb');
    if (!$cf) {
        gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
        echo 'Failed to write call file.';
        die;
    }
    @fWrite($cf, $call, strLen($call));
    @fClose($cf);
    @chmod($filename, 0666);
    $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
    if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
        $our_host_ids = @gs_get_listen_to_ids();
        if (!is_array($our_host_ids)) {
            $our_host_ids = array();
        }
        $user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
    } else {
        $user_is_on_this_host = true;
    }
    if ($user_is_on_this_host) {
        # the Asterisk of this user and the web server both run on this host
        $err = 0;
        $out = array();
        @exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            @unlink($filename);
            gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"');
            echo 'Failed to move call file.';
            die;
        }
    } else {
        $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        @unlink($filename);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
            echo 'Failed to scp call file.';
            die;
        }
        //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
        $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
            echo 'Failed to mv call file on remote host.';
            die;
        }
    }
}
开发者ID:rkania,项目名称:GS3,代码行数:57,代码来源:forwards_queues.php

示例4: _shReadSecStatsFromFile

 private static function _shReadSecStatsFromFile($shFileName)
 {
     $logFile = fopen($shFileName, 'r');
     if ($logFile) {
         while (!feof($logFile)) {
             $line = fgets($logFile, 4096);
             self::_shDecodeSecLogLine($line);
         }
         fClose($logFile);
     }
 }
开发者ID:alesconti,项目名称:FF_2015,代码行数:11,代码来源:security.php

示例5: _shReadSecStatsFromFile

 private function _shReadSecStatsFromFile($shFileName)
 {
     $logFile = fopen($shFileName, 'r');
     if ($logFile) {
         while (!feof($logFile)) {
             $line = fgets($logFile, 4096);
             Sh404sefHelperSecurity::_shDecodeSecLogLine($line);
         }
         fClose($logFile);
     }
 }
开发者ID:lautarodragan,项目名称:ideary,代码行数:11,代码来源:security.php

示例6: set

 /**
  * @see	\dns\system\cache\source\ICacheSource::set()
  */
 public function set($cacheName, $value, $maxLifetime)
 {
     $filename = $this->getFilename($cacheName);
     $content = "<?php exit; /* cache: " . $cacheName . " (generated at " . gmdate('r') . ") DO NOT EDIT THIS FILE */ ?>\n";
     $content .= serialize($value);
     if (!file_exists($filename)) {
         @touch($filename);
     }
     $handler = fOpen($filename, "a+");
     fWrite($handler, $content);
     fClose($handler);
 }
开发者ID:cengjing,项目名称:Domain-Control-Panel,代码行数:15,代码来源:DiskCacheSource.class.php

示例7: parse

 function parse($quizFileName)
 {
     $quizFile = fOpen($quizFileName, 'r');
     if ($quizFile) {
         $this->parseStart();
         while (($quizLine = fGets($quizFile, 4096)) !== false) {
             $this->parseLine($quizLine);
         }
         $this->parseEnd();
         fClose($quizFile);
     }
 }
开发者ID:RichardMartin,项目名称:uQuiz,代码行数:12,代码来源:QuizParser.php

示例8: gs_send_phone_desktop_msg

function gs_send_phone_desktop_msg($ip, $port, $ext, $registrar, $text, $extra = array())
{
    static $sock = null;
    static $lAddr = '0.0.0.0';
    static $lPort = 0;
    static $have_sockets = null;
    if ($have_sockets === null) {
        $have_sockets = function_exists('socket_create');
        // about 15 to 45 % faster
    }
    if (is_array($extra) && array_key_exists('fake_callid', $extra)) {
        $fake_callid = $extra['fake_callid'];
    } else {
        $fake_callid = rand(1000000000, 2000000000);
    }
    if ($have_sockets) {
        if (!$sock) {
            $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
            if (!$sock) {
                return false;
            }
            //socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1);
            //socket_bind($sock, '0.0.0.0', 12345);
            @socket_getSockName($sock, $lAddr, $lPort);
            //echo "Local socket is at $lAddr:$lPort\n";
            @socket_set_nonblock($sock);
        }
    } else {
        $sock = @fSockOpen('udp://' . $ip, $port, $err, $errmsg, 1);
        if (!$sock) {
            return false;
        }
        @stream_set_blocking($sock, 0);
        @stream_set_timeout($sock, 1);
    }
    $sipmsg = 'MESSAGE sip:' . $ext . '@' . $ip . ' SIP/2.0' . "\r\n" . 'Via: SIP/2.0/UDP ' . $registrar . ':' . $lPort . "\r\n" . 'To: sip:' . $ext . '@' . $ip . '' . "\r\n" . 'Call-ID: ' . $fake_callid . '@' . $registrar . "\r\n" . 'CSeq: 1 MESSAGE' . "\r\n" . 'Content-Type: text/plain; charset=utf-8' . "\r\n" . 'Max-Forwards: 9' . "\r\n" . 'From: sip:fake@' . $registrar . ':' . $lPort . ';tag=fake' . "\r\n" . 'Content-Length: ' . strLen($text) . "\r\n" . 'Content-Disposition: desktop' . "\r\n" . "\r\n" . $text;
    if ($have_sockets) {
        return @socket_sendto($sock, $sipmsg, strLen($sipmsg), 0, $ip, $port);
    } else {
        $written = @fWrite($sock, $sipmsg, strlen($sipmsg));
        @fClose($sock);
        return $written;
    }
}
开发者ID:rkania,项目名称:GS3,代码行数:44,代码来源:send-phone-msg.php

示例9: send

 function send($data = '')
 {
     if ($this->sock) {
         fwrite($this->sock, trim(strToUpper($this->method)) . " " . (array_key_exists('path', $this->url) ? $this->url['path'] : "") . (array_key_exists('query', $this->url) ? "?{$this->url['query']}" : "") . " HTTP/1.1\r\n" . "Host: {$this->url['host']}\r\n" . $this->requestHeaders . (preg_match("/(^|\r\n)Connection: /", $this->requestHeaders) ? "" : "Connection: Close\r\n") . "\r\n" . $data);
         $this->responseText = '';
         $this->status = null;
         $this->statusText = null;
         $isBody = false;
         while (!feof($this->sock)) {
             $line = fgets($this->sock, 1024);
             if ($this->status === null) {
                 if (!preg_match("/^HTTP\\/[\\d.]+\\s+(\\d+)(\\s+([^\r\n]+))?/i", $line, $matches)) {
                     throw new Exception('Invalid response');
                 }
                 $this->status = intval($matches[1]);
                 if (isset($matches[3])) {
                     $this->statusText = $matches[3];
                 }
             } else {
                 if ($isBody) {
                     $this->responseText .= $line;
                 } else {
                     if (preg_match("/^[\r\n]+\$/", $line)) {
                         $isBody = true;
                     } else {
                         if (!preg_match("/^([^:]+):\\s*([^\r\n]+)/", $line, $matches)) {
                             throw new Exception('Invalid header');
                         }
                         $this->responseHeaders[$this->capitalize($matches[1])] = $matches[2];
                     }
                 }
             }
         }
         fClose($this->sock);
         if (array_key_exists('Transfer-Encoding', $this->responseHeaders) && preg_match('/(^|[,\\s])chunked([,\\s]|$)/i', $this->responseHeaders['Transfer-Encoding'])) {
             $this->responseText = preg_replace("/^[a-f0-9]+[^\r\n]*\r?\n|\r?\n0+[^\r\n]*[\r\n]+\$/i", '', $this->responseText);
         }
     }
 }
开发者ID:Rotmistrz,项目名称:forumweb,代码行数:39,代码来源:HttpRequest.class.php

示例10: aastra_push_str

function aastra_push_str($phone_ip, $xml)
{
    $prov_host = gs_get_conf('GS_PROV_HOST');
    //FIXME - call wget or something. this function should not block
    // for so long!
    // see _gs_prov_phone_checkcfg_by_ip_do_aastra() in
    // opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php
    //$xml = utf8_decode($xml);
    if (subStr($xml, 0, 5) !== '<' . '?xml') {
        $xmlpi = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\n";
    } else {
        $xmlpi = '';
    }
    $data = "POST / HTTP/1.1\r\n";
    $data .= "Host: {$phone_ip}\r\n";
    $data .= "Referer: {$prov_host}\r\n";
    $data .= "Connection: Close\r\n";
    $data .= "Content-Type: text/xml; charset=utf-8\r\n";
    $data .= "Content-Length: " . (strLen('xml=') + strLen($xmlpi) + strLen($xml)) . "\r\n";
    $data .= "\r\n";
    $data .= 'xml=' . $xmlpi . $xml;
    $socket = @fSockOpen($phone_ip, 80, $error_no, $error_str, 4);
    if (!$socket) {
        gs_log(GS_LOG_NOTICE, "Aastra: Failed to open socket - IP: {$phone_ip}");
        return 0;
    }
    stream_set_timeout($socket, 4);
    $bytes_written = (int) @fWrite($socket, $data, strLen($data));
    @fFlush($socket);
    $response = @fGetS($socket);
    @fClose($socket);
    if (strPos($response, '200') === false) {
        gs_log(GS_LOG_WARNING, "Aastra: Failed to push XML to phone {$phone_ip}");
        return 0;
    }
    gs_log(GS_LOG_DEBUG, "Aastra: Pushed {$bytes_written} bytes to phone {$phone_ip}");
    return $bytes_written;
}
开发者ID:rkania,项目名称:GS3,代码行数:38,代码来源:aastra-fns.php

示例11: parseIt

 protected function parseIt($filename = '')
 {
     if (!file_exists($filename) || !is_readable($filename)) {
         echo "file name error!";
         return FALSE;
     }
     $header = NULL;
     $data = array();
     if (($handle = fopen($filename, 'r')) !== FALSE) {
         while (($row = fgetcsv($handle, 0, ',')) !== FALSE) {
             if (!$header) {
                 $header = $row;
             } else {
                 $data[] = array_combine($header, $row);
             }
         }
         fClose($handle);
     }
     return $data;
 }
开发者ID:ravi2jdesign,项目名称:magentoOLD,代码行数:20,代码来源:ProdUp1Controller.php

示例12: shCloseLogFile

function shCloseLogFile()
{
    global $shLogger;
    if (!empty($shLogger)) {
        $shLogger->log('Closing log file at shutdown' . "\n\n");
        if (!empty($shLogger->logFile)) {
            fClose($shLogger->logFile);
        }
    }
}
开发者ID:sangkasi,项目名称:joomla,代码行数:10,代码来源:sh404sef.class.php

示例13: finish

 public function finish()
 {
     fClose($this->DumpFile);
 }
开发者ID:ljarray,项目名称:dbpedia,代码行数:4,代码来源:NTripleDumpDestination.php

示例14: buildlanguage

 /**
  * build language files from database
  *
  * @param	boolean	$force
  */
 public static function buildlanguage($force = false)
 {
     $availableLanguages = array("de", "en");
     foreach ($availableLanguages as $languageID => $languageCode) {
         $file = DNS_DIR . "/lang/" . $languageCode . ".lang.php";
         if (!file_exists($file) || filemtime($file) + 86400 < time() || $force === true) {
             if (file_exists($file)) {
                 @unlink($file);
             }
             @touch($file);
             $items = self::getDB()->query("select * from dns_language where languageID = ?", array($languageID));
             $content = "<?php\n/**\n* language: " . $languageCode . "\n* encoding: UTF-8\n* generated at " . gmdate("r") . "\n* \n* DO NOT EDIT THIS FILE\n*/\n";
             $content .= "\$lang = array();\n";
             while ($row = self::getDB()->fetch_array($items)) {
                 print_r($row);
                 $content .= "\$lang['" . $row['languageItem'] . "'] = '" . str_replace("\$", '$', $row['languageValue']) . "';\n";
             }
             $handler = fOpen($file, "a+");
             fWrite($handler, $content);
             fClose($handler);
         }
     }
 }
开发者ID:cengjing,项目名称:Domain-Control-Panel,代码行数:28,代码来源:DNS.class.php

示例15: gs_callforward_activate

function gs_callforward_activate($user, $source, $case, $active)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    if (!in_array($source, array('internal', 'external'), true)) {
        return new GsError('Source must be internal|external.');
    }
    if (!in_array($case, array('always', 'busy', 'unavail', 'offline'), true)) {
        return new GsError('Case must be always|busy|unavail|offline.');
    }
    if (!in_array($active, array('no', 'std', 'var', 'vml', 'ano', 'trl', 'par'), true)) {
        return new GsError('Active must be no|std|var|vml|ano|trl|par.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if (!$user_id) {
        return new GsError('Unknown user.');
    }
    # get user_ext
    #
    $user_ext = $db->executeGetOne('SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`=\'' . $db->escape($user_id) . '\'');
    if (!$user_ext) {
        return new GsError('Unknown user extension.');
    }
    # check if user has an entry
    #
    $num = $db->executeGetOne('SELECT COUNT(*) FROM `callforwards` WHERE `user_id`=' . $user_id . ' AND `source`=\'' . $db->escape($source) . '\' AND `case`=\'' . $db->escape($case) . '\'');
    if ($num < 1) {
        $ok = $db->execute('INSERT INTO `callforwards` (`user_id`, `source`, `case`, `number_std`, `number_var`, `number_vml`, `active`) VALUES (' . $user_id . ', \'' . $db->escape($source) . '\', \'' . $db->escape($case) . '\', \'\', \'\', \'\', \'no\')');
    } else {
        $ok = true;
    }
    # do not allow time rules if no time rules  are defined
    #
    if ($active == 'trl') {
        $id = (int) $db->executeGetOne('SELECT `_user_id` from `cf_timerules` WHERE `_user_id`=' . $user_id);
        if (!$id) {
            return new GsError('No time rules defined. Cannot activate call forward.');
        }
    } else {
        if ($active == 'par') {
            $id = (int) $db->executeGetOne('SELECT `_user_id` from `cf_parallelcall` WHERE `_user_id`=' . $user_id);
            if (!$id) {
                return new GsError('No parsllel call tragets. Cannot activate call forward.');
            }
        }
    }
    # set state
    #
    $ok = $ok && $db->execute('UPDATE `callforwards` SET
	`active`=\'' . $db->escape($active) . '\'
WHERE
	`user_id`=' . $user_id . ' AND
	`source`=\'' . $db->escape($source) . '\' AND
	`case`=\'' . $db->escape($case) . '\'
LIMIT 1');
    if (!$ok) {
        return new GsError('Failed to set call forwarding status.');
    }
    # do not allow an empty number to be active
    #
    if ($active == 'std' || $active == 'var') {
        $field = 'number_' . $active;
        $number = $db->executeGetOne('SELECT `' . $field . '` FROM `callforwards` WHERE `user_id`=' . $user_id . ' AND `source`=\'' . $db->escape($source) . '\' AND `case`=\'' . $db->escape($case) . '\'');
        if (trim($number) == '') {
            $db->execute('UPDATE `callforwards` SET `active`=\'no\' WHERE `user_id`=' . $user_id . ' AND `source`=\'' . $db->escape($source) . '\' AND `case`=\'' . $db->escape($case) . '\'');
            return new GsError('Number is empty. Cannot activate call forward.');
        }
    }
    if ($case === 'always') {
        $filename = '/tmp/gs-' . $user_id . '-' . time() . '-' . rand(10000, 99999) . '.call';
        $call = "Channel: local/toggle@toggle-cfwd-hint\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: toggle-cfwd-hint\n" . "Extension: toggle\n" . "Callerid: {$user} <Toggle>\n" . "Setvar: __user_id=" . $user_id . "\n" . "Setvar: __user_name=" . $user_ext . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user=" . $user_ext . "\n" . "Setvar: __record_file=" . $filename . "\n";
        $cf = @fOpen($filename, 'wb');
        if (!$cf) {
            gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
            return new GsError('Failed to write call file.');
        }
        @fWrite($cf, $call, strLen($call));
        @fClose($cf);
        @chmod($filename, 0666);
        $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
        if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
            $our_host_ids = @gs_get_listen_to_ids();
            if (!is_array($our_host_ids)) {
                $our_host_ids = array();
            }
            $user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
        } else {
            $user_is_on_this_host = true;
        }
        if ($user_is_on_this_host) {
            # the Asterisk of this user and the web server both run on this host
//.........这里部分代码省略.........
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:101,代码来源:gs_callforward_activate.php


注:本文中的fClose函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。