本文整理汇总了PHP中ZPush类的典型用法代码示例。如果您正苦于以下问题:PHP ZPush类的具体用法?PHP ZPush怎么用?PHP ZPush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZPush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Handle
/**
* Handles a webservice command
*
* @param int $commandCode
*
* @access public
* @return boolean
* @throws SoapFault
*/
public function Handle($commandCode)
{
if (Request::GetDeviceType() !== "webservice" || Request::GetDeviceID() !== "webservice") {
throw new FatalException("Invalid device id and type for webservice execution");
}
if (Request::GetGETUser() != Request::GetAuthUser()) {
ZLog::Write(LOGLEVEL_INFO, sprintf("Webservice::HandleWebservice('%s'): user '%s' executing action for user '%s'", $commandCode, Request::GetAuthUser(), Request::GetGETUser()));
}
// initialize non-wsdl soap server
$this->server = new SoapServer(null, array('uri' => "http://z-push.sf.net/webservice"));
// the webservice command is handled by its class
if ($commandCode == ZPush::COMMAND_WEBSERVICE_DEVICE) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceDevice service", $commandCode));
include_once 'webservicedevice.php';
$this->server->setClass("WebserviceDevice");
}
// the webservice command is handled by its class
if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) {
if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true) {
throw new HTTPReturnCodeException(sprintf("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS.", Request::GetAuthUser()), 403);
}
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceUsers service", $commandCode));
if (ZPush::GetBackend()->Setup("SYSTEM", true) == false) {
throw new AuthenticationRequiredException(sprintf("User '%s' has no admin privileges", Request::GetAuthUser()));
}
include_once 'webserviceusers.php';
$this->server->setClass("WebserviceUsers");
}
$this->server->handle();
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): sucessfully sent %d bytes", $commandCode, ob_get_length()));
return true;
}
示例2: BackendCombined
/**
* Constructor of the combined backend
*
* @access public
*/
public function BackendCombined()
{
parent::Backend();
$this->config = BackendCombinedConfig::GetBackendCombinedConfig();
foreach ($this->config['backends'] as $i => $b) {
// load and instatiate backend
ZPush::IncludeBackend($b['name']);
$this->backends[$i] = new $b['name']($b['config']);
}
ZLog::Write(LOGLEVEL_INFO, sprintf("Combined %d backends loaded.", count($this->backends)));
}
示例3: BackendCombined
/**
* Constructor of the combined backend
*
* @access public
*/
public function BackendCombined()
{
parent::Backend();
$this->config = BackendCombinedConfig::GetBackendCombinedConfig();
$backend_values = array_unique(array_values($this->config['folderbackend']));
foreach ($backend_values as $i) {
ZPush::IncludeBackend($this->config['backends'][$i]['name']);
$this->backends[$i] = new $this->config['backends'][$i]['name']();
}
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined %d backends loaded.", count($this->backends)));
}
示例4: ListDevicesDetails
/**
* Returns a list of all known devices with users and when they synchronized for the first time
*
* @access public
* @return array
*/
public function ListDevicesDetails()
{
$devices = ZPushAdmin::ListDevices(false);
$output = array();
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceUsers::ListLastSync(): found %d devices", count($devices)));
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d devices and getting users", count($devices)), true);
foreach ($devices as $deviceId) {
$output[$deviceId] = array();
$users = ZPushAdmin::ListUsers($deviceId);
foreach ($users as $user) {
$output[$deviceId][$user] = ZPushAdmin::GetDeviceDetails($deviceId, $user);
}
}
return $output;
}
示例5: ListUserFolders
/**
* Returns a list of folders of the Request::GetGETUser().
* If the user has not enough permissions an empty result is returned.
*
* @access public
* @return array
*/
public function ListUserFolders()
{
$user = Request::GetGETUser();
$output = array();
$hasRights = ZPush::GetBackend()->Setup($user);
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceInfo::ListUserFolders(): permissions to open store '%s': %s", $user, Utils::PrintAsString($hasRights)));
if ($hasRights) {
$folders = ZPush::GetBackend()->GetHierarchy();
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d folders", count($folders)), true);
foreach ($folders as $folder) {
$folder->StripData();
unset($folder->Store, $folder->flags, $folder->content, $folder->NoBackendFolder);
$output[] = $folder;
}
}
return $output;
}
示例6: Config
/**
* Only used to load additional folder sync information for hierarchy changes
*
* @param array $state current state of additional hierarchy folders
*
* @access public
* @return boolean
*/
public function Config($state, $flags = 0)
{
// we should never forward this changes to a backend
if (!isset($this->destinationImporter)) {
foreach ($state as $addKey => $addFolder) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : process folder '%s'", $addFolder->displayname));
if (isset($addFolder->NoBackendFolder) && $addFolder->NoBackendFolder == true) {
$hasRights = ZPush::GetBackend()->Setup($addFolder->Store, true, $addFolder->serverid);
// delete the folder on the device
if (!$hasRights) {
// delete the folder only if it was an additional folder before, else ignore it
$synchedfolder = $this->GetFolder($addFolder->serverid);
if (isset($synchedfolder->NoBackendFolder) && $synchedfolder->NoBackendFolder == true) {
$this->ImportFolderDeletion($addFolder->serverid, $addFolder->parentid);
}
continue;
}
}
// add folder to the device - if folder is already on the device, nothing will happen
$this->ImportFolderChange($addFolder);
}
// look for folders which are currently on the device if there are now not to be synched anymore
$alreadyDeleted = $this->GetDeletedFolders();
foreach ($this->ExportFolders(true) as $sid => $folder) {
// we are only looking at additional folders
if (isset($folder->NoBackendFolder)) {
// look if this folder is still in the list of additional folders and was not already deleted (e.g. missing permissions)
if (!array_key_exists($sid, $state) && !array_key_exists($sid, $alreadyDeleted)) {
ZLog::Write(LOGLEVEL_INFO, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : previously synchronized folder '%s' is not to be synched anymore. Sending delete to mobile.", $folder->displayname));
$this->ImportFolderDeletion($folder->serverid, $folder->parentid);
}
}
}
}
return true;
}
示例7: define
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
require_once 'vendor/autoload.php';
require_once 'config.php';
/**
* //TODO resync of single folders of a users device
*/
/************************************************
* MAIN
*/
define('BASE_PATH_CLI', dirname(__FILE__) . "/");
set_include_path(get_include_path() . PATH_SEPARATOR . BASE_PATH_CLI);
try {
ZPush::CheckConfig();
ZLog::Initialize();
ZPushAdminCLI::CheckEnv();
ZPushAdminCLI::CheckOptions();
if (!ZPushAdminCLI::SureWhatToDo()) {
// show error message if available
if (ZPushAdminCLI::GetErrorMessage()) {
echo "ERROR: " . ZPushAdminCLI::GetErrorMessage() . "\n";
}
echo ZPushAdminCLI::UsageInstructions();
exit(1);
}
ZPushAdminCLI::RunCommand();
} catch (ZPushException $zpe) {
die(get_class($zpe) . ": " . $zpe->getMessage() . "\n");
}
示例8: IgnoreNextMessage
/**
* Indicates if the next messages should be ignored (not be sent to the mobile!)
*
* @param string $messageid (opt) id of the message which is to be exported next
* @param string $folderid (opt) parent id of the message
* @param boolean $markAsIgnored (opt) to peek without setting the next message to be
* ignored, set this value to false
* @access public
* @return boolean
*/
public function IgnoreNextMessage($markAsIgnored = true, $messageid = false, $folderid = false)
{
// as the next message id is not available at all point this method is called, we use different indicators.
// potentialbroken indicates that we know that the broken message should be exported next,
// alltho we do not know for sure as it's export message orders can change
// if the $messageid is available and matches then we are sure and only then really ignore it
$potentialBroken = false;
$realBroken = false;
if (Request::GetCommandCode() == ZPush::COMMAND_SYNC && $this->ignore_messageid !== false) {
$potentialBroken = true;
}
if ($messageid !== false && $this->ignore_messageid == $messageid) {
$realBroken = true;
}
// this call is just to know what should be happening
// no further actions necessary
if ($markAsIgnored === false) {
return $potentialBroken;
}
// we should really do something here
// first we check if we are in the loop mode, if so,
// we update the potential broken id message so we loop count the same message
$changedData = false;
// exclusive block
if ($this->blockMutex()) {
$loopdata = $this->hasData() ? $this->getData() : array();
// check and initialize the array structure
$this->checkArrayStructure($loopdata, $folderid);
$current = $loopdata[self::$devid][self::$user][$folderid];
// we found our broken message!
if ($realBroken) {
$this->ignore_messageid = false;
$current['ignored'] = $messageid;
$changedData = true;
// check if this message was broken before - here we know that it still is and remove it from the tracking
$brokenkey = self::BROKENMSGS . "-" . $folderid;
if (isset($loopdata[self::$devid][self::$user][$brokenkey]) && isset($loopdata[self::$devid][self::$user][$brokenkey][$messageid])) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IgnoreNextMessage(): previously broken message '%s' is still broken and will not be tracked anymore", $messageid));
unset($loopdata[self::$devid][self::$user][$brokenkey][$messageid]);
}
} else {
// update potential id if looping on an item
if (isset($current['loopcount'])) {
$current['potential'] = $messageid;
// this message should be the broken one, but is not!!
// we should reset the loop count because this is certainly not the broken one
if ($potentialBroken) {
$current['loopcount'] = 1;
ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IgnoreNextMessage(): this should be the broken one, but is not! Resetting loop count.");
}
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IgnoreNextMessage(): Loop mode, potential broken message id '%s'", $current['potential']));
$changedData = true;
}
}
// update loop data
if ($changedData == true) {
$loopdata[self::$devid][self::$user][$folderid] = $current;
$ok = $this->setData($loopdata);
}
$this->releaseMutex();
}
// end exclusive block
if ($realBroken) {
ZPush::GetTopCollector()->AnnounceInformation("Broken message ignored", true);
}
return $realBroken;
}
示例9: sprintf
if ($ex instanceof AuthenticationRequiredException) {
ZPush::PrintZPushLegal($exclass, sprintf('<pre>%s</pre>', $ex->getMessage()));
// log the failed login attemt e.g. for fail2ban
if (defined('LOGAUTHFAIL') && LOGAUTHFAIL != false) {
ZLog::Write(LOGLEVEL_WARN, sprintf("IP: %s failed to authenticate user '%s'", Request::GetRemoteAddr(), Request::GetAuthUser() ? Request::GetAuthUser() : Request::GetGETUser()));
}
} else {
if ($ex instanceof WBXMLException) {
ZLog::Write(LOGLEVEL_FATAL, "Request could not be processed correctly due to a WBXMLException. Please report this.");
} else {
if (!$ex instanceof ZPushException || $ex->showLegalNotice()) {
$cmdinfo = Request::GetCommand() ? sprintf(" processing command <i>%s</i>", Request::GetCommand()) : "";
$extrace = $ex->getTrace();
$trace = !empty($extrace) ? "\n\nTrace:\n" . print_r($extrace, 1) : "";
ZPush::PrintZPushLegal($exclass . $cmdinfo, sprintf('<pre>%s</pre>', $ex->getMessage() . $trace));
}
}
}
// Announce exception to process loop detection
if (ZPush::GetDeviceManager(false)) {
ZPush::GetDeviceManager()->AnnounceProcessException($ex);
}
// Announce exception if the TopCollector if available
ZPush::GetTopCollector()->AnnounceInformation(get_class($ex), true);
}
// save device data if the DeviceManager is available
if (ZPush::GetDeviceManager(false)) {
ZPush::GetDeviceManager()->Save();
}
// end gracefully
ZLog::Write(LOGLEVEL_DEBUG, '-------- End');
示例10: DoAutodiscover
/**
* Does the complete autodiscover.
* @access public
* @throws AuthenticationRequiredException if login to the backend failed.
* @throws ZPushException if the incoming XML is invalid..
*
* @return void
*/
public function DoAutodiscover()
{
$response = "";
try {
$incomingXml = $this->getIncomingXml();
$backend = ZPush::GetBackend();
$username = $this->login($backend, $incomingXml);
$userDetails = $backend->GetUserDetails($username);
$email = $this->getAttribFromUserDetails($userDetails, 'emailaddress') ? $this->getAttribFromUserDetails($userDetails, 'emailaddress') : $incomingXml->Request->EMailAddress;
$userFullname = $this->getAttribFromUserDetails($userDetails, 'fullname') ? $this->getAttribFromUserDetails($userDetails, 'fullname') : $email;
ZLog::Write(LOGLEVEL_WBXML, sprintf("Resolved user's '%s' fullname to '%s'", $username, $userFullname));
// At the moment Z-Push only supports mobile response schema for autodiscover. Send empty response if the client request outlook response schema.
if ($incomingXml->Request->AcceptableResponseSchema == ZPushAutodiscover::ACCEPTABLERESPONSESCHEMAMOBILESYNC) {
$response = $this->createResponse($email, $userFullname);
setcookie("membername", $username);
}
} catch (AuthenticationRequiredException $ex) {
if (isset($incomingXml)) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to complete autodiscover because login failed for user with email '%s'", $incomingXml->Request->EMailAddress));
} else {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to complete autodiscover incorrect request: '%s'", $ex->getMessage()));
}
http_response_code(401);
header('WWW-Authenticate: Basic realm="ZPush"');
} catch (ZPushException $ex) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to complete autodiscover because of ZPushException. Error: %s", $ex->getMessage()));
if (!headers_sent()) {
header('HTTP/1.1 ' . $ex->getHTTPCodeString());
foreach ($ex->getHTTPHeaders() as $h) {
header($h);
}
}
}
$this->sendResponse($response);
}
示例11: Handle
/**
* Handles creates, updates or deletes of a folder
* issued by the commands FolderCreate, FolderUpdate and FolderDelete
*
* @param int $commandCode
*
* @access public
* @return boolean
*/
public function Handle($commandCode)
{
$el = self::$decoder->getElement();
if ($el[EN_TYPE] != EN_TYPE_STARTTAG) {
return false;
}
$create = $update = $delete = false;
if ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERCREATE) {
$create = true;
} else {
if ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) {
$update = true;
} else {
if ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) {
$delete = true;
}
}
}
if (!$create && !$update && !$delete) {
return false;
}
// SyncKey
if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) {
return false;
}
$synckey = self::$decoder->getElementContent();
if (!self::$decoder->getElementEndTag()) {
return false;
}
// ServerID
$serverid = false;
if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID)) {
$serverid = self::$decoder->getElementContent();
if (!self::$decoder->getElementEndTag()) {
return false;
}
}
// Parent
$parentid = false;
// when creating or updating more information is necessary
if (!$delete) {
if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_PARENTID)) {
$parentid = self::$decoder->getElementContent();
if (!self::$decoder->getElementEndTag()) {
return false;
}
}
// Displayname
if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_DISPLAYNAME)) {
return false;
}
$displayname = self::$decoder->getElementContent();
if (!self::$decoder->getElementEndTag()) {
return false;
}
// Type
$type = false;
if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_TYPE)) {
$type = self::$decoder->getElementContent();
if (!self::$decoder->getElementEndTag()) {
return false;
}
}
}
// endtag foldercreate, folderupdate, folderdelete
if (!self::$decoder->getElementEndTag()) {
return false;
}
$status = SYNC_FSSTATUS_SUCCESS;
// Get state of hierarchy
try {
$syncstate = self::$deviceManager->GetStateManager()->GetSyncState($synckey);
$newsynckey = self::$deviceManager->GetStateManager()->GetNewSyncKey($synckey);
// Over the ChangesWrapper the HierarchyCache is notified about all changes
$changesMem = self::$deviceManager->GetHierarchyChangesWrapper();
// the hierarchyCache should now fully be initialized - check for changes in the additional folders
$changesMem->Config(ZPush::GetAdditionalSyncFolders());
// there are unprocessed changes in the hierarchy, trigger resync
if ($changesMem->GetChangeCount() > 0) {
throw new StatusException("HandleFolderChange() can not proceed as there are unprocessed hierarchy changes", SYNC_FSSTATUS_SERVERERROR);
}
// any additional folders can not be modified!
if ($serverid !== false && ZPush::GetAdditionalSyncFolderStore($serverid)) {
throw new StatusException("HandleFolderChange() can not change additional folders which are configured", SYNC_FSSTATUS_SYSTEMFOLDER);
}
// switch user store if this this happens inside an additional folder
// if this is an additional folder the backend has to be setup correctly
if (!self::$backend->Setup(ZPush::GetAdditionalSyncFolderStore($parentid != false ? $parentid : $serverid))) {
throw new StatusException(sprintf("HandleFolderChange() could not Setup() the backend for folder id '%s'", $parentid != false ? $parentid : $serverid), SYNC_FSSTATUS_SERVERERROR);
}
} catch (StateNotFoundException $snfex) {
//.........这里部分代码省略.........
示例12: ImportMessageChange
/**
* Imports a single message
*
* @param array $props
* @param long $flags
* @param object $retmapimessage
*
* @access public
* @return long
*/
public function ImportMessageChange($props, $flags, &$retmapimessage)
{
$sourcekey = $props[PR_SOURCE_KEY];
$parentsourcekey = $props[PR_PARENT_SOURCE_KEY];
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, $parentsourcekey, $sourcekey);
if (!$entryid) {
return SYNC_E_IGNORE;
}
$mapimessage = mapi_msgstore_openentry($this->store, $entryid);
try {
$message = $this->mapiprovider->GetMessage($mapimessage, $this->contentparameters);
} catch (SyncObjectBrokenException $mbe) {
$brokenSO = $mbe->GetSyncObject();
if (!$brokenSO) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("PHPWrapper->ImportMessageChange(): Catched SyncObjectBrokenException but broken SyncObject available"));
} else {
if (!isset($brokenSO->id)) {
$brokenSO->id = "Unknown ID";
ZLog::Write(LOGLEVEL_ERROR, sprintf("PHPWrapper->ImportMessageChange(): Catched SyncObjectBrokenException but no ID of object set"));
}
ZPush::GetDeviceManager()->AnnounceIgnoredMessage(false, $brokenSO->id, $brokenSO);
}
// tell MAPI to ignore the message
return SYNC_E_IGNORE;
}
// substitute the MAPI SYNC_NEW_MESSAGE flag by a z-push proprietary flag
if ($flags == SYNC_NEW_MESSAGE) {
$message->flags = SYNC_NEWMESSAGE;
} else {
$message->flags = $flags;
}
$this->importer->ImportMessageChange(bin2hex($sourcekey), $message);
// Tell MAPI it doesn't need to do anything itself, as we've done all the work already.
return SYNC_E_IGNORE;
}
示例13: Handle
//.........这里部分代码省略.........
}
if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_ALLORNONE)) {
$cpo->BodyPreference($bptype)->SetAllOrNone(self::$decoder->getElementContent());
if (!self::$decoder->getElementEndTag()) {
return false;
}
}
if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_PREVIEW)) {
$cpo->BodyPreference($bptype)->SetPreview(self::$decoder->getElementContent());
if (!self::$decoder->getElementEndTag()) {
return false;
}
}
if (!self::$decoder->getElementEndTag()) {
return false;
}
}
$e = self::$decoder->peek();
if ($e[EN_TYPE] == EN_TYPE_ENDTAG) {
self::$decoder->getElementEndTag();
break;
}
}
}
if (!self::$decoder->getElementEndTag()) {
//store
return false;
}
if (!self::$decoder->getElementEndTag()) {
//search
return false;
}
// get SearchProvider
$searchprovider = ZPush::GetSearchProvider();
$status = SYNC_SEARCHSTATUS_SUCCESS;
$rows = array();
// TODO support other searches
if ($searchprovider->SupportsType($searchname)) {
$storestatus = SYNC_SEARCHSTATUS_STORE_SUCCESS;
try {
if ($searchname == ISearchProvider::SEARCH_GAL) {
//get search results from the searchprovider
$rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange);
} elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
$rows = $searchprovider->GetMailboxSearchResults($cpo);
}
} catch (StatusException $stex) {
$storestatus = $stex->getCode();
}
} else {
$rows = array('searchtotal' => 0);
$status = SYNC_SEARCHSTATUS_SERVERERROR;
ZLog::Write(LOGLEVEL_WARN, sprintf("Searchtype '%s' is not supported.", $searchname));
self::$topCollector->AnnounceInformation(sprintf("Unsupported type '%s''", $searchname), true);
}
$searchprovider->Disconnect();
self::$topCollector->AnnounceInformation(sprintf("'%s' search found %d results", $searchname, $rows['searchtotal']), true);
self::$encoder->startWBXML();
self::$encoder->startTag(SYNC_SEARCH_SEARCH);
self::$encoder->startTag(SYNC_SEARCH_STATUS);
self::$encoder->content($status);
self::$encoder->endTag();
if ($status == SYNC_SEARCHSTATUS_SUCCESS) {
self::$encoder->startTag(SYNC_SEARCH_RESPONSE);
self::$encoder->startTag(SYNC_SEARCH_STORE);
self::$encoder->startTag(SYNC_SEARCH_STATUS);
示例14: DoAutodiscover
/**
* Does the complete autodiscover.
* @access public
* @throws AuthenticationRequiredException if login to the backend failed.
* @throws ZPushException if the incoming XML is invalid..
*
* @return void
*/
public function DoAutodiscover()
{
if (!defined('REAL_BASE_PATH')) {
define('REAL_BASE_PATH', str_replace('autodiscover/', '', BASE_PATH));
}
set_include_path(get_include_path() . PATH_SEPARATOR . REAL_BASE_PATH);
$response = "";
try {
$incomingXml = $this->getIncomingXml();
$backend = ZPush::GetBackend();
$username = $this->login($backend, $incomingXml);
$userDetails = $backend->GetUserDetails($username);
$email = $this->getAttribFromUserDetails($userDetails, 'emailaddress') ? $this->getAttribFromUserDetails($userDetails, 'emailaddress') : $incomingXml->Request->EMailAddress;
$userFullname = $this->getAttribFromUserDetails($userDetails, 'fullname') ? $this->getAttribFromUserDetails($userDetails, 'fullname') : $email;
ZLog::Write(LOGLEVEL_WBXML, sprintf("Resolved user's '%s' fullname to '%s'", $username, $userFullname));
$response = $this->createResponse($email, $userFullname);
setcookie("membername", $username);
} catch (AuthenticationRequiredException $ex) {
if (isset($incomingXml)) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to complete autodiscover because login failed for user with email '%s'", $incomingXml->Request->EMailAddress));
} else {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to complete autodiscover incorrect request: '%s'", $ex->getMessage()));
}
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="ZPush"');
http_response_code(401);
} catch (ZPushException $ex) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to complete autodiscover because of ZPushException. Error: %s", $ex->getMessage()));
if (!headers_sent()) {
header('HTTP/1.1 ' . $ex->getHTTPCodeString());
foreach ($ex->getHTTPHeaders() as $h) {
header($h);
}
}
}
$this->sendResponse($response);
}
示例15: Handle
/**
* Handles the FolderSync command
*
* @param int $commandCode
*
* @access public
* @return boolean
*/
public function Handle($commandCode)
{
// Maps serverid -> clientid for items that are received from the PIM
$map = array();
// Parse input
if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC)) {
return false;
}
if (!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_SYNCKEY)) {
return false;
}
$synckey = self::$decoder->getElementContent();
if (!self::$decoder->getElementEndTag()) {
return false;
}
$status = SYNC_FSSTATUS_SUCCESS;
$newsynckey = $synckey;
try {
$syncstate = self::$deviceManager->GetStateManager()->GetSyncState($synckey);
// We will be saving the sync state under 'newsynckey'
$newsynckey = self::$deviceManager->GetStateManager()->GetNewSyncKey($synckey);
} catch (StateNotFoundException $snfex) {
$status = SYNC_FSSTATUS_SYNCKEYERROR;
} catch (StateInvalidException $sive) {
$status = SYNC_FSSTATUS_SYNCKEYERROR;
}
// The ChangesWrapper caches all imports in-memory, so we can send a change count
// before sending the actual data.
// the HierarchyCache is notified and the changes from the PIM are transmitted to the actual backend
$changesMem = self::$deviceManager->GetHierarchyChangesWrapper();
// the hierarchyCache should now fully be initialized - check for changes in the additional folders
$changesMem->Config(ZPush::GetAdditionalSyncFolders());
// process incoming changes
if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_CHANGES)) {
// Ignore <Count> if present
if (self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_COUNT)) {
self::$decoder->getElementContent();
if (!self::$decoder->getElementEndTag()) {
return false;
}
}
// Process the changes (either <Add>, <Modify>, or <Remove>)
$element = self::$decoder->getElement();
if ($element[EN_TYPE] != EN_TYPE_STARTTAG) {
return false;
}
$importer = false;
while (1) {
$folder = new SyncFolder();
if (!$folder->Decode(self::$decoder)) {
break;
}
try {
if ($status == SYNC_FSSTATUS_SUCCESS && !$importer) {
// Configure the backends importer with last state
$importer = self::$backend->GetImporter();
$importer->Config($syncstate);
// the messages from the PIM will be forwarded to the backend
$changesMem->forwardImporter($importer);
}
if ($status == SYNC_FSSTATUS_SUCCESS) {
switch ($element[EN_TAG]) {
case SYNC_ADD:
case SYNC_MODIFY:
$serverid = $changesMem->ImportFolderChange($folder);
break;
case SYNC_REMOVE:
$serverid = $changesMem->ImportFolderDeletion($folder);
break;
}
// TODO what does $map??
if ($serverid) {
$map[$serverid] = $folder->clientid;
}
} else {
ZLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): ignoring incoming folderchange for folder '%s' as status indicates problem.", $folder->displayname));
self::$topCollector->AnnounceInformation("Incoming change ignored", true);
}
} catch (StatusException $stex) {
$status = $stex->getCode();
}
}
if (!self::$decoder->getElementEndTag()) {
return false;
}
} else {
// check for a potential process loop like described in Issue ZP-5
if ($synckey != "0" && self::$deviceManager->IsHierarchyFullResyncRequired()) {
$status = SYNC_FSSTATUS_SYNCKEYERROR;
}
self::$deviceManager->AnnounceProcessStatus(false, $status);
}
//.........这里部分代码省略.........