用户
 找回密码
 入住 CI 中国社区
搜索
查看: 5964|回复: 20
收起左侧

[程序 App] 自学2个月,写的一个文章系统。

[复制链接]
发表于 2015-9-28 16:22:27 | 显示全部楼层 |阅读模式
这个是

首页

首页
 楼主| 发表于 2015-9-28 17:37:44 | 显示全部楼层
这个是view的几个页面
首先是index.html

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>TIAN.26</title>
<link href="<?php echo base_url(); ?>admin/css/fonts.css"
        rel="stylesheet" type="text/css" />
<link href="<?php echo base_url(); ?>admin/css/style.css"
        rel="stylesheet" type="text/css" />
<link href="<?php echo base_url(); ?>admin/css/isotope.css"
        rel="stylesheet" type="text/css" />
<link href="<?php echo base_url(); ?>admin/css/mqueries.css"
        rel="stylesheet" type="text/css" media="screen" />
<link href="<?php echo base_url(); ?>admin/css/gallery.css"
        rel="stylesheet" type="text/css" />
<link href="<?php echo base_url(); ?>assets/css/bootstrap.min.css"
        rel="stylesheet" type="text/css" />
<script src="<?php echo base_url(); ?>assets/js/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js"></script>
<script src="<?php echo base_url(); ?>admin/js/jquery.modernizr.min.js"></script>
</head>
<body>
        <div id="page">
                <header id="header" class="wrapper">
                        <div class="header_top clearfix">
                                <nav id="nav" class="right_float">
                                        <ul>
                                                <li><a class="loadcontent" rel="主页"></a></li>
                                        </ul>
                                </nav>
                        </div>
                </header>
                <section id="main">
                        <div class="main_inner wrapper clearfix">
                                <ul class="filter">
                                        <li><a class="active" href="" data-option-value="*">一些文章 <strong><small>
                                                                        <?php echo $this->db->query('select * from article where a_show="已审"')->num_rows();?>
                                                        </small></strong>
                                        </a></li>
                                        <li><a href="" data-option-value=".print">关于家人 <strong><small>
                                                                        <?php echo $this->db->get_where('article',array('a_state'=>'关于家人','a_show'=>'已审'))->num_rows();?>
                                                        </small></strong>
                                        </a></li>
                                        <li><a href="" data-option-value=".work">关于工作 <strong><small>
                                                                        <?php echo $this->db->get_where('article',array('a_state'=>'关于工作','a_show'=>'已审'))->num_rows();?>
                                                        </small></strong>
                                        </a></li>
                                        <li><a href="" data-option-value=".post">关于朋友 <strong><small>
                                                                        <?php echo $this->db->get_where('article',array('a_state'=>'关于朋友','a_show'=>'已审'))->num_rows();?>
                                                        </small></strong>
                                        </a></li>
                                        <li><a href="" data-option-value=".motion">思考感悟 <strong><small>
                                                                        <?php echo $this->db->get_where('article',array('a_state'=>'思考感悟','a_show'=>'已审'))->num_rows();?>
                                                        </small></strong>
                                        </a></li>
                                </ul>
                                <hr>
                                <div id="masonry" class="entries clearfix">
                                        <?php
                                         foreach ($news as $row ):                       
                    if($row->a_state=='关于家人'){
                                        ?>
                                        <div class="masonry_item entry print sliphover-overlay">
                                                <div class="img_holder ">
                                                        <a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                rel="Diam nonumy eirmod" class="loadcontent"><img
                                                                src="<?php echo base_url('uploads/'.$row->img); ?>"
                                                                alt="<?php echo $row->a_title?>" /></a>
                                                </div>
                                                <div class="entry-headline">
                                                        <div class="entry-title">
                                                                <h5>
                                                                <?php echo $row->username; ?><br>
                                                                        <a
                                                                                href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                                rel="Diam nonumy eirmod" class="loadcontent"> <?php echo $row->a_title;?>
                                                                        </a>
                                                                </h5>
                                                        </div>
                                                        <div class="entry-date">
                                                                <?php echo $row->a_crtime; ?>
                                                        </div>
                                                        <input value="<?php echo $row->a_id?>" type="hidden">
                                                </div>
                                                <div class="entry-info">
                                                <div class="entry-meta clearfix">
                            <div class="meta_views right_float"><span><?php echo $row->a_num?></span></div>
                            <div class="meta_likes right_float"><a  class="loadcontent"></a><span>12</span></div>
                            <div class="meta_comments right_float"><a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>" rel="Diam nonumy eirmod" class="loadcontent">
                           <span class="ds-thread-count" data-thread-key="<?php echo $row->a_id?>"></span></a></div>
                        </div>
                                        </div>
                                        </div>
                                        <?php
                                        }
                    if($row->a_state=='关于工作'){
                                        ?>
                                        <div class="masonry_item entry work">
                                                <div class="img_holder">
                                                        <a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                rel="Diam nonumy eirmod" class="loadcontent" ><img
                                                                src="<?php echo base_url('uploads/'.$row->img); ?>"
                                                                alt="<?php echo $row->a_title?>" /></a>
                                                </div>
                                                <div class="entry-headline">
                                                        <div class="entry-title">
                                                                <h5>
                                                                <?php echo $row->username; ?><br>
                                                                        <a
                                                                                href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                                rel="Diam nonumy eirmod" class="loadcontent"> <?php echo $row->a_title ;?>
                                                                        </a>
                                                                </h5>
                                                        </div>
                                                        <div class="entry-date">
                                                                <?php echo $row->a_crtime; ?>
                                                        </div>
                                                </div>
                                                <div class="entry-info">
                                                <div class="entry-meta clearfix">
                            <div class="meta_views right_float"><span><?php echo $row->a_num?></span></div>
                            <div class="meta_likes right_float"><a class="loadcontent"></a><span>12</span></div>
                            <div class="meta_comments right_float"><a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>" rel="Diam nonumy eirmod" class="loadcontent">
                           <span class="ds-thread-count" data-thread-key="<?php echo $row->a_id?>"></span>
                            </a></div>
                        </div>
                                        </div>
                                        </div>
                                        <?php
                                        }
                    if($row->a_state=='关于朋友'){
                                        ?>
                                        <div class="masonry_item entry post">
                                                <div class="img_holder">
                                                        <a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                rel="Diam nonumy eirmod" class="loadcontent"><img
                                                                src="<?php echo base_url('uploads/'.$row->img); ?>"
                                                                alt="<?php echo $row->a_title?>" /></a>
                                                </div>
                                                <div class="entry-headline">
                                                        <div class="entry-title">
                                                                <h5>
                                                <?php echo $row->username; ?><br>
                                                                        <a
                                                                                href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                                rel="Diam nonumy eirmod" class="loadcontent"> <?php echo $row->a_title ;?>
                                                                        </a>
                                                                </h5>
                                                        </div>
                                                        <div class="entry-date">
                                                                <?php echo $row->a_crtime; ?>
                                                        </div>
                                                </div>
                                                <div class="entry-info">
                                                <div class="entry-meta clearfix">
                            <div class="meta_views right_float"><span><?php echo $row->a_num?></span></div>
                            <div class="meta_likes right_float"><a class="loadcontent"></a><span>12</span></div>
                            <div class="meta_comments right_float"><a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"rel="Diam nonumy eirmod" class="loadcontent">
                            <span class="ds-thread-count" data-thread-key="<?php echo $row->a_id?>"></span>
                            </a></div>
                        </div>
                                        </div>
                                        </div>
                                        <?php   }if($row->a_state=='思考感悟'){?>
                                        <div class="masonry_item entry motion">
                                                <div class="img_holder">
                                                        <a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                rel="Diam nonumy eirmod" class="loadcontent"> <img
                                                                src="<?php echo base_url('uploads/'.$row->img); ?>"
                                                                alt="<?php echo $row->a_title?>" /></a>
                                                </div>
                                                <div class="entry-headline">
                                                        <div class="entry-title">
                                                                <h5>
                                                        <?php echo $row->username; ?><br>
                                                                        <a
                                                                                href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"
                                                                                rel="Diam nonumy eirmod" class="loadcontent"> <?php echo $row->a_title ;?>
                                                                        </a>
                                                                </h5>
                                                        </div>
                                                        <div class="entry-date">
                                                                <?php echo $row->a_crtime; ?>
                                                        </div>
                                                </div>
                                                <div class="entry-info">
                                                <div class="entry-meta clearfix">
                            <div class="meta_views right_float"><span><?php echo $row->a_num?></span></div>
                            <div class="meta_likes right_float"><a  class="loadcontent"></a><span>12</span></div>
                            <div class="meta_comments right_float"><a href="<?php echo site_url('admin/user/short/'.$row->a_id.'/'.$row->a_num); ?>"rel="Diam nonumy eirmod" class="loadcontent">
                           <span class="ds-thread-count" data-thread-key="<?php echo $row->a_id?>"></span>
                            </a></div>
                           
                        </div>
                                        </div>
                                        </div>
                                        <?php  }endforeach;?>
                                </div>
                        </div>
                </section>
                        <span id="allnum"></span>
                <footer id="footer">
                        <div class="footer_inner wrapper clearfix">
                                <div class="left_float">Copyright © 2015 by YETIAN. All rights
                                        reserved</div>
                                <div class="right_float">
                                        Created by <a href="<?php echo site_url('usercon/contact')?>">YE
                                                TIAN</a>
                                </div>
                        </div>
                </footer>
        </div>
        <script src="<?php echo base_url(); ?>admin/js/jquery-1.7.1.min.js"></script>
        <script src="<?php echo base_url(); ?>admin/js/jquery.isotope.min.js"></script>
        <script src='<?php echo base_url(); ?>admin/js/jquery.easing.1.3.js'></script>
        <script src='<?php echo base_url(); ?>admin/js/jquery.easing.compatibility.js'></script>
        <script src="<?php echo base_url(); ?>admin/js/script.js"></script>
