function dumpCourseInfo() { $files = getFileNames(); $stored = false; $t = 0; $totalSects = 0; $totalCourses = 0; $totalTime = 0; $totals = array(0, 0, 0); global $conn; if (!IS_CLI) { echo "<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse; border: 0;'>\n"; echo "<tr><th>Subject</th><th>Courses</th><th>Sections</th><th>Elapsed Time</th><th>Failed</th></tr>\n"; } $ins_crs_stmt = $conn->prepare("INSERT INTO COURSE(subject, number, suffix, title, credits) " . "VALUES(?, ?, ?, ?, ?)") or die("ps course " . $conn->error); if (DENORM_TABLES) { $ins_sect_stmt = $conn->prepare("INSERT INTO NX_COURSE(callnr, crs_id, course, title, credits, section, enrolled, capacity, instructor, flags, comments) " . "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") or die("ps section {$conn->error}"); } else { $ins_sect_stmt = $conn->prepare("INSERT INTO SECTION(callnr, alt_title, crs_id,section,enrolled,capacity,instructor,flags,comments) " . "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)") or die("ps section " . $conn->error); } $ins_slot_stmt = $conn->prepare("INSERT INTO TIMESLOT(callnr, day, start, end, room) " . "VALUES(?, ?, TIME(?), TIME(?), ?)") or die("ps timeslot " . $conn->error); $conn->autocommit(FALSE); $term; if (DENORM_TABLES) { $conn->query("ALTER TABLE NX_COURSE DISABLE KEYS"); } if (IS_CLI) { $new_line = "\n"; } else { $new_line = "<br/>\n"; } $hashes = array(); foreach ($files as $key => $name) { if (!isset($term)) { list($term, $subj) = sscanf($name, "%s.%s.html"); } $t0 = microtime(true); $result = storeDataFrom($key, SOURCE_URL . $name); $actuals = array(0, 0); $skipped = array(); foreach ($result[0] as $crs) { $crs->id = getCourseID($crs->subject, $crs->coursenr, $crs->coursevar, $conn); if (!$crs->id) { if (SCRAPE_COURSES) { $ins_crs_stmt->bind_param("ssssd", $crs->subject, $crs->coursenr, $crs->coursevar, $crs->title, $crs->credits); if (!$ins_crs_stmt->execute()) { echo "{$crs->subject} {$crs->coursenr}{$crs->coursevar} could not be inserted ({$conn->error})"; continue; } $crs->id = $conn->insert_id; $actuals[0]++; } else { $skipped[] = array("number" => "{$crs->subject}.{$crs->coursenr}{$crs->coursevar}", "reason" => "NotFound"); continue; } } $baseMask = 0; if (strpos($crs->title, "ST:") === 0) { $baseMask = Flags::ST; } foreach ($crs->sections as $sec) { $flags = $baseMask; if ($sec->cancelled) { $flags |= Flags::CANCELLED; } if ($sec->online) { $flags |= Flags::ONLINE; } if (substr($sec->section, 0, 1) == 'H') { $flags |= Flags::HONORS; } /* */ if (DENORM_TABLES) { $course = "{$crs->subject}{$crs->coursenr}{$crs->coursevar}"; $ins_sect_stmt->bind_param("iissdsiisis", $sec->callnr, $crs->id, $course, $sec->alt_title, $crs->credits, $sec->section, $sec->enrolled, $sec->capacity, $sec->instructor, $flags, $sec->comments); } else { $ins_sect_stmt->bind_param("isisiisis", $sec->callnr, $sec->alt_title, $crs->id, $sec->section, $sec->enrolled, $sec->capacity, $sec->instructor, $flags, $sec->comments); } if (!$ins_sect_stmt->execute()) { echo "{$crs->subject}.{$crs->coursenr}{$crs->coursevar}.{$sec->section} could not be inserted: {$conn->error}{$new_line}"; continue; } $failed = false; if ($sec->slots && count($sec->slots) > 0) { foreach ($sec->slots as $slot) { $ins_slot_stmt->bind_param("iisss", $sec->callnr, $slot->dayOfWeek, $slot->startTime, $slot->endTime, $slot->location); if (!$ins_slot_stmt->execute()) { $skipped[] = array("number" => "{$crs->coursenr}{$crs->coursevar}-{$sec->section}", "reason" => "{$conn->error}"); echo "Failed to execute insert timeslot statement(course={$crs->coursenr}{$crs->coursevar}-{$sec->section}; start={$slot->startTime}; end={$slot->endTime}):{$new_line}\t{$conn->error}{$new_line}"; $failed = true; break; } } } if ($failed) { $conn->rollback(); } else { $conn->commit(); $actuals[1]++; } } } list($count_courses, $count_sections) = $actuals; $tf = microtime(true); $dt = $tf - $t0; if (IS_CLI) { echo "{$key}\t{$count_courses}\t{$count_sections}\t" . sprintf("%.3lfs", $dt) . "\n"; } else { echo "<tr><td>{$key}</td><td>{$count_courses}</td><td>{$count_sections}</td><td>" . sprintf("%.3lfs", $dt) . "</td>"; echo "<td><span onclick='showExpandErrors(this);'>" . count($skipped) . "</span>"; if (count($skipped) > 0) { echo "<div style='display:none;'>"; foreach ($skipped as $ent) { echo $ent['number'] . ": " . $ent['reason'] . "<br/>"; } echo "</div>"; } echo "</td></tr>\n"; } $hashes[] = $result[2] . "{$count_courses}{$count_sections}"; while (ob_get_level() > 0) { ob_end_flush(); } flush(); $totalTime += $dt; $totalSects += $count_sections; $totalCourses += $count_courses; } if (DENORM_TABLES) { $conn->query("ALTER TABLE NX_COURSE ENABLE KEYS"); } if (IS_CLI) { echo "\n"; echo "Total Courses:\t{$totalCourses}\n"; echo "Total Sections:\t{$totalSects}\n"; echo "Total Time:\t" . sprintf("%.3lfs", $totalTime) . "\n"; } else { echo "</table><br/>"; echo "Total Courses: {$totalCourses}<br/>\n"; echo "Total Sections: {$totalSects}<br/>\n"; echo "Total Time: " . sprintf("%.3lfs", $totalTime) . "<br/>\n"; } $ins_crs_stmt->reset(); $ins_sect_stmt->reset(); $ins_slot_stmt->reset(); $conn->close(); return $hashes; }
$results_id = mysql_query($sql_id) or die("Unable to execute:" . mysql_error()); $row_id = mysql_fetch_array($results_id); echo $row_id['information']; } if (isset($_POST['photos'])) { //print_r(getFileNames()); $sql_photos = "SELECT * FROM events WHERE ID={$ID}"; $results_photos = mysql_query($sql_photos) or die("Unable to execute:" . mysql_error()); $row_photos = mysql_fetch_array($results_photos); //echo $row_photos['ID']; //print_r( getFileNames($row_photos['images'], $row_photos['ID']) ); /** add images to the javascript **/ echo '<script type="text/javascript"> <!-- var viewer = new PhotoViewer();'; foreach ($file_names = getFileNames($row_photos['images'], $row_photos['ID']) as $file_name) { echo "viewer.add('" . $file_name . "');"; } echo '//--></script>'; /// echo "<br />"; echo "<div >"; echo "<table width='700'><tr class='fade-area-1'>"; $columCount = 0; foreach ($file_names = getThumbNames($row_photos['images'], $row_photos['ID']) as $file_name) { echo '<td><div align="center"><a href="javascript:void(viewer.show(' . $columCount . '))"><img style="max-height:160px;max-width:160px;" class="fieldCampImages shadowed" src="' . $file_name . '"/></a></div></td>'; $columCount++; if ($columCount % 4 == 0) { echo '</tr><tr height="10"></tr><tr>'; } }
<?php // Does a basic import of data from Po's CMAT18 registration files. // There are a few quirks and manual touch-ups that are required. // 1) Only "standard" individual events are imported. Events without // age groups such as push hands and group events will be skipped // and must be added manually. // 2) Weight for push hands competitors will need to be entered manually // by looking at which push hands event is listed under "Events". // // When running the script, it is best to save the output to a file // to maintain a record of additional manual work that needs to be done. require_once '../util/Db.php'; require_once '../util/TextUtils.php'; $fileNames = getFileNames(); if (count($fileNames) == 0) { print "No input file(s).\n"; exit(1); } else { importFiles($fileNames); exit(0); } /** * File names passed in through command line parameters. * @return array */ function getFileNames() { global $argv; if (count($argv) > 1) { return array_slice($argv, 1);