<?php ////////////////////////////////////////////////////////// // // embed.php // outputs the UKC logbook in a form suitable for embedding // ////////////////////////////////////////////////////////// //Include table handling class include 'tableExtractor.class.php'; $tx = new tableExtractor(); $_GET['id'] = "76394"; //HARD CODE HACK // Make sure an ID number if supplied if (!isset($_GET['id'])) { echo "<strong>You need to supply an UKC user ID number, or hardcode one.</strong>"; exit(1); } //Set source data URL $url = "http://www.ukclimbing.com/logbook/showlog.html?id=" . $_GET['id']; //Parse table structure $tx->source = file_get_contents($url); $tx->anchorWithin = true; $tx->anchor = 'Climb name'; $tableArray = $tx->extractTable(); /* [1] Array outline [1] "Climb name" [2] "Grade" [3] "Style" [4] "Partner(s)" [5] "Notes"
$tableP = new tableExtractor(); $tableP->anchor = '<div class="informaltable">'; $tableP->source = file_get_contents('http://standards.freedesktop.org/menu-spec/latest/apa.html'); $tableParr = $tableP->extractTable(); $MainCategories = array(); //foreach($tableParr as $key => $row) if(is_numeric(substr($row['Main Category'],0,1))) unset($tableParr[$key]); echo "char *MainCategories[" . count($tableParr) . "] = {\n"; foreach ($tableParr as $row) { $MainCategories[] = $row['Main Category']; echo "\t\"" . $row['Main Category'] . "\",\n"; } echo "};\n"; echo "Menu *MainCategoryLists[" . count($tableParr) . "];\n"; echo "#define MAIN_CATEGORY_COUNT " . count($tableParr) . "\n"; echo "\n/* Additional Categories */\n"; $tableA = new tableExtractor(); $tableA->anchor = 'Additional Category'; $tableA->source = file_get_contents('http://standards.freedesktop.org/menu-spec/latest/apa.html'); $tableAarr = $tableA->extractTable(); //foreach($tableAarr as $key => $row) if(is_numeric(substr($row['Additional Category'],0,1))) unset($tableAarr[$key]); echo "char *AdditionalCategories[" . count($tableAarr) . "] = {\n"; foreach ($tableAarr as $row) { echo "\t\"" . $row['Additional Category'] . "\", /* With " . $row['Related Categories'] . " */\n"; } echo "};\n"; echo "Menu *AdditionalCategoryLists[" . count($tableAarr) . "];\n"; echo "#define ADDITIONAL_CATEGORY_COUNT " . count($tableAarr) . "\n"; echo "\n/* Main->Additional items */\n"; echo "void add_additional_categories() {\n"; echo "\tMenuItem *new_item;\n"; foreach ($tableAarr as $idx2 => $row) {