Skip to content

Commit

Permalink
5394: block changing OC-specific cache types and sizes by ocprop
Browse files Browse the repository at this point in the history
  • Loading branch information
following committed Mar 24, 2013
1 parent 76543d5 commit 7eccc1d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions htdocs/editcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,22 @@ function getWaypoints($cacheid)
$activation_date = 'NULL';
}

// check for Ocprop data to ignore
if ($ocpropping)
{
$rs = sql("SELECT `type`, `size` FROM `caches` WHERE `cache_id`='&1'", $cache_id);
if ($r = sql_fetch_assoc($rs))
{
if ($r['type'] == 8 && $cache_type == 7)
$cache_type = 8;
if ($r['type'] == 10 && $cache_type == 2)
$cache_type = 10;
if ($r['size'] == 8 && ($sel_size == 1 || $sel_size == 2))
$sel_size = 8;
}
sql_free_result($rs);
}

// save to DB
// status update will trigger touching the last_modified date of all depending records
sql("UPDATE `caches` SET `name`='&1', `longitude`='&2', `latitude`='&3', `type`='&4', `date_hidden`='&5', `country`='&6', `size`='&7', `difficulty`='&8', `terrain`='&9', `status`='&10', `search_time`='&11', `way_length`='&12', `logpw`='&13', `wp_gc`='&14', `wp_nc`='&15', `date_activate` = $activation_date WHERE `cache_id`='&16'", $cache_name, $cache_lon, $cache_lat, $cache_type, date('Y-m-d', mktime(0, 0, 0, $cache_hidden_month, $cache_hidden_day, $cache_hidden_year)), $cache_country, $sel_size, $cache_difficulty, $cache_terrain, $status, $search_time, $way_length, $log_pw, $wp_gc, $wp_nc, $cache_id);
Expand Down
5 changes: 5 additions & 0 deletions htdocs/lib/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function __autoload($class_name)
require_once($file);
}



if (isset($opt['rootpath']))
$rootpath = $opt['rootpath'];
else if (isset($rootpath))
Expand Down Expand Up @@ -247,6 +249,9 @@ function __autoload($class_name)
}
}

// are we Ocprop?
$ocpropping = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],"Ocprop/");

// zeitmessung
require_once($rootpath . 'lib/bench.inc.php');
$bScriptExecution = new Cbench;
Expand Down
11 changes: 11 additions & 0 deletions htdocs/lib2/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function __autoload($class_name)
}
}


// yepp, we will use UTF-8
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
Expand Down Expand Up @@ -74,6 +75,8 @@ function __autoload($class_name)
$opt['template']['style'] = $opt['template']['default']['style'];
$opt['stylepath'] = $opt['rootpath'] . 'templates2/' . $opt['template']['style'] . '/';

check_useragent();

/* setup smarty
*
*/
Expand Down Expand Up @@ -228,6 +231,14 @@ function set_timezone()
date_default_timezone_set($opt['php']['timezone']);
}

function check_useragent()
{
global $_SERVER, $ocpropping;

// are we Ocprop?
$ocpropping = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],"Ocprop/");
}

function fix_magic_quotes_gpc()
{
// Disable magic_quotes_runtime
Expand Down

0 comments on commit 7eccc1d

Please sign in to comment.