public function __construct() { $goodVisit = new GoodVisitor(); $badVisit = new BadVisitor(); $cinema = new Cinema(); $museum = new Museum(); $museum->accept($goodVisit); $cinema->accept($goodVisit); $cinema->accept($badVisit); $museum->accept($badVisit); }
public function doUrl() { if ($this->urlInput->checkPost()) { $url = $this->urlInput->getUrl(); // ----------------- // $curler = new Curler(); $startPage = new StartPage($url, $curler); $startPage->getStartLinks(); // days every body can $calander = new Calander($url . $startPage->getCalanderLink(), $curler); $daysEvaeyBodyCan = $calander->getDayEverybodyCan(); $cinema = new Cinema($url . $startPage->getCinemaLink(), $curler, $daysEvaeyBodyCan); $filmsForXDays = $cinema->getMoviesFromDays(); $dataPresenter = new PresentDataView(); $this->html = $dataPresenter->generateHTML($filmsForXDays); } else { $this->html = $this->urlInput->generateInputField(); } }
public function getCinemasFromDb($columnsNames = ["id", "name", "address"]) { if (is_array($columnsNames) && !empty($columnsNames)) { $columns = implode(",", $columnsNames); $sqlQuery = "SELECT " . $columns . " FROM cinemas"; $conn = parent::getConnection(); $result = $conn->query($sqlQuery); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $cinema = new Cinema(parent::getConnection()); if (array_key_exists("id", $row)) { $cinema->setId($row["id"]); } if (array_key_exists("name", $row)) { $cinema->setName($row["name"]); } if (array_key_exists("address", $row)) { $cinema->setAddress($row["address"]); } $this->setArrayWithCinemas($cinema); } } } }
<!DOCTYPE> <head> <title>Bios</title> <link rel="stylesheet" href="css/style.css"> <?php // echo '<meta http-equiv="refresh" content="0">'; ?> </head> <body> <pre> <?php $start = microtime(true); $visitors = 300; $maxAmount = 800; $takenSeats = NULL; $cinema = new Cinema($maxAmount, $takenSeats); $cinema->giveSeatNumbers($visitors); ?> </pre> <?php echo '<p>Took ' . (microtime(true) - $start) . ' seconds to place ' . $visitors . ' into a Cinema of ' . $maxAmount . '</p>'; ?> <div id="cinema"> <?php $cinema->showSeats(); ?> </div> <p> </p> </body>
$dateFormatted = substr($date, 0, 16); $screeningId = $screening->getId(); echo "<li>Cinema: <a href='showInfo.php?type=cinema&id={$cinemaId}'>{$cinemaName}</a>, Date & Time: {$dateFormatted}"; renderTicketForm($screeningId); echo "</li>"; } echo "</ul>"; } else { echo "<p>No screenings</p>"; } } if ($_SERVER["REQUEST_METHOD"] === "GET" && $_GET["type"] === "cinema") { $id = $_GET["id"]; $db = DATABASE::getInstance(); $mysqli = $db->getConnection(); $cinema = new Cinema($mysqli); $cinema->findCinemaById($id); $cinemaName = $cinema->getName(); $cinemaAddress = $cinema->getAddress(); echo "<h3>Name: {$cinemaName}</h3>"; echo "<p>Address: {$cinemaAddress}</p>"; echo "<h3>Cinema Screenings:</h3>"; $fetcher = new ScreeningFetcher($db); $fetcher->getCinemaScreenings($id); $screeningsArray = $fetcher->getArrayWithCinemaScreenings(); if (!empty($screeningsArray)) { echo "<ul>"; foreach ($screeningsArray as $screening) { $movieName = $screening->getMovie()->getName(); $movieId = $screening->getMovie()->getId(); $date = $screening->getDate();
<?php require_once "../classes/Database.php"; require_once "../classes/Cinema.php"; if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["cinema_name"])) { $name = htmlentities($_POST["cinema_name"]); $address = htmlentities($_POST["cinema_address"]); $db = DATABASE::getInstance(); $mysqli = $db->getConnection(); $cinema = new Cinema($mysqli); $cinema->setName($name); $cinema->setAddress($address); $cinema->addToDatabase(); header("location: adminPanel.php"); } else { header("location: adminPanel.php"); }
public function scrape() { $url = 'http://www.gnccinemas.com.br/conteudo/home.asp'; $referer = 'http://www.gnccinemas.com.br/conteudo/home.asp'; $curl_handle = curl_init(); /* TODO adicionar controle de excecao, por tempo fazer essa chamada mais generica */ curl_setopt($curl_handle, CURLOPT_URL, $url); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, 'CodCidade=1'); curl_setopt($curl_handle, CURLOPT_REFERER, $referer); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Firefox'); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); $cinema = new Cinema(); $cinema->name = 'Teste GNC'; $cinema->address = 'Rua X'; $cinema->phone = '123'; $cinema->ticket = '456'; //phpQuery::$debug = 1; if (!empty($buffer)) { phpQuery::newDocument($buffer); $line = pq('td.td_pontilhada_l0t0r0b0'); $trs = pq('table tr', $line); $htmlSalas = pq('.topo_tabela_azul4[width="210"]'); /** aqui pega o link para o cinema do grupo. Deve fazer um novo curl para pegar o endereco foreach($htmlSalas as $sala){ echo trim(pq('a',$sala)->attr('href')); } */ //$filmes = pq('div.a ,div.b', $prog); foreach ($trs as $key => $value) { /* echo '<pre>'; print_r(pq($value)->html()); echo '</pre>'; return; */ $filme = trim(pq('a.nome_filme_programacao-home', $value)->text()); if (empty($filme)) { continue; } $showtimes = trim(pq('.horarios_programacao-home', $value)->text()); $showtimes = explode(" - ", $showtimes); /*$censura = trim(pq('input',$value)->attr('value')); $legenda = pq('div.legenda span',$value)->attr('onmouseover'); $legenda = strtolower($legenda); $pattern = '(legendado|dublado|nacional)'; preg_match($pattern, $legenda, $matches); $legenda = trim($matches[0]); $horarios = pq('div.horas > span', $value); */ $filme_horarios = new Movie(); $filme_horarios->name = $filme; $filme_horarios->age = "censura"; //$censura; $filme_horarios->subtitle = "legenda"; //$legenda; //verificar se nao e' possivel passar a lista de diretamente para o showtimes $filme_horarios->showtime = $showtimes; /* foreach ($horarios as $key => $value) { $horario = pq($value)->text(); if (!empty($horario)) { $filme_horarios->set_showtime($horario); } } */ $cinema->set_movie($filme_horarios); } return $cinema; // echo '<pre>'; // print_r($cinema); // echo '</pre>'; } }
<?php require_once "../classes/Database.php"; require_once "../classes/Screening.php"; require_once "../classes/Movie.php"; require_once "../classes/Cinema.php"; if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["movie"])) { $movieId = $_POST["movie"]; $cinemaId = $_POST["cinema"]; $dateFormatted = str_replace("T", " ", $_POST["date"]); $db = DATABASE::getInstance(); $mysqli = $db->getConnection(); $movie = new Movie($mysqli); $movie->findMovieById($movieId); $cinema = new Cinema($mysqli); $cinema->findCinemaById($cinemaId); $screening = new Screening($mysqli); $screening->setMovie($movie); $screening->setCinema($cinema); $screening->setDate($dateFormatted); $screening->addToDatabase(); header("location: adminPanel.php"); }
public function getCinemaScreenings($id) { $sqlQuery = "SELECT id, cinema_id, movie_id, date FROM screenings WHERE date > NOW() AND cinema_id = {$id} ORDER BY date "; $conn = parent::getConnection(); $result = $conn->query($sqlQuery); if ($result->num_rows > 0) { while (list($id, $cinemaId, $movieId, $date) = $result->fetch_array(MYSQLI_NUM)) { $movie = new Movie($conn); $movie->findMovieById($movieId); $cinema = new Cinema($conn); $cinema->findCinemaById($cinemaId); $screening = new Screening($conn); $screening->setMovie($movie); $screening->setCinema($cinema); $screening->setDate($date); $screening->setId($id); $this->setArrayWithCinemaScreenings($screening); } } }
echo "tickets - " . $this->tickets . "<br>"; echo "shown movies - " . $this->show_movies . "<br>"; } function __construct($name, $em, $ad, $tick, $show) { $this->name = $name; $this->employee = $em; $this->adress = $ad; $this->tickets = $tick; $this->show_movies = $show; } } class Hot_movies extends Cinema { public static $premiere = "Warcraft"; } $Imax = new Cinema('Cinema city', 2, 'Blabla #55', 200, 5); $Imax->print_info(); echo "Premiere movies in all cinemas :<br>" . Hot_movies::$premiere . "<br>"; echo "<pre>"; echo $Imax->sale(5); echo "<br>"; echo $Imax->sale(10); echo "</pre>"; $d2 = new Cinema('Burgas Cinema', 5, 'Lalala #21', 100, 2); $d2->print_info(); echo "<pre>"; echo $d2->sale(1); echo "<br>"; echo $d2->sale(2); echo "</pre>";