Here's the code that makes the pages:
Code: Select all
<?php
import_request_variables('pg');
if($send=='send'){
include('edited out');
//Insert data into databases
$newpage = "$page_link".".php";
$query = "edited out query";
mysql_query($query);
include('includes/random_gen.php');
$pageid = get_rand_id(10);
$query2 = "edited out query";
mysql_query($query2);
//create new files
//create new pages, front end page, back end page
switch($layout){
case 1:
$filename = '../templates/three_cols.php';
$filename2 = 'templates/three_cols.php';
break;
//etc etc truncated to make easier to read
}
//open files for reading
$fh = fopen ($filename, "r") or die ("couldn't open file");
$fh2 = fopen ($filename2, "r") or die ("couldn't open file");
//get data from files
$data = fread($fh,filesize($filename));
$data2 = fread($fh2,filesize($filename2));
//close files
fclose($fh);
fclose($fh2);
//new files
$fh = fopen("../$newpage","w") or die ("couldn't make file");
$fh2 = fopen("$newpage","w") or die ("couldn't make file2");
//replace content in the data
$data = str_replace('0000000000',"$pageid",$data);
$data2 = str_replace('0000000000',"$pageid",$data2);
//Proper navigation heading?
switch($parent_page){
case 1: //home
$data = str_replace('<body>','<body id="page1">',$data);
$data2 = str_replace('<body>','<body id="page1">',$data2);
break;
//etc etc...truncated to make it easier to read
}
//write the data into the files
fwrite($fh,$data);
fwrite($fh2,$data2);
//close files
fclose($fh);
fclose($fh2);
//set permissions
chmod("../$newpage",0644);
chmod("$newpage",0644);
//end file creation
header("Location: $newpage");
exit(0);
}
?>Any help is greatly appreciated, thanks,
Justin