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


PHP fwrite函数代码示例

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


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

示例1: sendData

 protected static function sendData($host, $POST, $HEAD, $filepath, $mediafile, $TAIL)
 {
     $sock = fsockopen("ssl://" . $host, 443);
     fwrite($sock, $POST);
     fwrite($sock, $HEAD);
     //write file data
     $buf = 1024;
     $totalread = 0;
     $fp = fopen($filepath, "r");
     while ($totalread < $mediafile['filesize']) {
         $buff = fread($fp, $buf);
         fwrite($sock, $buff, $buf);
         $totalread += $buf;
     }
     //echo $TAIL;
     fwrite($sock, $TAIL);
     sleep(1);
     $data = fgets($sock, 8192);
     $data .= fgets($sock, 8192);
     $data .= fgets($sock, 8192);
     $data .= fgets($sock, 8192);
     $data .= fgets($sock, 8192);
     $data .= fgets($sock, 8192);
     $data .= fgets($sock, 8192);
     fclose($sock);
     list($header, $body) = preg_split("/\\R\\R/", $data, 2);
     $json = json_decode($body);
     if (!is_null($json)) {
         return $json;
     }
     return false;
 }
开发者ID:abazad,项目名称:whatsappGUI,代码行数:32,代码来源:mediauploader.php

示例2: _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

示例3: testTooLargeMegaBytes

 public function testTooLargeMegaBytes()
 {
     fwrite($this->file, str_repeat('0', 1400000));
     $constraint = new File(array('maxSize' => '1M', 'maxSizeMessage' => 'myMessage'));
     $this->context->expects($this->once())->method('addViolation')->with('myMessage', array('{{ limit }}' => '1 MB', '{{ size }}' => '1.4 MB', '{{ file }}' => $this->path));
     $this->validator->validate($this->getFile($this->path), $constraint);
 }
开发者ID:nashadalam,项目名称:symfony,代码行数:7,代码来源:FileValidatorTest.php

示例4: 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

示例5: 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

示例6: write_log

 /**
  * Write Log File
  *
  * Generally this function will be called using the global log_message() function
  *
  * @param    string    the error level
  * @param    string    the error message
  * @param    bool    whether the error is a native PHP error
  * @return    bool
  */
 public function write_log($level = 'error', $msg, $php_error = FALSE)
 {
     if ($this->_enabled === FALSE) {
         return FALSE;
     }
     $level = strtoupper($level);
     if (!isset($this->_levels[$level]) or $this->_levels[$level] > $this->_threshold) {
         return FALSE;
     }
     $filepath = $this->_log_path . 'log-' . date('Y-m-d') . '.php';
     $message = '';
     if (!file_exists($filepath)) {
         $message .= "<" . "?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?" . ">\n\n";
     }
     if (!($fp = @fopen($filepath, FOPEN_WRITE_CREATE))) {
         return FALSE;
     }
     $message .= $level . ' ' . ($level == 'INFO' ? ' -' : '-') . ' ' . date($this->_date_fmt) . ' --> ' . $msg . "\n";
     flock($fp, LOCK_EX);
     fwrite($fp, $message);
     flock($fp, LOCK_UN);
     fclose($fp);
     @chmod($filepath, FILE_WRITE_MODE);
     return TRUE;
 }
开发者ID:jorgemunoz8807,项目名称:admin_portal,代码行数:35,代码来源:Log.php

示例7: generatePDF

 function generatePDF()
 {
     // tempfolder
     $tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (is_dir($tmpFolder)) {
         Filesystem::removeFolder($tmpFolder);
     }
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     //Get site
     Requirements::clear();
     $link = Director::absoluteURL($this->pdfLink() . "/?view=1");
     $response = Director::test($link);
     $content = $response->getBody();
     $content = utf8_decode($content);
     $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
     if (!file_exists($contentfile)) {
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $content);
             fclose($fh);
         }
     }
     return $contentfile;
 }
开发者ID:pstaender,项目名称:ShopSystem,代码行数:28,代码来源:ShopInvoice.php

示例8: __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

示例9: 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

示例10: getInputStream

 protected function getInputStream($input)
 {
     $stream = fopen('php://memory', 'r+', false);
     fwrite($stream, $input);
     rewind($stream);
     return $stream;
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:7,代码来源:LegacyDialogHelperTest.php

示例11: 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

示例12: 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

示例13: wsOnMessage

function wsOnMessage($clientID, $message, $messageLength, $binary)
{
    global $Server;
    $ip = long2ip($Server->wsClients[$clientID][6]);
    // check if message length is 0
    if ($messageLength == 0) {
        $Server->wsClose($clientID);
        return;
    }
    //The speaker is the only person in the room. Don't let them feel lonely.
    if (sizeof($Server->wsClients) == 1) {
        $Server->wsSend($clientID, "There isn't anyone else in the room, but I'll still listen to you. --Your Trusty Server");
    } else {
        //Send the message to everyone but the person who said it
        foreach ($Server->wsClients as $id => $client) {
            if ($id != $clientID) {
                $Server->wsSend($id, "{$message}");
            }
        }
    }
    //and to arduino forst decoding mesage and sending only one byte
    if ("{$message}" == "arduino1") {
        `mode com4: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
        $fp = fopen("com4", "w+");
        fwrite($fp, chr(0x1));
        fclose($fp);
    }
}
开发者ID:nicotrial,项目名称:EscaparateInteractivo,代码行数:28,代码来源:server.php

示例14: getSuggestion

 function getSuggestion($word)
 {
     if ($fh = fopen($this->tmpfile, "w")) {
         fwrite($fh, "!\n");
         fwrite($fh, "^{$word}\n");
         fclose($fh);
     } else {
         die("Error opening tmp file.");
     }
     $data = shell_exec($this->cmd);
     $returnData = array();
     $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($dataArr as $dstr) {
         $matches = array();
         // Skip this line.
         if (strpos($dstr, "@") === 0) {
             continue;
         }
         preg_match("/\\& .* .* .*: (.*)/i", $dstr, $matches);
         if (!empty($matches[1])) {
             // For some reason, the exec version seems to add commas?
             $returnData[] = str_replace(",", "", $matches[1]);
         }
     }
     return $returnData;
 }
开发者ID:BackupTheBerlios,项目名称:morgos-svn,代码行数:26,代码来源:TinyPspellShell.class.php

示例15: 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


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