diff options
| author | root | 2014-03-12 16:25:54 +0100 |
|---|---|---|
| committer | root | 2014-03-12 16:25:54 +0100 |
| commit | 3d85e8b07382727cfe1cbf7f3a7add424ac47a04 (patch) | |
| tree | 155122a3b476ff90534795a15b629fb5ccfea964 | |
| parent | c5eb023d8ecedee1f94aff6892df818f85a0d8a3 (diff) | |
| parent | eecb232938a20bd33eb5928e54d7fd3cffea9b2a (diff) | |
| download | random-3d85e8b07382727cfe1cbf7f3a7add424ac47a04.tar.gz | |
merge and adding stuff
| -rw-r--r-- | www/failure.php | 60 | ||||
| -rw-r--r-- | www/header.php | 19 | ||||
| -rw-r--r-- | www/index.php | 14 | ||||
| -rw-r--r-- | www/youtube.php | 74 |
4 files changed, 136 insertions, 31 deletions
diff --git a/www/failure.php b/www/failure.php index 21cd87c..5ccc7a8 100644 --- a/www/failure.php +++ b/www/failure.php @@ -1,15 +1,59 @@ <!Doctype html> <head> -<title>404 - No Droids found</title> -<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> +<title>Welcome</title> +<meta http-equiv='Content-type' content='text/html; charset=utf-8' /> +<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /> +<link rel='stylesheet' type='text/css' href='style.css'/> +<style type='text/css'> +a2 { + color: blue; +} +tt { + text-align: center; +} +</style> </head> -<body> +<body vlink='#000000' link='#000000' alink='#9a9696'> <center> -<img src="404.jpg" alt="404 - not found"> +<? include("header.php"); ?> +<table align="center"><tr><td> +<h1> Welcome! </h1> +<? //<img src="404.jpg" alt="404 - not found"> ?> -<br><br> -Recommandations: -<table> -<tr><td><a href="/youtube">Get a random youtube Video</a></td><td><a href="/puush">or a random puush file</a></td></tr> +</td></tr><tr><td> +On this website, you can get a random +</td></tr><tr><td> +</td></tr><tr><td> +</td></tr><tr><td> +<ul> +<li> +<table><tr><td> +<a href="/youtube">YouTube video</a> +</td></tr></table> +</li> +<li> +<table><tr><td> +<a href="/puush">puush file</a> +</td></tr></table> +</li> +<li> +<table><tr><td> +<a href="/random">random subsite</a> +</td></tr></table> +</li> +</ul> +</td></tr> +<tr><td> +</td></tr><tr><td> +completely free and as often as you like. +</td></tr> </table> + +<br><br> +For comments, questions or suggestions drop a <br> <a href="/about"><font color='blue'>mail</font></a>. + +<? include("piwik.php");?> + +</body> +</html> diff --git a/www/header.php b/www/header.php new file mode 100644 index 0000000..fb17d93 --- /dev/null +++ b/www/header.php @@ -0,0 +1,19 @@ +<div id='header' align='center' class='small'> +<table width='700px'><tr> +<td><a href='/'>Home</a></td> +<td>|</td> +<td><a href='/youtube'>Youtube</a></td> +<td>|</td> +<td><a href='/puush'>Puush</a></td> +<td>|</td> +<td><a href='/about'>About</a></td> +</tr> +</table> +</div> +<div> +<table width='700px'><tr> +<td> +<hr> +</td> +</table> +</div> diff --git a/www/index.php b/www/index.php index 24db3f5..f793c10 100644 --- a/www/index.php +++ b/www/index.php @@ -1,5 +1,8 @@ <? +if(empty($_GET["task"])){ + include("failure.php"); +} else { switch($_GET["task"]){ case("youtube"): include("youtube.php"); @@ -7,7 +10,16 @@ switch($_GET["task"]){ case("puush"): include("puush.php"); break; + case("about"): + include("about.php"); + break; + case("random"): + $array = array("youtube.php", "puush.php", "about.php", "lolrndm.php"); + $site = mt_rand(0, count($array)-1); + include($array[$site]); + break; default: - include("failure.php"); + include("lolrndm.php"); break; } +} diff --git a/www/youtube.php b/www/youtube.php index 05d61d6..1e902f7 100644 --- a/www/youtube.php +++ b/www/youtube.php @@ -1,18 +1,4 @@ -<!Doctype html> -<head> -<title>Random YouTube Video</title> -<meta http-equiv='Content-type' content='text/html; charset=utf-8' /> -<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /> -<link rel='stylesheet' type='text/css' href='style.css'/> -</head> -<!--body link='#000000' alink='#000000' vlink='#6a6862'> -<body link='#000000' alink='#000000' vlink='#41403d'> -<body link='#000000' alink='#000000' vlink='#2c2b29'--> -<body vlnk='#5b5b5b' vlink='#000000' link='#000000' alink='#9a9696'> -<center> - <?php -include("header.php"); // generates the $youtube object with API version 2 $clientLibraryPath = "../zend/library"; @@ -23,6 +9,11 @@ Zend_Loader::loadClass('Zend_Gdata_YouTube'); $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); +function error(){ + header("Refresh: 0; /youtube"); + exit; +} + function searchterm(){ $db = new SQLite3("../database/dict.db"); @@ -37,6 +28,9 @@ function searchterm(){ $random = mt_rand(1,$numRows); $search_word_db = $db->query("SELECT word FROM " . $table . " WHERE id=" . $random . ";"); + if(empty($search_word_db)){ + error(); + } $search_word_ar = $search_word_db->fetchArray(); $search_word = $search_word_ar["word"]; @@ -47,7 +41,13 @@ function getAndPrintVideoFeed($location, $yt) { $videoFeed = $yt->getVideoFeed($location); + if(empty($videoFeed)){ + error(); + } $videoID = printVideoFeed($videoFeed); + if(empty($videoID)){ + error(); + } return $videoID; } @@ -57,11 +57,16 @@ function printVideoFeed($videoFeed) $res_quant = count($videoFeed); $video = mt_rand(0, $res_quant-1); - if(!empty($video)){ - $videoId = printVideoEntry($videoFeed[$video]); - } else { - header("Refresh: 0; /youtube"); + + if(empty($video)){ + error(); } + + $videoId = printVideoEntry($videoFeed[$video]); + if(empty($videoId)){ + error(); + } + return $videoId; } @@ -69,6 +74,9 @@ function printVideoFeed($videoFeed) function printVideoEntry($videoEntry) { $videoId = $videoEntry->getVideoId(); + if(empty($videoId)){ + error(); + } return $videoId; } @@ -77,29 +85,51 @@ function start($yt){ $searchstring = searchterm(); $location = $yt->newVideoQuery(); + if(empty($location)){ + error(); + } // $location->setOrderBy('viewCount'); $location->setSafeSearch('none'); $location->setVideoQuery($searchstring); + if(empty($location)){ + error(); + } $videoID = getAndPrintVideoFeed($location, $yt); + if(empty($videoID)){ + error(); + } if(fopen("https://gdata.youtube.com/feeds/api/videos/" . $videoID , "r")){ return $videoID; } else { - start(); + start($yt); } } $videoID = start($yt); ?> +<!Doctype html> +<head> +<title>Random YouTube Video</title> +<meta http-equiv='Content-type' content='text/html; charset=utf-8' /> +<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /> +<link rel='stylesheet' type='text/css' href='style.css'/> +</head> +<!--body link='#000000' alink='#000000' vlink='#6a6862'> +<body link='#000000' alink='#000000' vlink='#41403d'> +<body link='#000000' alink='#000000' vlink='#2c2b29'--> +<body vlnk='#5b5b5b' vlink='#000000' link='#000000' alink='#9a9696'> +<center> -<h1>A random YouTube video!</h1> <br> -<iframe width="560" height="315" src="https://www.youtube.com/embed/<? echo $videoID ?>" frameborder="0" allowfullscreen></iframe> <br><br> +<?php include("header.php"); ?> + +<h1>A random youtube video!</h1> <br> +<iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo $videoID ?>" frameborder="0" allowfullscreen></iframe> <br><br> <a href="youtube">Get another one</a> </center> <?include("piwik.php"); - |
