Advertisement
Guest User

Untitled

a guest
Mar 6th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. <?php
  2. defined( '_JEXEC' ) or die;
  3. ?>
  4.  
  5. <?php
  6. class plgSystemRatingx extends JPlugin
  7.  
  8. {
  9. public function onContentBeforeDisplay()
  10. {
  11. ?>
  12. <script type="text/javascript" src="jquery.js"></script>
  13. <script type="text/javascript">
  14. $(document).ready(function()
  15. {
  16. $(".like").click(function()
  17. {
  18. var id=$(this).attr("id");
  19. var name=$(this).attr("name");
  20. var dataString = 'id='+ id + '&name='+ name;
  21. $("#votebox").slideDown("slow");
  22.  
  23. $("#flash").fadeIn("slow");
  24.  
  25. $.ajax
  26. ({
  27. type: "POST",
  28. url: "conf.php",
  29. data: dataString,
  30. cache: false,
  31. success: function(html)
  32. {
  33. $("#flash").fadeOut("slow");
  34. $("#content").html(html);
  35. }
  36. });
  37. });
  38.  
  39. $(".close").click(function()
  40. {
  41. $("#votebox").slideUp("slow");
  42. });
  43.  
  44. });
  45. </script>
  46. <body>
  47. <div style="margin:50px">
  48. <a href="#" class="like" id="1" name="up">Like</a> -- <a href="#" class="like" id="1" name="down">Dislike</a>
  49. <div id="votebox">
  50. <span id='close'><a href="#" class="close" title="Close This">X</a></span>
  51. <div style="height:13px">
  52. <div id="flash">Loading........</div>
  53. </div>
  54. <div id="content">
  55. </div>
  56. </div>
  57. </div>
  58. <?php
  59. return true;
  60. }
  61. }
  62.  
  63. <?php
  64. $mysql_hostname = "localhost";
  65. $mysql_user = "px";
  66. $mysql_password = "px";
  67. $mysql_database = "jum";
  68. $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
  69. or die("Opps some thing went wrong");
  70. mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
  71.  
  72.  
  73. if($_POST['id'])
  74. {
  75. $id=mysql_real_escape_string($_POST['id']);
  76. $name=mysql_real_escape_string($_POST['name']);
  77.  
  78.  
  79. mysql_query("update messages set $name=$name+1 where id='$id'");
  80.  
  81.  
  82. $result=mysql_query("select up,down from messages where id='$id'");
  83. $row=mysql_fetch_array($result);
  84. $up_value=$row['up'];
  85. $down_value=$row['down'];
  86. $total=$up_value+$down_value;
  87.  
  88. $up_per=($up_value*100)/$total;
  89. $down_per=($down_value*100)/$total;
  90. ?>
  91. <div style="margin-bottom:10px">
  92. <b>Ratings for this blog</b> ( <?php echo $total; ?> total)
  93. </div>
  94. <table width="700px">
  95.  
  96. <tr>
  97. <td width="30px"></td>
  98. <td width="60px"><?php echo $up_value; ?></td>
  99. <td width="600px"><div id="greebar" style="width:<?php echo $up_per; ?>%"></div></td>
  100. </tr>
  101.  
  102. <tr>
  103. <td width="30px"></td>
  104. <td width="60px"><?php echo $down_value; ?></td>
  105. <td width="600px"><div id="redbar" style="width:<?php echo $down_per; ?>%"></div></td>
  106. </tr>
  107.  
  108. </table>
  109.  
  110. <?php
  111.  
  112. }
  113. ?>
  114.  
  115. <?php
  116. defined( '_JEXEC' ) or die;
  117. ?>
  118. <?php
  119. if(JRequest::getVar('id'))
  120. {
  121.  
  122. $id = JRequest::getInt('id');
  123. $name = JRequest::getInt('name');
  124.  
  125. $db = JFactory::getDbo();
  126.  
  127. $query = $db->getQuery(true);
  128. $query2 = $db->getQuery(true);
  129. $queryup = $db->getQuery(true);
  130. $querydown = $db->getQuery(true);
  131.  
  132. $query->update('messages');
  133. $query->set("message = 1");
  134. $query->where("id = $id");
  135.  
  136. $query2->select('up,down');
  137. $query2->from('messages');
  138. $query2->where("id = $id");
  139.  
  140.  
  141.  
  142. $queryup->select('up');
  143. $queryup->from('messages');
  144. $queryup->where("id = $id");
  145.  
  146. $querydown->select('down');
  147. $querydown->from('messages');
  148. $querydown->where("id = $id");
  149.  
  150.  
  151. $db->setQuery( $query );
  152. $db->query();
  153. $db->setQuery( $query2 );
  154. $db->query();
  155.  
  156. $db->setQuery( $queryup );
  157. $data0 = $db->query();
  158. $db->setQuery( $querydown );
  159. $data1 = $db->query();
  160.  
  161.  
  162. $up_value= $db->insertid($data0);;
  163. $down_value = $db->insertid($data1);
  164.  
  165. $total=$up_value+$down_value;
  166.  
  167. $up_per=($up_value*100)/$total;
  168. $down_per=($down_value*100)/$total;
  169.  
  170. ?>
  171.  
  172. <table width="700px">
  173.  
  174. <tr>
  175. <td width="30px"></td>
  176. <td width="60px"><?php echo $up_value; ?></td>
  177. <td width="600px"><div id="greebar" style="width:<?php echo $up_per; ?>%"></div></td>
  178. </tr>
  179.  
  180. <tr>
  181. <td width="30px"></td>
  182. <td width="60px"><?php echo $down_value; ?></td>
  183. <td width="600px"><div id="redbar" style="width:<?php echo $down_per; ?>%"></div></td>
  184. </tr>
  185.  
  186. </table>
  187. <?php
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement