'; include("User/common.php"); include("User/templates.php"); $link=mk_connection(); mysql_select_db("people"); function mk_name($forenames,$surname,$title="") { $forenames=trim($forenames); $initials=""; while ($forenames!="") { $initials=$initials . substr($forenames,0,1) . "."; $spaceat=strpos($forenames . " "," "); $forenames=trim(substr($forenames,$spaceat)); } return StripSlashes("$title $initials $surname"); } function LaTeX_safe($text) { $ans=$text; $ans=str_replace('&','\\&',$text); $ans=str_replace('\\\\','\\hfill\\break',$ans); return $ans; } function HTML_safe($text) { $ans=str_replace('\\\\','
',$text); return $ans; } //first tidyup from previous runs.... //I don't know why the tidying up at the end doesn't always work - timing? $d = opendir("."); while (false !== ($entry = readdir($d))) { if (preg_match("/^semtmp/i",$entry)) unlink($entry); } closedir($d); //Get standard seminar data if (isset($HTTP_GET_VARS['category_id'])) { $category_id=$HTTP_GET_VARS['category_id']; $result=mysql_query(" select p1.id, p2.id as id2, category_id, p1.forenames, p1.surname, p1.title, p1.email, p2.forenames as forenames2, p2.surname as surname2, p2.title as title2, p2.email as email2, usual_room, usual_dow, category_note, LOWER(TIME_FORMAT(usual_time,'%l.%i %p')) as usual_time, s.category from seminar_categories as s left join people as p1 on p1.UNIX_account=s.organiser left join people as p2 on p2.UNIX_account=s.second_organiser where p1.active='-1' and category_id='$category_id'"); if (mysql_num_rows($result)==0) exit("Error! Seminar category $category_id is not defined."); extract(mysql_fetch_assoc($result)); $linkid=$id; $linkid2=$id2; $organiser=mk_name($forenames,$surname,$title); if ($id2<>"") $organiser2=mk_name($forenames2,$surname2,$title2); } else { $today=getdate(); $this_monday=date('jS F Y',mktime(0,0,0,$today['mon'],$today['mday']-$today['wday']+1,$today['year'])); $next_sunday=date('jS F Y',mktime(0,0,0,$today['mon'],$today['mday']-$today['wday']+14,$today['year'])); $mysql_this_sunday=date('Y-m-d',mktime(0,0,0,$today['mon'],$today['mday']-$today['wday']+0,$today['year'])); $mysql_next_monday=date('Y-m-d',mktime(0,0,0,$today['mon'],$today['mday']-$today['wday']+15,$today['year'])); } if (isset($HTTP_GET_VARS['all'])) { $all=$HTTP_GET_VARS['all']; $status_filter="and status<>'1'"; } else { $status_filter="and status='2'"; } if (isset($category_id)) { $result=mysql_query(" select seminars.id, DAYNAME(date) as dow, DATE_FORMAT(date,'%d/%m/%y') as date, date as order_date, LOWER(TIME_FORMAT(time,'%l.%i %p')) as time, speaker, institution, title, abstract_link, abstract, room, note, status, seminar_categories.category as joint_with from seminars,seminar_categories where (seminars.category_id='$category_id' and seminars.joint_id=seminar_categories.category_id $status_filter) or (seminars.joint_id='$category_id' and seminars.category_id=seminar_categories.category_id $status_filter) order by order_date DESC, time"); } else { $result=mysql_query(" select s.id, DAYNAME(date) as dow, DATE_FORMAT(date,'%d/%m/%y') as date, date as real_date, LOWER(TIME_FORMAT(time,'%l.%i %p')) as time, speaker, institution, title, abstract_link, abstract, room, note, sc1.category as category1, sc2.category as category2, sc1.category_id as category_id1, sc2.category_id as category_id2 from seminars as s,seminar_categories as sc1,seminar_categories as sc2 where status='2' and s.category_id=sc1.category_id and s.joint_id=sc2.category_id and date>'$mysql_this_sunday' and date<'$mysql_next_monday' order by real_date,time"); } if (mysql_num_rows($result)>0) { if ($HTTP_GET_VARS['fmt']=='pdf') { if (!isset($all)) $which="Current"; else $which="Current (and \\textcolor{red}{future})"; $filename=tempnam(".","semtmp"); $texfilename=$filename . '.tex'; $logfilename=$filename . '.log'; $auxfilename=$filename . '.aux'; $outfilename=$filename . '.out'; $pdffilename=$filename . '.pdf'; $today=date('jS F Y'); rename($filename,$texfilename); chmod($texfilename,0770); $fp=fopen($texfilename,'w'); fwrite($fp, "\\documentclass[11pt,a4paper,pdftex]{article} \\usepackage{amsfonts} \\usepackage[colorlinks=true,pdfstartview=FitH,linkcolor=blue,citecolor=blue,urlcolor=blue,bookmarks=false]{hyperref} \\setlength{\\textwidth}{8.276in} \\setlength{\\textheight}{11.705in} \\addtolength{\\textwidth}{-2in} \\addtolength{\\textheight}{-2in} \\setlength{\\oddsidemargin}{0pt} \\setlength{\\evensidemargin}{\\oddsidemargin} \\setlength{\\topmargin}{0pt} \\addtolength{\\topmargin}{-\\headheight} \\addtolength{\\topmargin}{-\\headsep} \\pagestyle{empty} \\begin{document} \\begin{center} \LARGE University of Glasgow\\\\Department of Mathematics \\end{center}\n"); $organiser=str_replace(". ",".\\ ",$organiser); $linkid="http://www.maths.gla.ac.uk/people/?id=$linkid"; if ($id2<>"") $linkid2="http://www.maths.gla.ac.uk/people/?id=$linkid2"; if (isset($category_id)) { if ($id2=="") fwrite($fp,"\\section*{{$which} $category seminars} These seminars are organised by \\href{{$linkid}}{{$organiser}}. "); else fwrite($fp,"\\section*{{$which} $category seminars} These seminars are organised by \\href{{$linkid}}{{$organiser}} and \\href{{$linkid2}}{{$organiser2}}. "); if (trim($usual_dow . $usual_time . $usual_room)!=="") fwrite($fp,"Unless otherwise stated, each will take place on a $usual_dow at $usual_time in $usual_room."); if (trim($category_note)!=="") fwrite($fp,"\\par \\bigskip $category_note"); } else { fwrite($fp,"\\section*{Biweekly seminar list} Seminars for the period $this_monday to $next_sunday."); } fwrite($fp,"\\bigskip\\bigskip\\begin{center} \\begin{tabular}{rp{4in}} "); while ($row = mysql_fetch_assoc($result)) { extract($row); if (trim($title)!=="" and trim($title)!=="To be announced") { $title=LaTeX_safe("``\\emph{{$title}}''"); if (trim($abstract_link)!=="") { $title="\href{{abstracts/$abstract_link.pdf}}{{$title}}"; } if (trim($abstract)!=="") { $title="\href{{http://www.maths.gla.ac.uk/events/seminars/mkabs.php?id=$id\\&fmt=pdf}}{{$title}}"; } } $speaker=LaTeX_safe($speaker); $institution=LaTeX_safe($institution); if (trim($room=="")) $room="(Venue to be announced)"; elseif ($room==$usual_room) $room=""; else $room="(in $room)"; if ($dow==$usual_dow) $dow=""; if ($time==$usual_time) $time=""; if (trim($institution)!=="") $institution="($institution)"; if (!isset($category_id)) { $category=$category1; if (trim($category2)!=="None") $category.="/$category2"; fwrite($fp,"\\multicolumn{2}{l}{\\textbf{{$category}}}\\\\"); } elseif (trim($joint_with)!=="None") fwrite($fp,"\\multicolumn{2}{l}{\\textbf{(Joint with the $joint_with seminar)}}\\\\"); if (trim($note)!=="") fwrite($fp,"\\multicolumn{2}{l}{\\textbf{($note)}}\\\\"); if ($status=="3") $speaker="\\textcolor{red}{{$speaker}}"; fwrite($fp,"$time $dow $date & $speaker $institution\\\\ $room &$title\\\\[8pt]\n"); } fwrite($fp,"\\end{tabular} \\end{center} \\flushright{{$today}} \\end{document}"); fclose($fp); # exec("/local/teTeX/bin/pdflatex $texfilename ",$output,$return_value); exec("/usr/bin/pdflatex $texfilename ",$output,$return_value); if ($return_value>0) { $content.="

Error creating PDF!

"; if (isset($all)) { $fp=fopen($logfilename,'r'); $contents = fread ($fp, filesize ($logfilename)); $errors=preg_replace("/(.*)^! U(.*)! E(.*)/ms","U\\2",$contents); fclose($fp); $content.= "

Here is the likely reason for the error:

$errors";
//          fpassthru($fp);
            $content.= "
"; } else { $content.= "

Sorry!. Please let me know about this problem and try the html version instead. $texfilename"; } echo $content; // if (file_exists($texfilename)) unlink($texfilename); if (file_exists($logfilename)) unlink($logfilename); if (file_exists($auxfilename)) unlink($auxfilename); if (file_exists($outfilename)) unlink($outfilename); if (file_exists($pdffilename)) unlink($pdffilename); exit; } header("Content-type: application/pdf"); $fp=fopen($pdffilename,'r'); fpassthru($fp); fclose($fp); unlink($texfilename); unlink($logfilename); unlink($auxfilename); unlink($outfilename); unlink($pdffilename); exit; } //end pdf creation else { $linkid="/people/?id=$linkid"; $linkid2="/people/?id=$linkid2"; if (!isset($all)) $which="Current"; else $which="Current (and future)"; if (isset($category_id)) $semtitle="$which $category seminars"; else $semtitle= 'Biweekly seminar list (' . "$this_monday-$next_sunday" . ')'; if (isset($category_id)) { if ($id2=="") $preamble="These seminars are organised by $organiser. "; else $preamble="These seminars are organised by $organiser and $organiser2. "; } if (trim($usual_dow . $usual_time . $usual_room)!=="") $preamble.="Unless otherwise stated, each will take place on a $usual_dow at $usual_time in $usual_room."; $content=''; while ($row = mysql_fetch_assoc($result)) { extract($row); $tmp_title=TeX2HTML($title); if ($tmp_title) $title=$tmp_title; if (trim($title)!=="" and trim($title)!=="To be announced") { $title='"' . $title . '"'; if (trim($abstract_link)!=="") { $title='' . $title . ''; } if (trim($abstract)!=="") { $title='' . $title . ''; } } if (trim($room=="")) $room="(Venue to be announced)"; elseif ($room==$usual_room) $room=""; else $room="(in $room)"; if ($dow==$usual_dow) $dow=""; if ($time==$usual_time) $time=""; if (trim($institution)!=="") $institution="($institution)"; if (!isset($category_id)) { $category=$category1; $category='' . $category1 . ''; if (trim($category2)!=="None") $category.='/' . $category2 . ''; $content.= "\n"; } elseif (trim($joint_with)!=="None") $content.= "\n"; if (trim($note)!=="") $content.= "\n"; if ($status=="3") $speaker="$speaker"; $content.= "\n "; } $content.='
$category
(Joint with the $joint_with seminar)
$note
$time $dow $date$speaker $institution
$room $title
 
'; if (isset($category_id)) { $cat_bit="category_id=$category_id&"; } if (isset($all)) { $cat_bit.="all=$all&"; } $aspdf=stripslashes("View as PDF"); } } else $linkid="/people/?id=$linkid"; $linkid2="/people/?id=$linkid2"; { if (isset($category_id)) $semtitle="$which $category seminars"; else $semtitle= 'Biweekly seminar list (' . "$this_monday-$next_sunday" . ')'; if (isset($category_id)) $preamble="These seminars are organised by $organiser. "; if (trim($usual_dow) . trim($usual_time) . trim($usual_room) <>"") $preamble.="Unless otherwise stated, each will take place on a $usual_dow at $usual_time in $usual_room.

"; //$content= 'There are currently no seminars on this list.'; $aspdf=''; } $template="../phpTemplates/seminars.dwt"; if (isset($category_id)) $regions["doctitle"]="$category Seminars"; else $regions["doctitle"]="Biweekly seminar list"; $regions["title"]=$semtitle; $regions["preamble"]=$preamble; $regions["note"]=$category_note; $regions["seminars"]=$content; $regions["aspdf"]=$aspdf; // echo fill_out_template($template,$regions); ?>


Other seminars