From 54148e5f2bbf3bd6698120fe69814954ee4becab Mon Sep 17 00:00:00 2001 From: Git Date: Fri, 21 Jun 2013 08:00:44 +0000 Subject: [PATCH] Empty commit --- classes/text.class.php | 110 ++++++++++++++++++++--------------------- gazelle.sql | 46 +++++++++++++++++ sphinx.conf | 73 ++++++++++++++++----------- 3 files changed, 144 insertions(+), 85 deletions(-) diff --git a/classes/text.class.php b/classes/text.class.php index 8cfcaf8c..052ed83d 100644 --- a/classes/text.class.php +++ b/classes/text.class.php @@ -604,38 +604,38 @@ private function to_html ($Array) { $Str = ''; foreach ($Array as $Block) { if (is_string($Block)) { - $Str.=$this->smileys($Block); + $Str .= $this->smileys($Block); continue; } if ($this->Levels < $this->MaximumNests) { switch ($Block['Type']) { case 'b': - $Str.=''.$this->to_html($Block['Val']).''; + $Str .= ''.$this->to_html($Block['Val']).''; break; case 'u': - $Str.=''.$this->to_html($Block['Val']).''; + $Str .= ''.$this->to_html($Block['Val']).''; break; case 'i': - $Str.=''.$this->to_html($Block['Val']).""; + $Str .= ''.$this->to_html($Block['Val']).""; break; case 's': - $Str.=''.$this->to_html($Block['Val']).''; + $Str .= ''.$this->to_html($Block['Val']).''; break; case 'important': - $Str.=''.$this->to_html($Block['Val']).''; + $Str .= ''.$this->to_html($Block['Val']).''; break; case 'user': - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; break; case 'artist': - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; break; case 'rule': $Rule = trim(strtolower($Block['Val'])); if ($Rule[0] != 'r' && $Rule[0] != 'h') { $Rule = 'r'.$Rule; } - $Str.=''.preg_replace('/[aA-zZ]/', '', $Block['Val']).''; + $Str .= ''.preg_replace('/[aA-zZ]/', '', $Block['Val']).''; break; case 'torrent': $Pattern = '/('.NONSSL_SITE_URL.'\/torrents\.php.*[\?&]id=)?(\d+)($|&|\#).*/i'; @@ -655,43 +655,43 @@ private function to_html ($Array) { } break; case 'wiki': - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; break; case 'tex': - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; break; case 'plain': - $Str.=$Block['Val']; + $Str .= $Block['Val']; break; case 'pre': - $Str.='
'.$Block['Val'].'
'; + $Str .= '
'.$Block['Val'].'
'; break; case 'code': - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; break; case 'list': - $Str.='<'.$Block['ListType'].'>'; + $Str .= '<'.$Block['ListType'].'>'; foreach ($Block['Val'] as $Line) { - $Str.='
  • '.$this->to_html($Line).'
  • '; + $Str .= '
  • '.$this->to_html($Line).'
  • '; } - $Str.=''; + $Str .= ''; break; case 'align': $ValidAttribs = array('left', 'center', 'right'); if (!in_array($Block['Attr'], $ValidAttribs)) { - $Str.='[align='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/align]'; + $Str .= '[align='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/align]'; } else { - $Str.='
    '.$this->to_html($Block['Val']).'
    '; + $Str .= '
    '.$this->to_html($Block['Val']).'
    '; } break; case 'color': case 'colour': $ValidAttribs = array('aqua', 'black', 'blue', 'fuchsia', 'green', 'grey', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow'); if (!in_array($Block['Attr'], $ValidAttribs) && !preg_match('/^#[0-9a-f]{6}$/', $Block['Attr'])) { - $Str.='[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]'; + $Str .= '[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]'; } else { - $Str.=''.$this->to_html($Block['Val']).''; + $Str .= ''.$this->to_html($Block['Val']).''; } break; case 'headline': @@ -713,81 +713,81 @@ private function to_html ($Array) { case 'size': $ValidAttribs = array('1','2','3','4','5','6','7','8','9','10'); if (!in_array($Block['Attr'], $ValidAttribs)) { - $Str.='[size='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/size]'; + $Str .= '[size='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/size]'; } else { - $Str.=''.$this->to_html($Block['Val']).''; + $Str .= ''.$this->to_html($Block['Val']).''; } break; case 'quote': $this->NoImg++; // No images inside quote tags $this->InQuotes++; if ($this->InQuotes == $this->NestsBeforeHide) { //Put quotes that are nested beyond the specified limit in [hide] tags. - $Str.='Older quotes: Show'; - $Str.='
    '; // Ensure new line after quote train hiding } $this->NoImg--; $this->InQuotes--; break; case 'hide': - $Str.=''.(($Block['Attr']) ? $Block['Attr'] : 'Hidden text').': Show'; - $Str.=''; + $Str .= ''.(($Block['Attr']) ? $Block['Attr'] : 'Hidden text').': Show'; + $Str .= ''; break; case 'mature': global $LoggedUser; if ($LoggedUser['EnableMatureContent']) { if (!empty($Block['Attr'])) { - $Str.='Mature content: ' . $Block['Attr'] . '
    Show'; - $Str.=''; + $Str .= 'Mature content: ' . $Block['Attr'] . '
    Show'; + $Str .= ''; } else { - $Str.='Use of the [mature] tag requires a description. The correct format is as follows: [mature=description] ...content... [/mature], where "description" is a mandatory description of the post. Misleading descriptions will be penalized. For further information on our mature content policies, please refer to this wiki.'; + $Str .= 'Use of the [mature] tag requires a description. The correct format is as follows: [mature=description] ...content... [/mature], where "description" is a mandatory description of the post. Misleading descriptions will be penalized. For further information on our mature content policies, please refer to this wiki.'; } } else { - $Str.='Mature content has been blocked. You can choose to view mature content by editing your settings.'; + $Str .= 'Mature content has been blocked. You can choose to view mature content by editing your settings.'; } break; case 'img': if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) { - $Str.=''.$Block['Val'].' (image)'; + $Str .= ''.$Block['Val'].' (image)'; break; } if (!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) { - $Str.='[img]'.$Block['Val'].'[/img]'; + $Str .= '[img]'.$Block['Val'].'[/img]'; } else { $LocalURL = $this->local_url($Block['Val']); if ($LocalURL) { - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; } else { - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; } } break; case 'aud': if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) { - $Str.=''.$Block['Val'].' (audio)'; + $Str .= ''.$Block['Val'].' (audio)'; break; } if (!$this->valid_url($Block['Val'], '\.(mp3|ogg|wav)')) { - $Str.='[aud]'.$Block['Val'].'[/aud]'; + $Str .= '[aud]'.$Block['Val'].'[/aud]'; } else { //TODO: Proxy this for staff? - $Str.=''; + $Str .= ''; } break; @@ -802,14 +802,14 @@ private function to_html ($Array) { } if (!$this->valid_url($Block['Attr'])) { - $Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]'; + $Str .= '[url='.$Block['Attr'].']'.$Block['Val'].'[/url]'; } else { $LocalURL = $this->local_url($Block['Attr']); if ($LocalURL) { if ($NoName) { $Block['Val'] = substr($LocalURL,1); } - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; } else { - $Str.=''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; } } break; @@ -818,15 +818,15 @@ private function to_html ($Array) { if (!$this->valid_url($Block['Attr'], '', true)) { $Array = $this->parse($Block['Attr']); $Block['Attr'] = $Array; - $Str.=$this->to_html($Block['Attr']); + $Str .= $this->to_html($Block['Attr']); } else { $LocalURL = $this->local_url($Block['Attr']); if ($LocalURL) { - $Str.=''.substr($LocalURL,1).''; + $Str .= ''.substr($LocalURL,1).''; } else { - $Str.=''.$Block['Attr'].''; + $Str .= ''.$Block['Attr'].''; } } @@ -843,7 +843,7 @@ private function raw_text ($Array) { $Str = ''; foreach ($Array as $Block) { if (is_string($Block)) { - $Str.=$Block; + $Str .= $Block; continue; } switch ($Block['Type']) { @@ -858,7 +858,7 @@ private function raw_text ($Array) { case 'quote': case 'align': - $Str.=$this->raw_text($Block['Val']); + $Str .= $this->raw_text($Block['Val']); break; case 'tex': //since this will never strip cleanly, just remove it break; @@ -869,11 +869,11 @@ private function raw_text ($Array) { case 'code': case 'aud': case 'img': - $Str.=$Block['Val']; + $Str .= $Block['Val']; break; case 'list': foreach ($Block['Val'] as $Line) { - $Str.=$Block['Tag'].$this->raw_text($Line); + $Str .= $Block['Tag'].$this->raw_text($Line); } break; @@ -885,17 +885,17 @@ private function raw_text ($Array) { $Block['Val'] = $this->raw_text($Block['Val']); } - $Str.=$Block['Val']; + $Str .= $Block['Val']; break; case 'inlineurl': if (!$this->valid_url($Block['Attr'], '', true)) { $Array = $this->parse($Block['Attr']); $Block['Attr'] = $Array; - $Str.=$this->raw_text($Block['Attr']); + $Str .= $this->raw_text($Block['Attr']); } else { - $Str.=$Block['Attr']; + $Str .= $Block['Attr']; } break; diff --git a/gazelle.sql b/gazelle.sql index 40abb598..1fda58d3 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -723,6 +723,12 @@ CREATE TABLE `schedule` ( `NextBiWeekly` int(2) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +CREATE TABLE `sphinx_a` ( + `gid` int(11) DEFAULT NULL, + `aname` text CHARACTER SET utf8 COLLATE utf8_bin, + KEY `gid` (`gid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; + CREATE TABLE `sphinx_delta` ( `ID` int(10) NOT NULL, `GroupID` int(11) NOT NULL DEFAULT '0', @@ -862,6 +868,46 @@ CREATE TABLE `sphinx_requests_delta` ( KEY `LastVote` (`LastVote`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `sphinx_t` ( + `id` int(11) NOT NULL, + `gid` int(11) NOT NULL, + `uid` int(11) NOT NULL, + `size` bigint(20) DEFAULT NULL, + `snatched` int(11) DEFAULT NULL, + `seeders` int(11) DEFAULT NULL, + `leechers` int(11) DEFAULT NULL, + `time` int(11) DEFAULT NULL, + `logscore` smallint(6) DEFAULT NULL, + `scene` tinyint(4) DEFAULT NULL, + `haslog` tinyint(4) DEFAULT NULL, + `hascue` tinyint(4) DEFAULT NULL, + `freetorrent` tinyint(4) DEFAULT NULL, + `media` varchar(15) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `format` varchar(15) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `encoding` varchar(30) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `remyear` smallint(6) DEFAULT NULL, + `remtitle` varchar(80) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `remrlabel` varchar(80) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `remcnumber` varchar(80) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `filelist` mediumtext CHARACTER SET utf8 COLLATE utf8_bin, + `remident` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `gid_remident` (`gid`,`remident`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; + +CREATE TABLE `sphinx_tg` ( + `id` int(11) NOT NULL, + `name` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `tags` varchar(500) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `year` smallint(6) DEFAULT NULL, + `rlabel` varchar(80) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `cnumber` varchar(80) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, + `catid` smallint(6) DEFAULT NULL, + `reltype` smallint(6) DEFAULT NULL, + `vanityhouse` tinyint(4) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; + CREATE TABLE `staff_blog` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `UserID` int(10) unsigned NOT NULL, diff --git a/sphinx.conf b/sphinx.conf index a51e5a11..c6874e0b 100644 --- a/sphinx.conf +++ b/sphinx.conf @@ -37,52 +37,34 @@ source torrents : torrents_base { sql_query_pre = set group_concat_max_len = 101400 sql_query_pre = set @starttime = now() - sql_query_pre = create temporary table sphinx_tg \ - (id int primary key, name varchar(300), tags varchar(500), \ - year smallint, rlabel varchar(80), \ - cnumber varchar(80), catid smallint, time int, \ - reltype smallint, vanityhouse tinyint) \ - engine=myisam; - + sql_query_pre = truncate sphinx_tg sql_query_pre = insert into sphinx_tg \ - (id, name, tags, year, rlabel, cnumber, catid, time, reltype, \ + (id, name, tags, year, rlabel, cnumber, catid, reltype, \ vanityhouse) \ select id, name, taglist, year, recordlabel, cataloguenumber, \ categoryid, unix_timestamp(time), releasetype, \ vanityhouse \ from torrents_group \ - where time < @starttime; + where time < @starttime - sql_query_pre = create temporary table sphinx_t \ - (id int primary key, gid int, size bigint, snatched int, \ - seeders int, leechers int, time int, logscore smallint, \ - scene tinyint, haslog tinyint, hascue tinyint, \ - freetorrent tinyint, media varchar(15), \ - format varchar(15), encoding varchar(30), \ - remyear smallint, remtitle varchar(50), \ - remrlabel varchar(50), remcnumber varchar(50), \ - filelist mediumtext, \ - index (gid)) \ - engine=myisam; - + sql_query_pre = truncate sphinx_t sql_query_pre = insert into sphinx_t \ (id, gid, size, snatched, seeders, leechers, time, logscore, scene, \ haslog, hascue, freetorrent, media, format, encoding, \ - remyear, remtitle, remrlabel, remcnumber, filelist) \ - select id, groupid, size, snatched, seeders, leechers, time, \ + remyear, remtitle, remrlabel, remcnumber, filelist, uid, remident) \ + select id, groupid, size, snatched, seeders, leechers, unix_timestamp(time), \ logscore, cast(scene as char), cast(haslog as char), \ cast(hascue as char), cast(freetorrent as char), media, \ format, encoding, remasteryear, remastertitle, \ - remasterrecordlabel, remastercataloguenumber, filelist \ + remasterrecordlabel, remastercataloguenumber, filelist, userid, \ + crc32(concat_ws(' ', media, remasteryear, remastertitle, \ + remasterrecordlabel, remastercataloguenumber)) \ from torrents \ - where time < @starttime; + where time < @starttime - sql_query_pre = create temporary table sphinx_a \ - (gid int primary key, aname text) \ - engine=myisam; - + sql_query_pre = truncate sphinx_a sql_query_pre = insert into sphinx_a \ (gid, aname) \ select groupid, group_concat(aa.name separator ' ') \ @@ -90,7 +72,7 @@ source torrents : torrents_base { join artists_alias aa using(aliasid) \ where importance in ('1','3','4','5','6') \ group by ta.groupid \ - order by null; + order by null sql_query = select t.id, g.id groupid, g.name groupname, tags taglist, \ @@ -450,6 +432,37 @@ index log_delta : log { path = /var/data/sphinx/log_delta } +source better_transcode : connect { + sql_attr_uint = logscore + sql_attr_uint = groupid + sql_attr_uint = uploader + + sql_query = select t.id, groupid, logscore, format, encoding, \ + name groupname, tags taglist, year, uploader, remident \ + from (select t.id, gid groupid, uid uploader, remident, \ + if(media='cd',max(t.logscore),100) logscore, \ + group_concat(distinct format separator ' ') \ + format, \ + group_concat(distinct encoding separator ' ') \ + encoding \ + from sphinx_t t \ + where format in ('mp3', 'flac') \ + group by gid, remident) t \ + join sphinx_tg g on g.id = groupid \ + where catid = 1 + + sql_joined_field = artistname from query; \ + select t.id, aname \ + from sphinx_a \ + join sphinx_t t using(gid) \ + order by t.id asc +} +index better_transcode : torrents { + source = better_transcode + path = /var/data/sphinx/better_transcode + phrase_boundary = +} + indexer { mem_limit = 64M }