</body>
<script type="text/javascript">
var duoshuoQuery = {short_name:"tian26"};
        (function() {
                var ds = document.createElement('script');
                ds.type = 'text/javascript';ds.async = true;
                ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
                ds.charset = 'UTF-8';
                (document.getElementsByTagName('head')[0]
                 || document.getElementsByTagName('body')[0]).appendChild(ds);
        })();
</script>
</html>

捕获666.PNG
 楼主| 发表于 2015-9-28 17:35:58 | 显示全部楼层
这个use.php控制器--


<?php
        class User extends CI_Controller {
                function __construct() {
                        parent::__construct ();
                        $this->load->model ( 'usermodel' );
                }
                function user() {
                        $data ['news'] = $this->usermodel->art ();
                        $this->load->view ( 'admin/index.html', $data );
                }
               
                function contact() {
                        $this->load->view ( 'admin/contact.html' );
                }
                function short() {
                        $id = $this->uri->segment ( 4 );
                        $num=$this->uri->segment(5)+1;
                        $news ['onlynews'] = $this->usermodel->onlymessage ( $id );
                        if($news){
                                $this->update($id, $num);
                                $this->load->view ( 'admin/shortcodes', $news );
                        }
                       
                }
                function showcon(){
                        //exit('sss');
                        $a_id=$this->uri->segment(4);
                        $avg=5;
                        if(!isset($_POST['c_comment'])||empty($_POST['c_comment'])||!isset($_POST['c_auth'])||empty($_POST['c_auth'])){
                                echo '{"success":false,"msg":"评论或用户名不能为空"}';
                                return;
                        }
                        $c_comment=$_POST['c_comment'];
                        $c_auth=$_POST['c_auth'];
                        $c_email=$_POST['c_email'];
                        $c_state='合格';
                        $c_crtime=date('y-m-d H:i:s',time());
                        $a_title=$_POST['a_title'];
                        $arr=array(
                                        'c_comment'=>$c_comment,
                                        'c_crtime'=>$c_crtime,
                                        'c_auth'=>$c_auth,
                                        'c_email'=>$c_email,
                                        'c_state'=>$c_state,
                                        'a_title'=>$a_title,
                                        'a_id'=>$a_id
                        );
                        $re=$this->usermodel->comment($arr);
                        $num=$this->usermodel->re($a_id);
                        $allpages=ceil($num/$avg);
                        $arrRet=array('success'=>false);
                        if( $re===false ){
                                $arrRet['c_comment']='添加失败';
                        }else{
                                $arrRet['success']=true;
                                $arrRet['c_id']=$re;
                                $arrRet['c_comment']=$c_comment;
                                $arrRet['c_crtime']=$c_crtime;
                                $arrRet['c_email']=$c_email;
                                $arrRet['c_auth']=$c_auth;
                                $arrRet['num']=$num;
                        }
                        echo json_encode($arrRet);
                }
        function get_all(){
                $a_id=$this->uri->segment(4);
                $num=$this->usermodel->re($a_id);
                $page=$_POST['page'];
                $avg=$_POST['avg'];
                $data=$this->usermodel->get_comment($a_id,$page,$avg);
                $arrRet=array();
                foreach($data as $d){
                        array_push($arrRet, array(
                                        'c_id'=>$d->c_id,
                                        'c_comment'=>$d->c_comment,
                                        'c_auth'=>$d->c_auth,
                                        'c_email'=>$d->c_email,
                                        'c_crtime'=>$d->c_crtime,
                                        'num'=>$num
                                ));
                        }
       
                echo json_encode($arrRet);
        }
        function aa(){
                $a_id=$this->uri->segment(4);
                $num=$this->usermodel->re($a_id);
                return $num;
        }
       
        function update($id,$num){
           $data=$this->usermodel->update($id,$num);
                return $data;
        }
        }
        ?>


       
       
       
       
       
       
       
