コード例 #1
0
 /**
  * Ajax call to return the comments for the relevant recipe
  */
 public function getCommentsAction()
 {
     $items_per_page = $this->session->pagination['items_per_page'] ? $this->session->pagination['items_per_page'] : 5;
     $page = $this->_getParam('page');
     $offset = $items_per_page * ($page - 1);
     $c = new Comment();
     $rowset = $c->getComments($this->recipe->id, $items_per_page, $offset);
     $this->view->pagination_config = array('total_items' => $this->recipe->comments_count, 'items_per_page' => $items_per_page, 'style' => 'digg_with_jquery');
     echo $this->view->partial('partials/comments.phtml', array('comments' => $rowset, 'pagination_config' => $this->view->pagination_config));
 }
コード例 #2
0
 public function actionGetComment()
 {
     $page = $_GET['page'];
     $mid = $_POST['mid'];
     $id = $_POST['id'];
     $type = $_POST['type'];
     $object_id = $_POST['id'];
     $model = new Comment();
     $comments = $model->getComments($type, $object_id);
     $data = array('comments' => $comments);
     $this->renderPartial('list', $data);
 }
コード例 #3
0
ファイル: Crag.class.php プロジェクト: pekka-m/ClimbingWeb
 /**
  * hakee haettavan cragin cragId:n crag taulusta sekä cragiin liittyvät kommentit annetun cragid:n mukaan
  * @param  integer $_cragid haettavan cragin cragId
  * @return array   palauttaa kaiken datan json enkoodattuna ajax kutsua varten
  */
 public function getCragJson($_cragid)
 {
     require '/var/www/db-init-climb.php';
     require 'Comment.class.php';
     $comment = new Comment();
     $stmt = $db->prepare("SELECT CragId, Name \n             FROM Crag\n             WHERE CragId=:cragid");
     $stmt->execute([':cragid' => $_cragid]);
     $data = $stmt->fetch(PDO::FETCH_ASSOC);
     $muuttuja = $comment->getComments($_cragid, 'crag');
     $muuttuja = $muuttuja->fetchAll();
     $data['Image'] = $this->loadCragPic($_cragid);
     $data['Comments'] = $muuttuja;
     return json_encode($data);
 }
コード例 #4
0
 public function html_display($result)
 {
     $result = parent::html_display($result);
     if (Value::get(get_class($this) . '_commented', true) && Component::isActive('Comment')) {
         if ($result instanceof DBObject) {
             $comments = Comment::getComments($result->getMeta('table'), $result->getMeta('id'));
             Backend::addContent(Render::renderFile('comments.tpl.php', array('comment_list' => $comments)));
             if (Permission::check('create', 'comment')) {
                 $values = array('foreign_table' => $result->getMeta('table'), 'foreign_id' => $result->getMeta('id'));
                 Backend::addContent(Render::renderFile('comment.add.tpl.php', $values));
             }
         }
     }
     return $result;
 }
コード例 #5
0
ファイル: Route.class.php プロジェクト: pekka-m/ClimbingWeb
 public function getRoutejson($_routeid)
 {
     require '/var/www/db-init-climb.php';
     require 'Comment.class.php';
     $comment = new Comment();
     $stmt = $db->prepare("SELECT RouteId, Name, Grade, Description \n    FROM Route \n    WHERE RouteId=:routeid");
     $stmt->execute([':routeid' => $_routeid]);
     $data = $stmt->fetch(PDO::FETCH_ASSOC);
     $data['Grade'] = preg_replace('/-/', '', parent::unConvert($data['Grade']));
     $muuttuja = $comment->getComments($_routeid, 'route');
     $muuttuja = $muuttuja->fetchAll();
     $data['Image'] = $this->loadRoutePic($_routeid);
     $data['Comments'] = $muuttuja;
     echo json_encode($data);
 }
コード例 #6
0
ファイル: live.php プロジェクト: ancon/ptLive
    public function echoComment($news_id)
    {
        $comments = Comment::getComments($news_id);
        echo '<div class="comment-list">';
        if (count($comments) > 0) {
            foreach ($comments as $c) {
                $name = htmlspecialchars($c->name);
                $msg = htmlspecialchars($c->msg);
                echo <<<EOF
                    <div class="clearfix">
                        <strong>{$name}:</strong>
                        <span class="msg">{$msg}</span>
                        <span class="time">{$c->time}</span>
                    </div>
EOF;
            }
        }
        echo '</div>';
    }
