r39369 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39368‎ | r39369 | r39370 >
Date:22:11, 14 August 2008
Author:dale
Status:old
Tags:
Comment:
escaped output values, database refactoring to use mediaWiki db_wrappers, style updates
Modified paths:
  • /branches/MetavidWiki-exp/MetavidWiki/RELEASE (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Image.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_ImageGallery.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_MagicWords.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_MetavidInterface/MV_EditPageAjax.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_MetavidInterface/MV_MetavidInterface.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_MetavidInterface/MV_Overlay.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_ParserCache.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Settings.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Stream.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_StreamFile.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_StreamImage.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Title.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMVAdmin.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/maintenance/tv2mvWiki/README (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/util/MV_OggSplit.php (modified) (history)

Diff [purge]

Index: branches/MetavidWiki-exp/MetavidWiki/RELEASE
@@ -1,10 +1,38 @@
2 -version beta 02
3 -changes in this release:
 2+version beta 1.0rc1
 3+changes features of this release:
44
55
6 -mv_embed
 6+= Metavid 1.0rc1 Release Summary =
77
 8+== Unified Search ==
 9+* new unified search model groups and agrgates relavent semantic metadata per search
 10+* advanced search improvments
811
 12+== Mv_embed ==
 13+* support stream selection, supports flash stream type (Summer of code Sstudent *stjepan*)
 14+* flash media server added for serving portions of flvs to arbitrary clients. (thanks FLV4PHP)
 15+* Also See http://metavid.ucsc.edu/wiki/index.php/Mv_embed
 16+
 17+== JQuery 1.2.6 ==
 18+* updated to latest and greates
 19+* Also see http://docs.jquery.com/Release:jQuery_1.2.6
 20+
 21+== Updated compatibility to latest metavidWiki version *1.13* ==
 22+* Also see http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_13_0RC2/phase3/RELEASE-NOTES
 23+
 24+== Updated Compatibility to latest Semantic MediaWiki 1.2 ==
 25+* faster, lazyloading of all classes, better db structure, + lots more
 26+* Also See http://semantic-mediawiki.org/wiki/SMW_1.2
 27+
 28+== Massive security review (thanks '''tstarling''') ==
 29+* properly escaped all values outputted to browser and database
 30+* proper use of database wrapper functions
 31+* closed some security holes (running older versions of metavid is a bad idea please update now)
 32+
 33+
 34+
 35+==Old Versions==
 36+
937 version: beta 01
1038 First Release of the metavidWiki software (nothing too special just gziped the svn)
1139 see http://metavid.ucsc.edu/wiki/index.php/MetaVidWiki_Features_Overview
Index: branches/MetavidWiki-exp/MetavidWiki/maintenance/tv2mvWiki/README
@@ -1,14 +1,19 @@
2 -This is the latest version of the metavid capture software.
3 -It has been tuned a bit to be more genneraly applicable/scallable
 2+This will eventually host the tools for capturing brodcasted content
 3+and insertting it into a wiki
44
5 -The genneral flow and machine layout is as follows:
 5+presently the script metavid project uses are accesible here:
 6+http://slugforge.cse.ucsc.edu/gf/project/metavid/
 7+but I don't recomend using them not genneraly applicable.
 8+
 9+
 10+
 11+The genneral flow and machine layout should be as follows:
612 note: obvisuly your layout may differ and adjustments may be needed.
713
814 dependencies:
915 metavidWiki
1016 ffmpeg2theora
11 - icecast
12 -
 17+ icecast
1318 ~Video for Linux~ compatible capture hardware
1419
1520
@@ -47,6 +52,5 @@
4853 mediaWiki_demon.php
4954
5055
51 -
5256 ===http capture admin===
5357 (can be run on any server)
\ No newline at end of file
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -6,7 +6,7 @@
77 * for more info visit http:/metavid.ucsc.edu/code
88 *
99 */
10 -define('MV_VERSION','0.1 (pre alpha)');
 10+define('MV_VERSION','1.0rc1 (pre alpha)');
1111
1212
1313 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
@@ -155,8 +155,8 @@
156156 $wgSpecialPages['MediaSearch'] = array('MediaSearch');
157157 $wgSpecialPages['MV_SpecialSearch'] = array('MV_SpecialSearch');
158158
159 - $wgAutoloadClasses['MV_SpecialMVAdmin'] = dirname(__FILE__) .'/specials/MV_SpecialMVAdmin.php';
160 - $wgSpecialPages['MV_SpecialMVAdmin'] = array('MV_SpecialMVAdmin');
 159+ $wgAutoloadClasses['MVAdmin'] = dirname(__FILE__) .'/specials/MV_SpecialMVAdmin.php';
 160+ $wgSpecialPages['MVAdmin'] = array('MV_SpecialMVAdmin');
161161 //require_once( dirname(__FILE__) . '/specials/MV_SpecialCRUDStream.php');
162162 //require_once( dirname(__FILE__) . '/specials/MV_SpecialListStreams.php');
163163 //require_once( dirname(__FILE__) . '/specials/MV_SpecialExport.php');
@@ -228,7 +228,7 @@
229229 $mvgScriptPath = htmlspecialchars( $mvgScriptPath );
230230 $wgJsMimeType = htmlspecialchars( $wgJsMimeType) ;
231231 /* (moved to on_dom ready) but here as well*/
232 - $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/jquery/jquery-1.2.1.js\"></script>");
 232+ $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/jquery/jquery-1.2.6.min.js\"></script>");
