PageRenderTime 73ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/new/PHPSource/outcomment_pt.php

http://clover-mana.googlecode.com/
PHP | 164 lines | 146 code | 17 blank | 1 comment | 30 complexity | 750b5fd8cc0a63d84fed4781a5fcd496 MD5 | raw file
  1. <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
  2. <?php
  3. session_start();
  4. include("dbconfig.php");
  5. $listID=0;
  6. if(!isset($PID))
  7. $PID=0;
  8. if(isset($_REQUEST["listID"]))
  9. {
  10. $listID= $_REQUEST["listID"];
  11. $PID = $_REQUEST["PID"];
  12. if(!isset($_REQUEST["PID"]) || ($_REQUEST["PID"]) == NULL)
  13. $PID = -1;
  14. $MID = $_REQUEST["MID"];
  15. $loaiOut=$_REQUEST["loaiOut"];
  16. }
  17. $start=$listID*5;
  18. $end=$start+5;
  19. //tim user da post
  20. $wt = -1;
  21. $string = "SELECT UID FROM posting WHERE PID = $PID";
  22. $string1 = "SELECT UID FROM manga WHERE MID = $MID";
  23. $rs = mysql_query($string,$connection);
  24. $kq = mysql_fetch_array($rs);
  25. $userpost = mysql_num_rows($rs);
  26. $rs1 = mysql_query($string1,$connection);
  27. $kq1 = mysql_fetch_array($rs1);
  28. $userpost1 = mysql_num_rows($rs1);
  29. if($userpost >0 || $userpost1 >0 )
  30. {
  31. if($kq[0] == $_SESSION['userid'] || $kq1[0] == $_SESSION['userid'] )
  32. $wt = 1;
  33. }
  34. if($loaiOut <0)
  35. {
  36. $coutrow = "SELECT CMID,UID,DatePost,CmContent FROM comments where ChapID='$PID' ORDER BY CMID DESC ";
  37. $strSQL = "SELECT CMID,UID,DatePost,CmContent FROM comments where ChapID='$PID' ORDER BY CMID DESC LIMIT $start,$end ";
  38. $dai = 715;
  39. }
  40. else
  41. {
  42. $coutrow = "SELECT CMID,UID,DatePost,CmContent FROM comments where MID='$MID' ORDER BY CMID DESC ";
  43. $strSQL = "SELECT CMID,UID,DatePost,CmContent FROM comments where MID='$MID' ORDER BY CMID DESC LIMIT $start,$end ";
  44. $dai = 568;
  45. }
  46. $cout = mysql_query($coutrow,$connection);
  47. $result = mysql_query($strSQL,$connection);
  48. if(mysql_errno() != 0)
  49. {
  50. return -1;
  51. }
  52. $num = mysql_num_rows($cout);
  53. $sum = mysql_num_rows($result);
  54. $list =(int) ($num /5);
  55. $temp = $num % 5;
  56. if($temp!=0)
  57. $list+=1;
  58. if($list>1)
  59. {
  60. echo "<div id=\"listcomment\">";
  61. $startp = $listID-2;
  62. if($startp >=1)
  63. {
  64. echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,0,$loaiOut)\"><<</a></span>&nbsp;";
  65. }
  66. else
  67. echo "<span class='pagecurrent'><<</span>&nbsp; ";
  68. if($listID>0)
  69. echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,$listID-1,$loaiOut)\"><</a></span>&nbsp;";
  70. else
  71. echo "<span class='pagecurrent'><</span>&nbsp; ";
  72. $startp=$startp>0?$startp:1;
  73. for($i=$startp;$i<=$listID;$i++)
  74. {
  75. if($i!=$listID+1)
  76. echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,($i-1),$loaiOut)\">$i</a></span>&nbsp;";
  77. else
  78. echo "<span class='pagecurrent'>$i</span>&nbsp; ";
  79. }
  80. $endp = $listID+4;
  81. $endp=$list>=$endp?$endp:$list;
  82. for($i=$listID+1;$i<=$endp;$i++)
  83. {
  84. if($i!=$listID+1)
  85. echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,($i-1),$loaiOut)\">$i</a></span>&nbsp;";
  86. else
  87. echo "<span class='pagecurrent'>$i</span>&nbsp; ";
  88. }
  89. if($listID<$list-1)
  90. {
  91. echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,$listID+1,$loaiOut)\">></a></span>&nbsp;";
  92. echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,$list-1,$loaiOut)\">>></a></span>&nbsp;";
  93. }
  94. else
  95. {
  96. echo "<span class='pagecurrent'>></span>&nbsp; ";
  97. echo "<span class='pagecurrent'>>></span>&nbsp; ";
  98. }
  99. echo "</div>";
  100. }
  101. echo "
  102. <div id=\"OutputComment\">";
  103. for($i=0;$i<$sum;$i++)
  104. {
  105. $row = mysql_fetch_array($result);
  106. $str = "SELECT account.Username,Power FROM account WHERE account.UID = '$row[1]' ";
  107. $result_user = mysql_query($str,$connection);
  108. if(mysql_errno() != 0)
  109. {
  110. return -1;
  111. }
  112. $row_user = mysql_fetch_array($result_user);
  113. $power = $row_user[1];
  114. if($power == 1)
  115. {
  116. $class = "admin";
  117. $img_ico = "images/admin_ico.png";
  118. }
  119. else
  120. {
  121. $class = "mem";
  122. $img_ico = "images/mem_ico.jpg";
  123. }
  124. $datepost = $row[2];
  125. $datepost=strtotime($datepost);
  126. $datepost=date("d-m-Y",$datepost);
  127. echo "
  128. <div id=\"userComment\" style=\"width:".$dai."px\"><img src = \"$img_ico\">
  129. <span class = \"$class\"> $row_user[0]</span><br>Ngŕy post: $datepost";
  130. if(isset($_SESSION['userid']))
  131. {
  132. $IDuser = $_SESSION['userid'];
  133. if($row[1] == $IDuser || $_SESSION["power"]==1 || $wt > 0)
  134. echo" <a id=\"$row[0]\" onclick=\"DeleteComment($row[0],$PID,$loaiOut);\" href =\"javascript:show($row[0])\"> <img src=\"images/drop.png\" />
  135. </a>";
  136. }
  137. echo " <div id=\"txtcomment\">$row[3] </div> </div>";
  138. }
  139. echo " </div> ";
  140. mysql_close($connection);
  141. ?>