zoukankan      html  css  js  c++  java
  • php开发简单网站模板

    View Code
    <?php # Script 2.1 - config.inc.php
    
    /* 
     *    File name: config.inc.php
     *    Created by: Larry E. Ullman of DMC Insights, Inc. 
     *    Contact: LarryUllman@DMCInsights.com, http://www.dmcinsights.com
     *    Last modified: November 8, 2006
     *    
     *    Configuration file does the following things:
     *    - Has site settings in one location.
     *    - Stores URLs and URIs as constants.
     *    - Sets how errors will be handled.
     */
    
    # ******************** #
    # ***** SETTINGS ***** #
    
    // Errors are emailed here.
    $contact_email = 'address@example.com'; 
    
    // Determine whether we're working on a local server
    // or on the real server:
    if (stristr($_SERVER['HTTP_HOST'], 'local') || (substr($_SERVER['HTTP_HOST'], 0, 7) == '192.168')) {
        $local = TRUE;
    } else {
        $local = FALSE;
    }
    
    // Determine location of files and the URL of the site:
    // Allow for development on different servers.
    if ($local) {
    
        // Always debug when running locally:
        $debug = TRUE;
        
        // Define the constants:
        define ('BASE_URI', '/path/to/html/folder/');
        define ('BASE_URL',    'http://localhost/php/phpAdvancedVisualPro/simpleWeb/');
        define ('DB', '/path/to/mysql.inc.php');
        
    } else {
    
        define ('BASE_URI', '/path/to/live/html/folder/');
        define ('BASE_URL',    'http://www.example.com/');
        define ('DB', '/path/to/live/mysql.inc.php');
        
    }
        
    /* 
     *    Most important setting...
     *    The $debug variable is used to set error management.
     *    To debug a specific page, add this to the index.php page:
    
    if ($p == 'thismodule') $debug = TRUE;
    require_once('./includes/config.inc.php');
    
     *    To debug the entire site, do
    
    $debug = TRUE;
    
     *    before this next conditional.
     */
    
    // Assume debugging is off. 
    if (!isset($debug)) {
        $debug = FALSE;
    }
    
    # ***** SETTINGS ***** #
    # ******************** #
    
    
    # **************************** #
    # ***** ERROR MANAGEMENT ***** #
    
    // Create the error handler.
    function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {
    
        global $debug, $contact_email;
        
        // Build the error message.
        $message = "An error occurred in script '$e_file' on line $e_line: \n<br />$e_message\n<br />";
        
        // Add the date and time.
        $message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />";
        
        // Append $e_vars to the $message.
        $message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n<br />";
        
        if ($debug) { // Show the error.
        
            echo '<p class="error">' . $message . '</p>';
            
        } else { 
        
            // Log the error:
            error_log ($message, 1, $contact_email); // Send email.
            
            // Only print an error message if the error isn't a notice or strict.
            if ( ($e_number != E_NOTICE) && ($e_number < 2048)) {
                echo '<p class="error">A system error occurred. We apologize for the inconvenience.</p>';
            }
            
        } // End of $debug IF.
    
    } // End of my_error_handler() definition.
    
    // Use my error handler:
    set_error_handler ('my_error_handler');
    
    # ***** ERROR MANAGEMENT ***** #
    # **************************** #
    
    ?>

    header.php

    <?php //header.html
    //lthis page begins the html header for the site
    //check for a $page_title value
    if(!isset($page_title)) $page_title='default page Title';
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo $page_title;?></title>
    
    <link href="style.css" rel="stylesheet" type="text/css"/>
    
    
    </head>
    
    <body>
    <div id="container">
        <div id="header">
        <h1>Your Site</h1>
        <p>i like bylines</p>
        <form name="form1" id="form1" method="get" action="index.php">
        <input type="text" name="terms" value="Search..." />
        <input type="hidden" name="p" value="search" />
        <input type="submit" class="button"  name="submit" value="GO"  />
        </form>
        </div>
       
       <div id="navigation">
       <ul id="navlist">
           <li><a href="index.php">Home</a></li>
        <li><a href="index.php?p=about">About Us </a></li>
        <li><a href="index.php?p=this">This</a></li>
        <li><a href="index.php?p=that">That</a></li>
        <li><a href="index.php?p=contact">Contact</a></li>
       <li><p><strong>A tiny little service annoumcement .</strong><br/>Put all
           your little tidbits of information or pictures in this small yet useful little area</p>
           </li>
         </ul>
         </div>
         
        <div id="sidebar">
            <h2>The Sidebar</h2>
              <p>You have reached the sidebar, put news, links, or anything textual in here. 
              I think I'll drag on with typing nonsense text, until you feel really really
               sleepy. Of course, you wouldn't waste time reading this. Some Latin would be more                useful.</p>
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas venenatis enim ut purus. In hac habitasse platea dictumst. Sed rutrum tempus turpis. Sed rhoncus dui eu ipsum. Pellentesque tincidunt. Quisque pulvinar. Morbi quis leo sit amet neque tempor fringilla. Pellentesque faucibus metus vitae erat. Quisque a urna ut sapien accumsan ornare. Nulla porta pretium eros. Fusce velit erat, accumsan pellentesque, porttitor eu
            , commodo quis, augue. <a href="#">Fusce convallis ipsum eget felis</a>. </p>
            </div>
           
          <div id="content">
       
            
     

    footer.php

    <!-- footer.html-->
    </div>
    
    <div id="footer">
      <p><a href="http://validator.w3.org/check?uri=referer" target="_blank">Valid 
      XHTML</a> | <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank">Valid 
      CSS</a> |CopyRight &copy;Your name 
      Here |design by <a href="http://">XXX</a></p>
     </div>
     </div>
     </body>
     </html>
     

    main.inc.php

    <?php
     if (!defined('BASE_URL')) {
    
        // Need the BASE_URL, defined in the config file:
        require_once ('config.inc.php');
        
        // Redirect to the index page:
        $url = BASE_URL . 'index.php';
        header ("Location: $url");
        exit;
        
    } // End of defined() IF.
    ?>
      <h2>Welcome to Leaves.</h2>
          <p>Welcome to Leaves, a static, 3 column layout made with your usual CSS and XHTML. It is able to correctly accommodate any font size increases or shrinkages (Is that a word?). It seems to work fine in Firefox, Opera, Internet Explorer and Safari. It's more minimal than other designs, because I think images (drop shadows, giant header images) are being obsessively over used these days. I think it detracts from the content and shoves way too much information to a viewer all at the same time, so here you go: Leaves, a minimalist design. Feel free to massacre or change the design to your liking. Well, I guess it's time for some more Latin. <strong>If you want me to create a custom design for you, feel free to drop me a line anytime at web@smallpark.org </strong></p>
          <h2>Why I like Latin Filler Text. </h2>
          <p>Aenean eros arcu, condimentum nec, dapibus ut, tincidunt sit amet, urna. Quisque viverra, eros sed imperdiet iaculis, est risus facilisis quam, id malesuada arcu nulla luctus urna. Nullam et est. Vestibulum velit sem, faucibus cursus, dapibus vestibulum, pellentesque et, urna. Donec luctus. Donec lectus. Aliquam eget eros facilisis tortor feugiat sollicitudin. Integer lobortis vulputate sapien. Sed iaculis erat ac nunc. <a href="#">Etiam eu enim.</a> Mauris ipsum urna, rhoncus at, bibendum sit amet, euismod eget, dolor. Mauris fermentum quam vitae ligula. Vestibulum in libero feugiat justo dictum consectetuer. Vestibulum euismod purus eget elit. Nunc sed massa porta elit bibendum posuere. Nunc pulvinar justo sit amet odio. In sed est. Phasellus ornare elementum nulla. Nulla ipsum neque, cursus a, viverra a, imperdiet at, enim. Quisque facilisis, diam sed accumsan suscipit, odio arcu hendrerit dolor, quis aliquet massa nulla nec sem. </p>
          <h2>Because I just do. </h2>
          <p><a href="#">Proin sagittis leo in diam</a>. Vestibulum vestibulum orci vel libero. Cras molestie pede quis odio. Phasellus tempus dolor eu risus. Aenean tellus tortor, dignissim sit amet, tempus eu, eleifend porttitor, ipsum. Fusce diam. Suspendisse potenti. Duis consequat scelerisque lacus. Proin et massa. Duis adipiscing, lectus a euismod consectetuer, pede libero ornare dui, et lacinia ipsum ipsum nec lectus. Suspendisse sed nunc quis odio aliquet feugiat. Pellentesque sapien. Phasellus sed lorem eu augue luctus commodo. Nullam interdum convallis nunc. Fusce varius. Ut egestas. Fusce interdum iaculis pede. Sed vehicula vestibulum odio. <a href="#">Donec id diam. </a></p>

    index.php文件

    <?php /*index.php索引页面,组合适当的部分来形成完整的web页面。*/
    
    require_once('config.inc.php');
    
    //validate what page to show
    if(isset($_GET['p']))
    {
        $p=$_GET['p'];
    }
    elseif(isset($_POST['p'])) 
    {
        //forms
        $p=$_POST['p'];
    }
    else
     {
         $p=NULL;
     }
     //determien what page to display
     switch ($p)
     {
         case 'about':
             $page='about.inc.php';
            $page_title='About this Site';
            break;
        case 'this':
            $page='this.inc.php';
             $page_title='This is another page';
            break;
        case 'that':
              $page='that.inc.php';
            $page_title='That is also a page';
            break;
        case 'contact':
            $page='contact.inc.php';
            $page_title='Contact us';
            break;
        
        case 'search':
            $page='search.inc.php';
            $page_title='Search Results';
            break;
        default:
            $page='main.inc.php';
            $page_title="Site home Page";
            break;
     }
     
     //make sure file exists
     if(!file_exists($page))
     {
         $page='main.inc.php';
         $page_title='Site home Page';
     }
     
     require_once('header.php');
     
     require_once($page);
      
     require_once('footer.html');
    
    ?>
        
        

    style.css文件:

    /* --------------------------------------------------
    CSS Document For Leaves v1.0 - Anthonyy @ OSWD.org
    -------------------------------------------------- */
    
    /* CONTAINER */
    
            #container {
                width: 750px;
                margin: 0 auto;
                font-family: Lucida Grande, Tahoma, Arial, Helvetica, sans-serif; /* Lucida Grande for the Macs, Tahoma for the PCs */
                font-size: 11px;
                line-height: 1.6em;
                color: #666;
                background-color: #FFF;
            }
            
    /* GENERAL MOJO AND MULA */
            
            h1 {
                font-family: Arial, Helvetica, sans-serif;
                font-weight: normal;
                font-size: 32px;
                color: #CC6633;
                margin-bottom: 30px;
                background-color: #FFF;
            }
            
            h2 {
                color: #666666;
                font-size: 16px;
                font-family: Arial, Helvetica, sans-serif;
                background-color: #FFF;
            }
            
            a {
                color:#CC6714;
                text-decoration: none;
            }
    
            a:hover {
                color:#CC6714;
                background-color: #F5F5F5;
            }
    
            
            form {
                float:right;
                margin-top: -45px;
                font-size: 9px;
            }
            
            input {
                background-color: #FFF;
                color: #999999;
                border: 1px solid #CCC;
                font-size: 11px;
                padding: 3px;
            }
            
            .button {
                padding: 2px;
            }
            
            .error {
                color: #F03;
                font-size: 16px;
                font-family: Arial, Helvetica, sans-serif;
                background-color: #FFF;
            }
            
    /* HEADER ELEMENTS */
    
            #header {
                border-bottom: 4px solid #948979;
                padding-top: 10px;
                clear: both;
                margin-bottom: 10px;
            }
            
    
            /* the slogan */
            #header p { 
                margin-top: -20px;
                margin-left: 30px;
                color: #999999;
            }
    
    /* NAVIGATION ELEMENTS */
        
             #navigation ul {
                margin-left: 0;
                padding-left: 0;
                list-style-type: none;            
                float: left;
                width: 140px;
            }
    
            #navigation a {
                display: block;
                padding: 5px;
                width: 140px;
                border-bottom: 1px solid #CCC;
            }
    
            #navigation a:link, #navlist a:visited {
                color:#CC6714;
                text-decoration: none;
            }
            
            #navigation a:hover {
                background: #000000 url(../images/arrow.gif) 96% 50% no-repeat;
                background-color: #F5F5F5;
                color:#CC6714;
            }
    
    /* THE SMALL BOX BELOW NAV */
    
            #navigation p {
                margin-top: 40px;
                padding: 5px;
                border-bottom: 1px dotted #CCC;
                border-top: 1px dotted #CCC;
            }
            
    /* CONTENT ELEMENTS */
    
            #content {
                width: 362px;
                margin-left: 180px;
                margin-right: 200px;
            }
            
            #content p {
                padding-bottom: 10px;
                border-bottom: 1px solid #DDDDDD; /* A faint grey line below the text */
            }
    
    /* SIDEBAR ELEMENTS */
    
            #sidebar {
                float: right;
                width: 175px;
            }
            
            #sidebar p {
                padding-bottom: 10px;
                border-bottom: 1px solid #DDDDDD;
            }
    
    /* FOOTER ELEMENTS */
    
            #footer {
                margin-top: 20px;
                clear: both;
                background-color:#575352;
                padding: 0px 5px 0px 5px;
            }
            
            #footer p {
                color:#89817f;
                padding: 5px;
            }
            
            #footer p a {
                color: #89817f;
                border-bottom: 1px dotted #89817f;
            }
            
            #footer p a:hover {
                color: #FFFFFF;
                background-color:#575352;
            }
            
            /* And they lived happily ever after. The End. */
  • 相关阅读:
    已解决:No 'Access-Control-Allow-Origin'跨域问题
    (转 )聊聊GIS中的坐标系|再版
    CentOs如何挂载硬盘(手把手教你 )
    CentOS如何挂载硬盘
    CentOS7 复制文件夹和移动文件夹
    centos中怎么查看一个文件的创建时间
    vue项目报错Trailing spaces not allowed.
    (转)Vue框架Element UI教程-安装环境搭建(一)
    windows 根据端口查看进行PID 并杀掉进程
    完美解决CentOS8 yum安装AppStream报错,更新yum后无法makecache的问题
  • 原文地址:https://www.cnblogs.com/youxin/p/2642081.html
Copyright © 2011-2022 走看看