Last active
August 29, 2015 14:19
-
-
Save eduo/5be67b78f7cef578330b to your computer and use it in GitHub Desktop.
HamsterSpit Libraries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
date_default_timezone_set('UTC'); | |
// Functions Start Here | |
thisHost="yourhost.com" | |
if(!function_exists('date_diff')) { | |
class DateInterval { | |
public $y; | |
public $m; | |
public $d; | |
public $h; | |
public $i; | |
public $s; | |
public $invert; | |
public function format($format) { | |
$format = str_replace('%R%y', ($this->invert ? '-' : '+') . $this->y, $format); | |
$format = str_replace('%R%m', ($this->invert ? '-' : '+') . $this->m, $format); | |
$format = str_replace('%R%d', ($this->invert ? '-' : '+') . $this->d, $format); | |
$format = str_replace('%R%h', ($this->invert ? '-' : '+') . $this->h, $format); | |
$format = str_replace('%R%i', ($this->invert ? '-' : '+') . $this->i, $format); | |
$format = str_replace('%R%s', ($this->invert ? '-' : '+') . $this->s, $format); | |
$format = str_replace('%y', $this->y, $format); | |
$format = str_replace('%m', $this->m, $format); | |
$format = str_replace('%d', $this->d, $format); | |
$format = str_replace('%h', $this->h, $format); | |
$format = str_replace('%i', $this->i, $format); | |
$format = str_replace('%s', $this->s, $format); | |
return $format; | |
} | |
} | |
function date_diff(DateTime $date1, DateTime $date2) { | |
$diff = new DateInterval(); | |
if($date1 > $date2) { | |
$tmp = $date1; | |
$date1 = $date2; | |
$date2 = $tmp; | |
$diff->invert = true; | |
} | |
$diff->y = ((int) $date2->format('Y')) - ((int) $date1->format('Y')); | |
$diff->m = ((int) $date2->format('n')) - ((int) $date1->format('n')); | |
if($diff->m < 0) { | |
$diff->y -= 1; | |
$diff->m = $diff->m + 12; | |
} | |
$diff->d = ((int) $date2->format('j')) - ((int) $date1->format('j')); | |
if($diff->d < 0) { | |
$diff->m -= 1; | |
$diff->d = $diff->d + ((int) $date1->format('t')); | |
} | |
$diff->h = ((int) $date2->format('G')) - ((int) $date1->format('G')); | |
if($diff->h < 0) { | |
$diff->d -= 1; | |
$diff->h = $diff->h + 24; | |
} | |
$diff->i = ((int) $date2->format('i')) - ((int) $date1->format('i')); | |
if($diff->i < 0) { | |
$diff->h -= 1; | |
$diff->i = $diff->i + 60; | |
} | |
$diff->s = ((int) $date2->format('s')) - ((int) $date1->format('s')); | |
if($diff->s < 0) { | |
$diff->i -= 1; | |
$diff->s = $diff->s + 60; | |
} | |
return $diff; | |
} | |
} | |
function encodethisurl($url) | |
{ | |
// safely cast back already encoded "&" within the query | |
$url = str_replace( "&","&",$url ); | |
$phpsep = (strlen(ini_get('arg_separator.input')>0)) ?ini_get('arg_separator.output'):"&"; | |
// cut optionally anchor | |
$ancpos = strrpos($url,"#"); | |
$lasteq = strrpos($url,"="); | |
$lastsep = strrpos($url,"&"); | |
$lastqsep = strrpos($url,"?"); | |
$firstsep = strpos($url, "?"); | |
$urlenc = ($firstsep > 0)?substr($url,0,$firstsep):$url; // encoded origin uri | |
// recognize wrong positioned anchor example.php#anchor?asdasd | |
if ($ancpos !== false | |
|| ($ancpos > 0 | |
&& ($lasteq > 0 && $lasteq < $ancpos ) | |
&& ($lastsep > 0 && $lastsep < $ancpos ) | |
&& ($lastqsep > 0 && $lastqsep < $ancpos ) | |
) | |
) | |
{ | |
$anc = "#" . myUrlEncode( substr( $url,$ancpos+1 ) ); | |
$url = substr( $url,0,$ancpos ); | |
} | |
else | |
{ | |
$anc = ""; | |
} | |
// separate uri and query string | |
if ($firstsep == false) | |
{ | |
$qry = ""; // no query | |
// $urlenc = $url.$anc; // anchor | |
$urlenc = str_replace(basename($url),urlencode(basename($url)),$url).$anc; // anchor | |
} | |
else | |
{ | |
$qry = substr( $url, $firstsep + 1 ) ; | |
$vals = explode( "&", $qry ); | |
$valsenc = array(); | |
foreach( $vals as $v ) | |
{ | |
$buf = explode( "=", $v ); | |
$buf[0]=urlencode($buf[0]); | |
$buf[1]=urlencode($buf[1]); | |
$valsenc[] = implode("=",$buf); | |
} | |
$urlenc = substr( $url, 0 , $firstsep ); // encoded origin uri | |
$urlenc.= "?" . implode($phpsep, $valsenc ) // encoded query string | |
. $anc; // anchor | |
} | |
$urlenc = htmlentities( $urlenc, ENT_QUOTES ); | |
// echo "Url was $url and now is $urlenc\n"; | |
return $urlenc; | |
} | |
function myUrlEncode($string) { | |
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D'); | |
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]"); | |
return str_replace($entities, $replacements, urlencode($string)); | |
} | |
function escape($str) | |
{ | |
$search=array("\\","\0","\n","\r","\x1a","'",'"'); | |
$replace=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); | |
return str_replace($search,$replace,$str); | |
} | |
if (!function_exists("preg_filter")) { | |
function preg_filter($pattern, $replacement, $subject, $limit=-1, $count=NULL) { | |
// just do the replacing first, and eventually filter later | |
$r = preg_replace($pattern, $replacement, $subject, $limit, $count); | |
// look at subject lines one-by-one, remove from result per index | |
foreach ((array)$subject as $si=>$s) { | |
$any = 0; | |
foreach ((array)$pattern as $p) { | |
$any = $any ||preg_match($p, $s); | |
} | |
// remove if NONE of the patterns matched | |
if (!$any) { | |
if (is_array($r)) { | |
unset($r[$si]); // del from result array | |
} | |
else { | |
return NULL; // subject was a str | |
} | |
} | |
} | |
return $r; // is already string if $subject was too | |
} | |
} | |
function parse_episode($title) { | |
$file = $title; | |
if(strpos($title,"/") > 0) { | |
$title = strrchr($title,"/"); | |
$title = str_replace("/","",$title); | |
} | |
$pos=strpos($title,".torrent"); | |
if($pos > 0) { | |
$name = substr($title,0,$pos); | |
} else { | |
$name = $title; | |
} | |
// echo "Name $name for title $title\n"; | |
$title = str_replace("."," ",$title); | |
$title = str_replace("-"," ",$title); | |
$title = str_replace("_"," ",$title); | |
$title = str_replace("'","",$title); | |
$title = ereg_replace("[ \t\n\r]+", " ", $title); | |
$title = str_replace("[Xx]264","",$title); | |
$title = str_replace("[aA][cC]3","",$title); | |
// echo "Checking for properness in $name\n"; | |
$title = str_replace("PROPER","",$title); | |
$title = str_replace("REPACK","",$title); | |
// echo "$name is now $title\n"; | |
$title = str_replace(" "," ",$title); | |
// Episodios Dobles Formato SxxExx-Exx - EpiDouble | |
$filter=preg_filter("/(.*) [Ss]([0-9][0-9]*)[Ee]([0-9][0-9]*) [Ee]([0-9][0-9]*).*/","\\1|\\2|\\3|\\4||||",$title); | |
if(strlen($filter) > 0) { return "$name|EP2|$filter"; } | |
// Episodios Dobles Formato SxxExxExx - EpiDouble | |
$filter=preg_filter("/(.*) [Ss]([0-9][0-9]*)[Ee]([0-9][0-9]*)[Ee]([0-9][0-9]*).*/","\\1|\\2|\\3|\\4||||",$title); | |
if(strlen($filter) > 0) { return "$name|EP2|$filter"; } | |
// Episodios Dobles Formato #x##-## - EpiDouble | |
$filter=preg_filter("/(.*) ([0-9][0-9]*)[Xx]([0-9][0-9]*) ([0-9][0-9]*).*/","\\1|\\2|\\3|\\4||||",$title); | |
if(strlen($filter) > 0) { return "$name|EP2|$filter"; } | |
// Episodios Simples Formato SxxExx - EpiNormal | |
$filter=preg_filter("/(.*) [Ss]([0-9][0-9]*)[Ee]([0-9][0-9]*).*/","\\1|\\2|\\3|||||",$title); | |
if(strlen($filter) > 0) { return "$name|EPI|$filter"; } | |
// Episodios Simples Formato #x## - EpiNormal | |
$filter=preg_filter("/(.*) ([0-9][0-9]*)[Xx]([0-9][0-9]*).*/","\\1|\\2|\\3|||||",$title); | |
if(strlen($filter) > 0) { return "$name|EPI|$filter"; } | |
// Episodios Formato Fecha yyyy mm dd - EpiDate | |
$filter=preg_filter("/(.*) (19[0-9]{2}|20[0-1][0-9]) (0[0-9]|1[0-2]) ([0-2][0-9]|3[0-1]) .*/","\\1||||\\2\\3\\4|||",$title); | |
if(strlen($filter) > 0) { return "$name|DAY|$filter"; } | |
// Episodios Formato Fecha mm dd yyyy - EpiDate | |
$filter=preg_filter("/(.*) (0[0-9]|1[0-2]) ([0-2][0-9]|3[0-1]) (19[0-9]{2}|20[0-1][0-9]) .*/","\\1||||\\4\\2\\3|||",$title); | |
if(strlen($filter) > 0) { return "$name|DAY|$filter"; } | |
// Episodios Especiales Formato Fecha Sxx - Special | |
$filter=preg_filter("/(.*) [Ss]([0-9][0-9]*) .*/","\\1|||||\\2||",$title); | |
if(strlen($filter) > 0) { return "$name|SPC|$filter"; } | |
// Episodios Especiales Formato Fecha Exx - Special | |
$filter=preg_filter("/(.*) [Ee]([0-9][0-9]*) .*/","\\1|||||\\2||",$title); | |
if(strlen($filter) > 0) { return "$name|SPC|$filter"; } | |
// Episodios Simples Formato Part #of# - Multipart | |
$filter=preg_filter("/(.*) Part ([0-9][0-9]*)[ ]*[Oo][Ff][ ]*([0-9][0-9]*).*/","\\1||||||\\2|\\3",$title); | |
if(strlen($filter) > 0) { return "$name|PRT|$filter"; } | |
// Episodios Simples Formato #of# - Multipart | |
$filter=preg_filter("/(.*) ([0-9][0-9]*)[ ]*[Oo][Ff][ ]*([0-9][0-9]*).*/","\\1||||||\\2|\\3",$title); | |
if(strlen($filter) > 0) { return "$name|PRT|$filter"; } | |
return "$name|UNK|UNK|||||||"; | |
} | |
function get_quality($title) { | |
// Check for 720p | |
$filter=preg_filter("/.*\.(720[Pp])\..*/","\\1",$title); | |
if(strlen($filter) > 0) { return "$title|720p"; } | |
// Check for WSp | |
$filter=preg_filter("/.*\.([Ww][Ss])\..*/","\\1",$title); | |
if(strlen($filter) > 0) { return "$title|WS"; } | |
return "$title|FS"; | |
} | |
function get_proper($title) { | |
// Check for PROPER | |
// echo "Searching for Proper in $title\n"; | |
$filter=preg_filter("/.*(PROPER).*/","\\1",$title); | |
// echo "Result for Proper in $title was $filter\n"; | |
if(strlen($filter) > 0) { return "1"; } | |
return "0"; | |
} | |
function insertTorrentList($title) { | |
list($fileURL, | |
$episodeID, | |
$fileEpisodeType, | |
$showID, | |
$fileSeason, | |
$fileEpisode1, | |
$fileEpisode2, | |
$fileShowDate, | |
$fileSpecialID, | |
$filePart, | |
$fileParts, | |
$fileQuality, | |
$fileReleaseGroup, | |
$filePublicationDate, | |
$fileProper, | |
$infoHash, | |
$magnetURI, | |
$fileSize) = explode('|',$title); | |
if(stripos($episodeID,'.PROPER.') > 0) { $fileProper = 1; } | |
$sql = " | |
INSERT IGNORE INTO Files | |
( | |
fileurl, | |
episodeid, | |
fileepisodetype, | |
showid, | |
fileseason, | |
fileepisode1, | |
fileepisode2, | |
fileshowdate, | |
filespecialid, | |
filepart, | |
fileparts, | |
filequality, | |
filereleasegroup, | |
filepublicationdate, | |
fileproper, | |
infoHash, | |
magnetURI, | |
fileSize) | |
VALUES ( | |
'$fileURL', | |
'$episodeID', | |
'$fileEpisodeType', | |
'$showID', | |
'$fileSeason', | |
'$fileEpisode1', | |
'$fileEpisode2', | |
'$fileShowDate', | |
'$fileSpecialID', | |
'$filePart', | |
'$fileParts', | |
'$fileQuality', | |
'$fileReleaseGroup', | |
'$filePublicationDate', | |
'$fileProper', | |
'$infoHash', | |
'$magnetURI', | |
'$fileSize'); | |
"; | |
// echo "$sql\n"; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect(); | |
$insertresult = $db->query($sql); | |
// echo "$showID: ($insertresult) ";print_r($insertresult);echo "\n"; | |
$db->close(); | |
} | |
function mkdir_recursive($pathname, $mode=0777) | |
{ | |
is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname), $mode); | |
return is_dir($pathname) || @mkdir($pathname, $mode); | |
} | |
function createRSSFile($showID) { | |
// Get most recent 25 items for a given Show | |
$sql = " | |
SELECT DISTINCT | |
s.showID, | |
s.showName, | |
s.showDescription, | |
fileSeason, | |
fileEpisodeType, | |
fileEpisode1, | |
fileEpisode2, | |
episodeDescription, | |
e.episodeTitle, | |
CONCAT(e.episodeAirDate,' ',s.showAirTime,':00 ',SUBSTRING_INDEX(s.showTimeZone,' ',1)) as episodeAired, | |
concat(e.episodeAirDate,' ',s.showAirTime) as origDate, | |
substring_index(s.showTimeZone,' ',1) as origTimeZone, | |
filePublicationDate as releaseDate, | |
fileURL, | |
DATE_FORMAT(filePublicationDate,'%a, %d %b %Y %T') AS filePublicationDate, | |
IF(LENGTH(episodeImage) > 5,episodeImage,'') as episodeImage, | |
IF(LENGTH(episodeScreenCap) > 5,episodeScreenCap,'') AS episodeScreenCap, | |
lower(f.infoHash) as infoHash, | |
-- f.magnetURI, | |
-- CONCAT('magnet:?xt=urn:btih:',lower(infohash),'&dn=',f.episodeID) AS magnetURI, | |
if(f.fileSize<128,128,f.fileSize) as fileSize, | |
f.fileepisodetype, | |
fileReleaseGroup, | |
if(fileQuality='720p',fileQuality,'SD') as fileQuality, | |
f.episodeID | |
FROM | |
Files f | |
INNER JOIN TorrentShowMaps t | |
ON f.showid = t.torrentshow | |
INNER JOIN Shows s | |
ON t.showid = s.showid | |
LEFT JOIN Episodes e | |
ON e.showID = s.showID | |
AND e.episodeSeasonNumber = f.fileseason | |
AND e.episodeInSeason = f.fileepisode1 | |
AND e.episodeInSeason > 0 | |
WHERE t.showid = '$showID' | |
ORDER BY releaseDate DESC | |
LIMIT 0, 25; | |
"; | |
// echo "<pre>\n$sql\n</pre>\n"; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect();$RSSItems = $db->query($sql);$db->close(); | |
if(count($RSSItems) != 0) { | |
extract($RSSItems[0]); | |
// <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | |
// http://$thisHost/rss/CougarTown/ | |
// '.htmlentities($showDescription).' | |
$xml = ' | |
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom"> | |
<channel> | |
<atom:link href="http://'.$thisHost.'/rss/'.$showID.'/" rel="self" type="application/rss+xml" /> | |
<image> | |
<title>'.$thisHost.'</title> | |
<url>http://www.'.$thisHost.'/hamsterspit-logo.png</url> | |
<link>http://'.$thisHost.'/</link> | |
</image> | |
<title>'.xmlentities($showName).' - Simple Feed</title> | |
<link>http://'.$thisHost.'/show/'.$showID.'/</link> | |
<description>5.<![CDATA[ | |
'.$showName.' - Simple Feed | |
]]> | |
</description> | |
<language>en-us</language> | |
<copyright>'.$thisHost.'</copyright> | |
<lastBuildDate>'.gmdate(DATE_RSS, time()).'</lastBuildDate> | |
<generator>SolScribe Hamster Factory</generator> | |
<webMaster>TheHamster@'.$thisHost.' ('.$thisHost.' Feedmaster)</webMaster> | |
<ttl>15</ttl>'; | |
$fullxml = ' | |
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom"> | |
<channel> | |
<atom:link href="http://'.$thisHost.'/fullrss/'.$showID.'/" rel="self" type="application/rss+xml" /> | |
<image> | |
<title>'.$thisHost.'</title> | |
<url>http://www.'.$thisHost.'/hamsterspit-logo.png</url> | |
<link>http://'.$thisHost.'/</link> | |
</image> | |
<title>'.xmlentities($showName).' - Full Feed - Torrent + Feed</title> | |
<link>http://'.$thisHost.'/show/'.$showID.'/</link> | |
<description>6.<![CDATA[ | |
'.$showName.' (Broadcatching Feed - Torrent + Magnet) | |
]]> | |
</description> | |
<language>en-us</language> | |
<copyright>'.$thisHost.'</copyright> | |
<lastBuildDate>'.gmdate(DATE_RSS, time()).'</lastBuildDate> | |
<generator>SolScribe Hamster Factory</generator> | |
<webMaster>TheHamster@'.$thisHost.' ('.$thisHost.' Feedmaster)</webMaster> | |
<ttl>15</ttl>'; | |
foreach($RSSItems as $RSSItem) { | |
extract($RSSItem); | |
$magnetURI = 'magnet:?xt=urn:btih:'.$infohash.'&dn='.xmlentities(f.episodeID); | |
$episodes=($fileEpisodeType=="EP2")?str_pad($fileEpisode1,2,'0',STR_PAD_LEFT) | |
.'-'.str_pad($fileEpisode2,2,'0',STR_PAD_LEFT):str_pad($fileEpisode1,2,'0',STR_PAD_LEFT); | |
$episodeData = $fileSeason.'x'.$episodes; | |
$episodesLong=($fileEpisodeType=="EP2")?"Episodes $fileEpisode1, $fileEpisode2":"Episode $fileEpisode1"; | |
$episodeDataLong = "Season $fileSeason, $episodesLong"; | |
$episodeTitle = (strlen($episodeTitle)>0)?' - '.$episodeTitle:''; | |
$finalTitle= $showName.' '.$episodeData.$episodeTitle; | |
if(!empty($episodeImage)) { | |
$episodeImage = "rss/$showID/banners/_cache/$episodeImage"; | |
if(file_exists($episodeImage) == true) { | |
$episodeImage = "http://".$thisHost."/SolBend/$episodeImage"; | |
$imageLink = '<img align="right" width="250px" style="float:right;vertical-align:top" src="'.$episodeImage.'">'; | |
} | |
} elseif(!empty($episodeScreenCap)) { | |
$episodeImage = str_ireplace("http://images.tvrage.com/screencaps","",$episodeScreenCap); | |
$episodeImage = "rss/$showID/screencaps/$episodeScreenCap"; | |
if(file_exists($episodeImage) == true) { | |
$episodeImage = "http://".$thisHost."/SolBend/$episodeImage"; | |
$imageLink = '<img align="right" width="250px" style="float:right;vertical-align:top" src="'.$episodeImage.'">'; | |
} | |
} else { | |
$imageLink = ''; | |
} | |
// echo "\n\nEncoding $fileURL\n"; | |
$thisFileURL = encodethisurl($fileURL); | |
switch ($fileQuality) { | |
case '720p': | |
$fileQuality = 'High-Definition (720p)'; | |
break; | |
default: | |
$fileQuality = 'Standard-Definition (SD)'; | |
} | |
$timezone = str_ireplace('GMT','',$origTimeZone); | |
// echo "Original date (timezone $timezone): $origDate\n"; | |
$origDate = strtotime($origDate)+($timezone*3600*-1); | |
// $releaseDate = strtotime($releaseDate); | |
$releaseDate = strtotime($releaseDate)+($timezone*3600*-1); | |
$timeDiff = abs($releaseDate-$origDate); | |
$hourDiff = floor($timeDiff/(60*60)); | |
$minuteDiff = floor(($timeDiff-$hourDiff*60*60)/60); | |
// $origDate = gmdate('Y-m-d H:i:s',$origDate); | |
$origDateF = gmdate('l, F j, Y, \a\t H:i',$origDate); | |
// $releaseDate = gmdate('Y-m-d H:i:s',$releaseDate); | |
$releaseDateF = gmdate('F j, \a\t H:i',$releaseDate); | |
$horas=""; | |
$minutos=""; | |
if($hourDiff > 0) { $horas= ($hourDiff > 1)?"$hourDiff hours":"$hourDiff hour"; } | |
if($minuteDiff > 0) { $minutos= ($minuteDiff > 1)?"$hourDiff minutes":"$hourDiff minute"; } | |
$elapsedTime = ($hourDiff > 0 && $minuteDiff > 0)?"$horas and $minutos":$horas.$minutos; | |
switch($fileReleaseGroup) { | |
case 'EZTV': | |
$releaseGroup = " by $fileReleaseGroup"; | |
break; | |
case 'VTV': | |
$releaseGroup = " by $fileReleaseGroup"; | |
break; | |
case 'MVGroup': | |
$releaseGroup = " by $fileReleaseGroup"; | |
break; | |
} | |
if($origDate > $releaseDate) { | |
$releaseBrag = "Aired on $origDateF<br>".$releaseGroup; | |
} else { | |
$releaseBrag = "Aired on $origDateF and released $elapsedTime later".$releaseGroup.", on $releaseDateF."; | |
} | |
$releaseBrag = (!empty($fileSize))?$releaseBrag.'<br>(File Size: '.$fileSize.')':$releaseBrag; | |
// echo "ReleaseDate is $releaseDate ($releaseDateF) - ".gmdate(DATE_RSS,$releaseDate)."\n"; | |
// $releaseBrag = (strlen($episodeDescription) > 5)?$releaseBrag."<br>Sinopsis: $episodeDescription":$releaseBrag; | |
// $releaseBrag = $releaseBrag."<br>$origDate - $releaseDate"; | |
$episodeType = ($fileEpisodeType=="EP2"?"(Double Episode)":"(Single Episode)"); | |
// <torrent xmlns="http://xmlns.ezrss.it/0.1/"> | |
$xml .= ' <item> | |
<title>'.xmlentities($episodeID).'</title> | |
<description>1.<![CDATA[ | |
<h1>'.$finalTitle.'</h1> | |
]]> | |
</description> | |
<pubDate>'.gmdate(DATE_RSS, $releaseDate).'</pubDate> | |
<enclosure url="'.$thisFileURL.'" type="application/x-bittorrent" length="'.$fileSize.'"/> | |
<link>'.$thisFileURL.'</link> | |
<guid isPermaLink="true">'.$thisFileURL.'</guid> | |
<torrent xmlns="http://xmlns.ezrss.it/0.1/"> | |
<fileName>'.$thisFileURL.'</fileName> | |
<infoHash>'.$infoHash.'</infoHash> | |
<magnetURI>'.$magnetURI.'</magnetURI> | |
<contentLength>'.$fileSize.'</contentLength> | |
<trackers> | |
<group order="random"> | |
<tracker>http://tracker.openbittorrent.com/announce</tracker> | |
</group> | |
</trackers> | |
</torrent> | |
</item> | |
'; | |
$fullxml .= ' <item> | |
<title>'.xmlentities($episodeID).'</title> | |
<description>2.<![CDATA[ | |
<h1>'.$finalTitle.'</h1> | |
'.$imageLink.' | |
<h2><a href="http://'.$thisHost.'/show/'.$showID.'/">'.$showName.'</a></h2>'.$episodeDataLong.'<strong>'.$episodeTitle.'</strong><br>'.$fileQuality.'<br> | |
<em>'.$episodeType.'</em><br>'.$releaseBrag.'<br><div style="text-align:center;margin:0px auto;"><a href="'.$magnetURI.'">Magnet</a> | <a href="'.$thisFileURL.'">Torrent</a></div> | |
]]> | |
</description> | |
<pubDate>'.gmdate(DATE_RSS, $releaseDate).'</pubDate> | |
<enclosure url="'.$thisFileURL.'" type="application/x-bittorrent" length="'.$fileSize.'"/> | |
<link>'.$thisFileURL.'</link> | |
<guid isPermaLink="true">'.$thisFileURL.'</guid> | |
<torrent xmlns="http://xmlns.ezrss.it/0.1/"> | |
<fileName>'.$thisFileURL.'</fileName> | |
<infoHash>'.$infoHash.'</infoHash> | |
<magnetURI>'.$magnetURI.'</magnetURI> | |
<contentLength>'.$fileSize.'</contentLength> | |
<trackers> | |
<group order="random"> | |
<tracker>http://tracker.openbittorrent.com/announce</tracker> | |
</group> | |
</trackers> | |
</torrent> | |
</item> | |
'; | |
} | |
$xml .= ' </channel> | |
</rss>'; | |
$fullxml .= ' </channel> | |
</rss>'; | |
// echo "<pre>$xml</pre>"; | |
$showPath = "rss/$showID"; | |
// Checks whether $showID directory exists | |
if(file_exists($showPath) == false) { | |
if(is_dir($showPath) == false) { | |
echo "Creating directory for $showID.\n"; | |
if(!mkdir_recursive("$showPath",0777)) { | |
die(); | |
} | |
} | |
} | |
// Reset RSS until fixed | |
$xml = ""; | |
$fullxml = $xml; | |
// echo "Creates $showID RSS regardless of whether it exists already in $showID"; | |
$xmlFile="rss/$showID/rss.xml"; | |
$xo = fopen($xmlFile,'w') or die('Error writing file $xmlFile'); | |
fwrite($xo,$xml); | |
fclose($xo); | |
$fullxmlFile="rss/$showID/fullrss.xml"; | |
$xo = fopen($fullxmlFile,'w') or die('Error writing file $fullxmlFile'); | |
fwrite($xo,$fullxml); | |
fclose($xo); | |
echo "Saving $fullxmlFile"; | |
} | |
} | |
function selfURL() { | |
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; | |
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; | |
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); | |
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; | |
} | |
function strleft($s1, $s2) { | |
return substr($s1, 0, strpos($s1, $s2)); | |
} | |
function get_headers_x($url,$format=0, $user='', $pass='', $referer='') { | |
$refererline = ''; | |
$authline = ''; | |
if (!empty($user)) { | |
$authentification = base64_encode($user.':'.$pass); | |
$authline = "Authorization: Basic $authentification\r\n"; | |
} | |
if (!empty($referer)) { | |
$refererline = "Referer: $referer\r\n"; | |
} | |
$url_info=parse_url($url); | |
$port = isset($url_info['port']) ? $url_info['port'] : 80; | |
$fp=fsockopen($url_info['host'], $port, $errno, $errstr, 30); | |
if($fp) { | |
$head = "GET ".@$url_info['path']."?".@$url_info['query']." HTTP/1.0\r\n"; | |
if (!empty($url_info['port'])) { | |
$head .= "Host: ".@$url_info['host'].":".$url_info['port']."\r\n"; | |
} else { | |
$head .= "Host: ".@$url_info['host']."\r\n"; | |
} | |
$head .= "Connection: Close\r\n"; | |
$head .= "Accept: */*\r\n"; | |
$head .= $refererline; | |
$head .= $authline; | |
$head .= "\r\n"; | |
fputs($fp, $head); | |
while(!feof($fp) or ($eoheader==true)) { | |
if($header=fgets($fp, 1024)) { | |
if ($header == "\r\n") { | |
$eoheader = true; | |
break; | |
} else { | |
$header = trim($header); | |
} | |
if($format == 1) { | |
$key = array_shift(explode(':',$header)); | |
if($key == $header) { | |
$headers[] = $header; | |
} else { | |
$headers[$key]=substr($header,strlen($key)+2); | |
} | |
unset($key); | |
} else { | |
$headers[] = $header; | |
} | |
} | |
} | |
return $headers; | |
} else { | |
// print "$errstr ($errno)<br />"; | |
return false; | |
} | |
} | |
function showFileName($filepath) | |
{ | |
preg_match('/[^?]*/', $filepath, $matches); | |
$string = $matches[0]; | |
#split the string by the literal dot in the filename | |
$pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); | |
#get the last dot position | |
$lastdot = $pattern[count($pattern)-1][1]; | |
#now extract the filename using the basename function | |
$filename = basename(substr($string, 0, $lastdot-1)); | |
#return the filename part | |
return $filename; | |
} | |
/** | |
* get_redirect_url() | |
* Gets the address that the provided URL redirects to, | |
* or FALSE if there's no redirect. | |
* | |
* @param string $url | |
* @return string | |
*/ | |
function get_redirect_url($url){ | |
$redirect_url = null; | |
$url_parts = @parse_url($url); | |
if (!$url_parts) return false; | |
if (!isset($url_parts['host'])) return false; //can't process relative URLs | |
if (!isset($url_parts['path'])) $url_parts['path'] = '/'; | |
$sock = fsockopen($url_parts['host'], (isset($url_parts['port']) ? (int)$url_parts['port'] : 80), $errno, $errstr, 30); | |
if (!$sock) return false; | |
$request = "HEAD " . $url_parts['path'] . (isset($url_parts['query']) ? '?'.$url_parts['query'] : '') . " HTTP/1.1\r\n"; | |
$request .= 'Host: ' . $url_parts['host'] . "\r\n"; | |
$request .= "Connection: Close\r\n\r\n"; | |
fwrite($sock, $request); | |
$response = ''; | |
while(!feof($sock)) $response .= fread($sock, 8192); | |
fclose($sock); | |
if (preg_match('/^Location: (.+?)$/m', $response, $matches)){ | |
if ( substr($matches[1], 0, 1) == "/" ) | |
return $url_parts['scheme'] . "://" . $url_parts['host'] . trim($matches[1]); | |
else | |
return trim($matches[1]); | |
} else { | |
return false; | |
} | |
} | |
/** | |
* get_all_redirects() | |
* Follows and collects all redirects, in order, for the given URL. | |
* | |
* @param string $url | |
* @return array | |
*/ | |
function get_all_redirects($url){ | |
$redirects = array(); | |
while ($newurl = get_redirect_url($url)){ | |
if (in_array($newurl, $redirects)){ | |
break; | |
} | |
$redirects[] = $newurl; | |
$url = $newurl; | |
} | |
return $redirects; | |
} | |
/** | |
* get_final_url() | |
* Gets the address that the URL ultimately leads to. | |
* Returns $url itself if it isn't a redirect. | |
* | |
* @param string $url | |
* @return string | |
*/ | |
function get_final_url($url){ | |
$redirects = get_all_redirects($url); | |
if (count($redirects)>0){ | |
return array_pop($redirects); | |
} else { | |
return $url; | |
} | |
} | |
function get_web_page( $url ) | |
{ | |
$options = array( | |
CURLOPT_RETURNTRANSFER => true, // return web page | |
CURLOPT_HEADER => true, // return headers | |
CURLOPT_FOLLOWLOCATION => true, // follow redirects | |
CURLOPT_ENCODING => "", // handle all encodings | |
CURLOPT_USERAGENT => "spider", // who am i | |
CURLOPT_AUTOREFERER => true, // set referer on redirect | |
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect | |
CURLOPT_TIMEOUT => 120, // timeout on response | |
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects | |
); | |
$ch = curl_init( $url ); | |
curl_setopt_array( $ch, $options ); | |
$content = curl_exec( $ch ); | |
$err = curl_errno( $ch ); | |
$errmsg = curl_error( $ch ); | |
$header = curl_getinfo( $ch ); | |
curl_close( $ch ); | |
//$header['errno'] = $err; | |
// $header['errmsg'] = $errmsg; | |
//$header['content'] = $content; | |
print($header[0]); | |
return $header; | |
} | |
class GetImage { | |
var $source; | |
var $save_to; | |
var $set_extension; | |
var $quality; | |
function download($method = 'curl',$new_name= "") // default method: cURL | |
{ | |
$info = @GetImageSize($this->source); | |
$mime = $info['mime']; | |
// What sort of image? | |
$type = substr(strrchr($mime, '/'), 1); | |
switch ($type) | |
{ | |
case 'jpeg': | |
$image_create_func = 'ImageCreateFromJPEG'; | |
$image_save_func = 'ImageJPEG'; | |
$new_image_ext = 'jpg'; | |
// Best Quality: 100 | |
$quality = isSet($this->quality) ? $this->quality : 100; | |
break; | |
case 'png': | |
$image_create_func = 'ImageCreateFromPNG'; | |
$image_save_func = 'ImagePNG'; | |
$new_image_ext = 'png'; | |
// Compression Level: from 0 (no compression) to 9 | |
$quality = isSet($this->quality) ? $this->quality : 0; | |
break; | |
case 'bmp': | |
$image_create_func = 'ImageCreateFromBMP'; | |
$image_save_func = 'ImageBMP'; | |
$new_image_ext = 'bmp'; | |
break; | |
case 'gif': | |
$image_create_func = 'ImageCreateFromGIF'; | |
$image_save_func = 'ImageGIF'; | |
$new_image_ext = 'gif'; | |
break; | |
case 'vnd.wap.wbmp': | |
$image_create_func = 'ImageCreateFromWBMP'; | |
$image_save_func = 'ImageWBMP'; | |
$new_image_ext = 'bmp'; | |
break; | |
case 'xbm': | |
$image_create_func = 'ImageCreateFromXBM'; | |
$image_save_func = 'ImageXBM'; | |
$new_image_ext = 'xbm'; | |
break; | |
default: | |
$image_create_func = 'ImageCreateFromJPEG'; | |
$image_save_func = 'ImageJPEG'; | |
$new_image_ext = 'jpg'; | |
} | |
if(strlen($new_name)<1) { | |
if(isSet($this->set_extension)) | |
{ | |
$ext = strrchr($this->source, "."); | |
$strlen = strlen($ext); | |
$new_name = basename(substr($this->source, 0, -$strlen)).'.'.$new_image_ext; | |
} | |
else | |
{ | |
$new_name = basename($this->source); | |
} | |
} | |
$save_to = $this->save_to.$new_name; | |
// print "File to download will be $save_to\n"; | |
if($method == 'curl') | |
{ | |
$save_image = $this->LoadImageCURL($save_to); | |
} | |
elseif($method == 'gd') | |
{ | |
$img = $image_create_func($this->source); | |
if(isSet($quality)) | |
{ | |
$save_image = $image_save_func($img, $save_to, $quality); | |
} | |
else | |
{ | |
$save_image = $image_save_func($img, $save_to); | |
} | |
} | |
return $save_image; | |
} | |
function LoadImageCURL($save_to) | |
{ | |
$ch = curl_init($this->source); | |
/* echo "Auxilio! $save_to"; | |
if(substr($save_to,1,1)=='/') { | |
$save_to = | |
}*/ | |
$fp = fopen($save_to, "wb"); | |
// set URL and other appropriate options | |
$options = array(CURLOPT_FILE => $fp, | |
CURLOPT_HEADER => 0, | |
CURLOPT_FOLLOWLOCATION => 1, | |
CURLOPT_TIMEOUT => 60); // 1 minute timeout (should be enough) | |
curl_setopt_array($ch, $options); | |
curl_exec($ch); | |
curl_close($ch); | |
fclose($fp); | |
} | |
} | |
function mem($process='Process') { | |
return number_format(memory_get_usage(), 0, '.', ',')." bytes : $process"; | |
} | |
function dd($v) { | |
global $a; | |
echo "<blockquote>\n"; | |
$q= "while(list(\$key,\$val) = each($".$v. ") ) { ". | |
" echo \"<b>\$key</b>=>\$val.<br>\";". | |
" if(( is_array(\$val)) && (\$key != \"GLOBALS\")) {". | |
" @dd( \$v.\"[\".\$key.\"]\" );". | |
"}}"; | |
eval($q); | |
echo "</blockquote>\n"; | |
} | |
function array_size($arr) { | |
ob_start(); | |
print_r($arr); | |
$mem = ob_get_contents(); | |
ob_end_clean(); | |
$mem = preg_replace("/\n +/", "", $mem); | |
$mem = strlen($mem); | |
return $mem; | |
} | |
function getDataFileContents($show,$type) { | |
extract($show); | |
$showPath = "rss/$showID/"; | |
$days = 1; | |
switch($type) { | |
case 'showName': | |
$fileName = 'id-tvcom.html'; | |
$url = "http://epguides.com/$showEpguides/"; | |
$CURLOPT_COOKIE = 'ListDisplay=tv.com'; | |
break; | |
case 'TVCOMID': | |
$fileName = 'id-tvcom.html'; | |
$url = "http://epguides.com/$showEpguides/"; | |
$CURLOPT_COOKIE = 'ListDisplay=tv.com'; | |
break; | |
case 'IMDBID': | |
$fileName = 'id-tvcom.html'; | |
$url = "http://epguides.com/$showEpguides/"; | |
$CURLOPT_COOKIE = 'ListDisplay=tv.com'; | |
break; | |
case 'TVRAGEID': | |
$fileName = 'id-tvrage.html'; | |
$url = "http://epguides.com/$showEpguides/"; | |
$CURLOPT_COOKIE = 'ListDisplay=tvrage.com'; | |
break; | |
case 'TVDBID': | |
$fileName = 'id-tvdb.html'; | |
$url = "http://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=$showIMDBID"; | |
echo "\n$url\n"; | |
$CURLOPT_COOKIE = 'ListDisplay=tvrage.com'; | |
break; | |
case 'TVDBBANNERS': | |
$fileName = 'banner-tvdb.html'; | |
$url = "http://thetvdb.com/api/57B6D2941EA0A254/series/$showTVDBID/banners.xml"; | |
$CURLOPT_COOKIE = 'ListDisplay=tvrage.com'; | |
$days = 7; | |
break; | |
case 'TVDBEPISODES': | |
$fileName = 'eps-tvdb.html'; | |
$url = "http://thetvdb.com/api/57B6D2941EA0A254/series/$showTVDBID/all/en.xml"; | |
$CURLOPT_COOKIE = 'ListDisplay=tvrage.com'; | |
$days = 7; | |
break; | |
case 'TVREPS': | |
$fileName = 'eps-tvrage.html'; | |
$url = "http://services.tvrage.com/feeds/full_show_info.php?sid=".str_ireplace('id-','',$showTVRageID); | |
// echo "\n$url\n"; | |
// return($url); | |
$CURLOPT_COOKIE = 'ListDisplay=tvrage.com'; | |
break; | |
} | |
$getFile = false; | |
$filePath = $showPath.$fileName; | |
// echo "$type - Checking $filePath.\n"; | |
if(file_exists($filePath) == true) { | |
if ((time() - filemtime($filePath)) > ($days *86400)) { | |
// unlink("$tvcomPath"); | |
$getFile = true; | |
} elseif (filesize($filePath)< 20) { | |
$getFile = true; | |
} else { | |
$data=file_get_contents($filePath); | |
} | |
} else { | |
$getFile = true; | |
} | |
if($getFile == true) { | |
echo "File $filePath doesn't exist. Downloading.\n"; | |
$url = get_final_url($url); | |
$header = get_headers_x($url); | |
if(stripos($header[0],'404') > 0) { | |
echo "404 - Page not present: $url\n"; | |
continue; | |
} | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_COOKIE,$CURLOPT_COOKIE); | |
curl_setopt($ch, CURLOPT_URL,$url); | |
ob_start(); | |
curl_exec($ch); | |
$data = ob_get_contents(); | |
ob_end_clean(); | |
curl_close($ch); | |
$xo = fopen($filePath,'w') or die('Error writing file $filePath'); | |
fwrite($xo,$data); | |
fclose($xo); | |
} | |
return $data; | |
} | |
function getSingleShowDiv($showID) { | |
$sql = "SELECT | |
if(showEnded = '0000-00-0000' AND (showStatus != 'Canceled/Ended' || showStatus is NULL),'active','inactive') as hint, | |
showName, showSeasons, showStatus,showEnded, | |
Ifnull(showBanner, '') AS showBanner, | |
showTVComID, showEpguides, showTVRageID, | |
showIMDBID, | |
IF(showTVDBID = 999999, NULL, showTVDBID) AS showTVDBID, | |
IF(LENGTH(showBanner) > 0, 1, 0) AS gotBanner, | |
IF(LENGTH(showFanart) > 0, 1, 0) AS gotFanart, | |
IF(LENGTH(showPoster) > 0, 1, 0) AS gotPoster | |
FROM Shows | |
WHERE 1 = 1 | |
AND showID = '$showID' | |
-- AND showEnded = '0000-00-0000' | |
-- AND (showStatus != 'Canceled/Ended' || showStatus is NULL) | |
ORDER BY gotBanner DESC, | |
showName ASC | |
limit 0,1;" | |
; | |
// echo "<br><pre>$sql</pre><br>"; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect(); | |
$shows=$db->query($sql); | |
$db->close(); | |
$show = $shows[0]; | |
// echo "<br>Show ($showID): ".print_r($show)."<br><br>"; | |
extract($show); | |
if($gotBanner==1 && file_exists("SolBend/rss/$showID/img/banner_t.jpg")) { | |
$bannertd = "<td class=\"banner\"><div class=\"banner\"><img src=\"/SolBend/rss/$showID/img/banner_t.jpg\"></div></td>"; | |
} else { | |
$bannertd = "<td class=\"banner\"><div class=\"banner\"> </div></td>"; | |
} | |
if($gotPoster==1 && file_exists("SolBend/rss/$showID/img/poster_t.jpg")) { | |
$posterdiv = "<div class=\"poster\"><img src=\"/SolBend/rss/$showID/img/poster_t.jpg\"></div>"; | |
} else { | |
} | |
if($gotFanart==1 && file_exists("SolBend/rss/$showID/img/fanart_t.jpg")) { | |
$fanartdiv = "<div class=\"fanart\"><img src=\"/SolBend/rss/$showID/img/fanart_t.jpg\"></div>"; | |
} else { | |
} | |
$seasonsspan=""; | |
if(!empty($showSeasons)) { | |
$seasonsspan = "<span class=\"seasons\"> ($showSeasons seasons)</span>"; | |
} | |
$statusspan = " "; | |
if(!empty($showStatus)) { | |
$statusspan = "<span class=\"shostatus\">$showStatus</span>"; | |
} | |
$rssFeed = ""; | |
if($hint == 'active' && file_exists("rss/$showID/rss.xml")) { | |
$rssFeed = " (<a href=\"".SERVEURI."rss/$showID/rss.xml\">rss</a>)"; | |
} | |
$shownametd ="<td class=\"showData\"><a href=\"?action=showInfo&showID=$showID\">$showName</a>$rssFeed<br>".$statusspan.$seasonsspan."</td>"; | |
if(!empty($showTVDBID)) { $linktvdb = "<a href=\"http://thetvdb.com/index.php?tab=series&id=$showTVDBID\">[TVDB]</a>"; } | |
else { $linktvdb = "<a href=\"http://thetvdb.com/index.php?string=".urlencode($showName)."&searchseriesid=&tab=listseries&function=Search\">[NODB]</a>"; } | |
if(!empty($showTVRageID)) { $linktvrage = "<a href=\"http://www.tvrage.com/shows/$showTVRageID\">[TVRage]</a>"; } | |
else { $linktvrage = "<a href=\"http://www.tvrage.com/search.php?search=".urlencode($showName)."\">[NORage]</a>"; } | |
if(!empty($showEpguides)) { | |
$linkepguides = "<a href=\"http://epguides.com/$showEpguides/\">[Epguides]</a>"; | |
} else { | |
if(empty($showname)) { $showName = $showID; } | |
$epguidesURL = getEpguidesURL($showName); | |
if(!empty($epguidesURL)) { | |
$linkepguides = "<a href=\"$epguidesURL\">[NEWE]</a>"; | |
} else { | |
$linkepguides = "[NOE]"; | |
} | |
} | |
if(!empty($showTVComID)) { $linktvcom = "<a href=\"http://www.tv.com/show/$showTVComID/summary.html\">[TV.Com]</a>"; } | |
else { $linktvcom= "[TV.Com]"; } | |
if(!empty($showIMDBID)) { $linkimdb = "<a href=\"http://imdb.com/title/$showIMDBID\">[IMDB]</a>"; } | |
else { $linkimdb= "[IMDB]"; } | |
$linksdivs = "<div>$linktvdb</div> | |
<div>$linktvrage</div> | |
<div>$linkepguides</div> | |
<div>$linktvcom</div> | |
<div>$linkimdb</div>"; | |
$thisShowDiv .= "<div class=\"singleshow\"> | |
<table> | |
<tr class=\"banner\"> | |
$bannertd | |
</tr> | |
<tr> | |
$shownametd | |
</tr> | |
<tr class=\"links\"> | |
<td> | |
$linksdivs | |
</td> | |
</tr> | |
</table> | |
</div>\n"; | |
return $thisShowDiv; | |
} | |
function getEpguidesURL($showid) { | |
$newshowid=preg_replace('/^[tT][hH][eE]/','',$showid); | |
$newshowid = str_ireplace(' ','',ucwords($newshowid)); | |
$url="http://epguides.com/$newshowid/"; | |
$header = get_headers_x($url); | |
if(stripos($header[0],'404') > 0) { | |
$url= ''; | |
return $url; | |
} else { | |
$url = get_final_url($url); | |
} | |
$header = get_headers_x($url); | |
if(stripos($header[0],'404') > 0) { | |
$url= ''; | |
return $url; | |
} else { | |
if(substr($url,0,4) == 'http') { } else { $url = ''; } | |
return $url; | |
} | |
} | |
function getShowImage($type,$imgName,$imgPath) { | |
// print "pelos pelos pelos"; | |
$imgFile = "$imgPath/$type/".basename($imgName); | |
$url = "http://thetvdb.com/banners/$imgName"; | |
$imgFilePathParts = pathinfo($url); | |
$imgExt = $imgFilePathParts['extension']; | |
$imgLink = "$imgPath/$type.$imgExt"; | |
$makeThumb = true; | |
if(!mkdir_recursive("$imgPath/$type",0777)) { | |
// die(); | |
} | |
if(file_exists($imgFile)) { | |
$return = " !"; | |
$makeThumb = false; | |
} else { | |
$img = new GetImage; | |
$img->source = $url; | |
// echo "$imgPath/$type/"; | |
// exit; | |
$img->save_to = "$imgPath/$type/"; | |
$get = $img->download('curl'); | |
if($get){ } | |
$return = " [DL'd]..."; | |
} | |
// echo "link($imgFile,$imgLink)"; | |
if(file_exists($imgFile)) { | |
// echo "File $imgFile exists. Checking for link $imgLink\n"; | |
if(file_exists($imgLink)) { | |
// echo "File $imgLink exists. Deleting...\n"; | |
unlink($imgLink); | |
} else { | |
// echo "Link $imgLink didn't exist.\n"; | |
} | |
link($imgFile,$imgLink); | |
if(file_exists($imgLink)) { | |
$return = " [Linked]..."; | |
} else { | |
} | |
$thumbFile = $type."_t.".$imgExt; | |
if(file_exists($imgPath."/".$thumbFile)) { | |
unlink($imgPath."/".$thumbFile); | |
} | |
if(!file_exists($imgPath."/".$thumbFile)) { | |
$thumb = new GetImage; | |
switch($type) { | |
case 'banner': | |
$sizes="width=436&height=436&"; | |
break; | |
case 'poster': | |
$sizes="width=160&height=160&"; | |
break; | |
case 'fanart': | |
$sizes="width=436&height=436&"; | |
break; | |
} | |
$thumbURL = SERVERURI."image.php/".$type."_t.".$imgExt."?".$sizes."image=/SolBend/$imgFile"; | |
// echo "\n\n$thumbURL\n\n"; | |
$thumb->source = $thumbURL; | |
$thumbFile = $type."_t.".$imgExt; | |
$thumb->save_to = $imgPath; | |
$thumbGet = $thumb->download('curl',"/".$thumbFile); | |
if($thumbGet){ } | |
$return = " [Thumbed]... $thumbURL \n"; | |
} else { | |
} | |
} | |
return $return; | |
} | |
function getThumbImgs($thumbType) { | |
/* | |
switch($thumbType) { | |
default: | |
$sql = " | |
SELECT | |
COUNT(*) AS total | |
FROM ThumbShows | |
WHERE thumbType = $thumbType | |
; | |
"; | |
} | |
// echo $sql."<br>"; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect(); | |
$lines = $db->query($sql); | |
$db->close(); | |
$thistotal = 0; | |
foreach($lines as $line) { | |
extract($line); | |
$lasttotal = $thistotal; | |
$thistotal = $thistotal + $total; | |
$randomline = rand($lasttotal,$thistotal-1); | |
*/ | |
switch ($thumbType) { | |
case 1: | |
$sql = " | |
SELECT showID,SUBSTRING_INDEX(showName,' (',1) showName FROM | |
(SELECT T.showID,max(F.FilePublicationDate) maxDate,S.showName | |
FROM Files F, TorrentShowMaps T, Shows S,ThumbShows TS | |
WHERE F.showID = T.TorrentShow | |
AND T.ShowID = S.ShowID | |
AND TS.ShowID = S.ShowID | |
AND TS.ThumbType = 1 | |
GROUP BY T.ShowID | |
ORDER BY maxDate DESC | |
LIMIT 0,100) t1 | |
ORDER BY RAND() LIMIT 0,4 | |
;"; | |
break; | |
case 2: | |
$sql = " | |
SELECT showID,SUBSTRING_INDEX(showName,' (',1) showName FROM | |
(SELECT S.showID, | |
-- CONCAT( | |
showName | |
-- ',<br>',REPEAT('★',FLOOR(showTVDBRating/2)),REPEAT('☆',(5-FLOOR(showTVDBRating/2)))) showName | |
FROM | |
Shows S,ThumbShows TS | |
WHERE showStatus in | |
('Returning Series','TBD/On The Bubble') | |
AND TS.ShowID = S.ShowID | |
AND TS.ThumbType = 1 | |
ORDER BY showTVDBRating DESC | |
LIMIT 0,100) t1 | |
ORDER BY RAND() LIMIT 0,4 | |
;"; | |
break; | |
case 3: | |
$sql = " | |
SELECT showID,SUBSTRING_INDEX(showName,' (',1) showName FROM | |
(SELECT S.showID,showName | |
FROM | |
Shows S,ThumbShows TS | |
WHERE showStatus in | |
('New Series') | |
AND TS.ShowID = S.ShowID | |
AND TS.ThumbType = 1 | |
ORDER BY S.showStarted DESC | |
LIMIT 0,20) t1 | |
ORDER BY RAND() LIMIT 0,4 | |
;"; | |
break; | |
case 4: | |
$sql = " | |
SELECT DISTINCT S.showID,SUBSTRING_INDEX(S.showName,' (',1) showName | |
FROM Files F, TorrentShowMaps T, Shows S,ThumbShows TS | |
WHERE F.showID = T.TorrentShow | |
AND T.ShowID = S.ShowID | |
AND TS.ShowID = S.ShowID | |
AND TS.ThumbType = 1 | |
ORDER BY RAND() LIMIT 0,4 | |
;"; | |
break; | |
default: | |
$sql = " | |
SELECT showID,showName FROM | |
(SELECT T.showID,max(F.FilePublicationDate) maxDate,S.showName | |
FROM Files F, TorrentShowMaps T, Shows S | |
WHERE F.showID = T.TorrentShow | |
AND T.ShowID = S.ShowID | |
GROUP BY T.ShowID | |
ORDER BY maxDate DESC | |
LIMIT 0,100) t1 | |
ORDER BY RAND() LIMIT 0,4 | |
; | |
"; | |
// echo $sql."<br>"; | |
} | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect();$showValues = $db->query($sql);$db->close(); | |
foreach($showValues as $showValue) { | |
extract($showValue); | |
if(file_exists("SolBend/rss/$showID/img/poster_t.jpg")) { | |
$divs .= "<div class=\"mainThumb\"><a href=\"/show/$showID\" rel=\"external\"><img class=\"mainThumb\" title=\"$showName\" src=\"".SERVERURI."rss/$showID/img/poster_t.jpg\"><div class=\"show-description\">$showName</div></a></div>"; | |
} else { | |
// $divs .= "<div class=\"mainThumb NoTitle\"><div class=\"show-description-big\"><a href=\"/show/$showID\" rel=\"external\">$showName</a></div></div>"; | |
$divs .= "<div class=\"mainThumb NoTitle\"><a href=\"/show/$showID\" rel=\"external\">$showName</a></div>"; | |
} | |
} | |
// } | |
return $divs; | |
} | |
function getNewShows() { | |
// $db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$showshortcuts .=' <div id="recent"><div class="thumbTitle">Recently Updated</div><div | |
class="thumbRow">'.getThumbImgs(1).'</div></div>'."\n"; | |
$showshortcuts .=' <div id="popular"><div class="thumbTitle">Popular Shows</div><div | |
class="thumbRow">'.getThumbImgs(2).'</div></div>'."\n"; | |
$showshortcuts .=' <div id="new"><div class="thumbTitle">Young Shows</div><div | |
class="thumbRow">'.getThumbImgs(3).'</div></div>'."\n"; | |
$showshortcuts .=' <div id="popular"><div class="thumbTitle">Random Shows</div><div | |
class="thumbRow">'.getThumbImgs(4).'</div></div>'."\n"; | |
return $showshortcuts; | |
} | |
function getCalPage($date) { | |
// $newDate =date(strtotime($date)); | |
$newDate = new DateTime($date); | |
$year = date_format($newDate,'Y'); | |
$month = date_format($newDate,'M'); | |
$day = date_format($newDate,'j'); | |
$calDiv = "<div class=\"calpage\">$day<br><span class=\"calpageMonth\">$month</span><br>$year</div>"; | |
return $calDiv; | |
} | |
function arr_search ( $array, $expression ) { | |
$result = array(); | |
$expression = preg_replace ( "/([^\s]+?)(=|<|>|!)/", "\$a['$1']$2", $expression ); | |
foreach ( $array as $a ) if ( eval ( "return $expression;" ) ) $result[] = $a; | |
return $result; | |
} | |
function addLog() { | |
$time = date("M j G:i:s Y"); | |
$ip = getenv('REMOTE_ADDR'); | |
$userAgent = getenv('HTTP_USER_AGENT'); | |
$referrer = getenv('HTTP_REFERER'); | |
$query = getenv('QUERY_STRING'); | |
$page = getenv('SCRIPT_NAME'); | |
$sql = "INSERT INTO accesslog | |
(page,time,ip,userAgent,referrer,query) | |
values ('$page',now(),'$ip','$userAgent','$referrer','$query');"; | |
// phpinfo(); | |
// echo $sql; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect(); | |
$db->query($sql); | |
$db->close(); | |
} | |
function createFullRSSFile() { | |
// Get most recent 100 items for all Shows | |
$sql = " | |
SELECT DISTINCT | |
s.showID, | |
s.showName, | |
s.showDescription, | |
fileSeason, | |
fileEpisodeType, | |
fileEpisode1, | |
fileEpisode2, | |
episodeDescription, | |
e.episodeTitle, | |
CONCAT(e.episodeAirDate,' ',s.showAirTime,':00 ',SUBSTRING_INDEX(s.showTimeZone,' ',1)) as episodeAired, | |
concat(e.episodeAirDate,' ',s.showAirTime) as origDate, | |
substring_index(s.showTimeZone,' ',1) as origTimeZone, | |
filePublicationDate as releaseDate, | |
fileURL, | |
DATE_FORMAT(filePublicationDate,'%a, %d %b %Y %T') AS filePublicationDate, | |
IF(LENGTH(episodeImage) > 5,episodeImage,'') as episodeImage, | |
IF(LENGTH(episodeScreenCap) > 5,episodeScreenCap,'') AS episodeScreenCap, | |
-- IF(LENGTH(episodeImage) > 5,CONCAT('http://thetvdb.com/banners/',episodeImage), | |
-- IF(LENGTH(episodeScreenCap) < 5,episodeScreenCap,'')) AS episodeImage, | |
lower(f.infoHash) as infoHash, | |
-- f.magnetURI, | |
CONCAT('magnet:?xt=urn:btih:',lower(infoHash),'&dn=',f.episodeID) AS magnetURI, | |
if(f.fileSize<128,128,f.fileSize) as fileSize, | |
f.fileepisodetype, | |
fileReleaseGroup, | |
if(fileQuality='720p',fileQuality,'SD') as fileQuality, | |
f.episodeID | |
FROM | |
Files f, | |
TorrentShowMaps t, | |
Shows s | |
LEFT JOIN Episodes e | |
ON e.showID = s.showID | |
AND e.episodeInSeason > 0 | |
WHERE f.showid = t.torrentshow | |
AND t.showid = s.showid | |
AND e.episodeSeasonNumber = f.fileseason | |
AND e.episodeInSeason = f.fileepisode1 | |
ORDER BY releaseDate DESC | |
LIMIT 0, 100; | |
"; | |
// echo "<pre>\n$sql\n</pre>\n"; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect();$RSSItems = $db->query($sql);$db->close(); | |
if(count($RSSItems) != 0) { | |
extract($RSSItems[0]); | |
// <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | |
// http://$thisHost/rss/CougarTown/ | |
// '.htmlentities($showDescription).' | |
$xml = ' | |
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom"> | |
<channel> | |
<atom:link href="http://'.$thisHost.'/rss/'.$showID.'/" rel="self" type="application/rss+xml" /> | |
<image> | |
<title>'.$thisHost.'</title> | |
<url>http://'.$thisHost.'/hamsterspit-logo.png</url> | |
<link>http://'.$thisHost.'/</link> | |
</image> | |
<title>Full Feed - Torrent + Feed</title> | |
<link>http://'.$thisHost.'/</link> | |
<description>3.<![CDATA[ | |
All Shows (Broadcatching Feed - Torrent + Magnet) | |
]]> | |
</description> | |
<language>en-us</language> | |
<copyright>'.$thisHost.'</copyright> | |
<lastBuildDate>'.gmdate(DATE_RSS, time()).'</lastBuildDate> | |
<generator>SolScribe Hamster Factory</generator> | |
<webMaster>TheHamster@'.$thisHost.' ('.$thisHost.' Feedmaster)</webMaster> | |
<ttl>15</ttl>'; | |
foreach($RSSItems as $RSSItem) { | |
extract($RSSItem,EXTR_OVERWRITE); | |
$episodes=($fileEpisodeType=="EP2")?str_pad($fileEpisode1,2,'0',STR_PAD_LEFT) | |
.'-'.str_pad($fileEpisode2,2,'0',STR_PAD_LEFT):str_pad($fileEpisode1,2,'0',STR_PAD_LEFT); | |
$episodeData = $fileSeason.'x'.$episodes; | |
$episodesLong=($fileEpisodeType=="EP2")?"Episodes $fileEpisode1, $fileEpisode2":"Episode $fileEpisode1"; | |
$episodeDataLong = "Season $fileSeason, $episodesLong"; | |
$episodeTitle = (strlen($episodeTitle)>0)?' - '.$episodeTitle:''; | |
$finalTitle= $showName.' '.$episodeData.$episodeTitle; | |
// echo "$imageLink\n"; | |
$imageLink = ""; | |
if(!empty($episodeImage)) { | |
$episodeImage = "rss/$showID/banners/_cache/$episodeImage"; | |
if(file_exists($episodeImage) == true) { | |
$episodeImage = "/SolBend/$episodeImage"; | |
$imageLink = '<img align="right" width="250px" style="float:right;vertical-align:top" src="'.$episodeImage.'">'; | |
} | |
} elseif(!empty($episodeScreenCap)) { | |
$episodeImage = str_ireplace("http://images.tvrage.com/screencaps","",$episodeScreenCap); | |
$episodeImage = "rss/$showID/screencaps/$episodeScreenCap"; | |
if(file_exists($episodeImage) == true) { | |
$episodeImage = "/SolBend/$episodeImage"; | |
$imageLink = '<img align="right" width="250px" style="float:right;vertical-align:top" src="'.$episodeImage.'">'; | |
} | |
} else { | |
$imageLink = ''; | |
} | |
// echo "\n\nEncoding $fileURL\n"; | |
$thisFileURL = encodethisurl($fileURL); | |
switch ($fileQuality) { | |
case '720p': | |
$fileQuality = 'High-Definition (720p)'; | |
break; | |
default: | |
$fileQuality = 'Standard-Definition (SD)'; | |
} | |
$timezone = str_ireplace('GMT','',$origTimeZone); | |
$origDate = strtotime($origDate)+($timezone*3600*-1); | |
$releaseDate = strtotime($releaseDate)+($timezone*3600*-1); | |
$timeDiff = abs($releaseDate-$origDate); | |
$hourDiff = floor($timeDiff/(60*60)); | |
$minuteDiff = floor(($timeDiff-$hourDiff*60*60)/60); | |
// $origDate = gmdate('Y-m-d H:i:s',$origDate); | |
$origDateF = gmdate('l, F j, Y, \a\t H:i',$origDate); | |
// $releaseDate = gmdate('Y-m-d H:i:s',$releaseDate); | |
$releaseDateF = gmdate('F j, \a\t H:i',$releaseDate); | |
$horas=""; | |
$minutos=""; | |
if($hourDiff > 0) { $horas= ($hourDiff > 1)?"$hourDiff hours":"$hourDiff hour"; } | |
if($minuteDiff > 0) { $minutos= ($minuteDiff > 1)?"$hourDiff minutes":"$hourDiff minute"; } | |
$elapsedTime = ($hourDiff > 0 && $minuteDiff > 0)?"$horas and $minutos":$horas.$minutos; | |
switch($fileReleaseGroup) { | |
case 'EZTV': | |
$releaseGroup = " by $fileReleaseGroup"; | |
break; | |
case 'VTV': | |
$releaseGroup = " by $fileReleaseGroup"; | |
break; | |
case 'MVGroup': | |
$releaseGroup = " by $fileReleaseGroup"; | |
break; | |
} | |
if($origDate > $releaseDate) { | |
$releaseBrag = "Aired on $origDateF<br>".$releaseGroup; | |
} else { | |
$releaseBrag = "Aired on $origDateF and released $elapsedTime later".$releaseGroup.", on $releaseDateF."; | |
} | |
$releaseBrag = (!empty($fileSize))?$releaseBrag.'<br>(File Size: '.$fileSize.')':$releaseBrag; | |
// echo "ReleaseDate is $releaseDate ($releaseDateF) - ".gmdate(DATE_RSS,$releaseDate)."\n"; | |
// $releaseBrag = (strlen($episodeDescription) > 5)?$releaseBrag."<br>Sinopsis: $episodeDescription":$releaseBrag; | |
// $releaseBrag = $releaseBrag."<br>$origDate - $releaseDate"; | |
$episodeType = ($fileEpisodeType=="EP2"?"(Double Episode)":"(Single Episode)"); | |
// <torrent xmlns="http://xmlns.ezrss.it/0.1/"> | |
$xml .= ' <item> | |
<title>'.xmlentities($episodeID).'</title> | |
<description>4.<![CDATA[ | |
<h1>'.$finalTitle.'</h1> | |
'.$imageLink.' | |
<h2><a href="http://'.$thisHost.'/show/'.$showID.'/">'.$showName.'</a></h2>'.$episodeDataLong.'<strong>'.$episodeTitle.'</strong><br>'.$fileQuality.'<br> | |
<em>'.$episodeType.'</em><br>'.$releaseBrag.'<br><div style="text-align:center;margin:0px auto;"><a href="'.$magnetURI.'">Magnet</a> | <a href="'.$thisFileURL.'">Torrent</a></div> | |
]]> | |
</description> | |
<pubDate>'.gmdate(DATE_RSS, $releaseDate).'</pubDate> | |
<enclosure url="'.$thisFileURL.'" type="application/x-bittorrent" length="'.$fileSize.'"/> | |
<link>'.$thisFileURL.'</link> | |
<guid isPermaLink="true">'.$thisFileURL.'</guid> | |
<torrent xmlns="http://xmlns.ezrss.it/0.1/"> | |
<fileName>'.$thisFileURL.'</fileName> | |
<infoHash>'.$infoHash.'</infoHash> | |
<magnetURI>'.$magnetURI.'</magnetURI> | |
<contentLength>'.$fileSize.'</contentLength> | |
<trackers> | |
<group order="random"> | |
<tracker>http://tracker.openbittorrent.com/announce</tracker> | |
</group> | |
</trackers> | |
</torrent> | |
</item> | |
'; | |
} | |
$xml .= ' </channel> | |
</rss>'; | |
// echo "<pre>$xml</pre>"; | |
$showPath = "fullxml"; | |
// Checks whether $showID directory exists | |
if(file_exists($showPath) == false) { | |
if(is_dir($showPath) == false) { | |
echo "Creating directory for $showID.\n"; | |
if(!mkdir_recursive("$showPath",0777)) { | |
die(); | |
} | |
} | |
} | |
// echo "Creates $showID RSS regardless of whether it exists already in $showID"; | |
$xmlFile="$showPath/rss.xml"; | |
$xo = fopen($xmlFile,'w') or die('Error writing file $xmlFile'); | |
fwrite($xo,$xml); | |
fclose($xo); | |
} | |
} | |
function getFullShowList() { | |
$sql = " | |
SELECT DISTINCT showName, showID | |
FROM Shows s | |
WHERE showStatus <> 'Canceled/Ended' | |
AND LENGTH(showEpguides) > 0 | |
ORDER BY showName; | |
"; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect();$showIDs = $db->query($sql);$db->close(); | |
if(count($showIDs) > 0) { | |
echo '<ul id="showList">'; | |
foreach($showIDs as $show) { | |
extract($show,EXTR_OVERWRITE); | |
echo '<li><a href="/show/'.$showID.'">'.$showName.'</a> (<a href="/rss/'.$showID.'">RSS</a>)</li>'; | |
} | |
echo '<ul id="showList">'; | |
} | |
} | |
function getMyShowDiv($showID) { | |
$showID = escape($showID); | |
$sql = " | |
SELECT DISTINCT | |
s.*,MIN(episodeAirDate) as nextAirDate, | |
if(s.showStatus='Canceled/Ended',1,0) as orderline | |
FROM Shows s | |
LEFT JOIN Episodes e | |
ON e.showID = s.showID | |
AND e.episodeAirdate > NOW() | |
WHERE 1=1 | |
AND s.showID = '$showID' | |
GROUP BY e.episodeAirDate | |
order by orderline,s.showID | |
LIMIT 0,1; | |
"; | |
$db = new EasyMySql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); | |
$db->connect();$showData = $db->query($sql);$db->close(); | |
extract($showData[0]); | |
$nextEpisode = ""; | |
if(!empty($nextAirDate)) { | |
$timezone = str_ireplace('GMT','',$showTimezone); | |
$timezone = trim(substr($timezone,0,stripos($timezone," "))); | |
$origDate = strtotime($nextAirDate)+($timezone*3600*-1); | |
$todayDate = time(); | |
$nextAirDate = $origDate; | |
$daysUntil = count_days($todayDate,$nextAirDate); | |
$nextEpisode = ($daysUntil == 0)?"today":($daysUntil == 1)?"tomorrow":"in $daysUntil days."; | |
$nextEpisode = "Will air next $nextEpisode"; | |
} else if($showStatus == 'Canceled/Ended') { | |
$nextEpisode = "Series has been cancelled"; | |
} | |
// $nextEpisode = "$showStatus"; | |
// print_r($showData[0]); | |
echo '<div class="myShowItem" data-id="'.$showID.'">' | |
.'<div class="myShowBanner"><img class="myShowBannerImage" src="'."/SolBend/rss/$showID/img/banner_t.jpg".'"></div>' | |
.'<div class="myShowDetails">' | |
.'<div><img class="myShowPoster" src="http://'.$thisHost.'/SolBend/rss/'.$showID.'/img/poster_t.jpg"></div>' | |
.'<div class="myShowClose"><img src="/images2/21-circle-east.png"></div>' | |
.'<div class="HDCheck">Prefer HD</div>' | |
.'<div class="AddToRSSCheck">Add to RSS</div>' | |
.'<div class="myShowSummary">' | |
.'<span class="myShowText"><a href="'."/show/$showID".'">'."$showName".'</a></span>' | |
.'<span class="nextEpisode">'."$nextEpisode".'<br></span>' | |
.'</div>' | |
.'<div class="removeShow" data-id="'.$showID.'"><img src="/images2/21-skull.png"></div>' | |
.'</div>' | |
.'</div>'; | |
} | |
function count_days( $a, $b ) | |
{ | |
// First we need to break these dates into their constituent parts: | |
$gd_a = getdate( $a ); | |
$gd_b = getdate( $b ); | |
// Now recreate these timestamps, based upon noon on each day | |
// The specific time doesn't matter but it must be the same each day | |
$a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] ); | |
$b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] ); | |
// Subtract these two numbers and divide by the number of seconds in a | |
// day. Round the result since crossing over a daylight savings time | |
// barrier will cause this time to be off by an hour or two. | |
return round( abs( $a_new - $b_new ) / 86400 ); | |
} | |
function newid($len=8) | |
{ | |
$hex = md5("your_random_salt_here_31415" . uniqid("", true)); | |
$pack = pack('H*', $hex); | |
$uid = base64_encode($pack); // max 22 chars | |
$uid = ereg_replace("[^A-Za-z0-9]", "", $uid); // mixed case | |
//$uid = ereg_replace("[^A-Z0-9]", "", strtoupper($uid)); // uppercase only | |
if ($len<4) | |
$len=4; | |
if ($len>128) | |
$len=128; // prevent silliness, can remove | |
while (strlen($uid)<$len) | |
$uid = $uid . gen_uuid(22); // append until length achieved | |
return strtolower(substr($uid, 0, $len)); | |
} | |
function xmlentities($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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment