I have a game server compilation process in PHP but the exec function is turned off on my hosting. Can we compile it from the ssh2 machine and upload it to the panel? I want to shoot remotely with ssh2 php execLyrics distribution will come for the amxmodx version php panel will be compiled remotely via ssh2 and uploaded to the panel.
<?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ı";
}
}
?>
<script src="<?php echo $page->LoadTheme_File('skynlexx/js/uploadifive/jquery.min.js');?>" type="text/javascript"></script>
<script src="<?php echo $page->LoadTheme_File('skynlexx/js/uploadifive/jquery.uploadifive.js');?>" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $page->LoadTheme_File('skynlexx/js/uploadifive/uploadifive.css');?>">
<style type="text/css">
#queue {
color: #fff !important;
height: auto;
overflow: auto;
margin-bottom: 10px;
padding: 0 3px 3px;
width: 100%;
}
.uploadifive-queue-item {
background: linear-gradient( to bottom, #007bff 5%, #31353d 120%);
}
</style>
<div id='gelenveri'></div>
<div class="alert alert-warning">
<div>
<center>
<b><font size="3">Eklenti Yuklenecek IP : <?php echo $serverinfo["ServerIP"]; ?> </font></b>
</br>
<b><font size="3">Sadece <font color="red">.sma</font> dosyası kabul edilir</font></b>
</br>
<b><font size="2">Sma dosyalarında<font color="red"> motd_write, connect, bind</font> komutu kullanınırsa hata verecektir.</font></b>
</div>
</div>
<form>
<table style="width: 100%;" class="table table-hover table-bordered">
<tbody>
<tr align="center">
<td colspan="2"><b>Extra eklenti yükleme (sma)<br>
Yüklediğiniz eklentileri <a href="Dosya_Duzenle.html&ID=15"><u>plugins-panel.ini</u></a> Sayfasında bulabilirsiniz.
</b></td>
</tr>
<tr>
<td align="center">
<input id="file_upload" name="file_upload" type="file" multiple="true">
</td>
</tr>
</tbody>
</table>
<div id="queue"></div>
</form>
<script type="text/javascript">
<?php $timestamp = time(); ?>
$('#file_upload').uploadifive({
'fileTypeExts' : '*.sma;',
'auto' : true,
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
},
'queueID' : 'queue',
'uploadScript' : '<?=$page->CreatePageLink($cur_page,"Yukle");?>',
'onUploadComplete' : function(file, data) {
var skynlexx = 'skymesaj.php?skynlexx=1';
$.get(skynlexx,function (msg){
Swal.fire({
title: "<b>Sonuç</b>",
html: msg,
});
});
}
});
</script>
Compilation requires you to have a server with the same settings to work. I think it's easier for you to try and ask your hosting admin about the move or just move to a dedicated server and then become root.
Remembering that "with great power comes great responsibility".