예제 #1
0
 /**
  * SET CONTENT OF ROBOTS.TXT
  *
  * @return  (string) robots.txt
  */
 public function setContent($content)
 {
     global $REX;
     $out = '';
     $langs = array_keys($REX['CLANG']);
     // get clang ids
     $defaultRobotsTxt = 'User-agent: *' . "\r\n" . 'Disallow:';
     if (!$REX['ADDON']['seo42']['settings']['no_robots_txt_auto_disallow']) {
         foreach ($langs as $lang) {
             $query = "SELECT id FROM " . $REX['TABLE_PREFIX'] . "article WHERE seo_noindex = '1' AND status = 1 AND clang = " . $lang;
             $sql = new rex_sql();
             $sql->setQuery($query);
             for ($i = 1; $i <= $sql->getRows(); $i++) {
                 $out .= "Disallow: /" . seo42::getTrimmedUrl($sql->getValue('id'), $lang) . "\r\n";
                 $sql->next();
             }
         }
     }
     if ($out != '') {
         $out = "User-agent: *" . "\r\n" . $out . "\r\n";
     }
     if ($out == '' && $content == '') {
         $this->robots_txt = $defaultRobotsTxt;
     } else {
         $this->robots_txt = $out . $content;
     }
 }
/**
 * Alle Metafelder löschen, nicht das nach einem Import in der Parameter Tabelle
 * noch Datensätze zu Feldern stehen, welche nicht als Spalten in der
 * rex_article angelegt wurden!
 */
function rex_a62_metainfo_cleanup($params)
{
    global $REX;
    // Cleanup nur durchführen, wenn auch die rex_article Tabelle neu angelegt wird
    if (isset($params['force']) && $params['force'] != true && strpos($params['content'], 'CREATE TABLE `' . $REX['TABLE_PREFIX'] . 'article`') === false && strpos($params['content'], 'CREATE TABLE ' . $REX['TABLE_PREFIX'] . 'article') === false) {
        return;
    }
    require_once $REX['INCLUDE_PATH'] . '/addons/metainfo/classes/class.rex_table_manager.inc.php';
    $sql = new rex_sql();
    $sql->setQuery('SELECT name FROM ' . $REX['TABLE_PREFIX'] . '62_params');
    for ($i = 0; $i < $sql->getRows(); $i++) {
        if (substr($sql->getValue('name'), 0, 4) == 'med_') {
            $tableManager = new rex_a62_tableManager($REX['TABLE_PREFIX'] . 'file');
        } else {
            $tableManager = new rex_a62_tableManager($REX['TABLE_PREFIX'] . 'article');
        }
        $tableManager->deleteColumn($sql->getValue('name'));
        $sql->next();
    }
    // evtl reste aufräumen
    $tablePrefixes = array('article' => array('art_', 'cat_'), 'file' => array('med_'));
    foreach ($tablePrefixes as $table => $prefixes) {
        $table = $REX['TABLE_PREFIX'] . $table;
        $tableManager = new rex_a62_tableManager($table);
        foreach (rex_sql::showColumns($table) as $column) {
            $column = $column['name'];
            if (in_array(substr($column, 0, 4), $prefixes)) {
                $tableManager->deleteColumn($column);
            }
        }
    }
    $sql = new rex_sql();
    $sql->setQuery('DELETE FROM ' . $REX['TABLE_PREFIX'] . '62_params');
    rex_generateAll();
}
예제 #3
0
 private function showList($cat)
 {
     $addSql = "";
     $cats = explode("~~", $cat);
     if (!in_array(999, $cats)) {
         $addSql = 'AND category LIKE \'%|';
         $addSql .= implode('|%\' OR category LIKE \'%|', $cats);
         $addSql .= '|%\'';
     }
     $addWhere = ' WHERE (
             ((offline_date = "0000-00-00") OR (REPLACE(offline_date, "-", "") > CURDATE() + 0))
             AND
             ((archive_date = "0000-00-00") OR REPLACE(archive_date, "-", "") > CURDATE() + 0)
             AND 
             ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
     )';
     $qry = "\tSELECT * \r\n\t\t\t\t\tFROM " . TBL_NEWS . " \r\n                    " . $addWhere . "\r\n\t\t\t\t\tAND status=1 \r\n                    " . $addSql . "\r\n\t\t\t\t\tORDER BY online_date DESC\r\n\t\t\t\t";
     $sql = new rex_sql();
     #$sql->debugsql = true;
     $data = $sql->getArray($qry);
     /* create one master array of the records */
     $posts = array();
     foreach ($data as $row) {
         $posts[] = array('post' => $row);
     }
     return $posts;
 }
예제 #4
0
function focus_setup_metainfo()
{
    global $REX;
    if (!isset($REX['USER'])) {
        return;
    }
    $install_metas = array('med_focuspoint_data' => array('Focuspoint Data', 'med_focuspoint_data', 200, '', 1, '', '', '', ''), 'med_focuspoint_css' => array('Focuspoint CSS', 'med_focuspoint_css', 201, '', 1, '', '', '', ''));
    $db = new rex_sql();
    foreach ($db->getDbArray('SHOW COLUMNS FROM `rex_file` LIKE \'med_focuspoint_%\';') as $column) {
        unset($install_metas[$column['Field']]);
    }
    foreach ($install_metas as $k => $v) {
        $db->setQuery('SELECT `name` FROM `rex_62_params` WHERE `name`=\'' . $k . '\';');
        if ($db->getRows() > 0) {
            // FIELD KNOWN TO METAINFO BUT MISSING IN ARTICLE..
            $db->setQuery('ALTER TABLE `rex_file` ADD `' . $k . '` TEXT NOT NULL;');
            if ($REX['REDAXO']) {
                echo rex_info('Metainfo Feld ' . $k . ' wurde repariert.');
            }
        } else {
            if (!function_exists('a62_add_field')) {
                require_once $REX['INCLUDE_PATH'] . '/addons/metainfo/functions/function_metainfo.inc.php';
            }
            a62_add_field($v[0], $v[1], $v[2], $v[3], $v[4], $v[5], $v[6], $v[7], $v[8]);
            if ($REX['REDAXO']) {
                echo rex_info('Metainfo Feld ' . $k . ' wurde angelegt.');
            }
        }
    }
    rex_file::copy(rex_path::addon("focuspoint", "classes/class.rex_effect_focuspoint_resize.inc.php"), rex_path::addon("image_manager", "classes/effects/class.rex_effect_focuspoint_resize.inc.php"));
}
 function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0)
 {
     $this->label = $this->elements[1];
     $table = $this->elements[2];
     // ***** ERSTER AUFRUF -> key erstellen
     if (!$send) {
         $this->value = md5($_SERVER["REMOTE_ADDR"] . time());
     } else {
         // in tabelle nachsehen ob formcode vorhanden
         $sql = 'select ' . $this->label . ' from ' . $table . ' WHERE ' . $this->label . '="' . $this->value . '" LIMIT 1';
         $cd = new rex_sql();
         if ($this->params["debug"]) {
             $cd->debugsql = true;
         }
         $cd->setQuery($sql);
         if ($cd->getRows() == 1) {
             $this->params["warning"][] = $this->elements[3];
             $this->params["warning_messages"][] = $this->elements[3];
         }
     }
     $form_output[] = '<input type="hidden" name="FORM[' . $this->params["form_name"] . '][el_' . $this->id . ']" value="' . htmlspecialchars(stripslashes($this->value)) . '" />';
     $email_elements[$this->label] = stripslashes($this->value);
     $sql_elements[$this->label] = stripslashes($this->value);
     return;
 }
예제 #6
0
 /**
  * publish a news by id & clang
  * if publish-lang == all => $clang is not needed, but must be set
  * @param $id
  * @param $clang
  * @param DateTime $time
  * @return string
  */
 public static function publishNews($id, $clang, DateTime $time)
 {
     /**
      * @var array $REX
      * @var i18n $I18N
      */
     global $REX, $I18N;
     $sql = new rex_sql();
     $sql->setTable(rex_asd_news_config::getTable());
     $sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $clang);
     if (rex_asd_news_config::getConfig('published-lang') == 'all') {
         $sql->setWhere('`id` = ' . $id);
     }
     $sql->setValue('publishedAt', $time->format('Y-m-d H:i'));
     $sql->setValue('publishedBy', $REX['USER']->getValue('user_id'));
     $sql->setValue('status', 1);
     $sql->update();
     $sql->setQuery('SELECT * FROM `' . rex_asd_news_config::getTable() . '` WHERE `id` = ' . $id . ' AND `clang` = ' . $clang);
     return '
     <td>' . $id . '</td>
     <td>' . $sql->getValue('title') . '</td>
     <td><span>' . $time->format('d.m.Y H:i') . '</span></td>
     <td><a href="' . self::getBaseUrl($clang) . 'unpublish&amp;id=' . $id . '" class="rex-online" onclick="return confirm(\'' . $I18N->msg('asd_news_really_unpublish') . '\');">' . $I18N->msg('asd_news_published') . '</a></td>
     <td><a href="' . self::getBaseUrl($clang) . 'edit&amp;id=' . $id . '">' . $I18N->msg('edit') . '</a></td>
     <td><a href="' . self::getBaseUrl($clang) . 'delete&amp;id=' . $id . '" onclick="return confirm(\'' . $I18N->msg('asd_news_really_delete') . '\');">' . $I18N->msg('delete') . '</a></td>
     <td><a href="' . self::getBaseUrl($clang) . 'status&amp;id=' . $id . '" class="rex-online">' . $I18N->msg('status_online') . '</a></td>';
 }
 function rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $from_re_sliceid = 0, $to_revision_delete = FALSE)
 {
     global $REX;
     if ($to_revision_delete) {
         $dc = new rex_sql();
         // $dc->debugsql = 1;
         $dc->setQuery('delete from ' . $REX['TABLE_PREFIX'] . 'article_slice where article_id=' . $article_id . ' and clang=' . $clang . ' and revision=' . $to_revision_id);
     }
     if ($from_revision_id == $to_revision_id) {
         return false;
     }
     $gc = new rex_sql();
     // $gc->debugsql = 1;
     $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$article_id}' and clang='{$clang}' and revision='{$from_revision_id}'");
     if ($gc->getRows() == 1) {
         // letzt slice_id des ziels holen ..
         $glid = new rex_sql();
         // $glid->debugsql = 1;
         $glid->setQuery("\n\t\t\t\t\tselect \n\t\t\t\t\t\tr1.id, r1.re_article_slice_id\n\t        from \n\t\t\t\t\t\t" . $REX['TABLE_PREFIX'] . "article_slice as r1\n\t\t\t\t\tleft join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id = r2.re_article_slice_id\n\t        where \n\t\t\t\t\t\tr1.article_id = {$article_id} and r1.clang = {$clang} and \n\t\t\t\t\t\tr2.id is NULL and \n\t\t\t\t\t\tr1.revision='{$to_revision_id}';");
         if ($glid->getRows() == 1) {
             $to_last_slice_id = $glid->getValue("r1.id");
         } else {
             $to_last_slice_id = 0;
         }
         $ins = new rex_sql();
         // $ins->debugsql = 1;
         $ins->setTable($REX['TABLE_PREFIX'] . "article_slice");
         $cols = new rex_sql();
         $cols->setquery("SHOW COLUMNS FROM " . $REX['TABLE_PREFIX'] . "article_slice");
         for ($j = 0; $j < $cols->rows; $j++, $cols->next()) {
             $colname = $cols->getValue("Field");
             if ($colname == "re_article_slice_id") {
                 $value = $to_last_slice_id;
             } elseif ($colname == "revision") {
                 $value = $to_revision_id;
             } elseif ($colname == "createdate") {
                 $value = time();
             } elseif ($colname == "updatedate") {
                 $value = time();
             } elseif ($colname == "createuser") {
                 $value = $REX["USER"]->getValue("login");
             } elseif ($colname == "updateuser") {
                 $value = $REX["USER"]->getValue("login");
             } else {
                 $value = $gc->getValue($colname);
             }
             if ($colname != "id") {
                 $ins->setValue($colname, $ins->escape($value));
             }
         }
         $ins->insert();
         // id holen und als re setzen und weitermachen..
         rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $gc->getValue("id"));
         return true;
     }
     rex_generateArticle($article_id);
     return true;
 }
function rex_a128_historyHandler($params)
{
    global $page, $subpage, $REX_USER, $REX;
    $mypage = $params['mypage'];
    require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_historyManager.inc.php';
    require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_history.inc.php';
    require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_historyItem.inc.php';
    $function = rex_request('function', 'string');
    $mode = rex_request('mode', 'string');
    // Alle Histories registrierens
    $articleHistory =& rexHistoryManager::getHistory('articles');
    $templateHistory =& rexHistoryManager::getHistory('templates');
    $moduleHistory =& rexHistoryManager::getHistory('modules');
    $actionHistory =& rexHistoryManager::getHistory('actions');
    $sql = new rex_sql();
    $sql->debugsql = true;
    if ($page == 'module' && $function == 'edit' && ($module_id = rex_get('modul_id', 'int')) != 0) {
        $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'modultyp WHERE id=' . $module_id);
        if (isset($result[0])) {
            $link = 'index.php?page=' . $page . '&function=' . $function . '&modul_id=' . $module_id;
            $title = $result[0]['name'];
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $module_id . ']';
            }
            $moduleHistory->addItem(new rexHistoryItem($title, $link));
        }
    } elseif ($page == 'module' && $subpage == 'actions' && $function == 'edit' && ($action_id = rex_get('action_id', 'int')) != 0) {
        $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'action WHERE id=' . $action_id);
        if (isset($result[0])) {
            $link = 'index.php?page=' . $page . '&subpage=' . $subpage . '&function=' . $function . '&modul_id=' . $action_id;
            $title = $result[0]['name'];
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $action_id . ']';
            }
            $actionHistory->addItem(new rexHistoryItem($title, $link));
        }
    } elseif ($page == 'template' && $function == 'edit' && ($template_id = rex_get('template_id', 'int')) != 0) {
        $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id=' . $template_id);
        if (isset($result[0])) {
            $link = 'index.php?page=' . $page . '&function=' . $function . '&template_id=' . $template_id;
            $title = $result[0]['name'];
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $template_id . ']';
            }
            $templateHistory->addItem(new rexHistoryItem($title, $link));
        }
    } elseif ($page == 'content' && $mode == 'edit' && ($article_id = rex_get('article_id', 'int')) != 0) {
        $art = OOArticle::getArticleById($article_id);
        if (OOArticle::isValid($art)) {
            $link = 'index.php?page=' . $page . '&mode=' . $mode . '&article_id=' . $article_id;
            $title = $art->getName();
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $article_id . ']';
            }
            $articleHistory->addItem(new rexHistoryItem($title, $link));
        }
    }
}
예제 #9
0
 /**
  * check if entrys exists for the addon
  * @return bool
  */
 public static function checkEntrys()
 {
     global $REX;
     $sql = new rex_sql();
     $sql->setTable($REX['TABLE_PREFIX'] . 'url_control_generate');
     $sql->setWhere('`table` = "' . rex_asd_news_config::getTable() . '"');
     $sql->select('1');
     return (bool) $sql->getRows();
 }
 public static function init()
 {
     global $REX;
     $sql = new rex_sql();
     $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'global_settings');
     self::$globalValues = $sql;
     self::$curClang = $REX['CUR_CLANG'];
     self::$defaultClang = $REX['START_CLANG_ID'];
 }
 public static function init()
 {
     global $REX;
     $sql = new rex_sql();
     $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'tracking_code WHERE id = 1');
     if ($sql->getRows() > 0) {
         self::$trackingCode = $sql->getValue('tracking_code');
     }
 }
예제 #12
0
/**
 * Vorgehensweise
 * Die install.sql muss bereits ausgeführt worden sein und die Module und
 * Action somit bereits in der Datenbank stehen.
 * Als erstes werden die IDs des Modules "Gästebuch - Eintragsliste" und der
 * Action "Gästebuch - Eintragsliste StatusPerdatei" ausgelesen und dann nachgesehen,
 * ob es dazu schon eine Zuweisung in der Tabelle rex_module_action gibt.
 * Ist das nicht der Fall, werden die IDs entsprechend eingetragen.
 *
 * Die automatische Zuweisung zwischen Action und Modul ist damit erledigt.
 * Im Fehlerfalle muss eine Meldung ausgegeben werden.
 * Die Action könnte dann evtl. per Hand noch zugewiesen werden.
 *
 *
 * @param   string  Name des Modules (auf richtige Schreibweise achten!)
 * @param   string  Name der Action (auf richtige Schreibweise achten!)
 * @return  mixed   TRUE oder ein Fehlertext
 */
function rex_a63_installAction2Modul($modul_name, $action_name)
{
    global $REX;
    if (!isset($modul_name) or $modul_name == '' or !isset($action_name) or $action_name == '') {
        return 'rex_a63_installAction2Modul: Keinen Modul- oder Aktionname übergeben.';
    }
    /**
     * Diese Abfrage gibt zurück
     * - wenn es bereits eine Verküpfung in der Tabelle rex_module_action gibt:
     * m_id  a_id  mod_action_m_id   mod_action_a_id
     *  42     9       true             true
     *
     * - gibt es noch keine Verknüpfung, sieht die Rückgabe so aus:
     * m_id  a_id  mod_action_m_id   mod_action_a_id
     *  42     9       false             false
     *
     * m_id und a_id sind von MySQL vergebene IDs und entsprechen nicht diesem Beispiel hier!
     *
     */
    $qry = 'SELECT `' . $REX['TABLE_PREFIX'] . 'module`.`id` AS m_id, `' . $REX['TABLE_PREFIX'] . 'action`.`id` AS a_id,
            IF(`' . $REX['TABLE_PREFIX'] . 'module_action`.`module_id` != 0, "true", "false") AS mod_action_m_id,
            IF(`' . $REX['TABLE_PREFIX'] . 'module_action`.`action_id` != 0, "true", "false") AS mod_action_a_id
          FROM (`' . $REX['TABLE_PREFIX'] . 'module` , `' . $REX['TABLE_PREFIX'] . 'action`)
          LEFT JOIN `' . $REX['TABLE_PREFIX'] . 'module_action` ON ( `' . $REX['TABLE_PREFIX'] . 'module_action`.`module_id` = `' . $REX['TABLE_PREFIX'] . 'module`.`id`
            AND `' . $REX['TABLE_PREFIX'] . 'module_action`.`action_id` = `' . $REX['TABLE_PREFIX'] . 'action`.`id` )
          WHERE `' . $REX['TABLE_PREFIX'] . 'module`.`name` = "' . $modul_name . '"
            AND `' . $REX['TABLE_PREFIX'] . 'action`.`name` = "' . $action_name . '"
          LIMIT 1';
    $sql = new rex_sql();
    //$sql->debugsql = true;
    $data = $sql->getArray($qry);
    if (is_array($data) and $sql->getRows() == 1) {
        foreach ($data as $row) {
            // prüfe IDs auf vorhandensein
            // sind diese IDs in dieser Kombination noch nicht in der Verknüpfungstabelle
            // dann können sie dort eingetragen werden
            if ($row['mod_action_m_id'] == 'false' and $row['mod_action_a_id'] == 'false') {
                $qry = 'INSERT INTO `' . $REX['TABLE_PREFIX'] . 'module_action` ( `id` , `module_id` , `action_id` )
                VALUES (NULL , "' . $row['m_id'] . '", "' . $row['a_id'] . '")';
                $sql2 = new rex_sql();
                //$sql->debugsql = true;
                $sql2->setQuery($qry);
                if (!$REX['a63_sql_compare']) {
                    $sql2->freeResult();
                }
            } else {
                return 'rex_a63_installAction2Modul: Es exitiert bereits eine Zuweisung zwischen dem Modul "' . $modul_name . '" und der Aktion "' . $action_name . '".';
            }
        }
    } else {
        return 'rex_a63_installAction2Modul: Fehler in der Datenbankabfrage. Ist der Modulname "' . $modul_name . '" und der Aktionname "' . $action_name . '" richtig?';
    }
    if (!$REX['a63_sql_compare']) {
        $sql->freeResult();
    }
    return true;
}
/**
 * Installiert ein Template
 * @param $file Dateiname des Templates
 * @param $template_name Name mit dem das Template installiert werden soll
 * @param [$debug=false] Debugflag 
 */
function rex_installTemplate($file, $template_name, $debug = false)
{
    global $REX, $REX_USER;
    $content = sql::escape(file_get_contents($file . '.tpl'));
    $sql = new rex_sql();
    $sql->debugsql = $debug;
    $qry = 'INSERT INTO ' . $REX['TABLE_PREFIX'] . 'template SET `name` = ' . sql::escape($template_name) . ', `content` = ' . $content . ', `createdate` = ' . sql::escape(time()) . ', `createuser` = ' . sql::escape($REX_USER->getValue('login'));
    $sql->setQuery(_prepare_query($qry));
    return $sql->getError();
}
 /**
  * Führt eine SQL Query aus und schreibt sie in die Logdatei.
  * @param KLogger $log Logdatei Objekt
  * @param rex_sql $sql SQL Objekt
  * @param String $query SQL Query
  */
 public static function logQuery(&$log, &$sql, $query)
 {
     $sql->setQuery($query);
     if ($sql->getError() == '') {
         $log->logInfo('>> [QRY] ' . htmlentities($query));
     } else {
         $log->logError('>> [QRY] ' . htmlentities($query));
         $log->logError('>> [QRY] ' . $sql->getError());
     }
 }
예제 #15
0
 /**
  * delete the metafields
  */
 public static function delFields()
 {
     global $REX;
     $sql = new rex_sql();
     $sql->setQuery('SELECT `name` FROM ' . $REX['TABLE_PREFIX'] . '62_params WHERE `name` LIKE "asd_%"');
     $delFields = array();
     for ($i = 1; $i <= $sql->getRows(); $i++) {
         $delFields[] = a62_delete_field($sql->getValue('name'));
         $sql->next();
     }
     return self::checkErrorMessage($delFields);
 }
/**
 * Importiert die gegebene SQL-Datei in die Datenbank
 *
 * @return true bei Erfolg, sonst eine Fehlermeldung
 */
function rex_install_dump($file, $debug = false)
{
    $sql = new rex_sql();
    $sql->debugsql = $debug;
    $error = '';
    foreach (rex_read_sql_dump($file) as $query) {
        $sql->setQuery(rex_install_prepare_query($query));
        if (($sqlerr = $sql->getError()) != '') {
            $error .= $sqlerr . "\n<br />";
        }
    }
    return $error == '' ? true : $error;
}
 function execute()
 {
     $subject_key = $this->action["elements"][2];
     $body_key = $this->action["elements"][3];
     $user_id_key = $this->action["elements"][4];
     foreach ($this->elements_sql as $key => $value) {
         if ($subject_key == $key) {
             $subject = $value;
         }
         if ($body_key == $key) {
             $body = $value;
         }
         if ($user_id_key == $key) {
             $from_user_id = $value;
         }
         // echo "<br /> $key => $value";
     }
     if ($subject == "" or $body == "" or $from_user_id == "") {
         return FALSE;
     }
     // User auslesen
     $gu = new rex_sql();
     // $gu->debugsql = 1;
     // $gu->setQuery('select * from rex_com_user where id<>"'.$from_user_id.'" order by id');
     $gu->setQuery('select * from rex_com_user order by id');
     foreach ($gu->getArray() as $user) {
         $user_body = $body;
         $user_subject = $subject;
         $to_user_id = $user["id"];
         // Empfaenger einbauen
         $in = new rex_sql();
         // $in->debugsql = 1;
         $in->setTable("rex_com_message");
         $in->setValue("user_id", $to_user_id);
         $in->setValue("from_user_id", $from_user_id);
         $in->setValue("to_user_id", $to_user_id);
         $in->setValue("subject", $user_subject);
         $in->setValue("body", $user_body);
         $in->setValue("create_datetime", time());
         $in->insert();
         /*
         $in = new rex_sql;
         // $in->debugsql = 1;
         $in->setTable("rex_com_message");
         $in->setValue("user_id",$from_user_id);
         $in->setValue("from_user_id",$from_user_id);
         $in->setValue("to_user_id",$to_user_id);
         $in->setValue("subject",$user_subject);
         $in->setValue("body",$user_body);
         $in->setValue("create_datetime",time());
         $in->insert();
         */
         rex_com_user::exeAction($to_user_id, "sendemail_newmessage", $user);
     }
 }
 function enterObject(&$warning, $send, &$warning_messages)
 {
     if ($send == "1") {
         foreach ($this->xaObjects as $xoObject) {
             $sql = 'select ' . $this->xaElements[2] . ' from ' . $this->params["main_table"] . ' WHERE ' . $this->xaElements[2] . '="' . $xoObject->getValue() . '" LIMIT 1';
             $cd = new rex_sql();
             $cd->setQuery($sql);
             if ($cd->getRows() > 0) {
                 $warning["el_" . $xoObject->getId()] = $this->params["error_class"];
                 $warning_messages[] = $this->xaElements[3];
             }
         }
     }
 }
