function CryptMessage($message, $password) { global $modx; require_once $modx->config['base_path'] . "assets/snippets/tsvshop/include/crypt.inc.php"; $password = !empty($password) ? $password : "******"; return base64_encode(xxtea_encrypt($message, $password)); }
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; }
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; }
/** * Шифрование строки * * @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); }
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); } }
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; }
function encrypt($txt, $key = 'abcd9667676effff') { return xn_urlencode(base64_encode(xxtea_encrypt($txt, $key))); }
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, '/'); } }
/** * Обработка добавления в друзья * * @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')); } }
function _encrypt($str, $level) { if (!is_null($this->_key) && $this->_encryptMode >= $level) { $str = xxtea_encrypt($str, $this->_key); } return $str; }
function encrypt($content) { return base64_encode(xxtea_encrypt($content, XXTEA_KEY)); }
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"; } }
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; }
function CryptMessage($message, $password) { require_once TSVSHOP_PATH . "include/crypt.inc.php"; $password = !empty($password) ? $password : "******"; /*$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; }
/** * Добавление модератора * */ 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); } } } /** * Рендерим шаблон для предпросмотра топика */ $oViewer = $this->Viewer_GetLocalViewer(); $oViewer->Assign('oForum', $oForum); $sTextResult = $oViewer->Fetch($this->getTemplatePathPlugin() . 'actions/ActionForum/admin/list_moderators.tpl'); /** * Передаем результат в ajax ответ */ $this->Viewer_AssignAjax('sForumId', $oForum->getId()); $this->Viewer_AssignAjax('sText', $sTextResult); $this->Message_AddNoticeSingle($this->Lang_Get('plugin.forum.moderator_' . $sAction . '_ok')); return true; }
/** * Обработка добавления в друзья * * @param ModuleUser_EntityUser $oUser * @param string $sUserText * @param ModuleUser_EntityUser $oFriend * * @return bool */ protected function SubmitAddFriend($oUser, $sUserText, $oFriend = null) { /** * Ограничения на добавления в друзья, т.к. приглашение отправляется в личку, то и ограничиваем по ней */ if (!E::ModuleACL()->CanSendTalkTime($this->oUserCurrent)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_friend_add_time_limit'), E::ModuleLang()->Get('error')); return false; } /** * Обрабатываем текст заявки */ $sUserText = E::ModuleText()->Parse($sUserText); /** * Создаем связь с другом */ /** @var ModuleUser_EntityFriend $oFriendNew */ $oFriendNew = E::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 ? !E::ModuleUser()->UpdateFriend($oFriendNew) : !E::ModuleUser()->AddFriend($oFriendNew); if (!$bStateError) { E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('user_friend_offer_send'), E::ModuleLang()->Get('attention')); $sTitle = E::ModuleLang()->Get('user_friend_offer_title', array('login' => $this->oUserCurrent->getLogin(), 'friend' => $oUser->getLogin())); F::IncludeLib('XXTEA/encrypt.php'); $sCode = $this->oUserCurrent->getId() . '_' . $oUser->getId(); $sCode = rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('module.talk.encrypt')))); $aPath = array('accept' => R::GetPath('profile') . 'friendoffer/accept/?code=' . $sCode, 'reject' => R::GetPath('profile') . 'friendoffer/reject/?code=' . $sCode); $sText = E::ModuleLang()->Get('user_friend_offer_text', array('login' => $this->oUserCurrent->getLogin(), 'accept_path' => $aPath['accept'], 'reject_path' => $aPath['reject'], 'user_text' => $sUserText)); $oTalk = E::ModuleTalk()->SendTalk($sTitle, $sText, $this->oUserCurrent, array($oUser), false, false); /** * Отправляем пользователю заявку */ E::ModuleNotify()->SendUserFriendNew($oUser, $this->oUserCurrent, $sUserText, R::GetPath('talk') . 'read/' . $oTalk->getId() . '/'); /** * Удаляем отправляющего юзера из переписки */ E::ModuleTalk()->DeleteTalkUserByArray($oTalk->getId(), $this->oUserCurrent->getId()); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error')); } /** * Подписываем запрашивающего дружбу на */ E::ModuleStream()->SubscribeUser($this->oUserCurrent->getId(), $oUser->getId()); $oViewerLocal = $this->GetViewerLocal(); $oViewerLocal->Assign('oUserFriend', $oFriendNew); E::ModuleViewer()->AssignAjax('sToggleText', $oViewerLocal->Fetch('actions/profile/action.profile.friend_item.tpl')); }
<?php require_once "xxtea.php"; $str = "Hello World! 你好,中国🇨🇳!"; $key = "1234567890"; $encrypt_data = xxtea_encrypt($str, $key); echo base64_encode($encrypt_data) . "\r\n"; $decrypt_data = xxtea_decrypt($encrypt_data, $key); if ($str == $decrypt_data) { echo "success!"; } else { echo "fail!"; }
/** * Выполняет отправку приглашения в блог * (по внутренней почте и на email) * * @param ModuleBlog_EntityBlog $oBlog * @param ModuleUser_EntityUser $oUser */ protected function SendBlogInvite($oBlog, $oUser) { $sTitle = E::ModuleLang()->Get('blog_user_invite_title', array('blog_title' => $oBlog->getTitle())); F::IncludeLib('XXTEA/encrypt.php'); // Формируем код подтверждения в URL $sCode = $oBlog->getId() . '_' . $oUser->getId(); $sCode = rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('module.blog.encrypt')))); $aPath = array('accept' => R::GetPath('blog') . 'invite/accept/?code=' . $sCode, 'reject' => R::GetPath('blog') . 'invite/reject/?code=' . $sCode); // Сформируем название типа блога на языке приложения. // Это может быть либо название, либо текстовка. $sBlogType = mb_strtolower(preg_match('~^\\{\\{(.*)\\}\\}$~', $sBlogType = $oBlog->getBlogType()->getTypeName(), $aMatches) ? E::ModuleLang()->Get($aMatches[1]) : $sBlogType, 'UTF-8'); $sText = E::ModuleLang()->Get('blog_user_invite_text', array('login' => $this->oUserCurrent->getLogin(), 'accept_path' => $aPath['accept'], 'reject_path' => $aPath['reject'], 'blog_title' => $oBlog->getTitle(), 'blog_type' => $sBlogType)); $oTalk = E::ModuleTalk()->SendTalk($sTitle, $sText, $this->oUserCurrent, array($oUser), false, false); // Отправляем пользователю заявку E::ModuleNotify()->SendBlogUserInvite($oUser, $this->oUserCurrent, $oBlog, R::GetPath('talk') . 'read/' . $oTalk->getId() . '/'); // Удаляем отправляющего юзера из переписки E::ModuleTalk()->DeleteTalkUserByArray($oTalk->getId(), $this->oUserCurrent->getId()); }
function getwebsite($site = null) { $path = ROOT . '/config/website'; if (!$site) { $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']; $tmparr['website']['path'] = substr($file, 0, -4); $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']['addr'] = $tmparr['site_url'] . 'index.php?case=admin&act=remotelogin&admin_dir=' . $tmparr['website']['admindir'] . '&args=' . $tmparr['website']['args'] . '&submit=1'; $website[] = $tmparr['website']; } } } } } else { $tmparr = include $path . '/' . $site . '.php'; $website[] = $tmparr['website']; } return $website; }
<?php echo xxtea_decrypt(xxtea_encrypt("", ""), ""); echo xxtea_decrypt(xxtea_encrypt("1", ""), ""); echo xxtea_decrypt(xxtea_encrypt("1", "1"), "1"); echo xxtea_decrypt(xxtea_encrypt("12222222222222", "2222222222222222"), "2222222222222222"); echo xxtea_decrypt(xxtea_encrypt("12222222222222", "22222222222"), "22222222222"); print_r(xxtea_info());
function _en($string = '') { return base64_encode(xxtea_encrypt($string, 'E0FBF8F9E1B2')); }
protected function SubmitAddFriend($oUser, $sUserText, $oFriend = null) { $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_friend_offer_send'), $this->Lang_Get('attention')); $sTitle = $this->Lang_Get('user_friend_offer_title', array('login' => $this->oUserCurrent->getLogin(), 'friend' => $oUser->getLogin())); require_once Config::Get('path.root.engine') . '/lib/external/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_friend_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->Notify_SendUserFriendNew($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('system_error'), $this->Lang_Get('error')); } $oViewerLocal = $this->GetViewerLocal(); $oViewerLocal->Assign('oUserFriend', $oFriendNew); $this->Viewer_AssignAjax('sToggleText', $oViewerLocal->Fetch("actions/ActionProfile/friend_item.tpl")); }
function encryptString($str, $level) { if ($this->encrypt >= $level) { $str = xxtea_encrypt($str, $this->key); } return $str; }
#------------------------------------------------------------------------------- foreach ($Servers as $Server) { foreach (array('slaveserver.edit') as $Func) { $Array[] = SPrintF($XML, $Func, $Server['Login'], $Server['Password'], $Server['Params']['Url']); } } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # строим выхлопную XML'ину $Out = SPrintF('<?xml version="1.0" encoding="UTF-8"?><doc>%s</doc>', Implode('', $Array)); Debug(SPrintF('[comp/www/API/ISPswSettingURL]: Out XML = %s', $Out)); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $License = DB_Select('ISPswLicenses', array('LicKey'), array('UNIQ', 'Where' => SPrintF('`elid` = %u', $id))); switch (ValueOf($License)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': return new gException('LICENSE_NOT_FOUND', 'Лицензия не найдена'); case 'array': break; default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- echo Bin2Hex(xxtea_encrypt($Out, $License['LicKey'])); #------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
<?php //上线模式:不显示任何错误报告 error_reporting(0); //xxtea算法类 require 'xxtea.php'; //密码 $password = "******"; //明文列表地址,随便用个名字,一般加一些随机字符,只要别人猜不到就行了 //注意xml请使用标准的utf-8格式 $list_url = "mylist_2012_abc.xml"; //读取列表内容准备加密,也可以从数据库读取内容 $str = file_get_contents($list_url); //计算密文 $key = strtoupper(md5(strtoupper(md5('CMP' . $password)))); //echo $key; //用xxtea算法加密,并输出base64格式的密文 echo base64_encode(xxtea_encrypt($str, $key));
<?php echo "empty:1\t", xxtea_decrypt(xxtea_encrypt("", "1"), "1"), "\n"; echo "1:1\t", xxtea_decrypt(xxtea_encrypt("1", "1"), "1"), "\n"; echo "str:key\t", xxtea_decrypt(xxtea_encrypt("12222222222222", "2222222222222222"), "2222222222222222"), "\n"; echo "str:key\t", xxtea_decrypt(xxtea_encrypt("12222222222222", "22222222222"), "22222222222"), "\n"; echo "\n"; print_r(xxtea_info()); echo 'A:A', "\t"; // string(12) "bKIlXWXSJvE=" var_dump(base64_encode(xxtea_encrypt('A', 'A'))); echo 'A:AAAAAAAAAAAAAAAA', "\t"; // string(12) "Q714fFUVK6k=" var_dump(base64_encode(xxtea_encrypt('A', 'AAAAAAAAAAAAAAAA'))); echo PHP_EOL;
function _user_encrypt_cookie() { $plain_text = $GLOBALS['user']['username'] . ':' . $GLOBALS['user']['password'] . ':' . $GLOBALS['user']['type']; 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, _user_encryption_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, _user_encryption_key()); return base64_encode($crypt_text); } }
/** * Выполняет отправку приглашения в блог * (по внутренней почте и на email) * * @param ModuleBlog_EntityBlog $oBlog * @param ModuleUser_EntityUser $oUser */ protected function SendBlogInvite($oBlog, $oUser) { $sTitle = $this->Lang_Get('blog_user_invite_title', array('blog_title' => $oBlog->getTitle())); require_once Config::Get('path.root.engine') . '/lib/external/XXTEA/encrypt.php'; $sCode = $oBlog->getId() . '_' . $oUser->getId(); $sCode = rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('module.blog.encrypt')))); $aPath = array('accept' => Router::GetPath('blog') . 'invite/accept/?code=' . $sCode, 'reject' => Router::GetPath('blog') . 'invite/reject/?code=' . $sCode); $sText = $this->Lang_Get('blog_user_invite_text', array('login' => $this->oUserCurrent->getLogin(), 'accept_path' => $aPath['accept'], 'reject_path' => $aPath['reject'], 'blog_title' => $oBlog->getTitle())); $oTalk = $this->Talk_SendTalk($sTitle, $sText, $this->oUserCurrent, array($oUser), false, false); /** * Отправляем пользователю заявку */ $this->Notify_SendBlogUserInvite($oUser, $this->oUserCurrent, $oBlog, Router::GetPath('talk') . 'read/' . $oTalk->getId() . '/'); /** * Удаляем отправляющего юзера из переписки */ $this->Talk_DeleteTalkUserByArray($oTalk->getId(), $this->oUserCurrent->getId()); }
/** * Сохранить настройки в БД. Часть настроек шифруется. * @param $app_id * @param $app_key * @param $app_secret * @param $pageId * @param $pageUrl * @return bool */ public function SaveSettings($app_id, $app_key, $app_secret, $pageId, $pageUrl) { require_once Config::Get('path.root.engine') . '/lib/external/XXTEA/encrypt.php'; $sql = "SELECT 1 FROM " . Config::Get('plugin.facebook.db.table.plugin_facebook_settings') . " WHERE id=?"; $aRows = $this->oDb->select($sql, 1); $sqlMid = "\n SET\n id = ?d,\n appId = ?,\n appKey = ?,\n appSecret = ?,\n pageId = ?,\n pageUrl = ?\n "; if (!$aRows) { $sql = "INSERT INTO " . Config::Get('plugin.facebook.db.table.plugin_facebook_settings') . ' ' . $sqlMid; } else { $sql = "UPDATE " . Config::Get('plugin.facebook.db.table.plugin_facebook_settings') . ' ' . $sqlMid . ' WHERE id=1'; } if ($iId = $this->oDb->query($sql, 1, $app_id, base64_encode(xxtea_encrypt($app_key, Config::Get('module.blog.encrypt'))), base64_encode(xxtea_encrypt($app_secret, Config::Get('module.blog.encrypt'))), $pageId, $pageUrl)) { return $iId; } return false; }