Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Admin extends CI_Controller {
  5.  
  6. /**
  7. * Index Page for this controller.
  8. *
  9. * Maps to the following URL
  10. * http://example.com/index.php/welcome
  11. * - or -
  12. * http://example.com/index.php/welcome/index
  13. * - or -
  14. * Since this controller is set as the default controller in
  15. * config/routes.php, it's displayed at http://example.com/
  16. *
  17. * So any other public methods not prefixed with an underscore will
  18. * map to /index.php/welcome/<method_name>
  19. * @see https://codeigniter.com/user_guide/general/urls.html
  20. */
  21.  
  22. public function __construct(){
  23. parent::__construct();
  24.  
  25. $this->load->model('Security_model');
  26.  
  27.  
  28. }
  29.  
  30.  
  31. public function index()
  32. {
  33. $this->load->view('welcome_message');
  34. }
  35.  
  36. public function adminindex()
  37. {
  38. $this->load->view('admin/index');
  39. //echo "string";
  40. }
  41.  
  42.  
  43.  
  44. public function adminlogin()
  45. {
  46. //$this->load->view('welcome_message');
  47.  
  48. $this->load->view('admin/adminlogin');
  49. //$this->load->function('verifylogin');
  50. }
  51.  
  52.  
  53. public function verifylogin()
  54. {
  55. $email = $this->input->post('email');
  56. $pass = $this->input->post('pass');
  57.  
  58.  
  59. $query = $this->db->get('Admin');
  60.  
  61. foreach ($query->result() as $row)
  62. {
  63.  
  64.  
  65. if(password_verify($pass,$row->password)&&$email==$row->password){
  66. echo "TRUE";
  67. }
  68. else{
  69. echo "FALSE";
  70. }
  71.  
  72. }
  73.  
  74. echo "Email is $email <br> Password is $pass";
  75. }
  76.  
  77.  
  78.  
  79.  
  80.  
  81. public function sampleSecurity()
  82. {
  83.  
  84. $x = $this->Security_model->encrypt_string('admin');
  85.  
  86. echo "<br>Hashed String:";
  87. echo $this->Security_model->hash_pass('admin');
  88. echo "<br>encrypted String:";
  89. echo $x;
  90. echo "<br>Decrypted String:";
  91. echo $this->Security_model->decrypt_string($x);
  92.  
  93.  
  94. echo "<br/><br/>";
  95. if(password_verify("admin",$this->Security_model->hash_pass('admin'))){
  96. echo "TRUE";
  97. }
  98. else{
  99. echo "FALSE";
  100. }
  101. }
  102.  
  103. public function database()
  104. {
  105. $query = $this->db->get('Admin');
  106.  
  107. foreach ($query->result() as $row)
  108. {
  109. echo $row->password;
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement