function __construct() { $dbconfig = base_config::getConfigFile(); $dns = $dbconfig['DBTYPE'] . ':dbname=' . $dbconfig['DBNAME'] . ';host=' . $dbconfig['DBHOST']; try { $this->connection = new PDO($dns, $dbconfig['DBUSER'], $dbconfig['DBPASS']); } catch (PDOException $e) { messages::logError($e->getMessage()); die('Connection to database failed!'); } $this->dbprefix = $dbconfig['DBPREF']; }
/** * Initiiert Grundsystem */ public static function init() { self::$baseDir = dirname(dirname(__DIR__)); self::$logfiles = array('errors' => self::$baseDir . '/logs/error.txt', 'system' => self::$baseDir . '/logs/system.txt'); self::$uploadDir = self::$baseDir . '/uploads/'; self::$bannerDir = self::$baseDir . '/uploads/banners/'; self::$updateServer = 'http://nobody-knows.org/updatepools/affiliatr/'; self::$updateFolder = self::$baseDir . '/upgrade/'; self::$cacheFolder = self::$baseDir . '/cache/'; self::$updateCache = self::$cacheFolder . '/update.cache'; $http = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; self::$rootPath = $http . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if (strpos(self::$rootPath, 'affiliat_r') === false) { self::$rootPath .= '/' . basename(self::$baseDir); } }
private function checkRequirements() { if (!class_exists('PDO')) { \messages::registerError('PHP PDO extension not found! Unable to proceed. Contact your host!', true); die; } foreach ($this->checkFolders as $checkFolder) { if (!is_writable(\base_config::$baseDir . '/' . $checkFolder)) { \messages::registerError("Unable to write in folder <b>/{$checkFolder}</b>!", true); } } if (!\base_config::canConnect()) { \messages::registerNotice('PHP setting <b>allow_url_fopen</b> is diabled. This is not required, but recommended.', true); } }
/** * Prüft ob Update verfügbar sind * @return string|null */ public function checkForUpdates() { $data = array('version' => $this->getSysVersion(), 'language' => $this->getSysLanguage(), 'phpvers' => PHP_VERSION, 'isauto' => (int) \base_config::canConnect()); $url = \base_config::$updateServer . 'noauto.php?data=' . base64_encode(json_encode($data)); if (!\base_config::canConnect()) { return $url; } if (file_exists(\base_config::$updateCache)) { $updateCache = json_decode(file_get_contents(\base_config::$updateCache), true); if ($updateCache['expire'] >= time()) { if (!empty($updateCache['message'])) { \messages::registerNotice($updateCache['message'], true); } return; } } try { $url = \base_config::$updateServer . 'newver.php?data=' . base64_encode(json_encode($data)); $updateData = fopen($url, 'r'); $updateData = fgets($updateData); $updateData = json_decode(base64_decode($updateData), true); $updateMessage = ''; if (version_compare($updateData['newversion'], $this->getSysVersion(), '>')) { if (isset($updateData['forceupdate']) && $updateData['forceupdate']) { header("Location: ?module=system/update&file=" . $updateData['updatefile']); } $updateMessage = \language::replaceLanguageConstant(\language::returnLanguageConstant('UPDATE_NEWVERSION'), array('{{versionlink}}' => '?module=system/update&file=' . $updateData['updatefile'])); \messages::registerNotice($updateMessage, true); } $cacheTmp = array('expire' => time() + 43200, 'message' => $updateMessage); file_put_contents(\base_config::$updateCache, json_encode($cacheTmp)); } catch (\Exception $ex) { \messages::registerError($ex->getMessage(), true); } return null; }
<?php /** * Common inits * @author Stefan Seehafer <*****@*****.**> * @copyright (c) 2013-2015, Stefan Seehafer * @license http://www.gnu.org/licenses/gpl.txt GPLv3 */ if (version_compare(PHP_VERSION, '5.3.3', '<')) { die('Affiliat*r does not support php version prior to PHP 5.3.3!'); } include __DIR__ . '/class/base_config.php'; include __DIR__ . '/functions.php'; set_error_handler("errorHandler"); spl_autoload_register('autoLoader'); base_config::init();