Activity Stream
48,167 MEMBERS
61148 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1.     
    #1
    Member
    Website's:
    maxneeds.info

    Question 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

    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

  2.   Sponsored Links

  3.     
    #2
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    Code: 
    $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;
        }
    }
    Something like this maybe.

    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!

  4.     
    #3
    Member
    Website's:
    maxneeds.info
    thanks jmz but i have many .gz archives.

  5.     
    #4
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Firstly 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;
       }

    Before i can build the getMeta() method witch will hold the links and other statuses, i need to examine the contents of the text file to look for similarities

    -- 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
        
    }

    The above is all example and untested.
    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


  6.     
    #5
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    Quote Originally Posted by litewarez View Post
    Firstly 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
    Before i can build the getMeta() method witch will hold the links and other statuses, i need to examine the contents of the text file to look for similarities
    He 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!

  7.     
    #6
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Update 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


  8.     
    #7
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    Again, 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!

  9.     
    #8
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Yea 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


  10.     
    #9
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    Yes 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!

  11.     
    #10
    Member
    Website's:
    maxneeds.info
    litewarez 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...

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Selling] .:: Clip23.Com ::. Having a video site should not be complicated
    By errabbaa in forum Completed Transactions
    Replies: 1
    Last Post: 16th Sep 2012, 12:14 AM
  2. So, the question is:
    By M.D.House in forum General Discussion
    Replies: 6
    Last Post: 15th Nov 2011, 02:52 AM
  3. Question
    By UmairDiGrt in forum Other
    Replies: 5
    Last Post: 14th Aug 2011, 09:01 AM
  4. Question
    By MasterDKR in forum Webmaster Discussion
    Replies: 13
    Last Post: 3rd Sep 2010, 04:28 AM
  5. Replies: 5
    Last Post: 3rd Jan 2010, 05:23 PM

Tags for this Thread

BE SOCIAL