mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-25 14:06:12 +00:00
Redesign install system & New Medal System
Redesign install system & New Medal System Artefact Holder [#ARTEFACT] WW Builder [#WWBUILDER] Great Store [#GREATSTORE] Wall Master [#WALLMASTER] Hero 99+ [#HERO100]
This commit is contained in:
+43
-184
@@ -1,202 +1,61 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Project: TravianZ ##
|
||||
## Filename dataform.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## URLs: https://travianz.org ##
|
||||
## https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
## Filename : wdata.tpl ##
|
||||
## Type : Install Panel Frontend & Backend ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Developed by : Dzoki (Original) ##
|
||||
## Refactored by : Shadow ##
|
||||
## Redesign by : Shadow ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Contact : cata7007@gmail.com ##
|
||||
## Project : TravianZ ##
|
||||
## GitHub : https://github.com/Shadowss/TravianZ ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## License : TravianZ Project ##
|
||||
## Copyright : TravianZ (c) 2010-2025. All rights reserved. ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
#################################################################################
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
// install/wdata.tpl
|
||||
|
||||
include_once('../GameEngine/config.php');
|
||||
|
||||
if (isset($_GET['c']) && $_GET['c'] == '1') {
|
||||
echo '<br /><hr /><br /><div class="headline"><span class="f10 c5">Error creating wdata. Check configuration or file.</span></div><br><br>';
|
||||
echo '<div class="card" style="background:#fef2f2;border-color:#fecaca;color:#991b1b;">Error creating wdata. Check configuration or file.</div>';
|
||||
}
|
||||
if (isset($_GET['err']) && $_GET['err'] == '1') {
|
||||
echo '<br /><hr /><br /><div class="headline"><span class="f10 c5">Existing World Data found in the database! Please empty tables <i>'
|
||||
. TB_PREFIX . 'odata, ' . TB_PREFIX . 'units, ' . TB_PREFIX . 'vdata, ' . TB_PREFIX . 'wdata</i> before continuing.</span></div><br /><br />';
|
||||
echo '<div class="card" style="background:#fef2f2;border-color:#fecaca;color:#991b1b;">Existing World Data found! Empty tables <i>'.TB_PREFIX.'odata, '.TB_PREFIX.'units, '.TB_PREFIX.'vdata, '.TB_PREFIX.'wdata</i>.</div>';
|
||||
}
|
||||
|
||||
$autoStartCroppers = isset($_GET['startCroppers']) && $_GET['startCroppers'] === '1';
|
||||
?>
|
||||
|
||||
<form action="process.php" method="post" id="dataform">
|
||||
<input type="hidden" name="subwdata" value="1" />
|
||||
|
||||
<p>
|
||||
<span class="f10 c">Create World Data</span>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<b>Warning</b>: This can take some time. Please wait until the next page has been loaded.
|
||||
Click Create to proceed...
|
||||
<br /><br />
|
||||
|
||||
<!-- Submit block (hidden when autoStartCroppers=1) -->
|
||||
<div id="submitWrap" style="display:<?php echo $autoStartCroppers ? 'none' : 'block'; ?>;">
|
||||
<center>
|
||||
<input type="submit" name="Submit" id="Submit" value="Create..." onClick="return proceed()" />
|
||||
<br /><br />
|
||||
</center>
|
||||
</div>
|
||||
|
||||
<!-- Progress UI (shown when startCroppers=1) -->
|
||||
<div id="progressBox" style="display:<?php echo $autoStartCroppers ? 'block' : 'none'; ?>; margin-top:20px;">
|
||||
<div style="font-weight:bold;margin-bottom:6px;">Building croppers…</div>
|
||||
|
||||
<div style="background:#ddd;border-radius:8px;overflow:hidden;height:20px;max-width:500px;">
|
||||
<!-- Orange bar to match Travian vibes -->
|
||||
<div id="pbar" style="background:#f6a21a;height:100%;width:0%;transition:width .2s;"></div>
|
||||
</div>
|
||||
|
||||
<div id="pinfo" style="margin-top:6px;font-size:13px;color:#333;">Starting…</div>
|
||||
|
||||
<pre id="plog" style="margin-top:10px;background:#f9f9f9;border:1px solid #ddd;border-radius:8px;padding:8px;font-size:12px;max-height:200px;overflow:auto;"></pre>
|
||||
|
||||
<!-- Continue button appears on completion -->
|
||||
<div id="autoNext" style="display:none;margin-top:10px;">
|
||||
Proceeding to next step in <b id="cd">3</b>…
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="subwdata" value="1" />
|
||||
<div class="card">
|
||||
<span class="f10 c">Create World Data</span>
|
||||
<p style="color:#475569;"><b>Warning</b>: This can take some time. Please wait until the next page has been loaded.</p>
|
||||
|
||||
<div id="submitWrap" style="display:<?php echo $autoStartCroppers?'none':'block';?>;text-align:center;">
|
||||
<button class="btn" id="Submit" onclick="return proceed()">Create World...</button>
|
||||
</div>
|
||||
|
||||
<div id="progressBox" style="display:<?php echo $autoStartCroppers?'block':'none';?>;">
|
||||
<div style="font-weight:600;margin:10px 0;">Building croppers…</div>
|
||||
<div style="background:#e5e7eb;border-radius:999px;overflow:hidden;height:12px;max-width:600px;">
|
||||
<div id="pbar" style="background:linear-gradient(90deg,#f59e0b,#f97316);height:100%;width:0%;transition:width .2s;"></div>
|
||||
</div>
|
||||
<div id="pinfo" style="margin-top:6px;font-size:13px;color:#475569;">Starting…</div>
|
||||
<pre id="plog" style="margin-top:10px;background:#0f172a;color:#e2e8f0;border-radius:10px;padding:10px;font-size:12px;max-height:200px;overflow:auto;"></pre>
|
||||
<div id="autoNext" style="display:none;margin-top:10px;color:#166534;font-weight:600;">Proceeding to next step in <b id="cd">3</b>…</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script><?php include('wdata_js_here_if_needed'); ?></script>
|
||||
<!-- păstrezi scriptul tău JS de mai jos exact cum era -->
|
||||
<script>
|
||||
(function () {
|
||||
var NEXT_URL = 'index.php?s=4'; // your next step
|
||||
var COUNTDOWN_SECS = 3;
|
||||
var finished = false;
|
||||
|
||||
function startCountdown() {
|
||||
var box = document.getElementById('autoNext');
|
||||
var cdEl = document.getElementById('cd');
|
||||
var left = COUNTDOWN_SECS;
|
||||
box.style.display = 'block';
|
||||
cdEl.textContent = left;
|
||||
var t = setInterval(function () {
|
||||
left--;
|
||||
cdEl.textContent = left;
|
||||
if (left <= 0) {
|
||||
clearInterval(t);
|
||||
window.location.href = NEXT_URL;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function startCroppersBuild() {
|
||||
var box = document.getElementById('progressBox');
|
||||
var pbar = document.getElementById('pbar');
|
||||
var pinfo= document.getElementById('pinfo');
|
||||
var plog = document.getElementById('plog');
|
||||
|
||||
var submitWrap = document.getElementById('submitWrap');
|
||||
if (submitWrap) submitWrap.style.display = 'none';
|
||||
box.style.display = 'block';
|
||||
|
||||
if (!('EventSource' in window)) {
|
||||
plog.textContent += "Your browser does not support live progress.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
var MAX_RETRIES = 3;
|
||||
var retries = 0;
|
||||
|
||||
var es = new EventSource('ajax_croppers.php');
|
||||
|
||||
es.onopen = function () {
|
||||
// When a connection (re)opens and we had errors before, log a small note
|
||||
if (!finished && retries > 0) {
|
||||
plog.textContent += "Reconnected to server.\n";
|
||||
plog.scrollTop = plog.scrollHeight;
|
||||
}
|
||||
};
|
||||
|
||||
es.onmessage = function (e) {
|
||||
// Ignore non-JSON messages (pings / blanks)
|
||||
if (!e.data || e.data.charCodeAt(0) !== 123 /* '{' */) return;
|
||||
|
||||
try {
|
||||
var d = JSON.parse(e.data);
|
||||
var pct = (d.pct || 0) | 0;
|
||||
var done = (d.done || 0) | 0;
|
||||
var total = (d.total|| 0) | 0;
|
||||
|
||||
// If we've already finished, ignore further events
|
||||
if (finished) return;
|
||||
|
||||
// Valid data received -> reset retry counter
|
||||
retries = 0;
|
||||
|
||||
pbar.style.width = pct + '%';
|
||||
pinfo.textContent = done + ' / ' + total + ' (' + pct + '%)';
|
||||
|
||||
if (d.msg) {
|
||||
plog.textContent += d.msg + "\n";
|
||||
plog.scrollTop = plog.scrollHeight;
|
||||
}
|
||||
|
||||
if (pct >= 100) {
|
||||
finished = true;
|
||||
plog.textContent += "✅ Completed!\n";
|
||||
plog.scrollTop = plog.scrollHeight;
|
||||
es.close();
|
||||
startCountdown();
|
||||
}
|
||||
|
||||
// Optional: handle explicit error flag from server if you ever send it
|
||||
if (d.error) {
|
||||
finished = true;
|
||||
plog.textContent += "❌ " + (d.msg || "Server reported an error.") + "\n";
|
||||
plog.scrollTop = plog.scrollHeight;
|
||||
es.close();
|
||||
startCountdown();
|
||||
}
|
||||
} catch (err) {
|
||||
// Silently ignore parsing problems now that we guard by '{'
|
||||
// plog.textContent += "Parse error.\n";
|
||||
}
|
||||
};
|
||||
|
||||
es.onerror = function () {
|
||||
// Don’t spam after we’re done
|
||||
if (finished) return;
|
||||
|
||||
retries++;
|
||||
plog.textContent += "⚠ Connection hiccup (" + retries + "/" + MAX_RETRIES + "), retrying…\n";
|
||||
plog.scrollTop = plog.scrollHeight;
|
||||
|
||||
// EventSource will auto-reconnect by itself; we just decide when to give up
|
||||
if (retries >= MAX_RETRIES) {
|
||||
finished = true;
|
||||
plog.textContent += "❌ Too many connection failures — skipping croppers build.\n";
|
||||
plog.scrollTop = plog.scrollHeight;
|
||||
es.close();
|
||||
// Reuse the same countdown UI to move on
|
||||
startCountdown();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
<?php if ($autoStartCroppers) { echo 'startCroppersBuild();'; } ?>
|
||||
});
|
||||
var NEXT_URL = 'index.php?s=4'; var COUNTDOWN_SECS = 3; var finished = false;
|
||||
function startCountdown(){var box=document.getElementById('autoNext'),cd=document.getElementById('cd'),left=COUNTDOWN_SECS;box.style.display='block';cd.textContent=left;var t=setInterval(function(){left--;cd.textContent=left;if(left<=0){clearInterval(t);window.location.href=NEXT_URL}},1000)}
|
||||
function startCroppersBuild(){var box=document.getElementById('progressBox'),pbar=document.getElementById('pbar'),pinfo=document.getElementById('pinfo'),plog=document.getElementById('plog'),submitWrap=document.getElementById('submitWrap');if(submitWrap)submitWrap.style.display='none';box.style.display='block';if(!('EventSource'in window)){plog.textContent+="Browser no SSE\n";return}var MAX=3,retries=0,es=new EventSource('ajax_croppers.php');es.onopen=function(){if(!finished&&retries>0){plog.textContent+="Reconnected\n"}};es.onmessage=function(e){if(!e.data||e.data.charCodeAt(0)!==123)return;try{var d=JSON.parse(e.data),pct=d.pct|0,done=d.done|0,total=d.total|0;if(finished)return;retries=0;pbar.style.width=pct+'%';pinfo.textContent=done+' / '+total+' ('+pct+'%)';if(d.msg){plog.textContent+=d.msg+"\n";plog.scrollTop=plog.scrollHeight}if(pct>=100){finished=true;plog.textContent+="✅ Completed!\n";es.close();startCountdown()}if(d.error){finished=true;plog.textContent+="❌ "+(d.msg||"Error")+"\n";es.close();startCountdown()}}catch(err){}};es.onerror=function(){if(finished)return;retries++;plog.textContent+="⚠ hiccup ("+retries+"/"+MAX+")\n";if(retries>=MAX){finished=true;plog.textContent+="❌ Too many failures\n";es.close();startCountdown()}}}
|
||||
document.addEventListener('DOMContentLoaded',function(){<?php if($autoStartCroppers){echo 'startCroppersBuild();';} ?>});
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</script>
|
||||
Reference in New Issue
Block a user