捕获444.PNG
 楼主| 发表于 2015-9-28 17:38:38 | 显示全部楼层
然后是拿个文章具体内容展示shortcodes.php

<html>
<title>TIAN.26</title>
<link href="<?php echo base_url(); ?>admin/css/fonts.css"
        rel="stylesheet" type="text/css" />
<link href="<?php echo base_url(); ?>admin/css/style.css"
        rel="stylesheet" type="text/css" />
<link href="<?php echo base_url(); ?>admin/css/isotope.css"
        rel="stylesheet" type="text/css" />
<link href="<?php echo base_url(); ?>admin/css/mqueries.css"
        rel="stylesheet" type="text/css" media="screen" />
<link href="<?php echo base_url(); ?>admin/css/animate.css"
        rel="stylesheet" type="text/css" media="screen" />
<link href="<?php echo base_url(); ?>admin/css/jPages.css"
        rel="stylesheet" type="text/css" media="screen" />
<link href="<?php echo base_url(); ?>assets/css/bootstrap.min.css"
        rel="stylesheet" type="text/css" />
<script src="<?php echo base_url(); ?>admin/js/jquery.modernizr.min.js"></script>
<body>
        <div id="page">
        <header id="header" class="wrapper">
                        <div class="header_top clearfix">
                                <nav id="nav" class="right_float">
                                        <ul>
                                                <li><a
                                                        class="loadcontent" rel="主页"></a></li>
                                        </ul>
                                </nav>
                        </div>
                </header>
                        <section id="main">
                        <div class="main_inner wrapper clearfix">
                        <ul class="filter">
                                <li><a href="<?php echo site_url('admin/user/user'); ?>"><span>一些文章</span></a></li>
                                <li><a class="active"> <?php echo $onlynews->a_state;?>
                                </a></li>
                        </ul>
                        </div>
                <div style="text-align: center" class="wrapper">
                        <h4>
                                <?php echo $onlynews->a_title; ?><br> <small><?php echo $onlynews->username ?></small>
                        </h4>
                        <small> <?php echo $onlynews->a_crtime ;?>
                        </small><br>
                </div>
                <div class="wrapper" style="width: 40%">
                        <article>
                                <div id="showContent"><?php echo $onlynews->a_content;?></div>
                        </article>
                </div>
                <div class="wrapper " style="width: 40%; padding-top: 5px;">
                        <div class="ds-thread" data-thread-key="<?php echo $onlynews->a_id?>"></div>
                         <span><a id="loginqq" href="javascript:;" onclick="UYAN_RENDER.socialLogin('qq')" class="qq" title="使用QQ帐号登录"></a></span>
                </div>
                </section>
                <footer id="footer">
                        <div class="footer_inner wrapper clearfix">
                                <div class="left_float">Copyright © 2015 by YETIAN. All rights
                                        reserved</div>
                                <div class="right_float">
                                        Created by <a href="<?php echo site_url('usercon/contact')?>">YE
                                                TIAN</a>
                                </div>
                        </div>
                </footer>
        </div>
       
