Файл: Kagao-v3.0/upload/inc/add_mysqli/db.php
Строк: 685
<?php
/*
 _
| | _____   __ _  __ _  ___ 
| |/ / _  / _` |/ _` |/ _ 
|   < (_) | (_| | (_| | (_) |
|_|____/ __, |__,_|___/
           |___/             
----------------------------#
Developer: Stevie-Ray Zilka #
Copyright: Stevie-Ray Zilka #
Version:   3.0.10 End Final #
----------------------------#
*/
$domain             = 'http://localhost/kogao4/';
$newslettermail     = 'newsletter@kogaoscript.com';
//Module
define('module_beo',             1);  //Beobachter Modul  //1=on  //0=off
define('module_support',         1);     //Support Modul     //1=on  //0=off
define('module_nachrichten',     1);  //Nachrichten Modul //1=on  //0=off
define('module_rechnung',         1);     //Rechnungsmodul    //1=on  //0=off
define('module_productsearch',    1);  //Produktsuche (EAN)//1=on  //0=off
//Das Automodul und Immobilienmodul können Sie via Admin aktivieren.
define('status', 'offline');            //online  offline
if(status == 'online'){
define('db_host', 'localhost');
define('db_user', 'kogaodemo');
define('db_pass', '$daimler2011$');
define('db_name', 'kogao_demo');
}else{
//Achtung diese Angaben stehen für den Offline Modus ( Bsp. xampp etc )
define('db_host', 'localhost');
define('db_user', 'root');
define('db_pass', '');
define('db_name', 'kogao4');
}
define('kogao_settings_art', 0);    //1=> Anzeigen werden automatisch freigeschaltet
                                    //0=> Anzeigen müssen vom Admin freigeschaltet werden
