/** * 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 = rex_sql::factory(); $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 = rex_sql::factory(); $sql->setQuery('DELETE FROM ' . $REX['TABLE_PREFIX'] . '62_params'); }
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(); }
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; }
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; }
public function formatElement() { $name = $this->getFieldName(); $qry = 'SELECT ' . $this->labelField . ',' . $name . ' FROM ' . $this->table->getTableName() . ' WHERE 1=1'; if ($this->whereCondition != '') { $qry .= ' AND (' . $this->whereCondition . ')'; } // Im Edit Mode das Feld selbst nicht als Position einfügen if ($this->table->isEditMode()) { $qry .= ' AND (' . $name . '!=' . $this->getValue() . ')'; } $qry .= ' ORDER BY ' . $name; $sql = rex_sql::factory(); $sql->setQuery($qry); $this->select->addOption(rex_i18n::msg($this->firstOptionMsg), 1); $value = 1; foreach ($sql as $opt) { $value = $opt->getValue($name) + 1; $this->select->addOption(rex_i18n::rawMsg($this->optionMsg, $opt->getValue($this->labelField)), $value); } if (!$this->table->isEditMode()) { $this->select->setSelected($value); } return parent::formatElement(); }
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; }
/** * 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; }
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); }
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')); }
public static function get_slices_for_article($article_id, $clang_id = FALSE, $ctype_id = FALSE, $modultyp_id = FALSE) { global $REX; self::$slices = array(); $sql = rex_sql::factory(); $qry = ' SELECT id, re_article_slice_id, modultyp_id, ctype, clang FROM ' . $REX['TABLE_PREFIX'] . 'article_slice WHERE article_id=' . $article_id; if ($clang_id !== FALSE) { $qry .= ' AND clang = ' . $clang_id; } $sql->setQuery($qry); while ($sql->hasNext()) { self::$slices[$sql->getValue('re_article_slice_id')] = array('id' => $sql->getValue('id'), 'clang_id' => $sql->getValue('clang'), 'ctype_id' => $sql->getValue('ctype'), 'modultyp_id' => $sql->getValue('modultyp_id')); $sql->next(); } if (count(self::$slices) > 1) { self::order_slices(); } if (count(self::$slices) && $modultyp_id !== FALSE) { self::filter_slices_by_modultyp_id($modultyp_id); } if (count(self::$slices) && $ctype_id !== FALSE) { self::filter_slices_by_ctype_id($ctype_id); } if (count(self::$slices)) { foreach (self::$slices as $key => $val) { self::$slices[$key] = OOArticleSlice::getArticleSliceById($val['id'], $val['clang_id']); } } return self::$slices; }
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 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; }
protected static function updatePrio($order, $table, $idField, $useLike) { global $REX; $sql = rex_sql::factory(); foreach ($order as $prio => $keyname) { $sql->setQuery('UPDATE ' . $table . ' SET priority = ' . ($prio + 1) . ' ' . self::getWhere($useLike, $idField, $keyname)); } }
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 = rex_sql::factory(); // $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 = rex_sql::factory(); // $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 = rex_sql::factory(); // $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 = rex_sql::factory(); // $ins->debugsql = 1; $ins->setTable($REX['TABLE_PREFIX'] . "article_slice"); $cols = rex_sql::factory(); $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; }
public function isValid($value) { $sql = rex_sql::factory(); $sql->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'template WHERE id=' . $value . ' AND active=1'); if ($sql->getRows() != 1 && $value != 0) { return rex_i18n::msg('system_setting_default_template_id_invalid'); } return true; }
public static function getEntriesByTimeline() { //Start - get all timelines from the database $sql = rex_sql::factory(); $timelines = $sql->getArray('SELECT `user_id` FROM `' . rex::getTablePrefix() . 'socialhub_facebook_timeline`'); unset($sql); if (empty($timelines)) { return false; } //End - get all timelines from the database //Start - get all accounts from the database $sql = rex_sql::factory(); $accounts = $sql->getArray('SELECT * FROM `' . rex::getTablePrefix() . 'socialhub_facebook_account` ORDER BY `id` ASC'); unset($sql); if (empty($accounts)) { return false; } //End - get all accounts from the database //Start - get entries by timeline from twitter foreach ($timelines as $timeline) { $fb = new Facebook\Facebook(['app_id' => $accounts[0]['app_id'], 'app_secret' => $accounts[0]['app_secret'], 'default_graph_version' => 'v2.5', 'default_access_token' => $accounts[0]['app_id'] . '|' . $accounts[0]['app_secret']]); try { $response = $fb->get('/' . $timeline['user_id'] . '/posts'); } catch (Facebook\Exceptions\FacebookResponseException $e) { echo rex_view::error('Graph returned an error: ' . $e->getMessage()); } catch (Facebook\Exceptions\FacebookSDKException $e) { echo rex_view::error('Facebook SDK returned an error: ' . $e->getMessage()); } if (empty($response)) { return; } $response = json_decode($response->getBody(), true); foreach ($response['data'] as $post) { list($userID, $postID) = explode('_', $post['id']); $newPost = rex_sql::factory(); $newPost->setTable(rex::getTablePrefix() . 'socialhub_entry_timeline'); $newPost->setWhere(['post_id' => $postID]); $newPost->select(); if ($newPost->getRows() === 0) { $newPost->reset(); $newPost->setTable(rex::getTablePrefix() . 'socialhub_entry_timeline'); $newPost->setValue('source', 'facebook'); $newPost->setValue('post_id', $postID); $newPost->setValue('message', $post['message']); $newPost->setValue('author_id', $userID); $newPost->setValue('created_time', date('Y-m-d H:i:s', strtotime($post['created_time']))); $newPost->setValue('query', '/' . $timeline['user_id'] . '/posts'); try { $newPost->insert(); } catch (rex_sql_exception $e) { echo rex_view::warning($e->getMessage()); } } } } //End - get entries by timeline from twitter }
function execute() { global $REX; $config = OOPlugin::getProperty('cronjob', 'article_status', 'config'); $from = $config['from']; $to = $config['to']; $from['before'] = (array) $from['before']; $to['before'] = (array) $to['before']; $sql = rex_sql::factory(); // $sql->debugsql = true; $sql->setQuery(' SELECT name FROM ' . $REX['TABLE_PREFIX'] . '62_params WHERE name="' . $from['field'] . '" OR name="' . $to['field'] . '" '); $rows = $sql->getRows(); if ($rows < 2) { if ($rows == 0) { $msg = 'Metainfo fields "' . $from['field'] . '" and "' . $to['field'] . '" not found'; } else { $field = $sql->getValue('name') == $from['field'] ? $to['field'] : $from['field']; $msg = 'Metainfo field "' . $field . '" not found'; } $this->setMessage($msg); return false; } $time = time(); $sql->setQuery(' SELECT id, clang, status FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE ( ' . $from['field'] . ' > 0 AND ' . $from['field'] . ' < ' . $time . ' AND status IN (' . implode(',', $from['before']) . ') AND (' . $to['field'] . ' > ' . $time . ' OR ' . $to['field'] . ' = 0 OR ' . $to['field'] . ' = "") ) OR ( ' . $to['field'] . ' > 0 AND ' . $to['field'] . ' < ' . $time . ' AND status IN (' . implode(',', $to['before']) . ') ) '); $rows = $sql->getRows(); include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_structure.inc.php'; for ($i = 0; $i < $rows; $i++) { if (in_array($sql->getValue('status'), $from['before'])) { $status = $from['after']; } else { $status = $to['after']; } rex_articleStatus($sql->getValue('id'), $sql->getValue('clang'), $status); $sql->next(); } $this->setMessage('Updated articles: ' . $rows); return true; }
static function getTemplate($name) { $gt = rex_sql::factory(); $gt->setQuery('select * from ' . rex::getTablePrefix() . 'yform_email_template where name=:name', [':name' => $name]); if ($gt->getRows() == 1) { $b = $gt->getArray(); return current($b); } return false; }
function includeGlobalTemplate() { global $REX; $sql = rex_sql::factory(); $qry = 'SELECT content FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id = ' . $REX['ADDON']['rex_globals']['settings']['include_template_id'] . ''; $sql->setQuery($qry); if ($sql->getRows() == 1) { eval('?>' . $sql->getValue('content')); } }
function getTemplate($name) { $gt = rex_sql::factory(); $gt->setQuery('select * from rex_xform_email_template where name="' . mysql_real_escape_string($name) . '"'); if ($gt->getRows() == 1) { $b = $gt->getArray(); return current($b); } return FALSE; }
function rex_yrewrite_domaincheck($field, $value, $yform) { $sql = 'select ' . $field . ' from ' . $yform->objparams['main_table'] . ' where ' . $field . '="' . mysql_real_escape_string($value) . '" and alias_domain="" AND !(' . $yform->objparams['main_where'] . ')'; $a = rex_sql::factory(); $result = $a->getArray($sql); if (count($result) > 0) { return true; } return false; }
static function getTemplate($name) { $gt = rex_sql::factory(); $gt->setQuery('select * from ' . rex::getTablePrefix() . 'yform_email_template where name="' . mysql_real_escape_string($name) . '"'); if ($gt->getRows() == 1) { $b = $gt->getArray(); return current($b); } return false; }
public function execute() { $config = rex_plugin::get('cronjob', 'article_status')->getProperty('config'); $from = $config['from']; $to = $config['to']; $from['before'] = (array) $from['before']; $to['before'] = (array) $to['before']; $sql = rex_sql::factory(); // $sql->setDebug(); $sql->setQuery(' SELECT name FROM ' . rex::getTablePrefix() . 'metainfo_field WHERE name="' . $from['field'] . '" OR name="' . $to['field'] . '" '); $rows = $sql->getRows(); if ($rows < 2) { if ($rows == 0) { $msg = 'Metainfo fields "' . $from['field'] . '" and "' . $to['field'] . '" not found'; } else { $field = $sql->getValue('name') == $from['field'] ? $to['field'] : $from['field']; $msg = 'Metainfo field "' . $field . '" not found'; } $this->setMessage($msg); return false; } $time = time(); $sql->setQuery(' SELECT id, clang_id, status FROM ' . rex::getTablePrefix() . 'article WHERE ( ' . $from['field'] . ' > 0 AND ' . $from['field'] . ' < ' . $time . ' AND status IN (' . implode(',', $from['before']) . ') AND (' . $to['field'] . ' > ' . $time . ' OR ' . $to['field'] . ' = 0 OR ' . $to['field'] . ' = "") ) OR ( ' . $to['field'] . ' > 0 AND ' . $to['field'] . ' < ' . $time . ' AND status IN (' . implode(',', $to['before']) . ') ) '); $rows = $sql->getRows(); include_once rex_path::addon('structure', 'functions/function_rex_structure.php'); for ($i = 0; $i < $rows; ++$i) { if (in_array($sql->getValue('status'), $from['before'])) { $status = $from['after']; } else { $status = $to['after']; } rex_article_service::articleStatus($sql->getValue('id'), $sql->getValue('clang_id'), $status); $sql->next(); } $this->setMessage('Updated articles: ' . $rows); return true; }
public function setValue($value) { $value = (int) $value; $sql = rex_sql::factory(); $sql->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'template WHERE id=' . $value . ' AND active=1'); if ($sql->getRows() != 1 && $value != 0) { return rex_i18n::msg('system_setting_default_template_id_invalid'); } rex_config::set('structure/content', 'default_template_id', $value); return true; }
static function getTemplate($name) { global $REX; $gt = rex_sql::factory(); $gt->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'xform_email_template where name="' . mysql_real_escape_string($name) . '"'); if ($gt->getRows() == 1) { $b = $gt->getArray(); return current($b); } return false; }
public static function deleteSlices() { $IDs = rex_get('slices'); $sql = rex_sql::factory(); // $sql->setDebug(); $sql->setTable(rex::getTablePrefix() . 'article_slice'); $sql->setWhere("id IN('" . implode("','", $IDs) . "')", array()); $sql->delete(); $_SESSION[__CLASS__]['active'] = 0; die; }
function execute() { global $REX; $tables = rex_sql::showTables(1, $REX['TABLE_PREFIX']); if (is_array($tables) && !empty($tables)) { $sql = rex_sql::factory(); // $sql->debugsql = true; return $sql->setQuery('OPTIMIZE TABLE ' . implode(', ', $tables)); } return false; }
function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0) { $SEL = new rex_select(); $SEL->setName('FORM[' . $this->params["form_name"] . '][el_' . $this->id . ']'); $SEL->setId("el_" . $this->id); $SEL->setSize(1); $sql = $this->elements[4]; $teams = rex_sql::factory(); $teams->debugsql = $this->params["debug"]; $teams->setQuery($sql); $sqlnames = array(); // mit --- keine auswahl --- if ($this->elements[3] != 1) { $SEL->addOption($this->elements[3], "0"); } foreach ($teams->getArray() as $t) { if (!isset($this->elements[6]) || $this->elements[6] == "") { $v = $t['name']; } else { $v = $t[$this->elements[6]]; } if ($this->elements[5] == "") { $k = $t['id']; } else { $k = $t[$this->elements[5]]; } $SEL->addOption($v, $k); if (isset($this->elements[7])) { $sqlnames[$k] = $t[$this->elements[7]]; } } $wc = ""; if (isset($warning["el_" . $this->getId()])) { $wc = $warning["el_" . $this->getId()]; } $SEL->setStyle(' class="select ' . $wc . '"'); if ($this->value == "" && isset($this->elements[7]) && $this->elements[7] != "") { $this->value = $this->elements[7]; } $SEL->setSelected($this->value); $form_output[] = ' <p class="formselect" id="' . $this->getHTMLId() . '"> <label class="select ' . $wc . '" for="el_' . $this->id . '" >' . $this->elements[2] . '</label> ' . $SEL->get() . ' </p>'; $email_elements[$this->elements[1]] = stripslashes($this->value); if (isset($sqlnames[$this->value])) { $email_elements[$this->elements[1] . '_SQLNAME'] = stripslashes($sqlnames[$this->value]); } if (!isset($this->elements[8]) || $this->elements[8] != "no_db") { $sql_elements[$this->elements[1]] = $this->value; } }
public static function control() { global $REX; $myself = 'url_control'; $addon = $REX['ADDON'][$myself]['addon']; $rewriter = $REX['ADDON'][$myself]['rewriter']; // http://www.domain.de/kategorie/artikel.html $url_full = parent::getFullRequestedUrl(); $parse = parse_url($url_full); $url_path = $parse['path']; $sql = rex_sql::factory(); //$sql->debugsql = true; $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'url_control_manager WHERE status = "1" AND ( url = "' . mysql_real_escape_string($url_full) . '" OR url = "' . mysql_real_escape_string($url_path) . '" ) '); if ($sql->getRows() == 1) { $method = $sql->getValue('method'); $params = unserialize($sql->getValue('method_parameters')); switch ($method) { case 'article': $article_id = (int) $params['article']['article_id']; $clang = (int) $params['article']['clang']; if ($params['article']['action'] == 'view') { return array('article_id' => $article_id, 'clang' => $clang); } elseif ($params['article']['action'] == 'redirect') { $a = OOArticle::getArticleById((int) $params['article']['article_id'], (int) $params['article']['clang']); if ($a instanceof OOArticle) { if (isset($rewriter[$addon]['get_url'])) { $func = $rewriter[$addon]['get_url']; $url = call_user_func($func, $article_id, $clang); } else { $url = $a->getUrl(); } } //$url = rex_getUrl((int) $params['article']['article_id'], (int) $params['article']['clang']); self::redirect($a->getUrl(), $params['http_type']['code']); } break; case 'target_url': $url = $params['target_url']['url']; self::redirect($url, $params['http_type']['code']); break; } } return false; }
/** * Importiert die gegebene SQL-Datei in die Datenbank * * @return true bei Erfolg, sonst eine Fehlermeldung */ function rex_install_dump($file, $debug = false) { $sql = rex_sql::factory(); $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; }