kakserpom /
phpdaemon
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace PHPDaemon\Clients\IRC; |
||
| 3 | |||
| 4 | use PHPDaemon\Utils\IRC; |
||
| 5 | |||
| 6 | class ChannelParticipant |
||
| 7 | { |
||
| 8 | use \PHPDaemon\Traits\ClassWatchdog; |
||
| 9 | use \PHPDaemon\Traits\StaticObjectWatchdog; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | public $channel; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | public $nick; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | public $user; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | public $flag; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | public $mode; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var boolean |
||
| 38 | */ |
||
| 39 | public $unverified; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | public $host; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $channel |
||
| 48 | * @param string $nick |
||
| 49 | */ |
||
| 50 | public function __construct($channel, $nick) |
||
| 51 | { |
||
| 52 | $this->channel = $channel; |
||
| 53 | $this->setNick($nick); |
||
| 54 | $this->channel->attach($this); |
||
|
0 ignored issues
–
show
|
|||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @TODO DESCR |
||
| 59 | * @param string $nick |
||
| 60 | * @return $this |
||
| 61 | */ |
||
| 62 | public function setNick($nick) |
||
| 63 | { |
||
| 64 | if ($this->nick === $nick) { |
||
| 65 | return $this; |
||
| 66 | } |
||
| 67 | $this->nick = $nick; |
||
| 68 | unset($this->channel->nicknames[$this->nick]); |
||
| 69 | $this->nick = $nick; |
||
| 70 | $this->channel->nicknames[$this->nick] = $this; |
||
| 71 | return $this; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @TODO DESCR |
||
| 76 | * @param string $channel |
||
| 77 | * @param string $nick |
||
| 78 | * @return static |
||
| 79 | */ |
||
| 80 | public static function instance($channel, $nick) |
||
| 81 | { |
||
| 82 | if (isset($channel->nicknames[$nick])) { |
||
| 83 | return $channel->nicknames[$nick]; |
||
| 84 | } |
||
| 85 | return new static($channel, $nick); |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param string $flag |
||
| 90 | * @return $this |
||
| 91 | */ |
||
| 92 | public function setFlag($flag) |
||
| 93 | { |
||
| 94 | $flag = strtr($flag, ['H' => '', 'G' => '', '*' => '']); |
||
| 95 | $this->flag = $flag; |
||
| 96 | if ($flag === '@') { |
||
| 97 | $this->mode = 'o'; |
||
| 98 | } elseif ($flag === '%') { |
||
| 99 | $this->mode = 'h'; |
||
| 100 | } elseif ($flag === '+') { |
||
| 101 | $this->mode = 'v'; |
||
| 102 | } |
||
| 103 | return $this; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @TODO DESCR |
||
| 108 | */ |
||
| 109 | public function onModeUpdate() |
||
| 110 | { |
||
| 111 | if (mb_orig_strpos($this->mode, 'o') !== false) { |
||
| 112 | $this->flag = '@'; |
||
| 113 | } elseif (mb_orig_strpos($this->mode, 'h') !== false) { |
||
| 114 | $this->flag = '%'; |
||
| 115 | } elseif (mb_orig_strpos($this->mode, 'v') !== false) { |
||
| 116 | $this->flag = '+'; |
||
| 117 | } else { |
||
| 118 | $this->flag = ''; |
||
| 119 | } |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @TODO DESCR |
||
| 124 | * @return string |
||
| 125 | */ |
||
| 126 | public function getUsermask() |
||
| 127 | { |
||
| 128 | return $this->nick . '!' . ($this->unverified ? '~' : '') . $this->user . '@' . $this->host; |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @TODO DESCR |
||
| 133 | * @param array|string $mask |
||
| 134 | * @return $this |
||
| 135 | */ |
||
| 136 | public function setUsermask($mask) |
||
| 137 | { |
||
| 138 | if (is_string($mask)) { |
||
| 139 | $mask = IRC::parseUsermask($mask); |
||
| 140 | } |
||
| 141 | $this |
||
| 142 | ->setUnverified($mask['unverified']) |
||
| 143 | ->setUser($mask['user']) |
||
| 144 | ->setNick($mask['nick']) |
||
| 145 | ->setHost($mask['host']); |
||
| 146 | return $this; |
||
| 147 | } |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @TODO DESCR |
||
| 151 | * @param string $host |
||
| 152 | * @return $this |
||
| 153 | */ |
||
| 154 | public function setHost($host) |
||
| 155 | { |
||
| 156 | $this->host = $host; |
||
| 157 | return $this; |
||
| 158 | } |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @TODO DESCR |
||
| 162 | * @param string $user |
||
| 163 | * @return $this |
||
| 164 | */ |
||
| 165 | public function setUser($user) |
||
| 166 | { |
||
| 167 | $this->user = $user; |
||
| 168 | return $this; |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @TODO DESCR |
||
| 173 | * @param boolean $bool |
||
| 174 | * @return $this |
||
| 175 | */ |
||
| 176 | public function setUnverified($bool) |
||
| 177 | { |
||
| 178 | $this->unverified = (bool)$bool; |
||
| 179 | return $this; |
||
| 180 | } |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @TODO DESCR |
||
| 184 | */ |
||
| 185 | public function destroy() |
||
| 186 | { |
||
| 187 | $this->channel->detach($this); |
||
|
0 ignored issues
–
show
|
|||
| 188 | } |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @TODO DESCR |
||
| 192 | * @param string $msg |
||
| 193 | */ |
||
| 194 | public function chanMessage($msg) |
||
| 195 | { |
||
| 196 | $this->channel->message($this->nick . ': ' . $msg); |
||
|
0 ignored issues
–
show
|
|||
| 197 | } |
||
| 198 | } |
||
| 199 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.