Whats your next admin panel feature going to be?
Whats your next admin panel feature going to be?
PHP Code:[LEFT]<?[/LEFT]
[LEFT]$name = $_GET['name'];[/LEFT]
[LEFT]echo "Hi, your name is $name";[/LEFT]
[LEFT]?>[/LEFT]
[LEFT][/LEFT]
Ok wanna help me? I need a form field, where you type in a username and a password and it adds it to the log.txt file which i will CHMOD to 777.
The file is like this;
Ryan||password||
So it will need to to post a new user in there so say if in the username form i put 'Demo' and in the password form i put 'Password' i would like the result in the log.txt file to be this;
Demo||Password||
Ryan||ryanspassword||
Thanks dude.
Edit: I might be able to do this myself.
Last edited by Drugs; 09-08-2006 at 01:18 PM.
lol i should get the admin panel and so should fujiti
this work ryan
??
The first thing you need to know how to do is use the fopen() fread() and fwrite() functions. After that you must build a data parser. Here is the one I use for my flatfile member system:
Code:
$file = "storage.dat";
$file = file($file);
foreach($file as $Key => $Val)
{
//explode that data into a new array:
$Data[$Key] = explode("||", $Val);
}
Next you would make the member list page, that is quite simple, just loop through with the data given above. Here is the whole code I use for an output situation. A sample data file and run file will be included aswell, call this output.php:
Code:
<?php
function ffdisplay($Lines, $rows){
$Lines = file($Lines);
foreach($Lines as $Key => $Val)
{
//explode that data into a new array:
$Data[$Key] = explode("||", $Val);
}
echo "Layout:<br>";
for($a = 0; $a < $rows; $a++)
{
if($a != "0"){
echo '||';
}
echo ''.$Data[0][$a].'';
}
echo "<br>------------------------<br>";
for($K = 1; $K < sizeof($Lines); $K++)
{
echo '<p>';
for($a = 0; $a < $rows; $a++)
{
echo ''.$Data[0][$a].': '.$Data[$K][$a].'<br>';
}
echo '</p>';
}
}
?>
Now lets make your data page.
Code:
Username||Age||Password
colin ||13||some md5 data
somebody really cool||20||some md5 data
That has the data, as you can see, the first line contains a sample of the page layout, this script is built for that, some scripts won't be. Here is the test.php page. That should be saved as sample.dat.
Code:
<?php
include("output.php");
ffdisplay("sample.dat", "2");
?>
Now you need to build the fwrite function, I just briefed you on the bases of the code.
Last edited by Colin-Roberts; 09-08-2006 at 01:28 PM.
.:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
.:.: Stand up for what is right, even if you stand alone:.:.
You will lmao.
I am doing the add user bit now.
Feature ATM
Admin Panel Features
Add announcement.
Add action.
Admin shout.
Admin coloured name.
List of admins.
Shoutbox Features
HTML Disabled.
Very easily customised.
Smilie feature.
More coming soon ;D
Last edited by Drugs; 09-08-2006 at 01:24 PM.
PHP Code:New Code Posted: See Most Recent Post, It Makes The Output Look Better
Last edited by Fujitsu; 09-08-2006 at 01:34 PM.
PHP Code:[LEFT]<?[/LEFT]
[LEFT]$name = $_GET['name'];[/LEFT]
[LEFT]echo "Hi, your name is $name";[/LEFT]
[LEFT]?>[/LEFT]
[LEFT][/LEFT]
lol fujitsu you make my elaborate scripts look bad.
.:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
.:.: Stand up for what is right, even if you stand alone:.:.
That one would be better as it puts 2 line breaks after the output, making it easier to read.PHP Code:<?php
$username = $_GET["username"];
$password = $_GET["password"];
$out = fopen("log.txt", "a");
if (!$out) {
print("Error opening file, CHMOD to 777.");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<b>Username Tried:</b> $username<br><b>Password Tried:</b> $password<br><br>");
fclose($out);
?>
PHP Code:[LEFT]<?[/LEFT]
[LEFT]$name = $_GET['name'];[/LEFT]
[LEFT]echo "Hi, your name is $name";[/LEFT]
[LEFT]?>[/LEFT]
[LEFT][/LEFT]
ryan you should have a word filter also.
.:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
.:.: Stand up for what is right, even if you stand alone:.:.
LOL Fujitsu you don't even have a form to add it..
I have this so far;
createuser.php
And adduser.php;PHP Code:<html>
<head>
<title>PixelResources User Creator</title>
</head>
<body>
<?php
if($_COOKIE['in'] == "1"){}
else{
die("You are not authrised to view this page.");
}
?>
<font size=1> <font face='verdana'>
<b>Add an admin</b><br><br>
<FORM name="shout" action="adduser.php" method="POST">
Username;<br>
<INPUT TYPE="TEXT" name="name" size="20"><br><br>
Password;<br>
<INPUT TYPE="TEXT" name="message" size="20"><br><br>
<br><br>
<INPUT TYPE="Submit" name="submit" value="Create Admin" size="20">
</FORM>
<br>
</font>
<?php
// Copyright 2006 - 2007 PixelResources
?>
</body>
</html>
Yet because the folder users which the log.txt folder is in passworded via .htaccess it is unable to write, even though it is CHMOD'ed to 777, this is the error i get once the i press Add User.PHP Code:<?php
$name = $_POST['name'];
$website = $_POST['website'];
$message = $_POST['message'];
if(empty($name) OR empty($message))
{
echo "
<script language='javascript'>
alert('Please fill in both the Username and the Password fields...');
</script>
";
}
else
{
echo "
<script language='javascript'>
alert('The user was successfully created...');
</script>
";
$name = ($name);
$message = ($message);
$tag = ("<font size=\"1\" face=\"Verdana\">
$name||$message||<br>");
$read = fopen("/users/log.txt", "r");
$contents = fread($read, filesize('/users/log.txt'));
fclose($read);
$write = fopen("/users/log.txt", "w");
fwrite($write, "$tag $contents");
fclose($write);
}
print "<meta http-equiv=\"refresh\" content=\"0;adminindex.php\">";
// Copyright 2006 - 2007 PixelResources
?>
![]()
That was the code to log access attempts...
PHP Code:[LEFT]<?[/LEFT]
[LEFT]$name = $_GET['name'];[/LEFT]
[LEFT]echo "Hi, your name is $name";[/LEFT]
[LEFT]?>[/LEFT]
[LEFT][/LEFT]
Want to hide these adverts? Register an account for free!