/** * 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()); } }
function asd_news_addClang($params) { global $REX; $id = $params['id']; $name = $params['name']; $now = new DateTime(); $error = false; $sql = new rex_sql(); $sql->setQuery('SELECT * FROM `' . rex_asd_news_config::getTable() . '` WHERE `clang` = ' . $REX['START_CLANG_ID']); for ($i = 1; $i <= $sql->getRows(); $i++) { $save = new rex_sql(); $save->setTable(rex_asd_news_config::getTable()); $save->setValues($sql->getRow()); $save->setValue('clang', $id); $save->setValue('createdAt', $now->format('Y-m-d H:i:s')); $save->setValue('updatedAt', $now->format('Y-m-d H:i:s')); $save->setValue('publishedAt', '0000-00-00 00:00:00'); $save->setValue('createdBy', $REX['USER']->getValue('user_id')); $save->setValue('updatedBy', $REX['USER']->getValue('user_id')); $save->setValue('publishedBy', 0); $save->setValue('status', 0); unset($save->values['news_id']); if (!$save->insert()) { $error = $save->getError(); } } if ($error) { echo rex_warning('ASD News: Neuigkeiten in der Sprache "' . $name . '" konnten nicht angelegt werden<br />' . $error); } else { echo rex_info('ASD News: Neuigkeiten in der Sprache "' . $name . '" wurden angelegt'); } }
/** * 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(); }
/** * 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; }
public function execute(array $params = []) { $qry = $this->stmt->queryString; $timer = new rex_timer(); parent::execute($params); $err = $errno = ''; if ($this->hasError()) { ++self::$errors; $err = parent::getError(); $errno = parent::getErrno(); } self::$queries[] = ['rows' => $this->getRows(), 'time' => $timer->getFormattedDelta(), 'query' => $qry, 'error' => $err, 'errno' => $errno]; return $this; }
function execute() { $query = trim($this->action["elements"][2]); if ($query == "") { if ($this->params["debug"]) { echo 'ActionQuery Error: no query'; } return; } $sql = new rex_sql(); if ($this->params["debug"]) { $sql->debugsql = TRUE; } // SQL Objekt mit Werten füllen foreach ($this->elements_sql as $key => $value) { $query = str_replace('###' . $key . '###', addslashes($value), $query); } $sql->setQuery($query); if ($sql->getError() != "") { $this->params["form_show"] = TRUE; $this->params["hasWarnings"] = TRUE; $this->params["warning_messages"][] = $this->action["elements"][3]; } }
$REX['HTDOCS_PATH'] = './'; include 'redaxo/include/master.inc.php'; // Dateiname der lokalen Bankleitzahlen-Datei $_blzfilename = $REX['HTDOCS_PATH'] . 'blz.txt'; // Falls allow_url_fopen aktiviert ist kann die Datei auch direkt vom Server verarbeitet werden // hierzu einfach die folgende Zeile auskommentieren //$_blzfilename = 'http://www.bundesbank.de/download/zahlungsverkehr/bankleitzahlen/20100906/blz_20100906.txt'; // SQL zum anlegen der Tabelle $_sql_create = "\n\tCREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%9999_blz` (\n\t `blz` int(8) NOT NULL default '0',\n\t `merkmal` char(1) NOT NULL default '',\n\t `bezeichnung` varchar(58) NOT NULL default '',\n\t `plz` varchar(5) NOT NULL default '',\n\t `ort` varchar(35) NOT NULL default '',\n\t `kurzbezeichnung` varchar(27) NOT NULL default '',\n\t `pan` varchar(5) NOT NULL default '',\n\t `bic` varchar(11) NOT NULL default '',\n\t `prz` char(2) NOT NULL default '',\n\t `satznr` int(6) NOT NULL default '0',\n\t `aendkz` char(1) NOT NULL default '',\n\t `blzloesch` char(1) NOT NULL default '',\n\t `blznachfolge` int(8) NOT NULL default '0',\n\t PRIMARY KEY (`satznr`)\n\t) TYPE=MyISAM;\n\t"; // Tabelle anlegen $_sql = new rex_sql(); $_sql->debugsql = false; $_sql_create = str_replace('%TABLE_PREFIX%', $REX['TABLE_PREFIX'], $_sql_create); $_sql->setQuery($_sql_create); if ($_sql->hasError()) { echo "<br />\n" . 'Error Message: ' . htmlspecialchars($_sql->getError()); echo "<br />\n" . 'Error Code: ' . $_sql->getErrno(); echo "<br />\n" . 'Query: ' . $_sql_create; } // Tabelle leeren falls schon vorhanden $_query = 'TRUNCATE TABLE ' . $REX['TABLE_PREFIX'] . '9999_blz'; $_sql->setQuery($_query); if ($_sql->hasError()) { echo "<br />\n" . 'Error Message: ' . htmlspecialchars($_sql->getError()); echo "<br />\n" . 'Error Code: ' . $_sql->getErrno(); echo "<br />\n" . 'Query: ' . $_query; } // Eingabe-Datei Postleitzahlen öffnen $_fp = fopen($_blzfilename, 'r'); if (!$_fp) { echo "<br />\n" . 'Beim öffnen der Datei ' . $blzfilename . ' ist ein Fehler aufgetreten!';
<?php /** * XO-Form * @author jan.kristinus[at]redaxo[dot]de Jan Kristinus * @author <a href="http://www.yakamara.de">www.yakamara.de</a> */ // Tabelle anlegen Redaxo 4.0.x $sql = new rex_sql(); $sql->setQuery("CREATE TABLE IF NOT EXISTS `rex_xform_email_template` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(255) NOT NULL default '',\n `mail_from` varchar(255) NOT NULL default '',\n `mail_from_name` varchar(255) NOT NULL default '',\n `subject` varchar(255) NOT NULL default '',\n `body` text NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;\n"); // evtl. Fehler beim Anlegen? if ($sql->hasError()) { $msg = 'MySQL-Error: ' . $sql->getErrno() . '<br />'; $msg .= $sql->getError(); // Evtl Ausgabe einer Meldung // $rxa_htmlinsert['meldung'] = 'Das Addon wurde nicht installiert, weil...'; $REX['ADDON']['install']['xform'] = 0; $REX['ADDON']['installmsg']['xform'] = $msg; } else { // Installation erfolgreich $REX['ADDON']['install']['xform'] = 1; }
/** * Importiert den SQL Dump $filename in die Datenbank * * @param string Pfad + Dateinamen zur SQL-Datei * * @return array Gibt ein Assoc. Array zurück. * 'state' => boolean (Status ob fehler aufgetreten sind) * 'message' => Evtl. Status/Fehlermeldung */ function rex_a1_import_db($filename) { global $REX, $I18N_IM_EXPORT; $return = array(); $return['state'] = false; $return['message'] = ''; $msg = ''; $error = ''; if ($filename == '' || substr($filename, -4, 4) != ".sql") { $return['message'] = $I18N_IM_EXPORT->msg('no_import_file_chosen_or_wrong_version') . '<br>'; return $return; } $conts = rex_get_file_contents($filename); // Versionsstempel prüfen // ## Redaxo Database Dump Version x.x $version = strpos($conts, '## Redaxo Database Dump Version ' . $REX['VERSION']); if ($version === false) { $return['message'] = $I18N_IM_EXPORT->msg('no_valid_import_file') . '. [## Redaxo Database Dump Version ' . $REX['VERSION'] . '] is missing'; return $return; } // Versionsstempel entfernen $conts = trim(str_replace('## Redaxo Database Dump Version ' . $REX['VERSION'], '', $conts)); // Prefix prüfen // ## Prefix xxx_ if (preg_match('/^## Prefix ([a-zA-Z0-9\\_]*)/', $conts, $matches) && isset($matches[1])) { // prefix entfernen $prefix = $matches[1]; $conts = trim(str_replace('## Prefix ' . $prefix, '', $conts)); } else { // Prefix wurde nicht gefunden $return['message'] = $I18N_IM_EXPORT->msg('no_valid_import_file') . '. [## Prefix ' . $REX['TABLE_PREFIX'] . '] is missing'; return $return; } // Prefix im export mit dem der installation angleichen if ($REX['TABLE_PREFIX'] != $prefix) { // Hier case-insensitiv ersetzen, damit alle möglich Schreibweisen (TABLE TablE, tAblE,..) ersetzt werden // Dies ist wichtig, da auch SQLs innerhalb von Ein/Ausgabe der Module vom rex-admin verwendet werden $conts = preg_replace('/(TABLE `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts); $conts = preg_replace('/(INTO `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts); $conts = preg_replace('/(EXISTS `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts); } // Inhalt der /generated Ordner komplett leeren rex_generateAll(); // ----- EXTENSION POINT $filesize = filesize($filename); $msg = rex_register_extension_point('A1_BEFORE_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize)); // Datei aufteilen $lines = explode("\n", $conts); $add = new rex_sql(); $error = ''; foreach ($lines as $line) { $line = trim($line, "\r"); // Windows spezifische extras $line = trim($line, ";"); // mysql 3.x if ($line == '') { continue; } $add->setQuery($line); if ($add->hasError()) { $error .= "\n" . $add->getError(); } } if ($error != '') { $return['message'] = trim($error); return $return; } $msg .= $I18N_IM_EXPORT->msg('database_imported') . '. ' . $I18N_IM_EXPORT->msg('entry_count', count($lines)) . '<br />'; // CLANG Array aktualisieren unset($REX['CLANG']); $db = new rex_sql(); $db->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'clang'); for ($i = 0; $i < $db->getRows(); $i++) { $id = $db->getValue('id'); $name = $db->getValue('name'); $REX['CLANG'][$id] = $name; $db->next(); } // prüfen, ob eine user tabelle angelegt wurde $result = $db->getArray('SHOW TABLES'); $user_table_found = false; foreach ($result as $row) { if (in_array($REX['TABLE_PREFIX'] . 'user', $row)) { $user_table_found = true; break; } } if (!$user_table_found) { $create_user_table = ' CREATE TABLE ' . $REX['TABLE_PREFIX'] . 'user ( user_id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL, description text NOT NULL, login varchar(50) NOT NULL, psw varchar(50) NOT NULL, status varchar(5) NOT NULL, rights text NOT NULL, login_tries tinyint(4) NOT NULL DEFAULT 0, createuser varchar(255) NOT NULL, updateuser varchar(255) NOT NULL, createdate int(11) NOT NULL DEFAULT 0, updatedate int(11) NOT NULL DEFAULT 0, lasttrydate int(11) NOT NULL DEFAULT 0, session_id varchar(255) NOT NULL, PRIMARY KEY(user_id) ) TYPE=MyISAM;'; $db->setQuery($create_user_table); $error = $db->getError(); if ($error != '') { // evtl vorhergehende meldungen löschen, damit nur der fehler angezeigt wird $msg = ''; $msg .= $error; } } // generated neu erstellen, wenn kein Fehler aufgetreten ist if ($error == '') { // ----- EXTENSION POINT $msg = rex_register_extension_point('A1_AFTER_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize)); $msg .= rex_generateAll(); $return['state'] = true; } $return['message'] = $msg; return $return; }
$EA->setTable($REX['TABLE_PREFIX'] . "article"); $EA->setWhere("id='{$article_id}' and clang={$clang}"); $EA->setValue('name', $article_name); $EA->setValue('template_id', $template_id); // $EA->setValue('path',$KATPATH); $EA->addGlobalUpdateFields(); $EA->setValue('prior', $Position_Article); if ($EA->update()) { $amessage = $I18N->msg('article_updated'); // ----- PRIOR rex_newArtPrio($category_id, $clang, $Position_Article, $thisArt->getValue('prior')); rex_generateArticle($article_id); // ----- EXTENSION POINT $amessage = rex_register_extension_point('ART_UPDATED', $amessage, array('id' => $article_id, 'status' => $thisArt->getValue('status'), 'name' => $article_name, 'clang' => $clang, 're_id' => $category_id, 'prior' => $Position_Article, 'path' => $KATPATH, 'template_id' => $template_id)); } else { $amessage = $EA->getError(); } } elseif ($function == 'artdelete_function' && $article_id != '' && $KATPERM && !$REX_USER->hasPerm('editContentOnly[]')) { // --------------------- ARTIKEL DELETE $message = rex_deleteArticle($article_id); $re_id = $thisArt->getValue("re_id"); // ----- PRIO $CL = $REX['CLANG']; reset($CL); for ($j = 0; $j < count($CL); $j++) { $mlang = key($CL); rex_newArtPrio($thisArt->getValue("re_id"), $mlang, 0, 1); next($CL); } // ----- EXTENSION POINT $message = rex_register_extension_point('ART_DELETED', $message, array("id" => $article_id, "re_id" => $re_id));
$sql->setQuery('CREATE TABLE IF NOT EXISTS `rex_website` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain` varchar(255) NOT NULL, `title` varchar(255) NOT NULL, `start_article_id` int(11) NOT NULL, `notfound_article_id` int(11) NOT NULL, `default_template_id` int(11) NOT NULL, `table_prefix` varchar(255) NOT NULL, `protocol` varchar(255) NOT NULL, `color` varchar(255) NOT NULL, `priority` INT(11) NOT NULL, `theme_id` int(11) default 0, PRIMARY KEY (`id`) ) ENGINE=MyISAM;'); $sql->setQuery('INSERT INTO `rex_website` VALUES (1, "' . rex_website_manager_utils::sanitizeUrl($REX['SERVER']) . '", "' . $REX['SERVERNAME'] . '", ' . $REX['START_ARTICLE_ID'] . ', ' . $REX['NOTFOUND_ARTICLE_ID'] . ', ' . $REX['DEFAULT_TEMPLATE_ID'] . ', "' . $firstTablePrefix . '", "' . $firstWebsiteProtocol . '", "' . $firstWebsiteColor . '", 1, ' . $defaultThemeId . ')'); $error = $sql->getError(); // create dirs $msg = array(); $msg[0] = rex_website_manager_utils::checkDir(WEBSITE_MANAGER_DATA_DIR); $msg[1] = rex_website_manager_utils::checkDir(WEBSITE_MANAGER_LOG_DIR); $msg[2] = rex_website_manager_utils::checkDir(WEBSITE_MANAGER_CUSTOM_DIR); $msg[3] = rex_website_manager_utils::checkDir(WEBSITE_MANAGER_GENERATED_DIR); if ($msg[0] != '') { rex_warning($msg[0]); } elseif ($msg[1] != '') { rex_warning($msg[1]); } elseif ($msg[2] != '') { rex_warning($msg[2]); } elseif ($msg[3] != '') { rex_warning($msg[3]); } else {
$postsavemode |= $status; } $faction->setTable($REX['TABLE_PREFIX'] . 'action'); $faction->setValue('name', $name); $faction->setValue('preview', $previewaction); $faction->setValue('presave', $presaveaction); $faction->setValue('postsave', $postsaveaction); $faction->setValue('previewmode', $previewmode); $faction->setValue('presavemode', $presavemode); $faction->setValue('postsavemode', $postsavemode); if ($function == 'add') { $faction->addGlobalCreateFields(); if ($faction->insert()) { $info = $I18N->msg('action_added'); } else { $warning = $faction->getError(); } } else { $faction->addGlobalUpdateFields(); $faction->setWhere('id=' . $action_id); if ($faction->update()) { $info = $I18N->msg('action_updated'); } else { $warning = $faction->getError(); } } if (isset($goon) and $goon != '') { $save = 'nein'; } else { $function = ''; }
if (rex_post('savemeta', 'string')) { $meta_article_name = rex_post('meta_article_name', 'string'); $meta_sql = new rex_sql(); $meta_sql->setTable($REX['TABLE_PREFIX'] . "article"); // $meta_sql->debugsql = 1; $meta_sql->setWhere("id='{$article_id}' AND clang={$clang}"); $meta_sql->setValue('name', $meta_article_name); $meta_sql->addGlobalUpdateFields(); if ($meta_sql->update()) { $article->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "article WHERE id='{$article_id}' AND clang='{$clang}'"); $info = $I18N->msg("metadata_updated"); rex_deleteCacheArticle($article_id, $clang); // ----- EXTENSION POINT $info = rex_register_extension_point('ART_META_UPDATED', $info, array('id' => $article_id, 'clang' => $clang, 'name' => $meta_article_name)); } else { $warning = $meta_sql->getError(); } } // ------------------------------------------ END: SAVE METADATA // ------------------------------------------ START: CONTENT HEAD MENUE $num_ctypes = count($REX['CTYPE']); $ctype_menu = ''; if ($num_ctypes > 0) { $listElements = array(); if ($num_ctypes > 1) { $listElements[] = $I18N->msg('content_types') . ': '; } else { $listElements[] = $I18N->msg('content_type') . ': '; } $i = 1; foreach ($REX['CTYPE'] as $key => $val) {
} else { $modultyp->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module where id=' . $modul_id); if ($modultyp->getRows() == 1) { $old_ausgabe = $modultyp->getValue('ausgabe'); // $modultyp->setQuery("UPDATE ".$REX['TABLE_PREFIX']."modultyp SET name='$mname', eingabe='$eingabe', ausgabe='$ausgabe' WHERE id='$modul_id'"); $UMOD = new rex_sql(); $UMOD->setTable($REX['TABLE_PREFIX'] . 'module'); $UMOD->setWhere('id=' . $modul_id); $UMOD->setValue('name', $mname); $UMOD->setValue('eingabe', $eingabe); $UMOD->setValue('ausgabe', $ausgabe); $UMOD->addGlobalUpdateFields(); if ($UMOD->update()) { $info = $I18N->msg('module_updated') . ' | ' . $I18N->msg('articel_updated'); } else { $warning = $UMOD->getError(); } $new_ausgabe = stripslashes($ausgabe); if ($old_ausgabe != $new_ausgabe) { // article updaten - nur wenn ausgabe sich veraendert hat $gc = new rex_sql(); $gc->setQuery("SELECT DISTINCT(" . $REX['TABLE_PREFIX'] . "article.id) FROM " . $REX['TABLE_PREFIX'] . "article\r\n LEFT JOIN " . $REX['TABLE_PREFIX'] . "article_slice ON " . $REX['TABLE_PREFIX'] . "article.id=" . $REX['TABLE_PREFIX'] . "article_slice.article_id\r\n WHERE " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id='{$modul_id}'"); for ($i = 0; $i < $gc->getRows(); $i++) { rex_deleteCacheArticle($gc->getValue($REX['TABLE_PREFIX'] . "article.id")); $gc->next(); } } } } if ($goon != '') { $save = '0';
// --------------------------------- FUNCTIONS if (rex_post('upd_profile_button', 'string')) { $updateuser = new rex_sql(); $updateuser->setTable($REX['TABLE_PREFIX'] . 'user'); $updateuser->setWhere('user_id=' . $user_id); $updateuser->setValue('name', $username); if ($REX['PSWFUNC'] != '' && $userpsw != $sql->getValue($REX['TABLE_PREFIX'] . 'user.psw')) { $userpsw = call_user_func($REX['PSWFUNC'], $userpsw); } $updateuser->setValue('psw', $userpsw); $updateuser->setValue('description', $userdesc); $updateuser->addGlobalUpdateFields(); if ($updateuser->update()) { $info = $I18N->msg('user_data_updated'); } else { $warning = $updateuser->getError(); } } // ---------------------------------- ERR MSG if ($info != '') { echo rex_info($info); } if ($warning != '') { echo rex_warning($warning); } // --------------------------------- FORMS $sql = new rex_login_sql(); $sql->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'user where user_id=' . $user_id); if ($sql->getRows() != 1) { echo rex_warning('You have no permission to this area!'); } else {
/** * @access public * @return Returns <code>true</code> on success or <code>false</code> on error */ function delete() { global $REX; $qry = 'DELETE FROM ' . $this->_getTableName() . ' WHERE file_id = ' . $this->getId() . ' LIMIT 1'; $sql = new rex_sql(); // $sql->debugsql = true; $sql->setQuery($qry); ### todo - loeschen des files unlink($REX['MEDIAFOLDER'] . $this->getFileName()); return $sql->getError(); }
/** * @access public * @return Returns <code>true</code> on success or <code>false</code> on error */ function delete($filename = null) { global $REX; if ($filename != null) { $OOMed = OOMedia::getMediaByFileName($filename); if ($OOMed) { return $OOMed->delete(); } } else { $qry = 'DELETE FROM ' . $this->_getTableName() . ' WHERE file_id = ' . $this->getId() . ' LIMIT 1'; $sql = new rex_sql(); $sql->setQuery($qry); if ($this->fileExists()) { unlink($REX['MEDIAFOLDER'] . DIRECTORY_SEPARATOR . $this->getFileName()); } return $sql->getError(); } return false; }
$ctypes[$i] = stripslashes($ctypes[$i]); } $TPL = new rex_sql(); $TPL->setTable($REX['TABLE_PREFIX'] . "template"); $TPL->setValue("name", $templatename); $TPL->setValue("active", $active); $TPL->setValue("content", $content); if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $message = $I18N->msg("template_added"); } else { $message = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); $message = $TPL->update($I18N->msg("template_updated")); } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0); if (isset($goon) and $goon != "") { $function = "edit"; $save = "nein";
<?php $func = rex_request('func', 'string'); if (rex_request('func', 'string') == 'save') { $trackingCode = trim(rex_request('tracking_code', 'string')); $sql = new rex_sql(); //$sql->debugsql = 1; $sql->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'tracking_code SET tracking_code = "' . $trackingCode . '" WHERE id = 1'); if ($sql->getError() == '') { echo rex_info($I18N->msg('tracking_code_configfile_update')); } else { echo rex_warning($I18N->msg('tracking_code_configfile_nosave')); } } rex_tracking_code::init(); $trackingCode = rex_tracking_code::getTrackingCode(); ?> <div class="rex-addon-output"> <h2 class="rex-hl2"><?php echo $I18N->msg('tracking_code_tracking_code', rex_tracking_code_utils::sanitizeUrl($REX['SERVER'])); ?> </h2> <div class="rex-area-content"> <form action="index.php" method="post"> <textarea <?php if (OOPlugin::isAvailable('be_utilities', 'codemirror') || isset($REX['ADDON']['be_style']['plugin_customizer']['codemirror']) && $REX['ADDON']['be_style']['plugin_customizer']['codemirror'] == 1) { ?> style="display: none;"<?php } ?>
} if ($func == 'unpublish') { $sql = new rex_sql(); $sql->setTable(rex_asd_news_config::getTable()); $sql->setWhere('id=' . $id . ' AND clang = ' . $clang); $sql->setValue('publishedAt', '0000-00-00 00:00:00'); $sql->setValue('publishedBy', 0); $successMessage = $I18N->msg('asd_news_unpublished_s'); if (rex_asd_news_config::getConfig('published-lang') == 'all') { $sql->setWhere('`id` = ' . $id); $successMessage = $I18N->msg('asd_news_unpublished_m'); } if ($sql->update()) { echo rex_info($successMessage); } else { echo rex_warning($sql->getError()); } $func = ''; } if ($func == '') { $list = new rex_list(' SELECT `id`, `title`, `publishedAt`, `status` FROM `' . rex_asd_news_config::getTable() . '` WHERE `clang` = ' . $clang . ' ORDER BY CASE WHEN `publishedAt` = "0000-00-00 00:00:00" THEN 1 ELSE 0 END DESC, `publishedAt` DESC, `updatedAt` DESC'); $list->addParam('clang', $clang);
} else { $msg = $I18N->msg('pool_kat_not_deleted'); } } elseif ($media_method == 'add_file_cat') { $db = new rex_sql(); $db->setTable($REX['TABLE_PREFIX'] . 'file_category'); $db->setValue('name', rex_request('catname', 'string')); $db->setValue('re_id', rex_request('cat_id', 'int')); $db->setValue('path', rex_request('catpath', 'string')); // TODO Update + Create zugleich? $db->addGlobalCreateFields(); $db->addGlobalUpdateFields(); if ($db->insert()) { $msg .= $I18N->msg('pool_kat_saved', stripslashes(rex_request('catname'))); } else { $msg .= $db->getError(); } } $link = 'index.php?page=medienpool&subpage=categories&cat_id='; $textpath = '<li> : <a href="' . $link . '0">Start</a></li>'; if (!isset($cat_id) or $cat_id == '') { $cat_id = 0; } if ($cat_id == 0 || !($OOCat = OOMediaCategory::getCategoryById($cat_id))) { $OOCats = OOMediaCategory::getRootCategories(); $cat_id = 0; $catpath = "|"; } else { $OOCats = $OOCat->getChildren(); $paths = explode("|", $OOCat->getPath()); for ($i = 1; $i < count($paths); $i++) {
/** * Ändert den Status des Artikels * * @param int $article_id Id des Artikels die gelöscht werden soll * @param int $clang Id der Sprache * @param int|null $status Status auf den der Artikel gesetzt werden soll, oder NULL wenn zum nächsten Status weitergeschaltet werden soll * * @return array Ein Array welches den status sowie eine Fehlermeldung beinhaltet */ function rex_articleStatus($article_id, $clang, $status = null) { global $REX, $I18N; $success = false; $message = ''; $artStatusTypes = rex_articleStatusTypes(); $GA = new rex_sql(); $GA->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where id='{$article_id}' and clang={$clang}"); if ($GA->getRows() == 1) { // Status wurde nicht von außen vorgegeben, // => zyklisch auf den nächsten Weiterschalten if (!$status) { $newstatus = ($GA->getValue('status') + 1) % count($artStatusTypes); } else { $newstatus = $status; } $EA = new rex_sql(); $EA->setTable($REX['TABLE_PREFIX'] . "article"); $EA->setWhere("id='{$article_id}' and clang={$clang}"); $EA->setValue('status', $newstatus); $EA->addGlobalUpdateFields(); if ($EA->update()) { $message = $I18N->msg('article_status_updated'); rex_deleteCacheArticle($article_id, $clang); // ----- EXTENSION POINT $message = rex_register_extension_point('ART_STATUS', $message, array('id' => $article_id, 'clang' => $clang, 'status' => $newstatus)); $success = true; } else { $message = $EA->getError(); } } else { $message = $I18N->msg("no_such_category"); } return array($success, $message); }
$info = $I18N->msg('pool_kat_deleted'); } else { $warning = $I18N->msg('pool_kat_not_deleted'); } } elseif ($media_method == 'add_file_cat') { $db = new rex_sql(); $db->setTable($REX['TABLE_PREFIX'] . 'file_category'); $db->setValue('name', rex_request('catname', 'string')); $db->setValue('re_id', rex_request('cat_id', 'int')); $db->setValue('path', rex_request('catpath', 'string')); $db->addGlobalCreateFields(); $db->addGlobalUpdateFields(); if ($db->insert()) { $info = $I18N->msg('pool_kat_saved', stripslashes(rex_request('catname'))); } else { $warning = $db->getError(); } } $link = 'index.php?page=mediapool&subpage=categories&cat_id='; $textpath = '<li> : <a href="' . $link . '0">Start</a></li>'; $cat_id = rex_request('cat_id', 'int'); if ($cat_id == 0 || !($OOCat = OOMediaCategory::getCategoryById($cat_id))) { $OOCats = OOMediaCategory::getRootCategories(); $cat_id = 0; $catpath = "|"; } else { $OOCats = $OOCat->getChildren(); // TODO getParentTree() verwenden $paths = explode("|", $OOCat->getPath()); for ($i = 1; $i < count($paths); $i++) { $iid = current($paths);
function rex_medienpool_registerFile($physical_filename, $org_filename, $filename, $category_id, $title, $filesize, $filetype) { global $REX, $REX_USER; $abs_file = $REX['MEDIAFOLDER'] . '/' . $physical_filename; if (!file_exists($abs_file)) { return false; } if (empty($filesize)) { $filesize = filesize($abs_file); } if (empty($filetype) && function_exists('mime_content_type')) { $filetype = mime_content_type($abs_file); } @chmod($abs_file, $REX['FILEPERM']); $filename = rex_medienpool_filename($filename, false); $org_filename = strtolower($org_filename); // Ggf Alte Datei umbennen rename($abs_file, $REX['MEDIAFOLDER'] . '/' . $filename); $abs_file = $REX['MEDIAFOLDER'] . '/' . $filename; // get widht height $size = @getimagesize($abs_file); $FILESQL = new rex_sql(); // $FILESQL->debugsql=1; $FILESQL->setTable($REX['TABLE_PREFIX'] . "file"); $FILESQL->setValue('filename', $filename); $FILESQL->setValue('originalname', $org_filename); $FILESQL->setValue('category_id', $category_id); $FILESQL->setValue('title', $title); $FILESQL->setValue('filesize', $filesize); $FILESQL->setValue('filetype', $filetype); $FILESQL->setValue('width', $size[0]); $FILESQL->setValue('height', $size[1]); // TODO Hier Update + Create zugleich? $FILESQL->addGlobalUpdateFields(); $FILESQL->addGlobalCreateFields(); $FILESQL->insert(); return $FILESQL->getError() == ''; }
$ctypes[$i] = stripslashes($ctypes[$i]); } $TPL = new rex_sql(); $TPL->setTable($REX['TABLE_PREFIX'] . "template"); $TPL->setValue("name", $templatename); $TPL->setValue("active", $active); $TPL->setValue("content", $content); if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $info = $I18N->msg("template_added"); } else { $warning = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); if ($TPL->update()) { $info = $I18N->msg("template_updated"); } else { $warning = $TPL->getError(); } } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content);
// ------------------------------------------ START: SAVE METADATA if (rex_post('savemeta', 'string')) { $meta_sql = new rex_sql(); $meta_sql->setTable($REX['TABLE_PREFIX'] . "article"); // $meta_sql->debugsql = 1; $meta_sql->setWhere("id='{$article_id}' AND clang={$clang}"); $meta_sql->setValue('name', $meta_article_name); $meta_sql->addGlobalUpdateFields(); if ($meta_sql->update()) { $article->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "article WHERE id='{$article_id}' AND clang='{$clang}'"); $message = $I18N->msg("metadata_updated") . $message; rex_generateArticle($article_id); // ----- EXTENSION POINT $message = rex_register_extension_point('ART_META_UPDATED', $message, array('id' => $article_id, 'clang' => $clang, 'name' => $meta_article_name)); } else { $message .= $meta_sql->getError(); } } // ------------------------------------------ END: SAVE METADATA // ------------------------------------------ START: CONTENT HEAD MENUE $num_ctypes = count($REX['CTYPE']); $ctype_menu = ''; if ($num_ctypes > 0) { $listElements = array(); if ($num_ctypes > 1) { $listElements[] = $I18N->msg('content_types') . ': '; } else { $listElements[] = $I18N->msg('content_type') . ': '; } $i = 1; foreach ($REX['CTYPE'] as $key => $val) {
$postsavemode |= $status; } $faction->setTable($REX['TABLE_PREFIX'] . 'action'); $faction->setValue('name', $name); $faction->setValue('preview', $previewaction); $faction->setValue('presave', $presaveaction); $faction->setValue('postsave', $postsaveaction); $faction->setValue('previewmode', $previewmode); $faction->setValue('presavemode', $presavemode); $faction->setValue('postsavemode', $postsavemode); if ($function == 'add') { $faction->addGlobalCreateFields(); if ($faction->insert()) { $message = $I18N->msg('action_added'); } else { $message = $faction->getError(); } } else { $faction->addGlobalUpdateFields(); $faction->setWhere('id=' . $action_id); if ($faction->update()) { $message = $I18N->msg('action_updated'); } else { $message = $faction->getError(); } } if (isset($goon) and $goon != '') { $save = 'nein'; } else { $function = ''; }
/** * @access public * @return Returns <code>true</code> on success or <code>false</code> on error */ function delete($recurse = false) { // Rekursiv löschen? if ($recurse) { if ($this->hasChildren()) { $childs = $this->getChildren(); foreach ($childs as $child) { $child->_delete($recurse); } } } // Alle Dateien löschen if ($this->hasFiles()) { $files = $this->getFiles(); foreach ($files as $file) { $file->_delete(); } } $qry = 'DELETE FROM ' . $this->_getTableName() . ' WHERE id = ' . $this->getId() . ' LIMIT 1'; $sql = new rex_sql(); // $sql->debugsql = true; // echo $qry; // return; $sql->setQuery($qry); return $sql->getError(); }
/** * Fügt dem Feld neue Werte via SQL-Query hinzu. * Dieser Query muss ein 2 Spaltiges Resultset beschreiben. * * @param $query SQL-Query * @access protected */ function addSqlValues($query) { $sql = new rex_sql(); // $sql->debugsql = true; $result = $sql->getArray($query, MYSQL_NUM); if ($sql->hasError()) { echo $sql->getError(); } if (is_array($result) && count($result) >= 1) { $value = array_shift($result); $count = count($value); if ($count >= 4) { // Add first Option $this->addValue($value[0], $value[1], $value[2], $value[3]); foreach ($result as $value) { // Add remaing Options $this->addValue($value[0], $value[1], $value[2], $value[3]); } } elseif ($count == 2) { // Add first Option $this->addValue($value[0], $value[1]); foreach ($result as $value) { // Add remaing Options $this->addValue($value[0], $value[1]); } } elseif ($count == 1) { // Add first Option $this->addValue($value[0], $value[0]); foreach ($result as $value) { // Add remaing Options $this->addValue($value[0], $value[0]); } } } }
function checkLogin() { global $REX; $fvs = new rex_sql(); // $fvs->debugsql = true; $userId = $this->getSessionVar('UID'); $check = parent::checkLogin(); if ($check) { // gelungenen versuch speichern | login_tries = 0 if ($this->usr_login != '') { $this->sessionFixation(); $fvs->setQuery('UPDATE ' . $this->tableName . ' SET login_tries=0, lasttrydate=' . time() . ', session_id="' . session_id() . '" WHERE login="******" LIMIT 1'); } } else { // fehlversuch speichern | login_tries++ if ($this->usr_login != '') { $fvs->setQuery('UPDATE ' . $this->tableName . ' SET login_tries=login_tries+1,session_id="",lasttrydate=' . time() . ' WHERE login="******" LIMIT 1'); } } if ($this->isLoggedOut() && $userId != '') { $fvs->setQuery('UPDATE ' . $this->tableName . ' SET session_id="" WHERE user_id="' . $userId . '" LIMIT 1'); } if ($fvs->hasError()) { return $fvs->getError(); } return $check; }