Documentation is available at chester_export.php
- #!/usr/local/bin/php
- <?php
- /**
- * Chester Export Command-line Script
- *
- * This is a command-line script for exporting registrations to
- * Chester. This script requires three command-line arguments
- * - a CompUnix name
- * - a path to a simple CIB->Chester label file
- * - an email address to mail the results to
- *
- * This file is part of CompInaBox.
- * @package CommandLine-Scripts
- * @author Eric D. Nielsen <nielsene@alum.mit.edu>
- * @copyright CompInaBox Copyright 2005, Eric D. Nielsen. All Rights Reserved.
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @filesource
- */
- /**
- * Include path information.
- */
- include("paths.inc");
- if ($argv[1]=="") die("No Comp Name provided\n");
- if ($argv[2]=="") die("No Comp File provided\n");
- if ($argv[3]=="") die("No email address provided for document delivery\n");
- $unixname=$argv[1];
- if (!ereg("^[-a-zA-Z0-9_]*$",$unixname)) die ("Badly formed compname\n");
- $mailto = $argv[3];
- $CIB_TOOL_ROLE="register";
- include "$CIB_CONFIG_PATH/comps/{$unixname}_config.inc";
- if (!isset($SD_compname)) die ("Invalid Comp Name.");
- include "$CIB_INCLUDE_PATH/tools/SlidingDoors_header.inc";
- ini_alter("include_path", "$CIB_WEB_PATH/$CIB_WEB_INSTALL/$CIB_TOOL_ROLE/$unixname/PREPARSED");
- $partSeperator=md5(uniqid(time()));
- $body.=<<<END_BODY
- This is a MIME Encoded Email\n\n--$partSeperator
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- This email was sent via SlidingDoors, the on-line registration
- component of CompInaBox. Attached are raw text files containing the
- registration data, suitible for importing directly into the Chester
- scrutineering program.
- Reply to this message to get in touch with the CompInaBox Server Administrator.
- $CIB_SERVER_ADMIN_NAME
- $CIB_SERVER_HOST_NAME CompInaBox Server Administrator
- END_BODY;
- $body.=<<<END_PART_HEADER
- --$partSeperator
- Content-Type: text/plain; charset=us-ascii; name="by-school.txt"
- Content-Transfer-Encoding: 7bit
- END_PART_HEADER;
- $query =<<<END_QUERY
- SELECT COUNT(*) FROM judges_info;
- END_QUERY;
- $result=$db->query($query);
- list($numJudges)=$result->getRowAt(0);
- $file = "Adjudicators\t$numJudges\tEvery export will reassign numbers to judges\n";
- $query =<<<END_QUERY
- SELECT judgeid,lastname,firstname
- FROM judges_info JOIN people ON (peopleid=judgeid)
- ORDER BY lastname, firstname;
- END_QUERY;$result=$db->query($query);
- for ($i=0;$i < $numJudges;$i++)
- {
- list($id,$lastname,$firstname) = $result->getRowAt($i);
- $subQuery ="UPDATE judges_info SET abbrev='$i' WHERE judgeid=$id;";
- $db->query($subQuery);
- $file.="$i\t$firstname $lastname\n";
- }
- $query =<<<END_QUERY
- SELECT eventid, programnumber, class, level,
- style, age, type
- FROM events NATURAL JOIN
- events_categories
- ORDER BY programnumber;
- END_QUERY;$result = $db->query($query);
- $numEvents=$result->numrows();
- $file.="\nEvents\t$numEvents\n";
- for ($i=0;$i < $numEvents;$i++)
- {
- list ($eventID, $eventNumber, $class, $level,
- $style, $age, $type) = $result->getRowAt($i);
- // HACKED
- include ($argv[2]); // very insecure
- $file .="\nEvent $eventNumber $eventCat $eventLevel $eventStyle ";
- $query = "SELECT dancename FROM events_dances WHERE eventid=$eventID ORDER BY danceorder;";
- $danceResult = $db->query($query);
- $numDances = $danceResult->numrows();
- $file .="$numDances ";
- $query = "SELECT competitornumber FROM events_registration WHERE eventid=$eventID ORDER BY competitornumber;";
- $entrantsResult = $db->query($query);
- $numEntrants = $entrantsResult->numrows();
- $file .= "$numEntrants\tDB EventID:$eventID\n";
- for ($j=0;$j<$numDances;$j++)
- {
- list($dance) = $danceResult->getRowAt($j);
- $file .= "$dance\n";
- }
- for ($j=0;$j<$numEntrants;$j++)
- {
- if ($j!=0 && ($j%10)==0)
- $file .= "\n";
- else if ($j!=0) $file .=" ";
- list($number) = $entrantsResult->getRowAt($j);
- $file .= $number;
- }
- $file .= "\n";
- }
- $body.="$file\n";
- $body.="\n--$partSeperator--\n";
- $headers="";
- $headers.=<<<END_HEADERS
- From: $CIB_SERVER_ADMIN_EMAIL\r
- X-mailer: CompInaBox (via PHP)\r
- MIME-Version: 1.0\r
- Content-Type: multipart/mixed;\r
- boundary="$partSeperator"
- END_HEADERS;mail("$mailto","[$unixname Competition] Chester Export",$body,$headers);
- ?>
Documentation generated on Tue, 25 Apr 2006 12:59:08 -0400 by phpDocumentor 1.3.0RC3