Author Topic: Create a TUBE site driven by TGPX data  (Read 18003 times)

0 Members and 1 Guest are viewing this topic.

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Create a TUBE site driven by TGPX data
« on: August 06, 2012, 02:11:26 AM »
You can use TGPX to drive a very flexible and efficient tube site.  By adding a new field, (  flv_url for instance ), to your DB and importing readily available flash videos into your DB you can then present these vids using a bit of php code and a standalone video player.  I'm currently using JWPlayer for this, but you can use any player you choose.  Your landing page is created by TGPX and the PHP player page variables are driven from the landing page.

You can make the page as simple or as complex as you want, by adding ratings, views (click-tracking), and video tags (keywords, tags).  The main advantages of using TGPX to create mini-tube sites is that you can use it on any domain you have and the server load is much less than a TubeX install (or any other tube script install) would be.  One disadvantage is that you cannot easily provide for uploading videos, (maybe you can but thats way beyond my skills!) 

Of course, with TubeX open sourced now, that may still be your best bet.  I'm just letting you know that there are other options available.

Sample pages here:

Landing Page, by TPGX: http://phatblaxxx.com/

Any interested persons may request my current code if they want to play around with this.
« Last Edit: August 07, 2013, 01:39:22 AM by a4evermedia »

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Re: Create a TUBE site driven by TGPX data
« Reply #1 on: August 05, 2013, 08:19:22 AM »
I've had requests to post the PHP code for this task and will be doing so this week.

I am attempting to flesh out the details for this procedure in an easily understandable way.  As I do so, please comment if something is confusing or unclear and I will try to clarify.

Step 1: Create a new User Defined Gallery Field in TPGX.

        for example; Field Name: clip_url , Label: Clip URL , Type: Text

Step 2: Download and install the flash video player of your choice.  I am using the free JWPlayer at this time.


Step 3: Create a PHP page to play your video clips.

        This is the script that will parse the parameters that will be passed from your template page, do some error checking, caches the video page and plays the video.  I have named the script player.php and placed it in my /videos/ directory.

Code: [Select]
<?php

   if((!isset($_GET['d'])) || (empty($_GET['d'])) || !(is_numeric($_GET['d'])) )
     {
       //  Missing or invalid parameters, video_error.php
       include '../YOURSERVER/includes/video_error.php';
       exit;
     }

$videoid = $_GET["d"];

$titleurl = $_GET["t"];



   // Define path and name of cached file 

   $cachefile = '/home/YOURSERVER/public_html/_cache/' . $videoid . '_cached';

   // How long to keep cache file? 

   $cachetime = 24 * 3600;     

   // Is cache file still fresh? If so, serve it.     

   if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) { 

   include($cachefile); 

   exit; 

   } 

// Access database login information

include '../YOURSERVER/includes/variables.php';

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die('Error encountered with connection: '.mysql_error());

// Retrieve TGPX video info for display

$sql = "SELECT *,`tx_galleries`.`gallery_id` AS `gallery_id` FROM `tx_galleries` LEFT JOIN `tx_gallery_previews` ON `tx_gallery_previews`.`gallery_id` = `tx_galleries`.`gallery_id` LEFT JOIN `tx_gallery_fields` ON \n"
    . "`tx_gallery_fields`.`gallery_id` = `tx_galleries`.`gallery_id` WHERE `tx_gallery_fields`.`gallery_id` =$videoid LIMIT 0, 30 ";

$result=mysql_query($sql);

$num=mysql_numrows($result);

// If ID number not found, video_error1

if ($num == 0) {
    include '../YOURSERVER/includes/video_error1.php';
    die();
    exit;
}

$id_num=mysql_result($result,0,"gallery_id");
$id_click=mysql_result($result,0,"gallery_url");
$id_url=mysql_result($result,0,"clip_url");
$id_title=mysql_result($result,0,"description");
$id_prev=mysql_result($result,0,"preview_url");
$id_tag=mysql_result($result,0,"tags");

//  If video ID is not Tagged for display on tube site, go to video_error2

if ($id_tag != 'YOURIDTAG') {
    include '../YOURSERVER/includes/video_error2.php';
    die();
    exit;
}

$id_title = str_replace("'","",$id_title) ;

$id_title = ucwords($id_title) ;

// Correct relative URLs if necessary

