コード例 #1
0
ファイル: listing.php プロジェクト: WebPassions/2015
    ?>
</td>
                    <td><?php 
    echo $record->getNewvisits();
    ?>
</td>
                    <td><?php 
    echo $record->getVisits();
    ?>
</td>
                    <td><?php 
    echo $record->getPageviews();
    ?>
</td>
                    <td><?php 
    echo sec2time($record->getTimeonsite());
    ?>
</td>
                </tr>
                <?php 
    $id++;
    ?>
            <?php 
}
?>
            </tbody>
        </table>
    </div>
    <div class="panel-footer text-right">
        <?php 
echo $this->FormLink->back(COCKPIT);
コード例 #2
0
ファイル: buildings.php プロジェクト: Wehmeyer/Litotex-0.7
             $message = $message . "<br>" . $op_set_n_res2 . ": " . $tofew_res2;
         }
         $tofew_res3 = $res3 - $userdata['res3'];
         if ($tofew_res3 > 0) {
             $message = $message . "<br>" . $op_set_n_res3 . ": " . $tofew_res3;
         }
         $tofew_res4 = $res4 - $userdata['res4'];
         if ($tofew_res4 > 0) {
             $message = $message . "<br>" . $op_set_n_res4 . ": " . $tofew_res4;
         }
     }
     $message = $message . "<br><br><a href='" . $file . "?bid={$row_buildings['bid']}&action=remove&&cxid={$sid}'>{$building10}</a>";
 }
 $size = $userdata[$row_buildings['tabless']];
 $size_new = $userdata[$row_buildings['tabless']] + 1;
 $buildtime = sec2time($row_buildings['time'] * $size_new);
 $row_buildings['res1'] = $row_buildings['res1'] * ($userdata[$row_buildings['tabless']] + 1);
 $row_buildings['res2'] = $row_buildings['res2'] * ($userdata[$row_buildings['tabless']] + 1);
 $row_buildings['res3'] = $row_buildings['res3'] * ($userdata[$row_buildings['tabless']] + 1);
 $row_buildings['res4'] = $row_buildings['res4'] * ($userdata[$row_buildings['tabless']] + 1);
 $build_name = $row_buildings['name'];
 $build_description = $row_buildings['description'];
 if ($build_name == "") {
     $build_name = "<span class=\"redfont\">" . $buildingerror1 . "</span>";
 }
 if ($build_description == "") {
     $build_description = "<span class=\"redfont\">" . $buildingerror1 . "</span>";
 }
 if ($size_new == "") {
     $size = "<span class=\"redfont\">" . $buildingerror1 . "</span>";
 }
コード例 #3
0
ファイル: ftp.php プロジェクト: mewtutorial/RapidTube
function ftp_go()
{
    global $list, $options, $FtpUpload, $FtpBytesTotal, $FtpChunkSize, $FtpTimeStart, $FtpUploadBytesSent, $FtpLastChunkTime, $FtpLast;
    require_once CLASS_DIR . "ftp.php";
    $ftp = new ftp();
    if (!$ftp->SetServer($_POST["host"], (int) $_POST["port"])) {
        $ftp->quit();
        printf(lang(79), $_POST["host"] . ":" . $_POST["port"]);
        echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />';
    } else {
        if (!$ftp->connect()) {
            $ftp->quit();
            echo "<br />";
            printf(lang(79), $_POST["host"] . ":" . $_POST["port"]);
            echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />';
        } else {
            printf(lang(81), 'ftp://' . $_POST['host'] . ':' . $_POST['port']);
            if (!$ftp->login($_POST["login"], $_POST["password"])) {
                $ftp->quit();
                echo "<br />";
                echo lang(80);
                echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />';
            } else {
                //$ftp->Passive(FALSE);
                if (!$ftp->chdir($_POST["dir"])) {
                    $ftp->quit();
                    echo "<br />";
                    printf(lang(159), $_POST['dir']);
                    echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />';
                } else {
                    ?>
<br />
				<div id="status"></div>
				<br />
				<table cellspacing="0" cellpadding="0">
					<tr>
						<td></td>
						<td>
						<div class="progressouter">
						<div style="width:298px">
							<div id="progress" class="ftpprogress"></div>
						</div>
						</div>
						</td>
						<td></td>
					</tr>
					<tr>
						<td align="left" id="received">0 KB</td>
						<td align="center" id="percent">0%</td>
						<td align="right" id="speed">0 KB/s</td>
					</tr>
				</table>
				<br />
				<script type="text/javascript">switchCell(3);</script>
<?php 
                    for ($i = 0; $i < count($_POST["files"]); $i++) {
                        $file = $list[$_POST["files"][$i]];
                        echo '<script type="text/javascript">pr(0,0,0);changeStatus(' . "'" . addslashes(basename($file["name"])) . "', '" . $file["size"] . "');</script>";
                        $FtpUpload = true;
                        $FtpBytesTotal = filesize($file['name']);
                        $FtpChunkSize = round($FtpBytesTotal / 333);
                        $FtpTimeStart = getmicrotime();
                        $FtpUploadBytesSent = $FtpLastChunkTime = $FtpLast = 0;
                        if ($ftp->put($file["name"], basename($file["name"]))) {
                            $time = round(getmicrotime() - $FtpTimeStart);
                            $speed = @round($FtpBytesTotal / 1024 / $time, 2);
                            echo '<script type="text/javascript">pr(100, ' . "'" . bytesToKbOrMbOrGb($FtpBytesTotal) . "', " . $speed . ")</script>\r\n";
                            flush();
                            if (@$_POST["del_ok"] && !$options['disable_deleting']) {
                                if (@unlink($file["name"])) {
                                    unset($list[$_POST["files"][$i]]);
                                }
                            }
                            printf(lang(160), '<a href="ftp://' . $_POST["login"] . ':' . $_POST["password"] . '@' . $_POST["host"] . ':' . $_POST["port"] . $_POST["dir"] . (substr($_POST["dir"], -1) != '/' ? '/' : '') . basename($file["name"]) . '"><b>' . basename($file["name"]) . '</b></a>');
                            echo "<br />" . lang(161) . ": <b>" . sec2time($time) . "</b><br />" . lang(162) . ": <b>" . $speed . " KB/s</b><br /><br />";
                        } else {
                            printf(lang(163), basename($file['name']));
                            echo "<br />";
                        }
                    }
                    $ftp->quit();
                }
            }
        }
    }
}
コード例 #4
0
ファイル: ftp.php プロジェクト: SheppeR/rapidleech
function getftpurl($host, $port, $url, $saveToFile = 0)
{
    global $nn, $lastError, $PHP_SELF, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize, $options;
    $ftp = new ftp(FALSE, FALSE);
    $server = "{$host}:{$port}";
    if (empty($host) || empty($port) || !$ftp->SetServer($host, (int) $port)) {
        $ftp->quit();
        $lastError = sprintf(lang(79), $server);
        return FALSE;
    } else {
        if (!$ftp->connect()) {
            $ftp->quit();
            $lastError = sprintf(lang(79), $server);
            return FALSE;
        } else {
            if (!$ftp->login()) {
                $ftp->quit();
                $lastError = lang(80);
                return FALSE;
            } else {
                echo '<p>';
                printf(lang(81), $server);
                echo '<br />';
                //$ftp->Passive(FALSE);
                $tmp = explode("/", $url);
                $ftp_file = array_pop($tmp);
                $ftp_dir = implode('/', $tmp);
                $ftp->chdir($ftp_dir);
                $fileSize = $FtpBytesTotal = $ftp->filesize($ftp_file);
                $FtpChunkSize = round($fileSize / 333);
                if (strpos($saveToFile, '?') !== false) {
                    $saveToFile = substr($saveToFile, 0, strpos($saveToFile, '?'));
                }
                if ($options['file_size_limit'] > 0) {
                    if ($fileSize > $options['file_size_limit'] * 1024 * 1024) {
                        $lastError = lang(336) . bytesToKbOrMbOrGb($options['file_size_limit'] * 1024 * 1024) . ".";
                        return false;
                    }
                }
                if (!empty($options['rename_prefix'])) {
                    $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile);
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
                }
                if (!empty($options['rename_suffix'])) {
                    $ext = strrchr(basename($saveToFile), '.');
                    $before_ext = explode($ext, basename($saveToFile));
                    $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext;
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
                }
                if ($options['rename_underscore']) {
                    $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile));
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
                }
                $filetype = strrchr($saveToFile, '.');
                if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) {
                    if ($options['forbidden_filetypes_block']) {
                        html_error(sprintf(lang(82), $filetype));
                    }
                    $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile);
                }
                if (@file_exists($saveToFile) && $options['bw_save']) {
                    // Skip in audl.
                    if (isset($_GET['audl'])) {
                        echo '<script type="text/javascript">parent.nextlink();</script>';
                    }
                    html_error(lang(99) . ': ' . link_for_file($saveToFile));
                } elseif (@file_exists($saveToFile)) {
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . '_' . basename($saveToFile);
                }
                printf(lang(83), basename($saveToFile), bytesToKbOrMbOrGb($fileSize));
                echo "<br />";
                require_once TEMPLATE_DIR . '/transloadui.php';
                $FtpTimeStart = getmicrotime();
                if ($ftp->get($ftp_file, $saveToFile)) {
                    $ftp->quit();
                    $time = getmicrotime() - $FtpTimeStart;
                    return array('time' => sec2time(round($time)), 'speed' => @round($FtpBytesTotal / 1024 / $time, 2), 'received' => TRUE, 'size' => bytesToKbOrMbOrGb($fileSize), 'bytesReceived' => $FtpBytesReceived, 'bytesTotal' => $FtpBytesTotal, 'file' => $saveToFile);
                }
                $ftp->quit();
                return FALSE;
            }
        }
    }
}
コード例 #5
0
 function storeIGCvalues()
 {
     $data_time = array();
     $data_alt = array();
     $data_speed = array();
     $data_vario = array();
     $data_takeoff_distance = array();
     if (!$this->checkSanedFiles()) {
         return;
     }
     $filename = $this->getIGCFilename(2);
     $lines = @file($filename);
     if (!$lines) {
         return;
     }
     $i = 0;
     $day_offset = 0;
     $currentDate = 0;
     $prevDate = 0;
     // GUS begin
     $interval = 20;
     $lastSnap = -1;
     $normOrder = array();
     // GUS end
     $limiter = max(1, intval(count($lines) / 8000));
     // GUS in for limiter
     $li = 0;
     // GUS in for limiter
     foreach ($lines as $line) {
         $line = trim($line);
         if (strlen($line) == 0) {
             continue;
         }
         if (strtoupper(substr($line, 0, 5)) == "HFDTE" || strtoupper(substr($line, 0, 5)) == "HPDTE") {
             // HFDTE170104  OR HPDTE310805
             $dt = substr($line, 5, 6);
             $yr_last = substr($dt, 4, 2);
             // case of YY=0 (1 digit) HFDTE08070
             if ($yr_last == "0") {
                 $yr_last = "00";
             }
             if ($yr_last > 80) {
                 $yr = "19" . $yr_last;
             } else {
                 $yr = "20" . $yr_last;
             }
             $prevDate = $currentDate;
             $currentDate = mktime(0, 0, 0, substr($dt, 2, 2), substr($dt, 0, 2), $yr);
             //echo "DATE cahnge : $currentDate  $prevDate <BR>";
             if ($prevDate > 0 && $currentDate - $prevDate > 86400) {
                 // more than one day
                 break;
             }
         }
         if ($line[0] == 'B') {
             if (strlen($line) < 23) {
                 continue;
             }
             // also check for bad points
             // 012345678901234567890123456789
             // B1522144902558N00848090EV0058400000
             if ($line[24] == 'V') {
                 continue;
             }
             if ($li++ % $limiter) {
                 continue;
             }
             // GUS in for limiter
             $thisPoint = new gpsPoint($line, $this->timezone);
             $thisPoint->gpsTime += $day_offset;
             // $goodPoints[$i]['time']=sec2Time($thisPoint->getTime(),1);
             $goodPoints[$i]['time'] = $thisPoint->getTime();
             $goodPoints[$i]['lon'] = $thisPoint->lon;
             $goodPoints[$i]['lat'] = $thisPoint->lat;
             $goodPoints[$i]['alt'] = $thisPoint->getAlt();
             $goodPoints[$i]['altV'] = $thisPoint->getAlt(true);
             // prefer vario Alt
             if ($i > 0) {
                 $tmp = $lastPoint->calcDistance($thisPoint);
                 $time_diff = $thisPoint->getTime() - $lastPoint->getTime();
                 if ($time_diff < 0 && $time_diff > -36000) {
                     // if the time is less than 10 hours in the past  we just ignore it
                     continue;
                     // GUS out:
                     /*} else if ($time_diff < 0) {  // CHANGING DAY , means the flight is at night
                     		array_pop($goodPoints);
                     		break;*/
                 } else {
                     if ($time_diff > $this->max_allowed_time_gap * 4) {
                         // found time gap
                         array_pop($goodPoints);
                         break;
                     }
                 }
                 /*	if ( ($lastPoint->getTime() - $thisPoint->getTime()  ) > 3600 )  { // more than 1 hour
                                  		$day_offset = 86400; // if time seems to have gone backwards, add a day
                                    $thisPoint->gpsTime += 86400;
                      		        } else if ( ($lastPoint->getTime() - $thisPoint->getTime()  ) > 0 ) {
                 				$lastPoint=new gpsPoint($line,$this->timezone);
                 				$lastPoint->gpsTime+=$day_offset;
                 				continue;
                 			}
                 			*/
                 $deltaseconds = $thisPoint->getTime() - $lastPoint->getTime();
                 if ($deltaseconds < -85000) {
                     $deltaseconds += 86400;
                 }
                 // GUS in
                 if ($deltaseconds) {
                     $speed = $deltaseconds ? $tmp * 3.6 / $deltaseconds : 0.0;
                     /* in km/h */
                     $goodPoints[$i]['vario'] = ($thisPoint->getAlt() - $lastPoint->getAlt()) / $deltaseconds;
                 } else {
                     $speed = 0;
                     $data_vario[$i] = 0;
                 }
                 $goodPoints[$i]['speed'] = $speed;
                 $goodPoints[$i]['dis'] = $takeoffPoint->calcDistance($thisPoint) / 1000;
             } else {
                 $goodPoints[$i]['speed'] = 0;
                 $goodPoints[$i]['vario'] = 0;
                 $takeoffPoint = new gpsPoint($line, $this->timezone);
                 $goodPoints[$i]['dis'] = 0;
             }
             $lastPoint = new gpsPoint($line, $this->timezone);
             $lastPoint->gpsTime += $day_offset;
             // GUS begin
             $timeSnap = intval($lastPoint->getTime() / $interval) * $interval;
             if ($lastSnap != $timeSnap) {
                 $lastSnap = $timeSnap;
                 $normIndex[$lastSnap] = $goodPoints[$i];
                 $normOrder[] = $lastSnap;
                 //DEBUG('IGC',1, "[time: $i] $line<br>");
             }
             // GUS end
             $i++;
         }
     }
     $pointsNum = count($goodPoints);
     //echo "pointsNum : $pointsNum<br>";
     $min_time = floor($goodPoints[0]['time'] / 60) * 60;
     $max_time = ceil($goodPoints[$pointsNum - 1]['time'] / 60) * 60;
     // echo "max / min time: $max_time $min_time<BR>";
     $k = 0;
     // GUS begin
     $o = 0;
     for ($i = $min_time; $i != $max_time; $i += $interval) {
         if ($i >= 86400) {
             $i -= 86400;
         }
         $from = isset($normIndex[$i]) ? $o++ : $o;
         $normPoints[$k] = $normIndex[$normOrder[$from]];
         $normPoints[$k]['timeText'] = sec2time($i);
         $normPoints[$k]['time'] = $i;
         $k++;
     }
     // GUS end
     /*$org_array_pos = 0;
     		foreach($normPoints as $norm_array_pos=>$normPoint) { // for each point  in the timeline
     			$timeval=$normPoint['time'];
     			if ( $goodPoints[$org_array_pos]['time'] >= $timeval && $org_array_pos< count($goodPoints)  &&
     				!($org_array_pos==0 && $goodPoints[0]['time'] < $timeval)   ) {
     
     				$normPoints[$norm_array_pos]['lon']=$goodPoints[$org_array_pos]['lon'];
     				$normPoints[$norm_array_pos]['lat']=$goodPoints[$org_array_pos]['lat'];
     
     				$normPoints[$norm_array_pos]['speed']=$goodPoints[$org_array_pos]['speed'];
     				$normPoints[$norm_array_pos]['vario']=$goodPoints[$org_array_pos]['vario'];
     				$normPoints[$norm_array_pos]['alt']=$goodPoints[$org_array_pos]['alt'];
     				$normPoints[$norm_array_pos]['altV']=$goodPoints[$org_array_pos]['altV'];
     				$normPoints[$norm_array_pos]['dis']=$goodPoints[$org_array_pos]['dis'];
     				// if ($normPoints[$norm_array_pos]['alt']==0) $normPoints[$norm_array_pos]['alt']="-";
     
     				while ($goodPoints[$org_array_pos]['time'] <  $timeval + $interval  && ($org_array_pos)< count($goodPoints) ) {
     					$org_array_pos++;
     				}
     			} else if ( !isset($normPoints[$norm_array_pos]['lon']) ) {     // GUS in
     				if ($norm_array_pos ) {
     					$normPoints[$norm_array_pos]['lon']=$normPoints[$norm_array_pos-1]['lon'];
     					$normPoints[$norm_array_pos]['lat']=$normPoints[$norm_array_pos-1]['lat'];
     					$normPoints[$norm_array_pos]['speed']=$normPoints[$norm_array_pos-1]['speed'];
     					$normPoints[$norm_array_pos]['vario']=$normPoints[$norm_array_pos-1]['vario'];
     					$normPoints[$norm_array_pos]['alt']=$normPoints[$norm_array_pos-1]['alt'];
     					$normPoints[$norm_array_pos]['altV']=$normPoints[$norm_array_pos-1]['altV'];
     					$normPoints[$norm_array_pos]['dis']=$normPoints[$norm_array_pos-1]['dis'];
     				}	else {
     					$normPoints[$norm_array_pos]['lon']=$goodPoints[0]['lon'];
     					$normPoints[$norm_array_pos]['lat']=$goodPoints[0]['lat'];
     					$normPoints[$norm_array_pos]['speed']=$goodPoints[0]['speed'];
     					$normPoints[$norm_array_pos]['vario']=$goodPoints[0]['vario'];
     					$normPoints[$norm_array_pos]['alt']=$goodPoints[0]['alt'];
     					$normPoints[$norm_array_pos]['altV']=$goodPoints[0]['altV'];
     					$normPoints[$norm_array_pos]['dis']=$goodPoints[0]['dis'];
     				}*/
     /*
     			if ($org_array_pos>0) {
     				$normPoints[$norm_array_pos]['speed']="-";
     				$normPoints[$norm_array_pos]['vario']="-";
     				$normPoints[$norm_array_pos]['alt']="-";
     			}
     */
     /*             }
     		} // end foreach*/
     // now write it to file
     $outputBuffer = '$min_time=' . $min_time . ';$max_time=' . $max_time . ";\n\n\n";
     // $jsOutput="";
     foreach ($normPoints as $point) {
         $outputBuffer .= '$time=' . $point['time'] . '; $lat=' . $point['lat'] . '; $lon=' . $point['lon'] . '; $dis=' . $point['dis'] . '; $alt=' . $point['alt'] . '; $altV=' . $point['altV'] . '; $speed=' . $point['speed'] . '; $vario=' . $point['vario'] . ";\n";
         $this_tm = $point['time'] - $min_time;
         //$jsOutput.=sprintf("lt[$this_tm]=%.6f;ln[$this_tm]=%.6f;d[$this_tm]=%d;a[$this_tm]=%d;s[$this_tm]=%0.1f;v[$this_tm]=%.2f;\n"
         //							,$point['lat'],-$point['lon'],$point['dis'],$point['alt'],$point['speed'],$point['vario']);
     }
     $path_igc = dirname($this->getPointsFilename(1));
     if (!is_dir($path_igc)) {
         makeDir($path_igc, 0755);
     }
     // write saned js file
     // writeFile($this->getJsFilename(1),$jsOutput);
     // write saned IGC file
     writeFile($this->getPointsFilename(1), $outputBuffer);
     return 1;
 }
コード例 #6
0
ファイル: listing.php プロジェクト: WebPassions/2015
            break;
        case "10":
            echo BackendTranslate::getLabel('oct');
            break;
        case "11":
            echo BackendTranslate::getLabel('nov');
            break;
        case "12":
            echo BackendTranslate::getLabel('dec');
            break;
    }
    echo '</td>';
    echo '<td>' . $record->getNewvisits() . '</td>';
    echo '<td>' . $record->getVisits() . '</td>';
    echo '<td>' . $record->getPageviews() . '</td>';
    echo '<td>' . sec2time($record->getTimeonsite()) . '</td>';
    echo '</tr>';
    $id++;
}
?>
                    </tbody>
                </table>
            </div>
            <div class="panel-footer text-right">
                <?php 
echo $this->FormLink->back(COCKPIT);
?>
            </div>
        </div>
    </div>
