Update.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. include("Source/cachefix.php"); //This must be the first line in every file.
  17. include("Source/sql.php");
  18. include("Source/sign.php");
  19. include("Source/userlist.php");
  20. $curLine = $_GET['lineNum'];
  21. $channel = "#omnimaga";
  22. if (isset($_GET['channel']))
  23. $channel = base64_url_decode($_GET['channel']);
  24. $nick = "0";
  25. if (isset($_GET['nick']))
  26. {
  27. $nick = base64_url_decode($_GET['nick']);
  28. $signature = base64_url_decode($_GET['signature']);
  29. if (!checkSignature($nick,$signature))
  30. $nick = "0";
  31. }
  32. $pm = false;
  33. if ($channel[0] == "*") //PM
  34. {
  35. $sender = substr($channel,1);
  36. $channel = $nick;
  37. $pm = true;
  38. }
  39. $countBeforeQuit = 0;
  40. while (true)
  41. {
  42. if ($countBeforeQuit++ == 50)//Timeout after 25 seconds.
  43. die();
  44. if ($nick != "0")
  45. UpdateUser($nick,$channel);
  46. CleanOfflineUsers(); //This gets called often enough. We can't have have constant presence in the matrix without a helper app, this is the closest we'll get.
  47. $query = sql_query("SELECT * FROM `irc_lines` WHERE `line_number` > %s AND (`channel` = '%s' OR `channel` = '%s' OR (`channel` = '%s' AND `name1` = '%s'))",$curLine + 0,$channel,$nick,$pm?$sender:"0", $nick);
  48. $result = mysql_fetch_array($query);
  49. //Sorunome edit START
  50. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  51. $ignorelist = "";
  52. if ($userSql["name"]!=NULL) {
  53. $ignorelist = $userSql["ignores"];
  54. }
  55. //Sorunome edit END
  56. if (!isset($result[0]))
  57. {
  58. $result = mysql_fetch_array(sql_query("SELECT * FROM `irc_lines` WHERE `line_number` > %s AND locate('%s',`message`) != 0 AND NOT ((`type` = 'pm' AND `name1` <> '%s') OR (`type` = 'server'))",$curLine + 0,substr($nick,0,4), $nick));
  59. if (!isset($result[0])) {usleep(500000); continue;}
  60. if (strpos($userSql["ignores"],strtolower($result["name1"])."\n")===false) { //Sorunome edit
  61. echo $result['line_number'] . ":highlight:0:0:". base64_url_encode($result['channel']) . "::" . base64_url_encode($result['name1']) . ":" . base64_url_encode($result['message']);
  62. } else { //Sorunome edit START
  63. echo $result['line_number'].":curline:0:0:";
  64. } //Sorunome edit END
  65. die; //That's it, folks!
  66. }
  67. do {
  68. if (!isset($result['time'])) $result['time'] = time();
  69. if (strpos($userSql["ignores"],strtolower($result["name1"])."\n")===false) { //sorunome edit
  70. switch (strtolower($result['type']))
  71. {
  72. case "pm":
  73. case "message":
  74. 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;
  75. case "action":
  76. 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;
  77. case "join":
  78. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1']));break;
  79. case "part":
  80. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  81. case "kick":
  82. 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;
  83. case "quit":
  84. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  85. case "mode":
  86. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  87. case "nick":
  88. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["name2"]));break;
  89. case "topic":
  90. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  91. case "reload":
  92. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . "::";break;
  93. case "server":
  94. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  95. case "topic":
  96. echo $result['line_number'] . ":" . $result['type'] . ":" . $result['Online'] . ":" . $result['time'] . ":" . base64_url_encode(htmlspecialchars($result['name1'])) . ":" . base64_url_encode(htmlspecialchars($result["message"]));break;
  97. }
  98. echo "\n";
  99. } else { //Sorunome edit START
  100. echo $result['line_number'].":curline:0:0:";
  101. } //Sorunome edit END
  102. } while ($result = mysql_fetch_array($query));
  103. break;
  104. }
  105. ?>