コード例 #7
0
ファイル: WComment.php プロジェクト: vangogogo/justsns
 public function run()
 {
     $data = $this->items;
     $role = $data['role'];
     $type = $data['type'];
     $object_id = $data['object_id'];
     switch ($role) {
         case 2:
             echo "您无法评论,日志发布者设置好友可评论";
             exit;
             break;
         case 3:
             echo "您无法评论,日志发布者已经关闭评论";
             exit;
             break;
     }
     $model = new Comment();
     $comments = $model->getComments($type, $object_id);
     $data['icon_list'] = Smile::model()->findAll();
     $data['comments'] = $comments;
     $this->render('WComment', $data);
 }
コード例 #8
0
ファイル: comment.php プロジェクト: Fragan/Gallery_photo
	          <div class="col-md-3 no-padd">
	            <button onclick="antiSpam();" type="button" name="send" class="btn btn-sm btn-primary btn-block" style="margin-top: 10px;"><span class="glyphicon glyphicon-send"></span> Envoyer</button>
	          </div>
	          <input type="text" name="gallery" value="<?php 
echo $gallery;
?>
" hidden >
	          <input type="text" name="pics" value="<?php 
echo $pics;
?>
" hidden >
	        </form>
			<div class="col-md-12 sep"></div>
			<div class="col-md-12">
				<?php 
$comment->getComments($gallery, $pics);
?>
			</div>
	      	
	    	<div class="col-md-12 sep"></div>
	    	<div class="col-md-12">
	    		<a href="#" onclick="window.close();" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-chevron-left"></span> Retourner à la galerie</a>
	    	</div>
			
	  	</div>
	    
	    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	    <script src="js/jquery.min.js"></script>
	    <!-- Include all compiled plugins (below), or include individual files as needed -->
	    <script src="style/bootstrap/js/bootstrap.min.js"></script>
      <script type="text/javascript" src="js/jquery-ui/jquery-ui.js"></script>