$findme = 'http:';

$pos = strpos($id_url, $findme);

if ($pos === false) {
        $id_url = 'http://yoursite.com' . $id_url ;
}

$id_url = ($id_url);

$pos = strpos($id_prev, $findme);

if ($pos === false) {
        $id_prev = 'http://yoursite.com' . $id_prev ;
}


   // if no file or too old, render and capture HTML page. 

   ob_start();


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>

>

    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/x-thumbs.js"></script>
    <script type="text/javascript" src="/js/video-watch.js"></script>


<link rel="stylesheet" href="style.css" type="text/css" />

<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>

<base target="_blank" />

<script type="text/javascript">
var exoOpts = {
  idzone_300x250: '368348',
  idzone_468x60: '368348',
  idsite: '138642',
  preroll: {},
  pause: {},
  postroll: {},
  time: {
    startAt: 50
  },
  show_thumb: '1'
};
</script>

<base target="_blank">

</head>

<body oncontextmenu="return false;">



 
<div id="vid-rapper" style="position:relative;height:505px;width:640px;top:22px;margin-left:auto;margin-right:auto;background-color:#c2c2c2;color:black;font-size:18px;line-height:135%;border: 1px solid #000000;">


 &nbsp;<?php echo $id_title; ?>
<div id='mediaplayer'> </div>

<script type="text/javascript">
  jwplayer('mediaplayer').setup({
    'flashplayer': '/jwplayer/player.swf',
    'id': 'playerID',
    'type': 'video',
    'provider': 'video',
    'width': '640',
    'height': '480',
    'file': 'loader.php?id=<? echo $id_num; ?>&u=<? echo $id_url; ?>&pt=flv',
    'image': '<?php echo $id_prev; ?>',
    'title': '<?php echo $id_title; ?>',
    'bufferlength': '2',
    'stretching' : 'fill',
    'controlbar': 'bottom',
    'allowmenu': 'true'
   
  });

function loadClip(href)
{
    var playlist = jwplayer().getPlaylist();

    playlist[0].file = 'loader.php?&pt=flv';

    jwplayer().load(playlist).play(true);
}
</script>

</div>
</div>



</body>
</html>

<?php 

     // Save the cached content to a file 

       $fp = fopen($cachefile, 'w'); 

       fwrite($fp, ob_get_contents()); 

       fclose($fp);     

   

     // Send browser output 

     ob_end_flush(); 

 ?>


Since you dont want picture galleries to appear on the tube site.  The script checks for a tag of your choice (YOURIDTAG) located in the TAG field of your TGPX database.

If the ID number is not found in the TGPX database or the gallery ID is not tagged for display on the tube site, there are two PHP error files to handle this, and one to handle parameter passing errors.

Sample for invalid or no parameters passed to script (video_error.php): http://www.phatblaxxx.com/videos/player.php

Sample for ID number not found (video_error1.php): http://www.phatblaxxx.com/videos/player.php?d=35292263646

Sample for ID number not tagged for tube site use (video_error2.php): http://www.phatblaxxx.com/videos/player.php?d=352

Above is the code for player.php.  I will be adding comments to clarify sections of the code as needed.  If you have any questions I will try to answer them.  I will be post the code for the video_error files forthwith.

Step 4: Edit your TGPX template page to link to your PHP video page.

Code: [Select]
<a href="http://www.yoursite.com/videos/player.php?d={$gallery.gallery_id|urlencode}"  target="_blank"  ><div class="vidtitle">{$gallery.description|htmlspecialchars}</div><div id="fixpic"><img src="{$gallery.preview_url|htmlspecialchars}"  alt="{$gallery.description|htmlspecialchars}"  title="{$gallery.description|htmlspecialchars}"  height="200" width="260"  border="2" /></a>


MORE TO COME!
« Last Edit: August 15, 2013, 03:43:28 AM by a4evermedia »

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Re: Create a TUBE site driven by TGPX data
« Reply #2 on: August 14, 2013, 03:12:35 PM »
Script posting updated

Offline Dred

  • Newbie
  • *
  • Posts: 25
  • Karma: +10/-0
    • View Profile
    • http://ebony-gloryhole.com/
Re: Create a TUBE site driven by TGPX data
« Reply #3 on: November 15, 2013, 01:18:18 PM »
Just wondering.
For this setup, are you using a single MySQL db for both TGPX and TubeX or are they separate?

