example code: how to manually access the database of webEdition.

wo speichert webEdition Datenbank Zugangsdaten?

Where does webEdition save database credentials username password?

vim /var/www/webEdition/we/include/conf/we_conf.inc.php

so setzt webEdition mysql queries ab:

Beispiel: we_listview_object.class.php $this->DB_WE->query($q);

oder auch hier:

function we_tag_listview($attribs){
->
$GLOBALS['lv'] = new we_listview_customer($name, $we_rows, $we_offset, $we_lv_order, $we_lv_desc, $cond, $cols, $docid, $hidedirindex);
->
$this->anz_all = f('SELECT COUNT(1) AS cnt FROM ' . CUSTOMER_TABLE . $where, 'cnt', $this->DB_WE);

$this->DB_WE->query('SELECT * ' . $extra . ' FROM ' . CUSTOMER_TABLE . $where . ' ' . $orderstring . ' ' . (($this->maxItemsPerPage > 0) ? (' LIMIT ' . $this->start . ',' . $this->maxItemsPerPage) : ''));
$this->anz = $this->DB_WE->num_rows();
->
function getHash($query, we_database_base $DB_WE = NULL, $resultType = MYSQL_BOTH){
...
$DB_WE->query($query);
->
/**
* make an sql-Query to the DB
* @param string $Query_String the sql-query
* @param bool $allowUnion this parameter is deprecated; it determines if the query is allowed to have unions
* @return bool true, if the query was successfull
*/

function query($Query_String, $allowUnion = false, $unbuffered = false){
if($Query_String == ''){
return true;
}
if(self::$Trigger_cnt){
$time = microtime(true);
}
if(!$this->retry){
$this->Errno = 0;
$this->Error = '';
$this->Row = 0;
}
/* No empty queries, please, since PHP4 chokes on them. */
if(!$this->isConnected() && !$this->_connect()){
return false;
}

queries send:

SELECT * FROM tblFile WHERE ID=1203;
SELECT Path FROM tblTemplates WHERE ID=53;
SELECT * FROM tblcustomerfilter WHERE modelTable="tblFile" AND modelId = 1203;
SELECT COUNT(1) AS cnt FROM tblWebUser;

here the result is processed:

/** walk result set
* @param $resultType int
* @return bool true, if rows was successfully fetched
*/

public function next_record($resultType = MYSQL_BOTH){
if(!($this->Query_ID)){
$this->halt("next_record called with no query pending.");
return false;
}
$this->Record = $this->fetch_array($resultType);
$this->Row++;
$this->Errno = $this->errno();
$this->Error = $this->error();

$stat = is_array($this->Record);
return $stat;
}

manchmal aber auch so:

$db = new DB_WE(); $query = ‚SELECT * FROM‘; $hash = getHash($query,$db); if ( count($hash)) { return weDocumentCustomerFilter::getFilterByDbHash($hash); } unset($db);

hier established webedition die mysql connection

the file is called: we_database_mysql.class.php

 /* public: connection management */ protected function connect($Database = DB_DATABASE, $Host = DB_HOST, $User = DB_USER, $Password = DB_PASSWORD){ /* establish connection, select database */ if(!$this->isConnected()){ switch(DB_CONNECT){ case 'pconnect': $this->Link_ID = @mysql_pconnect($Host, $User, $Password); if($this->Link_ID){ $this->conType = 'pconnect'; break; } //intentionally no break case 'connect': $this->Link_ID = @mysql_connect($Host, $User, $Password); if(!$this->Link_ID){ $this->halt("(p)connect($Host, $User) failed."); return false; } $this->conType = 'connect'; break; default: $this->halt('Error in DB connect'); exit('Error in DB connect'); } if(!@mysql_select_db($Database, $this->Link_ID) && !@mysql_select_db($Database, $this->Link_ID) && !@mysql_select_db($Database, $this->Link_ID) && !@mysql_select_db($Database, $this->Link_ID)){ $this->halt('cannot use database ' . $this->Database); return false; } if($this->Link_ID){ $this->_setup(); } } return ($this->Link_ID > 0); }
admin