• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP stream_filter_prepend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testCrc32

 public function testCrc32()
 {
     $filter = stream_filter_prepend($this->fp, 'horde_bin2hex', STREAM_FILTER_READ);
     rewind($this->fp);
     $this->assertEquals(bin2hex($this->testdata), stream_get_contents($this->fp));
     stream_filter_remove($filter);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:7,代码来源:Bin2hexTest.php


示例2: testNull

 public function testNull()
 {
     $filter = stream_filter_prepend($this->fp, 'horde_null', STREAM_FILTER_READ);
     rewind($this->fp);
     $this->assertEquals('abcdefghij', stream_get_contents($this->fp));
     stream_filter_remove($filter);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:7,代码来源:NullTest.php


示例3: sgprepend

function sgprepend($stream, $callback, $read_write = STREAM_FILTER_ALL)
{
    $ret = @stream_filter_prepend($stream, sgregister(), $read_write, $callback);
    if ($ret === false) {
        $error = error_get_last() + array('message' => '');
        throw new RuntimeException('Unable to prepend filter: ' . $error['message']);
    }
    return $ret;
}
开发者ID:Finzy,项目名称:stageDB,代码行数:9,代码来源:FilterFns.php


示例4: testCrc32

 public function testCrc32()
 {
     $params = new stdClass();
     $filter = stream_filter_prepend($this->fp, 'horde_crc32', STREAM_FILTER_READ, $params);
     rewind($this->fp);
     while (fread($this->fp, 1024)) {
     }
     $this->assertObjectHasAttribute('crc32', $params);
     $this->assertEquals(crc32($this->testdata), $params->crc32);
     stream_filter_remove($filter);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:11,代码来源:Crc32Test.php


示例5: filter_test

function filter_test($names)
{
    $fp = tmpfile();
    fwrite($fp, $GLOBALS["text"]);
    rewind($fp);
    foreach ($names as $name) {
        echo "filter: {$name}\n";
        var_dump(stream_filter_prepend($fp, $name));
    }
    var_dump(fgets($fp));
    fclose($fp);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:basic.php


示例6: testBug12673

 public function testBug12673()
 {
     $test = str_repeat(str_repeat("A", 1) . "\r\n", 4000);
     rewind($this->fp);
     fwrite($this->fp, $test);
     $filter = stream_filter_prepend($this->fp, 'horde_eol', STREAM_FILTER_READ, array('eol' => "\r\n"));
     rewind($this->fp);
     $this->assertEquals($test, stream_get_contents($this->fp));
     $test = str_repeat(str_repeat("A", 14) . "\r\n", 2);
     rewind($this->fp);
     ftruncate($this->fp, 0);
     fwrite($this->fp, $test);
     stream_filter_prepend($this->fp, 'horde_eol', STREAM_FILTER_READ, array('eol' => "\r\n"));
     rewind($this->fp);
     $this->assertEquals($test, fread($this->fp, 14) . fread($this->fp, 1) . fread($this->fp, 1) . fread($this->fp, 14) . fread($this->fp, 2) . fread($this->fp, 100));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:16,代码来源:EolTest.php


示例7: _checkEncoding

 /**
  * Checks if the data needs to be encoded like e.g., when outputing binary
  * data in-line during ITEMOPERATIONS requests.
  *
  * @param mixed  $data  The data to check. A string or stream resource.
  * @param string $tag   The tag we are outputing.
  *
  * @return mixed  The encoded data. A string or stream resource with
  *                a filter attached.
  */
 protected function _checkEncoding($data, $tag)
 {
     if ($tag == Horde_ActiveSync_Request_ItemOperations::ITEMOPERATIONS_DATA) {
         // See Bug: 14086. Use a STREAM_FILTER_WRITE and perform the
         // filtering here instead of using the currently broken behavior of
         // PHP when using base64-encode as STREAM_FILTER_READ. feof() is
         // apparently not safe to use when using STREAM_FILTER_READ.
         if (is_resource($data)) {
             $temp = fopen('php://temp/', 'r+');
             $filter = stream_filter_prepend($temp, 'convert.base64-encode', STREAM_FILTER_WRITE);
             rewind($data);
             while (!feof($data)) {
                 fwrite($temp, fread($data, 8192));
             }
             stream_filter_remove($filter);
             rewind($temp);
             return $temp;
         } else {
             return base64_encode($data);
         }
     }
     return $data;
 }
开发者ID:horde,项目名称:horde,代码行数:33,代码来源:AirSyncBaseLocation.php


示例8: array

 function &prependFilter($filtername, $read_write = STREAM_FILTER_READ, $params = array())
 {
     $res = false;
     if ($this->_fh) {
         // Capture PHP errors
         $php_errormsg = '';
         $track_errors = ini_get('track_errors');
         ini_set('track_errors', true);
         $res = @stream_filter_prepend($this->_fh, $filername, $read_write, $params);
         if (!$res && $php_errormsg) {
             $this->setError($php_errormsg);
         } else {
             JUtility::array_unshift_ref($res, $this->filters);
         }
         // push the new resource onto the filter stack
         // restore error tracking to what it was before
         ini_set('track_errors', $track_errors);
     }
     return $res;
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:20,代码来源:stream.php


示例9: var_dump

        if ($closed > 0) {
            var_dump($closed++);
        }
        return PSFS_PASS_ON;
    }
}
class SecondFilter extends php_user_filter
{
    public function filter($in, $out, &$consumed, $closing)
    {
        static $closed = 0;
        while ($bucket = stream_bucket_make_writeable($in)) {
            stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data));
        }
        if ($closing) {
            $closed++;
        }
        if ($closed > 0) {
            var_dump($closed++);
        }
        return PSFS_PASS_ON;
    }
}
$r = fopen("php://stdout", "w+");
stream_filter_register("first", "FirstFilter");
stream_filter_register("second", "SecondFilter");
$first = stream_filter_prepend($r, "first", STREAM_FILTER_WRITE, []);
$second = stream_filter_prepend($r, "second", STREAM_FILTER_WRITE, []);
fwrite($r, "test\n");
stream_filter_remove($second);
stream_filter_remove($first);
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_standard_tests_streams_stream_multi_filters_close.php


示例10: CheckBack

 public function CheckBack($header)
 {
     $statuscode = intval(substr($header, 9, 3));
     if ($statuscode != 200) {
         switch ($statuscode) {
             case 509:
                 html_error('[Mega] Transfer quota exeeded.');
             case 503:
                 html_error('Too many connections for this download.');
             case 403:
                 html_error('Link used/expired.');
             case 404:
                 html_error('Link expired.');
             default:
                 html_error('[HTTP] ' . trim(substr($header, 9, strpos($header, "\n") - 8)));
         }
     }
     global $fp;
     if (empty($fp) || !is_resource($fp)) {
         html_error("Error: Your rapidleech version is outdated and it doesn't support this plugin.");
     }
     if (!empty($_GET['T8']['fkey'])) {
         $key = $this->base64_to_a32(urldecode($_GET['T8']['fkey']));
     } elseif (preg_match('@^(T8)?!([^!]{8})!([\\w\\-\\,]{43})@i', parse_url($_GET['referer'], PHP_URL_FRAGMENT), $dat)) {
         $key = $this->base64_to_a32($dat[2]);
     } else {
         html_error("[CB] File's key not found.");
     }
     $iv = array_merge(array_slice($key, 4, 2), array(0, 0));
     $key = array($key[0] ^ $key[4], $key[1] ^ $key[5], $key[2] ^ $key[6], $key[3] ^ $key[7]);
     $opts = array('iv' => $this->a32_to_str($iv), 'key' => $this->a32_to_str($key), 'mode' => 'ctr');
     stream_filter_register('MegaDlDecrypt', 'Th3822_MegaDlDecrypt');
     stream_filter_prepend($fp, 'MegaDlDecrypt', STREAM_FILTER_READ, $opts);
 }
开发者ID:sayedharounokpay,项目名称:LikesPlanet,代码行数:34,代码来源:mega_co_nz.php


示例11: enable_compression

 /**
  * attempt enable IMAP COMPRESS extension
  * @todo: currently does not work ...
  * @return void
  */
 public function enable_compression()
 {
     if ($this->is_supported('COMPRESS=DEFLATE')) {
         $this->send_command("COMPRESS DEFLATE\r\n");
         $res = $this->get_response(false, true);
         if ($this->check_response($res, true)) {
             stream_filter_prepend($this->handle, 'zlib.inflate', STREAM_FILTER_READ);
             stream_filter_append($this->handle, 'zlib.deflate', STREAM_FILTER_WRITE, 6);
             $this->debug[] = 'DEFLATE compression extension activated';
         }
     }
 }
开发者ID:R-J,项目名称:hm3,代码行数:17,代码来源:hm-imap.php


示例12: var_dump

<?php

var_dump(stream_get_filters("a"));
var_dump(stream_filter_register());
var_dump(stream_filter_append());
var_dump(stream_filter_prepend());
var_dump(stream_filter_remove());
var_dump(stream_bucket_make_writeable());
var_dump(stream_bucket_append());
var_dump(stream_bucket_prepend());
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:user_filter_errors.php


示例13: convert

 /**
  *
  * Change file encoding
  *
  * @param string $file file path
  * @param string $from original file encoding
  * @param string $to target file encoding
  * @throws waException
  * @return string converted file path
  */
 public static function convert($file, $from, $to = 'UTF-8')
 {
     if ($src = fopen($file, 'rb')) {
         $filter = sprintf('convert.iconv.%s/%s//IGNORE', $from, $to);
         if (!@stream_filter_prepend($src, $filter)) {
             throw new waException("error while register file filter");
         }
         $file = preg_replace('/(\\.[^\\.]+)$/', '.' . $to . '$1', $file);
         if ($this->fp && ($dst = fopen($file, 'wb'))) {
             stream_copy_to_stream($this->fp, $dst);
             fclose($src);
             fclose($dst);
         } else {
             throw new waException("Error while convert file encoding");
         }
         return $file;
     } else {
         return false;
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:30,代码来源:waFiles.class.php


示例14: convert

 /**
  *
  * Changes text file character encoding.
  *
  * @param string $file Path to file
  * @param string $from Original encoding
  * @param string $to Target encoding
  * @param string $target Optional path to save encoded file to
  * @throws waException
  * @return string Path to file containing converted text
  */
 public static function convert($file, $from, $to = 'UTF-8', $target = null)
 {
     if ($src = fopen($file, 'rb')) {
         $filter = sprintf('convert.iconv.%s/%s//IGNORE', $from, $to);
         if (!@stream_filter_prepend($src, $filter)) {
             throw new waException("error while register file filter");
         }
         if ($target === null) {
             $extension = pathinfo($file, PATHINFO_EXTENSION);
             if ($extension) {
                 $extension = '.' . $extension;
             }
             $target = preg_replace('@\\.[^\\.]+$@', '', $file) . '_' . $to . $extension;
         }
         if ($dst = fopen($target, 'wb')) {
             stream_copy_to_stream($src, $dst);
             fclose($src);
             fclose($dst);
         } else {
             fclose($src);
             throw new waException("Error while convert file encoding");
         }
         return $target;
     } else {
         return false;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:38,代码来源:waFiles.class.php


示例15: prependFilter

 /**
  * Prepend a filter to the chain
  *
  * @param   string   $filtername  The key name of the filter.
  * @param   integer  $read_write  Optional. Defaults to STREAM_FILTER_READ.
  * @param   array    $params      An array of params for the stream_filter_prepend call.
  *
  * @return  mixed
  *
  * @see     http://php.net/manual/en/function.stream-filter-prepend.php
  * @since   11.1
  */
 public function prependFilter($filtername, $read_write = STREAM_FILTER_READ, $params = array())
 {
     $res = false;
     if ($this->_fh) {
         // Capture PHP errors
         $php_errormsg = '';
         $track_errors = ini_get('track_errors');
         ini_set('track_errors', true);
         $res = @stream_filter_prepend($this->_fh, $filtername, $read_write, $params);
         if (!$res && $php_errormsg) {
             $this->setError($php_errormsg);
             // set the error msg
         } else {
             array_unshift($res, '');
             $res[0] =& $this->filters;
         }
         // Restore error tracking to what it was before.
         ini_set('track_errors', $track_errors);
     }
     return $res;
 }
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:33,代码来源:stream.php


示例16: _addToZipFile

 /**
  * Adds a "file" to the ZIP archive.
  *
  * @param array $file  See self::createZipFile().
  */
 protected function _addToZipFile($file)
 {
     $name = str_replace('\\', '/', $file['name']);
     /* See if time/date information has been provided. */
     $ftime = isset($file['time']) ? $file['time'] : null;
     /* Get the hex time. */
     $dtime = dechex($this->_unix2DosTime($ftime));
     $hexdtime = chr(hexdec($dtime[6] . $dtime[7])) . chr(hexdec($dtime[4] . $dtime[5])) . chr(hexdec($dtime[2] . $dtime[3])) . chr(hexdec($dtime[0] . $dtime[1]));
     /* "Local file header" segment. */
     if (is_resource($file['data'])) {
         $zdata = fopen('php://temp', 'r+');
         $params = new stdClass();
         stream_filter_register('horde_compress_filter_crc32', 'Horde_Stream_Filter_Crc32');
         $filter = stream_filter_prepend($file['data'], 'horde_compress_filter_crc32', STREAM_FILTER_READ, $params);
         $filter2 = stream_filter_append($zdata, 'zlib.deflate', STREAM_FILTER_WRITE);
         rewind($file['data']);
         stream_copy_to_stream($file['data'], $zdata);
         $crc = $params->crc32;
         $unc_len = ftell($file['data']);
         stream_filter_remove($filter2);
         stream_filter_remove($filter);
         fseek($zdata, 0, SEEK_END);
         $c_len = ftell($zdata);
     } else {
         $unc_len = strlen($file['data']);
         $crc = crc32($file['data']);
         $zdata = gzdeflate($file['data']);
         $c_len = strlen($zdata);
     }
     /* Common data for the two entries. */
     $common = "" . "" . "" . $hexdtime . pack('V', $crc) . pack('V', $c_len) . pack('V', $unc_len) . pack('v', strlen($name)) . pack('v', 0);
     /* Extra field length. */
     /* Add this entry to zip data. */
     fseek($this->_tmp, 0, SEEK_END);
     $old_offset = ftell($this->_tmp);
     fwrite($this->_tmp, self::FILE_HEADER . $common . $name);
     /* "File data" segment. */
     if (is_resource($zdata)) {
         rewind($zdata);
         stream_copy_to_stream($zdata, $this->_tmp);
     } else {
         fwrite($this->_tmp, $zdata);
     }
     /* Add to central directory record. */
     $this->_ctrldir[] = self::CTRL_DIR_HEADER . "" . $common . pack('v', 0) . pack('v', 0) . pack('v', 0) . pack('V', 32) . pack('V', $old_offset) . $name;
     /* File name. */
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:52,代码来源:Zip.php


示例17: restore

 private function restore()
 {
     setlocale(LC_CTYPE, 'ru_RU.UTF-8', 'en_US.UTF-8');
     if ($this->file) {
         $fsize = file_exists($this->file) ? filesize($this->file) : false;
         $this->fp = @fopen($this->file, 'a');
         if (!$this->fp) {
             throw new waException("error while open CSV file");
         }
         fseek($this->fp, 0, SEEK_END);
         if (strtolower($this->encoding) != 'utf-8') {
             switch ($this->method) {
                 case 'mb':
                     if (class_exists('waFilesFilter')) {
                         waFilesFilter::register();
                         if (!@stream_filter_prepend($this->fp, 'convert.mb.UTF-8/' . $this->encoding)) {
                             throw new waException("error while register file filter");
                         }
                     } else {
                         throw new waException("error while search filter class");
                     }
                     break;
                 case 'iconv':
                 default:
                     if (!@stream_filter_prepend($this->fp, 'convert.iconv.UTF-8/' . $this->encoding . '//TRANSLIT//IGNORE')) {
                         throw new waException("error while register file filter");
                     }
                     break;
             }
         }
         if (!$this->offset) {
             if ($fsize) {
                 fseek($this->fp, 0);
                 ftruncate($this->fp, 0);
                 fseek($this->fp, 0);
             }
             if ($this->data_mapping) {
                 $this->write($this->data_mapping, true);
             }
         } else {
             fseek($this->fp, 0);
             ftruncate($this->fp, $this->offset);
             fseek($this->fp, 0, SEEK_END);
         }
     } else {
         throw new waException("CSV file not found");
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:48,代码来源:shopCsvWriter.class.php


示例18: _checkEncoding

 /**
  * Checks if the data needs to be encoded like e.g., when outputing binary
  * data in-line during ITEMOPERATIONS requests. Concrete classes should
  * override this if needed.
  *
  * @param mixed  $data  The data to check. A string or stream resource.
  * @param string $tag   The tag we are outputing.
  *
  * @return mixed  The encoded data. A string or stream resource with
  *                a filter attached.
  */
 protected function _checkEncoding($data, $tag)
 {
     if (is_resource($data)) {
         stream_filter_register('horde_null', 'Horde_Stream_Filter_Null');
         stream_filter_register('horde_eol', 'Horde_Stream_Filter_Eol');
         $filter_null = stream_filter_prepend($data, 'horde_null', STREAM_FILTER_READ);
         $filter_eol = stream_filter_prepend($data, 'horde_eol', STREAM_FILTER_READ);
     }
     return $data;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:21,代码来源:Base.php


示例19: createResponse

 private function createResponse(TransactionInterface $transaction)
 {
     $errorNo = null;
     $errorMsg = null;
     $request = $transaction->getRequest();
     $config = $request->getConfig();
     if (isset($config['stream']) && $config['stream']) {
         $request->setHeader('Transfer-Encoding', 'chunked');
     } elseif ($request->getBody() !== null) {
         $request->setHeader('Content-Length', $request->getBody()->getSize());
     }
     $socket = @stream_socket_client($this->entrypoint, $errorNo, $errorMsg, $this->getDefaultTimeout($transaction), STREAM_CLIENT_CONNECT, $this->context);
     if (!$socket) {
         throw new RequestException(sprintf('Cannot open socket connection: %s [code %d] [%s]', $errorMsg, $errorNo, $this->entrypoint), $request);
     }
     // Check if tls is needed
     if ($this->useTls) {
         if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
             throw new RequestException(sprintf('Cannot enable tls: %s', error_get_last()['message']), $request);
         }
     }
     // Write headers
     $isWrite = $this->fwrite($socket, $this->getRequestHeaderAsString($request));
     // Write body if set
     if ($request->getBody() !== null && $isWrite !== false) {
         $stream = $request->getBody();
         $filter = null;
         if ($request->getHeader('Transfer-Encoding') == 'chunked') {
             $filter = stream_filter_prepend($socket, 'chunk', STREAM_FILTER_WRITE);
         }
         while (!$stream->eof() && $isWrite) {
             $isWrite = $this->fwrite($socket, $stream->read(self::CHUNK_SIZE));
         }
         if ($request->getHeader('Transfer-Encoding') == 'chunked') {
             stream_filter_remove($filter);
             if (false !== $isWrite) {
                 $isWrite = $this->fwrite($socket, "0\r\n\r\n");
             }
         }
     }
     stream_set_timeout($socket, $this->getDefaultTimeout($transaction));
     // Response should be available, extract headers
     do {
         $response = $this->getResponseWithHeaders($socket);
     } while ($response !== null && $response->getStatusCode() == 100);
     // Check timeout
     $metadata = stream_get_meta_data($socket);
     if ($metadata['timed_out']) {
         throw new RequestException('Timed out while reading socket', $request, $response);
     }
     if (false === $isWrite) {
         // When an error happen and no response it is most probably due to TLS configuration
         if ($response === null) {
             throw new RequestException('Error while sending request (Broken Pipe), check your TLS configuration and logs in docker daemon for more information ', $request);
         }
         throw new RequestException('Error while sending request (Broken Pipe)', $request, $response);
     }
     if (null == $response) {
         throw new RequestException('No response could be parsed: check server log', $request);
     }
     $this->setResponseStream($response, $socket, $request->getEmitter(), $config->hasKey('attach_filter') && $config->get('attach_filter'));
     $transaction->setResponse($response);
     // If wait read all contents
     if ($config->hasKey('wait') && $config->get('wait')) {
         $response->getBody()->getContents();
     }
     return $response;
 }
开发者ID:schmunk42,项目名称:docker-php,代码行数:68,代码来源:DockerAdapter.php


示例20: Products_importFile

/**
 * import from an uploaded file
 *
 * @param array $vars array of parameters
 *
 * @return status
 */
function Products_importFile($vars = false)
{
    // { set up variables
    if ($vars === false) {
        return false;
    }
    if (!@$vars->productsImportDeleteAfter['varvalue']) {
        $vars->productsImportDeleteAfter = array('varvalue' => false);
    }
    if (!@$vars->productsImportDelimiter['varvalue']) {
        $vars->productsImportDelimiter = array('varvalue' => ',');
    }
    if (!@$vars->productsImportFileUrl['varvalue']) {
        $vars->productsImportFileUrl = array('varvalue' => 'ww.cache/products/import.csv');
    }
    if (!@$vars->productsImportImagesDir['varvalue']) {
        $vars->productsImportImagesDir = array('varvalue' => 'ww.cache/products/images');
    }
    $fname = USERBASE . '/' . $vars->productsImportFileUrl['varvalue'];
    // }
    if (strpos($fname, '..') !== false) {
        return array('message' => __('Invalid file URL'));
    }
    if (!file_exists($fname)) {
        return array('message' => __('File not uploaded'));
    }
    if (function_exists('mb_detect_encoding')) {
        $charset = mb_detect_encoding(file_get_contents($fname), 'UTF-8', true);
    } else {
        $charset = 'UTF-8';
    }
    $handle = fopen($fname, 'r');
    if ($charset != 'UTF-8') {
        stream_filter_register("utf8encode", "Utf8encode_Filter") or die(__('Failed to register filter'));
        stream_filter_prepend($handle, "utf8encode");
    }
    $row = fgetcsv($handle, 1000, $vars->productsImportDelimiter['varvalue']);
    // { check the headers
    $headers = array();
    foreach ($row as $k => $v) {
        if ($v) {
            $headers[$v] = $k;
        }
    }
    if (!isset($headers['_name']) || !isset($headers['_ean']) || !isset($headers['_stocknumber']) || !isset($headers['_type']) || !isset($headers['_categories'])) {
        $req = '_name, _ean, _stocknumber, _type, _categories';
        return array('message' => __('Missing required headers (%1)', array($req), 'core') . '. ' . __('Please use the Download link to get a sample import file.'), 'headers-found' => $headers);
    }
    // }
    $product_types = array();
    $imported = 0;
    $categoriesByName = array();
    $preUpload = (int) @$vars->productsImportSetExisting['varvalue'];
    $postUpload = (int) @$vars->productsImportSetImported['varvalue'];
    if ($preUpload) {
        dbQuery('update products set enabled=' . ($preUpload - 1) . ', date_edited=now()');
    }
    // { do the import
    while (($data = fgetcsv($handle, 1000, $vars->productsImportDelimiter['varvalue'])) !== false) {
        $id = 0;
        $stocknumber = $data[$headers['_stocknumber']];
        // { stockcontrol_total (how many are in stock)
        $stockcontrol_total = '';
        if (isset($headers['_stockcontrol_total']) && isset($data[$headers['_stockcontrol_total']])) {
            $stockcontrol_total = ',stockcontrol_total=' . (int) $data[$headers['_stockcontrol_total']];
        }
        // }
        $type = $data[$headers['_type']];
        if (!$type) {
            $type = 'default';
        }
        if (isset($product_types[$type]) && $product_types[$type]) {
            $type_id = $product_types[$type];
        } else {
            $type_id = (int) dbOne('select id from products_types where name="' . addslashes($type) . '"', 'id');
            if (!$type_id) {
                $type_id = (int) dbOne('select id from products_types limit 1', 'id');
            }
            $product_types[$type] = $type_id;
        }
        $name = $data[$headers['_name']];
        $ean = $data[$headers['_ean']];
        if ($stocknumber) {
            $id = (int) dbOne('select id from products where stock_number="' . addslashes($stocknumber) . '"', 'id');
            if ($id) {
                dbQuery('update products set ean="' . addslashes($ean) . '"' . ',product_type_id=' . $type_id . ',name="' . addslashes($name) . '",date_edited=now()' . $stockcontrol_total . ' where id=' . $id);
            }
        }
        if (!$id) {
            $sql = 'insert into products set ' . 'stock_number="' . addslashes($stocknumber) . '"' . $stockcontrol_total . ',product_type_id=' . $type_id . ',name="' . addslashes($name) . '"' . ',ean="' . addslashes($ean) . '"' . ',date_created=now()' . ',date_edited=now()' . ',activates_on=now()' . ',expires_on="2100-01-01"' . ',enabled=1' . ',data_fields="{}"' . ',online_store_fields="{}"';
            dbQuery($sql);
            $id = dbLastInsertId();
        }
//.........这里部分代码省略.........
开发者ID:raylouis,项目名称:kvwebme,代码行数:101,代码来源:plugin.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP stream_filter_register函数代码示例发布时间:2022-05-23
下一篇:
PHP stream_filter_append函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap