<?php
$eklentikelime = array(
"\"(.*)rcon_password(.*)\"","\"(.*)connect (.*)\""
);
$ssh2 = new ogcp_ssh2();
if(isset($_GET["Yukle"])) {
if($ssh2->ConnectwAuth($serverinfo["MachIP"],(int)$serverinfo["MachPort"],$serverinfo["MachUser"],$serverinfo["MachPass"])) {
if($_FILES['Filedata']['error'] == 0 && pathinfo($_FILES['Filedata']['name'])['extension'] == "sma") {
//move_uploaded_file($_FILES['Filedata']['tmp_name'], );
$eskiad = $_FILES['Filedata']['name'];
$yeniad2 = tr_karakter($eskiad);
$yeniadxd = filtre_sma($yeniad2);
$yeniad4 = bosluk_sil($yeniadxd);
$yeniad4 = mb_strtolower($yeniad4);
$yeniad3 = preg_replace("/\./", "", $serverinfo["ServerIP"]).'_'.$yeniad4;
$_FILES['Filedata']['name'] = $yeniad3;
$main_name = explode('.',$_FILES["Filedata"]["name"])[0];
$filecontent = file_get_contents($_FILES['Filedata']['tmp_name']);
$durum = 2;
foreach($eklentikelime as $kelime) {
preg_match('/'.$kelime.'/i',$filecontent,$matches);
if(count($matches) > 0) { $durum = 0; break; }
}
if($durum == 2) {
$smafile = "./".$main_name.".sma";
file_put_contents("./__hcsgp_system/compiler/".$main_name.".sma", $filecontent);
$output = exec("cd ./__hcsgp_system/compiler; ./amxxpc {$smafile} -o".$main_name.".amxx >> ".$main_name.'.log');
if(file_exists("./__hcsgp_system/compiler/".$main_name.".amxx")) {
$_FILES['Filedata']['tmp_name'] = "./__hcsgp_system/compiler/".$main_name.".amxx";
$_FILES['Filedata']['name'] = $main_name.".amxx";
$log = file_get_contents('./__hcsgp_system/compiler/'.$main_name.'.log');
if ( $ssh2->SFTP_UploadFile($_FILES['Filedata']['tmp_name'],$serverinfo["ServerPath"]."/cstrike/addons/amxmodx/plugins/".$_FILES['Filedata']['name']) ) {
// $log = implode("\n",array_slice(explode("\n",$log), 3, -3));
@file_put_contents($ssh2->SFTP_FileLink($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins-panel.ini"), @file_get_contents($ssh2->SFTP_FileLink($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins-panel.ini"))."\r\n".$_FILES['Filedata']['name']."");
$_SESSION['WebFTPMesaj'] = '<strong>İşlem Başarılı!</strong><br/>Eklenti plugins-panel.ini\'ye eklenmiştir!<br/>Eklenti adı: <h7 style="color:#428bca;"> '.$main_name.'.amxx </br><h4>Çıktısı</h4><pre style="background-color:black; color: #adff2f;">'.$log.'</pre></div>';
} else {
$_SESSION['WebFTPMesaj'] = '<div class="alert alert-warning"><button type="button" class="close" data-dismiss="alert">×</button><strong>İşlem Başarısız!</strong><br/>Eklenti sunucuya aktarılamadı!</div>';
}
unlink("./__hcsgp_system/compiler/".$main_name.".amxx");
} else {
$_SESSION['WebFTPMesaj'] = '<div class="alert alert-danger"><strong>Hatalı Eklenti!</strong><br/>'.$_FILES['Filedata']['name'].' isimli Eklenti derlenemedi!<br/><h4>Eklenti Çıktısı</h4><br/><pre style="background-color:black; color: #adff2f;">'.$log.'</pre></div>';
unlink("./__hcsgp_system/compiler/".$main_name.".sma");
unlink('./__hcsgp_system/compiler/'.$main_name.'.log');
}
//unlink("./__hcsgp_system/compiler/".$main_name.".sma");
unlink('./__hcsgp_system/compiler/'.$main_name.'.log');
} else {
$_SESSION['WebFTPMesaj'] = '<div class="alert alert-warning"><button type="button" class="close" data-dismiss="alert">×</button><strong>İşlem Başarısız!</strong><br/>Eklentide yasaklanmış komut bulundu!</div>';
$durum = -1;
}
}else {
$_SESSION['WebFTPMesaj'] = "Dosya Uzantısına izin verilmiyor! sadece .sma !";
}
} else {
$_SESSION['WebFTPMesaj'] = "Sunucu Ile Baglanti Kurulamadı";
}
}
?>