本文整理汇总了PHP中fclose函数的典型用法代码示例。如果您正苦于以下问题:PHP fclose函数的具体用法?PHP fclose怎么用?PHP fclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fclose函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sshiconn
function sshiconn($cmd, $pass, $ip, $sshp = 22)
{
$ip = $_REQUEST['ip'];
$pass = $_REQUEST['pass'];
$sshp = $_REQUEST['sshp'];
if (!isset($_REQUEST['sshp'])) {
$sshp = '22';
}
$connection = ssh2_connect($ip, $sshp);
if (!$connection) {
throw new Exception("fail: unable to establish connection\nPlease IP or if server is on and connected");
}
$pass_success = ssh2_auth_password($connection, 'root', $pass);
if (!$pass_success) {
throw new Exception("fail: unable to establish connection\nPlease Check your password");
}
$stream = ssh2_exec($connection, $cmd);
$errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
stream_set_blocking($errorStream, true);
stream_set_blocking($stream, true);
print_r($cmd);
$output = stream_get_contents($stream);
fclose($stream);
fclose($errorStream);
ssh2_exec($connection, 'exit');
unset($connection);
return $output;
}
开发者ID:shadowhome,项目名称:synxb,代码行数:28,代码来源:functions.php
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getArgument('path');
if (!file_exists($path)) {
$output->writeln("{$path} is not a file or a path");
}
$filePaths = [];
if (is_file($path)) {
$filePaths = [realpath($path)];
} elseif (is_dir($path)) {
$filePaths = array_diff(scandir($path), array('..', '.'));
} else {
$output->writeln("{$path} is not known.");
}
$generator = new StopwordGenerator($filePaths);
if ($input->getArgument('type') === 'json') {
echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
echo json_last_error_msg();
die;
$output->write(json_encode($this->toArray($generator->getStopwords())));
} else {
$stopwords = $generator->getStopwords();
$stdout = fopen('php://stdout', 'w');
echo 'token,freq' . PHP_EOL;
foreach ($stopwords as $token => $freq) {
fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
}
fclose($stdout);
}
}
开发者ID:yooper,项目名称:php-text-analysis,代码行数:30,代码来源:StopWordsCommand.php
示例3: _recaptcha_http_post
/**
* Submits an HTTP POST to a reCAPTCHA server
* @param string $host
* @param string $path
* @param array $data
* @param int port
* @return array response
*/
function _recaptcha_http_post($host, $path, $data, $port = 80)
{
$req = _recaptcha_qsencode($data);
$proxy_host = "proxy.iiit.ac.in";
$proxy_port = "8080";
$http_request = "POST http://{$host}{$path} HTTP/1.0\r\n";
$http_request .= "Host: {$host}\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
$http_request .= "Content-Length: " . strlen($req) . "\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
$http_request .= "\r\n";
$http_request .= $req;
$response = '';
if (false == ($fs = @fsockopen($proxy_host, $proxy_port, $errno, $errstr, 10))) {
die('Could not open socket aah');
}
fwrite($fs, $http_request);
while (!feof($fs)) {
$response .= fgets($fs, 1160);
}
// One TCP-IP packet
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);
return $response;
}
开发者ID:nehaljwani,项目名称:SSAD,代码行数:33,代码来源:recaptchaproxy.php
示例4: lookup
/**
* Returns a stock by symbol (case-insensitively) else false if not found.
*/
function lookup($symbol)
{
// reject symbols that start with ^
if (preg_match("/^\\^/", $symbol)) {
return false;
}
// reject symbols that contain commas
if (preg_match("/,/", $symbol)) {
return false;
}
// open connection to Yahoo
$handle = @fopen("http://download.finance.yahoo.com/d/quotes.csv?f=snl1&s={$symbol}", "r");
if ($handle === false) {
// trigger (big, orange) error
trigger_error("Could not connect to Yahoo!", E_USER_ERROR);
exit;
}
// download first line of CSV file
$data = fgetcsv($handle);
if ($data === false || count($data) == 1) {
return false;
}
// close connection to Yahoo
fclose($handle);
// ensure symbol was found
if ($data[2] === "0.00") {
return false;
}
// return stock as an associative array
return ["symbol" => $data[0], "name" => $data[1], "price" => $data[2]];
}
开发者ID:ilyarudyak,项目名称:cs50_h,代码行数:34,代码来源:functions.php
示例5: sync_object
function sync_object($object_type, $object_name)
{
# Should only provide error information on stderr: put stdout to syslog
$cmd = "geni-sync-wireless {$object_type} {$object_name}";
error_log("SYNC(cmd) " . $cmd);
$descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
$process = proc_open($cmd, $descriptors, $pipes);
$std_output = stream_get_contents($pipes[1]);
# Should be empty
$err_output = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
$proc_value = proc_close($process);
$full_output = $std_output . $err_output;
foreach (split("\n", $full_output) as $line) {
if (strlen(trim($line)) == 0) {
continue;
}
error_log("SYNC(output) " . $line);
}
if ($proc_value != RESPONSE_ERROR::NONE) {
error_log("WIRELESS SYNC error: {$proc_value}");
}
return $proc_value;
}
开发者ID:ahelsing,项目名称:geni-portal,代码行数:25,代码来源:wireless_operations.php
示例6: __construct
/**
* Constructor
*
* @param array $data the form data as name => value
* @param string|null $suffix the optional suffix for the tmp file
* @param string|null $suffix the optional prefix for the tmp file. If null 'php_tmpfile_' is used.
* @param string|null $directory directory where the file should be created. Autodetected if not provided.
* @param string|null $encoding of the data. Default is 'UTF-8'.
*/
public function __construct($data, $suffix = null, $prefix = null, $directory = null, $encoding = 'UTF-8')
{
if ($directory === null) {
$directory = self::getTempDir();
}
$suffix = '.fdf';
$prefix = 'php_pdftk_fdf_';
$this->_fileName = tempnam($directory, $prefix);
$newName = $this->_fileName . $suffix;
rename($this->_fileName, $newName);
$this->_fileName = $newName;
$fields = '';
foreach ($data as $key => $value) {
// Create UTF-16BE string encode as ASCII hex
// See http://blog.tremily.us/posts/PDF_forms/
$utf16Value = mb_convert_encoding($value, 'UTF-16BE', $encoding);
/* Also create UTF-16BE encoded key, this allows field names containing
* german umlauts and most likely many other "special" characters.
* See issue #17 (https://github.com/mikehaertl/php-pdftk/issues/17)
*/
$utf16Key = mb_convert_encoding($key, 'UTF-16BE', $encoding);
// Escape parenthesis
$utf16Value = strtr($utf16Value, array('(' => '\\(', ')' => '\\)'));
$fields .= "<</T(" . chr(0xfe) . chr(0xff) . $utf16Key . ")/V(" . chr(0xfe) . chr(0xff) . $utf16Value . ")>>\n";
}
// Use fwrite, since file_put_contents() messes around with character encoding
$fp = fopen($this->_fileName, 'w');
fwrite($fp, self::FDF_HEADER);
fwrite($fp, $fields);
fwrite($fp, self::FDF_FOOTER);
fclose($fp);
}
开发者ID:aviddv1,项目名称:php-pdftk,代码行数:41,代码来源:FdfFile.php
示例7: graph_3D_Pie
function graph_3D_Pie($file, $table)
{
$handle = fopen("{$file}", "w");
fwrite($handle, "<chart>\n");
fwrite($handle, "\t<chart_data>\n");
fwrite($handle, "\t\t<row>\n");
fwrite($handle, "\t\t\t<null/>\n");
foreach ($table as $key => $value) {
if ($value != 0) {
fwrite($handle, "\t\t\t<string>{$key}</string>\n");
}
}
fwrite($handle, "\t\t</row>\n");
fwrite($handle, "\t\t<row>\n");
fwrite($handle, "\t\t\t<string></string>\n");
foreach ($table as $key => $value) {
if ($value != 0) {
fwrite($handle, "\t\t\t<number>{$value}</number>\n");
}
}
fwrite($handle, "\t\t</row>\n");
fwrite($handle, "\t</chart_data>\n");
fwrite($handle, "\t<chart_type>3d pie</chart_type>\n");
fwrite($handle, "\t<chart_value color='000000' alpha='65' font='arial' bold='true' size='10' position='inside' prefix='' suffix='' decimals='0' separator='' as_percentage='true' />\n");
fwrite($handle, "\t<draw>\n");
fwrite($handle, "\t\t<text color='000000' alpha ='50' size='25' x='-50' y='0' width='500' height='50' h_align='center' v_align='middle'>{$title}</text>\n");
fwrite($handle, "\t<\\draw>\n");
fwrite($handle, "\t<legend_label layout='horizontal' bullet='circle' font='arial' bold='true' size='12' color='ffffff' alpha='85' />\n");
fwrite($handle, "\t<legend_rect x='0' y='45' width='50' height='210' margin='10' fill_color='ffffff' fill_alpha='10' line_color='000000' line_alpha='0' line_thickness='0' />\n");
fwrite($handle, "</chart>\n");
fclose($handle);
}
开发者ID:relisher,项目名称:logiciel_de_compte,代码行数:32,代码来源:graph_3D_pie.php
示例8: parseFile
/**
*
* @param string $path
* The file containg a MIME message
* @return \Swift_Message
*/
public function parseFile($path)
{
$fp = fopen($path, "rb");
$message = $this->parseStream($fp);
fclose($fp);
return $message;
}
开发者ID:perk11,项目名称:to-swift-mime-parser,代码行数:13,代码来源:MimeParser.php
示例9: writeData
public function writeData()
{
$fn = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . $this->file_name;
$fd = fopen($fn, "w");
fwrite($fd, $this->data);
fclose($fd);
}
开发者ID:imdaqian,项目名称:TTT,代码行数:7,代码来源:BaseTradeData.php
示例10: testCloseStream
public function testCloseStream()
{
//ensure all basic stream stuff works
$sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$this->assertTrue(file_exists($file));
file_put_contents($file, file_get_contents($sourceFile));
$this->assertEquals(file_get_contents($sourceFile), file_get_contents($file));
unlink($file);
clearstatcache();
$this->assertFalse(file_exists($file));
//test callback
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$actual = false;
$callback = function ($path) use(&$actual) {
$actual = $path;
};
\OC\Files\Stream\Close::registerCallback($tmpFile, $callback);
$fh = fopen($file, 'w');
fwrite($fh, 'asd');
fclose($fh);
$this->assertSame($tmpFile, $actual);
}
开发者ID:TechArea,项目名称:core,代码行数:25,代码来源:streamwrappers.php
示例11: createSettingsFile
public static function createSettingsFile($dbHostname, $dbName, $dbUsername, $dbPassword, $tablePrefix)
{
$encryptionSalt = Utils::generateRandomAlphanumericStr("DDD");
$dbUsername = Utils::sanitize($dbUsername);
$dbPassword = Utils::sanitize($dbPassword);
$tablePrefix = Utils::sanitize($tablePrefix);
$content = <<<END
<?php
\$dbHostname = '{$dbHostname}';
\$dbName = '{$dbName}';
\$dbUsername = '{$dbUsername}';
\$dbPassword = '{$dbPassword}';
\$dbTablePrefix = '{$tablePrefix}';
\$encryptionSalt = '{$encryptionSalt}';
END;
$file = __DIR__ . "/../../settings.php";
$handle = @fopen($file, "w");
if ($handle) {
fwrite($handle, $content);
fclose($handle);
return array(true, "");
}
// no such luck! we couldn't create the file on the server. The user will need to do it manually
return array(false, $content);
}
开发者ID:balmychan,项目名称:generatedata,代码行数:26,代码来源:Installation.class.php
示例12: save
function save($file, $data)
{
mkdir_recursive($file);
$fh = fopen($file, 'w') or print "can't open file";
fwrite($fh, $data);
fclose($fh);
}
开发者ID:baki250,项目名称:angular-io-app,代码行数:7,代码来源:lib.global.php
示例13: verifCode
function verifCode($decryptedTabIdMdp)
{
if (file_exists("C:\\wamp64\\www\\Web\\" . $decryptedTabIdMdp->identifiant) == true) {
//Si oui on ouvre le dossier et on recupere le mot de passe.
$handle = fopen("C:\\wamp64\\www\\Web\\" . $decryptedTabIdMdp->identifiant . "\\Confg.txt", "r+");
fgets($handle);
$Code = fgets($handle);
$Code = explode(":", $Code);
$Code = $Code[1];
fclose($handle);
$Code = dechiffrementdata($Code, $decryptedTabIdMdp->IV);
//On verifie le mot de passe
if ($Code == $decryptedTabIdMdp->code) {
// Si la comparraison est ok on renvoie vrai
$ok = "vrai\\\\" . $Code;
} else {
// Si la comparraison n'est pas correcte on renvoie faux
$Anwser = 'null';
$ok = "faux\\\\" . $Anwser;
}
return $ok;
} else {
$Anwser = 'null';
$ok = "faux\\\\" . $Anwser;
}
}
开发者ID:jeoff09,项目名称:Project-Optimisation,代码行数:26,代码来源:data.php
示例14: addFieldToModule
public function addFieldToModule($field)
{
global $log;
$fileName = 'modules/Settings/Vtiger/models/CompanyDetails.php';
$fileExists = file_exists($fileName);
if ($fileExists) {
require_once $fileName;
$fileContent = file_get_contents($fileName);
$placeToAdd = "'website' => 'text',";
$newField = "'{$field}' => 'text',";
if (self::parse_data($placeToAdd, $fileContent)) {
$fileContent = str_replace($placeToAdd, $placeToAdd . PHP_EOL . ' ' . $newField, $fileContent);
} else {
if (self::parse_data('?>', $fileContent)) {
$fileContent = str_replace('?>', '', $fileContent);
}
$fileContent = $fileContent . PHP_EOL . $placeToAdd . PHP_EOL . ' ' . $newField . PHP_EOL . ');';
}
$log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - add line to modules/Settings/Vtiger/models/CompanyDetails.php ');
} else {
$log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - File does not exist');
return FALSE;
}
$filePointer = fopen($fileName, 'w');
fwrite($filePointer, $fileContent);
fclose($filePointer);
return TRUE;
}
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:28,代码来源:SaveCompanyField.php
示例15: isXliff
public static function isXliff($stringData = null, $fullPathToFile = null)
{
self::_reset();
$info = array();
if (!empty($stringData) && empty($fullPathToFile)) {
$stringData = substr($stringData, 0, 1024);
} elseif (empty($stringData) && !empty($fullPathToFile)) {
$info = FilesStorage::pathinfo_fix($fullPathToFile);
$file_pointer = fopen("{$fullPathToFile}", 'r');
// Checking Requirements (By specs, I know that xliff version is in the first 1KB)
$stringData = fread($file_pointer, 1024);
fclose($file_pointer);
} elseif (!empty($stringData) && !empty($fullPathToFile)) {
//we want to check extension and content
$info = FilesStorage::pathinfo_fix($fullPathToFile);
}
self::$fileType['info'] = $info;
//we want to check extension also if file path is specified
if (!empty($info) && !self::isXliffExtension()) {
//THIS IS NOT an xliff
return false;
}
// preg_match( '|<xliff\s.*?version\s?=\s?["\'](.*?)["\'](.*?)>|si', $stringData, $tmp );
if (!empty($stringData)) {
return array($stringData);
}
return false;
}
开发者ID:spMohanty,项目名称:MateCat,代码行数:28,代码来源:DetectProprietaryXliff.php
示例16: dwld
public function dwld()
{
$this->min();
if (is_numeric($this->getParam("id"))) {
$this->download->newDownload();
if ($this->download->getIsLocal()) {
$url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($url) . '";');
readfile($url);
} else {
$url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
header("Content-Disposition: attachment; filename=" . basename($url));
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($url));
flush();
// this doesn't really matter.
$fp = fopen($url, "r");
while (!feof($fp)) {
echo fread($fp, 65536);
flush();
// this is essential for large downloads
}
fclose($fp);
}
} else {
throw new \Model\downloads\exception\DownloadCantBeFind("No Download ID given");
}
}
开发者ID:oliverde8,项目名称:oweb-framework,代码行数:33,代码来源:Download.php
示例17: suche
function suche($wort, $kat)
{
if ($kat == '') {
$kat = 0;
}
$f = fopen("/tmp/x", "w");
fputs($f, $wort . " " . $kat . "\n");
$treffer = suchWDB($wort, $kat);
fputs($f, print_r($treffer, true) . "\n");
$notfound = "";
$rc = array('msg' => '', 'cnt' => 0, 'data' => '');
if (count($treffer) == 0) {
$rc['msg'] = $wort . ' not found';
echo json_encode($rc);
} else {
if (count($treffer) == 1) {
$data = getWContent($treffer[0]['id']);
mkcontent($data);
fclose($f);
} else {
$rc['cnt'] = count($treffer);
$rc['data'] = $treffer;
echo json_encode($rc);
}
}
}
开发者ID:vanloswang,项目名称:kivitendo-crm,代码行数:26,代码来源:wissen.php
示例18: send_request_via_fsockopen1
function send_request_via_fsockopen1($host, $path, $content)
{
$posturl = "ssl://" . $host;
$header = "Host: {$host}\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: text/xml\r\n";
$header .= "Content-Length: " . strlen($content) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$fp = fsockopen($posturl, 443, $errno, $errstr, 30);
if (!$fp) {
$response = false;
} else {
error_reporting(E_ERROR);
fputs($fp, "POST {$path} HTTP/1.1\r\n");
fputs($fp, $header . $content);
fwrite($fp, $out);
$response = "";
while (!feof($fp)) {
$response = $response . fgets($fp, 128);
}
fclose($fp);
error_reporting(E_ALL ^ E_NOTICE);
}
return $response;
}
开发者ID:shaheerali49,项目名称:herozfitcart,代码行数:25,代码来源:authnetfunction.php
示例19: getMp3StreamTitle
function getMp3StreamTitle($steam_url)
{
$result = false;
$icy_metaint = -1;
$needle = 'StreamTitle=';
$ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36';
$opts = array('http' => array('method' => 'GET', 'header' => 'Icy-MetaData: 1', 'user_agent' => $ua));
$default = stream_context_set_default($opts);
$stream = fopen($steam_url, 'r');
if ($stream && ($meta_data = stream_get_meta_data($stream)) && isset($meta_data['wrapper_data'])) {
foreach ($meta_data['wrapper_data'] as $header) {
if (strpos(strtolower($header), 'icy-metaint') !== false) {
$tmp = explode(":", $header);
$icy_metaint = trim($tmp[1]);
break;
}
}
}
if ($icy_metaint != -1) {
$buffer = stream_get_contents($stream, 300, $icy_metaint);
if (strpos($buffer, $needle) !== false) {
$title = explode($needle, $buffer);
$title = trim($title[1]);
$result = substr($title, 1, strpos($title, ';') - 2);
}
}
if ($stream) {
fclose($stream);
}
return $result;
}
开发者ID:yoelrola,项目名称:test-metadata-players,代码行数:31,代码来源:get.php
示例20: save_picture
/**
Upload a profile picture for the group
*/
function save_picture($ext)
{
global $cfg;
if (!$this->user->logged_in() || !$this->user->group) {
throw new Exception("Access denied!");
}
if (!isset($_SERVER["CONTENT_LENGTH"])) {
throw new Exception("Invalid parameters");
}
$size = (int) $_SERVER["CONTENT_LENGTH"];
$file_name = rand() . time() . "{$this->user->id}.{$ext}";
$file_path = "{$cfg['dir']['content']}{$file_name}";
// Write the new one
$input = fopen("php://input", "rb");
$output = fopen($file_path, "wb");
if (!$input || !$output) {
throw new Exception("Cannot open files!");
}
while ($size > 0) {
$data = fread($input, $size > 1024 ? 1024 : $size);
$size -= 1024;
fwrite($output, $data);
}
fclose($input);
fclose($output);
// Update the profile image
$this->group->update($this->user->group, array('picture' => $file_name));
}
开发者ID:nandor,项目名称:kit,代码行数:31,代码来源:GroupController.php
注:本文中的fclose函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论