/new/PHPSource/outcomment_pt.php
PHP | 164 lines | 146 code | 17 blank | 1 comment | 30 complexity | 750b5fd8cc0a63d84fed4781a5fcd496 MD5 | raw file
- <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
- <?php
- session_start();
- include("dbconfig.php");
- $listID=0;
- if(!isset($PID))
- $PID=0;
- if(isset($_REQUEST["listID"]))
- {
- $listID= $_REQUEST["listID"];
-
- $PID = $_REQUEST["PID"];
- if(!isset($_REQUEST["PID"]) || ($_REQUEST["PID"]) == NULL)
- $PID = -1;
- $MID = $_REQUEST["MID"];
- $loaiOut=$_REQUEST["loaiOut"];
- }
-
- $start=$listID*5;
- $end=$start+5;
-
- //tim user da post
-
- $wt = -1;
- $string = "SELECT UID FROM posting WHERE PID = $PID";
- $string1 = "SELECT UID FROM manga WHERE MID = $MID";
-
- $rs = mysql_query($string,$connection);
- $kq = mysql_fetch_array($rs);
- $userpost = mysql_num_rows($rs);
-
- $rs1 = mysql_query($string1,$connection);
- $kq1 = mysql_fetch_array($rs1);
- $userpost1 = mysql_num_rows($rs1);
- if($userpost >0 || $userpost1 >0 )
- {
- if($kq[0] == $_SESSION['userid'] || $kq1[0] == $_SESSION['userid'] )
- $wt = 1;
- }
-
- if($loaiOut <0)
- {
- $coutrow = "SELECT CMID,UID,DatePost,CmContent FROM comments where ChapID='$PID' ORDER BY CMID DESC ";
- $strSQL = "SELECT CMID,UID,DatePost,CmContent FROM comments where ChapID='$PID' ORDER BY CMID DESC LIMIT $start,$end ";
- $dai = 715;
- }
- else
- {
- $coutrow = "SELECT CMID,UID,DatePost,CmContent FROM comments where MID='$MID' ORDER BY CMID DESC ";
- $strSQL = "SELECT CMID,UID,DatePost,CmContent FROM comments where MID='$MID' ORDER BY CMID DESC LIMIT $start,$end ";
- $dai = 568;
- }
- $cout = mysql_query($coutrow,$connection);
- $result = mysql_query($strSQL,$connection);
- if(mysql_errno() != 0)
- {
- return -1;
- }
- $num = mysql_num_rows($cout);
- $sum = mysql_num_rows($result);
- $list =(int) ($num /5);
- $temp = $num % 5;
- if($temp!=0)
- $list+=1;
-
- if($list>1)
- {
- echo "<div id=\"listcomment\">";
-
- $startp = $listID-2;
- if($startp >=1)
- {
- echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,0,$loaiOut)\"><<</a></span> ";
-
- }
- else
- echo "<span class='pagecurrent'><<</span> ";
-
- if($listID>0)
- echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,$listID-1,$loaiOut)\"><</a></span> ";
- else
- echo "<span class='pagecurrent'><</span> ";
- $startp=$startp>0?$startp:1;
-
-
-
- for($i=$startp;$i<=$listID;$i++)
- {
- if($i!=$listID+1)
- echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,($i-1),$loaiOut)\">$i</a></span> ";
- else
- echo "<span class='pagecurrent'>$i</span> ";
-
- }
-
-
- $endp = $listID+4;
- $endp=$list>=$endp?$endp:$list;
-
- for($i=$listID+1;$i<=$endp;$i++)
- {
- if($i!=$listID+1)
- echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,($i-1),$loaiOut)\">$i</a></span> ";
- else
- echo "<span class='pagecurrent'>$i</span> ";
- }
-
-
- if($listID<$list-1)
- {
- echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,$listID+1,$loaiOut)\">></a></span> ";
- echo "<span class='pagelink'><a href ='javascript:show()\' onclick=\"listcomment($PID,$MID,$list-1,$loaiOut)\">>></a></span> ";
- }
- else
- {
- echo "<span class='pagecurrent'>></span> ";
- echo "<span class='pagecurrent'>>></span> ";
- }
- echo "</div>";
- }
- echo "
- <div id=\"OutputComment\">";
-
- for($i=0;$i<$sum;$i++)
- {
- $row = mysql_fetch_array($result);
-
- $str = "SELECT account.Username,Power FROM account WHERE account.UID = '$row[1]' ";
- $result_user = mysql_query($str,$connection);
- if(mysql_errno() != 0)
- {
- return -1;
- }
- $row_user = mysql_fetch_array($result_user);
- $power = $row_user[1];
- if($power == 1)
- {
- $class = "admin";
- $img_ico = "images/admin_ico.png";
- }
- else
- {
- $class = "mem";
- $img_ico = "images/mem_ico.jpg";
- }
- $datepost = $row[2];
- $datepost=strtotime($datepost);
- $datepost=date("d-m-Y",$datepost);
- echo "
- <div id=\"userComment\" style=\"width:".$dai."px\"><img src = \"$img_ico\">
- <span class = \"$class\"> $row_user[0]</span><br>Ngŕy post: $datepost";
- if(isset($_SESSION['userid']))
- {
- $IDuser = $_SESSION['userid'];
- if($row[1] == $IDuser || $_SESSION["power"]==1 || $wt > 0)
- echo" <a id=\"$row[0]\" onclick=\"DeleteComment($row[0],$PID,$loaiOut);\" href =\"javascript:show($row[0])\"> <img src=\"images/drop.png\" />
- </a>";
- }
- echo " <div id=\"txtcomment\">$row[3] </div> </div>";
- }
-
- echo " </div> ";
- mysql_close($connection);
- ?>