`
sq1228
  • 浏览: 81402 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

个人不成熟作品全静态站点引思

    博客分类:
  • PHP
阅读更多
php代码:
<?/************** 
  静态页面生成类 
  作者:逛悠~ 
  时间:2005-8-11 
  功能:根据页面生成时间 
  更新和生成新的html页面 
  **************/ 
  class htmlProduct { 
      public $title;  //标题; 
      public $id;     //id号 
      public $keywords = 'PHP,ASP,JSP,web,w3c,W3C,WEB,java'; 
      public $buttons =array('home' =>'home.php', 
                             'code_share' =>'code_share.php', 
                             'download' =>'download.php', 
                             'communicate' =>'communicate.php' 
                            ); 
      public $result; 
      public $content; 

      function __construct($title='',$id='',$content='') 
      { 
          $this->reuslt=''; 
          $this->id=$id; 
          $this->content=$content; 
           
      } 
      function create_html_page() 
      {   //update $id.html 's contents if its lastmodified time more than 3 days! 
          if(file_exists("article/$this->id.html")&&(time()-filemtime("article/$this->id.html"))>25600) 
              { 
                  $fp=fopen("article/$this->id.html","w"); 
                  fputs($fp,$this->Display()); 
                  fclose($fp); 
              } 
          elseif(!file_exists("article/$this->id.html")) 
              { 
                  $fp=fopen("article/$this->id.html","w"); 
                  fputs($fp,$this->Display()); 
                  fclose($fp); 
              } 
               
              return  realpath("article/$this->id.html"); 
      } 
      function create_index_page() { 
        if(file_exists("article/index$this->id.html")&&(time()-filemtime("article/index$this->id.html"))>25600) 
              { 
                  $fp=fopen("article/index$this->id.html","w"); 
                  fputs($fp,$this->Display()); 
                  fclose($fp); 
              } 
          elseif(!file_exists("article/index$this->id.html")) 
              { 
                  $fp=fopen("article/index$this->id.html","w"); 
                  fputs($fp,$this->Display()); 
                  fclose($fp); 
              } 
               
              return  realpath("article/index$this->id.html"); 
      } 
      // class Page's operations 
      public function __set($name,$value) 
      { 
          $this->$name=$value; 
      } 
     
      // product html page! 
      public function Display() 
      { 
          $str.= "<html>\r\n<head>\r\n"; 
          $str.= $this->DisplayTitle(); 
          $str.= $this->DisplayKeywords(); 
          $str.= $this->DisplayStyles(); 
          $str.= "</head>\r\n<body>\r\n"; 
          $str.= $this->DisplayHeader(); 
          $str.= $this->DisplayMenu($this->buttons); 
          $str.="<div width='100%' style='background:#eeeeee;border: 
          1px gray solid;height:500;padding:30px;font-size:9pt'>"; 
          $str.= nl2br($this->content); 
          $str.="</div>"; 
          $str.=$this->DisplayFooter(); 
          $str.="</body>\r\n</html>\r\n"; 
          return $str; 
           
      } 
      public function DisplayTitle() 
      { 
          return  "<title>$this->title</title>"; 
      } 
      public function DisplayKeywords() 
      { 
          return "<meta name=\"keywords\" content=\"".htmlentities($this->keywords)."\" />"; 
      } 
      public function DisplayStyles() 
      { 
           
          $str.='<style>'; 
          $str.='<!--'; 
          $str.='h1{color:white;font-size:24pt;text-align:center;font-family:arial,sans-serif}'; 
          $str.='.menu{color:white;font-size:12pt;text-align:center;font-family:arial,sans-serif;font-weight:bold}'; 
          $str.='td{background:gray}'; 
          $str.='p{color:black;font-size:12pt;text-align:justify;font-family:arial,sans-serif}'; 
          $str.='p.foot{color:white;font-size:9pt;text-align:center;font-family:arial,sans-serif;font-weight:bold}'; 
          $str.='a:link,a:visited,a:active{color:white}'; 
          $str.='-->'; 
          $str.='</style>'; 
         
          return $str; 
     
      } 

      public function DisplayHeader() 
      { 
           
          $str='<table width ="100%" cellpadding ="12" cellspacing ="0" border ="0">'; 
          $str.='<tr bgcolor="black">'; 
          $str.='<td align="left"><img src="images/logo.gif" /></td>'; 
          $str.='<td>'; 
          $str.='<h1>Test Complete Html Create!</h1>'; 
          $str.='</td>'; 
          $str.='<td align ="right"><img src ="images/logo.gif" /></td>'; 
          $str.='</tr>'; 
          $str.='</table>'; 

          return $str; 
     

      } 
      public function DisplayMenu($buttons) 
      { 
          $str="<table width='100%' bgcolor='white' cellpadding='4' cellspacing='4'>\r\n"; 
          $str.="<tr>\r\n"; 

          //calculate button size 
          $width =100/count($buttons); 
          foreach($buttons as $name=>$url) 
          { 
              $str.=$this->DisplayButton($width,$name,$url,!$this->IsURLCurrentPage($url)); 
          } 
          $str.= "</tr>\r\n"; 
          $str.="</table>\r\n"; 
          return $str; 
      } 
      public function IsUrlCurrentPage($url) 
      { 
          if(strpos($_SERVER['PHP_SELF'],$url)==false) 
          { 
              return false; 
          } 
          else 
          { 
              return true; 
          } 
      } 
      public function DisplayButton($width,$name,$url,$active =true) 
      { 
          if($active) 
          { 
              $str="<td width ='".htmlentities($width)."%'> 
              <a href='".htmlentities($url)."'> 
              <img src='images/s_logo.gif' alt='".htmlentities($name)."'border='0' /></a> 
              <a href='".htmlentities($url)."'><span class='menui'>$name</span></a></td>"; 
          } 
          else 
          { 
              $str.= "<td width='".htmlentities($width)."%'><img src='images/side_logo.gif'> 
              <span class='menu'>$name</span></td>"; 
          } 
          return $str; 
      } 
      public function DisplayFooter() 
      { 
           
          $str='<table width="100%" bgcolor="black" cellpadding="12" border="0">'; 
          $str.='<tr>'; 
          $str.='<td>'; 
          $str.='<p class="foot">©Test Complete Html Create.</p>'; 
          $str.='<p class="foot">Please see my <a href=\'legal.php\'>legal information page</a></p>'; 
          $str.='</td>'; 
          $str.='</tr>'; 
          $str.='</table>'; 
         
          return $str; 
               
      } 
  } 
  ?> 

//生成页面(包含分页)
<?php 
/* 
目前手上没有5.0的mysql,用的是appserv,所以使用的面向过程的连接办法 
汗~ 
*/ 
require ('htmlProduct.php'); 
$html= new htmlProduct(); 
$db=mysql_connect('localhost','yoyibf','haoying'); 
$select=mysql_select_db('phpstudy'); 
$result=mysql_query("select article_id,article_title,article_intro from arti_auth "); 
$num=mysql_num_rows($result); 


//生成文章列和单项内容页面 
while($row =mysql_fetch_array($result)) 
{ 
    $html->id=$row['article_id']; 
    $html->content=$row['article_intro']; 
    $html->title=$row['article_title']; 
    //create html page! 
    $arr[]=array("url"=>$html->create_html_page(), 
                 "modifiled"=>filemtime($html->create_html_page()), 
                 "create_stauts"=>"ture" 
                 ); 
    $list_arr[]=array('id'=>$row['article_id'], 
                 'title'=>$row['article_title'] 
                 ); 
     
} 
//生成主题列表页一 
for($j=0,$i=0;$j<ceil($num/5);$j++) { 
    //分页连接 
    $str='<pre><p>Article list for://目前一共有'.$num.'条记录,['.($j+1).'/'.ceil($num/5).'],进入第<select onchange=\'javascript:location.href=this.options[this.selectedIndex].value\'>'; 
    for($m=0;$m<ceil($num/5);$m++) 
    { 
        $str.='<option value=\'/article/index'.($m+1).'.html\''; 
        $str.=($m==$j)?" selected>":">"; 
        $str.=($m+1).'</a></option>'; 
    } 
    $str.='</select>页<hr>'; 
    for($i=$j*5;$i<$j*5+5&&$i<$num;$i++)    
        $str.='<a style="text-decoration:none;color:#000000" href=\'/article/'.($i+1).'.html\'>['.($i+1).']'.$list_arr[$i]['title'].'</a><br />'; 
//生成主题列表页面 
$html->id=($j+1); 
$html->content=$str; 
$html->title='主题页'; 
$html->create_index_page(); 
//===============================index.$j.html 
echo "<pre>"; 
echo $str; 
echo "<hr>"; 
} 

 

分享到:
评论

相关推荐

    苹果cmsV10暗色系动漫影视网站模板无限制版

    - 网站开发者:需要一套成熟稳定的模板来快速搭建动漫站点的专业人士。 通过上述分析可以看出,苹果CMS V10暗色系动漫影视网站模板不仅具备丰富的功能模块,而且在技术架构上也进行了细致考虑,非常适合用于创建...

    lucasvigier.github.io

    2. **个人主页构建**: 通过GitHub Pages创建个人主页,开发者通常会使用Jekyll、Hugo等静态站点生成器,或者直接用HTML、CSS和JavaScript编写静态页面。 3. **CSS技术**: 项目中的CSS可能是用来设计和美化网页布局...

    WilliamLee1004.github.io

    8. **静态网站生成器**: 虽然没有明确提到,但个人站点也可能使用Jekyll、Hugo、Gatsby等静态网站生成器,它们能将Markdown和其他内容源转换为静态HTML,简化网站开发和维护。 9. **SEO优化**: 一个成熟的个人网站...

    bodenstabp.github.io

    【标题】"bodenstabp.github.io" 是一个个人或组织在GitHub上托管的网站项目,通常用于展示个人作品、博客、项目代码等。这样的项目表明用户利用了GitHub Pages服务来创建并发布自己的网页。 【描述】"bodenstabp....

    r3alitya.github.io:项目现场的东西

    在IT行业中,GitHub是一个非常重要的平台,它是一个用于...通过持续迭代和更新,"r3alitya.github.io"有望成为一个展示'r3alitya'技能和作品的成熟平台。对于其他开发者来说,这样的公开项目也是学习和交流的好资源。

    Web 2.0 编程思想:16条法则

    例如,在设计一个社交网站时,开发者需要思考如何让用户更轻松地创建和管理个人主页,以及如何促进用户之间的互动。 #### 法则二:重视URI与URL的作用 Web 2.0的核心在于信息的互联互通。因此,必须重视URI(统一...

    客客威客系统KPPW 2.2 GBK Beta.zip

    且针对现有的服务和作品的业务功能进行了进一步细化的深入,满足了大部分的创意型产品的买卖交易。 五、用户经验权限体系改造更体贴 新版本重构了用户经验权限体系,针对威客应用的贴切需求,将雇主信用和威客...

    客客出品专业威客系统KPPW v2.5 GBK.zip

    伪静态规则做了全面调整,能适应于各种服务器运行环境下的稳定运行。新版同时增强了任务、商品、资讯信息的SEO规则设置和关键词的描点链接等功能,让您的网站尽快得到搜索引擎的收录。 八、增值功能更丰富 丰富...

    天人短文网站系统(带手机版) v4.58

    它采用ASP编程语言,并且支持Access和MSSQL两种数据库,这使得该系统具有良好的兼容性和可扩展性,无论对于小型个人站点还是大型文学社区都能胜任。 1. **ASP架构**:ASP(Active Server Pages)是一种服务器端脚本...

    基于ASP的EXW Flash整站系统[EXW Flash CMS] v2.0.zip

    5. **安全性和稳定性** - 作为成熟的CMS系统,v2.0可能已经解决了早期版本的漏洞,并增强了系统的稳定性和安全性。 **应用场景:** 1. **企业官网** - 对于希望通过吸引眼球的动画展示企业形象的公司,EXW Flash ...

    天人短文网站系统(带手机版) v4.45

    2. **数据库支持**:系统同时支持Access和MSSQL两种数据库,Access适合小型站点,而MSSQL则适用于高并发、大数据量的网站,可根据实际需求选择。 3. **后台管理**:通过单一后台管理系统,可以方便地对所有内容进行...

    armaan110.github.io

    标题“armaan110.github.io”表明这是一个个人或项目的GitHub Pages网站,通常用于展示个人作品、博客或者开源项目。这种类型的网站往往基于静态页面生成技术,如Jekyll或Hugo,而“armaan110”可能是创建者或维护者...

    客客出品专业威客系统KPPW源码 v2.5

    [修复]后台的服务管理和作品管理处点搜索回到首页 [修复]订金招标结束后,好评的花朵图标未显示 [修复]发布0元任务,后台显示未付款 [修复]商品和服务下架,用户中心依旧有增值工具按钮 [修复]单人悬赏任务自动选稿...

Global site tag (gtag.js) - Google Analytics