function parse_candidates($_xml_str) { if (empty($_xml_str)) { return null; } $candidates = array(); $dom = new XMLDOM(); $xml_dom = $dom->load_from_xml($_xml_str); if (!empty($xml_dom)) { $tags = array('email_addr', 'phone_num', 'name', 'social', 'current_position', 'current_employer'); $candidates = $dom->get_assoc($tags); foreach ($candidates as $i => $candidate) { $candidates[$i]['name'] = sanitize(stripslashes($candidate['name'])); $candidates[$i]['current_position'] = sanitize(stripslashes($candidate['current_position'])); $candidates[$i]['current_employer'] = sanitize(stripslashes($candidate['current_employer'])); if (is_null($candidate['social']) || empty($candidate['social'])) { $candidates[$i]['social'] = 'NULL'; } else { $candidates[$i]['social'] = strtolower($candidate['social']); } } } return $candidates; }
} } else { if ($job->update($data) == false) { echo "ko"; exit; } } echo "ok"; exit; } if ($_POST['action'] == 'close') { if (!isset($_POST['payload'])) { echo "ko"; exit; } $xml_dom->load_from_xml($_POST['payload']); $jobs = $xml_dom->get('id'); $query = "UPDATE jobs SET closed = 'Y' WHERE id IN ("; $i = 0; foreach ($jobs as $job) { $query .= $job->nodeValue; if ($i < $jobs->length - 1) { $query .= ", "; } $i++; } $query .= ")"; $mysqli = Database::connect(); if (!$mysqli->execute($query)) { echo "ko"; exit;
} else { $seeking = htmlspecialchars_decode(stripslashes($seeking)) . "\n\n" . $_POST['seeking']; } // update career profile $data = array(); $data['seeking'] = $seeking; $data['updated_on'] = date('Y-m-d'); $data['imported_on'] = $data['updated_on']; if ($member->update($data) === false) { echo 'ko'; exit; } // import job profiles $positions_xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $positions_xml .= $_POST['positions']; if (!$xml_dom->load_from_xml($positions_xml)) { echo 'ko'; exit; } $mysqli = Database::connect(); $nodes = $xml_dom->get('position'); foreach ($nodes as $node) { $data = array(); foreach ($node->childNodes as $child) { switch ($child->nodeName) { case 'title': $data['position_title'] = sql_nullify($child->nodeValue); break; case 'employer': $data['employer'] = sql_nullify($child->nodeValue); break;