Load.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?PHP
  2. /*
  3. OmnomIRC COPYRIGHT 2010,2011 Netham45
  4. This file is part of OmnomIRC.
  5. OmnomIRC is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. OmnomIRC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with OmnomIRC. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #error_reporting(E_ALL);
  17. #ini_set('display_errors', '1');
  18. include("Source/cachefix.php"); //This must be the first line in every file.
  19. header('Content-type: text/javascript');
  20. include("Source/sql.php");
  21. include("Source/sign.php");
  22. include("Source/userlist.php");
  23. ob_start();
  24. $count = $_GET['count'];
  25. $channel = "#omnimaga";
  26. if (isset($_GET['channel']))
  27. $channel = base64_url_decode($_GET['channel']);
  28. $nick = "0";
  29. if (isset($_GET['nick']))
  30. {
  31. $nick = base64_url_decode($_GET['nick']);
  32. $signature = base64_url_decode($_GET['signature']);
  33. if ($signature != base64_url_encode(sign($nick)))
  34. $nick = "0";
  35. }
  36. if ($channel[0] == "*") //PM
  37. {
  38. $sender = substr($channel,1);
  39. $channel = $nick;
  40. $res = sql_query("SELECT x.* FROM (
  41. SELECT * FROM `irc_lines`
  42. WHERE
  43. (`channel` = '%s'
  44. AND `name1` = '%s')
  45. OR
  46. (`channel` = '%s'
  47. AND `name1` = '%s')
  48. ORDER BY `line_number` DESC
  49. LIMIT %s
  50. ) AS x
  51. ORDER BY `line_number` ASC",$channel,$sender,$sender,$channel,$count + 0);
  52. }
  53. else
  54. {
  55. $res = sql_query("SELECT x.* FROM (
  56. SELECT * FROM `irc_lines`
  57. WHERE `channel` = '%s' OR `channel` = '%s'
  58. ORDER BY `line_number` DESC
  59. LIMIT %s
  60. ) AS x
  61. ORDER BY `line_number` ASC",$channel,$nick,$count + 0);
  62. }
  63. echo "void('$nick');";
  64. while ($result = mysql_fetch_array($res))
  65. {
  66. //Sorunome edit START
  67. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  68. $ignorelist = "";
  69. if ($userSql["name"]!=NULL) {
  70. $ignorelist = $userSql["ignores"];
  71. }
  72. //Sorunome edit END
  73. if (strpos($userSql["ignores"],strtolower($result["name1"])."\n")===false) { //Sorunome edit
  74. echo "addLine('";
  75. switch (strtolower($result['type']))
  76. {
  77. case "pm":
  78. case "message":
  79. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result['message'])) . ':' . base64_url_encode(htmlspecialchars("0"));break;
  80. case "action":
  81. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result['message'])) . ':' . base64_url_encode(htmlspecialchars("0"));break;
  82. case "join":
  83. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1']));break;
  84. case "part":
  85. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  86. case "kick":
  87. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["name2"])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  88. case "quit":
  89. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  90. case "mode":
  91. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  92. case "nick":
  93. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["name2"]));break;
  94. case "server":
  95. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  96. case "topic":
  97. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  98. }
  99. echo "');";
  100. } //Sorunome edit
  101. }
  102. $curMax = mysql_fetch_array(sql_query("SELECT MAX(`line_number`) FROM `irc_lines`"));
  103. echo "addLine('" . $curMax[0] . ":curline');";
  104. //Sorunome edit START
  105. $curtopic = mysql_fetch_array(sql_query("SELECT * FROM `irc_topics` WHERE `chan`='%s'",strtolower($channel)));
  106. echo "addLine('" . $curMax[0] . ":topic:0:" . time() . "::" . base64_url_encode($curtopic["topic"]) . "');";
  107. //Sorunome edit END
  108. $users = Array();
  109. $result = sql_query("SELECT * FROM `irc_users` WHERE `channel`='%s'",$channel);
  110. while ($user = mysql_fetch_array($result))
  111. {
  112. $users[count($users)][0] = strtolower($user['username']);
  113. $users[count($users) - 1][1] = $user['username'];
  114. $users[count($users) - 1][2] = $user['online'];
  115. $users[count($users) - 1][3] = $user['channel'];
  116. }
  117. asort($users);
  118. foreach ($users as $user)
  119. {
  120. echo "addUser('" . base64_url_encode(htmlspecialchars($user[1])) . ":" . $user[2] . "');";
  121. }
  122. ob_end_flush();
  123. ?>