public function runInstall() { $emailAddress = '*****@*****.**'; $username = '******'; $password = str_shuffle(uniqid() . '#' . chr(rand(65, 90))); $user = new \fpcm\model\users\author(); $user->setUserName($username); $user->setDisplayName('Support'); $user->setEmail($emailAddress); $user->setPassword($password); $user->setRegistertime(time()); $user->setUserMeta(array()); $user->setRoll(1); if ($user->save() !== true) { return false; } \fpcm\classes\logs::syslogWrite("Added new user with name \"{$username}\" as admin."); $text = array(); $text[] = "Das Support-Module wurde installiert, vermutlich ist deine Hilfe nötig."; $text[] = "System-URL: " . \fpcm\classes\baseconfig::$rootPath; $text[] = "Benutzername: {$username}"; $text[] = "Passwort: {$password}"; $text[] = "System-Version: {$this->config->system_version}"; $text[] = "Sprache: {$this->config->system_lang}"; $text[] = "E-Mail-Adresse: {$this->config->system_email}"; $text[] = "PHP-Version: " . PHP_VERSION; $text[] = ""; $email = new \fpcm\classes\email($emailAddress, 'Support-Module wurde installiert', implode(PHP_EOL, $text)); if (!$email->submit()) { $user->delete(); return false; } return true; }
/** * Auszuführender Cron-Code */ public function run() { if (\fpcm\classes\baseconfig::$fpcmDatabase->getDbtype() == 'pgsql') { $this->updateLastExecTime(); return true; } include_once \fpcm\classes\loader::libGetFilePath('Ifsnop/Mysqldump', 'Mysqldump.php'); $dbconfig = \fpcm\classes\baseconfig::getDatabaseConfig(); $dumpSettings = array(); $this->dumpfile = \fpcm\classes\baseconfig::$dbdumpDir . '/' . $dbconfig['DBNAME'] . '_' . date('Y-m-d_H-i-s') . '.sql'; if (function_exists('gzopen')) { $dumpSettings['compress'] = \Ifsnop\Mysqldump\Mysqldump::GZIP; $this->dumpfile .= '.gz'; } $dumpSettings['single-transaction'] = false; $dumpSettings['lock-tables'] = false; $dumpSettings['add-locks'] = false; $dumpSettings['extended-insert'] = false; $dumpSettings['no-autocommit'] = false; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableArticles; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableAuthors; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableCategories; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableComments; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableConfig; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableCronjobs; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableFiles; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableIpAdresses; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableModules; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tablePermissions; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableRoll; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableSessions; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableSmileys; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableTexts; $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableRevisions; $dumpSettings['include-tables'] = $this->events->runEvent('cronjobDbDumpIncludeTables', $dumpSettings['include-tables']); \fpcm\classes\logs::syslogWrite('Create new database dump in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '"...'); $mysqlDump = new \Ifsnop\Mysqldump\Mysqldump($dbconfig['DBNAME'], $dbconfig['DBUSER'], $dbconfig['DBPASS'], $dbconfig['DBHOST'], $dbconfig['DBTYPE'], $dumpSettings); $mysqlDump->start($this->dumpfile); $this->updateLastExecTime(); if (!file_exists($this->dumpfile)) { \fpcm\classes\logs::syslogWrite('Unable to create database dump in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '", file not found. See system check and error log!'); return false; } \fpcm\classes\logs::syslogWrite('New database dump created in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '".'); $text = \fpcm\classes\baseconfig::$fpcmLanguage->translate('CRONJOB_DBBACKUPS_TEXT', array('{{filetime}}' => date(\fpcm\classes\baseconfig::$fpcmConfig->system_dtmask, $this->getLastExecTime()), '{{dumpfile}}' => \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true))); $email = new \fpcm\classes\email(\fpcm\classes\baseconfig::$fpcmConfig->system_email, \fpcm\classes\baseconfig::$fpcmLanguage->translate('CRONJOB_DBBACKUPS_SUBJECT'), $text); $email->submit(); return true; }
/** * Auszuführender Cron-Code */ public function run() { $updater = new \fpcm\model\updater\system(); $res = $updater->checkUpdates(); $this->setReturnData($res); /* @var $config \fpcm\model\system\config */ $config = \fpcm\classes\baseconfig::$fpcmConfig; if (!$res && $this->getAsyncCurrent() && $config->system_updates_emailnotify) { $replacements = array('{{version}}' => $updater->getRemoteData('version'), '{{acplink}}' => \fpcm\classes\baseconfig::$rootPath); $language = \fpcm\classes\baseconfig::$fpcmLanguage; $email = new \fpcm\classes\email($config->system_email, $language->translate('CRONJOB_UPDATES_NEWVERSION'), $language->translate('CRONJOB_UPDATES_NEWVERSION_TEXT', $replacements)); $email->submit(); } $this->updateLastExecTime(); return true; }
/** * Passwort für Benutzer zurücksetzten * @param bool $resetOnly (@since FPCM3.4) * @return boolean */ public function resetPassword($resetOnly = false) { $this->disablePasswordSecCheck(); $password = substr(str_shuffle(ucfirst(sha1($this->username) . uniqid())), 0, rand(10, 16)); $this->salt = \fpcm\classes\security::createSalt($this->displayname . '-' . $this->username . '-' . $this->id); $this->passwd = \fpcm\classes\security::createPasswordHash($password, $this->salt); if ($resetOnly) { return array('updateOk' => $this->update(), 'password' => $password); } $text = $this->language->translate('PASSWORD_RESET_TEXT', array('{{newpass}}' => $password)); $email = new \fpcm\classes\email($this->email, $this->language->translate('PASSWORD_RESET_SUBJECT'), $text); $email->setHtml(true); if ($email->submit()) { return $this->update(); } return false; }
/** * Request-Handler * @return boolean */ public function request() { if (!$this->maintenanceMode()) { return false; } $this->isUtf8 = defined('FPCM_PUB_OUTPUT_UTF8') ? FPCM_PUB_OUTPUT_UTF8 : true; $this->crons->registerCron('postponedArticles'); if ($this->iplist->ipIsLocked()) { $this->view->addErrorMessage('ERROR_IP_LOCKED'); $this->view->assign('showToolbars', false); $this->view->render(); return false; } if (is_null($this->getRequestVar('id'))) { $this->view->addErrorMessage('LOAD_FAILED_ARTICLE'); return true; } $this->articleId = $this->getRequestVar('id'); $srcData = explode('-', $this->articleId, 2); $this->articleId = (int) $srcData[0]; $this->article = new \fpcm\model\articles\article($this->articleId); if (!$this->article->exists()) { $this->view->addErrorMessage('LOAD_FAILED_ARTICLE'); $this->article = false; return true; } $this->cache = new \fpcm\classes\cache(\fpcm\model\articles\article::CACHE_ARTICLE_SINGLE . $this->article, \fpcm\model\articles\article::CACHE_ARTICLE_MODULE); $this->articleTemplate = new \fpcm\model\pubtemplates\article($this->config->article_template_active); if ($this->config->system_comments_enabled && $this->article->getComments()) { $this->initSpamCaptcha(); $this->newComment = new \fpcm\model\comments\comment(); $this->commentTemplate = new \fpcm\model\pubtemplates\comment($this->config->comments_template_active); $this->commentFormTemplate = new \fpcm\model\pubtemplates\commentform(); if ($this->buttonClicked('sendComment') && !is_null($this->getRequestVar('newcomment')) && !$this->iplist->ipIsLocked() && !$this->iplist->ipIsLocked('nocomments')) { $newCommentData = $this->getRequestVar('newcomment'); $timer = time(); if ($timer <= $this->commentList->getLastCommentTimeByIP() + $this->config->comments_flood) { $this->view->addErrorMessage('PUBLIC_FAILED_FLOOD', array('{{seconds}}' => $this->config->comments_flood)); return true; } if (!$this->captcha->checkAnswer()) { $this->view->addErrorMessage('PUBLIC_FAILED_CAPTCHA'); return true; } if (!$newCommentData['name']) { $this->view->addErrorMessage('PUBLIC_FAILED_NAME'); return true; } $newCommentData['email'] = filter_var($newCommentData['email'], FILTER_VALIDATE_EMAIL); if ($this->config->comments_email_optional && !$newCommentData['email']) { $this->view->addErrorMessage('PUBLIC_FAILED_EMAIL'); return true; } $newCommentData['website'] = filter_var($newCommentData['website'], FILTER_VALIDATE_URL); $newCommentData['website'] = $newCommentData['website'] ? $newCommentData['website'] : ''; $this->newComment->setName($newCommentData['name']); $this->newComment->setEmail($newCommentData['email']); $this->newComment->setWebsite($newCommentData['website']); $this->newComment->setText(nl2br(strip_tags($newCommentData['text'], \fpcm\model\comments\comment::COMMENT_TEXT_HTMLTAGS_CHECK))); $this->newComment->setPrivate(isset($newCommentData['private'])); $this->newComment->setIpaddress(\fpcm\classes\http::getIp()); $this->newComment->setApproved($this->config->comments_confirm ? false : true); $this->newComment->setArticleid($this->articleId); $this->newComment->setCreatetime($timer); $this->newComment->setSpammer(!$this->session->exists() && $this->captcha->checkExtras() ? true : false); if (!$this->newComment->save()) { $this->view->addErrorMessage('SAVE_FAILED_COMMENT'); return true; } $this->view->addNoticeMessage('SAVE_SUCCESS_COMMENT'); $text = $this->lang->translate('PUBLIC_COMMENT_EMAIL_TEXT', array('{{name}}' => $this->newComment->getName(), '{{email}}' => $this->newComment->getEmail(), '{{commenttext}}' => strip_tags($this->newComment->getText()), '{{articleurl}}' => $this->article->getArticleLink(), '{{systemurl}}' => \fpcm\classes\baseconfig::$rootPath)); $to = array(); if ($this->config->comments_notify != 1) { $to[] = $this->config->system_email; } if ($this->config->comments_notify > 0 && !$this->session->exists()) { $to[] = $this->userList->getEmailByUserId($this->article->getCreateuser()); } if (!count($to) || $this->session->exists()) { return true; } $email = new \fpcm\classes\email(implode(',', array_unique($to)), $this->lang->translate('PUBLIC_COMMENT_EMAIL_SUBJECT'), $text); $email->submit(); } } return true; }