Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ _tables.php
_globals.php
_cfg.php
/logs
.agents/*
.agents
skills-lock.json
1 change: 1 addition & 0 deletions _SQL/zmeny.sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function AddZmenyFile($version)
AddZmenyFile('3.4.5.652');
AddZmenyFile('3.4.5.655');
AddZmenyFile('3.4.6.656');
AddZmenyFile('3.4.5.658');
//#############################################################################

require_once ('connect.inc.php');
Expand Down
24 changes: 24 additions & 0 deletions _SQL/zmeny_3.4.5.658.sql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?
// zmeny pro verzi 3.4.9.658 - ORIS API integration

$version_upd = '3.4.5.658';

//#############################################################################

require_once ('prepare.inc.php');

//#############################################################################
// SQL dotazy pro zmenu db. na novejsi verzi
//############################################################################
$sql[0] = "ALTER TABLE `".TBL_ZAVXUS."`
ADD COLUMN `oris_entry_id` INT UNSIGNED NULL,
ADD COLUMN `sync_status` ENUM('LOCAL_ONLY', 'SYNCED', 'PENDING_CREATE', 'PENDING_UPDATE', 'PENDING_DELETE', 'FAILED_CREATE', 'FAILED_UPDATE', 'FAILED_DELETE') NOT NULL DEFAULT 'LOCAL_ONLY',
ADD COLUMN `sync_timestamp` DATETIME NULL,
ADD COLUMN `sync_error_payload` TEXT NULL,
ADD INDEX `sync_status` (`sync_status`)";

$sql[1] = "ALTER TABLE `".TBL_RACE."`
ADD COLUMN `oris_entry_start` DATETIME NULL";

require_once ('action.inc.php');
?>
44 changes: 44 additions & 0 deletions adm_oris_sync.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
define("__HIDE_TEST__", "_KeAr_PHP_WEB_");
require_once("connect.inc.php");
require_once("sess.inc.php");
require_once("common.inc.php");

if (!IsLoggedAdmin() && !IsLoggedRegistrator()) {
die("Access denied. You must be an administrator or a registrator to run this script manually.");
}

?>
<!DOCTYPE html>
<html>
<head>
<title>ORIS Sync Daemon Manual Trigger</title>
<style>
body { font-family: monospace; background: #222; color: #0f0; padding: 20px; }
.log { white-space: pre-wrap; margin-top: 20px; }
.btn { padding: 10px 20px; background: #444; color: #fff; text-decoration: none; border: 1px solid #777; }
</style>
</head>
<body>
<h2>Manual ORIS Sync Execution</h2>
<p>Executing daemon...</p>
<div class="log">
<?php
// Capture output
ob_start();
define('ORIS_MANUAL_SYNC', true);
try {
require_once("oris_sync_daemon.php");
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
$output = ob_get_clean();

// Display standard output
echo htmlspecialchars($output);
?>
</div>
<br>
<a href="index.php" class="btn">Return to System</a>
</body>
</html>
25 changes: 14 additions & 11 deletions ads_oris.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,24 @@ function startsWith( $haystack, $needle ) {
return substr( $haystack, 0, $length ) === $needle;
}

$json = file_get_contents('https://oris.orientacnisporty.cz/API/?format=json&method=getRegistration&sport=1&year='.$ORIS_year);
$obj = json_decode($json);
require_once './lib/OrisIntegrationService.php';
$service = new OrisIntegrationService(null);
$obj = $service->getRegistration(1, $ORIS_year);

$arr_oris = array();

foreach ($obj->Data as $key=>$value)
{
$user = new User();
$user->create($value->UserID, $value->FirstName, $value->LastName, $value->RegNo, $value->SI, $value->ClubID);

$reg = $value->RegNo;
if (startsWith($reg, $g_shortcut))
if (is_array($obj) || is_object($obj)) {
foreach ($obj as $key=>$value)
{
$arr_oris["user"] [$reg]= $user;
$arr_oris["members"][$reg] = 0;
$user = new User();
$user->create($value['UserID'], $value['FirstName'], $value['LastName'], $value['RegNo'], $value['SI'], $value['ClubID']);

$reg = $value['RegNo'];
if (startsWith($reg, $g_shortcut))
{
$arr_oris["user"] [$reg]= $user;
$arr_oris["members"][$reg] = 0;
}
}
}
//konec nahrani dat z orisu
Expand Down
4 changes: 3 additions & 1 deletion ads_oris_si_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
'format' => 'json',
'method' => 'editPerson',
'userid' => $oris_id,
'si' => $zaznam['si_chip'],
'clubkey' => $g_oris_club_key,
'firstname' => $zaznam['jmeno'],
'lastname' => $zaznam['prijmeni'],
Expand All @@ -39,6 +38,9 @@
'zip' => $zaznam['psc'],
'country' => (!empty($zaznam['narodnost']) ? $zaznam['narodnost'] : 'CZ')
);
if (!empty($zaznam['si_chip']) && $zaznam['si_chip'] != 0 && $zaznam['si_chip'] !== '0') {
$params['si'] = $zaznam['si_chip'];
}

$url = "https://oris.ceskyorientak.cz/API/?" . http_build_query($params);

Expand Down
Loading