function deer($processed_data) { if (($type = $this->is_banned($processed_data)) !== false) { $this->log(Bashful::c('bold', 'red') . 'Banned' . Bashful::reset() . ': ' . Bashful::bold() . $processed_data['nick'] . Bashful::unbold() . '@' . $processed_data['host'] . ' on ' . $processed_data['replyto'] . ' (' . $type . ': ' . $processed_data[$type] . ')'); return; } $replyto = $processed_data['recepient']; $privileged = $this->is_privileged($processed_data); if (strpos($replyto, '#') !== 0 && $privileged == false) { $this->log('Ignoring deerme in priv'); return; } $timer_to = 'cake'; //$timer_to = $replyto; // TODO: make this channel specific! if (!isset($this->deer_used[$timer_to])) { $this->deer_used[$timer_to] = false; } $requested_deer = $this->strip_command($processed_data['message']); if ($requested_deer == '') { $requested_deer = 'deer'; } $mods_deer = $this->get_mods($requested_deer); $mods_deer == !empty($mods_deer) ? $mods_deer : array(); $requested_deer = $this->strip_mods($requested_deer); $timeout = $this->deer_timeout; // check for samedeer or samenick. Add timeout as punishment. if ($replyto == $this->last['channel'] && $processed_data['nick'] == $this->last['nick'] || $requested_deer != 'random' && $replyto == $this->last['channel'] && $requested_deer == $this->last['deer'] && array_diff($mods_deer, $this->last['modifiers']) == array()) { $timeout = $timeout * $this->timeout_punish; } // if person is in NICELIST, completely ignore the punishment! :D:D:D $timeout = $privileged != false && is_numeric($privileged['timeout']) ? $privileged['timeout'] : $timeout; // if privileged, undo punish! if ($requested_deer == 'help') { $deertime = !isset($this->deer_used[$timer_to]) || $this->deer_used[$timer_to] + $timeout < microtime(true) ? 'Ready to deer!' : floor($this->deer_used[$timer_to] - microtime(true) + $timeout) . ' seconds until deer.'; $this->notice($processed_data['nick'], chr(02) . 'How to deer:' . chr(02) . ' Type deerme <mods>|<deer> to deer or deerme help modifiers for available mods. (' . Deer::count_deer() . ' deer total) ' . chr(02) . 'Status: ' . chr(02) . $deertime . ' ' . chr(02) . 'Create your own: ' . chr(02) . $this->deeritor, IRCINE_PRIO_MEDIUM); return; } if ($requested_deer == 'help modifiers') { $modifiers = Deer::$deer_modifiers; $mods = array(); foreach ($modifiers as $mod => $name) { $mods[] = $mod . '(=' . $name . ')'; } $mods = implode(', ', $mods); $this->notice($processed_data['nick'], chr(02) . 'Available modifiers: ' . chr(02) . $mods . '.', IRCINE_PRIO_MEDIUM); return; } if ($this->deer_used[$timer_to] + $timeout > microtime(true)) { $this->log('Deer called, but deer not so fast :('); if ($timeout < $this->deer_timeout) { $this->notice($processed_data['nick'], 'You are privileged! You have LOWER timeout than others (-' . ($this->deer_timeout - $timeout) . ' seconds), which is like ' . floor($this->deer_used[$timer_to] - microtime(true) + $timeout) . ' seconds from now, bro.', IRCINE_PRIO_MEDIUM); } elseif ($timeout > $this->deer_timeout) { $this->notice($processed_data['nick'], 'You have somehow been punished! You have HIGHER timeout than others (+' . ($timeout - $this->deer_timeout) . ' seconds), which is like <CENSORED> seconds from now, bro.', IRCINE_PRIO_MEDIUM); } elseif ($timeout == $this->deer_timeout) { $this->notice($processed_data['nick'], 'Deer called, but deer not so fast :( It only walks the earth every ' . $timeout . ' seconds, which is like ' . floor($this->deer_used[$timer_to] - microtime(true) + $timeout) . ' seconds from now, bro.', IRCINE_PRIO_MEDIUM); } return; } // fetch deer from db $deer = Deer::get_deer($requested_deer); if (empty($deer)) { $this->log('No such deer.'); $this->say($replyto, '404: Deer Not Found. Go to ' . $this->deeritor . ' and create it.', IRCINE_PRIO_MEDIUM); return; } // apply modifier, turn into IRC $data = explode(PHP_EOL, Deer::parse_deer(Deer::apply_modifiers($deer['kinskode'], $mods_deer))); foreach ($data as $line) { $this->say($replyto, $line, IRCINE_PRIO_MEDIUM); // TODO: THROTTLE THIS BITCH? } $used_mods = in_array('x', $mods_deer) ? Deer::$x_last_mods : $mods_deer; $used_mods_friendly = empty($used_mods) ? '' : ' (' . implode(', ', $used_mods) . ')'; if (strtolower($requested_deer) == 'random') { $this->say($replyto, $deer['deer'] . ' by ' . $deer['creator'] . $used_mods_friendly, IRCINE_PRIO_MEDIUM); } $this->log('Deer "' . $deer['deer'] . '" is walking in ' . $replyto . '!'); $this->deer_used[$timer_to] = microtime(true); $this->last = array('deer' => $deer['deer'], 'nick' => $processed_data['nick'], 'channel' => $replyto, 'creator' => $deer['creator'], 'modifiers' => $used_mods); }
$output = $_GET['output']; $deer = new Deer(); $deer_info = $deer->get_deer($deer->sanitize_deer(isset($_GET['deer']) ? $_GET['deer'] : 'deer')); $kins = $deer_info['kinskode']; if ($deer_info['status'] != 'found') { header('HTTP/1.1 404 Deer Not Found'); die('Deer not found!'); } $modifiers = isset($_GET['modifiers']) && $_GET['modifiers'] != '' ? str_split(preg_replace("/[^a-z]/i", '', $_GET['modifiers'])) : array(); sort($modifiers); $modifiers = implode(array_unique($modifiers)); $sizemultiplier = strpos($modifiers, 'h') !== false ? 3 : 1; $cellspacing = strpos($modifiers, 'c') !== false ? 2 : 0; $lonely_secluded = strpos($modifiers, 'a') !== false ? 10 : 1; if (strlen($modifiers) > 0) { $kins = $deer->apply_modifiers($kins, $modifiers); } $kins = explode(PHP_EOL, $kins); $deer_file = $image_dir . $deer_info['deer'] . '__' . $modifiers . '.' . $output; $mem = array('height' => $deer->get_height($kins), 'width' => $deer->get_width($kins)); $height = ($mem['height'] * $col['height'] + ($mem['height'] * $cellspacing - $cellspacing)) * $lonely_secluded * $sizemultiplier; $width = ($mem['width'] * $col['width'] + ($mem['width'] * $cellspacing - $cellspacing)) * $lonely_secluded * $sizemultiplier; $rectangles = ''; $allocated = array(); $y = 0; switch ($output) { case 'jpg': case 'jpeg': case 'png': $img = @imagecreate($width, $height); $bg = imagecolorallocate($img, 255, 255, 255);