Minor formatting changes
This commit is contained in:
parent
7920705d2b
commit
1166cfc4d7
@ -140,10 +140,10 @@ abstract class BaseDatabaseTestCase extends PHPUnit\DbUnit\TestCase {
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param array $rowsArr Array of rows
|
||||
* @return int|null Last insert id if available, NULL otherwise
|
||||
* @return int|null Last insert id if available, null otherwise
|
||||
*/
|
||||
private function pdoInsert(string $table, array $rowsArr = []): ?int {
|
||||
$ret = NULL;
|
||||
$ret = null;
|
||||
if (!empty($rowsArr)) {
|
||||
$values = ':' . implode(', :', array_keys($rowsArr));
|
||||
$columns = implode(', ', array_keys($rowsArr));
|
||||
@ -161,7 +161,7 @@ abstract class BaseDatabaseTestCase extends PHPUnit\DbUnit\TestCase {
|
||||
* Execute raw insert query on database
|
||||
*
|
||||
* @param string $query Insert query
|
||||
* @return int|null Last insert id if available, NULL otherwise
|
||||
* @return int|null Last insert id if available, null otherwise
|
||||
*/
|
||||
private function pdoInsertRaw(string $query): ?int {
|
||||
$ret = null;
|
||||
|
@ -37,19 +37,19 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
|
||||
$position = $json[0];
|
||||
self::assertEquals(1, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
|
||||
$position = $json[1];
|
||||
self::assertEquals(2, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(2, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,20 +78,20 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertCount(2, $json, "Wrong count of positions");
|
||||
|
||||
$position = $json[0];
|
||||
self::assertEquals(1, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(1, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
|
||||
$position = $json[1];
|
||||
self::assertEquals(2, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(2, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,20 +148,20 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertCount(2, $json, "Wrong count of positions");
|
||||
|
||||
$position = $json[0];
|
||||
self::assertEquals(1, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(1, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
|
||||
$position = $json[1];
|
||||
self::assertEquals(2, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(2, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,12 +195,12 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertCount(1, $json, "Wrong count of positions");
|
||||
|
||||
$position = $json[0];
|
||||
self::assertEquals(2, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 3, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(2, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 3, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,20 +235,20 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertCount(2, $json, "Wrong count of positions");
|
||||
|
||||
$position = $json[0];
|
||||
self::assertEquals(2, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 3, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(2, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 3, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
|
||||
$position = $json[1];
|
||||
self::assertEquals(3, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 2, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($trackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(3, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 2, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($trackName, (string) $position->trackname, "Wrong trackname");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,14 +349,14 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertCount(1, $json, "Wrong count of positions");
|
||||
|
||||
$position = $json[0];
|
||||
self::assertEquals($afterId + 1, (int) $position->id,"Wrong position id");
|
||||
self::assertEquals($this->testLat + 1, (float) $position->latitude,"Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude,"Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp,"Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username,"Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname,"Wrong trackname");
|
||||
self::assertEquals(111195, (int) $position->meters,"Wrong distance delta");
|
||||
self::assertEquals(1, (int) $position->seconds,"Wrong timestamp delta");
|
||||
self::assertEquals($afterId + 1, (int) $position->id, "Wrong position id");
|
||||
self::assertEquals($this->testLat + 1, (float) $position->latitude, "Wrong latitude");
|
||||
self::assertEquals($this->testLon, (float) $position->longitude, "Wrong longitude");
|
||||
self::assertEquals($this->testTimestamp + 1, (int) $position->timestamp, "Wrong timestamp");
|
||||
self::assertEquals($this->testAdminUser, (string) $position->username, "Wrong username");
|
||||
self::assertEquals($this->testTrackName, (string) $position->trackname, "Wrong trackname");
|
||||
self::assertEquals(111195, (int) $position->meters, "Wrong distance delta");
|
||||
self::assertEquals(1, (int) $position->seconds, "Wrong timestamp delta");
|
||||
}
|
||||
|
||||
|
||||
@ -387,12 +387,12 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertCount(2, $json, "Wrong count of tracks");
|
||||
|
||||
$track = $json[0];
|
||||
self::assertEquals($this->testTrackId2, (int) $track->id,"Wrong track id");
|
||||
self::assertEquals($this->testTrackName . "2", (string) $track->name,"Wrong track name");
|
||||
self::assertEquals($this->testTrackId2, (int) $track->id, "Wrong track id");
|
||||
self::assertEquals($this->testTrackName . "2", (string) $track->name, "Wrong track name");
|
||||
|
||||
$track = $json[1];
|
||||
self::assertEquals($this->testTrackId, (int) $track->id,"Wrong track id");
|
||||
self::assertEquals($this->testTrackName, (string) $track->name,"Wrong track name");
|
||||
self::assertEquals($this->testTrackId, (int) $track->id, "Wrong track id");
|
||||
self::assertEquals($this->testTrackName, (string) $track->name, "Wrong track name");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -420,12 +420,12 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertCount(2, $json, "Wrong count of tracks");
|
||||
|
||||
$track = $json[0];
|
||||
self::assertEquals($this->testTrackId2, (int) $track->id,"Wrong track id");
|
||||
self::assertEquals($this->testTrackName . "2", (string) $track->name,"Wrong track name");
|
||||
self::assertEquals($this->testTrackId2, (int) $track->id, "Wrong track id");
|
||||
self::assertEquals($this->testTrackName . "2", (string) $track->name, "Wrong track name");
|
||||
|
||||
$track = $json[1];
|
||||
self::assertEquals($this->testTrackId, (int) $track->id,"Wrong track id");
|
||||
self::assertEquals($this->testTrackName, (string) $track->name,"Wrong track name");
|
||||
self::assertEquals($this->testTrackId, (int) $track->id, "Wrong track id");
|
||||
self::assertEquals($this->testTrackName, (string) $track->name, "Wrong track name");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -626,8 +626,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals("Wrong old password", (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals("Wrong old password", (string) $json->message, "Wrong error message");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -871,8 +871,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertEquals(200, $response->getStatusCode(), "Unexpected status code");
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
self::assertEquals(2, $this->getConnection()->getRowCount("tracks"), "Wrong row count");
|
||||
}
|
||||
|
||||
@ -899,8 +899,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertEquals(200, $response->getStatusCode(), "Unexpected status code");
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -918,7 +918,7 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
}
|
||||
|
||||
|
||||
@ -938,8 +938,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertEquals(200, $response->getStatusCode(), "Unexpected status code");
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -959,8 +959,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertEquals(200, $response->getStatusCode(), "Unexpected status code");
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
self::assertEquals(2, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||
|
||||
}
|
||||
@ -981,8 +981,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertEquals(200, $response->getStatusCode(), "Unexpected status code");
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
self::assertEquals(1, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||
}
|
||||
|
||||
@ -1002,8 +1002,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertEquals(200, $response->getStatusCode(), "Unexpected status code");
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
self::assertEquals(1, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||
}
|
||||
|
||||
@ -1024,8 +1024,8 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
self::assertEquals(200, $response->getStatusCode(), "Unexpected status code");
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error,"Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["servererror"], (string) $json->message, "Wrong error message");
|
||||
self::assertEquals(2, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||
}
|
||||
|
||||
@ -1074,7 +1074,7 @@ class InternalAPITest extends UloggerAPITestCase {
|
||||
$json = json_decode($response->getBody());
|
||||
self::assertNotNull($json, "JSON object is null");
|
||||
self::assertEquals(1, (int) $json->error, "Wrong error status");
|
||||
self::assertEquals($lang["userexists"], (string) $json->message,"Wrong error message");
|
||||
self::assertEquals($lang["userexists"], (string) $json->message, "Wrong error message");
|
||||
self::assertEquals(2, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||
}
|
||||
|
||||
|
@ -41,11 +41,11 @@ class PositionTest extends UloggerDatabaseTestCase {
|
||||
);
|
||||
$this->assertTableContains($expected, $actual, "Wrong actual table data");
|
||||
|
||||
$posId = uPosition::add($userId, $trackId, NULL, $this->testLat, $this->testLon);
|
||||
$posId = uPosition::add($userId, $trackId, null, $this->testLat, $this->testLon);
|
||||
self::assertFalse($posId, "Adding position with null time stamp should fail");
|
||||
$posId = uPosition::add($userId, $trackId, $this->testTimestamp, NULL, $this->testLon);
|
||||
$posId = uPosition::add($userId, $trackId, $this->testTimestamp, null, $this->testLon);
|
||||
self::assertFalse($posId, "Adding position with null latitude should fail");
|
||||
$posId = uPosition::add($userId, $trackId, $this->testTimestamp, $this->testLat, NULL);
|
||||
$posId = uPosition::add($userId, $trackId, $this->testTimestamp, $this->testLat, null);
|
||||
self::assertFalse($posId, "Adding position with null longitude should fail");
|
||||
|
||||
$posId = uPosition::add($userId, $trackId, "", $this->testLat, $this->testLon);
|
||||
@ -156,7 +156,7 @@ class PositionTest extends UloggerDatabaseTestCase {
|
||||
self::assertCount(2, $posArr, "Wrong row count");
|
||||
$posArr = uPosition::getAll($userId, $trackId);
|
||||
self::assertCount(1, $posArr, "Wrong row count");
|
||||
$posArr = uPosition::getAll(NULL, $trackId);
|
||||
$posArr = uPosition::getAll(null, $trackId);
|
||||
self::assertCount(1, $posArr, "Wrong row count");
|
||||
$posArr = uPosition::getAll($userId3);
|
||||
self::assertCount(0, $posArr, "Wrong row count");
|
||||
|
@ -72,11 +72,11 @@ class TrackTest extends UloggerDatabaseTestCase {
|
||||
);
|
||||
$this->assertTableContains($expected, $actual, "Wrong actual table data");
|
||||
|
||||
$posId = $track->addPosition($userId, NULL, $this->testLat, $this->testLon);
|
||||
$posId = $track->addPosition($userId, null, $this->testLat, $this->testLon);
|
||||
self::assertFalse($posId, "Adding position with null time stamp should fail");
|
||||
$posId = $track->addPosition($userId, $this->testTimestamp, NULL, $this->testLon);
|
||||
$posId = $track->addPosition($userId, $this->testTimestamp, null, $this->testLon);
|
||||
self::assertFalse($posId, "Adding position with null latitude should fail");
|
||||
$posId = $track->addPosition($userId, $this->testTimestamp, $this->testLat, NULL);
|
||||
$posId = $track->addPosition($userId, $this->testTimestamp, $this->testLat, null);
|
||||
self::assertFalse($posId, "Adding position with null longitude should fail");
|
||||
|
||||
$posId = $track->addPosition($userId, "", $this->testLat, $this->testLon);
|
||||
@ -113,7 +113,7 @@ class TrackTest extends UloggerDatabaseTestCase {
|
||||
uTrack::deleteAll($userId);
|
||||
self::assertEquals(1, $this->getConnection()->getRowCount('tracks'), "Wrong row count");
|
||||
self::assertEquals(1, $this->getConnection()->getRowCount('positions'), "Wrong row count");
|
||||
self::assertFalse(uTrack::deleteAll(NULL), "User id should not be empty");
|
||||
self::assertFalse(uTrack::deleteAll(null), "User id should not be empty");
|
||||
}
|
||||
|
||||
public function testUpdate(): void {
|
||||
|
@ -75,7 +75,7 @@ class UserTest extends UloggerDatabaseTestCase {
|
||||
}
|
||||
|
||||
public function testIsAdmin(): void {
|
||||
$this->addTestUser($this->testUser, NULL, true);
|
||||
$this->addTestUser($this->testUser, null, true);
|
||||
$user = new uUser($this->testUser);
|
||||
self::assertTrue($user->isAdmin, "User should be admin");
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ select {
|
||||
width: 165px;
|
||||
padding-left: 10px;
|
||||
color: lightgray;
|
||||
background-color: rgba(102, 102, 102, 0.9);
|
||||
background-color: rgba(102, 102, 102, 90%);
|
||||
}
|
||||
|
||||
#menu-button {
|
||||
@ -122,7 +122,7 @@ select {
|
||||
#menu.menu-hidden #menu-button {
|
||||
font-weight: normal;
|
||||
border-color: white;
|
||||
background-color: rgba(0, 60, 136, 0.3);
|
||||
background-color: rgba(0, 60, 136, 30%);
|
||||
}
|
||||
|
||||
#menu.menu-hidden #menu-button a::after {
|
||||
@ -153,7 +153,7 @@ select {
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
label[for=user] {
|
||||
label[for="user"] {
|
||||
display: block;
|
||||
padding-top: 1em;
|
||||
}
|
||||
@ -340,7 +340,7 @@ label[for=user] {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: black; /* fallback */
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
background-color: rgba(0, 0, 0, 40%);
|
||||
}
|
||||
|
||||
#modal-header {
|
||||
@ -353,7 +353,7 @@ label[for=user] {
|
||||
|
||||
#modal-header button {
|
||||
border: none;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
background-color: rgba(0, 0, 0, 0%);
|
||||
}
|
||||
|
||||
#modal-body {
|
||||
@ -363,13 +363,13 @@ label[for=user] {
|
||||
transform: translate(-50%, -50%) !important;
|
||||
font-size: 0.9em;
|
||||
min-width: 300px;
|
||||
margin: 0 auto 15% auto;
|
||||
margin: 0 auto 15%;
|
||||
padding: 1em;
|
||||
color: white;
|
||||
border: 1px solid #888;
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
background-color: rgba(102, 102, 102, 0.9);
|
||||
background-color: rgba(102, 102, 102, 90%);
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
@ -378,10 +378,10 @@ label[for=user] {
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
#modal input[type=text],
|
||||
#modal input[type=color],
|
||||
#modal input[type=number],
|
||||
#modal input[type=password] {
|
||||
#modal input[type="text"],
|
||||
#modal input[type="color"],
|
||||
#modal input[type="number"],
|
||||
#modal input[type="password"] {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
@ -395,7 +395,7 @@ label[for=user] {
|
||||
#modal.image {
|
||||
overflow: hidden;
|
||||
padding-top: 0;
|
||||
background-color: rgba(45, 45, 45, 0.95);
|
||||
background-color: rgba(45, 45, 45, 95%);
|
||||
}
|
||||
|
||||
#modal.image #modal-body img {
|
||||
@ -466,11 +466,11 @@ button > * {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#configForm label {
|
||||
#config-form label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#configForm label b {
|
||||
#config-form label b {
|
||||
display: inline-block;
|
||||
text-align: right;
|
||||
width: 250px;
|
||||
@ -479,30 +479,30 @@ button > * {
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
#configForm input[type=text],
|
||||
#configForm input[type=number],
|
||||
#configForm input[type=color],
|
||||
#configForm select {
|
||||
#config-form input[type="text"],
|
||||
#config-form input[type="number"],
|
||||
#config-form input[type="color"],
|
||||
#config-form select {
|
||||
width: 150px;
|
||||
margin: 3px 0;
|
||||
padding: 2px 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#configForm input[type=checkbox] {
|
||||
#config-form input[type="checkbox"] {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#configForm select {
|
||||
#config-form select {
|
||||
padding: 2px 0;
|
||||
}
|
||||
|
||||
#configForm input[type=color] {
|
||||
#config-form input[type="color"] {
|
||||
vertical-align: middle;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#configForm img {
|
||||
#config-form img {
|
||||
height: 13px;
|
||||
vertical-align: middle;
|
||||
margin: 0 5px;
|
||||
@ -531,7 +531,7 @@ button > * {
|
||||
padding: 6px 20px;
|
||||
border-radius: 5px;
|
||||
border-top: 1px solid #555;
|
||||
box-shadow: 10px 10px 10px -8px rgba(0, 0, 0, 0.3);
|
||||
box-shadow: 10px 10px 10px -8px rgba(0, 0, 0, 30%);
|
||||
z-index: 100000;
|
||||
opacity: 0;
|
||||
transition: all 1s;
|
||||
@ -596,7 +596,7 @@ button > * {
|
||||
}
|
||||
|
||||
.alert.spinner > span::before, .alert.spinner > span::after {
|
||||
content: '';
|
||||
content: "";
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@ -661,8 +661,8 @@ button > * {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 10px;
|
||||
background-color: #666;
|
||||
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
|
||||
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
|
||||
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 20%));
|
||||
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 20%));
|
||||
}
|
||||
|
||||
.ol-popup::after, .ol-popup::before {
|
||||
@ -695,7 +695,7 @@ button > * {
|
||||
right: -10px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background-image: url(../../images/close.svg) !important;
|
||||
background-image: url("../../images/close.svg") !important;
|
||||
background-repeat: no-repeat !important;
|
||||
}
|
||||
|
||||
@ -710,11 +710,12 @@ button > * {
|
||||
}
|
||||
|
||||
.gm-style .gm-style-iw-t::after {
|
||||
background: linear-gradient(45deg, rgb(102, 102, 102) 50%, rgba(255, 255, 255, 0) 51%, rgba(255, 255, 255, 0) 100%) !important;
|
||||
/* stylelint-disable-next-line max-line-length */
|
||||
background: linear-gradient(45deg, rgb(102, 102, 102) 50%, rgba(255, 255, 255, 0%) 51%, rgba(255, 255, 255, 0%) 100%) !important;
|
||||
}
|
||||
|
||||
.gm-style-iw button {
|
||||
background-image: url(../../images/close.svg) !important;
|
||||
background-image: url("../../images/close.svg") !important;
|
||||
background-repeat: no-repeat !important;
|
||||
}
|
||||
|
||||
@ -744,11 +745,11 @@ button > * {
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
background-color: rgba(0, 60, 136, 0.5);
|
||||
background-color: rgba(0, 60, 136, 50%);
|
||||
}
|
||||
|
||||
.ol-layerswitcher:hover {
|
||||
background-color: rgba(0, 60, 136, 0.7);
|
||||
background-color: rgba(0, 60, 136, 70%);
|
||||
}
|
||||
|
||||
.ol-layerswitcher label {
|
||||
|
@ -17,15 +17,15 @@
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('ROOT_DIR')) { define('ROOT_DIR', dirname(__DIR__)); }
|
||||
require_once(ROOT_DIR . "/helpers/user.php");
|
||||
require_once(ROOT_DIR . "/helpers/utils.php");
|
||||
if (!defined('BASE_URL')) { define('BASE_URL', uUtils::getBaseUrl()); }
|
||||
if (!defined('ROOT_DIR')) { define('ROOT_DIR', dirname(__DIR__)); }
|
||||
require_once(ROOT_DIR . "/helpers/user.php");
|
||||
require_once(ROOT_DIR . "/helpers/utils.php");
|
||||
if (!defined('BASE_URL')) { define('BASE_URL', uUtils::getBaseUrl()); }
|
||||
|
||||
/**
|
||||
* Authentication
|
||||
*/
|
||||
class uAuth {
|
||||
class uAuth {
|
||||
|
||||
/** @var bool Is user authenticated */
|
||||
private $isAuthenticated = false;
|
||||
@ -198,4 +198,4 @@
|
||||
return $this->hasReadWriteAccess($ownerId) || uConfig::getInstance()->publicTracks;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
require_once(ROOT_DIR . "/helpers/utils.php");
|
||||
|
||||
/**
|
||||
/**
|
||||
* PDO wrapper
|
||||
*/
|
||||
class uDb extends PDO {
|
||||
class uDb extends PDO {
|
||||
/**
|
||||
* Singleton instance
|
||||
*
|
||||
@ -275,7 +275,7 @@ require_once(ROOT_DIR . "/helpers/utils.php");
|
||||
*/
|
||||
public static function getDbName($dsn) {
|
||||
$name = "";
|
||||
if (strpos($dsn, ":") !== false) {
|
||||
if ($dsn && strpos($dsn, ":") !== false) {
|
||||
list($scheme, $dsnWithoutScheme) = explode(":", $dsn, 2);
|
||||
switch ($scheme) {
|
||||
case "sqlite":
|
||||
@ -301,7 +301,7 @@ require_once(ROOT_DIR . "/helpers/utils.php");
|
||||
/**
|
||||
* Normalize DSN.
|
||||
* Make sure sqlite DSN file path is absolute
|
||||
* @param $dsn string DSN
|
||||
* @param string $dsn DSN
|
||||
* @return string Normalized DSN
|
||||
*/
|
||||
public static function normalizeDsn($dsn) {
|
||||
@ -316,5 +316,5 @@ require_once(ROOT_DIR . "/helpers/utils.php");
|
||||
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR . $arr[1];
|
||||
return $scheme . ":" . realpath(dirname($path)) . DIRECTORY_SEPARATOR . basename(($path));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -17,12 +17,12 @@
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once(ROOT_DIR . "/helpers/config.php");
|
||||
require_once(ROOT_DIR . "/helpers/config.php");
|
||||
|
||||
/**
|
||||
/**
|
||||
* Localization
|
||||
*/
|
||||
class uLang {
|
||||
class uLang {
|
||||
|
||||
/**
|
||||
* Available languages
|
||||
@ -111,6 +111,6 @@
|
||||
return $this->setupStrings;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -21,10 +21,10 @@ require_once(ROOT_DIR . "/helpers/db.php");
|
||||
require_once(ROOT_DIR . "/helpers/track.php");
|
||||
require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
|
||||
/**
|
||||
/**
|
||||
* Positions handling
|
||||
*/
|
||||
class uPosition {
|
||||
class uPosition {
|
||||
/** @param int Position id */
|
||||
public $id;
|
||||
/** @param int Unix time stamp */
|
||||
@ -62,7 +62,7 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* Constructor
|
||||
* @param integer $positionId Position id
|
||||
*/
|
||||
public function __construct($positionId = NULL) {
|
||||
public function __construct($positionId = null) {
|
||||
|
||||
if (!empty($positionId)) {
|
||||
$query = "SELECT p.id, " . self::db()->unix_timestamp('p.time') . " AS tstamp, p.user_id, p.track_id,
|
||||
@ -118,8 +118,8 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* @return int|bool New position id in database, false on error
|
||||
*/
|
||||
public static function add($userId, $trackId, $timestamp, $lat, $lon,
|
||||
$altitude = NULL, $speed = NULL, $bearing = NULL, $accuracy = NULL,
|
||||
$provider = NULL, $comment = NULL, $image = NULL) {
|
||||
$altitude = null, $speed = null, $bearing = null, $accuracy = null,
|
||||
$provider = null, $comment = null, $image = null) {
|
||||
$positionId = false;
|
||||
if (is_numeric($lat) && is_numeric($lon) && is_numeric($timestamp) && is_numeric($userId) && is_numeric($trackId)) {
|
||||
$track = new uTrack($trackId);
|
||||
@ -196,7 +196,7 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
$stmt->execute([ $this->id ]);
|
||||
$this->removeImage();
|
||||
$ret = true;
|
||||
$this->id = NULL;
|
||||
$this->id = null;
|
||||
$this->isValid = false;
|
||||
} catch (PDOException $e) {
|
||||
// TODO: handle exception
|
||||
@ -213,7 +213,7 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* @param int $trackId Optional track id
|
||||
* @return bool True if success, false otherwise
|
||||
*/
|
||||
public static function deleteAll($userId, $trackId = NULL) {
|
||||
public static function deleteAll($userId, $trackId = null) {
|
||||
$ret = false;
|
||||
if (!empty($userId)) {
|
||||
$args = [];
|
||||
@ -244,13 +244,13 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* @param int $userId Optional user id
|
||||
* @return uPosition Position
|
||||
*/
|
||||
public static function getLast($userId = NULL) {
|
||||
public static function getLast($userId = null) {
|
||||
if (!empty($userId)) {
|
||||
$where = "WHERE p.user_id = ?";
|
||||
$params = [ $userId ];
|
||||
} else {
|
||||
$where = "";
|
||||
$params = NULL;
|
||||
$params = null;
|
||||
}
|
||||
$query = "SELECT p.id, " . self::db()->unix_timestamp('p.time') . " AS tstamp, p.user_id, p.track_id,
|
||||
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
|
||||
@ -311,7 +311,7 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* @param array $rules Optional rules
|
||||
* @return uPosition[]|bool Array of uPosition positions, false on error
|
||||
*/
|
||||
public static function getAll($userId = NULL, $trackId = NULL, $afterId = NULL, $rules = []) {
|
||||
public static function getAll($userId = null, $trackId = null, $afterId = null, $rules = []) {
|
||||
if (!empty($userId)) {
|
||||
$rules[] = "p.user_id = " . self::db()->quote($userId);
|
||||
}
|
||||
@ -357,7 +357,7 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* @param array $rules Optional rules
|
||||
* @return uPosition[]|bool Array of uPosition positions, false on error
|
||||
*/
|
||||
public static function getAllWithImage($userId = NULL, $trackId = NULL, $afterId = NULL, $rules = []) {
|
||||
public static function getAllWithImage($userId = null, $trackId = null, $afterId = null, $rules = []) {
|
||||
$rules[] = "p.image IS NOT NULL";
|
||||
return self::getAll($userId, $trackId, $afterId, $rules);
|
||||
}
|
||||
@ -369,7 +369,7 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* @param int $trackId Optional track id
|
||||
* @return bool True if success, false otherwise
|
||||
*/
|
||||
public static function removeImages($userId, $trackId = NULL) {
|
||||
public static function removeImages($userId, $trackId = null) {
|
||||
if (($positions = self::getAllWithImage($userId, $trackId)) !== false) {
|
||||
foreach ($positions as $position) {
|
||||
try {
|
||||
@ -477,7 +477,7 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
* @param array|null $params Optional array of bind parameters
|
||||
* @throws PDOException
|
||||
*/
|
||||
private function loadWithQuery($query, $params = NULL) {
|
||||
private function loadWithQuery($query, $params = null) {
|
||||
$stmt = self::db()->prepare($query);
|
||||
$stmt->execute($params);
|
||||
|
||||
@ -500,6 +500,6 @@ require_once(ROOT_DIR . "/helpers/upload.php");
|
||||
$this->isValid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -20,10 +20,10 @@
|
||||
require_once(ROOT_DIR . "/helpers/db.php");
|
||||
require_once(ROOT_DIR . "/helpers/position.php");
|
||||
|
||||
/**
|
||||
/**
|
||||
* Track handling
|
||||
*/
|
||||
class uTrack {
|
||||
class uTrack {
|
||||
public $id;
|
||||
public $userId;
|
||||
public $name;
|
||||
@ -36,7 +36,7 @@
|
||||
*
|
||||
* @param int $trackId Track id
|
||||
*/
|
||||
public function __construct($trackId = NULL) {
|
||||
public function __construct($trackId = null) {
|
||||
|
||||
if (!empty($trackId)) {
|
||||
try {
|
||||
@ -75,7 +75,7 @@
|
||||
* @param string $comment Optional comment
|
||||
* @return int|bool New track id, false on error
|
||||
*/
|
||||
public static function add($userId, $name, $comment = NULL) {
|
||||
public static function add($userId, $name, $comment = null) {
|
||||
$trackId = false;
|
||||
if (!empty($userId) && !empty($name)) {
|
||||
try {
|
||||
@ -110,8 +110,8 @@
|
||||
* @return int|bool New position id in database, false on error
|
||||
*/
|
||||
public function addPosition($userId, $timestamp, $lat, $lon,
|
||||
$altitude = NULL, $speed = NULL, $bearing = NULL, $accuracy = NULL,
|
||||
$provider = NULL, $comment = NULL, $imageId = NULL) {
|
||||
$altitude = null, $speed = null, $bearing = null, $accuracy = null,
|
||||
$provider = null, $comment = null, $imageId = null) {
|
||||
return uPosition::add($userId, $this->id, $timestamp, $lat, $lon,
|
||||
$altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId);
|
||||
}
|
||||
@ -134,10 +134,10 @@
|
||||
$stmt = self::db()->prepare($query);
|
||||
$stmt->execute([ $this->id ]);
|
||||
$ret = true;
|
||||
$this->id = NULL;
|
||||
$this->userId = NULL;
|
||||
$this->name = NULL;
|
||||
$this->comment = NULL;
|
||||
$this->id = null;
|
||||
$this->userId = null;
|
||||
$this->name = null;
|
||||
$this->comment = null;
|
||||
$this->isValid = false;
|
||||
} catch (PDOException $e) {
|
||||
// TODO: handle exception
|
||||
@ -150,15 +150,15 @@
|
||||
/**
|
||||
* Update track
|
||||
*
|
||||
* @param string|null $name New name (not empty string) or NULL if not changed
|
||||
* @param string|null $comment New comment or NULL if not changed (to remove content use empty string: "")
|
||||
* @param string|null $name New name (not empty string) or null if not changed
|
||||
* @param string|null $comment New comment or null if not changed (to remove content use empty string: "")
|
||||
* @return bool True if success, false otherwise
|
||||
*/
|
||||
public function update($name = NULL, $comment = NULL) {
|
||||
public function update($name = null, $comment = null) {
|
||||
$ret = false;
|
||||
if (empty($name)) { $name = $this->name; }
|
||||
if (is_null($comment)) { $comment = $this->comment; }
|
||||
if ($comment === "") { $comment = NULL; }
|
||||
if ($comment === "") { $comment = null; }
|
||||
if ($this->isValid) {
|
||||
try {
|
||||
$query = "UPDATE " . self::db()->table('tracks') . " SET name = ?, comment = ? WHERE id = ?";
|
||||
@ -205,7 +205,7 @@
|
||||
* @param int $userId Optional limit to user id
|
||||
* @return array|bool Array of uTrack tracks, false on error
|
||||
*/
|
||||
public static function getAll($userId = NULL) {
|
||||
public static function getAll($userId = null) {
|
||||
if (!empty($userId)) {
|
||||
$where = "WHERE user_id=" . self::db()->quote($userId);
|
||||
} else {
|
||||
@ -241,6 +241,6 @@
|
||||
$track->isValid = true;
|
||||
return $track;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -61,20 +61,20 @@ class uUpload {
|
||||
/**
|
||||
* Get file extension for given mime
|
||||
* @param $mime
|
||||
* @return string|null Extension or NULL if not found
|
||||
* @return string|null Extension or null if not found
|
||||
*/
|
||||
private static function getExtension($mime) {
|
||||
if (self::isKnownMime($mime)) {
|
||||
return self::getMimeMap()[$mime];
|
||||
}
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save file to uploads, basic sanitizing
|
||||
* @param array $uploaded File meta array from $_FILES[]
|
||||
* @param int $trackId
|
||||
* @return string|NULL Unique file name, null on error
|
||||
* @return string|null Unique file name, null on error
|
||||
*/
|
||||
public static function add($uploaded, $trackId) {
|
||||
try {
|
||||
@ -82,7 +82,7 @@ class uUpload {
|
||||
} catch (Exception $e) {
|
||||
syslog(LOG_ERR, $e->getMessage());
|
||||
// save exception to txt file as image replacement?
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
$extension = self::getExtension($fileMeta[self::META_TYPE]);
|
||||
@ -93,7 +93,7 @@ class uUpload {
|
||||
if (move_uploaded_file($fileMeta[self::META_TMP_NAME], self::$uploadDir . $fileName)) {
|
||||
return $fileName;
|
||||
}
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,7 +140,7 @@ class uUpload {
|
||||
$uploadErrors[UPLOAD_ERR_CANT_WRITE] = "Failed to write file to disk";
|
||||
$uploadErrors[UPLOAD_ERR_EXTENSION] = "A PHP extension stopped file upload";
|
||||
|
||||
$file = NULL;
|
||||
$file = null;
|
||||
$fileError = isset($fileMeta[self::META_ERROR]) ? $fileMeta[self::META_ERROR] : UPLOAD_ERR_OK;
|
||||
if ($fileMeta[self::META_SIZE] > uUtils::getSystemUploadLimit() && $fileError == UPLOAD_ERR_OK) {
|
||||
$fileError = UPLOAD_ERR_FORM_SIZE;
|
||||
|
@ -20,10 +20,10 @@
|
||||
require_once(ROOT_DIR . "/helpers/track.php");
|
||||
require_once(ROOT_DIR . "/helpers/position.php");
|
||||
|
||||
/**
|
||||
/**
|
||||
* User handling routines
|
||||
*/
|
||||
class uUser {
|
||||
class uUser {
|
||||
public $id;
|
||||
public $login;
|
||||
public $hash;
|
||||
@ -35,7 +35,7 @@
|
||||
*
|
||||
* @param string $login Login
|
||||
*/
|
||||
public function __construct($login = NULL) {
|
||||
public function __construct($login = null) {
|
||||
if (!empty($login)) {
|
||||
try {
|
||||
$query = "SELECT id, login, password, admin FROM " . self::db()->table('users') . " WHERE login = ? LIMIT 1";
|
||||
@ -109,9 +109,9 @@
|
||||
$stmt = self::db()->prepare($query);
|
||||
$stmt->execute([ $this->id ]);
|
||||
$ret = true;
|
||||
$this->id = NULL;
|
||||
$this->login = NULL;
|
||||
$this->hash = NULL;
|
||||
$this->id = null;
|
||||
$this->login = null;
|
||||
$this->hash = null;
|
||||
$this->isValid = false;
|
||||
$this->isAdmin = false;
|
||||
} catch (PDOException $e) {
|
||||
@ -237,5 +237,5 @@
|
||||
$user->isValid = true;
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -17,10 +17,10 @@
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* Various util functions
|
||||
*/
|
||||
class uUtils {
|
||||
class uUtils {
|
||||
|
||||
/**
|
||||
* Calculate maximum allowed size of uploaded file
|
||||
@ -78,7 +78,7 @@
|
||||
* @param string $errorMessage Message
|
||||
* @param array|null $extra Optional array of extra parameters
|
||||
*/
|
||||
public static function exitWithError($errorMessage, $extra = NULL) {
|
||||
public static function exitWithError($errorMessage, $extra = null) {
|
||||
$extra['message'] = $errorMessage;
|
||||
self::exitWithStatus(true, $extra);
|
||||
}
|
||||
@ -88,7 +88,7 @@
|
||||
*
|
||||
* @param array|null $extra Optional array of extra parameters
|
||||
*/
|
||||
public static function exitWithSuccess($extra = NULL) {
|
||||
public static function exitWithSuccess($extra = null) {
|
||||
self::exitWithStatus(false, $extra);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@
|
||||
* @param boolean $isError Error if true
|
||||
* @param array|null $extra Optional array of extra parameters
|
||||
*/
|
||||
private static function exitWithStatus($isError, $extra = NULL) {
|
||||
private static function exitWithStatus($isError, $extra = null) {
|
||||
$output = [];
|
||||
if ($isError) {
|
||||
$output["error"] = true;
|
||||
@ -137,45 +137,45 @@
|
||||
return $proto . str_replace("//", "/", $host . $path . "/");
|
||||
}
|
||||
|
||||
public static function postFloat($name, $default = NULL) {
|
||||
public static function postFloat($name, $default = null) {
|
||||
return self::requestValue($name, $default, INPUT_POST, FILTER_VALIDATE_FLOAT);
|
||||
}
|
||||
|
||||
public static function getFloat($name, $default = NULL) {
|
||||
public static function getFloat($name, $default = null) {
|
||||
return self::requestValue($name, $default, INPUT_GET, FILTER_VALIDATE_FLOAT);
|
||||
}
|
||||
|
||||
public static function postPass($name, $default = NULL) {
|
||||
public static function postPass($name, $default = null) {
|
||||
return self::requestValue($name, $default, INPUT_POST);
|
||||
}
|
||||
|
||||
public static function postString($name, $default = NULL) {
|
||||
public static function postString($name, $default = null) {
|
||||
return self::requestString($name, $default, INPUT_POST);
|
||||
}
|
||||
|
||||
public static function getString($name, $default = NULL) {
|
||||
public static function getString($name, $default = null) {
|
||||
return self::requestString($name, $default, INPUT_GET);
|
||||
}
|
||||
|
||||
public static function postBool($name, $default = NULL) {
|
||||
public static function postBool($name, $default = null) {
|
||||
$input = filter_input(INPUT_POST, $name, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
return $input !== null ? (bool) $input : $default;
|
||||
}
|
||||
|
||||
public static function getBool($name, $default = NULL) {
|
||||
public static function getBool($name, $default = null) {
|
||||
$input = filter_input(INPUT_GET, $name, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
return $input !== null ? (bool) $input : $default;
|
||||
}
|
||||
|
||||
public static function postInt($name, $default = NULL) {
|
||||
public static function postInt($name, $default = null) {
|
||||
return self::requestInt($name, $default, INPUT_POST);
|
||||
}
|
||||
|
||||
public static function getInt($name, $default = NULL) {
|
||||
public static function getInt($name, $default = null) {
|
||||
return self::requestInt($name, $default, INPUT_GET);
|
||||
}
|
||||
|
||||
public static function requestFile($name, $default = NULL) {
|
||||
public static function requestFile($name, $default = null) {
|
||||
if (isset($_FILES[$name])) {
|
||||
$files = $_FILES[$name];
|
||||
if (isset($files["name"], $files["type"], $files["size"], $files["tmp_name"])) {
|
||||
@ -185,7 +185,7 @@
|
||||
return $default;
|
||||
}
|
||||
|
||||
public static function postArray($name, $default = NULL) {
|
||||
public static function postArray($name, $default = null) {
|
||||
return ((isset($_POST[$name]) && is_array($_POST[$name])) ? $_POST[$name] : $default);
|
||||
}
|
||||
|
||||
@ -222,6 +222,6 @@
|
||||
return $default;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
38
index.php
38
index.php
@ -17,32 +17,32 @@
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/helpers/auth.php');
|
||||
require_once(ROOT_DIR . '/helpers/config.php');
|
||||
require_once(ROOT_DIR . '/helpers/position.php');
|
||||
require_once(ROOT_DIR . '/helpers/track.php');
|
||||
require_once(ROOT_DIR . '/helpers/utils.php');
|
||||
require_once(ROOT_DIR . '/helpers/lang.php');
|
||||
require_once(__DIR__ . '/helpers/auth.php');
|
||||
require_once(ROOT_DIR . '/helpers/config.php');
|
||||
require_once(ROOT_DIR . '/helpers/position.php');
|
||||
require_once(ROOT_DIR . '/helpers/track.php');
|
||||
require_once(ROOT_DIR . '/helpers/utils.php');
|
||||
require_once(ROOT_DIR . '/helpers/lang.php');
|
||||
|
||||
$login = uUtils::postString('user');
|
||||
$pass = uUtils::postPass('pass');
|
||||
$action = uUtils::postString('action');
|
||||
$login = uUtils::postString('user');
|
||||
$pass = uUtils::postPass('pass');
|
||||
$action = uUtils::postString('action');
|
||||
|
||||
$config = uConfig::getInstance();
|
||||
$lang = (new uLang($config))->getStrings();
|
||||
$langsArr = uLang::getLanguages();
|
||||
$config = uConfig::getInstance();
|
||||
$lang = (new uLang($config))->getStrings();
|
||||
$langsArr = uLang::getLanguages();
|
||||
|
||||
$auth = new uAuth();
|
||||
if ($action === 'auth') {
|
||||
$auth = new uAuth();
|
||||
if ($action === 'auth') {
|
||||
$auth->checkLogin($login, $pass);
|
||||
}
|
||||
}
|
||||
|
||||
if ($action === 'auth' && !$auth->isAuthenticated()) {
|
||||
if ($action === 'auth' && !$auth->isAuthenticated()) {
|
||||
$auth->exitWithRedirect('login.php?auth_error=1');
|
||||
}
|
||||
if ($config->requireAuthentication && !$auth->isAuthenticated()) {
|
||||
}
|
||||
if ($config->requireAuthentication && !$auth->isAuthenticated()) {
|
||||
$auth->exitWithRedirect('login.php');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
@ -199,7 +199,7 @@ export default class ConfigDialogModel extends ViewModel {
|
||||
}
|
||||
return `<div><img style="vertical-align: bottom; margin-right: 10px;" src="images/settings.svg" alt="${$._('settings')}"> <b>${$._('editingconfig')}</b></div>
|
||||
<div style="clear: both; padding-bottom: 1em;"></div>
|
||||
<form id="configForm">
|
||||
<form id="config-form">
|
||||
<label><b>${$._('language')}</b>
|
||||
<select data-bind="lang">
|
||||
${langOptions}
|
||||
|
@ -138,7 +138,7 @@ foreach ($gpxFiles as $i => $gpxFile) {
|
||||
$trackCnt = 0;
|
||||
foreach ($gpx->trk as $trk) {
|
||||
$trackName = empty($trk->name) ? $gpxName : (string) $trk->name;
|
||||
$metaName = empty($gpx->metadata->name) ? NULL : (string) $gpx->metadata->name;
|
||||
$metaName = empty($gpx->metadata->name) ? null : (string) $gpx->metadata->name;
|
||||
$trackId = uTrack::add($userId, $trackName, $metaName);
|
||||
if ($trackId === false) {
|
||||
uUtils::exitWithError($lang["servererror"]);
|
||||
@ -154,10 +154,10 @@ foreach ($gpxFiles as $i => $gpxFile) {
|
||||
uUtils::exitWithError($lang["iparsefailure"]);
|
||||
}
|
||||
$time = isset($point->time) ? strtotime($point->time) : 0;
|
||||
$altitude = isset($point->ele) ? (double) $point->ele : NULL;
|
||||
$speed = NULL;
|
||||
$bearing = NULL;
|
||||
$accuracy = NULL;
|
||||
$altitude = isset($point->ele) ? (double) $point->ele : null;
|
||||
$speed = null;
|
||||
$bearing = null;
|
||||
$accuracy = null;
|
||||
$provider = "gps";
|
||||
if (!empty($point->extensions)) {
|
||||
// parse ulogger extensions
|
||||
@ -169,7 +169,7 @@ foreach ($gpxFiles as $i => $gpxFile) {
|
||||
}
|
||||
$ret = $track->addPosition($userId,
|
||||
$time, (double) $point["lat"], (double) $point["lon"], $altitude,
|
||||
$speed, $bearing, $accuracy, $provider, NULL, NULL);
|
||||
$speed, $bearing, $accuracy, $provider, null, null);
|
||||
if ($ret === false) {
|
||||
$track->delete();
|
||||
uUtils::exitWithError($lang["servererror"]);
|
||||
|
@ -100,8 +100,8 @@ if ($trackId && $userId) {
|
||||
$xml->setIndent(true);
|
||||
$xml->startDocument("1.0", "utf-8");
|
||||
$xml->startElement("kml");
|
||||
$xml->writeAttributeNs("xsi", "schemaLocation", NULL, "http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd");
|
||||
$xml->writeAttributeNs("xmlns", "xsi", NULL, "http://www.w3.org/2001/XMLSchema-instance");
|
||||
$xml->writeAttributeNs("xsi", "schemaLocation", null, "http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd");
|
||||
$xml->writeAttributeNs("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
|
||||
$xml->writeAttribute("xmlns", "http://www.opengis.net/kml/2.2");
|
||||
$xml->startElement("Document");
|
||||
$xml->writeElement("name", $positionsArr[0]->trackName);
|
||||
@ -182,9 +182,9 @@ if ($trackId && $userId) {
|
||||
$xml->startDocument("1.0", "utf-8");
|
||||
$xml->startElement("gpx");
|
||||
$xml->writeAttribute("xmlns", "http://www.topografix.com/GPX/1/1");
|
||||
$xml->writeAttributeNs("xsi", "schemaLocation", NULL, "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd https://github.com/bfabiszewski/ulogger-android/1 https://raw.githubusercontent.com/bfabiszewski/ulogger-server/master/scripts/gpx_extensions1.xsd");
|
||||
$xml->writeAttributeNs("xmlns", "xsi", NULL, "http://www.w3.org/2001/XMLSchema-instance");
|
||||
$xml->writeAttributeNs("xmlns", "ulogger", NULL, "https://github.com/bfabiszewski/ulogger-android/1");
|
||||
$xml->writeAttributeNs("xsi", "schemaLocation", null, "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd https://github.com/bfabiszewski/ulogger-android/1 https://raw.githubusercontent.com/bfabiszewski/ulogger-server/master/scripts/gpx_extensions1.xsd");
|
||||
$xml->writeAttributeNs("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
|
||||
$xml->writeAttributeNs("xmlns", "ulogger", null, "https://github.com/bfabiszewski/ulogger-android/1");
|
||||
$xml->writeAttribute("creator", "μlogger-server " . $config->version);
|
||||
$xml->writeAttribute("version", "1.1");
|
||||
$xml->startElement("metadata");
|
||||
@ -206,7 +206,9 @@ if ($trackId && $userId) {
|
||||
$xml->startElement("trkpt");
|
||||
$xml->writeAttribute("lat", $position->latitude);
|
||||
$xml->writeAttribute("lon", $position->longitude);
|
||||
if (!is_null($position->altitude)) { $xml->writeElement("ele", $position->altitude); }
|
||||
if (!is_null($position->altitude)) {
|
||||
$xml->writeElement("ele", $position->altitude);
|
||||
}
|
||||
$xml->writeElement("time", gmdate("Y-m-d\TH:i:s\Z", $position->timestamp));
|
||||
$xml->writeElement("name", ++$i);
|
||||
if (!is_null($position->comment)) {
|
||||
@ -218,18 +220,17 @@ if ($trackId && $userId) {
|
||||
$xml->startElement("extensions");
|
||||
|
||||
if (!is_null($position->speed)) {
|
||||
$xml->writeElementNS("ulogger", "speed", NULL, $position->speed);
|
||||
$xml->writeElementNS("ulogger", "speed", null, $position->speed);
|
||||
}
|
||||
if (!is_null($position->bearing)) {
|
||||
$xml->writeElementNS("ulogger", "bearing", NULL, $position->bearing);
|
||||
$xml->writeElementNS("ulogger", "bearing", null, $position->bearing);
|
||||
}
|
||||
if (!is_null($position->accuracy)) {
|
||||
$xml->writeElementNS("ulogger", "accuracy", NULL, $position->accuracy);
|
||||
$xml->writeElementNS("ulogger", "accuracy", null, $position->accuracy);
|
||||
}
|
||||
if (!is_null($position->provider)) {
|
||||
$xml->writeElementNS("ulogger", "provider", NULL, $position->provider);
|
||||
$xml->writeElementNS("ulogger", "provider", null, $position->provider);
|
||||
}
|
||||
|
||||
$xml->endElement();
|
||||
}
|
||||
$xml->endElement();
|
||||
|
@ -41,7 +41,7 @@ if ($admin && !$auth->isAdmin()) {
|
||||
}
|
||||
|
||||
$aUser = new uUser($login);
|
||||
$data = NULL;
|
||||
$data = null;
|
||||
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
|
@ -73,7 +73,7 @@ else if (empty($gpx->trk)) {
|
||||
$trackList = [];
|
||||
foreach ($gpx->trk as $trk) {
|
||||
$trackName = empty($trk->name) ? $gpxName : (string) $trk->name;
|
||||
$metaName = empty($gpx->metadata->name) ? NULL : (string) $gpx->metadata->name;
|
||||
$metaName = empty($gpx->metadata->name) ? null : (string) $gpx->metadata->name;
|
||||
$trackId = uTrack::add($auth->user->id, $trackName, $metaName);
|
||||
if ($trackId === false) {
|
||||
uUtils::exitWithError($lang["servererror"]);
|
||||
@ -89,11 +89,11 @@ foreach ($gpx->trk as $trk) {
|
||||
uUtils::exitWithError($lang["iparsefailure"]);
|
||||
}
|
||||
$time = isset($point->time) ? strtotime($point->time) : 1;
|
||||
$altitude = isset($point->ele) ? (double) $point->ele : NULL;
|
||||
$comment = isset($point->desc) && !empty($point->desc) ? (string) $point->desc : NULL;
|
||||
$speed = NULL;
|
||||
$bearing = NULL;
|
||||
$accuracy = NULL;
|
||||
$altitude = isset($point->ele) ? (double) $point->ele : null;
|
||||
$comment = isset($point->desc) && !empty($point->desc) ? (string) $point->desc : null;
|
||||
$speed = null;
|
||||
$bearing = null;
|
||||
$accuracy = null;
|
||||
$provider = "gps";
|
||||
if (!empty($point->extensions)) {
|
||||
// parse ulogger extensions
|
||||
@ -105,7 +105,7 @@ foreach ($gpx->trk as $trk) {
|
||||
}
|
||||
$ret = $track->addPosition($auth->user->id,
|
||||
$time, (double) $point["lat"], (double) $point["lon"], $altitude,
|
||||
$speed, $bearing, $accuracy, $provider, $comment, NULL);
|
||||
$speed, $bearing, $accuracy, $provider, $comment, null);
|
||||
if ($ret === false) {
|
||||
$track->delete();
|
||||
uUtils::exitWithError($lang["servererror"]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user