Zend - The PHP Company




HTML

Add Code


Dynamic Page  

Type: application
Added by: ghost
Entered: 22/10/2000
Last modified: 01/12/2000
Rating: **** (4 votes)
Views: 11372
Dynamic Page is a framework, to let you store the entire web site (or multiple sites) and related data in a database, and from that, build the pages, using different "code snippets". This way, you can easily build sites, that reuses code, regardless of type, replace entire code segments in any number of pages immediately. It supports pure HTML snippets, PHP code execution, and "page descriptors", which is a way of describing wich "code snippets" to use, in composing the page. Code from one page, can be used in another page. Data from one page, can be copied to another page. It also has support for pictures and other types of objects, wich can be retrieved from the database. It currently uses MySQL as database. The code is fast, and very small (appx. 1.8 Kbyte) For further information, read the documentation in the package. The code is licensed under the GPL, developed by W10.NET Ltd. The complete set of files will be found at: ftp://w10.net/pub/W10/DynamicPage/


<?php
<script language="PHP">
//  DynamicPage 0.01 - Copyright (C) 2000  W10.NET Ltd, Scotland. Http://w10.net
//     The complete file package will be found on: ftp://w10.net/W10/DynamicPage
/*
    The copyright line above, must not be removed at any time.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/ 

// Configuration code.
// -------------------
$DefaultSiteName    "A" 
$DataBaseHost        "localhost" 
$UserName            "user" 
$UserPass            "pass" 
$DataBase            "ABC" 
$BasePageName        "Index" 
$CommonPageName        "Common" 
$UndefinedPageName    "Undefined" 
// -------------------

if (empty($page)) $page $BasePageName
if (empty(
$SiteName)) $SiteName$DefaultSiteName 

$sql_tok mysql_connect($DataBaseHost,$UserName,$UserPass) ; 
mysql_select_db($DataBase,$sql_tok) ;

Snippet($page,"") ; 

mysql_close($sql_tok) ; 



function 
Snippet($page,$xx_name)
{
    global    
$SiteName,$sql_tok,$UndefinedPageName 

    if (
strstr($xx_name,':') != "") { $xx_pn split(":",$xx_name,2); $page $xx_pn[0] ; $xx_name $xx_pn[1] ; } 
    
$sql_idx mysql_query("select * from PAGEbuild where Wn='$SiteName' and Pn='$page' and Sn='$xx_name'",$sql_tok) ; 
    if (
mysql_num_rows($sql_idx) == 0Snippet($UndefinedPageName,"") ;
    
    
$xx_part mysql_fetch_array($sql_idx) ; 
    
$xx_text stripslashes($xx_part[Code]) ; 
    
$xx_Type strtolower($xx_part[Type]) ; 
    
    if (
$xx_Type == "page")
    {    
        
$xx_page explode("n",urldecode(ereg_replace("%0D","",urlencode($xx_text)))) ; 
        for (
$i $i < (sizeof($xx_page)-1) ; $i++) Snippet($page,$xx_page[$i]) ;
    }

    if (
$xx_Type == "html")    echo $xx_text 
    if (
$xx_Type == "code")    eval($xx_text) ;
    if (
$xx_Type == "pict")    Object($page,$xx_name) ; 
}

function 
Common($name) { global $CommonPageName Snippet($CommonPageName,$name) ; }

function 
Object($page,$name)
{
    global 
$object,$SiteName,$sql_tok ;
    
$sql_idx_tt mysql_query("select * from PAGEbuild where Wn='$SiteName' and Pn='$page' and Sn='$name'",$sql_tok) ; 
    
$xx_part mysql_fetch_array($sql_idx_tt) ; 
    
$Type strtolower($xx_part(Type)) ; 
    
    if (
$Type == "pict")    Header("Content-type: image/gif");
    if (
$Type == "object")    Header("Content-type: $mime");

    echo 
base64_decode($xx_part[Code]) ;     
}


</script>

?>


Usage Example




Rate This Script





Search



This Category All Categories