├── views ├── Movie │ ├── publish.php │ ├── addqueue.php │ ├── makeedit.php │ ├── viewed.php │ ├── removecomment.php │ ├── towatch.php │ ├── vote.php │ ├── addcomment.php │ ├── index.php │ ├── wall.php │ ├── queue.php │ ├── stat.php │ ├── addman.php │ ├── add.php │ ├── display.php │ ├── addimdb.php │ └── edit.php ├── Error │ ├── badurl.php │ ├── badview.php │ └── badtemplate.php ├── Series │ ├── makeedit.php │ ├── index.php │ ├── display.php │ ├── create.php │ └── edit.php ├── User │ ├── towatch.php │ └── recomended.php ├── Login │ ├── login.php │ └── index.php ├── Home │ └── index.php └── maintemplate.php ├── public ├── img │ └── posters │ │ └── index.php ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff └── js │ └── bootstrap.min.js ├── .htaccess ├── classes ├── auth.php ├── arraytools.php ├── viewmodel.php ├── basecontroller.php ├── functions.php ├── basemodel.php ├── view.php ├── session.php ├── database.php ├── loader.php └── imdb.php ├── models ├── error.php ├── home.php ├── login.php ├── user.php ├── series.php └── movie.php ├── config └── config_sample.php ├── .gitattributes ├── controllers ├── error.php ├── home.php ├── login.php ├── user.php ├── series.php └── movie.php ├── index.php ├── README.md ├── .gitignore └── db.sql /views/Movie/publish.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/img/posters/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /views/Movie/addqueue.php: -------------------------------------------------------------------------------- 1 | Fel! -------------------------------------------------------------------------------- /views/Movie/makeedit.php: -------------------------------------------------------------------------------- 1 | Fel! -------------------------------------------------------------------------------- /views/Movie/viewed.php: -------------------------------------------------------------------------------- 1 | Fel! -------------------------------------------------------------------------------- /views/Movie/removecomment.php: -------------------------------------------------------------------------------- 1 | Fel! -------------------------------------------------------------------------------- /views/Movie/towatch.php: -------------------------------------------------------------------------------- 1 | Något gick fel! 2 | -------------------------------------------------------------------------------- /views/Movie/vote.php: -------------------------------------------------------------------------------- 1 | Något gick fel! 2 | -------------------------------------------------------------------------------- /views/Error/badurl.php: -------------------------------------------------------------------------------- 1 |
The URL you have requested does not exist.
-------------------------------------------------------------------------------- /views/Movie/addcomment.php: -------------------------------------------------------------------------------- 1 | Du försöker posta en tom kommentar! Skriv något så blir det bra :) -------------------------------------------------------------------------------- /views/Series/makeedit.php: -------------------------------------------------------------------------------- 1 | '; 3 | var_dump($_POST); 4 | echo ''; -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Groggy1/PHP-movie-database/HEAD/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Groggy1/PHP-movie-database/HEAD/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Groggy1/PHP-movie-database/HEAD/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /views/Series/index.php: -------------------------------------------------------------------------------- 1 | printTable($viewModel -> get("tableBody"), $viewModel -> get("tableHead")); -------------------------------------------------------------------------------- /views/User/towatch.php: -------------------------------------------------------------------------------- 1 | printTable($viewModel -> get("tableBody"), $viewModel -> get("tableHead")); 4 | -------------------------------------------------------------------------------- /views/Login/login.php: -------------------------------------------------------------------------------- 1 |The controller action you requested does not have a view. This should exist as viewFile; ?>. Please create this file. -------------------------------------------------------------------------------- /views/Movie/index.php: -------------------------------------------------------------------------------- 1 | get("actors"); 4 | echo $viewModel -> get("directors"); 5 | $functions -> printTable($viewModel -> get("tableBody"), $viewModel -> get("tableHead")); 6 | ?> 7 | -------------------------------------------------------------------------------- /views/User/recomended.php: -------------------------------------------------------------------------------- 1 |
Poäng är beräknade på filmens genres och de filmer du betygsatt sedan tidigare.
2 | printTable($viewModel -> get("tableBody"), $viewModel -> get("tableHead")); -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | Options +FollowSymLinks 2 | RewriteEngine on 3 | RewriteRule ^(cron|install|old)($|/) - [L] 4 | RewriteRule ^([a-zA-Z]*)/?([a-zA-Z]*)?/?([a-zA-Z0-9]*)?/?([a-zA-Z0-9]*)?/?([a-zA-Z0-9]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&id=$3&id2=$4&id3=$5&id4=$6 [NC,L] -------------------------------------------------------------------------------- /views/Home/index.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /views/Error/badtemplate.php: -------------------------------------------------------------------------------- 1 |The controller action you requested is configured to access /views/.php as a view template, but this does not exist. Please make sure this file exists in /views or change the template name argument in your controller action's $this->returnView() method call to an existing template.
-------------------------------------------------------------------------------- /classes/auth.php: -------------------------------------------------------------------------------- 1 | 'login','action' => 'index','path' => $urlValues)); 8 | $controller = $loader -> createController(); 9 | $controller -> executeAction(); 10 | die(); 11 | } 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /views/Series/display.php: -------------------------------------------------------------------------------- 1 |2 | [Ändra] 3 |
4 | ' . $viewModel -> get("seriesname") . ''; 6 | echo $viewModel -> get("seriesdesc"); 7 | $functions = new Functions(); 8 | $functions -> printTable($viewModel -> get("tableBody"), $viewModel -> get("tableHead")); 9 | -------------------------------------------------------------------------------- /models/error.php: -------------------------------------------------------------------------------- 1 | viewModel->set("pageTitle","Error - Bad URL"); 15 | return $this->viewModel; 16 | } 17 | } 18 | 19 | ?> 20 | -------------------------------------------------------------------------------- /config/config_sample.php: -------------------------------------------------------------------------------- 1 | get('posters'); 3 | $first = $posters[0]; 4 | $second = $posters[1]; 5 | $third = $posters[2]; 6 | ?> 7 |Av dessa har ' . $viewModel -> get(watched) . ' filmer setts'; 8 | echo '
' . $viewModel -> get(towatch) . ' filmer är markerade för att ses
'; 9 | echo '' . $viewModel -> get(watchedtowatch) . ' filmer har varit markerade för att ses och setts
'; 10 | echo 'Det finns ' . $viewModel -> get(numberinqueue) . ' filmer i kö
'; 11 | echo '' . $viewModel -> get(movieswithoutruntime) . ' filmer saknar speltid
'; 12 | ?> 13 |I filmerna finns det totalt ' . $viewModel -> get(numberofactors) . ' skådespelare
'; 19 | echo 'Filmerna spänner över ' . $viewModel -> get(numberofgenres) . ' olika genres
'; 20 | $subtitle = $viewModel -> get(subtitle); 21 | for ($i = 0; $i <= sizeof($subtitle) - 1; $i++) : 22 | echo 'Det finns ' . $subtitle[$i][1] . ' filmer med ' . $subtitle[$i][0] . '
'; 23 | endfor; 24 | ?> 25 |Det har postats totalt ' . $viewModel -> get(comments) . ' kommentar på filmerna
'; 31 | echo 'Det har postats ' . $viewModel -> get(numberofnews) . ' nyheter
'; 32 | echo 'Det har lagts ' . $votes[0][1] . ' röster på filmerna
'; 33 | echo 'Rösterna har ett genomsnitt på ' . number_format($votes[0][0], 1) . ' poäng
'; 34 | ?> 35 |4 | [ändra] 5 |
6 |' . $value['name'] . ' ' . $value['date'] . '
'; 92 | echo '' . nl2br($value['comment']) . '
'; 93 | } 94 | ?> 95 |'; 5 | var_dump($url); 6 | echo ''; 7 | */ 8 | ?> 9 | 10 | 11 | 12 |
(.*?)(<|<\/p>)/ms', $plotPageHtml, 1))); 90 | $releaseinfoHtml = $this->geturl("http://www.imdb.com/title/" . $arr['title_id'] . "/releaseinfo"); 91 | $arr['also_known_as'] = $this->getAkaTitles($releaseinfoHtml); 92 | $arr['release_dates'] = $this->getReleaseDates($releaseinfoHtml); 93 | $arr['recommended_titles'] = $this->getRecommendedTitles($arr['title_id']); 94 | $arr['media_images'] = $this->getMediaImages($arr['title_id']); 95 | $arr['videos'] = $this->getVideos($arr['title_id']); 96 | } 97 | 98 | return $arr; 99 | } 100 | 101 | // Scan all Release Dates. 102 | private function getReleaseDates($html){ 103 | $releaseDates = array(); 104 | foreach($this->match_all('/
| (.*?)<\/td>/ms', $r, 1))); 106 | $date = trim(strip_tags($this->match('/ | (.*?)<\/td>/ms', $r, 1))); 107 | array_push($releaseDates, $country . " = " . $date); 108 | } 109 | return array_filter($releaseDates); 110 | } 111 | 112 | // Scan all AKA Titles. 113 | private function getAkaTitles($html){ 114 | $akaTitles = array(); 115 | foreach($this->match_all('/ |
| (.*?)<\/td>/ms', $m, 1);
117 | $akaCountry = trim($akaTitleMatch[0]);
118 | $akaTitle = trim($akaTitleMatch[1]);
119 | array_push($akaTitles, $akaTitle . " = " . $akaCountry);
120 | }
121 | return array_filter($akaTitles);
122 | }
123 |
124 | // Collect all Media Images.
125 | private function getMediaImages($titleId){
126 | $url = "http://www.imdb.com/title/" . $titleId . "/mediaindex";
127 | $html = $this->geturl($url);
128 | $media = array();
129 | $media = array_merge($media, $this->scanMediaImages($html));
130 | foreach($this->match_all('/ (.*?)<\/div>/msi', $html, 1), 1) as $i) {
141 | array_push($pics, preg_replace('/_V1\..*?.jpg/ms', "_V1._SY0.jpg", $i));
142 | }
143 | return array_filter($pics);
144 | }
145 |
146 | // Get recommended titles by IMDb title id.
147 | public function getRecommendedTitles($titleId){
148 | $json = $this->geturl("http://www.imdb.com/widget/recommendations/_ajax/get_more_recs?specs=p13nsims%3A${titleId}");
149 | $resp = json_decode($json, true);
150 | $arr = array();
151 | if(isset($resp["recommendations"])) {
152 | foreach($resp["recommendations"] as $val) {
153 | $name = $this->match('/title="(.*?)"/msi', $val['content'], 1);
154 | $arr[$val['tconst']] = $name;
155 | }
156 | }
157 | return array_filter($arr);
158 | }
159 |
160 | // Get all Videos and Trailers
161 | public function getVideos($titleId){
162 | $html = $this->geturl("http://www.imdb.com/title/${titleId}/videogallery");
163 | $videos = array();
164 | foreach ($this->match_all('/ .*?match('/ | .*? | .*?\((.*?)\)<\/span>/msi', $m, 1);
179 | $rating = $this->match('/ | .*? | ',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(this.options.viewport.selector||this.options.viewport);for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show()},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var c=a.contains(document.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!c)return;var d=this,e=this.tip(),f=this.getUID(this.type);this.setContent(),e.attr("id",f),this.$element.attr("aria-describedby",f),this.options.animation&&e.addClass("fade");var g="function"==typeof this.options.placement?this.options.placement.call(this,e[0],this.$element[0]):this.options.placement,h=/\s?auto?\s?/i,i=h.test(g);i&&(g=g.replace(h,"")||"top"),e.detach().css({top:0,left:0,display:"block"}).addClass(g).data("bs."+this.type,this),this.options.container?e.appendTo(this.options.container):e.insertAfter(this.$element);var j=this.getPosition(),k=e[0].offsetWidth,l=e[0].offsetHeight;if(i){var m=g,n=this.$element.parent(),o=this.getPosition(n);g="bottom"==g&&j.top+j.height+l-o.scroll>o.height?"top":"top"==g&&j.top-o.scroll-l<0?"bottom":"right"==g&&j.right+k>o.width?"left":"left"==g&&j.left-k '}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").empty()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},c.prototype.tip=function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){var e=a.proxy(this.process,this);this.$body=a("body"),this.$scrollElement=a(a(c).is("body")?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.$scrollElement.on("scroll.bs.scrollspy",e),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.1.1",b.DEFAULTS={offset:10},b.prototype.refresh=function(){var b="offset",c=0;a.isWindow(this.$scrollElement[0])||(b="position",c=this.$scrollElement.scrollTop()),this.offsets=[],this.targets=[];var d=this;this.$body.find(this.selector).map(function(){var d=a(this),e=d.data("target")||d.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[b]().top+c,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){d.offsets.push(this[0]),d.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b<=e[0])return g!=(a=f[0])&&this.activate(a);for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(!e[a+1]||b<=e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,a(this.selector).parentsUntil(this.options.target,".active").removeClass("active");var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")};var d=a.fn.scrollspy;a.fn.scrollspy=c,a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=d,this},a(window).on("load.bs.scrollspy.data-api",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);c.call(b,b.data())})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new c(this)),"string"==typeof b&&e[b]()})}var c=function(b){this.element=a(b)};c.VERSION="3.1.1",c.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a")[0],f=a.Event("show.bs.tab",{relatedTarget:e});if(b.trigger(f),!f.isDefaultPrevented()){var g=a(d);this.activate(b.closest("li"),c),this.activate(g,g.parent(),function(){b.trigger({type:"shown.bs.tab",relatedTarget:e})})}}},c.prototype.activate=function(b,c,d){function e(){f.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),g?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var f=c.find("> .active"),g=d&&a.support.transition&&f.hasClass("fade");g?f.one(a.support.transition.end,e).emulateTransitionEnd(150):e(),f.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this},a(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(c){c.preventDefault(),b.call(a(this),"show")})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=this.unpin=this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.1.1",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=a(document).height(),d=this.$target.scrollTop(),e=this.$element.offset(),f=this.options.offset,g=f.top,h=f.bottom;"object"!=typeof f&&(h=g=f),"function"==typeof g&&(g=f.top(this.$element)),"function"==typeof h&&(h=f.bottom(this.$element));var i=null!=this.unpin&&d+this.unpin<=e.top?!1:null!=h&&e.top+this.$element.height()>=b-h?"bottom":null!=g&&g>=d?"top":!1;if(this.affixed!==i){null!=this.unpin&&this.$element.css("top","");var j="affix"+(i?"-"+i:""),k=a.Event(j+".bs.affix");this.$element.trigger(k),k.isDefaultPrevented()||(this.affixed=i,this.unpin="bottom"==i?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(j).trigger(a.Event(j.replace("affix","affixed"))),"bottom"==i&&this.$element.offset({top:b-this.$element.height()-h}))}}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},d.offsetBottom&&(d.offset.bottom=d.offsetBottom),d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery);
--------------------------------------------------------------------------------
/models/movie.php:
--------------------------------------------------------------------------------
1 | urlValues AS $key => $value) {
15 | if (substr($key, 0, 2) == 'id') {
16 | $glink .= $value . '/';
17 | $ylink .= $value . '/';
18 | $alink .= $value . '/';
19 | $dlink .= $value . '/';
20 | if (substr($value, 0, 1) == 'g') {
21 | $genre = substr($value, 1);
22 | $glink = substr($glink, 0, strlen($glink) - (strlen($value) + 1));
23 | } elseif (substr($value, 0, 1) == 'y') {
24 | $year = substr($value, 1);
25 | $ylink = substr($ylink, 0, strlen($ylink) - (strlen($value) + 1));
26 | } elseif (substr($value, 0, 1) == 'a') {
27 | $actor = substr($value, 1);
28 | $alink = substr($alink, 0, strlen($alink) - (strlen($value) + 1));
29 | } elseif (substr($value, 0, 1) == 'd') {
30 | $director = substr($value, 1);
31 | $dlink = substr($dlink, 0, strlen($dlink) - (strlen($value) + 1));
32 | }
33 | }
34 | }
35 |
36 | $glink = rtrim($glink, '/');
37 | $ylink = rtrim($ylink, '/');
38 | $alink = rtrim($alink, '/');
39 | $dlink = rtrim($dlink, '/');
40 |
41 | $param = array();
42 | $SQL = "SELECT allMovies.id, allMovies.title, allMovies.year, allMovies.genre";
43 | if (strlen($actor) > 0 && strlen($director) == 0) {
44 | $SQL .= ", group_concat(DISTINCT concat(directors.id,':',directors.director) separator '|') AS directors";
45 | } elseif (strlen($actor) == 0 && strlen($director) > 0) {
46 | $SQL .= ", group_concat(DISTINCT concat(actors.id,':',actors.actor) separator '|') AS actors";
47 | }
48 | $SQL .= " FROM allMovies";
49 |
50 | if (strlen($actor) > 0 || strlen($director) > 0) {
51 | $SQL .= " JOIN actorsinmovies ON allMovies.id = actorsinmovies.movie_id
52 | JOIN directorsinmovies ON directorsinmovies.movie_id = allMovies.id";
53 | if (strlen($actor) > 0 && strlen($director) == 0) {
54 | $SQL .= " JOIN directors ON directors.id = directorsinmovies.director_id";
55 | } elseif (strlen($actor) == 0 && strlen($director) > 0) {
56 | $SQL .= " JOIN actors ON actors.id = actorsinmovies.actor_id";
57 | }
58 | }
59 | $SQL .= " WHERE";
60 | if (strlen($actor) > 0) {
61 | $SQL .= " actorsinmovies.actor_id = :aid AND";
62 | $param = array_merge($param, array(':aid' => $actor));
63 | }
64 | if (strlen($director) > 0) {
65 | $SQL .= " directorsinmovies.director_id = :did AND";
66 | $param = array_merge($param, array(':did' => $director));
67 | }
68 | if (strlen($genre) > 0) {
69 | $SQL .= " (genre LIKE :genre1 OR genre LIKE :genre2 OR genre LIKE :genre3) AND";
70 | $param = array_merge($param, array(':genre1' => '%|' . $genre . ':%', ':genre2' => $genre . ':%', ':genre3' => '%|' . $genre));
71 | }
72 | if (strlen($year) > 0) {
73 | $SQL .= " year = :year AND";
74 | $param = array_merge($param, array(':year' => $year));
75 | }
76 | $SQL .= " 1=1 GROUP BY allMovies.id ORDER BY allMovies.title ";
77 |
78 | $result = $this -> db -> select_query($SQL, $param);
79 |
80 | $i = 0;
81 | foreach ($result AS $value) {
82 | $actors[] = explode('|', $value['actors']);
83 | $directors[] = explode('|', $value['directors']);
84 | $tableBody[$i][0] = '' . $value['title'] . '';
85 | $tableBody[$i][1] = '' . $value['year'] . '';
86 | $genres = explode('|', $value['genre']);
87 | foreach ($genres AS $value2) {
88 | $localgenre = explode(':', $value2);
89 | $tableBody[$i][2] .= '' . $localgenre[1] . '';
90 | if (end($genres) !== $value2) {
91 | $tableBody[$i][2] .= ', ';
92 | }
93 | }
94 | $i++;
95 | }
96 |
97 | foreach ($ar -> unique_flat_array($actors) as $value) {
98 | if (strlen($value) != 0) {
99 | $local = explode(':', $value);
100 | $actorsout .= '' . $local[1] . '';
101 | if ($value !== end($ar -> unique_flat_array($actors)))
102 | $actorsout .= ', ';
103 | }
104 | }
105 | foreach ($ar -> unique_flat_array($directors) as $value) {
106 | if (strlen($value) != 0) {
107 | $local = explode(':', $value);
108 | $directorsout .= '' . $local[1] . '';
109 | if ($value !== end($ar -> unique_flat_array($directors)))
110 | $directorsout .= ', ';
111 | }
112 | }
113 |
114 | $this -> viewModel -> set('actors', trim($actorsout, ','));
115 | $this -> viewModel -> set('directors', trim($directorsout, ','));
116 | $this -> viewModel -> set('tableHead', array('Film', 'År', 'Genre'));
117 | $this -> viewModel -> set('tableBody', $tableBody);
118 | $this -> viewModel -> set('urlValues', $this -> urlValues);
119 | $this -> viewModel -> set('pageTitle', TITLE . 'Alla filmer');
120 | return $this -> viewModel;
121 | }
122 |
123 | public function display() {
124 | $id = $this -> urlValues['id'];
125 | $ar = new ArrayTools();
126 |
127 | $sql = "SELECT movies.youtube, movies.imdbid, movies.runtime, movies.title, movies.year, movies.poster, movies.plot, movies.sub, group_concat(DISTINCT concat(actors.id,',',actors.actor) separator '|') AS actor, group_concat(DISTINCT concat(directors.id,',',directors.director) separator '|') AS director, movietype.type, group_concat(DISTINCT concat(genres.id,',',genres.genre) separator '|') AS genre, series.name AS seriesname, series.id AS seriesid
128 | FROM movies
129 | LEFT JOIN actorsinmovies ON movies.id = actorsinmovies.movie_id
130 | LEFT JOIN actors ON actors.id = actorsinmovies.actor_id
131 | LEFT JOIN directorsinmovies ON movies.id = directorsinmovies.movie_id
132 | LEFT JOIN directors ON directorsinmovies.director_id = directors.id
133 | LEFT JOIN movietype ON movies.type = movietype.short
134 | LEFT JOIN genresinmovies ON movies.id = genresinmovies.movie_id
135 | LEFT JOIN genres ON genresinmovies.genre_id = genres.id
136 | LEFT JOIN moviesinseries ON movies.id = moviesinseries.movieID
137 | LEFT JOIN series ON moviesinseries.seriesID = series.id
138 | WHERE movies.id = :id
139 | GROUP BY movies.id";
140 |
141 | $result = $this -> db -> select_query($sql, array(':id' => $id));
142 | $result = $result[0];
143 |
144 | $sql = "SELECT user_id, value FROM uservote
145 | WHERE movie_id = :movieid";
146 |
147 | $votes = $this -> db -> select_query($sql, array(':movieid' => $id));
148 |
149 | $averagepoint = 0;
150 | $numberofvoters = 0;
151 |
152 | $sql = "SELECT id, name FROM users";
153 |
154 | $users = $this -> db -> select_query($sql);
155 |
156 | foreach ($votes as $value) {
157 | foreach ($users as $key => $value2) {
158 | if ($value2['id'] == $value['user_id']) {
159 | $users[$key]['value'] = $value['value'];
160 | }
161 | }
162 | $averagepoint += $value['value'];
163 | if (isset($value['value'])) {
164 | $numberofvoters++;
165 | }
166 | }
167 |
168 | $sql = "SELECT userid FROM userviewed
169 | WHERE movieid = :id";
170 |
171 | $viewed = $ar -> unique_flat_array($this -> db -> select_query($sql, array(':id' => $id)));
172 |
173 | $sql = "SELECT userid FROM towatch
174 | WHERE movieid = :id";
175 |
176 | $towatch = $ar -> unique_flat_array($this -> db -> select_query($sql, array(':id' => $id)));
177 |
178 | $sql = "SELECT usercomment.comment, users.name, usercomment.date FROM usercomment
179 | JOIN users ON usercomment.userid = users.id
180 | WHERE usercomment.movieid = :id
181 | ORDER BY usercomment.date, usercomment.id DESC";
182 |
183 | $comments = $this -> db -> select_query($sql, array(':id' => $id));
184 |
185 | $sql = "SELECT userid FROM towatchagain WHERE movieid = :id";
186 | $watchagain = $ar -> unique_flat_array($this -> db -> select_query($sql, array(':id' => $id)));
187 |
188 | foreach ($users as $key => $value) {
189 | $usertable[$key][0] = $value['name'];
190 |
191 | if (in_array($key + 1, $viewed)) {
192 | $usertable[$key][1] .= '';
193 | } else {
194 | if ($_SESSION['user_id'] == $key + 1) {
195 | $usertable[$key][1] .= '';
196 | } else {
197 | $usertable[$key][1] .= '';
198 | }
199 | }
200 |
201 | for ($i = 1; $i <= 5; $i++) {
202 | if ($value['value'] == $i) {
203 | $usertable[$key][2] .= '' . $i . ' ';
204 | } else {
205 | if ($_SESSION['user_id'] == $key + 1) {
206 | $usertable[$key][2] .= '' . $i . ' ';
207 | } else {
208 | $usertable[$key][2] .= '' . $i . ' ';
209 | }
210 | }
211 | }
212 |
213 | if (in_array($key + 1, $towatch)) {
214 | $usertable[$key][3] .= '';
215 | } else {
216 | if ($_SESSION['user_id'] == $key + 1) {
217 | if (!in_array($_SESSION['user_id'], $viewed)) {
218 | $usertable[$key][3] .= '';
219 | } else {
220 | $usertable[$key][3] .= '';
221 | }
222 | } else {
223 | $usertable[$key][3] .= '';
224 | }
225 | }
226 |
227 | if (in_array($key + 1, $viewed)) {
228 | if(in_array($key + 1, $watchagain) && $_SESSION['user_id'] == $key + 1) {
229 | $usertable[$key][4] .= '';
230 | } elseif ($_SESSION['user_id'] == $key + 1) {
231 | $usertable[$key][4] .= '';
232 | } elseif (in_array($key + 1, $watchagain)) {
233 | $usertable[$key][4] .= '';
234 | } else {
235 | $usertable[$key][4] .= '';
236 | }
237 | } else {
238 | $usertable[$key][4] .= '';
239 | }
240 | }
241 |
242 | $this -> viewModel -> set('comments', $comments);
243 | $this -> viewModel -> set('betygHead', array('Namn', 'Sedd', 'Betyg', 'Att se', 'Se igen'));
244 | $this -> viewModel -> set('betygBody', $usertable);
245 | $this -> viewModel -> set('avgPoints', number_format($averagepoint / $numberofvoters, 1));
246 | $this -> viewModel -> set('seriesid', $result['seriesid']);
247 | $this -> viewModel -> set('seriesname', $result['seriesname']);
248 | $this -> viewModel -> set('imdbid', $result['imdbid']);
249 | $this -> viewModel -> set('runtime', $result['runtime']);
250 | $this -> viewModel -> set('title', $result['title']);
251 | $this -> viewModel -> set('year', $result['year']);
252 | $this -> viewModel -> set('poster', $result['poster']);
253 | $this -> viewModel -> set('plot', $result['plot']);
254 | $this -> viewModel -> set('sub', $result['sub']);
255 | $this -> viewModel -> set('actor', $result['actor']);
256 | $this -> viewModel -> set('director', $result['director']);
257 | $this -> viewModel -> set('type', $result['type']);
258 | $this -> viewModel -> set('genre', $result['genre']);
259 | $this -> viewModel -> set('youtube', $result['youtube']);
260 | $this -> viewModel -> set('id', $result['id']);
261 | $this -> viewModel -> set('urlValues', $this -> urlValues);
262 | $this -> viewModel -> set('pageTitle', TITLE . $result['title']);
263 | return $this -> viewModel;
264 | }
265 |
266 | public function vote() {
267 | $url = filter_var_array($this -> urlValues, FILTER_VALIDATE_INT);
268 | if ($url['id'] && $url['id2']) {
269 | $param = array(':mid' => $url['id'], ':uid' => $_SESSION['user_id']);
270 | $ar = new ArrayTools();
271 |
272 | $sql = "SELECT count(*) FROM `userviewed` WHERE
273 | `movieid` = :mid AND `userid` = :uid";
274 |
275 | $result = $ar -> unique_flat_array($this -> db -> select_query($sql, $param));
276 |
277 | if ($result[0] == 0) {
278 | $sql = "INSERT INTO userviewed (userid, movieid, date)
279 | VALUE (:uid,:mid,NOW())";
280 |
281 | $this -> db -> select_query($sql, $param);
282 | }
283 | $sql = "SELECT user_id FROM `uservote`
284 | WHERE `user_id` = :uid AND `movie_id` = :mid";
285 |
286 | $result = $ar -> unique_flat_array($this -> db -> select_query($sql, $param));
287 | var_dump($result);
288 | if (empty($result)) {
289 | $sql = "INSERT INTO `uservote`(`user_id`, `movie_id`, `value`, date)
290 | VALUES (:uid,:mid,:vote, NOW())";
291 | $param = array(':mid' => $url['id'], ':uid' => $_SESSION['user_id'], ':vote' => $url['id2']);
292 |
293 | $this -> db -> select_query($sql, $param);
294 | } else {
295 | $sql = "UPDATE `uservote` SET `value`=:vote , `date` = NOW()
296 | WHERE `movie_id` = :mid AND `user_id` = :uid";
297 | $param = array(':mid' => $url['id'], ':uid' => $_SESSION['user_id'], ':vote' => $url['id2']);
298 |
299 | $this -> db -> select_query($sql, $param);
300 | }
301 |
302 | $sql = "DELETE FROM `towatchagain` WHERE `movieid`=:mid AND `userid`=:uid";
303 | $param = array(':mid' => $url['id'], ':uid' => $_SESSION['user_id']);
304 | $this -> db -> select_query($sql, $param);
305 |
306 | header('location:' . URL . 'movie/display/' . $url['id']);
307 | }
308 | $this -> viewModel -> set('urlValues', $this -> urlValues);
309 | $this -> viewModel -> set('pageTitle', TITLE . 'Fel!');
310 | return $this -> viewModel;
311 | }
312 |
313 | public function towatch() {
314 | $url = filter_var_array($this -> urlValues, FILTER_VALIDATE_INT);
315 | if ($url['id']) {
316 | $sql = "INSERT INTO towatch(movieid, userid, date)
317 | VALUES (:mid,:uid,now())";
318 | $param = array(':mid' => $url['id'], ':uid' => $_SESSION['user_id']);
319 | $this -> db -> select_query($sql, $param);
320 | header('location:' . URL . 'movie/display/' . $url['id']);
321 | }
322 | $this -> viewModel -> set('urlValues', $this -> urlValues);
323 | $this -> viewModel -> set('pageTitle', TITLE . 'Fel!');
324 | return $this -> viewModel;
325 | }
326 |
327 | public function towatchagain() {
328 | $url = $this -> urlValues;
329 | if ($url['id'] && $url['id'] == "again") {
330 | $sql = "INSERT INTO towatchagain(movieid, userid, added)
331 | VALUES (:mid,:uid,now())";
332 | $param = array(':mid' => $url['id2'], ':uid' => $_SESSION['user_id']);
333 | $this -> db -> select_query($sql, $param);
334 | header('location:' . URL . 'movie/display/' . $url['id2']);
335 | } elseif ($url['id']) {
336 | $sql = "DELETE FROM `towatchagain` WHERE `movieid`=:mid AND `userid`=:uid";
337 | $param = array(':mid' => $url['id2'], ':uid' => $_SESSION['user_id']);
338 | $this -> db -> select_query($sql, $param);
339 | header('location:' . URL . 'movie/display/' . $url['id2']);
340 | }
341 | $this -> viewModel -> set('urlValues', $this -> urlValues);
342 | $this -> viewModel -> set('pageTitle', TITLE . 'Fel!');
343 | return $this -> viewModel;
344 | }
345 |
346 | public function viewed() {
347 | $url = filter_var_array($this -> urlValues, FILTER_VALIDATE_INT);
348 | if ($url['id']) {
349 | $sql = "INSERT INTO userviewed (userid, movieid, date)
350 | VALUE (:uid,:mid,NOW())";
351 | $param = array(':mid' => $url['id'], ':uid' => $_SESSION['user_id']);
352 | $this -> db -> select_query($sql, $param);
353 | header('location:' . URL . 'movie/display/' . $url['id']);
354 | }
355 | $this -> viewModel -> set('urlValues', $this -> urlValues);
356 | $this -> viewModel -> set('pageTitle', TITLE . 'Fel!');
357 | return $this -> viewModel;
358 | }
359 |
360 | public function edit() {
361 | $id = $this -> urlValues['id'];
362 | $ar = new ArrayTools();
363 |
364 | $sql = "SELECT movies.youtube, movies.imdbid, movies.runtime, movies.title, movies.year, movies.poster, movies.plot, movies.sub, group_concat(DISTINCT concat(actors.id,',',actors.actor) separator '|') AS actor, group_concat(DISTINCT concat(directors.id,',',directors.director) separator '|') AS director, movietype.type, group_concat(DISTINCT concat(genres.id,',',genres.genre) separator '|') AS genre
365 | FROM movies
366 | LEFT JOIN actorsinmovies ON movies.id = actorsinmovies.movie_id
367 | LEFT JOIN actors ON actors.id = actorsinmovies.actor_id
368 | LEFT JOIN directorsinmovies ON movies.id = directorsinmovies.movie_id
369 | LEFT JOIN directors ON directorsinmovies.director_id = directors.id
370 | LEFT JOIN movietype ON movies.type = movietype.short
371 | LEFT JOIN genresinmovies ON movies.id = genresinmovies.movie_id
372 | LEFT JOIN genres ON genresinmovies.genre_id = genres.id
373 | WHERE movies.id = :id
374 | GROUP BY movies.id";
375 |
376 | $result = $this -> db -> select_query($sql, array(':id' => $id));
377 | $result = $result[0];
378 |
379 | $types = $this -> db -> select_query("SELECT short, type FROM movietype");
380 | foreach ($types as $value) {
381 | $types2[$value['short']] = $value['type'];
382 | }
383 | $actors = $this -> db -> select_query("SELECT id,actor FROM actors");
384 | foreach ($actors as $value) {
385 | $actors2[$value['id']] = $value['actor'];
386 | }
387 |
388 | $comments = $this -> db -> select_query("SELECT `comment`,`id` FROM `usercomment` WHERE `userid` = :uid AND `movieid` = :mid ORDER BY `id` DESC", array(':uid' => $_SESSION['user_id'], ':mid' => $id));
389 |
390 | $sql = "SELECT series.name, moviesinseries.number FROM moviesinseries
391 | JOIN series ON moviesinseries.seriesID = series.id
392 | WHERE moviesinseries.movieID = :id";
393 | $serie = $this -> db -> select_query($sql, array(":id" => $id));
394 |
395 | $series = $this -> db -> select_query("SELECT series.id, series.name FROM series");
396 |
397 | $this -> viewModel -> set('series', $series);
398 | $this -> viewModel -> set('number', $serie[0]["number"]);
399 | $this -> viewModel -> set('theSerie', $serie[0]["name"]);
400 | $this -> viewModel -> set('comments', $comments);
401 | $this -> viewModel -> set('actors', $actors2);
402 | $this -> viewModel -> set('types', $types2);
403 | $this -> viewModel -> set('imdbid', $result['imdbid']);
404 | $this -> viewModel -> set('runtime', $result['runtime']);
405 | $this -> viewModel -> set('title', $result['title']);
406 | $this -> viewModel -> set('year', $result['year']);
407 | $this -> viewModel -> set('poster', $result['poster']);
408 | $this -> viewModel -> set('plot', $result['plot']);
409 | $this -> viewModel -> set('sub', $result['sub']);
410 | $this -> viewModel -> set('actor', $result['actor']);
411 | $this -> viewModel -> set('director', $result['director']);
412 | $this -> viewModel -> set('type', $result['type']);
413 | $this -> viewModel -> set('genre', $result['genre']);
414 | $this -> viewModel -> set('youtube', $result['youtube']);
415 | $this -> viewModel -> set('urlValues', $this -> urlValues);
416 | $this -> viewModel -> set('pageTitle', TITLE . 'Ändra "' . $result['title'] . '"');
417 | return $this -> viewModel;
418 | }
419 |
420 | public function wall() {
421 | $numberofimgperside = 9;
422 | $ar = new ArrayTools();
423 | $url = filter_var_array($this -> urlValues, FILTER_VALIDATE_INT);
424 | $sql = "SELECT `id`,`poster` FROM `movies`
425 | ORDER BY id DESC ";
426 | if ($url['id']) {
427 | $sql .= "LIMIT " . $numberofimgperside * ((int)$url['id'] - 1) . ", " . $numberofimgperside;
428 | } else {
429 | $url['id'] = 1;
430 | $sql .= "LIMIT " . $numberofimgperside;
431 | }
432 |
433 | $result = $this -> db -> select_query($sql);
434 |
435 | $sql = "SELECT count(id)
436 | FROM movies
437 | ORDER BY id DESC";
438 |
439 | $numberofmovies = $ar -> unique_flat_array($this -> db -> select_query($sql));
440 | $numberofmovies = $numberofmovies[0];
441 |
442 | $antalSidor = ceil($numberofmovies / 9);
443 |
444 | if ($this -> urlValues['id'] == 0) {
445 | $id = 1;
446 | $classone = 'class="notclickable"';
447 | } elseif ($this -> urlValues['id'] == $antalSidor) {
448 | $id = $antalSidor;
449 | $classtwo = 'class="notclickable"';
450 | } else {
451 | $id = $this -> urlValues['id'];
452 | }
453 |
454 | $getPrew = 'href="' . URL . $this -> urlValues['controller'] . '/' . $this -> urlValues['action'] . '/' . ($id - 1) . '" ' . $classone;
455 | $getNext = 'href="' . URL . $this -> urlValues['controller'] . '/' . $this -> urlValues['action'] . '/' . ($id + 1) . '"' . $classtwo;
456 |
457 | $row = 1;
458 | foreach ($result as $key => $value) {
459 | if ($key == 3 || $key == 6)
460 | $row++;
461 | $posters[$row] .= ' |