wpdb->_real_escape($overview)."') ON DUPLICATE KEY UPDATE `tmdb_id` = ".$id.", `first_air_date` = ".$first_air_date.", `homepage` = '".$homepage."', `in_production` = '".$in_production."', `last_air_date` = ".$last_air_date.", `name` = '".$name."', `next_episode_to_air` = '".$next_episode_to_air."', `number_of_episodes` = '".$number_of_episodes."', `original_language` = '".$original_language."', `original_name` = '".$original_name."', `overview` = '". $wpdb->_real_escape($overview)."';"); echo $query; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_siminn_to_movie_table($siminn_id,$title,$tmdb_id,$imdbId,$ttvdbId,$backdrop,$poster) { //echo $id.'-'.$backdrop_path.'-'.$first_air_date.'-'.$homepage.'-'. $in_production; global $wpdb; $query = $wpdb->prepare("INSERT INTO ".DB_NAME.".`Movie` (`siminn_id`, `Title`, `themoviedb`, `Imdb`, `tvdb_id`, `tv_show`, `themoviedb_background`) VALUES ('".$siminn_id."', '".$title."', '".$tmdb_id."', '".$imdbId."', '".$ttvdbId."', '1', '".$backdrop."', '".$poster."' ) ON DUPLICATE KEY UPDATE `siminn_id` = '".$siminn_id."', `Title` = '".$title."', `themoviedb` = '".$tmdb_id."', `Imdb` = '".$imdbId."', `tvdb_id` = '".$ttvdbId."', `tv_show` = '1', `themoviedb_background` = '".$backdrop."', `Poster` = '".$poster."' ;"); //echo $query; $results = $wpdb->get_results($query); return $results; } function update_tv_from_siminn_to_movie_table($siminn_id,$title,$tmdb_id,$imdbId,$tvdb_id,$backdrop,$poster) { //echo $id.'-'.$backdrop_path.'-'.$first_air_date.'-'.$homepage.'-'. $in_production; global $wpdb; $query = "UPDATE ".DB_NAME.".`Movie` SET `Title` ='".esc_sql($title)."', `themoviedb` ='".esc_sql($tmdb_id)."', `Imdb` ='".esc_sql($imdbId)."', `tvdb_id` ='".esc_sql($tvdb_id)."' `themoviedb_background` ='".esc_sql($backdrop)."' WHERE `siminn_id` = ".esc_sql($siminn_id); $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_seasons($tmdb_id, $air_date, $episode_count, $name, $tmdb_season_id, $overview, $poster_path, $season_number, $poster, $movie_id) { global $wpdb; $query = $wpdb->prepare("INSERT INTO ".DB_NAME.". `Series_Seasons` (`tmdb_season_id`, `air_date`, `episode_count`, `name`, `tmdb_id`, `description`, `poster_path`, `season_number`, `poster`, `movie_id`) VALUES (".$tmdb_season_id.", '".$air_date."', ".$episode_count.", '".$name."', ".$tmdb_id.", '".$wpdb->_real_escape($overview)."', '".$poster_path."', '".$season_number."', '".$poster."' ".$movie_id.") ON DUPLICATE KEY UPDATE `tmdb_season_id` = ".$tmdb_season_id.", `air_date` = '".$air_date."', `episode_count` = ".$episode_count.", `name` = '".$name."', `tmdb_id` = ".$tmdb_id.", `description` = '".$wpdb->_real_escape($overview)."', `poster_path` = '".$poster_path."', `season_number` = '".$season_number."', `poster` = '".$poster."', `movie_id` = '".$movie_id."';"); //echo $query; $results = $wpdb->query($query); //echo '-- ' . $query; if ($wpdb->last_error) { //echo 'You done bad! ' . $wpdb->last_error; } return $results; } function insert_tv_from_themoviedb_seasons_episodes($tmdb_id, $tmdb_season_id, $tmdb_episode_id, $air_date, $episode_number , $name, $overview, $production_code, $season_number, $still, $still_path, $movie_id) { global $wpdb; $query = $wpdb->prepare("INSERT INTO ".DB_NAME.". `Series_Episodes` (`tmdb_id`, `tmdb_season_id`, `tmdb_episode_id`, `air_date`, `episode_number`, `name`, `overview`, `production_code`, `season_number`, `still`, `still_path`, `vote_count`, `vote_average`, `movie_id`) VALUES (".$tmdb_id.", '.$tmdb_season_id.', ".$tmdb_episode_id.", '".$air_date."', '".$episode_number."', '".$name."', '".$wpdb->_real_escape($overview)."', '".$production_code."', '".$season_number."', '".$still."', '".$still_path."', '".$vote_count."', '".$vote_average."', ".$movie_id.") ON DUPLICATE KEY UPDATE `tmdb_id` = ".$tmdb_id.", `tmdb_season_id` = '".$tmdb_season_id."', `tmdb_episode_id` = ".$tmdb_episode_id.", `air_date` = '".$air_date."', `episode_number` = '".$episode_number."', `name` = '".$name."', `overview` = '".$wpdb->_real_escape($overview)."', `production_code` = '".$production_code."', `season_number` = '".$season_number."', `still_path` = '".$still_path."', `still` = '".$still."', `vote_count` = '".$vote_count."', `vote_average` = '".$vote_average."' `movie_id` = '".$movie_id."' ;"); //echo $query; $results = $wpdb->query($query); //echo '-- ' . $query; if ($wpdb->last_error) { //echo 'You done bad! ' . $wpdb->last_error; } return $results; } function delete_tv_from_themoviedb_languages($tmdb_id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Languages` WHERE tmdb_id = $tmdb_id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_languages($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Languages` WHERE movie_id = $id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_from_themoviedb_runtime($tmdb_id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Runtime` WHERE tmdb_id = $tmdb_id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_runtime($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Runtime` WHERE movie_id = $id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_from_themoviedb_genres($tmdb_id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Genres` WHERE tmdb_id = $tmdb_id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_genres($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Genres` WHERE movie_id = $id"; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_genres($tmdb_id, $genre_id, $name, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Genres` (`tmdb_id`, `genre_id`, `name`, `movie_id`) VALUES (".$tmdb_id.", '".$genre_id."', '".$name."', '".$movie_id."');"; $results = $wpdb->get_results($query); return $results; } function insert_tv_genres($id, $genre_id, $name) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Genres` (`movie_id`, `genre_id`, `name`) VALUES (".$id.", '".$genre_id."', '".$name."');"; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_languages($tmdb_id, $language, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Languages` (`tmdb_id`, `language`, `movie_id`) VALUES (".$tmdb_id.", '".$language."', '".$movie_id."');"; $results = $wpdb->get_results($query); return $results; } function insert_tv_languages($language, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Languages` ( `language`, `movie_id`) VALUES ( '".$language."', '".$movie_id."');"; $results = $wpdb->get_results($query); return $results; } function delete_tv_from_themoviedb_network($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Network` WHERE tmdb_id = $id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_network($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Network` WHERE movie_id = $id"; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_network($tmdb_id, $network_id, $name, $logo_path, $origin_country, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Network` (`tmdb_id`, `network_id`, `name`, `logo_path`, `origin_country`, `movie_id`) VALUES (".$tmdb_id.", '".$network_id."', '".$name."', '".$logo_path."', '".$origin_country."', '".$movie_id."');"; $results = $wpdb->get_results($query); return $results; } function insert_tv_network($network_id, $name, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Network` ( `network_id`, `name`, `logo_path`, `origin_country`, `movie_id`) VALUES ( '".$network_id."', '".$name."', '".$logo_path."', '".$origin_country."', '".$movie_id."');"; $results = $wpdb->get_results($query); return $results; } function delete_tv_from_themoviedb_origin_country($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Origin_Country` WHERE tmdb_id = $id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_origin_country($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Origin_Country` WHERE movie_id = $id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_from_themoviedb_production_companies($tmdb_id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Production_companies` WHERE tmdb_id = $tmdb_id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_production_companies($id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Production_companies` WHERE movie_id = $id"; $results = $wpdb->get_results($query); return $results; } function delete_tv_from_themoviedb_created_by($tmdb_id) { global $wpdb; $query = "DELETE FROM ".DB_NAME.".`Series_Created_by` WHERE tmdb_id = $tmdb_id"; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_origin_country($tmdb_id, $origin_country, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Origin_Country` (`tmdb_id`, `origin_country`, `movie_id`) VALUES (".$tmdb_id.", '".$origin_country."', '".$movie_id."');"; //echo $query; $results = $wpdb->get_results($query); return $results; } function insert_tv_origin_country($origin_country, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Origin_Country` ( `origin_country`, `movie_id`) VALUES ( '".$origin_country."', '".$movie_id."');"; //echo $query; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_created_by($tmdb_id, $person_id, $credit_id, $name, $profile_path, $gender, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Created_by` (`tmdb_id`, `credit_id`, `person_id`, `name`, `profile_path`, `gender`, `movie_id`) VALUES (".$tmdb_id.", '".$person_id."', '".$credit_id."', '".$name."', '".$profile_path."', '".$gender."', '".$movie_id."');"; //echo $query; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_runtime($tmdb_id, $runtime, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Runtime` (`tmdb_id`, `runtime`, `movie_id`) VALUES (".$tmdb_id.", '".$runtime."', '".$movie_id."');"; $results = $wpdb->get_results($query); return $results; } function insert_tv_runtime($runtime, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Runtime` ( `runtime`, `movie_id`) VALUES ( '".$runtime."', '".$movie_id."');"; $results = $wpdb->get_results($query); return $results; } function insert_tv_from_themoviedb_production_companies($tmdb_id, $company_id, $name, $logo_path, $origin_country, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Production_companies` (`tmdb_id`, `company_id`, `name`, `logo_path`, `origin_country`, `movie_id`) VALUES (".$tmdb_id.", '".$company_id."', '".$name."', '".$logo_path."', '".$origin_country."', '".$movie_id."');"; //echo $query; $results = $wpdb->get_results($query); return $results; } function insert_tv_production_companies($tmdb_id, $company_id, $name, $logo_path, $origin_country, $movie_id) { global $wpdb; $query = "INSERT INTO ".DB_NAME.". `Series_Production_companies` (`tmdb_id`, `company_id`, `name`, `logo_path`, `origin_country`, `movie_id`) VALUES (".$tmdb_id.", '".$company_id."', '".$name."', '".$logo_path."', '".$origin_country."', '".$movie_id."');"; //echo $query; $results = $wpdb->get_results($query); return $results; } function insert_themoviedb_to_movie($themoviedb_id,$movie_id){ global $wpdb; $query = "UPDATE ".DB_NAME.".`Movie` SET `themoviedb` ='".esc_sql($themoviedb_id)."' WHERE `ID_Movie` = ".esc_sql($movie_id); $results = $wpdb->get_results($query); } function insert_themoviedb_rating($moviedb_rating,$movie_id){ global $wpdb; $query = "UPDATE ".DB_NAME.".`Movie` SET `themoviedb_rating` ='".esc_sql($moviedb_rating)."' WHERE `ID_Movie` = ".esc_sql($movie_id); $results = $wpdb->get_results($query); } function insert_metacritic($einkunn,$movie_id){ global $wpdb; $query = "UPDATE ".DB_NAME.".`Movie` SET `metacritic_rating` ='".esc_sql($einkunn)."' WHERE `ID_Movie` = ".esc_sql($movie_id); $results = $wpdb->get_results($query); } function insert_kvikmyndir_einkunn($kvikmyndir_einkunn,$movie_id){ global $wpdb; $query = "UPDATE ".DB_NAME.".`Movie` SET `kvikmyndir_einkunn` ='".esc_sql($kvikmyndir_einkunn)."' WHERE `ID_Movie` = ".esc_sql($movie_id); $results = $wpdb->get_results($query); } function insert_imdb_track($id_movie, $imdb, $title,$rating,$votes){ global $wpdb; $wpdb->query("INSERT INTO ".DB_NAME.".`imdb_track` (`kvikmyndir-id` ,`imdb-id`,`Title`,`rating`,`votes` ) VALUES ('".$id_movie."', '".$imdb."', '".$title."','".$rating."', '".$votes."')" ); } function findByAlphabet($letters, $count = false, $orderBy = null, $limitFrom = null, $limitNumber = null){ // Where clause $where = ' WHERE TRIM(LEADING \'The \' FROM Title) LIKE "' . esc_sql($letters) . '%"'; if($letters == "0-9"){ $where = ' WHERE `Title` REGEXP "[0-9]\S*"'; } if($count) { $query = 'SELECT count(*) AS Total FROM `Movie`' . $where; } else { // Order the results $orderstr = " ORDER BY TRIM(LEADING 'The ' FROM Title)"; //$orderstr = " ORDER BY `Title` ASC"; //$orderstr = ""; if(!is_null($orderBy)) { $orderstr = " ORDER BY $orderBy"; } // Limit the results set $limitstr = ""; if(!is_null($limitFrom) && !is_null($limitNumber)) { $limitstr = " LIMIT $limitFrom,$limitNumber"; } $query = "SELECT DISTINCT `ID_Movie`, `Key`, `Title`, `Seria`, `TitleAliases`, `Year`, `Runtime`, `Tagline`, `Plot`, `Website`, `Language`, `MPAARated`, `CertificateIS`, `Poster`, `Sound`, `Awards`,`Cash`, `PreviewDate`, `PremiereDate`, `PremiereDateIS`, `VHSdate`, `DVDdate`, `BLURAYdate`, `Status`, `Hits`, `Rated`, `VotesCount`, `Distributor`, `P_Status`, `P_CreationDate`, `P_ModificationDate`, `P_Author`, `P_Editor`, `P_ModificationUser`, `Imdb`, `Rotten`, `fileName` FROM `Movie` LEFT JOIN `vfsFile` AS p ON ( `Poster` = p.`id` ) " . $where . $orderstr . $limitstr; } $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_islkvik($aukagenre){ $query = sprintf("SELECT m.`ID_Movie` , m.`Title` , m.`Year` , m.`Poster` , m.`Plot` , m.`CertificateIS` , m.`PremiereDateIS` , m.`TitleAliases` AS `TitleAlias` , p.`fileName` AS `PosterName` , mg.`Genre` , mg2.`Genre` AS genre_t FROM `Movie` m INNER JOIN `Movie_Genre` mg ON m.`ID_Movie` = mg.`Movie` INNER JOIN `Movie_Genre` mg2 ON m.`ID_Movie` = mg2.`Movie` LEFT JOIN `vfsFile` p ON m.`Poster` = p.`id` WHERE mg2.`Genre` =75 AND mg.`Genre` = ".esc_sql($aukagenre)." GROUP BY ID_Movie, Title, Poster, TitleAlias, PosterName ORDER BY Year DESC, PremiereDateIS DESC" ); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_movie_bygenre_multi($aukagenre1,$aukagenre2,$query2,$fjoldi){ global $wpdb; $query = sprintf("SELECT m.`ID_Movie` , m.`imdb_rating`, m.`Title` , m.`Year` , m.`Poster` , m.`TitleAliases` AS `TitleAlias` , p.`fileName` AS `PosterName` , mg.`Genre` , mg2.`Genre` AS genre_t FROM `Movie` m INNER JOIN `Movie_Genre` mg ON m.`ID_Movie` = mg.`Movie` INNER JOIN `Movie_Genre` mg2 ON m.`ID_Movie` = mg2.`Movie` LEFT JOIN `vfsFile` p ON m.`Poster` = p.`id` WHERE mg2.`Genre` = ".esc_sql($aukagenre1)." AND mg.`Genre` = ".esc_sql($aukagenre2)." GROUP BY ID_Movie, Title, Poster, TitleAlias, PosterName, imdb_rating ORDER BY Year DESC LIMIT ".esc_sql($fjoldi)."" ); $query=$query2; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_movie_bygenre_multi_fra_til($aukagenre1,$aukagenre2,$query2,$fra,$til){ global $wpdb; $query=$query2; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_movie_by_multiple_parameters($yearfrom,$yearto,$imdbfrom,$imdbto,$genres,$start_position,$position){ // $genre is an array ...needs to be split up for multiple Inner joins and where functions $genresArray = explode(',', $genres); $count = 0; $sql_genre_join = ''; $sql_genre_where = ''; foreach ($genresArray as $genre) { $count++; $sql_genre_join .= 'INNER JOIN `Movie_Genre` AS genre'.$count.' ON m.`ID_Movie` = genre'.$count.'.`Movie`'; $sql_genre_where .= ' genre'.$count.'.`Genre` = '.$genre.' AND'; } $sql_genre_where = rtrim($sql_genre_where,'AND'); /*SELECT m.`ID_Movie` , m.`Title`,m.`Plot`,m.`imdb_rating` , m.`Year` ,m.`Poster` , m.`TitleAliases` AS `TitleAlias` , p.`orginalName` AS `PosterName` FROM `Movie` m LEFT JOIN `vfsFile` p ON ( m.`Poster` = p.`id` ) INNER JOIN `Movie_Genre` AS genre1 ON m.`ID_Movie` = genre1.`Movie` INNER JOIN `Movie_Genre` AS genre2 ON m.`ID_Movie` = genre2.`Movie` WHERE (m.`imdb_rating`> 0 AND m.`imdb_rating`< 4) AND (m.`Year`> 1900 AND m.`Year`<2022) AND ( genre1.`Genre` = 1 AND genre2.`Genre` = 3) ORDER BY m.`Year` DESC LIMIT 0,100*/ global $wpdb; $query = "SELECT m.`ID_Movie`,t.`ID_TrailerFile` , m.`Title`,m.`Plot`,m.`imdb_rating` , m.`Year` ,m.`Poster` , m.`TitleAliases` AS `TitleAlias` , p.`orginalName` AS `PosterName` FROM `Movie` m LEFT JOIN `vfsFile` p ON ( m.`Poster` = p.`id` ) LEFT JOIN `Trailer` t ON ( m.`ID_Movie` = t.`Movie` ) ".$sql_genre_join." WHERE (m.`imdb_rating`> ".esc_sql($imdbfrom)." AND m.`imdb_rating`< ".esc_sql($imdbto).") AND (m.`Year`> ".esc_sql($yearfrom)." AND m.`Year`<".esc_sql($yearto).") AND (".$sql_genre_where.") ORDER BY m.`Year` DESC LIMIT ".$start_position.",".$position; //echo $query; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_movie_bygenre($genre,$fjoldi){ global $wpdb; $query = sprintf("SELECT m.`ID_Movie` , m.`Title` , m.`Year` , m.`Poster` , m.`TitleAliases` AS `TitleAlias` , p.`fileName` AS `PosterName` , mg.`Genre` FROM `Movie` m INNER JOIN `Movie_Genre` mg ON m.`ID_Movie` = mg.`Movie` LEFT JOIN `vfsFile` p ON m.`Poster` = p.`id` WHERE `Genre` IN (".$genre.") GROUP BY ID_Movie, Title, Poster, TitleAlias, PosterName ORDER BY Year DESC LIMIT ".esc_sql($fjoldi)."" ); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_movie_by_single_genre($genre,$fjoldi){ $query = sprintf("SELECT m.`ID_Movie` , m.`Title` , m.`Year` , m.`Poster` , m.`TitleAliases` AS `TitleAlias` , p.`fileName` AS `PosterName` , mg.`Genre` , mg2.`Genre` AS genre_t FROM `Movie` m INNER JOIN `Movie_Genre` mg ON m.`ID_Movie` = mg.`Movie` INNER JOIN `Movie_Genre` mg2 ON m.`ID_Movie` = mg2.`Movie` LEFT JOIN `vfsFile` p ON m.`Poster` = p.`id` WHERE mg2.`Genre` = ".esc_sql($genre)." GROUP BY ID_Movie, Title, Poster, TitleAlias, PosterName ORDER BY Year DESC LIMIT ".esc_sql($fjoldi) ); $query=$query2; $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_PersonByMovieAndRole($idMovie, $role){ global $wpdb; $query = sprintf("SELECT `ID_Movie`, `Title`, `ID_Person`, `Name`, `RealName`,`imdb`, `Role`, `Character`,`image`,`Attribute`, `Order` as `Ord`, `Updated` FROM ".DB_NAME.".`PersonToMovie` WHERE ID_Movie = ".esc_sql($idMovie)." AND Role = ".esc_sql($role)." ORDER by Ord"); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_PersonByMovieAndRole_tmdb($idMovie, $id_tmdb, $role){ global $wpdb; $query = "SELECT `ID_Movie`, `Title`, `ID_Person`, `Name`, `RealName`,`imdb` ,`tmdb_id`, `Role`, `Character`,`image`,`Attribute`, `Order` as `Ord`, `Updated` FROM ".DB_NAME.".`PersonToMovie` WHERE tmdb_id = ".esc_sql($id_tmdb)." And ID_Movie = ".esc_sql($idMovie).""; $results = $wpdb->get_results($query); //echo $query; return $results; } function find_CharacterbyMovieAndActor($idMovie,$person){ global $wpdb; $query = sprintf("SELECT `ID_Movie`, `Title`, `ID_Person`, `Name`, `RealName`,`imdb`, `Role`, `Character`,`image`,`Attribute`, `Order` as `Ord` FROM ".DB_NAME.".`PersonToMovie` WHERE ID_Movie = ".esc_sql($idMovie)." AND ID_Person = ".esc_sql($person)." ORDER by Ord"); $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_MovieByPersonAndRole($idPerson, $role){ global $wpdb; $query = sprintf("SELECT n.`ID_Person` ,n.`image` , n.`ID_Movie` AS `ID_Movie_byperson` , m.`ID_Movie` , m.`Title` , m.`Year` , m.`Poster` , m.`Plot` , m.`CertificateIS` , m.`PremiereDateIS` , m.`imdb_rating`, m.`revenue` , m.`TitleAliases` AS `TitleAlias` , p.`orginalName` AS `PosterName` FROM `PersonToMovie` AS n LEFT JOIN `Movie` AS m ON (m.`ID_Movie` = n.`ID_Movie`) LEFT JOIN `vfsFile` AS p ON (p.`id` = m.`poster`) LEFT JOIN `Trailer` t ON ( m.`ID_Movie` = t.`Movie` ) LEFT JOIN `ExtraVideos` e ON ( m.`ID_Movie` = e.`Movie` ) WHERE n. ID_Person = ".esc_sql($idPerson)." AND n. Role = ".esc_sql($role)." GROUP BY ID_Movie, Title, Poster, TitleAlias, PosterName ORDER BY Year DESC, PremiereDateIS DESC" ); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_MoviesByPerson($idPerson){ global $wpdb; $query = sprintf("SELECT n.`ID_Person` ,n.`image` , n.`ID_Movie` AS `ID_Movie_byperson`, n.`Role`, m.`ID_Movie` , m.`Title` , m.`Year` , m.`Poster` , m.`Plot` , m.`CertificateIS` , m.`PremiereDateIS` , m.`imdb_rating`, m.`revenue` , m.`TitleAliases` AS `TitleAlias` , p.`orginalName` AS `PosterName` FROM `PersonToMovie` AS n LEFT JOIN `Movie` AS m ON (m.`ID_Movie` = n.`ID_Movie`) LEFT JOIN `vfsFile` AS p ON (p.`id` = m.`poster`) LEFT JOIN `Trailer` t ON ( m.`ID_Movie` = t.`Movie` ) LEFT JOIN `ExtraVideos` e ON ( m.`ID_Movie` = e.`Movie` ) WHERE n. ID_Person = ".esc_sql($idPerson)." GROUP BY ID_Movie, Title, Poster, TitleAlias, PosterName ORDER BY Year DESC, PremiereDateIS DESC" ); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_top_movie_by_actor($idPerson){ global $wpdb; $query = sprintf("SELECT m.`imdb_rating` ,m.`Title` , m.`ID_Movie` FROM `PersonToMovie` AS n LEFT JOIN `Movie` AS m ON (m.`ID_Movie` = n.`ID_Movie`) WHERE n. ID_Person = ".esc_sql($idPerson)." GROUP BY m.`ID_Movie` , m.`Title` ORDER BY m.`imdb_rating` DESC LIMIT 0,1 " ); $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_tvshows_without_tmdb_id(){ global $wpdb; $query = sprintf("SELECT `ID_Movie`, Title, `TitleAliases`, `themoviedb` from Movie Where tv_show =1 and themoviedb = 0" ); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_bottom_movie_by_actor($idPerson){ global $wpdb; $query = sprintf("SELECT m.`imdb_rating` ,m.`Title` , m.`ID_Movie` FROM `PersonToMovie` AS n LEFT JOIN `Movie` AS m ON (m.`ID_Movie` = n.`ID_Movie`) WHERE n. ID_Person = ".esc_sql($idPerson)." AND m.`imdb_rating` != 0 GROUP BY m.`ID_Movie` , m.`Title` ORDER BY m.`imdb_rating` ASC LIMIT 0,1 " ); $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_PersonByName($name){ global $wpdb; $query = "SELECT * FROM `Person` WHERE Name LIKE '%".esc_sql($name)."%' LIMIT 0,20" ; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_PersonByID($id){ global $wpdb; $query = "SELECT * FROM `Person` WHERE ID_Person = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_tv_serie($id){ global $wpdb; $query = sprintf("SELECT s.`id`, s.`tmdb_id`, `backdrop_path`, `episode_runtime`, `last_air_date` `first_air_date`, `homepage`, `in_production`, s.`name`, sn.`name` as `network_name`, sn.`logo_path`, `name_is`, `next_episode_to_air`, `number_of_episodes`, `number_of_seasons`, s.`origin_country`, `original_language`, `original_name`, `overview`, `poster`, `type`, `vote_average`, `vote_count`, `popularity`, `poster_path`, `status`, `overview_icelandic` FROM Series as s JOIN Series_Network as sn ON s.`tmdb_id` = sn.`tmdb_id` WHERE s.`tmdb_id` = ".esc_sql($id).""); $results = $wpdb->get_row($query, OBJECT); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_tv_serie_by_tvdb($id){ global $wpdb; $query = sprintf("SELECT s.`id`, s.`tmdb_id`, `backdrop_path`, `episode_runtime`, `last_air_date` `first_air_date`, `homepage`, `in_production`, s.`name`, sn.`name` as `network_name`, sn.`logo_path`, `name_is`, `next_episode_to_air`, `number_of_episodes`, `number_of_seasons`, s.`origin_country`, `original_language`, `original_name`, `overview`, `poster`, `type`, `vote_average`, `vote_count`, `popularity`, `poster_path`, `status`, `overview_icelandic` FROM Series as s JOIN Series_Network as sn ON s.`tmdb_id` = sn.`tmdb_id` WHERE s.`tvdb_id` = ".esc_sql($id).""); $results = $wpdb->get_row($query, OBJECT); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_tv_series($id){ global $wpdb; $query = sprintf("SELECT `id`, `tmdb_id`,`movie_id`, `air_date`, `episode_count`, `tmdb_season_id`, `name`, `poster_path`, `season_number`, `name_is`, `poster` FROM Series_Seasons WHERE `movie_id` = ".esc_sql($id)." ORDER BY season_number DESC"); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_tv_series_tmdb($id){ global $wpdb; $query = sprintf("SELECT `id`, `tmdb_id`, `air_date`, `episode_count`, `tmdb_season_id`, `name`, `poster_path`, `season_number`, `name_is`, `poster` FROM Series_Seasons WHERE `tmdb_id` = ".esc_sql($id)." ORDER BY season_number DESC"); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_episodes_tmdb($series, $season){ global $wpdb; $query = sprintf("SELECT * FROM Series_Episodes WHERE `tmdb_id` = ".esc_sql($series)." AND `tmdb_season_id` = ".esc_sql($season)." ORDER BY `episode_number` ASC "); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_episodes($movie_id, $season){ global $wpdb; $query = sprintf("SELECT * FROM Series_Episodes WHERE `movie_id` = ".esc_sql($movie_id)." AND `tmdb_season_id` = ".esc_sql($season)." ORDER BY `episode_number` ASC "); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_Genre_ByMovie($movie){ global $wpdb; $query = sprintf("SELECT M.`ID_Movie`, M.`Name`, M.`ID_Genre` FROM MovieGenre M WHERE M.`ID_Movie` = ".esc_sql($movie)."" ); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Þaðð fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; $message .= 'Whole query: ' . $query; $message .= mysql_error() . "\n"; die($message); } return $results; } function find_Genre(){ global $wpdb; $query = sprintf("SELECT * FROM `Genre`" ); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_podcast($id){ global $wpdb; $query = "SELECT * FROM `Podcast` WHERE movie_id = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } /* KVIKMYNDIR ENDAR */ /***************/ /* ----------------------*/ /* KVIKMYNDIR BYRJAR */ function find_tokustadir($count){ global $wpdb; $query = "SELECT * FROM tokustadir LIMIT 0,".esc_sql($count).";"; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_tokustadir_filter($count,$land){ global $wpdb; if($land=='1') { $query = "SELECT * FROM tokustadir AS t JOIN Movie as M ON t.movie_id = M.ID_Movie WHERE M.`language` = 'íslenska' LIMIT 0,".esc_sql($count).";"; } else { $query = "SELECT * FROM tokustadir AS t JOIN Movie as M ON t.movie_id = M.ID_Movie WHERE M.`language` != 'íslenska' LIMIT 0,".esc_sql($count).";"; } $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_tokust_by_movie($fjoldi,$movie){ global $wpdb; $query = "SELECT f.`id`,`name`,`address`,`movie_id`,`mynd`,`lat`,`lng`,`type`,M.`key` FROM tokustadir as f JOIN Movie as M ON f.movie_id = M.ID_Movie WHERE M.`ID_Movie` = '".esc_sql($movie)."' LIMIT 0,".esc_sql($fjoldi).";"; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_tokust_by_movie_with_lat($fjoldi,$movie){ global $wpdb; $query = "SELECT f.`id`,`name`,`address`,`movie_id`,`mynd`,`lat`,`lng`,`type`,M.`key` FROM tokustadir as f JOIN Movie as M ON f.movie_id = M.ID_Movie WHERE M.`ID_Movie` = '".esc_sql($movie)."' AND f.`lat` != '' LIMIT 0,".esc_sql($fjoldi).";"; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_tokust_by_geotrail(){ $query = "SELECT f.`id`,`name`,`address`,`movie_id`,`mynd`,`lat`,`lng`,`geotrail`,`link`,`type`,M.`key` FROM tokustadir as f JOIN Movie as M ON f.movie_id = M.ID_Movie WHERE f.geotrail != ''"; $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_tokust_by_id($id){ global $wpdb; $query = "SELECT f.`id`,`name`,`address`,`movie_id`,`mynd`,`lat`,`lng`,`type`,M.`key` FROM tokustadir as f JOIN Movie as M ON f.movie_id = M.ID_Movie WHERE f.`id` = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = ('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_tokust_no_lat($fjoldi){ global $wpdb; $query = "SELECT f.`id`,`name`,`address`,`movie_id`,`mynd`,`lat`,`lng`,`type`,M.`key` FROM tokustadir as f JOIN Movie as M ON f.movie_id = M.ID_Movie WHERE f.`lat` = '' AND f.`type` <> 'aukaatridi' ORDER BY RAND() LIMIT 0,".esc_sql($fjoldi).";"; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_tokust_by_movie_no_lat($fjoldi,$movie){ global $wpdb; $query = "SELECT f.`id`,`name`,`address`,`movie_id`,`mynd`,`lat`,`lng`,`type`,M.`key` FROM tokustadir as f JOIN Movie as M ON f.movie_id = M.ID_Movie WHERE M.`ID_Movie` = '".esc_sql($movie)."' AND f.`lat` = '' AND f.`type` <> 'aukaatridi' LIMIT 0,".esc_sql($fjoldi).";"; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } /* KVIKMYNDIR ENDAR */ /***************/ /* ----------------------*/ /* SÝNINGATÍMAR BYRJAR */ function hreinsa_bio(){ //$wpdb->get_results("DELETE FROM ".DB_NAME.".`FeedMovie_New` where `CinemaId_fk` = ".$id.""); //$wpdb->get_results("truncate table `FeedMovie_New`"); } function hreinsa_sambio(){ global $wpdb; //$wpdb->get_results("DELETE FROM ".DB_NAME.".`FeedMovie_New` where `CinemaId_fk` = ".$id.""); $wpdb->query("DELETE FROM FeedMovie_New WHERE CinemaId_fk = 6 OR CinemaId_fk = 7 OR CinemaId_fk = 8 OR CinemaId_fk = 9 OR CinemaId_fk = 10 OR CinemaId_fk = 11"); } function hreinsa_midi_bio(){ global $wpdb; //$wpdb->get_results("DELETE FROM ".DB_NAME.".`FeedMovie_New` where `CinemaId_fk` = ".$id.""); $wpdb->query("DELETE FROM FeedMovie_New WHERE CinemaId_fk = 1 OR CinemaId_fk = 2 OR CinemaId_fk = 3 OR CinemaId_fk = 4 OR CinemaId_fk = 5"); } function insert_syningartima($uniqueid, $bio,$klukkan,$time,$title,$leyfd, $biomyndnr,$salur,$url,$tegund,$language){ global $wpdb; $wpdb->query("INSERT INTO ".DB_NAME.".`FeedMovie_New` (`FeedId` ,`CinemaId_fk`,`ShowTime`,`date`,`Title`,`RatingIcoSmall`,`salur`,`Url`,`tegund`,`language` ) VALUES ('".$uniqueid."', '".$bio."', '".$klukkan."','".$time."', '".$title."', '".$leyfd."', '".$salur."', '".$url."', '".$tegund."', '".$language."')" ); } function hreinsa_affiliate_bt(){ $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_bt` " ); } function hreinsa_affiliate_filma(){ $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_filma` " ); } function hreinsa_affiliate_vodafone(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_vodafone` " ); } function hreinsa_affiliate_siminn_movies(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_siminn_movies` " ); } function hreinsa_affiliate_siminn_tv_show_all(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_siminn_tv_shows` " ); $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_siminn_tv_shows_series` " ); $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_siminn_tv_shows_series_episodes` " ); } function hreinsa_affiliate_netflix(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_netflix` " ); } function hreinsa_affiliate_netflix_new(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_netflix_new` " ); } function hreinsa_affiliate_ruv_movies(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_ruv_movies` " ); } function hreinsa_affiliate_netflix_episodes(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_netflix_episodes` " ); } function hreinsa_affiliate_stod2marathon(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_stod2marathon` " ); } function hreinsa_affiliate_viaplay_movies(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_viaplay` " ); } function hreinsa_affiliate_disneyplus_movies(){ global $wpdb; $wpdb->get_results("TRUNCATE TABLE ".DB_NAME.".`affiliate_disneyplus_movies` " ); } function insert_affiliate_bt($bt_id, $imdb_id){ $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_bt` (`bt_id` ,`imdb_id` ) VALUES ('".esc_sql($bt_id)."', '".esc_sql($imdb_id)."')" ); } function insert_affiliate_filma( $imdb_id, $filma_url){ $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_filma` (`imdb_id`,`filma_link` ) VALUES ('".esc_sql($imdb_id)."','".esc_sql($filma_url)."')" ); } /* function insert_affiliate_vodafone( $movie_id, $codename){ $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_vodafone` (`movie_id`,`codename` ) VALUES ('".esc_sql($movie_id)."','".esc_sql($codename)."')" ); }*/ function insert_affiliate_vodafone($title,$imdbId,$id,$licenseStart,$licenseEnd, $type, $vodprice, $ownprice) { global $wpdb; $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_vodafone` (`title`,`imdb_id`,`movie_id`,`licenseStart` ,`licenseEnd`,`type`,`vod_price`,`own_price`) VALUES ('".esc_sql($title)."','".esc_sql($imdbId)."','".esc_sql($id)."','".date('Y-m-d H:i:s',$licenseStart)."','".date('Y-m-d H:i:s',$licenseEnd)."','".esc_sql($type)."','".esc_sql($vodprice)."','".esc_sql($ownprice)."')" ); } function insert_affiliate_siminn_movie($title,$siminn_id,$tmdbId,$kmId,$imdbId, $licenseEnd, $price, $genres, $service) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_siminn_movies` (`title`,`siminn_id`,`tmdbId`,`kvikmyndir_id`,`imdb_id` ,`licenseEnd`,`price`,`genres`,`service`) VALUES ('".esc_sql($title)."','".esc_sql($siminn_id)."','".esc_sql($tmdbId)."','".esc_sql($kmId)."','".esc_sql($imdbId)."','".$licenseEnd."','".esc_sql($price)."','".esc_sql($genres)."','".esc_sql($service)."')"; //echo $query; $results = $wpdb->get_results($query); } function insert_affiliate_ruv_movie($title,$ruv_id,$slug,$image,$web_available_episodes, $short_description) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_ruv_movies` (`title`,`ruv_id`,`slug`,`image`,`web_available_episodes` ,`short_description`) VALUES ('".esc_sql($title)."','".esc_sql($ruv_id)."','".esc_sql($slug)."','".esc_sql($image)."','".esc_sql($web_available_episodes)."','".esc_sql($short_description)."')"; //echo "insert".$query; $results = $wpdb->get_results($query); } function insert_affiliate_viaplay_movie($viaplay_id,$image,$imdb_id,$imdb_rating,$url) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_viaplay` (`viaplay_id`,`image`,`imdb_id`,`imdb_rating`,`url`) VALUES ('".esc_sql($viaplay_id)."','".esc_sql($image)."','".esc_sql($imdb_id)."','".esc_sql($imdb_rating)."','".esc_sql($url)."')"; //echo "insert".$query; $results = $wpdb->get_results($query); } function insert_affiliate_disneyplus_movie($disney_id,$title,$url,$image) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_disneyplus_movies` (`disney_id`,`title`,`url`,`image`) VALUES ('".esc_sql($disney_id)."','".esc_sql($title)."','".esc_sql($url)."','".esc_sql($image)."')"; //echo "insert".$query; $results = $wpdb->get_results($query); } function insert_affiliate_siminn_tvshow($title,$siminn_id,$tmdbId,$kmId,$imdbId,$ttvdbId, $licenseEnd, $price, $genres, $service) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_siminn_tv_shows` (`title`,`siminn_id`,`tmdbId`,`kvikmyndir_id`,`imdb_id`,`ttvdbId` ,`licenseEnd`,`price`,`genres`,`service`) VALUES ('".esc_sql($title)."','".esc_sql($siminn_id)."','".esc_sql($tmdbId)."','".esc_sql($kmId)."','".esc_sql($imdbId)."','".esc_sql($ttvdbId)."','".$licenseEnd."','".esc_sql($price)."','".esc_sql($genres)."','".esc_sql($service)."')"; //echo $query; $results = $wpdb->get_results($query); } function insert_affiliate_siminn_tv_series($title,$siminn_id,$siminn_serie_id,$season_number) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_siminn_tv_shows_series` (`title`,`siminn_id`,`siminn_serie_id`,`season_number`) VALUES ('".esc_sql($title)."','".esc_sql($siminn_id)."','".esc_sql($siminn_serie_id)."',".esc_sql($season_number).")"; //echo $query; $results = $wpdb->get_results($query); } function insert_affiliate_siminn_tv_series_episode($title,$siminn_id,$siminn_series_id,$siminn_serie_id,$siminn_episode_id, $season_number, $episode_number, $availableUntil, $img_backdrop,$img_portrait,$img_landscape) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_siminn_tv_shows_series_episodes` (`title`,`siminn_show_id`,`siminn_serie_id`,`siminn_episode_id`,`season_number`,`episode_number` ,`available_until`,`img_backdrop`,`img_portrait`,`img_landscape`) VALUES ('".esc_sql($title)."','".esc_sql($siminn_id)."','".esc_sql($siminn_series_id)."','".esc_sql($siminn_episode_id)."','".esc_sql($season_number)."','".esc_sql($episode_number)."','".$availableUntil."','".esc_sql($img_backdrop)."','".esc_sql($img_portrait)."','".esc_sql($img_landscape)."')"; //echo $query; $results = $wpdb->get_results($query); } function insert_affiliate_netflix($title,$imdbId,$id,$download, $type, $image, $synopsis, $rating, $released, $runtime, $unogsdate) { global $wpdb; $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_netflix` (`title`,`imdb_id`,`movie_id`,`download`,`type`,`image`,`synopsis`,`rating`,`released`,`runtime`,`unogsdate`) VALUES ('".esc_sql($title)."','".esc_sql($imdbId)."','".esc_sql($id)."','".esc_sql($download)."','".esc_sql($type)."','".esc_sql($image)."','".esc_sql($synopsis)."','".esc_sql($rating)."','".esc_sql($released)."','".esc_sql($runtime)."','".esc_sql($unogsdate)."')" ); } function insert_affiliate_netflix_new($title,$imdbId,$id,$download, $type, $image, $synopsis, $rating, $released, $runtime, $unogsdate) { global $wpdb; $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_netflix_new` (`title`,`imdb_id`,`movie_id`,`download`,`type`,`image`,`synopsis`,`rating`,`released`,`runtime`,`unogsdate`) VALUES ('".esc_sql($title)."','".esc_sql($imdbId)."','".esc_sql($id)."','".esc_sql($download)."','".esc_sql($type)."','".esc_sql($image)."','".esc_sql($synopsis)."','".esc_sql($rating)."','".esc_sql($released)."','".esc_sql($runtime)."','".esc_sql($unogsdate)."')" ); } function insert_affiliate_netflix_episodes($series_id,$episode_id, $title, $img, $synopsis, $available) { global $wpdb; $query = "INSERT INTO ".DB_NAME.".`affiliate_netflix_episodes` (`series_id`,`episode_id`,`title`,`img`,`synopsis`) VALUES (".esc_sql($series_id).",".esc_sql($episode_id).",'".esc_sql($title)."','".esc_sql($img)."','".esc_sql($synopsis)."')"; //echo $query; $results = $wpdb->get_results($query); } function insert_affiliate_stod2marathon($title,$imdbId,$id,$licenseStart,$licenseEnd, $type) { global $wpdb; $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_stod2marathon` (`title`,`imdb_id`,`movie_id`,`licenseStart` ,`licenseEnd`,`type`) VALUES ('".esc_sql($title)."','".esc_sql($imdbId)."','".esc_sql($id)."','".date('Y-m-d H:i:s',$licenseStart)."','".date('Y-m-d H:i:s',$licenseEnd)."','".esc_sql($type)."')" ); } function find_movie_by_title_syningartimar($title){ global $wpdb; $query = sprintf("SELECT `ID_Movie`, `Title`, `TitleAliases` FROM `Movie` WHERE Title = '".esc_sql($title)."' OR TitleAliases = '".esc_sql($title)."' ORDER BY ID_Movie DESC;"); $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function insert_syningartima_midi($uniqueid, $bio,$klukkan,$dags,$title,$leyfd, $url, $salur, $tegund, $language){ global $wpdb; $wpdb->query("INSERT INTO ".DB_NAME.".`FeedMovie_New` (`FeedId` ,`CinemaId_fk`,`ShowTime`,`date`,`Title`,`RatingIcoSmall`,`Url`,`salur`,`tegund`,`language` ) VALUES ('".esc_sql($uniqueid)."', '".esc_sql($bio)."', '".esc_sql($klukkan)."','".esc_sql($dags)."', '".esc_sql($title)."', '".esc_sql($leyfd)."', '".esc_sql($url)."', '".esc_sql($salur)."', '".esc_sql($tegund)."', '".esc_sql($language)."')" ); } //TENGJA MYNDIR FRÁ BÍÓHÚSUNUM function find_tengd_mynd($id){ global $wpdb; $query = sprintf("SELECT * FROM ".DB_NAME.".Feed2Movie where IDFeed = '".esc_sql($id)."'" ); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } //TENGJA MYNDIR FRÁ BÍÓHÚSUNUM function biotimar_otengdar_myndir(){ global $wpdb; $query = sprintf("SELECT f.`FeedId`,f.`Title`, m.`ID_Movie`, f.`Url`, f.`Genre`, f.`RatingIcoBig`, f.`RatingIcoSmall`, f.`PosterBig`, f.`PosterSmall`, s.`IDMovie`, s.`Date`, m.`Poster`, m.`CertificateIS`, m.`Plot`, m.`TitleAliases`, m.`PremiereDateIS`, m.`imdb`, p.`orginalName` AS `OrginalPosterName` FROM `FeedMovie_New` AS f LEFT JOIN `Feed2Movie` s ON (f.`FeedId` = s.`IDFeed`) LEFT JOIN `Movie` AS m ON (s.`IDMovie` = m.`ID_Movie`) LEFT JOIN `vfsFile` AS p ON (p.`id` = m.`poster`) WHERE m.`ID_Movie` is null GROUP BY `FeedId`,`Title`, `ID_Movie`, `Url`, `Genre`, `RatingIcoBig`, `RatingIcoSmall`, `PosterBig`, `PosterSmall`, `IDMovie`, `Date`, `Poster`, `CertificateIS`, `Plot`, `TitleAliases`, `PremiereDateIS`, `imdb`, `OrginalPosterName` order by ID_Movie" ); $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function insert_feed2movie($feed,$movie_id){ global $wpdb; $wpdb->get_results("INSERT INTO ".DB_NAME.".`Feed2Movie` (`IDFeed` ,`IDMovie` ) VALUES ('".esc_sql($feed)."', '".esc_sql($movie_id)."')" ); } function biotimar_otengd(){ global $wpdb; $query = sprintf("SELECT f.`IDFeed`, `Title`, `Url` FROM ".DB_NAME.".`FeedNotConnected` AS f LEFT JOIN `FeedMovie_New` c ON (f.`IDFeed` = c.`FeedId`) ORDER BY `CinemaId_fk`" ); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') . "\n" . mysql_error(); $message .= 'Whole query: ' . $query; die($message); } return $results; } function insert_feed2movieNotConnected($feed){ global $wpdb; $wpdb->get_results("INSERT INTO ".DB_NAME.".`FeedNotConnected` (`IDFeed` ) VALUES ('".esc_sql($feed)."' "); } /* SÝNINGATÍMAR ENDAR */ /***************/ /* ----------------------*/ /* TOPPLISTAR BYRJA */ function find_list_by_id($id){ global $wpdb; $query = sprintf("SELECT * FROM `game_movie` WHERE game_id = ".$id." ORDER BY `id`;"); $results = $wpdb->get_results($query); if (!$results) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } return $results; } function find_list_by_movie($id){ global $wpdb; $query = sprintf("SELECT * FROM `game_movie` WHERE movie_id = ".$id." ORDER BY `game_id`;"); $results = $wpdb->get_results($query); /*if (!$results) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); }*/ return $results; } function find_lists(){ global $wpdb; $query = sprintf("SELECT * FROM `game` ORDER BY `id` desc;"); $results = $wpdb->get_results($query); if (!$results) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } return $results; } function find_top_100(){ $query = sprintf("SELECT `Movie` AS `ID_Movie` , `Movie`.`Title` , CAST( AVG( `VoteMovie`.`Mark` ) AS DECIMAL( 4, 1 ) ) AS `MarkA` , SUM( `Weight` ) AS `WeightA` , `Poster` , `fileName` FROM `VoteMovie` INNER JOIN `Movie` ON `Movie`.`ID_Movie` = `VoteMovie`.`Movie` LEFT JOIN `vfsFile` p ON ( `Poster` = p.`id` ) GROUP BY `VoteMovie`.`Movie` , `VoteMovie`.`Weight` HAVING `WeightA` >=100 ORDER BY `MarkA` DESC LIMIT 100; "); $results = $wpdb->get_results($query); if (!$results) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } return $results; } function find_botn_25(){ $query = sprintf("SELECT `Movie` AS `ID_Movie`,`Movie`.`Title`, CAST(AVG(`VoteMovie`.`Mark`) AS DECIMAL(4,1)) AS `MarkA`, SUM(`Weight`)AS `WeightA`,`Poster`, `fileName` FROM `VoteMovie` INNER JOIN `Movie` ON `Movie`.`ID_Movie`=`VoteMovie`.`Movie` LEFT JOIN `vfsFile` p ON ( `Poster` = p.`id` ) GROUP BY `VoteMovie`.`Movie`, `VoteMovie`.`Weight` HAVING `WeightA` >= 25 order by `MarkA` limit 25; "); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_newsletter(){ $query = sprintf("SELECT MyNewsletter.User,NewsletterType, A.Email, A.ID_User, B.Name FROM `MyNewsletter` JOIN User AS A ON MyNewsletter.User = A.ID_User JOIN UserProfile AS B ON MyNewsletter.User = B.User WHERE NewsletterType = 1; "); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_newsletter_users(){ $query = sprintf("SELECT * FROM `User` WHERE Email != '' "); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } /* TOPPLISTAR ENDAR */ /***************/ /* ----------------------*/ /* MY STUFF BYRJA */ function find_i_own($user_id){ $query = sprintf("SELECT * FROM `MyMovies` WHERE `ID_User_FK` = ".$user_id." order by `Purchased`;"); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_i_wannawatch($user_id){ $query = sprintf("SELECT * FROM `IWantToSeeMovies` WHERE `ID_User_FK` = ".$user_id." order by `Added`;"); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function update_sja($user_id,$movie_id,$inn_ut){ if($inn_ut == 1){ $query = sprintf("INSERT IGNORE INTO `IWantToSeeMovies` SET `ID_User_FK` = '".esc_sql($user_id)."', `ID_Movie_FK` = '".esc_sql($movie_id)."';"); } else { $query = sprintf("DELETE FROM `IWantToSeeMovies` WHERE `ID_User_FK` = ".esc_sql($user_id)." AND `ID_Movie_FK` = ".esc_sql($movie_id).";"); } $results = $wpdb->get_results($query); if (!$results) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; //die($message); } return $results; } function user_sja_mynd($user_id,$movie_id){ $query = "SELECT * FROM `IWantToSeeMovies` WHERE `ID_User_FK` = ".esc_sql($user_id)." AND `ID_Movie_FK` = ".esc_sql($movie_id).";"; $results = $wpdb->get_results($query); if (mysql_num_rows($results) > 0) { return 1; } else { return 0; } if (!$results) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; //die($message); } return $results; } function find_auglysingar($svaedi,$notkun){ global $wpdb; $query = "SELECT * FROM `auglysingar` WHERE `notkun` = ".$notkun." AND `svaedi` = ".$svaedi." ORDER BY RAND();"; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function bordi_skodadur($id){ global $wpdb; $query = "UPDATE ".DB_NAME.".`auglysingar` SET birtingar = birtingar + 1 WHERE ID=".$id; $results = $wpdb->get_results($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } /* ----------------------*/ /* API */ function api_skodad($key, $api){ global $wpdb; $query = "UPDATE `api_lyklar` SET access_count = access_count + 1 WHERE `key`='".$key."'"; $query2 = "INSERT INTO `api_log`(`access_by` ,`access_to` ) VALUES ('".esc_sql($key)."', '".esc_sql($api)."')" ; $results = $wpdb->get_results($query); $results2 = $wpdb->get_results($query2); return $results; } function api_check_key($key){ global $wpdb; $query = "SELECT * FROM `api_lyklar` WHERE `key` = '".$key."'"; $results = $wpdb->get_results($query); if(count($results) == 0){ if (!$results) { $message = utf8_encode('Það fór eittshvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } } else { return 1; } return $results; } function api_logged($key, $api){ global $wpdb; $key_back = api_check_key($key); if($key_back==1) { } else { echo ('ooops - something is wrong. Key broken - please let us know if this is an error at kvikmyndir@kvikmyndir.is'); exit; } api_skodad($key, $api); } function find_movie_all($count){ global $wpdb; $query = "SELECT m.`ID_Movie`,m.`Poster`AS `poster_id`,m.`Title`,m.`Plot`,m.`TitleAliases`,m.`imdb_rating`, m.`Year`, m.`tv_show`, m.`imdb`, p.`orginalName` AS `Poster`, tr.`Description`, tr.`ID_TrailerFile`, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_netflix WHERE affiliate_netflix.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Netflix, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_netflix_new WHERE affiliate_netflix_new.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Netflix7, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_stod2marathon WHERE affiliate_stod2marathon.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Stod2marathon, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_vodafone WHERE affiliate_vodafone.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Vodafone, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_siminn_movies WHERE affiliate_siminn_movies.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Siminn, CASE WHEN EXISTS ( SELECT source_name,source_id,affiliate_to_movie.movie_id FROM affiliate_to_movie INNER JOIN affiliate_ruv_movies ON (affiliate_to_movie.source_id = affiliate_ruv_movies.ruv_id ) WHERE affiliate_to_movie.movie_id = ID_Movie AND source_name = 'ruv' ) THEN '1' ELSE '0' END AS Ruv, CASE WHEN EXISTS (SELECT source_name,source_id,movie_id FROM affiliate_to_movie WHERE affiliate_to_movie.movie_id = ID_Movie AND source_name = 'disneyplus') THEN '1' ELSE '0' END AS Disneyplus, CASE WHEN EXISTS (SELECT source_name,source_id,movie_id FROM affiliate_to_movie WHERE affiliate_to_movie.movie_id = ID_Movie AND source_name = 'viaplay') THEN '1' ELSE '0' END AS Viaplay FROM `Movie` as m JOIN ( SELECT MAX(`ID_TrailerFile`), Movie, ID_TrailerFile FROM `Trailer` GROUP BY Movie ) tr_newest ON (tr_newest.`Movie` = m.`ID_Movie`) JOIN `Trailer` tr ON (tr.`ID_TrailerFile` = tr_newest.`ID_TrailerFile`) LEFT JOIN `vfsFile` p ON ( m.`Poster` = p.`id` ) ORDER BY m.`Year` DESC Limit 0,".$count.""; $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_movie_all_no_trailer($count){ global $wpdb; $query = "SELECT m.`ID_Movie`,m.`Poster`AS `poster_id`,m.`Title`,m.`Plot`,m.`TitleAliases`,m.`imdb_rating`, m.`Year`, m.`tv_show`, m.`imdb`, p.`orginalName` AS `Poster`, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_netflix WHERE affiliate_netflix.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Netflix, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_netflix_new WHERE affiliate_netflix_new.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Netflix7, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_stod2marathon WHERE affiliate_stod2marathon.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Stod2marathon, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_vodafone WHERE affiliate_vodafone.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Vodafone, CASE WHEN EXISTS (SELECT imdb_id FROM affiliate_siminn_movies WHERE affiliate_siminn_movies.imdb_id = imdb AND imdb != '') THEN '1' ELSE '0' END AS Siminn, CASE WHEN EXISTS (SELECT source_name,source_id,movie_id FROM affiliate_to_movie WHERE affiliate_to_movie.movie_id = ID_Movie AND source_name = 'ruv') THEN '1' ELSE '0' END AS Ruv, CASE WHEN EXISTS (SELECT source_name,source_id,movie_id FROM affiliate_to_movie WHERE affiliate_to_movie.movie_id = ID_Movie AND source_name = 'disneyplus') THEN '1' ELSE '0' END AS Disneyplus FROM `Movie` as m LEFT JOIN `vfsFile` p ON ( m.`Poster` = p.`id` ) ORDER BY m.`Year` DESC Limit 0,".$count.""; $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_forsala($id){ global $wpdb; $query = "SELECT * FROM `forsala` WHERE movie = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return 0; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function get_netflix($id){ global $wpdb; $query = "SELECT * FROM `affiliate_netflix` WHERE imdb_id = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return '0'; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function get_affiliate($id,$name){ global $wpdb; $query = "SELECT * FROM affiliate_to_movie as affiliate WHERE movie_id = ".esc_sql($id)." AND source_name = '".esc_sql($name)."'"; $results = $wpdb->get_row($query); if (empty($results)) { return '0'; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function get_marathon($id){ global $wpdb; $query = "SELECT * FROM `affiliate_stod2marathon` WHERE imdb_id = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return '0'; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function get_viaplay($id){ global $wpdb; $query = "SELECT * FROM `affiliate_viaplay` WHERE viaplay_id = '".esc_sql($id)."'"; $results = $wpdb->get_row($query); if (empty($results)) { return '0'; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function get_stod2($id){ global $wpdb; $query = "SELECT * FROM `affiliate_vodafone` WHERE imdb_id = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return '0'; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function get_siminn($id){ global $wpdb; $query = "SELECT * FROM `affiliate_siminn_movies` WHERE imdb_id = ".esc_sql($id).""; $results = $wpdb->get_row($query); if (empty($results)) { return '0'; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function get_ruv($id){ global $wpdb; $query = "SELECT * FROM `affiliate_to_movie` JOIN `affiliate_ruv_movies` AS ruv ON affiliate_to_movie.source_id = ruv.ruv_id WHERE `affiliate_to_movie`.movie_id = ".esc_sql($id)." AND `affiliate_to_movie`.source_name = 'ruv';"; $results = $wpdb->get_row($query); if (empty($results)) { return '0'; } if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ; // $message .= 'Whole query: ' . $query; //$message .= mysql_error() . "\n"; die($message); } return $results; } function find_showtimes_not_connected(){ global $wpdb; $query = sprintf("SELECT `FeedId`, `Title`, `CinemaId_fk`, `Url` FROM FeedMovie_all_dates AS a WHERE NOT EXISTS ( SELECT * FROM Feed2Movie AS b WHERE a.FeedId=b.IDFeed ) Group by FeedId, Title, `CinemaId_fk`, Url " ); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_available_on_netflix_missing_from_us($count){ global $wpdb; $query = sprintf("SELECT * FROM `affiliate_netflix` WHERE NOT EXISTS (SELECT * FROM Movie WHERE Movie.imdb = affiliate_netflix.`imdb_id`) Limit 0,".$count."" ); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_available_on_viaplay_missing_from_us($count){ global $wpdb; $query = sprintf("SELECT * FROM `affiliate_viaplay` WHERE NOT EXISTS (SELECT * FROM Movie WHERE Movie.imdb = affiliate_viaplay.`imdb_id`) Limit 0,".$count."" ); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() //$message .= 'Whole query: ' . $query; die($message); } return $results; } function find_available_on_ruv_missing_from_us($count){ global $wpdb; $query = sprintf("SELECT * FROM affiliate_ruv_movies ruv WHERE ruv.ruv_id NOT IN (SELECT affiliate.source_id FROM affiliate_to_movie affiliate WHERE affiliate.source_name = 'ruv')"); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() $message .= 'Whole query: ' . $query; die($message); } return $results; } function find_available_on_disney_missing_from_us($count){ global $wpdb; $query = sprintf("SELECT * FROM affiliate_disneyplus_movies AS disney WHERE disney.disney_id NOT IN (SELECT affiliate.source_id FROM affiliate_to_movie affiliate WHERE affiliate.source_name = 'disneyplus')"); $results = $wpdb->get_results($query); if (!$results) { $message = utf8_encode('Það fór eitthvað úrskeiðis. Vinsamlega reyndu aftur ') ;//. "\n";. mysql_error() $message .= 'Whole query: ' . $query; die($message); } return $results; } function insert_tengja_myndir_affiliate($id_movie, $id_affiliate, $affilate){ global $wpdb; $wpdb->get_results("INSERT INTO ".DB_NAME.".`affiliate_to_movie` (`movie_id` ,`source_id`,`source_name` ) VALUES ('".esc_sql($id_movie)."', '".esc_sql($id_affiliate)."', '".esc_sql($affilate)."' ) ON DUPLICATE KEY UPDATE `movie_id`='".esc_sql($id_movie)."' "); }