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


PHP getSize函数代码示例

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


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

示例1: listFiles

function listFiles($dir)
{
    global $cfg;
    $list = array();
    $full = $cfg['root'] . trim($dir, '/\\') . DIR_SEP;
    $thumb = $cfg['root'] . $cfg['thumb']['dir'] . DIR_SEP . trim($dir, '/\\') . DIR_SEP;
    $files = scandir($full);
    natcasesort($files);
    for ($i = -1, $iCount = count($files); ++$i < $iCount;) {
        $ext = substr($files[$i], strrpos($files[$i], '.') + 1);
        if (!in_array($files[$i], $cfg['hide']['file']) && !in_array($ext, $cfg['deny'][$cfg['type']]) && in_array($ext, $cfg['allow'][$cfg['type']]) && is_file($full . $files[$i])) {
            $imgSize = array(0, 0);
            if (in_array($ext, $cfg['allow']['image'])) {
                if ($cfg['thumb']['auto'] && !file_exists($thumb . $files[$i])) {
                    create_thumbnail($full . $files[$i], $thumb . $files[$i]);
                }
                $imgSize = getimagesize($full . $files[$i]);
            }
            $stats = getSize($full . $files[$i]);
            $list[] = array('name' => $files[$i], 'ext' => $ext, 'width' => $imgSize[0], 'height' => $imgSize[1], 'size' => $stats['_size'], 'date' => date($cfg['thumb']['date'], $stats['mtime']), 'r_size' => $stats['size'], 'mtime' => $stats['mtime'], 'thumb' => '/' . $cfg['url'] . '/' . $cfg['thumb']['dir'] . '/' . $dir . $files[$i]);
        }
    }
    switch ($cfg['sort']) {
        case 'size':
            usort($list, 'sortSize');
            break;
        case 'date':
            usort($list, 'sortDate');
            break;
        default:
            //name
            break;
    }
    return $list;
}
开发者ID:jfkz,项目名称:aquarel-cms,代码行数:35,代码来源:cfg.php

示例2: get_folder_contents

function get_folder_contents($folder, $parent = false)
{
    if ($parent) {
        $folder = $parent . DIRECTORY_SEPARATOR . $folder;
    }
    $output = array();
    $curdir = array();
    if ($handle = opendir($folder)) {
        while ($entry = readdir($handle)) {
            if ($entry != "." && $entry != "..") {
                array_push($curdir, $entry);
            }
        }
        closedir($handle);
    }
    // $curdir = scandir($folder);
    foreach ($curdir as $k => $v) {
        if (!in_array($v, array('.', '..'))) {
            if (is_dir($folder . DIRECTORY_SEPARATOR . $v)) {
                array_push($output, array('name' => $v, 'type' => 'folder', 'modified' => date('m/d/y H:i:s', filemtime($folder . DIRECTORY_SEPARATOR . $v)), 'size' => '&ndash;'));
            } else {
                $file = explode('.', $v);
                $ext = array_pop($file);
                $size = getSize($folder . DIRECTORY_SEPARATOR . $v);
                array_push($output, array('name' => $v, 'type' => $ext, 'modified' => date('m/d/y H:i:s', filemtime($folder . DIRECTORY_SEPARATOR . $v)), 'size' => $size));
            }
        }
    }
    return $output;
}
开发者ID:joeyfromspace,项目名称:hdtracks-metadata,代码行数:30,代码来源:metadata_util.php

示例3: loadDir

