Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
@@ -1,18 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* Wrapper for retrieving file contents. Methods available for removing files and directories as well.
|
||||
* Last Updated: $Date: 2009-12-02 21:34:26 -0500 (Wed, 02 Dec 2009) $
|
||||
* Last Updated: $Date: 2010-06-24 05:35:43 -0400 (Thu, 24 Jun 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @author $Author: matt $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Services Kernel
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @subpackage Kernel
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Tuesday 22nd February 2005 (16:55)
|
||||
* @version $Revision: 350 $
|
||||
* @version $Revision: 432 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IPS_CLASSES_PATH' ) )
|
||||
@@ -46,18 +49,30 @@ class classFileManagement
|
||||
*
|
||||
* @access public
|
||||
* @var integer HTTP Status code
|
||||
* @var string HTTP Status text
|
||||
*/
|
||||
public $http_status_code = 0;
|
||||
|
||||
/**
|
||||
* HTTP Status Code/Text
|
||||
*
|
||||
* @access public
|
||||
* @var string HTTP Status text
|
||||
*/
|
||||
public $http_status_text = "";
|
||||
|
||||
/**
|
||||
* Raw HTTP header output
|
||||
*
|
||||
* @access public
|
||||
* @var string Raw HTTP header results
|
||||
*/
|
||||
public $raw_headers = '';
|
||||
|
||||
/**#@+
|
||||
* Set Authentication
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
* @var string
|
||||
* @var string
|
||||
* @var string
|
||||
*/
|
||||
public $auth_req = 0;
|
||||
public $auth_user;
|
||||
@@ -220,7 +235,7 @@ class classFileManagement
|
||||
|
||||
$host = $url_parts['host'];
|
||||
$port = ( isset($url_parts['port']) ) ? $url_parts['port'] : ( $url_parts['scheme'] == 'https' ? 443 : 80 );
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Tidy up path
|
||||
//-------------------------------
|
||||
@@ -243,7 +258,7 @@ class classFileManagement
|
||||
// Open connection
|
||||
//-------------------------------
|
||||
|
||||
if ( ! $fp = @fsockopen( $host, $port, $errno, $errstr, $fsocket_timeout ) )
|
||||
if ( ! $fp = @fsockopen( $url_parts['scheme'] == 'https' ? "ssl://" . $host : $host, $port, $errno, $errstr, $fsocket_timeout ) )
|
||||
{
|
||||
$this->errors[] = "Не могу установить соединение с {$host}";
|
||||
return FALSE;
|
||||
@@ -309,10 +324,12 @@ class classFileManagement
|
||||
{
|
||||
$_chunked = true;
|
||||
}
|
||||
|
||||
$tmp = split("\r\n\r\n", $data, 2);
|
||||
|
||||
$tmp = preg_split("/\r\n\r\n/", $data, 2);
|
||||
$data = trim($tmp[1]);
|
||||
|
||||
$this->raw_headers = trim($tmp[0]);
|
||||
|
||||
//-----------------------------------------
|
||||
// Easy way out :P
|
||||
//-----------------------------------------
|
||||
@@ -341,12 +358,14 @@ class classFileManagement
|
||||
{
|
||||
$ch = curl_init( $file_location );
|
||||
|
||||
curl_setopt( $ch, CURLOPT_HEADER , 0);
|
||||
curl_setopt( $ch, CURLOPT_HEADER , 1);
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT , $this->timeout );
|
||||
curl_setopt( $ch, CURLOPT_POST , 0 );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_FAILONERROR , 1 );
|
||||
curl_setopt( $ch, CURLOPT_MAXREDIRS , 10 );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER , false );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST , 1 );
|
||||
|
||||
/**
|
||||
* Cannot set this when safe_mode or open_basedir is enabled
|
||||
@@ -364,7 +383,15 @@ class classFileManagement
|
||||
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
if( $data )
|
||||
{
|
||||
$tmp = preg_split("/\r\n\r\n/", $data, 2);
|
||||
$data = trim($tmp[1]);
|
||||
|
||||
$this->raw_headers = trim($tmp[0]);
|
||||
}
|
||||
|
||||
if ( $data )
|
||||
{
|
||||
$this->http_status_code = 200;
|
||||
@@ -378,6 +405,69 @@ class classFileManagement
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tail a file
|
||||
*
|
||||
* @access public
|
||||
* @param string Full path to file
|
||||
* @param int No. lines to tail
|
||||
*/
|
||||
public function tailFile( $file, $lines=100 )
|
||||
{
|
||||
/* INIT */
|
||||
$content = '';
|
||||
$t = array();
|
||||
|
||||
if ( file_exists( $file ) )
|
||||
{
|
||||
$handle = @fopen( $file, 'r' );
|
||||
|
||||
if ( $handle )
|
||||
{
|
||||
$l = $lines;
|
||||
$pos = -2;
|
||||
$beg = false;
|
||||
|
||||
while ( $l > 0 )
|
||||
{
|
||||
$_t = " ";
|
||||
|
||||
while( $_t != "\n" )
|
||||
{
|
||||
if ( @fseek( $handle, $pos, SEEK_END ) == -1 )
|
||||
{
|
||||
$beg = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$_t = @fgetc( $handle );
|
||||
$pos--;
|
||||
}
|
||||
|
||||
$l--;
|
||||
|
||||
if ( $beg )
|
||||
{
|
||||
rewind( $handle );
|
||||
}
|
||||
|
||||
$t[ $lines - $l - 1 ] = @fgets( $handle );
|
||||
|
||||
if ( $beg )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@fclose ($handle);
|
||||
|
||||
$content = trim( implode( "", array_reverse( $t ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies contents of one directory to another, creating if necessary
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user