PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/rxwandc/application/admin.rxwan.com/classes/model/soft/log.php

https://bitbucket.org/i1598/caiyun_stat
PHP | 75 lines | 42 code | 10 blank | 23 comment | 2 complexity | 0a9ada683c1606f60e1e37ea0838bd11 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. defined ( 'SYSPATH' ) or die ( 'No direct script access.' );
  3. class Model_Soft_Log extends Model {
  4. private $table = 'log';
  5. private $table_user = 'user';
  6. /**
  7. * 获取版本号的数量
  8. */
  9. public function get_count() {
  10. return DB::select ( array (DB::expr ( 'COUNT(*)' ), 'totalcount' ) )->from ( $this->table )->execute ( Database::instance ( 'soft' ) )->get ( 'totalcount' );
  11. }
  12. /**
  13. * 获得顶级目录 版本号
  14. * @param unknown_type $limit
  15. * @param unknown_type $offset
  16. */
  17. public function get_list($limit, $offset) {
  18. $list_data = DB::select ()->from ( $this->table )->order_by('dateline','DESC')->limit ( $limit )->offset ( $offset )->execute ( Database::instance ( 'soft' ) )->as_array ();
  19. if(! empty($list_data)){
  20. foreach ( $list_data as $k => $v ) {
  21. $list_data [$k] ['admin_username'] = $this->get_admin_username ( $v ['admin_id'] );
  22. $list_data [$k] ['ip'] = long2ip ( $v ['admin_ip'] );
  23. }
  24. }
  25. return $list_data;
  26. }
  27. /**
  28. * 获取管理员username
  29. * @param unknown_type $id
  30. */
  31. public function get_admin_username($id) {
  32. return DB::select ( 'username' )->from ( $this->table_user )->where ( 'user_id', '=', $id )->execute ( Database::instance ( 'opsys' ) )->get ( 'username' );
  33. }
  34. /**
  35. * 添加说明
  36. * @param unknown_type $id
  37. * @param unknown_type $explain
  38. */
  39. public function add_explain($id, $explain) {
  40. $json = array('statusCode'=>300,'message'=>'键入失败');
  41. $result = DB::update ( $this->table )->set ( array ('explain' => $explain ) )->where ( 'id', '=', $id )->execute ( Database::instance ( 'soft' ) );
  42. $json = array ();
  43. if ($result !== false) {
  44. $json ['statusCode'] = 200;
  45. $json ['message'] = '键入成功';
  46. $json ['navTabId'] = 'version_log';
  47. $json ['callbackType'] = 'closeCurrent';
  48. $json ['forwardUrl'] = '';
  49. }
  50. return json_encode ( $json );
  51. }
  52. /**
  53. * 添加操作
  54. */
  55. public function add($data){
  56. return DB::insert($this->table,array_keys($data))->values($data)->execute(Database::instance('soft'));
  57. }
  58. /**
  59. * 写日志
  60. */
  61. public function record_log($operate) {
  62. $data_log = array ('admin_id' => UID, 'admin_ip' => UIP, 'dateline' => TIME, 'operate' => $operate );
  63. return $this->add($data_log);
  64. }
  65. }