Skip to content

Commit

Permalink
Code cleaning (#2352)
Browse files Browse the repository at this point in the history
* 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
deg-pl authored Apr 11, 2022
1 parent d31d8a4 commit 6ebc32d
Show file tree
Hide file tree
Showing 44 changed files with 711 additions and 1,394 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "opencaching/opencaching.pl",
"description": "The source code of Opencaching.PL (and some other domains)",
"license": "GPL-3.0-only",
"require": {
"php": "^7.4",
"ext-json": "*",
Expand Down
21 changes: 9 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 70 additions & 55 deletions myroutes_add_map2.php
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&amp;key=' . $googleMapKey
. '&amp;language=' . I18n::getCurrentLang()
);

$tplname = 'myroutes_add_map2';
/** @var View $view */
$view = tpl_getView();
$view->addLocalJs(
'https://maps.googleapis.com/maps/api/js?libraries=geometry&amp;key='.$googlemap_key.
'&amp;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();
Loading

0 comments on commit 6ebc32d

Please sign in to comment.