0'; mysqli_query($db, $query); } // // Clear any remaining tags // function ClearTag ($Field) { global $Key; global $db; $query='select * from entry where '.$Field.' is not null and '.$Field.' < 0'; $entry_res=mysqli_query($db, $query); while ($entry_row=mysqli_fetch_assoc($entry_res)) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "'.$Field.'", "'.$entry_row['entry'].'", "'.abs($entry_row[$Field]).'", "")' ; mysqli_query($db, $c_query); $query='update entry set '.$Field.'=null where entry='.$entry_row['entry']; mysqli_query($db, $query); } } // ?>

Import Files

Processing 

0) { switch ($Control_D) { case 'ENTRY': $XR=explode("\t", $Line); if ((is_numeric($XR[0]) && $XR[0] > 0) && ((is_numeric($XR[1]) && $XR[1] > 0) || empty($XR[1]))) { $query='select comp_entry from entry where entry="'.$XR[0].'"'; $xr_res=mysqli_query($db, $query); $xr_row=mysqli_fetch_row($xr_res); if ($xr_row[0] != $XR[1]) { $query='update entry set comp_entry="'.$XR[1].'" where entry="'.$XR[0].'"'; mysqli_query($db, $query); ++$Cnt; if (mysqli_affected_rows($db) > 0) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "comp_entry", "'.$XR[0].'", "'.$xr_row[0].'", "'.$XR[1].'")' ; mysqli_query($db, $c_query); } else { ++$CntNo; } } else { ++$CntNo; } } else { ++$CntNo; } break; case 'JUDGE': $JL=explode("\t", $Line); $query='delete from judge_list where bjcpid="'.$JL[10].'"'; mysqli_query($db, $query); $query='insert into judge_list values (null, "'.$JL[0].'", "'.$JL[1].'", "'.$JL[2].'", '; $query.='"'.$JL[3].'", "'.$JL[4].'", "'.$JL[5].'", "'.$JL[6].'", "'.$JL[7].'", "'.$JL[8].'", '; $query.='"'.$JL[9].'", "'.$JL[10].'", "'.$JL[11].'")'; mysqli_query($db, $query); ++$Cnt; break; case 'RESULTS': switch ($FileFormat) { // BOCK case 'BOCK': $RES=explode(",", $Line); if (!is_numeric($RES[0])) { break; } foreach (array(4, 3, 2, 1) as $place_loop) { $res_place=abs($place_loop - 7); if (empty($RES[$res_place])) { continue; } $query='select * from entry where entry="'.$RES[$res_place].'"'; $entry_res=mysqli_query($db, $query); if (mysqli_num_rows($entry_res) < 1) { continue; } $entry_row=mysqli_fetch_assoc($entry_res); $query='update entry set place="'.$place_loop.'", flight="'.$RES[0].'"'; if ($place_loop != abs($entry_row['place'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "place", "'.$RES[$res_place].'", "'.(empty($entry_row['place']) ? '' : abs($entry_row['place'])).'", "'.$place_loop.'")' ; mysqli_query($db, $c_query); } if ($RES[0] != abs($entry_row['flight'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "flight", "'.$RES[$res_place].'", "'.(empty($entry_row['flight']) ? '' : abs($entry_row['flight'])).'", "'.$RES[0].'")' ; mysqli_query($db, $c_query); } $query.=' where entry="'.$RES[$res_place].'"'; mysqli_query($db, $query); } ++$Cnt; break; // CHS case 'CHS': $RES=explode("\t", $Line); $query='select * from entry where entry="'.$RES[0].'"'; $entry_res=mysqli_query($db, $query); $entry_row=mysqli_fetch_assoc($entry_res); $query='update entry set '; $AddComma=FALSE; if (!empty($RES[1])) { $query.='comp_entry="'.$RES[1].'"'; $AddComma=TRUE; if ($RES[1] != abs($entry_row['comp_entry']) || empty($entry_row['comp_entry'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "comp_entry", "'.$RES[0].'", "'.(empty($entry_row['comp_entry']) ? '' : abs($entry_row['comp_entry'])).'", "'.$RES[1].'")' ; mysqli_query($db, $c_query); } } if (!empty($RES[2])) { $query.=($AddComma ? ', ' : '').'flight="'.$RES[2].'"'; $AddComma=TRUE; if ($RES[2] != abs($entry_row['flight']) || empty($entry_row['flight'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "flight", "'.$RES[0].'", "'.(empty($entry_row['flight']) ? '' : abs($entry_row['flight'])).'", "'.$RES[2].'")' ; mysqli_query($db, $c_query); } } if (!empty($RES[3])) { if (is_numeric($RES[3]) && $RES[3] > 0 && $RES[3] < 20) { $query.=($AddComma ? ', ' : '').'flight_pos="'.$RES[3].'"'; $AddComma=TRUE; if ($RES[3] != abs($entry_row['flight_pos']) || empty($entry_row['flight_pos'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "flight_pos", "'.$RES[0].'", "'.(empty($entry_row['flight_pos']) ? '' : abs($entry_row['flight_pos'])).'", "'.$RES[3].'")' ; mysqli_query($db, $c_query); } } } if (!empty($RES[4])) { $Value=(strcasecmp($RES[4], 'HM') == 0) ? 4 : $RES[4]; if (is_numeric($Value) && $Value >= 1 && $Value <= 4) { $query.=($AddComma ? ', ' : '').'place="'.$Value.'"'; $AddComma=TRUE; if ($RES[4] != abs($entry_row['place']) || empty($entry_row['place'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "place", "'.$RES[0].'", "'.(empty($entry_row['place']) ? '' : abs($entry_row['place'])).'", "'.$RES[4].'")' ; mysqli_query($db, $c_query); } } } if (!empty($RES[5])) { $Value=(strcasecmp($RES[5], 'HM') == 0) ? 4 : $RES[5]; if (is_numeric($Value) && $Value >= 1 && $Value <= 4) { $query.=($AddComma ? ', ' : '').'bos_place="'.$Value.'"'; $AddComma=TRUE; if ($RES[5] != abs($entry_row['bos_place']) || empty($entry_row['bos_place'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "bos_place", "'.$RES[0].'", "'.(empty($entry_row['bos_place']) ? '' : abs($entry_row['bos_place'])).'", "'.$RES[5].'")' ; mysqli_query($db, $c_query); } } } if (!empty($RES[6])) { $Value=is_numeric($RES[6]) ? $RES[6] : 0; if (is_numeric($Value) && $Value >= 0 && $Value <= 50) { $query.=($AddComma ? ', ' : '').'score="'.$Value.'"'; if ($RES[6] != abs($entry_row['score']) || empty($entry_row['score'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "score", "'.$RES[0].'", "'.(empty($entry_row['score']) ? '' : abs($entry_row['score'])).'", "'.$RES[6].'")' ; mysqli_query($db, $c_query); } } } $query.=' where entry="'.$RES[0].'"'; mysqli_query($db, $query); ++$Cnt; break 2; // HCCP1 case 'HCCP1': $ColonPos=stripos($Line, 'score: '); if ($ColonPos !== FALSE) { $entry_num=intval(substr($Line,0,4)); $query='select * from entry where '.($Renum == 'Y' ? 'comp_' : '').'entry="'.$entry_num.'"'; $entry_res=mysqli_query($db, $query); $entry_row=mysqli_fetch_assoc($entry_res); $query='update entry set'; if ($Renum != 'Y') { $query.=' comp_entry=entry'; if ($entry_num != abs($entry_row['comp_entry']) || empty($entry_row['comp_entry'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "comp_entry", "'.$entry_num.'", "'.(empty($entry_row['comp_entry']) ? '' : abs($entry_row['comp_entry'])).'", "'.$entry_num.'")' ; mysqli_query($db, $c_query); } $AddComma=TRUE; } else { $AddComma=FALSE; } $Score_Str=trim(substr($Line,$ColonPos+7,4)); $Value=floatval($Score_Str); if (!empty($Score_Str) && $Value >= 0 && $Value <= 50) { $query.=($AddComma ? ',' : '').' score="'.$Value.'"'; if ($Value != abs($entry_row['score']) || empty($entry_row['score'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "score", "'.$entry_num.'", "'.(empty($entry_row['score']) ? '' : abs($entry_row['score'])).'", "'.$Value.'")' ; mysqli_query($db, $c_query); } $AddComma=TRUE; } $Place=substr($Line,$ColonPos+12,1); if (is_numeric($Place) && (($Place >=1 && $Place <= 3) || $Place == 'H')) { $Place=($Place == 'H' ? '4' : $Place); $query.=($AddComma ? ',' : '').' place="'.$Place.'"'; if ($Place != abs($entry_row['place']) || empty($entry_row['place'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "place", "'.$entry_num.'", "'.(empty($entry_row['place']) ? '' : abs($entry_row['place'])).'", "'.$Place.'")' ; mysqli_query($db, $c_query); } } $query.=' where '.($Renum == 'Y' ? 'comp_' : '').'entry="'.$entry_num.'"'; mysqli_query($db, $query); if (mysqli_affected_rows($db) > 0) { ++$Cnt; } } break; // HCCP2 case 'HCCP2': $LineLen=strlen($Line); if (substr($Line,0,5) == 'Table') { $Table=intval(substr($Line,6,2)); } elseif (substr($Line,0,4) == 'BEST') { $Table=-1; $BOS=0; } elseif ($Table != 0 && $LineLen > 70) { if ($Table == -1) { $SpacePos=strpos($Line, ' '); $Fname=substr($Line,0,$SpacePos); $Lname=rtrim(substr($Line,$SpacePos+1,24-$SpacePos)); } $DigitPos=45; $StepIt='Y';; while ($StepIt=='Y' && $DigitPos < $LineLen) { $Chk=substr($Line,$DigitPos,1); if ($Chk>='0' && $Chk<='9') { $StepIt='N'; } else { ++$DigitPos; } } $CatSize=1; $StepIt='Y'; $DigitFound=FALSE; while ($StepIt=='Y' && $DigitPos+$CatSize < $LineLen) { $Chk=substr($Line,$DigitPos+$CatSize,1); if (!$DigitFound && $Chk>='A' && $Chk <= 'Z') { ++$CatSize; } elseif ($Chk>='0' && $Chk<='9') { ++$CatSize; $DigitFound=TRUE; } else { $StepIt='N'; } } $TestStr=trim(substr($Line,$DigitPos,$CatSize)); if (empty($TestStr)) { break; } $Chk=substr($TestStr, 0, 1); $query='select * from style_type where sg="'.$Comp_SG.'" and type_prefix="'.($Chk >= 'A' ? $Chk : '').'" order by type_seq'; $type_res=mysqli_query($db, $query); if (mysqli_num_rows($type_res) < 1) { $query='select * from style_type where sg="'.$Comp_SG.'" order by type_seq'; $type_res=mysqli_query($db, $query); } $type_row=mysqli_fetch_assoc($type_res); $TypeSeq=$type_row['type_seq']; $Cat=intval($TestStr); $SubCat=substr($Line,$DigitPos+$CatSize,1); if ($Table == -1) { ++$BOS; if ($Fname == 'Group:') { $query='select brewer from brewer where groupname="'.$Lname.'"'; } else { $query='select brewer from brewer where concat_ws(" ", fname, lname)="'.$Fname.' '.$Lname.'"'; } $brewer_res=mysqli_query($db, $query); if (mysqli_num_rows($brewer_res) != 1) { continue; } $brewer_row=mysqli_fetch_assoc($brewer_res); $query='select * from entry where brewer='.$brewer_row['brewer'].' and cat="'.$Cat.'"'; if (cntSubCat($TypeSeq, $Cat) != 0) { $query.=' and sub_cat="'.$SubCat.'"'; } $query.=' and removed!="Y"'; $entry_res=mysqli_query($db, $query); if (mysqli_num_rows($entry_res) != 1) { continue; } $entry_row=mysqli_fetch_assoc($entry_res); if ($BOS != abs($entry_row['bos_place']) || empty($entry_row['bos_place'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "bos_place", "'.$entry_row['entry'].'", "'.(empty($entry_row['bos_place']) ? '' : abs($entry_row['bos_place'])).'", "'.$BOS.'")' ; mysqli_query($db, $c_query); } $query='update entry set bos_place="'.$BOS.'" where entry='.$entry_row['entry']; mysqli_query($db, $query); ++$BosCnt; } else { $query='select * from entry where cat="'.$Cat.'"'; if (cntSubCat($TypeSeq, $Cat) != 0) { $query.=' and sub_cat="'.$SubCat.'"'; } $entry_res=mysqli_query($db, $query); while ($entry_row=mysqli_fetch_assoc($entry_res)) { if ($Table != abs($entry_row['flight']) || empty($entry_row['flight'])) { $c_query='insert into changelog values (null, null,"'.$Key.'", "entry", "C", "flight", "'.$entry_row['entry'].'", "'.(empty($entry_row['flight']) ? '' : abs($entry_row['flight'])).'", "'.$Table.'")' ; mysqli_query($db, $c_query); } } $query='update entry set flight="'.$Table.'" where cat="'.$Cat.'"'; if (cntSubCat($TypeSeq, $Cat) != 0) { $query.=' and sub_cat="'.$SubCat.'"'; } mysqli_query($db, $query); ++$Cnt; } } break; } break; default: } $Line=''; } } else { $Line.=$char; } } fclose($fp); } @unlink($imp_name); if ($Control_D == 'RESULTS') { switch ($FileFormat) { case 'BOCK': ClearTag('flight'); ClearTag('place'); break; case 'CHS': ClearTag ('comp_entry'); ClearTag ('flight'); ClearTag ('flight_pos'); ClearTag ('place'); ClearTag ('bos_place'); ClearTag ('score'); break; case 'HCCP1': ClearTag ('comp_entry'); ClearTag ('place'); ClearTag ('score'); break; case 'HCCP2': ClearTag ('flight'); ClearTag ('bos_place'); break; } } echo ''."\n"; echo $Cnt.' Records Processed
'."\n"; if ($BosCnt > 0) { echo $BosCnt.' Best-Of-Show Records Processed
'."\n"; } if ($CntNo > 0) { echo $CntNo.' Records Bypassed
'."\n"; } echo '
'."\n"; echo '
'."\n"; ?>