diff --git a/Changelog b/Changelog index 8c39add6a..99fdfe13c 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2016-05-10 DariusIII + * Chg: Rename releaseid to releases_id * Upd: Remove unused scripts, update mysqltuner.pl * Chg: Rename bookinfoid to bookinfo_id, consoleinfoid to consoleinfo_id and pre_id to predb_id * Chg: Rename musicinfoid to musicinfo_id diff --git a/misc/reqscraper/config.dist.php b/misc/reqscraper/config.dist.php deleted file mode 100644 index 6103264b6..000000000 --- a/misc/reqscraper/config.dist.php +++ /dev/null @@ -1,15 +0,0 @@ - -Copyright (c): 1999-2000 ispi, all rights reserved -Version: 1.0 - - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -You may contact the author of Snoopy by e-mail at: -monte@ispi.net - -Or, write to: -Monte Ohrt -CTO, ispi -237 S. 70th suite 220 -Lincoln, NE 68510 - -The latest version of Snoopy can be obtained from: -http://snoopy.sourceforge.com - -*************************************************/ - -class Snoopy -{ - /**** Public variables ****/ - - /* user definable vars */ - - var $host = "www.php.net"; // host name we are connecting to - var $port = 80; // port we are connecting to - var $proxy_host = ""; // proxy host to use - var $proxy_port = ""; // proxy port to use - var $agent = "Snoopy v1.0"; // agent we masquerade as - var $referer = ""; // referer info to pass - var $cookies = []; // array of cookies to pass - // $cookies["username"]="joe"; - var $rawheaders = []; // array of raw headers to send - // $rawheaders["Content-type"]="text/html"; - - var $maxredirs = 5; // http redirection depth maximum. 0 = disallow - var $lastredirectaddr = ""; // contains address of last redirected address - var $offsiteok = true; // allows redirection off-site - var $maxframes = 0; // frame content depth maximum. 0 = disallow - var $expandlinks = true; // expand links to fully qualified URLs. - // this only applies to fetchlinks() - // or submitlinks() - var $passcookies = true; // pass set cookies back through redirects - // NOTE: this currently does not respect - // dates, domains or paths. - - var $user = ""; // user for http authentication - var $pass = ""; // password for http authentication - - // http accept types - var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - - var $results = ""; // where the content is put - - var $error = ""; // error messages sent here - var $response_code = ""; // response code returned from server - var $headers = []; // headers returned from server sent here - var $maxlength = 500000; // max return data length (body) - var $read_timeout = 0; // timeout on read operations, in seconds - // supported only since PHP 4 Beta 4 - // set to 0 to disallow timeouts - var $timed_out = false; // if a read operation timed out - var $status = 0; // http request status - - var $curl_path = "/usr/bin/curl"; - // Snoopy will use cURL for fetching - // SSL content if a full system path to - // the cURL binary is supplied here. - // set to false if you do not have - // cURL installed. See http://curl.haxx.se - // for details on installing cURL. - // Snoopy does *not* use the cURL - // library functions built into php, - // as these functions are not stable - // as of this Snoopy release. - - // send Accept-encoding: gzip? - var $use_gzip = true; - - /**** Private variables ****/ - - var $_maxlinelen = 4096; // max line length (headers) - - var $_httpmethod = "GET"; // default http request method - var $_httpversion = "HTTP/1.0"; // default http request version - var $_submit_method = "POST"; // default submit method - var $_submit_type = "application/x-www-form-urlencoded"; // default submit type - var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type - var $_redirectaddr = false; // will be set if page fetched is a redirect - var $_redirectdepth = 0; // increments on an http redirect - var $_frameurls = []; // frame src urls - var $_framedepth = 0; // increments on frame depth - - var $_isproxy = false; // set if using a proxy server - var $_fp_timeout = 30; // timeout for socket connection - -/*======================================================================*\ - Function: fetch - Purpose: fetch the contents of a web page - (and possibly other protocols in the - future like ftp, nntp, gopher, etc.) - Input: $URI the location of the page to fetch - Output: $this->results the output text from the fetch -\*======================================================================*/ - - function fetch($URI) - { - - //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); - $URI_PARTS = parse_url($URI); - if (!empty($URI_PARTS["user"])) - $this->user = $URI_PARTS["user"]; - if (!empty($URI_PARTS["pass"])) - $this->pass = $URI_PARTS["pass"]; - - switch($URI_PARTS["scheme"]) - { - case "http": - $this->host = $URI_PARTS["host"]; - if(!empty($URI_PARTS["port"])) - $this->port = $URI_PARTS["port"]; - if($this->_connect($fp)) - { - if($this->_isproxy) - { - // using proxy, send entire URI - $this->_httprequest($URI,$fp,$URI,$this->_httpmethod); - } - else - { - $path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : ""); - // no proxy, send only the path - $this->_httprequest($path, $fp, $URI, $this->_httpmethod); - } - - $this->_disconnect($fp); - - if($this->_redirectaddr) - { - /* url was redirected, check if we've hit the max depth */ - if($this->maxredirs > $this->_redirectdepth) - { - // only follow redirect if it's on this site, or offsiteok is true - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) - { - /* follow the redirect */ - $this->_redirectdepth++; - $this->lastredirectaddr=$this->_redirectaddr; - $this->fetch($this->_redirectaddr); - } - } - } - - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) - { - $frameurls = $this->_frameurls; - $this->_frameurls = []; - - while(list(,$frameurl) = each($frameurls)) - { - if($this->_framedepth < $this->maxframes) - { - $this->fetch($frameurl); - $this->_framedepth++; - } - else - break; - } - } - } - else - { - return false; - } - return true; - break; - case "https": - if(!$this->curl_path || (!is_executable($this->curl_path))) { - $this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n"; - return false; - } - $this->host = $URI_PARTS["host"]; - if(!empty($URI_PARTS["port"])) - $this->port = $URI_PARTS["port"]; - if($this->_isproxy) - { - // using proxy, send entire URI - $this->_httpsrequest($URI,$URI,$this->_httpmethod); - } - else - { - $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); - // no proxy, send only the path - $this->_httpsrequest($path, $URI, $this->_httpmethod); - } - - if($this->_redirectaddr) - { - /* url was redirected, check if we've hit the max depth */ - if($this->maxredirs > $this->_redirectdepth) - { - // only follow redirect if it's on this site, or offsiteok is true - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) - { - /* follow the redirect */ - $this->_redirectdepth++; - $this->lastredirectaddr=$this->_redirectaddr; - $this->fetch($this->_redirectaddr); - } - } - } - - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) - { - $frameurls = $this->_frameurls; - $this->_frameurls = []; - - while(list(,$frameurl) = each($frameurls)) - { - if($this->_framedepth < $this->maxframes) - { - $this->fetch($frameurl); - $this->_framedepth++; - } - else - break; - } - } - return true; - break; - default: - // not a valid protocol - $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; - return false; - break; - } - return true; - } - - - -/*======================================================================*\ - Private functions -\*======================================================================*/ - - -/*======================================================================*\ - Function: _striplinks - Purpose: strip the hyperlinks from an html document - Input: $document document to strip. - Output: $match an array of the links -\*======================================================================*/ - - function _striplinks($document) - { - preg_match_all("'<\s*a\s+.*href\s*=\s* # find ]+)) # if quote found, match up to next matching - # quote, otherwise match up to next space - 'isx",$document,$links); - - - // catenate the non-empty matches from the conditional subpattern - - while(list($key,$val) = each($links[2])) - { - if(!empty($val)) - $match[] = $val; - } - - while(list($key,$val) = each($links[3])) - { - if(!empty($val)) - $match[] = $val; - } - - // return the links - return $match; - } - -/*======================================================================*\ - Function: _stripform - Purpose: strip the form elements from an html document - Input: $document document to strip. - Output: $match an array of the links -\*======================================================================*/ - - function _stripform($document) - { - preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); - - // catenate the matches - $match = implode("\r\n",$elements[0]); - - // return the links - return $match; - } - - - -/*======================================================================*\ - Function: _striptext - Purpose: strip the text from an html document - Input: $document document to strip. - Output: $text the resulting text -\*======================================================================*/ - - function _striptext($document) - { - - // I didn't use preg eval (//e) since that is only available in PHP 4.0. - // so, list your entities one by one here. I included some of the - // more common ones. - - $search = array("']*?>.*?'si", // strip out javascript - "'<[\/\!]*?[^<>]*?>'si", // strip out html tags - "'([\r\n])[\s]+'", // strip out white space - "'&(quote|#34);'i", // replace html entities - "'&(amp|#38);'i", - "'&(lt|#60);'i", - "'&(gt|#62);'i", - "'&(nbsp|#160);'i", - "'&(iexcl|#161);'i", - "'&(cent|#162);'i", - "'&(pound|#163);'i", - "'&(copy|#169);'i" - ); - $replace = array( "", - "", - "\\1", - "\"", - "&", - "<", - ">", - " ", - chr(161), - chr(162), - chr(163), - chr(169)); - - $text = preg_replace($search,$replace,$document); - - return $text; - } - -/*======================================================================*\ - Function: _expandlinks - Purpose: expand each link into a fully qualified URL - Input: $links the links to qualify - $URI the full URI to get the base from - Output: $expandedLinks the expanded links -\*======================================================================*/ - - function _expandlinks($links,$URI) - { - - preg_match("/^[^\?]+/",$URI,$match); - - $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); - - $search = array( "|^http://".preg_quote($this->host)."|i", - "|^(?!http://)(\/)?(?!mailto:)|i", - "|/\./|", - "|/[^\/]+/\.\./|" - ); - - $replace = array( "", - $match."/", - "/", - "/" - ); - - $expandedLinks = preg_replace($search,$replace,$links); - - return $expandedLinks; - } - -/*======================================================================*\ - Function: _httprequest - Purpose: go get the http data from the server - Input: $url the url to fetch - $fp the current open file pointer - $URI the full URI - $body body contents to send if any (POST) - Output: -\*======================================================================*/ - - function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") - { - if($this->passcookies && $this->_redirectaddr) - $this->setcookies(); - - $URI_PARTS = parse_url($URI); - if(empty($url)) - $url = "/"; - $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; - if(!empty($this->agent)) - $headers .= "User-Agent: ".$this->agent."\r\n"; - if(!empty($this->host) && !isset($this->rawheaders['Host'])) - $headers .= "Host: ".$this->host."\r\n"; - if(!empty($this->accept)) - $headers .= "Accept: ".$this->accept."\r\n"; - - if($this->use_gzip) { - // make sure PHP was built with --with-zlib - // and we can handle gzipp'ed data - if ( function_exists(gzinflate) ) { - $headers .= "Accept-encoding: gzip\r\n"; - } - else { - trigger_error( - "use_gzip is on, but PHP was built without zlib support.". - " Requesting file(s) without gzip encoding.", - E_USER_NOTICE); - } - } - - if(!empty($this->referer)) - $headers .= "Referer: ".$this->referer."\r\n"; - if(!empty($this->cookies)) - { - if(!is_array($this->cookies)) - $this->cookies = (array)$this->cookies; - - reset($this->cookies); - if ( count($this->cookies) > 0 ) { - $cookie_headers .= 'Cookie: '; - foreach ( $this->cookies as $cookieKey => $cookieVal ) { - $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; - } - $headers .= substr($cookie_headers,0,-2) . "\r\n"; - } - } - if(!empty($this->rawheaders)) - { - if(!is_array($this->rawheaders)) - $this->rawheaders = (array)$this->rawheaders; - while(list($headerKey,$headerVal) = each($this->rawheaders)) - $headers .= $headerKey.": ".$headerVal."\r\n"; - } - if(!empty($content_type)) { - $headers .= "Content-type: $content_type"; - if ($content_type == "multipart/form-data") - $headers .= "; boundary=".$this->_mime_boundary; - $headers .= "\r\n"; - } - if(!empty($body)) - $headers .= "Content-length: ".strlen($body)."\r\n"; - if(!empty($this->user) || !empty($this->pass)) - $headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n"; - - $headers .= "\r\n"; - - // set the read timeout if needed - if ($this->read_timeout > 0) - socket_set_timeout($fp, $this->read_timeout); - $this->timed_out = false; - - fwrite($fp,$headers.$body,strlen($headers.$body)); - - $this->_redirectaddr = false; - unset($this->headers); - - // content was returned gzip encoded? - $is_gzipped = false; - - while($currentHeader = fgets($fp,$this->_maxlinelen)) - { - if ($this->read_timeout > 0 && $this->_check_timeout($fp)) - { - $this->status=-100; - return false; - } - - // if($currentHeader == "\r\n") - if(preg_match("/^\r?\n$/", $currentHeader) ) - break; - - // if a header begins with Location: or URI:, set the redirect - if(preg_match("/^(Location:|URI:)/i",$currentHeader)) - { - // get URL portion of the redirect - preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches); - // look for :// in the Location header to see if hostname is included - if(!preg_match("|\:\/\/|",$matches[2])) - { - // no host in the path, so prepend - $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; - // eliminate double slash - if(!preg_match("|^/|",$matches[2])) - $this->_redirectaddr .= "/".$matches[2]; - else - $this->_redirectaddr .= $matches[2]; - } - else - $this->_redirectaddr = $matches[2]; - } - - if(preg_match("|^HTTP/|",$currentHeader)) - { - if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status)) - { - $this->status= $status[1]; - } - $this->response_code = $currentHeader; - } - - if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) { - $is_gzipped = true; - } - - $this->headers[] = $currentHeader; - } - - # $results = fread($fp, $this->maxlength); - $results = ""; - while ( $data = fread($fp, $this->maxlength) ) { - $results .= $data; - if ( - strlen($results) > $this->maxlength ) { - break; - } - } - - // gunzip - if ( $is_gzipped ) { - // per http://www.php.net/manual/en/function.gzencode.php - $results = substr($results, 10); - $results = gzinflate($results); - } - - if ($this->read_timeout > 0 && $this->_check_timeout($fp)) - { - $this->status=-100; - return false; - } - - // check if there is a a redirect meta tag - - if(preg_match("']*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) - { - $this->_redirectaddr = $this->_expandlinks($match[1],$URI); - } - - // have we hit our frame depth and is there frame src to fetch? - if(($this->_framedepth < $this->maxframes) && preg_match_all("']+)'i",$results,$match)) - { - $this->results[] = $results; - for($x=0; $x_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); - } - // have we already fetched framed content? - elseif(is_array($this->results)) - $this->results[] = $results; - // no framed content - else - $this->results = $results; - - return true; - } - -/*======================================================================*\ - Function: _httpsrequest - Purpose: go get the https data from the server using curl - Input: $url the url to fetch - $URI the full URI - $body body contents to send if any (POST) - Output: -\*======================================================================*/ - - function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") - { - if($this->passcookies && $this->_redirectaddr) - $this->setcookies(); - - $headers = []; - - $URI_PARTS = parse_url($URI); - if(empty($url)) - $url = "/"; - // GET ... header not needed for curl - //$headers[] = $http_method." ".$url." ".$this->_httpversion; - if(!empty($this->agent)) - $headers[] = "User-Agent: ".$this->agent; - if(!empty($this->host)) - $headers[] = "Host: ".$this->host; - if(!empty($this->accept)) - $headers[] = "Accept: ".$this->accept; - if(!empty($this->referer)) - $headers[] = "Referer: ".$this->referer; - if(!empty($this->cookies)) - { - if(!is_array($this->cookies)) - $this->cookies = (array)$this->cookies; - - reset($this->cookies); - if ( count($this->cookies) > 0 ) { - $cookie_str = 'Cookie: '; - foreach ( $this->cookies as $cookieKey => $cookieVal ) { - $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; - } - $headers[] = substr($cookie_str,0,-2); - } - } - if(!empty($this->rawheaders)) - { - if(!is_array($this->rawheaders)) - $this->rawheaders = (array)$this->rawheaders; - while(list($headerKey,$headerVal) = each($this->rawheaders)) - $headers[] = $headerKey.": ".$headerVal; - } - if(!empty($content_type)) { - if ($content_type == "multipart/form-data") - $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; - else - $headers[] = "Content-type: $content_type"; - } - if(!empty($body)) - $headers[] = "Content-length: ".strlen($body); - if(!empty($this->user) || !empty($this->pass)) - $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); - - for($curr_header = 0; $curr_header < count($headers); $curr_header++) { - $cmdline_params .= " -H \"".$headers[$curr_header]."\""; - } - - if(!empty($body)) - $cmdline_params .= " -d \"$body\""; - - if($this->read_timeout > 0) - $cmdline_params .= " -m ".$this->read_timeout; - - $headerfile = uniqid(time()); - - # accept self-signed certs - $cmdline_params .= " -k"; - exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return); - - if($return) - { - $this->error = "Error: cURL could not retrieve the document, error $return."; - return false; - } - - - $results = implode("\r\n",$results); - - $result_headers = file("/tmp/$headerfile"); - - $this->_redirectaddr = false; - unset($this->headers); - - for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) - { - - // if a header begins with Location: or URI:, set the redirect - if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) - { - // get URL portion of the redirect - preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches); - // look for :// in the Location header to see if hostname is included - if(!preg_match("|\:\/\/|",$matches[2])) - { - // no host in the path, so prepend - $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; - // eliminate double slash - if(!preg_match("|^/|",$matches[2])) - $this->_redirectaddr .= "/".$matches[2]; - else - $this->_redirectaddr .= $matches[2]; - } - else - $this->_redirectaddr = $matches[2]; - } - - if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) - { - $this->response_code = $result_headers[$currentHeader]; - if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match)) - { - $this->status= $match[1]; - } - } - $this->headers[] = $result_headers[$currentHeader]; - } - - // check if there is a a redirect meta tag - - if(preg_match("']*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) - { - $this->_redirectaddr = $this->_expandlinks($match[1],$URI); - } - - // have we hit our frame depth and is there frame src to fetch? - if(($this->_framedepth < $this->maxframes) && preg_match_all("']+)'i",$results,$match)) - { - $this->results[] = $results; - for($x=0; $x_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); - } - // have we already fetched framed content? - elseif(is_array($this->results)) - $this->results[] = $results; - // no framed content - else - $this->results = $results; - - unlink("/tmp/$headerfile"); - - return true; - } - -/*======================================================================*\ - Function: setcookies() - Purpose: set cookies for a redirection -\*======================================================================*/ - - function setcookies() - { - for($x=0; $xheaders); $x++) - { - if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match)) - $this->cookies[$match[1]] = $match[2]; - } - } - - -/*======================================================================*\ - Function: _check_timeout - Purpose: checks whether timeout has occurred - Input: $fp file pointer -\*======================================================================*/ - - function _check_timeout($fp) - { - if ($this->read_timeout > 0) { - $fp_status = socket_get_status($fp); - if ($fp_status["timed_out"]) { - $this->timed_out = true; - return true; - } - } - return false; - } - -/*======================================================================*\ - Function: _connect - Purpose: make a socket connection - Input: $fp file pointer -\*======================================================================*/ - - function _connect(&$fp) - { - if(!empty($this->proxy_host) && !empty($this->proxy_port)) - { - $this->_isproxy = true; - $host = $this->proxy_host; - $port = $this->proxy_port; - } - else - { - $host = $this->host; - $port = $this->port; - } - - $this->status = 0; - - if($fp = fsockopen( - $host, - $port, - $errno, - $errstr, - $this->_fp_timeout - )) - { - // socket connection succeeded - - return true; - } - else - { - // socket connection failed - $this->status = $errno; - switch($errno) - { - case -3: - $this->error="socket creation failed (-3)"; - case -4: - $this->error="dns lookup failure (-4)"; - case -5: - $this->error="connection refused or timed out (-5)"; - default: - $this->error="connection failed (".$errno.")"; - } - return false; - } - } -/*======================================================================*\ - Function: _disconnect - Purpose: disconnect a socket connection - Input: $fp file pointer -\*======================================================================*/ - - function _disconnect($fp) - { - return(fclose($fp)); - } - - -/*======================================================================*\ - Function: _prepare_post_body - Purpose: Prepare post body according to encoding type - Input: $formvars - form variables - $formfiles - form upload files - Output: post body -\*======================================================================*/ - - function _prepare_post_body($formvars, $formfiles) - { - settype($formvars, "array"); - settype($formfiles, "array"); - - if (count($formvars) == 0 && count($formfiles) == 0) - return; - - switch ($this->_submit_type) { - case "application/x-www-form-urlencoded": - reset($formvars); - while(list($key,$val) = each($formvars)) { - if (is_array($val) || is_object($val)) { - while (list($cur_key, $cur_val) = each($val)) { - $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; - } - } else - $postdata .= urlencode($key)."=".urlencode($val)."&"; - } - break; - - case "multipart/form-data": - $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); - - reset($formvars); - while(list($key,$val) = each($formvars)) { - if (is_array($val) || is_object($val)) { - while (list($cur_key, $cur_val) = each($val)) { - $postdata .= "--".$this->_mime_boundary."\r\n"; - $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; - $postdata .= "$cur_val\r\n"; - } - } else { - $postdata .= "--".$this->_mime_boundary."\r\n"; - $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; - $postdata .= "$val\r\n"; - } - } - - reset($formfiles); - while (list($field_name, $file_names) = each($formfiles)) { - settype($file_names, "array"); - while (list(, $file_name) = each($file_names)) { - if (!is_readable($file_name)) continue; - - $fp = fopen($file_name, "r"); - $file_content = fread($fp, filesize($file_name)); - fclose($fp); - $base_name = basename($file_name); - - $postdata .= "--".$this->_mime_boundary."\r\n"; - $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; - $postdata .= "$file_content\r\n"; - } - } - $postdata .= "--".$this->_mime_boundary."--\r\n"; - break; - } - - return $postdata; - } -} \ No newline at end of file diff --git a/misc/reqscraper/magpierss/rss_cache.inc b/misc/reqscraper/magpierss/rss_cache.inc deleted file mode 100644 index 7d9726f3b..000000000 --- a/misc/reqscraper/magpierss/rss_cache.inc +++ /dev/null @@ -1,198 +0,0 @@ - - * Version: 0.51 - * License: GPL - * - * The lastest version of MagpieRSS can be obtained from: - * http://magpierss.sourceforge.net - * - * For questions, help, comments, discussion, etc., please join the - * Magpie mailing list: - * http://lists.sourceforge.net/lists/listinfo/magpierss-general - * - */ - -class RSSCache { - var $BASE_CACHE = './cache'; // where the cache files are stored - var $MAX_AGE = 3600; // when are files stale, default one hour - var $ERROR = ""; // accumulate error messages - - function RSSCache ($base='', $age='') { - if ( $base ) { - $this->BASE_CACHE = $base; - } - if ( $age ) { - $this->MAX_AGE = $age; - } - - // attempt to make the cache directory - if ( ! file_exists( $this->BASE_CACHE ) ) { - $status = @mkdir( $this->BASE_CACHE, 0755 ); - - // if make failed - if ( ! $status ) { - $this->error( - "Cache couldn't make dir '" . $this->BASE_CACHE . "'." - ); - } - } - } - -/*=======================================================================*\ - Function: set - Purpose: add an item to the cache, keyed on url - Input: url from wich the rss file was fetched - Output: true on sucess -\*=======================================================================*/ - function set ($url, $rss) { - $this->ERROR = ""; - $cache_file = $this->file_name( $url ); - $fp = @fopen( $cache_file, 'w' ); - - if ( ! $fp ) { - $this->error( - "Cache unable to open file for writing: $cache_file" - ); - return 0; - } - - - $data = $this->serialize( $rss ); - fwrite( $fp, $data ); - fclose( $fp ); - - return $cache_file; - } - -/*=======================================================================*\ - Function: get - Purpose: fetch an item from the cache - Input: url from wich the rss file was fetched - Output: cached object on HIT, false on MISS -\*=======================================================================*/ - function get ($url) { - $this->ERROR = ""; - $cache_file = $this->file_name( $url ); - - if ( ! file_exists( $cache_file ) ) { - $this->debug( - "Cache doesn't contain: $url (cache file: $cache_file)" - ); - return 0; - } - - $fp = @fopen($cache_file, 'r'); - if ( ! $fp ) { - $this->error( - "Failed to open cache file for reading: $cache_file" - ); - return 0; - } - - if ($filesize = filesize($cache_file) ) { - $data = fread( $fp, filesize($cache_file) ); - $rss = $this->unserialize( $data ); - - return $rss; - } - - return 0; - } - -/*=======================================================================*\ - Function: check_cache - Purpose: check a url for membership in the cache - and whether the object is older then MAX_AGE (ie. STALE) - Input: url from wich the rss file was fetched - Output: cached object on HIT, false on MISS -\*=======================================================================*/ - function check_cache ( $url ) { - $this->ERROR = ""; - $filename = $this->file_name( $url ); - - if ( file_exists( $filename ) ) { - // find how long ago the file was added to the cache - // and whether that is longer then MAX_AGE - $mtime = filemtime( $filename ); - $age = time() - $mtime; - if ( $this->MAX_AGE > $age ) { - // object exists and is current - return 'HIT'; - } - else { - // object exists but is old - return 'STALE'; - } - } - else { - // object does not exist - return 'MISS'; - } - } - - function cache_age( $cache_key ) { - $filename = $this->file_name( $url ); - if ( file_exists( $filename ) ) { - $mtime = filemtime( $filename ); - $age = time() - $mtime; - return $age; - } - else { - return -1; - } - } - -/*=======================================================================*\ - Function: serialize -\*=======================================================================*/ - function serialize ( $rss ) { - return serialize( $rss ); - } - -/*=======================================================================*\ - Function: unserialize -\*=======================================================================*/ - function unserialize ( $data ) { - return unserialize( $data ); - } - -/*=======================================================================*\ - Function: file_name - Purpose: map url to location in cache - Input: url from wich the rss file was fetched - Output: a file name -\*=======================================================================*/ - function file_name ($url) { - $filename = md5( $url ); - return join( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) ); - } - -/*=======================================================================*\ - Function: error - Purpose: register error -\*=======================================================================*/ - function error ($errormsg, $lvl=E_USER_WARNING) { - // append PHP's error message if track_errors enabled - if ( isset($php_errormsg) ) { - $errormsg .= " ($php_errormsg)"; - } - $this->ERROR = $errormsg; - if ( MAGPIE_DEBUG ) { - trigger_error( $errormsg, $lvl); - } - else { - error_log( $errormsg, 0); - } - } - - function debug ($debugmsg, $lvl=E_USER_NOTICE) { - if ( MAGPIE_DEBUG ) { - $this->error("MagpieRSS [debug] $debugmsg", $lvl); - } - } - -} diff --git a/misc/reqscraper/magpierss/rss_fetch.inc b/misc/reqscraper/magpierss/rss_fetch.inc deleted file mode 100644 index 3e0cd30c6..000000000 --- a/misc/reqscraper/magpierss/rss_fetch.inc +++ /dev/null @@ -1,456 +0,0 @@ - - * License: GPL - * - * The lastest version of MagpieRSS can be obtained from: - * http://magpierss.sourceforge.net - * - * For questions, help, comments, discussion, etc., please join the - * Magpie mailing list: - * magpierss-general@lists.sourceforge.net - * - */ - -// Setup MAGPIE_DIR for use on hosts that don't include -// the current path in include_path. -// with thanks to rajiv and smarty -if (!defined('DIR_SEP')) { - define('DIR_SEP', DIRECTORY_SEPARATOR); -} - -if (!defined('MAGPIE_DIR')) { - define('MAGPIE_DIR', dirname(__FILE__) . DIR_SEP); -} - -require_once( MAGPIE_DIR . 'rss_parse.inc' ); -require_once( MAGPIE_DIR . 'rss_cache.inc' ); - -// for including 3rd party libraries -define('MAGPIE_EXTLIB', MAGPIE_DIR . 'extlib' . DIR_SEP); -require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc'); - - -/* - * CONSTANTS - redefine these in your script to change the - * behaviour of fetch_rss() currently, most options effect the cache - * - * MAGPIE_CACHE_ON - Should Magpie cache parsed RSS objects? - * For me a built in cache was essential to creating a "PHP-like" - * feel to Magpie, see rss_cache.inc for rationale - * - * - * MAGPIE_CACHE_DIR - Where should Magpie cache parsed RSS objects? - * This should be a location that the webserver can write to. If this - * directory does not already exist Mapie will try to be smart and create - * it. This will often fail for permissions reasons. - * - * - * MAGPIE_CACHE_AGE - How long to store cached RSS objects? In seconds. - * - * - * MAGPIE_CACHE_FRESH_ONLY - If remote fetch fails, throw error - * instead of returning stale object? - * - * MAGPIE_DEBUG - Display debugging notices? - * -*/ - - -/*=======================================================================*\ - Function: fetch_rss: - Purpose: return RSS object for the give url - maintain the cache - Input: url of RSS file - Output: parsed RSS object (see rss_parse.inc) - - NOTES ON CACHEING: - If caching is on (MAGPIE_CACHE_ON) fetch_rss will first check the cache. - - NOTES ON RETRIEVING REMOTE FILES: - If conditional gets are on (MAGPIE_CONDITIONAL_GET_ON) fetch_rss will - return a cached object, and touch the cache object upon recieving a - 304. - - NOTES ON FAILED REQUESTS: - If there is an HTTP error while fetching an RSS object, the cached - version will be return, if it exists (and if MAGPIE_CACHE_FRESH_ONLY is off) -\*=======================================================================*/ - -define('MAGPIE_VERSION', '0.72'); - -$MAGPIE_ERROR = ""; - -function fetch_rss ($url) { - // initialize constants - init(); - - if ( !isset($url) ) { - error("fetch_rss called without a url"); - return false; - } - - // if cache is disabled - if ( !MAGPIE_CACHE_ON ) { - // fetch file, and parse it - $resp = _fetch_remote_file( $url ); - if ( is_success( $resp->status ) ) { - return _response_to_rss( $resp ); - } - else { - error("Failed to fetch $url and cache is off"); - return false; - } - } - // else cache is ON - else { - // Flow - // 1. check cache - // 2. if there is a hit, make sure its fresh - // 3. if cached obj fails freshness check, fetch remote - // 4. if remote fails, return stale object, or error - - $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); - - if (MAGPIE_DEBUG and $cache->ERROR) { - debug($cache->ERROR, E_USER_WARNING); - } - - - $cache_status = 0; // response of check_cache - $request_headers = []; // HTTP headers to send with fetch - $rss = 0; // parsed RSS object - $errormsg = 0; // errors, if any - - // store parsed XML by desired output encoding - // as character munging happens at parse time - $cache_key = $url . MAGPIE_OUTPUT_ENCODING; - - if (!$cache->ERROR) { - // return cache HIT, MISS, or STALE - $cache_status = $cache->check_cache( $cache_key); - } - - // if object cached, and cache is fresh, return cached obj - if ( $cache_status == 'HIT' ) { - $rss = $cache->get( $cache_key ); - if ( isset($rss) and $rss ) { - // should be cache age - $rss->from_cache = 1; - if ( MAGPIE_DEBUG > 1) { - debug("MagpieRSS: Cache HIT", E_USER_NOTICE); - } - return $rss; - } - } - - // else attempt a conditional get - - // setup headers - if ( $cache_status == 'STALE' ) { - $rss = $cache->get( $cache_key ); - if ( $rss and $rss->etag and $rss->last_modified ) { - $request_headers['If-None-Match'] = $rss->etag; - $request_headers['If-Last-Modified'] = $rss->last_modified; - } - } - - $resp = _fetch_remote_file( $url, $request_headers ); - - if (isset($resp) and $resp) { - if ($resp->status == '304' ) { - // we have the most current copy - if ( MAGPIE_DEBUG > 1) { - debug("Got 304 for $url"); - } - // reset cache on 304 (at minutillo insistent prodding) - $cache->set($cache_key, $rss); - return $rss; - } - elseif ( is_success( $resp->status ) ) { - $rss = _response_to_rss( $resp ); - if ( $rss ) { - if (MAGPIE_DEBUG > 1) { - debug("Fetch successful"); - } - // add object to cache - $cache->set( $cache_key, $rss ); - return $rss; - } - } - else { - $errormsg = "Failed to fetch $url "; - if ( $resp->status == '-100' ) { - $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; - } - elseif ( $resp->error ) { - # compensate for Snoopy's annoying habbit to tacking - # on '\n' - $http_error = substr($resp->error, 0, -2); - $errormsg .= "(HTTP Error: $http_error)"; - } - else { - $errormsg .= "(HTTP Response: " . $resp->response_code .')'; - } - } - } - else { - $errormsg = "Unable to retrieve RSS file for unknown reasons."; - } - - // else fetch failed - - // attempt to return cached object - if ($rss) { - if ( MAGPIE_DEBUG ) { - debug("Returning STALE object for $url"); - } - return $rss; - } - - // else we totally failed - error( $errormsg ); - - return false; - - } // end if ( !MAGPIE_CACHE_ON ) { -} // end fetch_rss() - -/*=======================================================================*\ - Function: error - Purpose: set MAGPIE_ERROR, and trigger error -\*=======================================================================*/ - -function error ($errormsg, $lvl=E_USER_WARNING) { - global $MAGPIE_ERROR; - - // append PHP's error message if track_errors enabled - if ( isset($php_errormsg) ) { - $errormsg .= " ($php_errormsg)"; - } - if ( $errormsg ) { - $errormsg = "MagpieRSS: $errormsg"; - $MAGPIE_ERROR = $errormsg; - trigger_error( $errormsg, $lvl); - } -} - -function debug ($debugmsg, $lvl=E_USER_NOTICE) { - trigger_error("MagpieRSS [debug] $debugmsg", $lvl); -} - -/*=======================================================================*\ - Function: magpie_error - Purpose: accessor for the magpie error variable -\*=======================================================================*/ -function magpie_error ($errormsg="") { - global $MAGPIE_ERROR; - - if ( isset($errormsg) and $errormsg ) { - $MAGPIE_ERROR = $errormsg; - } - - return $MAGPIE_ERROR; -} - -/*=======================================================================*\ - Function: _fetch_remote_file - Purpose: retrieve an arbitrary remote file - Input: url of the remote file - headers to send along with the request (optional) - Output: an HTTP response object (see Snoopy.class.inc) -\*=======================================================================*/ -function _fetch_remote_file ($url, $headers = "" ) { - // Snoopy is an HTTP client in PHP - $client = new Snoopy(); - $client->agent = MAGPIE_USER_AGENT; - $client->read_timeout = MAGPIE_FETCH_TIME_OUT; - $client->use_gzip = MAGPIE_USE_GZIP; - if (is_array($headers) ) { - $client->rawheaders = $headers; - } - - @$client->fetch($url); - return $client; - -} - -/*=======================================================================*\ - Function: _response_to_rss - Purpose: parse an HTTP response object into an RSS object - Input: an HTTP response object (see Snoopy) - Output: parsed RSS object (see rss_parse) -\*=======================================================================*/ -function _response_to_rss ($resp) { - $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); - - // if RSS parsed successfully - if ( $rss and !$rss->ERROR) { - - // find Etag, and Last-Modified - foreach($resp->headers as $h) { - // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" - if (strpos($h, ": ")) { - list($field, $val) = explode(": ", $h, 2); - } - else { - $field = $h; - $val = ""; - } - - if ( $field == 'ETag' ) { - $rss->etag = $val; - } - - if ( $field == 'Last-Modified' ) { - $rss->last_modified = $val; - } - } - - return $rss; - } // else construct error message - else { - $errormsg = "Failed to parse RSS file."; - - if ($rss) { - $errormsg .= " (" . $rss->ERROR . ")"; - } - error($errormsg); - - return false; - } // end if ($rss and !$rss->error) -} - -/*=======================================================================*\ - Function: init - Purpose: setup constants with default values - check for user overrides -\*=======================================================================*/ -function init () { - if ( defined('MAGPIE_INITALIZED') ) { - return; - } - else { - define('MAGPIE_INITALIZED', true); - } - - if ( !defined('MAGPIE_CACHE_ON') ) { - define('MAGPIE_CACHE_ON', true); - } - - if ( !defined('MAGPIE_CACHE_DIR') ) { - define('MAGPIE_CACHE_DIR', './cache'); - } - - if ( !defined('MAGPIE_CACHE_AGE') ) { - define('MAGPIE_CACHE_AGE', 60*60); // one hour - } - - if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { - define('MAGPIE_CACHE_FRESH_ONLY', false); - } - - if ( !defined('MAGPIE_OUTPUT_ENCODING') ) { - define('MAGPIE_OUTPUT_ENCODING', 'ISO-8859-1'); - } - - if ( !defined('MAGPIE_INPUT_ENCODING') ) { - define('MAGPIE_INPUT_ENCODING', null); - } - - if ( !defined('MAGPIE_DETECT_ENCODING') ) { - define('MAGPIE_DETECT_ENCODING', true); - } - - if ( !defined('MAGPIE_DEBUG') ) { - define('MAGPIE_DEBUG', 0); - } - - if ( !defined('MAGPIE_USER_AGENT') ) { - $ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net'; - - if ( MAGPIE_CACHE_ON ) { - $ua = $ua . ')'; - } - else { - $ua = $ua . '; No cache)'; - } - - define('MAGPIE_USER_AGENT', $ua); - } - - if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { - define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout - } - - // use gzip encoding to fetch rss files if supported? - if ( !defined('MAGPIE_USE_GZIP') ) { - define('MAGPIE_USE_GZIP', true); - } -} - -// NOTE: the following code should really be in Snoopy, or at least -// somewhere other then rss_fetch! - -/*=======================================================================*\ - HTTP STATUS CODE PREDICATES - These functions attempt to classify an HTTP status code - based on RFC 2616 and RFC 2518. - - All of them take an HTTP status code as input, and return true or false - - All this code is adapted from LWP's HTTP::Status. -\*=======================================================================*/ - - -/*=======================================================================*\ - Function: is_info - Purpose: return true if Informational status code -\*=======================================================================*/ -function is_info ($sc) { - return $sc >= 100 && $sc < 200; -} - -/*=======================================================================*\ - Function: is_success - Purpose: return true if Successful status code -\*=======================================================================*/ -function is_success ($sc) { - return $sc >= 200 && $sc < 300; -} - -/*=======================================================================*\ - Function: is_redirect - Purpose: return true if Redirection status code -\*=======================================================================*/ -function is_redirect ($sc) { - return $sc >= 300 && $sc < 400; -} - -/*=======================================================================*\ - Function: is_error - Purpose: return true if Error status code -\*=======================================================================*/ -function is_error ($sc) { - return $sc >= 400 && $sc < 600; -} - -/*=======================================================================*\ - Function: is_client_error - Purpose: return true if Error status code, and its a client error -\*=======================================================================*/ -function is_client_error ($sc) { - return $sc >= 400 && $sc < 500; -} - -/*=======================================================================*\ - Function: is_client_error - Purpose: return true if Error status code, and its a server error -\*=======================================================================*/ -function is_server_error ($sc) { - return $sc >= 500 && $sc < 600; -} \ No newline at end of file diff --git a/misc/reqscraper/magpierss/rss_parse.inc b/misc/reqscraper/magpierss/rss_parse.inc deleted file mode 100644 index 68b9c5589..000000000 --- a/misc/reqscraper/magpierss/rss_parse.inc +++ /dev/null @@ -1,608 +0,0 @@ - -* @version 0.7a -* @license GPL -* -*/ - -define('RSS', 'RSS'); -define('ATOM', 'Atom'); - -require_once (MAGPIE_DIR . 'rss_utils.inc'); - -/** -* Hybrid parser, and object, takes RSS as a string and returns a simple object. -* -* see: rss_fetch.inc for a simpler interface with integrated caching support -* -*/ -class MagpieRSS { - var $parser; - - var $current_item = []; // item currently being parsed - var $items = []; // collection of parsed items - var $channel = []; // hash of channel fields - var $textinput = []; - var $image = []; - var $feed_type; - var $feed_version; - var $encoding = ''; // output encoding of parsed rss - - var $_source_encoding = ''; // only set if we have to parse xml prolog - - var $ERROR = ""; - var $WARNING = ""; - - // define some constants - - var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); - var $_KNOWN_ENCODINGS = array('UTF-8', 'US-ASCII', 'ISO-8859-1'); - - // parser variables, useless if you're not a parser, treat as private - var $stack = []; // parser stack - var $inchannel = false; - var $initem = false; - var $incontent = false; // if in Atom field - var $intextinput = false; - var $inimage = false; - var $current_namespace = false; - - - /** - * Set up XML parser, parse source, and return populated RSS object.. - * - * @param string $source string containing the RSS to be parsed - * - * NOTE: Probably a good idea to leave the encoding options alone unless - * you know what you're doing as PHP's character set support is - * a little weird. - * - * NOTE: A lot of this is unnecessary but harmless with PHP5 - * - * - * @param string $output_encoding output the parsed RSS in this character - * set defaults to ISO-8859-1 as this is PHP's - * default. - * - * NOTE: might be changed to UTF-8 in future - * versions. - * - * @param string $input_encoding the character set of the incoming RSS source. - * Leave blank and Magpie will try to figure it - * out. - * - * - * @param bool $detect_encoding if false Magpie won't attempt to detect - * source encoding. (caveat emptor) - * - */ - function MagpieRSS ($source, $output_encoding='ISO-8859-1', - $input_encoding=null, $detect_encoding=true) - { - # if PHP xml isn't compiled in, die - # - if (!function_exists('xml_parser_create')) { - $this->error( "Failed to load PHP's XML Extension. " . - "http://www.php.net/manual/en/ref.xml.php", - E_USER_ERROR ); - } - - list($parser, $source) = $this->create_parser($source, - $output_encoding, $input_encoding, $detect_encoding); - - - if (!is_resource($parser)) { - $this->error( "Failed to create an instance of PHP's XML parser. " . - "http://www.php.net/manual/en/ref.xml.php", - E_USER_ERROR ); - } - - - $this->parser = $parser; - - # pass in parser, and a reference to this object - # setup handlers - # - xml_set_object( $this->parser, $this ); - xml_set_element_handler($this->parser, - 'feed_start_element', 'feed_end_element' ); - - xml_set_character_data_handler( $this->parser, 'feed_cdata' ); - - $status = xml_parse( $this->parser, $source ); - - if (! $status ) { - $errorcode = xml_get_error_code( $this->parser ); - if ( $errorcode != XML_ERROR_NONE ) { - $xml_error = xml_error_string( $errorcode ); - $error_line = xml_get_current_line_number($this->parser); - $error_col = xml_get_current_column_number($this->parser); - $errormsg = "$xml_error at line $error_line, column $error_col"; - - $this->error( $errormsg ); - } - } - - xml_parser_free( $this->parser ); - - $this->normalize(); - } - - function feed_start_element($p, $element, &$attrs) { - $el = $element = strtolower($element); - $attrs = array_change_key_case($attrs, CASE_LOWER); - - // check for a namespace, and split if found - $ns = false; - if ( strpos( $element, ':' ) ) { - list($ns, $el) = split( ':', $element, 2); - } - if ( $ns and $ns != 'rdf' ) { - $this->current_namespace = $ns; - } - - # if feed type isn't set, then this is first element of feed - # identify feed from root element - # - if (!isset($this->feed_type) ) { - if ( $el == 'rdf' ) { - $this->feed_type = RSS; - $this->feed_version = '1.0'; - } - elseif ( $el == 'rss' ) { - $this->feed_type = RSS; - $this->feed_version = $attrs['version']; - } - elseif ( $el == 'feed' ) { - $this->feed_type = ATOM; - $this->feed_version = $attrs['version']; - $this->inchannel = true; - } - return; - } - - if ( $el == 'channel' ) - { - $this->inchannel = true; - } - elseif ($el == 'attr') - { - if (isset($attrs['name']) && isset($attrs['value'])) - $this->append($attrs['name'], $attrs['value']); - } - elseif ($el == 'item' or $el == 'entry' ) - { - $this->initem = true; - if ( isset($attrs['rdf:about']) ) { - $this->current_item['about'] = $attrs['rdf:about']; - } - } - - // if we're in the default namespace of an RSS feed, - // record textinput or image fields - elseif ( - $this->feed_type == RSS and - $this->current_namespace == '' and - $el == 'textinput' ) - { - $this->intextinput = true; - } - - elseif ( - $this->feed_type == RSS and - $this->current_namespace == '' and - $el == 'image' ) - { - $this->inimage = true; - } - - # handle atom content constructs - elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) - { - // avoid clashing w/ RSS mod_content - if ($el == 'content' ) { - $el = 'atom_content'; - } - - $this->incontent = $el; - - - } - - // if inside an Atom content construct (e.g. content or summary) field treat tags as text - elseif ($this->feed_type == ATOM and $this->incontent ) - { - // if tags are inlined, then flatten - $attrs_str = join(' ', - array_map('map_attrs', - array_keys($attrs), - array_values($attrs) ) ); - - $this->append_content( "<$element $attrs_str>" ); - - array_unshift( $this->stack, $el ); - } - - // Atom support many links per containging element. - // Magpie treats link elements of type rel='alternate' - // as being equivalent to RSS's simple link element. - // - elseif ($this->feed_type == ATOM and $el == 'link' ) - { - if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) - { - $link_el = 'link'; - } - else { - $link_el = 'link_' . $attrs['rel']; - } - - $this->append($link_el, $attrs['href']); - } - // set stack[0] to current element - else { - array_unshift($this->stack, $el); - } - } - - - - function feed_cdata ($p, $text) { - if ($this->feed_type == ATOM and $this->incontent) - { - $this->append_content( $text ); - } - else { - $current_el = join('_', array_reverse($this->stack)); - $this->append($current_el, $text); - } - } - - function feed_end_element ($p, $el) { - $el = strtolower($el); - - if ( $el == 'item' or $el == 'entry' ) - { - $this->items[] = $this->current_item; - $this->current_item = []; - $this->initem = false; - } - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) - { - $this->intextinput = false; - } - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) - { - $this->inimage = false; - } - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) - { - $this->incontent = false; - } - elseif ($el == 'channel' or $el == 'feed' ) - { - $this->inchannel = false; - } - elseif ($this->feed_type == ATOM and $this->incontent ) { - // balance tags properly - // note: i don't think this is actually neccessary - if ( $this->stack[0] == $el ) - { - $this->append_content(""); - } - else { - $this->append_content("<$el />"); - } - - array_shift( $this->stack ); - } - else { - array_shift( $this->stack ); - } - - $this->current_namespace = false; - } - - function concat (&$str1, $str2="") { - if (!isset($str1) ) { - $str1=""; - } - $str1 .= $str2; - } - - - - function append_content($text) { - if ( $this->initem ) { - $this->concat( $this->current_item[ $this->incontent ], $text ); - } - elseif ( $this->inchannel ) { - $this->concat( $this->channel[ $this->incontent ], $text ); - } - } - - // smart append - field and namespace aware - function append($el, $text) { - if (!$el) { - return; - } - if ( $this->current_namespace ) - { - if ( $this->initem ) { - $this->concat( - $this->current_item[ $this->current_namespace ][ $el ], $text); - } - elseif ($this->inchannel) { - $this->concat( - $this->channel[ $this->current_namespace][ $el ], $text ); - } - elseif ($this->intextinput) { - $this->concat( - $this->textinput[ $this->current_namespace][ $el ], $text ); - } - elseif ($this->inimage) { - $this->concat( - $this->image[ $this->current_namespace ][ $el ], $text ); - } - } - else { - if ( $this->initem ) { - $this->concat( - $this->current_item[ $el ], $text); - } - elseif ($this->intextinput) { - $this->concat( - $this->textinput[ $el ], $text ); - } - elseif ($this->inimage) { - $this->concat( - $this->image[ $el ], $text ); - } - elseif ($this->inchannel) { - $this->concat( - $this->channel[ $el ], $text ); - } - - } - } - - function normalize () { - // if atom populate rss fields - if ( $this->is_atom() ) { - $this->channel['description'] = $this->channel['tagline']; - for ( $i = 0; $i < count($this->items); $i++) { - $item = $this->items[$i]; - if ( isset($item['summary']) ) - $item['description'] = $item['summary']; - if ( isset($item['atom_content'])) - $item['content']['encoded'] = $item['atom_content']; - - $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified']; - if ( $atom_date ) { - $epoch = @parse_w3cdtf($atom_date); - if ($epoch and $epoch > 0) { - $item['date_timestamp'] = $epoch; - } - } - - $this->items[$i] = $item; - } - } - elseif ( $this->is_rss() ) { - $this->channel['tagline'] = $this->channel['description']; - for ( $i = 0; $i < count($this->items); $i++) { - $item = $this->items[$i]; - if ( isset($item['description'])) - $item['summary'] = $item['description']; - if ( isset($item['content']['encoded'] ) ) - $item['atom_content'] = $item['content']['encoded']; - - if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) { - $epoch = @parse_w3cdtf($item['dc']['date']); - if ($epoch and $epoch > 0) { - $item['date_timestamp'] = $epoch; - } - } - elseif ( isset($item['pubdate']) ) { - $epoch = @strtotime($item['pubdate']); - if ($epoch > 0) { - $item['date_timestamp'] = $epoch; - } - } - - $this->items[$i] = $item; - } - } - } - - - function is_rss () { - if ( $this->feed_type == RSS ) { - return $this->feed_version; - } - else { - return false; - } - } - - function is_atom() { - if ( $this->feed_type == ATOM ) { - return $this->feed_version; - } - else { - return false; - } - } - - /** - * return XML parser, and possibly re-encoded source - * - */ - function create_parser($source, $out_enc, $in_enc, $detect) { - if ( substr(phpversion(),0,1) == 5) { - $parser = $this->php5_create_parser($in_enc, $detect); - } - else { - list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); - } - if ($out_enc) { - $this->encoding = $out_enc; - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $out_enc); - } - - return array($parser, $source); - } - - /** - * Instantiate an XML parser under PHP5 - * - * PHP5 will do a fine job of detecting input encoding - * if passed an empty string as the encoding. - * - * All hail libxml2! - * - */ - function php5_create_parser($in_enc, $detect) { - // by default php5 does a fine job of detecting input encodings - if(!$detect && $in_enc) { - return xml_parser_create($in_enc); - } - else { - return xml_parser_create(''); - } - } - - /** - * Instaniate an XML parser under PHP4 - * - * Unfortunately PHP4's support for character encodings - * and especially XML and character encodings sucks. As - * long as the documents you parse only contain characters - * from the ISO-8859-1 character set (a superset of ASCII, - * and a subset of UTF-8) you're fine. However once you - * step out of that comfy little world things get mad, bad, - * and dangerous to know. - * - * The following code is based on SJM's work with FoF - * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss - * - */ - function php4_create_parser($source, $in_enc, $detect) { - if ( !$detect ) { - return array(xml_parser_create($in_enc), $source); - } - - if (!$in_enc) { - if (preg_match('//m', $source, $m)) { - $in_enc = strtoupper($m[1]); - $this->source_encoding = $in_enc; - } - else { - $in_enc = 'UTF-8'; - } - } - - if ($this->known_encoding($in_enc)) { - return array(xml_parser_create($in_enc), $source); - } - - // the dectected encoding is not one of the simple encodings PHP knows - - // attempt to use the iconv extension to - // cast the XML to a known encoding - // @see http://php.net/iconv - - if (function_exists('iconv')) { - $encoded_source = iconv($in_enc,'UTF-8', $source); - if ($encoded_source) { - return array(xml_parser_create('UTF-8'), $encoded_source); - } - } - - // iconv didn't work, try mb_convert_encoding - // @see http://php.net/mbstring - if(function_exists('mb_convert_encoding')) { - $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc ); - if ($encoded_source) { - return array(xml_parser_create('UTF-8'), $encoded_source); - } - } - - // else - $this->error("Feed is in an unsupported character encoding. ($in_enc) " . - "You may see strange artifacts, and mangled characters.", - E_USER_NOTICE); - - return array(xml_parser_create(), $source); - } - - function known_encoding($enc) { - $enc = strtoupper($enc); - if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) { - return $enc; - } - else { - return false; - } - } - - function error ($errormsg, $lvl=E_USER_WARNING) { - // append PHP's error message if track_errors enabled - if ( isset($php_errormsg) ) { - $errormsg .= " ($php_errormsg)"; - } - if ( MAGPIE_DEBUG ) { - trigger_error( $errormsg, $lvl); - } - else { - error_log( $errormsg, 0); - } - - $notices = E_USER_NOTICE|E_NOTICE; - if ( $lvl&$notices ) { - $this->WARNING = $errormsg; - } else { - $this->ERROR = $errormsg; - } - } - - -} // end class RSS - -function map_attrs($k, $v) { - return "$k=\"$v\""; -} - -// patch to support medieval versions of PHP4.1.x, -// courtesy, Ryan Currie, ryan@digibliss.com - -if (!function_exists('array_change_key_case')) { - define("CASE_UPPER",1); - define("CASE_LOWER",0); - - - function array_change_key_case($array,$case=CASE_LOWER) { - if ($case=CASE_LOWER) $cmd=strtolower; - elseif ($case=CASE_UPPER) $cmd=strtoupper; - foreach($array as $key=>$value) { - $output[$cmd($key)]=$value; - } - return $output; - } - -} diff --git a/misc/reqscraper/magpierss/rss_utils.inc b/misc/reqscraper/magpierss/rss_utils.inc deleted file mode 100644 index 3900a9554..000000000 --- a/misc/reqscraper/magpierss/rss_utils.inc +++ /dev/null @@ -1,65 +0,0 @@ - - * Version: 0.51 - * License: GPL - * - * The lastest version of MagpieRSS can be obtained from: - * http://magpierss.sourceforge.net - * - * For questions, help, comments, discussion, etc., please join the - * Magpie mailing list: - * magpierss-general@lists.sourceforge.net - */ - - -/*======================================================================*\ - Function: parse_w3cdtf - Purpose: parse a W3CDTF date into unix epoch - - NOTE: http://www.w3.org/TR/NOTE-datetime -\*======================================================================*/ - -function parse_w3cdtf ( $date_str ) { - - # regex to match wc3dtf - $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; - - if ( preg_match( $pat, $date_str, $match ) ) { - list( $year, $month, $day, $hours, $minutes, $seconds) = - array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); - - # calc epoch for current date assuming GMT - $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); - - $offset = 0; - if ( $match[10] == 'Z' ) { - # zulu time, aka GMT - } - else { - list( $tz_mod, $tz_hour, $tz_min ) = - array( $match[8], $match[9], $match[10]); - - # zero out the variables - if ( ! $tz_hour ) { $tz_hour = 0; } - if ( ! $tz_min ) { $tz_min = 0; } - - $offset_secs = (($tz_hour*60)+$tz_min)*60; - - # is timezone ahead of GMT? then subtract offset - # - if ( $tz_mod == '+' ) { - $offset_secs = $offset_secs * -1; - } - - $offset = $offset_secs; - } - $epoch = $epoch + $offset; - return $epoch; - } - else { - return -1; - } -} \ No newline at end of file diff --git a/misc/reqscraper/query.php b/misc/reqscraper/query.php deleted file mode 100644 index 0cba23a77..000000000 --- a/misc/reqscraper/query.php +++ /dev/null @@ -1,81 +0,0 @@ -"; -while ($row = mysql_fetch_assoc($result)) - $ret.="\n"; -$ret.=""; - -// -// output xml -// -header("Content-type: text/xml"); -echo "\n"; -echo $ret; -die(); - - -function cleanXML($strin) -{ - $strout = null; - - for ($i = 0; $i < strlen($strin); $i++) - { - $ord = ord($strin[$i]); - - if (($ord > 0 && $ord < 32) || ($ord >= 127)) - { - $strout .= "&#{$ord};"; - } - else - { - switch ($strin[$i]) - { - case '<': - $strout .= '<'; - break; - case '>': - $strout .= '>'; - break; - case '&': - $strout .= '&'; - break; - case '"': - $strout .= '"'; - break; - default: - $strout .= $strin[$i]; - } - } - } - - return $strout; -} \ No newline at end of file diff --git a/misc/reqscraper/rss.php b/misc/reqscraper/rss.php deleted file mode 100644 index 64d1a0d23..000000000 --- a/misc/reqscraper/rss.php +++ /dev/null @@ -1,76 +0,0 @@ - 100 || !is_numeric($limit)) $limit = 100; - -if ($type == "") -{ - header("Content-type: text/xml"); - echo "\n"; - echo "no group specified\n"; - die(); -} - -if ($type != "g") -{ - $result = mysql_query("select ID from feed where '".mysql_real_escape_string($type)."' REGEXP code"); - $feedid = -1; - while ($row = mysql_fetch_assoc($result)) - $feedid = $row["id"]; - - $result = mysql_query("select item.*, feed.* from item join ( select ID from item where feedID = '".mysql_real_escape_string($feedid)."' order by adddateunique desc limit ".$limit." ) x on x.ID = item.ID inner join feed on feed.ID = item.feedID inner join access on access.guid = '".mysql_real_escape_string($uid)."' order by item.id desc"); -} -else - $result = mysql_query("select item.*, feed.* from item join ( select item.ID from item inner join access on access.guid = '".mysql_real_escape_string($uid)."' and item.feedid != coalesce(access.misc, -1) and role=2 where feedid in (select id from feed where name = 'gid') ORDER BY item.adddateunique DESC LIMIT ".$limit." ) x on x.ID = item.ID inner join feed on feed.ID = item.feedID order by item.ID desc"); - -if (!$result) -{ - header("Content-type: text/xml"); - echo "\n"; - echo "general error"; - die(); -} - -// -// build metadata about the item(s) -// -$xml = ""; -while ($row = mysql_fetch_assoc($result)) -{ - //create the xml - $xml .= "\t\n"; - $xml .= "\t\t".htmlentities($row['title'])."\n"; - $xml .= "\t\t".date('r', strtotime($row['adddate']))."\n"; - $xml .= "\t\t".htmlentities($row['reqid'])."\n"; - $xml .= "\t\t".htmlentities($row['code'])."\n"; - $xml .= "\t\t".htmlentities($row['link'])."\n"; - if ($row['description']!= "") - $xml .= "\t\t\n"; - $xml .= "\t\t".htmlentities($row['guid'])."\n"; - $xml .= "\t\n"; -} - -// -// build the xml -// -$xmlstart = " - - -".mysql_real_escape_string(htmlentities($type))." feed -http://www.newznab.com -".mysql_real_escape_string(htmlentities($type))." feed -en-us\n"; - -$xmlend = "\n"; - -$ret = $xmlstart . $xml . $xmlend; - -// -// output xml -// -header("Content-type: text/xml"); -echo "\n"; -echo $ret; \ No newline at end of file diff --git a/misc/reqscraper/schema.sql b/misc/reqscraper/schema.sql deleted file mode 100644 index afa33bac9..000000000 --- a/misc/reqscraper/schema.sql +++ /dev/null @@ -1,68 +0,0 @@ - -DROP TABLE IF EXISTS `feed`; -CREATE TABLE `feed` -( - `ID` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `code` VARCHAR(50) NULL, - `name` VARCHAR(255) NULL, - `url` VARCHAR(1000) NOT NULL, - `reqidcol` VARCHAR(255) NULL, - `reqidregex` VARCHAR(2000) NOT NULL, - `titlecol` VARCHAR(255) NULL, - `titleregex` VARCHAR(2000) NOT NULL, - `lastupdate` DATETIME NULL, - `updatemins` TINYINT(3) NOT NULL DEFAULT '55', - `status` INT NOT NULL DEFAULT 1, - PRIMARY KEY (`ID`) -) ENGINE=MYISAM AUTO_INCREMENT=1 ; - -CREATE INDEX ix_feed_code ON feed (CODE); - -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.teevee', 'abteevee', 'http://abteevee.allfilled.com/rss.php', 'title', '/(?P.*)/i', 'description', '/^ReqId: (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.erotica', 'aberotica', 'http://aberotica.allfilled.com/rss.php', 'title', '/(?P<title>.*)/i', 'description', '/^ReqId: (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.games.wii', 'abgwii', 'http://www.abgx.net/rss/abgw/posted.rss', 'title', '/^Req\\s\\d{1,6}\\s\\-\\s(?P<title>.\\S*)/i', 'title', '/^Req (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.games.xbox360', 'abg360', 'http://www.abgx.net/rss/x360/posted.rss', 'title', '/^Req\\s\\d{1,6}\\s\\-\\s(?P<title>.\\S*)/i', 'title', '/^Req (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.console.ps3', 'ps3', 'http://www.abgx.net/rss/abcp/posted.rss', 'title', '/^Req\\s\\d{1,6}\\s\\-\\s(?P<title>.\\S*)/i', 'title', '/^Req (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.sony.psp', 'psp', 'http://www.abgx.net/rss/absp/posted.rss', 'title', '/^Req\\s\\d{1,6}\\s\\-\\s(?P<title>.\\S*)/i', 'title', '/^Req (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.games.nintendods', 'nds', 'http://www.abgx.net/rss/abgn/posted.rss', 'title', '/^Req\\s\\d{1,6}\\s\\-\\s(?P<title>.\\S*)/i', 'title', '/^Req (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.inner-sanctum', 'innersanct', 'http://rss.omgwtfnzbs.org/rss-info.php', 'title', '/^(?P<title>.*)$/i', '', '-1', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.moovee', 'abmoovee', 'http://abmoovee.allfilled.com/rss.php', 'title', '/(?P<title>.*)/i', 'description', '/^ReqId: (?P<reqid>\\d{3,6})/i', NULL); -INSERT INTO feed (CODE, NAME, url, titlecol, titleregex, reqidcol, reqidregex, lastupdate) VALUES ('alt.binaries.srrdb', 'srrdb', 'http://www.srrdb.com/feed/srrs', 'title', '/(?P<title>.*)/i', 'description', '/Archived files.*<td>(?P<reqid>.*?\\.(avi|mkv|mp4|mov|wmv|iso|img|mp3|m3u|gcm|ps3|wad|ac3|nds|bin|mdf))<\\/td>/ims', null); - - - -DROP TABLE IF EXISTS `item`; -CREATE TABLE `item` -( - `ID` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `feedID` INT NOT NULL, - `reqid` VARCHAR(255) NOT NULL, - `title` VARCHAR(255) NULL, - `link` VARCHAR(1000) NULL, - `description` VARCHAR(1000) NULL, - `pubdate` DATETIME NOT NULL, - `guid` VARCHAR(1000) NULL, - `adddate` DATETIME NOT NULL, - `adddateunique` BIGINT UNSIGNED NOT NULL, - PRIMARY KEY (`ID`) -) ENGINE=MYISAM AUTO_INCREMENT=1 ; - -CREATE INDEX ix_item_feedID ON item (feedID); -CREATE INDEX ix_item_reqid ON item (reqid); -CREATE UNIQUE INDEX ix_reqid_title ON item (reqid, title); -CREATE UNIQUE INDEX ix_feedid_reqid ON item (feedID, reqid); -CREATE INDEX ix_item_adddateunique ON item (adddateunique); - - -DROP TABLE IF EXISTS `access`; -CREATE TABLE `access` -( - `ID` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `guid` VARCHAR(40) NOT NULL, - `role` INT NOT NULL, - `description` VARCHAR(1000) NULL, - `misc` VARCHAR(1000) NULL, - PRIMARY KEY (`ID`) -) ENGINE=MYISAM AUTO_INCREMENT=1 ; - -CREATE INDEX ix_access_guid ON access (guid); \ No newline at end of file diff --git a/misc/reqscraper/scrape.php b/misc/reqscraper/scrape.php deleted file mode 100644 index 1720705fc..000000000 --- a/misc/reqscraper/scrape.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php - -require_once('magpierss/rss_fetch.inc'); -require_once('config.php'); - -// -// retrieve a list of feeds to be scraped -// -$result = mysql_query("SELECT *, NOW() as now FROM feed WHERE status=1"); -while ($row = mysql_fetch_assoc($result)) -{ - - if (strtotime($row['now']) - strtotime($row['lastupdate']) < $row['updatemins']*60) { - continue; - } - - echo "checking ".$row["code"]."\n"; - $rss = fetch_rss($row["url"]); - - $upd = mysql_query("UPDATE feed SET lastupdate = NOW() WHERE ID = ".$row['ID']); - - // - // scrape every item into a database table - // - foreach ($rss->items as $item) - { - $link = ""; - if (isset($item['link'])) - $link = mysql_real_escape_string($item['link']); - - if (isset($item['description'])) - $description = mysql_real_escape_string($item['description']); - elseif (isset($item['summary'])) - $description = mysql_real_escape_string($item['description']); - else - $description = ""; - - $feedID = $row["id"]; - - if (isset($item['pubdate'])) - $pubdate = date("Y-m-d H:i:s", strtotime($item['pubdate'])); - elseif (isset($item["dc"]) && isset($item["dc"]["date"])) - $pubdate = date("Y-m-d H:i:s", strtotime($item["dc"]["date"])); - else - $pubdate = date("Y-m-d H:i:s"); - - // - // store 'specific stuff' like parsed reqids by regexing - // - $reqid = 0; - $matches = ""; - - $title = ""; - if (preg_match($row["titleregex"], $item[$row["titlecol"]], $matches)) - $title = mysql_real_escape_string($matches["title"]); - - //straight md5 - if ($row["reqidregex"] == "-1" && $title != "") - { - $reqid = md5($title); - } - //regex reqid out of columns - else - { - //multi dimensional position - $multi = strpos($row["reqidcol"], ':'); - if ($multi !== FALSE) - { - $part1 = substr($row["reqidcol"], 0, $multi); - $part2 = substr($row["reqidcol"], $multi + 1); - - if (preg_match($row["reqidregex"], $item[$part1][$part2], $matches)) - $reqid = mysql_real_escape_string($matches["reqid"]); - } - else - { - if (preg_match($row["reqidregex"], $item[$row["reqidcol"]], $matches)) - $reqid = mysql_real_escape_string($matches["reqid"]); - } - } - - if (isset($item['guid'])) - $guid = mysql_real_escape_string($item['guid']); - else - { - if ($title != "" && $reqid != 0) - $guid = md5($reqid.$title); - else - $guid = md5(uniqid()); - } - - $addateunique = round(microtime(true) * 1000); - $res = mysql_query("INSERT INTO item (feedID, reqid, title, link, description, pubdate, guid, adddate, adddateunique) VALUES ($feedID, '$reqid', '$title', '$link', '$description', '$pubdate', '$guid', NOW(), '$addateunique') ON DUPLICATE KEY update reqid = '$reqid', title = '$title'"); - } -} \ No newline at end of file diff --git a/misc/reqscraper/update.sql b/misc/reqscraper/update.sql deleted file mode 100644 index b0fb62f16..000000000 --- a/misc/reqscraper/update.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE `feed` ADD `updatemins` TINYINT( 3 ) NOT NULL DEFAULT '55' AFTER `titleregex`; - -ALTER TABLE `item` ADD UNIQUE `ix_reqid_title` ( `reqid` , `title` ); - -ALTER TABLE `item` DROP INDEX `ix_item_guid`; \ No newline at end of file diff --git a/misc/sphinxsearch/populate_rt_indexes.php b/misc/sphinxsearch/populate_rt_indexes.php index 5d4f11eff..bb786495d 100644 --- a/misc/sphinxsearch/populate_rt_indexes.php +++ b/misc/sphinxsearch/populate_rt_indexes.php @@ -31,7 +31,7 @@ function populate_rt($table, $max) $query = ( 'SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename FROM releases r - LEFT JOIN release_files rf ON(r.id=rf.releaseid) + LEFT JOIN release_files rf ON(r.id=rf.releases_id) WHERE r.id > %d GROUP BY r.id ORDER BY r.id ASC diff --git a/misc/sphinxsearch/toggle_search_type.php b/misc/sphinxsearch/toggle_search_type.php index 7bf310f32..6871b64a9 100644 --- a/misc/sphinxsearch/toggle_search_type.php +++ b/misc/sphinxsearch/toggle_search_type.php @@ -66,7 +66,7 @@ function revertToStandard($pdo) sprintf(" CREATE TABLE release_search_data ( id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - releaseid INT(11) UNSIGNED NOT NULL, + releases_id INT(11) UNSIGNED NOT NULL, guid VARCHAR(50) NOT NULL, name VARCHAR(255) NOT NULL DEFAULT '', searchname VARCHAR(255) NOT NULL DEFAULT '', @@ -75,7 +75,7 @@ function revertToStandard($pdo) FULLTEXT INDEX ix_releasesearch_name_ft (name), FULLTEXT INDEX ix_releasesearch_searchname_ft (searchname), FULLTEXT INDEX ix_releasesearch_fromname_ft (fromname), - INDEX ix_releasesearch_releaseid (releaseid), + INDEX ix_releasesearch_releases_id (releases_id), INDEX ix_releasesearch_guid (guid) ) %s @@ -87,7 +87,7 @@ function revertToStandard($pdo) ); echo $pdo->log->info('Populating the releasearch table with initial data. (Slow)' . PHP_EOL); - $pdo->queryInsert('INSERT INTO release_search_data (releaseid, guid, name, searchname, fromname) + $pdo->queryInsert('INSERT INTO release_search_data (releases_id, guid, name, searchname, fromname) SELECT id, guid, name, searchname, fromname FROM releases'); echo $pdo->log->info('Adding the auto-population triggers. (Quick)' . PHP_EOL); @@ -97,7 +97,7 @@ function revertToStandard($pdo) $pdo->exec(' CREATE TRIGGER insert_search AFTER INSERT ON releases FOR EACH ROW BEGIN - INSERT INTO release_search_data (releaseid, guid, name, searchname, fromname) + INSERT INTO release_search_data (releases_id, guid, name, searchname, fromname) VALUES (NEW.id, NEW.guid, NEW.name, NEW.searchname, NEW.fromname); END; @@ -106,24 +106,24 @@ function revertToStandard($pdo) IF NEW.guid != OLD.guid THEN UPDATE release_search_data SET guid = NEW.guid - WHERE releaseid = OLD.id; + WHERE releases_id = OLD.id; END IF; IF NEW.name != OLD.name THEN UPDATE release_search_data SET name = NEW.name - WHERE releaseid = OLD.id; + WHERE releases_id = OLD.id; END IF; IF NEW.fromname != OLD.fromname THEN UPDATE release_search_data SET fromname = NEW.fromname - WHERE releaseid = OLD.id; + WHERE releases_id = OLD.id; END IF; END; CREATE TRIGGER delete_search AFTER DELETE ON releases FOR EACH ROW BEGIN DELETE FROM release_search_data - WHERE releaseid = OLD.id; + WHERE releases_id = OLD.id; END;' ); echo $pdo->log->header('Standard search should once again be available.' . PHP_EOL); diff --git a/misc/update/nix/tmux/bin/fixreleasenames.php b/misc/update/nix/tmux/bin/fixreleasenames.php index 5815c135d..3fc1631af 100644 --- a/misc/update/nix/tmux/bin/fixreleasenames.php +++ b/misc/update/nix/tmux/bin/fixreleasenames.php @@ -18,7 +18,7 @@ if (!isset($argv[1])) { $pieces = explode(' ', $argv[1]); if (isset($pieces[1]) && $pieces[0] == 'nfo') { $release = $pieces[1]; - if ($res = $db->queryOneRow(sprintf('SELECT rel.guid AS guid, nfo.releaseid AS nfoid, rel.groupid, rel.categories_id, rel.name, rel.searchname, uncompress(nfo) AS textstring, rel.id AS releaseid FROM releases rel INNER JOIN release_nfos nfo ON (nfo.releaseid = rel.id) WHERE rel.id = %d', $release))) { + if ($res = $db->queryOneRow(sprintf('SELECT rel.guid AS guid, nfo.releases_id AS nfoid, rel.groupid, rel.categories_id, rel.name, rel.searchname, uncompress(nfo) AS textstring, rel.id AS releaseid FROM releases rel INNER JOIN release_nfos nfo ON (nfo.releases_id = rel.id) WHERE rel.id = %d', $release))) { //ignore encrypted nfos if (preg_match('/^=newz\[NZB\]=\w+/', $res['textstring'])) { $namefixer->done = $namefixer->matched = false; @@ -37,8 +37,8 @@ if (!isset($argv[1])) { } else if (isset($pieces[1]) && $pieces[0] == 'filename') { $release = $pieces[1]; if ($res = $db->queryOneRow(sprintf('SELECT relfiles.name AS textstring, rel.categories_id, rel.searchname, ' - . 'rel.groupid, relfiles.releaseid AS fileid, rel.id AS releaseid, rel.name FROM releases rel ' - . 'INNER JOIN release_files relfiles ON (relfiles.releaseid = rel.id) WHERE rel.id = %d', $release))) { + . 'rel.groupid, relfiles.releases_id AS fileid, rel.id AS releaseid, rel.name FROM releases rel ' + . 'INNER JOIN release_files relfiles ON (relfiles.releases_id = rel.id) WHERE rel.id = %d', $release))) { $namefixer->done = $namefixer->matched = false; if ($namefixer->checkName($res, true, 'Filenames, ', 1, 1) !== true) { echo '.'; @@ -48,8 +48,8 @@ if (!isset($argv[1])) { } else if (isset($pieces[1]) && $pieces[0] == 'srr') { $release = $pieces[1]; if ($res = $db->queryOneRow(sprintf('SELECT relfiles.name AS textstring, rel.categories_id, rel.searchname, ' - . 'rel.groupid, relfiles.releaseid AS fileid, rel.id AS releaseid, rel.name FROM releases rel ' - . 'INNER JOIN release_files relfiles ON (relfiles.releaseid = rel.id) WHERE rel.id = %d', $release))) { + . 'rel.groupid, relfiles.releases_id AS fileid, rel.id AS releaseid, rel.name FROM releases rel ' + . 'INNER JOIN release_files relfiles ON (relfiles.releases_id = rel.id) WHERE rel.id = %d', $release))) { $namefixer->done = $namefixer->matched = false; if ($namefixer->checkName($res, true, 'Srr, ', 1, 1) !== true) { echo '.'; @@ -58,7 +58,7 @@ if (!isset($argv[1])) { } }else if (isset($pieces[1]) && $pieces[0] == 'md5') { $release = $pieces[1]; - if ($res = $db->queryOneRow(sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categories_id, r.groupid, dehashstatus, rf.name AS filename FROM releases r LEFT JOIN release_files rf ON r.id = rf.releaseid WHERE r.id = %d', $release))) { + if ($res = $db->queryOneRow(sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categories_id, r.groupid, dehashstatus, rf.name AS filename FROM releases r LEFT JOIN release_files rf ON r.id = rf.releases_id WHERE r.id = %d', $release))) { if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['name'], $matches)) { $namefixer->matchPredbHash($matches[0], $res, 1, 1, true, 1); } else if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['filename'], $matches)) { diff --git a/misc/update/nix/tmux/bin/groupfixrelnames.php b/misc/update/nix/tmux/bin/groupfixrelnames.php index ce03b8076..95f0cf0f7 100644 --- a/misc/update/nix/tmux/bin/groupfixrelnames.php +++ b/misc/update/nix/tmux/bin/groupfixrelnames.php @@ -27,7 +27,7 @@ if (!isset($argv[1])) { SELECT r.id AS releaseid, r.guid, r.groupid, r.categories_id, r.name, r.searchname, uncompress(nfo) AS textstring FROM releases r - INNER JOIN release_nfos rn ON r.id = rn.releaseid + INNER JOIN release_nfos rn ON r.id = rn.releases_id WHERE r.guid %s AND r.nzbstatus = 1 AND r.proc_nfo = 0 @@ -67,7 +67,7 @@ if (!isset($argv[1])) { SELECT DISTINCT r.id AS releaseid, r.name, r.searchname, r.categories_id, r.groupid, r.dehashstatus, rf.name AS filename FROM releases r - LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid AND rf.ishashed = 1 + LEFT OUTER JOIN release_files rf ON r.id = rf.releases_id AND rf.ishashed = 1 WHERE r.guid %s AND nzbstatus = 1 AND r.ishashed = 1 AND r.dehashstatus BETWEEN -6 AND 0 diff --git a/misc/update/python/fixreleasenames_threaded.py b/misc/update/python/fixreleasenames_threaded.py index 8edc6f21a..51833f7d7 100644 --- a/misc/update/python/fixreleasenames_threaded.py +++ b/misc/update/python/fixreleasenames_threaded.py @@ -65,11 +65,11 @@ elif len(sys.argv) > 1 and sys.argv[1] == "miscsorter": cur[0].execute(run, (int(perrun[0]) * int(run_threads[0]))) datas = cur[0].fetchall() elif len(sys.argv) > 1 and (sys.argv[1] == "filename"): - run = "SELECT DISTINCT rel.id AS releaseid FROM releases rel INNER JOIN release_files relfiles ON (relfiles.releaseid = rel.id) WHERE nzbstatus = 1 AND proc_files = 0 AND" + clean + "ORDER BY postdate ASC LIMIT %s" + run = "SELECT DISTINCT rel.id AS releaseid FROM releases rel INNER JOIN release_files relfiles ON (relfiles.releases_id = rel.id) WHERE nzbstatus = 1 AND proc_files = 0 AND" + clean + "ORDER BY postdate ASC LIMIT %s" cur[0].execute(run, (int(perrun[0]) * int(run_threads[0]))) datas = cur[0].fetchall() elif len(sys.argv) > 1 and (sys.argv[1] == "md5"): - run = "SELECT DISTINCT rel.id FROM releases rel LEFT OUTER JOIN release_files rf ON rel.id = rf.releaseid AND rf.ishashed = 1 WHERE nzbstatus = 1 AND rel.dehashstatus BETWEEN -6 AND 0 AND rel.ishashed = 1 AND predb_id = 0 ORDER BY dehashstatus DESC, postdate ASC LIMIT %s" + run = "SELECT DISTINCT rel.id FROM releases rel LEFT OUTER JOIN release_files rf ON rel.id = rf.releases_id AND rf.ishashed = 1 WHERE nzbstatus = 1 AND rel.dehashstatus BETWEEN -6 AND 0 AND rel.ishashed = 1 AND predb_id = 0 ORDER BY dehashstatus DESC, postdate ASC LIMIT %s" cur[0].execute(run, (int(perrun[0])*int(run_threads[0]))) datas = cur[0].fetchall() elif len(sys.argv) > 1 and (sys.argv[1] == "par2"): diff --git a/misc/update/python/groupfixrelnames_threaded.py b/misc/update/python/groupfixrelnames_threaded.py index 79ee1dead..19e094adb 100644 --- a/misc/update/python/groupfixrelnames_threaded.py +++ b/misc/update/python/groupfixrelnames_threaded.py @@ -54,12 +54,12 @@ if threads > 16: maxperrun = int(run_perrun[0]) if sys.argv[1] == "md5": - join = "LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid AND rf.ishashed = 1" + join = "LEFT OUTER JOIN release_files rf ON r.id = rf.releases_id AND rf.ishashed = 1" where = "r.ishashed = 1 AND r.dehashstatus BETWEEN -6 AND 0" elif sys.argv[1] == "nfo": where = "r.proc_nfo = 0 AND r.nfostatus = 1" elif sys.argv[1] == "filename": - join = "INNER JOIN release_files rf ON r.id = rf.releaseid" + join = "INNER JOIN release_files rf ON r.id = rf.releases_id" where = "r.proc_files = 0" elif sys.argv[1] == "par2": where = "r.proc_par2 = 0" diff --git a/newznab/Books.php b/newznab/Books.php index 7aec19b4e..ff5f3e6ec 100644 --- a/newznab/Books.php +++ b/newznab/Books.php @@ -238,7 +238,7 @@ class Books rn.id AS nfoid FROM releases r LEFT OUTER JOIN groups g ON g.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id INNER JOIN bookinfo boo ON boo.id = r.bookinfo_id WHERE boo.id IN (%s) diff --git a/newznab/Console.php b/newznab/Console.php index 8704a78f7..7c25b79f7 100644 --- a/newznab/Console.php +++ b/newznab/Console.php @@ -237,7 +237,7 @@ class Console rn.id AS nfoid FROM releases r LEFT OUTER JOIN groups g ON g.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id INNER JOIN consoleinfo con ON con.id = r.consoleinfo_id INNER JOIN genres ON con.genreid = genres.id diff --git a/newznab/Games.php b/newznab/Games.php index dcfa73e12..50f9902b6 100644 --- a/newznab/Games.php +++ b/newznab/Games.php @@ -236,7 +236,7 @@ class Games GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, - GROUP_CONCAT(rn.releaseid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, + GROUP_CONCAT(rn.releases_id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, GROUP_CONCAT(g.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, @@ -246,10 +246,10 @@ class Games GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, GROUP_CONCAT(df.failed ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_failed, con.*, YEAR (con.releasedate) as year, r.gamesinfo_id, g.name AS group_name, - rn.releaseid AS nfoid + rn.releases_id AS nfoid FROM releases r LEFT OUTER JOIN groups g ON g.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id INNER JOIN gamesinfo con ON con.id = r.gamesinfo_id WHERE con.id IN (%s) diff --git a/newznab/MiscSorter.php b/newznab/MiscSorter.php index b7fef39e3..ac8bdcef2 100644 --- a/newznab/MiscSorter.php +++ b/newznab/MiscSorter.php @@ -70,7 +70,7 @@ class MiscSorter SELECT UNCOMPRESS(rn.nfo) AS nfo, r.id, r.name, r.searchname FROM release_nfos rn - INNER JOIN releases r ON rn.releaseid = r.id + INNER JOIN releases r ON rn.releases_id = r.id INNER JOIN groups g ON r.groupid = g.id WHERE rn.nfo IS NOT NULL AND r.proc_sorter = %d diff --git a/newznab/Movie.php b/newznab/Movie.php index cf03813f0..dd51a25fb 100644 --- a/newznab/Movie.php +++ b/newznab/Movie.php @@ -315,7 +315,7 @@ class Movie GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, - GROUP_CONCAT(rn.releaseid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, + GROUP_CONCAT(rn.releases_id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, GROUP_CONCAT(g.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, @@ -327,10 +327,10 @@ class Movie GROUP_CONCAT(cp.title, ' > ', c.title ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_catname, m.*, g.name AS group_name, - rn.releaseid AS nfoid + rn.releases_id AS nfoid FROM releases r LEFT OUTER JOIN groups g ON g.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id LEFT OUTER JOIN categories c ON c.id = r.categories_id LEFT OUTER JOIN categories cp ON cp.id = c.parentid diff --git a/newznab/Music.php b/newznab/Music.php index f555ee685..ce146400f 100644 --- a/newznab/Music.php +++ b/newznab/Music.php @@ -234,7 +234,7 @@ class Music GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, - GROUP_CONCAT(rn.releaseid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, + GROUP_CONCAT(rn.releases_id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, GROUP_CONCAT(g.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, @@ -246,10 +246,10 @@ class Music m.*, r.musicinfo_id, r.haspreview, g.name AS group_name, - rn.releaseid AS nfoid + rn.releases_id AS nfoid FROM releases r LEFT OUTER JOIN groups g ON g.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id INNER JOIN musicinfo m ON m.id = r.musicinfo_id WHERE m.id IN (%s) diff --git a/newznab/NameFixer.php b/newznab/NameFixer.php index 3f76c5341..84edd0686 100755 --- a/newznab/NameFixer.php +++ b/newznab/NameFixer.php @@ -190,7 +190,7 @@ class NameFixer $query = sprintf(' SELECT rel.id AS releaseid FROM releases rel - INNER JOIN release_nfos nfo ON (nfo.releaseid = rel.id) + INNER JOIN release_nfos nfo ON (nfo.releases_id = rel.id) WHERE rel.nzbstatus = %d AND rel.predb_id = 0', NZB::NZB_ADDED @@ -201,7 +201,7 @@ class NameFixer $query = sprintf(' SELECT rel.id AS releaseid FROM releases rel - INNER JOIN release_nfos nfo ON (nfo.releaseid = rel.id) + INNER JOIN release_nfos nfo ON (nfo.releases_id = rel.id) WHERE (rel.isrenamed = %d OR rel.categories_id = %d) AND rel.proc_nfo = %d', self::IS_RENAMED_NONE, @@ -222,10 +222,10 @@ class NameFixer foreach ($releases as $rel) { $releaseRow = $this->pdo->queryOneRow( sprintf(' - SELECT nfo.releaseid AS nfoid, rel.groupid, rel.categories_id, rel.name, rel.searchname, + SELECT nfo.releases_id AS nfoid, rel.groupid, rel.categories_id, rel.name, rel.searchname, UNCOMPRESS(nfo) AS textstring, rel.id AS releaseid FROM releases rel - INNER JOIN release_nfos nfo ON (nfo.releaseid = rel.id) + INNER JOIN release_nfos nfo ON (nfo.releases_id = rel.id) WHERE rel.id = %d', $rel['releaseid'] ) @@ -280,9 +280,9 @@ class NameFixer if ($cats === 3) { $query = sprintf(' SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.groupid, - rf.releaseid AS fileid, rel.id AS releaseid + rf.releases_id AS fileid, rel.id AS releaseid FROM releases rel - INNER JOIN release_files rf ON (rf.releaseid = rel.id) + INNER JOIN release_files rf ON (rf.releases_id = rel.id) WHERE rel.nzbstatus = %d AND rel.predb_id = 0', NZB::NZB_ADDED @@ -292,9 +292,9 @@ class NameFixer } else { $query = sprintf(' SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.groupid, - rf.releaseid AS fileid, rel.id AS releaseid + rf.releases_id AS fileid, rel.id AS releaseid FROM releases rel - INNER JOIN release_files rf ON (rf.releaseid = rel.id) + INNER JOIN release_files rf ON (rf.releases_id = rel.id) WHERE (rel.isrenamed = %d OR rel.categories_id IN (%s)) AND rel.predb_id = 0 AND rel.proc_files = %d @@ -826,7 +826,7 @@ class NameFixer preg_match_all('#[a-zA-Z0-9]{3,}#', $preTitle, $matches, PREG_PATTERN_ORDER); $titlematch = '+' . implode(' +', $matches[0]); $join = sprintf( - "INNER JOIN release_search_data rs ON rs.releaseid = r.id + "INNER JOIN release_search_data rs ON rs.releases_id = r.id WHERE (MATCH (rs.name) AGAINST ('%1\$s' IN BOOLEAN MODE) OR MATCH (rs.searchname) AGAINST ('%1\$s' IN BOOLEAN MODE))", @@ -859,7 +859,7 @@ class NameFixer r.groupid, r.categories_id, rf.name AS filename FROM releases r - INNER JOIN release_files rf ON r.id = rf.releaseid + INNER JOIN release_files rf ON r.id = rf.releases_id AND rf.name IS NOT NULL WHERE r.predb_id = 0 %s %s', diff --git a/newznab/PreDb.php b/newznab/PreDb.php index 2af5bd90c..b102ad947 100644 --- a/newznab/PreDb.php +++ b/newznab/PreDb.php @@ -172,7 +172,7 @@ Class PreDb $tq = ''; if ($time == 1) { - $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releaseid, rf.size DESC'; + $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releases_id, rf.size DESC'; } $ct = ''; if ($cats == 1) { @@ -191,12 +191,12 @@ Class PreDb if ($cats === 3) { $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categories_id, r.groupid, ' . 'dehashstatus, rf.name AS filename FROM releases r ' - . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' + . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releases_id ' . 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND predb_id = 0 %s', $regex); } else { $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categories_id, r.groupid, ' . 'dehashstatus, rf.name AS filename FROM releases r ' - . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' + . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releases_id ' . 'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq); } diff --git a/newznab/RSS.php b/newznab/RSS.php index f175a0789..68ae685c9 100644 --- a/newznab/RSS.php +++ b/newznab/RSS.php @@ -57,7 +57,7 @@ Class RSS if (count($cat)) { if ($cat[0] == -2) { - $cartSearch = sprintf(' INNER JOIN users_releases ON users_releases.userid = %d AND users_releases.releaseid = r.id ', $userID); + $cartSearch = sprintf(' INNER JOIN users_releases ON users_releases.userid = %d AND users_releases.releases_id = r.id ', $userID); } else if ($cat[0] != -1) { $catSearch = $this->releases->categorySQL($cat); } diff --git a/newznab/ReleaseComments.php b/newznab/ReleaseComments.php index d6a6566de..baaff18fe 100644 --- a/newznab/ReleaseComments.php +++ b/newznab/ReleaseComments.php @@ -249,6 +249,6 @@ class ReleaseComments else $limit = " LIMIT ".$start.",".$num; - return $this->pdo->query(sprintf("SELECT release_comments.*, r.guid, r.searchname, users.username FROM release_comments INNER JOIN releases r ON r.id = release_comments.releaseid LEFT OUTER JOIN users ON users.id = release_comments.userid WHERE userid = %d ORDER BY release_comments.createddate DESC ".$limit, $uid)); + return $this->pdo->query(sprintf("SELECT release_comments.*, r.guid, r.searchname, users.username FROM release_comments INNER JOIN releases r ON r.id = release_comments.releases_id LEFT OUTER JOIN users ON users.id = release_comments.userid WHERE userid = %d ORDER BY release_comments.createddate DESC ".$limit, $uid)); } } diff --git a/newznab/ReleaseExtra.php b/newznab/ReleaseExtra.php index 79688ec32..63d3e6293 100644 --- a/newznab/ReleaseExtra.php +++ b/newznab/ReleaseExtra.php @@ -75,12 +75,12 @@ class ReleaseExtra public function getBriefByGuid($guid) { - return $this->pdo->queryOneRow(sprintf("SELECT containerformat, videocodec, videoduration, videoaspect, CONCAT(video_data.videowidth,'x',video_data.videoheight,' @',format(videoframerate,0),'fps') AS size, GROUP_CONCAT(DISTINCT release_audio.audiolanguage SEPARATOR ', ') AS audio, GROUP_CONCAT(DISTINCT release_audio.audioformat,' (',SUBSTRING(release_audio.audiochannels,1,1),' ch)' SEPARATOR ', ') AS audioformat, GROUP_CONCAT(DISTINCT release_audio.audioformat,' (',SUBSTRING(release_audio.audiochannels,1,1),' ch)' SEPARATOR ', ') AS audioformat, GROUP_CONCAT(DISTINCT release_subtitles.subslanguage SEPARATOR ', ') AS subs FROM video_data LEFT OUTER JOIN release_subtitles ON video_data.releaseid = release_subtitles.releaseid LEFT OUTER JOIN release_audio ON video_data.releaseid = release_audio.releaseid INNER JOIN releases r ON r.id = video_data.releaseid WHERE r.guid = %s GROUP BY r.id", $this->pdo->escapeString($guid))); + return $this->pdo->queryOneRow(sprintf("SELECT containerformat, videocodec, videoduration, videoaspect, CONCAT(video_data.videowidth,'x',video_data.videoheight,' @',format(videoframerate,0),'fps') AS size, GROUP_CONCAT(DISTINCT release_audio.audiolanguage SEPARATOR ', ') AS audio, GROUP_CONCAT(DISTINCT release_audio.audioformat,' (',SUBSTRING(release_audio.audiochannels,1,1),' ch)' SEPARATOR ', ') AS audioformat, GROUP_CONCAT(DISTINCT release_audio.audioformat,' (',SUBSTRING(release_audio.audiochannels,1,1),' ch)' SEPARATOR ', ') AS audioformat, GROUP_CONCAT(DISTINCT release_subtitles.subslanguage SEPARATOR ', ') AS subs FROM video_data LEFT OUTER JOIN release_subtitles ON video_data.releases_id = release_subtitles.releases_id LEFT OUTER JOIN release_audio ON video_data.releases_id = release_audio.releases_id INNER JOIN releases r ON r.id = video_data.releases_id WHERE r.guid = %s GROUP BY r.id", $this->pdo->escapeString($guid))); } public function getByGuid($guid) { - return $this->pdo->queryOneRow(sprintf('SELECT video_data.* FROM video_data INNER JOIN releases r ON r.id = video_data.releaseid WHERE r.guid = %s', $this->pdo->escapeString($guid))); + return $this->pdo->queryOneRow(sprintf('SELECT video_data.* FROM video_data INNER JOIN releases r ON r.id = video_data.releases_id WHERE r.guid = %s', $this->pdo->escapeString($guid))); } public function delete($id) diff --git a/newznab/ReleaseFiles.php b/newznab/ReleaseFiles.php index e5c15c561..ad93b6d4e 100644 --- a/newznab/ReleaseFiles.php +++ b/newznab/ReleaseFiles.php @@ -49,7 +49,7 @@ class ReleaseFiles */ public function getByGuid($guid) { - return $this->pdo->query(sprintf("SELECT release_files.* FROM release_files INNER JOIN releases r ON r.id = release_files.releaseid WHERE r.guid = %s ORDER BY release_files.name ", $this->pdo->escapeString($guid))); + return $this->pdo->query(sprintf("SELECT release_files.* FROM release_files INNER JOIN releases r ON r.id = release_files.releases_id WHERE r.guid = %s ORDER BY release_files.name ", $this->pdo->escapeString($guid))); } /** diff --git a/newznab/ReleaseRemover.php b/newznab/ReleaseRemover.php index 6c3cd7f48..28cc12e42 100644 --- a/newznab/ReleaseRemover.php +++ b/newznab/ReleaseRemover.php @@ -446,7 +446,7 @@ class ReleaseRemover $this->query = sprintf( "SELECT r.guid, r.searchname, r.id FROM releases r %s - STRAIGHT_JOIN release_files rf ON r.id = rf.releaseid + STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id WHERE r.searchname NOT REGEXP %s AND rf.name %s AND r.categories_id NOT IN (%d, %d, %d, %d, %d, %d) %s %s", @@ -493,7 +493,7 @@ class ReleaseRemover $this->query = sprintf( "SELECT r.guid, r.searchname, r.id FROM releases r %s - STRAIGHT_JOIN release_files rf ON r.id = rf.releaseid + STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id WHERE rf.name %s %s", $ftJoin, $this->pdo->likeString('install.bin', true, true), @@ -531,7 +531,7 @@ class ReleaseRemover $this->query = sprintf( "SELECT r.guid, r.searchname, r.id FROM releases r %s - STRAIGHT_JOIN release_files rf ON r.id = rf.releaseid + STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id WHERE rf.name %s %s %s", $ftJoin, $this->pdo->likeString('password.url', true, true), @@ -743,7 +743,7 @@ class ReleaseRemover $this->query = sprintf( "SELECT r.guid, r.searchname, r.id FROM releases r %s - STRAIGHT_JOIN release_files rf ON r.id = rf.releaseid + STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id WHERE (rf.name REGEXP '[.]scr[$ \"]' OR r.name REGEXP '[.]scr[$ \"]') %s %s", $ftJoin, @@ -864,7 +864,7 @@ class ReleaseRemover ); if ($opTypeName == 'Subject') { - $join = (NN_RELEASE_SEARCH_TYPE == ReleaseSearch::SPHINX ? 'INNER JOIN releases_se rse ON rse.id = r.id' : 'INNER JOIN release_search_data rs ON rs.releaseid = r.id'); + $join = (NN_RELEASE_SEARCH_TYPE == ReleaseSearch::SPHINX ? 'INNER JOIN releases_se rse ON rse.id = r.id' : 'INNER JOIN release_search_data rs ON rs.releases_id = r.id'); } else { $join = ''; } @@ -931,7 +931,7 @@ class ReleaseRemover } } - $regexSQL = sprintf("STRAIGHT_JOIN release_files rf ON r.id = rf.releaseid + $regexSQL = sprintf("STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id WHERE rf.name REGEXP %s ", $this->pdo->escapeString($regex['regex']) ); @@ -1012,7 +1012,7 @@ class ReleaseRemover $this->query = " SELECT r.guid, r.searchname FROM releases r - LEFT JOIN release_files rf ON (r.id = rf.releaseid) + LEFT JOIN release_files rf ON (r.id = rf.releases_id) WHERE r.categories_id BETWEEN ' . Category::TV_ROOT . ' AND ' . Category::TV_OTHER . ' AND rf.name REGEXP 'x264.*\.wmv$' GROUP BY r.id" @@ -1054,7 +1054,7 @@ class ReleaseRemover $this->query = " SELECT r.guid, r.searchname, r.id FROM releases r - LEFT JOIN release_files rf ON r.id = rf.releaseid + LEFT JOIN release_files rf ON r.id = rf.releases_id WHERE {$categories} AND (r.imdbid NOT IN ('0000000', 0) OR xxxinfo_id > 0) AND r.nfostatus = 1 diff --git a/newznab/ReleaseSearch.php b/newznab/ReleaseSearch.php index bd26a1c46..ae97cd59c 100644 --- a/newznab/ReleaseSearch.php +++ b/newznab/ReleaseSearch.php @@ -40,7 +40,7 @@ class ReleaseSearch break; case self::FULLTEXT: default: - $this->fullTextJoinString = 'INNER JOIN release_search_data rs on rs.releaseid = r.id'; + $this->fullTextJoinString = 'INNER JOIN release_search_data rs on rs.releases_id = r.id'; break; } diff --git a/newznab/Releases.php b/newznab/Releases.php index 57d83e947..7082f1ca1 100755 --- a/newznab/Releases.php +++ b/newznab/Releases.php @@ -205,7 +205,7 @@ class Releases CONCAT(cp.id, ',', c.id) AS category_ids, (SELECT df.failed) AS failed, rn.id AS nfoid, - re.releaseid AS reid, + re.releases_id AS reid, v.tvdb, v.trakt, v.tvrage, v.tvmaze, v.imdb, v.tmdb, tve.title, tve.firstaired FROM @@ -222,8 +222,8 @@ class Releases INNER JOIN categories cp ON cp.id = c.parentid LEFT OUTER JOIN videos v ON r.videos_id = v.id LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id - LEFT OUTER JOIN video_data re ON re.releaseid = r.id - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN video_data re ON re.releases_id = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id GROUP BY r.id ORDER BY %7\$s %8\$s", @@ -479,13 +479,13 @@ class Releases CONCAT(cp.title, '-', c.title) AS category_name, %s AS category_ids, groups.name AS group_name, - rn.id AS nfoid, re.releaseid AS reid, + rn.id AS nfoid, re.releases_id AS reid, tve.firstaired, (SELECT df.failed) AS failed FROM releases r - LEFT OUTER JOIN video_data re ON re.releaseid = r.id + LEFT OUTER JOIN video_data re ON re.releases_id = r.id INNER JOIN groups ON groups.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN tv_episodes tve ON tve.videos_id = r.videos_id INNER JOIN categories c ON c.id = r.categories_id INNER JOIN categories cp ON cp.id = c.parentid @@ -604,14 +604,14 @@ class Releases sprintf(' DELETE r, rn, rc, uc, rf, ra, rs, rv, re, df FROM releases r - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id - LEFT OUTER JOIN release_comments rc ON rc.releaseid = r.id - LEFT OUTER JOIN user_downloads uc ON uc.releaseid = r.id - LEFT OUTER JOIN release_files rf ON rf.releaseid = r.id - LEFT OUTER JOIN release_audio ra ON ra.releaseid = r.id - LEFT OUTER JOIN release_subtitles rs ON rs.releaseid = r.id - LEFT OUTER JOIN video_data rv ON rv.releaseid = r.id - LEFT OUTER JOIN releaseextrafull re ON re.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id + LEFT OUTER JOIN release_comments rc ON rc.releases_id = r.id + LEFT OUTER JOIN user_downloads uc ON uc.releases_id = r.id + LEFT OUTER JOIN release_files rf ON rf.releases_id = r.id + LEFT OUTER JOIN release_audio ra ON ra.releases_id = r.id + LEFT OUTER JOIN release_subtitles rs ON rs.releases_id = r.id + LEFT OUTER JOIN video_data rv ON rv.releases_id = r.id + LEFT OUTER JOIN releaseextrafull re ON re.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id WHERE r.guid = %s', $this->pdo->escapeString($identifiers['g']) @@ -888,15 +888,15 @@ class Releases (SELECT df.failed) AS failed, groups.name AS group_name, rn.id AS nfoid, - re.releaseid AS reid, + re.releases_id AS reid, cp.id AS categoryparentid, v.tvdb, v.trakt, v.tvrage, v.tvmaze, v.imdb, v.tmdb, tve.firstaired FROM releases r - LEFT OUTER JOIN video_data re ON re.releaseid = r.id + LEFT OUTER JOIN video_data re ON re.releases_id = r.id LEFT OUTER JOIN videos v ON r.videos_id = v.id LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id INNER JOIN groups ON groups.id = r.groupid INNER JOIN categories c ON c.id = r.categories_id INNER JOIN categories cp ON cp.id = c.parentid @@ -983,15 +983,15 @@ class Releases %s AS category_ids, groups.name AS group_name, rn.id AS nfoid, - re.releaseid AS reid + re.releases_id AS reid FROM releases r LEFT OUTER JOIN videos v ON r.videos_id = v.id LEFT OUTER JOIN tv_info tvi ON v.id = tvi.videos_id LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id INNER JOIN categories c ON c.id = r.categories_id INNER JOIN groups ON groups.id = r.groupid - LEFT OUTER JOIN video_data re ON re.releaseid = r.id - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN video_data re ON re.releases_id = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id INNER JOIN categories cp ON cp.id = c.parentid %s", $this->getConcatenatedCategoryIDs(), @@ -1044,12 +1044,12 @@ class Releases %s AS category_ids, groups.name AS group_name, rn.id AS nfoid, - re.releaseid AS reid + re.releases_id AS reid FROM releases r INNER JOIN categories c ON c.id = r.categories_id INNER JOIN groups ON groups.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id - LEFT OUTER JOIN releaseextrafull re ON re.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id + LEFT OUTER JOIN releaseextrafull re ON re.releases_id = r.id INNER JOIN categories cp ON cp.id = c.parentid %s", $this->getConcatenatedCategoryIDs(), @@ -1105,7 +1105,7 @@ class Releases FROM releases r INNER JOIN groups g ON g.id = r.groupid INNER JOIN categories c ON c.id = r.categories_id - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id INNER JOIN categories cp ON cp.id = c.parentid %s", $this->getConcatenatedCategoryIDs(), diff --git a/newznab/Sharing.php b/newznab/Sharing.php index e1a23b0a5..8956654e0 100644 --- a/newznab/Sharing.php +++ b/newznab/Sharing.php @@ -174,7 +174,7 @@ Class Sharing 'SELECT rc.text, rc.id, %s, u.username, HEX(r.nzb_guid) AS nzb_guid FROM release_comments rc INNER JOIN users u ON rc.userid = u.id - INNER JOIN releases r on rc.releaseid = r.id + INNER JOIN releases r on rc.releases_id = r.id WHERE (rc.shared = 0 or issynced = 1) LIMIT %d', $this->pdo->unix_timestamp_column('rc.createddate'), $this->siteSettings['max_push'] @@ -301,7 +301,7 @@ Class Sharing SELECT r.id FROM release_comments rc INNER JOIN releases r USING (nzb_guid) - WHERE rc.releaseid = 0' + WHERE rc.releases_id = 0' ); $found = count($res); if ($found > 0) { @@ -310,9 +310,9 @@ Class Sharing sprintf(" UPDATE release_comments rc INNER JOIN releases r USING (nzb_guid) - SET rc.releaseid = %d, r.comments = r.comments + 1 + SET rc.releases_id = %d, r.comments = r.comments + 1 WHERE r.id = %d - AND rc.releaseid = 0", + AND rc.releases_id = 0", $row['id'], $row['id'] ) diff --git a/newznab/SphinxSearch.php b/newznab/SphinxSearch.php index 5986d3841..18c79fbb0 100755 --- a/newznab/SphinxSearch.php +++ b/newznab/SphinxSearch.php @@ -109,7 +109,7 @@ class SphinxSearch sprintf(' SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename FROM releases r - LEFT JOIN release_files rf ON (r.id=rf.releaseid) + LEFT JOIN release_files rf ON (r.id=rf.releases_id) WHERE r.id = %d GROUP BY r.id LIMIT 1', $releaseID diff --git a/newznab/SpotNab.php b/newznab/SpotNab.php index 67ae853af..a5de4b57c 100644 --- a/newznab/SpotNab.php +++ b/newznab/SpotNab.php @@ -897,7 +897,7 @@ class SpotNab { $affected = $this->_pdo->queryExec(sprintf('UPDATE release_comments, releases SET release_comments.gid = UNHEX(releases.nzb_guid), release_comments.nzb_guid = UNHEX(releases.nzb_guid) - WHERE releases.id = release_comments.releaseid + WHERE releases.id = release_comments.releases_id AND release_comments.gid IS NULL AND UNHEX(release_comments.nzb_guid) = "0" AND UNHEX(releases.nzb_guid) IS NOT NULL @@ -2046,7 +2046,7 @@ class SpotNab { $sql = sprintf("SELECT r.gid, rc.id, rc.text, u.username, " ."rc.isvisible, rc.createddate, rc.host " ."FROM release_comments rc " - ."JOIN releases r ON r.id = rc.releaseid AND rc.releaseid != 0 " + ."JOIN releases r ON r.id = rc.releases_id AND rc.releases_id != 0 " ."JOIN users u ON rc.userid = u.id AND rc.userid != 0 " ."WHERE r.gid IS NOT NULL " ."AND sourceid = 0 AND issynced = 0 " diff --git a/newznab/Users.php b/newznab/Users.php index 73c2254a2..14c3c06d3 100644 --- a/newznab/Users.php +++ b/newznab/Users.php @@ -732,7 +732,7 @@ class Users if ($releaseid != "") $releaseid = " AND releases.id = " . $this->pdo->escapeString($releaseid); - return $this->pdo->query(sprintf("SELECT users_releases.*, releases.searchname,releases.guid FROM users_releases INNER JOIN releases on releases.id = users_releases.releaseid WHERE userid = %d %s", $uid, $releaseid)); + return $this->pdo->query(sprintf("SELECT users_releases.*, releases.searchname,releases.guid FROM users_releases INNER JOIN releases on releases.id = users_releases.releases_id WHERE userid = %d %s", $uid, $releaseid)); } public function delCartByGuid($ids, $userID) @@ -1112,7 +1112,7 @@ class Users public function getDownloadRequestsForUser($userID) { return $this->pdo->query(sprintf('SELECT u.*, r.guid, r.searchname FROM user_downloads u - LEFT OUTER JOIN releases r ON r.id = u.releaseid + LEFT OUTER JOIN releases r ON r.id = u.releases_id WHERE u.userid = %d ORDER BY u.timestamp DESC', diff --git a/newznab/XXX.php b/newznab/XXX.php index e242724ef..648f30142 100644 --- a/newznab/XXX.php +++ b/newznab/XXX.php @@ -207,7 +207,7 @@ class XXX GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, - GROUP_CONCAT(rn.releaseid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, + GROUP_CONCAT(rn.releases_id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, GROUP_CONCAT(g.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, @@ -219,10 +219,10 @@ class XXX GROUP_CONCAT(cp.title, ' > ', c.title ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_catname, xxx.*, UNCOMPRESS(xxx.plot) AS plot, g.name AS group_name, - rn.releaseid AS nfoid + rn.releases_id AS nfoid FROM releases r LEFT OUTER JOIN groups g ON g.id = r.groupid - LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id + LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id LEFT OUTER JOIN categories c ON c.id = r.categories_id LEFT OUTER JOIN categories cp ON cp.id = c.parentid diff --git a/newznab/libraries/Forking.php b/newznab/libraries/Forking.php index b8e4013a1..e2d0256a9 100644 --- a/newznab/libraries/Forking.php +++ b/newznab/libraries/Forking.php @@ -505,7 +505,7 @@ class Forking extends \fork_daemon } switch($this->workTypeOptions[0]) { case "md5": - $join = "LEFT OUTER JOIN release_files rf ON (r.id = rf.releaseid) AND rf.ishashed = 1"; + $join = "LEFT OUTER JOIN release_files rf ON (r.id = rf.releases_id) AND rf.ishashed = 1"; $where = "r.ishashed = 1 AND r.dehashstatus BETWEEN -6 AND 0"; break; @@ -514,7 +514,7 @@ class Forking extends \fork_daemon break; case "filename": - $join = "INNER JOIN release_files rf ON rf.releaseid = r.id"; + $join = "INNER JOIN release_files rf ON rf.releases_id = r.id"; $where = "r.proc_files = 0"; break; diff --git a/newznab/processing/post/ProcessAdditional.php b/newznab/processing/post/ProcessAdditional.php index 7e37ff912..7a8c51fc4 100644 --- a/newznab/processing/post/ProcessAdditional.php +++ b/newznab/processing/post/ProcessAdditional.php @@ -1654,7 +1654,7 @@ class ProcessAdditional $releaseFiles = $this->pdo->queryOneRow( sprintf( ' - SELECT COUNT(release_files.releaseid) AS count, + SELECT COUNT(release_files.releases_id) AS count, SUM(release_files.size) AS size FROM release_files WHERE releaseid = %d', diff --git a/resources/db/patches/mysql/+3~general.sql b/resources/db/patches/mysql/+3~general.sql new file mode 100644 index 000000000..f3a3ceb21 --- /dev/null +++ b/resources/db/patches/mysql/+3~general.sql @@ -0,0 +1,26 @@ +# Change audio_data.releaseid to audio_data.releases_id to follow lithium convention. +ALTER TABLE audio_data CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change release_comments.releaseid to release_comments.releases_id to follow lithium convention. +ALTER TABLE release_comments CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change release_files.releaseid to release_files.releases_id to follow lithium convention. +ALTER TABLE release_files CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change release_nfos.releaseid to release_nfos.releases_id to follow lithium convention. +ALTER TABLE release_nfos CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change release_search_data.releaseid to release_search_data.releases_id to follow lithium convention. +ALTER TABLE release_search_data CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change release_subtitles.releaseid to release_subtitles.releases_id to follow lithium convention. +ALTER TABLE release_subtitles CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change releaseextrafull.releaseid to releaseextrafull.releases_id to follow lithium convention. +ALTER TABLE releaseextrafull CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change users_releases.releaseid to users_releases.releases_id to follow lithium convention. +ALTER TABLE users_releases CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; + +# Change video_data.releaseid to video_data.releases_id to follow lithium convention. +ALTER TABLE video_data CHANGE COLUMN releaseid releases_id INT(11) NOT NULL COMMENT 'FK to releases.id'; diff --git a/www/themes/Charisma/templates/searchraw.tpl b/www/themes/Charisma/templates/searchraw.tpl index ddf83eab3..cf11f7162 100755 --- a/www/themes/Charisma/templates/searchraw.tpl +++ b/www/themes/Charisma/templates/searchraw.tpl @@ -63,7 +63,7 @@ style="color:red;">{$result.binnum} /{$result.totalParts}</span>{else}100%{/if}</td> {/if} - <td class="less">{if $result.releaseid > 0}<a title="View Nzb details" + <td class="less">{if $result.releases_id > 0}<a title="View Nzb details" href="{$smarty.const.WWW_TOP}/details/{$result.guid}"> Yes</a>{/if}</td> </tr> diff --git a/www/themes/Charisma/templates/viewnzb.tpl b/www/themes/Charisma/templates/viewnzb.tpl index a701b6966..231072537 100755 --- a/www/themes/Charisma/templates/viewnzb.tpl +++ b/www/themes/Charisma/templates/viewnzb.tpl @@ -148,7 +148,7 @@ {if ($release.haspreview == 1 && $userdata.canpreview == 1) || ($release.haspreview == 2 && $userdata.canpreview == 1)} <li><a href="#pane7" data-toggle="tab">Preview</a></li> {/if} - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <li><a href="#pane8" data-toggle="tab">MediaInfo</a></li> {/if} {if isset($xxx.backdrop) && $xxx.backdrop == 1} @@ -640,7 +640,7 @@ data-target="#modal-image"/> </div> {/if} - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <div id="pane8" class="tab-pane"> <table style="width:100%;" class="data table table-condensed table-striped table-responsive table-hover"> diff --git a/www/themes/Gamma/templates/console.tpl b/www/themes/Gamma/templates/console.tpl index 799fa29d6..c959f755f 100755 --- a/www/themes/Gamma/templates/console.tpl +++ b/www/themes/Gamma/templates/console.tpl @@ -194,7 +194,7 @@ <div class="movextra"> <b>{$result.title|escape:"htmlall"}</b> <a class="rndbtn btn btn-mini btn-info" href="{$smarty.const.WWW_TOP}/console?platform={$result.platform}" title="View similar nzbs">Similar</a> {if $isadmin} - <a class="rndbtn btn btn-mini btn-warning" href="{$smarty.const.WWW_TOP}/admin/release-edit.php?id={$result.releaseid}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Edit Release">Edit</a> <a class="rndbtn confirm_action btn btn-mini btn-danger" href="{$smarty.const.WWW_TOP}/admin/release-delete.php?id={$result.releaseid}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Delete Release">Delete</a> + <a class="rndbtn btn btn-mini btn-warning" href="{$smarty.const.WWW_TOP}/admin/release-edit.php?id={$result.releases_id}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Edit Release">Edit</a> <a class="rndbtn confirm_action btn btn-mini btn-danger" href="{$smarty.const.WWW_TOP}/admin/release-delete.php?id={$result.releases_id}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Delete Release">Delete</a> {/if} <br /> <ul class="inline"> diff --git a/www/themes/Gamma/templates/games.tpl b/www/themes/Gamma/templates/games.tpl index 16030e820..c53fb3470 100755 --- a/www/themes/Gamma/templates/games.tpl +++ b/www/themes/Gamma/templates/games.tpl @@ -199,8 +199,8 @@ {/if} </li> {if $isadmin} - <a class="rndbtn confirm_action btn btn-mini btn-danger pull-right" href="{$smarty.const.WWW_TOP}/admin/release-delete.php?id={$result.releaseid}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Delete Release">Delete</a> - <a class="rndbtn btn btn-mini btn-warning pull-right" href="{$smarty.const.WWW_TOP}/admin/release-edit.php?id={$result.releaseid}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Edit Release">Edit</a> + <a class="rndbtn confirm_action btn btn-mini btn-danger pull-right" href="{$smarty.const.WWW_TOP}/admin/release-delete.php?id={$result.releases_id}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Delete Release">Delete</a> + <a class="rndbtn btn btn-mini btn-warning pull-right" href="{$smarty.const.WWW_TOP}/admin/release-edit.php?id={$result.releases_id}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Edit Release">Edit</a> {/if} </ul> {if isset($result.genre) && $result.genre != ""} diff --git a/www/themes/Gamma/templates/music.tpl b/www/themes/Gamma/templates/music.tpl index 86480d323..7f8aae44d 100755 --- a/www/themes/Gamma/templates/music.tpl +++ b/www/themes/Gamma/templates/music.tpl @@ -185,8 +185,8 @@ <b>{$result.title|escape:"htmlall"}</b> <a class="rndbtn btn btn-mini btn-info" href="{$smarty.const.WWW_TOP}/music?artist={$result.artist|escape:"url"}" title="View similar nzbs">Similar</a> {if $isadmin} - <a class="rndbtn btn btn-mini btn-warning" href="{$smarty.const.WWW_TOP}/admin/release-edit.php?id={$result.releaseid}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Edit Release">Edit</a> - <a class="rndbtn confirm_action btn btn-mini btn-danger" href="{$smarty.const.WWW_TOP}/admin/release-delete.php?id={$result.releaseid}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Delete Release">Delete</a> + <a class="rndbtn btn btn-mini btn-warning" href="{$smarty.const.WWW_TOP}/admin/release-edit.php?id={$result.releases_id}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Edit Release">Edit</a> + <a class="rndbtn confirm_action btn btn-mini btn-danger" href="{$smarty.const.WWW_TOP}/admin/release-delete.php?id={$result.releases_id}&from={$smarty.server.REQUEST_URI|escape:"url"}" title="Delete Release">Delete</a> {/if} <br/> <ul class="inline"> diff --git a/www/themes/Gamma/templates/searchraw.tpl b/www/themes/Gamma/templates/searchraw.tpl index 50f818a50..8140fd2e5 100755 --- a/www/themes/Gamma/templates/searchraw.tpl +++ b/www/themes/Gamma/templates/searchraw.tpl @@ -57,7 +57,7 @@ <td><span title="procstat">{$result.procstat}</span>/<span title="totalparts">{$result.totalParts}</span>/<span title="regex">{if $result.regexid == ""}_{else}{$result.regexid}{/if}</span>/<span title="relpart">{$result.relpart}</span>/<span title="reltotalpart">{$result.reltotalpart}</span></td> <td class="less">{if $result.binnum < $result.totalParts}<span class="label label-danger">{$result.binnum}/{$result.totalParts}</span>{else}<span class="label label-success">100%</span>{/if}</td> {/if} - <td class="less">{if $result.releaseid > 0}<a class="btn btn-mini" title="View Nzb details" href="{$smarty.const.WWW_TOP}/details/{$result.guid}/{$result.filename|escape:"seourl"}">Yes</a>{/if}</td> + <td class="less">{if $result.releases_id > 0}<a class="btn btn-mini" title="View Nzb details" href="{$smarty.const.WWW_TOP}/details/{$result.guid}/{$result.filename|escape:"seourl"}">Yes</a>{/if}</td> </tr> {/foreach} diff --git a/www/themes/Gamma/templates/viewnzb.tpl b/www/themes/Gamma/templates/viewnzb.tpl index 9e7781c86..b3128adf9 100755 --- a/www/themes/Gamma/templates/viewnzb.tpl +++ b/www/themes/Gamma/templates/viewnzb.tpl @@ -4,7 +4,7 @@ <div id="content"> <ul id="tabs" class="nav nav-tabs" data-tabs="tabs"> <li class="active"><a href="#info" data-toggle="tab">Info</a></li> - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <li><a href="#mediainfo" data-toggle="tab">Media info</a></li> {/if} {if $release.jpgstatus == 1 && $userdata.canpreview == 1} @@ -297,7 +297,7 @@ <dt>Category</dt> <dd><a title="Browse by {$release.category_name}" href="{$smarty.const.WWW_TOP}/browse?t={$release.categories_id}">{$release.category_name}</a></dd> - {if $nfo.releaseid|@count > 0} + {if $nfo.releases_id|@count > 0} <dt>Nfo</dt> <dd><a href="{$smarty.const.WWW_TOP}/nfo/{$release.guid}" title="View Nfo">View Nfo</a></dd> {/if} @@ -391,7 +391,7 @@ </dl> </div> <div class="tab-pane" id="mediainfo"> - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <td style="padding:0;"> <table style="width:100%;" class="innerdata highlight table table-striped"> <tr> diff --git a/www/themes/Gentele/templates/searchraw.tpl b/www/themes/Gentele/templates/searchraw.tpl index ddf83eab3..cf11f7162 100755 --- a/www/themes/Gentele/templates/searchraw.tpl +++ b/www/themes/Gentele/templates/searchraw.tpl @@ -63,7 +63,7 @@ style="color:red;">{$result.binnum} /{$result.totalParts}</span>{else}100%{/if}</td> {/if} - <td class="less">{if $result.releaseid > 0}<a title="View Nzb details" + <td class="less">{if $result.releases_id > 0}<a title="View Nzb details" href="{$smarty.const.WWW_TOP}/details/{$result.guid}"> Yes</a>{/if}</td> </tr> diff --git a/www/themes/Gentele/templates/viewnzb.tpl b/www/themes/Gentele/templates/viewnzb.tpl index 7fe66d217..b382d9319 100755 --- a/www/themes/Gentele/templates/viewnzb.tpl +++ b/www/themes/Gentele/templates/viewnzb.tpl @@ -152,7 +152,7 @@ {if ($release.haspreview == 1 && $userdata.canpreview == 1) || ($release.haspreview == 2 && $userdata.canpreview == 1)} <li role="presentation"><a href="#pane7" data-toggle="tab">Preview</a></li> {/if} - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <li role="presentation"><a href="#pane8" data-toggle="tab">MediaInfo</a></li> {/if} {if isset($xxx.backdrop) && $xxx.backdrop == 1} @@ -649,7 +649,7 @@ data-target="#modal-image"/> </div> {/if} - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <div id="pane8" class="tab-pane"> <table style="width:100%;" class="data table table-striped responsive-utilities jambo-table"> diff --git a/www/themes/Omicron/templates/searchraw.tpl b/www/themes/Omicron/templates/searchraw.tpl index ddf83eab3..cf11f7162 100755 --- a/www/themes/Omicron/templates/searchraw.tpl +++ b/www/themes/Omicron/templates/searchraw.tpl @@ -63,7 +63,7 @@ style="color:red;">{$result.binnum} /{$result.totalParts}</span>{else}100%{/if}</td> {/if} - <td class="less">{if $result.releaseid > 0}<a title="View Nzb details" + <td class="less">{if $result.releases_id > 0}<a title="View Nzb details" href="{$smarty.const.WWW_TOP}/details/{$result.guid}"> Yes</a>{/if}</td> </tr> diff --git a/www/themes/Omicron/templates/viewnzb.tpl b/www/themes/Omicron/templates/viewnzb.tpl index fbf070e1c..a94f87102 100755 --- a/www/themes/Omicron/templates/viewnzb.tpl +++ b/www/themes/Omicron/templates/viewnzb.tpl @@ -148,7 +148,7 @@ {if ($release.haspreview == 1 && $userdata.canpreview == 1) || ($release.haspreview == 2 && $userdata.canpreview == 1)} <li><a href="#pane7" data-toggle="tab">Preview</a></li> {/if} - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <li><a href="#pane8" data-toggle="tab">MediaInfo</a></li> {/if} {if isset($xxx.backdrop) && $xxx.backdrop == 1} @@ -640,7 +640,7 @@ data-target="#modal-image"/> </div> {/if} - {if $reVideo.releaseid|@count > 0 || $reAudio|@count > 0} + {if $reVideo.releases_id|@count > 0 || $reAudio|@count > 0} <div id="pane8" class="tab-pane"> <table style="width:100%;" class="data table table-condensed table-striped table-responsive table-hover">