sessions.path.php 498 B

12345678910111213141516171819202122232425
  1. <?php
  2. Router::paths(array(
  3. '/sessions'=>function($res,$args){
  4. if(Bugs::$user){
  5. $res->write(
  6. Bugs::template('sessions')
  7. ->run(Bugs::$user)
  8. );
  9. }else{
  10. Router::redirect(Router::$base);
  11. }
  12. },
  13. '/sessions/remove/{id}'=>function($res,$args){
  14. error_handle_type('json');
  15. if(Bugs::$user){
  16. Bugs::$sql->query("
  17. DELETE FROM sessions
  18. WHERE u_id = ?
  19. AND id = ?
  20. ",'is',Bugs::$user->id,$args->id)->execute();
  21. }
  22. $res->json(array());
  23. }
  24. ));
  25. ?>