|
5 | 5 | */
|
6 | 6 | class AdminController extends AppController
|
7 | 7 | {
|
8 |
| - public $_models=array(); |
| 8 | + public $_models=array('Errorlog'); |
9 | 9 | public $_daos=array();
|
10 | 10 | public $_components=array('Upgrade','Utility');
|
11 | 11 | public $_forms=array('Admin');
|
@@ -54,7 +54,87 @@ function indexAction()
|
54 | 54 | }
|
55 | 55 | }//end indexAction
|
56 | 56 |
|
57 |
| - |
| 57 | + |
| 58 | + /** show logs*/ |
| 59 | + function showlogAction() |
| 60 | + { |
| 61 | + if(!$this->logged||!$this->userSession->Dao->getAdmin()==1) |
| 62 | + { |
| 63 | + throw new Zend_Exception("You should be an administrator"); |
| 64 | + } |
| 65 | + if(!$this->getRequest()->isXmlHttpRequest()) |
| 66 | + { |
| 67 | + throw new Zend_Exception("Why are you here ? Should be ajax."); |
| 68 | + } |
| 69 | + $this->_helper->layout->disableLayout(); |
| 70 | + |
| 71 | + $start=$this->_getParam("startlog"); |
| 72 | + $end=$this->_getParam("endlog"); |
| 73 | + $module=$this->_getParam("modulelog"); |
| 74 | + $priority=$this->_getParam("prioritylog"); |
| 75 | + if(!isset($start)) |
| 76 | + { |
| 77 | + $start=date('c',strtotime("-24 hour")); |
| 78 | + } |
| 79 | + else |
| 80 | + { |
| 81 | + $start=date('c', strtotime($start)); |
| 82 | + } |
| 83 | + if(!isset($end)) |
| 84 | + { |
| 85 | + $end= date('c'); |
| 86 | + } |
| 87 | + else |
| 88 | + { |
| 89 | + $end=date('c', strtotime($end)); |
| 90 | + } |
| 91 | + if(!isset($module)) |
| 92 | + { |
| 93 | + $module='all'; |
| 94 | + } |
| 95 | + if(!isset($priority)) |
| 96 | + { |
| 97 | + $priority='all'; |
| 98 | + } |
| 99 | + |
| 100 | + $logs=$this->Errorlog->getLog($start, $end,$module,$priority); |
| 101 | + foreach ($logs as $key=>$log) |
| 102 | + { |
| 103 | + $logs[$key]=$log->_toArray(); |
| 104 | + if(substr($log->getMessage(), 0, 5)=='Fatal') |
| 105 | + { |
| 106 | + $shortMessage=substr($log->getMessage(), strpos($log->getMessage(), "[message]")+10,40); |
| 107 | + } |
| 108 | + elseif(substr($log->getMessage(), 0, 6)=='Server') |
| 109 | + { |
| 110 | + $shortMessage=substr($log->getMessage(), strpos($log->getMessage(), "Message:")+9,40); |
| 111 | + } |
| 112 | + else |
| 113 | + { |
| 114 | + $shortMessage=substr($log->getMessage(), 0,40); |
| 115 | + } |
| 116 | + $logs[$key]['shortMessage']=$shortMessage.' ...'; |
| 117 | + } |
| 118 | + $this->view->jsonLogs=JsonComponent::encode($logs); |
| 119 | + $this->view->jsonLogs=htmlentities($this->view->jsonLogs); |
| 120 | + |
| 121 | + if($this->_request->isPost()) |
| 122 | + { |
| 123 | + $this->_helper->viewRenderer->setNoRender(); |
| 124 | + echo $this->view->jsonLogs; |
| 125 | + return; |
| 126 | + } |
| 127 | + |
| 128 | + $modulesConfig=Zend_Registry::get('configsModules'); |
| 129 | + |
| 130 | + $modules=array('all','core'); |
| 131 | + foreach($modulesConfig as $key=>$module) |
| 132 | + { |
| 133 | + $modules[]=$key; |
| 134 | + } |
| 135 | + $this->view->modulesLog=$modules; |
| 136 | + }//showlogAction |
| 137 | + |
58 | 138 | /** upgrade database*/
|
59 | 139 | function upgradeAction()
|
60 | 140 | {
|
|
0 commit comments