-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unused code (write caches/users on map) * Remove unused code (cleanup access logs) Now this is done via CleanCacheAccessLogsJob.php * Remove unused code (auto archive caches) Now this is done via AutoArchiveCachesJob.php * UserNotify.php code quality upgrade * Remove old delete user CLI scripts. Now it should be done via user admin panel * Remove obsolete runwatch.php Now this job is done via WatchlistNotifyJob.php * Remove obsolete run_publish.php Now this job is done via PublishCachesJob.php * Remove obsolete PowerTrailCronJob.php Now this job is done via GeoPathJob.php * Remove obsolete run_notify.php Now this job is done via NewCachesNotify.Job * Remove obsolete GeoKrety jobs Now this job is done via GeoKretyNewJob.php and GeoKretyDbQueueJob.php * Remove obsolete okapi_cronjob.php Now this job is done via OkapiSignallingJob.php * Remove obsolete repairGeocachesAltitude.php and some cleaning and fixing around cache altitude. - prevent error 'ErrorException: [/srv/ocpl/myroutes_edit.php:46] Undefined variable: route_id' - prevent error 'Undefined variable: route_id in myroutes_search.php' * CS-Fixer fixes * composer.json - add license & htmlpurifier upgrade 4.13.0 -> 4.14.0
- Loading branch information
Showing
44 changed files
with
711 additions
and
1,394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,97 @@ | ||
<?php | ||
|
||
use src\Models\ApplicationContainer; | ||
use src\Models\OcConfig\OcConfig; | ||
use src\Utils\Database\XDb; | ||
use src\Utils\I18n\I18n; | ||
use src\Models\OcConfig\OcConfig; | ||
use src\Models\ApplicationContainer; | ||
use src\Utils\View\View; | ||
|
||
require_once (__DIR__.'/lib/common.inc.php'); | ||
require_once __DIR__ . '/lib/common.inc.php'; | ||
|
||
global $googlemap_key; | ||
$googleMapKey = OcConfig::instance()->getGoogleMapKey(); | ||
|
||
//user logged in? | ||
$loggedUser = ApplicationContainer::GetAuthorizedUser(); | ||
if (!$loggedUser) { | ||
|
||
if (! $loggedUser) { | ||
$target = urlencode(tpl_get_current_page()); | ||
tpl_redirect('login.php?target=' . $target); | ||
|
||
exit; | ||
} | ||
|
||
$view = tpl_getView(); | ||
$view->setTemplate('myroutes_add_map2') | ||
->addLocalJs( | ||
'https://maps.googleapis.com/maps/api/js?libraries=geometry&key=' . $googleMapKey | ||
. '&language=' . I18n::getCurrentLang() | ||
); | ||
|
||
$tplname = 'myroutes_add_map2'; | ||
/** @var View $view */ | ||
$view = tpl_getView(); | ||
$view->addLocalJs( | ||
'https://maps.googleapis.com/maps/api/js?libraries=geometry&key='.$googlemap_key. | ||
'&language='.I18n::getCurrentLang()); | ||
// set map center | ||
tpl_set_var('map_lat', OcConfig::getMapDefaultCenter()->getLatitude()); | ||
tpl_set_var('map_lon', OcConfig::getMapDefaultCenter()->getLongitude()); | ||
tpl_set_var('map_zoom', OcConfig::getStartPageMapZoom() + 1); | ||
|
||
// set map center | ||
tpl_set_var('map_lat',OcConfig::getMapDefaultCenter()->getLatitude()); | ||
tpl_set_var('map_lon',OcConfig::getMapDefaultCenter()->getLongitude()); | ||
tpl_set_var('map_zoom', OcConfig::getStartPageMapZoom() + 1); | ||
$user_id = $loggedUser->getUserId(); | ||
$name = $_POST['name'] ?? ''; | ||
tpl_set_var('name', htmlspecialchars($name, ENT_COMPAT)); | ||
|
||
$user_id = $loggedUser->getUserId(); | ||
$name = isset($_POST['name']) ? $_POST['name'] : ''; | ||
tpl_set_var('name', htmlspecialchars($name, ENT_COMPAT, 'UTF-8')); | ||
$desc = $_POST['desc'] ?? ''; | ||
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT)); | ||
|
||
$desc = isset($_POST['desc']) ? $_POST['desc'] : ''; | ||
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8')); | ||
$radius = $_POST['radius'] ?? '0'; | ||
tpl_set_var('radius', $radius); | ||
|
||
$radius = isset($_POST['radius']) ? $_POST['radius'] : '0'; | ||
tpl_set_var('radius', $radius); | ||
if (isset($_POST['back'])) { | ||
tpl_redirect('myroutes.php'); | ||
|
||
if (isset($_POST['back'])) { | ||
tpl_redirect('myroutes.php'); | ||
exit; | ||
} | ||
exit; | ||
} | ||
|
||
if (isset($_POST['submitform'])) { | ||
$length = isset($_POST['distance']) ? $_POST['distance'] : '0'; | ||
$route_points = isset($_POST['route_points']) ? explode(" ", $_POST['route_points']) : array(); | ||
if (isset($_POST['submitform'])) { | ||
$length = $_POST['distance'] ?? '0'; | ||
$route_points = isset($_POST['route_points']) ? explode(' ', $_POST['route_points']) : []; | ||
|
||
// insert route name | ||
XDb::xSql( | ||
"INSERT INTO `routes` ( | ||
// insert route name | ||
XDb::xSql( | ||
'INSERT INTO `routes` ( | ||
`user_id`, `name`, `description`, `radius`, `length`) | ||
VALUES (?, ?, ?, ?, ?)", | ||
$user_id, $name, $desc, $radius, $length); | ||
|
||
// get route_id | ||
$route_id = XDb::xMultiVariableQueryValue( | ||
"SELECT route_id FROM `routes` | ||
WHERE name= :1 AND description= :2 AND user_id= :3", | ||
0, $name, $desc, $user_id); | ||
|
||
$point_num = 0; | ||
foreach ($route_points as $route_point) { | ||
$point_num++; | ||
$latlng = explode(",", $route_point); | ||
XDb::xSql( | ||
"INSERT into route_points (route_id,point_nr,lat,lon) | ||
VALUES (?, ?, ?, ?)", | ||
$route_id, $point_num, $latlng[0], $latlng[1]); | ||
} | ||
|
||
tpl_redirect('myroutes.php'); | ||
exit; | ||
} //end submit | ||
VALUES (?, ?, ?, ?, ?)', | ||
$user_id, | ||
$name, | ||
$desc, | ||
$radius, | ||
$length | ||
); | ||
|
||
// get route_id | ||
$route_id = XDb::xMultiVariableQueryValue( | ||
'SELECT route_id FROM `routes` | ||
WHERE name= :1 AND description= :2 AND user_id= :3', | ||
0, | ||
$name, | ||
$desc, | ||
$user_id | ||
); | ||
|
||
$point_num = 0; | ||
|
||
foreach ($route_points as $route_point) { | ||
$point_num++; | ||
$latlng = explode(',', $route_point); | ||
XDb::xSql( | ||
'INSERT into route_points (route_id,point_nr,lat,lon) | ||
VALUES (?, ?, ?, ?)', | ||
$route_id, | ||
$point_num, | ||
$latlng[0], | ||
$latlng[1] | ||
); | ||
} | ||
|
||
tpl_redirect('myroutes.php'); | ||
|
||
exit; | ||
} //end submit | ||
|
||
//make the template and send it out | ||
tpl_BuildTemplate(); |
Oops, something went wrong.