コード例 #1
0
 function formatResult($skin, $result)
 {
     global $wgUser, $wgLang, $mvImageArchive, $mvgScriptPath, $wgRequest;
     #make sure the first letter is upper case (makeTitle() should do that)
     //$result->title = strtoupper($result->title[0]) . substr($result->title, 1);
     //$img_url = $mvImageArchive . $result->title . '?size=icon&time=0:00:00';
     //$img_url = MV_StreamImage::getStreamImageURL($result->stream_id, '0:00:00', 'icon', true);
     //$img_html = '<img src="'.$img_url . '" width="80" height="60">';
     //$title = Title::makeTitle( MV_NS_SITTING, $result->title  );
     //$spec_list = Title::makeTitle(MV_NS_SPECIAL, "Special:Mv_List_Streams");
     $stream_id = $wgRequest->getVal('stream_id');
     $stream_name = MV_Stream::getStreamNameFromId($stream_id);
     //$stream_name = 'New';
     $title = Title::newFromText($stream_name, MV_NS_STREAM);
     $text = $result->title;
     $form = '<form method="post" action="' . $title->getEditURL() . '">';
     $form .= '<input type="hidden" name="mv_action" value="add_existing_stream_file"></input>';
     $form .= '<input type="hidden" name="sf_new' . '[stream_id]" value="' . $stream_id . '"></input>';
     $form .= '<input type="hidden" name="sf_new' . '[id]" value="' . $result->id . '"></input>';
     //$form.='<input type="hidden" name="sf_new'.'[duration]" value="'.$result->duration.'"></input>';
     //$form.='<input type="hidden" name="sf_new'.'[base_offset]" value="'.$result->base_offset.'"></input>';
     //$form.='<input type="hidden" name="sf_new'.'[path]" value="'.$text.'"></input>';
     //$form.='<input type="hidden" name="sf_new'.'[file_desc_mesg]" value="'.$result->file_desc_mesg.'"></input>';
     $form .= '<input type="submit" name="submit" value="Add"></input>';
     $form .= '</form>';
     $rlink = $text . $form;
     return $rlink;
 }
コード例 #2
0
 function getStreamImageURL($stream_id, $req_time = null, $req_size = null, $directLink = false)
 {
     global $wgScript, $mvWebImgLoc, $mvLocalImgLoc, $mvExternalImages;
     //check global external image prefrence:
     $req_size_out = $req_size != null ? '&size=' . $req_size : '';
     if ($mvExternalImages) {
         global $mvExternalImgServerPath;
         //try to get the stream_name for external requests:
         $sn = MV_Stream::getStreamNameFromId($stream_id);
         return $mvExternalImgServerPath . '?action=ajax&rs=mv_frame_server&stream_name=' . $sn . '&t=' . $req_time . $req_size_out;
     }
     //by default return a non-direct link so that javascript can modify the url to get new images
     if (!$directLink) {
         return $wgScript . '?action=ajax&rs=mv_frame_server&stream_id=' . $stream_id . '&t=' . $req_time . $req_size_out;
     }
     $req_time = MV_StreamImage::procRequestTime($stream_id, $req_time);
     if ($req_time == false) {
         return MV_StreamImage::getMissingImageURL($req_size);
     }
     //print "got req time: $req_time<br />";
     //first check if the file exist
     if (is_file(MV_StreamImage::getLocalImagePath($stream_id, $req_time, $req_size))) {
         if ($req_size == null) {
             $s = '';
             $ext = 'jpg';
             //default type is jpg
         } else {
             list($im_width, $im_height, $ext) = MV_StreamImage::getSizeType($req_size);
             $s = '_' . $im_width . 'x' . $im_height;
         }
         return $mvWebImgLoc . '/' . MV_StreamImage::getRelativeImagePath($stream_id) . '/' . $req_time . $s . '.' . $ext;
     } else {
         //throw 'error finding image';
         return MV_StreamImage::getMissingImageURL($req_size);
     }
 }
コード例 #3
0
    function getItemOutput($row, $opt = array())
    {
        global $wgUser;
        $sk = $wgUser->getSkin();
        //set defaults:
        $person_ht = $bill_ht = $category_ht = $o = '';
        if (!isset($row->start_time)) {
            $row->start_time = 0;
        }
        if (!isset($row->end_time)) {
            $row->end_time = 60 * 20;
        }
        $mvd_out_html = '';
        $mvd_rows = MV_Index::getMVDInRange($row->stream_id, $row->start_time, $row->end_time, $mvd_type = 'anno_en', $getText = true, $smw_properties = array('Speech_by', 'Bill', 'category'), $options = array('limit' => 1));
        if (count($mvd_rows) != 0) {
            reset($mvd_rows);
            $mvd_row = current($mvd_rows);
            if (isset($opt['use_mvd_time']) && $opt['use_mvd_time']) {
                $row->start_time = $mvd_row->start_time;
                $row->end_time = $mvd_row->end_time;
            }
            // print_r($mvd_rows);
            // print "type of: " . gettype($mvd_row);
            if (isset($mvd_row->Speech_by)) {
                if (trim($mvd_row->Speech_by) != '') {
                    $ptitle = Title::MakeTitle(NS_MAIN, $mvd_row->Speech_by);
                    $mvd_out_html .= '<span class="keywords">' . $sk->makeKnownLinkObj($ptitle, $ptitle->getText()) . '</span><br />';
                }
            }
            if (isset($mvd_row->Bill)) {
                if (trim($mvd_row->Bill) != '') {
                    $btitle = Title::MakeTitle(NS_MAIN, $mvd_row->Bill);
                    $mvd_out_html .= '<span class="keywords">Bill: ' . $sk->makeKnownLinkObj($btitle) . '
 						</span><br />';
                }
            }
            global $wgContLang;
            $mvdNStxt = $wgContLang->getNsText(MV_NS_MVD);
            //grab categories if no bill or speech
            if ($this->params['display_cat'] || $mvd_out_html == '') {
                $dbr = wfGetDB(DB_READ);
                $cl_res = $dbr->select('categorylinks', 'cl_to', array('cl_sortkey' => $mvdNStxt . ':' . str_replace('_', ' ', $mvd_row->wiki_title)), 'getTopClips::Categories', 'LIMIT 0, 5');
                if ($dbr->numRows($cl_res) != 0) {
                    $mvd_out_html .= '<span class="keywords">Categories: ';
                    $coma = '';
                    while ($cl_row = $dbr->fetchObject($cl_res)) {
                        $cTitle = Title::MakeTitle(NS_CATEGORY, $cl_row->cl_to);
                        $mvd_out_html .= $coma . $sk->makeKnownLinkObj($cTitle, $cTitle->getText());
                        $coma = ', ';
                    }
                    $mvd_out_html .= '</span><br />';
                }
            }
        } else {
            //we have not meta
            //if( isset($opt['remove_no_meta']) && $opt['remove_no_meta'])
            //return false;
        }
        // first make link and stream title:
        $mvStream = MV_Stream::newStreamByID($row->stream_id);
        if (!$mvStream->doesStreamExist()) {
            return false;
        }
        //limit our output range to < 20 min
        if ($row->end_time - $row->start_time > 20 * 60) {
            $row->end_time = $row->start_time + 20 * 60;
        }
        $nt = $mvStream->getStreamName() . '/' . seconds2npt($row->start_time) . '/' . seconds2npt($row->end_time);
        $mvTitle = new MV_Title($nt, MV_NS_STREAM);
        $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range = '0'));
        // output the image:
        $o .= $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for ' . $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL('small') . '"/>', 'tl=1');
        $title_span = '';
        if (isset($mvStream->date_start_time)) {
            $parts = split('_', $mvStream->getStreamName());
            if (count($parts) >= 3) {
                $title_span = ucfirst($parts[0] . ' ');
            } else {
                $title_span = $mvStream->getStreamName();
            }
            $title_span .= date('F jS, Y', $mvStream->date_start_time);
        } else {
            $title_span = $mvTitle->getStreamNameText() . $mvTitle->getTimeDesc();
        }
        $o .= '<span class="title">' . $sk->makeKnownLinkObj($mvStreamTitle, $title_span, 'tl=1') . '</span>';
        //add mvd_annotative output:
        $o .= $mvd_out_html;
        return $o;
    }
コード例 #4
0
 function generate($take_duration)
 {
     global $mvgIP;
     require_once $mvgIP . '/includes/MV_Index.php';
     $s = MV_Stream::newStreamByName($this->name);
     if (!$s->db_load_stream()) {
         return "An error occured while loading stream info please notify Administrator";
     }
     $stream_duration = $s->getDuration();
     if ($stream_duration === NULL) {
         return "Error: Stream Duration not set";
     }
     $sitting_id = $s->getSittingId();
     $editors = $this->getAssignedEditors($sitting_id);
     $readers = $this->getAssignedReaders($sitting_id);
     $reporters = $this->getAssignedReporters($sitting_id);
     $editors_count = count($editors);
     $readers_count = count($readers);
     $reporters_count = count($reporters);
     $html = '';
     if ($editors_count == 0) {
         $html .= "No Editors Assigned";
         return $html;
     }
     if ($readers_count == 0) {
         $html .= "No Readers Assigned";
         return $html;
     }
     if ($reporters_count == 0) {
         $html .= "No Reporters Assigned";
         return $html;
     }
     //delete all existing take transcripts
     $dbr =& wfGetDB(DB_SLAVE);
     $result =& MV_Index::getMVDInRange($s->getStreamId(), 0, $s->getDuration(), $this->mvd_tracks);
     while ($row = $dbr->fetchObject($result)) {
         $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
         $art = new Article($title);
         if ($art->exists()) {
             $art->doDelete("new takes generated", true);
         }
     }
     $num_editor = 0;
     $num_reader = 0;
     $num_reporter = 0;
     for ($i = 0; $i < $stream_duration; $i = $i + $take_duration) {
         $start_time = $i;
         $end_time = $i + $take_duration;
         $title_text = 'Take_en:' . $this->name . '/' . seconds2ntp($start_time) . '/' . seconds2ntp($end_time);
         $title = Title::newFromText($title_text, MV_NS_MVD);
         $editor = User::newFromId($editors[$num_editor]);
         $editor_name = $editor->getRealName();
         $reader = User::newFromId($readers[$num_editor]);
         $reader_name = $reader->getRealName();
         $reporter = User::newFromId($reporters[$num_editor]);
         $reporter_name = $reporter->getRealName();
         $article = new Article($title);
         $text = '[[Edited By::' . $editor_name . ']], ' . '[[Read By::' . $reader_name . ']], ' . '[[Reported By::' . $reporter_name . ']], ' . '[[Status::Incomplete]]';
         $article->doEdit($text, 'Automatically Generated', EDIT_NEW);
         if ($num_editor < $editors_count - 1) {
             $num_editor++;
         } else {
             $num_editor = 0;
         }
         if ($num_reader < $readers_count - 1) {
             $num_reader++;
         } else {
             $num_reader = 0;
         }
         if ($num_reporter < $reporters_count - 1) {
             $num_reporter++;
         } else {
             $num_reporter = 0;
         }
     }
     $html .= 'Takes Successfully Generated';
     return $html;
 }
コード例 #5
0
 function get_nav_page($stream_title)
 {
     global $mvgIP;
     // output sliders for stream navigation:
     $out = '<h3>' . wfMsg('mv_tool_navigate') . ' ' . htmlspecialchars(ucfirst($stream_title)) . '</h3>';
     // normalize stream title:
     $stream_title = str_replace(' ', '_', strtolower($stream_title));
     // get the total length of the stream:
     $stream = new MV_Stream(array('name' => $stream_title));
     // $out.= "sn: ". $stream->name . '<br />';
     $duration = $stream->getDuration();
     // $out.=" duration: $duration";
     $MvOverlay = new MV_Overlay();
     $titleKey = 'mvd_type:' . ucfirst($stream_title) . '/' . $_REQUEST['time_range'];
     $out .= $MvOverlay->get_adjust_disp($titleKey, 'nav');
     $out .= '<input type="button" id="mv_go_nav" value="Go">';
     // set range:
     $this->js_eval = 'var end_time = \'' . htmlspecialchars($duration) . '\';';
     return $out;
 }
