function output_list($type, $list, $fields, $idstr) { switch ($type) { case 'xml': xml_header($fields); xml_data($list, $fields); xml_footer(); break; case 'dom': dom_header($fields); dom_data($list, $fields); dom_footer(); break; case 'img': img_header($fields); img_data($list, $fields, $idstr); img_footer(); break; case 'csv': default: csv_header($fields); csv_data($list, $fields); csv_footer(); break; } }
function write_major_file($code, $data, $type) { $pointer = new XMLWriter(); $time = strftime("%Y-%m-%d %H:%m:%S"); foreach (array_keys($data) as $group) { echo "writing major xml files for: {$group}\n"; $dir = realpath(dirname(dirname(__FILE__)) . "/modules") . "/isco_{$code}/modules/" . "isco_{$code}_major_{$group}"; if (!is_dir($dir)) { if (!mkdir($dir, 0777, TRUE)) { echo "Couldn't make {$dir}!"; exit(1); } } $pointer->openURI("file://{$dir}/majorgroup" . $group . ".xml"); xml_header($pointer, $code, $group); foreach ($type as $i => $level) { write_group($pointer, $i, $level, $code, $group, $data[$group], $time, $type); } xml_footer($pointer); $pointer->flush(); } }
// BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // BOINC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see <http://www.gnu.org/licenses/>. require_once "../inc/forum_db.inc"; require_once "../inc/util.inc"; require_once "../inc/xml.inc"; xml_header(); if (DISABLE_FORUMS) { xml_error(-1, "Forums are disabled"); } $retval = db_init_xml(); if ($retval) { xml_error($retval); } $method = get_str("method", true); if ($method != "user_posts" && $method != "user_threads") { xml_error(-1); } $userid = get_int("userid", true); $user = BoincUser::lookup_id($userid); if (!$user) { xml_error(ERR_DB_NOT_FOUND);
function show_status_xml($x) { xml_header(); echo "<server_status>\n<daemon_status>\n"; $daemons = $x->daemons; foreach ($daemons->local_daemons as $d) { daemon_xml($d); } foreach ($daemons->remote_daemons as $d) { daemon_xml($d); } foreach ($daemons->disabled_daemons as $d) { daemon_xml($d); } echo "</daemon_status>\n<database_file_states>\n"; $j = $x->jobs; item_xml("results_ready_to_send", $j->results_ready_to_send); item_xml("results_in_progress", $j->results_in_progress); item_xml("workunits_waiting_for_validation", $j->wus_need_validate); item_xml("workunits_waiting_for_assimilation", $j->wus_need_assimilate); item_xml("workunits_waiting_for_deletion", $j->wus_need_file_delete); item_xml("results_waiting_for_deletion", $j->results_need_file_delete); item_xml("transitioner_backlog_hours", $j->transitioner_backlog); item_xml("users_with_recent_credit", $j->users_with_recent_credit); item_xml("users_with_credit", $j->users_with_credit); item_xml("users_registered_in_past_24_hours", $j->users_past_24_hours); item_xml("hosts_with_recent_credit", $j->hosts_with_recent_credit); item_xml("hosts_with_credit", $j->hosts_with_credit); item_xml("hosts_registered_in_past_24_hours", $j->hosts_past_24_hours); item_xml("current_floating_point_speed", $j->flops); echo "<tasks_by_app>\n"; foreach ($j->apps as $app) { echo "<app>\n"; item_xml("id", $app->id); item_xml("name", $app->name); item_xml("unsent", $app->unsent); item_xml("in_progress", $app->in_progress); item_xml("avg_runtime", $app->info->avg); item_xml("min_runtime", $app->info->min); item_xml("max_runtime", $app->info->max); item_xml("users", $app->info->users); echo "</app>\n"; } echo "</tasks_by_app>\n</database_file_states>\n</server_status>\n"; }
/** * Exports data of the given range. * * This function calls the functions that export the data sepcified by the given $export_range. * It calls the function output_data afterwards. * * @access public * @param string $range_id Stud.IP-range_id for export */ function export_range($range_id) { global $o_mode, $range_name, $ex_person_details, $persons, $ex_sem; // Ist die Range-ID eine Einrichtungs-ID? $query = "SELECT Name FROM Institute WHERE Institut_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); $name = $statement->fetchColumn(); if ($name) { $range_name = $name; output_data(xml_header(), $o_mode); $output_startet = true; export_inst($range_id); } // Ist die Range-ID eine Fakultaets-ID? Dann auch untergeordnete Institute exportieren! $query = "SELECT Name, Institut_id\n FROM Institute\n WHERE fakultaets_id = ? AND Institut_id != fakultaets_id"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { if ($row['Name'] != '') { // output_data ( xml_header(), $o_mode); export_inst($row['Institut_id']); } } // Ist die Range-ID eine Seminar-ID? $query = "SELECT Name, Seminar_id, Institut_id\n FROM seminare\n WHERE Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); $row = $statement->fetch(PDO::FETCH_ASSOC); if ($row && $row['Name'] != '') { $range_name = $row['Name']; if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } export_inst($row['Institut_id'], $row['Seminar_id']); } // Ist die Range-ID ein Range-Tree-Item? if ($range_id != 'root') { $tree_object = new RangeTreeObject($range_id); $range_name = $tree_object->item_data["name"]; // Tree-Item ist ein Institut: if ($tree_object->item_data['studip_object'] == 'inst') { if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } export_inst($tree_object->item_data['studip_object_id']); } // Tree-Item hat Institute als Kinder: $inst_array = $tree_object->GetInstKids(); if (count($inst_array) > 0) { if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } while (list($key, $inst_ids) = each($inst_array)) { export_inst($inst_ids); } } } $query = "SELECT 1 FROM sem_tree WHERE sem_tree_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($range_id)); if ($statement->fetchColumn() || $range_id == 'root') { if (!$output_startet) { output_data(xml_header(), $o_mode); $output_startet = true; } if (isset($ex_sem) && ($semester = Semester::find($ex_sem))) { $args = array('sem_number' => array(SemesterData::GetSemesterIndexById($ex_sem))); } else { $args = array(); } if ($range_id != 'root') { $the_tree = TreeAbstract::GetInstance('StudipSemTree', $args); $sem_ids = array_unique($the_tree->getSemIds($range_id, true)); } if (is_array($sem_ids) || $range_id == 'root') { if (is_array($sem_ids)) { $query = "SELECT DISTINCT Institut_id\n FROM seminare\n WHERE Seminar_id IN (?)"; $statement = DBManager::get()->prepare($query); $statement->execute(array($sem_ids)); $to_export = $statement->fetchAll(PDO::FETCH_COLUMN); } else { $sem_ids = 'root'; $query = "SELECT DISTINCT Institut_id\n FROM seminare\n INNER JOIN seminar_sem_tree USING (seminar_id)"; if ($semester) { $query .= " WHERE seminare.start_time <= :begin\n AND (:begin <= (seminare.start_time + seminare.duration_time) OR\n seminare.duration_time = -1)"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':begin', $semester->beginn); $statement->execute(); } else { $statement = DBManager::get()->query($query); } $to_export = $statement->fetchAll(PDO::FETCH_COLUMN); } foreach ($to_export as $inst) { export_inst($inst, $sem_ids); } } } if ($ex_person_details && is_array($persons)) { export_persons(array_keys($persons)); } output_data(xml_footer(), $o_mode, $flush = true); }
/** * Display an XML error. */ function display_xml_error($e) { xml_header(); ?> <error time="<?php echo iso_date(); ?> "> <?php echo xmlescape($e->getMessage()); ?> </error> <?php die; }
function show_teams_xml($list) { xml_header(); echo "<teams>\n"; sort_list($list); foreach ($list as $team) { show_team_xml($team); } echo "</teams>\n"; }
function write_error($errorCode, $requestArray) { $tree =& xml_header(); $root =& $tree->getRoot(); $xml_error =& $root->addChild('Error'); $errorDescription = errorDescription($errorCode); $xml_errorCode =& $xml_error->addChild('Code', $errorCode); $xml_errorDescription =& $xml_error->addChild('Description', $errorDescription); send($tree, $requestArray); }
$sql_sort = "p.post_time DESC"; } else { $sql_sort = "rand()"; } $sql_news = ''; if ($news_type == 'news') { $sql_news = "AND t.news_id > 0"; } $sql = "SELECT t.topic_id, t.topic_title, t.topic_first_post_id, u.user_id, u.username, p.post_time\n\t\tFROM " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS p\n\t\tWHERE t.forum_id IN (" . $allowed_forums . ")\n\t\t\t\tAND u.user_id = t.topic_poster\n\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\t" . $sql_news . "\n\t\tORDER BY " . $sql_sort . "\n\t\tLIMIT " . $news_items; $result = $news_recent ? $db->sql_query($sql, 0, 'posts_flash_', POSTS_CACHE_FOLDER) : $db->sql_query($sql); $xml_content = ''; while ($row = $db->sql_fetchrow($result)) { $topic_title = strip_tags($row['topic_title']); $topic_author = $row['username']; $topic_user_id = $row['user_id']; $news_url = $news_base_address . $news_base_url . '?' . POST_TOPIC_URL . '=' . $row['topic_id']; $xml_content .= '<item url="' . $news_url . '">' . $topic_title . '</item>' . "\n"; } $time = gmdate('D, d M Y H:i:s', time()) . ' GMT'; $xml_content = xml_file_content($xml_content); if ($news_cache) { if ($f = @fopen($news_cache_file, 'w')) { @fwrite($f, $xml_content, strlen($xml_content)); @fclose($f); } } xml_header($time); echo $xml_content; } $db->sql_close(); exit;