function loadDir($dirName)
{
    if ($handle = openDir($dirName)) {
        echo "<tr class='trTitle'><td>类型</td><td>文件名</td><td>大小</td><td>最后修改时间</td><td>操作</td></tr>";
        while (false !== ($files = readDir($handle))) {
            if ($files != "." && $files != "..") {
                $urlStrs = $dirName . "/" . $files;
                if (!is_dir($dirName . "/" . $files)) {
                    $types = "文件";
                    $cons = "<a href=\"loaddir.php?action=edit&urlstr={$urlStrs}\">编辑</a>";
                    $className = "file";
                    $fileSize = getSize($dirName . "/" . $files);
                    $fileaTime = date("Y-m-d H:i:s", getEditTime($dirName . "/" . $files));
                    $arrayfile[] = "<tr class='{$className}'><td>{$types}</td><td>{$files}</td><td>" . $fileSize . " bytes</td><td>{$fileaTime}</td><td>{$cons}</td></tr>";
                }
                //echo "<tr class='$className'><td>$types</td><td>$files</td><td>".$fileSize." bytes</td><td>$fileaTime</td><td>$cons</td></tr>";
            }
        }
        //$arraydirLen=count($arraydir);
        //for($i=0;$i<$arraydirLen;$i++) echo $arraydir[$i];
        $arrayfileLen = count($arrayfile);
        for ($i = 0; $i < $arrayfileLen; $i++) {
            echo $arrayfile[$i];
        }
        //echo $arraydir;
        closeDir($handle);
    }
}
开发者ID:jyyy410team,项目名称:hts,代码行数:28,代码来源:loaddir-old.php

示例4: renderEntry

function renderEntry($entry)
{
    list($width, $height) = getSize(150, 'user_content/' . $entry['uid'] . '.' . $entry['ext']);
    // entry is an array with uid, name, reason
    $html = '<div style="border: 1px solid #000; padding: 10px;"><a href="?tab=view&show=' . $entry['uid'] . '">';
    $html .= '<img src="' . $GLOBALS['app_config']['server']['url'] . '/user_content/' . $entry['uid'] . '.' . $entry['ext'] . '" width="' . $width . '" height="' . $height . '" />';
    $html .= '<br /><div align="center" style="font-size: 14px; font-weight: bold;"><fb:name uid="' . $entry['uid'] . '" firstnameonly=1 linked=0 reflexive=0 /></a></div>';
    $html .= '</div>';
    return $html;
}
开发者ID:sjlu,项目名称:photo-contests,代码行数:10,代码来源:view.php

示例5: getImages

/**
 * Get all images in specified folder.
 * @param string $folder  path to directory to read
 * @return array          array containing image data
 */
function getImages($folder)
{
    $images = array();
    if ($handle = opendir($folder)) {
        while (false !== ($file = readdir($handle))) {
            $path = $folder . $file;
            if (!is_dir($path) && isImage($file)) {
                list($width, $height) = getimagesize($path);
                $images[$file] = array('is_dir' => false, 'name' => $file, 'short' => strlen($file) > 30 ? substr($file, 0, 20) . '...' . substr($file, -10) : $file, 'link' => $path, 'thumb' => $file, 'width' => $width, 'height' => $height, 'size' => getSize($path));
            }
        }
        closedir($handle);
    }
    ksort($images);
    return $images;
}
开发者ID:benct,项目名称:web-gallery,代码行数:21,代码来源:func.php

示例6: size_dir

function size_dir($path) {
	chmod($path, 0755);
	if (!is_dir($path))
   		return getSize($path);
	if(FALSE === ($handle = opendir($path)))
		return -1;
	$size=0;
	foreach (scandir($path) as $file){
   		if ($file=='.' or $file=='..')
       		continue;
		$dirsize=size_dir($path.'/'.$file);
		if($dirsize == -1)
			$dirsize = 0;
		$size+=$dirsize;
	}
	return $size;
}
开发者ID:slambert,项目名称:Add-Art-Image-Cropper,代码行数:17,代码来源:dlaszip.php

示例7: getSpeed