コード例 #9
0
ファイル: View.php プロジェクト: vgck/archive
 public function main()
 {
     //loadLanguageFile('play');
     include '../lang/English.php';
     include '../lang/sk/play.php';
     /*if (isset($_GET['name'])) {
           $seo_url = mysql_secure($_GET['name']);
           $result = $mysqli->query('SELECT * FROM tbl_games WHERE seo_url ='.$seo_url);// AND published=1
       } else {
           $result = $mysqli->query('SELECT * FROM tbl_games WHERE game_id ='.$id);// AND published=1
       }*/
     $result = Query::query('SELECT * FROM Games WHERE GameID =' . $this->request[0]);
     // AND published=1
     $game_exists = $result->num_rows;
     if ($game_exists != 0) {
         if (isset($_COOKIE['ava_username'])) {
             $show = 1;
         }
     } else {
         // Game not found
         header("HTTP/1.0 404 Not Found");
         include 'includes/misc/404.php';
         exit;
     }
     Query::query('UPDATE Games SET Plays = Plays+1 WHERE GameID = ' . $this->request[0]);
     Query::query('UPDATE Games SET PlaysM = PlaysM+1 WHERE GameID = ' . $this->request[0]);
     Query::query('UPDATE Games SET PlaysW = PlaysW+1 WHERE GameID = ' . $this->request[0]);
     $row2 = $result->fetch_assoc();
     $id = $row2['GameID'];
     //$game = $row2;
     $this->set('id', $row2['GameID']);
     $this->set('site_url', Settings::Get('site_url'));
     $this->set('game_id', $row2['GameID']);
     $this->set('plays', $row2['Plays']);
     $this->set('content', $row2['Content']);
     $this->set('scores', $row2['Scores']);
     $this->set('width', $row2['Width']);
     $this->set('height', $row2['Height']);
     $this->set('type', $row2['Type']);
     $this->set('title', $row2['Title']);
     $this->set('name', Utils::getTranslation($row2['Key'], "TITLE", $row2['Title']));
     $this->set('description', Utils::getTranslation($row2['Key'], "DESC", $row2['Desc']));
     $this->set('instruction', Utils::getTranslation($row2['Key'], "INSTR", $row2['Instr']));
     if ($row2['Type'] == 'swf' && Settings::Get('fullscreen_mode') == 1) {
         $this->set('full_screen_url', '<a href="' . $_SERVER['REQUEST_URI'] . '#" onclick="ResizeFlash(' . $row2['Height'] . ', ' . $row2['Width'] . '); return false"><img src="/boxarcade/img/tool_fullscreen.jpg"/></a>');
     } else {
         $this->set('full_screen_url', '<a href="' . Settings::Get('site_url') . '/full_screen.php?id=' . $id . '"><img src="/boxarcade/img/tool_fullscreen.jpg"/></a>');
     }
     //if ($user['login_status'] != 0) {
     if (1 == 0) {
         $this->set('rating', round(Query::query('SELECT rating FROM tbl_games WHERE game_id = ' . $id)->fetch_row()[0]));
         $this->set('user_rated', Query::query('SELECT COUNT(*) as Num FROM tbl_votes WHERE user_id=' . $user['id'] . ' AND game_id=' . $id)->fetch_row()[0]);
     } else {
         $this->set('rating', 0);
         $this->set('user_rated', 0);
     }
     $row_cat = Query::query('SELECT catName FROM tbl_game_categories WHERE catID=' . $row2['CatID'])->fetch_assoc();
     $this->set('catID', $row2['CatID']);
     $this->set('category', $row_cat['catName']);
     $this->set('date_added', Utils::FormatDate($row2['DateAdded'], 'date'));
     $this->set('image_url', Utils::GameImageUrl(Utils::TitleToFile($row2['Title']) . "." . $row2['Type'], 1, Utils::TitleToFile($row2['Title'])));
     // Favorite game button
     $this->set('login_status', 1);
     //if ($user['login_status'] == 1) {
     //if(1==0) {
     if (User::login_check(Query::$mysqli) == true) {
         $user_id = $_SESSION['user_id'];
         $user_fav_yet = Query::query('SELECT COUNT(user_id) FROM favorites WHERE user_id=' . $user_id . ' AND game_id=' . $id)->fetch_row()[0];
         if ($user_fav_yet >= 1) {
             $this->set('fav_game', '<a id="favo" href="' . $_SERVER['REQUEST_URI'] . '#" onclick="EditFav(' . $row2['GameID'] . ', 1,\'' . Settings::Get('site_url') . '\', \'<img src=&quot;/boxarcade/img/tool-unfavorite.jpg&quot; />\', \'<img src=&quot;/boxarcade/img/tool-favorite.jpg&quot; />\', ' . $user_id . ' ); return false"><img src="/boxarcade/img/tool-unfavorite.jpg"/></a>');
         } else {
             $this->set('fav_game', '<a id="favo" href="' . $_SERVER['REQUEST_URI'] . '#" onclick="EditFav(' . $row2['GameID'] . ', 0,\'' . Settings::Get('site_url') . '\', \'<img src=&quot;/boxarcade/img/tool-unfavorite.jpg&quot; />\', \'<img src=&quot;/boxarcade/img/tool-favorite.jpg&quot; />\', ' . $user_id . ' ); return false"><img src="/boxarcade/img/tool-favorite.jpg"/></a>');
         }
     } else {
         $this->set('fav_game', '<a href="' . Settings::Get('site_url') . '/index.php?task=login"><img src="/boxarcade/img/tool-favorite.jpg"/></a>');
     }
     // Report game button
     if (Settings::Get('report_permissions') == "1" || Settings::Get('report_permissions') == "2") {
         //&& $user['login_status'] == 1) {
         $this->set('report_game', '<a href="' . $_SERVER['REQUEST_URI'] . '#" onclick="ShowPopup(\'ava-popup\', \'' . Settings::Get('site_url') . '/includes/overlays/report.php?id=' . $row2['GameID'] . '\', \'' . GAME_REPORT . '\'); return false"><img src="/boxarcade/img/tool-report.png"/></a>');
     }
     $this->set('report_bug', '<a href="' . $_SERVER['REQUEST_URI'] . '#" onclick="ShowPopup(\'ava-popup\', \'' . Settings::Get('site_url') . '/includes/overlays/report.php?id=' . $row2['GameID'] . '\', \'Bug Report\'); return false"><img src="/boxarcade/img/tool-bug.jpg"/></a>');
     $this->set('send', '<a href="' . $_SERVER['REQUEST_URI'] . '#" onclick="ShowPopup(\'ava-popup\', \'' . Settings::Get('site_url') . '/includes/overlays/send_game.php?id=' . $row2['GameID'] . '\', \'Send Game\'); return false"><img src="/boxarcade/img/tool-send.jpg"/></a>');
     // Define the overall rating for use in the template
     $this->set('rating_image', '');
     //GenerateRating(3); //$row2['rating']);
     // Define the 'new rating' section for the template
     if (isset($_COOKIE["ava_username"]) || 42 == 42) {
     } else {
         $this->set('new_rating_form', GAME_LOGIN_TO_RATE);
     }
     // If admin is logged in, show admin options
     //if ($user['admin'] == 1) {
     if (1 == 0) {
         $this->set('admin_options', '<a href="' . $setting['site_url'] . '/admin/?task=manage_games#id=' . $id . '"><img src=".' . $setting['template_url'] . '/images/edit.gif"/></a>');
     } else {
         $this->set('admin_options', '');
     }
     $did = $row2['DevID'];
     $usr = Query::query('SELECT username, id, usrAvatarType, seo_url FROM tbl_users WHERE id=' . $did . ' LIMIT 1')->fetch_assoc();
     $this->set('user_avatar', Utils::getAvatar($usr['id'], $usr['usrAvatarType']));
     //'uploads/avatars/' . $usr['id'] . $usr['usrAvatarType'];
     $this->set('user_name', $usr['username']);
     $this->set('profile', Utils::ProfileUrl($usr['id'], $usr['seo_url']));
     $this->set('show', '$show');
     $this->set('admin', '');
     //$user['admin'];
     $this->set('login_status', '');
     //$user['login_status'];
     //EmbedGame
     // Does this game have an advert set?
     /*if (/* $row2['advert_id'] *42 == 1)
       $ad_id = $setting['default_ad'];
          else
       $ad_id = 2; //$row2['advert_id'];*/
     $ad_id = 2;
     // Is the user supposed to see the ad?
     if (Settings::Get('user_ads') == 1) {
         if ($user['login_status'] == 1) {
             $user_show_ad = 0;
         } else {
             $user_show_ad = 1;
         }
     } else {
         if (Settings::Get('user_ads') == 2) {
             if ($user['admin'] == 1) {
                 $user_show_ad = 0;
             } else {
                 $user_show_ad = 1;
             }
         } else {
             $user_show_ad = 1;
         }
     }
     if (defined("PRELOAD_INFO")) {
         $plm = PRELOAD_INFO;
         $cts = CLICK_TO_SKIP;
     } else {
         $plm = 'Advertisement: Your game is loading';
         $cts = 'click here to skip';
     }
     $this->set('ad_id', $ad_id);
     $this->set('skip_ads', Settings::Get('skip_ads'));
     $this->set('user_show_ad', $user_show_ad);
     $this->set('plm', $plm);
     $this->set('cts', $cts);
     // Resize flash if required
     if (isset($template['max_game_width']) && $width > $template['max_game_width']) {
         $gWidth = $row2['Width'];
         $gHeight = $row2['Height'];
         $h1 = $template['max_game_width'] / $gWidth;
         $h2 = $gHeight * $h1;
         $width = $template['max_game_width'];
         $height = $h2;
     } else {
         $width = $row2['Width'];
         $height = $row2['Height'];
     }
     $this->set('width', $width);
     $this->set('height', $height);
     //$this->set('type', $this->request['type']);
     //$this->set('title', $this->request['title']);
     $this->set('relgames', Game::getRelatedGames($id));
     $this->set('comments', Comment::getComments($id));
     $this->render("Pages/View");
 }
