Explode Option

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Explode Option

    ok guys i want to know if it is possible to use random text in a url area of ur script? supposing i have this code img src="http:// so instead of addin 1 url there i want to put the images urls in a text file and get them exploded in the http:// area is it possible???? i dont want to use random image
    Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

    <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>


    #2
    cant understand what u want lol

    Comment


      #3
      lol ok ill explain it again i want links to my <img src=http://here randomly change"> code to change randomly by using some random text coding, i dont want to use random image codes.
      are u gettin me now?
      Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

      <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

      Comment


        #4
        <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php

        $folder = &#39;.&#39;;

        $extList = array();
        $extList[&#39;gif&#39;] = &#39;image/gif&#39;;
        $extList[&#39;jpg&#39;] = &#39;image/jpeg&#39;;
        $extList[&#39;jpeg&#39;] = &#39;image/jpeg&#39;;
        $extList[&#39;png&#39;] = &#39;image/png&#39;;

        $img = null;

        if (substr($folder,-1) != &#39;/&#39;) {
        $folder = $folder.&#39;/&#39;;
        }

        if (isset($_GET[&#39;img&#39;])) {
        $imageInfo = pathinfo($_GET[&#39;img&#39;]);
        if (
        isset( $extList[ strtolower( $imageInfo[&#39;extension&#39;] ) ] ) &&
        file_exists( $folder.$imageInfo[&#39;basename&#39;] )
        ) {
        $img = $folder.$imageInfo[&#39;basename&#39;];
        }
        } else {
        $fileList = array();
        $handle = opendir($folder);
        while ( false !== ( $file = readdir($handle) ) ) {
        $file_info = pathinfo($file);
        if (
        isset( $extList[ strtolower( $file_info[&#39;extension&#39;] ) ] )
        ) {
        $fileList[] = $file;
        }
        }
        closedir($handle);

        if (count($fileList) > 0) {
        $imageNumber = time() % count($fileList);
        $img = $folder.$fileList[$imageNumber];
        }
        }

        if ($img!=null) {
        $imageInfo = pathinfo($img);
        $contentType = &#39;Content-type: &#39;.$extList[ $imageInfo[&#39;extension&#39;] ];
        header ($contentType);
        readfile($img);
        } else {
        if ( function_exists(&#39;imagecreate&#39;) ) {
        header ("Content-type: image/png");
        $im = @imagecreate (100, 100)
        or die ("Cannot initialize new GD image stream");
        $background_color = imagecolorallocate ($im, 255, 255, 255);
        $text_color = imagecolorallocate ($im, 0,0,0);
        imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
        imagepng ($im);
        imagedestroy($im);
        }
        }

        ?></div>


        create a file called index.php tusing the code above, place it in a folder called logo.gif and also place your random images in this folder, then you just use a standard image link using logo.gif as the image name, this will then randomise the images you place in the folder

        Hope this helps
        :p:p:p

        Comment


          #5
          u only want the filename to randomise rite?

          Comment


            #6
            yes bro i only want the url part to randomly change not the img src=\"http:// only the 123.com/xxx.gif only this part i want to change rendomly with some random code
            Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

            <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

            Comment


              #7
              K create a txt file with ur links in like so. for this example will use links.txt

              -blah.com/path1/path2/jig.gif
              -foo.org/path1/path2/dance.jpg

              etc. etc. we will use the - to distinguish between the different urls

              code is:
              Code:
              <?php
              $xfile = @file("links.txt");
              $random_num = rand (0,count($xfile)-1);
              $udata = explode("-",$xfile[$random_num]);
              $link = $udata[1];
              
              echo "<img src=\"http://$link\" alt=\"*\"/>";
              ?>
              Should do it

              Comment


                #8
                guys im having problem with the random code sometimes it shows nothing on my page after u refresh the page for 2 to 3 times only then a pic shows up and agan the next will get blank. how to fix this error?
                Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

                <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

                Comment


                  #9
                  with this code
                  Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

                  <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

                  Comment


                    #10
                    i think i know what your after lol create a file and call it links.txt cmod to 777
                    add in there
                    Code:
                    ::<a href=\"YOUR LINK\">LINK NAME</a>
                     ::<a href=\"YOUR LINK\">LINK NAME</a>
                    add as many as you want... then on the page you want to show the random links put
                    Code:
                    $xfile = @file("links.txt");
                    $random_num = rand (0,count($xfile)-1);
                    $udata = explode("::",$xfile[$random_num]);
                    echo "$udata[1]";
                    that should work fine and it would flick thru links......
                    if you want it to show images with the links add this to the links.txt
                    Code:
                    ::<a href=\"YOUR LINK\"><img src=\"images/home.gif\" alt=\"LINK NAME OR LEAVE BLANK\"/></a>
                    add as many as you like...
                    :-) hope it works for ya

                    Comment


                      #11
                      brother the code works fine but the problem im facing is that sometimes it dont fetch anything from links.txt file it remains blank until u refresh ur index again
                      Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

                      <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

                      Comment

                      Working...
                      X