Beispiel #1
0
 function logBefore()
 {
     $this->startTm = microtime(true);
     global $APP;
     $type = getAppType();
     $userId = null;
     if ($type == "user") {
         $userId = $_SESSION["uid"];
     } else {
         if ($type == "emp" || $type == "store") {
             $userId = $_SESSION["empId"];
         } else {
             if ($type == "admin") {
                 $userId = $_SESSION["adminId"];
             }
         }
     }
     if (!(is_int($userId) || ctype_digit($userId))) {
         $userId = 'NULL';
     }
     $content = $this->myVarExport($_GET, 2000);
     $ct = $_SERVER["HTTP_CONTENT_TYPE"];
     if (!preg_match('/x-www-form-urlencoded|form-data/i', $ct)) {
         $post = file_get_contents("php://input");
         $content2 = $this->myVarExport($post, 2000);
     } else {
         $content2 = $this->myVarExport($_POST, 2000);
     }
     if ($content2 != "") {
         $content .= ";\n" . $content2;
     }
     $remoteAddr = @$_SERVER['REMOTE_ADDR'] ?: 'unknown';
     $reqsz = strlen($_SERVER["REQUEST_URI"]) + (@$_SERVER["HTTP_CONTENT_LENGTH"] ?: $_SERVER["CONTENT_LENGTH"] ?: 0);
     $ua = $_SERVER["HTTP_USER_AGENT"];
     $ver = getClientVersion();
     $sql = sprintf("INSERT INTO ApiLog (tm, addr, ua, app, ses, userId, ac, req, reqsz, ver) VALUES ('%s', %s, %s, %s, %s, {$userId}, %s, %s, {$reqsz}, %s)", date(FMT_DT), Q($remoteAddr), Q($ua), Q($APP), Q(session_id()), Q($this->ac), Q($content), Q($ver["str"]));
     $this->id = execOne($sql, true);
     // 		$logStr = "=== [" . date("Y-m-d H:i:s") . "] id={$this->logId} from=$remoteAddr ses=" . session_id() . " app=$APP user=$userId ac=$ac >>>$content<<<\n";
 }
Beispiel #2
0
function getIosVersion()
{
    $ver = getClientVersion();
    return $ver["type"] == "ios" ? (int) $ver["ver"] : false;
}