mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-29 04:23:34 +00:00
SCP: replace user_error's with exceptions
This commit is contained in:
parent
2eb4ebf11c
commit
a6fd9ea8b6
@ -34,6 +34,7 @@ namespace phpseclib\Net;
|
|||||||
|
|
||||||
use phpseclib\Net\SSH1;
|
use phpseclib\Net\SSH1;
|
||||||
use phpseclib\Net\SSH2;
|
use phpseclib\Net\SSH2;
|
||||||
|
use phpseclib\Exception\FileNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP implementations of SCP.
|
* Pure-PHP implementations of SCP.
|
||||||
@ -140,6 +141,7 @@ class SCP
|
|||||||
* @param String $data
|
* @param String $data
|
||||||
* @param optional Integer $mode
|
* @param optional Integer $mode
|
||||||
* @param optional Callable $callback
|
* @param optional Callable $callback
|
||||||
|
* @throws \phpseclib\Exception\FileNotFoundException if you're uploading via a file and the file doesn't exist
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
@ -168,8 +170,7 @@ class SCP
|
|||||||
$size = strlen($data);
|
$size = strlen($data);
|
||||||
} else {
|
} else {
|
||||||
if (!is_file($data)) {
|
if (!is_file($data)) {
|
||||||
user_error("$data is not a valid file", E_USER_NOTICE);
|
throw new FileNotFoundException("$data is not a valid file");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fp = @fopen($data, 'rb');
|
$fp = @fopen($data, 'rb');
|
||||||
@ -289,6 +290,7 @@ class SCP
|
|||||||
* Receives a packet from an SSH server
|
* Receives a packet from an SSH server
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
|
* @throws \UnexpectedValueException on receipt of an unexpected packet
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _receive()
|
function _receive()
|
||||||
@ -314,8 +316,7 @@ class SCP
|
|||||||
$this->ssh->bitmap = 0;
|
$this->ssh->bitmap = 0;
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
user_error('Unknown packet received', E_USER_NOTICE);
|
throw new \UnexpectedValueException('Unknown packet received');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user