Advertisement
Guest User

Untitled

a guest
Feb 10th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.49 KB | None | 0 0
  1. require_once ("/home/u972076373/public_html/engine/classes/mysql.php");
  2. include("config.php");
  3. function putComm($id){
  4. global $db;
  5.  
  6.  
  7. $result = $db->query("SELECT * FROM dle_iphoto_icomments WHERE id_post = '$id' ORDER BY date DESC");
  8.  
  9. if($db->num_rows($result) > 0){
  10.    
  11.     while($row = $db->get_row($result)){
  12.         $name = $row['name'];
  13.         $email = $row['email'];
  14.         $comment = $row['comment'];
  15.         $date = $row['date'];
  16.         $default = "mm";
  17.         $size = 35;
  18.        if($grav_url != NULL) {$grav_url = "http://www.gravatar.com/avatar/".md5(strtolower(trim($email)))."?d=".$default."&s=".$size;}else{$grav_url = "/comments/img/profile-img.jpg";};
  19. }}
  20.  
  21.    
  22. if($id){
  23. return "<div class=\"cmt-cnt\">
  24.        <img src=\"{$grav_url}\" />
  25.        <div class=\"thecom\">
  26.            <h5>{$name}</h5><span data-utime=\"1371248446\" class=\"com-dt\">{$date}</span>
  27.            <br/>
  28.            <p>
  29.            
  30.             {$comment}
  31.            </p>
  32.        </div>
  33.    </div>
  34.    
  35. <div class=\"new-com-bt\" id=\"{$id}\">
  36.        <span>Напишите комментарий ...</span>
  37.    </div>
  38.    <div class=\"new-com-cnt\" id=\"new-com-cnt{$id}\" >
  39.        <input type=\"text\" id=\"name-com{$id}\" name=\"name-com\" value=\"\" placeholder=\"Имя\" />
  40.        <input type=\"text\" id=\"mail-com{$id}\" name=\"mail-com\" value=\"\" placeholder=\"Емайл\" />
  41.         <textarea id=\"new-com{$id}\" class=\"the-new-com\" placeholder=\"Сообщение\"></textarea>
  42.      
  43.        <div id=\"bt-add-com{$id}\" class=\"bt-add-com\">Post comment</div>
  44.        <div class=\"bt-cancel-com\">Cancel</div>
  45.    </div>
  46.  
  47.    <div class=\"clear\"></div>
  48. <script type=\"text/javascript\">
  49.   $(function(){
  50.        //alert(event.timeStamp);
  51.        $('#{$id}').click(function(event){    
  52.            $(this).hide();
  53.            $('#new-com-cnt{$id}').show();
  54.            $('#name-com{$id}').focus();
  55.        });
  56.  
  57.      
  58.        $('.the-new-com').bind('input propertychange', function() {
  59.           $(\"#bt-add-com{$id}\").css({opacity:0.6});
  60.           var checklength = $(this).val().length;
  61.           if(checklength){ $(\"#bt-add-com{$id}\").css({opacity:1}); }
  62.        });
  63.  
  64.        /* on clic  on the cancel button */
  65.        $('.bt-cancel-com').click(function(){
  66.            $('#new-com{$id}').val();
  67.            $('#new-com-cnt{$id}').fadeOut('fast', function(){
  68.                $('#{$id}').fadeIn('fast');
  69.            });
  70.        });
  71.  
  72.        // on post comment click
  73.        $('#bt-add-com{$id}').click(function(){
  74.            var theCom = $('#new-com{$id}');
  75.            var theName = $('#name-com{$id}');
  76.            var theMail = $('#mail-com{$id}');
  77.  
  78.            if( !theCom.val()){
  79.               'You need to write a comment!';
  80.            }else{
  81.                $.ajax({
  82.                    type: \"POST\",
  83.                    url: \"/comments/ajax/add-comment.php\",
  84.                    data: 'act=add-com&id_post='+{$id}+'&name='+theName.val()+'&email='+theMail.val()+'&comment='+theCom.val(),
  85.                    success: function(html){
  86.                        theCom.val('');
  87.                        theMail.val('');
  88.                        theName.val('');
  89.                        $('#new-com-cnt{$id}').hide('fast', function(){
  90.                            $('#{$id}').show('fast');
  91.                            $('#{$id}').before(html);  
  92.                        })
  93.                    }  
  94.                });
  95.            }
  96.        });
  97.  
  98.    });
  99. </script>";
  100. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement