View Single Post
 
More PHP help needed!
Reply
Posted 2008-06-25, 08:11 AM
Alright! I've practiced a ton of php and am learning more and more. Now, I've figured out how to make an admin area (secure login/logout) with a page creator, page editor, and IP logger. The page editor is actually what I need help with as of right now.

I'm using a rather strange method to edit things. Really what I want is to edit the raw data. As of right now, I'm editing the data output. I've yet to figure out how to edit any other way. So, please take a look and tell me a better way with this.


index.php
Code:
<?php 

// Page asks for user cookie of proof of signed in.  If not, then use is given the login page.

if ($_GET['function']=="newpage" && isset($_COOKIE['HIDDEN'])) {
	include('inc/main.php');
	}
elseif ($_GET['function']=="editpage" && isset($_COOKIE['HIDDEN'])) {
	include('inc/editpage.php');
	}
elseif ($_GET['function']=="editpage" && $_GET['data']=="process" && isset($_COOKIE['HIDDEN'])) {
	include('inc/editpage.php');
	}
elseif ($_GET['function']=="logged" && isset($_COOKIE['HIDDEN'])) {
	include('inc/logging.php');
	}
elseif (isset($_COOKIE['HIDDEN'])) {
	include('inc/main2.php');
	}
else {
	include('login.php');
	}
?>


index.php?function=editpage
Code:
		  <form id="form1" name="form1" method="post" action="index.php?function=editpage&data=process">
            <label>File Name (e.g. file.php - Look below for folder contents)<br />
            <input name="pageopen" type="text" value="" />                   
            <br /></label>
			<label>[To edit pages from the admin folder type "./" without the quotes.]<br />Folder Location (e.g. ../ or /site/)<br />
			<input name="pageloc" type="text" value="" />
            </label>
            <input name="Submit" type="submit" value="Submit" />
		  </form>
	  <br />
        <form action="fedit.php" method="post">
        <label>Edit File (Once File is Opened)<br />
        <textarea name="edit" cols="60" rows="25">
<?php 
if (isset($_REQUEST['pageopen']) && isset($_POST['pageloc'])) {
$thepage = $_POST['pageopen'];
$thedir = $_POST['pageloc'];
chdir("$thedir");
include("$thepage");
}
else {
echo "";
}
?>
</textarea>
        </label>
        <input name="pagename" type="text" value="<?php 
		if (isset($_POST['pageloc'])) {
			$thepage = $_POST['pageopen'];
			echo "$thepage";
			}
		else
			echo "";
		?>" />
        <input name="pagedir" type="text" value="<?php 
		if (isset($_POST['pageloc'])) {
			$thedir = $_POST['pageloc'];
			echo "$thedir";
			}
		else
			echo "";
		?>" />
        <input name="submitter" type="submit" value="Save" />
        </form>

fedit.php
Code:
<?php 
if (isset($_COOKIE['HIDDEN'])) {
	header("Location: index.php?function=editpage");
	$thepage = stripslashes($_POST['pagename']);
	$thedir = $_POST['pagedir'];
	$edit = stripslashes($_POST['edit']);
	chdir("$thedir");
	unlink("$thepage");
	$fp = fopen("$thepage", "a");
	fwrite($fp, "$edit");
	fclose($fp);
	exit;
	}
else {
	header("Location: index.php?function=editpage");
	} 
?>
So, I don't believe there are any more pages that need to be defined to understand this.
 
Work List
疲れていますから 寝むってありますね。 むずかしいです。 また、ケーキ屋で ケーキを食べていました。

I've considered being a translator, but I dunno. It feels like a lot of work. If someone gets angry then I have to deal with it, you know? I'd rather just relax.

 
Speed Test
 
Favorite Anime/Manga
#01 Clannad ~After Story~
#02 Trigun {Maximum}
#03 Koi Kaze
#04 Berserk
#05 Outlaw Star
#06 Slayers
#07 Desert Punk
#08 Spirited Away
#09 Fullmetal Alchemist
#10 Shakugan no Shana
#11 Death Note
#12 FLCL
#13 Tokyo Magnitude 8.0
#14 Toradora
#15 Gunslinger Girl

 
Anime List

Last edited by Goodlookinguy; 2008-06-25 at 08:13 AM.
Old
Profile PM WWW Search
Goodlookinguy seldom sees opportunities until they cease to beGoodlookinguy seldom sees opportunities until they cease to beGoodlookinguy seldom sees opportunities until they cease to beGoodlookinguy seldom sees opportunities until they cease to be
 
 
Goodlookinguy