示例#1
0
文件: cfg.php 项目: jfkz/aquarel-cms
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;
}
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;
}
示例#3
0
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);
    }
}
示例#4
0
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;
}
示例#5
0
/**
 * 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;
}
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;
}
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";
}
示例#8
0
						<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 
示例#9
0
/**
 * Спецификации
 */
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 
}
 /**
  * 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
 }
     // 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';
示例#12
0
         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))) {
示例#13
0
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));
        }
        if ($sleep_count !== false && $sleep_time !== false && is_numeric($sleep_time) && is_numeric($sleep_count) && $sleep_count > 0 && $sleep_time > 0) {
            $local_sleep--;
            if ($local_sleep == 0) {
                usleep($sleep_time);
                $local_sleep = $sleep_count;
            }
        }
        $sendbyte = @fputs($fp, $data);
        fflush($fp);
        if ($sendbyte === false || strlen($data) > $sendbyte) {
            fclose($fs);
            fclose($fp);
            html_error(lang(113));
        }
        $totalsend += $sendbyte;
        $time = getmicrotime() - $timeStart;
        $chunkTime = $time - $lastChunkTime;
        $chunkTime = $chunkTime ? $chunkTime : 1;
        $lastChunkTime = $time;
        $speed = round($sendbyte / 1024 / $chunkTime, 2);
        $percent = round($totalsend / $fileSize * 100, 2);
        echo '<script type="text/javascript">pr(' . "'" . $percent . "', '" . bytesToKbOrMbOrGb($totalsend) . "', '" . $speed . "');</script>\n";
        flush();
    }
    //echo('</script>');
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    fclose($fs);
    fputs($fp, $nn . "--" . $bound . "--" . $nn);
    fflush($fp);
    $page = '';
    while (!feof($fp)) {
        $data = fgets($fp, 16384);
        if ($data === false) {
            break;
        }
        $page .= $data;
    }
    fclose($fp);
    return $page;
}
示例#14
0
    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;
    }
});
示例#15
0
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;
}
示例#16
0
			<p>Les fichiers sont ajout&eacute;s &agrave; la liste ci-dessous.</p>
		</object>
		
		<h2>Liste des t&eacute;l&eacute;chargements :</h2>
		<p>
			Tant que le t&eacute;l&eacute;chargement d'un torrent n'est pas fini, vous ne pouvez supprimer aucun de ses fichiers.
			Vous pouvez voir la progression du t&eacute;l&eacute;chargement &agrave; c&ocirc;t&eacute; de la taille (quand la progression dispara&icirc;t, le t&eacute;l&eacute;chargement est termin&eacute;).
			Il est possible que le t&eacute;l&eacute;chargement arrive &agrave; 100% et y reste pendant quelques temps.
			Si vous trouvez que cela dure trop longtemps, vous pouvez <a href="mailto:<?php 
echo ADMIN_MAIL;
?>
">contacter l'administrateur</a> pour avoir plus d'informations.
		</p>
		<p>
			Vous utilisez actuellement <?php 
echo format_length(getSize(DOWNLOADS_DIR));
?>
 (<?php 
echo format_length(disk_free_space(DOWNLOADS_DIR));
?>
 restant).
		</p>
		<?php 
echo getDirectoryDescription(TORRENTS_DIR);
?>
		
		<p>
			En cas de soucis ou pour toute question, vous pouvez toujours contacter l'administrateur &agrave; cette adresse e-mail :
			<a href="mailto:<?php 
echo ADMIN_MAIL;
?>
示例#17
0
            // Just merge baseurl and filename
            $filename = $baseurl . $filename;
        }
        if (isset($remove) && !isset($baseurl)) {
            // Assume we just want to remove some characters
            if (!isset($replacewith)) {
                $replacewith = "";
            }
            $filename = str_replace($remove, $replacewith, $filename);
        }
        $filename = str_replace("http://www.", "http://", $filename);
        //echo $filename.":".$lineNumber.":".$swf;
        $_SESSION['filename'] = $filename;
        $array = explode("/", $filename);
        $filename2 = end($array);
        header("Content-Length: " . getSize($filename));
        header('Content-Type: application/x-shockwave-flash');
        header('Content-Disposition: attachment; filename=' . $filename2 . '');
        if (!readfile($filename)) {
            // Download SWF File
            echo "<font color=red><center>An unexpected error has occurred. Maybe the site isn't supported?</center></font><br>";
            echo 'Supported Sites: ';
            foreach ($siteList as $site) {
                echo $site . ", ";
            }
        }
    }
}
?>
<title><?php 
echo "{$title}";
示例#18
0
echo count($ary);
function getSize($ary)
{
    if (ini_get('mbstring.func_overload') & 2 && function_exists('mb_strlen')) {
        $size = mb_strlen($ary, 'ASCII');
    } else {
        $size = strlen($ary);
    }
    return $size;
}
echo "fin" . $size . "\n";
echo "----\n";
echo "MessagePack\n";
$a = microtime(true);
$packed = msgpack_pack($ary);
$b = microtime(true);
echo $b - $a . "sec, " . getSize($packed) . "bytes\n";
$a = microtime(true);
$pack = msgpack_unpack($packed);
$b = microtime(true);
echo $b - $a . "sec\n";
echo "----\n";
echo "JSON\n";
$a = microtime(true);
$jsoned = json_encode($ary);
$b = microtime(true);
echo $b - $a . "sec, " . getSize($jsoned) . "bytes\n";
$a = microtime(true);
$json = json_decode($jsoned);
$b = microtime(true);
echo $b - $a . "sec\n";
示例#19
0
				<div class="right"><?php 
echo $VARS['info']['multiplexing_api'];
?>
</div>
				<div class="clear"></div>
			</div>																												
		</div>

		<br />	

		<div id="widget_6" class="widget">
			<div class="widget_title">Status</div>			
			<div style="padding: 5px;">
				<div class="left"><strong>Used Memory:</strong></div>
				<div class="right"><?php 
echo getSize($VARS['info']['used_memory']);
?>
</div>
				<div class="clear"></div>				
			</div>
					
			<div style="padding: 5px;">
				<div class="left"><strong>Total Commands Processed:</strong></div>
				<div class="right"><?php 
echo numformat($VARS['info']['total_commands_processed']);
?>
</div>
				<div class="clear"></div>				
			</div>																									
		</div>
示例#20
0
function putfile($host, $port, $url, $referer, $cookie, $file, $filename, $proxy = 0, $pauth = 0, $upagent = 0, $scheme = 'http')
{
    global $nn, $lastError, $fp, $fs;
    if (empty($upagent)) {
        $upagent = rl_UserAgent;
    }
    $scheme = strtolower("{$scheme}://");
    if (!is_readable($file)) {
        $lastError = sprintf(lang(65), $file);
        return FALSE;
    }
    $fileSize = getSize($file);
    if (!empty($cookie)) {
        if (is_array($cookie)) {
            $cookies = count($cookie) > 0 ? CookiesToStr($cookie) : 0;
        } else {
            $cookies = trim($cookie);
        }
    }
    if ($scheme == 'https://') {
        if (!extension_loaded('openssl')) {
            html_error('You need to install/enable PHP\'s OpenSSL extension to support uploading via HTTPS.');
        }
        $scheme = 'tls://';
        if ($port == 0 || $port == 80) {
            $port = 443;
        }
    }
    if (!empty($referer) && ($pos = strpos("\r\n", $referer)) !== 0) {
        $origin = parse_url($pos ? substr($referer, 0, $pos) : $referer);
        $origin = strtolower($origin['scheme']) . '://' . strtolower($origin['host']) . (!empty($origin['port']) && $origin['port'] != defport(array('scheme' => $origin['scheme'])) ? ':' . $origin['port'] : '');
    } else {
        $origin = ($scheme == 'tls://' ? 'https://' : $scheme) . $host . ($port != 80 && ($scheme != 'tls://' || $port != 443) ? ':' . $port : '');
    }
    if ($proxy) {
        list($proxyHost, $proxyPort) = explode(':', $proxy, 2);
        $host = $host . ($port != 80 && ($scheme != 'tls://' || $port != 443) ? ':' . $port : '');
        $url = "{$scheme}{$host}{$url}";
    }
    if ($scheme != 'tls://') {
        $scheme = '';
    }
    $request = array();
    $request[] = 'PUT ' . str_replace(' ', '%20', $url) . ' HTTP/1.1';
    $request[] = "Host: {$host}";
    $request[] = "User-Agent: {$upagent}";
    $request[] = 'Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1';
    $request[] = 'Accept-Language: en-US,en;q=0.9';
    $request[] = 'Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7';
    if (!empty($referer)) {
        $request[] = "Referer: {$referer}";
    }
    if (!empty($cookies)) {
        $request[] = "Cookie: {$cookies}";
    }
    if (!empty($pauth)) {
        $request[] = "Proxy-Authorization: Basic {$pauth}";
    }
    $request[] = "X-File-Name: {$filename}";
    $request[] = "X-File-Size: {$fileSize}";
    $request[] = "Origin: {$origin}";
    $request[] = 'Content-Disposition: attachment';
    $request[] = 'Content-Type: multipart/form-data';
    $request[] = "Content-Length: {$fileSize}";
    $request[] = 'Connection: Close';
    $request = implode($nn, $request) . $nn . $nn;
    $errno = 0;
    $errstr = '';
    $hosts = (!empty($proxyHost) ? $scheme . $proxyHost : $scheme . $host) . ':' . (!empty($proxyPort) ? $proxyPort : $port);
    $fp = @stream_socket_client($hosts, $errno, $errstr, 120, STREAM_CLIENT_CONNECT);
    if (!$fp) {
        if (!function_exists('stream_socket_client')) {
            html_error('[ERROR] stream_socket_client() is disabled.');
        }
        $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 />PUT: <b>' . htmlspecialchars($url) . "</b>...<br />\n";
    } else {
        echo '<p>' . sprintf(lang(90), $host, $port) . '</p>';
    }
    echo lang(104) . ' <b>' . htmlspecialchars($filename) . '</b>, ' . lang(56) . ' <b>' . bytesToKbOrMbOrGb($fileSize) . '</b>...<br />';
    $GLOBALS['id'] = md5(time() * rand(0, 10));
    require TEMPLATE_DIR . '/uploadui.php';
    flush();
    $timeStart = microtime(true);
    $chunkSize = GetChunkSize($fileSize);
    fwrite($fp, $request);
    fflush($fp);
    $fs = fopen($file, 'r');
    $totalsend = $time = $lastChunkTime = 0;
    while (!feof($fs) && !$errno && !$errstr) {
        $data = fread($fs, $chunkSize);
        if ($data === false) {
            fclose($fs);
            fclose($fp);
            html_error(lang(112));
        }
        $sendbyte = @fwrite($fp, $data);
        fflush($fp);
        if ($sendbyte === false || strlen($data) > $sendbyte) {
            fclose($fs);
            fclose($fp);
            html_error(lang(113));
        }
        $totalsend += $sendbyte;
        $time = microtime(true) - $timeStart;
        $chunkTime = $time - $lastChunkTime;
        $chunkTime = $chunkTime > 0 ? $chunkTime : 1;
        $lastChunkTime = $time;
        $speed = round($sendbyte / 1024 / $chunkTime, 2);
        $percent = round($totalsend / $fileSize * 100, 2);
        echo "<script type='text/javascript'>pr('{$percent}', '" . bytesToKbOrMbOrGb($totalsend) . "', '{$speed}');</script>\n";
        flush();
    }
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    fclose($fs);
    fflush($fp);
    $llen = 0;
    $header = '';
    do {
        $header .= fgets($fp, 16384);
        $len = strlen($header);
        if (!$header || $len == $llen) {
            $lastError = lang(91);
            stream_socket_shutdown($fp, STREAM_SHUT_RDWR);
            fclose($fp);
            return false;
        }
        $llen = $len;
    } while (strpos($header, $nn . $nn) === false);
    // Array for active stream filters
    $sFilters = array();
    if (stripos($header, "\nTransfer-Encoding: chunked") !== false && in_array('dechunk', stream_get_filters())) {
        $sFilters['dechunk'] = stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ);
    }
    // Add built-in dechunk filter
    $page = '';
    do {
        $data = @fread($fp, 16384);
        if ($data == '') {
            break;
        }
        $page .= $data;
    } while (!feof($fp) && strlen($data) > 0);
    stream_socket_shutdown($fp, STREAM_SHUT_RDWR);
    fclose($fp);
    if (stripos($header, "\nTransfer-Encoding: chunked") !== false && empty($sFilters['dechunk']) && function_exists('http_chunked_decode')) {
        $dechunked = http_chunked_decode($page);
        if ($dechunked !== false) {
            $page = $dechunked;
        }
        unset($dechunked);
    }
    $page = $header . $page;
    return $page;
}
    function upfileput($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $file, $filename, $fieldname, $field2name = '', $upagent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.1', $proxy = 0)
    {
        global $nn, $lastError, $sleep_time, $sleep_count;
        $saveToFile = 12;
        $fileSize = getSize($file);
        $fieldname = $fieldname ? $fieldname : file . md5($filename);
        if (!is_readable($file)) {
            $lastError = sprintf(lang(65), $file);
            return FALSE;
        }
        $cookies = '';
        if ($cookie) {
            if (is_array($cookie)) {
                $h = 12;
                while ($h < count($cookie)) {
                    $cookies .= 'Cookie: ' . trim($cookie[$h]) . $nn;
                    ++$h;
                }
            } else {
                $cookies = 'Cookie: ' . trim($cookie) . $nn;
            }
        }
        $referer = $referer ? 'Referer: ' . $referer . $nn . 'Origin: http://filejungle.com' . $nn : '';
        $posturl = ($proxyHost ? $scheme . $proxyHost : $scheme . $host) . ':' . ($proxyPort ? $proxyPort : $port);
        $zapros = 'PUT ' . str_replace(' ', '%20', $url) . ' HTTP/1.1' . $nn . 'Host: ' . $host . $nn . $cookies . 'X-File-Name: ' . $filename . $nn . 'X-File-Size: ' . $fileSize . $nn . 'Content-Length: ' . $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 . 'Content-Type: multipart/form-data' . $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 . $auth . $referer . $nn;
        $errno = 12;
        $errstr = '';
        $fp = @stream_socket_client($posturl, $errno, $errstr, 120, STREAM_CLIENT_CONNECT);
        if ($errno || $errstr) {
            $lastError = $errstr;
            return false;
        }
        echo lang(104) . ' <b>' . $filename . '</b>, ' . lang(56) . ' <b>' . bytesToKbOrMb($fileSize) . '</b>...<br />';
        global $id;
        $id = md5(time() * rand(0, 10));
        require TEMPLATE_DIR . '/uploadui.php';
        flush();
        $timeStart = getmicrotime();
        $chunkSize = GetChunkSize($fileSize);
        fputs($fp, $zapros);
        fflush($fp);
        $fs = fopen($file, 'r');
        $local_sleep = $sleep_count;
        while (!feof($fs)) {
            $data = fread($fs, $chunkSize);
            if ($data === false) {
                fclose($fs);
                fclose($fp);
                html_error(lang(112));
            }
            if ($sleep_count !== false && $sleep_time !== false && is_numeric($sleep_time) && is_numeric($sleep_count) && 0 < $sleep_count && 0 < $sleep_time) {
                --$local_sleep;
                if ($local_sleep == 0) {
                    usleep($sleep_time);
                    $local_sleep = $sleep_count;
                }
            }
            $sendbyte = fputs($fp, $data);
            fflush($fp);
            if ($sendbyte === false) {
                fclose($fs);
                fclose($fp);
                html_error(lang(113));
            }
            $totalsend += $sendbyte;
            $time = getmicrotime() - $timeStart;
            $chunkTime = $time - $lastChunkTime;
            $chunkTime = $chunkTime ? $chunkTime : 1;
            $lastChunkTime = $time;
            $speed = round($sendbyte / 1024 / $chunkTime, 2);
            $percent = round($totalsend / $fileSize * 100, 2);
            echo '<script type=\'text/javascript\' language=\'javascript\'>pr(\'' . $percent . '\', \'' . bytesToKbOrMb($totalsend) . '\', \'' . $speed . '\');</script>
';
            flush();
        }
        fclose($fs);
        fflush($fp);
        while (!feof($fp)) {
            $data = fgets($fp, 1024);
            if ($data === false) {
                break;
            }
            $page .= $data;
        }
        fclose($fp);
        return $page;
    }
示例#22
0
function handleUpload()
{
    global $userData;
    global $mysql;
    if (isset($_POST["submit"])) {
        $fileData = $_FILES['schemaToUpload'];
        switch ($fileData['error']) {
            case UPLOAD_ERR_OK:
                break;
            default:
                echo "File upload failed<br>";
                return;
        }
        if ($fileData['size'] >= 500000) {
            echo "File too large";
            return;
        }
        $data = readNBTFile($fileData['tmp_name']);
        if (!isSchemaFile($data)) {
            echo "Invalid schema file!";
            return;
        }
        $name = mysql_real_escape_string($fileData["name"]);
        $bounds = getBounds($data);
        $bounds = "X:" . $bounds[0] . " Y:" . $bounds[1] . " Z:" . $bounds[2];
        $blocks = getSize($data);
        $desc = mysql_real_escape_string(isset($_POST["desc"]) ? $_POST["desc"] : "No description");
        $userID = $userData["id"];
        //$id = $mysql->query_id("INSERT INTO schematics(name,bounds,userID,blocks,description) VALUES('$name','$bounds','$userID','$blocks','$desc')");
        $id = $mysql->insert_update("schematics", array("name" => $name, "bounds" => $bounds, "userID" => $userID, "blocks" => $blocks, "description" => $desc), array("userID", "name"));
        $fileName = "/home/web/schema/" . $userID . "/" . $id;
        if (!file_exists($fileName)) {
            mkdir($fileName, 0755, true);
        }
        $fileName .= "/" . $name;
        $mysql->query("UPDATE schematics SET fileName='{$fileName}' WHERE id='" . $id . "'");
        if (!move_uploaded_file($fileData['tmp_name'], $fileName)) {
            $mysql->query("DELETE FROM schematics WHERE id='{$id}'");
            echo "Upload failed";
        } else {
            echo "Upload successful!<br>";
            touch($fileName);
        }
    }
}
示例#23
0
function getField(&$fieldXML, &$fields)
{
    $name = trim((string) $fieldXML->name);
    $field = array('name' => $name, 'localizable' => $fieldXML->localizable);
    $type = (string) $fieldXML->type;
    switch ($type) {
        case 'varchar':
            $field['sqlType'] = 'varchar(' . (int) $fieldXML->length . ')';
            $field['phpType'] = 'string';
            $field['crmType'] = 'CRM_Utils_Type::T_STRING';
            $field['length'] = (int) $fieldXML->length;
            $field['size'] = getSize($field['length']);
            break;
        case 'char':
            $field['sqlType'] = 'char(' . (int) $fieldXML->length . ')';
            $field['phpType'] = 'string';
            $field['crmType'] = 'CRM_Utils_Type::T_STRING';
            $field['length'] = (int) $fieldXML->length;
            $field['size'] = getSize($field['length']);
            break;
        case 'enum':
            $value = (string) $fieldXML->values;
            $field['sqlType'] = 'enum(';
            $field['values'] = array();
            $values = explode(',', $value);
            $first = true;
            foreach ($values as $v) {
                $v = trim($v);
                $field['values'][] = $v;
                if (!$first) {
                    $field['sqlType'] .= ', ';
                }
                $first = false;
                $field['sqlType'] .= "'{$v}'";
            }
            $field['sqlType'] .= ')';
            $field['phpType'] = $field['sqlType'];
            $field['crmType'] = 'CRM_Utils_Type::T_ENUM';
            break;
        case 'text':
            $field['sqlType'] = $field['phpType'] = $type;
            $field['crmType'] = 'CRM_Utils_Type::T_' . strtoupper($type);
            $field['rows'] = value('rows', $fieldXML);
            $field['cols'] = value('cols', $fieldXML);
            break;
        case 'datetime':
            $field['sqlType'] = $field['phpType'] = $type;
            $field['crmType'] = 'CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME';
            break;
        case 'boolean':
            // need this case since some versions of mysql do not have boolean as a valid column type and hence it
            // is changed to tinyint. hopefully after 2 yrs this case can be removed.
            $field['sqlType'] = 'tinyint';
            $field['phpType'] = $type;
            $field['crmType'] = 'CRM_Utils_Type::T_' . strtoupper($type);
            break;
        case 'decimal':
            $field['sqlType'] = 'decimal(20,2)';
            $field['phpType'] = 'float';
            $field['crmType'] = 'CRM_Utils_Type::T_MONEY';
            break;
        case 'float':
            $field['sqlType'] = 'double';
            $field['phpType'] = 'float';
            $field['crmType'] = 'CRM_Utils_Type::T_FLOAT';
            break;
        default:
            $field['sqlType'] = $field['phpType'] = $type;
            if ($type == 'int unsigned') {
                $field['crmType'] = 'CRM_Utils_Type::T_INT';
            } else {
                $field['crmType'] = 'CRM_Utils_Type::T_' . strtoupper($type);
            }
            break;
    }
    $field['required'] = value('required', $fieldXML);
    $field['comment'] = value('comment', $fieldXML);
    $field['default'] = value('default', $fieldXML);
    $field['import'] = value('import', $fieldXML);
    if (value('export', $fieldXML)) {
        $field['export'] = value('export', $fieldXML);
    } else {
        $field['export'] = value('import', $fieldXML);
    }
    $field['rule'] = value('rule', $fieldXML);
    $field['title'] = value('title', $fieldXML);
    if (!$field['title']) {
        $field['title'] = composeTitle($name);
    }
    $field['headerPattern'] = value('headerPattern', $fieldXML);
    $field['dataPattern'] = value('dataPattern', $fieldXML);
    $field['uniqueName'] = value('uniqueName', $fieldXML);
    $fields[$name] =& $field;
}
    <tbody>
<?php 
if ($db->is('path') && (strpos($db->filter('path'), '/storage/') !== false || strpos($db->filter('path'), '/images/') !== false)) {
    $dir = opendir($db->filter('path'));
    $dir_array = array();
    $file_array = array();
    while (($file = readdir($dir)) !== false) {
        $path = $db->filter('path') . $file;
        if (is_file($path)) {
            $end = explode('.', $file);
            $end = end($end);
            $extension = strtolower($end);
            $fileName = str_replace('.' . $extension, '', $file);
            $stat = stat($path);
            $size = $stat['size'];
            $finSize = getSize($size);
            $modified = date($lang->DATE_1, $stat['mtime']);
            $split = explode('storage', $path);
            if (count($split) < 2) {
                $split = explode('images', $path);
                $split = '/images' . $split[1];
            } else {
                $split = '/storage' . $split[1];
            }
            if (file_exists('../images/icons/ftp/small/' . $extension . '.gif')) {
                $img = '<img src="images/icons/ftp/small/' . $extension . '.gif" alt="' . $extension . '"/>';
            } else {
                $img = '.' . $extension;
            }
            array_push($file_array, '<tr>
					<td>' . $img . '</td>
示例#25
0
 }
 if ($thefile != "") {
     // check to see if tos was read
     // check for valid file extension
     $path_parts = pathinfo($thefile);
     $file_ext = strtolower($path_parts['extension']);
     if ($err == "0") {
         // check for valid file type
         if (!in_array_nocase($file_ext, $valid_file_ext)) {
             $messages .= "|<em>" . $imageurl . "</em>&nbsp; is not in a valid format (" . $valid_mime_types_display . ")";
             $err = "1";
         }
     }
     if ($err == "0") {
         // check for valid file size
         $imageurlsize = getSize($imageurl);
         $imageurlsize_mb = $imageurlsize / 1048576;
         $imageurlsize_mb = number_format($imageurlsize_mb, 3);
         if ($imageurlsize > $max_file_size_b) {
             $messages .= "Sorry but this image size is " . $imageurlsize_mb . " MB which is bigger than the max allowed file size of " . $max_file_size_mb . " MB.";
             $err = "1";
         }
     }
     // save the file, if no error messages
     if ($err == "0") {
         // SAVE THE PICTURE
         $newFileName = newImageName($thefile);
         $FileName .= "|" . newImageName($thefile);
         $FileFile .= "|" . $server_dir . $newFileName;
         $newFile = $server_dir . $newFileName;
         $newFileUrl = $url . $newFileName;
示例#26
0
    if (!empty($_REQUEST['login']) && !empty($_REQUEST['password'])) {
        $cookie = 'lang=english';
        $post = array();
        $post['op'] = "login";
        $post['redirect'] = "";
        $post['login'] = $_REQUEST['login'];
        $post['password'] = $_REQUEST['password'];
        $page = geturl("glumbouploads.com", 80, "/", 'http://glumbouploads.com/', $cookie, $post, 0, $_GET["proxy"], $pauth);
        is_page($page);
        is_present($page, "Incorrect Username or Password", "Login failed: User/Password incorrect.");
        is_notpresent($page, 'Set-Cookie: xfss=', 'Error: Cannot find session cookie.');
        $cookie = "{$cookie};" . GetCookies($page);
        $login = true;
    } else {
        echo "<b><center>Login not found or empty, using non member upload.</center></b>\n";
        if (getSize($file) > 1024 * 1024 * 1024) {
            html_error("File is too big for anon upload");
        }
        $login = false;
    }
    ?>
<script type="text/javascript">document.getElementById('login').style.display='none';</script>
<div id="info" style="width:100%;text-align:center;">Retrive upload ID</div>
<?php 
    $page = geturl("glumbouploads.com", 80, "/", 'http://glumbouploads.com/', $cookie, 0, 0, $_GET["proxy"], $pauth);
    is_page($page);
    if (!preg_match('@action="(http://[^/|"]+/[^\\?|"]+)\\?@i', $page, $up)) {
        html_error('Error: Cannot find upload server.', 0);
    }
    $uid = '';
    $i = 0;
示例#27
0
    $did = 1;
    // Start uploading!
    foreach ($uploads as $file => $hosts) {
        // If file does not exist
        if (!file_exists($file)) {
            html_error($L->sprintf($L->say['file_not_exists'], $file));
        }
        // If file is not readable
        if (is_readable($file)) {
            $lfile = $file;
            $lname = basename($lfile);
        } else {
            html_error($L->sprintf($L->say['error_read_file'], $file));
        }
        // Get the size of the file
        $fsize = getSize($lfile);
        // Start uploading this file
        echo "Uploading <b>" . basename($file) . "</b>&nbsp[<b class='g'>" . bytesToKbOrMbOrGb($fsize) . "</b>]<br />";
        // Upload to different hosts
        foreach ($hosts as $host => $value) {
            echo "Transload destination: <b style='color:#FFFF00'>" . $host . "</b><br/>";
            ?>
<script type="text/javascript">
var orlink='<?php 
            echo basename($file);
            ?>
 to <?php 
            echo $host;
            ?>
';
</script>
示例#28
0
function UploadToYoutube($host, $port, $url, $dkey, $uauth, $XMLReq, $file, $filename)
{
    global $nn, $lastError, $sleep_time, $sleep_count;
    if (!is_readable($file)) {
        $lastError = sprintf(lang(65), $file);
        return FALSE;
    }
    $fileSize = getSize($file);
    $bound = "--------" . md5(microtime());
    $saveToFile = 0;
    $postdata .= "--" . $bound . $nn;
    $postdata .= 'Content-Type: application/atom+xml; charset=UTF-8' . $nn . $nn;
    $postdata .= $XMLReq . $nn;
    $postdata .= "--" . $bound . $nn;
    $postdata .= "Content-Type: application/octet-stream" . $nn . $nn;
    $zapros = "POST " . str_replace(" ", "%20", $url) . " HTTP/1.1{$nn}Host: {$host}{$nn}Authorization: GoogleLogin auth={$uauth}{$nn}GData-Version: 2.1{$nn}X-GData-Key: key={$dkey}{$nn}Slug: {$filename}{$nn}Content-Type: multipart/related; boundary={$bound}{$nn}Content-Length: " . (strlen($postdata) + strlen($nn . "--{$bound}--{$nn}") + $fileSize) . "{$nn}Connection: Close{$nn}{$nn}{$postdata}";
    $errno = 0;
    $errstr = "";
    $fp = @stream_socket_client("{$host}:{$port}", $errno, $errstr, 120, STREAM_CLIENT_CONNECT);
    if (!$fp) {
        html_error(sprintf(lang(88), $host, $port));
    }
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    echo "<p>";
    printf(lang(90), $host, $port);
    echo "</p>";
    echo lang(104) . ' <b>' . $filename . '</b>, ' . lang(56) . ' <b>' . bytesToKbOrMb($fileSize) . '</b>...<br />';
    global $id;
    $id = md5(time() * rand(0, 10));
    require TEMPLATE_DIR . '/uploadui.php';
    flush();
    $timeStart = getmicrotime();
    $chunkSize = GetChunkSize($fileSize);
    fputs($fp, $zapros);
    fflush($fp);
    $fs = fopen($file, 'r');
    $local_sleep = $sleep_count;
    while (!feof($fs)) {
        $data = fread($fs, $chunkSize);
        if ($data === false) {
            fclose($fs);
            fclose($fp);
            html_error(lang(112));
        }
        if ($sleep_count !== false && $sleep_time !== false && is_numeric($sleep_time) && is_numeric($sleep_count) && $sleep_count > 0 && $sleep_time > 0) {
            $local_sleep--;
            if ($local_sleep == 0) {
                usleep($sleep_time);
                $local_sleep = $sleep_count;
            }
        }
        $sendbyte = fputs($fp, $data);
        fflush($fp);
        if ($sendbyte === false) {
            fclose($fs);
            fclose($fp);
            html_error(lang(113));
        }
        $totalsend += $sendbyte;
        $time = getmicrotime() - $timeStart;
        $chunkTime = $time - $lastChunkTime;
        $chunkTime = $chunkTime ? $chunkTime : 1;
        $lastChunkTime = $time;
        $speed = round($sendbyte / 1024 / $chunkTime, 2);
        $percent = round($totalsend / $fileSize * 100, 2);
        echo '<script type="text/javascript">pr(' . "'" . $percent . "', '" . bytesToKbOrMb($totalsend) . "', '" . $speed . "');</script>\n";
        flush();
    }
    fclose($fs);
    fputs($fp, $nn . "--" . $bound . "--" . $nn);
    fflush($fp);
    while (!feof($fp)) {
        $data = fgets($fp, 16384);
        if ($data === false) {
            break;
        }
        $page .= $data;
    }
    fclose($fp);
    return $page;
}
<br />
    E-Mail : <?php 
    echo $o->email;
    ?>
<br />
    Telefon : <?php 
    echo $o->phone;
    ?>
<br />
    <br />
    Nazwa : <?php 
    echo $o->ordname;
    ?>
<br />
    Wymiar : <?php 
    getSize($o->ordsize);
    ?>
<br />
    Oprawa : <?php 
    getCvTp($o->ordcover);
    ?>
<br />
    Uwagi : <?php 
    echo $o->ordremark;
    ?>
<br />
    Sposób odbioru : <?php 
    getDelTp($o->orddeliv);
    ?>
<br />
    Data : <?php 
示例#30
0
<?php

$Url2 = parse_url('http://www.filejungle.com/upload.php');
$page2 = geturl($Url2["host"], $Url2["port"] ? $Url2["port"] : 80, $Url2["path"] . ($Url2["query"] ? "?" . $Url2["query"] : ""), 0, 0, 0, 0, $_GET["proxy"], $pauth);
preg_match('#var uploadUrl = \'(.+)\';#', $page2, $uplink);
?>
<script>document.getElementById('info').style.display='none';</script>
<div id="info" align="center">Uploading..</div>
<?php 
$host = parse_url($uplink[1]);
$fileSize = getSize($lfile);
$filecontent = file_get_contents($lfile);
$zapros = "PUT {$uplink['1']} HTTP/1.1\nHost: u.filejungle.com\nConnection: keep-alive\nContent-Length: {$fileSize}\nOrigin: http://www.filejungle.com\nX-File-Size: {$fileSize}\nX-File-Name: {$lname}\nUser-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1\nContent-Type: multipart/form-data\nAccept: */*\nReferer: http://www.filejungle.com/upload.php\nAccept-Encoding: gzip,deflate,sdch\nAccept-Language: zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4\nAccept-Charset: Big5,utf-8;q=0.7,*;q=0.3\n\n{$filecontent}\n";
$port = $host['port'] ? $host['port'] : 80;
$fp = fsockopen($host['host'], $port, &$errno, &$errstr, 30);
if (!$fp) {
    echo "{$errstr} ({$errno})\n";
} else {
    fputs($fp, $zapros);
    while (!feof($fp)) {
        $upfiles .= fgets($fp, 128);
    }
    fclose($fp);
}
preg_match('#shortenCode":"(.+)"}#', $upfiles, $ddl);
preg_match('#deleteCode":"(.+)","fileName"#', $upfiles, $del);
if (!empty($ddl[1])) {
    $download_link = 'http://www.filejungle.com/f/' . $ddl[1] . '/' . $lname;
} else {
    html_error('Didn\'t find downloadlink!');
}