function get_entry_xml($entry_file) { global $row, $global_pref; // debug("get_entry_xml: file: $entry_file"); $entry_file = "db/" . $entry_file; $xml = new XMLFile(); $fh = fopen($entry_file, 'r'); if ($fh == false) { piv_error("Index File corrupt!", "One of the xml files needed could not be found. <br /><br />This is can normally be fixed by recreating the index-file. Click <a href='reindex.php'>reindex</a> to do so now, and then go <a href='javascript:history.go(-1)'>back</a> to the last page.", 0); } $xml->read_file_handle($fh); fclose($fh); $row_entrypoint =& $xml->roottag->tags[0]; $row['code'] = rem_code_padding($row_entrypoint->attributes['CODE']); $row['id'] = $row_entrypoint->attributes['UID']; $row['template'] = $row_entrypoint->tags[0]->cdata; $row['date'] = $row_entrypoint->tags[1]->cdata; $row['user'] = $row_entrypoint->tags[2]->cdata; $row['title'] = rem_entities($row_entrypoint->tags[3]->cdata); $row['subtitle'] = rem_entities($row_entrypoint->tags[4]->cdata); $row['introduction'] = rem_entities($row_entrypoint->tags[5]->cdata); $row['body'] = rem_entities($row_entrypoint->tags[6]->cdata); $row['media'] = $row_entrypoint->tags[7]->cdata; $row['links'] = $row_entrypoint->tags[8]->cdata; $row['url'] = $global_pref['pivot_url'] . str_replace("%1", $row['code'], $global_pref['file_format']); $row['xmlfilename'] = $entry_file; $commcount = 0; unset($row['comments']); //debug("user: "******"") { $row['comments'][$commcount]['name'] = rem_entities($row_entrypoint->tags[9 + $commcount]->tags[0]->cdata); $row['comments'][$commcount]['email'] = rem_entities($row_entrypoint->tags[9 + $commcount]->tags[1]->cdata); $row['comments'][$commcount]['url'] = $row_entrypoint->tags[9 + $commcount]->tags[2]->cdata; $row['comments'][$commcount]['ip'] = $row_entrypoint->tags[9 + $commcount]->tags[3]->cdata; $row['comments'][$commcount]['date'] = $row_entrypoint->tags[9 + $commcount]->tags[4]->cdata; $row['comments'][$commcount]['comment'] = rem_entities($row_entrypoint->tags[9 + $commcount]->tags[5]->cdata); $commcount++; } $xml->cleanup(); }
function read_entry($filename, $updateindex = TRUE) { global $global_pref; $xml = new XMLFile(); if ($filename == "") { $filename = $this->entry['filename']; } //debug("read entry: $filename". ( ($updateindex) ? "(T)" : "(F)")); if ($this->entry['filename'] == "ROOT") { debug("root lezen"); $this->entry['template'] = "weblog.html"; return; } @($fh = fopen($filename, 'r')); if ($fh == false) { piv_error("File Does not Exist!", "One of the xml files needed ({$filename}) could not be found. <br /><br />This can normally be fixed by recreating the index-file. Click <a href='reindex.php'>reindex</a> to do so now, and then go <a href='javascript:history.go(-1)'>back</a> to the last page.", 0); } $xml->read_file_handle($fh); fclose($fh); $row_entrypoint =& $xml->roottag->tags[0]; $row =& $xml->roottag->tags[0]->make_array(); $this->entry['code'] = rem_code_padding($row_entrypoint->attributes['CODE']); $this->entry['id'] = $this->set_id(); @($this->entry['category'] = trim($row_entrypoint->attributes['CATEGORY'])); debug("leescat2: " . $this->entry['category']); $this->entry['template'] = $row['template']; $this->entry['date'] = $row['date']; $this->entry['user'] = $row['user']; $this->entry['title'] = rem_entities($row['title']); $this->entry['subtitle'] = rem_entities($row['subtitle']); $this->entry['introduction'] = rem_entities($row['introduction']); $this->entry['body'] = rem_entities($row['body']); $this->entry['media'] = $row['media']; $this->entry['links'] = $row['links']; $this->entry['url'] = $this['url']; $this->entry['filename'] = $filename; unset($commnames); if (isset($row['comment'])) { for ($i = 0; $i < count($row['comment']); $i++) { $row['comment'][$i]['name'] = substr(rem_entities($row['comment'][$i]['name']), 0, 30); $row['comment'][$i]['email'] = rem_entities($row['comment'][$i]['email']); $row['comment'][$i]['comment'] = rem_entities($row['comment'][$i]['comment']); $commnames[] = $row['comment'][$i]['name']; } $this->entry['comments'] = $row['comment']; $this->entry['commnames'] = implode(", ", array_unique($commnames)); $commcount = count($commnames); } else { unset($this->entry['comments']); $commcount = 0; } $this->entry['commcount'] = $commcount; if ($commcount == 0) { $commcount_str = $global_pref['commentsarr'][0]; $this->entry['commcount_str'] = str_replace("%num%", $global_pref['comments_numbersarr'][0], $commcount_str); } else { if ($commcount == 1) { $commcount_str = $global_pref['commentsarr'][1]; $this->entry['commcount_str'] = str_replace("%num%", $global_pref['comments_numbersarr'][1], $commcount_str); } else { if (isset($global_pref['comments_numbersarr'][$commcount])) { $num = $global_pref['comments_numbersarr'][$commcount]; } else { $num = $commcount; } $commcount_str = $global_pref['commentsarr'][2]; $this->entry['commcount_str'] = str_replace("%num%", $num, $commcount_str); } } if ($this->entry['media'] != "") { $media_lines = explode("#", $this->entry['media']); $i = 0; unset($this->entry['media']); foreach ($media_lines as $media_line) { @(list($file, $width, $height, $name) = explode("|", $media_line)); $i++; $this->entry['media'][] = array("file" => $file, "width" => $width, "height" => $height, "name" => $name); } } if ($this->entry['category'] == "") { $this->entry['category'] = "standard"; } $xml->cleanup(); $this->update_index(FALSE); // Sometimes the code is another number than the filename would suggest. If so, // this needs to be fixed, by renaming the file. if ($filename != $this->set_filename($this->entry['code'])) { debug("rename: " . $filename . " , ", $this->set_filename($this->entry['code'])); rename($filename, $this->set_filename($this->entry['code'])); } return TRUE; }