function getSpeed($r)
{
    global $config;
    // Calculate the average download and
    // upload speed within 3 seconds.
    // Required line in sudo configuration:
    //   www-data        ALL=NOPASSWD: /sbin/ifconfig eth0
    if ($r == "rx") {
        $cmd = "sudo ifconfig " . $config["interface"] . " | grep 'RX bytes' | cut -d: -f2 | awk '{ print \$1 }'";
    } else {
        if ($r == "tx") {
            $cmd = "sudo ifconfig " . $config["interface"] . " | grep 'TX bytes' | cut -d: -f3 | awk '{ print \$1 }'";
        } else {
            die("ERROR2");
        }
    }
    // Executing and get total send/received
    // bytes the next three seconds
    $o1 = shell_exec($cmd);
    sleep(1);
    $o2 = shell_exec($cmd);
    sleep(1);
    $o3 = shell_exec($cmd);
    sleep(1);
    $o4 = shell_exec($cmd);
    // Calculate differences
    $o1 = $o2 - $o1;
    $o2 = $o3 - $o2;
    $o3 = $o4 - $o3;
    // Calc average
    $o = ($o1 + $o2 + $o3) / 3;
    return getSize($o) . "/s";
}
开发者ID:nwgat,项目名称:mirror-serverdashboard,代码行数:33,代码来源:getStatus.php

示例8: while

						<td><b>文件名</b></td>
						<td><b>修改日期</b></td>
						<td><b>文件大小</b></td>
						<td><b>操作</b></td>
					</tr>
					<?php 
$flag_file = 0;
//检测是否有文件
$fso = @opendir($CurrentPath);
while ($file = @readdir($fso)) {
    $fullpath = "{$CurrentPath}\\{$file}";
    $is_dir = @is_dir($fullpath);
    if ($is_dir == "0") {
        $flag_file++;
        $size = @filesize("{$CurrentPath}/{$file}");
        $size = @getSize($size);
        $lastsave = @date("Y-n-d H:i:s", filemtime("{$CurrentPath}/{$file}"));
        echo "<tr bgcolor=\"#EFEFEF\">\n";
        echo "<td>◇ " . dealString($file) . "</td>\n";
        echo "  <td>{$lastsave}</td>\n";
        echo "  <td>{$size}</td>\n";
        ?>
					<td><input type="hidden" id="<?php 
        echo $flag_file . "path";
        ?>
"
						value="<?php 
        echo $filec;
        ?>
"><a
						href="?downfile=<?php 
开发者ID:huguangAOA,项目名称:sk_vjudge,代码行数:31,代码来源:file.php

示例9: spec_tab_content

/**
 * Спецификации
 */
function spec_tab_content()
{
    global $post;
    $ins_text = get_post_meta($post->ID, '_ins_text', true);
    $sert_text = get_post_meta($post->ID, '_sert_text', true);
    ?>
    <div class="cr-product-block spec-taber">

        <div class="block-title-block">
            <h3 class="block-title col-xs-12">Описание</h3>
        </div>

        <div class="col-xs-4 docer-col">

            <div class="ins-ti">Инструкции и сертификаты</div>
            <ul>
                <li>
                    <?php 
    if (!empty($ins_text)) {
        $filetype = wp_check_filetype($ins_text);
        $file = str_replace(get_home_url(), $_SERVER['DOCUMENT_ROOT'], $ins_text);
        echo '<i class="fa fa-file-' . $filetype['ext'] . '-o"></i>';
        echo '<a href="' . esc_url($ins_text) . '" title="Инструкция для ' . get_the_title() . '">Инструкция для ' . get_the_title() . ' ' . getSize($file) . '</a>';
    }
    ?>
                </li>
                <li>
                    <?php 
    if (!empty($sert_text)) {
        $filetype = wp_check_filetype($sert_text);
        $file = str_replace(get_home_url(), $_SERVER['DOCUMENT_ROOT'], $sert_text);
        echo '<i class="fa fa-file-' . $filetype['ext'] . '-o"></i>';
        echo '<a href="' . esc_url($sert_text) . '" title="Скачать сертификат соответствия ' . get_the_title() . '">Скачать сертификат соответствия ' . get_the_title() . ' ' . getSize($file) . '</a>';
    }
    ?>
                </li>
            </ul>

        </div>

        <div class="col-xs-8">
            <?php 
    $cont = new BE_Compare_Products();
    $cont->new_product_tab_content();
    ?>
        </div>

    </div>
<?php 
}
开发者ID:WP-Panda,项目名称:m.video,代码行数:53,代码来源:woocommerce-config.php

示例10: getRecursiveAttached

 /**
  * Private function : Recursivly get attached documents
  *
  * @param $mid : message id
  * @param $path : temporary path
  * @param $maxsize : of document to be retrieved
  * @param $structure : of the message or part
  * @param $part : part for recursive
  *
  * Result is stored in $this->files
  *
  */
 function getRecursiveAttached($mid, $path, $maxsize, $structure, $part = "")
 {
     global $LANG;
     if ($structure->type == 1) {
         // multipart
         reset($structure->parts);
         while (list($index, $sub) = each($structure->parts)) {
             $this->getRecursiveAttached($mid, $path, $maxsize, $sub, $part ? $part . "." . ($index + 1) : $index + 1);
         }
     } else {
         $filename = '';
         if ($structure->ifdparameters) {
             // get filename of attachment if present
             // if there are any dparameters present in this part
             if (count($structure->dparameters) > 0) {
                 foreach ($structure->dparameters as $dparam) {
                     if (utf8_strtoupper($dparam->attribute) == 'NAME' || utf8_strtoupper($dparam->attribute) == 'FILENAME') {
                         $filename = $dparam->value;
                     }
                 }
             }
         }
         //if no filename found
         if (empty($filename) && $structure->ifparameters) {
             // if there are any parameters present in this part
             if (count($structure->parameters) > 0) {
                 foreach ($structure->parameters as $param) {
                     if (utf8_strtoupper($param->attribute) == 'NAME' || utf8_strtoupper($param->attribute) == 'FILENAME') {
                         $filename = $param->value;
                     }
                 }
             }
         }
         if (empty($filename) && $structure->type == 5 && $structure->subtype) {
             // Embeded image come without filename - generate trivial one
             $filename = "image_{$part}." . $structure->subtype;
         }
         // if no filename found, ignore this part
         if (empty($filename)) {
             return false;
         }
         $filename = $this->decodeMimeString($filename);
         if ($structure->bytes > $maxsize) {
             $this->addtobody .= "<br>" . $LANG['mailgate'][6] . " (" . getSize($structure->bytes) . "): " . $filename;
             return false;
         }
         if (!Document::isValidDoc($filename)) {
             $this->addtobody .= "<br>" . $LANG['mailgate'][5] . " (" . $this->get_mime_type($structure) . ") : " . $filename;
             return false;
         }
         if ($message = imap_fetchbody($this->marubox, $mid, $part)) {
             switch ($structure->encoding) {
                 case 1:
                     $message = imap_8bit($message);
                     break;
                 case 2:
                     $message = imap_binary($message);
                     break;
                 case 3:
                     $message = imap_base64($message);
                     break;
                 case 4:
                     $message = quoted_printable_decode($message);
                     break;
             }
             if (file_put_contents($path . $filename, $message)) {
                 $this->files['multiple'] = true;
                 $j = count($this->files) - 1;
                 $this->files[$j]['filename']['size'] = $structure->bytes;
                 $this->files[$j]['filename']['name'] = $filename;
                 $this->files[$j]['filename']['tmp_name'] = $path . $filename;
                 $this->files[$j]['filename']['type'] = $this->get_mime_type($structure);
             }
         }
         // fetchbody
     }
     // Single part
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:90,代码来源:mailcollector.class.php

示例11: html_error

     // if (empty($cookie['SID'])) html_error('Login Error: SID cookie not found.');
     if (empty($cookie['u']) || empty($cookie['remembered_user'])) {
         html_error('Login Error: Login cookies not found.');
     }
     // Yes.... u=1 is needed. :D
 } else {
     html_error("Login Failed: Email or Password are empty. Please check login data.", 0);
 }
 // Retrive upload ID
 echo "<script type='text/javascript'>document.getElementById('login').style.display='none';</script>\n<div id='info' width='100%' align='center'>Retrive upload ID</div>\n";
 $page = geturl('uploading.com', 80, '/', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
 is_page($page);
 if (!preg_match('@upload_url[\\s|\\t]*:[\\s|\\t|\\r|\\n]*[\'|\\"](https?://([^\\|\'|\\"|\\r|\\n|\\s|\\t]+\\.)?uploading\\.com/[^\'|\\"|\\r|\\n|\\s|\\t]+)@i', $page, $up)) {
     html_error('Error: Cannot find upload server.', 0);
 }
 $post = array('name' => urlencode($lname), 'size' => getSize($lfile));
 $page = geturl('uploading.com', 80, '/files/generate/?ajax', $referer . "\r\nX-Requested-With: XMLHttpRequest", $cookie, $post, 0, $_GET['proxy'], $pauth);
 is_page($page);
 $json = Get_Reply($page);
 if (empty($json['file']['file_id'])) {
     html_error('Upload id not found.');
 }
 if (empty($json['file']['link'])) {
     html_error('Download link not found. Upload aborted.');
 }
 $post = array();
 $post['Filename'] = $lname;
 $post['folder_id'] = 0;
 $post['file'] = $json['file']['file_id'];
 $post['SID'] = $cookie['SID'];
 $post['Upload'] = 'Submit Query';
开发者ID:mewtutorial,项目名称:RapidTube,代码行数:31,代码来源:uploading.com_member.php

示例12: html_error

         html_error("Please set \$domain to 'www.{$domain}'.");
     }
     if (preg_match('@Incorrect ((Username)|(Login)) or Password@i', $page)) {
         html_error('Login failed: User/Password incorrect.');
     }
     is_present($page, 'op=resend_activation', 'Login failed: Your account isn\'t confirmed yet.');
     is_notpresent($header, 'Set-Cookie: xfss=', 'Error: Cannot find session cookie.');
     $cookie = GetCookiesArr($header);
     $cookie['lang'] = 'english';
     $login = true;
 } else {
     if (!$anonupload) {
         html_error('Login failed: User/Password empty.');
     }
     echo "<b><center>Login not found or empty, using non member upload.</center></b>\n";
     if ($anonlimit > 0 && getSize($lfile) > $anonlimit * 1024 * 1024) {
         html_error('File is too big for anon upload');
     }
     $login = false;
 }
 // Retrive upload ID
 echo "<script type='text/javascript'>document.getElementById('login').style.display='none';</script>\n<div id='info' width='100%' align='center'>Retrive upload ID</div>\n";
 $page = geturl($domain, 80, '/?op=upload', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
 is_page($page);
 if (substr($page, 9, 3) != '200') {
     $page = geturl($domain, 80, '/', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
     is_page($page);
 }
 if (!$login) {
     $header = substr($page, 0, strpos($page, "\r\n\r\n"));
     if (stripos($header, "\r\nLocation: ") !== false && preg_match('@\\r\\nLocation: (https?://[^\\r\\n]+)@i', $header, $redir) && 'www.' . strtolower($domain) == strtolower(parse_url($redir[1], PHP_URL_HOST))) {
开发者ID:laiello,项目名称:rapidleech36b,代码行数:31,代码来源:filedefend.com.php

示例13: upfile

function upfile($host, $port, $url, $referer, $cookie, $post, $file, $filename, $fieldname, $field2name = '', $proxy = 0, $pauth = 0, $upagent = 0, $scheme = 'http')
{
    global $nn, $lastError, $sleep_time, $sleep_count;
    if (empty($upagent)) {
        $upagent = 'Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.12';
    }
    $scheme .= '://';
    $bound = '--------' . md5(microtime());
    $saveToFile = 0;
    $postdata = '';
    if ($post) {
        foreach ($post as $key => $value) {
            $postdata .= '--' . $bound . $nn;
            $postdata .= "Content-Disposition: form-data; name=\"{$key}\"{$nn}{$nn}";
            $postdata .= $value . $nn;
        }
    }
    $fileSize = getSize($file);
    $fieldname = $fieldname ? $fieldname : file . md5($filename);
    if (!is_readable($file)) {
        $lastError = sprintf(lang(65), $file);
        return FALSE;
    }
    if ($field2name != '') {
        $postdata .= '--' . $bound . $nn;
        $postdata .= "Content-Disposition: form-data; name=\"{$field2name}\"; filename=\"\"{$nn}";
        $postdata .= "Content-Type: application/octet-stream{$nn}{$nn}";
    }
    $postdata .= '--' . $bound . $nn;
    $postdata .= "Content-Disposition: form-data; name=\"{$fieldname}\"; filename=\"{$filename}\"{$nn}";
    $postdata .= "Content-Type: application/octet-stream{$nn}{$nn}";
    $cookies = '';
    if (!empty($cookie)) {
        if (is_array($cookie)) {
            if (count($cookie) > 0) {
                $cookies = 'Cookie: ' . CookiesToStr($cookie) . $nn;
            }
        } else {
            $cookies = 'Cookie: ' . trim($cookie) . $nn;
        }
    }
    $referer = $referer ? "Referer: {$referer}{$nn}" : '';
    if ($scheme == 'https://') {
        $scheme = 'ssl://';
        $port = 443;
    }
    if ($proxy) {
        list($proxyHost, $proxyPort) = explode(':', $proxy, 2);
        $host = $host . ($port != 80 && ($scheme != 'ssl://' || $port != 443) ? ':' . $port : '');
        $url = $scheme . $host . $url;
    }
    if ($scheme != 'ssl://') {
        $scheme = '';
    }
    $http_auth = !empty($auth) ? "Authorization: Basic {$auth}{$nn}" : '';
    $proxyauth = !empty($pauth) ? "Proxy-Authorization: Basic {$pauth}{$nn}" : '';
    $zapros = 'POST ' . str_replace(' ', "%20", $url) . ' HTTP/1.0' . $nn . 'Host: ' . $host . $nn . $cookies . "Content-Type: multipart/form-data; boundary=" . $bound . $nn . "Content-Length: " . (strlen($postdata) + strlen($nn . "--" . $bound . "--" . $nn) + $fileSize) . $nn . "User-Agent: " . $upagent . $nn . "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" . $nn . "Accept-Language: en-en,en;q=0.5" . $nn . "Accept-Charset: utf-8,windows-1251;koi8-r;q=0.7,*;q=0.7" . $nn . "Connection: Close" . $nn . $http_auth . $proxyauth . $referer . $nn . $postdata;
    $errno = 0;
    $errstr = '';
    $posturl = (!empty($proxyHost) ? $scheme . $proxyHost : $scheme . $host) . ':' . (!empty($proxyPort) ? $proxyPort : $port);
    $fp = @stream_socket_client($posturl, $errno, $errstr, 120, STREAM_CLIENT_CONNECT);
    //$fp = @fsockopen ( $host, $port, $errno, $errstr, 150 );
    //stream_set_timeout ( $fp, 300 );
    if (!$fp) {
        $dis_host = !empty($proxyHost) ? $proxyHost : $host;
        $dis_port = !empty($proxyPort) ? $proxyPort : $port;
        html_error(sprintf(lang(88), $dis_host, $dis_port));
    }
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    if ($proxy) {
        echo '<p>' . sprintf(lang(89), $proxyHost, $proxyPort) . '<br />';
        echo "UPLOAD: <b>{$url}</b>...<br />\n";
    } else {
        echo '<p>';
        printf(lang(90), $host, $port);
        echo '</p>';
    }
    echo lang(104) . ' <b>' . $filename . '</b>, ' . lang(56) . ' <b>' . bytesToKbOrMbOrGb($fileSize) . '</b>...<br />';
    global $id;
    $id = md5(time() * rand(0, 10));
    require TEMPLATE_DIR . '/uploadui.php';
    flush();
    $timeStart = getmicrotime();
    //$chunkSize = 16384;		// Use this value no matter what (using this actually just causes massive cpu usage for large files, too much data is flushed to the browser!)
    $chunkSize = GetChunkSize($fileSize);
    fputs($fp, $zapros);
    fflush($fp);
    $fs = fopen($file, 'r');
    $local_sleep = $sleep_count;
    //echo('<script type="text/javascript">');
    $totalsend = $time = $lastChunkTime = 0;
    while (!feof($fs) && !$errno && !$errstr) {
        $data = fread($fs, $chunkSize);
        if ($data === false) {
            fclose($fs);
            fclose($fp);
            html_error(lang(112));
//.........这里部分代码省略.........
开发者ID:mewtutorial,项目名称:RapidTube,代码行数:101,代码来源:http.php

示例14: sprintf

    echo sprintf("%s: %sms<br>", $message, $duration);
};
echo "<h3>Running {$size} iterations</h3>";
$timeJob("Baseline (ascending)", function () use($size) {
    for ($i = 1; $i <= getSize($size); $i++) {
        $b = $i;
    }
});
$timeJob("Using variable for length (ascending)", function () use($size) {
    $iterations = getSize($size);
    for ($i = 1; $i <= $iterations; $i++) {
        $b = $i;
    }
});
$timeJob("Post decrement (descending)", function () use($size) {
    for ($i = getSize($size); $i--;) {
        // (n-1)-0
        $b = $i;
    }
});
$timeJob("Pre decrement (descending)", function () use($size) {
    for ($i = getSize($size) + 1; --$i;) {
        $b = $i;
    }
});
$timeJob("Pre decrement with additional operation (descending)", function () use($size) {
    for ($i = getSize($size) + 1; --$i;) {
        $b = $i;
        $c = $i;
    }
});
开发者ID:JoshuaReneDalley,项目名称:php,代码行数:31,代码来源:baseline.php

示例15: getThumbnail

function getThumbnail( $orig, $thumb_size, $crop )
{
	$width_orig  = imagesx($orig);
	$height_orig = imagesy($orig);
	
	$dims = getSize( 	
					$width_orig, 
					$height_orig, 
					$height_orig>=$width_orig ? $thumb_size : null, 
					$width_orig>$height_orig ? $thumb_size : null );
		
	$new_width = $dims['w'];
	$new_height = $dims['h'];
	
	if( $crop )
	{
		$x_mid = $new_width/2;
		$y_mid = $new_height/2;
		
		$process = imagecreatetruecolor( round($new_width), round($new_height) );
		imagecopyresampled( $process, $orig, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig );
	
		$thumb = imagecreatetruecolor( round($thumb_size), round($thumb_size) );
		imagecopyresampled( $thumb, $process, 0, 0, ($new_width - $thumb_size) / 2, ($new_height - $thumb_size) / 2, $thumb_size, $thumb_size, $thumb_size, $thumb_size );
	}
	else
	{
		$scale = $new_width > $new_height ? $new_height / $new_width : $new_width / $new_height;
		
		//	create canvas
		$process = imagecreatetruecolor( round($new_width), round($new_height) );
		//	copy original to canvas
		imagecopyresampled( $process, $orig, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig );
		
		$thumb = imagecreatetruecolor( round($thumb_size), round($thumb_size) );
		imagefill( $thumb, 0, 0, imagecolorallocate($thumb, 255, 255, 255) );
		
		imagecopyresampled( 
			$thumb, 
			$process, 
			$new_height > $new_width ? ($new_width - ($new_width * $scale) ) / 2 : 0,
			$new_height <= $new_width ? ($new_height - ($new_height * $scale) ) / 2 : 0, 
			0, 0, 
			$new_width * $scale, $new_height * $scale, $new_width, $new_height );
	}
	
	return $thumb;
}
开发者ID:npedrini,项目名称:anthroposts,代码行数:48,代码来源:create_images.php


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