";
}
$this->queryTime = $this->queryTime+$totaltime;
}
}
function dbQuery($query) {
// function to query the database
// check the connection and create it if necessary
if(empty($this->rs)) {
$this->dbConnect();
}
$tstart = $this->getMicroTime();
if(@!$result = mysql_query($query, $this->rs)) {
$this->messageQuit("Execution of a query to the database failed", $query);
} else {
$tend = $this->getMicroTime();
$totaltime = $tend-$tstart;
$this->queryTime = $this->queryTime+$totaltime;
if($this->dumpSQL) {
$this->queryCode .= " ";
}
$this->executedQueries = $this->executedQueries+1;
if(count($result) > 0) {
return $result;
} else {
return false;
}
}
}
function recordCount($rs) {
// function to count the number of rows in a record set
return mysql_num_rows($rs);
}
function fetchRow($rs, $mode='assoc') {
if($mode=='assoc') {
return mysql_fetch_assoc($rs);
} elseif($mode=='num') {
return mysql_fetch_row($rs);
} elseif($mode=='both') {
return mysql_fetch_array($rs, MYSQL_BOTH);
} else {
$this->messageQuit("Unknown get type ($mode) specified for fetchRow - must be empty, 'assoc', 'num' or 'both'.");
}
}
function affectedRows($rs) {
return mysql_affected_rows($this->rs);
}
function insertId($rs) {
return mysql_insert_id($this->rs);
}
function dbClose() {
// function to close a database connection
mysql_close($this->rs);
}
function getSettings() {
if(file_exists("assets/cache/etomiteCache.idx.php")) {
include_once "assets/cache/etomiteCache.idx.php";
} else {
$result = $this->dbQuery("SELECT setting_name, setting_value FROM ".$this->db."system_settings");
while ($row = $this->fetchRow($result, 'both')) {
$this->config[$row[0]] = $row[1];
}
}
// get current version information
include "manager/includes/version.inc.php";
$this->config['release'] = $release;
$this->config['patch_level'] = $patch_level;
$this->config['code_name'] = $code_name;
$this->config['full_appname'] = $full_appname;
$this->config['small_version'] = $small_version;
$this->config['slogan'] = $full_slogan;
// compile array of document aliases
// relocated from rewriteUrls() for greater flexibility in 0.6.1 Final
// we always run this routine now so that the template info gets populated too
// a blind array(), $this->tpl_list, is also included for comparisons
$aliases = array();
$templates = array();
$parents = array();
$limit_tmp = count($this->aliasListing);
for ($i_tmp=0; $i_tmp<$limit_tmp; $i_tmp++) {
if($this->aliasListing[$i_tmp]['alias'] != "") {
$aliases[$this->aliasListing[$i_tmp]['id']] = $this->aliasListing[$i_tmp]['alias'];
}
$templates[$this->aliasListing[$i_tmp]['id']] = $this->aliasListing[$i_tmp]['template'];
$parents[$this->aliasListing[$i_tmp]['id']] = $this->aliasListing[$i_tmp]['parent'];
$authenticates[$this->aliasListing[$i_tmp]['id']] = $this->aliasListing[$i_tmp]['authenticate'];
}
$this->aliases = $aliases;
$this->templates = $templates;
$this->parents = $parents;
$this->authenticates = $authenticates;
}
function getDocumentMethod() {
// function to test the query and find the retrieval method
if(isset($_REQUEST['q'])) {
return "alias";
} elseif(isset($_REQUEST['id'])) {
return "id";
} else {
return "none";
}
}
function getDocumentIdentifier($method) {
// function to test the query and find the retrieval method
switch($method) {
case "alias" :
return strip_tags($_REQUEST['q']);
break;
case "id" :
return strip_tags($_REQUEST['id']);
break;
case "none" :
return $this->config['site_start'];
break;
default :
return $this->config['site_start'];
}
}
function checkSession() {
if(isset($_SESSION['validated'])) {
return true;
} else {
return false;
}
}
function checkPreview() {
if($this->checkSession()==true) {
if(isset($_REQUEST['z']) && $_REQUEST['z']=='manprev') {
return true;
} else {
return false;
}
} else {
return false;
}
}
function checkSiteStatus() {
$siteStatus = $this->config['site_status'];
if($siteStatus==1) {
return true;
} else {
return false;
}
}
function cleanDocumentIdentifier($qOrig) {
if(strpos($q, "/")>0) {
$q = substr($q, 0, strpos($q, "/"));
}
$q = str_replace($this->config['friendly_url_prefix'], "", $qOrig);
$q = str_replace($this->config['friendly_url_suffix'], "", $q);
// we got an ID returned unless the error_page alias is "404"
if(is_numeric($q) && ($q != $this->aliases[$this->config['error_page']])) {
$this->documentMethod = 'id';
return $q;
// we didn't get an ID back, so instead we assume it's an alias
} else {
$this->documentMethod = 'alias';
return $q;
}
}
function checkCache($id) {
$cacheFile = "assets/cache/docid_".$id.".etoCache";
if(file_exists($cacheFile)) {
$this->documentGenerated=0;
return join("",file($cacheFile));
} else {
$this->documentGenerated=1;
return "";
}
}
function addNotice($content, $type="text/html") {
/*
PLEASE READ!
This function places a copyright message and a link to Etomite in the page about to be
sent to the visitor's browser. The message is placed just before your