</div>
コード例 #7
0
function getftpurl($host, $port, $url, $saveToFile = 0)
{
    global $nn, $lastError, $PHP_SELF, $AUTH, $IS_FTP, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize, $options;
    $ftp = new ftp(FALSE, FALSE);
    if (!$ftp->SetServer($host, (int) $port)) {
        $ftp->quit();
        $server = $host . ':' . $port;
        $lastError = sprintf(lang(79), $server) . "<br />" . '<a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />';
        return FALSE;
    } else {
        if (!$ftp->connect()) {
            $ftp->quit();
            $lastError = sprintf(lang(79), $server) . "<br />" . '<a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />';
            return FALSE;
        } else {
            if (!$ftp->login($AUTH["ftp"]["login"], $AUTH["ftp"]["password"])) {
                $ftp->quit();
                $lastError = lang(80) . "<br />" . '<a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />';
                return FALSE;
            } else {
                echo '<p>';
                printf(lang(81), $host);
                echo '<br />';
                //$ftp->Passive(FALSE);
                $tmp = explode("/", $url);
                $ftp_file = array_pop($tmp);
                $ftp_dir = implode("/", $tmp);
                $ftp->chdir($ftp_dir);
                $fileSize = $FtpBytesTotal = $ftp->filesize($ftp_file);
                $FtpChunkSize = round($fileSize / 333);
                list($saveToFile, $tmp) = explode('?', $saveToFile);
                if (!empty($options['rename_prefix'])) {
                    $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile);
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
                }
                if (!empty($options['rename_suffix'])) {
                    $ext = strrchr(basename($saveToFile), ".");
                    $before_ext = explode($ext, basename($saveToFile));
                    $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext;
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
                }
                if ($options['rename_underscore']) {
                    $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile));
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
                }
                $filetype = strrchr($saveToFile, ".");
                if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) {
                    if ($options['forbidden_filetypes_block']) {
                        html_error(sprintf(lang(82), $filetype));
                    } else {
                        $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile);
                    }
                }
                if (file_exists($saveToFile)) {
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . "_" . basename($saveToFile);
                }
                printf(lang(83), $saveToFile, bytesToKbOrMbOrGb($fileSize));
                echo "<br />";
                ?>
<br />
<table cellspacing="0" cellpadding="0" style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<tr>
<td></td>
<td>
<div class="progressouter">
<div id="progress" class="ftpprogress">
</div>
</div>
</td>
<td></td>
<tr>
<tr>
<td align="left" id="received">0 KB</td>
<td align="center" id="percent">0%</td>
<td align="right" id="speed">0 KB/s</td>
</tr>
</table>
<br />
<div id="resume" align="center" style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;"></div>
<script type="text/javascript">
/* <![CDATA[ */
function pr(percent, received, speed){
	document.getElementById("received").innerHTML = '<b>' + received + '</b>';
	document.getElementById("percent").innerHTML = '<b>' + percent + '%</b>';
	document.getElementById("progress").style.width = percent + '%';
	document.getElementById("speed").innerHTML = '<b>' + speed + ' KB/s</b>';
	document.title = 'Downloaded ' + percent + '%';
	return true;
	}

	function mail(str, field) {
	document.getElementById("mailPart." + field).innerHTML = str;
	return true;
	}
/* ]]> */
</script>
<br />
<?php 
                $FtpTimeStart = getmicrotime();
                if ($ftp->get($ftp_file, $saveToFile)) {
                    return array("time" => sec2time(round($time)), "speed" => @round($FtpBytesTotal / 1024 / (getmicrotime() - $FtpTimeStart), 2), "received" => TRUE, "size" => bytesToKbOrMbOrGb($fileSize), "bytesReceived" => $FtpBytesReceived, "bytesTotal" => $FtpBytesTotal, "file" => $saveToFile);
                } else {
                    return FALSE;
                }
                $ftp->quit();
            }
        }
    }
}
コード例 #8
0
"><div id="trafwaiting" align="left" style="display:none;"></div></div>
<div style="padding-left:20px; margin-top: 0px;">
<span>Quota Traffic allowed. Currently traffic:&nbsp;<span id="cur_traffic"><b class="g" style="position:absolute;"><span id="trafshowresults" style="position:float:center;display:;"><?php 
        $cur_trf = get_traffic(TRAFFIC_LST);
        echo bytesToKbOrMbOrGb($cur_trf[0]);
        ?>
</span>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="<?php 
        echo $ajax_serverfiles ? 'if(confirm(\'This will reset Current Traffic, proceed?\')){trafst();}' : 'alert(\'Ajax Disabled\');';
        ?>
;"><small>reset</small></a></b></span></span> 
<div style="height:3px;">&nbsp;</div>
<div style="float:left;">The D-Day traffic quota will expired</div><br><div style="height:3px;">&nbsp;</div>
<div style="float:left;">Auto-Reset traffic. set to 0 or blank to disable.
<?php 
        if ($day_reset_trafic > 0) {
            echo "<small class='g'>remain: " . sec2time(timeremain_traffic($day_reset_trafic, $cur_trf[1])) . "</small>";
        }
        ?>
</div>
<?php 
        if ($ajax_serverfiles) {
            ?>
<script type="text/javascript">function trafst() {document.trew.submit("posttraffic","trafwaiting","trafshowresults",""); }</script>
<?php 
        }
        ?>
</div></td>
</tr>

<tr>
<td class="tdacc"><input type="checkbox" id="limited_edition" name="limited_edition" onClick="var displ=this.checked?'':'none';document.getElementById('limitauthip').style.display=displ;document.getElementById('limitauthip2').style.display=displ;"<?php 
コード例 #9
0
ファイル: http.php プロジェクト: laiello/rapidleech36b
function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveToFile = 0, $proxy = 0, $pauth = 0, $auth = 0, $scheme = "http", $resume_from = 0, $XMLRequest = 0)
{
    global $nn, $lastError, $Resume, $bytesReceived, $fs, $force_name, $options, $L, $visitors, $ada_acc;
    $scheme .= '://';
    if ($post !== 0 && ($scheme == 'http://' || $scheme == 'https://')) {
        $method = 'POST';
        $postdata = is_array($post) ? formpostdata($post) : $post;
        $length = strlen($postdata);
        $content_tl = "Content-Type: application/x-www-form-urlencoded{$nn}" . "Content-Length: {$length}{$nn}";
    } else {
        $method = 'GET';
        $content_tl = $postdata = '';
    }
    $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://';
        if ($port == 0 || $port == 80) {
            $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}" : '';
    $request = array();
    $request[] = $method . ' ' . str_replace(' ', '%20', $url) . ' HTTP/1.1';
    $request[] = "Host: {$host}";
    $request[] = 'User-Agent: Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.12';
    $request[] = 'Accept: */*';
    $request[] = 'Accept-Language: en-US;q=0.7,en;q=0.3';
    $request[] = 'Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7';
    $request[] = 'Pragma: no-cache';
    $request[] = 'Cache-Control: no-cache';
    if ($Resume['use'] === TRUE) {
        $request[] = 'Range: bytes=' . $Resume['from'] . '-';
    }
    if ($XMLRequest) {
        $request[] = 'X-Requested-With: XMLHttpRequest';
    }
    $request = implode($nn, $request) . $nn . $http_auth . $proxyauth . $referer . $cookies . $content_tl . 'Connection: Close' . $nn . $nn . $postdata;
    if (isset($options['mip_enabled']) && $options['mip_enabled']) {
        $mip_action = "download";
        echo "<p>Multi IP Enabled</b>...<br />\n";
        if (file_exists(CLASS_DIR . "mip.php")) {
            @(include CLASS_DIR . "mip.php");
        }
    } else {
        $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) {
        $dis_host = !empty($proxyHost) ? $proxyHost : $host;
        $dis_port = !empty($proxyPort) ? $proxyPort : $port;
        html_error($L->sprintf($L->say['_couldnt_con_to'], $dis_host, $dis_port));
    }
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    if ($saveToFile) {
        if ($proxy) {
            echo '<p>' . $L->sprintf($L->say['_con_proxy'], $proxyHost, $proxyPort) . '<br />';
            echo "GET: <b>" . $url . "</b>...<br />\n";
        } else {
            echo "<p>";
            echo $L->sprintf($L->say['_con_to'], $host, $port) . '<br />';
            echo isset($options['mip_enabled']) && $options['mip_enabled'] ? "using IP: " . $mip_ip . "<br />\n" : "";
        }
    }
    #########################################################################
    fputs($fp, $request);
    fflush($fp);
    $timeStart = getmicrotime();
    // Rewrote the get header function according to the proxy script
    // Also made sure it goes faster and I think 8192 is the best value for retrieving headers
    // Oops.. The previous function hooked up everything and now I'm returning it back to normal
    $llen = 0;
    $header = '';
    do {
        $header .= fgets($fp, 16384);
        $len = strlen($header);
        if (!$header || $len == $llen) {
            $lastError = $L->say['_noheader'];
            return false;
        }
        $llen = $len;
    } while (strpos($header, $nn . $nn) === false);
    #########################################################################
    if ($saveToFile) {
        if (!isset($_GET['dis_plug']) || $_GET['dis_plug'] != 'on') {
            $cbhost = strpos($host, ':') !== false ? substr($host, 0, strpos($host, ':')) : $host;
            // Remove the port that may be added when it's using proxy
            $chkhost = preg_match('/^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}$/', $cbhost) ? false : true;
            if (!empty($referer)) {
                $cbrefhost = str_ireplace('www.', '', cut_str($referer, 'Referer: ', "\r\n"));
                $cbrefhost = parse_url($cbrefhost, PHP_URL_HOST);
                $chkref = empty($cbrefhost) || preg_match('/^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}$/', $cbrefhost) ? false : ($chkhost && strtolower($cbhost) == strtolower($cbrefhost) ? false : true);
            } else {
                $chkref = false;
            }
            $found = false;
            if ($chkhost || $chkref) {
                foreach ($GLOBALS['host'] as $site => $file) {
                    if ($chkhost && host_matches($site, $cbhost)) {
                        $found = true;
                    } elseif ($chkref && host_matches($site, $cbrefhost)) {
                        $found = true;
                    }
                    if ($found) {
                        if ($options['limitbyIP']) {
                            if ($ada_acc) {
                                global $premium_acc;
                                if (preg_match('|^(?:.+\\.)?(.+\\..+)$|i', $cbhost, $prematch) || preg_match('|^(?:.+\\.)?(.+\\..+)$|i', $cbrefhost, $prematch)) {
                                    $prematch = str_replace('.', '_', $prematch[1]);
                                    if (!empty($premium_acc[$prematch])) {
                                        $fname = basename($saveToFile) . "." . rand(1, 1000);
                                        $limitedfile = $visitors->userip . $fname;
                                        $ret = mkdir($visitors->tmp_dir . $limitedfile, 0777);
                                    }
                                }
                            }
                        }
                        require_once HOST_DIR . 'DownloadClass.php';
                        require_once HOST_DIR . "download/{$file}";
                        $class = substr($file, 0, -4);
                        $firstchar = substr($file, 0, 1);
                        if ($firstchar > 0) {
                            $class = "d{$class}";
                        }
                        if (!class_exists($class) || !method_exists($class, 'CheckBack')) {
                            break;
                        }
                        // is_callable(array($class , 'CheckBack'))
                        $hostClass = new $class(false);
                        $hostClass->CheckBack($header);
                        break;
                    }
                }
                unset($cbhost, $cbrefhost, $chkhost, $chkref, $found);
            }
        }
        if (preg_match('/^HTTP\\/1\\.[0|1] (\\d+) .*/', $header, $responsecode) && ($responsecode[1] == 404 || $responsecode[1] == 403)) {
            // Do some checking, please, at least tell them what error it was
            if ($responsecode[1] == 403) {
                $lastError = $L->say['_page_notfound'];
            } elseif ($responsecode[1] == 404) {
                $lastError = $L->say['_forbidden_access'];
            } else {
                // Weird, it shouldn't come here...
                $lastError = $L->say['_notfound_forbidden'];
            }
            return false;
        }
        $bytesTotal = trim(cut_str($header, "Content-Length:", "\n"));
        if ($options['maxlimitsize'] > 0) {
            if ($bytesTotal > $options['maxlimitsize'] * 1024 * 1024) {
                $lastError = $L->sprintf($L->say['_sorry_tobig'], bytesToKbOrMbOrGb($bytesTotal), $options["maxlimitsize"]);
                return false;
            }
        }
        if ($options['minlimitsize'] > 0) {
            if ($bytesTotal < $options['minlimitsize'] * 1024 * 1024) {
                $lastError = $L->sprintf($L->say['_sorry_tosmall'], bytesToKbOrMbOrGb($bytesTotal), $options["minlimitsize"]);
                return false;
            }
        }
        // check storage limit (it is in MB)
        if ($options['storage_limit'] > 0) {
            $serverfiles = calcUsedSpace();
            if ($serverfiles + $bytesTotal > $options['storage_limit'] * 1024 * 1024) {
                $lastError = $L->sprintf($L->say['_sorry_insuficient_storage'], bytesToKbOrMbOrGb($serverfiles), $options["storage_limit"]);
                return false;
            }
        }
        if (stripos($header, "\nLocation: ") !== false && preg_match('/\\nLocation: ([^\\r\\n]+)/i', $header, $redir)) {
            $redirect = trim($redir[1]);
            $lastError = $L->sprintf($L->say['_error_redirectto'], $redirect);
            return FALSE;
        }
        if (in_array(cut_str($header, "WWW-Authenticate: ", " "), array("Basic", "Digest"))) {
            $lastError = $L->say['_req_auth'];
            return FALSE;
        }
        //$ContentType = trim(cut_str($header, "Content-Type:", "\n"));
        if ($Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") === false) {
            $lastError = stripos($header, '503 Limit Exceeded') !== false ? $L->say['_error_resume'] : $L->say['_error_noresume'];
            return FALSE;
        }
        if ($force_name) {
            $FileName = $force_name;
            $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $FileName;
        } else {
            $ContentDisposition = trim(cut_str($header, "Content-Disposition:", "\n")) . "\n";
            if ($ContentDisposition && stripos($ContentDisposition, "filename=") !== false) {
                $FileName = trim(trim(trim(trim(trim(cut_str($ContentDisposition, "filename=", "\n")), "="), "?"), ";"), '"');
                if (strpos($FileName, "/") !== false) {
                    $FileName = basename($FileName);
                }
                if (preg_match("/UTF\\-8\\?B\\?(.*)\$/i", $FileName, $b64)) {
                    $FileName = preg_replace("/[^a-zA-Z0-9\\-\\.]/", "_", base64_decode($b64[1]));
                }
                $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $FileName;
            }
        }
        if (!empty($options["add_ext_5city"]) || !empty($options['rename_suffix']) || !empty($options['rename_prefix']) || $options['rename_underscore']) {
            if (!empty($options["add_ext_5city"])) {
                $ext = str_replace(".", "", $options["add_ext_5city"]);
                $File_Name = basename($saveToFile) . "." . $options["add_ext_5city"];
            }
            if (!empty($options['rename_prefix'])) {
                $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile);
            }
            if (!empty($options['rename_suffix'])) {
                $ext = strrchr(basename($saveToFile), ".");
                $before_ext = explode($ext, basename($saveToFile));
                $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext;
            }
            if ($options['rename_underscore']) {
                $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile));
            }
            $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
        }
        $filetype = strrchr($saveToFile, ".");
        if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) {
            if ($options['forbidden_filetypes_block']) {
                $lastError = $L->sprintf($L->say['_forbid_filetype'], $filetype);
                return false;
            } else {
                $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile);
            }
        }
        if (@file_exists($saveToFile) && $options['bw_save']) {
            html_error($L->say['_download'] . ': ' . link_for_file($saveToFile), 0);
        }
        if (@file_exists($saveToFile) && $Resume["use"] === TRUE) {
            $fs = @fopen($saveToFile, "ab");
            if (!$fs) {
                $lastError = $L->sprintf($L->say['_error_cantsave'], basename($saveToFile)) . '<br />' . $L->say['_error_trychmod'] . '<br /><a href="javascript:location.reload();">' . $L->say['_error_tryagain'] . '</a>';
                return FALSE;
            }
        } else {
            if (@file_exists($saveToFile)) {
                $saveToFile = dirname($saveToFile) . PATH_SPLITTER . TIME_NOW . "_" . basename($saveToFile);
            }
            $fs = @fopen($saveToFile, "wb");
            if (!$fs) {
                $secondName = dirname($saveToFile) . PATH_SPLITTER . str_replace(":", "", str_replace("?", "", basename($saveToFile)));
                $fs = @fopen($secondName, "wb");
                if (!$fs) {
                    $lastError = $L->sprintf($L->say['_error_cantsave'], basename($saveToFile)) . '<br />' . $L->say['_error_trychmod'] . '<br /><a href="javascript:location.reload();">' . $L->say['_error_tryagain'] . '</a>';
                    return FALSE;
                }
            }
        }
        flock($fs, LOCK_EX);
        if ($Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") !== false) {
            list($temp, $Resume['range']) = explode(' ', trim(cut_str($header, "\nContent-Range: ", "\n")));
            list($Resume['range'], $fileSize) = explode('/', $Resume['range']);
            $fileSize = bytesToKbOrMbOrGb($fileSize);
        } else {
            $fileSize = bytesToKbOrMbOrGb($bytesTotal);
        }
        $chunkSize = GetChunkSize($bytesTotal);
        $File_Name = basename($saveToFile);
        if (!empty($options["add_ext_5city"])) {
            $ext = "." . get_extension(basename($saveToFile));
            $File_Name = str_replace($ext, "", basename($saveToFile));
        }
        echo $L->sprintf($L->say['_saveprogres'], $File_Name, $ext, $fileSize) . '<br />';
        //$scriptStarted = false;
        require_once TEMPLATE_DIR . 'transloadui.php';
        if ($Resume['use'] === TRUE) {
            $received = bytesToKbOrMbOrGb(filesize($saveToFile));
            $percent = round($Resume['from'] / ($bytesTotal + $Resume['from']) * 100, 2);
            echo '<script type="text/javascript">pr(' . "'" . $percent . "', '" . $received . "', '0');</script>";
            //$scriptStarted = true;
            flush();
        }
    } else {
        $page = "";
    }
    $time = $last = $lastChunkTime = 0;
    do {
        $data = @fread($fp, $saveToFile ? $chunkSize : 16384);
        // 16384 saw this value in Pear HTTP_Request2 package // (fix - szal) using this actually just causes massive cpu usage for large files, too much data is flushed to the browser!)
        if ($data == '') {
            break;
        }
        if ($saveToFile) {
            $bytesSaved = fwrite($fs, $data);
            if ($bytesSaved !== false && strlen($data) == $bytesSaved) {
                //if ($bytesSaved > - 1) {
                $bytesReceived += $bytesSaved;
            } else {
                $lastError = $L->sprintf($L->say['_error_imposible_record'], $saveToFile);
                unlink($saveToFile);
                return false;
            }
            if ($bytesReceived >= $bytesTotal) {
                $percent = 100;
            } else {
                $percent = @round(($bytesReceived + $Resume['from']) / ($bytesTotal + $Resume['from']) * 100, 2);
            }
            if ($bytesReceived > $last + $chunkSize) {
                $received = bytesToKbOrMbOrGb($bytesReceived + $Resume['from']);
                $time = getmicrotime() - $timeStart;
                $chunkTime = $time - $lastChunkTime;
                $chunkTime = $chunkTime ? $chunkTime : 1;
                $lastChunkTime = $time;
                $speed = @round($chunkSize / 1024 / $chunkTime, 2);
                /* if (!$scriptStarted) {
                	  echo('<script type="text/javascript">');
                	  $scriptStarted = true;
                	  } */
                echo "<script type='text/javascript'>pr('" . $percent . "', '" . $received . "', '" . $speed . "');</script>";
                $last = $bytesReceived;
            }
        } else {
            $page .= $data;
        }
    } while (strlen($data) > 0);
    //echo('</script>');
    if ($saveToFile) {
        flock($fs, LOCK_UN);
        fclose($fs);
        if ($bytesReceived <= 0) {
            $lastError = $L->say['_error_misc'];
            fclose($fp);
            return FALSE;
        }
    }
    fclose($fp);
    if ($saveToFile) {
        return array('time' => sec2time(round($time)), 'speed' => @round($bytesTotal / 1024 / (getmicrotime() - $timeStart), 2), 'received' => true, 'size' => $fileSize, 'bytesReceived' => $bytesReceived + $Resume['from'], 'bytesTotal' => $bytesTotal + $Resume['from'], 'file' => $saveToFile);
    } else {
        if (stripos($header, "\nTransfer-Encoding: chunked") !== false && function_exists('http_chunked_decode')) {
            $dechunked = http_chunked_decode($page);
            if ($dechunked !== false) {
                $page = $dechunked;
            }
            unset($dechunked);
        }
        $page = $header . $page;
        return $page;
    }
}
コード例 #10
0
ファイル: ftp.php プロジェクト: laiello/rapidleech36b
function ftp_go()
{
    global $list, $options, $L;
    require_once CLASS_DIR . "ftp.php";
    $ftp = new ftp();
    if (!$ftp->SetServer($_POST["host"], (int) $_POST["port"])) {
        $ftp->quit();
        echo $L->sprintf($L->say['couldnt_establish_con'], $_POST["host"] . ":" . $_POST["port"]);
        echo '<br /><a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />';
    } else {
        if (!$ftp->connect()) {
            $ftp->quit();
            echo "<br />";
            echo $L->sprintf($L->say['couldnt_establish_con'], $_POST["host"] . ":" . $_POST["port"]);
            echo '<br /><a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />';
        } else {
            $L->sprintf($L->say['_con'], 'ftp://' . $_POST['host'] . ':' . $_POST['port']);
            if (!$ftp->login($_POST["login"], $_POST["password"])) {
                $ftp->quit();
                echo "<br />";
                echo $L->say['incorrect_userpass'];
                echo '<br /><a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />';
            } else {
                //$ftp->Passive(FALSE);
                if (!$ftp->chdir($_POST["dir"])) {
                    $ftp->quit();
                    echo "<br />";
                    echo $L->sprintf($L->say['_cant_locatefold'], $_POST['dir']);
                    echo '<br /><a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />';
                } else {
                    ?>
<br />
				<div id="status"></div>
				<br />
				<table cellspacing="0" cellpadding="0">
					<tr>
						<td></td>
						<td>
						<div class="progressouter">
						<div style="width:298px">
							<div id="progress" class="ftpprogress"></div>
						</div>
						</div>
						</td>
						<td></td>
					</tr>
					<tr>
						<td align="left" id="received">0 KB</td>
						<td align="center" id="percent">0%</td>
						<td align="right" id="speed">0 KB/s</td>
					</tr>
				</table>
				<br />
<?php 
                    for ($i = 0; $i < count($_POST["files"]); $i++) {
                        $file = $list[$_POST["files"][$i]];
                        echo '<script type="text/javascript">changeStatus(' . "'" . addslashes(basename($file["name"])) . "', '" . $file["size"] . "');</script>";
                        $FtpBytesTotal = filesize($file["name"]);
                        $FtpTimeStart = getmicrotime();
                        if ($ftp->put($file["name"], basename($file["name"]))) {
                            $time = round(getmicrotime() - $FtpTimeStart);
                            $speed = @round($FtpBytesTotal / 1024 / $time, 2);
                            echo '<script type="text/javascript">pr(100, ' . "'" . bytesToKbOrMbOrGb($FtpBytesTotal) . "', " . $speed . ")</script>\r\n";
                            flush();
                            if ($_POST["del_ok"] && !$options['disable_to']['act_del']) {
                                if (@unlink($file["name"])) {
                                    unset($list[$_POST["files"][$i]]);
                                }
                            }
                            echo $L->sprintf($L->say['_successupl'], '<a href="ftp://' . $_POST["login"] . ':' . $_POST["password"] . '@' . $_POST["host"] . ':' . $_POST["port"] . $_POST["dir"] . '/' . basename($file["name"]) . '"><b>' . basename($file["name"]) . '</b></a>');
                            echo "<br />" . $L->say['_time'] . ": <b>" . sec2time($time) . "</b><br />" . $L->say['_avg_spd'] . ": <b>" . $speed . " KB/s</b><br /><br />";
                        } else {
                            echo $L->sprintf($L->say['couldnt_upl_file'], basename($file['name'])) . "<br />";
                        }
                    }
                    $ftp->quit();
                }
            }
        }
    }
}
コード例 #11
0
ファイル: ftp.php プロジェクト: laiello/rapidleech36b
function getftpurl($host, $port, $url, $saveToFile = 0)
{
    global $nn, $lastError, $PHP_SELF, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize, $options, $L;
    $ftp = new ftp(FALSE, FALSE);
    $server = "{$host}:{$port}";
    if (empty($host) || empty($port) || !$ftp->SetServer($host, (int) $port)) {
        $ftp->quit();
        $lastError = $L->sprintf($L->say['couldnt_establish_con'], $server) . "<br />" . '<a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />';
        return FALSE;
    } else {
        if (!$ftp->connect()) {
            $ftp->quit();
            $lastError = $L->sprintf($L->say['couldnt_establish_con'], $server) . "<br />" . '<a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />';
            return FALSE;
        } else {
            if (!$ftp->login()) {
                $ftp->quit();
                $lastError = $L->say['incorrect_userpass'] . "<br />" . '<a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />';
                return FALSE;
            } else {
                echo '<p>';
                $L->sprintf($L->say['_con'], $host);
                echo '<br />';
                //$ftp->Passive(FALSE);
                $tmp = explode("/", $url);
                $ftp_file = array_pop($tmp);
                $ftp_dir = implode("/", $tmp);
                $ftp->chdir($ftp_dir);
                $fileSize = $FtpBytesTotal = $ftp->filesize($ftp_file);
                $FtpChunkSize = round($fileSize / 333);
                if (strpos($saveToFile, '?') !== false) {
                    $saveToFile = substr($saveToFile, 0, strpos($saveToFile, '?'));
                }
                if ($options['maxlimitsize'] > 0) {
                    if ($fileSize > $options['maxlimitsize'] * 1024 * 1024) {
                        $lastError = $L->sprintf($L->say['_sorry_tobig'], bytesToKbOrMbOrGb($fileSize), $options["maxlimitsize"]);
                        return false;
                    }
                }
                if ($options['minlimitsize'] > 0) {
                    if ($fileSize < $options['minlimitsize'] * 1024 * 1024) {
                        $lastError = $L->sprintf($L->say['_sorry_tosmall'], bytesToKbOrMbOrGb($fileSize), $options["minlimitsize"]);
                        return false;
                    }
                }
                if (!empty($options["add_ext_5city"]) || !empty($options['rename_suffix']) || !empty($options['rename_prefix']) || $options['rename_underscore']) {
                    if (!empty($options["add_ext_5city"])) {
                        $ext = str_replace(".", "", $options["add_ext_5city"]);
                        $File_Name = basename($saveToFile) . "." . $options["add_ext_5city"];
                    }
                    if (!empty($options['rename_prefix'])) {
                        $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile);
                    }
                    if (!empty($options['rename_suffix'])) {
                        $ext = strrchr(basename($saveToFile), ".");
                        $before_ext = explode($ext, basename($saveToFile));
                        $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext;
                    }
                    if ($options['rename_underscore']) {
                        $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile));
                    }
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
                }
                $filetype = strrchr($saveToFile, ".");
                if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) {
                    if ($options['forbidden_filetypes_block']) {
                        html_error($L->sprintf($L->say['_forbid_filetype'], $filetype));
                    } else {
                        $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile);
                    }
                }
                if (file_exists($saveToFile)) {
                    $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . "_" . basename($saveToFile);
                }
                if (!empty($options["add_ext_5city"])) {
                    $ext = "." . get_extension(basename($saveToFile));
                    $File_Name = str_replace($ext, "", basename($saveToFile));
                }
                echo $L->sprintf($L->say['_saveprogres'], $saveToFile, $ext, bytesToKbOrMbOrGb($fileSize)) . "<br />";
                require_once TEMPLATE_DIR . 'transloadui.php';
                $FtpTimeStart = getmicrotime();
                if ($ftp->get($ftp_file, $saveToFile)) {
                    $ftp->quit();
                    $time = getmicrotime() - $FtpTimeStart;
                    return array('time' => sec2time(round($time)), 'speed' => @round($FtpBytesTotal / 1024 / $time, 2), 'received' => TRUE, 'size' => bytesToKbOrMbOrGb($fileSize), 'bytesReceived' => $FtpBytesReceived, 'bytesTotal' => $FtpBytesTotal, 'file' => $saveToFile);
                }
                $ftp->quit();
                return FALSE;
            }
        }
    }
}
コード例 #12
0
ファイル: exploring.php プロジェクト: Wehmeyer/Litotex-0.7
 $result_explores = $db->query("SELECT * FROM cc" . $n . "_explore where race = " . $userdata['rassenid'] . " and (tabless !='' and tabless !='0' ) ORDER BY eid ASC");
 while ($row_explores = $db->fetch_array($result_explores)) {
     if ($row_explores['required'] <= $userdata['build_explore']) {
         $size = $userdata[$row_explores['tabless']];
         $size_new = $userdata[$row_explores['tabless']] + 1;
         $buildtime = sec2time($row_explores['time'] * $size_new);
         $res1 = $row_explores['res1'] * ($size + 1);
         $res2 = $row_explores['res2'] * ($size + 1);
         $res3 = $row_explores['res3'] * ($size + 1);
         $res4 = $row_explores['res4'] * ($size + 1);
         $anzeige_res1 = $op_set_n_res1 . ": " . $res1;
         $anzeige_res2 = $op_set_n_res2 . ": " . $res2;
         $anzeige_res3 = $op_set_n_res3 . ": " . $res3;
         $anzeige_res4 = $op_set_n_res4 . ": " . $res4;
         if (isset($show_bau) and $show_bau == 1) {
             $time_2_go = sec2time($requesttime);
             if ($userdata['eid'] == $row_explores['eid']) {
                 $es_wird_gebaut = 1;
                 $timer = time();
                 $cancelURL = "exploring.php?eid={$userdata['eid']}&action=del";
                 $message = make_timebanner($userdata['startexploretime'], $userdata['endexploretime'], $row_explores['eid'], "") . "<br><a href=\"{$cancelURL}\">" . $exploreabort . "</a>";
             } else {
                 $es_wird_gebaut = 1;
                 $message = 'Es wird bereits geforscht! ';
             }
         } else {
             $message = "<a href=\"exploring.php?action=explore&eid={$row_explores['eid']}\">{$explore}</a>";
         }
         $image = "\"" . $row_explores['explorePic'] . "\"";
         $new_found_inhalt = array($image, $row_explores['name'], $size, $row_explores['description'], $anzeige_res1, $anzeige_res2, $anzeige_res3, $anzeige_res4, $buildtime, $message);
         array_push($new_found, $new_found_inhalt);
コード例 #13
0
ファイル: main.php プロジェクト: laiello/rapidleech36b
</small><hr />
<?php 
echo $L->say['current_storage'];
?>
&nbsp;<b class="g"><?php 
echo bytesToKbOrMbOrGb($serverfiles);
?>
</b>&nbsp;&nbsp;&nbsp;
<?php 
if ($options["storage_limit"] > 0) {
    echo '(Max: <b class="r">' . bytesToKbOrMbOrGb($options["storage_limit"] * 1024 * 1024) . '</b>)';
}
if ($options["limitbytraffic"]) {
    echo "<br />" . $L->say['current_traffic'] . " <b class='g'>" . bytesToKbOrMbOrGb($traffic->total) . "</b>&nbsp;" . $L->say['of'] . "&nbsp;<span class=\"s\" title=\"" . $L->say['max_traffic'] . "\"><b>" . bytesToKbOrMbOrGb($traffic->max) . "</b></span> " . ($traffic->expiredate ? $L->say['until'] . " <small><span class='g'>" . date("d-M-Y", $traffic->expiredate) . "</span></small>" : "");
    if ($options["day_reset_trafic"] > 0) {
        echo "<br />" . $L->say['reset_traffic_remain'] . "&nbsp;<small class=\"s\">" . sec2time($traffic->timeremain()) . "</small>";
    }
}
if ($options["limit_timework"]) {
    echo "<br />" . $L->say['_timework'] . ": <b class=\"s\">{$options["workstart"]}</b>&nbsp;" . $L->say['upto'] . "&nbsp;<b class=\"s\">{$options["workend"]}</b>";
}
?>
</td>
</tr>

<?php 
if (is_array($deleted) && $deleted["count"] > 0) {
    ?>
<tr><td colspan="2">
<div style="height:5px;">&nbsp;</div><small class='subtitle'><?php 
    echo $L->say['log_act'];
コード例 #14
0
function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveToFile = 0, $proxy = 0, $pauth = 0, $auth = 0, $scheme = "http", $resume_from = 0)
{
    global $nn, $lastError, $PHP_SELF, $AUTH, $IS_FTP, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize, $Resume, $bytesReceived, $fs, $force_name, $options;
    $scheme .= "://";
    if ($post !== 0 && $scheme == "http://") {
        $method = "POST";
        $postdata = formpostdata($post);
        $length = strlen($postdata);
        $content_tl = "Content-Type: application/x-www-form-urlencoded" . $nn . "Content-Length: " . $length . $nn;
    } else {
        $method = "GET";
        $postdata = "";
        $content_tl = "";
    }
    if ($cookie) {
        if (is_array($cookie)) {
            for ($i = 0; $i < count($cookie); $i++) {
                $cookies .= "Cookie: " . $cookie[$i] . $nn;
            }
        } else {
            $cookies = "Cookie: " . $cookie . $nn;
        }
    }
    $referer = $referer ? "Referer: " . $referer . $nn : "";
    if ($scheme == "https://") {
        $scheme = "ssl://";
        $port = 443;
    }
    if ($proxy) {
        list($proxyHost, $proxyPort) = explode(":", $proxy);
        $url = $scheme . $host . ":" . $port . $url;
        $host = $host . ":" . $port;
    }
    if ($scheme != "ssl://") {
        $scheme = "";
    }
    $http_auth = $auth ? "Authorization: Basic " . $auth . $nn : "";
    $proxyauth = $pauth ? "Proxy-Authorization: Basic " . $pauth . $nn : "";
    $request = $method . " " . str_replace(" ", "%20", $url) . " HTTP/1.1" . $nn . "Host: " . $host . $nn . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14" . $nn . "Accept: */*" . $nn . "Accept-Language: en-us;q=0.7,en;q=0.3" . $nn . "Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7" . $nn . "Pragma: no-cache" . $nn . "Cache-Control: no-cache" . $nn . ($Resume["use"] === TRUE ? "Range: bytes=" . $Resume["from"] . "-" . $nn : "") . $http_auth . $proxyauth . $referer . $cookies . "Connection: Close" . $nn . $content_tl . $nn . $postdata;
    $errno = 0;
    $errstr = "";
    $hosts = ($proxyHost ? $scheme . $proxyHost : $scheme . $host) . ':' . ($proxyPort ? $proxyPort : $port);
    $fp = @stream_socket_client($hosts, $errno, $errstr, 120, STREAM_CLIENT_CONNECT);
    //$fp = @fsockopen($proxyHost ? $scheme.$proxyHost : $scheme.$host, $proxyPort ? $proxyPort : $port, $errno, $errstr, 15);
    if (!$fp) {
        $dis_host = $proxyHost ? $proxyHost : $host;
        $dis_port = $proxyPort ? $proxyPort : $port;
        html_error(sprintf(lang(88), $dis_host, $dis_port));
    }
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    if ($saveToFile) {
        if ($proxy) {
            echo '<p>' . sprintf(lang(89), $proxyHost, $proxyPort) . '<br />';
            echo "GET: <b>" . $url . "</b>...<br />\n";
        } else {
            echo "<p>";
            printf(lang(90), $host, $port);
            echo "</p>";
        }
    }
    #########################################################################
    fputs($fp, $request);
    fflush($fp);
    $timeStart = getmicrotime();
    // Rewrote the get header function according to the proxy script
    // Also made sure it goes faster and I think 8192 is the best value for retrieving headers
    // Oops.. The previous function hooked up everything and now I'm returning it back to normal
    do {
        $header .= fgets($fp, 16384);
    } while (strpos($header, $nn . $nn) === false);
    #########################################################################
    if (!$header) {
        $lastError = lang(91);
        return false;
    }
    $responsecode = "";
    preg_match('/^HTTP\\/1\\.0|1 ([0-9]+) .*/', $header, $responsecode);
    if (($responsecode[1] == 404 || $responsecode[1] == 403) && $saveToFile) {
        // Do some checking, please, at least tell them what error it was
        if ($responsecode[1] == 403) {
            $lastError = lang(92);
        } elseif ($responsecode[1] == 404) {
            $lastError = lang(93);
        } else {
            // Weird, it shouldn't come here...
            $lastError = lang(94);
        }
        return false;
    }
    if ($saveToFile) {
        //$bytesTotal = intval ( trim ( cut_str ( $header, "Content-Length:", "\n" ) ) );
        $bytesTotal = trim(cut_str($header, "Content-Length:", "\n"));
        global $options;
        if ($options['file_size_limit'] > 0) {
            if ($bytesTotal > $options['file_size_limit'] * 1024 * 1024) {
                $lastError = lang(336) . bytesToKbOrMbOrGb($options['file_size_limit'] * 1024 * 1024) . ".";
                return false;
            }
        }
        if (stristr($host, "rapidshare") && $bytesTotal < 10000) {
            while (!feof($fp)) {
                $page_src .= fread($fp, 1024 * 8);
            }
            is_present($page_src, "is already in use with another ip", lang(100));
        }
        if (stristr($host, "imageshack") && $bytesTotal < 15000) {
            while (!feof($fp)) {
                $page_src .= fread($fp, 1024 * 8);
            }
            is_present($page_src, "To avoid creation of corrupted zip files, you cannot create a zip on this torrent until it is done downloading");
        }
        $redir = "";
        if (trim(preg_match('/[^\\-]Location: *(.+)(\\r|\\n)+/i', $header, $redir))) {
            $redirect = $redir[1];
            $lastError = sprintf(lang(95), $redirect);
            return FALSE;
        }
        if (in_array(cut_str($header, "WWW-Authenticate: ", " "), array("Basic", "Digest"))) {
            $lastError = lang(96);
            return FALSE;
        }
        $ContentType = trim(cut_str($header, "Content-Type:", "\n"));
        if (stristr($host, "rapidshare") && stristr($ContentType, "text/html") && stristr($header, "404 Not Found")) {
            unset($saveToFile);
            $NoDownload = TRUE;
        } elseif (stristr($host, "megaupload") && stristr($ContentType, "text/html")) {
            unset($saveToFile);
            $NoDownload = TRUE;
        }
        if ($Resume["use"] === TRUE && !stristr($header, "Content-Range:")) {
            if (stristr($header, "503 Limit Exceeded")) {
                $lastError = lang(97);
            } else {
                $lastError = lang(98);
            }
            return FALSE;
        }
        if ($force_name) {
            $FileName = $force_name;
            $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $FileName;
        } else {
            $ContentDisposition = trim(cut_str($header, "Content-Disposition:", "\n")) . "\n";
            if ($ContentDisposition && stripos($ContentDisposition, "filename=") !== false) {
                $FileName = trim(trim(trim(trim(trim(cut_str($ContentDisposition, "filename=", "\n")), "="), "?"), ";"), '"');
                if (strpos($FileName, "/") !== false) {
                    $FileName = basename($FileName);
                }
                $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $FileName;
            }
        }
        if (!empty($options['rename_prefix'])) {
            $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile);
            $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
        }
        if (!empty($options['rename_suffix'])) {
            $ext = strrchr(basename($saveToFile), ".");
            $before_ext = explode($ext, basename($saveToFile));
            $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext;
            $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
        }
        if ($options['rename_underscore']) {
            $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile));
            $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name;
        }
        $filetype = strrchr($saveToFile, ".");
        if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) {
            if ($options['forbidden_filetypes_block']) {
                $lastError = sprintf(lang(82), $filetype);
                return false;
            } else {
                $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile);
            }
        }
        if (@file_exists($saveToFile) && $options['bw_save']) {
            html_error(lang(99) . ': ' . link_for_file($saveToFile), 0);
        }
        if (@file_exists($saveToFile) && $Resume["use"] === TRUE) {
            $fs = @fopen($saveToFile, "ab");
            if (!$fs) {
                $lastError = sprintf(lang(101), basename($saveToFile), dirname($saveToFile)) . '<br />' . lang(102) . '<br /><a href="javascript:location.reload();">' . lang(103) . '</a>';
                return FALSE;
            }
        } else {
            if (@file_exists($saveToFile)) {
                $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . "_" . basename($saveToFile);
            }
            $fs = @fopen($saveToFile, "wb");
            if (!$fs) {
                $secondName = dirname($saveToFile) . PATH_SPLITTER . str_replace(":", "", str_replace("?", "", basename($saveToFile)));
                $fs = @fopen($secondName, "wb");
                if (!$fs) {
                    $lastError = sprintf(lang(101), basename($saveToFile), dirname($saveToFile)) . '<br />' . lang(102) . '<br /><a href="javascript:location.reload();">' . lang(103) . '</a>';
                    return FALSE;
                }
            }
        }
        flock($fs, LOCK_EX);
        if ($Resume["use"] === TRUE && stristr($header, "Content-Range:")) {
            list($temp, $Resume["range"]) = explode(" ", trim(cut_str($header, "Content-Range:", "\n")));
            list($Resume["range"], $fileSize) = explode("/", $Resume["range"]);
            $fileSize = bytesToKbOrMbOrGb($fileSize);
        } else {
            $fileSize = bytesToKbOrMbOrGb($bytesTotal);
        }
        $chunkSize = GetChunkSize($bytesTotal);
        echo lang(104) . ' <b>' . basename($saveToFile) . '</b>, ' . lang(56) . ' <b>' . $fileSize . '</b>...<br />';
        //$scriptStarted = false;
        require TEMPLATE_DIR . '/transloadui.php';
        if ($Resume["use"] === TRUE) {
            $received = bytesToKbOrMbOrGb(filesize($saveToFile));
            $percent = round($Resume["from"] / ($bytesTotal + $Resume["from"]) * 100, 2);
            echo '<script type="text/javascript">pr(' . "'" . $percent . "', '" . $received . "', '0');</script>";
            //$scriptStarted = true;
            flush();
        }
    } else {
        $page = $header;
    }
    do {
        $data = @fread($fp, $saveToFile ? $chunkSize : 16384);
        // 16384 saw this value in Pear HTTP_Request2 package // (fix - szal) using this actually just causes massive cpu usage for large files, too much data is flushed to the browser!)
        if ($data == '') {
            break;
        }
        if ($saveToFile) {
            $bytesSaved = fwrite($fs, $data);
            if ($bytesSaved > -1) {
                $bytesReceived += $bytesSaved;
            } else {
                $lastError = sprintf(lang(105), $saveToFile);
                return false;
            }
            if ($bytesReceived >= $bytesTotal) {
                $percent = 100;
            } else {
                $percent = @round(($bytesReceived + $Resume["from"]) / ($bytesTotal + $Resume["from"]) * 100, 2);
            }
            if ($bytesReceived > $last + $chunkSize) {
                $received = bytesToKbOrMbOrGb($bytesReceived + $Resume["from"]);
                $time = getmicrotime() - $timeStart;
                $chunkTime = $time - $lastChunkTime;
                $chunkTime = $chunkTime ? $chunkTime : 1;
                $lastChunkTime = $time;
                $speed = @round($chunkSize / 1024 / $chunkTime, 2);
                /*if (!$scriptStarted) {
                			echo('<script type="text/javascript">');
                			$scriptStarted = true;
                		}*/
                echo '<script type="text/javascript">pr(' . "'" . $percent . "', '" . $received . "', '" . $speed . "');</script>";
                $last = $bytesReceived;
            }
        } else {
            $page .= $data;
        }
    } while (strlen($data) > 0);
    //echo('</script>');
    if ($saveToFile) {
        flock($fs, LOCK_UN);
        fclose($fs);
        if ($bytesReceived <= 0) {
            $lastError = lang(106);
            fclose($fp);
            return FALSE;
        }
    }
    fclose($fp);
    if ($saveToFile) {
        return array("time" => sec2time(round($time)), "speed" => @round($bytesTotal / 1024 / (getmicrotime() - $timeStart), 2), "received" => true, "size" => $fileSize, "bytesReceived" => $bytesReceived + $Resume["from"], "bytesTotal" => $bytesTotal + $Resume["from"], "file" => $saveToFile);
    } else {
        if ($NoDownload) {
            if (stristr($host, "rapidshare")) {
                is_present($page, "You have reached the limit for Free users", lang(107), 0);
                is_present($page, "The download session has expired", lang(108), 0);
                is_present($page, "Wrong access code.", lang(109), 0);
                is_present($page, "You have entered a wrong code too many times", lang(110), 0);
                print $page;
            } elseif (stristr($host, "megaupload")) {
                is_present($page, "Download limit exceeded", lang(111), 0);
                print $page;
            }
        } else {
            return $page;
        }
    }
}
コード例 #15
0
ファイル: http.php プロジェクト: Transcodes/rapidleech
function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveToFile = 0, $proxy = 0, $pauth = 0, $auth = 0, $scheme = 'http', $resume_from = 0, $XMLRequest = 0)
{
    global $nn, $lastError, $Resume, $bytesReceived, $fp, $fs, $force_name, $options, $sFilters;
    $scheme = strtolower($scheme) . '://';
    if ($post !== 0 && ($scheme == 'http://' || $scheme == 'https://')) {
        $method = 'POST';
        $postdata = is_array($post) ? formpostdata($post) : $post;
    } else {
        $method = 'GET';
        $postdata = '';
    }
    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 downloading via HTTPS.');
        }
        $scheme = 'tls://';
        if ($port == 0 || $port == 80) {
            $port = 443;
        }
    }
    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[] = $method . ' ' . str_replace(' ', '%20', $url) . ' HTTP/1.1';
    $request[] = "Host: {$host}";
    $request[] = 'User-Agent: ' . rl_UserAgent;
    $request[] = 'Accept: */*';
    $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}";
    }
    $request[] = 'Pragma: no-cache';
    $request[] = 'Cache-Control: no-cache';
    //	if ($Resume['use'] === TRUE) $request[] = 'Range: bytes=' . $Resume['from'] . '-';
    if (!empty($auth)) {
        $request[] = "Authorization: Basic {$auth}";
    }
    if (!empty($pauth)) {
        $request[] = "Proxy-Authorization: Basic {$pauth}";
    }
    if ($method == 'POST') {
        if (!empty($referer) && stripos($referer, "\nContent-Type: ") === false) {
            $request[] = 'Content-Type: application/x-www-form-urlencoded';
        }
        $request[] = 'Content-Length: ' . strlen($postdata);
    }
    if ($XMLRequest) {
        $request[] = 'X-Requested-With: XMLHttpRequest';
    }
    $request[] = 'Connection: Close';
    $request = implode($nn, $request) . $nn . $nn . $postdata;
    $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);
    //$fp = @fsockopen($proxyHost ? $scheme.$proxyHost : $scheme.$host, $proxyPort ? $proxyPort : $port, $errno, $errstr, 15);
    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 ($saveToFile) {
        if ($proxy) {
            echo '<p>' . sprintf(lang(89), $proxyHost, $proxyPort) . '<br />';
            echo 'GET: <b>' . $url . "</b>...<br />\n";
        } else {
            echo '<p>' . sprintf(lang(90), $host, $port) . '</p>';
        }
    }
    #########################################################################
    fwrite($fp, $request);
    fflush($fp);
    $timeStart = microtime(true);
    // Rewrote the get header function according to the proxy script
    // Also made sure it goes faster and I think 8192 is the best value for retrieving headers
    // Oops.. The previous function hooked up everything and now I'm returning it back to normal
    $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())) {
        // Add built-in dechunk filter
        $sFilters['dechunk'] = stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ);
        if (!$sFilters['dechunk'] && $saveToFile) {
            html_error('Unknown error while initializing dechunk filter, cannot continue download.');
        }
    }
    #########################################################################
    if ($saveToFile) {
        if (!isset($_GET['dis_plug']) || $_GET['dis_plug'] != 'on') {
            $cbhost = strpos($host, ':') !== false ? substr($host, 0, strpos($host, ':')) : $host;
            // Remove the port that may be added when it's using proxy
            $chkhost = preg_match('/^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}$/', $cbhost) ? false : true;
            if (!empty($referer)) {
                $cbrefhost = stripos($referer, 'www.') === 0 ? substr($referer, 4) : $referer;
                $cbrefhost = parse_url($cbrefhost, PHP_URL_HOST);
                $chkref = empty($cbrefhost) || preg_match('/^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}$/', $cbrefhost) ? false : ($chkhost && strtolower($cbhost) == strtolower($cbrefhost) ? false : true);
            } else {
                $chkref = false;
            }
            $found = false;
            if ($chkhost || $chkref) {
                foreach ($GLOBALS['host'] as $site => $file) {
                    if ($chkhost && host_matches($site, $cbhost)) {
                        $found = true;
                        break;
                    } elseif ($chkref && host_matches($site, $cbrefhost)) {
                        $found = true;
                        break;
                    }
                }
            }
            if ($found) {
                require_once HOST_DIR . 'DownloadClass.php';
                require_once HOST_DIR . "download/{$file}";
                $class = substr($file, 0, -4);
                $firstchar = substr($file, 0, 1);
                if ($firstchar > 0) {
                    $class = "d{$class}";
                }
                if (class_exists($class) && method_exists($class, 'CheckBack')) {
                    // is_callable(array($class , 'CheckBack'))
                    $hostClass = new $class(false);
                    $hostClass->CheckBack($header);
                }
            }
            unset($cbhost, $cbrefhost, $chkhost, $chkref, $found);
        }
        if (preg_match('/^HTTP\\/1\\.[0|1] (\\d+) .*/', $header, $responsecode) && ($responsecode[1] == 404 || $responsecode[1] == 403)) {
            // Do some checking, please, at least tell them what error it was
            if ($responsecode[1] == 403) {
                $lastError = lang(92);
            } elseif ($responsecode[1] == 404) {
                $lastError = lang(93);
            } else {
                // Weird, it shouldn't come here...
                $lastError = lang(94);
            }
            return false;
        }
        //$bytesTotal = intval ( trim ( cut_str ( $header, "Content-Length:", "\n" ) ) );
        $bytesTotal = trim(cut_str($header, "\nContent-Length: ", "\n"));
        global $options;
        if ($options['file_size_limit'] > 0 && $bytesTotal > $options['file_size_limit'] * 1024 * 1024) {
            $lastError = lang(336) . bytesToKbOrMbOrGb($options['file_size_limit'] * 1024 * 1024) . '.';
            return false;
        }
        if (stripos($header, "\nLocation: ") !== false && preg_match('/\\nLocation: ([^\\r\\n]+)/i', $header, $redir)) {
            $redirect = trim($redir[1]);
            $lastError = sprintf(lang(95), $redirect);
            return FALSE;
        }
        if (in_array(cut_str($header, "\nWWW-Authenticate: ", ' '), array('Basic', 'Digest'))) {
            $lastError = lang(96);
            return FALSE;
        }
        //$ContentType = trim (cut_str($header, "\nContent-Type:", "\n")); // Unused
        if ($Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") === false) {
            $lastError = stripos($header, '503 Limit Exceeded') !== false ? lang(97) : lang(98);
            return FALSE;
        }
        if ($force_name) {
            $FileName = $force_name;
        } else {
            $ContentDisposition = cut_str($header, "\nContent-Disposition: ", "\n");
            if (!empty($ContentDisposition) && stripos($ContentDisposition, 'filename') !== false) {
                if (preg_match("@filename\\*=UTF-8''((?:[\\w\\-\\.]|%[0-F]{2})+)@i", $ContentDisposition, $fn)) {
                    $FileName = rawurldecode($fn[1]);
                } elseif (preg_match('@filename=\\"?([^\\r\\n\\"\\;]+)\\"?@i', $ContentDisposition, $fn)) {
                    $FileName = $fn[1];
                } else {
                    $FileName = $saveToFile;
                }
            } else {
                $FileName = $saveToFile;
            }
        }
        $FileName = str_replace(array_merge(range(chr(0), chr(31)), str_split("<>:\"/|?*\\")), '', basename(trim($FileName)));
        if (!empty($options['rename_prefix'])) {
            $FileName = $options['rename_prefix'] . '_' . $FileName;
        }
        if (!empty($options['rename_suffix'])) {
            $ext = strrchr($FileName, '.');
            $before_ext = explode($ext, $FileName);
            $FileName = $before_ext[0] . '_' . $options['rename_suffix'] . $ext;
        }
        if ($options['rename_underscore']) {
            $FileName = str_replace(array(' ', '%20'), '_', $FileName);
        }
        $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $FileName;
        $filetype = strrchr($saveToFile, '.');
        if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) {
            if ($options['forbidden_filetypes_block']) {
                $lastError = sprintf(lang(82), $filetype);
                return false;
            } else {
                $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile);
            }
        }
        if (@file_exists($saveToFile) && $options['bw_save']) {
            // Skip in audl.
            if (isset($_GET['audl'])) {
                echo '<script type="text/javascript">parent.nextlink();</script>';
            }
            html_error(lang(99) . ': ' . link_for_file($saveToFile));
        }
        if (@file_exists($saveToFile) && $Resume['use'] === TRUE) {
            $fs = @fopen($saveToFile, 'ab');
            if (!$fs) {
                $lastError = sprintf(lang(101), basename($saveToFile), dirname($saveToFile)) . '<br />' . lang(102) . '<br /><a href="javascript:location.reload();">' . lang(103) . '</a>';
                return FALSE;
            }
        } else {
            if (@file_exists($saveToFile)) {
                $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . '_' . basename($saveToFile);
            }
            $fs = @fopen($saveToFile, 'wb');
            if (!$fs) {
                $secondName = dirname($saveToFile) . PATH_SPLITTER . str_replace(':', '', str_replace('?', '', basename($saveToFile)));
                $fs = @fopen($secondName, 'wb');
                if (!$fs) {
                    $lastError = sprintf(lang(101), basename($saveToFile), dirname($saveToFile)) . '<br />' . lang(102) . '<br /><a href="javascript:location.reload();">' . lang(103) . '</a>';
                    return FALSE;
                }
            }
        }
        flock($fs, LOCK_EX);
        if ($Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") !== false) {
            list($temp, $Resume['range']) = explode(' ', trim(cut_str($header, "\nContent-Range: ", "\n")));
            list($Resume['range'], $fileSize) = explode('/', $Resume['range']);
            $fileSize = bytesToKbOrMbOrGb($fileSize);
        } else {
            $fileSize = bytesToKbOrMbOrGb($bytesTotal);
        }
        $chunkSize = GetChunkSize($bytesTotal);
        echo lang(104) . ' <b>' . basename($saveToFile) . '</b>, ' . lang(56) . " <b>{$fileSize}</b>...<br />";
        //$scriptStarted = false;
        require_once TEMPLATE_DIR . '/transloadui.php';
        if ($Resume['use'] === TRUE) {
            $received = bytesToKbOrMbOrGb(filesize($saveToFile));
            $percent = round($Resume['from'] / ($bytesTotal + $Resume['from']) * 100, 2);
            echo "<script type='text/javascript'>pr('{$percent}', '{$received}', '0');</script>";
            //$scriptStarted = true;
            flush();
        }
    } else {
        $page = '';
    }
    $time = $last = $lastChunkTime = 0;
    do {
        $data = @fread($fp, $saveToFile ? $chunkSize : 16384);
        // 16384 saw this value in Pear HTTP_Request2 package // (fix - szal) using this actually just causes massive cpu usage for large files, too much data is flushed to the browser!)
        if ($data == '') {
            break;
        }
        if ($saveToFile) {
            $bytesSaved = fwrite($fs, $data);
            if ($bytesSaved !== false && strlen($data) == $bytesSaved) {
                //if ($bytesSaved > - 1) {
                $bytesReceived += $bytesSaved;
            } else {
                $lastError = sprintf(lang(105), basename($saveToFile));
                // unlink($saveToFile);
                return false;
            }
            if ($bytesReceived >= $bytesTotal) {
                $percent = 100;
            } else {
                $percent = @round(($bytesReceived + $Resume['from']) / ($bytesTotal + $Resume['from']) * 100, 2);
            }
            if ($bytesReceived > $last + $chunkSize) {
                $received = bytesToKbOrMbOrGb($bytesReceived + $Resume['from']);
                $time = microtime(true) - $timeStart;
                $chunkTime = $time - $lastChunkTime;
                $chunkTime = $chunkTime > 0 ? $chunkTime : 1;
                $lastChunkTime = $time;
                $speed = @round(($bytesReceived - $last) / 1024 / $chunkTime, 2);
                echo "<script type='text/javascript'>pr('{$percent}', '{$received}', '{$speed}');</script>";
                $last = $bytesReceived;
            }
            if (!empty($bytesTotal) && $bytesReceived + $chunkSize > $bytesTotal) {
                $chunkSize = $bytesTotal - $bytesReceived;
            }
        } else {
            $page .= $data;
        }
    } while (!feof($fp) && strlen($data) > 0);
    if ($saveToFile) {
        flock($fs, LOCK_UN);
        fclose($fs);
        if ($bytesReceived <= 0) {
            $lastError = lang(106);
            stream_socket_shutdown($fp, STREAM_SHUT_RDWR);
            fclose($fp);
            return FALSE;
        }
    }
    stream_socket_shutdown($fp, STREAM_SHUT_RDWR);
    fclose($fp);
    if ($saveToFile) {
        return array('time' => sec2time(round($time)), 'speed' => @round($bytesTotal / 1024 / (microtime(true) - $timeStart), 2), 'received' => true, 'size' => $fileSize, 'bytesReceived' => $bytesReceived + $Resume['from'], 'bytesTotal' => $bytesTotal + $Resume['from'], 'file' => $saveToFile);
    } else {
        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;
    }
}
コード例 #16
0
</ul></div></td>
<td class="tdacc">
<div id="curtrafic" align="center" style="position:absolute;float:left;width:200px;padding-left:270px; margin-top:-10px;"><div id="trafwaiting" align="left" style="display:none;"></div></div>
<div class="div_right_ndot"><ul>
<li class="ndot"><span>Quota Traffic allowed. Currently traffic:&nbsp;<span id="cur_traffic"><b class="g" style="position:absolute;"><span id="trafshowresults"><?php 
        echo bytesToKbOrMbOrGb($traffic->total);
        ?>
</span>&nbsp;&nbsp;<a href="javascript:;" onclick="<?php 
        echo $ajax_serverfiles ? 'if(confirm(\'This will reset Current Traffic, proceed?\')){trafst();}' : 'alert(\'Ajax Disabled\');';
        ?>
;"><small>reset</small></a></b></span></span></li>
<li class="ndot"><span>The D-Day traffic quota will expired</span></li>
<li class="ndot"><span>Auto-Reset traffic. set to 0 or blank to disable.
<?php 
        if ($options['day_reset_trafic'] > 0) {
            echo "<small class='g'>remain: " . sec2time($traffic->timeremain()) . "</small>";
        }
        ?>
</span></li></ul>
<?php 
        if ($ajax_serverfiles) {
            ?>
<script type="text/javascript">function trafst() {document.trew.submit("posttraffic","trafwaiting","trafshowresults",""); }</script>
<?php 
        }
        ?>
</div></td>
</tr>

<tr>
<td class="tdacc"><input type="checkbox" id="opt_limited_edition" name="opt_limited_edition" value="1" /><label for="opt_limited_edition">&nbsp;<b>Limit Authorize by IP</b></label></td>
コード例 #17
0
ファイル: build_deff.php プロジェクト: Wehmeyer/Litotex-0.7
            while ($rowt = $db->fetch_array($resultt)) {
            }
            if ($row['res1'] <= 0) {
                $row['res1']++;
            }
            if ($row['res2'] <= 0) {
                $row['res2']++;
            }
            if ($row['res3'] <= 0) {
                $row['res3']++;
            }
            if ($row['res4'] <= 0) {
                $row['res4']++;
            }
            $numOfMans = $userdata[$row['tabless']];
            $build_time = sec2time($row['stime']);
            $maxi = min(floor($userdata['res1'] / $row['res1']), floor($userdata['res2'] / $row['res2']), floor($userdata['res3'] / $row['res3']), floor($userdata['res4'] / $row['res4']));
            $url = "\"build_deff.php?action=create&soid={$row['sid']}\"";
            $new_found_inhalt = array("\"" . $row['solpic'] . "\"", $row['name'], $row['description'], $op_set_n_res1 . ": " . $row['res1'], $op_set_n_res2 . ": " . $row['res2'], $op_set_n_res3 . ": " . $row['res3'], $op_set_n_res4 . ": " . $row['res4'], $build_time, $numOfMans, $url, $maxi, $row['AP'], $row['VP']);
            array_push($new_found, $new_found_inhalt);
        }
    }
    $tpl->assign('daten', $new_found);
    template_out('build_deff.html', $modul_name);
    exit;
}
if ($action == "create") {
    $num = intval($_POST['num']);
    $soid = intval($_GET['soid']);
    if ($num == 0 || $soid == 0 || $num < 0) {
        show_error('BUILD_DEFF_ERROR_1', $modul_name);
コード例 #18
0
ファイル: members.php プロジェクト: Wehmeyer/Litotex-0.7
     $tpl->assign('ali_news_show', $ali_news_text);
     $tpl->assign('ali_news_date', $change_date);
 }
 $userrace = get_race($userdata['rassenid']);
 $cur_res_reload_time = round($op_res_reload_time / 60);
 $production_res1 = $op_set_res1 + $userdata['res1mine'] * $op_mup_res1;
 $production_res2 = $op_set_res3 + $userdata['res2mine'] * $op_mup_res3;
 $production_res3 = $op_set_res2 + $userdata['res3mine'] * $op_mup_res2;
 $production_res4 = $op_set_res4 + $userdata['res4mine'] * $op_mup_res4;
 $next4ressources = $userdata['lastressources'] + $op_res_reload_time - time();
 $allianzname = generate_allilink($userdata['allianzid']);
 $is_allianz = 0;
 if ($userdata['allianzid'] != 0) {
     $is_allianz = 1;
 }
 $tpl->assign('next4ressources', sec2time($next4ressources));
 $tpl->assign('daten', $daten);
 $tpl->assign('cur_res_reload_time', $cur_res_reload_time);
 $tpl->assign('production_res1', $production_res1);
 $tpl->assign('production_res2', $production_res2);
 $tpl->assign('production_res3', $production_res3);
 $tpl->assign('production_res4', $production_res4);
 $tpl->assign('is_allianz', $is_allianz);
 $tpl->assign('M_USER_RACE', $userrace);
 $tpl->assign('M_LANDSIZE_MAX', $op_max_c_size);
 $tpl->assign('M_LANDSIZE', $userdata['size']);
 $tpl->assign('M_A_NAME', $allianzname);
 $tpl->assign('M_KOORDS', $userdata['x'] . ":" . $userdata['y']);
 $tpl->assign('M_C_NAME', $userdata['name']);
 $tpl->assign('M_POINTS', $userdata['points']);
 template_out('members.html', $modul_name);