thx!

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Re: Create a TUBE site driven by TGPX data
« Reply #4 on: November 15, 2013, 08:21:23 PM »
Hey Dred

I am using the TGPX database with an extra field added which contains the URL of the clip to be played.

Offline Dred

  • Newbie
  • *
  • Posts: 25
  • Karma: +10/-0
    • View Profile
    • http://ebony-gloryhole.com/
Re: Create a TUBE site driven by TGPX data
« Reply #5 on: November 15, 2013, 10:11:02 PM »
Thx a4evermedia...I caught that part after re-reading the OP. Sorry about that!  :P

Now is that an edited/tweaked default TGPx template or did I miss some settings somewhere? LOL

The first time I installed both scripts I couldn't get the thumb sizes to change, I got so pissed-off that I ended up uninstalling both scripts.

thx again!

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Re: Create a TUBE site driven by TGPX data
« Reply #6 on: November 16, 2013, 06:42:39 PM »
The main dislpay or 'landing' is a standard TGPX build with a thumbnail uploaded by the user and the link for calling the player.php script (Step 4).  The only tricky part may be tweaking the code for the player.php page which will depend on the flash player you are using (Step 3).
« Last Edit: November 16, 2013, 06:44:40 PM by a4evermedia »

Offline Dred

  • Newbie
  • *
  • Posts: 25
  • Karma: +10/-0
    • View Profile
    • http://ebony-gloryhole.com/
Re: Create a TUBE site driven by TGPX data
« Reply #7 on: November 20, 2013, 06:37:03 AM »
ArRgh! Still can't get this to work.  >:(

Missing includes/variables.php (nope, no variables.php in the directory, yet the template is calling for it)
Missing video_error.php, video_1.php and video_error_2.php (maybe I could just strip this out of the code?)

The index.php is busted up, showing the template code and whatnot. So I'm pretty sure this is where I'm having the most issues, can't seem to figure out the templating...as simple as it is.

I'm trying to get something as basic-looking and clean as yours, a4evermedia. I love your clean design. Basically I'm trying to get your clean design and then I can add a background and a header graphic. Think you can you shoot me yours? I know I'm probably asking too much but I won't know unless I ask.

I just threw up a default tubex site until I can sort this out.

Thanks for all of your help a4evermedia.

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Re: Create a TUBE site driven by TGPX data
« Reply #8 on: November 20, 2013, 10:17:14 AM »
OK Dred, let's see if I can help you get this working!  :)

I try to keep the index template simple, using as few tables as possible.  I try to use CSS for everything.

The variables.php file contains your database login info.  You must create it and place it in a secure directory.  I placed it in the 'cgi-bin/includes' directory for security.  It should look something like this:

Code: [Select]
<?php
$username="tgpx_database_username";
$password="tgpx_database_password";
$database="tgpx_database_name";
?>

The video_error.php files are in the same directory as the variables.php file.   These files are necessary to make sure that the proper parameters are passed to the player.php script that is used to play the individual scripts.  There are examples posted earlier in this discussion.  In normal use the visitor will not see the errors pages because TGPX template will only create legitimate values for the player.php program.  But if someone tries to type in invalid entries the error checking in player.php will catch them.   I will PM you the raw code later on today since I don't have to worry about you hacking into the site :) 

As far as stripping out the the video_error checks, you can do that but player.php will break if someone enters invalid info; which is only a problem for someone trying to hack your site :)

Please PM me your direct email address.

a4ever
« Last Edit: November 20, 2013, 10:39:34 AM by a4evermedia »

Offline Dred

  • Newbie
  • *
  • Posts: 25
  • Karma: +10/-0
    • View Profile
    • http://ebony-gloryhole.com/
Re: Create a TUBE site driven by TGPX data
« Reply #9 on: November 20, 2013, 10:40:22 AM »
Definitely don't have to worry about me hacking into your site...especially if I can't wrap my head around something as simple as this scripts templating. LOL

thanks a lot a4evermedia!  :D

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Re: Create a TUBE site driven by TGPX data
« Reply #10 on: November 20, 2013, 03:38:06 PM »
PM sent

Offline Dred

  • Newbie
  • *
  • Posts: 25
  • Karma: +10/-0
    • View Profile
    • http://ebony-gloryhole.com/
