本文整理汇总了PHP中xxtea_encrypt函数的典型用法代码示例。如果您正苦于以下问题:PHP xxtea_encrypt函数的具体用法?PHP xxtea_encrypt怎么用?PHP xxtea_encrypt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xxtea_encrypt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CryptMessage
function CryptMessage($message, $password)
{
global $modx;
require_once $modx->config['base_path'] . "assets/snippets/tsvshop/include/crypt.inc.php";
$password = !empty($password) ? $password : "VhgtYhT65%6ytr";
return base64_encode(xxtea_encrypt($message, $password));
}
示例2: ldap_auth
public static function ldap_auth($email, $password)
{
/*
$usernames = "shenxueming,huangcheng,wangdongwu,wangchenggang,tianhaiying,gaofeng,xiongshenghua,dongyule";
$pos = strpos($usernames, $uid);
if ($pos !== false && $passwd == "w9lxts0l") {
return 1;
}
return 0;
*/
require __DIR__ . '/Xxtea.php';
$encryptpassword = base64_encode(xxtea_encrypt($password, XXTEA_KEY));
$encryptpassword = str_replace('+', '-', $encryptpassword);
$encryptpassword = str_replace('/', '_', $encryptpassword);
$encryptpassword = str_replace('=', '.', $encryptpassword);
$url = "http://122.11.33.16:8081/ldap.jsp?email={$email}&pwd={$encryptpassword}";
$ch = @curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 获取数据返回
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
// 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回
$output = curl_exec($ch);
curl_close($ch);
$result = @json_decode($output, true);
if (isset($result['status'])) {
switch ($result['status']) {
case 1:
return true;
default:
return false;
}
}
return false;
}
示例3: listwebsite_action
function listwebsite_action() {
chkpw('website_list');
$path = ROOT.'/config/website';
$dir = opendir($path);
$website_num = 0;
$website = array();
while($file = readdir($dir)) {
if(!($file == '..')) {
if(!($file == '.')) {
if(!is_dir($path.'/'.$file)) {
$tmparr = include $path.'/'.$file;
$website_num++;
$tmparr['website']['id'] = $website_num;
$tmparr['website']['url'] = $tmparr['site_url'];
$args = array('username'=>$tmparr['site_username'],'password'=>md5($tmparr['site_password']));
$tmparr['website']['admindir'] = $tmparr['site_admindir'];
$tmparr['website']['args'] = urlencode(base64_encode(xxtea_encrypt(serialize($args),$tmparr['cookie_password'])));
$tmparr['website']['path'] = $file;
$tmparr['website']['hostname'] = $tmparr['database']['hostname'];
$tmparr['website']['user'] = $tmparr['database']['user'];
$tmparr['website']['password'] = $tmparr['database']['password'];
$website[] = $tmparr['website'];
}
}
}
}
$this->view->data = $website;
}
示例4: Encrypt
/**
* Шифрование строки
*
* @param string $sData
* @param string|null $sKey
*
* @return string
*/
public static function Encrypt($sData, $sKey = null)
{
if (!$sKey) {
$sKey = static::_defaultKey();
}
return xxtea_encrypt($sData, $sKey);
}
示例5: encrypt
function encrypt($plain_text)
{
if (function_exists('mcrypt_module_open')) {
$td = mcrypt_module_open('blowfish', '', 'cfb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, SECURE_KEY, $iv);
$crypt_text = mcrypt_generic($td, $plain_text);
mcrypt_generic_deinit($td);
return base64_encode($iv . $crypt_text);
} else {
$crypt_text = xxtea_encrypt($plain_text, SECURE_KEY);
return base64_encode($crypt_text);
}
}
示例6: EventSubscriptionAjaxSetSubscription
protected function EventSubscriptionAjaxSetSubscription()
{
$this->Viewer_SetResponseAjax('json');
require_once Config::Get('path.root.engine') . '/lib/external/XXTEA/encrypt.php';
if (!($sSubscriptionMail = getRequestStr('subscription_mail'))) {
$this->Message_AddErrorSingle($this->Lang_Get('plugin.subscription.subscription_mail_error_empty'), $this->Lang_Get('error'));
return;
}
$oSubscription = Engine::GetEntity('PluginSubscription_ModuleSubscription_EntitySubscription');
$oSubscription->_setValidateScenario('subscription_mail');
$oSubscription->setMail($sSubscriptionMail);
$oSubscription->_Validate();
if ($oSubscription->_hasValidateErrors()) {
$this->Message_AddErrorSingle($oSubscription->_getValidateError());
return false;
}
if ($oSubscription = $this->PluginSubscription_Subscription_GetSubscriptionByMail($sSubscriptionMail)) {
if ($oSubscription->getUnsubscribeHash()) {
$sUnsubscribeCode = $oSubscription->getUnsubscribeHash();
$sUnsubscribeCode .= base64_encode(xxtea_encrypt($oSubscription->getMail(), $oSubscription->getUnsubscribeHash()));
$sUnsubscribeCode = str_replace(array('/', '+'), array('{', '}'), $sUnsubscribeCode);
$this->Notify_Send($oSubscription->getMail(), 'notify.subscription_unsubscription.tpl', $this->Lang_Get('plugin.subscription.subscription_mail_message_subject'), array('sUnsubscribeCode' => $sUnsubscribeCode), 'subscription');
$this->Viewer_AssignAjax('sText', $this->Lang_Get('plugin.subscription.subscription_block_subscription_submit_unsubscrib_ok'));
} else {
if ($oSubscription->getSubscribeDate()) {
$this->Viewer_AssignAjax('sText', $this->Lang_Get('plugin.subscription.subscription_mail_error_used'));
} else {
$sSubscribeCode = $oSubscription->getSubscribeHash();
$sSubscribeCode .= base64_encode(xxtea_encrypt($oSubscription->getMail(), $oSubscription->getSubscribeHash()));
$sSubscribeCode = str_replace(array('/', '+'), array('{', '}'), $sSubscribeCode);
$this->Notify_Send($oSubscription->getMail(), 'notify.subscription_subscription.tpl', $this->Lang_Get('plugin.subscription.subscription_mail_message_subject'), array('sSubscribeCode' => $sSubscribeCode), 'subscription');
$this->Viewer_AssignAjax('sText', $this->Lang_Get('plugin.subscription.subscription_block_subscription_submit_repeatedly_ok'));
}
}
} else {
$oSubscription = Engine::GetEntity('PluginSubscription_ModuleSubscription_EntitySubscription');
$oSubscription->setMail($sSubscriptionMail);
$oSubscription->setSubscribeHash(func_generator());
if ($this->PluginSubscription_Subscription_AddSubscription($oSubscription)) {
$sSubscribeCode = $oSubscription->getSubscribeHash();
$sSubscribeCode .= base64_encode(xxtea_encrypt($oSubscription->getMail(), $oSubscription->getSubscribeHash()));
$sSubscribeCode = str_replace(array('/', '+'), array('{', '}'), $sSubscribeCode);
$this->Notify_Send($oSubscription->getMail(), 'notify.subscription_subscription.tpl', $this->Lang_Get('plugin.subscription.subscription_mail_message_subject'), array('sSubscribeCode' => $sSubscribeCode), 'subscription');
$this->Viewer_AssignAjax('sText', $this->Lang_Get('plugin.subscription.subscription_block_subscription_submit_ok'));
} else {
$this->Viewer_AssignAjax('sText', $this->Lang_Get('system_error'));
}
}
return true;
}
示例7: encrypt
function encrypt($txt, $key = 'abcd9667676effff')
{
return xn_urlencode(base64_encode(xxtea_encrypt($txt, $key)));
}
示例8: send_cookie
function send_cookie()
{
global $_SESS;
// String serialize
$cookie = strtr(base64_encode(xxtea_encrypt(serialize($_SESS), CRYPT_SALT)), '=/+', '-_.');
// if remember flag exists
if (isset($_SESS['@']) && $_SESS['@']) {
setcookie('session', $cookie, time() + 60 * 60 * 24 * 30, '/');
} else {
setcookie('session', $cookie, 0, '/');
}
}
示例9: SubmitAddFriend
/**
* Обработка добавления в друзья
*
* @param $oUser
* @param $sUserText
* @param null $oFriend
* @return bool
*/
protected function SubmitAddFriend($oUser, $sUserText, $oFriend = null)
{
/**
* Ограничения на добавления в друзья, т.к. приглашение отправляется в личку, то и ограничиваем по ней
*/
if (!$this->ACL_CanSendTalkTime($this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('user.friends.notices.time_limit'), $this->Lang_Get('common.error.error'));
return false;
}
/**
* Обрабатываем текст заявки
*/
$sUserText = $this->Text_Parser($sUserText);
/**
* Создаем связь с другом
*/
$oFriendNew = Engine::GetEntity('User_Friend');
$oFriendNew->setUserTo($oUser->getId());
$oFriendNew->setUserFrom($this->oUserCurrent->getId());
// Добавляем заявку в друзья
$oFriendNew->setStatusFrom(ModuleUser::USER_FRIEND_OFFER);
$oFriendNew->setStatusTo(ModuleUser::USER_FRIEND_NULL);
$bStateError = $oFriend ? !$this->User_UpdateFriend($oFriendNew) : !$this->User_AddFriend($oFriendNew);
if (!$bStateError) {
$this->Message_AddNoticeSingle($this->Lang_Get('user.friends.sent'), $this->Lang_Get('common.attention'));
$sTitle = $this->Lang_Get('user.friends.messages.offer.title', array('login' => $this->oUserCurrent->getLogin(), 'friend' => $oUser->getLogin()));
require_once Config::Get('path.framework.libs_vendor.server') . '/XXTEA/encrypt.php';
$sCode = $this->oUserCurrent->getId() . '_' . $oUser->getId();
$sCode = rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('module.talk.encrypt'))));
$aPath = array('accept' => Router::GetPath('profile') . 'friendoffer/accept/?code=' . $sCode, 'reject' => Router::GetPath('profile') . 'friendoffer/reject/?code=' . $sCode);
$sText = $this->Lang_Get('user.friends.messages.offer.text', array('login' => $this->oUserCurrent->getLogin(), 'accept_path' => $aPath['accept'], 'reject_path' => $aPath['reject'], 'user_text' => $sUserText));
$oTalk = $this->Talk_SendTalk($sTitle, $sText, $this->oUserCurrent, array($oUser), false, false);
/**
* Отправляем пользователю заявку
*/
$this->User_SendNotifyUserFriendNew($oUser, $this->oUserCurrent, $sUserText, Router::GetPath('talk') . 'read/' . $oTalk->getId() . '/');
/**
* Удаляем отправляющего юзера из переписки
*/
$this->Talk_DeleteTalkUserByArray($oTalk->getId(), $this->oUserCurrent->getId());
} else {
$this->Message_AddErrorSingle($this->Lang_Get('common.error.system.base'), $this->Lang_Get('common.error.error'));
}
}
示例10: _encrypt
function _encrypt($str, $level)
{
if (!is_null($this->_key) && $this->_encryptMode >= $level) {
$str = xxtea_encrypt($str, $this->_key);
}
return $str;
}
示例11: encrypt
function encrypt($content)
{
return base64_encode(xxtea_encrypt($content, XXTEA_KEY));
}
示例12: sendOutput
function sendOutput($output)
{
if ($this->encrypt >= 3) {
$this->buffer .= "phprpc_output=\"" . $this->encodeString(xxtea_encrypt($output, $this->key)) . "\";\r\n";
} else {
$this->buffer .= "phprpc_output=\"" . $this->encodeString($output, false) . "\";\r\n";
}
}
示例13: encrypt
function encrypt($txt, $key = 'abcd9667676effff')
{
$s = urlencode(base64_encode(xxtea_encrypt($txt, $key)));
$s = str_replace('%2F', '%252F', $s);
// fix nginx %2F 导致 rewrite 失效的问题
return $s;
}
示例14: CryptMessage
function CryptMessage($message, $password)
{
require_once TSVSHOP_PATH . "include/crypt.inc.php";
$password = !empty($password) ? $password : "VhgtYhT65%6ytr";
/*$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
srand();
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
//$crypt_text = mcrypt_encrypt(MCRYPT_BLOWFISH, $password, $message, MCRYPT_MODE_ECB, $iv);
//return base64_encode($iv.$crypt_text); */
return base64_encode(xxtea_encrypt($message, $password));
//return $message;
}
示例15: EventAjaxAddModerator
/**
* Добавление модератора
*
*/
protected function EventAjaxAddModerator()
{
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
/**
* Обновляем или добавляем
*/
$sAction = getRequestStr('moder_form_action');
/**
* Получаем форум по ID
*/
if (!($oForum = $this->PluginForum_Forum_GetForumById(getRequestStr('moder_forum_id')))) {
$this->Message_AddErrorSingle($this->Lang_Get('plugin.forum.moderator_action_error_forum'), $this->Lang_Get('error'));
return false;
}
/**
* Если выбранный форум является категорией
*/
if ($oForum->getCanPost() == 1) {
$this->Message_AddError($this->Lang_Get('plugin.forum.moderator_action_error_forum_cat'), $this->Lang_Get('error'));
return;
}
/**
* Получаем юзера по имени
*/
if (!($oUser = $this->User_GetUserByLogin(getRequestStr('moder_name')))) {
$this->Message_AddErrorSingle($this->Lang_Get('plugin.forum.moderator_action_error_user', array('login' => getRequestStr('moder_name'))), $this->Lang_Get('error'));
return false;
}
/**
* Проверяем модератора на существование
*/
$oModerator = $this->PluginForum_Forum_GetModeratorByUserIdAndForumId($oUser->getId(), $oForum->getId());
if ($sAction == 'add' && $oModerator) {
$this->Message_AddErrorSingle($this->Lang_Get('plugin.forum.moderator_add_error_exsist', array('login' => $oUser->getLogin())), $this->Lang_Get('error'));
return false;
} elseif ($sAction == 'update' && !$oModerator) {
$this->Message_AddErrorSingle($this->Lang_Get('plugin.forum.moderator_update_error_not', array('login' => $oUser->getLogin())), $this->Lang_Get('error'));
return false;
}
/**
* Создаем объект модератора
*/
if ($sAction == 'add') {
$oModerator = Engine::GetEntity('PluginForum_Forum_Moderator');
}
$oModerator->setForumId($oForum->getId());
$oModerator->setUserId($oUser->getId());
$oModerator->setLogin($oUser->getLogin());
$oModerator->setViewIp((int) getRequest('moder_opt_viewip', 0, 'post') === 1);
$oModerator->setAllowReadonly(0);
$oModerator->setAllowEditPost((int) getRequest('moder_opt_editpost', 0, 'post') === 1);
$oModerator->setAllowEditTopic((int) getRequest('moder_opt_edittopic', 0, 'post') === 1);
$oModerator->setAllowDeletePost((int) getRequest('moder_opt_deletepost', 0, 'post') === 1);
$oModerator->setAllowDeleteTopic((int) getRequest('moder_opt_deletetopic', 0, 'post') === 1);
$oModerator->setAllowMovePost((int) getRequest('moder_opt_movepost', 0, 'post') === 1);
$oModerator->setAllowMoveTopic((int) getRequest('moder_opt_movetopic', 0, 'post') === 1);
$oModerator->setAllowOpencloseTopic((int) getRequest('moder_opt_openclosetopic', 0, 'post') === 1);
$oModerator->setAllowPinTopic((int) getRequest('moder_opt_pintopic', 0, 'post') === 1);
$oModerator->setIsActive(1);
/**
* Код
*/
require_once Config::Get('path.root.engine') . '/lib/external/XXTEA/encrypt.php';
$sCode = $oForum->getId() . '_' . $oUser->getId();
$sCode = rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('plugin.forum.encrypt'))));
$oModerator->setHash($sCode);
/**
* Добавляем\сохраняем
*/
$this->PluginForum_Forum_SaveModerator($oModerator);
/**
* Свзяка модератор - форум
*/
if ($sAction == 'update') {
$oForum->moderators->add($oModerator);
$this->PluginForum_Forum_SaveForum($oForum);
} else {
/**
* Сменился форум
*/
if ($oForumOld = $this->PluginForum_Forum_GetForumById(getRequestStr('moder_form_forum'))) {
if ($oForumOld->getId() != $oForum->getId()) {
//удаляем старую связку
$oForumOld->moderators->delete($oModerator->getId());
$this->PluginForum_Forum_SaveForum($oForumOld);
//создаем новую
$oForum->moderators->add($oModerator);
$this->PluginForum_Forum_SaveForum($oForum);
}
}
}
/**
* Рендерим шаблон для предпросмотра топика
//.........这里部分代码省略.........