Try: ca/tecreations/ViewFile.php -- Online
<?php
//create table book_parts (
// part_toc_label VARCHAR(32) default '',
// part_contents BLOB
//)
require_once $_SERVER['DOCUMENT_ROOT'] . "/Base.php";
global $PREFIX_DIR;
require_once $DOCROOT . $PREFIX_DIR . "Secure.php";
GLOBAL $DOCROOT, $db;
//$db->setDebug(true);
GLOBAL $part_toc_label, $part_contents;
$part_toc_label = $part_contents = "";
if (isset($_REQUEST['part_toc_label'])) {
$part_toc_label = $_REQUEST['part_toc_label'];
}
$action = "";
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
if ($action === "save") {
if (isset($_REQUEST['part_contents'])) {
$part_contents = $_REQUEST['part_contents'];
}
$result = $db->select("SELECT part_toc_label FROM book_parts WHERE part_toc_label='$part_toc_label'");
//print_r($result);
if ($result['count'] == 0) {
$sql = "INSERT INTO book_parts (part_toc_label,part_contents) VALUES('$part_toc_label','$part_contents')";
} else {
$sql = "UPDATE book_parts SET part_contents='$part_contents' WHERE part_toc_label='$part_toc_label'";
}
$db->issue($sql);
}
}
if (!empty($part_toc_label)) {
$result = $db->select("SELECT part_contents FROM book_parts WHERE part_toc_label='$part_toc_label'");
//print_r($result);print("<br />");
$count = $result['count'];
//print("result.count: " . $count . "<br />");
$row = $result['rows'];
if ($count == 1) {
//print("ROW: ");print_r($row); print("<br />");
$part_contents = $row['part_contents'];
}
}
GLOBAL $tec_purple;
$tec_purple = array(75,0,130);
function rgb2Hex($r = 0, $g = 0, $b = 0) {
$hex = sprintf("#%02x%02x%02x", $r,$g,$b);
return $hex;
}
// print(rgb2Hex(220,220,220));
// print("<br />");
// print(rgb2Hex(51,51,51));
// print("<br />");
require_once $DOCROOT . $PREFIX_DIR . "start_html.php";
?>
<style>
div.padded {
padding-top: 25px;
padding-right: 25px;
padding-bottom: 35px;
padding-left: 25px;
}
a.link {
text-decoration: none;
}
</style>
<link rel="stylesheet" type="text/css" href="/ca/tecreations/style.css">
</head>
<body>
<?php
include_once $DOCROOT . "$PREFIX_DIR/header_start.php";
include_once $DOCROOT . "$PREFIX_DIR/menu/userMenu.php";
include_once $DOCROOT . "$PREFIX_DIR/menu/contact.php";
include_once $DOCROOT . "$PREFIX_DIR/header_finish.php";
?>
<div>
<div class="jumbotron padded">
<p><a href="https://tecreations.ca/ca/tecreations/php_stuff/ViewFile.php?path=ca/tecreations/php_stuff/EditBookPart.php">View This Page's Code</a></p>
</div>
<div class="jumbotron padded">
</div>
<div class="padded jumbotron">
<div class="padded">
<div>
<div class="page-header">
<h4>Contents</h4>
</div>
<p> </p>
<form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div class="form-group">
<label for="part_toc_label">Part Table Of Contents Label:</label>
<div>
<input class="form-control" name="part_toc_label" id="part_toc_label" value="<?php GLOBAL $part_toc_label; echo $part_toc_label; ?>" />
<button type="submit" name="action" value="get" class="btn btn-primary">Get</button>
</div>
<div>
<label for="contents"><strong>Raw:</strong></label>
<textarea class="form-control" name="part_contents" id="part_contents" rows="40" cols="80"><?php GLOBAL $part_contents; echo $part_contents; ?></textarea>
</div>
</div>
<button type="submit" name="action" value="save" class="btn btn-primary">Save</button>
</form>
</div>
<?php include_once "$DOCROOT$PREFIX_DIR/footer.php";