예제 #19
0
function a587_getCategories($_ignoreoffline = true, $_onlyIDs = false, $_cats = false)
{
    global $REX;
    $return = array();
    if (!empty($_cats)) {
        $whereCats = array();
        $sqlCats = array();
        if (is_array($_cats)) {
            foreach ($_cats as $catID) {
                $whereCats[] = "path LIKE '%|" . intval($catID) . "|%'";
                $sqlCats[] = intval($catID);
            }
        }
        $return = array();
        $query = 'SELECT id,catname,path FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE startpage = 1';
        if (empty($REX['ADDON']['settings']['rexsearch']['indexoffline']) and $_ignoreoffline) {
            $query .= ' AND status = 1';
        }
        if (!empty($whereCats)) {
            $query .= ' AND (' . implode(' OR ', $whereCats) . ' OR (id IN (' . implode(',', $sqlCats) . ')))';
        }
        $query .= ' GROUP BY id ORDER BY id';
        $sql = new rex_sql();
        foreach ($sql->getArray($query) as $cat) {
            if ($_onlyIDs) {
                $return[] = $cat['id'];
            } else {
                $return[$cat['id']] = $cat['catname'];
            }
        }
    } else {
        $query = 'SELECT id,re_id,catname,path FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE startpage = 1 AND re_id=%d';
        if (empty($REX['ADDON']['settings']['rexsearch']['indexoffline']) and $_ignoreoffline) {
            $query .= ' AND status = 1';
        }
        $query .= ' GROUP BY id ORDER BY catprior,id';
        $sql = new rex_sql();
        $cats = $sql->getArray(sprintf($query, 0));
        while (!empty($cats)) {
            $cat = array_shift($cats);
            if ($_onlyIDs) {
                $return[] = $cat['id'];
            } else {
                $return[$cat['id']] = str_repeat('&nbsp;', substr_count($cat['path'], '|') * 2 - 2) . $cat['catname'];
            }
            array_splice($cats, 0, 0, $sql->getArray(sprintf($query, $cat['id'])));
        }
    }
    return $return;
}
 /**
  * Konstruktor. Stellt die Daten der Kategorie aus der Datenbank zusammen.
  * @param int $kategorie_id Kategorie ID.
  * @param int $clang_id Redaxo SprachID.
  * @param string $table_prefix Redaxo Tabellen Praefix ($REX['TABLE_PREFIX'])
  */
 public function __construct($kategorie_id, $clang_id, $table_prefix = "rex_")
 {
     $this->table_prefix = $table_prefix;
     // Sprachfallback
     $query_prove = "SELECT * FROM " . $this->table_prefix . "d2u_stellenmarkt_kategorien_lang AS lang " . "WHERE kategorie_id = " . $kategorie_id . " " . "ORDER BY clang_id DESC";
     $result_prove = new rex_sql();
     $result_prove->setQuery($query_prove);
     $num_rows_prove = $result_prove->getRows();
     $is_lang_available = false;
     $fallback_lang_id = 0;
     for ($i = 0; $i < $num_rows_prove; $i++) {
         if ($result_prove->getValue("lang.clang_id") == $clang_id) {
             $is_lang_available = true;
         } else {
             $fallback_lang_id = $result_prove->getValue("lang.clang_id");
         }
         $result_prove->next();
     }
     $sql_clang_id = $clang_id;
     if ($is_lang_available == false) {
         $sql_clang_id = $fallback_lang_id;
     }
     $query = "SELECT * FROM " . $this->table_prefix . "d2u_stellenmarkt_kategorien AS kategorien " . "LEFT JOIN " . $this->table_prefix . "d2u_stellenmarkt_kategorien_lang AS lang " . "ON kategorien.kategorie_id = lang.kategorie_id " . "WHERE kategorien.kategorie_id = " . $kategorie_id . " " . "AND (clang_id = " . $sql_clang_id . " OR clang_id IS NULL) " . "LIMIT 0, 1";
     $result = new rex_sql();
     $result->setQuery($query);
     $num_rows = $result->getRows();
     if ($num_rows > 0) {
         $this->kategorie_id = $result->getValue("kategorie_id");
         if ($result->getValue("clang_id") != "") {
             $this->clang_id = $result->getValue("clang_id");
         }
         $this->interne_bezeichnung = $result->getValue("interne_bezeichnung");
         $this->name = $result->getValue("name");
     }
 }
 function getValue($value)
 {
     if (!is_array($value)) {
         $value = array();
         $section =& $this->getSection();
         // Alle vorhanden Werte löschen
         $sql = new rex_sql();
         $sql->setQuery('SELECT `' . $this->foreignField . '` FROM `' . $this->foreignTable . '` WHERE ' . $section->_getWhereString());
         for ($i = 0; $i < $sql->getRows(); $i++) {
             $value[] = $sql->getValue($this->foreignField);
             $sql->next();
         }
     }
     return $value;
 }
 /**
  * Gibt den HTML Content zurück
  */
 function get()
 {
     $table = $this->getTable();
     $field = $this->getField();
     $foreignField = $this->getForeignField();
     $value = $this->formatValue();
     $qry = 'SELECT ' . $field . ' FROM ' . $table . ' WHERE ' . $foreignField . ' = "' . $value . '"';
     $sql = new rex_sql();
     // $sql->debugsql = true;
     $sql->setQuery($qry);
     if ($sql->getRows() == 1) {
         return $sql->getValue($field);
     }
     return '';
 }
