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


PHP str::bc36方法代码示例

本文整理汇总了PHP中str::bc36方法的典型用法代码示例。如果您正苦于以下问题:PHP str::bc36方法的具体用法?PHP str::bc36怎么用?PHP str::bc36使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在str的用法示例。


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

示例1: makeRex

 static function makeRex()
 {
     return str::bc36(strval(time()) . str_replace('.', '', $_SERVER['REMOTE_ADDR']));
 }
开发者ID:NatWeiss,项目名称:JankyPHP,代码行数:4,代码来源:file.php

示例2: drawFile

 static function drawFile($fname)
 {
     // settings
     ini_set('zlib.output_compression', 'Off');
     ini_set('output_buffering', 'Off');
     // clean output buffers
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_clean();
         if ($i > 10) {
             break;
         }
     }
     // content-type based on extension
     $types = array('default' => array('type' => 'application/octet-stream', 'attach' => true), 'mp3' => 'audio/mpeg', 'mov' => 'video/quicktime', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'pdf' => 'application/pdf', 'zip' => array('type' => 'application/zip', 'attach' => true), 'doc' => array('type' => 'application/msword', 'attach' => true));
     // get type
     $ext = file::ext($fname);
     $t = isset($types[$ext]) ? $types[$ext] : current($types);
     if (!is_array($t)) {
         $t = array('type' => $t);
     }
     // headers
     $id = str::bc36(time());
     $chunk = 1024 * 1024;
     $time_limit = (int) ($chunk / 100);
     $filesize = filesize($fname);
     header("Cache-Control:");
     header("Cache-Control: public");
     header("Pragma: ");
     header('Content-Type: ' . $t['type']);
     header('Content-Disposition: ' . ($t['attach'] ? 'attachment' : 'inline') . ';' . ' filename="' . basename($fname) . '"');
     //' filename="'.file::name($fname).'-'.$id.'.'.file::ext($fname).'"');
     header("Content-Transfer-Encoding: binary\n");
     // check if http_range is sent by browser (or download manager)
     header("Accept-Ranges: bytes");
     if (isset($_SERVER['HTTP_RANGE'])) {
         list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
         str_replace($range, "-", $range);
         $filesize2 = $filesize - 1;
         $new_length = $filesize2 - $range;
         header("HTTP/1.1 206 Partial Content");
         header("Content-Length: {$new_length}");
         header("Content-Range: bytes {$range}{$filesize2}/{$filesize}");
         $filesize = $new_length;
     } else {
         $filesize2 = $filesize - 1;
         header("Content-Range: bytes 0-{$filesize2}/{$filesize}");
     }
     header("Content-Length: " . $filesize);
     // draw
     $fp = fopen($fname, 'rb');
     if ($fp) {
         // resume
         if ($range > 0) {
             fseek($fp, $range);
         }
         // send
         while (!feof($fp) and connection_status() == 0) {
             set_time_limit($time_limit);
             $content = fread($fp, $chunk);
             echo $content;
             ob_flush();
             flush();
             $sent += strlen($content);
             unset($content);
             //funx::debug("$id sent ".(int)($sent/1024)."k".
             //	", memory used ".(int)(memory_get_usage(true)/1024)."k".
             //	", time limit ".(int)($time_limit/60)."m");
         }
         fclose($fp);
     }
     funx::debug("{$id} done ({$sent} of {$filesize}) (connection_status==" . (int) connection_status() . ")");
     return !connection_aborted() and connection_status() == 0 and $sent >= $filesize;
 }
开发者ID:NatWeiss,项目名称:JankyPHP,代码行数:73,代码来源:site.php


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