public static function deleteFile($id) { $values = []; for ($i = 1; $i <= 10; $i++) { $values[] = '`media' . $i . '` = ' . $id; } for ($i = 1; $i <= 10; $i++) { $values[] = '`medialist' . $i . '` LIKE "%|' . $id . '|%"'; } $sql = sql::factory(); $sql->query('SELECT id FROM ' . sql::table('structure_area') . ' WHERE ' . implode(' OR ', $values))->result(); if ($sql->num()) { echo message::warning(lang::get('file_in_use')); } else { $sql = sql::factory(); $sql->setTable('media'); $sql->setWhere('id=' . $id); $sql->select('filename'); $sql->result(); if (unlink(dir::media($sql->get('filename')))) { $sql->delete(); return message::success(lang::get('file_deleted'), true); } else { return message::warning(sprintf(lang::get('file_not_deleted'), dyn::get('hp_url'), $sql->get('filename')), true); } } }
function bootstrap_panel($title, $content, $buttons = false) { $class = ''; $clearfix = ''; try { if ($buttons !== false) { if (!is_array($buttons) && dyn::get('debug')) { throw new InvalidArgumentException('$buttons must be an array'); } $class = ' pull-left'; $clearfix = '<div class="clearfix"></div>'; $buttons = '<div class="btn-group pull-right">' . PHP_EOL . implode(PHP_EOL, (array) $buttons) . '</div>'; } } catch (InvalidArgumentException $e) { echo message::warning($e->getMessage()); } echo '<div class="row"> <div class="col-lg-12"> <div id="ajax-content"></div> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title' . $class . '">' . $title . '</h3> ' . $buttons . ' ' . $clearfix . ' </div> ' . $content . ' </div> </div> </div>'; }
public static function checkVersion() { $cacheFile = cache::getFileName(0, 'dynaoVersion'); // jeden Tag if (cache::exist($cacheFile, 86400)) { $content = json_decode(cache::read($cacheFile), true); } else { $server = 'http://api.dynao.de/version.json'; $ch = curl_init($server); curl_setopt($ch, CURLOPT_PORT, 80); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla (Statuscheck-Script)'); curl_setopt($ch, CURLOPT_TIMEOUT, 0); curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 300); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $curl = curl_exec($ch); curl_close($ch); $content = json_decode($curl, true); cache::write($content, $cacheFile); } if (is_null($content)) { return lang::get('version_fail_connect'); } $version = explode('.', $content['current']['version']); $cversion = explode('.', dyn::get('version')); if ($version[0] != $cversion[0]) { return lang::get('version_fail_version1'); } if ($version[1] != $cversion[1]) { return lang::get('version_fail_version2'); } if ($version[2] != $cversion[2]) { return lang::get('version_fail_version3'); } return true; }
public static function checkAddon($addons) { $return = ''; foreach ($addons as $name => $version) { if (is_int($name)) { $name = $version; $version = false; } if (isset(dyn::get('addons')[$name])) { $config = dyn::get('addons')[$name]; } // Nicht installiert if (!isset($config) || !is_array($config)) { $return .= sprintf(lang::get('addon_not_found'), $name); continue; } if (!addonConfig::isActive($name)) { $return .= sprintf(lang::get('addon_not_install_active'), $name); continue; } if (dyn::checkVersion($config['version'], $version) === false) { $return .= sprintf(lang::get('addon_need_version'), $name, $version); continue; } } if ($return == '') { return true; } else { return $return; } }
public static function isInCategory($is_structure, $structure) { if ($is_structure == 1) { return true; } return in_array(dyn::get('page_id'), (array) $structure); }
public static function checkVersion($version) { if (dyn::get('version') >= $version) { return true; } return sprintf(lang::get('template_wrong_version'), dyn::get('version'), $version); }
public static function getHTML() { return '<title>' . self::getTitle() . '</title> <meta name="description" content="' . self::getDescription() . '"> <meta name="keywords" content="' . self::getKeywords() . '"> <base href="' . dyn::get('hp_url') . '"> <link rel="canonical" href="' . self::getCanonicalUrl() . '">' . PHP_EOL; }
public function getPath() { if (dyn::get('backend')) { return '../media/' . $this->get('filename'); } else { return 'media/' . $this->get('filename'); } }
public static function saveConfig($from, $fromName, $confirmReading, $bbc) { $config = dyn::get('addons')['phpmailer']; $config['settings']['from'] = $from; $config['settings']['fromName'] = $fromName; $config['settings']['confirmReading'] = $confirmReading; $config['settings']['bbc'] = $bbc; return file_put_contents(dir::addon('phpmailer', 'config.json'), json_encode($config, JSON_PRETTY_PRINT)); }
public static function fe($id = '', $params = []) { if ($id == '') { type::super('page_id', 'int', dyn::get('start_page')); } $url = extension::get('URL_REWRITE', ['id' => $id, 'params' => $params]); if (!extension::has('URL_REWRITE')) { $url = 'index.php?page_id=' . $id; foreach ($params as $name => $value) { $url .= '&' . $name . '=' . $value; } } return $url; }
public static function checkDynVersion() { $cacheFile = cache::getFileName(0, 'dynaoVersion'); // jeden Tag if (cache::exist($cacheFile, 86400)) { $content = json_decode(cache::read($cacheFile), true); } else { $content = apiserver::getVersionFile(); cache::write($content, $cacheFile); } if (is_null($content)) { return lang::get('version_fail_connect'); } return self::checkVersion($content['current']['version'], dyn::get('version')); }
public function parseUrl($url) { $url = str_replace(dyn::get('hp_url'), '', $url); $url = trim($url, '/'); if (isset(self::$pathlist[$url])) { $id = self::$pathlist[$url]; extension::add('SET_PAGE_ID', function () use($id) { return $id; }); } if ($url == '') { $id = dyn::get('start_page'); } return $id; }
public function setArticles($offlines) { if ($offlines) { $where = ''; } else { $where = ' WHERE online = 1'; } $sql = sql::factory(); $sql->query('SELECT * FROM ' . sql::table('structure') . $where . ' ORDER BY `sort`')->result(); while ($sql->isNext()) { $prio = $sql->get('id') == dyn::get('start_page') ? 1 : 0.8; $updatedAt = new DateTime($sql->get('updatedAt')); $freq = self::getChangeFreq($updatedAt); self::$articles[] = ['loc' => dyn::get('hp_url') . seo_rewrite::rewriteId($sql->get('id')), 'prio' => $prio, 'freq' => $freq, 'lastmod' => $updatedAt->format('c')]; $sql->next(); } }
public static function addToPathlist($filter, $addonsUrls) { $addonnames = []; foreach (seo_control::getArticleNames(seo_control::getArticleByFilter($filter)) as $id => $name) { $name = rtrim($name, dyn::get('addons')['seo']['ending']); if ($name) { $name .= '/'; } foreach ($addonsUrls as $addonname) { $addonnames[$name . $addonname] = $id; } } extension::add('SEO_GENERATE_PATHLIST', function ($list) use($addonnames) { $list = array_merge($addonnames, $list); return $list; }); }
public static function sendLostPasswordMail($email) { $sql = sql::factory(); $sql->query('SELECT id FROM ' . sql::table('community_user') . ' WHERE `email` = ' . $sql->escape($email)); if (!$sql->num()) { return 'Keinen User mit der E-Mail-Adresse vorhanden'; } $content = file_get_contents(dir::addon('community', 'lostpasswordemail.txt')); $key = self::generateString(16); $url = dyn::get('hp_url') . 'index.php?lostpassword='******'{{url}}', $url, $content); // Mailsend $sql->setTable('community_user'); $sql->setWhere('id=' . $sql->get('id')); $sql->addPost('lostpw_key', $key); $sql->update(); }
public static function generateArticle($id, $block = false) { $return = []; $type = $block ? 'block' : 'article'; $backend = dyn::get('backend'); dyn::add('backend', false); $page = new page($id, true, $block); $blocks = $page->getBlocks(); foreach ($blocks as $block) { $block->setEval(false); $return[] = $block->getContent(); } if (self::exist($id, false, $type)) { self::deleteFile($id, $type); } self::write(implode(PHP_EOL, $return), $id, $type); dyn::add('backend', $backend); }
public static function getTreeStructurePage($parentId = 0, $lvl = 0) { $select = ''; $id = !$lvl ? 'id="structure-tree"' : ''; $sql = sql::factory(); $sql->query('SELECT * FROM ' . sql::table('structure') . ' WHERE parent_id = ' . $parentId . ' ORDER BY sort')->result(); if ($sql->num()) { $select .= '<ul ' . $id . '>'; while ($sql->isNext()) { $edit = ''; $online = ''; $offline = ''; $delete = ''; $name = $sql->get('name'); if (dyn::get('user')->hasPerm('page[content]')) { $name = '<a href="' . url::backend('structure', ['subpage' => 'pages', 'structure_id' => $sql->get('id')]) . '">' . $sql->get('name') . '</a>'; } if (dyn::get('user')->hasPerm('page[edit]')) { $edit = '<a href="' . url::backend('structure', ['subpage' => 'pages', 'action' => 'edit', 'id' => $sql->get('id')]) . '" class="btn btn-sm btn-default fa fa-pencil-square-o"></a>'; $online = '<a href="' . url::backend('structure', ['subpage' => 'pages', 'action' => 'online', 'id' => $sql->get('id')]) . '" class="btn btn-sm dyn-online fa fa-check" title="' . lang::get('online') . '"></a>'; $offline = '<a href="' . url::backend('structure', ['subpage' => 'pages', 'action' => 'online', 'id' => $sql->get('id')]) . '" class="btn btn-sm dyn-offline fa fa-times" title="' . lang::get('offline') . '"></a>'; } if (dyn::get('user')->hasPerm('page[delete]')) { $delete = '<a href="' . url::backend('structure', ['subpage' => 'pages', 'action' => 'delete', 'id' => $sql->get('id')]) . '" class="btn btn-sm btn-danger fa fa-trash-o delete"></a>'; } $online = $sql->get('online') ? $online : $offline; $select .= '<li data-id="' . $sql->get('id') . '">' . PHP_EOL . ' <div class="handle"><i class="fa fa-sort"></i> ' . $name . PHP_EOL . ' <span class="btn-group">' . $online . $edit . $delete . '</span>' . PHP_EOL . ' </div>' . PHP_EOL; $select .= self::getTreeStructurePage($sql->get('id'), $lvl + 1); if ($sql->counter + 1 == $sql->num()) { $select .= '<div class="droppages"></div>'; } $select .= '</li>' . PHP_EOL; $sql->next(); } $select .= '</ul>'; } elseif (!$select && $lvl == 0) { $select = lang::get('no_entries'); } return $select; }
public static function exportTables() { if (!isset($_POST["export"])) { echo message::danger(lang::get('exportSelect'), true); } else { $result = ''; foreach ($_POST["export"] as $table => $status) { $DB = dyn::get('DB'); $prefix = strlen($DB['prefix']); $result .= 'DROP TABLE IF EXISTS `dynaoimportexporttoll' . $table . '`;'; $sql = sql::factory(); $sql->query('SHOW CREATE TABLE ' . $DB['prefix'] . $table)->result(); $creatTable = "\n\n" . str_replace("CREATE TABLE `" . $DB['prefix'], "CREATE TABLE IF NOT EXISTS `dynaoimportexporttoll", $sql->get("Create Table")) . ";\n\n"; $result .= preg_replace("/(`.*` int.* DEFAULT) '(.*)'/", '${1} ${2}', $creatTable); $sql->query("SELECT * FROM " . $DB['prefix'] . $table)->result(); while ($sql->isNext()) { $result .= 'INSERT INTO `dynaoimportexporttoll' . $table . '` VALUES('; $i = 1; foreach ($sql->result as $row) { $result .= "'" . $sql->escape(str_replace(";", "`#semikolon#`", $row)) . "'"; if (count($sql->result) > $i) { $result .= ","; } $i++; } $result .= ");\n"; $sql->next(); } } $length = strlen($result); header('Content-Description: File Transfer'); header('Content-Type: application/sql'); header('Content-Disposition: attachment; filename=backup.sql'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . $length); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); header('Pragma: public'); echo $result; exit; } }
/** * Das Formular erstellen * * @param string $table Die SQL Tabelle * @param string $where Die SQL Abfrage * @param string $action Ziel URL um die Daten zu bearbeiten * @param string $method Die Methode (post|get) * */ public function __construct($table, $where, $action, $method = 'post') { $this->method = $method; $this->action = $action; $this->sql = sql::factory(); $this->sql->query('SELECT * FROM ' . sql::table($table) . ' WHERE ' . $where . ' LIMIT 1'); $this->sql->result(); if ($this->sql->num() == 1) { $this->setMode('edit'); $this->setWhere($where); } $this->setTable($table); if (dyn::get('backend')) { $this->loadBackend(); } $this->addFormAttribute('class', 'form-horizontal'); $this->addFormAttribute('action', $this->action); $this->addFormAttribute('method', $this->method); $this->setButtons(); $this->setSuccessMessage(lang::get('form_saved')); $this->addParam('action', $this->mode); }
<div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><?php echo lang::get('general'); ?> </h3> </div> <div class="panel-body"> <?php $form = form_install::factory('', '', 'index.php'); $form->addParam('page', $page); $field = $form->addTextField('hp_name', dyn::get('hp_name')); $field->fieldName(lang::get('settings_name_of_site')); $field = $form->addTextField('hp_url', dyn::get('hp_url')); $field->fieldName(lang::get('settings_url_of_site')); $field = $form->addSelectField('lang', dyn::get('lang')); $field->fieldName(lang::get('settings_backend_lang')); $handle = opendir(dir::backend('lib' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR)); while ($file = readdir($handle)) { if (in_array($file, ['.', '..'])) { continue; } $field->add($file, $file); } if ($form->isSubmit()) { $url = 'http://' . str_replace('http://', '', $form->get('hp_url')); $endSlash = substr($url, -1, 1); if ($endSlash != '/') { $url .= '/'; } dyn::add('hp_name', $form->get('hp_name'), true);
</div> </div> </section> <div class="container"> <div class="row"> <div class="col-lg-12"> <section id="content"> <?php echo slot::getSlot('boxen'); ?> <div class="row"> <div class="col-md-12"> <?php echo dyn::get('content'); ?> </div> </div> </section> </div> </div> <div class="row"> <div class="col-lg-12"> <section id="footer"> © Copyright 2013 - Design by <a href="http://dynao.de" target="_blank">dynao.de</a> </section> </div> </div> </div>
autoload::addDir(dir::classes('utils')); new dyn(); if (dyn::get('setup') == true) { header('Location: install/'); exit; } if (isset($DYN['backend'])) { dyn::add('backend', $DYN['backend']); } else { dyn::add('backend', true); } unset($DYN); include dir::functions('html_stuff.php'); include dir::functions('url_stuff.php'); lang::setDefault(); lang::setLang(dyn::get('lang')); $DB = dyn::get('DB'); sql::connect($DB['host'], $DB['user'], $DB['password'], $DB['database']); ob_start(); date_default_timezone_set(dyn::get('timezone', 'Europe/Berlin')); new userLogin(); dyn::add('user', new user(userLogin::getUser())); cache::setCache(dyn::get('cache')); addonConfig::loadAllConfig(); addonConfig::includeAllLangFiles(); addonConfig::includeAllLibs(); if (dyn::get('backend')) { include dir::backend('backend.php'); } else { include dir::backend('frontend.php'); }
<?php $action = type::super('action', 'string'); $id = type::super('id', 'int', 0); $subpage = type::super('subpage', 'string', 'pages'); $structure_id = type::super('structure_id', 'int'); if ($subpage == 'popup') { backend::addSubnavi('Popup', url::backend('structure', ['subpage' => 'popup'])); } if (dyn::get('user')->hasPerm('page[edit]') || dyn::get('user')->hasPerm('page[delete]') || dyn::get('user')->hasPerm('page[content]')) { backend::addSubnavi(lang::get('pages'), url::backend('structure', ['subpage' => 'pages'])); backend::addSubnavi(lang::get('blocks'), url::backend('structure', ['subpage' => 'blocks'])); } if (dyn::get('user')->hasPerm('page[module]')) { backend::addSubnavi(lang::get('modules'), url::backend('structure', ['subpage' => 'module'])); } include_once backend::getSubnaviInclude();
<?php if (type::get('checkversion', 'int', 0) == 1) { $cacheFile = cache::getFileName(0, 'dynaoVersion'); cache::exist($cacheFile, 0); echo message::success(lang::get('connection_again'), true); } if (ajax::is()) { if (type::super('text')) { $mail = mail('*****@*****.**', 'Neue Idee', type::super('text'), 'From: ' . dyn::get('user')->get('firstname') . ' ' . dyn::get('user')->get('name') . '<' . dyn::get('user')->get('email') . '>'); if ($mail) { ajax::addReturn(message::success(lang::get('idea_send'))); } else { ajax::addReturn(message::danger(lang::get('idea_error'))); } } else { ajax::addReturn(message::danger(lang::get('idea_empty'))); } } $versionCheck = dyn::checkDynVersion(); if ($versionCheck === lang::get('version_fail_connect')) { $message = lang::get('version_fail_connect'); $message .= '<br /><a href="' . url::backend('dashboard', ['subpage' => 'overview', 'checkversion' => 1]) . '">' . lang::get('try_again') . '</a>'; echo message::danger($message, true); } elseif ($versionCheck) { echo message::danger($versionCheck, true); } $stats = []; $sql = sql::factory(); $numPages = $sql->num('SELECT * FROM ' . sql::table('structure')); $sql = sql::factory();
<h3 class="panel-title pull-left"><?php echo lang::get('media'); ?> </h3> <?php if (dyn::get('user')->hasPerm('media[category][edit]')) { ?> <div class="btn-group pull-right"> <a href="<?php echo url::backend('media', ['subpage' => 'category', 'action' => 'add', 'pid' => $pid]); ?> " class="btn btn-sm btn-default"><?php echo lang::get('add'); ?> </a> </div> <?php } ?> <div class="clearfix"></div> </div> <?php echo $table->show(); ?> </div> </div> </div> <?php if (in_array($action, ['edit', 'add']) && dyn::get('user')->hasPerm('media[category][edit]')) { echo '</form>'; }
<?php layout::addJs('addons/mediamanager/layout/js/mediamanager.js'); userPerm::add('media[edit]', lang::get('media[edit]')); userPerm::add('media[delete]', lang::get('media[delete]')); userPerm::add('media[category][edit]', lang::get('media[category][edit]')); userPerm::add('media[category][delete]', lang::get('media[category][delete]')); if (dyn::get('user')->hasPerm('media[edit]') || dyn::get('user')->hasPerm('media[delete]') || dyn::get('user')->hasPerm('media[category][edit]') || dyn::get('user')->hasPerm('media[category][delete]')) { backend::addNavi(lang::get('media'), url::backend('media'), 'picture-o', 2, function () { return dir::addon('mediamanager', 'page' . DIRECTORY_SEPARATOR . 'media.php'); }); } form::addClassMethod('addMediaField', function ($name, $value) { return $this->addField($name, $value, 'formMedia'); }); form::addClassMethod('addMediaListField', function ($name, $value) { return $this->addField($name, $value, 'formMediaList'); }); $page = type::super('page', 'string'); $subpage = type::super('subpage', 'string'); $action = type::super('action', 'string'); pageArea::addType('varsMedia'); pageArea::addType('varsMedialist'); if (addonConfig::isActive('metainfos')) { metainfosPage::addType('DYN_MEDIA'); metainfosPage::addType('DYN_MEDIA_LIST'); if ($page == 'meta') { backend::addSubNavi(lang::get('media'), url::backend('meta', ['subpage' => 'media']), 'circle', -1, function () { return dir::addon('mediamanager', 'page' . DIRECTORY_SEPARATOR . 'meta.media.php'); }); }
public static function table($table) { $DB = dyn::get('DB'); return $DB['prefix'] . $table; }
</p> <p><?php echo lang::get('install_delete'); ?> </p> <p> <a href="http://dynao.de" target="_blank"><?php echo lang::get('dynao_site'); ?> </a><br /> <a href="http://dynao.de/forum" target="_blank"><?php echo lang::get('dynao_forum'); ?> </a> </p> <a class="btn btn-default btn-sm" href="<?php echo dyn::get('hp_url') . '/admin'; ?> "><?php echo lang::get('visit_admin'); ?> </a> </div> </div> </div> </div>
public static function makeSEOName($name, $ending = true) { $name = mb_strtolower($name); $search = ['ä', 'ü', 'ö', 'ß', '&']; $replace = ['ae', 'ue', 'oe', 'ss', 'und']; $name = str_replace($search, $replace, $name); $name = preg_replace('/[^a-z0-9]/', '-', $name); $name = preg_replace('/-{2,}/', '-', $name); if ($ending) { $name .= dyn::get('addons')['seo']['ending']; } return $name; }
if ($action == 'online' && dyn::get('user')->hasPerm('page[edit]')) { $sql = sql::factory(); $sql->query('SELECT online FROM ' . sql::table('structure') . ' WHERE id=' . $id)->result(); $online = $sql->get('online') ? 0 : 1; $sql->setTable('structure'); $sql->setWhere('id=' . $id); $sql->addPost('online', $online); $sql->update(); echo message::success(lang::get('save_status')); $action = ''; } if ($action == '') { if (ajax::is()) { echo pageMisc::getTreeStructurePage(); exit; } $button = []; if (dyn::get('user')->hasPerm('page[edit]')) { $button = ['<a class="btn btn-sm btn-default" href="' . url::backend('structure', ['subpage' => 'pages', 'action' => 'add']) . '">' . lang::get('add') . '</a>']; } ?> <div class="row" id="structure-body"><?php echo bootstrap::panel(lang::get('pages'), $button, pageMisc::getTreeStructurePage()); ?> </div> <?php if (dyn::get('user')->hasPerm('page[edit]')) { layout::addJs("layout/js/structureSort.js"); } } }