<?php
$path="../../";
include("../../map.php");
include("../../secure.php");
include("../../scripts.php");
?>
<style>
	.btn-success{width:50%}
</style>
<meta http-equiv="Content-Type" content="text/HTML; charset=utf-8" />
<script type="text/javascript" src="//cdn.<?php echo $cdnurl?>/js/wpanel.js" lang="<?php echo $sdil[150];?>" id="wjs" url="<?php echo $_SERVER['SERVER_NAME'];?>" pow="<?php echo $pow1?>" ver="<?php echo $pow2?>"></script>
<div class="panel panel-primary">
	<div class="panel-heading">
		Crm Veri Yönetimi
	</div>
	<div class="">
		<?php if($_GET["ne"]==""){?>
			<form action="?cmd=transfer" method="post" class="panel-body msa" style="padding: 5px 15px;">
				<div class="col-xs-2">
					<input name="stn1" type="text" placeholder="x Sütun" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<input name="stn2" type="text" placeholder="y Sütun" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<select name="tbl" class="form-control">
						<?php $result = mysqli_query($conn, "SHOW TABLES FROM $V3Db"); while ($row = mysqli_fetch_row($result)) {?>
							<option value="<?php echo $row[0];?>"><?php echo $row[0];?></option>
						<?php }?>
					</select>
				</div>
				<div class="col-xs-4">
					<input name="sql" type="text" placeholder="Sql Sorgusu" value="" placeholder="where ?" class="form-control">
				</div>
				<div class="col-xs-2">
					<button class="btn btn-success" type="submit" style="float:right">Veri Transfer</button>
				</div>
				<div style="clear:both;padding: 5px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> Sütunlar girilir, tablo seçilir, varsa sql koşulu yazılır</div>
			</form>

			<form action="?cmd=iupdate" method="post" class="panel-body" style="padding: 5px 15px;">
				<div class="col-xs-2">
					<input name="key" type="text" placeholder="Key" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<input name="val" type="text" placeholder="Value" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<select name="tbl" class="form-control">
						<?php $result = mysqli_query($conn, "SHOW TABLES FROM $V3Db"); while ($row = mysqli_fetch_row($result)) {?>
							<option value="<?php echo $row[0];?>"><?php echo $row[0];?></option>
						<?php }?>
					</select>
				</div>
				<div class="col-xs-4">
					<input name="sql" type="text" placeholder="Sql Sorgusu" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<button class="btn btn-success" type="submit" style="float:right">Json Güncelle</button>
				</div>
				<div style="clear:both;padding: 5px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> jSon Key ve Value girilir, tablo seçilir, varsa sql koşulu yazılır</div>
			</form>

			<form action="?cmd=update" method="post" class="panel-body" style="padding: 5px 15px;">
				<div class="col-xs-2">
					<input name="stn1" type="text" placeholder="x Sütun" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<input name="val1" type="text" placeholder="Value" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<select name="tbl" class="form-control">
						<?php $result = mysqli_query($conn, "SHOW TABLES FROM $V3Db"); while ($row = mysqli_fetch_row($result)) {?>
							<option value="<?php echo $row[0];?>"><?php echo $row[0];?></option>
						<?php }?>
					</select>
				</div>
				<div class="col-xs-4">
					<input name="sql" type="text" placeholder="Sql Sorgusu" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<button class="btn btn-success" type="submit" style="float:right">Veri Güncelle</button>
				</div>
				<div style="clear:both;padding: 5px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> Sütun ve değer girilir, tablo seçilir, varsa sql koşulu yazılır</div>
			</form>

			<form action="?cmd=delete" method="post" class="panel-body" style="padding: 5px 15px;">
				<div class="col-xs-6">
					<select name="tbl" class="form-control">
						<?php $result = mysqli_query($conn, "SHOW TABLES FROM $V3Db"); while ($row = mysqli_fetch_row($result)) {?>
							<option value="<?php echo $row[0];?>"><?php echo $row[0];?></option>
						<?php }?>
					</select>
				</div>
				<div class="col-xs-4" style="<?php if($MSA==""){echo "display:none;";}?>">
					<input name="sql" list="up_sql" type="text" placeholder="Sql Sorgusu" value="" class="form-control">
					<datalist id="up_sql">
						<option value="where ne='kayit'"></option>
						<option value="where ne='sayfa'"></option>
						<option value="where ne='haber'"></option>
						<option value="where ne='uye'"></option>
						<option value="where ne='fmesaj'"></option>
						<option value="where ne='basket'"></option>
					</datalist>
				</div>
				<div class="col-xs-2">
					<input type="checkbox" name="clear_media" value="1" title="Medya Temizle">
					<button class="btn btn-success" type="submit" style="float:right">Veri Sil</button>
				</div>
				<div style="clear:both;padding: 5px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> Tablo seçilir, <?php if($MSA==1){echo "varsa sql koşulu yazılır";}?></div>
			</form>

			<form action="?cmd=json_export" method="post" class="panel-body" style="padding: 5px 15px;">
				<div class="col-xs-4">
					<input name="keys" id="val1" type="text" placeholder="Sütunlar" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<select name="tbl" class="form-control">
						<?php $result = mysqli_query($conn, "SHOW TABLES FROM $V3Db"); while ($row = mysqli_fetch_row($result)) {?>
							<option value="<?php echo $row[0];?>"><?php echo $row[0];?></option>
						<?php }?>
					</select>
				</div>
				<div class="col-xs-2" style="<?php if($MSA==""){echo "display:none;";}?>">
					<input name="sql" list="jsonex_sql" type="text" placeholder="Sql Sorgusu" value="" class="form-control">
					<datalist id="jsonex_sql">
						<option value="where ne='kayit'"></option>
						<option value="where ne='sayfa'"></option>
						<option value="where ne='haber'"></option>
						<option value="where ne='uye'"></option>
						<option value="where ne='fmesaj'"></option>
						<option value="where ne='basket'"></option>
					</datalist>
				</div>
				<div class="col-xs-2" style="<?php if($MSA==""){echo "display:none;";}?>">
					<input name="sql_limit" type="text" placeholder="sql limit" value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<button class="btn btn-success" type="submit" style="float:right">jSon Export</button>
				</div>
				<div style="clear:both;padding: 5px; margin-top:45px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> Sütun ve değer girilir, tablo seçilir, varsa sql koşulu yazılır</div>
			</form>

			<form action="?cmd=json_import" method="post" class="panel-body" style="padding: 5px 15px;">
				<div class="col-xs-10">
					<textarea name="json" rows="3" cols="50" class="form-control" placeholder="jSon Verisi"></textarea>
				</div>
				<div class="col-xs-2">
					<button class="btn btn-success" type="submit" style="float:right">jSon Import</button>
				</div>
				<div style="clear:both;padding: 5px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> Export alınmış ve revize edilmiş jSon verisi...</div>
			</form>
		<?php }?>

		<form action="?cmd=kampanya" method="post" class="panel-body" style="padding: 5px 15px;">
		<div class="col-xs-2">
			<input name="val1" id="valc1" type="text" placeholder="Oran %" value="" class="form-control">
		</div>
		<div class="col-xs-2">
			<select name="sts" id="sts" class="form-control">
				<option value="pu">Artış %</option>
				<option value="pd">İndirim %</option>
				<option value="mu">Artış <?php echo $kpb?></option>
				<option value="md">İndirim <?php echo $kpb?></option>
			</select>
		</div>
		<div class="col-xs-2" style="<?php //if($MSA<>1){echo "display:none;";}?>">
			<select name="cat" class="form-control">
				<option value="0">Tüm</option>
				<?php $sqlx=mysqli_query($conn, "select * from kategoriler where ne='ukategori' and s2=1 order by sira asc"); while($rsx=mysqli_fetch_assoc($sqlx)){$x++;?>
					<option value="<?php echo $rsx["Cat_ID"];?>">+ <?php echo $rsx["Cat_".$_SESSION['lang'].""];?></option>
					<?php $sqly=mysqli_query($conn, "select * from kategoriler where ne='ualt_kategori' and c1=".$rsx["Cat_ID"]." order by sira asc"); while($rsy=mysqli_fetch_assoc($sqly)){$y++;?>
						<option value="<?php echo $rsy["Cat_ID"];?>">- <?php echo $rsy["Cat_".$_SESSION['lang'].""];?></option>
					<?php }}?>
				</select>
			</div>
			<div class="col-xs-4" style="<?php if($MSA<>1){echo "display:none;";}?>">
				<input name="sql" type="text" placeholder="Sql Sorgusu" value="where ne='kayit'" class="form-control">
			</div>
			<div class="col-xs-2">
				<button class="btn btn-success" type="submit" style="float:right">Uygula</button>
			</div>
			<div style="clear:both;padding: 5px; margin-top:45px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> Sütun ve değer girilir, tablo seçilir, varsa sql koşulu yazılır</div>
		</form>

		<form action="?cmd=towebp" method="post" class="panel-body" style="padding: 5px 15px; <?php if($MSA != 1 && $module["webp"] != 1){echo "display:none;";} ?>">
				<div class="col-xs-4">
					<input name="keys" id="val1" type="text" placeholder="..." value="" class="form-control">
				</div>
				<div class="col-xs-2">
					<select name="tbl" class="form-control">
							<option value="medya">medya</option>
					</select>
				</div>
				<div class="col-xs-4" style="<?php if($MSA==""){echo "display:none;";}?>">
					<input name="sql" list="towebp_sql" type="text" placeholder="Sql Sorgusu" value="where ne='resim'" class="form-control" autocomplete="off">
					<datalist id="towebp_sql">
						<option value="where ne='resim' and t3='kayit'"></option>
						<option value="where ne='resim' and where t3='sayfa'"></option>
						<option value="where ne='resim' and where t3='haber'"></option>
						<option value="where ne='resim' and where t3='uye'"></option>
					</datalist>
				</div>
				<div class="col-xs-2">
					<button class="btn btn-success" type="submit" style="float:right">toWebP</button>
				</div>
					<?php
					$towp = 0; $sqlm = mysqli_query($conn, "SELECT * FROM medya ne='resim'"); while ($rsm = mysqli_fetch_assoc($sqlm)) {
						$ext = strtolower(pathinfo(trim($rsm["t1"]), PATHINFO_EXTENSION));
						if ($ext != 'webp') {$towp++;}
					}
					?>
				<div style="clear:both;padding: 5px; margin-top:45px; margin-bottom:0px;" class="alert alert-warning"><i class="fa fa-info-circle" aria-hidden="true"></i> Toplam <b><?php echo $towp?></b> kayıt, varsa sql koşulu yazılır, uygulandığında, koşula bağlı resimleri WebP yapar...</div>
			</form>

	</div>
</div>

	<script>
		jQuery(function() {
			jQuery('#sts').change(function(){
				var val = jQuery('option:selected', this).val();
				if(val=='pu'){
					jQuery('#valc1').attr('placeholder','Artış %');
				} else if(val=='pd'){
					jQuery('#valc1').attr('placeholder','İndirim %');
				} else if(val=='mu'){
					jQuery('#valc1').attr('placeholder','Artış <?php echo $kpb?>');
				} else if(val=='md'){
					jQuery('#valc1').attr('placeholder','İndirim <?php echo $kpb?>');
				}
			});
		});
	</script>

<?php
if($_GET["cmd"]=="iupdate"){
	$i=0;$sqlc=mysqli_query($conn, "select * from ".$_POST["tbl"]." ".$_POST["sql"]." "); while($rsc=mysqli_fetch_assoc($sqlc)){$i++;
		$jsi = json_decode($rsc["n17"],true);
		$iarr = array();
		foreach($jsi as $key=>$value){
			if($_POST["key"]<>"" and $key==$_POST["key"]){
				$iarr = $iarr + array($_POST["key"] => $_POST["val"]);
			}else{
				$iarr = $iarr + array( $key => $value);
			}
		}
		//echo "".$rsc["id"]." => ".json_encode($iarr)."<hr>";
		$rjsi = json_encode($iarr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
		$Sqlu = mysqli_query($conn, "update ".$_POST["tbl"]." set n17='".addslashes(stripslashes($rjsi))."' where id=".$rsc["id"]."");
	}
	echo "<u>".$_POST["tbl"]."</u> tablosunda [<b>".$_POST["key"]."</b>] sütununa [<b>".$_POST["val"]."</b>] datası <u>".$_POST["sql"]."</u> koşul(u)(suz) ile <b>".$i."</b> data güncellendi <span onclick=\"history.back()\" style=\"float:right;cursor:pointer;\"><< Geri</span><hr>";

}elseif($_GET["cmd"]=="transfer"){
	$i=0;$sqlc=mysqli_query($conn, "select * from ".$_POST["tbl"]." ".$_POST["sql"]." "); while($rsc=mysqli_fetch_assoc($sqlc)){$i++;
		$Sqlu = mysqli_query($conn, "update ".$_POST["tbl"]." set ".$_POST["stn2"]."='".$rsc[$_POST["stn1"]]."' where id=".$rsc["id"]."");
	}
	echo "<u>".$_POST["tbl"]."</u> tablosunda [<b>".$_POST["stn2"]."</b>] sütununa [<b>".$_POST["stn1"]."</b>] datası <u>".$_POST["sql"]."</u> koşulu/koşulsuz ile <b>".$i."</b> data aktarıldı <span onclick=\"history.back()\" style=\"float:right;cursor:pointer;\"><< Geri</span><hr>";

}elseif($_GET["cmd"]=="update"){
	$i=0;$sqlc=mysqli_query($conn, "select * from ".$_POST["tbl"]." ".$_POST["sql"]." "); while($rsc=mysqli_fetch_assoc($sqlc)){$i++;
		$Sqlu = mysqli_query($conn, "update ".$_POST["tbl"]." set ".$_POST["stn1"]."='".$_POST["val1"]."' where id=".$rsc["id"]."");
	}
	echo "<u>".$_POST["tbl"]."</u> tablosunda [<b>".$_POST["stn1"]."</b>] datası [<b>".$_POST["val1"]."</b>] olarak <u>".$_POST["sql"]."</u> koşulu/koşulsuz ile <b>".$i."</b> data güncellendi <span onclick=\"history.back()\" style=\"float:right;cursor:pointer;\"><< Geri</span><hr>";

}elseif($_GET["cmd"]=="kampanya"){
	if($_POST["cat"]<>0){ $usql = " and (s10='".$_POST["cat"]."' or s9='".$_POST["cat"]."')"; }
	$i = 0;
	$sqlc = mysqli_query($conn, "select * from ".$_SESSION["lang"]." ".$_POST["sql"]." ".$usql.""); 
	while($rsc = mysqli_fetch_assoc($sqlc)){
		$i++;
	if(substr($_POST["sts"], 0, 1) == "p") { // Yüzde işlemleri
		$doran = (100 - $_POST["val1"]) / 100;
		$uoran = (100 + $_POST["val1"]) / 100;
		if($_POST["sts"] == "pd"){ // İndirim -> aşağı yuvarla
			$pb1 = floor($rsc["pb1"] * $doran);
			$pb2 = floor($rsc["pb2"] * $doran);
		} else { // Artış -> yukarı yuvarla
			$pb1 = ceil($rsc["pb1"] * $uoran);
			$pb2 = ceil($rsc["pb2"] * $uoran);
		}
	} else { // Sabit değer işlemleri (mu / md) yuvarlama yok
		$oran = $_POST["val1"];
		if($_POST["sts"] == "md"){
			$pb1 = ceil($rsc["pb1"] - $oran);
			$pb2 = ceil($rsc["pb2"] - $oran);
		} else {
			$pb1 = ceil($rsc["pb1"] + $oran);
			$pb2 = ceil($rsc["pb2"] + $oran);
		}
	}
	//echo "".$rsc["id"]." => ".$rsc["pb1"]." => ".$pb1."<br>";
	$Sqlu = mysqli_query($conn, "update ".$_SESSION["lang"]." set pb1='".sprice($pb1)."', pb2='".sprice($pb2)."' where id=".$rsc["id"]."");
}
echo "<u>".$_SESSION["lang"]."</u> tablosunda [<b>".$_POST["sts"]."</b>] methodu ile [<b>".$_POST["val1"]."</b>] işlem <u>".$_POST["sql"]."</u> koşulu/koşulsuz ile <b>".$i."</b> data güncellendi <span onclick=\"history.back()\" style=\"float:right;cursor:pointer;\"><< Geri</span><hr>";

}elseif($_GET["cmd"]=="delete"){
if($_POST["tbl"]<>"medya"){
	$i=0;$sqlc=mysqli_query($conn, "select * from ".$_POST["tbl"]." ".$_POST["sql"]." "); while($rsc=mysqli_fetch_assoc($sqlc)){$i++;
		for ($l = 1; $l <= $lx; $l++) {$sql = mysqli_query($conn, "delete from ".$_POST["tbl"]." where id=".$rsc["id"]."");}
			if($_POST["clear_media"]<>""){
				$sql=mysqli_query($conn, "select * from medya where ne='resim' and s1=".$rsc["id"].""); while($rsi=mysqli_fetch_assoc($sql)){
					$dosya1="../../../deppo/image/".$rsi["t1"]."";
					unlink($dosya1);
					$dosya2="../../../deppo/image/k_".$rsi["t1"]."";
					unlink($dosya2);
					$sqld = mysqli_query($conn, "delete from medya where s1=".$rsc["id"]."");
				}
			}
		}
	}elseif($_POST["tbl"]=="medya"){
		$sqlm=mysqli_query($conn, "select * from ".$_POST["tbl"]." ".$_POST["sql"]." "); while($rsm=mysqli_fetch_assoc($sqlm)){
			$dosya1="../../../deppo/image/".$rsm["t1"]."";
			unlink($dosya1);
			$dosya2="../../../deppo/image/k_".$rsm["t1"]."";
			unlink($dosya2);
			$dosya3="../../../deppo/video/".$rsm["n2"]."";
			unlink($dosya3);
			$sqld = mysqli_query($conn, "delete from medya where id=".$rsm["id"]."");
		}
	}
	echo "<u>".$_POST["tbl"]."</u> tablosundaki data(lar) <u>".$_POST["sql"]."</u> koşulu/koşulsuz ile <b>".$i."</b> data silindi <span onclick=\"history.back()\" style=\"float:right;cursor:pointer;\"><< Geri</span><hr>";

}elseif($_GET["cmd"]=="towebp"){
		$i=0;$sqlm=mysqli_query($conn, "select * from medya ".$_POST["sql"]." "); while($rsm=mysqli_fetch_assoc($sqlm)){
    		$ext = strtolower(pathinfo(trim($rsm["t1"]), PATHINFO_EXTENSION));			
			if ($ext != 'webp') {$i++;
				towebp("k_{$rsm["t1"]}", "../../../deppo/image/");
				$yeni = towebp($rsm["t1"], "../../../deppo/image/");

				$Sqlu = mysqli_query($conn, "update medya set t1='".$yeni."' where id=".$rsm["id"]."");
			}
		}
	echo "<u>medya</u> tablosundaki data(lar) <u>".$_POST["sql"]."</u> koşulu/koşulsuz ile <b>".$i."</b> data WebP Formatına dönüştü <span onclick=\"history.back()\" style=\"float:right;cursor:pointer;\"><< Geri</span><hr>";

}elseif($_GET["cmd"]=="json_export"){
	$keys = isset($_POST['keys']) ? explode(',', $_POST['keys']) : [];
	$sql  = isset($_POST['sql']) ? $_POST['sql'] : '';
	$tbl  = isset($_POST['tbl']) ? $_POST['tbl'] : '';
	$limit = isset($_POST['sql_limit']) ? trim($_POST['sql_limit']) : '';

	$keys = array_map('trim', $keys);
	$columns = implode(',', array_map(fn($col) => "`$col`", $keys));

	$allowed_conditions = ['=', '!=', '>', '<', '>=', '<=', 'LIKE'];
	preg_match('/(\w+)\s*(' . implode('|', $allowed_conditions) . ')\s*(.+)/', $sql, $matches);

	$column = trim($matches[1]);
	$operator = trim($matches[2]);
	$value = trim($matches[3], "'\"");

	$column = mysqli_real_escape_string($conn, $column);
	$value  = mysqli_real_escape_string($conn, $value);
	$tbl    = mysqli_real_escape_string($conn, $tbl);

	$query = "SELECT $columns FROM `$tbl` WHERE `$column` $operator '$value'";
	if ($limit !== '' && preg_match('/^\d+(,\d+)?$/', $limit)) {
		$query .= " LIMIT $limit";
	}

	$result = mysqli_query($conn, $query);
	$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);

	$data = [
		"columns" => $columns,
		"tbl" => $tbl,
		"sql" => "WHERE `$column` $operator '$value'",
		"results" => $rows
	];

	echo "<pre id=\"jsonOutput\" style=\"cursor: pointer; background: #f4f4f4; padding: 10px; border-radius: 5px; height:250px; overflow:auto;\">" . json_encode($data, JSON_UNESCAPED_UNICODE) . "</br></br>";
	echo $keys[1] . " columns, tbl, sql, ve results alanları ile birlikte, t1 değerlerine uygun SEO uyumlu n2 (description) ve n3 (title) olacak şekilde, aynı yapıda hazırla</pre>";

	mysqli_free_result($result);
	mysqli_close($conn);


}elseif($_GET["cmd"]=="json_import"){
	$json_data = isset($_POST['json']) ? trim($_POST['json']) : '';
	$data = json_decode($json_data, true);
	if (!$data || !isset($data["results"]) || !isset($data["tbl"])) {
		die(json_encode(["error" => "Geçersiz JSON verisi"]));
	}
	$tbl = $data["tbl"];
	$updated_count = 0;
	foreach ($data["results"] as $row){
		$columns = array_keys($row);
		if (count($columns) < 3) { // En az 3 sütun olmalı (ilk 2 sütun hariç tutulacağı için)
			continue;
		}
		$primary_column = $columns[0];
		$primary_value = $row[$primary_column];
		$update_columns = array_slice($columns, 2);
		
		if (empty($update_columns)) {
			continue; // Güncellenecek başka veri yoksa atla
		}
		$set_clause = implode(", ", array_map(fn($col) => "`$col` = ?", $update_columns));
		$values = array_map(fn($col) => $row[$col], $update_columns);
		$values[] = $primary_value;
		$types = str_repeat("s", count($update_columns)) . "s";
		$stmt = $conn->prepare("UPDATE `$tbl` SET $set_clause WHERE `$primary_column` = ?");
		$stmt->bind_param($types, ...$values);
		$stmt->execute();
		$updated_count++;
	}
	$conn->close();
	echo json_encode(["success" => true, "updated" => $updated_count], JSON_UNESCAPED_UNICODE);
}
?>

<script>
	const preElement = document.getElementById("jsonOutput");
// Kopyalandı ikonunu oluştur
	const icon = document.createElement("div");
	icon.innerText = "✓";
	icon.style.position = "absolute";
	icon.style.top = "5px";
	icon.style.right = "5px";
	icon.style.width = "20px";
	icon.style.height = "20px";
	icon.style.backgroundColor = "#4CAF50";
	icon.style.color = "white";
	icon.style.fontSize = "14px";
	icon.style.fontWeight = "bold";
	icon.style.textAlign = "center";
	icon.style.lineHeight = "20px";
	icon.style.borderRadius = "50%";
	icon.style.display = "none";
// Parent div oluştur ve pre içine ekle
	const container = document.createElement("div");
	container.style.position = "relative";
	container.style.display = "inline-block";
	preElement.parentNode.replaceChild(container, preElement);
	container.appendChild(preElement);
	container.appendChild(icon);
// Tıklanınca kopyalama işlemi
	preElement.addEventListener("click", function () {
		navigator.clipboard.writeText(this.innerText).then(() => {
			icon.style.display = "block";
			setTimeout(() => { icon.style.display = "none"; }, 1500);
		}).catch(err => console.error("Kopyalama hatası:", err));
	});
</script>