Exemplo n.º 1
0
 public function installSlots($update = false)
 {
     $slots = sql::factory();
     $slots->setTable('slots');
     $modul = sql::factory();
     $modul->setTable('module');
     foreach ($this->get('slots', []) as $name => $slot) {
         $slotExists = $slots->num('SELECT id FROM ' . sql::table('slots') . ' WHERE `name` = "' . $name . '" AND `template` = "' . $this->name . '"');
         if (!$update && $slotExists) {
             continue;
         }
         $modul->addPost('name', $name);
         $modul->addPost('input', $slot['input']);
         $modul->addPost('output', $slot['output']);
         if (!$slotExists) {
             $modul->save();
             $modul_id = $modul->insertId();
         } else {
             $modul->setWhere('name="' . $name . '"');
             $modul->update();
             $modul->result('SELECT id FROM ' . sql::table('module') . ' WHERE name = "' . $name . '"');
             $modul_id = $modul->get('id');
         }
         $slots->addPost('name', $name);
         $slots->addPost('description', $slot['description']);
         $slots->addPost('template', $this->name);
         $slots->addPost('modul', $modul_id);
         if (!$slotExists) {
             $slots->save();
         } else {
             $slots->setWhere('name="' . $name . '" AND template="' . $this->name . '"');
             $slots->update();
         }
     }
 }
Exemplo n.º 2
0
 function __construct($id)
 {
     $sql = new sql();
     $sql->result("SELECT * FROM " . sql::table('server') . " WHERE id = '" . $id . "'");
     $this->sql = $sql;
     $this->id = $this->sql->get('id');
 }
Exemplo n.º 3
0
    public static function getByStructureId($id)
    {
        $return = [];
        $classname = __CLASS__;
        $sql = sql::factory();
        $sql->query('
		SELECT
		  a.*, m.output
		FROM
		  ' . sql::table('structure_area') . ' AS a
		  LEFT JOIN
		    ' . sql::table('module') . ' AS m
			ON
			  m.id = a.modul
		WHERE
		  a.structure_id=' . $id . '
		  AND
		  a.online = 1
		ORDER BY
		  a.sort')->result();
        while ($sql->isNext()) {
            $sql2 = clone $sql;
            $return[] = new $classname($sql2);
            $sql->next();
        }
        return $return;
    }
Exemplo n.º 4
0
 public static function registerUser()
 {
     $sql = sql::factory();
     $sql->setTable('community_user');
     $sql->getPosts(['username' => 'string', 'password' => 'string', 'email' => 'string']);
     $validator = new validator();
     $email = $sql->getPost('email');
     $username = $sql->getPost('username');
     $password = $sql->getPost('password');
     $validUsername = $validator->costum($username, function () {
         preg_match('/\\w{4,}/', $username, $match);
         return $match[0] == $username;
     });
     if (!$validUsername) {
         return 'Username darf nur aus Buchstaben Zahlen und Unterstrich bestehen und muss mindestens 4 Zeichen lang sein.';
     }
     if ($sql->num('SELECT id FROM ' . sql::table('community_user') . ' WHERE `username`= "' . $sql->escape($username) . '"')) {
         return 'Benutzername schon vorhanden';
     }
     if (!$validator->email($email)) {
         return 'Bitte geben Sie eine E-Mail Adresse an';
     }
     $salt = userLogin::generateSalt();
     $sql->addDatePost('registerdate', 'now');
     $sql->addPost('salt', $salt);
     extension::get('COMMUNITY_USER_REGISTER', $sql);
     $password = userLogin::hash($password, $salt);
     $sql->addPost('password', $password);
     $sql->save();
     //Mail send
     return true;
 }
Exemplo n.º 5
0
 public function __construct($id)
 {
     $sql = sql::factory();
     $sql->query('SELECT * FROM ' . sql::table('user') . ' WHERE id=' . $id)->result();
     $this->entrys = $sql->result;
     $this->entrys['perms'] = explode('|', $this->get('perms'));
 }
Exemplo n.º 6
0
 protected static function loginPost()
 {
     $email = type::post('email', 'string');
     $password = type::post('password', 'string');
     // Formular ganz abgesendet?
     if (is_null($email) || is_null($password) || $email == '' || $password == '') {
         echo message::info(lang::get('login_form_notfull'), true);
         return;
     }
     $sql = sql::factory();
     $sql->query('SELECT password, id FROM ' . sql::table('user') . ' WHERE `email` = "' . $sql->escape($email) . '"');
     // Username mit E-Mail vorhanden?
     if (!$sql->num()) {
         echo message::danger(sprintf(lang::get('login_no_user'), $email), true);
         return;
     }
     $sql->result();
     // Password nicht gleich?
     if (!self::checkPassword($password, $sql->get('password'))) {
         echo message::danger(lang::get('login_pwd_false'), true);
         return;
     }
     self::loginSession();
     self::$userID = $sql->get('id');
     $_SESSION['login'] = $sql->get('id') . '||' . self::hash($password);
 }
Exemplo n.º 7
0
 protected static function loginPost()
 {
     $email = type::post('email', 'string');
     $password = type::post('password', 'string');
     $remember = type::post('remember', 'int');
     if (is_null($email) || is_null($password) || $email == '' || $password == '') {
         echo message::info(lang::get('fill_out_both'));
         return;
     }
     $sql = new sql();
     $sql->query('SELECT password, salt, id FROM ' . sql::table('user') . ' WHERE `email` = "' . $sql->escape($email) . '"');
     if (!$sql->num()) {
         echo message::danger(sprintf(lang::get('email_not_found'), htmlspecialchars($email)), true);
         $shake = 1;
         return;
     }
     $sql->result();
     if (!self::checkPassword($password, $sql->get('salt'), $sql->get('password'))) {
         echo message::danger(lang::get('wrong_pw'));
         $shake = 1;
         return;
     }
     self::loginSession();
     self::$userID = $sql->get('id');
     $_SESSION['login'] = $sql->get('id');
     if ($remember) {
         setcookie("remember", $sql->get('id'), time() + 3600 * 24 * 7);
     }
 }
Exemplo n.º 8
0
 public static function delete($id)
 {
     $sql = sql::factory();
     $sql->query('SELECT `structure_id`, `sort` FROM ' . sql::table('structure_area') . ' WHERE id=' . $id)->result();
     $delete = sql::factory();
     $delete->setTable('structure_area');
     $delete->setWhere('id=' . $id);
     $delete->delete();
     self::saveSortUp($sql->get('structure_id'), $sql->get('sort'));
     return $sql->get('structure_id');
 }
Exemplo n.º 9
0
 public function __construct($addon, $config = true)
 {
     $this->name = $addon;
     if ($config) {
         $configfile = dir::addon($addon, 'config.json');
         $this->config = json_decode(file_get_contents($configfile), true);
     }
     addonConfig::isSaved($addon);
     $this->sql = new sql();
     $this->sql->query('SELECT * FROM ' . sql::table('addons') . ' WHERE `name` = "' . $addon . '"')->result();
 }
Exemplo n.º 10
0
 public static function getAll()
 {
     if (!count(self::$all)) {
         $sql = sql::factory();
         $sql->query('SELECT name FROM ' . sql::table('addons') . ' WHERE `install` = 1  AND `active` = 1')->result();
         while ($sql->isNext()) {
             self::$all[] = $sql->get('name');
             $sql->next();
         }
     }
     return self::$all;
 }
Exemplo n.º 11
0
 public static function getMediaByExtension($extension)
 {
     $returnArray = [];
     $class = __CLASS__;
     $sql = sql::factory();
     $sql->result('SELECT * FROM ' . sql::table('media') . ' WHERE filename LIKE "%.' . $extension . '"');
     while ($sql->isNext()) {
         $returnArray[] = new $class($sql);
         $sql->next();
     }
     return $returnArray;
 }
Exemplo n.º 12
0
 public static function moduleList($active = false)
 {
     if (empty(self::$modulList)) {
         $sql = sql::factory();
         $sql->result('SELECT id, name FROM ' . sql::table('module') . ' ORDER BY `sort`');
         while ($sql->isNext()) {
             $selected = $active && $active == $sql->get('id') ? 'selected="selected"' : '';
             self::$modulList[] = '<option value="' . $sql->get('id') . '" ' . $selected . '>' . $sql->get('name') . '</option>';
             $sql->next();
         }
     }
     return implode(PHP_EOL, self::$modulList);
 }
Exemplo n.º 13
0
 protected function getOptions()
 {
     $return = [];
     if (empty($this->value)) {
         return '';
     }
     $sql = sql::factory();
     $sql->result('SELECT * FROM ' . sql::table('media') . ' WHERE id IN (' . implode(',', (array) $this->value) . ')  ORDER BY FIND_IN_SET(id, "' . implode(',', (array) $this->value) . '")');
     while ($sql->isNext()) {
         $return[] = '<option value="' . $sql->get('id') . '">' . $sql->get('filename') . '</option>';
         $sql->next();
     }
     return implode(PHP_EOL, $return);
 }
Exemplo n.º 14
0
 public static function getMetaInfos($form, $type)
 {
     $sql = sql::factory();
     $sql->query('SELECT * FROM ' . sql::table('metainfos') . ' WHERE `type` = "' . $type . '" ORDER BY `sort`')->result();
     while ($sql->isNext()) {
         $prefix = substr($type, 0, 3) . '_';
         $attributes = $sql->getRow();
         $attributes['name'] = $prefix . $attributes['name'];
         $element = self::getElement($attributes, $form->get($prefix . $sql->get('name')));
         $form->addElement($prefix . $sql->get('name'), $element);
         $sql->next();
     }
     return $form;
 }
Exemplo n.º 15
0
 public static function getBlock($name)
 {
     $sql = sql::factory();
     $sql->query("SELECT * FROM " . sql::table('blocks') . " WHERE name = '" . $name . "'")->result();
     if (!self::isInCategory($sql->get('is-structure'), $sql->getArray('structure'))) {
         return '';
     } else {
         if (!pageCache::exist($sql->get('id'), false, 'block')) {
             pageCache::generateArticle($sql->get('id'), true);
         }
         $content = pageCache::read($sql->get('id'), 'block');
         return pageArea::getEval($content);
     }
 }
Exemplo n.º 16
0
 public static function getParentsName($id)
 {
     $sql = sql::factory();
     $sql->query('SELECT name, id, seo_costum_url, parent_id FROM ' . sql::table('structure') . ' WHERE id = ' . $id)->result();
     if ($sql->get('seo_costum_url')) {
         $name = $sql->get('seo_costum_url');
         $name = str_replace('.html', '', $name);
     } else {
         $name = self::makeSEOName($sql->get('name'), false);
     }
     if ($sql->get('parent_id')) {
         $name = self::getParentsName($sql->get('parent_id')) . '/' . $name;
     }
     return $name;
 }
Exemplo n.º 17
0
 public static function getCategoryById($parentId, $offlinePages = false)
 {
     $extraWhere = '';
     if (!$offlinePages) {
         $extraWhere = ' AND online = 1';
     }
     $class = __CLASS__;
     $sql = sql::factory();
     $return = [];
     $sql->query('SELECT * FROM ' . sql::table('structure') . ' WHERE parent_id = ' . $parentId . $extraWhere . ' ORDER BY sort')->result();
     while ($sql->isNext()) {
         $sql2 = clone $sql;
         $return[] = new $class($sql2);
         $sql->next();
     }
     return $return;
 }
Exemplo n.º 18
0
 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();
     }
 }
Exemplo n.º 19
0
 public static function moduleList($active = false, $blocks = false)
 {
     if (!$blocks) {
         $where = ' WHERE `blocks` != 1';
         $mlist =& self::$modulList;
     } else {
         $where = '';
         $mlist =& self::$modulListAll;
     }
     if (empty($mlist)) {
         $sql = sql::factory();
         $sql->result('SELECT id, name FROM ' . sql::table('module') . $where . ' ORDER BY `sort`');
         while ($sql->isNext()) {
             $selected = $active && $active == $sql->get('id') ? 'selected="selected"' : '';
             $mlist[] = '<option value="' . $sql->get('id') . '" ' . $selected . '>' . $sql->get('name') . '</option>';
             $sql->next();
         }
     }
     return implode(PHP_EOL, $mlist);
 }
Exemplo n.º 20
0
 public function get()
 {
     $return = '';
     // Not indexing
     if (!dyn::get('addons')['seo']['robots']) {
         return 'User-agent: *' . PHP_EOL . 'Disallow: /';
     }
     $sql = sql::factory();
     $sql->query('SELECT id FROM ' . sql::table('structure') . ' WHERE seo_robots = 0');
     while ($sql->isNext()) {
         $return .= 'Disallow: /' . seo_rewrite::rewriteId($sql->get('id')) . PHP_EOL;
         $sql->next();
     }
     if ($return != '') {
         $return = 'User-agent: *' . PHP_EOL . $out . PHP_EOL;
     }
     if ($return == '') {
         return 'User-agent: *' . PHP_EOL . 'Disallow:';
     }
     return $return;
 }
