Actually, it now seems to me that all of my global variables are being
overwritten or ignored, and in ways that seem completely random.
Consider:
On
www.monkeyclaus.org the index page consists of just two lines of
code:
include("mcIncludes/mcConfig.php");
runMainLoop();
The included config file is below (with passwords x out). You'll see
that all config info is in a large associative array which should be
in global space on index.php after it is included. And yet I'm now
getting errors where functions use the global keyword to import
$config, and then hit it with extract(), but extract is complaining
that it needs to be handed an array. This is another thing that was
working yesterday morning and now is not.
<?php
define("ECLIPSE_ROOT",
"/usr/local/www/vhosts/monkeyclaus.org/htdocs/mcIncludes/");
global $PHP_SELF;
$self = $PHP_SELF;
$config["self"] = $self;
global $password;
// this next is the root level password for the site.
$config["mcUserName"] = "xxx";
$config["mcPassword"] = "xxx";
// these next 6 variables are needed for Costin's database class:
$config["db_persistent"] = 0;
$config["db_database"] = 'xxx';
$config["db_server"] = 'localhost';
$config["db_user"] = 'xxx';
$config["db_password"] = 'xxx';
$config["db_port"] = 3306;
// these next few addresses are given has web Urls
$config["nameOfDomain"] = '.monkeyclaus.org';
$config["linkToDS"] = "<a
href='mcControlPanel.php?password=$password'>Click here to get back to
the control panel screen.</a><br>\n\n";
$config["linkToWebSite"] = "<a
href='http://www.monkeyclaus.org/index.php'>Click here to go to the
front page of your web site.</a><br>\n\n";
$config["filesFolder"] = "http://www.monkeyclaus.org/mcFiles/";
$config["imagesFolder"] = "http://www.monkeyclaus.org/mcImages/"; //
This is the url version of the address, not the host version
$config["linkToLogin"] = "<div class='dvcllinkToLogin'><a
href='mcControlPanel.php'>login</a></div> \n\n";
$config["pathToIndex"] ="http://www.monkeyclaus.org/index.php"; //
this has to include the index page in the address.
$config["pathToDatabase"] = "<a href='http://mysql.catalog.com/'>Go to
the database</a><br> \n";
// These next few addresses are not web urls, rather, they need to be
given as the directory paths on the host computer
$config["pathToImageFolder"] =
"/usr/local/www/vhosts/monkeyclaus.org/htdocs/mcImages/"; //this needs
to be set from the site root, obviously
$config["pathToFileFolder"] =
"/usr/local/www/vhosts/monkeyclaus.org/htdocs/mcFiles/"; //this needs
to be set from the site root, obviously
$config["pathToNeededFiles"] =
"/usr/local/www/vhosts/monkeyclaus.org/htdocs/mcIncludes/"; //this
needs to be set from the site root, obviously
$config["sentTo"] = "lk******@geocities.com,
pe***@monkeyclaus.org,
ma**@monkeyclaus.org";
$config["adminEmail"] = "la******@krubner.com,
pe***@monkeyclaus.org,
ma**@monkeyclaus.org";
$config["simpleMode"] = 'n'; // 04-05-03 - set this line to 'n' if you
don't need the easy interface, you'll be presented with full options
instead.
$config["siteTitle"] = "monkeyclaus - who says you can't disguise a
social movement as a music label?";
$config["siteDescription"] = "local music, global awareness -
monkeyclaus has given everyone of its artists their own weblogs to
empower the voices of progressive cultural explorers.";
function getNeededFiles($needed = "all") {
global $config;
extract($config);
// open the directory and load all the files into the array
$theDir = opendir($pathToNeededFiles) or die("Can't open page");
while ($theDirFiles = readdir($theDir)) {
if ($theDirFiles != "." && $theDirFiles != ".." && $theDirFiles !=
"mcControlPanel.php" && $theDirFiles != "mcConfig.php" && $theDirFiles
!= "index.php") {
$theDirFiles = $pathToNeededFiles.$theDirFiles;
include_once($theDirFiles);
}
}
}
getNeededFiles();
$toBeExtracted = $config;
extract($toBeExtracted);
// 05-08-03: what follows are the classes that the procedural code
depends on. These need to be in global $forms, $io, $users, $links,
$sql, space.
// 06-21-03 - these used to be at the top of both index.php and
mcControlPanel.php. I'm going to try putting them here.
// 07-04-03 - starting today, all classes passed as parameters are
passed by reference. Before I unthinkingly passed them as
// copies and ended up with 4 copies of $sql in my code, and the
copies that existed inside the other objects did not have
// security turned on by the call to startUserMode() done here in
global space.
$db = new CMySQL($db_persistent, $db_database, $db_server, $db_user,
$db_password, $db_port);
$io = new McInputOutput();
$format = new McFormatting();
$output = new McOutput();
$validate = new McValidate();
$sql = new McSql($db, $io);
$users = new McUser($sql, $io, $config);
$nav = new McNav($sql, $io, $config);
// 07-04-03 - I just changed $links to $nav. This next line will be
needed for awhile for backwards compatibility.
$links = $nav;
$forms = new McForms($sql, $io, $config, $nav);
$render = new McPageRender();
//$sql->startUserMode($users);
?>