로그인 인증

Jul 25, 2016 am 08:50 AM

  1. /*
  2. *
  3. * @copyright 2011
  4. * @version $Id$
  5. * @access public
  6. * @property 문자열 $id
  7. * @property 문자열 $account
  8. * @property 문자열 $pwd
  9. * @property 문자열 $lastquesttime
  10. * @property 문자열 $lastip
  11. * @property int $regtime
  12. * @property int $accounttype
  13. * @property string $oldaccount
  14. * @property int $logintimes
  15. * @property string $currentIP
  16. * @property int $cid
  17. */
  18. class Resposity 확장 AdminActiveRecord {
  19. public $connectionPrefix = 'passport';
  20. protected $list = null;
  21. protected $passportConfig = null;
  22. public $oldaccount = '';
  23. /**
  24. * 지정된 AR 클래스의 정적 모델을 반환합니다.
  25. * @return Resposity 정적 모델 클래스
  26. */
  27. 공개 정적 함수 모델($className = __class__) {
  28. return parent::model ( $className );
  29. }
  30. /**
  31. * 필요하면 수정하세요.
  32. * @return은 기본 키를 혼합합니다.
  33. */
  34. 공용 함수 PrimaryKey() {
  35. return 'id';
  36. }
  37. /**
  38. * 모델 속성에 대한 @return 배열 유효성 검사 규칙.
  39. */
  40. 공용 함수 규칙() {
  41. // 참고:
  42. // 사용자 입력을 받을 속성에 대해서만 규칙을 정의해야 합니다.s
  43. return array (
  44. array ('accounttype,cid', 'required' ),
  45. array ('계정 유형', '범위', '범위' => 배열('0', '1', '2', '3', '4', '5', '6', '7' ) ),
  46. 배열('현재IP', 'ip')
  47. );
  48. }
  49. /**
  50. 기본 계정을 기준으로 사용자 정보 가져오기
  51. **/
  52. 보호 함수 getUserInfoByMainAccount($account,$cid){
  53. $account=strtolower($account);
  54. $cacheKey = 해시( 'md5', $account.'^]'.$cid.'^]'.'0' );
  55. $user=UtilD::getCache('resposity',$cacheKey);
  56. if(is_array($user)){
  57. UtilD::clearNullOrEmptyValue( $user );
  58. }else{
  59. $user=array();
  60. }
  61. if(count($user )){
  62. return $user;
  63. }else{
  64. $model = $this->find ( 'account=:account AND cid=:cid', array (':account' => $account,':cid' => $cid ) );
  65. if($model){
  66. $user=$model->getAttributes();
  67. unset($model);
  68. }
  69. UtilD::setCache('resposity',$cacheKey,$user);
  70. return $user;
  71. }
  72. }
  73. /**서브 계정*을 기반으로 사용자 정보 획득*/
  74. 보호 함수 getUserInfoByChildAccount($subaccount,$cid,$accounttype){
  75. if(!$ this->validate(array('accounttype'), true)){
  76. return -1000;
  77. }
  78. $subaccount=strtolower($subaccount);
  79. $cacheKey = hash ( 'md5 ', $subaccount.'^]'.$cid.'^]'.$accounttype );
  80. $userAccounts=UtilD::getCache('resposity',$cacheKey);
  81. if(is_array($userAccounts) )){
  82. UtilD::clearNullOrEmptyValue($userAccounts);
  83. }else{
  84. $userAccounts=array();
  85. }
  86. if(!count($userAccounts)){
  87. $accountRefer=new AccountRefer();
  88. $model=$accountRefer->find ( 'subaccount=:subaccount AND cid=:cid AND accounttype=:accounttype', array (':subaccount' => $subaccount ,':cid' => $this->cid,':accounttype'=> $accounttype) );
  89. if($model){
  90. $userAccounts=$model->getAttributes() ;
  91. UtilD::setCache('resposity',$cacheKey,$userAccounts);
  92. }
  93. }
  94. if(isset($userAccounts['account'])){
  95. return $ this->getUserInfoByMainAccount($userAccounts['account'],$userAccounts['cid']);
  96. }
  97. return array();
  98. }
  99. /**계정 유형에 따라 사용자 데이터 가져오기**/
  100. 공개 함수 getUserInfoByAccount(){
  101. if($this->accounttype==0){
  102. return $this->getUserInfoByMainAccount($this->account,$this-> ;cid);
  103. }else{
  104. return $this->getUserInfoByChildAccount($this->account,$this->cid,$this->accounttype);
  105. }
  106. }
  107. /**
  108. * 메인 계정을 통해 서브 계정 얻기
  109. */
  110. 공개 함수 getSubAccountByMainAccount(){
  111. $c=new CDbCriteria();
  112. $c->addCondition('cid=:cid AND account= :account', 'AND');
  113. $c->params=array(':cid'=>$this->cid, ':account'=>$this->account);
  114. $refer=new AccountRefer();
  115. $result=$refer->getListByPage(1, 30, $c);
  116. $data=array();
  117. if($result[ 'count']>0){
  118. foreach($result['data'] as $row){
  119. $data[$row['accounttype']]=$row['subaccount'];
  120. }
  121. }
  122. return $data;
  123. }
  124. /**
  125. 현재 가맹점의 운영 등급 획득
  126. 1은 본인이 추가한 사용자에 대해서는 모든 권한을 가지며, 다른 기관에서 추가한 사용자에 대해서는 권한이 없습니다.
  127. 2는 본인이 추가한 사용자에 대해서는 전체 권한을 가지며, 전체 권한을 갖습니다. accsessids에 의해 지정된 기관의 사용자에 대한 권한 쿼리 권한
  128. **/
  129. 공용 함수 getAccess(){
  130. if ($this->passportConfig = == null) {
  131. $this->passportConfig = PassportConfig::model ()->getItemConfigById ( $this->cid );
  132. }
  133. $ip=Yii::app ()->request->getUserHostAddress();
  134. $ips=CJSON::decode($passportConfig['iprouters']);
  135. if(!in_array ($ip,$ips)){
  136. throw new CHttpException(403, '이 페이지에 액세스할 수 있는 권한이 없습니다!');
  137. }
  138. }
  139. /**유명 브랜드 사용자의 개인정보 수정**/
  140. 공개 함수 saveUserAttributes($tickets,array $attributes){
  141. try{
  142. $user=$this ->getUserAttributes($tickets);
  143. if(empty($user) || !is_array($user)){
  144. return -1001;
  145. }
  146. $data=array();
  147. if($user[WebUserD::STORAGE_KEY]!=='[]'){
  148. $data=CJSON::decode($user[WebUserD::STORAGE_KEY]);
  149. }
  150. if(!is_array($data)){
  151. $data=array();
  152. }
  153. $attributes=array_change_key_case($attributes);
  154. foreach($attributes as $key=>$ 값){
  155. if(!is_array($value)){
  156. $data[$key]=$value;
  157. }else{
  158. if(!isset($data[$key]) ){
  159. $data[$key]=array();
  160. }
  161. $data[$key]=array_merge($data[$key],$attributes[$key]);
  162. }
  163. }
  164. $user[WebUserD::STORAGE_KEY]=CJSON::encode($data);
  165. $user['lastquesttime']=$_SERVER['REQUEST_TIME'];
  166. $user ['data']=CJSON::encode($data);
  167. $this->setAttributes($user,false);
  168. !$this->currentIP && $this->currentIP=' 127.0.0.1';
  169. !$this->lastip && $this->lastip=$this->currentIP;
  170. !$this->logintimes && $this- >logintimes = 0;
  171. $this->setIsNewRecord ( false );
  172. if($this->save()){
  173. UtilD::setCache('resposity', $tickets, $ user);
  174. }else{
  175. return -1003;
  176. }
  177. }catch(Exception $ex){
  178. return -1004;
  179. }
  180. }
  181. / **계정 개인 데이터 수정**/
  182. 공개 함수 saveUserAttributesByName( array $attributes){
  183. $user=$this->getUserInfoByMainAccount($this->account,$this->cid);
  184. if(empty($user)){
  185. return -1001;
  186. }
  187. $cacheKey = hash ( 'md5', $user['account'].'^]'.$user['cid '].'^]'.'0' );
  188. return $this-> saveUserAttributes($cacheKey,$attributes);
  189. }
  190. /**
  191. @return 배열
  192. 토큰을 기반으로 모든 계정 데이터 가져오기
  193. **/
  194. 공개 함수 getUserAttributes($tickets){
  195. $t = hash ( 'md5', $tickets . $this->currentIP . $this->cid );
  196. $ft=UtilD::getCache('resposity) ', $t);
  197. if (! $ft) {
  198. $ft = 0;
  199. } else {
  200. if ($ft > 4) { //如果1个ip 1分钟内连续5次获取失败
  201. return -1005;
  202. }
  203. }
  204. $user=UtilD::getCache('respososity',$tickets);
  205. if(!$user){
  206. $ft ;
  207. UtilD::setCache('respososity', $t,$ft,60);
  208. return -1001;
  209. }
  210. $user['lastquesttime']=$ _SERVER['REQUEST_TIME'];
  211. UtilD::setCache('respoosity',$tickets,$user);
  212. return $user;
  213. }
  214. /**기본 계정 추가**/
  215. 공개 함수 add(){
  216. 시도{
  217. if($this->accounttype!=0){
  218. return -1000;
  219. }
  220. $this->account=strtolower ($this->account);
  221. //检查主帐号是否存재
  222. $user=$this->getUserInfoByAccount();
  223. if(is_array($user) && count($user) ){
  224. return -1006;
  225. }
  226. //开始保存数据
  227. $this->setIsNewRecord ( true );
  228. $this->lastquesttime=$_SERVER['REQUEST_TIME' ];
  229. $this->regtime=$_SERVER['REQUEST_TIME'];
  230. $this->data='[]';
  231. $this->pwd=hash('sha256' ,$this->pwd);
  232. if(!$this->save()){
  233. return -1007;
  234. }else{
  235. $user=$this- >getAttributes();
  236. $cacheKey = hash ( 'md5',$this->account.'^]'.$this->cid.'^]'.$this->accounttype );
  237. UtilD::setCache('resposity', $cacheKey, $user);
  238. }
  239. }catch(Exception $ex){
  240. return -1004;
  241. }
  242. }
  243. /**연결된 하위 계정**/
  244. 공용 함수 addChild($subaccount){
  245. try{
  246. //检查子是否유동이름이 있는 帐号与主账号关联
  247. $subaccount=strtolower( $subaccount);
  248. $user=$this->getUserInfoByChildAccount($subaccount,$this->cid,$this->accounttype);
  249. if($user){
  250. return -1008 ;
  251. }
  252. $user=$this->getUserInfoByMainAccount($this->account,$this->cid);
  253. if(!$user){
  254. return -1001;
  255. }
  256. //유효한 정보 제공
  257. $accountRefer=new AccountRefer();
  258. $model=$accountRefer->find('pid=:pid AND cid =:cid AND 계정 유형=:accounttype', 배열 (':pid'=>$user['id'],':cid'=>$this->cid,':accounttype'=>$this ->계정 유형));
  259. if($model){
  260. return -1009;
  261. }
  262. $this->account=strtolower($this->account);
  263. $accountRefer->cid=$this->cid;
  264. $accountRefer->setIsNewRecord (true );
  265. $accountRefer->pid=$user['id'];
  266. $accountRefer->account=$user['account'];
  267. $accountRefer->subaccount=$subaccount;
  268. $
  269. $ accountRefer->accounttype=$this->accounttype;
  270. if($accountRefer->save()){
  271. $cacheKey = hash ( 'md5',$accountRefer->subaccount. '^]'.$accountRefer ->cid.'^]'.$accountRefer->accounttype );
  272. UtilD::setCache('resposity', $cacheKey, $accountRefer->getAttributes());
  273. }else{
  274. return -1010;
  275. }
  276. }catch(Exception $ex){
  277. return -1004;
  278. }
  279. }
  280. /**修改密碼**/
  281. public function changePassword(){
  282. try{
  283. $user=$this->getUserInfoByAccount();//檢查主帳號是否存在
  284. if(!$user){
  285. return -1001;
  286. }
  287. $this->setIsNewRecord ( false );
  288. $this->pwd=hash('sha256',$this->pwd);
  289. if($ this->pwd!==$user['pwd']){
  290. $this->setIsNewRecord ( false );
  291. $user['pwd']=$this->; pwd;
  292. $this->setAttributes($user,false);
  293. if($this->save()){
  294. $cacheKey = hash ( 'md5', $user['帳號'] .'^]'.$user['cid'].'^]'.'0' );
  295. UtilD::setCache('resposity', $cacheKey, $user);
  296. }else {
  297. return -1011;
  298. }
  299. }
  300. }catch(異常$ex){
  301. return -1004;
  302. }
  303. }
  304. /**修改子帳號** /
  305. public function repickAccount(){
  306. try{
  307. $accounts=$this->getUserInfoByChildAccount($this->oldaccount,$this->cid,$this->accounttype );
  308. if
  309. if (!$accounts){
  310. return -1001;
  311. }
  312. $cacheKey = hash ( 'md5',$this->oldaccount.'^]'.$this->cid.'^]' .$this->accounttype );
  313. $user=UtilD::getCache('resposity', $cacheKey);
  314. if($this->oldaccount!== $this->account){
  315. $accountRefer=new AccountRefer();
  316. $accountRefer->setIsNewRecord ( false );
  317. $accountRefer->setAttributes($user,false);
  318. $accountRefer->subaccount=$this->count;
  319. if($accountRefer->save()){
  320. $user['subaccount']=$this->account;
  321. UtilD::setCache('resposity', $cacheKey,array()) ;
  322. $cacheKey= hash ( 'md5',$user['子帳號'].'^]'.$this->cid. '^]'.$this->accounttype );
  323. UtilD::setCache('resposity', $cacheKey,$user);
  324. }else{
  325. return -1012;
  326. }
  327. }
  328. }catch(Exception $ex){
  329. return -1004;
  330. }
  331. }
  332. /**
  333. 刪除主帳號
  334. **/
  335. public function deleteMainAccount(🎝>*/
  336. public function deleteMainAccount(){ 嘗試{
  337. $user=$this->getUserInfoByMainAccount($this->account,$this->cid);
  338. if(!$user){
  339. return -1001;
  340. }
  341. //檢查是否有子帳號
  342. $accountRefer=new AccountRefer();
  343. $models=$accountRefer->findAll('pid=:pid', array (':pid' =>$user[ 'id']));
  344. if(is_array($models)&&count($models)){
  345. foreach($models as $model){
  346. $k= hash ( 'md5', $model ->subaccount.'^]'.$model->cid.'^]'.$model->accounttype );//刪除子帳號硬碟
  347. UtilD::setCache( 'resposity', $k,false) ;
  348. unset($model);
  349. }
  350. unset($models);
  351. }
  352. // 刪除主帳號伺服器
  353. $cacheKey = hash ( 'md5', $this ->account.'^]'.$this->cid.'^]'.'0' );
  354. if($this->deleteByPk($user ['id'])){
  355. UtilD ::setCache('resposity', $cacheKey,false);
  356. }else{
  357. return -1013;
  358. }
  359. }catch(異常$ex){
  360. return -1004;
  361. }
  362. }
  363. /**刪除子帳號**/
  364. public function deleteChildAccount(){
  365. try{
  366. $user= $this->getUserInfoByChildAccount($this->account, $this->cid,$this->accounttype);
  367. if(!$user){
  368. return -1014;
  369. }
  370. //刪除伺服器
  371. $cacheKey = hash ( ' md5', $this->account.'^]'.$this->cid.'^]'.$this->accounttype ) ;
  372. $child=UtilD::getCache('resposity',$cacheKey) ;
  373. $accountRefer=new AccountRefer();
  374. if($accountRefer->deleteByPk($child['id']) )){
  375. UtilD::setCache('resposity', $cacheKey,false );
  376. }else{
  377. 回傳-1014;
  378. }
  379. }catch(異常$ex){
  380. return -1004;
  381. }
  382. }
  383. 公用函數登入(){
  384. try{
  385. if(empty($this->currentIP)){
  386. return -1017 ;
  387. }
  388. $tickets=hash ( 'md5', $this- >account.'^]'.$this->cid.'^]'.$this->accounttype );
  389. $t = hash ( 'md5', $tickets . '&' 。 ;
  390. if (! $ft) {
  391. $ft = 0;
  392. } else {
  393. if ($ft > 4) { //如果1個ip 1分鐘內連續5次獲取失敗
  394. 回傳-1015;
  395. } }
  396. $user=$this->getUserInfoByAccount();
  397. if(!$user){
  398. $ft ;
  399. UtilD::setCache('resposity', $t,$ft,60 );
  400. return -1001;
  401. }
  402. $this->pwd=hash('sha256',$this->pwd);
  403. if($user['pwd']! ==$this->pwd){
  404. $ft ;
  405. UtilD::setCache('resposity', $t,$ft,60);
  406. return -1016;
  407. }
  408. $tickets=hash ( 'md5', $user['account'].'^]'.$user['cid'].'^]'.'0' );
  409. //새로운 버전으로 전환最后请求时间
  410. if(!isset($user['currentIP'])){
  411. $user['currentIP']=$this->currentIP;
  412. }
  413. $user[' lastip']=$user['currentIP'];
  414. $user['currentIP']=$this->currentIP;
  415. if(!isset($user['logintimes'])){
  416. $user['logintimes']=0;
  417. }
  418. $user['logintimes'] ;
  419. $user['lastquesttime']=$_SERVER['REQUEST_TIME'];
  420. $this ->setAttributes($user,false);
  421. if($this->save()){
  422. UtilD::setCache('resposity', $tickets,$user);
  423. 배열 반환 ('tickets'=>$tickets);
  424. }else{
  425. return -1017;
  426. }
  427. }catch(Exception $ex){
  428. return -1004;
  429. }
  430. }
  431. }
