예제 #1
0
 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('user has no permission for this operation!');
     }
     $type = rex_get('type', 'string');
     switch ($type) {
         case 'articles':
             $prefix = 'art\\_%';
             $defaultFields = [['translate:online_from', 'art_online_from', '1', '', '10', ''], ['translate:online_to', 'art_online_to', '2', '', '10', ''], ['translate:description', 'art_description', '3', '', '2', '']];
             break;
         case 'media':
             $prefix = 'med\\_%';
             $defaultFields = [['translate:pool_file_description', 'med_description', '1', '', '2', ''], ['translate:pool_file_copyright', 'med_copyright', '2', '', '1', '']];
             break;
         default:
             throw new rex_api_exception(sprintf('metainfo type "%s" does not have default field.', $type));
     }
     $existing = rex_sql::factory()->getArray('SELECT name FROM ' . rex::getTable('metainfo_field') . ' WHERE name LIKE ?', [$prefix]);
     $existing = array_column($existing, 'name', 'name');
     foreach ($defaultFields as $field) {
         if (!isset($existing[$field[1]])) {
             $return = call_user_func_array('rex_metainfo_add_field', $field);
             if (is_string($return)) {
                 throw new rex_api_exception($return);
             }
         }
     }
     return new rex_api_result(true, rex_i18n::msg('minfo_default_fields_created'));
 }
예제 #2
0
 private static function checkTables()
 {
     $slices_table = rex_sql_table::get(rex::getTable('article_slice'));
     $history_table = rex_sql_table::get(self::getTable());
     foreach ($slices_table->getColumns() as $column) {
         if (strtolower($column->getName()) != 'id') {
             $history_table->ensureColumn($column)->alter();
         }
     }
 }
예제 #3
0
 public function exec($type)
 {
     if (!in_array($type, [self::PREVIEW, self::PRESAVE, self::POSTSAVE])) {
         throw new InvalidArgumentException('$type musst be rex_article_action::PREVIEW, ::PRESAVE or ::POSTSAVE');
     }
     $this->messages = [];
     $this->save = true;
     $ga = rex_sql::factory();
     $ga->setQuery('SELECT a.id, `' . $type . '` as code FROM ' . rex::getTable('module_action') . ' ma,' . rex::getTable('action') . ' a WHERE `' . $type . '` != "" AND ma.action_id=a.id AND module_id=? AND (a.' . $type . 'mode & ?)', [$this->moduleId, $this->mode]);
     foreach ($ga as $row) {
         $action = $row->getValue('code');
         $action = str_replace($this->vars['search'], $this->vars['replace'], $action);
         $action = rex_var::parse($action, rex_var::ENV_BACKEND | rex_var::ENV_INPUT, 'action', $this->sql);
         require rex_stream::factory('action/' . $row->getValue('id') . '/' . $type, $action);
     }
 }
예제 #4
0
파일: service.php 프로젝트: VIEWSION/redaxo
 /**
  * Löscht eine Clang.
  *
  * @param int $id Zu löschende ClangId
  *
  * @throws rex_exception
  */
 public static function deleteCLang($id)
 {
     $startClang = rex_clang::getStartId();
     if ($id == $startClang) {
         throw new rex_functional_exception(rex_i18n::msg('clang_error_startidcanotbedeleted', $startClang));
     }
     if (!rex_clang::exists($id)) {
         throw new rex_functional_exception(rex_i18n::msg('clang_error_idcanotbedeleted', $id));
     }
     $clang = rex_clang::get($id);
     $del = rex_sql::factory();
     $del->setQuery('delete from ' . rex::getTablePrefix() . 'clang where id=?', [$id]);
     rex_sql_util::organizePriorities(rex::getTable('clang'), 'priority', '', 'priority');
     rex_delete_cache();
     // ----- EXTENSION POINT
     rex_extension::registerPoint(new rex_extension_point('CLANG_DELETED', '', ['id' => $clang->getId(), 'name' => $clang->getName(), 'clang' => $clang]));
 }
