Witam. Mam pytanko a mianowicie ma sześć plików php które wykonują określone czynności, poniżej jest ich zawartość, czy można jakoś ograniczyć ilość tych plików bez utraty ich funkcjonalności?? Może da się je zastąpić jednym lub dwoma plikami??
1. ssh.php - wyświetla w tabeli zawartość pliki rc.ssh
<?php
include("config.php");
{
?><html>
<link href="mm_linconpan.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 24px;
color: #9900FF;
font-style: italic;
}
-->
</style>
<center>
<div align="center"><span class="style1">Uprawnienia dla SSH</span><br>
<br>
<center>
</div>
<table border=1 bordercolor=black align=center>
<tr><td><b>Lp.</b></td><td><b>IP</b></td><td><b>Port</b></td><td><b>Interfejs</b></td><td align=center><b>*</b></td><td align=center><b>*</b></tr>
<?php
require('config.php');
$ile=exec('cat kolejkassh'); $licz=1;
for ($kolejka=700; $kolejka<$ile+1; $kolejka++){
if ($licz % 2==0) $kolor='#FFC980';
else $kolor=white;
$dane=exec('cat '.$ssh.'|grep -w '1:'.$kolejka.'''); if ($dane){
$ip1=exec('cat '.$ssh.'|grep -w '1:'.$kolejka.'''); $ip3=$ip2[0];
$port=$ip2[1];
$interface=$interface1[0];
echo '<tr bgcolor='.$kolor.'><td align=center>'.$licz.'</td><td>'.$ip3.'</td><td align=center>'.$port.'</td><td align=center>'.$interface.'</td><td align=center><a href=index2.php?strona=ssh_z&ip='.$ip3.'&port='.$port.'&interface='.$interface.'>zmień</a></td><td align=center><a href=index2.php?strona=ssh_u&uip='.$ip3.'>usuń</a></td></tr>'; $licz=$licz+1;
}}}
else echo "Błąd autoryzacji"; ?>
</table>
<br>
<table border=0 align=center>
<td><form method=post action=index2.php?strona=ssh_d>
<tr><td><center><input type=text size=12 name=dip value=
<?php echo $adresy; ?>></center></td></tr>
<tr><td><center><input type="submit" class="subHeader" value="Dodaj"></center></td></tr>
</form></td></table>
2. ssh_d.php - wyświetla kilka pól aby można było zrobić nowy wpis
<?php
$ip=$_POST['dip'];
include("config.php");
include("config_tmp.php");
{
$a=exec("cat $p2ptime|grep -w $ip"); if (!$a)
{
?>
<form method=post action=index2.php?strona=ssh_d_z>
<html>
<center><span style="font-size: 24px; font-weight: bold; color: #9900FF; font-style: italic; font-family: Verdana, Arial, Helvetica, sans-serif">
Dodawanie użytkownika dla SSH<br>
<?php echo $ip; ?></center><br>
<table border=0 align=center>
<tr>
<td>Adres IP:</td>
<td><input type=text size=12 name=iph value=
<?php echo $ip; ?>></td>
</tr>
<tr>
<td>Port:</td>
<td><input type=text size=4 name=porth></td>
</tr>
<tr>
<td>Interfejs:</td>
<td><input type=text size=4 name=interfaceh> [ lan (LAN),net (internet) ]</td>
</tr>
</table>
</html>
<table border=0 align=center>
<tr><td>
<input type=submit class=subHeader value=Zapisz></td></tr></table>
<?php
}
else echo "<big>Użytkownik o ip: <b>$ip</b> już istnieje</big>"; }
else
{
}
?>
3. ssh_d_z.php - zapisuje dane do pliku
<?php
$iph=$_POST['iph'];
$porth=$_POST['porth'];
$interfaceh=$_POST['interfaceh'];
include("config.php");
include("config_tmp.php");
{
$a=exec("cat $ssh|grep -w $iph"); if (!$a)
{
exec("echo $haslozap|sudo chmod 777 kolejkassh"); $klasa=exec("cat kolejkassh"); $plik=fopen("kolejkassh", "w"); $klasa=$klasa+1;
exec ("echo $haslozap|sudo chmod 666 $ssh"); $plik=fopen("$ssh", "a"); $ip1="$iph-$porth-$interfaceh # 1:$klasan";
exec("echo $haslozap|sudo chmod 644 $ssh"); echo "<big>Dla użytkownikownika o ip: <b>$iph</b> zostały nadane nowe regóły czasowaj blokady programów P2P</big>"; }
else echo "<big>Użytkownik o ip: <b>$iph</b> już istnieje</big>"; }
else
{
}
?>
4. ssh_u.php - usówa konkretny wpis z pliku
<?php
$ip=$_GET['uip'];
include("config.php");
include("config_tmp.php");
{
exec("echo $haslozap|sudo chmod 777 /etc/firewall/Firewall_HTB_P2P_Largo79"); exec("sed -e '/^$ip/d' $ssh >/tmp/rc.ssh"); exec("mv /tmp/rc.ssh $ssh"); exec("echo $haslozap|sudo chmod 755 /etc/firewall/Firewall_HTB_P2P_Largo79"); echo "<big>Użytkownikownik o ip: <b>$ip</b> został został usunięty z rc.ssh</big>"; }
else echo "Błąd autoryzacji"; ?>
5. ssh_z.php - wyświetla dane pobrane z pliku w celu ich edycji
<?php
$ip=$_GET['ip'];
$port=$_GET['port'];
$interface=$_GET['interface'];
include("config.php");
include("config_tmp.php");
{
$a=exec("cat $p2ptime|grep -w $ip"); if (!$a)
{
?>
<form method=post action=index2.php?strona=ssh_z_z>
<html>
<center><span style="font-size: 24px; font-weight: bold; color: #9900FF; font-style: italic; font-family: Verdana, Arial, Helvetica, sans-serif">
Dodawanie użytkownika dla SSH<br>
<?php echo $ip; ?></center><br>
<table border=0 align=center>
<tr>
<td>Adres IP:</td>
<td><input type=text size=12 name=iph value=
<?php echo $ip; ?>></td>
</tr>
<tr>
<td>Port:</td>
<td><input type=text size=4 name=porth value=
<?php echo $port; ?>></td>
</tr>
<tr>
<td>Interfejs:</td>
<td><input type=text size=4 name=interfaceh value=
<?php echo $interface; ?>> [ lan (LAN),net (internet) ]</td>
</tr>
</table>
</html>
<table border=0 align=center>
<tr><td>
<input type=submit class=subHeader value=Zapisz></td></tr></table>
<?php
}
else echo "<big>Użytkownik o ip: <b>$ip</b> już istnieje</big>"; }
else
{
}
?>
6. ssh_z_z.php - zapisuje zmienione dane
<?
$iph=$_POST['iph'];
$porth=$_POST['porth'];
$interfaceh=$_POST['interfaceh'];
include("config.php");
include("config_tmp.php");
{
$a=exec("cat $ssh|grep -w $iph"); $ip1=exec("cat $ssh|grep -w $iph"); $name2=$name1[2];
if ($a)
{
exec("echo $haslozap|sudo chmod 777 /etc/firewall/Firewall_HTB_P2P_Largo79"); exec("cat $ssh|sed -e 's!$iph.*!$iph-$porth-$interfaceh $name2!' >/tmp/rc.ssh"); exec("mv /tmp/rc.ssh $ssh"); exec("echo $haslozap|sudo chmod 644 $ssh"); exec("echo $haslozap|sudo chmod 755 /etc/firewall/Firewall_HTB_P2P_Largo79"); echo "<big>Użytkownikowi o ip: <b>$iph</b> zostały zmienione dane dla SSH</big>"; }
else echo "<big>Podano zły adres ip: <b>$iph</b></big>"; }
else
{
}
?>