Taigi ši syk patobulinau ramon moda. Nuo šiol ip bus galima pridet per adminke, ir tai labai gerai tiems kas turi warezus ar pramogu saitus, labai lengva pridet uploaderius, moderatorius, administratorius, vyr.administratorius ir savininkus. Tiesiog pasirenkat nari ir pasirenkat statusa jo. Automatiškai prideda to nario ip, ir jam irašo reikiamus user_rightus.
taigi pradesim. Susikuriam faila ADMINAI.PHP
ir jame irašom visa šita scripta:
<?
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Autorius: chipass
| chipass@gmail.com
| www.m4u.lt
+----------------------------------------------------*/
require_once "../maincore.php";
require_once BASEDIR."subheader.php";
require_once ADMIN."navigation.php";
$ip = getenv("REMOTE_ADDR");
$leistini = 'Jusu ip';
$result = dbquery("SELECT * FROM ".$db_prefix."admin_ip");
while ($data = dbarray($result)) {
$leistini .= "".$data['user_ip']."|";
}
$leistini_ip = explode("|", $leistini);
$nikas = $userdata['user_name'];
$laikas = showdate("longdate", time());
$irasas=$laikas."|".$ip."|".$nikas;
if (!in_array($ip, $leistini_ip)) {
$file=BASEDIR."adm468468468768inai651846848asdasdasd13213487.txt";
$duomenys=fopen($file, "a");
fwrite($duomenys, "$irasas\n");
fclose($duomenys);
$result = dbquery("INSERT INTO ".$db_prefix."blacklist (blacklist_ip, blacklist_reason) VALUES ('$ip', 'Mëginimas ásibrauti á Admin valdymà.')");
redirect(BASEDIR."index.php");
}
if (!iSUPERADMIN || $userdata['user_rights'] == "") fallback("../index.php");
if (!checkrights("S")) fallback("../index.php");
if (isset($_POST['add_admin'])) {
$user_id = $_POST['user_id'];
$user_ip = $_POST['user_ip'];
$user_statusas = $_POST['user_statusas'];
$result = dbquery("SELECT * FROM ".$db_prefix."admin_ip WHERE user_id = '".$user_id."'");
if (dbrows($result) == 0) {
$result = dbquery("INSERT INTO ".$db_prefix."admin_ip (user_id, user_ip, user_pridetas, user_statusas) VALUES ('$user_id', '$user_ip', '".time()."', '$user_statusas')");
if($user_statusas == 'uploader') { $result = dbquery("UPDATE ".$db_prefix."users SET user_level='102', user_rights='PH.N.D.A.W' WHERE user_id='$user_id'");}
elseif($user_statusas == 'moderator') { $result = dbquery("UPDATE ".$db_prefix."users SET user_level='102', user_rights='PO.FQ.F.PH.N.D.A.W.C.S.SU' WHERE user_id='$user_id'");}
elseif($user_statusas == 'admin') { $result = dbquery("UPDATE ".$db_prefix."users SET user_level='102', user_rights='PO.FQ.F.PH.NC.N.IM.D.DC.A.AC.W.WC.B.C.S.M.SU.UG' WHERE user_id='$user_id'");}
elseif($user_statusas == 'super_admin') { $result = dbquery("UPDATE ".$db_prefix."users SET user_level='103', user_rights='PO.CP.FQ.F.PH.NC.N.IM.D.DC.A.AC.W.WC.AD.B.C.S.M.SU.UG.SL' WHERE user_id='$user_id'");}
elseif($user_statusas == 'owner') { $result = dbquery("UPDATE ".$db_prefix."users SET user_level='103', user_rights='A.AC.AD.B.C.CP.DB.DC.D.FQ.F.IM.I.IP.M.N.NC.P.PH.PI.PO.S.SL.S1.S2.S3.S4.S5.S6.S7.SU.UG.U.W.WC' WHERE user_id='$user_id'");}
opentable('Dëmesio!');
echo "<center><font color='green'>Vartotojas sëkmingai pridëtas prie komandos.</font></center>";
closetable();
}
else {
opentable('Dëmesio!');
echo "<center><font color='red'>Ðis narys ir taip jau komandos narys<br>Norëdami pakelti arba sumaþinti ðio nario pareigas, <br>pirma já paðalinkite ið pareigø, tada vël pridëkite</center></font>";
closetable();
} }
if (isset($_GET['veiksmas']) && $_GET['veiksmas'] == "pasalinti")
{
if (isset($id) && !isNum($id)) fallback("../index.php");
$result = dbquery("DELETE FROM ".$db_prefix."admin_ip WHERE user_id='$id'");
$result = dbquery("UPDATE ".$db_prefix."users SET user_level='101', user_rights='' WHERE user_id='$id'");
opentable('Dëmesio!');
echo "<center><b><font color='brown'>Vartotojas sëkmingai paðalintas ið komandos.</font></center>";
closetable();
}
if (isset($_GET['veiksmas']) && $_GET['veiksmas'] == "koreguoti")
{
if (isset($id) && !isNum($id)) fallback("../index.php");
}
opentable('Pridëti naujà komandos nará');
echo"<form name='adminform' method='post' action='".FUSION_SELF."'>";
echo "
<table border='0' cellpadding='2' style='border-collapse: collapse' bordercolor='#111111' width='100%'>
<tr>
<td width='33%'>
<p align='right'><span lang='lt'>Vartotojo id:</span></td>
<td width='33%'>";
$result = dbquery("SELECT * FROM ".$db_prefix."users ORDER BY user_name");
echo "
<select name='user_id' class='textbox'>\n";
while ($data = dbarray($result)) {
echo "<option value='".$data['user_id']."'>".$data['user_name']."</option>\n";
$ip = $data['user_ip'];
}
echo "</select></td>
</tr>
<tr>
<td width='33%'>
<p align='right'><span lang='lt'>Vartotojo statusas:</span></td>
<td width='33%'><select size='1' name='user_statusas' class='textbox'>
<option value='uploader' selected>Uploaderis</option>
<option value='moderator'>Moderatorius</option>
<option value='admin'>Adminas</option>
<option value='super_admin'>Super adminas</option>
<option value='owner'>Savininkas</option>
</select></td>
</tr>
<tr><td class='tbl2' colspan='2' align='center'><input type='hidden' name='user_ip' value='$ip' size='15' class='textbox'><input type='submit' value='Pridëti komandos nará' name='add_admin' class='button'></tr>
</table>
</form>";
closetable();
opentable('Esami komandos nariai');
echo"
<div align='center'>
<center>
<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%' align='center'>
<tr>
<td width='1%' height='19' align='center' class='tbl'></td>
<td width='20%' height='19' align='center' class='tbl'><b>Vartotojo vardas</b></td>
<td width='5%' height='19' align='center' class='tbl1'><b>ID</span></b></td>
<td width='5%' height='19' align='center' class='tbl2'><b>IP</span></b></td>
<td width='20%' height='19' align='center' class='tbl1'><b>Pridëtas</b></td>
<td width='20%' height='19' align='center' class='tbl1'><b>Statusas</b></td>
<td width='20%' height='19' align='center' class='tbl2''><b>Veiksmas</b></span></td>
</tr>";
$result = dbquery("SELECT * FROM ".$db_prefix."admin_ip ORDER BY user_statusas");
$nr = 0;
while ($data = dbarray($result)) {
$vardas = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id = ".$data['user_id']." LIMIT 0,1");
while ($vardenis = dbarray($vardas)) {
$nr++;
echo"<tr>
<td width='1%' height='17' align='center' ><b>$nr.</b></td>
<td width='20%' height='17' align='center'><a href='".BASEDIR."profile.php?lookup=".$vardenis['user_id']."'>".$vardenis['user_name']."</a></td>
<td width='5%' height='17' align='center'>".$data['user_id']."</td>
<td width='5%' height='17' align='center'>".$data['user_ip']."</td>
<td width='20%' height='17' align='center'>".showdate("shortdate", $data['user_pridetas'])."</td>
<td width='20%' height='17' align='center'>";
if ($data['user_statusas'] == 'uploader') { echo "<b><font color='green'>Uploaderis</font></b>"; }
elseif ($data['user_statusas'] == 'moderator') { echo "<b><font color='green'>Moderatorius</font></b>"; }
elseif ($data['user_statusas'] == 'admin') { echo "<b><font color='blue'>Administratorius</font></b>"; }
elseif ($data['user_statusas'] == 'super_admin') { echo "<b><font color='blue'>Vyr. administratorius</font></b>"; }
elseif ($data['user_statusas'] == 'owner') { echo "<b><font color='red'>Ákûrëjas</font></b>"; }
elseif ($data['user_statusas'] == '') { echo "<b><font color='red'>Baninti!</font></b>"; }
echo "</td>
<td width='20%' height='17' align='center'><a href='".FUSION_SELF."?veiksmas=pasalinti&id=".$data['user_id']."'>Paðalinti</a></td>
</tr>";
}}
echo"
</table>
</center>
</div>
";
closetable();
?>
Paryškintoj vietoj irašot savo ip (Tai vienintelis kartas kai reikes irašyt ip rankiniu budu.)
Sukuriat pagrindinej direktorijoj pavadinimas.txt faila, ir jo pavadinima irašot vietoj adm468468468768inai651846848asdasdasd13213487. Nepamirškit suchmodint to txt failo i 777.
Toliau visuose failuose kur noresit, kad galetu užeit tik adminas ir tik su tam tikru ip, irašot toki koda:
$ip = getenv("REMOTE_ADDR");
$leistini = '';
$result = dbquery("SELECT * FROM ".$db_prefix."admin_ip");
while ($data = dbarray($result)) {
$leistini .= "".$data['user_ip']."|";
}
$leistini_ip = explode("|", $leistini);
$nikas = $userdata['user_name'];
$laikas = showdate("longdate", time());
$irasas=$laikas."|".$ip."|".$nikas;
if (!in_array($ip, $leistini_ip)) {
$file=BASEDIR."adm468468468768inai651asdasdas84684813213487.txt";
$duomenys=fopen($file, "a");
fwrite($duomenys, "$irasas\n");
fclose($duomenys);
$result = dbquery("INSERT INTO ".$db_prefix."blacklist (blacklist_ip, blacklist_reason) VALUES ('$ip', 'Mëginimas ásibrauti á Admin valdymà.')");
redirect(BASEDIR."index.php");
}
Ir cia pakeiskit to ilgo txt failo pavadinima i savo sukurto txt failo pavadinima.
Toliau duomenu baze: einat i pridetinius puslapius ir irasot toki koda ir spaudziat perziuret:
<?php
$result = dbquery(" CREATE TABLE ".$db_prefix."admin_ip (
`user_id` smallint(5) NOT NULL,
`user_ip` varchar(20) NOT NULL,
`user_pridetas` int(10) NOT NULL,
`user_statusas` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
$result = dbquery(" CREATE TABLE ".$db_prefix."admin VALUES(111, 'AD', 'admins.gif', 'Adminai', 'adminai.php', 2);");
?>
Cia prinscreen kaip atrodo: [img]http://www.ipix.lt/images/16009424.png[/img]
Butu malonu isgirst pasiulymus, pageidavimus ir papeikimus :)
| Straipsnio informacija
Autoriusbruzgis
Parašymo data2008 rugpjūčio 13 18:08:55
Komentarų17
Skaityta3825 Spausdinti |