Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Feb 2, 2016
2 parents 2b2c793 + 359eaac commit d63c4f8
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
2 changes: 2 additions & 0 deletions htdocs/api/email_problems.php
Expand Up @@ -8,6 +8,8 @@
$opt['rootpath'] = '../';
require($opt['rootpath'] . 'lib2/web.inc.php');

header('Content-type: text/plain; charset=utf-8');

if ($opt['logic']['api']['email_problems']['key'] &&
isset($_REQUEST['key']) &&
$opt['logic']['api']['email_problems']['key'] == $_REQUEST['key'])
Expand Down
2 changes: 1 addition & 1 deletion htdocs/api/gc2oc.php
Expand Up @@ -10,7 +10,7 @@
$opt['rootpath'] = '../';
require($opt['rootpath'] . 'lib2/web.inc.php');

header('Content-type: text/html; charset=utf-8');
header('Content-type: text/plain; charset=utf-8');

/*
* caches.wp_gc_maintained is intended for map and search filtering and
Expand Down
27 changes: 27 additions & 0 deletions htdocs/api/hidden_caches.php
@@ -0,0 +1,27 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Returns a list of all caches which have been hidden after publish.
* This allows an easier synchronization of this information on a
* replicated system than the XML interface.
***************************************************************************/

$opt['rootpath'] = '../';
require($opt['rootpath'] . 'lib2/web.inc.php');

header('Content-type: text/plain; charset=utf-8');

$rs = sql("
SELECT `wp_oc`
FROM `caches`
JOIN `cache_status` ON `cache_status`.`id`=`caches`.`status`
WHERE `cache_status`.`allow_user_view`=0 AND `caches`.`status` != 5
ORDER BY `cache_id`");
$wp_ocs = sql_fetch_column($rs);
foreach ($wp_ocs as $wp_oc)
echo $wp_oc."\n";

?>
2 changes: 1 addition & 1 deletion htdocs/api/ping.php
Expand Up @@ -8,7 +8,7 @@
$opt['rootpath'] = '../';
require($opt['rootpath'] . 'lib2/web.inc.php');

header('Content-type: text/html; charset=utf-8');
header('Content-type: text/plain; charset=utf-8');
echo sql_value("SELECT NOW()","");

?>
1 change: 1 addition & 0 deletions htdocs/config2/settings-dist.inc.php
Expand Up @@ -424,6 +424,7 @@
$opt['cron']['autoarchive']['run'] = false;
$opt['cron']['gcwp']['sources'] = array();
$opt['cron']['gcwp']['fulllist'] = '';
$opt['cron']['replicate']['delete_hidden_caches']['url'] = '';

/* E-Mail settings
*
Expand Down
35 changes: 35 additions & 0 deletions htdocs/util2/cron/modules/replicate.class.php
@@ -0,0 +1,35 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Replicate database contents between different OC installations/nodes
***************************************************************************/

checkJob(new replicate());

class replicate
{
var $name = 'replicate';
var $interval = 3600;

function run()
{
global $opt;

if ($opt['cron']['replicate']['delete_hidden_caches']['url'])
{
// This is used to remove unwanted data from test.opencaching.de
// (where any users may have admin rights and see hidden caches).

$hidden_caches = file_get_contents($opt['cron']['replicate']['delete_hidden_caches']['url']);
$hc = explode("\n", trim($hidden_caches));
$hc_imploded_and_escaped = "'" . implode("','", array_map('sql_escape', $hc)) . "'";
sql("DELETE FROM `caches` WHERE `wp_oc` IN (" .$hc_imploded_and_escaped. ")");
// All dependent data in other tables is deleted via trigger.
}
}
}

?>

0 comments on commit d63c4f8

Please sign in to comment.