public function testEmpty() { //if(empty($field) or str_replace(" ", "", $field)=='N/A' or $field=='0.0' or $field=='0' or $field==' '){ $empty1 = "N/A"; $empty2 = " "; $empty3 = ""; $empty4 = "0.0"; $empty5 = "0"; $this->assertTrue(IsEmpty($empty1)); $this->assertTrue(IsEmpty($empty2)); $this->assertTrue(IsEmpty($empty3)); $this->assertTrue(IsEmpty($empty4)); $this->assertTrue(IsEmpty($empty5)); }
function _rm_page_month($page) { $arr_month = array('01' => 'Styczeń', '02' => 'Luty', '03' => 'Marzec', '04' => 'Kwiecień', '05' => 'Maj', '06' => 'Czerwiec', '07' => 'Lipiec', '08' => 'Sierpień', '09' => 'Wrzesień', '10' => 'Październik', '11' => 'Listopad', '12' => 'Grudzień'); $year = substr($page, 0, 2); $month = substr($page, 2, 2); $ereg = '[0-9]{6}_[0-9]{5}\\.'; $raws = array(); foreach (rmconf('rawdir') as $udir => $dir) { if (!is_dir($dir)) { continue; } $raws = array_merge($raws, rawman_readdir(sprintf('%s20%02d_%02d/', $dir, $year, $month), $ereg)); } echo rawman_html('month', array('skins' => RM_WEB . '/skins', 'imgdir' => RM_WEB . '/index.php/image', 'content' => rawman_listmonth($raws), 'header' => $arr_month[$month] . ' 20' . $year, 'footer' => RetIf(!IsEmpty($_SESSION['bookmark']), sprintf('» <a href="' . RM_WEB . '/index.php/bookmark/all">%s</a> (%d) « ', 'Wyświetl ulubione', count($_SESSION['bookmark']))))); }
function _rm_page_main() { $content = ''; $months = array(); foreach (rmconf('rawdir') as $udir => $dir) { if (!is_dir($dir)) { continue; } $months = array_merge($months, rawman_readdir($dir, '[0-9]{4}_[0-9]{2}')); } sort($months); $years = array(); foreach ($months as $month) { if (preg_match('/\\d{2}(\\d{2})_(\\d{2})/', $month, $m)) { $years[$m[1]][] = $m[2]; } } $content = '<table border="0">'; foreach ($years as $year => $yd) { $content .= '<tr><td colspan="4" class="year">20' . $year . "</td></tr>\n"; for ($m = 1; $m <= 12; $m++) { if ($m % 3 == 1) { $content .= '<tr><td width="50"></td>'; } $content .= '<td>'; $month = sprintf('%02d', $m); if (in_array($month, $yd)) { $link = sprintf('%02d%02d', $year, $month); $content .= '<div>' . '<a href="' . RM_WEB . '/index.php/month/all/' . $link . '"> ' . '<img src="' . RM_WEB . '/index.php/stack/all/' . $link . '" border="0" />' . '<br clear="all" />' . $month . '</a>' . "</div>\n"; } $content .= '</td>'; if ($m % 3 == 0) { $content .= "</tr>\n"; } } } $content .= '</table>'; echo rawman_html('main', array('skins' => RM_WEB . '/skins', 'content' => $content, 'footer' => RetIf(!IsEmpty($_SESSION['bookmark']), sprintf('» <a href="' . RM_WEB . '/index.php/bookmark/all">%s</a> (%d) « ', 'Wyświetl ulubione', count($_SESSION['bookmark']))))); }
$codigo = $_POST["codigo"]; Query("delete from usuario where usua_codigo = '" . $codigo . "'"); Disconnect(); //* echo "<script type=\"text/javascript\">\n\t\t\t\t\talert(\"Se ha borrado exitosamente\");\n\t\t\t\t\twindow.location.href=\"../index.php\"\n\t\t\t\t</script>"; //*/ } catch (Exception $e) { echo "Message: " . $e->getMessage(); } } if (isset($_POST['ingresar'])) { try { Connect(); $usuario = $_POST["usuario"]; $clave = $_POST["clave"]; if (IsEmpty("select usua_codigo from usuario where usua_nombre='" . $usuario . "' and usua_clave='" . $clave . "'") == false) { $rol = Value("select rol_permiso from usuario,rol,rous where fk_usua=usua_codigo and fk_rol=rol_codigo and usua_nombre='" . $usuario . "'", "ROL_PERMISO"); if ($rol == false) { echo "<script type=\"text/javascript\">\n\t\t\t\t\talert(\"Agregue un rol al usuario\");\n\t\t\t\t\twindow.location.href=\"../index.php\"\n\t\t\t\t</script>"; //*/ } session_start(); $_SESSION['usuario'] = $usuario; $_SESSION['rol'] = $rol; } Disconnect(); echo "<script type=\"text/javascript\">\n\t\t\t\t\twindow.location.href=\"../index.php\"\n\t\t\t\t</script>"; //*/ } catch (Exception $e) { echo "Message: " . $e->getMessage(); }
<?php require "include/lib_xiii.php"; $info = new XIIICreatorInfo(); $log = new LogFile(); // Quick check. function IsEmpty($var) { if ($var == -1) { return true; } return false; } // Check for illegal inputs. if (IsEmpty($info->Get_HashCode()) && $info->Get_HashCode() != KEYPASS) { return; } // Invalid Port range. if ($info->Get_Port() > MAXPORT && $info->Get_Port() < MINPORT || $info->Get_QueryPort() > MAXPORT && $info->Get_QueryPort() < MINPORT) { return; } // Our checks seem to be "OK", so log it. $log->DateLog("[ASK] - Server " . $info->Get_Ip() . ":" . $info->Get_Port() . " asks for MasterServer regisration."); // Check if we got already the ip/port into our database. $idcheck = $info->CheckServerAlive($info->Get_Ip(), $info->Get_Port()); if ($idcheck != "") { if ($info->UpdateServer($idcheck)) { $log->DateLog("[SUCCESS] - Server at ip " . $info->Get_Ip() . ":" . $info->Get_Port() . " successfully updated for 6 more minutes!"); } } else { if ($info->AddServer($info->Get_Ip(), $info->Get_Port(), $info->Get_QueryPort())) {
function IsEmpty($obj) { if (is_array($obj)) { foreach ($obj as $o) { if (!IsEmpty($o)) { return false; } } return true; } else { if ($obj) { return false; } else { return true; } } }
</div> <div class = "col-xs-6"> <p>Audience Score</p> <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="<?php echo $movieInfoRow['tomatoUserMeter']; ?> " aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $movieInfoRow['tomatoUserMeter']; ?> %;"><?php echo $movieInfoRow['tomatoUserMeter']; ?> %</div> </div> <p>Average Rating: <?php if (IsEmpty($movieInfoRow['tomatoUserRating'])) { echo 'N/A'; } else { echo $movieInfoRow['tomatoUserRating'] . '/5'; } ?> </p> <p>Reviews: <?php echo $movieInfoRow['tomatoUserReviews']; ?> </p> </div> </div> </div> </div>
function getTheatre() { require "../includes/connect.php"; require "../functions/newMovie.php"; //EMPTIES INTHEATRES $truncateQuery = "TRUNCATE TABLE `intheatres`"; mysqli_query($conn, $truncateQuery) or die(mysqli_error($conn)); $scrapeUrl = 'http://igoogle.flixster.com/igoogle/showtimes'; $text = file_get_contents($scrapeUrl); $outerRegex = '#(?s)<select name="movie">(.*?)<\\/select>#'; preg_match($outerRegex, $text, $outer); echo $outer[0]; $showtimeRegex = '#<option value="(\\d*)" >[\\s]*(.*)#'; preg_match_all($showtimeRegex, $outer[0], $showtimes, PREG_SET_ORDER); foreach ($showtimes as $show) { //echo $show[0]; $code = $show[1]; $title = $show[2]; if (substr($title, -3) == "...") { //echo $name; //echo $code; $movieUrl = 'http://igoogle.flixster.com/igoogle/m/' . $code; $movieText = file_get_contents($movieUrl); $titleRegex = '#<h1 id="title">(.*)</h1>#'; preg_match($titleRegex, $movieText, $title); $title = $title[1]; } echo "title is "; if (IsEmpty($title)) { continue; } //$title = htmlentities ($title); //$title = str_replace("'", "", $title); echo $title . "<br>"; $selectQuery = "SELECT movieId FROM moviename"; $selectResult = mysqli_query($conn, $selectQuery); $exists = 0; while ($row = mysqli_fetch_array($selectResult)) { if (fuzzy_match($title, $row['movieId'])) { $exists = 1; break; } } if ($exists == 1) { echo "exists <br>"; $movieId = str_replace(" ", "+", $title); echo " movie id111 is " . $movieId; $movieId = mysqli_real_escape_string($conn, $movieId); echo "title is " . $title . " movie id is " . $movieId; if (IsEmpty($movieId)) { continue; } echo "inserting into theatre"; $theatreInsertQurey = "INSERT INTO `intheatres` (`movieId`, `code`) VALUES ('{$movieId}', '{$code}')"; mysqli_query($conn, $theatreInsertQurey) or die(mysqli_error($conn)); continue; } else { echo "doesnt exist <br>"; //doesnt exists echo "downloading new movie data"; newMovie($title); $movieId = mysqli_real_escape_string($conn, str_replace(" ", "+", $title)); if (IsEmpty($movieId)) { continue; } $theatreInsertQurey = "INSERT INTO `intheatres` (`movieId`, `code`) VALUES ('{$movieId}', '{$code}')"; mysqli_query($conn, $theatreInsertQurey) or die(mysqli_error($conn)); } echo "<br>"; } //endfunction }
function updateMovie() { set_time_limit(7200); require "../includes/connect.php"; require "../functions/string.php"; $selectQuery = "SELECT * FROM `imdb`"; $selectResult = mysqli_query($conn, $selectQuery) or die(mysqli_error($conn)); while ($row = mysqli_fetch_array($selectResult)) { $movieId = $row['movieId']; //$movieId = "Dragonheart+3:+The+Sorcerer's+Curse"; $imdbID = $row['imdbID']; //$imdbID = "tt2974918"; //$movieId = "Alvin+and+the+Chipmunks:+The+Road+Chip"; echo "updating id :" . $imdbID . " "; if (IsEmpty($imdbID) || IsEmpty($movieId)) { continue; } $movieInfoQuery = "SELECT * FROM `movieinfo` WHERE movieId = '" . mysql_real_escape_string($movieId) . "'"; //escape as id may have apostrophe $movieInfoResult = mysqli_query($conn, $movieInfoQuery) or die(mysqli_error($conn)); $movieInfoRow = mysqli_fetch_array($movieInfoResult); //if(IsEmpty($movieInfoRow['movieId'])){ // continue; //} echo "getting omdb for " . $movieId . ", "; //@ to suppress warnings and notices... /*OMDB API -DOESNT EXIST FOR ALL MOVIES*/ $omdbXml = @simplexml_load_file("http://www.omdbapi.com/?t=" . urlencode($movieId) . "&plot=full&r=xml&tomatoes=true"); echo "omdb is http://www.omdbapi.com/?t=" . urlencode($movieId) . "&plot=full&r=xml&tomatoes=true , "; $poster = ""; $metascore = ""; $imdbRating = ""; $imdbVotes = ""; //$imdbID = ""; $runtime = ""; $plot = ""; $releaseDate = ""; $rated = ""; $genre = ""; $director = ""; $writer = ""; $language = ""; $country = ""; $actors = ""; $website = ""; $boxOffice = ""; $awards = ""; $tomatoMeter = ""; $tomatoImage = ""; $tomatoRating = ""; $tomatoReviews = ""; $tomatoFresh = ""; $tomatoRotten = ""; $tomatoUserMeter = ""; $tomatoUserRating = ""; $tomatoUserReviews = ""; $imdbLink = ""; //echo $omdbXml->attributes()->response; if (@$omdbXml->root['response'] == "False") { echo "movie not found in omdb"; // throw new Exception("Cannot load xml source.\n"); $poster = ""; $metascore = ""; $imdbRating = ""; $imdbVotes = ""; //$imdbID = ""; $runtime = ""; $plot = ""; $releaseDate = ""; $rated = ""; $genre = ""; $rated = ""; $genre = ""; $director = ""; $writer = ""; $language = ""; $country = ""; $actors = ""; $website = ""; $boxOffice = ""; $awards = ""; $tomatoMeter = ""; $tomatoImage = ""; $tomatoRating = ""; $tomatoReviews = ""; $tomatoFresh = ""; $tomatoRotten = ""; $tomatoUserMeter = ""; $tomatoUserRating = ""; $tomatoUserReviews = ""; $imdbLink = ""; } else { //$genre = $omdbXml->movie['genre']; $director = mysql_real_escape_string(htmlentities(@$omdbXml->movie['director'])); //$releaseDate = $omdbXml->movie['released']; $writer = mysql_real_escape_string(htmlentities(@$omdbXml->movie['writer'])); $language = @$omdbXml->movie['language']; $country = @$omdbXml->movie['country']; $actors = mysql_real_escape_string(htmlentities(@$omdbXml->movie['actors'])); $website = @$omdbXml->movie['Website']; $boxOffice = @$omdbXml->movie['boxOffice']; $awards = @$omdbXml->movie['awards']; //omdb tomato $tomatoMeter = @$omdbXml->movie['tomatoMeter']; $tomatoImage = @$omdbXml->movie['tomatoImage']; $tomatoRating = @$omdbXml->movie['tomatoRating']; $tomatoReviews = @$omdbXml->movie['tomatoReviews']; $tomatoFresh = @$omdbXml->movie['tomatoFresh']; $tomatoRotten = @$omdbXml->movie['tomatoRotten']; $tomatoUserMeter = @$omdbXml->movie['tomatoUserMeter']; $tomatoUserRating = @$omdbXml->movie['tomatoUserRating']; $tomatoUserReviews = @$omdbXml->movie['tomatoUserReviews']; $metascore = @$omdbXml->movie['metascore']; $imdbRating = @$omdbXml->movie['imdbRating']; $imdbVotes = @$omdbXml->movie['imdbVotes']; //$imdbID = @$omdbXml->movie['imdbID']; $runtime = @$omdbXml->movie['runtime']; $plot = mysql_real_escape_string(@$omdbXml->movie['plot']); $releaseDate = @$omdbXml->movie['releaseDate']; $rated = @$omdbXml->movie['rated']; $genre = @$omdbXml->movie['genre']; $poster = @$omdbXml->movie['poster']; $imdbLink = ""; } $myApiFilmsUrl = "http://api.myapifilms.com/imdb/idIMDB?idIMDB=" . $imdbID . "&token=870c3596-fa05-4ced-82cf-a76d58be8a5a&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&trailer=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0"; //echo $myApiFilmsUrl."<br>"; $json = file_get_contents($myApiFilmsUrl); $data = json_decode($json, true); //true for array format //print_r($data); if (IsEmpty($plot)) { $plot = mysql_real_escape_string($data['data']['movies'][0]['plot']); } $imdbLink = $data['data']['movies'][0]['urlIMDB']; if (IsEmpty($poster)) { $poster = $data['data']['movies'][0]['urlPoster']; //$poster = 'http://ia.media-imdb.com/images/M/MV5BMTAzNjU4MzYwNDdeQTJeQWpwZ15BbWU4MDg3NTEzMjcx._V1_SY317_CR0,0,214,317_AL_.jpg'; } //echo "poster is".IsEmpty($poster); if (!IsEmpty($poster)) { //download if (IsEmpty($movieInfoRow['poster'])) { echo "download poster for update<br>"; downloadPoster($movieId, $poster); } } //$plot = "plesase."; $subtitleLink = 'http://www.opensubtitles.org/en/search2/sublanguageid-all/moviename-' . $movieId; //cant find $tomatoLink = ""; $tmdbLink = ""; $youtubeLink = ""; echo " --inserting...-"; $movieInfoInsertQuery = "UPDATE `movieinfo` SET \n\t\t\t\trated = IF(LENGTH(rated)=0, '{$rated}', rated),\n\t\t\t\treleaseDate = IF(LENGTH(releaseDate)=0, '{$releaseDate}', releaseDate),\n\t\t\t\truntime = IF(LENGTH(runtime)=0, '{$runtime}', runtime),\n\t\t\t\tgenre = IF(LENGTH(genre)=0, '{$genre}', genre),\n\t\t\t\tdirector = IF(LENGTH(director)=0, '{$director}', director),\n\t\t\t\twriter = IF(LENGTH(writer)=0, '{$writer}', writer),\n\t\t\t\tactors = IF(LENGTH(actors)=0, '{$actors}', actors),\n\t\t\t\tplot = IF(LENGTH(plot)=0, '{$plot}', plot),\n\t\t\t\tlanguage = IF(LENGTH(language)=0, '{$language}', language),\n\t\t\t\tcountry = IF(LENGTH(country)=0, '{$country}', country),\n\t\t\t\tawards = IF(LENGTH(awards)=0, '{$awards}', awards),\n\t\t\t\tposter = IF(LENGTH(poster)=0, '{$poster}', poster),\n\t\t\t\tboxOffice = IF(LENGTH(boxOffice)=0, '{$boxOffice}', boxOffice),\n\t\t\t\tWebsite = IF(LENGTH(Website)=0, '{$website}', Website)\n\t\t\t\tWHERE movieId = '" . mysql_real_escape_string($movieId) . "'"; echo $movieInfoInsertQuery; /*$movieInfoInsertQuery = "UPDATE `movieinfo` SET `rated` = IF(`rated` IS NULL, '$rated', `rated`), `releaseDate` = '$releaseDate', `runtime` = '$runtime', `genre` = '$genre', `director` = '$director', `writer` = '$writer', `actors` = '$actors', `plot` = '$plot', `language` = '$language', `country` = '$country', `awards` = '$awards', `poster` = '$poster', `boxOffice` = '$boxOffice', `Website` = '$website' WHERE `movieId = '$movieId'";*/ $tomatoInsertQuery = "UPDATE `tomato` SET \n\t\t\t\ttomatoMeter = '{$tomatoMeter}',\n\t\t\t\ttomatoImage = '{$tomatoImage}',\n\t\t\t\ttomatoRating = '{$tomatoRating}', \n\t\t\t\ttomatoReviews = '{$tomatoReviews}', \n\t\t\t\ttomatoFresh = '{$tomatoFresh}', \n\t\t\t\ttomatoRotten = '{$tomatoRotten}', \n\t\t\t\ttomatoUserMeter = '{$tomatoUserMeter}', \n\t\t\t\ttomatoUserRating = '{$tomatoUserRating}', \n\t\t\t\ttomatoUserReviews = '{$tomatoUserReviews}' \n\t\t\t\tWHERE movieId = '" . mysql_real_escape_string($movieId) . "'"; $linksInsertQuery = "UPDATE `links` SET \n\t\t\t\timdbLink = '{$imdbLink}'\n\t\t\t\tWHERE movieId = '" . mysql_real_escape_string($movieId) . "'"; $imdbInsertQuery = "UPDATE `imdb` SET \n\t\t\t\tmetaCriticScore = '{$metascore}'\n\t\t\t\tWHERE movieId = '" . mysql_real_escape_string($movieId) . "'"; if (IsEmpty($movieInfoRow['poster'])) { $posterQuery = "UPDATE `movieinfo` SET \n\t\t\t\t\t\tposter = '{$poster}'\n\t\t\t\t\t\tWHERE movieId = '" . mysql_real_escape_string($movieId) . "'"; mysqli_query($conn, $posterQuery) or die(mysqli_error($conn)); } if (!mysqli_query($conn, $movieInfoInsertQuery)) { die('Error: ' . mysqli_error($conn)); } echo "movieinfo updated, "; if (!mysqli_query($conn, $tomatoInsertQuery)) { die('Error: ' . mysqli_error($conn)); } echo "tomato updated, "; if (!mysqli_query($conn, $linksInsertQuery)) { die('Error: ' . mysqli_error($conn)); } echo "links updated, "; if (!mysqli_query($conn, $imdbInsertQuery)) { die('Error: ' . mysqli_error($conn)); } echo "imdb updated, "; echo "<br>"; /*mysqli_query($conn, $movieInfoInsertQuery) or die(mysqli_error($conn)); mysqli_query($conn, $imdbInsertQuery)or die(mysqli_error($conn)); mysqli_query($conn, $linksInsertQuery)or die(mysqli_error($conn)); mysqli_query($conn, $tomatoInsertQuery)or die(mysqli_error($conn));*/ } }
} //echo $counterFromUser; //echo $counterFromTitle; //echo $counterFromDescription++; } else { $articles[] = array('title' => (string) $item->title, 'description' => (string) $item->description, 'link' => (string) $item->link, 'date' => (string) $item->pubDate, 'image' => $image); } } } return $articles; //print out all objects of "articles" } if (!isset($_POST['submit'])) { //echo "Please input a key word 4" . "<br>"; } else { if (!IsEmpty($_POST['searchWord']) && isset($_COOKIE["SavedUserInfo"]) && $_COOKIE["SavedUserInfo"] != "999999999") { $inputWord = $_POST['searchWord']; $sInsertUser = $_COOKIE["SavedUserInfo"]; mysql_query("INSERT INTO accounts (`ID`, `ACCOUNT_NUMBER`, `USERNAME`, `EMAIL`, `PASSWORD`, `CREATED_DATE`, `KEYWORD`)\r\n\t\t\t\t\tVALUE(NULL, '{$sInsertUser}', '0', '0', '0', '0', '{$inputWord}')") or die(mysql_error()); echo "Input is added successfully"; } } if (!isset($_POST['submitAccount'])) { //echo "Please input a key word 2"; } else { $userName = $_POST['username']; $emailLocal = $_POST['email']; $passWord = $_POST['password']; date_default_timezone_set('America/Los_Angeles'); //$timezone = date_default_timezone_get(); $timezone = date("Y-m-d");
function rawman_editbox($pic) { // Reading params and settting form fields $par = rawman_mkdir(array(rawman_getpicdir($pic), 'param')) . $pic . '.txt'; $opt = rawman_convparams($par, array('rating' => 0, 'coloring' => 'none', 'wb' => 'camera', 'rotate' => 'none')); if (preg_match('/\\-b\\s+(\\d\\.\\d+)\\b/', $opt['dcraw'], $m)) { _fsine(array('brightness' => $m[1])); } if (IsEmpty($opt['wb']) && preg_match('/\\-a\\b/', $opt['dcraw'], $m)) { $opt['wb'] = 'auto'; } if (preg_match('/\\-gamma\\s+(\\d\\.\\d+)\\b/', $opt['cnvpre'], $m)) { _fsine(array('gamma' => $m[1])); } if (preg_match('/\\-t\\s+(\\d+)\\b/', $opt['dcraw'], $m)) { $opt['rotate'] = $m[1] == 270 ? 'left' : 'right'; } elseif (preg_match('/\\-rotate\\s+(\\d+)\\b/', $opt['cnvpre'], $m)) { $opt['rotate'] = $m[1] == 270 ? 'left' : 'right'; } $arr_ev = array('-2.00', '-1.66', '-1.50', '-1.33', '-1.00', '-0.66', '-0.50', '-0.33', '0.00', '+0.33', '+0.50', '+0.66', '+1.00', '+1.33', '+1.50', '+1.66', '+2.00'); $arr_high = array(0 => '0 - White', 1 => '1 - Pink', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9'); _fsine(array('ev' => '+0.33', 'rotate' => $opt['rotate'])); echo ' <form name="editForm">' . CreateHiddenField('balance', $opt['wb']) . rawman_wb($opt['wb'], true) . '<p style="clear:both;"></p> <ul> <li>Ekspozycja: ' . CreateSelectField('ev', $arr_ev, 0) . 'EV</li> <li>Jasność: ' . CreateInputText('brightness', 5) . '</li> <li>Gamma: ' . CreateInputText('gamma', 5) . '</li> <li>Ziarno: ' . CreateInputText('noise', 5) . '</li> <li>Odbłyski: ' . CreateSelectField('highlight', $arr_high) . '</li> </ul> ' . '<p style="clear:both;"></p>' . CreateHiddenField('rotate', $opt['rotate']) . rawman_rotate($opt['rotate'], true) . '<p style="clear:both;"></p>' . CreateButton('preview', 'View', 'onclick="editImg()"') . CreateButton('cancel', 'Cancel', 'onclick="rmSendReq(\'' . rmconf('elem-dir') . '/info\')"') . CreateButton('apply', 'Apply', 'onclick="applyImg()"') . '</form>'; }
function getRecent() { require "../includes/connect.php"; //require("../functions/string.php"); /* find title of each recently released movie then put into omdb */ //xml /*<RESPONSE_DATA> <FILE_INFORMATION Order_Number="19222835"> response_data->file_information['Order_Number'] */ $xml = simplexml_load_file("http://api.myapifilms.com/imdb/inTheaters?token=870c3596-fa05-4ced-82cf-a76d58be8a5a&format=xml&language=en-us"); //the "recently released" date $date = htmlentities($xml->data->movies->date); $trim = trim(str_replace(" ", "", $date)); $trim = str_replace(" ", "", $trim); //$rest = substr("abcdef", -1); // returns "f" $day = substr($trim, -2); $month = substr($trim, 0, 3); $year = date("Y"); //echo $date; global $formattedRecentDate; $formattedRecentDate = $day . " " . $month . " " . $year; //echo $formattedRecentDate; //store formatted date for use in recent.php so you dont have to keep calling api $newFileName = '../includes/recentDate.txt'; $appendContent = $formattedRecentDate; //If filename does not exist, the file is created. Otherwise, the existing file is overwritten, unless the FILE_APPEND flag is set. if (file_put_contents($newFileName, $appendContent) != false) { echo "File created (" . basename($newFileName) . ")"; } else { echo "Cannot create file (" . basename($newFileName) . ")"; } $zeroOrOne; //for($zeroOrOne=0; $zeroOrOne <=1; $zeroOrOne++){ for ($zeroOrOne = 0; $zeroOrOne <= 0; $zeroOrOne++) { //use this to skip first row (blank) $b = false; //movies[0] is the array for recently released, [1] is in theatres now foreach ($xml->data->movies[$zeroOrOne] as $movie) { if (!$b) { $b = true; continue; } //insert to omdb if not already found //rating is imdb rating $title = htmlentities($movie->title); echo $title . "<br>"; if (empty($title)) { continue; } //echo $title .'<br>'; $selectQuery = "SELECT movieId FROM moviename"; $selectResult = mysqli_query($conn, $selectQuery); $exists = 0; while ($row = mysqli_fetch_array($selectResult)) { if (fuzzy_match($title, $row['movieId'])) { $exists = 1; break; } } if ($exists == 1) { if ($zeroOrOne == 1) { $movieId = str_replace(" ", "+", $title); $theatreInsertQurey = "INSERT INTO `intheatres` (`movieId`) VALUES ('{$movieId}')"; mysqli_query($conn, $theatreInsertQurey) or die(mysqli_error($conn)); } continue; } else { //print("not found"); //insert /*MYAPIFILMS*/ //format is 20151113 if ($zeroOrOne == 0) { $releaseDate = $formattedRecentDate; } else { if ($zeroOrOne == 1) { //format is 20151113 $releaseDate = $movie->releaseDate; $day = substr($releaseDate, -2); $monthNum = substr($releaseDate, 5, 6); $monthName = date("F", mktime(0, 0, 0, $monthNum, 15)); $month = substr($monthName, 0, 3); $year = substr($releaseDate, 0, 4); $releaseDate = $day . " " . $month . " " . $year; } } //movieId $movieId = mysqli_real_escape_string($conn, str_replace(" ", "+", $title)); //rated $rated = htmlentities($movie->rated); //runtime $runtime = htmlentities($movie->runtime); //plot $plot = mysqli_real_escape_string($conn, htmlentities($movie->plot)); //poster $poster = $movie->urlPoster; echo $poster . "<br>"; //download downloadPoster($movieId, $poster); //imdblink $imdbLink = $movie->urlIMDB; $metascore = substr($movie->metascore, 0, -4); $imdbRating = $movie->rating; $imdbVotes = $movie->votes; $imdbID = $movie->idIMDB; try { //genre $genreList = ""; foreach ((array) $movie->genres->genre as $genre) { $temp = (string) $genre; $genreList = $genreList . $temp . " "; } $genreList = trim($genreList); $genre = $genreList; } catch (Exception $e) { //echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if (IsEmpty($movieId)) { continue; } //@ to suppress warnings and notices... /*OMDB API -DOESNT EXIST FOR ALL MOVIES*/ $omdbXml = @simplexml_load_file("http://www.omdbapi.com/?t=" . $movieId . "&y=" . $year . "&plot=full&r=xml&tomatoes=true"); $director = ""; $writer = ""; $language = ""; $country = ""; $actors = ""; $website = ""; $boxOffice = ""; $awards = ""; $tomatoMeter = ""; $tomatoImage = ""; $tomatoRating = ""; $tomatoReviews = ""; $tomatoFresh = ""; $tomatoRotten = ""; $tomatoUserMeter = ""; $tomatoUserRating = ""; $tomatoUserReviews = ""; if (@$omdbXml->root['response'] == "False") { // throw new Exception("Cannot load xml source.\n"); $director = ""; $writer = ""; $language = ""; $country = ""; $actors = ""; $website = ""; $boxOffice = ""; $awards = ""; $tomatoMeter = ""; $tomatoImage = ""; $tomatoRating = ""; $tomatoReviews = ""; $tomatoFresh = ""; $tomatoRotten = ""; $tomatoUserMeter = ""; $tomatoUserRating = ""; $tomatoUserReviews = ""; } else { //$genre = $omdbXml->movie['genre']; $director = @$omdbXml->movie['director']; //$releaseDate = $omdbXml->movie['released']; $writer = @$omdbXml->movie['writer']; $language = @$omdbXml->movie['language']; $country = @$omdbXml->movie['country']; $actors = @$omdbXml->movie['actors']; $website = @$omdbXml->movie['Website']; $boxOffice = @$omdbXml->movie['boxOffice']; $awards = @$omdbXml->movie['awards']; //omdb tomato $tomatoMeter = @$omdbXml->movie['tomatoMeter']; $tomatoImage = @$omdbXml->movie['tomatoImage']; $tomatoRating = @$omdbXml->movie['tomatoRating']; $tomatoReviews = @$omdbXml->movie['tomatoReviews']; $tomatoFresh = @$omdbXml->movie['tomatoFresh']; $tomatoRotten = @$omdbXml->movie['tomatoRotten']; $tomatoUserMeter = @$omdbXml->movie['tomatoUserMeter']; $tomatoUserRating = @$omdbXml->movie['tomatoUserRating']; $tomatoUserReviews = @$omdbXml->movie['tomatoUserReviews']; } $myApiFilmsUrl = "http://api.myapifilms.com/imdb/idIMDB?idIMDB=" . $imdbID . "&token=870c3596-fa05-4ced-82cf-a76d58be8a5a&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&trailer=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0"; $json = file_get_contents($myApiFilmsUrl); $data = json_decode($json, true); //true for array format if (IsEmpty($plot)) { $plot = mysqli_real_escape_string($conn, $data['data']['movies'][0]['plot']); } $imdbLink = $data['data']['movies'][0]['urlIMDB']; if (IsEmpty($poster)) { $poster = $data['data']['movies'][0]['urlPoster']; } if (!IsEmpty($poster)) { //download downloadPoster($movieId, $poster); } $subtitleLink = 'http://www.opensubtitles.org/en/search2/sublanguageid-all/moviename-' . $movieId; //cant find $tomatoLink = ""; $tmdbLink = ""; $youtubeLink = ""; $movieInfoInsertQuery = "INSERT INTO `movieinfo` (`movieId`, `rated`, `releaseDate`, `runtime`, `genre`, `director`, `writer`, `actors`, `plot`, `language`, `country`, `awards`, `poster`, `boxOffice`, `Website`, `Screenshots`) VALUES ('{$movieId}', '{$rated}', '{$releaseDate}', '{$runtime}', '{$genre}', '{$director}', '{$writer}', '{$actors}', '{$plot}', '{$language}', '{$country}', '{$awards}', '{$poster}', '{$boxOffice}', '{$website}', '{$boxOffice}')"; $movieNameInsertQuery = "INSERT INTO `moviename` (`movieId`, `name`) VALUES ('{$movieId}', '{$title}')"; $imdbInsertQuery = "INSERT INTO `imdb` (`movieId`, `metaCriticScore`, `imdbRating`, `imdbVotes`, `imdbID`) VALUES ('{$movieId}', '{$metascore}', '{$imdbRating}', '{$imdbVotes}', '{$imdbID}')"; $linksInsertQuery = "INSERT INTO `links` (`movieId`, `youtubeLink`, `imdbLink`, `tomatoLink`, `subtitleLink`) VALUES ('{$movieId}', '{$youtubeLink}', '{$imdbLink}', '{$tomatoLink}','{$subtitleLink}')"; $tomatoInsertQuery = "INSERT INTO `tomato` (`movieId`,`tomatoMeter`, `tomatoImage`, `tomatoRating`, `tomatoReviews`, `tomatoFresh`, `tomatoRotten`, `tomatoUserMeter`,`tomatoUserRating`, `tomatoUserReviews`) VALUES ('{$movieId}', '{$tomatoMeter}', '{$tomatoImage}', '{$tomatoRating}', '{$tomatoReviews}', '{$tomatoFresh}', '{$tomatoRotten}','{$tomatoUserMeter}', '{$tomatoUserRating}', '{$tomatoUserReviews}')"; if ($zeroOrOne == 1) { $theatreInsertQurey = "INSERT INTO `intheatres` (`movieId`) VALUES ('{$movieId}')"; mysqli_query($conn, $theatreInsertQurey) or die(mysqli_error($conn)); } mysqli_query($conn, $movieInfoInsertQuery) or die(mysqli_error($conn)); mysqli_query($conn, $movieNameInsertQuery) or die(mysqli_error($conn)); mysqli_query($conn, $imdbInsertQuery) or die(mysqli_error($conn)); mysqli_query($conn, $linksInsertQuery) or die(mysqli_error($conn)); mysqli_query($conn, $tomatoInsertQuery) or die(mysqli_error($conn)); } } } }
function newMovie($title) { //require("connect.php"); //require("string.php"); $movieId = str_replace(" ", "+", $title); $movieId = mysqli_real_escape_string($conn, $movieId); //in case of apostrophes etc. //@ to suppress warnings and notices... /*OMDB API -DOESNT EXIST FOR ALL MOVIES*/ $omdbXml = @simplexml_load_file("http://www.omdbapi.com/?t=" . urlencode($movieId) . "&plot=full&r=xml&tomatoes=true"); $poster = ""; $metascore = ""; $imdbRating = ""; $imdbVotes = ""; $imdbID = ""; $runtime = ""; $plot = ""; $releaseDate = ""; $rated = ""; $genre = ""; $director = ""; $writer = ""; $language = ""; $country = ""; $actors = ""; $website = ""; $boxOffice = ""; $awards = ""; $tomatoMeter = ""; $tomatoImage = ""; $tomatoRating = ""; $tomatoReviews = ""; $tomatoFresh = ""; $tomatoRotten = ""; $tomatoUserMeter = ""; $tomatoUserRating = ""; $tomatoUserReviews = ""; $imdbLink = ""; //echo $omdbXml->attributes()->response; if (@$omdbXml->root['response'] == "False") { echo "movie not found in omdb"; // throw new Exception("Cannot load xml source.\n"); $poster = ""; $metascore = ""; $imdbRating = ""; $imdbVotes = ""; $imdbID = ""; $runtime = ""; $plot = ""; $releaseDate = ""; $rated = ""; $genre = ""; $rated = ""; $genre = ""; $director = ""; $writer = ""; $language = ""; $country = ""; $actors = ""; $website = ""; $boxOffice = ""; $awards = ""; $tomatoMeter = ""; $tomatoImage = ""; $tomatoRating = ""; $tomatoReviews = ""; $tomatoFresh = ""; $tomatoRotten = ""; $tomatoUserMeter = ""; $tomatoUserRating = ""; $tomatoUserReviews = ""; $imdbLink = ""; } else { //$genre = $omdbXml->movie['genre']; $director = mysqli_real_escape_string($conn, htmlentities(@$omdbXml->movie['director'])); //$releaseDate = $omdbXml->movie['released']; $writer = mysqli_real_escape_string($conn, htmlentities(@$omdbXml->movie['writer'])); $language = @$omdbXml->movie['language']; $country = @$omdbXml->movie['country']; $actors = mysqli_real_escape_string($conn, htmlentities(@$omdbXml->movie['actors'])); $website = @$omdbXml->movie['Website']; $boxOffice = @$omdbXml->movie['boxOffice']; $awards = @$omdbXml->movie['awards']; //omdb tomato $tomatoMeter = @$omdbXml->movie['tomatoMeter']; $tomatoImage = @$omdbXml->movie['tomatoImage']; $tomatoRating = @$omdbXml->movie['tomatoRating']; $tomatoReviews = @$omdbXml->movie['tomatoReviews']; $tomatoFresh = @$omdbXml->movie['tomatoFresh']; $tomatoRotten = @$omdbXml->movie['tomatoRotten']; $tomatoUserMeter = @$omdbXml->movie['tomatoUserMeter']; $tomatoUserRating = @$omdbXml->movie['tomatoUserRating']; $tomatoUserReviews = @$omdbXml->movie['tomatoUserReviews']; $metascore = @$omdbXml->movie['metascore']; $imdbRating = @$omdbXml->movie['imdbRating']; $imdbVotes = @$omdbXml->movie['imdbVotes']; $imdbID = @$omdbXml->movie['imdbID']; $runtime = @$omdbXml->movie['runtime']; $plot = mysqli_real_escape_string($conn, @$omdbXml->movie['plot']); $releaseDate = @$omdbXml->movie['releaseDate']; $rated = @$omdbXml->movie['rated']; $genre = @$omdbXml->movie['genre']; $poster = @$omdbXml->movie['poster']; $imdbLink = ""; } if (!IsEmpty($imdbID)) { echo "getting myapi films "; $myApiFilmsUrl = "http://api.myapifilms.com/imdb/idIMDB?idIMDB=" . $imdbID . "&token=870c3596-fa05-4ced-82cf-a76d58be8a5a&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&trailer=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0"; $json = file_get_contents($myApiFilmsUrl); $data = json_decode($json, true); //true for array format if (IsEmpty($plot)) { $plot = mysqli_real_escape_string($conn, $data['data']['movies'][0]['plot']); } $imdbLink = $data['data']['movies'][0]['urlIMDB']; if (IsEmpty($poster)) { $poster = $data['data']['movies'][0]['urlPoster']; //$poster = 'http://ia.media-imdb.com/images/M/MV5BMTAzNjU4MzYwNDdeQTJeQWpwZ15BbWU4MDg3NTEzMjcx._V1_SY317_CR0,0,214,317_AL_.jpg'; } echo "poster is" . IsEmpty($poster); if (!IsEmpty($poster)) { //download echo "download poster"; downloadPoster($movieId, $poster); } } $subtitleLink = 'http://www.opensubtitles.org/en/search2/sublanguageid-all/moviename-' . $movieId; //cant find $tomatoLink = ""; $tmdbLink = ""; $youtubeLink = ""; if (IsEmpty($movieId)) { return; } $title = mysqli_real_escape_string($conn, $title); $movieInfoInsertQuery = "INSERT INTO `movieinfo` (`movieId`, `rated`, `releaseDate`, `runtime`, `genre`, `director`, `writer`, `actors`, `plot`, `language`, `country`, `awards`, `poster`, `boxOffice`, `Website`, `Screenshots`) VALUES ('{$movieId}', '{$rated}', '{$releaseDate}', '{$runtime}', '{$genre}', '{$director}', '{$writer}', '{$actors}', '{$plot}', '{$language}', '{$country}', '{$awards}', '{$poster}', '{$boxOffice}', '{$website}', '{$boxOffice}')"; $movieNameInsertQuery = "INSERT INTO `moviename` (`movieId`, `name`) VALUES ('{$movieId}', '{$title}')"; $imdbInsertQuery = "INSERT INTO `imdb` (`movieId`, `metaCriticScore`, `imdbRating`, `imdbVotes`, `imdbID`) VALUES ('{$movieId}', '{$metascore}', '{$imdbRating}', '{$imdbVotes}', '{$imdbID}')"; $linksInsertQuery = "INSERT INTO `links` (`movieId`, `youtubeLink`, `imdbLink`, `tomatoLink`, `subtitleLink`) VALUES ('{$movieId}', '{$youtubeLink}', '{$imdbLink}', '{$tomatoLink}','{$subtitleLink}')"; $tomatoInsertQuery = "INSERT INTO `tomato` (`movieId`,`tomatoMeter`, `tomatoImage`, `tomatoRating`, `tomatoReviews`, `tomatoFresh`, `tomatoRotten`, `tomatoUserMeter`,`tomatoUserRating`, `tomatoUserReviews`) VALUES ('{$movieId}', '{$tomatoMeter}', '{$tomatoImage}', '{$tomatoRating}', '{$tomatoReviews}', '{$tomatoFresh}', '{$tomatoRotten}','{$tomatoUserMeter}', '{$tomatoUserRating}', '{$tomatoUserReviews}')"; mysqli_query($conn, $movieInfoInsertQuery) or die(mysqli_error($conn)); echo "info d "; mysqli_query($conn, $movieNameInsertQuery) or die(mysqli_error($conn)); echo "name d "; mysqli_query($conn, $imdbInsertQuery) or die(mysqli_error($conn)); echo "imdb d "; mysqli_query($conn, $linksInsertQuery) or die(mysqli_error($conn)); echo "links d "; mysqli_query($conn, $tomatoInsertQuery) or die(mysqli_error($conn)); echo "tomato d <br>"; }
$date = $_POST["fecha"]; $email = $_POST["email"]; $pais = strtoupper($_POST["pais"]); $estado = strtoupper($_POST["estado"]); $municipio = strtoupper($_POST["municipio"]); $parroquia = strtoupper($_POST["parroquia"]); if (IsEmpty("select luga_codigo from lugar where luga_nombre='" . $pais . "'")) { Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $pais . "','pais',null)"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $estado . "','estado',(select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $municipio . "','municipio',(select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado'))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $parroquia . "','parroquia',(select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio'))"); } elseif (IsEmpty("select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')")) { Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $estado . "','estado',(select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $municipio . "','municipio',(select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $parroquia . "','parroquia',(select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))))"); } elseif (IsEmpty("select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))")) { Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $municipio . "','municipio',(select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $parroquia . "','parroquia',(select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))))"); } elseif (IsEmpty("select LUGA_codigo from lugar where luga_nombre='" . $parroquia . "' and luga_tipo='parroquia' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))")) { Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $parroquia . "','parroquia',(select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))))"); } Query("update propietario set prop_nombre='" . $nombre . "',prop_apellido='" . $apellido . "',prop_cedula=" . $ci . ",prop_fecha_nac=to_date('" . $date . "','yyyy-mm-dd'),prop_email='" . $email . "',fk_luga=(select LUGA_codigo from lugar where luga_nombre='" . $parroquia . "' and luga_tipo='parroquia' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))) where prop_codigo=" . $codigo); Disconnect(); //* echo "<script type=\"text/javascript\">\n\t\t\t\t\talert(\"Se ha modificado exitosamente\");\n\t\t\t\t\twindow.location.href=\"../index.php\"\n\t\t\t\t</script>"; //*/ } } catch (Exception $e) { echo "Message: " . $e->getMessage(); } }
function CreateCheckOne($name, $desc, $params = '') { global $form; return sprintf('<input type="checkbox" id="form-%s" name="form[%s]" value="1" %s %s /> %s ', $name, $name, RetIf(!IsEmpty($form[$name]), 'checked="checked"'), RetIf(!IsEmpty($params), $params), $desc); }
Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $estado . "','estado',(select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $municipio . "','municipio',(select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $parroquia . "','parroquia',(select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))))"); } elseif (IsEmpty("select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))")) { Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $municipio . "','municipio',(select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))"); Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $parroquia . "','parroquia',(select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))))"); } elseif (IsEmpty("select LUGA_codigo from lugar where luga_nombre='" . $parroquia . "' and luga_tipo='parroquia' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))")) { Query("insert into lugar values (SQ_LUGA_codigo.nextval,'" . $parroquia . "','parroquia',(select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais'))))"); } if (IsEmpty("select hara_codigo from haras where hara_nombre='" . $haras . "'")) { Query("insert into haras values (sq_hara_codigo.nextval,'" . $haras . "',(select LUGA_codigo from lugar where luga_nombre='" . $parroquia . "' and luga_tipo='parroquia' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $municipio . "' and luga_tipo='municipio' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $estado . "' and luga_tipo='estado' and fk_luga = (select LUGA_codigo from lugar where luga_nombre='" . $pais . "' and luga_tipo='pais')))))"); } if (IsEmpty("select caba_codigo from caballeriza where caba_numero = '" . $caballeriza . "'")) { Query("insert into caballeriza values (sq_caba_codigo.nextval,'" . $caballeriza . "','" . $entr . "','" . $vete . "')"); } if (IsEmpty("select pues_codigo from puesto, caballeriza where pues_numero = '" . $puesto . "' and caba_numero = '" . $caballeriza . "' and fk_caba = caba_codigo")) { if ($ffin == null) { Query("insert into puesto (pues_codigo,pues_fecha_inicio,pues_numero,fk_caba) values (sq_pues_codigo.nextval,to_date('" . $fini . "','yyyy-mm-dd'),'" . $puesto . "',(select CABA_codigo from CABALLERIZA WHERE CABA_numero='" . $caballeriza . "'))"); } else { Query("insert into puesto values (SQ_PUES_codigo.nextval,to_date('" . $fini . "','yyyy/mm/dd'),to_date('" . $ffin . "','yyyy/mm/dd'),'" . $puesto . "',(select CABA_codigo from CABALLERIZA WHERE CABA_numero='" . $caballeriza . "'))"); } } if ($raza == null) { $raza = null; } if ($padre == null) { $padre = null; } if ($madre == null) { $madre = null; }
function updateRating($i) { echo $i; require "../includes/connect.php"; $updateDate = new DateTime(); $updateDate = $updateDate->format('Y-m-d'); //convert to dd/mm/yyyy //$oldDate = $updateDate; //$timestamp = strtotime($oldDate); //$updateDate = date('d/m/Y', $timestamp); //$selectQuery = "SELECT imdbID FROM imdb"; $rowCountQuery = "SELECT COUNT(*) FROM imdb"; $rowCount = mysqli_query($conn, $rowCountQuery); $rowCountRow = mysqli_fetch_array($rowCount); $rowCount = $rowCountRow[0]; echo "number of rows is " . $rowCount . "<br>"; $count = ceil($rowCount / 2); echo "updating " . $count . " rows<br>"; if ($i == 1) { $selectQuery = "SELECT imdbID FROM imdb LIMIT {$count}"; } else { if ($i == 2) { //(SELECT * FROM table ORDER BY id DESC LIMIT 50) ORDER BY id ASC $selectQuery = "SELECT * FROM (\n\t\t\t\t\t\t\t SELECT * FROM imdb ORDER BY movieId DESC LIMIT {$count}\n\t\t\t\t\t\t\t) sub\n\t\t\t\t\t\t\tORDER BY movieId ASC"; } } $selectResult = mysqli_query($conn, $selectQuery) or die(mysqli_error($conn)); while ($row = mysqli_fetch_array($selectResult)) { //if no imdbID then ignore. if (IsEmpty($row['imdbID'])) { continue; } //ob_start(); $id = $row['imdbID']; $url = "http://api.myapifilms.com/imdb/idIMDB?idIMDB=" . $id . "&token=870c3596-fa05-4ced-82cf-a76d58be8a5a&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&trailer=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0"; $json = file_get_contents($url); $data = json_decode($json, true); //true for array format //print_r to see the json in array for so you know how to parse if (isset($data['data']['movies'][0]['rating'])) { $rating = str_replace(",", ".", $data['data']['movies'][0]['rating']); $votes = preg_replace('/[^\\d]+/i', '', $data['data']['movies'][0]['votes']); } else { continue; } $updateQuery = "UPDATE `imdb` SET imdbRating = '{$rating}', imdbVotes = '{$votes}' WHERE imdbID = '{$id}'"; mysqli_query($conn, $updateQuery) or die(mysqli_error($conn)); //format (just split by / and :)x //date:rating(imdb):votes,date:rating(imdb):votes, date:rating(imdb):votes, .. $newFileName = '../ratings/' . $id . ".php"; $appendContent = $updateDate . ":" . $rating . ":" . $votes . "/"; //if file doesnt exist /*if (!file_exists($newFileName)) { $headings = "date,rating,votes\n"; file_put_contents($newFileName,$headings, FILE_APPEND); }*/ /* date,close,open 1-May-12,58.13,3.41 30-Apr-12,53.98,4.55 27-Apr-12,67.00,6.78 */ //$appendContent = $updateDate.",". $rating.",". $votes."\n"; //If filename does not exist, the file is created. Otherwise, the existing file is overwritten, unless the FILE_APPEND flag is set. if (file_put_contents($newFileName, $appendContent, FILE_APPEND) != false) { echo "File created (" . basename($newFileName) . ")"; } else { echo "Cannot create file (" . basename($newFileName) . ")"; } // //echo ob_get_contents(); //ob_end_flush(); } mysqli_close($conn); }
function calcAverageRating($meta, $imdb, $tomato, $tomatoUser) { echo "--- meta = {$meta}, imdb={$imdb}, tomato={$tomato}, tomatouser={$tomatouser}"; if (IsEmpty($meta) or IsEmpty($imdb) or IsEmpty($tomato) or IsEmpty($tomatoUser)) { //$average = "N/A"; if (IsEmpty($meta) and IsEmpty($tomato) and IsEmpty($tomatoUser)) { echo "--empty meta, empty tomato, empty tomatouser"; $average = intval($imdb) * 10; } else { if (IsEmpty($imdb) and IsEmpty($tomato) and IsEmpty($tomatoUser)) { echo "--empty imdb, empty tomato, empty tomatouser"; $average = $meta; } else { if (IsEmpty($meta) and IsEmpty($imdb) and IsEmpty($tomato)) { echo "--empty meta, imdb, tomato"; $average = $tomatoUser / 5 * 100; } else { if (IsEmpty($tomato) and IsEmpty($tomatoUser)) { echo "--empty tomato, tomatouser "; $metaWeighting = $meta / 100 * 50; $imdbWeighting = $imdb / 10 * 50; $average = $metaWeighting + $imdbWeighting; } else { if (IsEmpty($meta)) { echo "--empty meta"; $imdbWeighting = $imdb / 10 * 50; $tomatoWeighting = $tomato / 10 * 34; $tomatoUserWeighting = $tomatoUser / 5 * 16; $average = $imdbWeighting + $tomatoWeighting + $tomatoUserWeighting; } else { if (IsEmpty($tomato)) { echo "--empty tomato"; $metaWeighting = $meta / 100 * 33; $imdbWeighting = $imdb / 10 * 34; $tomatoUserWeighting = $tomatoUser / 5 * 33; $average = $metaWeighting + $imdbWeighting + $tomatoUserWeighting; } else { echo "--ALL EMPTY"; $average = 0; } } } } } } } else { echo "--no empty"; $metaWeighting = $meta / 100 * 25; $imdbWeighting = $imdb / 10 * 25; $tomatoWeighting = $tomato / 10 * 34; $tomatoUserWeighting = $tomatoUser / 5 * 16; $average = $metaWeighting + $imdbWeighting + $tomatoWeighting + $tomatoUserWeighting; } echo "---average = {$average} ---<br>"; return $average; }