PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/deploy/referenzvideos/index.php

https://bitbucket.org/gvandenelzen/filmstudio
PHP | 384 lines | 341 code | 32 blank | 11 comment | 22 complexity | 9b8b984c3610c31e51285a3a435c6714 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /*
  3. * Created on Mar 8, 2011
  4. *
  5. * To change the template for this generated file go to
  6. * Window - Preferences - PHPeclipse - PHP - Code Templates
  7. */
  8. define("VIDEOS", "http://kloepfer.rushnewmedia.de/video-n66Q2/distribution-12998/stream/");
  9. define("THUMBS", "/video-n66Q2/distribution-12998/thumbs/");
  10. define("THUMB_POSTFIX", "_thumbsmall.jpg");
  11. define('BASE','http://kloepfer.rushnewmedia.de');
  12. define('PASS','q45RT50pLxt12vwmA');
  13. define ('CNET','193.228.149');
  14. require_once ('dbinclude.php');
  15. $domain=CNET;
  16. $allowed=false;
  17. $pass=$_REQUEST['pass'];
  18. $origin=$_SERVER['REMOTE_ADDR'];
  19. $pos=strpos ($origin ,CNET);
  20. if( $pass==PASS)
  21. {
  22. $allowed=true;
  23. }
  24. else
  25. {
  26. if(strpos ($origin ,CNET)!==false)
  27. $allowed=true;
  28. }
  29. if(!$allowed)
  30. {
  31. exit();
  32. }
  33. $script=$_SERVER['SCRIPT_NAME'];
  34. $formaction="$script";
  35. $categories=getCategories();
  36. $cat=$_REQUEST['cat'];
  37. $catname=$_REQUEST['Kategorie'];
  38. $reference=$_REQUEST['reference'];
  39. if(!isset($cat))$cat=$categories[0]['ID'];
  40. if(isset($catname))
  41. {
  42. foreach($categories as $catrecord)
  43. {
  44. if($catrecord['Name']==$catname)
  45. {
  46. $cat=$catrecord['ID'];
  47. break;
  48. }
  49. }
  50. }
  51. if(!isset($reference))
  52. {
  53. $ref=true;
  54. }
  55. else
  56. {
  57. $ref=false;
  58. }
  59. if(!isset($cat))$cat=$categories[0]['ID']; $videos=getVideos($cat,$ref);
  60. $amount=count($videos);
  61. /* if($amount==0) { $title=$website['Title']; echo makeNoVideo($title); exit; }
  62. */
  63. $catdropdown='<tr><td></td><td>Kategorie <select name="Kategorie" size="1">{OPTIONS}</select>&nbsp; <input type="submit" name="submit" id="submit" value="Zeigen" /></td></tr>';
  64. foreach($categories as $category)
  65. {
  66. $id= $category['ID'];
  67. $name= $category['Name'];
  68. if($cat==$id)
  69. {
  70. $options.="<option selected=\"selected\" value=\"$name\">$name</option>";
  71. }
  72. else
  73. {
  74. $options.="<option value=\"$name\">$name</option>";
  75. }
  76. }
  77. $catdropdown=str_replace("{OPTIONS}",$options,$catdropdown);
  78. function formatTS($ts)
  79. {
  80. return substr($ts,6,2).'.'.substr($ts,4,2).'.'.substr($ts,0,4);
  81. }
  82. function formatDuration($ts)
  83. {
  84. if($ts==0)
  85. return "";
  86. return $ts. " Sek.";
  87. }
  88. function getVideos($cat,$ref) {
  89. global $db;
  90. $refclause="";
  91. if($ref)
  92. {
  93. $refclause=" AND video.ReferenceVideo = 1 ";
  94. }
  95. $sql = "SELECT video.ID as id,video.FileName as videoname,video.Length as duration,video.UserRating as rating,video.UpdateTimestamp as timestamp,theme.ThemaText as theme,theme.ID as ThID,theme.DetailText as detail ,people.FirstName as firstname, people.LastName as lastname , category.Name as category FROM video,theme,people, category WHERE theme.ID=video.ThemeID AND people.ID=video.peopleID AND category.ID=theme.KategorieID AND Video.ACtive=1 AND category.ID=$cat $refclause ORDER BY `UpdateTimestamp` DESC " ;
  96. $sqlresult = mysql_query($sql, $db);
  97. if (!$sqlresult) {
  98. $error = mysql_error($db);
  99. sendRequestError($request, 'select all videos' . $error.$sql);
  100. };
  101. while($record = mysql_fetch_assoc($sqlresult) )
  102. {
  103. $filename=$record['videoname'];
  104. $thumb=array_shift(explode(".",$filename));
  105. $thumb=THUMBS.$thumb.THUMB_POSTFIX;
  106. if(!file_exists('..'.$thumb))
  107. {
  108. //continue;
  109. }
  110. $record['lastname']=htmlentities($record['lastname']);
  111. $record['firstname']=htmlentities($record['firstname']);
  112. $record['category']=htmlentities($record['category']);
  113. $record['theme']=htmlentities($record['theme']);
  114. $record['detail']=htmlentities($record['detail']);
  115. if($record['detail']=="0")
  116. $record['detail']="";
  117. $record['detail']=abreviate($record['detail'],80);
  118. $record['thumb']=BASE.$thumb;
  119. $record['videofile']=VIDEOS.$record['videoname'];
  120. $record['timestamp']=formatTS($record['timestamp']);
  121. $record['duration']=formatDuration($record['duration']);
  122. $records[]=$record;
  123. }
  124. return $records;
  125. }
  126. function getCategories() {
  127. global $db;
  128. $sql = "SELECT ID,Name FROM category " ;
  129. $sqlresult = mysql_query($sql, $db);
  130. if (!$sqlresult) {
  131. $error = mysql_error($db);
  132. sendRequestError($request, 'select all categories' . $error);
  133. };
  134. while($record = mysql_fetch_assoc($sqlresult) )
  135. {
  136. $records[]=$record;
  137. }
  138. return $records;
  139. }
  140. function abreviate($test,$len)
  141. {
  142. if(strlen($test)<=80)
  143. return $test;
  144. $newText="";
  145. $words=explode( " ",$test);
  146. foreach($words as $word)
  147. {
  148. $tmpText.=$word." ";
  149. if(strlen($tmpText)<$len)
  150. {
  151. $newText=$tmpText;
  152. }
  153. else
  154. {
  155. break;
  156. }
  157. }
  158. return $newText.'…';
  159. }
  160. $thumbRow =<<<TROW
  161. <tr>
  162. <td width="100"></td>
  163. <td align='left'>{THUMB1}</td><td align='left' >{THUMB2}</td>
  164. <tr height="40"></tr>
  165. </tr>
  166. TROW;
  167. $thumbBlock =<<<TBLK
  168. <table border="0" cellpadding="0" cellspacing="2" align='left'>
  169. <tr>
  170. <td width="135" height="96" rowspan="8" align='left' valign="top"><div style="position:relative;"><img src="{THUMBIMAGE}" width="128" height="96" />
  171. <div style="position:absolute;top:0px;left:0px;">
  172. <a class="movieSmallPlay" href='javascript:showMovie({MOVIE});'> </a>
  173. </div></div></td>
  174. </tr>
  175. <tr class="theme">
  176. <td width="59" valign="top" align='left'>Thema<br /></td>
  177. <td width="308" valign="top">{THEME}</td>
  178. </tr>
  179. <tr class="detail">
  180. <td width="59" valign="top" >Detail<br /></td>
  181. <td width="308" valign="top" >{DETAIL}</td>
  182. </tr>
  183. <tr class="detail">
  184. <td width="59" valign="top" >Bereich<br /></td>
  185. <td width="308" valign="top" >{BEREICH}</td>
  186. </tr>
  187. <tr class="detail">
  188. <td width="59" valign="top" >Name<br /></td>
  189. <td width="308" valign="top" >{NAME}</td>
  190. </tr>
  191. <tr class="detail">
  192. <td width="59" valign="top" >Länge<br /></td>
  193. <td width="308" valign="top" >{DURATION}</td>
  194. </tr>
  195. <tr class="detail">
  196. <td width="59" valign="top" >Datum<br /></td>
  197. <td width="308" valign="top" >{DATE}</td>
  198. </tr>
  199. <tr>
  200. </table>
  201. TBLK;
  202. $thumbsInRow=0;
  203. foreach($videos as $record)
  204. {
  205. $id=$record['id'];
  206. $theme=$record['theme'];
  207. $thumbimage =$record['thumb'];
  208. $videofile=$record['videofile'];
  209. $detail=$record['detail'];
  210. $duration=$record['duration'];
  211. $name=$record['firstname'].' '.$record['lastname'];
  212. $bereich=$record['category'];
  213. $date=$record['timestamp'];
  214. $rating= $record['rating'];
  215. $thumb=$thumbBlock;
  216. $thumb=str_replace("{THUMBIMAGE}",$thumbimage,$thumb);
  217. $thumb=str_replace("{THEME}",$theme,$thumb);
  218. $thumb=str_replace("{DETAIL}",$detail,$thumb);
  219. $thumb=str_replace("{BEREICH}",$bereich,$thumb);
  220. $thumb=str_replace("{NAME}",$name,$thumb);
  221. $thumb=str_replace("{DURATION}",$duration,$thumb);
  222. $thumb=str_replace("{DATE}",$date,$thumb);
  223. $thumb=str_replace("{MOVIE}",enquote($videofile),$thumb);
  224. $thumb=str_replace("{SELECT}",$select,$thumb);
  225. $thumb=str_replace("{ID}",$id,$thumb);
  226. if($thumbsInRow==0)
  227. {
  228. $rowofthumbs=str_replace("{THUMB1}",$thumb,$thumbRow);
  229. }
  230. if($thumbsInRow==1)
  231. {
  232. $rowofthumbs=str_replace("{THUMB2}",$thumb,$rowofthumbs);
  233. }
  234. $thumbsInRow++;
  235. if($thumbsInRow>1)
  236. {
  237. $rows.=$rowofthumbs;
  238. $thumbsInRow=0;
  239. }
  240. }
  241. if($thumbsInRow==1)
  242. {
  243. $rowofthumbs=str_replace("{THUMB2}","",$rowofthumbs);
  244. $rows.=$rowofthumbs;
  245. }
  246. if($amount==0)
  247. {
  248. $rows='<tr><td width="100"></td><td > Keine Videos</td><td ></td><tr height="40"></tr></tr>';
  249. ;
  250. }
  251. ?>
  252. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  253. <html xmlns="http://www.w3.org/1999/xhtml">
  254. <head>
  255. <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  256. <meta name="generator" content="Adobe GoLive" />
  257. <title>Kloepfer Filmstudio - Referenz-Videos</title>
  258. <script type='text/javascript' src='js/jwplayer.js'></script>
  259. <script type='text/javascript' src='js/jquery-1.7.2.min.js'></script>
  260. <script type="text/javascript" src="js/jquery.DOMWindow.js"></script>
  261. <script type="text/javascript">
  262. function showMovie(sFilename){
  263. $.openDOMWindow({
  264. windowSourceID:'#FilmDiv' ,
  265. height:'445',
  266. width:590 ,
  267. windowPadding:5,
  268. windowBGColor:'#222222',
  269. modal:1,
  270. overlay:1
  271. });
  272. playMovie(sFilename);
  273. }
  274. function closeit() {
  275. $.closeDOMWindow({
  276. windowSourceID:'#FilmDiv'
  277. });
  278. document.getElementById("mediaplayerContainer").innerHTML = '<div id="mediaplayer"></div>';
  279. }
  280. function playMovie(sFilename) {
  281. jwplayer('mediaplayer').setup({ 'flashplayer': 'player.swf', 'id': 'playerID', 'width': '566', 'height': '424',
  282. autostart : true, modes : [ { type : "flash", src : "player.swf", config : { file : sFilename } }, { type : "html5", config : { file : sFilename } }, ] }); }
  283. </script>
  284. <style type="text/css" media="all">
  285. body {
  286. color: #fff;
  287. font-size: 9pt;
  288. font-family: Arial, Verdana, Helvetica, sans-serif;
  289. background-color: #262626;
  290. }
  291. .genTitle {
  292. font-size: 14pt;
  293. }
  294. .theme {
  295. font-size: 10pt;
  296. }
  297. .detail {
  298. font-size: 8pt;
  299. }
  300. a.movieSmallPlay {
  301. background-image: url("img/smallplay.png");
  302. display: block;
  303. height: 35px;
  304. text-decoration: none;
  305. width: 35px;
  306. }
  307. a.movieSmallPlay:hover {
  308. background-image:url("img/smallplay_hover.png");
  309. }
  310. </style>
  311. <script type="text/javascript">
  312. </script>
  313. </head>
  314. <body>
  315. <form id="catform" name="catform" method="get" action="<?php echo $formaction;?>">
  316. <table cellspacing="2" cellpadding="0" border="0" width="100%" align="left">
  317. <tr>
  318. <td colspan="1"><h2><strong><em><img src="logo.jpg" alt="" height="166"
  319. width="148" border="0" /></em></strong></h2></td> <td class="dsR13" colspan="3" valign="top"></td>
  320. </tr>
  321. <tr>
  322. <td height="20"> </td>
  323. <td colspan="2" valign="top"><p class="genTitle">Willkommen im Klöpfer Filmstudio. </p></td>
  324. </tr>
  325. <tr>
  326. <td height="20"> </td>
  327. <td colspan="2" valign="top">Ihre Filme im Überblick. Zum Starten der Videos bitte auf den Play-Knopf klicken. </td>
  328. </tr>
  329. <?php echo "$catdropdown";?>
  330. <tr><td></td>
  331. <td colspan="3" align="center" valign="middle"><hr /></td>
  332. </tr>
  333. <?php echo "$rows";?>
  334. </table>
  335. </form>
  336. <style type="text/css">
  337. #gc {
  338. margin: 0 auto;
  339. width: 566px;
  340. }
  341. </style>
  342. <div style="DISPLAY:none; visibility:hidden; height:1px;" id="FilmDiv">
  343. <div style="text-align:right;"><a href="javascript:closeit();" ><img src="img/cross.gif" border="0" title="Fenster schließen"></a></div>
  344. <div class="gencontainer" id="gc">
  345. <div id="mediaplayerContainer">
  346. <div id="mediaplayer">JW Player goes here</div>
  347. </div>
  348. </div>
  349. </div>
  350. </body>
  351. </html>