Skip to content

Commit

Permalink
added tool for geokret waypoint tables consistency check
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Jun 11, 2013
1 parent 51c4629 commit 3c98533
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
4 changes: 4 additions & 0 deletions htdocs/util2/geokrety/.htaccess
@@ -0,0 +1,4 @@
<FilesMatch ".*">
Order Deny,Allow
Deny from All
</FilesMatch>
53 changes: 53 additions & 0 deletions htdocs/util2/geokrety/check-waypoints.php
@@ -0,0 +1,53 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Tests for consistency of gk_item_waypoint und gk_move_waypoint tables.
*
***************************************************************************/

$opt['rootpath'] = '../../';
require_once($opt['rootpath'] . 'lib2/cli.inc.php');

$itemwps = array();

// Get item waypoints
$rs = sql("SELECT `id` AS `itemid`, `wp` FROM `gk_item_waypoint`");
while ($r = sql_fetch_assoc($rs))
$itemwps[$r['itemid']][$r['wp']]['itemwp'] = true;
sql_free_result($rs);

// Get move waypoints
$rsItems = sql("SELECT DISTINCT `itemid` AS `id` FROM `gk_move`");
while ($rItem = sql_fetch_assoc($rsItems))
{
$lastmove = sql_value("
SELECT `id` FROM `gk_move`
WHERE `itemid`='&1'
ORDER BY `datemoved` DESC, `id` DESC
LIMIT 1",
0, $rItem['id']);

$rsWp = sql("
SELECT `wp` FROM `gk_move_waypoint`
LEFT JOIN `gk_move` ON `gk_move`.`id`=`gk_move_waypoint`.`id`
WHERE `gk_move`.`id`='&1' AND `logtypeid` IN (0,3)",
$lastmove);
while ($rWp = sql_fetch_assoc($rsWp))
$itemwps[$rItem['id']][$rWp['wp']]['movewp'] = true;
sql_free_result($rsWp);
}
sql_free_result($rsItems);

// test for missing waypoints
ksort($itemwps);
foreach ($itemwps as $itemid => $wps)
foreach ($wps as $wp => $flags)
if (isset($flags['itemwp']) && !isset($flags['movewp']))
echo "item ".$itemid.": ".$wp." is not the current wp in gk_move_waypoint\n";
else if (isset($flags['movewp']) && !isset($flags['itemwp']))
echo "item ".$itemid.": current wp ".$wp." is missing in gk_item_waypoint\n";

?>
2 changes: 1 addition & 1 deletion htdocs/util2/license/process-old-disabled-users.php
Expand Up @@ -12,7 +12,7 @@
***************************************************************************/

$opt['rootpath'] = '../../';
require_once($opt['rootpath'] . 'lib2/web.inc.php');
require_once($opt['rootpath'] . 'lib2/cli.inc.php');
require_once($opt['rootpath'] . 'lib2/logic/user.class.php');

$login->admin = ADMIN_USER;
Expand Down

0 comments on commit 3c98533

Please sign in to comment.