예제 #23
0
/**
 * Prüft ob dieses Addon Medien im Medienpool nutzt.
 * @global array $REX Redaxo Einstellungen
 * @param type $params Übergabeparameter des Extension Points
 * @return string Warnnachricht als Array
 */
function rex_d2u_stellenmarkt_media_is_in_use($params)
{
    global $REX;
    $warning = $params['subject'];
    $filename = addslashes($params['filename']);
    $sql_stelle = rex_sql::factory();
    $sql_stelle->setQuery('SELECT * FROM `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_stellen` WHERE bild = "' . $filename . '"');
    $rows_stelle = $sql_stelle->getRows();
    $sql_kontakt = rex_sql::factory();
    $sql_kontakt->setQuery('SELECT * FROM `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_kontakt` WHERE bild = "' . $filename . '"');
    $rows_kontakt = $sql_kontakt->getRows();
    $message = "";
    if ($rows_stelle > 0 || $rows_kontakt > 0) {
        $message = 'Stellenmarkt Addon:<br /><ul>';
    }
    for ($i = 0; $i < $rows_stelle; $i++) {
        $message .= '<li><a href="javascript:openPage(\'index.php?page=d2u_stellenmarkt&subpage=stellen&func=edit&entry_id=' . $sql_stelle->getValue('stellen_id') . '\')">' . $sql_stelle->getValue('interne_bezeichnung') . '</a></li>';
    }
    for ($i = 0; $i < $rows_kontakt; $i++) {
        $message .= '<li><a href="javascript:openPage(\'index.php?page=d2u_stellenmarkt&subpage=kontakte&func=edit&entry_id=' . $sql_kontakt->getValue('kontakt_id') . '\')">' . $sql_kontakt->getValue('name') . '</a></li>';
    }
    if (strlen($message) > 0) {
        $message .= '</ul>';
        $warning[] = $message;
    }
    return $warning;
}
예제 #24
0
 function executeAction()
 {
     $table = $this->getElement(2);
     // Tabelle vorhanden ?
     $sql = rex_sql::factory();
     $sql->debugsql = 1;
     $sql->setQuery('show tables');
     $table_exists = false;
     foreach ($sql->getArray() as $k => $v) {
         if ($table == $v) {
             $table_exists = true;
             break;
         }
     }
     if (!$table_exists) {
         $sql->setQuery('CREATE TABLE `' . $table . '` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY);');
     }
     // Welche Felder sind vorhanden ?
     $sql->setQuery('show columns from ' . $table);
     $sql_cols = $sql->getArray();
     $cols = array();
     foreach ($sql_cols as $k => $v) {
         $cols[] = $v['Field'];
     }
     // wenn Feld nicht in Datenbank, dann als TEXT anlegen.
     foreach ($this->params['value_pool']['sql'] as $key => $value) {
         if (!in_array($key, $cols)) {
             $sql->setQuery('ALTER TABLE `' . $table . '` ADD `' . $key . '` TEXT NOT NULL;');
         }
     }
     return;
 }
예제 #25
0
 public function tearDown()
 {
     $deleteuser = rex_sql::factory();
     $deleteuser->setQuery('DELETE FROM ' . rex::getTablePrefix() . "user WHERE login = '******' LIMIT 1");
     // make sure we don't mess up the global scope
     session_destroy();
 }
예제 #26
0
파일: revision.php 프로젝트: staabm/redaxo
 public static function copyContent($article_id, $clang, $from_revision_id, $to_revision_id)
 {
     if ($from_revision_id == $to_revision_id) {
         return false;
     }
     // clear the revision to which we will later copy all slices
     $dc = rex_sql::factory();
     // $dc->setDebug();
     $dc->setQuery('delete from ' . rex::getTablePrefix() . 'article_slice where article_id=' . $article_id . ' and clang_id=' . $clang . ' and revision=' . $to_revision_id);
     $gc = rex_sql::factory();
     $gc->setQuery('select * from ' . rex::getTablePrefix() . "article_slice where article_id='{$article_id}' and clang_id='{$clang}' and revision='{$from_revision_id}' ORDER by ctype_id, priority");
     $cols = rex_sql::factory();
     $cols->setquery('SHOW COLUMNS FROM ' . rex::getTablePrefix() . 'article_slice');
     foreach ($gc as $slice) {
         $ins = rex_sql::factory();
         // $ins->setDebug();
         $ins->setTable(rex::getTablePrefix() . 'article_slice');
         foreach ($cols as $col) {
             $colname = $col->getValue('Field');
             $ins->setValue($colname, $slice->getValue($colname));
         }
         $ins->setValue('id', 0);
         // trigger auto increment
         $ins->setValue('revision', $to_revision_id);
         $ins->addGlobalCreateFields();
         $ins->addGlobalUpdateFields();
         $ins->insert();
     }
     rex_article_cache::delete($article_id);
     return true;
 }
 function execute()
 {
     // START - Spezialfall "be_em_relation"
     /*
     $be_em_table_field = "";
     if($this->elements_sql["type_name"] == "be_em_relation")
     {
     	$be_em_table_field = $this->elements_sql["f1"];
     	$this->elements_sql["f1"] = $this->elements_sql["f3"]."_".$this->elements_sql["f1"];
     }
     */
     // ENDE - Spezialfall
     // ********************************* TABLE A
     // $this->params["debug"]= TRUE;
     $sql = rex_sql::factory();
     if ($this->params["debug"]) {
         $sql->debugsql = TRUE;
     }
     $main_table = "";
     if (isset($this->action["elements"][2]) && $this->action["elements"][2] != "") {
         $main_table = $this->action["elements"][2];
     } else {
         $main_table = $this->params["main_table"];
     }
     if ($main_table == "") {
         $this->params["form_show"] = TRUE;
         $this->params["hasWarnings"] = TRUE;
         $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
         return FALSE;
     }
     $sql->setTable($main_table);
     $where = "";
     if (isset($this->action["elements"][3]) && trim($this->action["elements"][3]) != "") {
         $where = trim($this->action["elements"][3]);
     }
     // SQL Objekt mit Werten füllen
     foreach ($this->elements_sql as $key => $value) {
         $sql->setValue($key, $value);
         if ($where != "") {
             $where = str_replace('###' . $key . '###', addslashes($value), $where);
         }
     }
     if ($where != "") {
         $sql->setWhere($where);
         $sql->update();
         $flag = "update";
     } else {
         $sql->insert();
         $flag = "insert";
         $id = $sql->getLastId();
         $this->elements_email["ID"] = $id;
         // $this->elements_sql["ID"] = $id;
         if ($id == 0) {
             $this->params["form_show"] = TRUE;
             $this->params["hasWarnings"] = TRUE;
             $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
         }
     }
     return;
 }
