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 :  /admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /admin/polana-v164-seo-install.php
<?php
declare(strict_types=1);
require_once dirname(__DIR__).'/includes/functions.php';
require_once dirname(__DIR__).'/includes/polana_v164_payload.php';
require_admin_role();
$root=dirname(__DIR__);$hub=$root.'/admin/polana-centrum-tresci.php';
$backupDir=dirname($root).'/.polana_v164_seo_backup';$manifest=$backupDir.'/manifest.json';
$msg='';$error='';
function p164_write(string $path,string $bytes):void{
 $tmp=tempnam(dirname($path),'.seo164_');
 if(!$tmp)throw new RuntimeException('Brak możliwości zapisu tymczasowego pliku.');
 try {
  if(file_put_contents($tmp,$bytes,LOCK_EX)!==strlen($bytes))throw new RuntimeException('Niepełny zapis pliku.');
  chmod($tmp,0644);
  if(!rename($tmp,$path))throw new RuntimeException('Nie można podmienić pliku.');
 }finally{if(is_file($tmp))unlink($tmp);}
}
function p164_hub_edit(string $src):string {
 if(str_contains($src,'POLANA_V164_SEO_LINK'))return $src;
 $needle=' <div class="items">';
 if(substr_count($src,$needle)!==1)throw new RuntimeException('Nie rozpoznano Centrum treści. Nawigację można dodać później ręcznie.');
 $pos=strpos($src,$needle)+strlen($needle);
 $card="\n  <!-- POLANA_V164_SEO_LINK -->\n  <?php if(\$role==='admin'):?><a class=\"item\" href=\"/admin/polana-v164-seo.php\"><span class=\"sym\">🔎</span><strong>SEO i Google</strong><small>Mapa strony, indeksowanie i Search Console.</small></a><?php endif;?>";
 return substr($src,0,$pos).$card.substr($src,$pos);
}
if(($_SERVER['REQUEST_METHOD']??'GET')==='POST'){
 verify_csrf();
 try {
  $action=(string)($_POST['action']??'');
  if($action==='install'){
   if(is_file($manifest))throw new RuntimeException('Znaleziono poprzednią instalację. Nie nadpisujemy automatycznie backupu.');
   $payload=p164_payload_files();$targets=[];
   foreach($payload as $rel=>$bytes){$targets[$rel]=$bytes;}
   if(is_file($hub)){$targets['admin/polana-centrum-tresci.php']=p164_hub_edit((string)file_get_contents($hub));}
   if(is_file($root.'/sitemap.xml') || is_file($root.'/robots.txt')) throw new RuntimeException('Istnieje fizyczny sitemap.xml lub robots.txt. Zrób ich kopię i usuń konflikt przed instalacją.');
   $ht=is_file($root.'/.htaccess')?(string)file_get_contents($root.'/.htaccess'):'';
   if(!preg_match('~RewriteRule[^\r\n]*sitemap[^\r\n]*sitemap\.php~i',$ht) || !preg_match('~RewriteRule[^\r\n]*robots[^\r\n]*robots\.php~i',$ht)) throw new RuntimeException('W .htaccess nie znaleziono tras sitemap.xml i robots.txt. Nie instalujemy bez poprawnego routingu.');
   if(!is_dir($backupDir) && !mkdir($backupDir,0700,true))throw new RuntimeException('Nie można utworzyć backupu poza WWW.');
   if(!is_writable($backupDir))throw new RuntimeException('Brak możliwości zapisu backupu.');
   $changes=[];
   foreach($targets as $relative=>$bytes) {
      $path=$root.'/'.$relative;
      if(!is_writable(dirname($path)))throw new RuntimeException('Brak możliwości aktualizacji '.$relative);
      $old=is_file($path)?file_get_contents($path):null;
      if($old===false)throw new RuntimeException('Nie można odczytać '.$relative);
      $filename=str_replace('/','__',$relative);
      if($old!==null && file_put_contents($backupDir.'/'.$filename.'.backup',$old,LOCK_EX)!==strlen($old))throw new RuntimeException('Nie zapisano backupu '.$relative);
      if($old!==null)chmod($backupDir.'/'.$filename.'.backup',0600);
      $changes[$relative]=['old_hash'=>$old===null?null:hash('sha256',$old),'new_hash'=>hash('sha256',$bytes),'new'=>($old===null)];
   }
   // Komplet backupów i manifest dopiero przed zmianą produkcji.
   $json=json_encode(['changed'=>$changes,'installed_at'=>date(DATE_ATOM)],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR);
   if(file_put_contents($manifest,$json,LOCK_EX)!==strlen($json))throw new RuntimeException('Nie udało się zapisać manifestu.');
   chmod($manifest,0600);
   foreach($targets as $relative=>$bytes)p164_write($root.'/'.$relative,$bytes);
   admin_log('seo_v164_install','Włączono dynamiczną sitemap i panel SEO.');
   $msg='Zainstalowano SEO. Mapa generuje się automatycznie.';
  }elseif($action==='rollback'){
   $data=is_file($manifest)?json_decode((string)file_get_contents($manifest),true):null;
   if(!is_array($data)||!isset($data['changed'])||!is_array($data['changed']))throw new RuntimeException('Brak manifestu rollback.');
   foreach($data['changed'] as $relative=>$info){
     if(!in_array($relative,['sitemap.php','robots.php','admin/polana-centrum-tresci.php'],true))throw new RuntimeException('Nieprawidłowy manifest.');
     $current=$root.'/'.$relative;
     if(!is_file($current)||hash_file('sha256',$current)!==$info['new_hash'])throw new RuntimeException('Plik '.$relative.' był zmieniany po instalacji. Rollback wstrzymany.');
   }
   foreach($data['changed'] as $relative=>$info){
     $current=$root.'/'.$relative;
     if($info['new'])unlink($current);
     else{
       $backup=$backupDir.'/'.str_replace('/','__',$relative).'.backup';
       if(!is_file($backup)||hash_file('sha256',$backup)!==$info['old_hash'])throw new RuntimeException('Backup nie pasuje do '.$relative);
       p164_write($current,(string)file_get_contents($backup));
     }
   }
   rename($manifest,$backupDir.'/manifest.restored.'.date('Ymd_His').'.json');
   admin_log('seo_v164_rollback','Przywrócono wcześniejszą sitemap i robots.');
   $msg='Przywrócono poprzednie pliki.';
  }else throw new RuntimeException('Nieznana operacja.');
 }catch(Throwable $e){$error=$e->getMessage();error_log('SEO V164 installer: '.$error);}
}
render_admin_header('Instalacja SEO V16.4');
?>
<main style="max-width:920px;margin:28px auto;padding:20px;background:white;border-radius:16px;color:#223529">
<h1>SEO V16.4 — instalacja i rollback</h1>
<p>Instalacja zachowuje kopie <code>sitemap.php</code>, <code>robots.php</code> oraz <code>admin/polana-centrum-tresci.php</code> poza WWW. Nie zmienia edytorów, tabel MariaDB, bloga ani tłumaczeń.</p>
<?php if($error):?><p style="color:#b42318"><?=e($error)?></p><?php endif;?>
<?php if($msg):?><p style="color:#126d35"><?=e($msg)?></p><?php endif;?>
<form method="post"><?=csrf_field()?><button name="action" value="install" onclick="return confirm('Włączyć nową sitemap oraz SEO w Centrum treści?')">Zainstaluj V16.4</button></form>
<br>
<form method="post"><?=csrf_field()?><button name="action" value="rollback" onclick="return confirm('Przywrócić stare pliki sitemap i robots?')">Przywróć poprzednią wersję</button></form>
<p><a href="/admin/polana-v164-seo.php">Otwórz panel SEO</a> · <a href="/sitemap.xml" target="_blank">Sitemap XML</a> · <a href="/robots.txt" target="_blank">Robots</a></p>
</main>
<?php render_admin_footer(); ?>

Youez - 2016 - github.com/yon3zu
LinuXploit