define('kogao_settings_path', 'kogao4/'); //wenn unterverzeichnis "verzechnis/" ansonsten leer lassen
function seturl(){ return sprintf("%s://%s", isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', $_SERVER['SERVER_NAME'].'/');}
$baseurl_setting = seturl() . kogao_settings_path;
$statusSystem    = kogao_settings_art;
interface serviceHandler
{
    const dbHost = db_host;
    const dbUser = db_user;
    const dbPass = db_pass;
    const dbName = db_name;
    const charset= 'utf8';
}
class functions{
    
    var $pro          = false;
    var $cate         = false;
    var $shownums     = 0x00;
    public function str($text){
        $text = str_replace(' ', '-', $text);
        $text = str_replace(',', '', $text);
        
        return $text;
    }
    public function getMerklistNum(){
        $get = $this->query('SELECT id FROM merkliste WHERE uid = "'.$_SESSION['login'].'"');
        $row = $this->num_rows($get);
        $this->free_result($get);
        return array('merkNum' => $row);
    }
    public function getMessageNum(){
        $get = $this->query('
            SELECT id 
            FROM   messages 
            WHERE  touid = "'.$_SESSION['login'].'" AND message_read = "1"
        ');
        $row = $this->num_rows($get);
        $this->free_result($get);
        return array('messagenum' => $row);
    }
    public function messageCode($touid, $fromuid, $aid){
        $createcode = md5( $touid . $fromuid . $aid );
        return $createcode;
    }
    public function rowMessageByCode($code = NULL){
        $get = $this->query('SELECT id FROM messages WHERE message_code = "'.$code.'" AND message_read = "1" AND touid = "'.$_SESSION['login'].'"');
        $row = $this->num_rows($get);
        $this->free_result($get);
        if($row >= 1){
        return '<div class="number">'.$row.'</div>';
        }else{
        return false;
        }
    }
    public function getMessages(){
        $get = $this->query('
            SELECT  Sub.*
            FROM     ( 
                SELECT * FROM 
                messages
                WHERE touid = "'.intval($_SESSION['login']).'"
                ORDER BY datum DESC
            ) AS Sub
            GROUP BY Sub.message_code
            ORDER BY Sub.datum DESC
            LIMIT 15
            
        ');
        while($row = $this->fetch_assoc($get)){
            $dataPackage[] = $row;
        }
        $this->free_result($get);
        return $dataPackage;
    }
    public function createHeader($text){
        return '<div style="float:left; clear:both; padding-top:15px; font-family:Open Sans; border-top:1px solid #eee; width:655px;"><div style="float:left; font-size:18px; font-weight:bold;">'.$text.'</div></div>';
    }
    public function createText($text){
        return '<div style="float:left; clear:both; font-size:14px; padding:20px; padding-top:10px; padding-left:0; font-family:Open Sans;">'.nl2br(htmlspecialchars_decode($text)).'</div>';
    }
    public function immobilienInfos($uid){
        $get = $this->query('SELECT * FROM user WHERE id = "'.$uid.'"');
        $row = $this->fetch_assoc($get);
        $this->free_result($get);
        echo $this->createHeader('Widerrufsrecht');
        echo $this->createText( $row['i_wieder'] );
        echo $this->createHeader('Verzicht auf Widerruf');
        echo $this->createText( $row['i_verzicht'] );
        echo $this->createHeader('Energieausweis');
        echo $this->createText( $row['i_energie'] );
        echo $this->createHeader('Warum Adressdaten');
        echo $this->createText( $row['i_adressen'] );
        echo $this->createHeader('Impressum inklusive Angabe §34 c');
        echo $this->createText( $row['i_impressum'] );
    }
    public function createMessage($touid, $fromuid, $text, $aid, $name = 0){
        if( is_numeric( $fromuid ) ){
            $fromuid = $fromuid;
            $email   = 0;
        }else{
            $email   = $fromuid;
            $fromuid = 0;
        }
        $fromuid1 = $fromuid ? $fromuid : $email;
        $this->query('INSERT INTO messages SET
            message_code = "'.$this->messageCode($touid, $fromuid1, $aid).'",
            touid          = "'.$touid.'",
            fromuid         = "'.$fromuid.'",
            email          = "'.$email.'",
            datum          = "'.time().'",
            message_text = "'.htmlspecialchars($text).'",
            name          = "'.$name.'",
            message_read = "1",
            aid          = "'.$aid.'"
        ');
    }
    public function userProfile(){
        $get = $this->query('SELECT * FROM user WHERE id = "'.$_SESSION['login'].'"');
        $row = $this->fetch_assoc($get);
        $this->free_result($get);
        return $row;
    }
    public function getByID($i = NULL){
        $get = $this->query('SELECT * FROM produkte WHERE id = "'.$i.'"');
        $row = $this->fetch_assoc($get);
        $this->free_result($get);
        return $row;
    }
    public function getPartnerLinks(){
        $get = $this->query('SELECT * FROM partnerlinks');
        while($row = $this->fetch_assoc($get)){
            $dataPackage[] = $row;
        }
        $this->free_result($get);
        return $dataPackage;
    }
    public function getSupportMail(){
        $get = $this->query('SELECT supportmail FROM settings WHERE id = "1"');
        $row = $this->fetch_row($get);
        $this->free_result($get);
        return $row[0];
    }
    public function sendmail($email, $subject, $text, $from){
        mail($email, $subject, $text, "From: <$from>");
    }
    public function setSeo($phrase, $maxLength=100000000000000)
    {
        $result = strtolower($phrase);
        
        $result = str_replace('ü', 'ue', $result);
        $result = str_replace('ä', 'ae', $result);
        $result = str_replace('ö', 'oe', $result);
        $result = str_replace('&', 'und', $result);
        $result = str_replace('ß', 'ss', $result);
        
        $result = preg_replace("/[^A-Za-z0-9s-._/]/", "", $result);
        $result = trim(preg_replace("/[s-]+/", " ", $result));
        $result = trim(substr($result, 0, $maxLength));
        $result = preg_replace("/s/", "-", $result);
        
        return $result;
    }
    public function isAdmin(){
        $get = $this->query('SELECT email, admin, id FROM user WHERE id = "'.intval($_SESSION['login']).'"');
        $row = $this->fetch_assoc($get);
        if($row['admin'] == 1 && $row['id'] == '1100'){
            return '<a href="admin.php"><div class="searchKey2">Admin</div></a>';
        }
        $this->free_result($get);
    }
    public function createCategory($db, $id, $selectcate = NULL, $int = 1){
        $get = $this->query('SELECT * FROM '.$db.' WHERE bigid = "'.$id.'"');
        $num = $this->num_rows($get);
        if($num == 0){
                print 'off';
        }else{
        while($c = $this->fetch_row($get)){
            if($selectcate == 'selectcat3'){
            ?>
            <a href="javascript:void()" onClick="selectcat3('<?php print $c[0]; ?>', '<?php print $c[2]; ?>')"><div class="bigCat cpipe3_<?php print $c[0]; ?> cpipe3all"><?php print $c[2]; ?></div></a>
            <?php
            }else{
            ?>
            <a href="javascript:void()" onClick="<?php echo $selectcate; ?>('<?php print $c[0]; ?>', '<?php print $c[1]; ?>')"><div class="bigCat cpipe<?php echo $int; ?>_<?php print $c[0]; ?> cpipe<?php echo $int; ?>all"><?php print $c[1]; ?></div></a>
            <?php
            }
        }
        }
        $this->free_result($get);
    }
    public function setFooter(){
        $get = $this->query('SELECT * FROM pages');
        while($row = $this->fetch_assoc($get)){
            $link = $this->setSeo($row['name']) . '-PAGE' . $row['id'];
            print '<a href="'.$link.'" style="color:#3e454d">'.utf8_encode($row["name"]).'</a>    ';
        }
        $this->free_result($get);
    }
    public function settings(){
        $get = $this->query('SELECT * FROM settings WHERE id = "1"');
        $row = $this->fetch_assoc($get);
        $dataPackage = $row;
        $this->free_result($get);
        return $dataPackage;
    }
    public function location($url){
        ?><script>window.location.href='<?php echo $url; ?>';</script><?php
        die;
    }
    public function lastSearchCategory(){
        $get = $this->query('SELECT * FROM lastsuche WHERE ip = "'.$_SERVER['REMOTE_ADDR'].'" ORDER BY id DESC LIMIT 5');
        while($row = $this->fetch_assoc($get)){
            $dataPackage[] = array(
                "name"    => utf8_encode($row['name']),
                "link"    => $row['link']
            );
        }
        $this->free_result($get);
        return $dataPackage;
    }
    public function isWatchList(){
        $get = $this->query('SELECT id FROM merkliste WHERE pid = "'.intval($_GET['id']).'" and uid = "'.$_SESSION['login'].'"');
        $row = $this->fetch_row($get);
        $this->free_result($get);
        if( $row[0] ){
            return true;
        }else{
            return false;
        }
    }
    public function sales(){
        $get = $this->query('SELECT * FROM paypal WHERE uid = "'.$_SESSION['login'].'"');
        while($row = $this->fetch_assoc($get)){
            $dataPackage[] = $row;
        }
        $this->free_result($get);
        return $dataPackage;
    }
    public function deleteWatchItem($id = NULL, $aid = NULL){
        $this->query('DELETE FROM merkliste WHERE pid = "'.intval($aid).'" and uid = "'.$_SESSION['login'].'"');
        $this->query('UPDATE produkte SET beobachter = beobachter-1 WHERE id = "'.intval($aid).'"');
    }
    public function watchList(){
        $get = $this->query('
            SELECT 
                produkte.*,
                merkliste.id AS watchid
            FROM
                merkliste
            LEFT JOIN 
                produkte
            ON
                produkte.id = merkliste.pid
            WHERE
                merkliste.uid = "'.$_SESSION['login'].'" AND produkte.statuscode = "1"
            ORDER BY
                merkliste.id DESC
        ');
        while($row = $this->fetch_assoc($get)){
            $dataPackage[] = $row;
        }
        $this->free_result($get);
        return $dataPackage;
    }
    
    public function showBeobachter($id = NULL){
        
        $get = $this->query('
            SELECT
                merkliste.*,
                user.a_name,
                user.email
            FROM
                merkliste
            LEFT JOIN
                user
            ON
                merkliste.uid = user.id
            WHERE
                merkliste.pid = "'.intval($id).'" AND
                merkliste.uid = "'.intval($_SESSION['login']).'"
        ');
        while($row = $this->fetch_assoc($get)){
            $dataPackage[] = $row;    
        }
        
        $this->free_result($get);
        
        return $dataPackage;
            
    }
    public function setWatchList($id, $lat = NULL, $lng = NULL){
        $get = $this->query('SELECT id FROM merkliste WHERE uid = "'.$_SESSION['login'].'" and pid = "'.intval($id).'"');
        $row = $this->fetch_assoc($get);
        if( empty($row['id']) ){
            $this->query('INSERT INTO merkliste SET uid = "'.$_SESSION['login'].'", pid = "'.intval($id).'", lng = "'.$lng.'", lat = "'.$lat.'", datum = "'.time().'"');
            $this->query('UPDATE produkte SET beobachter = beobachter+1 WHERE id = "'.intval($id).'"');
        }
        $this->free_result($get);
    }
    public function browseUnderCategory($i = NULL){
        $cat = $this->query('SELECT * FROM kategorie_under WHERE bigid = "'.$i.'" ORDER BY name');
        while($row = $this->fetch_row($cat)){
        if($this->shownums == true){
            ?><div style="float:left; clear:both; padding-top:7px; color:#666; font-weight:bold;"><a href="cat<?php print $i; ?>-<?php print $row[0]; ?>" style="font-size:11px;"><?php print utf8_encode($row[1]); ?></a> <font style="font-size:11px; font-weight:bold;">
            (<?php 
            $zahl = $this->query('SELECT id FROM produkte WHERE unterkategorie = "'.$row[0].'" AND statuscode = "1"');
            $endzahl = mysql_num_rows($zahl); print $endzahl; ?>)</font></div><?php
        }else{
            ?><div style="float:left; clear:both; padding-top:7px; color:#666; font-weight:bold;"><a href="cat<?php print $i; ?>-<?php print $row[0]; ?>" style="font-size:11px;"><?php print utf8_encode($row[1]); ?></a></div><?php
        }
        }
    }
    public function updateTopAnzeigen(){
        $this->query('UPDATE produkte SET topanzeige = "0", topbis = "" WHERE topbis = "'.date('d.m.Y').'"');
    }
    public function browse(){
        $this->cate = $this->query('SELECT * FROM kategorie_big ORDER BY name');
        while($this->row = $this->fetch_row($this->cate))
        {
            $zahl = $this->query('SELECT id FROM produkte WHERE kategorie = "'.$this->row[0].'"  AND statuscode = "1"');
            if($this->shownums == true){
            $endzahl = '(' . $this->num_rows($zahl) . ')';
            }else{
            $endzahl = false;
            }
            $data[] = array($this->row[0], utf8_encode($this->row[1]), $this->row[2], $this->str(utf8_decode($this->row[1])), $endzahl );
        }
        
        $this->free_result($this->cate);
        return $data;
    }
    public function rowCategoryNameUnder3($i){
        //$get = $this->query('');
    }
    public function rowCategoryNameUnder2($i){
        $get = $this->query('SELECT * FROM kategorie_under WHERE bigid = "'.$i.'" ORDER by name');
        while($row = $this->fetch_row($get)){
            ?>
            <div style="float:left; clear:both; padding-top:2px; color:#666;"><a href="cat<?php print $i; ?>-<?php print $row[0]; ?>" style="font-size:11px;"><?php print $row[1]; ?></a></div>
            <?php
        }
        $this->free_result($get);
    }
    public function rowCategoryName($i, $a){
        $get = $this->query('SELECT name FROM '.$a.' WHERE id = "'.$i.'"');
        $row = $this->fetch_row($get);
        $this->free_result($get);
        return $row[0];
    }
    public function geoStation($e){
        $get = $this->query('SELECT '.$e['db'].' FROM geo WHERE geo_plz = "'.$e['plz'].'"');
        $row = $this->fetch_row($get);
        $this->free_result($get);
        return $row[0];
    }
    public function seoGetTitle(){
        $get = $this->query('SELECT titel FROM produkte WHERE id = "'.intval( $this->_GET('id') ).'"');
        $row = $this->fetch_row($get);
        $this->free_result($get);
        return $row[0];
    }
    public function setProductLastListView(){
        $get = $this->query('SELECT id FROM list WHERE ip = "'.$_SERVER['REMOTE_ADDR'].'" and aid = "'.intval( $this->_GET('id') ).'"');
        $row = $this->fetch_row($get);
        if(empty( $row[0] )){
            $this->query('INSERT INTO list
                SET
                    ip  = "'.$_SERVER['REMOTE_ADDR'].'",
                    aid = "'.intval( $this->_GET('id') ).'"
            ');
        }
        $this->free_result($get);
    }
    public function getHomeProducts($limit, $where = ''){
        
        if(!empty($where)){
            $where2 = 'AND statuscode = "1"';
        }else{
            $where2 = 'WHERE statuscode = "1"';
        }
        $this->pro = $this->query('SELECT id, titel, preis, erstellung, kategorie, preisart, unterkategorie, postleitzahl, stadt, bild FROM produkte ' . $where . ' '.$where2.' ORDER by id DESC LIMIT ' . $limit);
        while($this->po = $this->fetch_assoc($this->pro)){
            $data[] = array(
                "id" => $this->po["id"],
                "titel" => $this->po["titel"],
                "preis" => $this->po["preis"],
                "erstellung" => $this->po["erstellung"],
                "kategorie" => $this->po["kategorie"],
                "preisart" => $this->po["preisart"],
                "unterkategorie" => $this->po["unterkategorie"],
                "postleitzahl" => $this->po["stadt"],
                "bild" => $this->po["bild"],
                "zufall" => mt_rand(1,2)
            );
        }
        
        $this->free_result($this->pro);
        return $data;
        
    }
    public function setViewCount($id = NULL){
        $this->query('UPDATE produkte SET counter = counter+1 WHERE id = "'.intval($id).'"');
    }
    public function productViewCustomer($id, $limit = 3){
        $get = $this->query('SELECT * FROM produkte WHERE uid = "'.intval( $id ).'" and id != "'. $this->_GET('id').'" LIMIT ' . $limit);
        $num = $this->num_rows($get);
        if( $num >= 1 ){
            while( $row = $this->fetch_assoc($get) ){
                //setTemplateHTML
                ?>
                <div class="cat1" onclick="location.href='itm<?php echo $row['id']; ?>'" style="width:660px; padding:0;">
                <div style="float:left;">
                    <div style="float:left; border-right:1px solid #f2f2f2; padding:4px; background:#fff;">
                    <div style="float:left; background:url(tpl/upload/<?php echo $row['bild']; ?>-160.jpg) #fff no-repeat center; width:160px; height:160px;"></div>
                    </div>
                </div>
                
                <div style="float:left; padding-left:20px; padding-top:10px; font-size:16px; width:240px;">
                    <div style="float:left; width:240px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><b><a href="itm<?php echo $row['id']; ?>"><?php echo $row['titel']; ?></a></b></div>
                    <div style="float:left; clear:both; padding-top:10px; color:#666;">
                        <?php echo $row['postleitzahl']; ?> <?php echo $row['stadt']; ?>
                    </div>
                </div>
                
                <div style="float:right; font-weight:bold; color:#ff8300; width:140px; padding:10px; font-size:16px;" align="right">
                <?php if($row['preisart'] != 3){ ?><?php echo number_format($row['preis'],0,',','.'); ?> EUR <br /><?php } ?><?php if($row['preisart'] == 1){ echo 'Festpreis'; }elseif($row['preisart'] == 2){ echo 'VB'; }else{ echo 'Auf Anfrage'; } ?>
                </div>
                
                </div>
                <?php
            }
        }else{
            //setTemplateHTML
            ?>
                Keine weiteren Anzeigen
            <?php
        }
        $this->free_result($get);
    }
    public function updateAllProducts(){
        
        $get = $this->query('
        SELECT 
            produkte.id,
            geo.geo_ort
        FROM 
            produkte
        LEFT JOIN
            geo
        ON
            produkte.postleitzahl = geo.geo_plz
        WHERE 
            produkte.stadt = ""
        ');
        while($row = $this->fetch_assoc($get)){
            $this->query('UPDATE produkte SET stadt = "'.$row['geo_ort'].'" WHERE id = "'.$row['id'].'"');
        }
        
        $this->free_result($get);
        
    }
    public function productViewSimlear($id = NULL, $art = NULL){
        $get = $this->query('SELECT * FROM produkte WHERE '.$art.' = "'.$id.'" ORDER BY rand() LIMIT 3');
        while($row = $this->fetch_assoc($get)){
            //setTemplateHTML
            ?>
            <div class="cat1" onclick="location.href='itm<?php echo $row['id']; ?>'" style="width:660px; padding:0;">
            <div style="float:left;">
                <div style="float:left; border:1px solid #f2f2f2; padding:4px; background:#fff;">
                <div style="float:left; background:url(tpl/upload/<?php echo $row['bild']; ?>-160.jpg) #fff no-repeat center; width:160px; height:160px; background-size:auto 160px;"></div>
                </div>
            </div>
            
            <div style="float:left; padding-left:20px; padding-top:10px; font-size:16px; width:240px;">
                <div style="float:left;white-space: nowrap;overflow: hidden;text-overflow: ellipsis; width:270px;"><b><a href="itm<?php echo $row['id']; ?>"><?php echo $row['titel']; ?></a></b></div>
                <div style="float:left; clear:both; padding-top:10px; color:#666;">
                    <?php echo $row['postleitzahl']; ?> <?php echo $row['stadt']; ?>
                </div>
            </div>
            
            <div style="float:right; font-weight:bold; color:#ff8300; width:140px; padding:10px; font-size:16px;" align="right">
            <?php if($row['preisart'] != 3){ ?><?php echo number_format($row['preis'],0,',','.'); ?> EUR <br /><?php } ?><?php if($row['preisart'] == 1){ echo 'Festpreis'; }elseif($row['preisart'] == 2){ echo 'VB'; }else{ echo 'Auf Anfrage'; } ?>
            </div>
            
            </div>
            <?php
        }
        $this->free_result($get);
    }
    
    public function numProductsDB(){
        
        $get = $this->query('SELECT id FROM produkte');
        $row = $this->num_rows($get);
        
        $this->free_result($get);
        
        return $row;
            
    }
    
    public function getLoginEmail(){
        
        $get = $this->query('SELECT email, a_name FROM user WHERE id = "'.intval($_SESSION['login']).'"');
        $row = $this->fetch_row($get);
        
        $this->free_result($get);
        
        $date  = date('A');
        $date2 = date('H');
        
        $name = explode(' ', $row[1]);
        $name = $name[0];
        
        $name = $row[1] ? $name : $row[0];
        
        if($date2 >= 20 && $date2 <= 23){
            $end = 'Guten Abend, ' . $name;
        }
        elseif($date == 'AM'){
            $end = 'Guten Morgen, ' . $name;    
        }else{
            $end = 'Guten Tag, ' . $name;
        }
        
        return $end;
                    
    }
    
    public function selectExtraCategory($id){
        
        $get = $this->query('SELECT * FROM kategorie_under WHERE bigid = "'.$id.'" LIMIT 3');
        while($row = $this->fetch_assoc($get)){
            ?>
            <a href="cat<?php echo $id; ?>-<?php echo $row['id']; ?>">
            <div style="float:left; padding:15px; width:223px; font-family:Open Sans; font-weight:bold; font-size:11px; border-bottom:1px solid #eee;">
                <li style="margin:0; padding:0; margin-left:15px; list-style:square"><?php echo $row['name']; ?></li>
            </div>
            </a>
            <?php
        }
        
        $this->free_result($get);
            
    }
    
}
class handle extends functions
{
    var $connect     = 0x01;
    var $select_db    = 0x00;
    var $setMode    = 0x00;
    var $setModeIO  = 0x00;
    
    public function db_error(){ return mysqli_error(); }
    public function db_atach(){ error_reporting($this->setMode); }
    
    public function query($_){ return $this->connectdb->query($_); }
    public function fetch_assoc($_){ return $_->fetch_assoc(); }
    public function num_rows($_){ return $_->num_rows; }
    public function fetch_row($_){ return $_->fetch_row(); }
    public function fetch_object($_){ return $_->fetch_object(); }
    public function insert_id($_ = NULL){ return $this->connectdb->insert_id; }
    public function real_escape($_){ return $this->connectdb->real_escape_string($_); }
    public function free_result($_){ return @$_->free_result(); }
    public function error(){ error_reporting($this->setModeIO); }
    public function _GET($e){
        if(empty( $_GET[$e] )){ return false; }else{
            return $_GET[$e];
        }
    }
    public function _SESSION($e){
        if(empty( $_SESSION[$e] )){
            return false;
        }else{
            return true;
        }
    }
}
class         onCreate 
extends     handle 
implements     serviceHandler
{
    
    var $baseurl = '::0x00::';
    
    var $connectdb;
    public function __construct($offline = NULL){
        
        $this->connectdb = @new mysqli( self::dbHost, self::dbUser, self::dbPass, self::dbName );
        
        $this->connectdb->query("SET NAMES 'self::charset'");
        
        /*
        $this->connect         = mysql_connect( self::dbHost, self::dbUser, self::dbPass );
        $this->select_db    = mysql_select_db( self::dbName, $this->connect );
                              mysql_query("SET NAMES 'self::charset'");
        
        $this->db_atach();
        */    
        
    }
    
    public function __destruct(){ mysql_close($this->connect); }
        
}
$e = new onCreate(0);
function wrapy($text, $num){
    return wordwrap($text, $num, "n", true);
}
function createseo($phrase, $maxLength=100000000000000)
{
    $result = strtolower($phrase);
    
    $result = str_replace('ü', 'ue', $result);
    $result = str_replace('ä', 'ae', $result);
    $result = str_replace('ö', 'oe', $result);
    $result = str_replace('&', 'und', $result);
    $result = str_replace('ß', 'ss', $result);
    $result = str_replace('/', '-', $result);
    $result = str_replace('amp', '', $result);
    
    $result = preg_replace("/[^A-Za-z0-9s-._/]/", "", $result);
    $result = trim(preg_replace("/[s-]+/", " ", $result));
    $result = trim(substr($result, 0, $maxLength));
    $result = preg_replace("/s/", "-", $result);
       
    return $result;
}
function loadPhotos($photo, $photo1 = NULL){
    $photo = str_replace($photo1.'|-|', '', $photo);
    $photo = str_replace($photo1, '', $photo);
    if(!empty($photo)){
    $photo = explode('|-|', $photo);
    $count = count($photo);
    for($i=0; $i<$count; $i++){
        ?>
        <div style="float:left; padding-right:5px;">
            <div style="float:left; width:95px; height:95px; padding:4px; background:url(tpl/upload/<?php echo $photo[$i]; ?>-160.jpg) center no-repeat; background-size:100px ; cursor:pointer;" onclick="loadBild('<?php echo $photo[$i]; ?>', 'r<?php echo $i; ?>')" class="box0 allboxes r<?php echo $i; ?>"></div>
        </div>
        <?php
    }
    }
}
function isAdmin()
{
    global $e;
    return $e->isAdmin();
}
function anzeigengesamt()
{
    global $e;
    return $e->numProductsDB();
}
function logged_mail()
{
    global $e;
    return $e->getLoginEmail();
}
function selectExtraCategory($id){
    global $e;
    return $e->selectExtraCategory($id);    
}
//Top-Anzeige Einstellungen
$taggebuhr = 0.50;
//PayPal Optionen
//PayPal Send Back Url
//
$title2 = $title . ' - Anzeigen des Anbieters';
$title3 = $title . ' - Anzeige erstellen - Schritt 2';
$title4 = $title . ' - Alle Kategorien';
$title5 = $title . ' - Anzeige erstellen';
$title6 = $title . ' - Kontakt aufnahme erfolgreich';
$title7 = $title . ' - Zuletzt besuchten Anzeigen';
$title8 = $title . ' - Meine Anzeigen';
$title9 = $title . ' - Meldung war erfolgreich';
//->Nicht ändern
$paypalaccept = $domain.'mainmeineanzeigen?sk=success'; //Transaktions Okay
$paypalnone   = $domain.'mainmeineanzeigen?sk=cancel'; //Transaktionabbruch von PayPal
function metacontent(){ global $metacontent; return $metacontent; }
class db extends onCreate
{
        const dbhost = db_host;
        const dbuser = db_user;
        const dbpass = db_pass;
        const dbname = db_name;
        public function __construct(){
            parent::__construct();
        }
        
        public function real_escape_beta($sql){ return mysql_escape_string($sql); }
        public function uft8_en($string){ return utf8_encode($string); }
        public function uft8_de($string){ return utf8_decode($string); }
}
$opendb = new db();
?>