本文整理汇总了PHP中CApi::Log方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::Log方法的具体用法?PHP CApi::Log怎么用?PHP CApi::Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: request
public function request($method, $url = '', $body = null, $headers = array())
{
$headers['user-agent'] = Constants::DAV_USER_AGENT;
$sLog = "REQUEST: " . $method;
if ($url != '') {
$sLog = $sLog . " " . $url;
}
if ($body != null) {
$sLog = $sLog . "\r\nBody:\r\n" . $body;
}
\CApi::Log($sLog, \ELogLevel::Full, 'dav-');
\CApi::LogObject($headers, \ELogLevel::Full, 'dav-');
$response = array();
try {
$response = parent::request($method, $url, $body, $headers);
} catch (\Sabre\DAV\Exception $ex) {
\CApi::LogObject($ex->getMessage(), \ELogLevel::Full, 'dav-');
throw $ex;
}
$sLog = "RESPONSE: " . $method;
if (!empty($response['body'])) {
$sLog = $sLog . "\r\nBody:\r\n" . $response['body'];
}
\CApi::Log($sLog, \ELogLevel::Full, 'dav-');
if (!empty($response['headers'])) {
\CApi::LogObject($response['headers'], \ELogLevel::Full, 'dav-');
}
return $response;
}
示例2: ChangePasswordProcess
/**
* @param CAccount $oAccount
*/
public function ChangePasswordProcess($oAccount)
{
if (0 < strlen($oAccount->PreviousMailPassword) && $oAccount->PreviousMailPassword !== $oAccount->IncomingMailPassword) {
$cpanel_hostname = CApi::GetConf('plugins.cpanel-change-password.config.hostname', 'localhost');
$cpanel_username = CApi::GetConf('plugins.cpanel-change-password.config.username', 'local');
$cpanel_password = CApi::GetConf('plugins.cpanel-change-password.config.password', '');
$email_user = urlencode($oAccount->Email);
$email_password = urlencode($oAccount->IncomingMailPassword);
$email_domain = urlencode($oAccount->Domain->Name);
$query = "https://" . $cpanel_hostname . ":2083/execute/Email/passwd_pop?email=" . $email_user . "&password=" . $email_password . "&domain=" . $email_domain;
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$header[0] = "Authorization: Basic " . base64_encode($cpanel_username . ":" . $cpanel_password) . "\n\r";
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_URL, $query);
$result = curl_exec($curl);
if ($result == false) {
CApi::Log("curl_exec threw error \"" . curl_error($curl) . "\" for {$query}");
curl_close($curl);
throw new CApiManagerException(Errs::UserManager_AccountNewPasswordUpdateError);
} else {
curl_close($curl);
$json_res = json_decode($result);
if (!$json_res->status) {
throw new CApiManagerException(Errs::UserManager_AccountNewPasswordUpdateError);
}
}
}
}
示例3: Init
public static function Init($oTenant = null)
{
parent::Init($oTenant);
$bResult = false;
$oUser = null;
$oClient = self::CreateClient($oTenant);
if ($oClient) {
if ($success = $oClient->Initialize()) {
if ($success = $oClient->Process()) {
if (strlen($oClient->access_token)) {
$success = $oClient->CallAPI('https://api.twitter.com/1.1/account/verify_credentials.json', 'GET', array(), array('FailOnAccessError' => true), $oUser);
}
}
$success = $oClient->Finalize($success);
}
if ($oClient->exit) {
$bResult = false;
exit;
}
if ($success && $oUser) {
// if you need re-ask user for permission
//$oClient->ResetAccessToken();
$aSocial = array('type' => self::$ConnectorName, 'id' => $oUser->id, 'name' => $oUser->name, 'email' => isset($oUser->email) ? $oUser->email : '', 'access_token' => $oClient->access_token, 'scopes' => self::$Scopes);
\CApi::Log('social_user_' . self::$ConnectorName);
\CApi::LogObject($oUser);
$bResult = $aSocial;
} else {
$bResult = false;
$oClient->ResetAccessToken();
self::_socialError($oClient->error, self::$ConnectorName);
}
}
return $bResult;
}
示例4: beforeMethod
/**
* This method is called before any HTTP method, but after authentication.
*
* @param string $sMethod
* @param string $path
* @throws \Sabre\DAV\Exception\NotAuthenticated
* @return bool
*/
public function beforeMethod($sMethod, $path)
{
$aHeaders = $this->server->httpRequest->getHeaders();
\CApi::Log($sMethod . ' ' . $path, \ELogLevel::Full, 'sabredav-');
\CApi::LogObject($aHeaders, \ELogLevel::Full, 'sabredav-');
$bLogBody = (bool) \CApi::GetConf('labs.dav.log-body', false);
if ($bLogBody) {
$body = $this->server->httpRequest->getBodyAsString();
$this->server->httpRequest->setBody($body);
\CApi::LogObject($body, \ELogLevel::Full, 'sabredav-');
}
\CApi::Log('', \ELogLevel::Full, 'sabredav-');
return;
}
示例5: Init
public static function Init($oTenant = null)
{
parent::Init($oTenant);
$bResult = false;
$oUser = null;
$oClient = self::CreateClient($oTenant);
if ($oClient) {
if ($success = $oClient->Initialize()) {
if ($success = $oClient->Process()) {
if (strlen($oClient->access_token)) {
$success = $oClient->CallAPI('https://www.googleapis.com/oauth2/v1/userinfo', 'GET', array(), array('FailOnAccessError' => true), $oUser);
} else {
$oClient->error = $oClient->authorization_error;
$success = false;
}
}
$success = $oClient->Finalize($success);
}
if ($oClient->exit) {
$bResult = false;
exit;
}
if ($success && $oUser) {
// if you need re-ask user for permission
$oClient->ResetAccessToken();
$iExpiresIn = 3600;
$dAccessTokenExpiry = new DateTime($oClient->access_token_expiry);
$aAccessToken = json_encode(array('access_token' => $oClient->access_token, 'created' => $dAccessTokenExpiry->getTimestamp() - $iExpiresIn, 'expires_in' => $iExpiresIn));
$aSocial = array('type' => self::$ConnectorName, 'id' => $oUser->id, 'name' => $oUser->name, 'email' => isset($oUser->email) ? $oUser->email : '', 'access_token' => $aAccessToken, 'refresh_token' => $oClient->refresh_token, 'scopes' => self::$Scopes);
\CApi::Log('social_user_' . self::$ConnectorName);
\CApi::LogObject($oUser);
$bResult = $aSocial;
} else {
$bResult = false;
$oClient->ResetAccessToken();
self::_socialError($oClient->error, self::$ConnectorName);
}
}
return $bResult;
}
示例6: Handle
/**
* @return void
*/
public function Handle()
{
$sVersion = file_get_contents(PSEVEN_APP_ROOT_PATH . 'VERSION');
define('PSEVEN_APP_VERSION', $sVersion);
if (!class_exists('MailSo\\Version')) {
echo 'MailSo';
return '';
} else {
if (!class_exists('\\CApi') || !\CApi::IsValid()) {
echo 'AfterLogic API';
return '';
}
}
$sPathInfo = \trim(\trim($this->oHttp->GetServer('PATH_INFO', '')), ' /');
if (!empty($sPathInfo)) {
if ('dav' === \substr($sPathInfo, 0, 3)) {
$this->oActions->PathInfoDav();
return '';
}
}
/* @var $oApiIntegrator \CApiIntegratorManager */
$oApiIntegrator = \CApi::Manager('integrator');
// ------ Redirect to HTTPS
$oSettings =& \CApi::GetSettings();
$bRedirectToHttps = $oSettings->GetConf('Common/RedirectToHttps');
$bHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== "off" || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == "443";
if ($bRedirectToHttps && !$bHttps) {
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
// ------
/* @var $oApiCapability \CApiCapabilityManager */
$oApiCapability = \CApi::Manager('capability');
$sResult = '';
$sQuery = \trim(\trim($this->oHttp->GetServer('QUERY_STRING', '')), ' /');
\CApi::Plugin()->RunQueryHandle($sQuery);
$iPos = \strpos($sQuery, '&');
if (0 < $iPos) {
$sQuery = \substr($sQuery, 0, $iPos);
}
$aPaths = explode('/', $sQuery);
if (0 < count($aPaths) && !empty($aPaths[0])) {
$sFirstPart = strtolower($aPaths[0]);
if ('ping' === $sFirstPart) {
@header('Content-Type: text/plain; charset=utf-8');
$sResult = 'Pong';
} else {
if ('pull' === $sFirstPart) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
pclose(popen("start /B git pull", "r"));
} else {
exec("git pull > /dev/null 2>&1 &");
}
\CApi::Location('./');
} else {
if ('ajax' === $sFirstPart) {
@ob_start();
$aResponseItem = null;
$sAction = $this->oHttp->GetPost('Action', null);
try {
\CApi::Log('AJAX: Action: ' . $sAction);
if ('SystemGetAppData' !== $sAction && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !$this->validateToken()) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidToken);
} else {
if (!empty($sAction)) {
$sMethodName = 'Ajax' . $sAction;
$this->oActions->SetActionParams($this->oHttp->GetPostAsArray());
if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) {
$aResponseItem = call_user_func(array($this->oActions, $sMethodName));
}
if (\CApi::Plugin()->JsonHookExists($sMethodName)) {
$aResponseItem = \CApi::Plugin()->RunJsonHook($this->oActions, $sMethodName, $aResponseItem);
}
}
}
if (!is_array($aResponseItem)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError);
}
} catch (\Exception $oException) {
//if ($oException instanceof \ProjectCore\Exceptions\ClientException &&
// \ProjectCore\Notifications::AuthError === $oException->getCode())
//{
// $oApiIntegrator = /* @var $oApiIntegrator \CApiIntegratorManager */ \CApi::Manager('integrator');
// $oApiIntegrator->setLastErrorCode(\ProjectCore\Notifications::AuthError);
// $oApiIntegrator->logoutAccount();
//}
\CApi::LogException($oException);
$sAction = empty($sAction) ? 'Unknown' : $sAction;
$aAdditionalParams = null;
if ($oException instanceof \ProjectCore\Exceptions\ClientException) {
$aAdditionalParams = $oException->GetObjectParams();
}
$aResponseItem = $this->oActions->ExceptionResponse(null, $sAction, $oException, $aAdditionalParams);
}
@header('Content-Type: application/json; charset=utf-8');
\CApi::Plugin()->RunHook('ajax.response-result', array($sAction, &$aResponseItem));
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger());
// \CApi::Log('AJAX: Response: '.$sResult);
//.........这里部分代码省略.........
示例7: GetSuggestContactItems
/**
* @param int $iUserId
* @param string $sSearch
* @param int $iRequestLimit
* @return bool|array
*/
public function GetSuggestContactItems($iUserId, $sSearch, $iRequestLimit)
{
$aResult = array();
$this->init($iUserId);
$sDefaultAB = \afterlogic\DAV\Constants::ADDRESSBOOK_DEFAULT_NAME;
$sCollectedAB = \afterlogic\DAV\Constants::ADDRESSBOOK_COLLECTED_NAME;
$aCollectedContactItems = $this->Dav->GetVcards($this->AddressBookHomeSet . $sCollectedAB);
$aDefaultContactItems = $this->Dav->GetVcards($this->AddressBookHomeSet . $sDefaultAB);
$aContactItems = array_merge($aDefaultContactItems, $aCollectedContactItems);
foreach ($aContactItems as $oItem) {
$sItemId = $oItem['href'];
$vCard = null;
try {
$vCard = \Sabre\VObject\Reader::read($oItem['data']);
} catch (Exception $ex) {
CApi::Log('SABREDAV: Invalid VCard with Id=' . $sItemId);
}
if (isset($vCard)) {
$oContactItem = new CContactListItem();
$oContactItem->InitBySabreCardDAVCard($vCard);
if (empty($sSearch) || stripos($oContactItem->Name, $sSearch) !== false || stripos($oContactItem->Email, $sSearch) !== false) {
$aResult[] = $oContactItem;
}
unset($oContactItem);
}
unset($vCard);
}
$this->sortItems($aResult, EContactSortField::Frequency, ESortOrder::ASC);
return array_slice($aResult, 0, $iRequestLimit);
}
示例8: InitAjaxAction
/**
* @return void
*/
public function InitAjaxAction($sPostName, $sTab, &$sMessage, &$sError, &$sRef)
{
if ($this->oTableAjaxAction && $this->IsInTab($sTab)) {
$sQueryAction = CPost::Get('QueryAction', '');
$sAjaxActionFunction = ucfirst($sTab) . ucfirst($sQueryAction) . (empty($sPostName) ? '' : '_' . $sPostName);
if (method_exists($this->oTableAjaxAction, $sAjaxActionFunction)) {
CApi::Log('call ' . get_class($this) . '->TableAjaxAction->' . $sAjaxActionFunction . '()');
$this->oTableAjaxAction->{$sAjaxActionFunction}();
if (!empty($this->oTableAjaxAction->LastError)) {
$sError = $this->oTableAjaxAction->LastError;
} else {
if (!empty($this->oTableAjaxAction->LastMessage)) {
$sMessage = $this->oTableAjaxAction->LastMessage;
}
}
if (!empty($this->oTableAjaxAction->Ref)) {
$sRef = $this->oTableAjaxAction->Ref;
}
if (!empty($sError)) {
CApi::Log('function ' . $sAjaxActionFunction . '() return $sError = ' . $sError, ELogLevel::Error);
}
}
}
}
示例9: Disconnect
/**
* @return bool
*/
public function Disconnect()
{
$result = false;
if ($this->oPDO != null) {
if (is_resource($this->rResultId)) {
$this->rResultId->closeCursor();
}
$this->rResultId = null;
if (CApi::$bUseDbLog) {
CApi::Log('DB : disconnect from ' . $this->sUser . '@' . $this->sHost);
}
unset($this->oPDO);
$this->oPDO = null;
$result = true;
}
return $result;
}
示例10: DbInsertArrays
/**
* @param object $oObject
* @param object $oHelper
* @return array
*/
public static function DbInsertArrays($oObject, $oHelper)
{
$aResult = array(false, false);
$sQueryParams = '';
$bUseLogQueryParams = (bool) CApi::GetConf('labs.db.log-query-params', false);
$oObject->initBeforeChange();
$aStaticMap = $oObject->getMap();
$aMap = api_AContainer::DbWriteKeys($aStaticMap, true);
$aDbKeys = array_keys($aMap);
$aResult[0] = array_map(array(&$oHelper, 'EscapeColumn'), $aDbKeys);
$aDbValues = array_values($aMap);
foreach ($aDbValues as $iIndex => $sKey) {
$mValue = $oObject->{$sKey};
if (isset($aStaticMap[$sKey][0])) {
if ('password' === $aStaticMap[$sKey][0]) {
$mValue = api_Utils::EncodePassword($mValue);
} else {
if ('datetime' === $aStaticMap[$sKey][0]) {
$mValue = $oHelper->TimeStampToDateFormat($mValue);
} else {
if ('serialize' === $aStaticMap[$sKey][0]) {
$mValue = '' === $mValue ? '' : serialize($mValue);
}
}
}
}
$aDbValues[$iIndex] = is_string($mValue) ? $oHelper->EscapeString($mValue) : (int) $mValue;
if ($bUseLogQueryParams) {
$sDbKey = isset($aDbKeys[$iIndex]) ? $aDbKeys[$iIndex] : '!unknown!';
$sQueryParams .= API_CRLF . API_TAB . $sDbKey . ' = ' . $aDbValues[$iIndex];
}
}
$aResult[1] = $aDbValues;
if ($bUseLogQueryParams) {
CApi::Log($sQueryParams);
}
return $aResult;
}
示例11: Modify
/**
* @return bool
*/
public function Modify($sModifyDn, $aModifyEntry)
{
$bResult = false;
if (!empty($sModifyDn)) {
if (!empty($this->sSearchDN)) {
$sModifyDn = $sModifyDn . ',' . $this->sSearchDN;
}
CApi::Log('ldap_modify = ' . $sModifyDn);
CApi::LogObject($aModifyEntry);
$bResult = !!@ldap_modify($this->rLink, $sModifyDn, $aModifyEntry);
$this->validateLdapErrorOnFalse($bResult);
}
return $bResult;
}
示例12: WriteLine
/**
* @param string $sLine
* @return bool
*/
public function WriteLine($sLine, $aHideValues = array())
{
$sLine = $sLine . "\r\n";
$sLogLine = 0 < count($aHideValues) ? str_replace($aHideValues, '*******', $sLine) : $sLine;
CApi::Log('NET > ' . api_Utils::ShowCRLF($sLogLine));
if (!@fputs($this->rConnect, $sLine)) {
CApi::Log('NET[Error] < Could not send user request', ELogLevel::Error);
return false;
}
return true;
}
示例13: LogEnd
public static function LogEnd()
{
CApi::Log('# script shutdown');
}
示例14: ClearAllContactsAndGroups
/**
* @param CAccount $oAccount
* @return bool
*/
public function ClearAllContactsAndGroups($oAccount)
{
$bResult = false;
$this->InitByAccount($oAccount);
$oAddressBooks = new \Sabre\CardDAV\UserAddressBooks(\afterlogic\DAV\Backend::Carddav(), $this->Principal);
foreach ($oAddressBooks->getChildren() as $oAddressBook) {
if ($oAddressBook && $oAddressBook instanceof \Sabre\CardDAV\AddressBook) {
try {
$oAddressBook->delete();
$bResult = true;
} catch (Exception $ex) {
CApi::Log($ex->getTraceAsString());
$bResult = false;
}
}
}
return $bResult;
}
示例15: initAjaxActionModules
/**
* @param string $sTab
* @return void
*/
protected function initAjaxActionModules($sTab)
{
$sError = '';
$sMessage = '';
$sRef = '';
if ($this->IsAuth()) {
if (!$this->IsOnlyReadAuthType()) {
try {
foreach ($this->aModules as $oModule) {
if ($oModule->IsInTab($sTab)) {
$oModule->InitAjaxAction('Pre', $sTab, $sMessage, $sError, $sRef);
}
}
if (empty($sError)) {
foreach ($this->aModules as $oModule) {
if ($oModule->IsInTab($sTab)) {
$oModule->InitAjaxAction('', $sTab, $sMessage, $sError, $sRef);
}
}
}
if (empty($sError)) {
foreach ($this->aModules as $oModule) {
if ($oModule->IsInTab($sTab)) {
$oModule->InitAjaxAction('Post', $sTab, $sMessage, $sError, $sRef);
}
}
}
} catch (Exception $oException) {
if (empty($sError)) {
$sError = $oException->getMessage();
}
}
} else {
$sError = AP_LANG_ADMIN_ONLY_READ;
}
} else {
$sError = AP_LANG_LOGIN_ACCESS_ERROR;
}
$sOb = @ob_get_contents();
@ob_clean();
if (0 < strlen($sOb)) {
CApi::Log(AP_CRLF . $sOb, ELogLevel::Error);
if (!empty($sError)) {
$sError = 'Json parse error';
}
}
$sAjaxResult = '{ "null": "null"';
if (!empty($sError)) {
$sAjaxResult .= ', "error": "' . ap_Utils::ReBuildStringToJavaScript($sError, '"') . '"';
} else {
if (!empty($sMessage)) {
$sAjaxResult .= ', "message": "' . ap_Utils::ReBuildStringToJavaScript($sMessage, '"') . '"';
}
}
if (!empty($sRef)) {
$sAjaxResult .= ', "ref": "' . ap_Utils::ReBuildStringToJavaScript($sRef, '"') . '"';
if (!empty($sError)) {
$this->ShowError($sError);
} else {
if (!empty($sMessage)) {
$this->ShowMessage($sMessage);
}
}
}
$sAjaxResult .= ' }';
echo $sAjaxResult;
CApi::Log('AJAX: ' . $sAjaxResult);
}