
Originally Posted by
kuroi
Why not use the Zen Cart database wrapper for your queries?
I did not know you could, I'm still learning as I go 

Originally Posted by
kuroi
How is this script called? In particular, what includes application_top which co-ordinates the loading of all the components that make up a Zen Cart page in the admin?
Ok like I mentioned before I really do not have any clue to what I'm doing lol, I took a look at other mods that where under tools in the admin panel to see how they where called. I think this is the file that is calling the admin page part of it is.
PHP Code:
<?php
require('includes/application_top.php');
function zen_display_files() {
global $check_directory, $found, $configuration_key_lookup;
for ($i = 0, $n = sizeof($check_directory); $i < $n; $i++) {
//echo 'I SEE ' . $check_directory[$i] . '<br>';
$dir_check = $check_directory[$i];
$file_extension = '.php';
if ($dir = @dir($dir_check)) {
while ($file = $dir->read()) {
if (!is_dir($dir_check . $file)) {
if (substr($file, strrpos($file, '.')) == $file_extension) {
$directory_array[] = $file;
}
}
}
if (sizeof($directory_array)) {
sort($directory_array);
}
$dir->close();
}
}
return $directory_array;
}
$action = (isset($_GET['action']) ? $_GET['action'] : '');
$za_who = $_GET['za_lookup'];
if ($action == 'new_page') {
$page = $_GET['define_it'];
$check_directory = array();
$check_directory[] = DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/';
$directory_files = zen_display_files();
$za_lookup = array();
for ($i = 0, $n = sizeof($directory_files); $i < $n; $i++) {
$za_lookup[] = array('id' => $i, 'text' => $directory_files[$i]);
}
// This will cause it to look for 'define_conditions.php'
$_GET['filename'] = $za_lookup[$page]['text'];
$_GET['box_name'] = BOX_TOOLS_DEFINE_CONDITIONS;
}
// define template specific file name defines
$file = zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/html_includes/', $_GET['filename'], 'false');
?>
<?php
switch ($_GET['action']) {
case 'set_editor':
// Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly.
$action='';
zen_redirect(zen_href_link(FILENAME_DEFINE_PAGES_EDITOR));
break;
case 'save':
if ( ($_GET['lngdir']) && ($_GET['filename']) ) {
if (file_exists($file)) {
if (file_exists('bak' . $file)) {
@unlink('bak' . $file);
}
@rename($file, 'bak' . $file);
$new_file = fopen($file, 'w');
$file_contents = stripslashes($_POST['file_contents']);
fwrite($new_file, $file_contents, strlen($file_contents));
fclose($new_file);
}
zen_redirect(zen_href_link(FILENAME_DEFINE_PAGES_EDITOR));
}
break;
}
if (!$_SESSION['language']) $_SESSION['language'] = $language;
$languages_array = array();
$languages = zen_get_languages();
$lng_exists = false;
for ($i=0; $i<sizeof($languages); $i++) {
if ($languages[$i]['directory'] == $_SESSION['language']) $lng_exists = true;
$languages_array[] = array('id' => $languages[$i]['directory'],
'text' => $languages[$i]['name']);
}
if (!$lng_exists) $_SESSION['language'] = $language;
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="init()">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<?PHP include "includes/modules/testimonials/testimonials.php"; ?>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br />
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Originally Posted by
kuroi
Finally, as an aside, rather than building a file structure with admin as it's root, why not just look down one level from your script into the images file?
This would work for the files that are in the admin section but for the other files that I have under the includes section they need to know what the admin folder is called.