quick php code help...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qwe
    Confirmed User
    • Jul 2003
    • 2109

    #1

    quick php code help...

    I want to put alot of urls into the php file, and once php file gets executed it will redirect to those urls one by one... like if I have 100 urls, once php file loads it will go to first url, then once php file get executed again it will load second url, and so on, then once it reaches the end it will start from the begging ... can someone hook me up please
  • Basic_man
    Programming King Pin
    • Oct 2003
    • 27360

    #2
    Originally posted by qwe
    I want to put alot of urls into the php file, and once php file gets executed it will redirect to those urls one by one... like if I have 100 urls, once php file loads it will go to first url, then once php file get executed again it will load second url, and so on, then once it reaches the end it will start from the begging ... can someone hook me up please
    Can get you up & running in no time with this. Get a hold on me on ICQ : 349-164-75
    UUGallery Builder - automated photo/video gallery plugin for Wordpress!
    Stop looking! Checkout Naked Hosting, online since 1999 !

    Comment

    • qwe
      Confirmed User
      • Jul 2003
      • 2109

      #3
      still looking

      Comment

      • qwe
        Confirmed User
        • Jul 2003
        • 2109

        #4
        bump bump

        Comment

        • woj
          <&(©¿©)&>
          • Jul 2002
          • 47882

          #5
          If you are looking to invest a few bucks, icq: 33375924
          Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
          Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
          Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

          Comment

          • Nookster
            Confirmed IT Professional
            • Nov 2005
            • 3744

            #6
            Here's help. Otherwise, I could make it for you but $$ talks.
            The Best Affiliate Software, Ever.

            Comment

            • quantum-x
              Confirmed User
              • Feb 2002
              • 6863

              #7
              Quick and dirty way to do it:
              Code:
              <?
              $urls = file('URLS.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
              $url = array_shift($urls);
              array_push($urls,$url);
              file_put_contents('URLS.txt',implode("\r\n",$urls));
              
              header('Location:'.$url);
              ?>
              Will work. Untested, don't ask for me to fix it if it doesn't kick - pay woj instead.
              PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

              Comment

              • Nookster
                Confirmed IT Professional
                • Nov 2005
                • 3744

                #8
                Originally posted by quantum-x
                Quick and dirty way to do it:
                Code:
                <?
                $urls = file('URLS.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
                $url = array_shift($urls);
                array_push($urls,$url);
                file_put_contents('URLS.txt',implode("\r\n",$urls));
                
                header('Location:'.$url);
                ?>
                Will work. Untested, don't ask for me to fix it if it doesn't kick - pay woj instead.
                It helps to completely read what he was looking for.
                The Best Affiliate Software, Ever.

                Comment

                • HomerSimpson
                  Too lazy to set a custom title
                  • Sep 2005
                  • 13826

                  #9
                  array + array_rand - and it's all done...

                  read the manual...
                  Make a bank with Chaturbate - the best selling webcam program
                  Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!!

                  PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email:

                  Comment

                  • quantum-x
                    Confirmed User
                    • Feb 2002
                    • 6863

                    #10
                    Originally posted by Nookster
                    It helps to completely read what he was looking for.
                    Care to point out what it doesn't do?
                    Takes a list of URLS. Each time the script is loaded, it redirects to the next, and so forth.
                    What did I miss?
                    PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                    Comment

                    • Killswitch - BANNED FOR LIFE

                      #11
                      Originally posted by Nookster
                      It helps to completely read what he was looking for.
                      I hope you don't call yourself a programmer.

                      Comment

                      • StuartD
                        Sofa King Band
                        • Jul 2002
                        • 29903

                        #12
                        Originally posted by quantum-x
                        Quick and dirty way to do it:
                        Code:
                        <?
                        $urls = file('URLS.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
                        $url = array_shift($urls);
                        array_push($urls,$url);
                        file_put_contents('URLS.txt',implode("\r\n",$urls));
                        
                        header('Location:'.$url);
                        ?>
                        Will work. Untested, don't ask for me to fix it if it doesn't kick - pay woj instead.
                        Yup, that would work.
                        A real solution would be to use a db or even xml file, but quantum-x has a solution that will work quite well
                        This is me on facebook
                        This is me on twitter

                        Comment

                        • rowan
                          Too lazy to set a custom title
                          • Mar 2002
                          • 17393

                          #13
                          q-x's solution will truncate the url file if the HD runs out of space.

                          (I know it's a quick and dirty free solution, just pointing out one potential issue.)

                          Comment

                          • sarettah
                            see you later, I'm gone
                            • Oct 2002
                            • 14297

                            #14
                            Originally posted by rowan
                            q-x's solution will truncate the url file if the HD runs out of space.

                            (I know it's a quick and dirty free solution, just pointing out one potential issue.)
                            Hmm. I don't think so. If the file had XX number of urls and took up XX amount of space at the beginning of the program it would still have xx number of urls and take up xx amount of space at the end. So, if the file fit on the HD before it still does after.

                            just
                            All cookies cleared!

                            Comment

                            • qwe
                              Confirmed User
                              • Jul 2003
                              • 2109

                              #15
                              Originally posted by quantum-x
                              Quick and dirty way to do it:
                              Code:
                              <?
                              $urls = file('URLS.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
                              $url = array_shift($urls);
                              array_push($urls,$url);
                              file_put_contents('URLS.txt',implode("\r\n",$urls));
                              
                              header('Location:'.$url);
                              ?>
                              Will work. Untested, don't ask for me to fix it if it doesn't kick - pay woj instead.
                              gives me this error

                              Parse error: syntax error, unexpected T_VARIABLE in /www/users/for/multiurl.php on line 3

                              Comment

                              • Killswitch - BANNED FOR LIFE

                                #16
                                $urls = file('URLS.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

                                Comment

                                • qwe
                                  Confirmed User
                                  • Jul 2003
                                  • 2109

                                  #17
                                  Originally posted by Killswitch
                                  $urls = file('URLS.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                                  now i get this:

                                  Fatal error: Call to undefined function: file_put_contents() in /www/users/for/multiurl.php on line 5

                                  Comment

                                  • XD2
                                    Confirmed User
                                    • Sep 2007
                                    • 454

                                    #18
                                    Originally posted by qwe
                                    gives me this error

                                    Parse error: syntax error, unexpected T_VARIABLE in /www/users/for/multiurl.php on line 3
                                    Second Line which is the first line of code needs a ; on the end.

                                    Code:
                                    $urls = file('URLS.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                                    EDIT: Didn't refresh page and see it had been answered
                                    David • 421-179-116 • support [@] adultnetworkuk [.] com

                                    Website Development • Website Hosting • Model Index Software • Website Reviews and Links
                                    Hit me up for more information on everything I do.

                                    Comment

                                    • Killswitch - BANNED FOR LIFE

                                      #19
                                      Originally posted by qwe
                                      now i get this:

                                      Fatal error: Call to undefined function: file_put_contents() in /www/users/for/multiurl.php on line 5
                                      file_put_contents() is a php5 function.
                                      Last edited by Guest; 11-23-2009, 04:57 PM.

                                      Comment

                                      • rowan
                                        Too lazy to set a custom title
                                        • Mar 2002
                                        • 17393

                                        #20
                                        Originally posted by sarettah
                                        Hmm. I don't think so. If the file had XX number of urls and took up XX amount of space at the beginning of the program it would still have xx number of urls and take up xx amount of space at the end. So, if the file fit on the HD before it still does after.

                                        just
                                        It's happened to me. ;) When you open a file for write it's first truncated, so if there's something else writing at that time, or the file system allows a truncate but not write when it's chock full, you'll end up with a 0 byte file. For a rotating buffer like this it's probably better to use a pointer and save that in a separate file - at least if that gets trashed then it just starts at 0 again...

                                        Comment

                                        • Deej
                                          I make pixels work
                                          • Jun 2005
                                          • 24386

                                          #21
                                          ... pay woj ...

                                          Deej's Designs n' What Not
                                          Hit me up for Design, CSS & Photo Retouching


                                          Icq#30096880

                                          Comment

                                          • rowan
                                            Too lazy to set a custom title
                                            • Mar 2002
                                            • 17393

                                            #22
                                            Replace the file_put_contents(...) line with this

                                            $fp = fopen('URLS.txt', 'r+');
                                            fwrite($fp, implode("\r\n",$urls))
                                            fclose($fp);

                                            Comment

                                            • Killswitch - BANNED FOR LIFE

                                              #23
                                              Originally posted by Killswitch
                                              file_put_contents() is a php5 function.
                                              Code:
                                              <?php
                                                if(!function_exists('file_put_contents')) {
                                                  function file_put_contents($filename, $data, $file_append = false) {
                                                    $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
                                                      if(!$fp) {
                                                        trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
                                                        return;
                                                      }
                                                    fputs($fp, $data);
                                                    fclose($fp);
                                                  }
                                                }
                                              ?>
                                              That should fix your problem. I highly suggest upgrading PHP to 5.x

                                              Comment

                                              • rowan
                                                Too lazy to set a custom title
                                                • Mar 2002
                                                • 17393

                                                #24
                                                Hey Killswitch, is the chick in your avatar some random_unverifiable_one_off_chick or from a program?

                                                Comment

                                                • qwe
                                                  Confirmed User
                                                  • Jul 2003
                                                  • 2109

                                                  #25
                                                  Originally posted by rowan
                                                  Replace the file_put_contents(...) line with this

                                                  $fp = fopen('URLS.txt', 'r+');
                                                  fwrite($fp, implode("\r\n",$urls))
                                                  fclose($fp);
                                                  after few runs i get this

                                                  Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 128 bytes) in /www/users/for/multiurl.php on line 6

                                                  Comment

                                                  • qwe
                                                    Confirmed User
                                                    • Jul 2003
                                                    • 2109

                                                    #26
                                                    Originally posted by Killswitch
                                                    Code:
                                                    <?php
                                                      if(!function_exists('file_put_contents')) {
                                                        function file_put_contents($filename, $data, $file_append = false) {
                                                          $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
                                                            if(!$fp) {
                                                              trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
                                                              return;
                                                            }
                                                          fputs($fp, $data);
                                                          fclose($fp);
                                                        }
                                                      }
                                                    ?>
                                                    That should fix your problem. I highly suggest upgrading PHP to 5.x
                                                    hey switch, where do I put that ? instead of file_put_contents line?

                                                    Comment

                                                    • rowan
                                                      Too lazy to set a custom title
                                                      • Mar 2002
                                                      • 17393

                                                      #27
                                                      Originally posted by qwe
                                                      after few runs i get this

                                                      Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 128 bytes) in /www/users/for/multiurl.php on line 6
                                                      lol... so it's a BIG list? I think it's time to call on woj. This isn't so simple any more.

                                                      Comment

                                                      • qwe
                                                        Confirmed User
                                                        • Jul 2003
                                                        • 2109

                                                        #28
                                                        Originally posted by rowan
                                                        lol... so it's a BIG list? I think it's time to call on woj. This isn't so simple any more.
                                                        nope, urls.txt has 10 urls in it, thats it

                                                        Comment

                                                        • rowan
                                                          Too lazy to set a custom title
                                                          • Mar 2002
                                                          • 17393

                                                          #29
                                                          Originally posted by qwe
                                                          nope, urls.txt has 10 urls in it, thats it
                                                          Has it grown? I can't think why else PHP would be complaining it's out of memory.

                                                          Comment

                                                          • rowan
                                                            Too lazy to set a custom title
                                                            • Mar 2002
                                                            • 17393

                                                            #30
                                                            And you can see that free help isn't always so quick... by now you probably could have paid to get a working solution that you didn't have to worry about...

                                                            Comment

                                                            • qwe
                                                              Confirmed User
                                                              • Jul 2003
                                                              • 2109

                                                              #31
                                                              Originally posted by rowan
                                                              Has it grown? I can't think why else PHP would be complaining it's out of memory.
                                                              yap, used to be 1kb file, now it's 137kb file with only 1 url in it instead of 10... hrmm

                                                              Comment

                                                              • quantum-x
                                                                Confirmed User
                                                                • Feb 2002
                                                                • 6863

                                                                #32
                                                                Why the fuck are you running PHP4 - In one month's time it will have been discontinued for THREE YEARS.

                                                                No wonder shit is breaking ;)
                                                                PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                                                                Comment

                                                                • rowan
                                                                  Too lazy to set a custom title
                                                                  • Mar 2002
                                                                  • 17393

                                                                  #33
                                                                  Does each redirect NEED to be sequential? If you do it randomly and there's enough loads (ie enough of a sample) then each URL will receive the same average amount of traffic anyway.

                                                                  Comment

                                                                  • qwe
                                                                    Confirmed User
                                                                    • Jul 2003
                                                                    • 2109

                                                                    #34
                                                                    Originally posted by Killswitch
                                                                    Code:
                                                                    <?php
                                                                      if(!function_exists('file_put_contents')) {
                                                                        function file_put_contents($filename, $data, $file_append = false) {
                                                                          $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
                                                                            if(!$fp) {
                                                                              trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
                                                                              return;
                                                                            }
                                                                          fputs($fp, $data);
                                                                          fclose($fp);
                                                                        }
                                                                      }
                                                                    ?>
                                                                    That should fix your problem. I highly suggest upgrading PHP to 5.x
                                                                    ok I put that before file_put_contents line and it works, but after it redirects to the site it deletes that site from urls.txt file for some reason ?

                                                                    Comment

                                                                    • quantum-x
                                                                      Confirmed User
                                                                      • Feb 2002
                                                                      • 6863

                                                                      #35
                                                                      Originally posted by rowan
                                                                      It's happened to me. ;) When you open a file for write it's first truncated, so if there's something else writing at that time, or the file system allows a truncate but not write when it's chock full, you'll end up with a 0 byte file. For a rotating buffer like this it's probably better to use a pointer and save that in a separate file - at least if that gets trashed then it just starts at 0 again...
                                                                      As with anything when you write to the filesystem. You should be / your host should be monitoring disc space anyhow.

                                                                      If you're out of space PHP will probaby grind itself to death when attempting to even run
                                                                      PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                                                                      Comment

                                                                      • qwe
                                                                        Confirmed User
                                                                        • Jul 2003
                                                                        • 2109

                                                                        #36
                                                                        Originally posted by rowan
                                                                        Does each redirect NEED to be sequential? If you do it randomly and there's enough loads (ie enough of a sample) then each URL will receive the same average amount of traffic anyway.
                                                                        it doesn't have to be, can be random too if it's easier

                                                                        Comment

                                                                        • rowan
                                                                          Too lazy to set a custom title
                                                                          • Mar 2002
                                                                          • 17393

                                                                          #37
                                                                          Originally posted by qwe
                                                                          it doesn't have to be, can be random too if it's easier
                                                                          Far easier.

                                                                          <?php
                                                                          $urls = file("URLS.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                                                                          header("HTTP/1.0 302 redirect");
                                                                          header("Location: " . $urls[(rand(0, count($urls) - 1))]);
                                                                          ?>

                                                                          Comment

                                                                          • qwe
                                                                            Confirmed User
                                                                            • Jul 2003
                                                                            • 2109

                                                                            #38
                                                                            Originally posted by rowan
                                                                            Far easier.

                                                                            <?php
                                                                            $urls = file("URLS.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                                                                            header("HTTP/1.0 302 redirect");
                                                                            header("Location: " . $urls[(rand(0, count($urls) - 1))]);
                                                                            ?>
                                                                            works like a charm, thanks bro

                                                                            Comment

                                                                            • rowan
                                                                              Too lazy to set a custom title
                                                                              • Mar 2002
                                                                              • 17393

                                                                              #39
                                                                              Damn, I should have left out a semicolon or two and extorted $3.82 from you.

                                                                              Comment

                                                                              • GrouchyAdmin
                                                                                Now choke yourself!
                                                                                • Apr 2006
                                                                                • 12085

                                                                                #40
                                                                                Sweet fucking Christ.

                                                                                Comment

                                                                                • qwe
                                                                                  Confirmed User
                                                                                  • Jul 2003
                                                                                  • 2109

                                                                                  #41
                                                                                  Originally posted by rowan
                                                                                  Damn, I should have left out a semicolon or two and extorted $3.82 from you.
                                                                                  btw, it should not have any issues with big files? or it's limited to like 1-100 urls or so ?

                                                                                  Comment

                                                                                  • rowan
                                                                                    Too lazy to set a custom title
                                                                                    • Mar 2002
                                                                                    • 17393

                                                                                    #42
                                                                                    Originally posted by qwe
                                                                                    btw, it should not have any issues with big files? or it's limited to like 1-100 urls or so ?
                                                                                    The answer will cost $3.82.

                                                                                    So long as your URL list isn't megs in size it should be fine. If it gets too big then PHP will die with an out of memory error.

                                                                                    Comment

                                                                                    • Killswitch - BANNED FOR LIFE

                                                                                      #43
                                                                                      Originally posted by rowan
                                                                                      Hey Killswitch, is the chick in your avatar some random_unverifiable_one_off_chick or from a program?
                                                                                      I found it on some site, I think it's one of those ex girlfriend site pics that are on every ex gf site.

                                                                                      Originally posted by qwe
                                                                                      yap, used to be 1kb file, now it's 137kb file with only 1 url in it instead of 10... hrmm
                                                                                      I put the code on my dev server and ran it, by the looks of it, when putting the first url to the bottom, it's putting enters in there somewhere..

                                                                                      Comment

                                                                                      • quantum-x
                                                                                        Confirmed User
                                                                                        • Feb 2002
                                                                                        • 6863

                                                                                        #44
                                                                                        Originally posted by Killswitch
                                                                                        I found it on some site, I think it's one of those ex girlfriend site pics that are on every ex gf site.



                                                                                        I put the code on my dev server and ran it, by the looks of it, when putting the first url to the bottom, it's putting enters in there somewhere..
                                                                                        That was my attempt to extort him, shhhh
                                                                                        PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                                                                                        Comment

                                                                                        • Killswitch - BANNED FOR LIFE

                                                                                          #45
                                                                                          Originally posted by quantum-x
                                                                                          That was my attempt to extort him, shhhh
                                                                                          I told him the problem, I didn't give him the fix.

                                                                                          Please send $1.28 to me when he pays you, for keeping my mouth shut. Thanks.

                                                                                          Comment

                                                                                          • quantum-x
                                                                                            Confirmed User
                                                                                            • Feb 2002
                                                                                            • 6863

                                                                                            #46
                                                                                            Originally posted by Killswitch
                                                                                            I told him the problem, I didn't give him the fix.

                                                                                            Please send $1.28 to me when he pays you, for keeping my mouth shut. Thanks.
                                                                                            egold ?
                                                                                            PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                                                                                            Comment

                                                                                            • Killswitch - BANNED FOR LIFE

                                                                                              #47
                                                                                              Originally posted by quantum-x
                                                                                              egold ?
                                                                                              WU please.

                                                                                              Comment

                                                                                              • Doctor Feelgood
                                                                                                Confirmed User
                                                                                                • Nov 2005
                                                                                                • 2112

                                                                                                #48
                                                                                                Originally posted by qwe
                                                                                                I want to put alot of urls into the php file, and once php file gets executed it will redirect to those urls one by one... like if I have 100 urls, once php file loads it will go to first url, then once php file get executed again it will load second url, and so on, then once it reaches the end it will start from the begging ... can someone hook me up please
                                                                                                something like this javascript popup

                                                                                                Code:
                                                                                                <!--
                                                                                                var how_many_ads = 3;
                                                                                                var now = new Date()
                                                                                                var sec = now.getSeconds()
                                                                                                var ad = sec % how_many_ads;
                                                                                                ad +=1;
                                                                                                if (ad==1) {url="http://www.url1.com/";}
                                                                                                if (ad==2) {url="http://www.url2.com/";}
                                                                                                if (ad==3) {url="http://www.url3.com/";}
                                                                                                rotpop=window.open('','rotpop','toolbar=0,menubar=0,scrollbars=1,status=0,resizable=1,top=1,left=1,width=790,height=570'); 
                                                                                                rotpop.blur();
                                                                                                rotpop.location=url;
                                                                                                -->

                                                                                                Comment

                                                                                                Working...