예제 #5
0
파일: export.php 프로젝트: DECAF/redaxo
$n = [];
$n['label'] = rex_i18n::msg('backup_export_select');
$n['field'] = $radios;
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/form.php');
$tableSelect = new rex_select();
$tableSelect->setMultiple();
$tableSelect->setId('rex-form-exporttables');
$tableSelect->setName('EXPTABLES[]');
$tableSelect->setAttribute('class', 'form-control');
$tables = rex_sql::showTables();
foreach ($tables as $table) {
    $tableSelect->addOption($table, $table);
    if ($table != rex::getTable('user') && 0 === strpos($table, rex::getTablePrefix()) && 0 !== strpos($table, rex::getTablePrefix() . rex::getTempPrefix())) {
        $tableSelect->setSelected($table);
    }
}
$formElements = [];
$n = [];
$n['header'] = '<div id="rex-js-exporttype-sql-div">';
$n['label'] = '<label for="rex-form-exporttables">' . rex_i18n::msg('backup_export_select_tables') . '</label>';
$n['field'] = $tableSelect->get();
$n['footer'] = '</div>';
$formElements[] = $n;
// Vorhandene Exporte auslesen
$sel_dirs = new rex_select();
$sel_dirs->setId('rex-form-exportdir');
$sel_dirs->setName('EXPDIR[]');
$sel_dirs->setMultiple();
예제 #6
0
파일: slice_ui.php 프로젝트: eaCe/slice_ui
 public static function addSlice()
 {
     $article_id = rex_request('article_id', 'int');
     $function = rex_request('page', 'string');
     $cut_slice_id = $slice_id = $_SESSION['slice_ui']['slice_id'];
     $module_id = $_SESSION['slice_ui']['module_id'];
     $clang = rex_get('clang');
     $ctype = rex_get('ctype');
     if (!self::checkPermissions(array('article_id' => $article_id, 'clang' => $clang, 'ctype' => $ctype, 'module_id' => $module_id))) {
         // Alle OBs schließen
         while (@ob_end_clean()) {
         }
         header("Location: " . rex_url::backendController() . '?article_id=' . $article_id . '&clang=' . $clang . '&page=content/edit&ctype=' . $ctype);
         exit;
     }
     $slice_revision = 0;
     $template_attributes = [];
     $newsql = rex_sql::factory();
     // $newsql->setDebug();
     $sliceTable = rex::getTablePrefix() . 'article_slice';
     $newsql->setTable($sliceTable);
     if (strpos($function, 'content/paste') !== false && !empty($_SESSION['slice_ui'])) {
         // determine priority value to get the new slice into the right order
         $priority = '0';
         // $prevSlice->setDebug();
         if ($function === 'content/paste') {
             $priority = 1;
         } else {
             $prevSlice = rex_sql::factory();
             $prevSlice->setQuery('SELECT * FROM ' . $sliceTable . ' WHERE id=' . rex_get('slice_id'));
             $priority = $prevSlice->getValue('priority') + 1;
         }
         $newsql->setValue('article_id', $article_id);
         $newsql->setValue('module_id', $module_id);
         $newsql->setValue('clang_id', $clang);
         $newsql->setValue('ctype_id', $ctype);
         $newsql->setValue('revision', $slice_revision);
         $newsql->setValue('priority', $priority);
         $newsql->addGlobalUpdateFields();
         $newsql->addGlobalCreateFields();
         try {
             $newsql->insert();
             $info = $action_message . rex_i18n::msg('block_added');
             $slice_id = $newsql->getLastId();
             if ($slice_id !== 0) {
                 $_SESSION['slice_ui']['slice_id'] = $slice_id;
             }
             rex_sql_util::organizePriorities(rex::getTable('article_slice'), 'priority', 'article_id=' . $article_id . ' AND clang_id=' . $clang . ' AND ctype_id=' . $ctype . ' AND revision=' . $slice_revision, 'priority, updatedate DESC');
             $function = '';
             // ----- EXTENSION POINT
             rex_extension::registerPoint(new rex_extension_point('SLICE_PASTED', '', ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
             if ($_SESSION['slice_ui']['cut'] == 1) {
                 $curr = rex_sql::factory();
                 $curr->setDebug();
                 $curr->setTable($sliceTable);
                 $curr->setWhere(array('id' => $cut_slice_id));
                 $curr->delete();
                 rex_sql_util::organizePriorities(rex::getTable('article_slice'), 'priority', 'article_id=' . $_SESSION['slice_ui']['article_id'] . ' AND clang_id=' . $clang . ' AND ctype_id=' . $ctype . ' AND revision=' . $slice_revision, 'priority, updatedate DESC');
             }
         } catch (rex_sql_exception $e) {
             // echo rex_view::warning($e->getMessage());
         }
         // Alle OBs schließen
         while (@ob_end_clean()) {
         }
         header("Location: " . rex_url::backendController() . '?article_id=' . $article_id . '&clang=' . $clang . '&page=content/edit&ctype=' . $ctype);
         exit;
     }
 }
예제 #7
0
<?php

/**
 * YREWRITE Addon.
 *
 * @author jan.kristinus@yakamara.de
 *
 * @package redaxo\yrewrite
 *
 * @var rex_addon $this
 */
rex_sql_table::get(rex::getTable('article'))->removeColumn('yrewrite_url')->removeColumn('yrewrite_priority')->removeColumn('yrewrite_changefreq')->removeColumn('yrewrite_title')->removeColumn('yrewrite_description')->removeColumn('yrewrite_index')->alter();
$sql = rex_sql::factory();
$sql->setQuery(sprintf('DROP TABLE IF EXISTS `%s`;', rex::getTable('yrewrite_domain')));
$sql->setQuery(sprintf('DROP TABLE IF EXISTS `%s`;', rex::getTable('yrewrite_forward')));
rex_delete_cache();
예제 #8
0
 */
rex_sql_table::get(rex::getTable('article'))->ensureColumn(new rex_sql_column('yrewrite_url', 'varchar(255)'))->ensureColumn(new rex_sql_column('yrewrite_canonical_url', 'varchar(255)'))->ensureColumn(new rex_sql_column('yrewrite_priority', 'varchar(5)'))->ensureColumn(new rex_sql_column('yrewrite_changefreq', 'varchar(10)'))->ensureColumn(new rex_sql_column('yrewrite_title', 'varchar(255)'))->ensureColumn(new rex_sql_column('yrewrite_description', 'text'))->ensureColumn(new rex_sql_column('yrewrite_index', 'tinyint(1)'))->alter();
$sql = rex_sql::factory();
$sql->setQuery('CREATE TABLE IF NOT EXISTS `' . rex::getTable('yrewrite_domain') . '` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `domain` varchar(255) NOT NULL,
    `mount_id` int(11) NOT NULL,
    `start_id` int(11) NOT NULL,
    `notfound_id` int(11) NOT NULL,
    `alias_domain` varchar(255) NOT NULL,
    `clangs` varchar(255) NOT NULL,
    `clang_start` int(11) NOT NULL,
    `robots` TEXT NOT NULL,
    `title_scheme` varchar(255) NOT NULL,
    `description` varchar(255) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
$sql->setQuery('CREATE TABLE IF NOT EXISTS `' . rex::getTable('yrewrite_forward') . '` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `domain` varchar(255) NOT NULL,
    `status` int(11) NOT NULL,
    `url` varchar(255) NOT NULL,
    `type` varchar(255) NOT NULL,
    `article_id` int(11) NOT NULL,
    `clang` int(11) NOT NULL,
    `extern` varchar(255) NOT NULL,
    `media` varchar(255) NOT NULL,
    `movetype` varchar(255) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
rex_delete_cache();
예제 #9
0
/**
 * @param string $filename
 *
 * @return bool
 */
function rex_mediapool_deleteMedia($filename)
{
    if ($uses = rex_mediapool_mediaIsInUse($filename)) {
        $msg = '<strong>' . rex_i18n::msg('pool_file_delete_error_1', $filename) . ' ' . rex_i18n::msg('pool_file_delete_error_2') . '</strong><br />' . $uses;
        return ['ok' => false, 'msg' => $msg];
    }
    $sql = rex_sql::factory();
    $sql->setQuery('DELETE FROM ' . rex::getTable('media') . ' WHERE filename = ? LIMIT 1', [$filename]);
    rex_file::delete(rex_path::media($filename));
    rex_media_cache::delete($filename);
    rex_extension::registerPoint(new rex_extension_point('MEDIA_DELETED', '', ['filename' => $filename]));
    return ['ok' => true, 'msg' => rex_i18n::msg('pool_file_deleted')];
}
예제 #10
0
파일: boot.php 프로젝트: staabm/redaxo
<?php

/**
 * Cronjob Addon.
 *
 * @author gharlan[at]web[dot]de Gregor Harlan
 *
 * @package redaxo5
 *
 * @var rex_addon $this
 */
define('REX_CRONJOB_LOG_FOLDER', $this->getDataPath());
define('REX_CRONJOB_TABLE', rex::getTable('cronjob'));
rex_extension::register('PACKAGES_INCLUDED', function () {
    foreach ($this->getAvailablePlugins() as $plugin) {
        if (($type = $plugin->getProperty('cronjob_type')) != '') {
            rex_cronjob_manager::registerType($type);
        }
    }
});
$nexttime = $this->getConfig('nexttime', 0);
if ($nexttime != 0 && time() >= $nexttime) {
    $EP = rex::isBackend() ? 'PAGE_CHECKED' : 'PACKAGES_INCLUDED';
    rex_extension::register($EP, function () {
        if (!rex::isBackend() || !in_array(rex_be_controller::getCurrentPagePart(1), ['setup', 'login', 'cronjob'])) {
            rex_cronjob_manager_sql::factory()->check();
        }
    });
}
예제 #11
0
 /**
  * Berechnet die Prios der Kategorien in einer Kategorie neu.
  *
  * @param int $parent_id KategorieId der Kategorie, die erneuert werden soll
  * @param int $clang     ClangId der Kategorie, die erneuert werden soll
  * @param int $new_prio  Neue PrioNr der Kategorie
  * @param int $old_prio  Alte PrioNr der Kategorie
  */
 public static function newCatPrio($parent_id, $clang, $new_prio, $old_prio)
 {
     if ($new_prio != $old_prio) {
         if ($new_prio < $old_prio) {
             $addsql = 'desc';
         } else {
             $addsql = 'asc';
         }
         rex_sql_util::organizePriorities(rex::getTable('article'), 'catpriority', 'clang_id=' . $clang . ' AND parent_id=' . $parent_id . ' AND startarticle=1', 'catpriority,updatedate ' . $addsql);
         rex_article_cache::deleteLists($parent_id);
     }
 }
예제 #12
0
 public static function getMissingWildcards()
 {
     $wildcards = [];
     if (\rex_addon::get('structure')->isAvailable() && \rex_plugin::get('structure', 'content')->isAvailable()) {
         $sql = \rex_sql::factory();
         // Slices der Artikel durchsuchen
         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         $fields = ['s.value' => range('1', '20')];
         $searchFields = [];
         $selectFields = [];
         foreach ($fields as $field => $numbers) {
             $concatFields = [];
             foreach ($numbers as $number) {
                 $concatFields[] = $field . $number;
                 $searchFields[] = $field . $number . ' RLIKE ' . $sql->escape(preg_quote(trim(self::getOpenTag())) . '.*' . preg_quote(trim(self::getCloseTag())));
             }
             $selectFields[] = 'CONCAT_WS("|", ' . implode(',', $concatFields) . ') AS subject';
         }
         $fields = $searchFields;
         $sql_query = ' SELECT       s.article_id AS id,
                                     s.clang_id,
                                     s.ctype_id,
                                     ' . implode(', ', $selectFields) . '
                         FROM        ' . \rex::getTable('article_slice') . ' AS s
                             LEFT JOIN
                                     ' . \rex::getTable('article') . ' AS a
                                 ON  (s.article_id = a.id AND s.clang_id = a.clang_id)
                         WHERE       ' . implode(' OR ', $fields) . '
                         ';
         $sql->setDebug(false);
         $sql->setQuery($sql_query);
         if ($sql->getRows() >= 1) {
             $items = $sql->getArray();
             foreach ($items as $item) {
                 preg_match_all(self::getRegexp(), $item['subject'], $matchesSubject, PREG_SET_ORDER);
                 foreach ($matchesSubject as $match) {
                     $wildcards[$match[0]]['wildcard'] = str_replace([self::getOpenTag(), self::getCloseTag()], '', $match[0]);
                     $wildcards[$match[0]]['url'] = \rex_url::backendController(['page' => 'content/edit', 'article_id' => $item['id'], 'mode' => 'edit', 'clang' => $item['clang_id'], 'ctype' => $item['ctype_id']]);
                 }
             }
         }
         // Alle bereits angelegten Platzhalter entfernen
         if (count($wildcards)) {
             $sql = \rex_sql::factory();
             $sql_query = '
                             SELECT  CONCAT("' . self::getOpenTag() . '", wildcard, "' . self::getCloseTag() . '") AS wildcard
                             FROM    ' . \rex::getTable('sprog_wildcard') . '
                             WHERE   clang_id = "' . \rex_clang::getStartId() . '"';
             $sql->setDebug(false);
             $sql->setQuery($sql_query);
             if ($sql->getRows() >= 1) {
                 $items = $sql->getArray();
                 foreach ($items as $item) {
                     if (isset($wildcards[$item['wildcard']])) {
                         unset($wildcards[$item['wildcard']]);
                     }
                 }
             }
         }
         return $wildcards;
     }
     return false;
 }
예제 #13
0
파일: content.php 프로젝트: alsahh/redaxo
     if ($function == 'edit') {
         $newsql->addGlobalUpdateFields();
         try {
             $newsql->update();
             $info = $action_message . rex_i18n::msg('block_updated');
             // ----- EXTENSION POINT
             $info = rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_SLICE_UPDATED', $info, ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
         } catch (rex_sql_exception $e) {
             $warning = $action_message . $e->getMessage();
         }
     } elseif ($function == 'add') {
         $newsql->addGlobalUpdateFields();
         $newsql->addGlobalCreateFields();
         try {
             $newsql->insert();
             rex_sql_util::organizePriorities(rex::getTable('article_slice'), 'priority', 'article_id=' . $article_id . ' AND clang_id=' . $clang . ' AND ctype_id=' . $ctype . ' AND revision=' . $slice_revision, 'priority, updatedate DESC');
             $info = $action_message . rex_i18n::msg('block_added');
             $slice_id = $newsql->getLastId();
             $function = '';
             // ----- EXTENSION POINT
             $info = rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_SLICE_ADDED', $info, ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
         } catch (rex_sql_exception $e) {
             $warning = $action_message . $e->getMessage();
         }
     }
 } else {
     // make delete
     if (rex_content_service::deleteSlice($slice_id)) {
         $global_info = rex_i18n::msg('block_deleted');
         // ----- EXTENSION POINT
         $global_info = rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_SLICE_DELETED', $global_info, ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
예제 #14
0
파일: update.php 프로젝트: DECAF/redaxo
<?php

if (rex_string::versionCompare(rex::getVersion(), '5.1.0-beta1', '<')) {
    rex_sql_table::get(rex::getTable('user'))->ensureColumn(new rex_sql_column('email', 'varchar(255)', true))->ensureColumn(new rex_sql_column('lastlogin', 'datetime', true))->alter();
    rex_sql_table::get(rex::getTable('clang'))->ensureColumn(new rex_sql_column('status', 'tinyint(1)'))->alter();
    rex_sql::factory()->setQuery('UPDATE ' . rex::getTable('clang') . ' SET `status` = 1');
}
if (PHP_VERSION_ID < 50509) {
    throw new rex_functional_exception(rex_i18n::msg('setup_301', PHP_VERSION, '5.5.9'));
}
예제 #15
0
 public function checkLogin()
 {
     $sql = rex_sql::factory();
     $userId = $this->getSessionVar('UID');
     $cookiename = 'rex_user_' . sha1(rex::getProperty('instname'));
     if ($cookiekey = rex_cookie($cookiename, 'string')) {
         if (!$userId) {
             $sql->setQuery('SELECT id FROM ' . rex::getTable('user') . ' WHERE cookiekey = ? LIMIT 1', [$cookiekey]);
             if ($sql->getRows() == 1) {
                 $this->setSessionVar('UID', $sql->getValue('id'));
                 setcookie($cookiename, $cookiekey, time() + 60 * 60 * 24 * 365);
             } else {
                 setcookie($cookiename, '', time() - 3600);
             }
         }
         $this->setSessionVar('STAMP', time());
     }
     $check = parent::checkLogin();
     if ($check) {
         // gelungenen versuch speichern | login_tries = 0
         if ($this->userLogin != '' || !$userId) {
             $this->regenerateSessionId();
             $params = [];
             $add = '';
             if ($this->stayLoggedIn || $cookiekey) {
                 $cookiekey = sha1($this->systemId . time() . $this->userLogin);
                 $add = 'cookiekey = ?, ';
                 $params[] = $cookiekey;
                 setcookie($cookiename, $cookiekey, time() + 60 * 60 * 24 * 365);
             }
             if (self::passwordNeedsRehash($this->user->getValue('password'))) {
                 $add .= 'password = ?, ';
                 $params[] = self::passwordHash($this->userPassword, true);
             }
             array_push($params, rex_sql::datetime(), session_id(), $this->userLogin);
             $sql->setQuery('UPDATE ' . $this->tableName . ' SET ' . $add . 'login_tries=0, lasttrydate=?, session_id=? WHERE login=? LIMIT 1', $params);
         }
         $this->user = new rex_user($this->user);
     } else {
         // fehlversuch speichern | login_tries++
         if ($this->userLogin != '') {
             $sql->setQuery('SELECT login_tries FROM ' . $this->tableName . ' WHERE login=? LIMIT 1', [$this->userLogin]);
             if ($sql->getRows() > 0) {
                 $login_tries = $sql->getValue('login_tries');
                 $sql->setQuery('UPDATE ' . $this->tableName . ' SET login_tries=login_tries+1,session_id="",cookiekey="",lasttrydate=? WHERE login=? LIMIT 1', [rex_sql::datetime(), $this->userLogin]);
                 if ($login_tries >= self::LOGIN_TRIES_1 - 1) {
                     $time = $login_tries < self::LOGIN_TRIES_2 ? self::RELOGIN_DELAY_1 : self::RELOGIN_DELAY_2;
                     $hours = floor($time / 3600);
                     $mins = floor(($time - $hours * 3600) / 60);
                     $secs = $time % 60;
                     $formatted = ($hours ? $hours . 'h ' : '') . ($hours || $mins ? $mins . 'min ' : '') . $secs . 's';
                     $this->message .= ' ' . rex_i18n::msg('login_wait', '<strong data-time="' . $time . '">' . $formatted . '</strong>');
                 }
             }
         }
     }
     if ($this->isLoggedOut() && $userId != '') {
         $sql->setQuery('UPDATE ' . $this->tableName . ' SET session_id="", cookiekey="" WHERE id=? LIMIT 1', [$userId]);
         setcookie($cookiename, '', time() - 3600);
     }
     return $check;
 }
예제 #16
0
 public static function generatePathFile()
 {
     $gc = rex_sql::factory();
     $content = $gc->getArray('select * from ' . rex::getTable('yrewrite_forward'));
     rex_file::put(self::$pathfile, json_encode($content));
 }
예제 #17
0
파일: install.php 프로젝트: DECAF/redaxo
<?php

rex_sql_util::importDump($this->getPath('_install.sql'));
$sql = rex_sql::factory();
$sql->setQuery('SELECT 1 FROM ' . rex::getTable('template') . ' LIMIT 1');
if (!$sql->getRows()) {
    $sql->setTable(rex::getTable('template'))->setValue('id', 1)->setValue('name', 'Default')->setValue('content', 'REX_ARTICLE[]')->setValue('active', 1)->setValue('attributes', '{"ctype":[],"modules":{"1":{"all":"1"}},"categories":{"all":"1"}}')->setRawValue('createdate', 'NOW()')->setRawValue('updatedate', 'NOW()')->insert();
}
예제 #18
0
파일: rex_test.php 프로젝트: staabm/redaxo
 public function testGetTable()
 {
     $this->assertEquals(rex::getTable('mytable'), 'rex_mytable', 'tablename gets properly prefixed');
 }
예제 #19
0
 protected function replaceVars(rex_sql $sql, $content)
 {
     $content = $this->replaceObjectVars($sql, $content);
     $content = $this->replaceCommonVars($content);
     $content = str_replace(['REX_MODULE_ID', 'REX_SLICE_ID', 'REX_CTYPE_ID'], [(int) $sql->getValue('module_id'), (int) $sql->getValue(rex::getTable('article_slice') . '.id'), (int) $sql->getValue('ctype_id')], $content);
     return $content;
 }
예제 #20
0
파일: roles.php 프로젝트: skerbis/redaxo
<?php

$message = '';
$content = '';
if ($func == 'delete') {
    $sql = rex_sql::factory();
    $sql->setQuery('DELETE FROM ' . rex::getTable('user_role') . ' WHERE id = ? LIMIT 1', [$id]);
    $message = rex_view::info(rex_i18n::msg('user_role_deleted'));
    $func = '';
}
if ($func == '') {
    $title = rex_i18n::msg('user_role_caption');
    $list = rex_list::factory('SELECT id, name FROM ' . rex::getTablePrefix() . 'user_role');
    $list->addTableAttribute('class', 'table-striped');
    $tdIcon = '<i class="rex-icon rex-icon-userrole"></i>';
    $thIcon = '<a href="' . $list->getUrl(['func' => 'add', 'default_value' => 1]) . '"' . rex::getAccesskey(rex_i18n::msg('create_user_role'), 'add') . ' title="' . rex_i18n::msg('create_user_role') . '"><i class="rex-icon rex-icon-add-userrole"></i></a>';
    $list->addColumn($thIcon, $tdIcon, 0, ['<th>###VALUE###</th>', '<td>###VALUE###</td>']);
    $list->setColumnParams($thIcon, ['func' => 'edit', 'id' => '###id###']);
    $list->setColumnLabel('id', rex_i18n::msg('id'));
    $list->setColumnLayout('id', ['<th>###VALUE###</th>', '<td>###VALUE###</td>']);
    $list->setColumnLabel('name', rex_i18n::msg('name'));
    $list->setColumnLayout('name', ['<th>###VALUE###</th>', '<td>###VALUE###</td>']);
    $list->setColumnParams('name', ['func' => 'edit', 'id' => '###id###']);
    $list->addColumn('edit', '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('edit'));
    $list->setColumnLabel('edit', rex_i18n::msg('user_functions'));
    $list->setColumnLayout('edit', ['<th colspan="2">###VALUE###</th>', '<td>###VALUE###</td>']);
    $list->setColumnParams('edit', ['func' => 'edit', 'id' => '###id###']);
    $list->addColumn('funcs', '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('user_role_delete'));
    $list->setColumnLabel('funcs', rex_i18n::msg('user_functions'));
    $list->setColumnLayout('funcs', ['', '<td>###VALUE###</td>']);
    $list->setColumnParams('funcs', ['func' => 'delete', 'id' => '###id###']);
예제 #21
0
파일: backup.php 프로젝트: VIEWSION/redaxo
 /**
  * Erstellt einen SQL Dump, der die aktuellen Datebankstruktur darstellt.
  * Dieser wird in der Datei $filename gespeichert.
  *
  * @param string $filename
  * @param array  $tables
  *
  * @return bool TRUE wenn ein Dump erstellt wurde, sonst FALSE
  */
 public static function exportDb($filename, array $tables = null)
 {
     $fp = @fopen($filename, 'w');
     if (!$fp) {
         return false;
     }
     $sql = rex_sql::factory();
     $nl = "\n";
     $insertSize = 5000;
     // ----- EXTENSION POINT
     rex_extension::registerPoint(new rex_extension_point('BACKUP_BEFORE_DB_EXPORT'));
     // Versionsstempel hinzufügen
     fwrite($fp, '## Redaxo Database Dump Version ' . rex::getVersion('%s') . $nl);
     fwrite($fp, '## Prefix ' . rex::getTablePrefix() . $nl);
     //fwrite($fp, '## charset '.rex_i18n::msg('htmlcharset').$nl.$nl);
     fwrite($fp, '## charset utf-8' . $nl . $nl);
     //  fwrite($fp, '/*!40110 START TRANSACTION; */'.$nl);
     if (is_null($tables)) {
         $tables = [];
         foreach (rex_sql::showTables(1, rex::getTablePrefix()) as $table) {
             if ($table != rex::getTable('user') && substr($table, 0, strlen(rex::getTablePrefix() . rex::getTempPrefix())) != rex::getTablePrefix() . rex::getTempPrefix()) {
                 // Tabellen die mit rex_tmp_ beginnne, werden nicht exportiert!
                 $tables[] = $table;
             }
         }
     }
     foreach ($tables as $table) {
         //---- export metadata
         $create = rex_sql::showCreateTable($table);
         fwrite($fp, 'DROP TABLE IF EXISTS `' . $table . '`;' . $nl);
         fwrite($fp, $create . ';' . $nl);
         $fields = $sql->getArray('SHOW FIELDS FROM `' . $table . '`');
         foreach ($fields as &$field) {
             if (preg_match('#^(bigint|int|smallint|mediumint|tinyint|timestamp)#i', $field['Type'])) {
                 $field = 'int';
             } elseif (preg_match('#^(float|double|decimal)#', $field['Type'])) {
                 $field = 'double';
             } elseif (preg_match('#^(char|varchar|text|longtext|mediumtext|tinytext)#', $field['Type'])) {
                 $field = 'string';
             }
             // else ?
         }
         //---- export tabledata
         $start = 0;
         $max = $insertSize;
         do {
             $array = $sql->getArray('SELECT * FROM `' . $table . '` LIMIT ' . $start . ',' . $max, [], PDO::FETCH_NUM);
             $count = $sql->getRows();
             if ($count > 0 && $start == 0) {
                 fwrite($fp, $nl . 'LOCK TABLES `' . $table . '` WRITE;');
                 fwrite($fp, $nl . '/*!40000 ALTER TABLE `' . $table . '` DISABLE KEYS */;');
             } elseif ($count == 0) {
                 break;
             }
             $start += $max;
             $values = [];
             foreach ($array as $row) {
                 $record = [];
                 foreach ($fields as $idx => $type) {
                     $column = $row[$idx];
                     switch ($type) {
                         case 'int':
                             $record[] = intval($column);
                             break;
                         case 'double':
                             $record[] = sprintf('%.10F', (double) $column);
                             break;
                         case 'string':
                         default:
                             $record[] = $sql->escape($column, "'");
                             break;
                     }
                 }
                 $values[] = $nl . '  (' . implode(',', $record) . ')';
             }
             if (!empty($values)) {
                 fwrite($fp, $nl . 'INSERT INTO `' . $table . '` VALUES ' . implode(',', $values) . ';');
                 unset($values);
             }
         } while ($count >= $max);
         if ($start > 0) {
             fwrite($fp, $nl . '/*!40000 ALTER TABLE `' . $table . '` ENABLE KEYS */;');
             fwrite($fp, $nl . 'UNLOCK TABLES;' . $nl . $nl);
         }
     }
     fclose($fp);
     $hasContent = true;
     // Den Dateiinhalt geben wir nur dann weiter, wenn es unbedingt notwendig ist.
     if (rex_extension::isRegistered('BACKUP_AFTER_DB_EXPORT')) {
         $content = rex_file::get($filename);
         $hashBefore = md5($content);
         // ----- EXTENSION POINT
         $content = rex_extension::registerPoint(new rex_extension_point('BACKUP_AFTER_DB_EXPORT', $content));
         $hashAfter = md5($content);
         if ($hashAfter != $hashBefore) {
             rex_file::put($filename, $content);
             $hasContent = !empty($content);
             unset($content);
         }
     }
     return $hasContent;
 }
예제 #22
0
 /**
  * Generiert eine Liste mit den Kindkategorien einer Kategorie.
  *
  * @param int $category_id Id der Kategorie
  *
  * @return bool TRUE bei Erfolg, sonst FALSE
  */
 public static function generateCategoryList($category_id)
 {
     // sanity check
     if ($category_id < 0) {
         return false;
     }
     $query = 'SELECT id, cast( name AS SIGNED ) AS sort FROM ' . rex::getTable('media_category') . ' WHERE parent_id = ' . $category_id . ' ORDER BY sort, name';
     $sql = rex_sql::factory();
     //$sql->setDebug();
     $sql->setQuery($query);
     $cacheArray = [];
     for ($i = 0; $i < $sql->getRows(); ++$i) {
         $cacheArray[] = $sql->getValue('id');
         $sql->next();
     }
     $list_file = rex_path::addonCache('mediapool', $category_id . '.mclist');
     if (rex_file::putCache($list_file, $cacheArray)) {
         return true;
     }
     return false;
 }
예제 #23
0
            if ($yform->objparams['actions_executed']) {
                echo rex_view::success($this->i18n('domain_added'));
                rex_yrewrite::deleteCache();
            } else {
                $showlist = false;
                $fragment = new rex_fragment();
                $fragment->setVar('class', 'edit', false);
                $fragment->setVar('title', $this->i18n('add_domain'));
                $fragment->setVar('body', $form, false);
                echo $fragment->parse('core/page/section.php');
            }
        }
    }
}
if ($showlist) {
    $sql = 'SELECT * FROM ' . rex::getTable('yrewrite_domain') . ' where alias_domain <> ""';
    $list = rex_list::factory($sql, 100);
    $list->setColumnFormat('id', 'Id');
    $list->addParam('page', 'yrewrite/alias_domains');
    $tdIcon = '<i class="fa fa-sitemap"></i>';
    $thIcon = '<a href="' . $list->getUrl(['func' => 'add']) . '"' . rex::getAccesskey($this->i18n('add_domain'), 'add') . '><i class="rex-icon rex-icon-add"></i></a>';
    $list->addColumn($thIcon, $tdIcon, 0, ['<th class="rex-table-icon">###VALUE###</th>', '<td class="rex-table-icon">###VALUE###</td>']);
    $list->setColumnParams($thIcon, ['func' => 'edit', 'data_id' => '###id###']);
    $list->setColumnParams('id', ['data_id' => '###id###', 'func' => 'edit']);
    $list->setColumnSortable('id');
    $list->removeColumn('id');
    $list->removeColumn('clangs');
    $list->removeColumn('clang_start');
    $list->setColumnLabel('domain', $this->i18n('domain'));
    $list->setColumnLabel('alias_domain', $this->i18n('alias_domain'));
    // $list->setColumnLabel("alias_domain",$this->i18n("alias_domain"));
예제 #24
0
 $sql = rex_sql::factory();
 // $sql->setDebug();
 $sql->setQuery('SELECT erledigt FROM rex_aufgaben_filter WHERE user = '******'erledigt');
 if ($aktueller_erledigt_status == 0) {
     $where = ' a.status > 0';
 } else {
     $where = ' a.status != 6';
 }
 $query = 'SELECT  a.*,
                 a.id AS id,
                 k.id,
                 k.kategorie AS kategorie_name,
                 k.farbe
         FROM    ' . rex::getTable('aufgaben_aufgaben') . ' AS a
         LEFT JOIN  ' . rex::getTable('aufgaben_kategorien') . ' AS k
         ON a.kategorie = k.id
         WHERE ' . $where . ' ' . $addsql . ' ORDER BY a.id DESC';
 $list = rex_list::factory($query, 30, 'aufgaben');
 $list->setNoRowsMessage('<div class="alert alert-info" role="alert"><strong>Keine Aufgaben vorhanden.</strong><br/><br/>Mögliche Ursachen:<br/><br/><ul><li>es ist keine Aufgabe angelegt</li><li>keine der vorhandenen Aufgaben erfüllt auf die eingestellten Filterkriterien</li><li>die Ausgabe der erledigten Aufgaben ist abgeschaltet</li></ul></div>');
 // --------------------
 //  Edit
 // --------------------
 $tdIcon = '<i class="rex-icon rex-icon-edit"></i>';
 $thIcon = '<a href="' . $list->getUrl(['func' => 'add']) . '"><i class="rex-icon rex-icon-add"></i></a>';
 $list->addColumn($thIcon, $tdIcon, 0, ['<th class="rex-table-icon">###VALUE###</th>', '<td class="rex-table-icon" style="border-left: 5px solid ###farbe###">###VALUE###</td>']);
 $list->setColumnParams($thIcon, ['func' => 'edit', 'id' => '###id###']);
 // --------------------
 //  remove Colums
 // --------------------
 $list->removeColumn('id');
예제 #25
0
파일: role.php 프로젝트: staabm/redaxo
 public static function removeOrReplaceItem(rex_extension_point $ep)
 {
     $params = $ep->getParams();
     $key = $params['key'];
     $item = '|' . $params['item'] . '|';
     $new = isset($params['new']) ? '|' . $params['new'] . '|' : '|';
     $sql = rex_sql::factory();
     $sql->setQuery('SELECT id, perms FROM ' . rex::getTable('user_role'));
     $update = rex_sql::factory();
     $update->prepareQuery('UPDATE ' . rex::getTable('user_role') . ' SET perms = ? WHERE id = ?');
     foreach ($sql as $row) {
         $perms = json_decode($row->getValue('perms'), true);
         if (isset($perms[$key]) && strpos($perms[$key], $item) !== false) {
             $perms[$key] = str_replace($item, $new, $perms[$key]);
             $update->execute([json_encode($perms), $row->getValue('id')]);
         }
     }
 }
예제 #26
0
                    echo rex_view::success($this->i18n('forward_added'));
                    rex_yrewrite_forward::generatePathFile();
                } else {
                    $showlist = false;
                    $fragment = new rex_fragment();
                    $fragment->setVar('class', 'edit', false);
                    $fragment->setVar('title', $this->i18n('forward_add'));
                    $fragment->setVar('body', $form, false);
                    echo $fragment->parse('core/page/section.php');
                }
            }
        }
    }
}
if ($showlist) {
    $sql = 'SELECT * FROM ' . rex::getTable('yrewrite_forward');
    $list = rex_list::factory($sql, 100);
    $list->setColumnFormat('id', 'Id');
    $list->addParam('page', 'yrewrite/forward');
    $tdIcon = '<i class="fa fa-sitemap"></i>';
    $thIcon = '<a href="' . $list->getUrl(['func' => 'add']) . '"' . rex::getAccesskey($this->i18n('forward_add'), 'add') . '><i class="rex-icon rex-icon-add"></i></a>';
    $list->addColumn($thIcon, $tdIcon, 0, ['<th class="rex-table-icon">###VALUE###</th>', '<td class="rex-table-icon">###VALUE###</td>']);
    $list->setColumnParams($thIcon, ['func' => 'edit', 'data_id' => '###id###']);
    $list->setColumnParams('id', ['data_id' => '###id###', 'func' => 'edit']);
    $list->setColumnSortable('id');
    $list->setColumnLabel('domain', $this->i18n('domain'));
    $list->setColumnLabel('status', $this->i18n('forward_status'));
    $list->setColumnLabel('url', $this->i18n('forward_url'));
    $list->setColumnLabel('type', $this->i18n('forward_type'));
    $list->removeColumn('id');
    $list->removeColumn('article_id');
예제 #27
0
파일: media.php 프로젝트: alsahh/redaxo
$button['attributes']['title'] = rex_i18n::msg('mediapool_view_list');
$button['icon'] = 'view-list';
$view_buttons[] = $button;

if (count($view_buttons) > 0) {
    $fragment = new rex_fragment();
    $fragment->setVar('buttons', $view_buttons, false);
    $fragment->setVar('size', 'xs', false);
    $toolbar .= $fragment->parse('core/buttons/button_group.php');
}
*/
// ----- EXTENSION POINT
$toolbar = rex_extension::registerPoint(new rex_extension_point('MEDIA_LIST_TOOLBAR', $toolbar, ['subpage' => $subpage, 'category_id' => $rex_file_category]));
// *************************************** Subpage: Media
if ($file_id && rex_post('btn_delete', 'string')) {
    $sql = rex_sql::factory()->setQuery('SELECT filename FROM ' . rex::getTable('media') . ' WHERE id = ?', [$file_id]);
    $media = null;
    if ($sql->getRows() == 1) {
        $media = rex_media::get($sql->getValue('filename'));
    }
    if ($media) {
        $filename = $media->getFileName();
        if ($PERMALL || rex::getUser()->getComplexPerm('media')->hasCategoryPerm($media->getCategoryId())) {
            $return = rex_mediapool_deleteMedia($filename);
            if ($return['ok']) {
                $success = $return['msg'];
            } else {
                $error = $return['msg'];
            }
            $file_id = 0;
        } else {
예제 #28
0
    $select_changefreq[] = rex_i18n::msg('yrewrite_changefreq_' . $changefreq) . '=' . $changefreq;
}
$index_setting = [];
$index_setting[] = rex_i18n::msg('yrewrite_index_status') . '=0';
$index_setting[] = rex_i18n::msg('yrewrite_index_index') . '=1';
$index_setting[] = rex_i18n::msg('yrewrite_index_noindex') . '=-1';
$yform = new rex_yform();
$yform->setObjectparams('form_action', rex_url::backendController(['page' => 'content/edit', 'article_id' => $article_id, 'clang' => $clang, 'ctype' => $ctype], false));
$yform->setObjectparams('form_id', 'yrewrite-seo');
$yform->setObjectparams('form_name', 'yrewrite-seo');
$yform->setHiddenField('yrewrite_func', 'seo');
$yform->setObjectparams('form_showformafterupdate', 1);
$yform->setObjectparams('main_table', rex::getTable('article'));
$yform->setObjectparams('main_id', $article_id);
$yform->setObjectparams('main_where', 'id=' . $article_id . ' and clang_id=' . $clang);
$yform->setObjectparams('getdata', true);
$yform->setValueField('text', ['yrewrite_title', rex_i18n::msg('yrewrite_seotitle')]);
$yform->setValueField('textarea', ['yrewrite_description', rex_i18n::msg('yrewrite_seodescription'), '', '', 'short']);
$yform->setValueField('select', ['yrewrite_changefreq', rex_i18n::msg('yrewrite_changefreq'), implode(',', $select_changefreq), '', rex_yrewrite_seo::$changefreq_default]);
$yform->setValueField('select', ['yrewrite_priority', rex_i18n::msg('yrewrite_priority'), implode(',', $select_priority), '', rex_yrewrite_seo::$priority_default]);
$yform->setValueField('select', ['yrewrite_index', rex_i18n::msg('yrewrite_index'), implode(',', $index_setting), '', rex_yrewrite_seo::$index_setting_default]);
$yform->setActionField('db', [rex::getTable('article'), 'id=' . $article_id . ' and clang_id=' . $clang]);
$yform->setObjectparams('submit_btn_label', $addon->i18n('update_seo'));
$form = $yform->getForm();
if ($yform->objparams['actions_executed']) {
    $form = rex_view::success(rex_i18n::msg('yrewrite_seoupdated')) . $form;
    rex_article_cache::delete($article_id, $clang);
} else {
}
$form = '<section id="rex-page-sidebar-yrewrite-seo" data-pjax-container="#rex-page-sidebar-yrewrite-seo" data-pjax-no-history="1">' . $form . '</section>';
return $form;
예제 #29
0
 $sql = rex_sql::factory();
 // $sql->setDebug();
 $sql->setQuery('SELECT done FROM rex_aufgaben_filter WHERE user = '******'done');
 if ($aktueller_done_status == 0) {
     $where = ' a.status > 0';
 } else {
     $where = ' a.status != 6';
 }
 $query = 'SELECT  a.*,
                 a.id AS id,
                 k.id,
                 k.category AS category_name,
                 k.color
         FROM    ' . rex::getTable('aufgaben') . ' AS a
         LEFT JOIN  ' . rex::getTable('aufgaben_categories') . ' AS k
         ON a.category = k.id
         WHERE ' . $where . ' ' . $addsql . ' ORDER BY a.id DESC';
 $list = rex_list::factory($query, 30, 'aufgaben');
 // Anzahl der Aufgaben
 $anzahl = $list->getRows();
 $sql_anzahl = rex_sql::factory();
 // $sql_anzahl->setDebug();
 $sql_anzahl->setTable('rex_aufgaben_user_settings');
 $sql_anzahl->setWhere('user = '******'rex_aufgaben_user_settings');
     $sql_anzahl_update->setWhere('user = '******'counter', $anzahl);
예제 #30
0
 /**
  * Kopiert die Inhalte eines Artikels in einen anderen Artikel.
  *
  * @param int $from_id    ArtikelId des Artikels, aus dem kopiert werden (Quell ArtikelId)
  * @param int $to_id      ArtikelId des Artikel, in den kopiert werden sollen (Ziel ArtikelId)
  * @param int $from_clang ClangId des Artikels, aus dem kopiert werden soll (Quell ClangId)
  * @param int $to_clang   ClangId des Artikels, in den kopiert werden soll (Ziel ClangId)
  * @param int $revision
  *
  * @return bool TRUE bei Erfolg, sonst FALSE
  */
 public static function copyContent($from_id, $to_id, $from_clang = 1, $to_clang = 1, $revision = 0)
 {
     if ($from_id == $to_id && $from_clang == $to_clang) {
         return false;
     }
     $gc = rex_sql::factory();
     $gc->setQuery('select * from ' . rex::getTablePrefix() . "article_slice where article_id='{$from_id}' and clang_id='{$from_clang}' and revision='{$revision}'");
     if ($gc->getRows() > 0) {
         $ins = rex_sql::factory();
         //$ins->setDebug();
         $ctypes = [];
         $cols = rex_sql::factory();
         //$cols->setDebug();
         $cols->setquery('SHOW COLUMNS FROM ' . rex::getTablePrefix() . 'article_slice');
         foreach ($gc as $slice) {
             foreach ($cols as $col) {
                 $colname = $col->getValue('Field');
                 if ($colname == 'clang_id') {
                     $value = $to_clang;
                 } elseif ($colname == 'article_id') {
                     $value = $to_id;
                 } else {
                     $value = $slice->getValue($colname);
                 }
                 // collect all affected ctypes
                 if ($colname == 'ctype_id') {
                     $ctypes[$value] = $value;
                 }
                 if ($colname != 'id') {
                     $ins->setValue($colname, $value);
                 }
             }
             $ins->addGlobalUpdateFields();
             $ins->addGlobalCreateFields();
             $ins->setTable(rex::getTablePrefix() . 'article_slice');
             $ins->insert();
         }
         foreach ($ctypes as $ctype) {
             // reorg slices
             rex_sql_util::organizePriorities(rex::getTable('article_slice'), 'priority', 'article_id=' . $to_id . ' AND clang_id=' . $to_clang . ' AND ctype_id=' . $ctype . ' AND revision=' . $revision, 'priority, updatedate');
         }
         rex_article_cache::deleteContent($to_id, $to_clang);
         return true;
     }
     return false;
 }