复제대码


본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Laravel의 플래시 세션 데이터로 작업합니다 Laravel의 플래시 세션 데이터로 작업합니다 Mar 12, 2025 pm 05:08 PM

Laravel은 직관적 인 플래시 방법을 사용하여 임시 세션 데이터 처리를 단순화합니다. 응용 프로그램에 간단한 메시지, 경고 또는 알림을 표시하는 데 적합합니다. 데이터는 기본적으로 후속 요청에만 지속됩니다. $ 요청-

PHP의 컬 : REST API에서 PHP Curl Extension 사용 방법 PHP의 컬 : REST API에서 PHP Curl Extension 사용 방법 Mar 14, 2025 am 11:42 AM

PHP 클라이언트 URL (CURL) 확장자는 개발자를위한 강력한 도구이며 원격 서버 및 REST API와의 원활한 상호 작용을 가능하게합니다. PHP CURL은 존경받는 다중 프로모토콜 파일 전송 라이브러리 인 Libcurl을 활용하여 효율적인 execu를 용이하게합니다.

Laravel 테스트에서 단순화 된 HTTP 응답 조롱 Laravel 테스트에서 단순화 된 HTTP 응답 조롱 Mar 12, 2025 pm 05:09 PM

Laravel은 간결한 HTTP 응답 시뮬레이션 구문을 제공하여 HTTP 상호 작용 테스트를 단순화합니다. 이 접근법은 테스트 시뮬레이션을보다 직관적으로 만들면서 코드 중복성을 크게 줄입니다. 기본 구현은 다양한 응답 유형 단축키를 제공합니다. Illuminate \ support \ Facades \ http를 사용하십시오. http :: 가짜 ([ 'google.com'=> ​​'Hello World', 'github.com'=> ​​[ 'foo'=> 'bar'], 'forge.laravel.com'=>

Codecanyon에서 12 개의 최고의 PHP 채팅 스크립트 Codecanyon에서 12 개의 최고의 PHP 채팅 스크립트 Mar 13, 2025 pm 12:08 PM

고객의 가장 긴급한 문제에 실시간 인스턴트 솔루션을 제공하고 싶습니까? 라이브 채팅을 통해 고객과 실시간 대화를 나누고 문제를 즉시 해결할 수 있습니다. 그것은 당신이 당신의 관습에 더 빠른 서비스를 제공 할 수 있도록합니다.

PHP에서 늦은 정적 결합의 개념을 설명하십시오. PHP에서 늦은 정적 결합의 개념을 설명하십시오. Mar 21, 2025 pm 01:33 PM

기사는 PHP 5.3에 도입 된 PHP의 LSB (Late STATIC BING)에 대해 논의하여 정적 방법의 런타임 해상도가보다 유연한 상속을 요구할 수있게한다. LSB의 실제 응용 프로그램 및 잠재적 성능

프레임 워크 사용자 정의/확장 : 사용자 정의 기능을 추가하는 방법. 프레임 워크 사용자 정의/확장 : 사용자 정의 기능을 추가하는 방법. Mar 28, 2025 pm 05:12 PM

이 기사에서는 프레임 워크에 사용자 정의 기능 추가, 아키텍처 이해, 확장 지점 식별 및 통합 및 디버깅을위한 모범 사례에 중점을 둡니다.

PHP의 CURL 라이브러리를 사용하여 JSON 데이터가 포함 된 게시물 요청을 보내는 방법은 무엇입니까? PHP의 CURL 라이브러리를 사용하여 JSON 데이터가 포함 된 게시물 요청을 보내는 방법은 무엇입니까? Apr 01, 2025 pm 03:12 PM

PHP 개발에서 PHP의 CURL 라이브러리를 사용하여 JSON 데이터를 보내면 종종 외부 API와 상호 작용해야합니다. 일반적인 방법 중 하나는 컬 라이브러리를 사용하여 게시물을 보내는 것입니다 ...

See all articles