message.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?PHP
  2. /*
  3. ip 108.174.51.58
  4. OmnomIRC COPYRIGHT 2010,2011 Netham45
  5. This file is part of OmnomIRC.
  6. OmnomIRC is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. OmnomIRC is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with OmnomIRC. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. include("Source/cachefix.php"); //This must be the first line in every file.
  18. include("Source/sql.php");
  19. include("Source/sign.php");
  20. if (!isset($_GET['signature']) || !isset($_GET['nick']) || !isset($_GET['message']) || !isset($_GET['channel'])) die("Missing Required Field");
  21. if (strlen($_GET['message']) < 4) die("Bad message");
  22. if (!checkSignature($_GET['nick'],$_GET['signature'],true)) die("Bad signature");
  23. $message = base64_url_decode(str_replace(" ","+",$_GET['message']));
  24. $type = "message";
  25. $message = str_replace(array("\r", "\r\n", "\n"), ' ', $message);
  26. $parts = explode(" ",$message);
  27. if ($parts[0] == "/me")
  28. {
  29. $type = "action";
  30. $message = preg_replace("/\/me/","",$message,1);
  31. }
  32. if (strlen($message) <= 0) die("Bad message");
  33. $nick = html_entity_decode(base64_url_decode($_GET['nick']));
  34. $channel = base64_url_decode($_GET['channel']);
  35. $pm = false;
  36. if ($parts[0] == "/msg" || $parts[0] == "/pm")
  37. {
  38. $pm=true;
  39. $channel = $parts[1];
  40. $message = "";
  41. unset($parts[0]);
  42. unset($parts[1]);
  43. $message = implode(" ",$parts);
  44. $type = "pm";
  45. }
  46. //Sorunome edit START
  47. $sendNormal = true;
  48. $reload = false;
  49. $sendPm = false;
  50. if ($parts[0] == "/ignore") {
  51. unset($parts[0]);
  52. $ignoreuser = strtolower(implode(" ",$parts));
  53. $returnmessage = "";
  54. $sendNormal = false;
  55. $sendPm = true;
  56. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  57. if ($userSql["name"]==NULL) {
  58. sql_query("INSERT INTO `irc_ignorelist` (name,ignores) VALUES('%s','')",strtolower($nick));
  59. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  60. }
  61. if (strpos($userSql["ignores"],$ignoreuser."\n")===false) {
  62. $userSql["ignores"].=$ignoreuser."\n";
  63. sql_query("UPDATE `irc_ignorelist` SET ignores='%s' WHERE name='%s'",$userSql["ignores"],strtolower($nick));
  64. $returnmessage = "\x033Now ignoring $ignoreuser.";
  65. $reload = true;
  66. } else {
  67. $returnmessage = "\x034ERROR: couldn't ignore $ignoreuser: already ignoring.";
  68. }
  69. }
  70. if ($parts[0] == "/unignore") {
  71. unset($parts[0]);
  72. $ignoreuser = strtolower(implode(" ",$parts));
  73. $returnmessage = "";
  74. $sendNormal = false;
  75. $sendPm = true;
  76. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  77. if ($userSql["name"]==NULL) {
  78. sql_query("INSERT INTO `irc_ignorelist` (name,ignores) VALUES('%s','')",strtolower($nick));
  79. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  80. }
  81. $allIgnoreUsers = explode("\n","\n".$userSql["ignores"]);
  82. $unignored = false;
  83. for ($i;$i<sizeof($allIgnoreUsers);$i++) {
  84. echo $allIgnoreUsers[$i]." ".$ignoreuser."\n";
  85. if ($allIgnoreUsers[$i]==$ignoreuser) {
  86. $unignored = true;
  87. unset($allIgnoreUsers[$i]);
  88. }
  89. }
  90. unset($allIgnoreUsers[0]); //whitespace bug
  91. $userSql["ignores"] = implode("\n",$allIgnoreUsers);
  92. if ($ignoreuser=="*") {$userSql["ignores"]="";$unignored=true;} //unignore all
  93. if ($unignored) {
  94. $returnmessage = "\x033You are not more ignoring $ignoreuser";
  95. if ($ignoreuser=="*") $returnmessage = "\x033You are no longer ignoring anybody.";
  96. mysql_fetch_array(sql_query("UPDATE `irc_ignorelist` SET ignores='%s' WHERE name='%s'",$userSql["ignores"],strtolower($nick)));
  97. $reload = true;
  98. } else {
  99. $returnmessage = "\x034ERROR: You weren't ignoring $ignoreuser";
  100. }
  101. }
  102. if ($parts[0] == "/ignorelist") {
  103. $returnmessage = "";
  104. $sendNormal = false;
  105. $sendPm = true;
  106. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  107. if ($userSql["name"]==NULL) {
  108. sql_query("INSERT INTO `irc_ignorelist` (name,ignores) VALUES('%s','')",strtolower($nick));
  109. $userSql = mysql_fetch_array(sql_query("SELECT * FROM `irc_ignorelist` WHERE name='%s'",strtolower($nick)));
  110. }
  111. $returnmessage = "\x033Ignored users: ".str_replace("\n",",",$userSql["ignores"]);
  112. }
  113. if ($parts[0] == "/reload" || $parts[0] == "/refresh") {$reload = true;$sendNormal=false;}
  114. //Sorunome edit END
  115. if ($channel[0] == "*") //PM
  116. {
  117. $type = "pm";
  118. $channel = substr($channel,1);
  119. }
  120. if ($sendNormal) {//sorunome edit
  121. sql_query("INSERT INTO `irc_outgoing_messages` (message,nick,channel,action) VALUES('%s','%s','%s','%s')",$message,$nick,$channel,($type=="action")?'1':'0');
  122. sql_query("INSERT INTO `irc_lines` (name1,message,type,channel,time,online) VALUES('%s','%s','%s','%s','%s',1)",$nick,$message,$type,$channel,time());
  123. }
  124. if ($sendPm) {//sorunome edit START
  125. sql_query("INSERT INTO `irc_lines` (name1,message,type,channel,time,online) VALUES('%s','%s','%s','%s','%s',1)","OmnomIRC",$returnmessage,"server",$nick,time());
  126. }
  127. if ($reload) {
  128. sql_query("INSERT INTO `irc_lines` (name1,message,type,channel,time,online) VALUES('%s','%s','%s','%s','%s',1)","OmnomIRC","THE GAME","reload",$nick,time());
  129. }
  130. if (isset($_GET['textmode'])) {
  131. session_start();
  132. echo "<html><head><meta http-equiv=\"refresh\" content=\"1;url=textmode.php?update=".$_SESSION['curline']."\"></head><body>Sending message...</body></html>";
  133. }
  134. //sorunome edit END
  135. ?>