Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MVC]Czy to już to?
daniel1302
post
Post #1





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

Ostrzeżenie: (0%)
-----


Witam,
czy ten skrypt zalicza się do skryptu zgodnego z wzorcami MVC?
Funkcje hexpass oraz safe email są w innym pliku pokazuje je tylko dla tego tematu
  1. <?php
  2. function safeEmail($str)
  3. {
  4. $pattern = '/^[a-zA-Z0-9.-_]+@[a-z0-9]+.([a-z]+){2,4}$/';
  5. if (!preg_match($pattern, $str))
  6. {
  7. return false;
  8. }
  9. else
  10. {
  11. return true;
  12. }
  13. }
  14. function hexPass($str)
  15. {
  16. $str = md5('Damned'.$str.'Land');
  17. $str = sha1('PHP5.///-0-'.md5($str).'-0-.5PHP');
  18. $str = md5($str);
  19. return $str;
  20. }
  21. class LoginModel
  22. {
  23. static public function getData($email, $pass)
  24. {
  25. $result=@mysql_fetch_assoc(mysql_query("SELECT id FROM players WHERE email='".safeEmail($email)."' AND pass='".hexPass($pass)."'"));
  26. return (!isset($result['id'])) ? false : $result;
  27. }
  28. }
  29.  
  30.  
  31. Class LoginView
  32. {
  33. static public function getVista($tpl, $actionFile)
  34. {
  35. $tpl->assign('actionFile', $actionFile);
  36. $tpl->parse('login.tpl');
  37. }
  38. }
  39.  
  40. class LoginController
  41. {
  42. static public function Loging ($email, $pass)
  43. {
  44. $test=LoginModel::getData($email, $pass);
  45. if ($test == false)
  46. {
  47. return false;
  48. } else
  49. {
  50. return $test['id'];
  51. }
  52. }
  53. }
  54. ?>


Ten post edytował daniel1302 18.03.2008, 19:59:44
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 16:37