コード例 #6
0
 function processUpload()
 {
     global $wgUser, $wgOut, $wgFileExtensions, $wgScriptPath;
     $details = null;
     $value = null;
     global $mvMediaFilesTable, $mvStreamFilesTable, $wgRequest;
     $stream_id = $wgRequest->getVal('stream_id');
     $file_desc_msg = $wgRequest->getVal('file_desc_msg');
     $newStream = MV_Stream::newStreamByID($stream_id);
     $files = $newStream->getFileList();
     $doAdd = true;
     foreach ($files as $sf) {
         if ($sf->file_desc_msg == $file_desc_msg) {
             $doAdd = false;
         }
     }
     if (!$doAdd) {
         $value = 99;
     } else {
         $value = $this->internalProcessUpload($details);
     }
     switch ($value) {
         case self::SUCCESS:
             $html = 'File has been uploaded successfully<br/>';
             $file = '' . $this->mLocalFile->getPath();
             if (file_exists($file)) {
                 $f = fopen($file, "rb");
                 $header = fread($f, 512);
                 $page['serial'] = substr($header, 14, 4);
                 $page['segments'] = ord($header[26]);
                 $page['rate'] = ord($header[27 + $page['segments'] + 15]);
                 $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 14]);
                 $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 13]);
                 $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 12]);
                 fseek($f, -6000, SEEK_END);
                 $end = fread($f, 6000);
                 $tail = strstr($end, "OggS");
                 if ($tail) {
                     $serial = substr($tail, 14, 4);
                     if ($serial == $page['serial']) {
                         $duration = 103;
                         $granulepos = ord($tail[6]);
                         $granulepos = $granulepos | ord($tail[7]) << 8;
                         $granulepos = $granulepos | ord($tail[8]) << 16;
                         $granulepos = $granulepos | ord($tail[9]) << 24;
                         $granulepos = $granulepos | ord($tail[10]) << 32;
                         $granulepos = $granulepos | ord($tail[11]) << 40;
                         $granulepos = $granulepos | ord($tail[12]) << 48;
                         $granulepos = $granulepos | ord($tail[13]) << 56;
                         $duration = $granulepos / $page['rate'];
                     }
                 }
                 fclose($f);
             }
             $dbr =& wfGetDB(DB_WRITE);
             $text = '' . $wgScriptPath . '/images/' . $this->mLocalFile->getUrlRel();
             if ($duration === null) {
                 $duration = 0;
             }
             if ($dbr->insert($mvMediaFilesTable, array('path' => $text, 'duration' => $duration, 'file_desc_msg' => $file_desc_msg), __METHOD__)) {
                 $result = $dbr->query("SELECT LAST_INSERT_ID() AS id");
                 $row = $dbr->fetchObject($result);
                 $id = $row->id;
                 if ($dbr->insert($mvStreamFilesTable, array('file_id' => $id, 'stream_id' => $stream_id), __METHOD__)) {
                     $stream_name = MV_Stream::getStreamNameFromId($stream_id);
                     $title = Title::newFromText($stream_name, MV_NS_STREAM);
                     $wgOut->redirect($title->getLocalURL("action=edit"));
                 } else {
                     $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
                 }
             } else {
                 $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
             }
             /*
             				
             				if ($dbr->insert($mvStreamFilesTable, array('stream_id'=>$stream_id))) {
             					$result = $dbr->query("SELECT LAST_INSERT_ID()");
             					$row = $dbr->fetchObject($result);
             					if ($duration===null)$duration=0;
             					if ($dbr->insert($mvMediaFilesTable, array('id'=>$row->id,'path'=>$text,'duration'=>$duration))) {
             					
             						//$html .='<input type="button" name="Close" value="Close" Onclick="window.opener.document.getElementById(\'path\').value=\''.$wgScriptPath.'/images/'.$this->mLocalFile->getUrlRel().'\'; window.opener.document.getElementById(\'duration\').value='.floor($duration).'; window.close()"></input>' ;
             						$stream_name = MV_Stream::getStreamNameFromId($stream_id);
             						$title = Title::newFromText( $stream_name, MV_NS_STREAM  );
             						$wgOut->redirect($title->getLocalURL("action=edit"));	
             						
             					}
             					else {
             						$html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
             					}
             				} else {
             				$html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
             				}
             */
             $wgOut->addHTML($html);
             break;
         case self::BEFORE_PROCESSING:
             break;
         case self::LARGE_FILE_SERVER:
             $this->mainUploadForm(wfMsgHtml('largefileserver'));
             break;
         case self::EMPTY_FILE:
             $this->mainUploadForm(wfMsgHtml('emptyfile'));
             break;
         case self::MIN_LENGHT_PARTNAME:
             $this->mainUploadForm(wfMsgHtml('minlength1'));
             break;
         case self::ILLEGAL_FILENAME:
             $filtered = $details['filtered'];
             $this->uploadError(wfMsgWikiHtml('illegalfilename', htmlspecialchars($filtered)));
             break;
         case self::PROTECTED_PAGE:
             $this->uploadError(wfMsgWikiHtml('protectedpage'));
             break;
         case self::OVERWRITE_EXISTING_FILE:
             $errorText = $details['overwrite'];
             $overwrite = new WikiError($wgOut->parse($errorText));
             $this->uploadError($overwrite->toString());
             break;
         case self::FILETYPE_MISSING:
             $this->uploadError(wfMsgExt('filetype-missing', array('parseinline')));
             break;
         case self::FILETYPE_BADTYPE:
             $finalExt = $details['finalExt'];
             $this->uploadError(wfMsgExt('filetype-banned-type', array('parseinline'), htmlspecialchars($finalExt), implode(wfMsgExt('comma-separator', array('escapenoentities')), $wgFileExtensions)));
             break;
         case self::VERIFICATION_ERROR:
             $veri = $details['veri'];
             $this->uploadError($veri->toString());
             break;
         case self::UPLOAD_VERIFICATION_ERROR:
             $error = $details['error'];
             $this->uploadError($error);
             break;
         case self::UPLOAD_WARNING:
             $warning = $details['warning'];
             $this->uploadWarning($warning);
             break;
         case self::INTERNAL_ERROR:
             $internal = $details['internal'];
             $this->showError($internal);
             break;
         case 99:
             $this->mainUploadForm('Type ' . $file_desc_msg . ' already exists');
             break;
         default:
             throw new MWException(__METHOD__ . ": Unknown value `{$value}`");
     }
 }
コード例 #7
0
 function onEdit(&$mvd_pages_cache, $mvd_id)
 {
     // force update local mvd_page_cache from db:
     $mvd_pages_cache[$mvd_id] = MV_Index::getMVDbyId($mvd_id);
     $stream_name = MV_Stream::getStreamNameFromId($this->mvd_pages[$mvd_id]->stream_id);
     $streamTitle = Title::newFromText($stream_name, MV_NS_STREAM);
     // clear the cache for the parent stream page:
     // print "clear parent stream: " . $streamTitle ."\n";
     Article::onArticleEdit($streamTitle);
 }
コード例 #8
0
function do_process_text($stream, $force)
{
    $dbr = wfGetDB(DB_SLAVE);
    if ($force) {
        global $botUserName;
        // get wiki stream id:
        $wikiStream = new MV_Stream(array('name' => $stream->name));
        // first remove all bot edited pages:
        $mvd_res = MV_Index::getMVDInRange($wikiStream->getStreamId(), null, null, 'Ht_en');
        while ($row = $dbr->fetchObject($mvd_res)) {
            $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
            $current = Revision::newFromTitle($title);
            if ($current->getUserText() == $botUserName) {
                $article = new Article($title);
                $article->doDelete('mvbot removal');
                print "removed {$row->wiki_title} \n";
            } else {
                print "skiped {$roe->wiki_title} (last edit by: " . $current->getUserText() . ")\n";
            }
        }
    }
    /* for now use the stream search table (in the future should put in our orphaned person data)
     * should be able to do quick checks against the index. */
    $sql = "SELECT (`time`+" . CC_OFFSET . ") as time, `value` " . "FROM `metavid`.`stream_attr_time_text`\n\t\t\t\t\t\tWHERE `stream_fk`=" . $stream->id . "\n\t\t\t\t\t\tAND `time` >= " . $stream->adj_start_time . "\n\t\t\t\t\t\tAND `time` <= " . $stream->adj_end_time . "\n\t\t\t\tORDER BY `time` ASC ";
    // $sql = "SELECT * FROM `metavid`.`stream_search` WHERE `stream_fk`={$stream->id}";
    $page_res = $dbr->query($sql);
    if ($dbr->numRows($page_res) == 0) {
        echo 'No pages for stream' . $stream->name . "\n";
    }
    $pages = array();
    while ($page = $dbr->fetchObject($page_res)) {
        $pages[] = $page;
    }
    print "Checking " . count($pages) . " text pages\n";
    $i = $j = 0;
    foreach ($pages as $inx => $page) {
        // status updates:
        if ($i == 50) {
            print "on {$j} of " . count($pages) . "\n";
            $i = 0;
        }
        $i++;
        $j++;
        $start_time = $page->time - $stream->adj_start_time;
        if (seconds2npt($start_time) < 0) {
            $start_time = '0:00:00';
        }
        if ($inx + 1 == count($pages)) {
            $end_time = $stream->adj_end_time - $stream->adj_start_time;
        } else {
            $end_time = $pages[$inx + 1]->time - $stream->adj_start_time;
        }
        if ($end_time - $start_time > 40) {
            $end_time = $start_time + 40;
        }
        // skip if end_time <1
        if ($end_time < 0) {
            continue;
        }
        // now pull up the person for the given stream time:`metavid`.`people`.`name_clean`
        $sql = "SELECT * , abs( `metavid`.`people_attr_stream_time`.`time` -{$page->time} ) AS `distance` " . "FROM `metavid`.`people_attr_stream_time` " . "LEFT JOIN `metavid`.`people` ON `metavid`.`people_attr_stream_time`.`people_fk` = `metavid`.`people`.`id` " . "WHERE `metavid`.`people_attr_stream_time`.`stream_fk` ={$stream->id} " . "AND  (`metavid`.`people_attr_stream_time`.`time`-{$page->time})>-4 " . "AND abs( `metavid`.`people_attr_stream_time`.`time` -{$page->time} )< 90 " . "ORDER BY `distance` ASC " . "LIMIT 1 ";
        $person_res = $dbr->query($sql);
        $page_title = $stream->name . '/' . seconds2npt($start_time) . '/' . seconds2npt($end_time);
        // print $page_title . "\n";
        $page_body = '';
        if ($dbr->numRows($person_res) != 0) {
            $person = $dbr->fetchObject($person_res);
            $person_name = utf8_encode($person->name_clean);
            $page_body .= "\n[[Spoken By::{$person_name}]] ";
        }
        $page_body .= trim(str_replace("\n", ' ', strtolower($page->value)));
        // print $page_title . "\n";
        // die;
        // print $page_body . "\n\n";
        do_update_wiki_page('Ht_en:' . $page_title, $page_body, MV_NS_MVD);
    }
}
コード例 #9
0
require_once 'maintenance_util.inc.php';
if (count($args) == 0 || isset($options['help'])) {
    print '
USAGE
 php ogg_thumb_insert.php stream_name filename interval duration

EXAMPLE where stream.ogg is 10min 20 seconds long and we get a frame every 5 seconds:
 ogg_thumb_insert.php stream_name stream.ogg 5 620

Notes:
  if possible you want to use the source footage rather than the ogg to generate the thumbnails (ie the mpeg2 or dv)

';
    exit;
}
$stream_name = $args[0];
$filename = $args[1];
$interval = $args[2];
$duration = $args[3];
$MV_Stream = MV_Stream::newStreamByName($stream_name);
$stream_id = $MV_Stream->getStreamId();
$filedir = '../stream_images/' . MV_StreamImage::getRelativeImagePath($stream_id);
$dbw = $dbr = wfGetDB(DB_MASTER);
for ($i = 0; $i < $duration; $i += $interval) {
    shell_exec("ffmpeg -ss {$i} -i {$filename} -vcodec mjpeg -vframes 1 -an -f rawvideo -y {$filedir}/{$i}.jpg");
    if (is_file("{$filedir}/{$i}.jpg")) {
        $dbw->query("INSERT INTO `mv_stream_images` (`stream_id`, `time`) VALUES ({$stream_id}, {$i})");
    } else {
        print "failed to create file: {$filedir}/{$i}.jpg \n";
    }
}
コード例 #10
0
 function add_stream()
 {
     $out = '';
     $mvTitle = new MV_Title($this->stream_name);
     //fist check if the given stream name already exists
     if ($mvTitle->doesStreamExist()) {
         $mv_page = Title::newFromText($this->stream_name, MV_NS_STREAM);
         return '<span class="error">' . wfMsg('mv_stream_already_exists', $this->stream_name, $mv_page->getFullURL()) . '</span> ';
     } else {
         //get the stream pointer
         //$stream =& mvGetMVStream(array('name'=>$this->stream_name,'sitting_id'=>$this->sitting_id));
         //$strarray = array($key=>val);
         //foreach ($this as $key => $val) {
         //	if (isset ($key)) {
         //		$strarray[$key] = $val;
         //	}
         //}
         $stream = new MV_Stream(array('name' => $this->stream_name, 'state' => $this->state, 'date_start_time' => $this->date_start_time, 'duration' => $this->duration, 'sitting_id' => $this->sitting_id));
         $stream->db_load_stream();
         //if the stream is inserted proceed with page insertion
         if ($stream->insertStream($this->stream_type)) {
             global $wgUser;
             $sk = $wgUser->getSkin();
             //insert page
             $streamTitle = Title::newFromText($this->stream_name, MV_NS_STREAM);
             $wgArticle = new Article($streamTitle);
             $success = $wgArticle->doEdit($this->stream_desc, wfMsg('mv_summary_add_stream'));
             if ($success) {
                 //stream inserted succesfully report to output
                 //$streamLink = $sk->makeLinkObj( $streamTitle,  $this->stream_name );
                 //$out='stream '.$streamLink.' added';
                 return true;
             } else {
                 //$out=wfMsg('mv_error_stream_insert');
                 return false;
             }
         } else {
             //stream failed insert
             return false;
         }
     }
     //return $out;
 }
コード例 #11
0
/**
 * global MV_Stream server
 * @@todo cache this function
 */
function mvGetMVStream($stream_init)
{
    global $MVStreams;
    // wfDebug('mv get stream: ' .$stream_name . "\n");
    if (is_object($stream_init)) {
        $stream_init = get_object_vars($stream_init);
    } elseif (is_string($stream_init)) {
        // if a string is passed in assume its the stream name:
        $stream_init = array('name' => $stream_init);
    }
    if (isset($stream_init['name'])) {
        $stream_name = $stream_init['name'];
    } elseif (isset($stream_init['id'])) {
        $stream_name = MV_Stream::getStreamNameFromId($stream_init['id']);
    } else {
        die('missing stream id or name' . $stream_init);
    }
    // @@todo cache in memcache)
    if (!isset($MVStreams[$stream_name])) {
        $MVStreams[$stream_name] = new MV_Stream($stream_init);
        $MVStreams[$stream_name]->db_load_stream();
    }
    return $MVStreams[$stream_name];
}
コード例 #12
0
function mv_frame_server($stream_name = '', $req_time = '', $req_size = '')
{
    global $wgRequest;
    $stream_id = '';
    // try loading vals from $wgRequest if not set
    $stream_name = $stream_name == '' ? $wgRequest->getVal('stream_name') : $stream_name;
    if ($stream_name == null) {
        $stream_id = $wgRequest->getVal('stream_id');
    }
    $req_time = $req_time == '' ? $wgRequest->getVal('t') : $req_time;
    $req_size = $req_size == '' ? $wgRequest->getVal('size') : $req_size;
    $redirect_req = $wgRequest->getVal('redirect') == 'true' ? true : false;
    if ($stream_id == '') {
        $mvStream = mvGetMVStream($stream_name);
        $stream_id = $mvStream->getStreamId();
    } else {
        $mvStream = new MV_Stream(array('id' => $stream_id));
    }
    if ($mvStream->db_load_stream()) {
        global $mvServeImageRedirect, $mvExternalImages;
        if ($mvServeImageRedirect || $redirect_req || $mvExternalImages) {
            header("Location:" . MV_StreamImage::getStreamImageURL($stream_id, $req_time, $req_size, true));
        } else {
            // serve up the image directly
            MV_StreamImage::getStreamImageRaw($stream_id, $req_time, $req_size, true);
        }
        exit;
    } else {
        return 'error: invalid stream name';
    }
}
コード例 #13
0
 function edit($textbox1_override = null)
 {
     global $wgOut, $wgUser, $wgRequest;
     $fname = 'MV_EditPage::edit';
     wfProfileIn($fname);
     wfDebug("{$fname}: enter\n");
     // this is not an article
     $wgOut->setArticleFlag(false);
     $this->importFormData($wgRequest);
     if ($textbox1_override) {
         $this->textbox1 = $textbox1_override;
     }
     $this->firsttime = false;
     if ($this->live) {
         $this->livePreview();
         wfProfileOut($fname);
         return;
     }
     $permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser);
     if (!$this->mTitle->exists()) {
         $permErrors += array_diff($this->mTitle->getUserPermissionsErrors('create', $wgUser), $permErrors);
     }
     # Ignore some permissions errors.
     $remove = array();
     foreach ($permErrors as $error) {
         if ($this->preview || $this->diff && ($error[0] == 'blockedtext' || $error[0] == 'autoblockedtext')) {
             // Don't worry about blocks when previewing/diffing
             $remove[] = $error;
         }
         if ($error[0] == 'readonlytext') {
             if ($this->edit) {
                 $this->formtype = 'preview';
             } elseif ($this->save || $this->preview || $this->diff) {
                 $remove[] = $error;
             }
         }
     }
     # array_diff returns elements in $permErrors that are not in $remove.
     $permErrors = array_diff($permErrors, $remove);
     if (!empty($permErrors)) {
         wfDebug("{$fname}: User can't edit\n");
         // limt rows for ajax:
         $non_ajax_rows = $wgUser->getIntOption('rows');
         $wgUser->setOption('rows', 5);
         $sk = $wgUser->getSkin();
         $cancel = '<a href="javascript:mv_disp_mvd(\'' . $this->mTitle->getDBkey() . '\',\'' . $this->mvd_id . '\');">' . wfMsgExt('cancel', array('parseinline')) . '</a>';
         // get the stream parent:
         $mvd = MV_Index::getMVDbyId($this->mvd_id);
         $stream_name = MV_Stream::getStreamNameFromId($mvd->stream_id);
         $lTitle = SpecialPage::getTitleFor('Userlogin');
         $loginLink = $lTitle->getFullURL('returnto=' . MWNamespace::getCanonicalName(MV_NS_STREAM) . ':' . $stream_name);
         $wgOut->addHTML(wfMsg('mv_user_cant_edit', $loginLink, $cancel));
         $wgOut->readOnlyPage($this->mArticle->getContent(), true, $permErrors);
         $wgUser->setOption('rows', $non_ajax_rows);
         wfProfileOut($fname);
         return;
     } else {
         if ($this->save) {
             $this->formtype = 'save';
         } elseif ($this->preview) {
             $this->formtype = 'preview';
         } elseif ($this->diff) {
             $this->formtype = 'diff';
         } else {
             # First time through
             $this->firsttime = true;
             if ($this->previewOnOpen()) {
                 $this->formtype = 'preview';
             } else {
                 $this->extractMetaDataFromArticle();
                 $this->formtype = 'initial';
             }
         }
     }
     wfProfileIn("{$fname}-business-end");
     $this->isConflict = false;
     // css / js subpages of user pages get a special treatment
     $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
     $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
     /* Notice that we can't use isDeleted, because it returns true if article is ever deleted
      * no matter it's current state
      */
     $this->deletedSinceEdit = false;
     if ($this->edittime != '') {
         /* Note that we rely on logging table, which hasn't been always there,
          * but that doesn't matter, because this only applies to brand new
          * deletes. This is done on every preview and save request. Move it further down
          * to only perform it on saves
          */
         if ($this->mTitle->isDeleted()) {
             $this->lastDelete = $this->getLastDelete();
             if (!is_null($this->lastDelete)) {
                 $deletetime = $this->lastDelete->log_timestamp;
                 if ($deletetime - $this->starttime > 0) {
                     $this->deletedSinceEdit = true;
                 }
             }
         }
     }
     # Show applicable editing introductions
     if ($this->formtype == 'initial' || $this->firsttime) {
         $this->showIntro();
     }
     if ($this->mTitle->isTalkPage()) {
         $wgOut->addWikiMsg('talkpagetext');
     }
     # Attempt submission here.  This will check for edit conflicts,
     # and redundantly check for locked database, blocked IPs, etc.
     # that edit() already checked just in case someone tries to sneak
     # in the back door with a hand-edited submission URL.
     // set up commit transaction
     // $dbw = wfGetDB( DB_MASTER );
     // $dbw->begin();
     if ('save' == $this->formtype) {
         if (!$this->attemptSave()) {
             wfProfileOut("{$fname}-business-end");
             wfProfileOut($fname);
             return;
         }
     }
     // $dbw->commit();
     # First time through: get contents, set time for conflict
     # checking, etc.
     if ('initial' == $this->formtype || $this->firsttime) {
         if ($this->initialiseForm() === false) {
             $this->noSuchSectionPage();
             wfProfileOut("{$fname}-business-end");
             wfProfileOut($fname);
             return;
         }
         if (!$this->mTitle->getArticleId()) {
             wfRunHooks('EditFormPreloadText', array(&$this->textbox1, &$this->mTitle));
         }
     }
     $this->showEditForm();
     wfProfileOut("{$fname}-business-end");
     wfProfileOut($fname);
 }