Exemplo n.º 21
0
 public function installBlocks($update = false)
 {
     $blocks = sql::factory();
     $blocks->setTable('blocks');
     foreach ($this->get('blocks', []) as $name => $block) {
         $blockExists = $blocks->num('SELECT id FROM ' . sql::table('blocks') . ' WHERE `name` = "' . $name . '" AND `template` = "' . $this->name . '"');
         if (!$update && $blockExists) {
             continue;
         }
         $this->installModule($block['module'], $update);
         $blocks->addPost('name', $name);
         $blocks->addPost('description', $block['description']);
         $blocks->addPost('template', $this->name);
         if (!$blockExists) {
             $blocks->save();
         } else {
             $blocks->setWhere('name="' . $name . '" AND template="' . $this->name . '"');
             $blocks->update();
         }
     }
 }
Exemplo n.º 22
0
    public static function getTreeStructurePagePopup($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()) {
                $button = '<button data-id="' . $sql->get('id') . '" data-name="' . $sql->get('name') . '" data-loading-text="' . lang::get('selected') . '" class="btn btn-sm btn-warning dyn-link-select">' . lang::get('select') . '</button>';
                $select .= '<li>' . PHP_EOL . '
					<div class="handle">' . $sql->get('name') . PHP_EOL . '
						<span class="btn-group">' . $button . '</span>' . PHP_EOL . '
					</div>' . PHP_EOL;
                $select .= self::getTreeStructurePagePopup($sql->get('id'), $lvl + 1);
                $select .= '</li>' . PHP_EOL;
                $sql->next();
            }
            $select .= '</ul>';
        }
        return $select;
    }
Exemplo n.º 23
0
 public static function getTreeStructure($parentId = 0, $lvl = 0, $spacer = ' &nbsp;', $active = 0)
 {
     $select = '';
     $sql = sql::factory();
     $sql->query('SELECT id, name FROM ' . sql::table('media_cat') . ' WHERE pid = ' . $parentId . ' ORDER BY sort')->result();
     while ($sql->isNext()) {
         $name = $sql->get('name');
         if ($lvl) {
             $name = '- ' . $name;
         }
         if ($spacer != '') {
             for ($i = 1; $i <= $lvl; $i++) {
                 $name = $spacer . $name;
             }
         }
         $selected = $active == $sql->get('id') ? 'selected="selected"' : '';
         $select .= '<option value="' . $sql->get('id') . '" ' . $selected . '>' . $name . '</option>' . PHP_EOL;
         $select .= self::getTreeStructure($sql->get('id'), $lvl + 1, $spacer, $active);
         $sql->next();
     }
     return $select;
 }
