I decided to post this for free as that PHP is free, and yes its coded by me
Well basically you can get the Embed of a video from Youtube and add it to your game, and it will show the video with details and stuff, well here I go.
First run this SQL:
CREATE TABLE IF NOT EXISTS `youtube` (
`videoID` int(11) NOT NULL auto_increment,
`videoNAME` varchar(255) NOT NULL default '',
`videoEMBED` text NOT NULL,
`videoVIEWS` int(11) NOT NULL default '0',
`videoINFO` text NOT NULL,
`videoADDEDDATE` int(11) NOT NULL default '0',
`videoADDEDBY` varchar(255) NOT NULL default '',
PRIMARY KEY (`videoID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;
Next Create a file called youtube.php and place this code inside it:
<?php
include "globals.php";
$_GET['videoID']=abs((int) $_GET['videoID']);
switch($_GET['action'])
{
case "addvideo": addvideo(); break;
case "addvideosub": addvideosub(); break;
case "deletevideo": deletevideo(); break;
case "deletevideosub": deletevideosub(); break;
case "allvideos": allvideos(); break;
default: index(); break;
}
function index()
{
global $db,$ir,$c,$userid,$h;
print "<hr width=75%><h3>Youtube Videos</h3><hr width=75%>";
print "<table border=0 width=60%>
<td>[[url='youtube.php?action=allvideos'][size="1"]All Videos[/size][/url]]</td>
<td>[[url='youtube.php?action=addvideo'][size="1"]Add Video[/size][/url]]</td>";
if($ir['user_level'] > 1)
{
print "<td>[[url='youtube.php?action=deletevideo'][size="1"]Delete Video[/size][/url]]</td>";
}
print "<td><form action='searchvideo.php' method='get'><input type='text' name='searchvideo' /><input type='submit' value='Search Video' /></form></td>
</table>";
$youtube=$db->query("SELECT * FROM youtube ORDER BY videoID DESC LIMIT 10");
print "
<table width=75% border=1 cellspacing=0>
<tr>
<th bgcolor=#CCCCCC>Last 10 videos added</th>
<th bgcolor=#CCCCCC>Watch</th>
</tr>";
while($ir=$db->fetch_row($youtube))
print "<tr>
<td bgcolor=#999999>{$ir['videoNAME']}</td>
<td bgcolor=#999999><center>[[size="1"][url='youtubevideo.php?v={$ir[']<font color=yellow>Watch</font>[/url][/size]]</center></td>
</tr>";
print "</table>
[size="1"]> [/size][url='explore.php']Back[/url]";
}
function addvideo()
{
global $db,$ir,$c,$userid,$h;
print "<h3>Adding a Video</h3>
[i]DO NOT ADD ANY SEXUAL VIDEOS AND MOVIES OR YOUR ACCOUNT WILL BE DELETED![/i]
<form action='youtube.php?action=addvideosub' method='post'>
Video Name: <input type='text' name='videoNAME' value='' />
Video Information: <input type='text' name='videoINFO' value='' />
Enter the Video Embed: <input type='text' name='videoEMBED' value='' />
<input type='submit' value='Add Video' /></form>
[size="1"]> [/size][url='youtube.php']Back[/url]";
}
function addvideosub()
{
global $db,$ir,$c,$userid,$h;
if($_POST['videoNAME'] == "" || $_POST['videoINFO'] == "" || $_POST['videoEMBED'] == "")
{
print "One or more of the fields were empty, go back and try again.
[size="1"]> [/size][url='youtube.php?action=addvideo']Back[/url]";
}
else
{
$db->query("INSERT INTO youtube (videoNAME, videoINFO, videoEMBED,videoADDEDBY, videoADDEDDATE) VALUES( '{$_POST['videoNAME']}', '{$_POST['videoINFO']}', '{$_POST['videoEMBED']}', '{$ir['username']}', unix_timestamp())");
print "{$_POST['videoNAME']} was added to the videos.";
stafflog_add("Added Video {$_POST['videoNAME']}");
}
}
function deletevideo()
{
global $db,$ir,$c,$userid,$h;
if($ir['user_level'] == 1)
{
die("Forbidden");
}
print "<h3>Deleting Item</h3>
[i]The video will be permanently removed from the game.[/i]
<form action='youtube.php?action=deletevideosub' method='post'>
Video: ".video_dropdown($c,'videoNAME')."
<input type='submit' value='Delete Video' /></form>
[size="1"]> [/size][url='youtube.php']back[/url]";
}
function deletevideosub()
{
global $db,$ir,$c,$userid,$h;
if($ir['user_level'] == 1)
{
die("Forbidden");
}
$d=$db->query("SELECT * FROM youtube WHERE videoID={$_POST['videoNAME']}");
$video=$db->fetch_row($d);
$db->query("DELETE FROM youtube WHERE videoID={$_POST['videoNAME']}");
print "The {$video['videoNAME']} video was removed.
[size="1"]> [/size][url='youtube.php']back[/url]";
stafflog_add("Deleted video {$video['videoNAME']}");
}
function allvideos()
{
global $db,$ir,$c,$userid,$h;
print "<h3>Showing all videos</h3>";
$youtube=$db->query("SELECT * FROM youtube ORDER BY videoNAME");
print "<table width=75% border=1 cellspacing=0>
<tr>
<th bgcolor=#CCCCCC>Showing all Videos Alphabetical Order</th>
<th bgcolor=#CCCCCC>Watch</th>
</tr>";
while($ir=$db->fetch_row($youtube))
print "<tr>
<td bgcolor=#999999>{$ir['videoNAME']}</td>
<td bgcolor=#999999><center>[[size="1"][url='youtubevideo.php?v={$ir[']<font color=yellow>Watch</font>[/url][/size]]</center></td>
</tr>";
print "</table>
[size="1"]> [/size][url='youtube.php']Back[/url]";
}
$h->endpage();
?>
After create a file called youtubevideo.php and place this code inside it:
<?php
include "globals.php";
$_GET['v'] = abs((int) $_GET['v']);
if(!$_GET['v'])
{
print "Invalid use of file";
}
else
{
$video=$db->query("SELECT * FROM youtube WHERE videoID={$_GET['v']}",$c);
if($db->num_rows($video) == 0)
{
print "There is no such video!";
}
else
{
$ir=mysql_fetch_array($video);
$dateadded=date('F j, Y',$ir['videoADDEDDATE']);
print "<table border=0 cellspacing=35>
<td><h3>{$ir['videoNAME']}</h3>
{$ir['videoEMBED']}</td>
<td>[b]Video Name:[/b] {$ir['videoNAME']}
[b]Video Information:[/b] {$ir['videoINFO']}
[b]Added By:[/b] {$ir['videoADDEDBY']}
[b]Date Added:[/b] $dateadded
[b]Video Views:[/b] {$ir['videoVIEWS']}
[b]Embed Code:[/b]
<textarea name='textarea' id='textarea' cols='35' rows='2'>{$ir['videoEMBED']}</textarea>
[size="1"]> [/size][url='youtube.php']Back[/url]</td>
</table>";
$db->query("UPDATE youtube SET videoVIEWS=videoVIEWS+1 WHERE videoID={$_GET['v']}");
}
}
$h->endpage();
?>
After create a file called searchvideo.php and place this code below in it:
<?php
include "globals.php";
if(!$_GET['searchvideo'])
{
print "You did not enter anything!
[size="1"]> [/size][url='youtube.php']Back[/url]";
}
else
{
$video=$db->query("SELECT * FROM youtube WHERE videoNAME LIKE ('%{$_GET['searchvideo']}%')");
print $db->num_rows($video)." Search Results
<table width=75% border=1 cellspacing=0>
<th bgcolor=#CCCCCC>Video Name</th>
<th bgcolor=#CCCCCC>Watch</th>
</tr>";
while($ir=$db->fetch_row($video))
{
print "<tr>
<td bgcolor=#999999>{$ir['videoNAME']}</a></td>
<td bgcolor=#999999><center>[[url='youtubevideo.php?v={$ir['][size="1"]<font color=yellow>Watch</font>[/size][/url]]</center></td>
</tr>";
}
print "</table>
[size="1"]> [/size][url='youtube.php']Back[/url]";
}
$h->endpage();
?>
Open and edit global_func.php and right at the bottom find:
?>
Add above:
function video_dropdown($connection,$ddname="videoNAME",$selected=-1)
{
global $db;
$ret="<select name='$ddname' type='dropdown'>";
$q=$db->query("SELECT * FROM youtube ORDER BY videoNAME ASC");
if($selected == -1) { $first=0; } else { $first=1; }
while($r=$db->fetch_row($q))
{
$ret.="\n<option value='{$r['videoID']}'";
if ($selected == $r['videoID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
$ret.=">{$r['videoNAME']}</option>";
}
$ret.="\n</select>";
return $ret;
}
Add a link in explore.php somewhere:
print "[url='youtube.php']Youtube Videos[/url]";
I think that's it, let me know if there is errors or bugs so I can see if I've missed anything
You can also add new stuff to it if you wish, enjoy!
Screenshots: