Results 1 to 10 of 21
-
27th May 2010, 04:09 PM #1OPMemberWebsite's:
maxneeds.infoBit more complicated PHP question
Hi guys !
I am not so good with php as you previously may know...
So i can't achieve the following and i hope you can help me with some script.
I want to get the contents from .gz file (which is a txt file) and search in this .txt file for match with '[url=http://rapidshare , [url=http://megaupload ,[url=http://hotfile , and .torrent '.
If there is match , then show rapidshare.png for [url=http://rapidshare
If there is match , then show megaupload.png for [url=http://megaupload
and so on...
Thanks !Porsche_maniak Reviewed by Porsche_maniak on . Bit more complicated PHP question Hi guys ! I am not so good with php as you previously may know... So i can't achieve the following and i hope you can help me with some script. I want to get the contents from .gz file (which is a txt file) and search in this .txt file for match with '[url=http://rapidshare , [url=http://megaupload ,[url=http://hotfile , and .torrent '. If there is match , then show rapidshare.png for [url=http://rapidshare If there is match , then show megaupload.png for [url=http://megaupload Rating: 5
-
27th May 2010, 04:31 PM #2(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comCode:$file = gzfile('yourfile.gz'); $file = implode("\n",$file); $matches = array( array('rapidshare.png', '[url=http://rapidshare'), array('megaupload.png', '[url=http://megaupload') ); foreach($matches as $match) { if(strpos($file, $match[1]) !== false) { $image = $match[0]; break; } }
This is assuming your gz file is purely a gzipped text file, not a tar.gz for example.Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
27th May 2010, 04:35 PM #3OPMemberWebsite's:
maxneeds.infothanks jmz but i have many .gz archives.
-
27th May 2010, 04:36 PM #4MemberWebsite's:
litewarez.net litewarez.com triniwarez.comFirstly you need to break it up.
- Archive Opening (extraction into memory) | gzopen
- Parsing the contents (Extract links from tags) | preg_match_all
- Compile the output.
So i would start by making a base class to work with
PHP Code:class GzipDownloads
{
protected $gzfile = null;
protected $gzcontents = null;
function __construct($file)
{
if(!file_exists($file))
{
trigger_error('Unable to open ' . $file,E_USER_ERROR); //Die here
}
$this->gzfile = gzopen($file);
$this->gzcontents = gzread($this->gzfile,filesize($file));
}
function getMeta()
{
preg_match_all('/\[url\=(.*?).*?\].*?\[.*?\]/is',$this->gzcontent,$matches);
$mata = array();
foreach($matches as $match)
{
//Url segment should be [1]
if(preg_match('/http:\/\//',$match[1]))
{
$usegments = parse_url($match[1]);
if($usegment['host'])
{
$host = str_replace(array('.com','.net','.co.uk','.org'),'',$usegment['host']); //Remove tld
$meta[$host] = true;
}
}
}
return $mata;
}
}
-- Updated CODE AND Read below
PHP Code:$gzd = new GzipDownloads('my.file.txt.gz');
$meta = $gzd->getMeta();
foreach($meta as $host)
{
if(file_exists('images/' . $host . '.png'))
{
//images/rapidshare.png exists so show it here!
//$host will be the domain name without any tld so rapidhsare links will be rapidshare, hotfile.com/../../../ will be hotfile
}
}
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
27th May 2010, 04:59 PM #5(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comHe doesn't need regex, just to check if it contains rs, mu or whatever else.
Also, gzfile() should be fine for any gzipped text file.
Porsche_maniak: the code I posted will read one gzipped text file and check which hosts it contains. This seems like what you are asking for.
If you wish to handle multiple files, simply read each one in a loop or use a class and have an object per file.
Regardless of how you read it in though, that is how you should match certain strings.Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
27th May 2010, 05:03 PM #6MemberWebsite's:
litewarez.net litewarez.com triniwarez.comUpdate my post, please check!
Edit:
I really don't know why people run from PCRE :/ puzzles me, i mean PHP /mysql can handle 100s / 1000s of queries per second yet people try so hard to get them down to like 3 and that :/Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
27th May 2010, 05:06 PM #7(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comAgain, im not trying to say your code is wrong lite, but regex is useless here.
He needs to check for matches, he doesn't need the matches.
Strpos is much, much faster.
Also, since all he wants is to read the files in and check for string matches, such a complex object won't be needed.Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
27th May 2010, 05:08 PM #8MemberWebsite's:
litewarez.net litewarez.com triniwarez.comYea i know dood, just saying using my code you only need to have an image in the folder and it will match for that aswell.
so if a new host came out called terahost.com, he just needs to add the terahost.png to the dir and its found,Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
27th May 2010, 05:10 PM #9(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comYes but the point is, it is excessive and slower than it could be.
All you need is to read each gz in, check for matches with strpos and use the correct image. It is a very, very simple problem with an equally simple solution.Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
27th May 2010, 05:10 PM #10OPMemberWebsite's:
maxneeds.infolitewarez really tnx for your effort,but i think that JmZ is right...
@ JmZ
how do i read each one in a loop ?
@litewarez
Hmm sounds interesting...
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[Selling] .:: Clip23.Com ::. Having a video site should not be complicated
By errabbaa in forum Completed TransactionsReplies: 1Last Post: 16th Sep 2012, 12:14 AM -
So, the question is:
By M.D.House in forum General DiscussionReplies: 6Last Post: 15th Nov 2011, 02:52 AM -
Question
By UmairDiGrt in forum OtherReplies: 5Last Post: 14th Aug 2011, 09:01 AM -
Question
By MasterDKR in forum Webmaster DiscussionReplies: 13Last Post: 3rd Sep 2010, 04:28 AM -
question about windows server before i buy and question about wrzhost
By priviet02 in forum Hosting DiscussionReplies: 5Last Post: 3rd Jan 2010, 05:23 PM
themaManager - edit and manage...
Version 4.04 released. Open older version (or...