/** * Parses uploaded file and checks for errors. */ function validate() { require_once 'wf-parse.php'; $parse = new BBXF_Parse(); $parse->read_file($_FILES['import_file']['tmp_name']); while ($parse->file_contents) { $current = $parse->find_element($parse->file_contents); if ('!--' != $current[0] && '?xml' != $current[0] && 'forums_data' != $current[0]) { die('Invalid top-level element (' . $current[0] . ').'); } $parse->call_element($current); $parse->file_contents = $parse->remove_element($current[1], $parse->file_contents); } $parse->check_for_duplicates(); $result = 'This is a valid export file. You should be able to import this properly using a compatible software plugin.'; display_result($result, $parse->forum_data); }
function map_tree($pers_array, $pers_array2) { // in first loop $pers_array and $pers_array2 hold persons A and B // in the next loop it will contain the parents, children and spouses of persons A and B, where they exist etc // the algorithm starts simultaneously from person A and person B in expanding circles until a common person is found (= connection found) // or until either person A or B runs out of persons (= no connection exists) global $dbh, $db_functions, $person, $person2, $globaltrack, $globaltrack2, $count; global $countfunc, $global_array; $count++; if ($count > 400000) { echo "Database too large!!!!"; exit; } $countfunc++; $tree = safe_text($_SESSION['tree_prefix']); $work_array = array(); $work_array2 = array(); // build closest circle around person A (parents, children, spouse(s)) foreach ($pers_array as $value) { // each array item has 4 parts, separated by "@": I124@par@I15@I54;I46;I326;I123;I15 $params = explode("@", $value); $persged = $params[0]; // the gedcomnumber of this person $refer = $params[1]; // the referrer type: par (parent), spo (spouse), chd (child) - this means who was the previous person that called this one $callged = $params[2]; // the gedcomnumber of the referrer (in case referrer is child: gedcomnumber;famc gedcomnumber) $pathway = $params[3]; // the path from person A to this person (gedcomnumbers separated by semi-colon) if ($refer == "chd") { $callarray = explode(";", $callged); // [0] = gedcomnumber of referring child, [1] = famc gedcomnumber of referring child } else { $callarray[0] = $callged; } $persDb = $db_functions->get_person($persged); if ($persDb == false) { echo "NO SUCH PERSON:" . "ref=" . $refer . "persged=" . $persged . "callged=" . $callged . "\$\$"; return false; } if ($refer == "fst") { $globaltrack .= $persDb->pers_gedcomnumber . "@"; } if (isset($persDb->pers_famc) and $persDb->pers_famc != "" and $refer != "par") { $famcDb = $db_functions->get_family($persDb->pers_famc); if ($famcDb == false) { echo "NO SUCH FAMILY"; return; } if (isset($famcDb->fam_man) and $famcDb->fam_man != "" and $famcDb->fam_man != "0" and strpos($globaltrack, $famcDb->fam_man . "@") === false) { if (strpos($_SESSION['next_path'], $famcDb->fam_man . "@") === false) { $work_array[] = $famcDb->fam_man . "@chd@" . $persged . ";" . $persDb->pers_famc . "@" . $pathway . ";" . "chd" . $famcDb->fam_man; $global_array[] = $famcDb->fam_man . "@chd@" . $persged . ";" . $persDb->pers_famc . "@" . $pathway . ";" . "chd" . $famcDb->fam_man; } $count++; $globaltrack .= $famcDb->fam_man . "@"; } if (isset($famcDb->fam_woman) and $famcDb->fam_woman != "" and $famcDb->fam_woman != "0" and strpos($globaltrack, $famcDb->fam_woman . "@") === false) { if (strpos($_SESSION['next_path'], $famcDb->fam_woman . "@") === false) { $work_array[] = $famcDb->fam_woman . "@chd@" . $persged . ";" . $persDb->pers_famc . "@" . $pathway . ";" . "chd" . $famcDb->fam_woman; $global_array[] = $famcDb->fam_woman . "@chd@" . $persged . ";" . $persDb->pers_famc . "@" . $pathway . ";" . "chd" . $famcDb->fam_woman; } $count++; $globaltrack .= $famcDb->fam_woman . "@"; } } if (isset($persDb->pers_fams) and $persDb->pers_fams != "") { $famsarray = explode(";", $persDb->pers_fams); foreach ($famsarray as $value) { if ($refer == "spo" and $value == $callged) { continue; } if ($refer == "fst" and $_SESSION['couple'] == $value) { continue; } $famsDb = $db_functions->get_family($value); if ($refer == "chd" and $famsDb->fam_woman == $persDb->pers_gedcomnumber and isset($famsDb->fam_man) and $famsDb->fam_man != "" and $famsDb->fam_gedcomnumber == $callarray[1]) { continue; } if (isset($famsDb->fam_children) and $famsDb->fam_children != "") { $childarray = explode(";", $famsDb->fam_children); foreach ($childarray as $value) { if ($refer == "chd" and $callarray[0] == $value) { continue; } if (strpos($globaltrack, $value . "@") === false) { if (strpos($_SESSION['next_path'], $value . "@") === false) { $work_array[] = $value . "@par@" . $persged . "@" . $pathway . ";" . "par" . $value; $global_array[] = $value . "@par@" . $persged . "@" . $pathway . ";" . "par" . $value; } $count++; $globaltrack .= $value . "@"; } } } } foreach ($famsarray as $value) { if ($refer == "chd" and $value == $callarray[1]) { continue; } if ($refer == "spo" and $value == $callged) { continue; } if ($refer == "fst" and $_SESSION['couple'] == $value) { continue; } $famsDb = $db_functions->get_family($value); if ($famsDb->fam_man == $persDb->pers_gedcomnumber) { if (isset($famsDb->fam_woman) and $famsDb->fam_woman != "" and $famsDb->fam_woman != "0" and strpos($globaltrack, $famsDb->fam_woman . "@") === false) { if (strpos($_SESSION['next_path'], $famsDb->fam_woman . "@") === false) { $work_array[] = $famsDb->fam_woman . "@spo@" . $value . "@" . $pathway . ";" . "spo" . $famsDb->fam_woman; $global_array[] = $famsDb->fam_woman . "@spo@" . $value . "@" . $pathway . ";" . "spo" . $famsDb->fam_woman; } $count++; $globaltrack .= $famsDb->fam_woman . "@"; } } else { if (isset($famsDb->fam_man) and $famsDb->fam_man != "" and $famsDb->fam_man != "0" and strpos($globaltrack, $famsDb->fam_man . "@") === false) { if (strpos($_SESSION['next_path'], $famsDb->fam_man . "@") === false) { $work_array[] = $famsDb->fam_man . "@spo@" . $value . "@" . $pathway . ";" . "spo" . $famsDb->fam_man; $global_array[] = $famsDb->fam_man . "@spo@" . $value . "@" . $pathway . ";" . "spo" . $famsDb->fam_man; } $count++; $globaltrack .= $famsDb->fam_man . "@"; } } } } } // build closest circle around person B (parents, children, spouse(s)) foreach ($pers_array2 as $value) { $params = explode("@", $value); $persged = $params[0]; $refer = $params[1]; $callged = $params[2]; $pathway = $params[3]; if ($refer == "chd") { $callarray = explode(";", $callged); } else { $callarray[0] = $callged; } $persDb = $db_functions->get_person($persged); if ($persDb == false) { echo "NO SUCH PERSON:" . "ref=" . $refer . "persged=" . $persged . "callged=" . $callged . "\$\$"; return false; } if ($refer == "fst") { $globaltrack2 .= $persDb->pers_gedcomnumber . "@"; } if (isset($persDb->pers_famc) and $persDb->pers_famc != "" and $refer != "par") { $famcDb = $db_functions->get_family($persDb->pers_famc); if ($famcDb == false) { echo "NO SUCH FAMILY"; return; } if (isset($famcDb->fam_man) and $famcDb->fam_man != "" and $famcDb->fam_man != "0") { $var1 = strpos($_SESSION['next_path'], $famcDb->fam_man . "@"); if (strpos($globaltrack, $famcDb->fam_man . "@") !== false and $var1 === false) { $totalpath = join_path($global_array, $pathway, $famcDb->fam_man, "chd"); $_SESSION['next_path'] .= $famcDb->fam_man . "@"; display_result($totalpath); return $famcDb->fam_man; } if (strpos($globaltrack2, $famcDb->fam_man . "@") === false) { if ($var1 === false) { $work_array2[] = $famcDb->fam_man . "@chd@" . $persged . ";" . $persDb->pers_famc . "@" . $pathway . ";" . "chd" . $famcDb->fam_man; } $count++; $globaltrack2 .= $famcDb->fam_man . "@"; } } if (isset($famcDb->fam_woman) and $famcDb->fam_woman != "" and $famcDb->fam_woman != "0") { $var2 = strpos($_SESSION['next_path'], $famcDb->fam_woman . "@"); if (strpos($globaltrack, $famcDb->fam_woman . "@") !== false and $var2 === false) { $totalpath = join_path($global_array, $pathway, $famcDb->fam_woman, "chd"); $_SESSION['next_path'] .= $famcDb->fam_woman . "@"; display_result($totalpath); return $famcDb->fam_woman; } if (strpos($globaltrack2, $famcDb->fam_woman . "@") === false) { if ($var2 === false) { $work_array2[] = $famcDb->fam_woman . "@chd@" . $persged . ";" . $persDb->pers_famc . "@" . $pathway . ";" . "chd" . $famcDb->fam_woman; } $count++; $globaltrack2 .= $famcDb->fam_woman . "@"; } } } if (isset($persDb->pers_fams) and $persDb->pers_fams != "") { $famsarray = explode(";", $persDb->pers_fams); foreach ($famsarray as $value) { if ($refer == "spo" and $value == $callged) { continue; } if ($refer == "fst" and $_SESSION['couple'] == $value) { continue; } $famsDb = $db_functions->get_family($value); if ($refer == "chd" and $famsDb->fam_woman == $persDb->pers_gedcomnumber and isset($famsDb->fam_man) and $famsDb->fam_man != "" and $famsDb->fam_gedcomnumber == $callarray[1]) { continue; } if (isset($famsDb->fam_children) and $famsDb->fam_children != "") { $childarray = explode(";", $famsDb->fam_children); foreach ($childarray as $value) { if ($refer == "chd" and $callarray[0] == $value) { continue; } $var3 = strpos($_SESSION['next_path'], $value . "@"); if (strpos($globaltrack, $value . "@") !== false and $var3 === false) { $totalpath = join_path($global_array, $pathway, $value, "par"); $_SESSION['next_path'] .= $value . "@"; display_result($totalpath); return $value; } if (strpos($globaltrack2, $value . "@") === false) { if ($var3 === false) { $work_array2[] = $value . "@par@" . $persged . "@" . $pathway . ";" . "par" . $value; } $count++; $globaltrack2 .= $value . "@"; } } } } foreach ($famsarray as $value) { if ($refer == "chd" and $value == $callarray[1]) { continue; } if ($refer == "spo" and $value == $callged) { continue; } if ($refer == "fst" and $_SESSION['couple'] == $value) { continue; } $famsDb = $db_functions->get_family($value); if ($famsDb->fam_man == $persDb->pers_gedcomnumber) { if (isset($famsDb->fam_woman) and $famsDb->fam_woman != "" and $famsDb->fam_woman != "0") { $var4 = strpos($_SESSION['next_path'], $famsDb->fam_woman . "@"); if (strpos($globaltrack, $famsDb->fam_woman . "@") !== false and $var4 === false) { $totalpath = join_path($global_array, $pathway, $famsDb->fam_woman, "spo"); $_SESSION['next_path'] .= $famsDb->fam_woman . "@"; display_result($totalpath); return $famsDb->fam_woman; } if (strpos($globaltrack2, $famsDb->fam_woman . "@") === false) { if ($var4 === false) { $work_array2[] = $famsDb->fam_woman . "@spo@" . $value . "@" . $pathway . ";" . "spo" . $famsDb->fam_woman; } $count++; $globaltrack2 .= $famsDb->fam_woman . "@"; } } } elseif ($famsDb->fam_woman == $persDb->pers_gedcomnumber) { if (isset($famsDb->fam_man) and $famsDb->fam_man != "" and $famsDb->fam_man != "0") { $var5 = strpos($_SESSION['next_path'], $famsDb->fam_man . "@"); if (strpos($globaltrack, $famsDb->fam_man . "@") !== false and $var5 === false) { $totalpath = join_path($global_array, $pathway, $famsDb->fam_man, "spo"); $_SESSION['next_path'] .= $famsDb->fam_man . "@"; display_result($totalpath); return $famsDb->fam_man; } if (strpos($globaltrack2, $famsDb->fam_man . "@") === false) { if ($var5 === false) { $work_array2[] = $famsDb->fam_man . "@spo@" . $value . "@" . $pathway . ";" . "spo" . $famsDb->fam_man; } $count++; $globaltrack2 .= $famsDb->fam_man . "@"; } } } } } } if (isset($work_array[0]) and isset($work_array2[0])) { // no common person was found but both A and B still have a wider circle to expand -> call this function again map_tree($work_array, $work_array2); } elseif (!isset($_SESSION['next_path'])) { echo "<br><span style='font-weight:bold;font-size:120%'> " . __("These persons are not related in any way.") . " <br><br>"; } else { echo "<br><span style='font-weight:bold;font-size:120%'> " . __("No further paths found.") . " <br><br>"; } }
} } else { $res = $abook->list_addr(); usort($res, 'alistcmp'); display_result($res, true); } } else { if (!empty($listall)) { $query = '*'; } /* Do the search */ if (!empty($query)) { if ($backend == -1) { $res = $abook->s_search($query); } else { $res = $abook->s_search($query, $backend); } if (!is_array($res)) { echo html_tag('p', '<b><br />' . _("Your search failed with the following error(s)") . ':<br />' . $abook->error . "</b>\n", 'center') . "\n</body></html>\n"; exit; } if (sizeof($res) == 0) { echo html_tag('p', '<br /><b>' . _("No persons matching your search were found") . "</b>\n", 'center') . "\n</body></html>\n"; exit; } display_result($res); } } } ?> </body></html>
/* if (isset($_GET['user'])) { $user = $_GET['user']; } else { $user = "******"; } */ /*TODO: Remove */ /* if (isset($_GET['count'])) { $count = $_GET['count']; } else { $count = 20; } */ /*TODO: change depending on the data to retrieve*/ //$getfield = "?screen_name=$user&count=$count"; $getfield = "?q=blaeblaebjkkzbekze"; $twitter = new TwitterAPIExchange($settings); $string = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), $assoc = TRUE); if (check_error($string)) { exit; } display_result($string);
printf("%20s %4s %-8s %s\n", "\$el ", "\$which", " \$xcl", "Result"); /* the default token will be $parser->current_element, which will be an array consisting of 'name' elements and their descendents */ $parser->XML_PullParser_getElement('name'); for ($i = 0; $i < 4; $i++) { display_result("lastname", $i); } echo "\nUsing token from XML_PullParser_getElement('lastname')\n"; printf("%20s %4s %-8s %s\n", "\$el ", "\$which", " \$xcl", "Result"); /* the default token will be $parser->current_element, which will be an array consisting of 'lastname' elements -- unlike 'name' it has no descendents */ $last_name = $parser->XML_PullParser_getElement('lastname'); for ($i = 0; $i < 4; $i++) { display_result("lastname", $i); } function display_result($el, $which) { global $parser; $type = ""; if (is_array($el)) { $token = $parser->XML_PullParser_getElementName($el); $type = "token({$token})"; } else { $name = $el; $type = "string({$name})"; } $result = $parser->XML_PullParser_getText($el, $which, TRUE); printf("%20s %4d %8s %s\n", $type, $which, "TRUE", $result); $result = $parser->XML_PullParser_getText($el, $which, FALSE);
function add_user($login, $passwd) { global $display; if (!$passwd) { echo "please, you have to set a password !\n"; exit; } $check = read_file("check"); if ($check == true) { echo "user already exist, use --modify-user instead\n"; exit; } else { $salt = gen_salt(); $crypt_pwd = crypt_pass($passwd, $salt); $str = $login . ":" . $crypt_pwd . "\r\n"; if ($display == true) { display_result($str); } else { write_file($str, "a"); } } }
$tags = array("entry"); $child_tags = array("name"); $parser = new XML_PullParser_doc($doc, $tags, $child_tags); $entry = $parser->XML_PullParser_getToken(); echo "Using token from XML_PullParser_getToken(), i.e <ENTRY>. . .</ENTRY>\n"; printf("%20s %4s %-8s %s\n", "\$el ", "\$which", " \$xcl", "Result"); for ($i = 0; $i < 6; $i++) { display_result($entry, $i); display_result("name", $i); } echo "\nUsing token from XML_PullParser_getElement('name')\n"; printf("%20s %4s %-8s %s\n", "\$el ", "\$which", " \$xcl", "Result"); $name = $parser->XML_PullParser_getElement('name'); for ($i = 0; $i < 6; $i++) { display_result($name, $i); display_result("name", $i); } function display_result($el, $which) { global $parser; $type = ""; if (is_array($el)) { $token = $parser->XML_PullParser_getElementName($el); $type = "token({$token})"; } else { $name = $el; $type = "string({$name})"; } $result = $parser->XML_PullParser_getText($el, $which, TRUE); printf("%20s %4d %8s %s\n", $type, $which, "TRUE", $result); $result = $parser->XML_PullParser_getText($el, $which, FALSE);