public function handle($quote) { $id = $quote->id; $username = $quote->user->username; $title = $quote->title; $url = URL::route('quote', [$quote->id]); $message = "#{$id} ({$username}): {$title} {$url}"; Twitter::postTweet(array('status' => $message, 'format' => 'json')); Irc::broadcast($message); }
<!-- IRC --> <?php $channels = Irc::get_irc_channels_for_event($id); if ($channels['status'] == Irc::OK) { $channels = $channels['values']; } else { $channels = array(); } $irc_channels = Irc::get_irc_channels_list(); ?> <div class="row-fluid"> <legend for="timeline">IRC Channel(s)</legend> <div id="irc_select_div" class="editable_hidden" style="display:none;"> <select id="irc_channels_select" name="irc_channels[]" data-placeholder="Select IRC channels" multiple="multiple" class="chzn-select input-xxlarge"> <?php foreach ($irc_channels as $value => $display) { ?> <option value="<?php echo $value; ?> "><?php echo $display; ?> </option> <?php } ?> </select> </div> <?php
/** * @param Irc $parent * @param $data * @param $extra * @return bool */ public function privmsg($parent, $data, $extra) { extract($extra); $network = $parent->getNetworkName(); $cmd = ''; $data = ''; if (strpos($msg, " ") !== false) { list(, $cmd) = explode(' ', trim($msg), 2); $cmd = trim($cmd); if (strpos($cmd, " ") !== false) { list($cmd, $data) = explode(' ', $cmd, 2); $data = trim($data); } } if (substr_count($msg, " ") > 2) { list(, $cmd, $data) = explode(' ', trim($msg), 3); } if ($private) { if (empty($cmd)) { $parent->privmsg($replyto, "Registrera: !sms reg #kanal dittnummer"); $parent->privmsg($replyto, "Verifiera nummer: !sms verify koden"); return true; } $cmd = strtolower($cmd); if ($cmd == 'reg' || $cmd == 'register') { if (strpos($data, ' ') !== false) { list($chan, $num) = explode(' ', $data, 2); $chan = trim($chan); $num = trim($num); } if (!in_array(strtolower($chan), self::$channels[$network])) { $parent->privmsg($replyto, "Ogiltig kanal, har kanalen sms-funktionen aktiverad?"); return true; } if (preg_match(self::$number, $num) == 0) { $parent->privmsg($replyto, "Ogiltigt nummer, ange endast siffror. t.ex: !sms reg {$chan} 0701234567"); return true; } $confirm = ''; $t = "abcdefghijklmnopqrstuvwxyz0123456789"; for ($i = 0; $i < 6; $i++) { $confirm .= substr($t, rand(0, strlen($t) - 1), 1); } if (!$this->service->sendSms($num, "Din verifieringskod är: {$confirm} - Om du inte vet vad det här är kan du ignorera detta sms")) { $parent->privmsg($replyto, "Kunde inte skicka SMS, prova igen om en stund"); return true; } $this->service->regUser($nick, $chan, $network, $num, $confirm); $parent->privmsg($replyto, "Ditt nummer har sparats/uppdaterats för {$chan}. " . "Ett SMS har skickats för att verifiera ditt nummer, vänligen skriv /msg {$parent->me()->nick} !sms verify koden"); } if ($cmd == 'verify') { $code = trim($data); if ($this->service->verifyUser($nick, $code)) { $parent->privmsg($replyto, "Ditt nummer har verifierats, du kan nu skicka sms till och ta emot sms från kanalen."); } else { $parent->privmsg($replyto, "Koden är ogiltig"); } } } else { if (!in_array($target, self::$channels[$network])) { return false; } if (!empty($cmd) && strtolower($cmd) == "list" && empty($data)) { $users = $this->service->listUsers($network, $target); $this->parent->notice($nick, "SMS-Användare i {$target}: " . implode(', ', $users)); return true; } if (empty($cmd) || empty($data)) { $parent->privmsg($replyto, "{$nick}: Syntax: !sms nick meddelande, t.ex: !sms {$nick} Hej! - !sms list, Lista med användare - För registrering: /msg {$parent->me()->nick} !sms reg {$target} 07xxxxxxxx"); return true; } $tonick = $cmd; $number = $this->service->getNumber($tonick, $target, $network); if ($number === false) { $parent->privmsg($replyto, "{$nick}: {$tonick} är inte registrerad. /msg {$parent->me()->nick} !sms reg {$target} nummer"); return true; } $smsprefix = "<{$nick}@{$target}> "; $smstext = $smsprefix . $data; if (strlen($smstext) > 160) { $parent->privmsg($replyto, "{$nick}: Ditt sms får max vara " . (160 - strlen($smsprefix)) . " tecken, nuvarande: " . strlen($data) . " tecken"); return true; } if ($this->service->sendSms($number, $smstext, 1)) { $this->service->insertHistory($nick, $tonick, $target, $network, $number, 1); $parent->privmsg($replyto, "04[SMS] Skickar sms till {$tonick}: 12{$smstext}"); return true; } else { $parent->privmsg($replyto, "{$nick}: Meddelandet kunde inte skickas, prova igen om en stund"); return true; } } }
} else { $app->response->status(201); $channels = Irc::get_irc_channels_for_event($id); if ($channels["status"] == Irc::ERROR) { $app->response->status(404); return; } else { echo json_encode($channels["values"]); } } }); $app->get('/events/:id/channels/:channel', function ($id, $channel) use($app) { header("Content-Type: application/json"); $chan = Irc::get_channel($channel); if ($chan["status"] == Irc::ERROR) { $app->response->status(404); return; } else { echo json_encode($chan["value"]); } }); $app->delete('/events/:id/channels/:channel', function ($id, $channel) use($app) { header("Content-Type: application/json"); $res = Irc::delete_channel($channel); if ($res["status"] == Irc::ERROR) { $app->response->status(500); echo json_encode($res["error"]); } else { $app->response->status(204); } });
function ItemModelId($path) { /* find pol, sol and the type of item */ list($pol_id, $sol_id, $rest) = sscanf($path, "/opt/xplico/pol_%d/sol_%d/%s"); $type = strtok($rest, '/'); /* set sol id and pol id to avoid error permision in the controller */ $this->Session->write('pol', $pol_id); $this->Session->write('sol', $sol_id); /* controller and id */ $control = null; $id = null; switch ($type) { case 'http': /* load model */ $Feed = new Feed_xml(); /* find id */ $control = 'Feed_xml'; $conditions = array('Feed_xml.rs_body' => $path); $param = array('recursive' => 0, 'fields' => array('Feed_xml.id'), 'conditions' => $conditions); $id = $Feed->find('first', $param); if ($id == null) { /* load model */ $Web = new Web(); /* find id */ $control = 'Web'; $conditions = array("or" => array('Web.rq_header' => $path, 'Web.rs_header' => $path, 'Web.rq_body' => $path, 'Web.rs_body' => $path)); $param = array('recursive' => 0, 'fields' => array('Web.id'), 'conditions' => $conditions); $id = $Web->find('first', $param); } break; case 'fbwchat': /* load model */ $Fbc = new Fbchat(); /* find id */ $control = 'Fbchat'; $conditions = array('Fbchat.chat' => $path); $param = array('recursive' => 0, 'fields' => array('Fbchat.id'), 'conditions' => $conditions); $id = $Fbc->find('first', $param); break; case 'ftp': /* load model */ $Ftp = new Ftp_file(); /* find id */ $control = 'Ftp_file'; $conditions = array('Ftp_file.file_path' => $path); $param = array('recursive' => 0, 'fields' => array('Ftp_file.id'), 'conditions' => $conditions); $id = $Ftp->find('first', $param); if ($id == null) { /* load model */ $Ftp = new Ftp(); /* find id */ $control = 'Ftp'; $conditions = array('Ftp.cmd_path' => $path); $param = array('recursive' => 0, 'fields' => array('Ftp.id'), 'conditions' => $conditions); $id = $Ftp->find('first', $param); } break; case 'ipp': case 'pjl': /* load model */ $Pjl = new Pjl(); /* find id */ $control = 'Pjl'; $conditions = array("or" => array('Pjl.pcl_path' => $path, 'Pjl.pdf_path' => $path)); $param = array('recursive' => 0, 'fields' => array('Pjl.id'), 'conditions' => $conditions); $id = $Pjl->find('first', $param); break; case 'mail': /* load model */ $Mail = new Email(); /* find id */ $control = 'Email'; $conditions = array('Email.mime_path' => $path); $param = array('recursive' => 0, 'fields' => array('Email.id'), 'conditions' => $conditions); $id = $Mail->find('first', $param); break; case 'mms': /* load model */ $Mms = new Mmscontent(); /* find id */ $control = 'Mmscontent'; $conditions = array('Mmscontent.file_path' => $path); $param = array('recursive' => 0, 'fields' => array('Mmscontent.id'), 'conditions' => $conditions); $id = $Mms->find('first', $param); break; case 'nntp': /* load model */ $Nntp = new Nntp_article(); /* find id */ $control = 'Nntp_article'; $conditions = array('Nntp_article.mime_path' => $path); $param = array('recursive' => 0, 'fields' => array('Nntp_article.id'), 'conditions' => $conditions); $id = $Nntp->find('first', $param); break; case 'telnet': /* load model */ $Teln = new Telnet(); /* find id */ $control = 'Telnet'; $conditions = array('Telnet.cmd' => $path); $param = array('recursive' => 0, 'fields' => array('Telnet.id'), 'conditions' => $conditions); $id = $Teln->find('first', $param); break; case 'tftp': /* load model */ $Tftp = new Tftp_file(); $control = 'Tftp_file'; $conditions = array('Tftp_file.file_path' => $path); $param = array('recursive' => 0, 'fields' => array('Tftp_file.id'), 'conditions' => $conditions); $id = $Tftp->find('first', $param); if ($id == null) { /* load model */ $Tftp = new Tftp(); /* find id */ $control = 'Tftp'; $conditions = array('Tftp.cmd_path' => $path); $param = array('recursive' => 0, 'fields' => array('Tftp.id'), 'conditions' => $conditions); $id = $Tftp->find('first', $param); } break; case 'sip': /* load model */ $mdl = new Sip(); $control = 'sips'; $conditions = array('Sip.commands' => $path); $param = array('recursive' => 0, 'fields' => array('Sip.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); if ($id == null) { $conditions = array('Sip.ucaller' => $path); $param = array('recursive' => 0, 'fields' => array('Sip.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); if ($id == null) { $conditions = array('Sip.ucalled' => $path); $param = array('recursive' => 0, 'fields' => array('Sip.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); } } break; case 'webmail': /* load model */ $mdl = new Webmail(); $control = 'webmails'; $conditions = array('Webmail.mime_path' => $path); $param = array('recursive' => 0, 'fields' => array('Webmail.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); break; case 'httpfile': /* load model */ $mdl = new Httpfile(); $control = 'httpfile'; $conditions = array('Httpfile.file_path' => $path); $param = array('recursive' => 0, 'fields' => array('Httpfile.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); break; case 'grbudp': /* load model */ $mdl = new Unknow(); $control = 'unknows'; $conditions = array('Unknow.file_path' => $path); $param = array('recursive' => 0, 'fields' => array('.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); break; case 'grbtcp': /* load model */ $mdl = new Unknow(); $control = 'unknows'; $conditions = array('Unknow.file_path' => $path); $param = array('recursive' => 0, 'fields' => array('.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); break; case 'rtp': /* load model */ $mdl = new Rtp(); $control = 'rtps'; $conditions = array('Rtp.ucaller' => $path); $param = array('recursive' => 0, 'fields' => array('Rtp.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); if ($id == null) { $conditions = array('Rtp.ucalled' => $path); $param = array('recursive' => 0, 'fields' => array('Rtp.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); } break; case 'irc': /* load model */ $mdl = new Irc(); $control = 'ircs'; $conditions = array('Irc.cmd_path' => $path); $param = array('recursive' => 0, 'fields' => array('Irc.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); if ($id == null) { /* load model */ $mdl = new Irc_channel(); $control = 'ircs'; $conditions = array('Irc_channel.channel_path' => $path); $param = array('recursive' => 0, 'fields' => array('Irc_channel.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); } break; case 'paltalk_exp': /* load model */ $mdl = new Paltalk_exp(); $control = 'paltalk_exps'; $conditions = array('Paltalk_exp.channel_path' => $path); $param = array('recursive' => 0, 'fields' => array('Paltalk_exp.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); break; case 'paltalk': /* load model */ $mdl = new Paltalk_room(); $control = 'paltalk_rooms'; $conditions = array('Paltalk_room.room_path' => $path); $param = array('recursive' => 0, 'fields' => array('Paltalk_room.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); break; case 'msn': /* load model */ $mdl = new Msn_chat(); $control = 'msn_chats'; $conditions = array('Msn_chat.chat_path' => $path); $param = array('recursive' => 0, 'fields' => array('Msn_chat.id'), 'conditions' => $conditions); $id = $mdl->find('first', $param); break; } if ($id != null) { return array('model' => $control, 'id' => $id[$control]['id']); } return null; }