public function addChannel(Channel $channel) { if (isset($this->channelNames[$channel->getName()])) { return; } $this->channelNames[$channel->getName()] = true; $this->collection->attach($channel); }
function followchannel($channelid){ if ($_SESSION['user']->isAnon()) return array("ok"=>false, "error"=>"you have to login"); global $LANGALL; global $CONF; $channel = new Channel(); if (!isset($channelid)) return array("ok"=>false, "error"=>"no id"); $channel->setId($channelid); if ($channel->getAsktofollow()){ if ($_SESSION['user']->isAnon()) return array("ok"=>false, "error"=>"anon cant follow"); require_once('class/Message.php'); $message = new Message(); $message->setUserFrom($_SESSION['user']); $message->setUserTo($channel->getUser()); $__ufid = $channel->unconfirmed_follow(); $check=hash('sha512',"00`Θ^*' ♣ hk".chr(11)."1".$__ufid); if ($channel->getUser()->getLang()=='pt_br'){ $message->setSubject($LANGALL['pt_br']['channel_asktofollow_subject']); eval($LANGALL['pt_br']['channel_asktofollow_msg']); $msg = '#'.$channel->getName().'\n<br/>'.'@'.$_SESSION['user']->getNickname().'\n<br/>'.$body; if (isset($_GET['msg_followchannel'])) $msg.=$_GET['msg_followchannel']; $message->setMsg($msg); } else { $message->setSubject($LANGALL['en_us']['channel_asktofollow_subject']); eval($LANGALL['pt_br']['channel_asktofollow_msg']); $msg = '#'.$channel->getName().'\n<br/>'.'@'.$_SESSION['user']->getNickname().'\n<br/>'.$body; if (isset($_GET['msg_followchannel'])) $msg.=$_GET['msg_followchannel']; $message->setMsg($msg); } $result=$message->save(); if ($result=='ok') return array("ok"=>false, "error"=>"asked for permission", "msg"=>"asked for permission"); else return array("ok"=>false, "error"=>"error cant send message: ".$result, "msg"=>""); } else { if ($channel->follow()) return array("ok"=>true, "error"=>""); else return array("ok"=>false, "error"=>"cant follow"); } }
/** * @return string */ public function getWorkingChannelName() { if (!isset($this->workingChannelName)) { $this->workingChannelName = $this->channel->getName() . '_' . spl_object_hash($this) . '_' . uniqid(); } return $this->workingChannelName; }
/** * @param Channel $channel */ public function add(Channel $channel) { $name = $this->normalizeName($channel->getName()); // prevent channel overwrites if ($this->exists($name)) { return; } $this->channels[$name] = $channel; }
global $CONF; $user=$_SESSION['user']; if (isset($_GET['urlname'])) { $channel = new Channel(); $channel->setUrlname($_GET['urlname']); $channel->load(); if ($channel->getId()>0) { $OG['request'] = 'openchannel'; $OG['channel_name'] = $channel->getName(); $OG['channel_desc'] = $channel->getDescription(); $OG['channel_logo'] = $CONF['url_path'] . $channel->getLogoFile('big'); if (isset($_GET['sms_ss'])){ $db = clone $GLOBALS['maindb']; $_anon=($user->isAnon())?'true':'false'; $db->query("INSERT INTO addthis(channelid,sms_ss,at_xt,userid,anon,ip) values ('{$channel->getId()}','".$_GET['sms_ss']."','".$_GET['at_xt']."','{$user->getId()}','{$_anon}','".$_SERVER['REMOTE_ADDR']."');"); } $_newcookie=(isset($_COOKIE['autoopenchannel']))?$_COOKIE['autoopenchannel'].'_':''; $_newcookie.=$channel->getId(); setcookie("autoopenchannel", $_newcookie, time()+60); } }
/** * TreeUpdate constructor. * * @param Channel $chan * @param array $updateData */ public function __construct(Channel $chan, array $updateData) { /** * This represents data from the base64urlsafe encoded JSON blob that is signed by the channel. */ $this->channelId = (int) $updateData['id']; $this->channelName = $chan->getName(); $this->merkleRoot = $updateData['root']; $this->stored = $updateData['stored']; $this->action = $this->stored['action']; $packageRelatedActions = [self::ACTION_CORE_UPDATE, self::ACTION_PACKAGE_UPDATE]; if (\in_array($this->action, $packageRelatedActions)) { // This is a package-related update: $this->checksum = $this->stored['checksum']; // This is the JSON message from the tree node, stored as an array: $data = \json_decode($updateData['data'], true); $this->updateMessage = $data; // What action are we performing? if ($this->action === self::ACTION_PACKAGE_UPDATE) { $this->packageType = $data['pkg_type']; $this->packageName = $data['name']; } else { $this->packageType = 'Core'; $this->packageName = 'Airship'; } if ($this->action === self::ACTION_CORE_UPDATE) { $state = State::instance(); $trustedSupplier = (string) ($state->universal['airship']['trusted-supplier'] ?? 'paragonie'); $this->supplier = $chan->getSupplier($trustedSupplier); } else { $this->supplier = $chan->getSupplier($data['supplier']); } } else { // This is a key-related update: if (!empty($updateData['master_signature'])) { $this->masterSig = $updateData['master_signature']; } $data = \json_decode($updateData['data'], true); try { $this->unpackMessageUpdate($chan, $data); } catch (NoSupplier $ex) { $this->isNewSupplier = true; $chan->createSupplier($data); $this->supplier = $chan->getSupplier($data['supplier']); } $this->keyType = $data['type']; $this->newPublicKey = $data['public_key']; } $this->supplierName = $this->supplier->getName(); }
/** * @param Message $message */ public function produce(Message $message) { $this->client->lpush($this->channel->getName(), array($message->getContent())); }
/** * Insert/delete entries in supplier_keys, while updating the database. * * Dear future security auditors: This is important. * * @param Channel $chan) * @param TreeUpdate[] $updates * @return bool */ protected function processTreeUpdates(Channel $chan, TreeUpdate ...$updates) : bool { $this->db->beginTransaction(); foreach ($updates as $update) { // Insert the new node in the database: $treeUpdateID = (int) $this->db->insertGet('airship_tree_updates', ['channel' => $chan->getName(), 'channelupdateid' => $update->getChannelId(), 'data' => $update->getNodeJSON(), 'merkleroot' => $update->getRoot()], 'treeupdateid'); // Update the JSON files separately: if ($update->isCreateKey()) { $this->insertKey($chan, $update); self::$continuumLogger->store(LogLevel::INFO, 'New public key', ['action' => 'KEYGGDRASIL', 'supplier' => $update->getSupplierName(), 'publicKey' => $update->getPublicKeyString(), 'merkleRoot' => $update->getRoot(), 'data' => $this->getLogData($update)]); } elseif ($update->isRevokeKey()) { $this->revokeKey($chan, $update); self::$continuumLogger->store(LogLevel::INFO, 'Public key revoked', ['action' => 'KEYGGDRASIL', 'supplier' => $update->getSupplierName(), 'publicKey' => $update->getPublicKeyString(), 'merkleRoot' => $update->getRoot(), 'data' => $this->getLogData($update)]); } else { $this->updatePackageQueue($update, $treeUpdateID); self::$continuumLogger->store(LogLevel::INFO, 'New package metadata', ['action' => 'KEYGGDRASIL', 'supplier' => $update->getSupplierName(), 'merkleRoot' => $update->getRoot(), 'data' => $this->getLogData($update)]); } } return $this->db->commit(); }
public function copyFrom(Channel $channel) { $this->setChannelId($channel->getChannelId()); $this->setBank($channel->getBank()); $this->setProgram($channel->getProgram()); $this->setVolume($channel->getVolume()); $this->setBalance($channel->getBalance()); $this->setChorus($channel->getChorus()); $this->setReverb($channel->getReverb()); $this->setPhaser($channel->getPhaser()); $this->setTremolo($channel->getTremolo()); $this->setName($channel->getName()); $this->parameters = array(); for ($i = 0; $i < $channel->countParameters(); $i++) { $this->addParameter(clone $channel->getParameter($i)); } }
if ($check==$_GET['c']){ $ufc_=Channel::confirmFollow($_GET['b'],$_GET['a']=='accept'); if (count($ufc_)>0){ $userto=new RegUser(); $userto->setId($ufc_['userid']);$userto->load(); $channel=new Channel(); $channel->setId($ufc_['channelid']); $message = new Message(); $message->setUserFrom($_SESSION['user']); $message->setUserTo($userto); if ($_GET['a']=='accept'){ $msg=$LANG['channel_confirmfollow_accepted']; if ($userto->getLang()=='pt_br'){ $message->setSubject($LANGALL['pt_br']['channel_asktofollow_subject']); $message->setMsg('#'.$channel->getName().'\n<br/>'.$LANGALL['pt_br']['channel_confirmfollow_accepted']); } else { $message->setSubject($LANGALL['en_us']['channel_asktofollow_subject']); $message->setMsg('#'.$channel->getName().'\n<br/>'.$LANGALL['en_us']['channel_confirmfollow_accepted']); } } else { $msg=$LANG['channel_confirmfollow_rejected']; if ($userto->getLang()=='pt_br'){ $message->setSubject($LANGALL['pt_br']['channel_asktofollow_subject']); $message->setMsg('#'.$channel->getName().'\n<br/>'.$LANGALL['pt_br']['channel_confirmfollow_rejected']); } else { $message->setSubject($LANGALL['en_us']['channel_asktofollow_subject']); $message->setMsg('#'.$channel->getName().'\n<br/>'.$LANGALL['en_us']['channel_confirmfollow_rejected']); } } $message->save();