Re: Create a TUBE site driven by TGPX data
« Reply #11 on: November 21, 2013, 07:08:06 AM »
Thanks a4evermedia, greatly appreciated!  ;D

Now I have to work on getting the player.php code working and I'm good to go.

A few questions though.

1. Did you make an empty _cache directory in the root?
I only ask because that's what this line of code is telling me...
Code: [Select]
// Define path and name of cached file  

   $cachefile = '/home/YOURSERVER/public_html/_cache/' . $videoid . '_cached';

2. Are you uploading galleries or just inputting the clip url?

3. Where do you upload the thumb for the index page.

(Just thought of this and probably answered my last two questioned...)
I'm guessing I have to upload a gallery in order to get a thumb for the main page and when they click on that thumb they get served the clip instead.
« Last Edit: November 21, 2013, 07:42:21 AM by Dred »

Offline a4evermedia

  • Global Moderator
  • Full Member
  • ***
  • Posts: 122
  • Karma: +25/-0
  • Gender: Male
    • View Profile
    • A4Ever Media
Re: Create a TUBE site driven by TGPX data
« Reply #12 on: November 21, 2013, 10:48:28 AM »
1. Yes, create the _cache directory yourself.  This is where the cached player.php pages are stored for the indivual video clips.  Very efficient and reduces the already low server load.

2-3.  What I acutually do most of the time is to export the appropriate (amateur black homemade) video clips from my TubeX installation, to include the clip URL and thumbnail, I then import this info into TGPX database.  To clarify, I enter the clips into my TUBEX installation then export the data to a text file which I then import into my TGPX installation.   That is what I do most often.  But the info can be entered individually as well of course.  Meaning that I sometimes upload a clip thumbnail thru the TGPX admin interface and in the gallery field I enter the link to the player.php with the appropriate ID parameter.

i.e., http://www.phatblaxxx.com/videos/player.php    note: this generates an error which calls video_error.php!

i.e., http://www.phatblaxxx.com/videos/player.php?d=16748

I dont do it this way often because you dont know what the ID is until after you enter the info, but it works.

The big Bonus is that the clips can appear on your other TGPX sites if they fit into the category of the page!

I prefer importing from my TUBEX install because not only is it quick, easy and efficient - the TUBEX link serves as my "gallery URL" in TGPX!

For instance, these two pages are served by the same clip URL:

http://sexworldtube.com/video/2130/

http://www.phatblaxxx.com/videos/player.php?d=1172

This is the code for exporting my TUBEX clips to be imported into TGPX:
Code: [Select]
{videos
var=$videos
amount=2000
username=PhatBlaXXX
paginate=false
pagination=$pagination
sort=date_added DESC}

{foreach var=$video from=$videos}
      {category var=$category id=$video.category_id}
      {clips var=$clips videoid=$video.video_id}
      {assign var=$clip code=$clips[0]}
      http://sexworldtube.com/video/{$video.video_id}/|6|{$video.title}|Homemade,Amateur,Webcams,Ebony,{$category.name}|{$video.tags}|http://www.sexworldtube.com{$video.thumbnail}|200x200|{$clip.clip}|phatblax<br/>
{/foreach}

I include the TAG 'phatblax' because that is my TAG ID for indicating that this is a clip to be displayed on the PhatBlaXXX site.

This makes it easy for me because on my SexWorldTube site user PhatBlaxxx contains the appropriate clips for the PhatBlaXXX site!
« Last Edit: November 22, 2013, 05:20:19 PM by a4evermedia »

Unofficial JMB Support Forums

Re: Create a TUBE site driven by TGPX data
« Reply #12 on: November 21, 2013, 10:48:28 AM »


Tags:
 

Related Topics

  Subject / Started by Replies Last post
12 Replies
10076 Views
Last post July 29, 2013, 01:24:58 PM
by a4evermedia
0 Replies
1731 Views
Last post June 10, 2013, 05:21:56 AM
by darkorns
0 Replies
1193 Views
Last post May 05, 2015, 06:57:24 AM
by greg
0 Replies
582 Views
Last post November 04, 2018, 01:32:32 AM
by The Dawg
1 Replies
305 Views
Last post June 29, 2019, 02:57:16 PM
by peeperd

anything