function add_to_a_log($name, $ip, $host, $timestamp, $location) { if (filesize($location) == 0) { $xml_header = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<entries>\n"; $fp = fopen($location, 'w'); fwrite($fp, $xml_header); fclose($fp); } $gbXML = new gbXML('entries', 'entry', $location); $id = $gbXML->get_max_value_for_tag('id'); ++$id; $tmpArray = array('id' => $id, 'name' => $name, 'ip' => $ip, 'host' => $host, 'timestamp' => $timestamp); $gbXML->append_record_to_file($tmpArray); }
<link rel="STYLESHEET" type="text/css" href="<?php echo '../templates/' . $template_folder . '/style.css'; ?> "> </head> <body> <br> <h2>Guestbook Admin Interface</h2> <?php //GET AN INSTANCE OF GBXML $data_type = 'messages'; $record_delim = 'message'; $filename = '../data/data.xml'; $gbXML = new gbXML($data_type, $record_delim, $filename); // Validate browser input ------------------------------------------------------------ $id = isset($_GET['id']) ? $_GET['id'] : FALSE; $order = isset($_GET['order']) ? $_GET['order'] : FALSE; $error = FALSE; if (!is_numeric($id)) { $error = TRUE; $errorMsg = 'The ID provided is not a number.'; } else { if (!$gbXML->tag_and_value_exist('id', $id)) { $error = TRUE; $errorMsg = 'The ID provided does not match any record in the GuestBook.'; } } //REMOVE THE RECORD FROM THE DATA.XML FILE //If we fail, set the error flag
$datain = fread($handle, filesize($filename)); fclose($handle); $out = explode("<!-- E -->", $datain); $outCount = count($out) - 1; $j = 0; for ($i = 0; $i <= $outCount; $i++) { if (unserialize($out[$i]) != FALSE) { $lines[$j] = unserialize($out[$i]); $j++; } } // Make user input safe, insert emoticons, and encode UBB code ------------------------------------- function formatMessage($mess) { $mess = stripcslashes($mess); $mess = html_entity_decode($mess, ENT_NOQUOTES, 'UTF-8'); $mess = utf8_encode($mess); return $mess; } for ($i = 0; $i < count($lines); $i++) { $gbXML = new gbXML('messages', 'message', 'data.xml'); $id = $gbXML->get_max_value_for_tag('id'); ++$id; $myUBB = new UBBCodeN(); $tmpArray = array('id' => $id, 'date' => $lines[$i]->showDate(), 'name' => formatMessage($lines[$i]->showFrom()), 'email' => $lines[$i]->showEmail(), 'msg' => formatMessage($lines[$i]->showMessage())); if ($gbXML->append_record_to_file($tmpArray) === TRUE) { // Add code to display progress } } echo "Conversion is complete."; }
<?php //check that ID is numeric if (@(!is_numeric($_GET['id']))) { echo <<<HTML <p class="error">The id supplied is not a number. Please try again.</p> <p><a href="javascript: history.go(-1);">Go back</a></p> HTML; include '../includes/admin_footer.php'; exit; } //Instantiate a gbXML object to work with the guestbook entries $data_type = 'messages'; $record_delim = 'message'; $filename = '../data/data.xml'; $mygbXML = new gbXML($data_type, $record_delim, $filename); //Check that the id we are trying to edit actually exists $tag_name = 'id'; $tag_value = $_GET['id']; if (!$mygbXML->tag_and_value_exist($tag_name, $tag_value)) { echo <<<HTML <p class="error">The id supplied does not exist in the guest book. Please try again.</p> <p><a href="javascript: history.go(-1);">Go back</a></p> HTML; include '../includes/admin_footer.php'; exit; } //go to the guestbook and get the ID requested to edit if (!($recordArray = $mygbXML->get_record_from_file($_GET['id']))) { echo <<<HTML
} // Assign, clean, add smiley faces and UBB encode user input // Note, we do not check input for bad words: if administrator wants to swear in their guestbook that's up the him/her. $id = $_POST['id']; $date = date("D m/j/y g:iA"); $yourname = @stripslashes($_POST['yourname']); $youremail = @stripslashes($_POST['youremail']); $yourmessage = smiley_face($_POST['yourmessage']); $myUBB = new UBBCodeN(); $yourmessage = $myUBB->encode($yourmessage); $yourmessage = stripslashes($yourmessage); //instantiate an instance of gbXML for working with the data file $data_type = 'messages'; $record_delim = 'message'; $filename = '../data/data.xml'; $mygbXML = new gbXML($data_type, $record_delim, $filename); //get our record ready to append $tmp_array = array('id' => $id, 'name' => $yourname, 'date' => $date, 'email' => $youremail, 'msg' => $yourmessage); //try to replace the existing record with the new one and display confirmation if ($mygbXML->replace_record_in_file($id, $tmp_array)) { echo <<<HTML <center><h2>Record Saved</h2> <p>This modified record has been saved: </p> <div class="gbookRecordBanner"></div> <div class="gbookRecord"> <p><span class="gbookRecordLabel">{$listnametxt}:</span> {$yourname} </p> <p><span class="gbookRecordLabel">{$listemailtxt}:</span> <a href="mailto:{$youremail}" />{$youremail}</a> </p> <p class="gbookRecordMsg"><span class="gbookRecordLabel">{$listMessagetxt}:</span> {$yourmessage}</p> </div>
function readXML($filename) { if (file_exists($filename)) { $tracking_array_parse = new gbXML("entries", "entry", $filename); $tracking_array_parse->parse_XML_data(); $tracking_array = $tracking_array_parse->parsed_array; echo "<table width=\"100%\"><tr><td><b>Name</b></td><td><b>IP</b></td><td><b>Host</b></td><td><b>Timestamp</b></td>"; foreach ($tracking_array as $key => $tracking_array_data) { echo "\n <tr>\n <td>{$tracking_array_data[name]}</td> \n <td>{$tracking_array_data[ip]}</td>\n <td>{$tracking_array_data[host]}</td>\n <td>{$tracking_array_data[timestamp]}</td>\n </tr>\n "; } echo "</table>"; } }
$selected = $selected; /*** loop over the options ***/ foreach ($options as $key => $option) { /*** assign a selected value ***/ $select = $selected == $key ? ' selected' : null; /*** add each option to the dropdown ***/ $dropdown .= '<option value="' . $option['abbr'] . '"' . $select . '>' . $option['name'] . '</option>'; } /*** close the select ***/ $dropdown .= '</select>' . "\n"; /*** and return the completed dropdown ***/ return $dropdown; } $languagefile = "../data/languages.xml"; if (file_exists($languagefile)) { $language_array_parse = new gbXML("languages", "language", $languagefile); $language_array_parse->parse_XML_data(); $language_array = $language_array_parse->parsed_array; } ?> <?php echo "<center>"; if (isset($_POST['Submit'])) { $f1 = $_POST['f1']; $f2 = $_POST['f2']; $f3 = $_POST['f3']; $f4 = $_POST['f4']; $f5 = $_POST['f5']; $f6 = $_POST['f6']; $f7 = $_POST['f7'];
require_once 'includes/class.gbXML.php'; require_once 'config.php'; require_once $language_file; //include our helper class for listing guestbook entries require_once 'includes/class.guestbook_entry_lister.php'; require_once 'includes/remove_special_chars.php'; $search = trim(isset($_POST['search_term']) ? remove_special_chars($_POST['search_term']) : ''); $pageNum = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 0; $search = isset($_GET['search_term']) ? $_GET['search_term'] : $search; if ($search == "") { echo "<center><font color=blue>Please enter a search term and try again.</font></center>"; include "includes/footer.php"; exit; } $search_terms = preg_split('/(\\s)+|\\.|,|;/', $search); $gbXML = new gbXML('messages', 'message', 'data/data.xml'); $records_array = $gbXML->parse_XML_data(); $found_records = array(); foreach ($records_array as $record) { foreach ($record as $key => $value) { $flag = true; foreach ($search_terms as $search_term) { if (substr_count(strtolower($value), strtolower($search_term)) > 0) { //Next foreach ($search_terms.... } else { $flag = false; $break; //Not allowed to continue... already doesn't qualify... } } if ($flag == true) {