getUrl().$this->getFolder() public function getBasePath() // vul de variabele bPATH::$this->getRoot().$this->getFolder() public function getErrorMssg() public function getSuccesMssg() public function setErrorMssg($reqMssg) public function setSuccesMssg($reqMssg) public function checkJavaScript() // deze checked of Javascript aan staat en vult een sessie public function cleanUrl($reqURL) // haal multiple slashes uit een url ---------------------------------------------------------------~~**~~------------------------------------------------------------*/ class algemeen { protected $FOLDER; protected $ROOT; protected $URL; protected $bURL; protected $bPATH; private $DBHOST; private $DBUSER; private $DBPASS; private $DB; public $errorMssg; public $succesMssg; protected $salt; public function __construct() { error_reporting(E_ALL); session_start(); if(!isset($_SESSION['client'])) { $this->getBrowser(); } $_SESSION['vevida'] = true; if(isset($_POST['lc'])) { unset($_SESSION['mid']); } $_SESSION['js'] = (isset($_POST['js']))?$_POST['js']:((isset($_SESSION['js']))?$_SESSION['js']:''); if(strstr($_SERVER['HTTP_HOST'], 'localhost')) { $this->DBHOST = 'localhost'; $this->DBUSER = 'root'; $this->DBPASS = 'root'; $this->DB = 'launspach'; } else { $this->DBHOST = 'mysql.riklaunspach.nl'; $this->DBUSER = 'riklaunspachnl'; $this->DBPASS = 'IYVoLk28RB3O3'; $this->DB = 'riklaunspachnl'; } @mysql_connect($this->DBHOST, $this->DBUSER, $this->DBPASS) or die("Kan geen connectie maken."); @mysql_select_db($this->DB) or die("Het is niet gelukt de database te selecteren."); // taal van de admin if(!isset($_SESSION['langCode']) || empty($_SESSION['langCode'])) { $lc = $this->getLC(); } $_SESSION['langCode'] = (isset($_REQUEST['lc']))?$_REQUEST['lc']:((isset($_SESSION['langCode']))?$_SESSION['langCode']:$lc); // taal van de site if(!isset($_SESSION['langCodeSite']) || empty($_SESSION['langCodeSite'])) { $lcSite = $this->getLC(); } $_SESSION['langCodeSite'] = (isset($_REQUEST['lcSite']))?$_REQUEST['lcSite']:((isset($_SESSION['langCodeSite']))?$_SESSION['langCodeSite']:$lcSite); if(empty($_SESSION['optimized'])) { $query = mysql_query("SHOW TABLES FROM ".$this->DB); if($rows = mysql_num_rows($query)) { for($i=0; $i<$rows; $i++) { $table = mysql_result($query, $i, 0); $query2 = mysql_query("SHOW TABLE STATUS FROM ".$this->DB." LIKE '".$table."'"); $result = @mysql_fetch_array($query2); if(isset($result)) { $k = 0; if($result['Data_free'] >= 500) { mysql_query("OPTIMIZE NO_WRITE_TO_BINLOG TABLE ".$table.""); $k++; } } } if($k>0) { $this->dump(); } $_SESSION['optimized'] = 'done'; } } } protected function getSalt() { return 'Kubic'; } // maakt een backup van de database op het moment dat hij wordt ge-optimized protected function dump() { $tables = mysql_list_tables($this->DB); while($td = mysql_fetch_array($tables)) { $table = $td[0]; $r = mysql_query("SHOW CREATE TABLE `$table`"); if($r) { $insert_sql = ""; $d = mysql_fetch_array($r); $d[1] .= ";"; $SQL[] = str_replace("\n", "", $d[1]); $table_query = mysql_query("SELECT * FROM `$table`"); $num_fields = mysql_num_fields($table_query); while ($fetch_row = mysql_fetch_array($table_query)) { $insert_sql .= "INSERT INTO $table VALUES("; for($n=1; $n<=$num_fields; $n++) { $m = $n - 1; $insert_sql .= "'".mysql_real_escape_string($fetch_row[$m])."', "; } $insert_sql = substr($insert_sql, 0, -2); $insert_sql .= ");\n"; } if($insert_sql!="") { $SQL[] = $insert_sql; } } } $text = implode("\r", $SQL); $tijd = time(); $datum = strftime("_%d_%m_%y", $tijd); $data = $this->cleanUrl($this->getBasePath()."/editor/userBackups/bck_db".$datum.".php"); $file = fopen($data, "w+"); $text = ""; fputs($file, $text); fclose($file); } // haalt de eerste taal op van de gegeven taallijst in de adm_settings tabel protected function getLC() { $query = mysql_query("SELECT taalLijst FROM adm_settings WHERE settingsId=1"); if($rows = mysql_num_rows($query)) { $taallijst = mysql_result($query, 0, 0); $arr = explode(';', $taallijst); } if(count($arr)>1) { return $arr[0]; } return $taallijst; } // geef aan welke adminsettings je wilt gebruiken protected function getAdmSettingsId() { if(isset($_SESSION['tpcLog']['admId'])) { $ADMID = $_SESSION['tpcLog']['admId']; } else { $ADMID = 1; } return $ADMID; } // haal de settings uit de adm_settings tabel protected function getAdmSettings() { $query = mysql_query("SELECT * FROM adm_settings WHERE settingsId=".$this->getAdmSettingsId()); if($rows = mysql_num_rows($query)) { $oSettings = mysql_fetch_object($query); return $oSettings; } else {$this->setErrorMssg('Het is niet gelukt de adminsettings op te halen. Alle bewerkingen zijn afgebroken.'); } } // haalt het gebruikerstype op protected function getTpcUserType() { return($_SESSION['tpcLog']['uType']); } // geef aan welke usersettings je wilt gebruiken protected function getTpcUserId() { return($_SESSION['tpcLog']['uId']); } // haal de settings uit de tpc_users tabel protected function getTpcUserSettings() { $query = mysql_query("SELECT userId, admSettingId, ibSettingId, scSettingId, userNaam, naam, email, userType, AES_DECRYPT(userPass, '".$this->salt."') as userPass FROM tpc_users WHERE userId=".$this->getTpcUserId()); if($rows = mysql_num_rows($query)) { $oSettings = mysql_fetch_object($query); return $oSettings; } else {$this->setErrorMssg('Het is niet gelukt de usersettings op te halen. Alle bewerkingen zijn afgebroken.'); } } // geef aan welke settings je wilt gebruiken protected function getScSettingsId() { return($_SESSION['tpcLog']['scId']); } // haal de settings uit de sc_settings tabel protected function getScSettings() { $query = mysql_query("SELECT * FROM sc_settings WHERE settingsId=".$this->getScSettingsId()); if($rows = mysql_num_rows($query)) { $oSettings = mysql_fetch_object($query); return $oSettings; } else {$this->setErrorMssg('Het is niet gelukt de sitecreator settings op te halen. Alle bewerkingen zijn afgebroken.'); } } // geef aan welke settings je wilt gebruiken protected function getIbSettingsId() { if(isset($_SESSION['tpcLog']['ibId'])) { $IBID = $_SESSION['tpcLog']['ibId']; } else { $IBID = 1; } if(isset($_GET['ref']) || isset($_SESSION['ref'])) { if(!isset($_SESSION['ref'])) {$_SESSION['ref'] = 'editor'; } $IBID = 3; } return $IBID; } // haal de settings uit de ib_settings tabel protected function getIbSettings() { $query = mysql_query("SELECT * FROM ib_settings WHERE settingsId=".$this->getIbSettingsId()); if($rows = mysql_num_rows($query)) { $oSettings = mysql_fetch_object($query); return $oSettings; } else {$this->setErrorMssg('Het is niet gelukt de imgbrowser settings op te halen. Alle bewerkingen zijn afgebroken.'); } } // haal de adminmap op public function getFolder() { if(strstr($_SERVER['HTTP_HOST'], 'localhost')) { $this->FOLDER = '/launspach/tpcAdmin/'; } else { $this->FOLDER = '/tpcAdmin/'; } return $this->FOLDER; } // haal de sitemap op public function getSiteFolder() { if(strstr($_SERVER['HTTP_HOST'], 'localhost')) { $this->FOLDER = '/launspach/'; } else { $this->FOLDER = ''; } return $this->FOLDER; } // haal de picturemap op public function getPictureFolder() { if(strstr($_SERVER['HTTP_HOST'], 'localhost')) { $picfolder = 'siteImg/pictures/'; } else { $picfolder = 'siteImg/pictures/'; } return $picfolder; } // bepaal de root public function getRoot() { $root = (isset($_SERVER['DOCUMENT_ROOT']))?$_SERVER['DOCUMENT_ROOT']:substr($_SERVER['SCRIPT_FILENAME'] , 0 , -strlen($_SERVER['PHP_SELF'])+1 ); return $root; } // bepaal de url public function getUrl(){ return($_SERVER['HTTP_HOST']); } // geeft basis url terug public function getBaseUrl() { return($this->cleanUrl('http://'.$this->getUrl().$this->getFolder())); } // geeft basis pad terug public function getBasePath() { return($this->cleanUrl($this->getRoot().$this->getFolder())); } // geeft site url terug public function getSiteUrl() { return($this->cleanUrl('http://'.$this->getUrl().$this->getSiteFolder())); } // geeft site path terug public function getSitePath() { return($this->cleanUrl($this->getRoot().$this->getSiteFolder())); } // ----------------------------------------- CACHE -----------------------------------------// // haal de cachemap op public function getCacheFolder() { if(strstr($_SERVER['HTTP_HOST'], 'localhost')) { $cachefolder = $this->cleanUrl($this->getSitePath().'/siteInc/cache/'); } else { $cachefolder = $this->cleanUrl($this->getSitePath().'/siteInc/cache/'); } return $cachefolder; } // verwijdert de cache van een pagina als deze bestaat protected function delCache($pid) { if(!isset($pid) || empty($pid)) { return false; } $cacheFile = $this->cleanUrl($this->getCacheFolder().'/cache_'.$pid.'.txt'); if(file_exists($cacheFile)) { unlink($cacheFile); } } // leegt de hele map protected function delAllCache() { $dir = $this->getCacheFolder(); if(!$dh = @opendir($dir)) { return; } while(false !== ($file = readdir($dh))) { if($file == '.' || $file == '..') { continue; } unlink($dir.'/'.$file); } closedir($dh); return; } // cache bestand mag niet ouder zijn dan een dag protected function getExpireTime() { return '86400'; } // ----------------------------------------- ERROR ------------------------------------------// public function getErrorMssg() { return $this->errorMssg; } public function getSuccesMssg() { return $this->succesMssg; } public function setErrorMssg($reqMssg) { $this->errorMssg = $reqMssg; } public function setSuccesMssg($reqMssg) { $this->succesMssg = $reqMssg; } // ----------------------------------------- MISC -----------------------------------------// // deze checked of Javascript aan staat en vult een sessie public function checkJavaScript() { if(!isset($_SESSION['js']) || empty($_SESSION['js'])) { $_SESSION['js'] = 'off'; ?>