Location: PHPKode > projects > WebMachinek > WMinst-0.62/new_page.php
<?php
require("$public/.sys/.conf.php");
require("$public/.sys/.dynimage.php");
require("$public/.sys/.start.php");

$slash = strstr($dir, "/");
if ($slash != "") {
 $length = strlen($dir);
 $position = strpos($dir, "/");
 $category = substr($dir, 0, $position );
 $subcat = "yes";
} else {
 $category = $dir;
 $subcat = "no";
}

$conn = pg_connect("dbname=$dbase user=$dbuser port=5432");
pg_exec($conn, "INSERT INTO category (dir) VALUES ('..');");
$query1 = pg_exec($conn, "SELECT OID FROM category
                           WHERE dir LIKE '..';");
pg_exec($conn,"DELETE FROM category
                WHERE dir LIKE '..';");

$query2 = pg_exec($conn,"SELECT max(page_pos)+1 FROM page
                          WHERE dir LIKE '$dir';");

$query3 = pg_exec($conn,"SELECT count(file)+1 FROM page
                          WHERE file LIKE 'index';");

$number = pg_fetch_array($query1, 0);
$filename = "page$number[0]";
$position = pg_fetch_array($query2, 0);
$iposition = pg_fetch_array($query3, 0);


if ($subcat == "yes") {
 pg_exec($conn,"INSERT INTO page (file, dir, child, page_pos)
                 VALUES ('$filename', '$dir', 't', '$position[0]');");
 pg_exec($conn,"INSERT INTO page_descr (file,dir,nav,title)
                 VALUES ('$filename','$dir','New Page','New Page');");
 pg_exec($conn,"INSERT INTO page_layout (file, dir)
                 VALUES ('$filename', '$dir');");
} elseif ($file == "index") {
 pg_exec($conn,"INSERT INTO page (file, dir, child, page_pos)
                 VALUES ('index', '$filename', 'f', '0');");
 pg_exec($conn,"INSERT INTO category (dir, pos)
                 VALUES ('$filename', '$iposition[0]');");
 pg_exec($conn,"INSERT INTO page_descr (file,dir,nav,title)
                 VALUES ('index','$filename','New Page','New Page');");
 pg_exec($conn,"INSERT INTO page_layout (file, dir)
                 VALUES ('index', '$filename');");
} else {
 pg_exec($conn,"INSERT INTO page (file, dir, child, page_pos)
                 VALUES ('$filename', '$dir', 'f', '$position[0]');");
 pg_exec($conn,"INSERT INTO page_descr (file,dir,nav,title)
                 VALUES ('$filename','$dir','New Page','New Page');");
 pg_exec($conn,"INSERT INTO page_layout (file, dir)
                 VALUES ('$filename', '$dir');");
}



if ($subcat == "yes") {
 startpage("$filename", "$dir", "t", "t", "$admin/$dir/$filename.php");
 startpage("$filename", "$dir", "t", "f", "$public/$dir/$filename.php");
 dynimage("New Page", "$public/$dir/$filename"."_img.php");
 dynimage("New Page", "$admin/$dir/$filename"."_img.php");
 $fp3 = fopen("$admin/.repos/$dir/$filename.xml", "w");
 fwrite($fp3, "<p>AUTOMATICALY GENERATED PAGE</p>");
 fclose($fp3);
} elseif ($file == "index") {
 mkdir("$admin/$filename", 0755);
 mkdir("$public/$filename", 0755);
 mkdir("$admin/.repos/$filename", 0755);
 startpage("index", "$filename", "f", "t", "$admin/$filename/index.php");
 startpage("index", "$filename", "f", "f", "$public/$filename/index.php");
 dynimage("New Page", "$public/$filename/index_img.php");
 dynimage("New Page", "$admin/$filename/index_img.php");
 $fp3 = fopen("$admin/.repos/$filename/index.xml", "w");
 fwrite($fp3, "<p>AUTOMATICALY GENERATED PAGE</p>");
 fclose($fp3);
} else {
 mkdir("$admin/$dir/$filename", 0755);
 mkdir("$public/$dir/$filename", 0755);
 startpage("$filename", "$dir", "f", "t", "$admin/$dir/$filename/index.php");
 startpage("$filename", "$dir", "f", "f", "$public/$dir/$filename/index.php");
 dynimage("New Page", "$public/$dir/$filename/$filename"."_img.php");
 dynimage("New Page", "$admin/$dir/$filename/$filename"."_img.php");

 $fp3 = fopen("$admin/.repos/$dir/$filename.xml", "w");
 fwrite($fp3, "<p>AUTOMATICALY GENERATED PAGE</p>");
 fclose($fp3);
}
pg_close($conn);


if ($file == "index") {
 $link = "$urladmin/$filename/index.php";
 echo("<a href='$link'>GO</a>");
 echo('<script LANGUAGE="JavaScript1.1" type="text/javascript">');
 echo("document.location=\"$link\"");
 echo("</script>");
} elseif ($subcat == "no") {
 $link = "$urladmin/$dir/$filename/index.php";
 echo("<a href='$link'>GO</a>");
 echo('<script LANGUAGE="JavaScript1.1" type="text/javascript">');
 echo("document.location=\"$link\"");
 echo("</script>");
} else {
 $link = "$urladmin/$dir/$filename.php";
 echo("<a href='$link'>GO</a>");
 echo('<script LANGUAGE="JavaScript1.1" type="text/javascript">');
 echo("document.location=\"$link\"");
 echo("</script>");
}
php?>

Return current item: WebMachinek