コード例 #10
0
ファイル: add_eval.php プロジェクト: jamestoot/Eval
    echo $arrComponent['id'];
    ?>
][component_comments]" placeholder="Comments"><?php 
    echo !empty($arrCompletedComponents[$arrComponent['id']]['comments']) ? $arrCompletedComponents[$arrComponent['id']]['comments'] : '';
    ?>
</textarea>
              </div>
            </div>
            <div class="row">
              <div class="columns">
                &nbsp;
              </div>
            </div>
            <?php 
    foreach ($arrCommentTypes as $arrCommentType) {
        $arrCommentsWithSubTypes = $objComment->getComments($arrComponent['id'], $arrCommentType['id'], NULL);
        ?>
            <div class="row">
              <div class="columns">
                <h5><?php 
        echo $arrCommentType['title'];
        ?>
 <small><?php 
        echo $arrCommentType['sub_title'];
        ?>
</small></h5>
              </div>
            </div>
              <?php 
        foreach ($arrCommentsWithSubTypes as $iSubTypeId => $arrCommentsWithSubType) {
            if (!empty($iSubTypeId) && $iSubTypeId > 0) {
コード例 #11
0
ファイル: index.php プロジェクト: rjon76/netspotapp
 /**
  * @var args[0] product ID, args[1] comment ID
  * for multiselect use ',' in @var, exp args[0] = 123,143
  */
 public function getComments($args = null)
 {
     include_once ENGINE_PATH . 'class/classComment.php';
     $comments = new Comment();
     $result = $comments->getComments($args);
     if (count($result)) {
         return $result;
     }
     return null;
 }
コード例 #12
0
ファイル: ImageController.php プロジェクト: hyttijan/MyImgur
 public static function get($id)
 {
     $nextid = Image::getNext($id);
     $previousid = Image::getPrevious($id);
     $image = Image::find($id);
     $user = BaseController::get_user_logged_in();
     $content['rated'] = $image->isRated($user);
     $content['rating'] = $image->getRating();
     $content['image'] = $image;
     $content['nextid'] = $nextid;
     $content['previousid'] = $previousid;
     $content['comments'] = Comment::getComments($image);
     return $content;
 }
コード例 #13
0
 function actionShowComments()
 {
     $this->view->render('adminLayout', 'admin/comments', Comment::getComments());
 }
コード例 #14
0
ファイル: index.php プロジェクト: nikhilsaldanha/Blog-It
    require_once 'core/tag.inc.php';
    $user = new User();
    $post = new Post();
    $comment = new Comment();
    $tag = new Tag();
    $post_cur = $post->getPost($pid);
    $loggedIn = 0;
    $name;
    if ($post_cur->num_rows == 0) {
        $app->notFound();
    } else {
        session_start();
        if ($user->isLoggedIn()) {
            $loggedIn = 1;
        }
        $comments = $comment->getComments($pid);
        $tag_result = $tag->getTagsByPostId($pid);
        $post = $post_cur->fetch_assoc();
        $name = $user->getName($post['author_id'])->fetch_assoc()['name'];
        $app->render('post.php', array('post' => $post, 'name' => $name, 'loggedIn' => $loggedIn, 'comment' => $comments, 'user' => $user, 'tag_result' => $tag_result));
    }
});
$app->post('/post/:id', function ($pid) use($app) {
    require_once 'core/post.inc.php';
    $post = new Post();
    $req = $app->request();
    if ($req->post('upvote')) {
        $post->upVote($pid);
        $app->redirect('/Blog-It/post/' . $pid . '#up');
    } elseif ($req->post('downvote')) {
        $post->downVote($pid);
コード例 #15
0
ファイル: profile.php プロジェクト: pekka-m/ClimbingWeb
?>
&page=pictures">Kuvat</a></li>
                </ul>
<?php 
if (isset($_GET['user'])) {
    $practice = new Practice();
    $exercise = new Exercise();
    $converter = new Converter();
    switch ($_GET['page']) {
        case "feed":
            $comments = new Comment();
            if (isset($_SESSION['user_is_logged'])) {
                echo $comments->printCommentBox($_GET['user']);
            }
            //tulostetaan kaikki kommentit
            $result = $comments->getComments($_GET['user']);
            while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
                $date = strtotime($row['DateTime']);
                echo "<div class='comment'>" . "<a href='profile.php?user="******"'><span class='commenter'>" . $comments->getCommenter($row['CommenterId']) . ":</span></a>" . "<span class='comment_text'>" . $row['Comment'] . "</span>" . "<span class='comment_date'>" . date("d.m.Y", $date) . "<br>" . date("H:i:s", $date) . "</span>" . "</div>";
            }
            //jos ollaan kirjauduttu sisään, näkyy kommentointiboxi
            break;
        case "profile":
            if (isset($_GET['edit']) && isset($_SESSION['user_is_logged'])) {
                echo $user->editForm();
            } else {
                echo $user->printTable();
                if ($_GET['user'] == $_SESSION['logged_user_email']) {
                    echo "<a href='profile.php?user={$_SESSION["logged_user_email"]}&edit=1'>Muokkaa</a>";
                }
            }
コード例 #16
0
ファイル: MiniController.php プロジェクト: vangogogo/justsns
 /**
  * ajax获得评论(显示全部XX条)
  */
 public function actionGetReply()
 {
     $uid = Yii::app()->request->getPost('mid');
     $object_id = Yii::app()->request->getPost('object_id');
     $object_type = 'mini';
     $params = array('object_type' => $object_type, 'object_id' => $object_id, 'uid' => $uid);
     $model = new Comment();
     $order = 'ctime ASC';
     $comments = $model->getComments($object_type, $object_id, 0, $order);
     if (empty($comments)) {
         echo -1;
         exit;
     } else {
         //剔除第一条信息
         unset($comments[0]);
         $data['comments'] = $comments;
         $data['id'] = $object_id;
         $data['uid'] = $uid;
         $data['mid'] = $uid;
         $this->renderPartial('reply_div', $data);
     }
 }
コード例 #17
0
ファイル: post.php プロジェクト: hackerghost93/socialiko
 public function show($id)
 {
     $data = $this->model->show($id);
     $like_controller = new Like();
     $comment_controller = new Comment();
     for ($i = 0; $i < count($data); ++$i) {
         $data[$i]['likes'] = $like_controller->getLikes($data[$i]['post_id']);
         $data[$i]['isLiked'] = $like_controller->isLiked($data[$i]['post_id']);
         $data[$i]['comments'] = $comment_controller->getComments($data[$i]['post_id']);
     }
     $this->view->post = $data;
     $this->view->styles = array();
     array_push($this->view->styles, URL . "/Public/bootstrap/css/styles.css");
     array_push($this->view->styles, URL . "/Public/bootstrap/css/post.css");
     $this->view->render('post/show');
 }
コード例 #18
0
ファイル: view_eval_pdf.php プロジェクト: jamestoot/Eval
            <div class="row">
              <div class="columns">
                <blockquote>
                  <p><?php 
        echo !empty($arrCompletedComponents[$arrComponent['id']]['comments']) ? $arrCompletedComponents[$arrComponent['id']]['comments'] : '';
        ?>
</p>
                </blockquote>              
              </div>
            </div>
            <?php 
    }
    ?>
            <?php 
    foreach ($arrCommentTypes as $arrCommentType) {
        $arrCommentsWithSubTypes = $objComment->getComments($arrComponent['id'], $arrCommentType['id'], $iEvaluationId);
        ?>
            <div class="row row-component-<?php 
        echo $arrComponent['id'];
        ?>
-comment-type-id-<?php 
        echo $arrCommentType['id'];
        ?>
">
              <div class="columns">
                &nbsp;
              </div>
            </div>
            <div class="row row-component-<?php 
        echo $arrComponent['id'];
        ?>
コード例 #19
0
            }
        }
    }
    public function getComments()
    {
        $result = self::$db->query("SELECT * FROM comments ORDER BY id DESC");
        $result->setFetchMode(PDO::FETCH_ASSOC);
        while ($row = $result->fetch()) {
            $formatdate = date("d:m:y H:i:s", $row['datetime']);
            $id = $row['id'];
            $email = $data->{"email"};
            $fio = $row['fio'];
            $telephone = $row['telephone'];
            $file = $row['imgpath'];
            $comment = $row['comment'];
            if ($file == 0) {
                echo "<div class='panel panel-default'><div class='panel-heading'><p>id:{$id} &nbsp; Date:{$formatdate}</p><p>фио:{$fio}</p></div><div class='panel-body'><p>комментарий:{$comment}</p></div></div>";
            } else {
                echo "<div class='panel panel-default'><div class='panel-heading'><p>id:{$id} &nbsp; Date:{$formatdate}</p><p>фио:{$fio}</p></div><div class='panel-body'><p>img:{$file}<br>комментарий:{$comment}</p></div></div>";
            }
        }
    }
}
$comment = new Comment();
Comment::db();
if (isset($_POST['jsonData'])) {
    $comment->addComment();
}
if (isset($_POST['getComments'])) {
    $comment->getComments();
}
コード例 #20
0
 public function viewAction()
 {
     $id = $this->_request->getParam('id');
     $captchaCode = $this->_request->getParam('captcha_code');
     $modelBlog = new Page();
     $blog = $modelBlog->getPage($id);
     if ($blog) {
         $this->view->blog = $blog;
         // tags
         $modelTags = new Tags();
         $where = array('blog_id' => $id);
         $tags = $modelTags->getTags($where);
         if ($tags) {
             $this->view->tags = $tags;
         }
         // 评论
         $modelComment = new Comment();
         $comments = $modelComment->getComments($id);
         $this->view->comments = $comments;
         $dataComment = $this->_request->getPost();
         // 获取表单提交值
         if ($dataComment) {
             if ($dataComment['captcha'] == $captchaCode) {
                 // 定义过滤规则
                 $filters = array('name' => array('StringTrim'), 'comment' => 'StripTags');
                 // 定义验证规则
                 $validators = array('name' => array(array('StringLength', 3, 16), 'NotEmpty', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_StringLength::INVALID => "请输入一个合法的字符串", Zend_Validate_StringLength::TOO_SHORT => "请输入字符长度为3-16", Zend_Validate_StringLength::TOO_LONG => "请输入字符长度为3-16"))), 'email' => array('EmailAddress', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_EmailAddress::INVALID_FORMAT => "邮件格式不正确,请重新输入。"))), 'comment' => array());
                 // 实例化过滤器并进行过滤验证
                 $data = $_POST;
                 $filterPost = new Zend_Filter_Input($filters, $validators, $data);
                 if ($filterPost->hasInvalid() || $filterPost->hasMissing()) {
                     $messages = $filterPost->getMessages();
                     foreach ($messages as $message) {
                         foreach ($message as $value) {
                             echo $value . "<br />";
                         }
                     }
                 }
                 // 将经过验证的数据写入数据库
                 $modelComment = new Comment();
                 $newComment = $modelComment->createComment($pid = $id, $filterPost->name, $filterPost->email, $filterPost->comment);
                 if ($newComment) {
                     $this->_redirect('/blog/view/id/' . $id);
                 } else {
                     echo "评论提交出错!";
                 }
             } else {
                 echo "验证码错误,请刷新后重新输入。";
             }
         }
         // 生成验证码
         $this->captcha_session = new Zend_Session_Namespace('captcha');
         //在默认构造函数里实例化
         $captcha = new Zend_Captcha_Image(array('font' => 'images/SIMYOU.TTF', 'session' => $this->captcha_session, 'fontsize' => 15, 'imgdir' => 'images/code/', 'width' => 120, 'height' => 30, 'gcFreq' => 3, 'dotNoiseLevel' => 5, 'lineNoiseLevel' => 1, 'wordlen' => 4));
         $captcha->generate();
         // 生成图片
         // 界面方式
         $this->view->img_dir = $captcha->getImgDir();
         $this->view->captcha_id = $captcha->getId();
         //图片文件名,md5编码
         $this->view->captcha_code = $captcha->getWord();
         $this->view->id = $id;
     } else {
         echo "该博客文章不存在!";
     }
 }
コード例 #21
0
ファイル: post.php プロジェクト: alexkonetchy/social-calendar
						</div>
						<form action="#" method="post" style="display:none;" id="add-comment">
							<input type="text" name="comment" placeholder="comment... (250 characters or less)" style="width:50%;" class="post-input">
							<input type="submit" name="add_comment" style="display:none;" value="Post" />
						</form>

						<?php 
}
?>
						<?php 
#######################################################
/**
 * Display the comments for the post
 */
$Comment = new Comment($Database);
foreach ($Comment->getComments($status["id"]) as $comment) {
    ?>
							<div class="post-comment">
								<div style="line-height:20px;margin-bottom:5px;color:#000;"><img src="<?php 
    echo $comment["thumbnail"];
    ?>
" style="width:20px;float:left;border-radius:2px;" /> &nbsp;<strong><a href="<?php 
    echo $url;
    ?>
/profile.php?id=<?php 
    echo $comment["user_id"];
    ?>
" style="color:#000;text-decoration:none;"><?php 
    echo $comment["first_name"] . ' ' . $comment["last_name"];
    ?>
</a></strong><div class="clear"></div></div>