Exemplo n.º 1
0
 function __construct()
 {
     // extracting notification options for this script
     // if you want other cronjob script use filename like
     // notify_%notification_interval%.php where %notification_interval%
     // is an interval name (we have 4 parameters for this field in DB now:
     // off, hourly, daily, weekly
     // name is case sensitive!
     $filename = explode(DS, __FILE__);
     $filename = end($filename);
     $filename = explode('.', $filename);
     $filename = $filename[0];
     $notification_interval = substr($filename, 7);
     $this->initConnection();
     //get the list of users with hourly notifications
     $users = $this->dbGetCol('SELECT users.id FROM users INNER JOIN preference ON users.id = preference.user_id WHERE preference.preference="notification_interval" AND preference.value="' . $notification_interval . '"');
     foreach ($users as $user_id) {
         $stream = new Stream();
         $stream->getUserNotifications($user_id, $notification_interval);
         $message = '';
         $message = $this->messageFromStream($user_id, $stream);
         if ($message) {
             $message = '<div style="width:450px; border:1px solid #000;"><div style="padding:5px;color:white; background-color:#345270">SlideWiki news stream for the latest week:</div><div style="padding:5px;">' . $message . '</div></div>';
             $this->sendEmailTo($user_id, $message);
         }
     }
 }
Exemplo n.º 2
0
 function activities()
 {
     $stream = new Stream();
     $stream->getMainPageStream(50);
     $this->set('stream', $stream);
     $this->set('page_title', 'Latest activities - SlideWiki');
     $this->set('page_keywords', 'SlideWiki, activities, presentations');
 }
Exemplo n.º 3
0
 /**
  * Set up a new Stream in pool
  *
  * @param Stream $stream
  * @throws Exception
  */
 public function setStream(Stream $stream)
 {
     /** @var $stream Stream */
     if (!$stream->isResource()) {
         throw new Exception("Is not a valid cURL Handle resource", Exception::INVALID_CURL);
     }
     curl_multi_add_handle($this->curl, $stream->getResource());
     $this->streams[$stream->getResource(true)] = $stream;
 }
Exemplo n.º 4
0
 public function testExpectStepsToNextToken()
 {
     $token1 = new Token(Token::IDENTIFIER, 'foo');
     $token2 = new Token(Token::IDENTIFIER, 'bar');
     $this->mockTokenizer->expects($this->exactly(3))->method('nextToken')->will($this->onConsecutiveCalls($token1, $token2, new Token(Token::EOF)));
     $stream = new Stream($this->mockTokenizer);
     $this->assertSame($token1, $stream->expect(Token::IDENTIFIER, 'foo'));
     $this->assertSame($token2, $stream->expect(Token::IDENTIFIER, 'bar'));
 }
Exemplo n.º 5
0
 public function get_contents()
 {
     $data = 'Test';
     $f = new Stream();
     $f->open(STREAM_MODE_WRITE);
     $f->write($data);
     $f->close();
     $this->assertEquals($data, FileUtil::getContents($f));
 }
Exemplo n.º 6
0
 function SaveSize()
 {
     $size = new Stream();
     $size->SetByteOrder($this->byteOrder);
     $size->AddInt32($this->size);
     $i = 0;
     for ($i = 0; $i < 4; $i++) {
         $c = ord($size->stream[$i]);
         $this->stream[$i] = chr($c);
     }
 }
Exemplo n.º 7
0
 public static function readCheckType(Stream $reader, $expectedType)
 {
     if ($reader instanceof IntReader) {
         $type = $reader->readInt();
     } else {
         $type = self::readIntEndian($reader);
     }
     if ($type != $expectedType) {
         throw new IOException("Expected chunk of type 0x" . dechex($expectedType) . ", read 0x" . dechex($type) . ".");
     }
 }
Exemplo n.º 8
0
 function activities()
 {
     $feed_type = $_GET['output'];
     if (!isset($feed_type)) {
         $feed_type = "RSS1.0";
     }
     //define channel
     $rss = new UniversalFeedCreator();
     $rss->useCached();
     $title = "SlideWiki -- Latest activities";
     $description = "list of latest activities on SlideWiki";
     $link = "http://slidewiki.org/";
     $syndicationURL = "http://slidewiki.aksw.org/feed/activities";
     $rss->title = $title;
     $rss->description = $description;
     $rss->link = $link;
     $rss->syndicationURL = $syndicationURL;
     $stream = new Stream();
     $stream->getMainPageStream(20);
     //channel items/entries
     foreach ($stream->activities as $i => $s) {
         switch ($s->type) {
             case 'created_deck':
                 $s->type = 'created deck';
                 break;
             case 'translated_deck_from':
                 $s->type = 'translated deck';
                 break;
             case 'commented_deck_revision':
                 $s->type = 'commented deck';
                 break;
             case 'followed_deck':
                 $s->type = 'started following deck';
                 break;
             case 'translated_deck':
                 $s->type = 'translated deck';
                 break;
             case 'created_deck_revision':
                 $s->type = 'created deck revision';
                 break;
         }
         $item = new FeedItem();
         $item->title = 'Activity ' . ($i + 1);
         $item->link = "http://slidewiki.org/?url=main/deck_stream&deck=" . $s->object->id;
         $item->description = '<a href="http://slidewiki.org/user/' . $s->subject->id . '">' . $s->subject->username . '</a> ' . $s->type . ' <a href="http://slidewiki.org/deck/' . $s->object->id . '_' . $s->object->slug_title . '">' . $s->object->title . '</a>';
         $item->source = "http://slidewiki.org/";
         $item->date = $s->timestamp;
         $item->author = '';
         $rss->addItem($item);
     }
     //Valid parameters are RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated),
     // MBOX, OPML, ATOM, ATOM1.0, ATOM0.3, HTML, JS
     $rss->outputFeed($feed_type);
 }
Exemplo n.º 9
0
 public function executeAddWallpost(sfWebRequest $request)
 {
     $message = $request->getPostParameter('message');
     $source_id = $this->getUser()->getAttribute('viewing_profile_id');
     $actor_id = $this->getUser()->getAttribute('id');
     $stream = new Stream();
     $stream->message = $message;
     $stream->actor_id = $actor_id;
     $stream->source_id = $source_id;
     $stream->save();
     $this->redirect('profile/index?uid=' . $source_id);
 }
Exemplo n.º 10
0
 public function index()
 {
     $CRs = new CR($this->db);
     $Actus = new Actu($this->db);
     $Streams = new Stream($this->db);
     $this->f3->set('actus', $Actus->all(10));
     $this->f3->set('streams', $Streams->find(NULL, array('order' => 'twitch_username ASC')));
     $this->f3->set('crs', $CRs->all(10));
     $this->f3->set('site_title', 'Un torrent d\'informations — thetartuffebay.org');
     $this->f3->set('page_head', 'Le premier site d\'information des tartuffes :o');
     $this->f3->set('view', 'home.htm');
 }
Exemplo n.º 11
0
 public function view()
 {
     $CR = new CR($this->db);
     $myCr = $CR->byUserName($this->f3->get('PARAMS.name'));
     $this->f3->set('list_cr', $myCr);
     $Stream = new Stream($this->db);
     $this->f3->set('list_stream', $myStream = $Stream->byUserName($this->f3->get('PARAMS.name')));
     if (!count($myCr) && !count($myStream)) {
         $this->f3->error(404);
         //$this->f3->reroute('@home');
     }
     $this->f3->set('site_title', 'Les CRs, Streams, Actus de ' . $this->f3->get('PARAMS.name') . ' | thetartuffebay.org');
     $this->f3->set('view', 'profil/view.htm');
 }
Exemplo n.º 12
0
 public static function get_session()
 {
     if (!self::$session) {
         // Generate the session ID.  This is slightly wasteful.
         $data = array();
         $data['type'] = 'stream';
         // This shouldn't be done here but at backend endpoint side
         if (isset($_REQUEST['client'])) {
             $data['agent'] = $_REQUEST['client'];
         }
         // Copy session geolocation
         // Same thing, should be done elsewhere
         $sid = session_id();
         if ($sid) {
             $location = Session::get_geolocation($sid);
             if (isset($location['latitude'])) {
                 $data['geo_latitude'] = $location['latitude'];
             }
             if (isset($location['longitude'])) {
                 $data['geo_longitude'] = $location['longitude'];
             }
             if (isset($location['name'])) {
                 $data['geo_name'] = $location['name'];
             }
         }
         self::$session = Session::create($data);
     }
     return self::$session;
 }
Exemplo n.º 13
0
 function server_loop()
 {
     while (true) {
         $read_fds = $this->fds;
         $write = $exp = null;
         if (stream_select($read_fds, $write, $exp, null)) {
             foreach ($read_fds as $socket) {
                 $socket_id = (int) $socket;
                 if ($socket_id == $this->server_socket_id) {
                     if ($client_socket_id = parent::accept()) {
                         $this->fds[$client_socket_id] = $this->client_sock[$client_socket_id];
                         $this->protocol->onConnect($this, $client_socket_id, 0);
                     }
                 } else {
                     $data = Stream::read($socket, $this->buffer_size);
                     if ($data !== false) {
                         $this->protocol->onReceive($this, $socket_id, 0, $data);
                     } else {
                         $this->close($socket_id);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 14
0
 public function testFromPath()
 {
     file_put_contents($path = tempnam(sys_get_temp_dir(), 'whatever'), 'foo');
     $stream = Stream::fromPath($path);
     $this->assertInstanceOf(Stream::class, $stream);
     $this->assertSame('foo', (string) $stream);
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $author = $model->author;
     $stream = new Stream();
     if (isset($_POST['Playlists'])) {
         $playlists = $_POST['Playlists'];
         if (isset($_POST['Stream']['url']) && $playlists['type'] == 2) {
             //2 - stream
             $exitstStream = Stream::model()->findByAttributes(array('playlist_id' => $id));
             if (!empty($exitstStream)) {
                 $stream = $exitstStream;
             }
             $stream->attributes = array('playlist_id' => $id, 'url' => $_POST['Stream']['url']);
             $stream->save();
             $playlists['files'] = '';
         } else {
             $stream->deleteAll("`playlist_id` = :playlist_id", array('playlist_id' => $id));
         }
         $model->attributes = $playlists;
         if ($author) {
             $model->author = $author;
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     if (count($model->stream) > 0) {
         $stream = $model->stream[0];
     }
     $this->render('update', array('model' => $model, 'stream' => $stream));
 }
Exemplo n.º 16
0
 /**
  * Get stream of the uploaded file
  * @return \Exedra\Http\Stream
  */
 public function getStream()
 {
     if (!$this->stream) {
         $this->stream = Stream::createFromPath($this->path);
     }
     return $this->stream;
 }
 /**
  * 
  * @param string $hostname
  * @param int $port
  */
 public function __construct($hostname, $port = null)
 {
     if ($port === null) {
         $port = -1;
     }
     $resource = fsockopen($hostname, $port);
     parent::__construct($resource);
 }
Exemplo n.º 18
0
 function __construct()
 {
     parent::__construct();
     $this->moudleId = -1;
     $this->id = -1;
     $this->isResult = -1;
     $this->headerIsReaded = false;
 }
Exemplo n.º 19
0
 public function __construct($streamData)
 {
     parent::__construct($streamData);
     $unpackFormat = ['vprocessorArchitecture', 'vprocessorLevel', 'vprocessorRevision', 'CnumberOfProcessors', 'CproductType', 'VmajorVersion', 'VminorVersion', 'VbuildNumber', 'VplatformId', 'VCSDVersionRVA', 'vsuiteMask', 'vreserved', 'V3vendorId', 'VversionInformation', 'VfeatureInformation', 'VamdExtendedCPUFeatures'];
     foreach (unpack(implode('/', $unpackFormat), $streamData) as $variable => $value) {
         $this->{$variable} = $value;
     }
 }
 function eof()
 {
     if (strlen($this->current_content) > 0) {
         return false;
     } else {
         return parent::eof();
     }
 }
 /**
  * 
  * @param string $filename
  * @param string $mode
  */
 public function __construct($filename, $mode = null)
 {
     if ($mode === null) {
         $mode = 'a+b';
     }
     $resource = fopen($filename, $mode);
     parent::__construct($resource);
 }
Exemplo n.º 22
0
 private function streamFromData($data)
 {
     $stream = new Stream();
     $stream->setService('azubu');
     $stream->setViewers($data->view_count);
     $stream->setPreviewImage($data->url_thumbnail);
     $stream->setBroadcasterLanguage($data->language);
     $stream->setLanguage($data->language);
     $stream->setStatus($data->title);
     $stream->setName($data->user->username);
     $stream->setLink($data->url_channel);
     /*
     $this->quality = $object->video_height;
     $this->setAverageFps( $object->average_fps );
     */
     return $stream;
 }
Exemplo n.º 23
0
 /**
  * @param int $length
  * @return string
  */
 public function read($length)
 {
     $content = parent::read($length);
     if ($content && !$this->reachedEof) {
         $this->cache .= $content;
     }
     if ($this->eof()) {
         $this->reachedEof = true;
     }
     return $content;
 }
Exemplo n.º 24
0
 private function streamFromData($data)
 {
     $stream = new Stream();
     $stream->setService('mlg');
     if (isset($data->viewers)) {
         $stream->setViewers($data->viewers);
     }
     $stream->setPreviewImage($data->image_16_9);
     $stream->setStatus($data->subtitle);
     $stream->setName($data->name);
     $stream->setLink($data->url);
     return $stream;
 }
Exemplo n.º 25
0
 private function streamFromData($data)
 {
     $stream = new Stream();
     $stream->setService('hitbox');
     // set quality
     $quality = json_decode($data->media_profiles);
     if ($quality !== null) {
         $quality = end($quality);
         $stream->setQuality($quality->height);
     }
     $stream->setViewers($data->media_views);
     $stream->setPreviewImage('http://edge.sf.hitbox.tv' . $data->media_thumbnail_large);
     $stream->setStatus($data->media_status);
     $stream->setName($data->media_name);
     $stream->setLink($data->channel->channel_link);
     return $stream;
 }
Exemplo n.º 26
0
 function server_loop()
 {
     while ($this->client_sock[0] = stream_socket_accept($this->server_sock, -1)) {
         stream_set_blocking($this->client_sock[0], 1);
         if (feof($this->client_sock[0])) {
             $this->close(0);
         }
         //堵塞Server必须读完全部数据
         $data = Stream::read($this->client_sock[0], $this->buffer_size);
         $this->protocol->onReceive($this, 0, 0, $data);
     }
 }
Exemplo n.º 27
0
function update_preferences($pref_id = 0)
{
    /* Get current keys */
    $sql = "SELECT `id`,`name`,`type` FROM `preference`";
    /* If it isn't the System Account's preferences */
    if ($pref_id != '-1') {
        $sql .= " WHERE `catagory` != 'system'";
    }
    $db_results = Dba::read($sql);
    $results = array();
    // Collect the current possible keys
    while ($r = Dba::fetch_assoc($db_results)) {
        $results[] = array('id' => $r['id'], 'name' => $r['name'], 'type' => $r['type']);
    }
    // end collecting keys
    /* Foreach through possible keys and assign them */
    foreach ($results as $data) {
        /* Get the Value from POST/GET var called $data */
        $name = $data['name'];
        $apply_to_all = 'check_' . $data['name'];
        $new_level = 'level_' . $data['name'];
        $id = $data['id'];
        $value = scrub_in($_REQUEST[$name]);
        /* Some preferences require some extra checks to be performed */
        switch ($name) {
            case 'transcode_bitrate':
                $value = Stream::validate_bitrate($value);
                break;
            default:
                break;
        }
        if (preg_match('/_pass$/', $name)) {
            if ($value == '******') {
                unset($_REQUEST[$name]);
            } else {
                if (preg_match('/md5_pass$/', $name)) {
                    $value = md5($value);
                }
            }
        }
        /* Run the update for this preference only if it's set */
        if (isset($_REQUEST[$name])) {
            Preference::update($id, $pref_id, $value, $_REQUEST[$apply_to_all]);
        }
        if (Access::check('interface', '100') && $_REQUEST[$new_level]) {
            Preference::update_level($id, $_REQUEST[$new_level]);
        }
    }
    // end foreach preferences
    // Now that we've done that we need to invalidate the cached preverences
    Preference::clear_from_session();
}
Exemplo n.º 28
0
 /**
  *
  * @param string $data Initial data
  * @param int $memSize Memory limit
  * @param string $mode Open mode
  */
 public function __construct($data = null, $memSize = null, $mode = 'w+')
 {
     $memSize = \intval($memSize);
     $file = 'php://';
     if ($memSize > 0) {
         $file .= "temp/maxmemory:{$memSize}";
     } else {
         $file .= 'memory';
     }
     $stream = Stream::open($file, $mode, false);
     parent::__construct($stream);
     $this->write($data);
 }
Exemplo n.º 29
0
 protected function conn_open($url)
 {
     $oldconn = $this->conn;
     if (!parent::conn_open($url)) {
         return false;
     }
     if ($this->conn !== $oldconn) {
         // Start SFTP subsystem on the new connection
         if (($this->sftp = ssh2_sftp($this->conn)) === false) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 30
0
 /**
  * Returns 
  *
  * @return  io.Stream
  */
 protected function archiveBytesAsStream($version = -1)
 {
     static $bytes = array(1 => "CCA", 2 => "CCA");
     $s = new Stream();
     $s->open(STREAM_WRITE);
     $s->write($bytes[$version < 0 ? $this->version() : $version]);
     $s->write(str_repeat("", 248));
     // Reserved bytes
     $s->close();
     return $s;
 }