PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/password.php

https://github.com/minea94/DboorZ
PHP | 80 lines | 67 code | 6 blank | 7 comment | 17 complexity | 111d4c95d92900379ea1f6ad4a41c891 MD5 | raw file
  1. <?php
  2. /*********************/
  3. /* */
  4. /* Version : 5.1.0 */
  5. /* Author : RM */
  6. /* Comment : 071223 */
  7. /* */
  8. /*********************/
  9. class GPage extends gamepage
  10. {
  11. public $pageState = -1;
  12. public $playerId = NULL;
  13. public function GPage( )
  14. {
  15. parent::gamepage( );
  16. $this->viewFile = "password.phtml";
  17. $this->contentCssClass = "activate";
  18. }
  19. public function load( )
  20. {
  21. parent::load( );
  22. $m = new PasswordModel( );
  23. if ( $this->isPost( ) && isset( $_POST['id'] ) && isset( $_POST['email'] ) && is_numeric( $_POST['id'] ) )
  24. {
  25. $playerId = intval( $_POST['id'] );
  26. $email = $_POST['email'];
  27. $this->pageState = $m->isPlayerIdHasEmail( $playerId, $email ) ? 3 : 2;
  28. if ( $this->pageState == 3 )
  29. {
  30. $name = $m->getPlayerName( $playerId );
  31. $newPassword = substr( md5( dechex( $playerId * mt_rand( 10, 100 ) ) ), mt_rand( 1, 5 ), 7 );
  32. $n = dechex( hexdec( $newPassword ) ^ hexdec( substr( md5( $name ), 2, 7 ) ) );
  33. $link = WebHelper::getbaseurl( )."password.php?id=".$playerId."&n=".$n."&c=".substr( md5( dechex( $playerId ).$name."777" ), 7, 7 );
  34. $to = $email;
  35. $from = $this->appConfig['system']['email'];
  36. $subject = forget_password_subject;
  37. $message = sprintf( forget_password_body, $name, $name, $newPassword, $link, $link );
  38. WebHelper::sendmail( $to, $from, $subject, $message );
  39. }
  40. }
  41. else if ( isset( $_GET['id'] ) && is_numeric( $_GET['id'] ) )
  42. {
  43. $this->playerId = intval( $_GET['id'] );
  44. $this->pageState = $m->isPlayerIdExists( $this->playerId ) ? 1 : 0 - 1;
  45. if ( isset( $_GET['n'] ) && trim( $_GET['n'] ) != "" && isset( $_GET['c'] ) )
  46. {
  47. if ( $this->pageState == 1 )
  48. {
  49. $name = $m->getPlayerName( $this->playerId );
  50. if ( trim( $_GET['c'] ) == substr( md5( dechex( $this->playerId ).$name."777" ), 7, 7 ) )
  51. {
  52. $newPassword = dechex( hexdec( $_GET['n'] ) ^ hexdec( substr( md5( $name ), 2, 7 ) ) );
  53. $m->setPlayerPassword( $this->playerId, $newPassword );
  54. $this->pageState = 4;
  55. }
  56. else
  57. {
  58. $this->pageState = 5;
  59. }
  60. }
  61. else
  62. {
  63. $this->pageState = 5;
  64. }
  65. }
  66. }
  67. $m->dispose( );
  68. }
  69. }
  70. require( ".".DIRECTORY_SEPARATOR."app".DIRECTORY_SEPARATOR."boot.php" );
  71. require_once( MODEL_PATH."password.php" );
  72. $p = new GPage( );
  73. $p->run( );
  74. ?>