Exemplo n.º 24
0
 /**
  * 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);
 }
Exemplo n.º 25
0
 protected static function loginPost()
 {
     $email = type::post('email', 'string');
     $password = type::post('password', 'string');
     // Formular ganz abgesendet?
     if (is_null($email) || is_null($password) || $email == '' || $password == '') {
         echo message::info(lang::get('login_form_notfull'), true);
         return;
     }
     $sql = sql::factory();
     $sql->query('SELECT password, salt, id FROM ' . sql::table('user') . ' WHERE `email` = "' . $sql->escape($email) . '"');
     // Username mit E-Mail vorhanden?
     if (!$sql->num()) {
         echo message::danger(sprintf(lang::get('login_no_user'), htmlspecialchars($email)), true);
         return;
     }
     $sql->result();
     // Password nicht gleich?
     if (!self::checkPassword($password, $sql->get('salt'), $sql->get('password'))) {
         echo message::danger(lang::get('login_pwd_false'), true);
         return;
     }
     self::loginSession();
     self::$userID = $sql->get('id');
     $_SESSION['login'] = $sql->get('id');
     // Falls alte Methode (sha1) neuen Salt generieren und salt updaten
     // sha1 deprecated 0.2 Beta
     $salt = $sql->get('salt');
     if (empty($salt)) {
         $salt = self::generateSalt();
         $sql->setTable('user');
         $sql->setWhere('`email` = "' . $email . '"');
         $sql->addPost('salt', $salt);
         $sql->addPost('password', self::hash($password, $salt));
         $sql->update();
     }
 }
Exemplo n.º 26
0
 public static function checkLogin()
 {
     $username = type::post('username', 'string', '');
     $password = type::post('password', 'string', '');
     if ($username == '' || $password == '') {
         echo message::info(lang::get('login_form_notfull'), true);
         return;
     }
     $sql = sql::factory();
     $sql->query('SELECT password, salt, id FROM ' . sql::table('community_user') . ' WHERE `username` = "' . $sql->escape($username) . '"');
     if (!$sql->num()) {
         echo message::danger(sprintf(lang::get('login_no_user'), $email), true);
         return;
     }
     $sql->result();
     if (!userLogin::checkPassword($password, $sql->get('salt'), $sql->get('password'))) {
         echo message::danger(lang::get('login_pwd_false'), true);
         return;
     }
     $_SESSION['community-login'] = $sql->get('id');
     self::checkSession();
     // Für spätere Foren-Bridges
     extension::get('COMMUNITY_USER_LOGIN', $password);
 }
Exemplo n.º 27
0
<?php

$sql = sql::factory();
$sql->query('ALTER TABLE `' . sql::table('structure') . '`
  DROP `seo_title`,
  DROP `seo_keywords`,
  DROP `seo_description`,
  DROP `seo_costum_url`,
  DROP `seo_robots`');
Exemplo n.º 28
0
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();
$numModule = $sql->num('SELECT * FROM ' . sql::table('module'));
$sql = sql::factory();
$numBlocks = $sql->num('SELECT * FROM ' . sql::table('blocks'));
$sql = sql::factory();
$numAddons = $sql->num('SELECT * FROM ' . sql::table('addons'));
$stats[] = ['num' => $numPages, 'text' => lang::get('numpages'), 'btn' => ['text' => lang::get('page_add'), 'url' => url::backend('structure', ['subpage' => 'pages', 'action' => 'add'])]];
$stats[] = ['num' => $numAddons, 'text' => lang::get('numaddons'), 'btn' => ''];
$stats[] = ['num' => $numModule, 'text' => lang::get('nummodule'), 'btn' => ['text' => lang::get('module_add'), 'url' => url::backend('structure', ['subpage' => 'module', 'action' => 'add'])]];
$stats[] = ['num' => $numBlocks, 'text' => lang::get('numblocks'), 'btn' => ['text' => lang::get('block_add'), 'url' => url::backend('structure', ['subpage' => 'blocks', 'action' => 'add'])]];
$stats = extension::get('DASHBOARD_STATS', $stats);
?>
<section id="slide">
	<div class="row">
    
    	<?php 
foreach ($stats as $stat) {
    $link = $stat['btn'] ? ' <a class="btn btn-warning btn-xs" href="' . $stat['btn']['url'] . '"><i class="fa fa-plus"></i> ' . $stat['btn']['text'] . '</a>' : '';
    echo '
					<div class="col-sm-4 col-md-2">
                	
Exemplo n.º 29
0
    protected static function generateAll()
    {
        if (empty(self::$slots)) {
            $sql = sql::factory();
            $sql->query('
			SELECT 
			  s.*, m.output 
			FROM 
			  ' . sql::table('slots') . ' AS s
			  LEFT JOIN
			  	' . sql::table('module') . ' AS m
					ON m.id = s.modul
			')->result();
            while ($sql->isNext()) {
                $sql2 = clone $sql;
                self::$slots[$sql->get('name')] = $sql2;
                $sql->next();
            }
        }
    }
Exemplo n.º 30
0
    $sql->getPosts(['name' => 'string', 'sort' => 'int', 'pid' => 'int']);
    if ($action == 'save-edit') {
        $sql->update();
    } else {
        $sql->save();
    }
    $sort = type::post('sort', 'int');
    $parent_id = type::post('pid', 'int');
    sql::sortTable('media_cat', $sort, '`pid` = ' . $parent_id . ' AND id != ' . $id);
}
$table = table::factory(['class' => ['js-sort']]);
$colFirstWidth = $action == 'edit' || $action == 'add' ? 50 : 25;
$table->addCollsLayout($colFirstWidth . ',*, 110');
$table->addRow()->addCell()->addCell(lang::get('category'))->addCell(lang::get('action'));
$table->addSection('tbody');
$table->setSql('SELECT * FROM ' . sql::table('media_cat') . ' WHERE pid = ' . $pid . ' ORDER BY sort ASC');
if (in_array($action, ['edit', 'add']) && dyn::get('user')->hasPerm('media[category][edit]')) {
    echo '<form method="post" action="index.php">';
    $inputHidden = formInput::factory('action', 'save-' . $action);
    $inputHidden->addAttribute('type', 'hidden');
    echo $inputHidden->get();
    $inputHidden = formInput::factory('page', 'media');
    $inputHidden->addAttribute('type', 'hidden');
    echo $inputHidden->get();
    $inputHidden = formInput::factory('subpage', 'category');
    $inputHidden->addAttribute('type', 'hidden');
    echo $inputHidden->get();
    $inputHidden = formInput::factory('pid', $pid);
    $inputHidden->addAttribute('type', 'hidden');
    echo $inputHidden->get();
    $buttonSubmit = formButton::factory('save', lang::get('category_save'));