1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me Please: problem with random video in php script

Discussion in 'PHP & Perl' started by administer, Sep 22, 2009.

  1. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    Hello,
    I have a redtube script for adult videos: xkeez.com
    would like to have the videos go from: A to Z in loop, no duplicate, when clicked on the link.
    videos numbers are in a .txt file
    what will be the php code for this. I'm not a php programmer, but have some knowledge of html.
    Thank you for your help.
    regards,
     
  2. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    If you provide the php script you have I wouldn't mind taking a look at it for you.
     
  3. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    Hello,
    here's the code:

    $videos = file("videos numbers.txt"); // file with redtube numbers (1 to X)
    shuffle($videos);

    videos numbers are in a .txt file
    - How would you write this so one would have the videos go from: 1 to X in loop, no duplicate, when clicked on a link.
    Thank you for your help
     
  4. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    Lets take a look at your code:

    Code:
    $videos = file("videos numbers.txt");
    This code is reading your text file into a PHP array.

    Code:
    shuffle($videos);
    This code is shuffling the array around.

    So to put these in numerical order, you would replace:

    Code:
    shuffle($videos);
    WITH

    Code:
    sort($videos);
    I am not sure what you mean when you say "when clicked on a link." could you explain a little bit more what you are trying to have happen?
     
  5. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    hello,
    thank you for your help.
    as videos do not change after one another, i have a javascript under a link so that when i clic on that link it goes from video1 to video 2 but as it's random, it goes to any number.
    as for your code, it plays only the first video over and over.
    you can see it here: http://xkeez.com
     
  6. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    I understand now.

    Try this:

    REPLACE

    Code:
    $videos = file("videos numbers.txt"); // file with redtube numbers (1 to X)
    shuffle($videos);
    
    WITH

    Code:
    //get the video ids from the txt file
    $videos = file("videos numbers.txt");
    
    //sort the video ids
    sort($videos);
    
    //lets get a count of the videos
    $total_vids = count($videos);
    
    //lets set the counter to 0 if its not already set
    if ($_GET['counter'] == '' || !isset($_GET['counter'])){
    	$counter = 0;
    } else {
    	$counter = $_GET['counter'];
    }
    
    //lets make sure the counter isn't past the last video, if it is then start over again
    if ($counter >= $total_vids){
     $counter = 0;
    }
    
    //this is the video id of the current video
    $video_id = $videos[$counter];
    
    //this gets the next id in the array
    $counter++;
    
    And then replace the link you have at the bottom:

    Code:
    <a href="http://xkeez.com/amateur.php">Click here for new video-Cliquer ici pour une autre Video</a>
    
    WITH

    Code:
    <a href="http://xkeez.com/amateur.php?counter=<?=$counter?>">Click here for new video-Cliquer ici pour une autre Video</a>
    
    Pretty much what you would do is use the $video_id variable in the embed for the video on your page. I think this should accomplish what you are attempting.

    Hope this helps.
     
    • Thanks Thanks x 1
    Last edited: Sep 23, 2009
  7. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    hello,
    thank you for your help. it does not work
    video numbers in .txt file are not consecutive order and are not 1,2,3,4 but in this order and style:
    1008
    200
    576
    32
     
  8. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    Sorry, my mistake, You should make a small change:

    REPLACE

    Code:
    sort($videos);
    WITH

    Code:
    sort($videos, SORT_NUMERIC);
    That should make it sort in the correct order.
     
  9. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    hello,
    vids do not change after clic. it stays with the same video.
     
  10. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    Here is the full page with your html and the player embedded:

    amateur.php
    Code:
    <?php
    //get the video ids from the txt file
    $videos = array();
    
    $videos = file("videos numbers.txt");
    
    //sort the video ids
    sort($videos, SORT_NUMERIC);
    
    //lets get a count of the videos
    $total_vids = count($videos);
    
    //lets set the counter to 0 if its not already set
    if ($_GET['counter'] == '' || !isset($_GET['counter'])){
    	$counter = 0;
    } else {
    	$counter = $_GET['counter'];
    }
    
    //lets make sure the counter isn't past the last video, if it is then start over again
    if ($counter >= $total_vids){
     $counter = 0;
    }
    
    
    //this will print the video id
    $video_id = $videos[$counter];
    
    //this gest the next video id in the array
    $counter++;
    ?>
    <style type="text/css">
    <!--
    body {
    	margin-top: 25px;
    	background-color: #000000;
    }
    .Style3 {font-size: 14px}
    body,td,th {
    	color: #FFCC00;
    }
    a:link {
    	color: #FF3300;
    }
    a:visited {
    	color: #FFCCFF;
    }
    .Style4 {font-size: 12}
    -->
    </style>
    <title>Doctissimo - Hentai - doujin - Sex - Sexe - Chiennes en Chaleur - Amateur - Baise - Youtube - Sexy </title><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
      
      <tr>
        <th width="156" rowspan="2" align="center" valign="middle" scope="row"></th>
        <th height="297" scope="row"><table width="95%" height="344" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
    
            <th width="50%" align="center" valign="middle" scope="row"><object height="344" width="434"><param name="movie" value="http://embed.redtube.com/player/"><param name="flashvars" value="id=<?=$video_id?>
    &style=redtube"><embed src="http://embed.redtube.com/player/?id=<?=$video_id?>
    &style=redtube" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="344" width="434"></object></th>
            <td width="50%" align="center" valign="middle">      <!-- Start Code -->
          <iframe src="http://adwords.idoo.com/banner.php?action=b&t=true&ref=25&w=434&h=344&grp=13" width="434" height="344" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" allowtransparency="true" background-color="transparent"></iframe>      <!-- End Code --></td>
          </tr>
        </table>
    </th>
      </tr>
      <tr>
    
        <th height="120" scope="row"><table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <th width="78%" height="97" align="center" valign="top" scope="row">
    
    <br><br><a href="amateur.php?counter=<?=$counter?>">Click here for new video-Cliquer ici pour une autre Video</a><br />
             </th>
            <td width="22%" align="left" valign="top"><a href="rss.xml" target="_blank"><img src="rss.png" alt="Get Sexy Rss" width="105" height="69" border="0" /></a></td>
          </tr>
    
        </table></th>
      </tr>
    </table>
    
    Lemme know if that works for you.
     
    Last edited: Sep 23, 2009
  11. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    waow, it works. thank you so much.
    i've a last question, how can i make this to work in Internet Explorer because it only works with Firefox
     
  12. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    hello again,
    can i give you a rep for your help?
    regards,
     
  13. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    oops, try this:

    REPLACE

    Code:
    $video_id = $videos[$counter];
    WITH

    Code:
    $video_id = trim($videos[$counter]);
     
  14. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    hello,
    thank you so much for your help.
    if you need translation from french to english or vice versa just let me know, i'll do it for free.
    can i give you a rep for your great help
     
  15. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    Rep is not necessary, just be sure to help other people on this forum whenever you can :)

    Glad you got it working.
     
    • Thanks Thanks x 1
  16. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    thank you very much.
    i'll try my best to help.
    again: thank you
    regards
     
  17. administer

    administer Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    1
    case solved.
    Closed !