</body>
<script src="<?php echo base_url(); ?>admin/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
var duoshuoQuery = {short_name:"tian26"};
        (function() {
                var ds = document.createElement('script');
                ds.type = 'text/javascript';ds.async = true;
                ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
                ds.charset = 'UTF-8';
                (document.getElementsByTagName('head')[0]
                 || document.getElementsByTagName('body')[0]).appendChild(ds);
        })();
        </script>
</html>
</html>
 楼主| 发表于 2015-9-28 16:24:07 | 显示全部楼层
这个文章的展示效果不到位。还望大家见谅

文章展示

文章展示
 楼主| 发表于 2015-9-28 16:56:47 | 显示全部楼层
这是源代码阿
发表于 2015-9-28 17:31:55 | 显示全部楼层
为何不见源代码
 楼主| 发表于 2015-9-28 17:42:35 | 显示全部楼层
这个是css和js一些image文件

admin.rar

265.52 KB, 下载次数: 72

 楼主| 发表于 2015-9-28 17:51:06 | 显示全部楼层
额,这个就是一个前台。后台是这个

application.rar

64.9 KB, 下载次数: 90

 楼主| 发表于 2015-9-28 17:52:19 | 显示全部楼层
这是是后台CSS和JS

assets.rar

627.18 KB, 下载次数: 72

本版积分规则