function render_symptom($dbc, $db_name, $id) { echo '<p>症状:</p>'; $diseases = array(); $values = array_merge(get_values($dbc, PREFIX . $id, "症状加(调整)"), get_values($dbc, PREFIX . $id, "症状减(调整)")); foreach ($values as $value) { if (array_key_exists($value, $diseases)) { $diseases[$value] = $diseases[$value] + 1; } else { $diseases[$value] = 1; } } arsort($diseases); //$diseases = array_slice(array_keys($diseases), 0, 5); $diseases = array_keys($diseases); echo '<ul>'; foreach ($diseases as $value) { //echo '<li class="list-group-item">'; echo '<li>'; echo render_value($dbc, $db_name, $value, true); echo ' <a class="btn btn-xs btn-primary" href="qa.php?db_name=' . $db_name . '&keywords=' . get_entity_name($dbc, $value) . '&question_type=症状" ><span class="glyphicon glyphicon-search"></span></a>'; echo '<p/></li>'; } echo '</ul>'; }
/** * Exporting values as a string * @package Skip\Forms * @since 1.0 * @ignore */ function export_values($option_groups) { foreach ($option_groups as $option_group) { $values = serialize((array) get_values($option_group)); $serialized_val .= $values; } return $serialized_val; }
function get_herb_plus($dbc, $db_name, $value) { $herb_links = array(); $herbs = array_merge(get_values($dbc, $value, '中药加(调整)')); foreach ($herbs as $herb) { $herb_links[] = render_value($dbc, $db_name, $herb, false); } $herb_title = ''; if (count($herb_links) != 0) { $herb_title = '加' . implode(', ', $herb_links); } return $herb_title; }
function render_treatment($dbc, $db_name, $id) { echo '<p>系统为您推荐如下的方剂:</p>'; $formulas = array(); $values = array_merge(get_subjects($dbc, PREFIX . $id, "治疗"), get_values($dbc, PREFIX . $id, "被...治疗")); foreach ($values as $value) { if (array_key_exists($value, $formulas)) { $formulas[$value] = $formulas[$value] + 1; } else { $formulas[$value] = 1; } } arsort($formulas); //$formulas = array_slice(array_keys($formulas), 0, 5); $formulas = array_keys($formulas); echo '<ol>'; foreach ($formulas as $value) { //echo '<li class="list-group-item">'; echo '<li>'; echo render_value($dbc, $db_name, $value, true); echo '<p/></li>'; } echo '</ol>'; }
$id = get_entity_of_type($dbc, $name, $question_type); if ($id != '') { array_push($ids, $id); } } if (!empty($ids)) { echo '<p>您输入的症状集合为:'; foreach ($ids as $id) { echo ' ' . render_value($dbc, $db_name, PREFIX . $id, false); } echo '</p>'; echo '<hr>'; echo '<p> 系统为您推荐如下的证候:</p>'; $formulas = array(); foreach ($ids as $id) { $values = array_merge(get_subjects($dbc, PREFIX . $id, "由...组成"), get_values($dbc, PREFIX . $id, "组成")); foreach ($values as $value) { if (array_key_exists($value, $formulas)) { $formulas[$value] = $formulas[$value] + 1; } else { $formulas[$value] = 1; } } } arsort($formulas); //print_r($syndromes); $formulas = array_slice(array_keys($formulas), 0, 5); //echo '<ul class="list-group">'; echo '<ol >'; foreach ($formulas as $value) { //echo '<li class="list-group-item">';
function get_map_values($conn, $map, $name, $type, $host_types) { $r_value_max = -1; $v_value_max = -1; $a_value_max = -1; $r_value_aux = -1; $v_value_aux = -1; $a_value_aux = -1; $sensor = ''; $ips = $name; $in_assets = 0; list($map_array, $obj_map) = get_map_objects($conn, $map); foreach ($obj_map as $object) { list($name, $sensor, $type, $ips, $in_assets) = get_assets($conn, $object['type_name'], $object['type'], $host_types); list($r_value_aux, $v_value_aux, $a_value_aux) = get_values($conn, $host_types, $object['type'], $name, TRUE); if ($r_value_aux > $r_value_max) { $r_value_max = $r_value_aux; } if ($v_value_aux > $v_value_max) { $v_value_max = $v_value_aux; } if ($a_value_aux > $a_value_max) { $a_value_max = $a_value_aux; } } $r_value = get_value_by_digit($r_value_max); $v_value = get_value_by_digit($v_value_max); $a_value = get_value_by_digit($a_value_max); return array($r_value, $v_value, $a_value, $name, $sensor, $type, $ips, $in_assets); }
<?php $poll_values = get_values($current_poll); $category = ucwords(str_replace("_", " ", $current_poll)); $column_names = get_column_names($current_poll); echo "<h2 class=\"center top-spacer_20\">" . format_poll_header($current_poll, $category) . "</h2>\n\n <form action=\"yearendpoll.php\" method=\"post\" name=\"year_end_" . $current_poll . "\" class=\"form-default\">\n <fieldset>\n<div class=\"control-group\">\n<div class=\"controls\">\n"; for ($i = 1; $i <= mysql_num_rows($poll_values); $i++) { $info = mysql_fetch_assoc($poll_values); echo "<label for=\"" . $info['id'] . "\" class=\"half\"><input type=\"checkbox\" name=\"year_end_votes[]\" id=\"" . $info['id'] . "\" value=\"" . $info['id'] . "\">"; for ($c = 1; $c <= count($column_names) - 2; $c++) { echo "<span>" . $info[$column_names[$c]]; if ($column_names[$c + 1] != 'votes') { echo " - "; } } echo "\n</span>\n</label>\n"; } echo "</div>\n<div class=\"control-group top-spacer_20\">\n\n <div class=\"controls\">\n\n <input type=\"checkbox\" id=\"song_write_in\"> <input type=\"text\" disabled=\"disabled\" class=\"input-xl\" id=\"write_in_value\" name=\"write_in_value\">\n\n <div class=\"form-other\">Other (please specify)</div>\n</div>\n</div>\n\n </div>\n<div class=\"form-actions\">\n<button class=\"btn-info disabled\" type=\"submit\" disabled=\"disabled\" id=\"vote\">Pick " . max_picks_for($current_poll) . " more!</button>\n\n <input type=\"hidden\" name=\"poll\" value=" . $current_poll . ">\n</div>\n\n </form>\n</div>\n</fieldset>";
<?php session_start(); // Initialize Session data ob_start(); // Turn on output buffering include_once "ewcfg8.php"; include_once "ewmysql8.php"; include_once "phpfn8.php"; include_once "userfn8.php"; if ($_POST['a_addopt']) { $fields = get_fields(); $values = get_values(); insert_data($fields, $values); } function get_fields() { $fields = array(); foreach ($_POST as $field => $value) { $field = str_replace("x_", "", $field); array_push($fields, $field); } return $fields; } function get_values() { $values = array(); foreach ($_POST as $field => $value) { array_push($values, $value); } return $values;
overall_header($lang['int_integration'], $lang['int_integration'], 'main'); $admin_tmpl['integration'] = true; } elseif (isset($_GET['action']) && $_GET['action'] == 'wizard') { $auth = user_auth('12'); overall_header($lang['wiz_wizard'], $lang['wiz_wizard'], 'main'); $admin_tmpl['wizard'] = true; $mn_users = load_basic_data('users'); $mn_categories = load_basic_data('categories'); $t_groups = array(); $t_groups = load_basic_data('templates_groups'); if (file_exists(MN_ROOT . $file['posts'])) { $p_file = file(MN_ROOT . $file['posts']); array_shift($p_file); $authors = array(); foreach ($p_file as $p_line) { $post = get_values('posts', $p_line, false); $authors[] = $post['author']; } $authors = array_unique($authors); } else { $authors = array(); } } elseif (isset($_POST['action']) && $_POST['action'] == 'wizard') { $auth = user_auth('12'); $wizard_code = ''; if (!empty($_POST['count']) && is_numeric($_POST['count'])) { $wizard_code .= '$mn_count = ' . $_POST['count'] . ';' . "\n "; } if (isset($_POST['categories']) && !empty($_POST['categories'])) { sort($_POST['categories']); $categories = trim(implode(',', $_POST['categories']), ',');
function get_snapshot($req) { global $CONFIG; set_time_limit(0); //this avoids timeouts $outputfile = $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/output.log"; require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php"; require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/classes.php"; //$lr=unserialize(file_get_contents($IOdir."lr")); //return "OK"; file_put_contents($outputfile, "Old indexing and classification files will now be saved in the IOdir directory with the prefix old_ and will be deleted after the whole process is completed\nIf there are problems and the process aborts before the end, rename them deleting that prefix in order to recover old data!\n\n"); //backup of the old files if (file_exists($IOdir . "changes")) { copy($IOdir . "changes", $IOdir . "old_changes"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_changes', 0666); } //set rw permissions for everybody for this file } if (file_exists($IOdir . "lr")) { copy($IOdir . "lr", $IOdir . "old_lr"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_lr', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "lr"); } if (file_exists($IOdir . "metadata_dt")) { copy($IOdir . "metadata_dt", $IOdir . "old_metadata_dt"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_metadata_dt', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "metadata_dt"); } if (file_exists($IOdir . "uses_dt")) { copy($IOdir . "uses_dt", $IOdir . "old_uses_dt"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_uses_dt', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "uses_dt"); } if (file_exists($IOdir . "tags_dt")) { copy($IOdir . "tags_dt", $IOdir . "old_tags_dt"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_tags_dt', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "tags_dt"); } if (file_exists($IOdir . "metadata_dt_raw")) { copy($IOdir . "metadata_dt_raw", $IOdir . "old_metadata_dt_raw"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_metadata_dt_raw', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "metadata_dt_raw"); } if (file_exists($IOdir . "uses_dt_raw")) { copy($IOdir . "uses_dt_raw", $IOdir . "old_uses_dt_raw"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_uses_dt_raw', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "uses_dt_raw"); } if (file_exists($IOdir . "tags_dt_raw")) { copy($IOdir . "tags_dt_raw", $IOdir . "old_tags_dt_raw"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_tags_dt_raw', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "tags_dt_raw"); } if (file_exists($IOdir . "tags_dd")) { copy($IOdir . "tags_dd", $IOdir . "old_tags_dd"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_tags_dd', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "tags_dd"); } if (file_exists($IOdir . "metadata_dd")) { copy($IOdir . "metadata_dd", $IOdir . "old_metadata_dd"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_metadata_dd', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "metadata_dd"); } if (file_exists($IOdir . "uses_dd")) { copy($IOdir . "uses_dd", $IOdir . "old_uses_dd"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_uses_dd', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "uses_dd"); } if (file_exists($IOdir . "tags_dd")) { copy($IOdir . "tags_dd", $IOdir . "old_tags_dd"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_tags_dd', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "tags_dd"); } if (file_exists($IOdir . "replinks_dd")) { copy($IOdir . "replinks_dd", $IOdir . "old_replinks_dd"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_replinks_dd', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "replinks_dd"); } if (file_exists($IOdir . "clusters_metadata")) { copy($IOdir . "clusters_metadata", $IOdir . "old_clusters_metadata"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_clusters_metadata', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "clusters_metadata"); } if (file_exists($IOdir . "clusters_uses")) { copy($IOdir . "clusters_uses", $IOdir . "old_clusters_uses"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_clusters_uses', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "clusters_uses"); } if (file_exists($IOdir . "clusters_tags")) { copy($IOdir . "clusters_tags", $IOdir . "old_clusters_tags"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_clusters_tags', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "clusters_tags"); } if (file_exists($IOdir . "clusters_replinks")) { copy($IOdir . "clusters_replinks", $IOdir . "old_clusters_replinks"); if (PHP_OS == "Linux") { chmod($IOdir . 'old_clusters_replinks', 0666); } //set rw permissions for everybody for this file unlink($IOdir . "clusters_replinks"); } //if you chose to use the Sesame RDF if ($data_source == 1) { require_once $CONFIG->path . "mod/mmsearch/custom/MeducatorParser.php"; file_put_contents($outputfile, "Downloading a new snapshot of data from the SESAME RDF...\n", FILE_APPEND); $address_base = $CONFIG->API_URL . "searchall?properties="; $metadatas_fields = explode(";", $metadata_fields); sort($metadatas_fields); $usess_fields = explode(";", $uses_fields); sort($usess_fields); $tagss_fields = explode(";", $tags_fields); sort($tagss_fields); $fields = array_unique(array_merge($metadatas_fields, $usess_fields, $tagss_fields)); if (!in_array("hasRepurposingContext", $fields)) { $fields[] = "hasRepurposingContext"; } //in order to return the "repurposedFrom" part as well, used for Replinks $finalresults = array(); foreach ($fields as $field) { if ($field == "seeAlso" || $field == "type") { continue; } //the first one is included by default, the second causes error $address = $address_base . "mdc:{$field}"; //I can't put all the fields together right now, since it will return only the resources that have all those fields, so I do a query field after field and then I make the union of the results $rdf_info = connectToSesame($address); $medParser = new MeducatorParser($rdf_info, true); $results = $medParser->results; foreach ($results as $key => $result) { if (array_key_exists($key, $finalresults)) { $finalresults[$key] = array_merge($finalresults[$key], $result); } else { $finalresults[$key] = $result; } } } //$b=print_r($finalresults,true); //file_put_contents("bbbb",$b); if (count($finalresults) > 0) { //we have to create a LearningResource object for each result and insert metadata into it foreach ($finalresults as $id => $data) { $seeAlso = $data["seeAlso"]; if (is_array($seeAlso)) { $values = array_unique(get_values($seeAlso, "seeAlso")); foreach ($values as $value) { if (strrchr($value, "#") != FALSE) { $guid = substr(strrchr($value, "#"), 1); break; } } } else { $guid = substr(strrchr($seeAlso, "#"), 1); } $entity = get_entity($guid); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (empty($entity)) { continue; } //this is a temporary check from the database since we still need it in order not to have problem with the normal search that still takes info from it ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $lr[$guid] = new LearningResource(); $lr[$guid]->setName($entity->get('name')); $lr[$guid]->setUsername($entity->get('username')); $lr[$guid]->setGUID($guid); //we extract the important part from each field and insert in the $lr[$guid] object foreach ($fields as $field) { $notused = array("type", "hasRepurposingContext"); if (in_array($field, $notused)) { continue; } //"type" is more difficult to handle, anyway we don't need it; "hasRepurposingContext" is used later for Replinks $value = ""; if (!is_array($data[$field])) { $value = $data[$field]; } elseif (isset($data[$field]["name"])) { $value = $data[$field]["name"]; } elseif (isset($data[$field]["label"])) { $value = $data[$field]["label"]; } else { //if we have different elements foreach ($data[$field] as $subfield) { if (!is_array($subfield)) { $subvalue = $subfield; } elseif (isset($subfield["name"])) { $subvalue = $subfield["name"]; } elseif (isset($subfield["label"])) { $subvalue = $subfield["label"]; } else { continue; } //I think there are not other cases, but if so, don't handle them in order to avoid errors if (is_array($subvalue)) { $subvalue = implode(";", $subvalue); } //if it is still an array, transform it in a string $value .= $subvalue . ";"; } $value = substr($value, 0, -1); //delete the last ; } if (is_array($value)) { $value = implode(";", $value); } //if it is still an array, transform it in a string if (strrchr($value, "#") != FALSE) { $value = substr(strrchr($value, "#"), 1); } //take only the important part if ($value != "") { $lr[$guid]->insertMetadata($field, $value); } } //now I add to the tags of the resource eventual tags added by the users $objs = get_entities_from_metadata('', '', 'object', '', '', 10000); foreach ($objs as $obj) { if ($obj->subtype == '28') { //I get only the objects that are bookmarks $link = $CONFIG->url . "pg/profile/" . $entity->get('username'); if ($obj->address == $link) { //I consider the bookmark only if it is a bookmark to the current resource if (!empty($obj->tags)) { if (is_array($obj->tags)) { $lr[$guid]->tags = array_merge($lr[$guid]->tags, $obj->tags); } else { $lr[$guid]->tags[] = $obj->tags; } } } } } //insert $replinks["from"] if (is_array($data["hasRepurposingContext"])) { $values = array_unique(get_values($data["hasRepurposingContext"], "seeAlso")); foreach ($values as $value) { $guid_from = substr(strrchr($value, "#"), 1); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $entity = get_entity($guid_from); if (empty($entity)) { continue; } //this is a temporary check from the database since we still need it in order not to have problem with the normal search that still takes info from it ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $lr[$guid]->replinks["from"][] = $guid_from; } } } //insert replinks["to"] foreach ($lr as $guid => $resource) { foreach ($resource->replinks["from"] as $guid_from) { $lr[$guid_from]->replinks["to"][] = $guid; } } } else { file_put_contents($outputfile, "\n\nNo resources returned. There must be an error somewhere...", FILE_APPEND); exit; } } elseif ($data_source == 2) { file_put_contents($outputfile, "Downloading a new snapshot of data from the Metamorphosis database...\n", FILE_APPEND); $metadatas_fields = explode(";", $metadata_fields); sort($metadatas_fields); $usess_fields = explode(";", $uses_fields); sort($usess_fields); $tagss_fields = explode(";", $tags_fields); sort($tagss_fields); $fields = array_unique(array_merge($metadatas_fields, $usess_fields, $tagss_fields)); $query = "SELECT distinct e.* from elggentities e join elggusers_entity u on e.guid = u.guid JOIN (SELECT subm1.*, s1.string FROM elggmetadata subm1 JOIN elggmetastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid where ((m1.name_id='440' AND m1.string IN ('356'))) and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes') order by e.time_created desc"; $entities = get_data($query, "entity_row_to_elggstar"); foreach ($entities as $entity) { $guid = $entity->getGUID(); $lr[$guid] = new LearningResource(); $lr[$guid]->setName($entity->get('name')); $lr[$guid]->setUsername($entity->get('username')); $lr[$guid]->setGUID($guid); $categorized_fields = profile_manager_get_categorized_fields($entity, true); $cats = $categorized_fields['categories']; $db_fields = $categorized_fields['fields']; if (!empty($db_fields)) { foreach ($cats as $cat_guid => $cat) { foreach ($db_fields[$cat_guid] as $db_field) { $metadata_name = $db_field->metadata_name; // get options $options = $db_field->getOptions(); // get type of db_field if ($db_field->user_editable == "no") { $valtype = "non_editable"; } else { $valtype = $db_field->metadata_type; } $field = $db_field->getTitle(); if (in_array($field, $fields)) { // get value if ($metadata = get_metadata_byname($entity->guid, $metadata_name)) { //print_r($metadata); if (is_array($metadata)) { $value = ''; foreach ($metadata as $md) { if (!empty($value)) { $value .= ', '; } $value .= $md->value; $access_id = $md->access_id; } } else { $value = $metadata->value; $access_id = $metadata->access_id; } } else { $value = ''; $access_id = ACCESS_DEFAULT; } if ($value != "") { $lr[$guid]->insertMetadata($field, $value); } } } } } //now I add to the tags of the resource eventual tags added by the users $objs = get_entities_from_metadata('', '', 'object', '', '', 10000); foreach ($objs as $obj) { if ($obj->subtype == '28') { //I get only the objects that are bookmarks $link = $CONFIG->url . "pg/profile/" . $entity->get('username'); if ($obj->address == $link) { //I consider the bookmark only if it is a bookmark to the current resource if (!empty($obj->tags)) { if (is_array($obj->tags)) { $lr[$guid]->tags = array_merge($lr[$guid]->tags, $obj->tags); } else { $lr[$guid]->tags[] = $obj->tags; } } } } } } //insert replinks foreach ($lr as $guid => $resource) { $entity = get_entity($guid); $lr[$guid]->insertReplinks($entity, $lr); } } krsort($lr); $guids = array_keys($lr); file_put_contents($IOdir . 'guids', serialize($guids)); //it saves guids in the file 'guids' if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'guids')) { chmod($IOdir . 'guids', 0666); } //set rw permissions for everybody for this file file_put_contents($IOdir . 'lr', serialize($lr)); //it saves resources in the file 'lr' if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'lr')) { chmod($IOdir . 'lr', 0666); } //set rw permissions for everybody for this file file_put_contents($outputfile, "Got snapshot...\n\n", FILE_APPEND); return "OK"; }
} else { $admin_tmpl['form_add_posts'] = false; $admin_tmpl['form_posts_list'] = true; if (file_exists(MN_ROOT . $file['posts'])) { # read posts file $p_file = file(MN_ROOT . $file['posts']); $posts_result = ''; $timestamps_all = array(); array_shift($p_file); $p_file = mn_natcasesort($p_file); $p_file = array_reverse($p_file, true); $categories = load_basic_data('categories'); $users = load_basic_data('users'); # put posts to arrays - one array for IDs, one for timestamps foreach ($p_file as $p_line) { $temp_var = get_values('posts', $p_line, false); if ($auth != 1 && $temp_var['author'] != $_SESSION['mn_user_id']) { continue; } $temp_var['tags_array'] = !empty($temp_var['tags']) ? explode(',', trim($temp_var['tags'])) : array(); $timestamps_all[$temp_var['timestamp']] = date('Y-m', $temp_var['timestamp']); if (isset($_GET['c']) && !empty($_GET['c']) && $temp_var['cat'] != $_GET['c']) { continue; } if (isset($_GET['d']) && !empty($_GET['d']) && date('Y-m', $temp_var['timestamp']) != $_GET['d']) { continue; } if (isset($_GET['a']) && !empty($_GET['a']) && $temp_var['author'] != $_GET['a']) { continue; } if (isset($_GET['s']) && !empty($_GET['s']) && $temp_var['status'] != $_GET['s']) {
$admin_tmpl['cats_main'] = true; $categories = load_basic_data('categories'); if (file_exists($file['categories_order'])) { $categories_order = unserialize(file_get_contents($file['categories_order'])); } else { $categories_order = array(); $i = 1; foreach ($categories as $id => $cname) { $categories_order[$i] = $id; $i++; } mn_put_contents($file['categories_order'], serialize($categories_order)); } $posts_count = get_posts_count(); if (isset($_REQUEST['action']) && isset($_REQUEST['id'])) { $var = get_values('categories', $_REQUEST['id']); } if (isset($_GET['action']) && $_GET['action'] == 'ajaxcall') { if (isset($_GET['cat_name']) && !empty($_GET['cat_name']) && !in_array($_GET['cat_name'], $categories)) { if (file_exists($file['categories'])) { $cats_file = file($file['categories']); $cats_file_lines = ''; foreach ($cats_file as $single_line) { $cat_data = explode(DELIMITER, $single_line); if (substr($cat_data[0], 0, 2) == '<?') { $auto_increment_id = trim($cat_data[1]); } else { $cats_file_lines .= $single_line; } } } else {
include_once dirname(__FILE__) . "/../../config/environment.php"; require_library('ResourceDataObjectElementsSetting'); $timestart = time_elapsed(); $resource_id = 20; $resource_path = "http://www.pensoft.net/J_FILES/EoLData/ZooKeys.xml"; $result = $GLOBALS['db_connection']->select("SELECT accesspoint_url FROM resources WHERE id={$resource_id}"); if ($result && ($row = $result->fetch_row())) { $resource_path_from_registry = $row[0]; if ($resource_path != $resource_path_from_registry && $resource_path_from_registry != '') { $resource_path = $resource_path_from_registry; } } echo "\n processing resource: {$resource_path} \n"; if ($local_path = Functions::save_remote_file_to_local($resource_path, array('download_wait_time' => 1000000, 'timeout' => 600, 'download_attempts' => 5))) { $func = new ResourceDataObjectElementsSetting($resource_id, $local_path); $dataObjects = get_values($local_path); $xml = remove_elements($local_path); $func->save_resource_document($xml); $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml"; $xml = fill_up_values($resource_path, $dataObjects); $func->save_resource_document($xml); Functions::set_resource_status_to_force_harvest($resource_id); // remove tmp file unlink($local_path); debug("\n temporary file removed: [{$local_path}]"); } $elapsed_time_sec = time_elapsed() - $timestart; echo "\n"; echo "elapsed time = {$elapsed_time_sec} seconds \n"; echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes \n"; echo "elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours \n";
$temperatures_connect = $temperatures_connect . ',' . $temperatures[$i]; $ozones_connect = $ozones_connect . ',' . $ozones[$i]; $no2s_connect = $no2s_connect . ',' . $no2s[$i]; $humiditys_connect = $humiditys_connect . ',' . $humiditys[$i]; $carbon_monoxide_connect = $carbon_monoxide_connect . ',' . $carbon_monoxide[$i]; } //delete the first sign, here a comma. $names_connect = substr($names_connect, 1); $dates_connect = substr($dates_connect, 1); $times_connect = substr($times_connect, 1); $temperatures_connect = substr($temperatures_connect, 1); $ozones_connect = substr($ozones_connect, 1); $no2s_connect = substr($no2s_connect, 1); $humiditys_connect = substr($humiditys_connect, 1); $carbon_monoxide_connect = substr($carbon_monoxide_connect, 1); //echo $names_connect; //$all_values is an array containing a string for every parameter as mentioned above. $all_values = array(); array_push($all_values, $names_connect); array_push($all_values, $dates_connect); array_push($all_values, $times_connect); array_push($all_values, $temperatures_connect); array_push($all_values, $ozones_connect); array_push($all_values, $no2s_connect); array_push($all_values, $humiditys_connect); array_push($all_values, $carbon_monoxide_connect); return $all_values; } $dies = get_id_coord(); $test = get_values($dies);
$galleries_file_content .= $auto_increment_id . DELIMITER . $_GET['gallery_name'] . DELIMITER . friendly_url($_GET['gallery_name']) . "\n"; if (mn_put_contents($file['galleries'], $galleries_file_content)) { echo '<li><input type="checkbox" name="galleries[]" id="gallery-' . $auto_increment_id . '" class="input-gallery" value="' . $auto_increment_id . '" checked="checked" /> <label for="gallery-' . $auto_increment_id . '">' . substr($_GET['gallery_name'], 0, 20) . '</label></li>'; die; } else { echo 'Error MN#44: cannot write to mn-galleries.php file!'; } die; } else { echo ''; } die; } $auth = user_auth('5'); if (isset($_REQUEST['action']) && isset($_REQUEST['id'])) { $var = get_values('galleries', $_REQUEST['id']); } if (isset($_POST['action']) && $_POST['action'] == 'add') { if (!empty($_POST['gallery_name'])) { if (file_exists($file['galleries'])) { $galleries_file = file($file['galleries']); $galleries_file_lines = ''; foreach ($galleries_file as $single_line) { $gallery_data = explode(DELIMITER, $single_line); if (substr($gallery_data[0], 0, 2) == '<?') { $auto_increment_id = trim($gallery_data[1]); } else { $galleries_file_lines .= $single_line; } } } else {
<span class="help"><?php echo $lang['users_avatar_help']; ?> <span class="simurl" onclick="document.getElementById('avatar-info').style.display = 'none'; document.getElementById('avatar-controls').style.display = 'block'; return false;">(<?php echo mb_strtolower($lang['uni_cancel'], 'UTF-8'); ?> )</span></span> </div> </form> </body> </html> <?php die; } else { $var = get_values('users', $_SESSION['mn_user_id']); $bday = explode('-', $var['birthdate']); $var['bday_day'] = @$bday[2]; $var['bday_month'] = @$bday[1]; $var['bday_year'] = @$bday[0]; if (isset($_GET['back']) && $_GET['back'] == 'edited') { overall_header($lang['users_profile'], $lang['users_msg_profile_edited'], 'ok'); } else { overall_header($lang['users_profile'], $lang['users_profile'] . ': ' . $_SESSION['mn_user_name'], 'main'); } } ?> <form action="./mn-profile.php" method="post" id="profile-edit" class="profile-form"> <fieldset>
$c_aprocess++; } elseif ($c_data[3] == 0) { continue; } $comments[] .= $c_line; } } } if (!empty($comments)) { $comments = mn_natcasesort($comments); $comments = array_reverse($comments); $comments_count = count($comments); $j_max = isset($widget_counts[1]) && is_numeric($widget_counts[1]) ? $widget_counts[1] : 5; $j_max = $comments_count < $j_max ? $comments_count : $j_max; for ($j = 0; $j < $j_max; $j++) { $c = get_values('comments', $comments[$j], false); $cp = get_post_data($c['post_id']); $c['timestamp'] = $c['timestamp'] + $conf['time_adj'] * 3600; if (mb_strlen($cp['title']) > 16) { $tooltip = ' title="' . $cp['title'] . '"'; $cp['title'] = mb_substr($cp['title'], 0, 15, 'utf-8') . '…'; } else { $cp['title']; $tooltip = ''; } if (isset($widget_counts[1]) && $widget_counts[1] == 'new' && ($c['timestamp'] < $_SESSION['mn_last_login'] || empty($_SESSION['mn_last_login']))) { continue; } else { $ua_info = get_useragent_info($c['user_agent']); $comments_result .= '<tr id="c' . $c['comment_id'] . '"><td class="c_author"><a href="./?p=' . $c['post_id'] . '#c-' . $c['comment_id'] . '">#</a> <strong>' . $c['author_name'] . '</strong><br /> <span class="info hide comment_status"><a href="./?p=' . $c['post_id'] . '"' . $tooltip . '>' . $cp['title'] . '</a></span></td><td class="edit"><img src="./stuff/img/icons/information-gray.png" alt="" class="tooltip" title="<strong>' . $lang['uni_date'] . ':</strong> ' . date('d.m.Y H:i', $c['timestamp']) . '<br /><strong>' . $lang['comm_ip_address'] . ':</strong> ' . $c['ip_address'] . '<br /><strong>' . $lang['comm_host'] . ':</strong> ' . $c['host'] . '<br /><strong>' . $lang['comm_user_browser'] . ':</strong> ' . $ua_info['browser'] . '<br /><strong>' . $lang['comm_user_os'] . ':</strong> ' . $ua_info['os'] . '" /><p><a href="./mn-comments.php?action=edit&post=' . $c['post_id'] . '&id=' . $c['comment_id'] . '" class="tooltip" title="' . $lang['uni_edit'] . '"><img src="./stuff/img/icons/edit-gray.png" alt="" /></a></p></td><td class="edit"><a href="./mn-comments.php?action=reply&post=' . $c['post_id'] . '&id=' . $c['comment_id'] . '" class="fancy tooltip" title="' . $lang['comm_reply'] . '"><img src="./stuff/img/icons/reply-gray.png" alt="" /></a><p><a href="./mn-comments.php?a=m&s=0&f=' . $c['post_id'] . '&c=' . $c['comment_id'] . '&t=' . $_SESSION['mn_token'] . '&from=index" class="ajaxcall tooltip" title="' . $lang['uni_delete'] . '"><img src="./stuff/img/icons/cross-gray.png" alt="" /></a></p></td><td><div class="comment-text">' . comment_format($c['comment_text']) . '</div></td></tr>'; }
function clone_object($object) { $values = get_values($object); return build_object(get_class($object), $values); }
} else { $error_message = $lang['users_msg_email_check']; } } else { $error_message = $lang['users_msg_forbidden_chars']; } } else { $error_message = $lang['users_msg_values_length']; } } else { $error_message = $lang['users_msg_empty_values']; } $var = array('user_id' => $_POST['id'], 'username' => $_POST['username'], 'email' => $_POST['email'], 'group' => $_POST['group'], 'status' => $_POST['status'], 'nickname' => $_POST['nickname'], 'gender' => $_POST['gender'], 'bday_day' => $_POST['bday_day'], 'bday_month' => $_POST['bday_month'], 'bday_year' => $_POST['bday_year'], 'location' => $_POST['location'], 'www' => $_POST['www'], 'icq' => $_POST['icq'], 'msn' => $_POST['msn'], 'skype' => $_POST['skype'], 'jabber' => $_POST['jabber'], 'about' => check_text($_POST['about'])); overall_header($lang['users_add_new_user'] . ' » ' . $var['username'], $error_message, 'error'); } elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id']) && $_GET['id'] != 1) { $var = get_values('users', $_GET['id']); $posts_count = get_posts_count('users'); $admin_tmpl['user_delete'] = true; $admin_tmpl['form_users'] = false; } elseif (isset($_POST['action']) && $_POST['action'] == 'delete' && isset($_POST['id']) && $_POST['id'] != 1) { $u_file = file($file['users']); $u_content = ''; foreach ($u_file as $u_line) { $u_data = explode(DELIMITER, $u_line); if ($u_data[0] == $_POST['id']) { continue; } else { $u_content .= $u_line; } } if (mn_put_contents($file['users'], $u_content)) {
function print_indicator_content($conn, $rs, $linked = 1) { $host_types = array("host", "server", "sensor"); // Linked to another map: loop by this map indicators if (preg_match("/view\\.php\\?map\\=(\\d+)/", $rs->fields['url'], $found)) { list($RiskValue, $VulnValue, $AvailValue, $v_ip, $a_ip, $name, $sensor, $type, $ips, $what, $in_assets) = get_map_values($conn, $found[1], $rs->fields["type_name"], $rs->fields["type"], $host_types); } else { // Asset Values list($name, $sensor, $type, $ips, $what, $in_assets) = get_assets($conn, $rs->fields["type_name"], $rs->fields["type"], $host_types); list($RiskValue, $VulnValue, $AvailValue, $v_ip, $a_ip, $r_ip) = get_values($conn, $host_types, $type, $name, $ips, false); } $gtype = $type == "net" ? "net" : "host"; $ips = $type == "net" ? $ips : $name; $r_url = "../control_panel/show_image.php?ip=" . urlencode($type == "host_group" ? $r_ip : $name) . "&range=week&what=compromise&start=N-1Y&end=N&type={$gtype}&zoom=1&hmenu=Risk&smenu=Metrics"; $v_url = "../vulnmeter/index.php?value=" . urlencode($type == "host_group" ? $v_ip : $ips) . "&type=hn&hmenu=Vulnerabilities&smenu=Vulnerabilities"; $a_url = "../nagios/index.php?sensor=" . urlencode($sensor) . "&hmenu=Availability&smenu=Availability&nagios_link=" . urlencode("/cgi-bin/status.cgi?host=all"); $size = $rs->fields["size"] > 0 ? $rs->fields["size"] : ''; $icon = $rs->fields["icon"]; if (preg_match("/\\#/", $icon)) { $aux = explode("#", $icon); $icon = $aux[0]; $bgcolor = $aux[1]; } else { $bgcolor = "transparent"; } if ($linked == 0) { $url = "javascript:;"; } else { if ($rs->fields["url"] == "REPORT") { $url = "../report/index.php?host=" . $ips; } else { $url = $rs->fields["url"] != '' ? $rs->fields["url"] : "javascript:;"; } } if (!$in_assets) { $icon = "../pixmaps/marker--exclamation.png"; $size = "16"; } $name = mb_detect_encoding($rs->fields["name"] . " ", 'UTF-8,ISO-8859-1') == 'UTF-8' ? $rs->fields["name"] : mb_convert_encoding($rs->fields["name"], 'UTF-8', 'ISO-8859-1'); ?> <table width="100%" border='0' cellspacing='0' cellpadding='1' style="background-color:<?php echo $bgcolor; ?> "> <tr> <td colspan='2' align='center'> <a href="<?php echo $url; ?> " class="ne"><i><?php echo $name; ?> </i></a> </td> </tr> <tr> <td> <a href="<?php echo $url; ?> "><img src="<?php echo $icon; ?> " width="<?php echo $size; ?> " border='0'/></a> </td> <td> <table border='0' cellspacing='0' cellpadding='1'> <tr> <td><a class="ne11" target="main" href="<?php echo $r_url; ?> ">R</a></td> <td><a class="ne11" target="main" href="<?php echo $v_url; ?> ">V</a></td> <td><a class="ne11" target="main" href="<?php echo $a_url; ?> ">A</a></td> </tr> <tr> <td><img src="images/<?php echo $RiskValue; ?> .gif" border='0'/></td> <td><img src="images/<?php echo $VulnValue; ?> .gif" border='0'/></td> <td><img src="images/<?php echo $AvailValue; ?> .gif" border='0'/></td> </tr> </table> </td> </tr> </table> <?php }
} $db = new ossim_db(); $conn = $db->connect(); $params = array($map); $query = "select * from risk_indicators where name <> 'rect' AND map= ? "; if (!($rs =& $conn->Execute($query, $params))) { print $conn->ErrorMsg(); } else { while (!$rs->EOF) { $name = $rs->fields["type_name"]; $type = $rs->fields["type"]; $host_types = array("host", "server", "sensor"); $what = "name"; $ips = $name; $in_assets = 1; list($RiskValue, $VulnValue, $AvailValue, $sensor, $r_ip, $v_ip) = get_values($conn, $host_types, $type, $name); $new_value = "txt" . $RiskValue . $VulnValue . $AvailValue; $gtype = $type == "net" ? "net" : "host"; $ips = $type == "net" ? $ips : $name; $r_url = "../control_panel/show_image.php?ip=" . urlencode($type == "host_group" ? $r_ip : $name) . "&range=year&what=compromise&start=N-1Y&end=N&type={$gtype}&zoom=1&hmenu=Risk&smenu=Metrics"; $v_url = "../vulnmeter/index.php?value=" . urlencode($type == "host_group" ? $v_ip : $ips) . "&type=hn&hmenu=Vulnerabilities&smenu=Vulnerabilities"; //$a_url = "../nagios/index.php?sensor=".urlencode($sensor)."&hmenu=Availability&smenu=Availability&detail=".urlencode(($type == "host_group") ? $a_ip : $ips).""; $a_url = "../nagios/index.php?sensor=" . urlencode($sensor) . "&hmenu=Availability&smenu=Availability&nagios_link=" . urlencode("/cgi-bin/status.cgi?host=all"); $change_div = "changeDiv('" . $rs->fields["id"] . "','" . $rs->fields["name"] . "','" . $rs->fields["url"] . "','" . $rs->fields["icon"] . "',{$new_value},'{$r_url}','{$v_url}','{$a_url}','{$ips}'," . $rs->fields["size"] . ");\n"; if ($in_assets) { echo $change_div; } $rs->MoveNext(); } } $conn->close();
//$array_connect will contain a string so it ist easy to overgive it to javascript $array_connect = ''; for ($i = 0; $i < count($id_coord); $i++) { $array_connect = $array_connect . ',' . $id_coord[$i]; } $array_connect = substr($array_connect, 1); /* $result=pg_query("select * from sensor_measureddata_join where id=75759 and date= (select max(date)from \"MeasuredData\" where \"sensorId\"=75759);"); $data = pg_fetch_object($result); $timestamp=$data->date; $date=substr($timestamp,0,10); $sub=explode("-",$date); $date=" ".$sub[2]."-".$sub[1]."-".$sub[0]; $time=substr($timestamp,10,9);*/ //The following line retrieves all values from every parameter for every ID, $all_values is an array. See pg_value_functions. $all_values = get_values(get_id_coord()); $anzahl = count($all_values); ?> //$all_values is an array. In every slot is a string with the values for one parameter. The following lines split these //strings so they can be used for the popups. var split_names="<?php echo $all_values[0]; ?> ".split(","); split_dates="<?php echo $all_values[1]; ?> ".split(","); split_times="<?php
/** * @internal * * @param string $namespace * @param string $key * @param object $object */ protected function addObject($namespace, $key, $object) { if (false == isset($this->values[$namespace][$key])) { $this->values[$namespace][$key] = []; } if (false == isset($this->objects[$namespace][$key])) { $this->objects[$namespace][$key] = []; } $objectKey = count($this->values[$namespace][$key]); $this->objects[$namespace][$key][$objectKey] = $object; $this->values[$namespace][$key][$objectKey] = get_values($object); $this->changedValues[$namespace][$key][$objectKey] = get_values($object); set_values($object, $this->values[$namespace][$key][$objectKey], true); }
$line .= $tmp; } if (preg_match('@^INSERT\\s@', $line)) { $line = preg_replace('@^INSERT.*?VALUES\\s@', '', $line); } else { if ($line[0] != '(') { continue; } } print "\r" . $progress[$j % 4]; $line = rtrim($line, "\n;"); $pos = strpos($line, '('); if ($pos !== false) { $line = substr($line, $pos); $offset = 0; $arr = get_values($line, $offset); for ($i = 0; $i < sizeof($arr); $i += $fields) { // pagename $pagename = $arr[$i + DUMP_TITLE]; // filename $filename = $DBInfo->pageToKeyname($pagename); // mtime $mtime = $arr[$i + DUMP_TIMESTAMP]; fwrite($lp, $pagename . "\t" . $filename . "\n"); $body = $arr[$i + DUMP_BODY]; echo "\r", $pagename, "\n"; if (strlen($filename) < 255) { if (!file_exists($dest_dir . '/' . $filename)) { file_put_contents($dest_dir . '/' . $filename, $body); } if ($mtime > 0) {
header('Location: ./mn-files.php?action=bulk&a=edit&files=' . $arrgs); exit; } $files_file = file($file['files']); $files_lines = ''; foreach ($files_file as $single_line) { $f_data = explode(DELIMITER, $single_line); // bulk delete if ($_POST['a'] == 'delete' && in_array($f_data[0], $_POST['files'])) { unlink(MN_ROOT . $dir['files'] . $f_data[5] . '/' . $f_data[1] . '.' . $f_data[2]); if (file_exists(MN_ROOT . $dir['thumbs'] . '_' . $f_data[1] . '.' . $f_data[2])) { @unlink(MN_ROOT . $dir['thumbs'] . '_' . $f_data[1] . '.' . $f_data[2]); } continue; } elseif ($_POST['a'] == 'edit' && in_array($f_data[0], $_POST['files'])) { $var = get_values('files', $single_line, false); $id = $var['file_id']; $old_file = $var['filename'] . '.' . $var['ext']; $new_filename = !empty($_POST['filename'][$id]) ? $_POST['filename'][$id] : $var['filename']; $new_file = $new_filename . '.' . $var['ext']; if ($old_file != $new_file) { rename(MN_ROOT . $dir[$var['dir']] . $old_file, MN_ROOT . $dir[$var['dir']] . $new_file); @mkdir(MN_ROOT . $dir[$var['dir']] . $new_file, 0777); @chmod(MN_ROOT . $dir[$var['dir']] . $new_file, 0777); if ($var['dir'] == 'images' && file_exists(MN_ROOT . $dir['thumbs'] . '_' . $old_file)) { rename(MN_ROOT . $dir['thumbs'] . '_' . $old_file, MN_ROOT . $dir['thumbs'] . '_' . $new_file); @mkdir(MN_ROOT . $dir['thumbs'] . '_' . $new_file, 0777); @chmod(MN_ROOT . $dir['thumbs'] . '_' . $new_file, 0777); } } $file_title = check_text($_POST['title'][$id], true);
function post_data($table, $fields, $types) { global $mysqli; $data = get_body($fields); if (is_null($data)) { return null; } $query = "INSERT INTO {$table} (" . join(', ', $fields) . ") VALUES (" . get_values($data, $types) . ")"; $result = $mysqli->query($query); return $result ? get_data_by_id($table, $mysqli->insert_id) : null; }
foreach ($c_file as $c_line) { $comments[] .= $c_line; } } } } $c_trash = 0; if (!empty($comments)) { $comments = mn_natcasesort($comments); $comments = array_reverse($comments); $comments_result = ''; $c_count = 0; $c_authors = array(); $c_ips = array(); foreach ($comments as $comments_line) { $var = get_values('comments', $comments_line, false); $post = get_post_data($var['post_id']); $comments_timestamps[$var['timestamp']] = date('Y-m', $var['timestamp']); if (isset($var['author_id']) && !empty($var['author_id'])) { $c_authors[] = $var['author_id']; } if (isset($var['ip_address']) && !empty($var['ip_address'])) { $c_ips[] = $var['ip_address']; } if (isset($var['status']) && $var['status'] == 0) { $c_trash++; } $posts[$post['id']] = $post['title']; if (!isset($_GET['trash']) && $var['status'] == 0) { continue; }
function get_types($dbc, $id) { return get_values($dbc, PREFIX . $id, '类型'); }
$var['tmpl_name'] = check_text($_POST['tmpl_name']); $var['tmpl_content'] = stripslashes($_POST['tmpl']); overall_header($lang['tmpl_templates'], $lang['tmpl_msg_empty_tmpl_name'], 'error'); } } } elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && !in_array($_GET['id'], $default_templates)) { if ($_GET['id'] < 21) { $var['tmpl_name'] = $lang['tmpl_tmpl_name_' . $_GET['id']]; $var['tmpl_id'] = $_GET['id']; } else { $var = get_values('templates', $_GET['id']); } $admin_tmpl['tmpl_delete'] = true; } elseif (isset($_POST['action']) && $_POST['action'] == 'delete' && isset($_POST['id']) && !in_array($_POST['id'], $default_templates)) { if ($_POST['id'] > 20) { $var = get_values('templates', $_POST['id']); $t_file = file($file['templates']); $t_content = ''; foreach ($t_file as $single_line) { $t_data = explode(DELIMITER, $single_line); if ($t_data[0] == $_POST['id']) { continue; } else { $t_content .= $single_line; } } if (mn_put_contents($file['templates'], $t_content) && unlink($dir['templates'] . $t_groups[$var['tmpl_group']] . '_' . $var['tmpl_type'] . '.html')) { header('location: ./mn-templates.php?back=deleted'); exit; } else { overal_header($lang['tmpl_templates'], $lang['tmpl_msg_put_contents_error'], 'error');
$encoding = mb_detect_encoding($string, "UTF-8", true); if ($encoding != FALSE) { $basic['DetectEncoding'] = $encoding; } else { $basic['DetectEncoding'] = "Encoding: Not detected"; } //Activty or Organisation specific tests if (xml_child_exists($xml, "//iati-activity")) { //ignore organisation files $checking_activity_file = true; $basic['activities'] = count($xml->xpath("//iati-activity")); //$generated = $xml->attributes()->{'generated-datetime'}; //$version = $xml->attributes()->version; //$activities = count($xml->xpath("//iati-activity")); $hierarchies = $xml->xpath("//@hierarchy"); $basic['hierarchies'] = get_values($hierarchies, "int"); } elseif (xml_child_exists($xml, "//iati-organisation")) { $checking_organisation_file = true; $org_identifier = $xml->xpath("//iati-identifier"); $basic['org_iati_identifier'] = (string) $org_identifier[0]; //print_r($xml->xpath("//name")); die; $org_name = $xml->xpath("//name"); //a simplexml object $name = (string) $org_name[0]; $basic['org_name'] = $name; //$basic['org_name'] = $basic['org_name']->0; $org_ref = $xml->xpath("//reporting-org/@ref"); $basic['org_reporting_org_ref'] = (string) $org_ref[0]; $basic['org_recipient_country_budget'] = count($xml->xpath("//recipient-country-budget")); $basic['org_recipient_org_budget'] = count($xml->xpath("//recipient-org-budget")); $basic['org_total_budget'] = count($xml->xpath("//total-budget"));