PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/system/application/controllers/home.php

https://github.com/mr-mark/mark-1
PHP | 124 lines | 95 code | 28 blank | 1 comment | 11 complexity | 5477a8fa68bc90bff84b61e549ace010 MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. class Home extends MainController {
  3. const PASSWORDLENGTH = 6;
  4. const ADMINEMAIL = "markteams@gmail.com";
  5. function Home()
  6. {
  7. parent::MainController();
  8. $this->loadJs('generals');
  9. $this->add_css('home');
  10. $this->load->model(array('Farm','Userrank'));
  11. }
  12. function index($reason = null)
  13. {
  14. $user = $this->user_model->is_authenticated();
  15. $frmMdl = new Farm();
  16. $this->data['allExistsFarm'] = $frmMdl->allExistsFarm();
  17. $usrRnkMdl = new Userrank();
  18. $this->data['bestUsers'] = $usrRnkMdl->getBestUser();
  19. $this->data['title'] = $this->lang->language['home_title'];
  20. $this->data['heading'] = '';
  21. $this->data['user'] = $user;
  22. if(isset($reason))
  23. {
  24. $this->data['reason'] = $reason;
  25. }
  26. $this->data['title'] = $this->lang->language['home_title'];
  27. $this->loadJs('jquery.hints');
  28. $this->loadJs('boxy');
  29. $this->add_css('boxy');
  30. $this->render('home');
  31. }
  32. function help()
  33. {
  34. $this->data['user'] = $this->user_model->is_authenticated();
  35. $this->data['title'] = $this->lang->language['helpPage'];
  36. $this->data['heading'] = '';
  37. $this->render('home');
  38. }
  39. function contact()
  40. {
  41. $this->data['user'] = $this->user_model->is_authenticated();
  42. if(!isset($_POST['name']) || trim($_POST['name'], " ") == "") {
  43. $this->data['title'] = $this->lang->language['contact'];
  44. $this->data['heading'] = '';
  45. $this->render('home');
  46. }
  47. else {
  48. $headers = 'MIME-Version: 1.0' . "\r\n";
  49. $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
  50. $headers .= 'From: yummy.com' . "\r\n";
  51. $message = "<BR /><BR />Name: " . substr(strip_tags($_POST['name']), 0, 250) . "<BR />";
  52. $message .= "e-mail: " . substr(strip_tags($_POST['email']), 0, 250) . "<BR /><BR />";
  53. $message .= "Description: " . substr(strip_tags($_POST['body']), 0, 5000) . "<BR />";
  54. if(mail(self::ADMINEMAIL, "yummy.com, New contact", $message, $headers))
  55. redirect(base_url()."message/index/15/");
  56. else
  57. redirect(base_url()."message/index/16/");
  58. }
  59. }
  60. function forgot($data = null)
  61. {
  62. $this->data['user'] = $this->user_model->is_authenticated();
  63. if($_POST['email'] != "")
  64. {
  65. $user = $this->user_model->get_user_by_mail($_POST['email']);
  66. if($user)
  67. {
  68. $headers = 'MIME-Version: 1.0' . "\r\n";
  69. $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
  70. $headers .= 'From: yummy.com' . "\r\n";
  71. //password GENERATOR
  72. $length = self::PASSWORDLENGTH;
  73. $characters = "0123456789abcdefghijklmnopqrstuvwxyz";
  74. $string = "";
  75. for ($p = 0; $p < $length; $p++) {
  76. $string .= $characters[mt_rand(0, strlen($characters))];
  77. }
  78. $message = str_replace(array('__USER__','__PASSWORD__'), array($user->first_name." ".$user->last_name,$string), $this->lang->language['forgotPassMail']);
  79. if(mail($user->email, 'Forgotten Password From Yummy', $message,$headers))
  80. {
  81. $fields = array('password');
  82. $user->password = md5($string);
  83. $this->user_model->update($user,$fields);
  84. redirect(base_url() . "message/index/20/");
  85. }
  86. }
  87. else
  88. {
  89. redirect(base_url() . "message/index/19/");
  90. }
  91. }
  92. $this->data['title'] = $this->lang->language['forgotPassword'];
  93. $this->data['heading'] = '';
  94. $this->render('home');
  95. }
  96. }