PHP site 2 5/3/2017


SUBMITTED BY: canonical

DATE: May 3, 2017, 11:34 p.m.

FORMAT: PHP

SIZE: 2.7 kB

HITS: 380

  1. If you want more of my pastes visit: https://randompaste.000webhostapp.com/index.html
  2. --------------------------------------------------------------------------------------
  3. view my last post at: https://bitbin.it/X2LSOj3b/
  4. --------------------------------------------------------------------------------------
  5. <?php
  6. $id = getGet('id');
  7. $ac = getGet('ac');
  8. $ctrl = getGet('ctrl');
  9. switch( $ctrl )
  10. {
  11. case 'noticia':
  12. $dao = 'NoticiaDAO';
  13. $vo = new NoticiaVO();
  14. break;
  15. case 'usuario':
  16. $dao = 'UsuarioDAO';
  17. $vo = new UsuarioVO();
  18. break;
  19. default:
  20. $dao = null;
  21. $vo = null;
  22. break;
  23. }
  24. if( !isPost() )
  25. {
  26. if( $ac=='view' )
  27. {
  28. if( !empty($id) )
  29. {
  30. $action = 'Atualizar';
  31. if( $dao )
  32. {
  33. $dados = call_user_func( array( $dao , 'getById' ) , $id )->fetch_object();
  34. if( $dados )
  35. {
  36. include 'set_'.$ctrl.'.php';//arquivo com os m�todos setters
  37. include 'view/'.$ctrl.'.php';
  38. }
  39. else
  40. echo tentou_invadir( 'O registro n�o existe', 'Esse registro <span>n�o existe</span> mais' );
  41. }
  42. else
  43. echo tentou_invadir( 'N�o existe $dao, $vo' );
  44. }
  45. else {
  46. if( $dao )
  47. {
  48. $action = 'Atualizar';
  49. $all = call_user_func( array( $dao , 'get2List' ) ,'','','' );
  50. include 'view/listagem.php';
  51. }
  52. else
  53. echo tentou_invadir( 'N�o existe $dao, $vo' );
  54. }
  55. }
  56. else if( $ac=='new' )
  57. {
  58. $dados = $vo;
  59. $action = 'Cadastrar';
  60. $data = date('d/m/Y');
  61. $hora = date('H:i:s');
  62. include 'view/'.$ctrl.'.php';
  63. }
  64. else if( $ac=='del' )
  65. {
  66. $action = 'Excluir';
  67. $dados = call_user_func( array( $dao , 'get2Del' ) ,'','','', $id );
  68. include 'view/deletar.php';
  69. }
  70. else if( $ac=='up' )
  71. {
  72. include 'view/banner.php';
  73. }
  74. else if( $ac=='list' )
  75. {
  76. include 'view/'.$ctrl.'.php';
  77. }
  78. else {
  79. echo tentou_invadir( 'Acessou sem $ac' );
  80. $action = 'view';
  81. }
  82. }
  83. else
  84. {
  85. $action = getGet('ac');
  86. include 'set_'.$ctrl.'.php';//arquivo com os m�todos setters
  87. if( $action=='Cadastrar' || $action=='Atualizar' )
  88. {
  89. try {
  90. salvarDAO( $dao, $vo );
  91. $pag_erro = 'view/ok.php';
  92. }
  93. catch ( Exception $e ){
  94. $log = new Logger( 'Mysql', $e->getMessage() );
  95. $log->createLog('log');
  96. $pag_erro = 'view/erro.php';
  97. }
  98. }
  99. else
  100. {
  101. try {
  102. excluirDAO( $dao, $vo );
  103. $pag_erro = 'view/ok.php';
  104. }
  105. catch ( Exception $e ){
  106. $log = new Logger( 'Mysql', $e->getMessage() );
  107. $log->createLog('log');
  108. $pag_erro = 'view/erro.php';
  109. }
  110. }
  111. include $pag_erro;
  112. }

comments powered by Disqus