Calendar Backup

[insert_php]
$parms = “yes”;
if($_GET[“prod”] == “”) $parms = “no”;
$prod = “‘” . $_GET[‘prod’] . “‘”;
$person = $_GET[‘person’] ;
$start = $_GET[‘start’] ;

if ($person <> “”) {

$pers = str_replace(“~”,” “,$person);
$pers = str_replace(“\'”,”‘”,$pers);
$pers = str_replace(“^”,”&”,$pers);
echo “ Performance Schedule for ” . “” . $pers . ““;

};

$showparm = ““];

date_default_timezone_set(“America/New_York”);

$mysqli = new mysqli(‘localhost’, ‘lictc_user’, ‘lictc’, ‘lictc’);

if ($mysqli->connect_error) {
die(‘Connect Error (‘ . $mysqli->connect_errno . ‘) ‘
. $mysqli->connect_error);
}

$today = date(“Y-m-d”);
$startday = $today;
if ($start <> “”) {
$startday = $start;
}
if ($startday < $today) { $startday = $today; } $enddate = date("Y-m-t", strtotime($startday)); $nextstring = $enddate . " +1 day"; $nextmonth = date("Y-m-d",strtotime("$nextstring")); $startdate = date("Y-m-1",strtotime($startday)); $prevstring = $startdate . " -1 month"; $prevmonth = date("Y-m-01",strtotime("$prevstring")); if ($parms == "no") { $sql = "SELECT Times.Date, Times.Time, Times.TVenue, Times.TAddress, Times.TTown, Performances.Production, Performances.ShowName, Performances.Company, Performances.Venue, Performances.Address, Performances.Town, Performances.TicketURL from `Performances` INNER JOIN Times ON Times.Production = Performances.Production where Date >=’$startday’ and Date <= '$enddate' and Performances.Status = 'active' order by Times.Date, Times.Time"; } else { $sql = "SELECT Times.Date, Times.Time, Times.TVenue, Times.TAddress, Times.TTown, Performances.Production, Performances.ShowName, Performances.Company, Performances.Venue, Performances.Address, Performances.Town, Performances.TicketURL from `Performances` INNER JOIN Times ON Times.Production = Performances.Production where Date >= ‘$today’ and Performances.Production = $prod
order by Times.Date, Times.Time”;
}

$result = $mysqli->query($sql);
$olddate = “old”;
$oldmonth = “old”;

if ($result->num_rows > 0) {
// output data of each row

echo “

“;
echo “

“;
echo “

“;
echo “

“;

$once = 0;
while($row = $result->fetch_assoc()) {

// Purchase ticket button
$ticketURL = $row[“TicketURL”];
if ($ticketURL <> “” and $person <> “” and $once == 0) {
$href = “location.href=’http://” . $ticketURL .”‘”;
echo “

” ;
}
$once = 1;

$showparm = ““;

$TVenue = $row[“TVenue”] ;
$Venue = $row[“Venue”];
if ($TVenue <> “”) {
$mapparm = “
“;
} else {
$mapparm = “
“;
}
$company = $row[“Company”];
$companyx = trim($company,” “);
$companyx = str_replace(” “,”~”,$companyx);
$companyparm = “
” ;

$mm = substr($row[“Date”],5,2);
$dd = substr($row[“Date”],8,2);
$yy = substr($row[“Date”],0,4);
$datestring = $row[“Date”];

$dateObj = DateTime::createFromFormat(‘Y-m-d’, $datestring);
$monthName = $dateObj->format(‘F’);
$dayName = $dateObj->format(‘l’);
$monthName = $dateObj->format(‘F’);
$datef = $dayName . ” ” . substr($monthName,0,3) . ” ” . $dd;
$showdatef = $datef;

$time = $row[“Time”];
$d = new DateTime($time);
$timef = $d->format( ‘g:i A’ );

if ($monthName <> $oldmonth) {
if ($prod <> “”” ) {
echo “

“;
} else {
if ($startday <> $today) {
echo “

“;
} else {
echo “

“;
}
}
}
$oldmonth = $monthName;

if ($showdatef <> $olddate) {
echo “

“;
}

$olddate = $datef;

if ($TVenue <> “”) {
if ($TVenue == $company) {
$compphrase = $companyparm . $company . “

“;
} else {
$compphrase = $companyparm . $company . “
” . $TVenue . “
“;
}
echo “

” . “

” . “

” . “

“;
} else {

if ($Venue == $company) {
$compphrase = $companyparm . $company . “
“;
} else {
$compphrase = $companyparm . $company . “
” . $Venue . “
“;
}
echo “

” . “

” . “

” . “

“;
}
}
} else {
echo “[end of list]”;
}
echo “

” .”Click show name for performance details.  Click map icon for map.  Click on company name to see shows performed by that company.” . “
” . “
 
” . “” . $monthName . “
” . “” . “” . $monthName . “  >
” . “” . $monthName . “  >
” . $showdatef . “
” . $timef , “ ” . $showparm . $row[“ShowName”] . “” . “ ” . $mapparm . ” ” . $compphrase . $row[“TAddress”] . “
” . $row[“TTown”] . “
” . $timef , “ ” . $showparm . $row[“ShowName”] . “” . “ ” . $mapparm . ” ” . $compphrase . $row[“Address”] . “
” . $row[“Town”] . “

“;
$mysqli->close();

[/insert_php]