コード例 #1
0
 function processUpload()
 {
     global $wgUser, $wgOut, $wgFileExtensions;
     $details = null;
     $value = null;
     $value = $this->internalProcessUpload($details);
     switch ($value) {
         case self::SUCCESS:
             // don't... do... REDIRECT
             return;
         case self::BEFORE_PROCESSING:
             return false;
         case self::LARGE_FILE_SERVER:
             return wfMsg('largefileserver');
         case self::EMPTY_FILE:
             return wfMsg('emptyfile');
         case self::MIN_LENGTH_PARTNAME:
             return wfMsg('minlength1');
             return;
         case self::ILLEGAL_FILENAME:
             $filtered = $details['filtered'];
             return wfMsg('illegalfilename', $filtered);
         case self::PROTECTED_PAGE:
             return wfMsg('protectedpage');
         case self::OVERWRITE_EXISTING_FILE:
             $errorText = $details['overwrite'];
             $overwrite = new WikiError($wgOut->parse($errorText));
             return $overwrite->toString();
         case self::FILETYPE_MISSING:
             return wfMsg('filetype-missing');
         case self::FILETYPE_BADTYPE:
             $finalExt = $details['finalExt'];
             return wfMsg('filetype-badtype');
         case self::VERIFICATION_ERROR:
             $veri = $details['veri'];
             return $veri->toString();
         case self::UPLOAD_VERIFICATION_ERROR:
             $error = $details['error'];
             return $error;
         case self::UPLOAD_WARNING:
             $warning = $details['warning'];
             return $warning;
     }
     throw new MWException(__METHOD__ . ": Unknown value `{$value}`");
 }
コード例 #2
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}`");
     }
 }
コード例 #3
0
 /**
  * Do the upload
  * Checks are made in SpecialUpload::execute()
  *
  * @access private
  */
 function processUpload()
 {
     global $wgUser, $wgOut, $wgFileExtensions;
     $details = null;
     $value = null;
     $value = $this->internalProcessUpload($details);
     switch ($value) {
         case self::SUCCESS:
             $wgOut->redirect($this->mLocalFile->getTitle()->getFullURL());
             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;
         default:
             throw new MWException(__METHOD__ . ": Unknown value `{$value}`");
     }
 }