233233 $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/jquery/plugins/jquery.autocomplete.js\"></script>");
234234 $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/jquery/plugins/jquery.hoverIntent.js\"></script>");
235235
@@ -266,15 +266,6 @@
267267 $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/mv_embed.js\"></script>");
268268 }
269269 }
270 - if($head_set=='search' || $head_set=='sequence'){
271 - //get jquery and autocomplete for seq/search
272 - //already included for all pages to support autoComplete
273 - if(!($mvEnableAutoComplete || $mvEnableJSLinkBack ||$mvEnableJSMVDrewrite) ){
274 - $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/jquery/jquery-1.2.1.js\"></script>");
275 - $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/jquery/plugins/jquery.autocomplete.js\"></script>");
276 - $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_embed/jquery/plugins/jquery.hoverIntent.js\"></script>");
277 - }
278 - }
279270
280271 if($head_set=='search')
281272 $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/mv_search.js\"></script>");
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Stream.php
@@ -12,7 +12,6 @@
1313 *
1414 */
1515 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
16 -/*the format to extension mapping*/
1716
1817 /* handles metavid stream config and updates mv_stream table*/
1918 class MV_Stream {
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_StreamFile.php
@@ -14,7 +14,6 @@
1515 * MvStreamFile handles the mapping of path types to urls &
1616 * active record style management of the mv_stream_files table
1717 */
18 -
1918 class MV_StreamFile{
2019 var $stream_id='';
2120 var $base_offset='';//base offset from the stream date_start_time
@@ -70,10 +69,9 @@
7170 $dbw->delete($mvStreamFilesTable, array('id'=>$this->id));
7271 }
7372 function writeStreamFileDB(){
74 - global $mvStreamFilesTable;
7573 $dbw = & wfGetDB(DB_WRITE);
7674 if($this->id==''){
77 - $dbw->insert($mvStreamFilesTable, array(
 75+ $dbw->insert('mv_stream_files', array(
7876 'stream_id'=>$this->stream_id,
7977 'base_offset'=>$this->base_offset,
8078 'duration'=>$this->duration,
@@ -83,7 +81,7 @@
8482 ), __METHOD__);
8583 }else{
8684 //update:
87 - $dbw->update($mvStreamFilesTable, array(
 85+ $dbw->update('mv_stream_files', array(
8886 'base_offset'=>$this->base_offset,
8987 'duration'=>$this->duration,
9088 'file_desc_msg'=>$this->file_desc_msg,
@@ -93,10 +91,10 @@
9492 }
9593 }
9694 function getStreamFileDB($quality=null){
97 - global $mvDefaultVideoQualityKey, $mvStreamFilesTable;
 95+ global $mvDefaultVideoQualityKey;
9896 if($quality==null)$quality=$mvDefaultVideoQualityKey;
9997 $dbr = & wfGetDB(DB_READ);
100 - $result = $dbr->select($dbr->tableName($mvStreamFilesTable), array('path'), array (
 98+ $result = $dbr->select('mv_stream_files', array('path'), array (
10199 'stream_id' => $this->_parent_stream->getStreamId(),
102100 'file_desc_msg'=>$quality
103101 ));
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_StreamImage.php
@@ -14,17 +14,7 @@
1515
1616 //two modes -stand alone- and -mediaWiki-
1717
18 -if ( !defined( 'MEDIAWIKI' ) ){
19 - die('not an entry point');
20 - //*stand alone mode*
21 - //need to setup db connection, etc grab the LocalSettings.php
22 - //include_once('../')
23 -
24 - //get config values etc
25 - //start object and serv image:
26 - //$MV_OggImage = new MV_OggImage(array('mode'=>'stand_alone'));
27 - //$MV_OggImage->doManuallRequest();
28 -}
 18+if ( !defined( 'MEDIAWIKI' ) )die('not an entry point');
2919
3020 //serves up images and does necessary transforms if the file does not exist
3121 //@@TODO in the future it would be ideal if it was integrated similar to oggHandler
@@ -57,7 +47,9 @@
5848
5949 //by default return a non-direct link so that javascript can modify the url to get new images
6050 if(!$directLink){
61 - return $wgScript.'?action=ajax&rs=mv_frame_server&stream_id='.$stream_id.'&t='.$req_time.$req_size_out;
 51+ return $wgScript.'?action=ajax&rs=mv_frame_server&stream_id=' .
 52+ htmlspecialchars($stream_id) .
 53+ '&t=' . htmlspecialchars($req_time) . htmlspecialchars($req_size_out);
6254 }
6355 $req_time = MV_StreamImage::procRequestTime($stream_id, $req_time);
6456 if($req_time==false){
@@ -73,8 +65,8 @@
7466 list($im_width, $im_height, $ext) = MV_StreamImage::getSizeType($req_size);
7567 $s='_'.$im_width.'x'.$im_height;
7668 }
77 - return $mvWebImgLoc .'/'. MV_StreamImage::getRelativeImagePath($stream_id) .
78 - '/'.$req_time.$s.'.'.$ext;
 69+ return htmlspecialchars($mvWebImgLoc) .'/'. MV_StreamImage::getRelativeImagePath($stream_id) .
 70+ '/'.htmlspecialchars($req_time).htmlspecialchars($s) . '.' . htmlspecialchars($ext);
7971 }else{
8072 //throw 'error finding image';
8173 return MV_StreamImage::getMissingImageURL($req_size);
@@ -88,7 +80,7 @@
8981 if($req_size)$s='_'.$im_width.'x'.$im_height;
9082
9183 if(MV_StreamImage::getMissingImagePath($req_size, $s, $ext) ){
92 - return $mvWebImgLoc .'/images_not_available'.$s.'.'.$ext;
 84+ return htmlspecialchars($mvWebImgLoc) .'/images_not_available'.$s.'.'.$ext;
9385 }
9486 }
9587 function getMissingImagePath($req_size){
@@ -98,15 +90,16 @@
9991 if($req_size)$s='_'.$im_width.'x'.$im_height;
10092
10193 if(is_file($mvLocalImgLoc.'/images_not_available'.$s.'.'.$ext)){
102 - return $mvLocalImgLoc.'/images_not_available'.$s.'.'.$ext;
 94+ return htmlspecialchars($mvLocalImgLoc) .
 95+ '/images_not_available' . htmlspecialchars($s) . '.' . htmlspecialchars($ext);
10396 }else{
10497 //try and generate it;
10598 if(!MV_StreamImage::doTransformImage($mvLocalImgLoc.'/images_not_available.jpg',
10699 $mvLocalImgLoc.'/images_not_available'.$s.'.'.$ext,
107100 $im_width, $im_height, $ext)){
108 - return $mvLocalImgLoc.'/images_not_available.jpg';
 101+ return htmlspecialchars($mvLocalImgLoc).'/images_not_available.jpg';
109102 }else{
110 - return $mvLocalImgLoc.'/images_not_available'.$s.'.'.$ext;
 103+ return htmlspecialchars($mvLocalImgLoc).'/images_not_available'.htmlspecialchars($s).'.'.htmlspecialchars($ext);
111104 }
112105 }
113106 }
@@ -131,7 +124,7 @@
132125 }
133126 }
134127 function procRequestTime($stream_id, $req_time){
135 - global $mvStreamImageTable, $mvShellOggFrameGrab, $mvImageGranularityRate;
 128+ global $mvShellOggFrameGrab, $mvImageGranularityRate;
136129 if(!$req_time)$req_time='0';
137130 if(count(explode(":",$req_time))==3){
138131 $req_time = ntp2seconds($req_time);
@@ -143,13 +136,17 @@
144137 //query the image db to find the closest to req time (while still being in front)
145138 $dbr = & wfGetDB(DB_READ);
146139 //if($req_time<$mvImageGranularityRate)$req_time = $mvImageGranularityRate;
147 - $select = " `id`, `time`, `time`-'$req_time' as distance ";
148 - $cond = " `stream_id`=$stream_id
 140+ $vars = " `id`, `time`, `time`-'$req_time' as distance ";
 141+ $conds = " `stream_id`=".mysql_real_escape_string($stream_id)
149142 AND (`time`-'$req_time')>=0
150 - AND (`time`-'$req_time')<= $mvImageGranularityRate";
 143+ AND (`time`-'$req_time')<= mysql_real_escape_string($mvImageGranularityRate);
151144 $opt['ORDER BY']=' `distance` ASC ';
152145 $opt['LIMIT']=1;
153 - $res = $dbr->select($mvStreamImageTable, $select, $cond, 'MV_StreamImage::procRequestTime', $opt);
 146+ $res = $dbr->select('mv_stream_images',
 147+ $vars,
 148+ $conds,
 149+ __METHOD__,
 150+ $opt);
154151 //print $dbr->lastQuery();
155152 //die;
156153 if($dbr->numRows($res)==0){
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_MagicWords.php
@@ -12,6 +12,7 @@
1313 * magic words has all parser rewrite keys functions
1414 * format is {{#mvData:magicTypeKey|format=format|num_results=#}} etc
1515 */
 16+if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
1617 class MV_MagicWords{
1718 var $args = array();
1819
@@ -92,12 +93,16 @@
9394 //gets the top few clip ranges
9495 function getTopClips(){
9596 $dbr = & wfGetDB(DB_READ);
96 - $result = $dbr->select('mv_clipview_digest', '`query_key`,`stream_id`,`start_time`, `end_time`, COUNT(1) as `hit_count`',
97 - 'view_date >=\''.$this->getStartTime().'\'',
98 - __METHOD__,
99 - array('GROUP BY' => 'query_key', 'ORDER BY'=>'`hit_count` ASC',
100 - 'LIMIT'=>($this->params['num_results']))
101 - );
 97+ $vars = array('query_key','stream_id','start_time','end_time', 'COUNT(1) as hit_count');
 98+ $conds = array('view_date >='.$dbr->addQuotes($this->getStartTime()));
 99+ $options = array('GROUP BY' => 'query_key', 'ORDER BY'=>'`hit_count` ASC',
 100+ 'LIMIT'=>($this->params['num_results']) );
 101+ $result = $dbr->select('mv_clipview_digest',
 102+ $vars,
 103+ $conds,
 104+ __METHOD__,
 105+ $options
 106+ );
102107 if($dbr->numRows($result)==0){
103108 return '';
104109 }else{
@@ -125,7 +130,7 @@
126131 $mvTitle->getTimeDesc().'" src="'.$mvTitle->getStreamImageURL('small').
127132 '"/>',
128133 'tl=1' );
129 -
 134+ $title_span='';
130135 if(isset($mvStream->date_start_time)){
131136 $parts = split('_',$mvStream->getStreamName());
132137 if(count($parts)>=3){
@@ -196,29 +201,50 @@
197202 function getTopSearches(){
198203 $dbr =& wfGetDB(DB_READ);
199204 $o='';
 205+ $options=array();
200206 /*$result = $dbr->select('mv_search_digest', '`query_key`, COUNT(1) as `hit_count`', "`time` >= '$start_time' ",
201207 __METHOD__,
202208 array('GROUP BY' => 'query_key', 'ORDER BY `hit_count` ASC',
203209 'LIMIT 0,'.$this->params['num_results']) );*/
204 - $sql="SELECT `mv_search_digest`.`query_key`, COUNT(1) as `hit_count`, `mv_query_key_lookup`.`filters`
 210+ /*$sql="SELECT `mv_search_digest`.`query_key`, COUNT(1) as `hit_count`, `mv_query_key_lookup`.`filters`
205211 FROM `mv_search_digest`
206212 LEFT JOIN `mv_query_key_lookup` ON (`mv_search_digest`.`query_key` = `mv_query_key_lookup`.`query_key`)
207213 WHERE `time` >= '{$this->getStartTime()}' GROUP BY `mv_search_digest`.`query_key`
208 - LIMIT 0, {$this->params[num_results]}";
209 - $result = $dbr->query($sql);
 214+ LIMIT 0, {$this->params[num_results]}";*/
 215+ //$from_tables
 216+ $vars = array($dbr->tableName('mv_search_digest').'.query_key',
 217+ 'COUNT(1) as `hit_count`',
 218+ $dbr->tableName('mv_query_key_lookup').'.filters');
 219+ $from_tables= $dbr->tableName('mv_search_digest').
 220+ ' LEFT JOIN' . $dbr->tableName('mv_query_key_lookup') .
 221+ ' ON ( '.
 222+ $dbr->tableName('mv_search_digest').'.query_key = ' .
 223+ $dbr->tableName('mv_query_key_lookup').'.query_key '.
 224+ ' ) ';
 225+ $conds = '`time` >= ' . $dbr->addQuotes($this->getStartTime());
 226+
 227+ $options['GROUP BY']=$dbr->tableName('mv_search_digest').'.query_key';
 228+ $options['LIMIT'] = $this->params[num_results];
 229+
 230+ $result = $dbr->select( $from_tables,
 231+ $vars,
 232+ $conds,
 233+ __METHOD__,
 234+ $options);
 235+
210236 if($dbr->numRows($result)==0){
211237 return '';
212238 }else{
213239 //@@todo probably should try to abstract out formating..
214240 //but will need to wait until we have a few more test cases to do a productive abstraction
215241 if($this->params['format']=='ul_list'){
216 - $class_attr=($this->params['class']!='')?' class="'.$this->params['class'].'"':'';
 242+ $class_attr=($this->params['class']!='')?' class="' . htmlspecialchars($this->params['class']) . '"':'';
217243 $o.='<ul'.$class_attr.'>';
218244 }
219245 $mvms=new MV_SpecialMediaSearch();
220246 $sTitle=Title::MakeTitle(NS_SPECIAL, 'MediaSearch');
221247 while($row = $dbr->fetchObject( $result )){
222 - $title_desc = $row->hit_count.' '.wfMsg('mv_date_'.$this->params['time_range']);
 248+ $title_desc = htmlspecialchars($row->hit_count).' '.wfMsg('mv_date_'.$this->params['time_range']);
223249 $mvms->loadFiltersFromSerialized($row->filters);
224250 $o.='<li><a title="'.$title_desc.'" href="'.$sTitle->escapeLocalURL($mvms->get_httpd_filters_query().'&tl=1' ).'">'.
225251 $mvms->getFilterDesc($query_key=true) .
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Settings.php
@@ -1,6 +1,5 @@
22 <?
33 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
4 -//include the default settings:
54 // (this file is depricated update your MV_LocalSettings.php to point to MV_LocalSettings)
65 include_once(dirname(__FILE__) .'/../MV_LocalSettings.php');
76 ?>
\ No newline at end of file
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_ImageGallery.php
@@ -9,6 +9,7 @@
1010 * @email dale@ucsc.edu
1111 * @url http://metavid.ucsc.edu
1212 */
 13+if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
1314 class MV_ImageGallery extends ImageGallery{
1415 private $mAttribs = array();
1516 private $contextTitle = false;
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php
@@ -101,7 +101,7 @@
102102 function getMVDInRange($stream_id, $start_time=null, $end_time=null, $mvd_type='all',$getText=false,$smw_properties='', $limit='200'){
103103 global $mvIndexTableName, $mvDefaultClipLength;
104104 $dbr =& wfGetDB(DB_SLAVE);
105 - //set up select vars:
 105+ //set up select vars:
106106 $conds=$options=$vars=array();
107107 $from_tables ='';
108108 //
@@ -118,12 +118,12 @@
119119 if(!is_array($smw_properties))
120120 $smw_properties = explode(',',$smw_properties);
121121 foreach($smw_properties as $prop_name){
122 - $vars[] = mysql_escape_string($prop_name).'.object_title as '.mysql_escape_string($prop_name);
 122+ $vars[] = mysql_real_escape_string($prop_name).'.object_title as '.mysql_real_escape_string($prop_name);
123123 $from_tables.=' LEFT JOIN '. $dbr->tableName('smw_relations') .
124 - ' as ' . mysql_escape_string($prop_name) .
 124+ ' as ' . mysql_real_escape_string($prop_name) .
125125 ' ON (' . $dbr->tableName('mv_mvd_index') . '.mv_page_id'.
126 - ' = ' . mysql_escape_string($prop_name) . '.subject_id'.
127 - ' AND '. mysql_escape_string($prop_name).'.relation_title'.
 126+ ' = ' . mysql_real_escape_string($prop_name) . '.subject_id'.
 127+ ' AND '. mysql_real_escape_string($prop_name).'.relation_title'.
128128 ' = ' . $dbr->addQuotes($prop_name) . ')';
129129 }
130130 }
@@ -144,9 +144,9 @@
145145
146146 }
147147 if($end_time)
148 - $cond[]='AND start_time <= '. $dbr->addQuotes($end_time);
 148+ $conds[]='start_time <= '. $dbr->addQuotes($end_time);
149149 if($start_time)
150 - $cond[]='AND end_time >= '. $dbr->addQuotes($start_time);
 150+ $conds[]='end_time >= '. $dbr->addQuotes($start_time);
151151
152152 //add in ordering
153153 $options['ORDER BY']= 'start_time ASC';
@@ -158,8 +158,8 @@
159159 $conds,
160160 __METHOD__,
161161 $options);
162 - /*print $dbr->lastQuery();
163 - die;*/
 162+ //print $dbr->lastQuery();
 163+ //die;
164164 //echo $sql;
165165 //$result =& $dbr->query( $sql, 'MV_Index:time_index_query');
166166 return $result;
@@ -249,7 +249,8 @@
250250 $from_tables_top='';
251251 $vars_top= $conds_top= $options_top=array();
252252
253 - $date_range_join = $do_top_range_query = false;
 253+ $do_top_range_query = false;
 254+ $date_range_join=true;
254255
255256 $dbr =& wfGetDB(DB_SLAVE);
256257 //organize the queries (group full-text searches and category/attributes)
@@ -273,6 +274,7 @@
274275
275276 $group_spoken=true;
276277 //$categoryTable = ;
 278+ $valid_filter_count=0;
277279 foreach($filters as $f){
278280 //proocc and or for fulltext:
279281 if(!isset($f['a']))$f['a']='and';
@@ -283,7 +285,9 @@
284286 }
285287 //add to the fulltext query:
286288 switch($f['t']){
287 - case 'spoken_by':
 289+ case 'spoken_by':
 290+ //skip if empty value:
 291+ if(trim($f['v'])=='')continue;
288292 //if we have an OR set prev to OR
289293 if($last_person_aon=='+' && $aon==''){
290294 $ftq=str_replace('+"spoken by', '"spoken by', $ftq);
@@ -292,17 +296,23 @@
293297 //full text based semantic query:
294298 $ftq.=' '.$aon.'"spoken by '. mysql_real_escape_string($f['v']).'" ';
295299 //table based query:
296 - $last_person_aon=$aon;
 300+ $last_person_aon=$aon;
 301+ $valid_filter_count++;
297302 //$conds[]=
298303 break;
299304 case 'match':
 305+ //skip if empty value:
 306+ if(trim($f['v'])=='')continue;
300307 $ftq_match.=$aon.'"'.mysql_real_escape_string($f['v']).'"';
301308 //only need to split out ftq match if spoken by is more than one
302309 if($ftq_match_asql!='')
303 - $ftq_match_asql = $asql;
 310+ $ftq_match_asql = $asql;
 311+ $valid_filter_count++;
304312 break;
305313 //top level queries (sets up time ranges )
306314 case 'category':
 315+ //skip if empty value:
 316+ if(trim($f['v'])=='')continue;
307317 $do_top_range_query=true;
308318 //full text based category query:
309319 $toplq.=' '.$aon.'"category '.mysql_real_escape_string($f['v']).'" ';
@@ -315,6 +325,7 @@
316326 case 'not':$toplq_cat='NOT';break;
317327 }
318328 $toplq_cat.=$dbr->tableName( 'categorylinks').'.cl_to='.$dbr->addQuotes($f['v']);
 329+ $valid_filter_count++;
319330 break;
320331 case 'date_range':
321332 $date_range_join = true;
@@ -323,22 +334,30 @@
324335 list($month, $day, $year) = explode('/',$f['ve']);
325336 $ets = mktime(0,0,0,$month, $day+1, $year); //(the start of the next day)
326337 //add date condtion:
327 - $date_cond = ' '.$asql.'( `mv_streams`.`date_start_time` > '
 338+ //note dissable and or for date range for now: $asql
 339+ $conds[] = ' ( `mv_streams`.`date_start_time` > '
328340 . $dbr->addQuotes($sts) .
329341 ' AND `mv_streams`.`date_start_time` < '. $dbr->addQuotes($ets) .
330 - ') ';
 342+ ') ';
 343+ //print $date_cond;
 344+ $valid_filter_count++;
331345 break;
332 - case 'stream_name':
 346+ case 'stream_name':
 347+ //skip if empty value:
 348+ if(trim($f['v'])=='')continue;
333349 $stream =& mvGetMVStream($f['v']);
334350 //add stream cond
335351 $conds[]=$asql." stream_id = ". $dbr->addQuotes($stream->getStreamId());
 352+ $valid_filter_count++;
336353 break;
337354 case 'smw_property':
338355 //more complicated query work needed
339356 break;
340357 }
341358 }
342 -
 359+ if($valid_filter_count==0){
 360+ return array();
 361+ }
343362 //add the top query to the base query:
344363 $ftq.=$toplq;
345364 $vars = "mv_page_id as id,". $dbr->tableName('mv_mvd_index').'.stream_id,
@@ -389,30 +408,33 @@
390409 //$sql.="WHERE ";
391410 //$sql.=" ( `{$mvIndexTableName}`.`mvd_type`='ht_en' OR `{$mvIndexTableName}`.`mvd_type`='anno_en') AND" ;
392411
393 - //add conditions:
394 - $conds.= ' '.$dbr->tableName('mv_mvd_index') . '.mvd_type = \'ht_en\' '.
395 - ' OR '. $dbr->tableName('mv_mvd_index') . '.mvd_type=\'anno_en\' '.
396 - $date_cond;
 412+ //add conditions to last condition element (cuz we have to manually mannage and or):
 413+
 414+ $conds[count($conds)]= ' '.$dbr->tableName('mv_mvd_index') . '.mvd_type = \'ht_en\' '.
 415+ ' OR '. $dbr->tableName('mv_mvd_index') . '.mvd_type=\'anno_en\' ';
 416+
397417 //limit to ht_en & anno_en (for now) (future allow selection
398 -
 418+ //$conds_inx = (count($conds)==0)?0:count($conds)-1;
399419 $two_part_anor='';
400420 if($group_spoken){
401421 $ftq.=$ftq_match;
402422 }else{
403423 if($ftq_match!=''){
404 - $conds.=$ftq_match_asql.' MATCH ( '. $dbr->tableName( 'searchindex' ).'.si_text )'.
 424+ $conds[].=$ftq_match_asql.' MATCH ( '. $dbr->tableName( 'searchindex' ).'.si_text )'.
405425 ' AGAINST(\''.$ftq_match.'\' IN BOOLEAN MODE) ';
406426 //if($ftq!='')$sql.=' AND ';
407427 }
408428 }
409429 if($ftq!=''){
410 - $conds.=" MATCH ( ".$dbr->tableName( 'searchindex' ).'.si_text ) '.
 430+ $conds[].=" MATCH ( ".$dbr->tableName( 'searchindex' ).'.si_text ) '.
411431 ' AGAINST(\''.$ftq.'\' IN BOOLEAN MODE) ';
412432 }
 433+ //print_r($conds);
 434+ //die;
413435 //date range stuff is SLOW when its the only filter (pulls up matches for everything)
414 - if($snq!='' || $ftq!='' && isset($date_range_andor))
 436+ /*if($snq!='' || $ftq!='' && isset($date_range_andor))
415437 $sql.=$date_range_andor;
416 - $sql.=" $date_range_where ";
 438+ $sql.=" $date_range_where ";*/
417439
418440 switch($this->order){
419441 case 'relevent':
@@ -436,7 +458,7 @@
437459 __METHOD__,
438460 $options);
439461
440 - echo "SQL:".$dbr->lastQuery($result)." \n";
 462+ //echo "SQL:".$dbr->lastQuery($result)." \n";
441463 //die;
442464 //$result = $dbr->query($sql, 'MV_Index:doFiltersQuery_base');
443465
Index: branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMVAdmin.php
@@ -27,11 +27,11 @@
2828
2929 class MVAdmin extends SpecialPage {
3030
31 - /**
 31+ /*
3232 * Constructor
3333 */
3434 public function __construct() {
35 - global $wgMessageCache; ///TODO: should these be messages?
 35+ global $wgMessageCache; ///TODO: should these be messages?
3636 $wgMessageCache->addMessages(array('mvadmin' => 'Admin functions for MetavidWiki'));
3737 parent::__construct('MVAdmin', 'delete');
3838 }
@@ -51,7 +51,8 @@
5252 $wgOut->permissionRequired('delete');
5353 return;
5454 }
55 -
 55+ $wgOut->addHTML('web admin install currently dissabled');
 56+ exit();
5657 $wgOut->setPageTitle(wfMsg('mvadmin'));
5758
5859 /**** Execute actions if any ****/
@@ -112,6 +113,4 @@
113114 $wgOut->addHTML($html);
114115 return true;
115116 }
116 -
117117 }
118 -SpecialPage :: addPage(new MVAdmin());
Index: branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -175,6 +175,7 @@
176176 );
177177 $this->unified_term_search = $term;
178178 //if not doing advanced search we are done
 179+
179180 if (!$this->adv_search)
180181 return;
181182 }
@@ -208,7 +209,10 @@
209210 if ($this->unified_term_search != '')
210211 $this->unified_term_search .= ' ';
211212 $this->unified_term_search .= $f['v'];
 213+ }else if($f['t']=='spoken_by'){
 214+ $this->unified_term_search = $f['v'];
212215 }
 216+
213217 }
214218 }
215219 } else {
@@ -232,8 +236,7 @@
233237 break;
234238 }
235239 }
236 - }
237 - //print "CUR un: " . $this->unified_term_search;
 240+ }
238241 }
239242 function doSearch($log_search=true) {
240243 global $mvEnableSearchDigest, $mvSearchDigestTable;
@@ -435,19 +438,21 @@
436439 //look for people matches max of 3
437440 $first_block = ' first_block';
438441 $matches = 0;
439 - $person_out = MV_SpecialMediaSearch :: auto_complete_person($this->unified_term_search, 3, 'person_html', $matches);
 442+ $person_out_ary=array();
 443+ $person_out = MV_SpecialMediaSearch :: auto_complete_person($this->unified_term_search, 3, 'person_html', $matches, $person_out_ary);
440444 if ($person_out != '' || count($sideBarLinkBucket['person']) != 0) {
441445 //for now don't include({$matches})
442446 $o .= "<div class=\"block{$first_block}\">
443447 <h6>" . wfMsg('mv_people_results') . "</h6>
444448 </div>";
445 - $o .= '<div class="block wide_block">' .
446 - $person_out;
 449+ $o .= '<div class="block wide_block">';
 450+ $o .= $person_out;
447451 if (isset ($sideBarLinkBucket['person'])) {
448452 $pAry = & $sideBarLinkBucket['person'];
449453 arsort($pAry);
450454 $i = 0;
451455 foreach ($pAry as $person_name => $count) {
 456+ if(in_array($person_name,$person_out_ary) )continue;
452457 if ($i == $perSectionCount)
453458 break;
454459 $o .= MV_SpecialMediaSearch :: format_ac_line($person_name, '', '', MV_SpecialMediaSearch :: getPersonImageURL($person_name), $format = 'person_html');
@@ -1061,7 +1066,7 @@
10621067 return $out;
10631068 }
10641069 /*@@todo cache result for given values*/
1065 - function auto_complete_person($val, $result_limit = '5', $format = 'ac_line', & $match_count = '') {
 1070+ function auto_complete_person($val, $result_limit = '5', $format = 'ac_line', & $match_count = '',& $person_ary=array()) {
10661071 $dbr = & wfGetDB(DB_SLAVE);
10671072 $result = $dbr->select('categorylinks', 'cl_sortkey', array (
10681073 'cl_to' => 'Person',
@@ -1076,6 +1081,7 @@
10771082 $out = '';
10781083 while ($row = $dbr->fetchObject($result)) {
10791084 $person_name = $row->cl_sortkey;
 1085+ $person_ary[$person_name]=true;
10801086 //make sure the person page exists:
10811087 $personTitle = Title :: makeTitle(NS_MAIN, $person_name);
10821088 if ($personTitle->exists()) {
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_ParserCache.php
@@ -9,6 +9,7 @@
1010 * @email dale@ucsc.edu
1111 * @url http://metavid.ucsc.edu
1212 */
 13+if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
1314 //quick hack to shift namespace of inline metavid parse cache
1415 //avoids conflicts of inline display with full article display
1516 class MV_ParserCache extends ParserCache{
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Title.php
@@ -274,13 +274,11 @@
275275 * web stream is file_desc_msg as: mv_ogg_low_quality
276276 * $mvDefaultVideoQualityKey in MV_Settings.php
277277 *
278 - * @@todo point to MV_OggSplit (for segmenting the ogg stream)
279 - * (for now using anx)
280278 */
281279 function getWebStreamURL($quality=null){
282280 global $mvStreamFilesTable, $mvVideoArchivePaths, $mvDefaultVideoQualityKey;
283281 //@@todo mediawiki path for media (insted of hard link to $mvVideoArchive)
284 - //@@todo make sure file exisits
 282+ //@@todo make sure file exisits
285283 if(!$quality)$quality=$mvDefaultVideoQualityKey;
286284 $anx_req='';
287285 if( $this->getStartTime()!='' && $this->getEndTime()!=''){
@@ -293,7 +291,10 @@
294292 'stream_id' => $this->mvStream->id,
295293 'file_desc_msg'=>$quality
296294 ));
297 - $streamFile =$dbr->fetchObject($result);
 295+ if( $dbr->numRows($result)==0)return false;
 296+ $streamFile =$dbr->fetchObject($result);
 297+
 298+ //print_r($streamFile);
298299 //make sure we have streamFiles (used to generate the link)
299300 $mvStreamFile = new MV_StreamFile($this->mvStream, $streamFile);
300301 //if link empty return false:
@@ -307,7 +308,8 @@
308309 function getROEURL(){
309310 $roeTitle = Title::newFromText('MvExportStream', NS_SPECIAL);
310311 //add the query:
311 - $query = 'feed_format=roe&stream_name='.$this->getStreamName().'&t='.$this->getTimeRequest();
 312+ $query = 'feed_format=roe&stream_name=' . htmlspecialchars($this->getStreamName()) .
 313+ '&t=' . htmlspecialchars( $this->getTimeRequest() );
312314 return $roeTitle->getFullURL($query) ;
313315 }
314316 function getEmbedVideoHtml($vid_id='', $size='', $force_server='', $autoplay=false){
@@ -320,32 +322,41 @@
321323 }else{
322324 list($vWidth, $vHeight, $na) = MV_StreamImage::getSizeType($size);
323325 }
324 - $vid_id=($vid_id=='')?'':'id="'.$vid_id.'"';
 326+
 327+
325328 $stream_web_url = $this->getWebStreamURL($mvDefaultVideoQualityKey);
326329 //print "lookign for q: $mvDefaultFlashQualityKey ";
327 - $flash_stream_url = $this->getWebStreamURL($mvDefaultFlashQualityKey);
 330+
 331+ //print "FOUND: $flash_stream_url";
328332 $roe_url = $this->getROEURL();
329333 if($stream_web_url){
330334 $o='';
331335 if($this->dispVideoPlayerTime){
332336 $o.='<span id="mv_videoPlayerTime">'.$this->getStartTime().' to '.
333 - $this->getEndTime() .
 337+ htmlspecialchars( $this->getEndTime() ) .
334338 '</span>';
335 - }
336 - $auto_play_attr=($autoplay)?' autoplay="true" ':'';
337 - $o.='<'.$tag.' '.$vid_id.' thumbnail="'.$this->getStreamImageURL($size, null, $force_server).'" '.
 339+ }
 340+ $o.='<'.htmlspecialchars($tag);
 341+ $o.=($vid_id=='')?'':' id="'.htmlspecialchars($vid_id).'" ';
 342+ $o.='thumbnail="'.$this->getStreamImageURL($size, null, $force_server).'" '.
338343 'roe="'.$roe_url.'" '.
339 - 'show_meta_link="false" ' . $auto_play_attr .
340 - 'style="width:'.$vWidth.'px;height:'.$vHeight.'px" '.
 344+ 'show_meta_link="false" ';
 345+ $o.= ($autoplay)?' autoplay="true" ':'';
 346+ $o.='style="width:'.htmlspecialchars($vWidth).'px;height:'.htmlspecialchars($vHeight).'px" '.
341347 'controls="true" embed_link="true" >';
342348
343 - if($stream_web_url!='')
344 - $o.='<source type="'.MV_StreamFile::getTypeForQK($mvDefaultVideoQualityKey).'" src="'.$stream_web_url .'"/>';
 349+ if($stream_web_url)
 350+ $o.='<source type="'.
 351+ htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultVideoQualityKey)) .
 352+ '" src="'.$stream_web_url .'"></source>';
 353+
 354+ $flash_stream_url = $this->getWebStreamURL($mvDefaultFlashQualityKey);
 355+ if($flash_stream_url)
 356+ $o.='<source type="'.
 357+ htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultFlashQualityKey)) .
 358+ '" src="'.$flash_stream_url .'"></source>';
345359
346 - if($flash_stream_url!='')
347 - $o.='<source type="'.MV_StreamFile::getTypeForQK($mvDefaultFlashQualityKey).'" src="'.$flash_stream_url .'"/>';
348 -
349 - $o.='</video>';
 360+ $o.='</video>';
350361 return $o;
351362 }else{
352363 return wfMsg('mv_error_stream_missing');
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Image.php
@@ -11,6 +11,7 @@
1212 *
1313 * extends image to deal give pointers to metavid media
1414 */
 15+if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
1516 class MV_Image extends Image {
1617
1718 }
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_MetavidInterface/MV_MetavidInterface.php
@@ -85,7 +85,7 @@
8686 var mvTitle = \''.htmlspecialchars($this->article->mvTitle->getWikiTitle()).'\';
8787 var mvTracks = \''.htmlspecialchars($this->components['MV_Overlay']->getMVDReqString()). '\';
8888 var mvgScriptPath = \''.htmlspecialchars($mvgScriptPath).'\';
89 - /*]]>*/</script>\n');
 89+ /*]]>*/</script>');
9090
9191 //also add prev next paging
9292 $this->page_header ='<h1 class="videoHeader">'.
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_MetavidInterface/MV_Overlay.php
@@ -154,7 +154,7 @@
155155 }else{
156156 $wgOut->addHTML($content);
157157 }
158 - $wgOut->addHTML("</div>\n");
 158+ $wgOut->addHTML("</div>");
159159 $wgOut->addHTML("</fieldset>");
160160 }
161161 function get_tl_mvd_request($titleKey, $mvd_id){
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_MetavidInterface/MV_EditPageAjax.php
@@ -80,7 +80,7 @@
8181 //output the person selector:
8282 if (!isset ($semantic_data['spoken_by']))$semantic_data['spoken_by'] = '';
8383 $img = mv_get_person_img($semantic_data['spoken_by']);
84 - $wgOut->addHTML('<img id=\"mv_edit_im_'.htmlspecialchars($this->mvd_id).'" style="display: block;margin-left: auto;margin-right: auto;" src="'.htmlspecialchars($img->getURL()).'" width="44">');
 84+ $wgOut->addHTML('<img id="mv_edit_im_'.htmlspecialchars($this->mvd_id).'" style="display: block;margin-left: auto;margin-right: auto;" src="'.htmlspecialchars($img->getURL()).'" width="44">');
8585 $wgOut->addHTML('<input style="font-size:x-small"
8686 value="'.htmlspecialchars($semantic_data['spoken_by']).'"
8787 name="smw_Spoken_By"
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -417,6 +417,7 @@
418418 },
419419 clientSupports: { 'thumbnail' : true },
420420 detect: function() {
 421+ js_log("running detect");
421422 this.players = new mediaPlayers();
422423
423424 // First some browser detection
@@ -1730,16 +1731,18 @@
17311732 if(quick_switch){
17321733 $j('#img_thumb_'+this.id).attr('src', src);
17331734 }else{
 1735+ var _this = this;
17341736 if(this.thumbnail_disp){
17351737 $j('#dc_'+this.id).append('<img src="'+src+'" ' +
17361738 'style="display:none;position:absolute;zindex:2;top:0px;left:0px;" ' +
17371739 'width="'+this.width+'" height="'+this.height+'" '+
17381740 'id = "new_img_thumb_'+this.id+'" />');
17391741 $j('#new_img_thumb_'+this.id).fadeIn("slow", function(){
 1742+ js_log('done fading in: '+src);
17401743 //once faded in remove org and rename new:
1741 - $j('#img_thumb_'+this.id).remove();
1742 - $j('#new_img_thumb_'+this.id).attr('id', 'img_thumb_'+this.id);
1743 - $j('#img_thumb_'+this.id).css('zIndex','1');
 1744+ $j('#img_thumb_'+_this.id).remove();
 1745+ $j('#new_img_thumb_'+_this.id).attr('id', 'img_thumb_'+_this.id);
 1746+ $j('#img_thumb_'+_this.id).css('zindex','1');
17441747 });
17451748 }
17461749 }
@@ -2458,7 +2461,14 @@
24592462 function loadExternalJs(url){
24602463 js_log('load js: '+ url);
24612464 if(window['$j'])
2462 - $j.getScript(url);
 2465+ //have to use direct ajax call insted of $j.getScript()
 2466+ //since you can't send "cache" option to $j.getScript()
 2467+ $j.ajax({
 2468+ type: "GET",
 2469+ url: url,
 2470+ dataType: 'script',
 2471+ cache: true
 2472+ });
24632473 else
24642474 {
24652475 var e = document.createElement("script");
Index: branches/MetavidWiki-exp/MetavidWiki/util/MV_OggSplit.php
@@ -1,4 +1,5 @@
22 <?php
 3+ if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
34 /**
45 * MV_OggSplit.php
56 *

Status & tagging log