<!DOCTYPE html> <head> <script src="js/jquery.min.js"></script> <script src="js/bootstrap.min.js"></script> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="js/jquery.singlePageNav.min.js"></script> <script src="js/setting.js"></script> <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <meta charset="utf-8"/> <style> pre{ white-space:pre-wrap; word-wrap:break-word; } </style> <link type="text/css" href="highlight/styles/a11y-light.css?t={{time()}}" rel="stylesheet"> <script src="highlight/highlight.pack.js"></script> <script> </script> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="css/templatemo-style.css?t={{time()}}"> <script src="require.js" ></script> </head><body> <?php require_once "pdo.php"; session_start(); $stmt = $pdo->prepare('SELECT content, headline,user_id FROM article WHERE article_id = :article_id'); $stmt->execute(array( ':article_id' => $_GET["article_id"])); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ( $row == false ) { header('Location: index.php'); } $stmt2 = $pdo->prepare('SELECT name FROM users WHERE user_id=:user_id'); $stmt2->execute(array( ':user_id' => $row["user_id"])); $row2 = $stmt2->fetch(PDO::FETCH_ASSOC); if (!isset($_SESSION['user_id'] )) { echo(" <script type='text/javascript' > $(document).ready(function(){ $('#new_comment').hide(); $('.hii').hide(); }); </script>" ); } ?> <div class="fixed-header"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">NOTE</a> </div> <nav class="main-menu"> </form> <ul> <li><a class="external" href="index.php">Home</a></li> <li><div class="hidee"><a class=" external " href="edit_article.php?article_id=<?=$_GET["article_id"]?>">编辑</a></div></li> </ul> </nav> </div> </div> <?php if (!isset($_SESSION['user_id'] )||$_SESSION['user_id']!=$row['user_id']) { echo(" <script type='text/javascript' > $(document).ready(function(){ $('.hidee').hide(); }); </script>" ); } ?> <div class="container"> <section class="col-md-12 content" id="home" > <div class="col-lg-12 col-md-12 content-item content-item-1 background"style=" background-color: rgba(255,255,255, 1); "> <pre> <div class="text-center" > <h1 class="main-title text-center dark-blue-text" style="margin-top:0em;"> <?=$row['headline']?></h1> <p><a href="personal_page.php?user_id=<?=$row["user_id"]?>" style= "margin-bottom: 5px;text-align:centre;" > 作者:<?=$row2['name']?></a></p> </div> <div id="article" > <?echo(htmlentities($row['content']))?> </div> </pre> </div> </section> <section class="col-md-12 content " > <div class="col-lg-12 col-md-12 content-item content-item-1 background" style="padding-top:2em;background-color: rgba(255,255,255, 0.7); "> <form method="post" name="contact-form" class="contact-form hii" id="new_comment" action='comment.php'> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="form-group contact-field"> <textarea name="comment" rows="5" class="form-control" id="message" placeholder="欢迎留下你的思考~" required></textarea> </div> </div> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="form-group margin-b-0"> <button type="submit" id="form-submit" class="btn no-bg btn-contact">提交</button> <input type="hidden" name="id" id="id" > <input type="hidden" name="article_id" value=<?=$_GET['article_id']?>> </div> </div> </form> <ul> <hr/> <?php $num_comment=-1; $stmt0 = $pdo->prepare('SELECT * FROM commentsss WHERE article_id = :article_id ORDER BY comment_id' ); $stmt0->execute(array( ':article_id' => $_GET["article_id"])); $buf=array(); while ( $row0 = $stmt0->fetch(PDO::FETCH_ASSOC) ) { if($row0['comment_id']==$num_comment+1) { if($row0['feedback_id']!=NULL) { $buf[]=$row0; } else{ $main_comment=$row0; } } else{ $num_comment++; echo('<div class="row">'); echo('<li> <div class="col-lg-1 col-md-1 "><a href="personal_page.php?user_id='.$main_comment['user_id'].'">'); echo(htmlentities($main_comment['name'])); echo('</a></div><div class="col-lg-10 col-md-10 text-centre" >'); echo(htmlentities($main_comment['content'])); echo("</p><hr/></div>"); if($buf!=null){ echo(" <div class='col-lg-1 col-md-1 '> <a data-toggle='collapse' href='#b".$num_comment."'>more</a>"); echo("</a></div>"); echo(' <div class="col-lg-12 col-md-12 collapse" id="b'.$num_comment.'">'); $num=0; foreach($buf as $feedback) { echo('<div class="row">'); echo(' <div class="col-lg-1 col-md-1 "><a href="personal_page.php?user_id='.$feedback['user_id'].'">'); echo(htmlentities($feedback['name'])); echo('</a></div><div class="col-lg-11 col-md-11 text-centre" >'); echo(htmlentities($feedback['content'])); echo("</p><hr/></div></div>"); $num++; } echo('<form method="post" name="contact-form" class="contact-form hii" action="feedback.php">'); echo(' <textarea name="feedback" rows="2" class="form-control" placeholder="回复" required></textarea>'); echo('<input type="hidden" name="article_id" value="'.$feedback['article_id'].'">'); echo('<input type="hidden" name="comment_id" value="'.$num_comment.'">'); echo('<input type="hidden" name="feedback_id" value="'.$num.'" >'); echo(' <button type="submit" style="margin:1em;" class="btn no-bg btn-contact ">提交</button>'); echo("</form></div></li></div>"); } else{ echo(" <div class='col-lg-1 col-md-1 '> <a data-toggle='collapse' href='#b".$num_comment."'>评论</a>"); echo("</a></div>"); echo(" <div class='col-lg-12 col-md-12 '>"); echo('<div id="b'.$num_comment.'" class="collapse">'); echo('<form method="post" name="contact-form" class="contact-form hii" action="feedback.php">'); echo(' <textarea name="feedback" rows="2" class="form-control" placeholder="回复" required></textarea>'); echo('<input type="hidden" name="article_id" value="'.$main_comment['article_id'].'">'); echo('<input type="hidden" name="comment_id" value="'.$num_comment.'">'); echo('<input type="hidden" name="feedback_id" value="0" >'); echo(' <button type="submit" style="margin:1em;" class="btn no-bg btn-contact ">提交</button>'); echo("</form></div></div></li></div>"); } $buf=array(); if($row0['feedback_id']!=NULL) { $buf[]=$row0; } else{ $main_comment=$row0; } } } if(isset($main_comment)) { $num_comment++; echo('<div class="row">'); echo('<li> <div class="col-lg-1 col-md-1 "><a href="personal_page.php?user_id='.$main_comment['user_id'].'">'); echo(htmlentities($main_comment['name'])); echo('</a></div><div class="col-lg-10 col-md-10 text-centre" >'); echo(htmlentities($main_comment['content'])); echo("</p><hr/></div>"); if($buf!=null){ echo(" <div class='col-lg-1 col-md-1 '> <a data-toggle='collapse' href='#b".$num_comment."'>more</a>"); echo("</a></div>"); echo(' <div class="col-lg-12 col-md-12 collapse" id="b'.$num_comment.'">'); $num=0; foreach($buf as $feedback) { echo('<div class="row">'); echo(' <div class="col-lg-1 col-md-1 "><a href="personal_page.php?user_id='.$feedback['user_id'].'">'); echo(htmlentities($feedback['name'])); echo('</a></div><div class="col-lg-11 col-md-11 text-centre" >'); echo(htmlentities($feedback['content'])); echo("</p><hr/></div></div>"); $num++; } echo('<form method="post" name="contact-form" class="contact-form hii" action="feedback.php">'); echo(' <textarea name="feedback" rows="2" class="form-control" placeholder="回复" required></textarea>'); echo('<input type="hidden" name="article_id" value="'.$feedback['article_id'].'">'); echo('<input type="hidden" name="comment_id" value="'.$num_comment.'">'); echo('<input type="hidden" name="feedback_id" value="'.$num.'" >'); echo(' <button type="submit" style="margin:1em;" class="btn no-bg btn-contact ">提交</button>'); echo("</form></div></li></div>"); } else{ echo(" <div class='col-lg-1 col-md-1 '> <a data-toggle='collapse' href='#b".$num_comment."'>评论</a>"); echo("</a></div>"); echo(" <div class='col-lg-12 col-md-12 '>"); echo('<div id="b'.$num_comment.'" class="collapse">'); echo('<form method="post" name="contact-form" class="contact-form hii" action="feedback.php">'); echo(' <textarea name="feedback" rows="2" class="form-control" placeholder="回复" required></textarea>'); echo('<input type="hidden" name="article_id" value="'.$main_comment['article_id'].'">'); echo('<input type="hidden" name="comment_id" value="'.$num_comment.'">'); echo('<input type="hidden" name="feedback_id" value="0" >'); echo(' <button type="submit" style="margin:1em;" class="btn no-bg btn-contact ">提交</button>'); echo("</form></div></div></li></div>"); } } $num_comment++; echo(" <script> $(document).ready(function(){ $('#id').val(".$num_comment."); }); </script>"); ?> </ul> </div> </section> </div> <div class="text-center footer"> <div class="container"> NOTEBOOK</div> </div> </body> </html> <script> $(document).ready(function(){ var str=<?=json_encode($row['content'])?>; $("#article").html(marked(str)); }); </script> <script> require.config({ paths : { "marked" : ["https://cdn.jsdelivr.net/npm/marked/marked.min"], "highlight" : "highlight/highlight.pack" } }) require(["marked","highlight"], function (marked,highlight) { var rendererMD = new marked.Renderer(); marked.setOptions({ renderer: rendererMD, gfm: true, tables: true, breaks: false, pedantic: false, sanitize: false, smartLists: true, smartypants: false }); marked.setOptions({ highlight: function (code) { return highlight.highlightAuto(code).value; } }); var str=<?=json_encode($row['content'])?>; $("#article").html(marked(str)); }); </script>