mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-05 03:14:21 +08:00
Fixed cPanel plugin
This commit is contained in:
parent
67678017a8
commit
4c38993c26
3 changed files with 57 additions and 31 deletions
|
@ -152,6 +152,11 @@ class CpanelChangePasswordDriver implements \RainLoop\Providers\ChangePassword\C
|
|||
$sResult = $oXmlApi->api2_query($sUser, 'Email', 'passwdpop', $aArgs);
|
||||
if ($sResult)
|
||||
{
|
||||
if ($this->oLogger)
|
||||
{
|
||||
$this->oLogger->Write('CPANEL: '.$sResult, \MailSo\Log\Enumerations\Type::INFO);
|
||||
}
|
||||
|
||||
$aResult = @\json_decode($sResult, true);
|
||||
$bResult = isset($aResult['cpanelresult']['data'][0]['result']) &&
|
||||
!!$aResult['cpanelresult']['data'][0]['result'];
|
||||
|
|
|
@ -656,7 +656,7 @@ class xmlapi
|
|||
|
||||
// Set the $auth string
|
||||
|
||||
$authstr;
|
||||
$authstr = '';
|
||||
if ($this->auth_type == 'hash') {
|
||||
$authstr = 'Authorization: WHM ' . $this->user . ':' . $this->auth . "\r\n";
|
||||
} elseif ($this->auth_type == 'pass') {
|
||||
|
@ -671,13 +671,33 @@ class xmlapi
|
|||
|
||||
// Perform the query (or pass the info to the functions that actually do perform the query)
|
||||
|
||||
$response;
|
||||
$response = '';
|
||||
if ($this->http_client == 'curl') {
|
||||
$response = $this->curl_query($url, $args, $authstr);
|
||||
} elseif ($this->http_client == 'fopen') {
|
||||
$response = $this->fopen_query($url, $args, $authstr);
|
||||
}
|
||||
|
||||
// fix #1
|
||||
$aMatch = array();
|
||||
if ($response && false !== stripos($response, '<html>') &&
|
||||
preg_match('/HTTP-EQUIV[\s]?=[\s]?"refresh"/i', $response) &&
|
||||
preg_match('/<meta [^>]+url[\s]?=[\s]?([^">]+)/i', $response, $aMatch) &&
|
||||
!empty($aMatch[1]) && 0 === strpos(trim($aMatch[1]), 'http'))
|
||||
{
|
||||
$url = trim($aMatch[1]) . $query_type . $function;
|
||||
if ($this->debug) {
|
||||
error_log('new URL: ' . $url);
|
||||
}
|
||||
|
||||
if ($this->http_client == 'curl') {
|
||||
$response = $this->curl_query($url, $args, $authstr);
|
||||
} elseif ($this->http_client == 'fopen') {
|
||||
$response = $this->fopen_query($url, $args, $authstr);
|
||||
}
|
||||
}
|
||||
// ---
|
||||
|
||||
/*
|
||||
* Post-Query Block
|
||||
* Handle response, return proper data types, debug, etc
|
||||
|
@ -1543,7 +1563,7 @@ class xmlapi
|
|||
*/
|
||||
public function editpkg($pkg)
|
||||
{
|
||||
if (!$isset($pkg['name'])) {
|
||||
if (!isset($pkg['name'])) {
|
||||
error_log("editpkg requires that name is defined in the array passed to it");
|
||||
|
||||
return false;
|
||||
|
@ -2183,7 +2203,7 @@ class xmlapi
|
|||
* Service Status
|
||||
*
|
||||
* This function will return the status of all services on the and whether they are running or not
|
||||
* @param string $service A single service to filter for.
|
||||
* @param array $args A single service to filter for.
|
||||
* @return mixed
|
||||
* @link http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ServiceStatus XML API Call documentation
|
||||
*/
|
||||
|
@ -2456,7 +2476,7 @@ class xmlapi
|
|||
}
|
||||
if (is_array($args)) {
|
||||
$display = '';
|
||||
foreach ($args as $key => $value) {
|
||||
foreach ($args as $value) {
|
||||
$display .= $value . '|';
|
||||
}
|
||||
$values['display'] = substr($display, 0, -1);
|
||||
|
|
|
@ -51,18 +51,18 @@ class SubStreams
|
|||
*/
|
||||
public static function CreateStream($aSubStreams)
|
||||
{
|
||||
if (!in_array(self::STREAM_NAME, stream_get_wrappers()))
|
||||
if (!\in_array(self::STREAM_NAME, \stream_get_wrappers()))
|
||||
{
|
||||
stream_wrapper_register(self::STREAM_NAME, '\MailSo\Base\StreamWrappers\SubStreams');
|
||||
\stream_wrapper_register(self::STREAM_NAME, '\MailSo\Base\StreamWrappers\SubStreams');
|
||||
}
|
||||
|
||||
$sHashName = md5(microtime(true).rand(1000, 9999));
|
||||
$sHashName = \md5(\microtime(true).\rand(1000, 9999));
|
||||
|
||||
self::$aStreams[$sHashName] = $aSubStreams;
|
||||
|
||||
\MailSo\Base\Loader::IncStatistic('CreateStream/SubStreams');
|
||||
|
||||
return fopen(self::STREAM_NAME.'://'.$sHashName, 'rb');
|
||||
return \fopen(self::STREAM_NAME.'://'.$sHashName, 'rb');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,10 +71,11 @@ class SubStreams
|
|||
protected function &getPart()
|
||||
{
|
||||
$nNull = null;
|
||||
if (isset($this->aSubStreams[$this->iIndex]));
|
||||
if (isset($this->aSubStreams[$this->iIndex]))
|
||||
{
|
||||
return $this->aSubStreams[$this->iIndex];
|
||||
}
|
||||
|
||||
return $nNull;
|
||||
}
|
||||
|
||||
|
@ -88,16 +89,16 @@ class SubStreams
|
|||
$this->aSubStreams = array();
|
||||
|
||||
$bResult = false;
|
||||
$aPath = parse_url($sPath);
|
||||
$aPath = \parse_url($sPath);
|
||||
|
||||
if (isset($aPath['host']) && isset($aPath['scheme']) &&
|
||||
0 < strlen($aPath['host']) && 0 < strlen($aPath['scheme']) &&
|
||||
if (isset($aPath['host'], $aPath['scheme']) &&
|
||||
0 < \strlen($aPath['host']) && 0 < \strlen($aPath['scheme']) &&
|
||||
self::STREAM_NAME === $aPath['scheme'])
|
||||
{
|
||||
$sHashName = $aPath['host'];
|
||||
if (isset(self::$aStreams[$sHashName]) &&
|
||||
is_array(self::$aStreams[$sHashName]) &&
|
||||
0 < count(self::$aStreams[$sHashName]))
|
||||
\is_array(self::$aStreams[$sHashName]) &&
|
||||
0 < \count(self::$aStreams[$sHashName]))
|
||||
{
|
||||
$this->iIndex = 0;
|
||||
$this->iPos = 0;
|
||||
|
@ -106,7 +107,7 @@ class SubStreams
|
|||
$this->aSubStreams = self::$aStreams[$sHashName];
|
||||
}
|
||||
|
||||
$bResult = 0 < count($this->aSubStreams);
|
||||
$bResult = 0 < \count($this->aSubStreams);
|
||||
}
|
||||
|
||||
return $bResult;
|
||||
|
@ -123,10 +124,10 @@ class SubStreams
|
|||
$mCurrentPart = null;
|
||||
if ($iCount > 0)
|
||||
{
|
||||
if ($iCount < strlen($this->sBuffer))
|
||||
if ($iCount < \strlen($this->sBuffer))
|
||||
{
|
||||
$sReturn = substr($this->sBuffer, 0, $iCount);
|
||||
$this->sBuffer = substr($this->sBuffer, $iCount);
|
||||
$sReturn = \substr($this->sBuffer, 0, $iCount);
|
||||
$this->sBuffer = \substr($this->sBuffer, $iCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -142,11 +143,11 @@ class SubStreams
|
|||
break;
|
||||
}
|
||||
|
||||
if (is_resource($mCurrentPart))
|
||||
if (\is_resource($mCurrentPart))
|
||||
{
|
||||
if (!feof($mCurrentPart))
|
||||
if (!\feof($mCurrentPart))
|
||||
{
|
||||
$sReadResult = fread($mCurrentPart, 8192);
|
||||
$sReadResult = @\fread($mCurrentPart, 8192);
|
||||
if (false === $sReadResult)
|
||||
{
|
||||
return false;
|
||||
|
@ -154,11 +155,11 @@ class SubStreams
|
|||
|
||||
$sReturn .= $sReadResult;
|
||||
|
||||
$iLen = strlen($sReturn);
|
||||
$iLen = \strlen($sReturn);
|
||||
if ($iCount < $iLen)
|
||||
{
|
||||
$this->sBuffer = substr($sReturn, $iCount);
|
||||
$sReturn = substr($sReturn, 0, $iCount);
|
||||
$this->sBuffer = \substr($sReturn, $iCount);
|
||||
$sReturn = \substr($sReturn, 0, $iCount);
|
||||
$iCount = 0;
|
||||
}
|
||||
else
|
||||
|
@ -171,17 +172,17 @@ class SubStreams
|
|||
$this->iIndex++;
|
||||
}
|
||||
}
|
||||
else if (is_string($mCurrentPart))
|
||||
else if (\is_string($mCurrentPart))
|
||||
{
|
||||
$sReadResult = substr($mCurrentPart, 0, $iCount);
|
||||
$sReadResult = \substr($mCurrentPart, 0, $iCount);
|
||||
|
||||
$sReturn .= $sReadResult;
|
||||
|
||||
$iLen = strlen($sReadResult);
|
||||
$iLen = \strlen($sReadResult);
|
||||
if ($iCount < $iLen)
|
||||
{
|
||||
$this->sBuffer = substr($sReturn, $iCount);
|
||||
$sReturn = substr($sReturn, 0, $iCount);
|
||||
$this->sBuffer = \substr($sReturn, $iCount);
|
||||
$sReturn = \substr($sReturn, 0, $iCount);
|
||||
$iCount = 0;
|
||||
}
|
||||
else
|
||||
|
@ -194,7 +195,7 @@ class SubStreams
|
|||
}
|
||||
}
|
||||
|
||||
$this->iPos += strlen($sReturn);
|
||||
$this->iPos += \strlen($sReturn);
|
||||
return $sReturn;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue