Esempio n. 1
0
 /**
  * AddUserlog function
  *
  * @param int $content content
  *
  * @return bool
  */
 function addUserlog($content)
 {
     $this->load->model('servicepublicclass/errorlogpublic', 'errorlogpublic');
     $userlog = new errorlogpublic();
     $userlog->loaderrorlog($content);
     $strArr = explode("\n", $userlog->stacktrace);
     if (count($strArr) >= 3) {
         $title = $strArr[0] . "\n" . $strArr[1] . "\n" . $strArr[2];
     } else {
         $title = $strArr[0];
     }
     $nowtime = date('Y-m-d H:i:s');
     if (isset($userlog->time)) {
         $nowtime = $userlog->time;
         if (strtotime($nowtime) < strtotime('1970-01-01 00:00:00') || strtotime($nowtime) == '') {
             $nowtime = date('Y-m-d H:i:s');
         }
     }
     $data = array('appkey' => $userlog->appkey, 'title' => $title, 'stacktrace' => $userlog->stacktrace, 'os_version' => $userlog->os_version, 'time' => $nowtime, 'device' => $userlog->deviceid, 'activity' => $userlog->activity, 'isfix' => 0, 'version' => isset($userlog->version) ? $userlog->version : '');
     $this->db->insert('errorlog', $data);
 }
Esempio n. 2
0
 function postErrorLog()
 {
     $this->load->model('servicepublicclass/errorlogpublic', 'errorlogpublic');
     if (!isset($_POST["content"])) {
         $ret = array('flag' => -3, 'msg' => 'Invalid content.');
         echo json_encode($ret);
         return;
     }
     $encoded_content = $_POST["content"];
     $content = json_decode($encoded_content);
     log_message('debug', $encoded_content);
     $errorlog = new errorlogpublic();
     $errorlog->loaderrorlog($content);
     $retParamsCheck = $this->utility->isPraramerValue($content, $array = array("appkey", "stacktrace", "time", "activity", "os_version", "deviceid"));
     if ($retParamsCheck["flag"] <= 0) {
         $ret = array('flag' => -2, 'msg' => $retParamsCheck['msg']);
         echo json_encode($ret);
         return;
     }
     $key = $errorlog->appkey;
     $isKeyAvailable = $this->utility->isKeyAvailale($key);
     if (!$isKeyAvailable) {
         $ret = array('flag' => -1, 'msg' => 'NotAvailable appkey  ');
         echo json_encode($ret);
         return;
     } else {
         try {
             $this->userlog->addUserlog($content);
             $ret = array('flag' => 1, 'msg' => 'ok');
         } catch (Exception $ex) {
             $ret = array('flag' => -4, 'msg' => 'DB Error');
         }
     }
     echo json_encode($ret);
 }