예제 #28
0
 public static function generateCSSFile($themeId)
 {
     global $REX;
     // include scss compiler
     if (!class_exists('scssc')) {
         require_once $REX['INCLUDE_PATH'] . '/addons/website_manager/plugins/themes/classes/class.scss.inc.php';
     }
     // vars
     $scssPhpFile = self::getScssPhpSourceFile();
     $cssFile = self::constructCSSFileWithPathForBackend($themeId);
     // get sql for scss php file
     $theme = rex_sql::factory();
     $theme->setQuery('SELECT * FROM rex_website_theme WHERE id = ' . $themeId);
     // interpret php to scss
     ob_start();
     include $scssPhpFile;
     $interpretedPhp = ob_get_contents();
     ob_end_clean();
     // strip comments
     $interpretedPhp = self::stripCSSComments($interpretedPhp);
     // compile scss to css
     try {
         $scss = new scssc();
         $scss->setFormatter('scss_formatter');
         $compiledScss = $scss->compile($interpretedPhp);
     } catch (Exception $e) {
         echo "<strong>SCSS Compile Error:</strong> <br/>";
         echo $e->getMessage();
         exit;
     }
     // write css
     $fileHandle = fopen($cssFile, 'w');
     fwrite($fileHandle, $compiledScss);
     fclose($fileHandle);
 }
예제 #29
0
 static function getListValue($params)
 {
     $return = array();
     $db = rex_sql::factory();
     // $db->debugsql = 1;
     $query = $params['params']['field']['query'];
     $pos = strrpos(strtoupper($query), 'ORDER BY ');
     if ($pos !== false) {
         $query = substr($query, 0, $pos);
     }
     $pos = strrpos(strtoupper($query), 'LIMIT ');
     if ($pos !== false) {
         $query = substr($query, 0, $pos);
     }
     $multiple = (int) $params['params']['field']['multiple'];
     if ($multiple != 1) {
         $where = ' `id` = ' . $db->escape($params['value']) . ' ';
     } else {
         $where = ' FIND_IN_SET(`id`, ' . $db->escape($params['value']) . ')';
     }
     $pos = strrpos(strtoupper($query), 'WHERE ');
     if ($pos !== false) {
         $query = substr($query, 0, $pos) . ' WHERE ' . $where . ' AND ' . substr($query, $pos + strlen('WHERE '));
     } else {
         $query .= ' WHERE ' . $where;
     }
     $db_array = $db->getArray($query);
     foreach ($db_array as $entry) {
         $return[] = $entry['name'];
     }
     if (count($return) == 0 && $params['value'] != '' && $params['value'] != '0') {
         $return[] = $params['value'];
     }
     return implode('<br />', $return);
 }
 function effectsFromType($type)
 {
     global $REX;
     $qry = '
   SELECT e.* 
   FROM ' . $REX['TABLE_PREFIX'] . '679_types t, ' . $REX['TABLE_PREFIX'] . '679_type_effects e
   WHERE e.type_id = t.id AND t.name="' . $type . '" order by e.prior';
     $sql = rex_sql::factory();
     //    $sql->debugsql = true;
     $sql->setQuery($qry);
     $effects = array();
     while ($sql->hasNext()) {
         $effname = $sql->getValue('effect');
         $params = unserialize($sql->getValue('parameters'));
         $effparams = array();
         // extract parameter out of array
         if (isset($params['rex_effect_' . $effname])) {
             foreach ($params['rex_effect_' . $effname] as $name => $value) {
                 $effparams[str_replace('rex_effect_' . $effname . '_', '', $name)] = $value;
                 unset($effparams[$name]);
             }
         }
         $effect = array('effect' => $effname, 'params' => $effparams);
         $effects[] = $effect;
         $sql->next();
     }
     return $effects;
 }