Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

93 users online



Php Redirect help

Php Redirect help

Currently viewing this thread: 1 (0 members and 1 guests)


ExtremeDesign

ExtremeDesign

Status: Offline!

Php Redirect help

I have this old php redirect script im trying to get to work. There is a login.php file and admin.php file. In the admin.php file there are lots of things leading to index.php, even when the member and password and url is added and you hit save, it goes to index.php but returns file not found..

What i need to know is what could be in this index.php file?

KungPaoChicken

KungPaoChicken

Status: Offline!

Quite confusing there, What i seem to get is that when you login and it returns to index.php? ANd i guess there is no index.php? If it says index.php is not found that means it doesnt exist in that dir.

___________________

i stupended my own signarture

ExtremeDesign

ExtremeDesign

Status: Offline!

This is the admin.php code.. I can show the login.php code too if needed. My question is what is in the index.php file that everything is leading into?

<html>
<?php
function userExists($file, $u)
{
$fp = fopen($file, "r");
$existe = 0;
while(!feof ($fp))
{
//$line = fgets($fp, 8000);
$line = fgets($fp, 1024);
$array = explode("|", $line);

$user = $array[0];
$pass = $array[1];
$url = $array[2];

if($user == $u){
$existe = existe + 1;
}
}

fclose($fp);
return $existe;
}

function frewrite($f, $r, $s)
{
$myFile = file($f);
foreach ($myFile as $row=>$data) { // $row is the line #, $data is the corresponding data to that line
//echo "$row: $data<br />\n"; // This will give you all rows + data in that file
}

//To edit a specific line:
$myFile[$r] = $s . "\n"; // Can be $myFile[0], $myFile[1], and so on

// To write:
$fp = fopen($f,'w');
fwrite($fp,implode('',$myFile));
fclose($fp);
}

function cutline($filename,$line_no) {

$strip_return=FALSE;

$data=file($filename);
$pipe=fopen($filename,'w');
$size=count($data);

if($line_no==-1)
{
$skip=$size-1;
}
else
{
$skip=$line_no-1;
}

for($line=0;$line<$size;$line++)
if($line!=$skip)
fputs($pipe,$data[$line]);
else
$strip_return=TRUE;

return $strip_return;
}

// END OF FUNCTIONS //

if ($_POST[user] && $_POST[pass] && $_POST[url] && $_POST[linha] == "")
{
if(userExists("ficheiro.txt", $_POST[user]) == 0)
{
$file=fopen("ficheiro.txt", "a");
fputs($file, "\n");
fputs($file, "$user|$pass|$url");
fclose($file);
print("<center><br>User added.<br>");
print ("<a href=\"index.php\"><p> Back </a></center>");
}
else
{
print "<center><br>There is a user with the corresponding username<br>";
print ("<a href=\"index.php\"><p> Back </a></center>");
}
}
elseif($_POST[action] == "doEdit") {

if($_POST[ed] != "")
{
$arg = $_POST[user] . "|" . $_POST[pass] . "|" . $_POST[url];
frewrite("ficheiro.txt", $_POST[linha], $arg);
print ("<center><a href=\"index.php\"><p> Back </a></center>");
}
elseif($_POST[dd] != ""){
cutline("ficheiro.txt", $_POST[linha]);
print ("<center><a href=\"index.php\"><p> Back </a></center>");
}
}
else{
?>
<form name="form2" method="post" action="index.php">
<input type="hidden" value="save" name="save">

<TABLE width=502 align=center border=1>
<TBODY>
<TR>
<TD width=137 ><STRONG>&nbsp;Username</STRONG></TD>
<TD width=362 ><INPUT name="user"></TD>
</TR>
<TR>
<TD><STRONG>&nbsp;Password</STRONG></TD>
<TD><INPUT type="password" name="pass"></TD>
</TR>
<TR>
<TD><STRONG>&nbsp;Url</STRONG></TD>
<TD><INPUT name="url"></TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD><INPUT type=submit value=Save name=submit>
<input type="reset" value=Reset name="Reset"></TD>
</TR>
</TBODY>
</TABLE>
</FORM>
<?php
if (file_exists("ficheiro.txt"))
{
$file=fopen("ficheiro.txt", "r");
print "<br><table width=\"55%\" align=center border=1>";

//if
$num = $num - 1;
while(!feof($file))
{
$linha = fgets($file, 1024);
$array = explode("|", $linha);

$user = $array[0];
$pass = $array[1];
$url = $array[2];

$num = $num + 1;
if($num == 0)
{
}
else {
if($user != "")
{
print "<form action=index.php method=post>";
print "<input type=hidden name=section value=user><input type=hidden name=action value=doEdit><input type=hidden name=linha value=$num>";
print "<tr><td width=\"137\"><input type=text name=user value=\"$user\"></td>
<td width=\"137\"><input type=text name=pass value=\"$pass\"></td>
<td><input type=text name=url value=\"$url\" size=\"50\"></td>";
print "<td width=\"35\"><input type=submit name=ed value=Edit></td>";
print "<td width=\"55\"><input type=submit name=dd value=Delete></td></tr>";
print "</form>";
}
}

}

print "</table>";
fclose($file);
print ("<br><center>number of users = $num <br></center>");
}
else {
print "The file doesn't exist!";
}
}
?>
<html>

KungPaoChicken

KungPaoChicken

Status: Offline!

just change index.php with admin.php, it script just stores the user info in that .txt file and admin.php edits it all... index.php isnt really needed i guess.

___________________

i stupended my own signarture

ExtremeDesign

ExtremeDesign

Status: Offline!

YOU DA MAN Grin Grin Grin Grin Grin

THANK YOU

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0079 seconds.