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:

[cc lang=”php” escaped=”true” width=”500″]
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;
}
[/cc]

queries send:

[cc lang=”sql” escaped=”true” width=”500″]

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;

[/cc]

here the result is processed:

[cc lang=”php” escaped=”true” width=”500″]
/** 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;
}
[/cc]

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 [cc lang=”php” escaped=”true” width=”500″] /* 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); } [/cc]

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin