// // Mission: to supply messages for different language environments class i18n { var $locale; var $text; var $searchpath; var $filename; /* * Constructor * the locale must of the common form, eg. de_DE, en_US or just plain en, de. * the searchpath is where the language files are located */ function i18n($locale, $searchpath) { $this->text = array(); $this->locale = $locale; $this->searchpath = $searchpath; $this->filename = $searchpath."/".$locale.".lang"; $this->loadTexts(); } /* * load texts from file. * The filename must be of the form: * * .lang * eg: de_DE.lang or en_US.lang or en_GB.lang * * The file must be in the common property format: * * key = value * # comments must be on one line * * values may contain placeholders for replacement of variables, e.g. * file_not_found = The file {0} could not be found. * there can be only 10 placeholders, {0} to {9}. */ function loadTexts() { if (is_readable($this->filename)) { $f = fopen($this->filename,"r"); while (!feof($f)) { $buffer = fgets($f, 4096); if (preg_match("/^(\w*)\s*=\s*(.*)$/", $buffer, $matches)) { $this->text[$matches[1]] = trim($matches[2]); } } fclose ($f); } } /* * return a message according to a key from the current locale * you can give up to 10 parameters for substitution. */ function msg($key, $p0='',$p1='',$p2='',$p3='',$p4='',$p5='',$p6='',$p7='',$p8='',$p9='') { $msg = $this->text[$key]; $patterns = array('/\{0\}/','/\{1\}/','/\{2\}/','/\{3\}/','/\{4\}/','/\{5\}/','/\{6\}/','/\{7\}/','/\{8\}/','/\{9\}/'); $replacements = array($p0,$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9); return preg_replace($patterns, $replacements, $msg); } /* * class function: find all defined locales in a searchpath * the language files must be of the form: .lang * e.g. de_DE.lang or en_US.lang */ function getLocales($searchpath) { $locales = array(); if (is_readable($searchpath)) { $handle=opendir($searchpath); while ($file = readdir ($handle)) { if ($file != "." && $file != "..") { if (preg_match("/^(\w+)\.lang$/", $file, $matches)) { $locales[] = $matches[1]; } } } closedir($handle); } return $locales; } } ?> identifier = @ mysql_pconnect($DB[$DBID][HOST], $DB[$DBID][LOGIN], $DB[$DBID][PSW]); $this->debugsql = false; $this->DBID = $DBID; $this->selectDB(); $this->zaehler = 0; $this->counter = 0; // MySQL Version bestimmen if ($REX['mysql_version'] == '') { $this->setQuery( 'SELECT VERSION() as VERSION'); $res = $this->get_array(); $arr = array(); preg_match('/([0-9]+\.([0-9\.])+)/',$res[0]['VERSION'], $arr); $REX['mysql_version'] = $arr[1]; } } function selectDB() { global $DB, $REX; if (!@ mysql_select_db($DB[$this->DBID][NAME])) { echo "Class SQL 1.1 | Database down. | Please contact ".$REX[error_emailaddress]."\n | Thank you!\n"; exit; } } function setQuery($select) { $this->zaehler = 0; $this->counter = 0; $this->select = $select; $this->selectDB(); $this->result = @ mysql_query("$select"); $this->rows = @ mysql_num_rows($this->result); $this->insertID = @ mysql_insert_id($this->result); $this->error = @ mysql_error(); if ($this->debugsql) echo htmlentities($select)."
".$this->rows." found
"; } function setTable($table) { $this->table = $table; } function setValue($feldname, $wertigkeit) { $this->feld[$this->zaehler] = $feldname; $this->wert[$this->zaehler] = $wertigkeit; $this->zaehler++; } function isValueOf($feld, $prop) { $value = @ mysql_result($this->result, $this->counter, "$feld"); if ($prop == "") { return TRUE; } else if (strstr($value, $prop)) { return TRUE; } else { return FALSE; } } function where($where) { $this->wherevar = "where $where"; } function getValue($value) { // wenn db verwechslungen, dann hier aktiv setzen // $this->selectDB(); $back = @ mysql_result($this->result, $this->counter, "$value"); return $back; } function getRows() { return $this->rows; } function nextValue() { $this->counter++; } function resetCounter() { $this->counter = 0; } function liste() { $back = ""; for ($i = 0; $i < $this->getRows(); $i ++) { for ($j = 0; $j < $this->zaehler; $j ++) { $back .= $this->getValue($this->feld[$j])." \n"; } $back .= "
"; $this->counter++; } return $back; } function update() { $sql = ""; for ($i = 0; $i < $this->zaehler; $i ++) { if ($sql != "") { $sql .= ","; } // $sql .= $this->feld[$i]."='".addslashes( $this->wert[$i])."'"; $sql .= $this->feld[$i]."='". ($this->wert[$i])."'"; } $this->selectDB(); $this->result = mysql_query("update $this->table set $sql $this->wherevar"); $this->error = @ mysql_error(); $this->message = "event updated
"; if ($this->debugsql) echo "update $this->table set $sql $this->wherevar"; } function insert() { $sql1 = ""; $sql2 = ""; for ($i = 0; $i < $this->zaehler; $i ++) { if ($sql1 != "") { $sql1 .= ","; } if ($sql2 != "") { $sql2 .= ","; } $sql1 .= $this->feld[$i]; // $sql2 .= "'".addslashes( $this->wert[$i])."'"; $sql2 .= "'". ($this->wert[$i])."'"; } $this->selectDB(); $this->result = @ mysql_query("insert into $this->table ($sql1) VALUES ($sql2)"); $this->last_insert_id = @ mysql_insert_id($this->identifier); $this->error = @ mysql_error(); $this->message = "new event inserted
"; if ($this->debugsql) echo htmlentities("insert into $this->table ($sql1) VALUES ($sql2)"); } function delete() { $this->selectDB(); $this->result = mysql_query("delete from $this->table $this->wherevar"); $this->error = @ mysql_error(); } function flush() { $this->zaehler = 0; $this->table = ""; $this->error = ""; $this->wherevar = ""; $this->select = ""; $this->counter = 0; $this->rows = 0; $this->result = ""; } function query($sql) { $this->selectDB(); $this->result = mysql_query("$sql"); $this->error = @ mysql_error(); if ($this->debugsql) echo $sql."
"; } function escape($string) { return mysql_escape_string($string); } function next() { $this->counter++; } function getLastID() { return $this->last_insert_id; } // GET ARRAY RESULT function get_array($sql = "") { if ($sql != "") { $this->setQuery($sql); } $data = null; while ($row = @ mysql_fetch_assoc($this->result)) { $data[] = $row; } return $data; } function getError() { return $this->error; } function setNewId($field) { $result = mysql_query("select $field from $this->table order by $field desc LIMIT 1"); if (@ mysql_num_rows($result) == 0) $id = 0; else $id = mysql_result($result, 0, "$field"); $id ++; $this->setValue($field, $id); return $id; } function getFieldnames() { $y = mysql_num_fields($this->result); for ($x = 0; $x < $y; $x ++) { $echo[] = mysql_field_name($this->result, $x); } return $echo; } } ?>init(); } ############### multiple felder ? function multiple($mul){ if ($mul == 1){ $this->select_multiple = " multiple"; }else{ $this->select_multiple = ""; } } ################ init function init(){ // $this->counter = 0; $this->select_name = "standard"; $this->select_size = 5; $this->select_multiple = ""; $this->option_selected = array(); // $this->option_anzahl= 0; } ################ select name function set_name($name){ $this->select_name = $name; } ################ select id function set_id($id){ $this->select_id = $id; } ################ select style function set_style($style){ $this->select_style = $style; } ################ select size function set_size($size){ $this->select_size = $size; } ################ selected feld - option value uebergeben function set_selected($selected){ $this->option_selected[] = $selected; // $this->option_anzahl++; } function resetSelected() { // unset($this->option_selected); // $this->option_anzahl= 0; } ################ optionen hinzufuegen function add_option($name,$value, $id = 0, $re_id = 0){ $this->options[$re_id][] = array( $name, $value, $id); // $this->counter++; } ############### show select function out(){ global $STYLE; $ausgabe = "\n\n"; return $ausgabe; } function out_group( $re_id, $level = 0) { if ($level > 100) { // nur mal so zu sicherheit .. man weiss nie ;) echo "select->out_group overflow ($groupname)"; exit; } $ausgabe = ''; $group = $this->get_group( $re_id); foreach( $group as $option) { $name = $option[0] ; $value = $option[1]; $id = $option[2]; $ausgabe .= $this->out_option( $name, $value, $level); $subgroup = $this->get_group( $id, true); if ( $subgroup !== false) { $ausgabe .= $this->out_group( $id, $level + 1); } } return $ausgabe; } function out_option( $name, $value, $level = 0) { for ($i=0;$i<$level;$i++) $bsps .= "   "; $selected = ''; if ( $this->option_selected !== null) { $selected = in_array( $value, $this->option_selected) ? ' selected="selected"' : ''; } return ' '. "\n"; } function get_group( $re_id, $ignore_main_group = false) { if ( $ignore_main_group && $re_id == 0) { return false; } foreach ( $this->options as $gname => $group) { if ( $gname == $re_id) { return $group; } } return false; } } ?>article_id = 0; $this->template_id = 0; $this->clang = 0; $this->ctype = ""; $this->slice_id = 0; $this->mode = "view"; $this->article_content = ""; $this->eval = FALSE; $this->setanker = true; unset($save); // AUSNAHME: modul auswählen problem // action=index.php#1212 problem if (strpos($_SERVER["HTTP_USER_AGENT"],"Mac") and strpos($_SERVER["HTTP_USER_AGENT"],"MSIE") ) $this->setanker = FALSE; } function setSliceId($value) { $this->slice_id = $value; } function setCType($value) { $this->ctype = $value; } function setCLang($value) { global $REX; if ($REX[CLANG][$value] == "") $value = 0; $this->clang = $value; } function setArticleId($article_id) { global $REX; $article_id = $article_id + 0; $this->article_id = $article_id+0; if (!$REX[GG]) { // ---------- select article $this->ARTICLE = new sql; // $this->ARTICLE->debugsql = 1; $this->ARTICLE->setQuery("select * from rex_article where rex_article.id='$article_id' and clang='".$this->clang."'"); if ($this->ARTICLE->getRows() == 1) { $this->template_id = $this->ARTICLE->getValue("rex_article.template_id"); $this->category_id = $this->getValue("category_id"); return TRUE; }else { $this->article_id = 0; $this->template_id = 0; $this->category_id = 0; return FALSE; } }else { if (@include $REX[INCLUDE_PATH]."/generated/articles/".$article_id.".".$this->clang.".article") { return TRUE; }else { return FALSE; } } } function setMode($mode) { $this->mode = $mode; } function setFunction($function) { $this->function = $function; } function setEval($value) { if ($value) $this->eval = TRUE; else $this->eval = FALSE; } function getValue($value) { global $REX; if ($value == "category_id") { if ($this->getValue("startpage")!=1) $value = "re_id"; else if($REX[GG]) $value = "article_id"; else $value = "id"; } if ($REX[GG]) return $REX[ART][$this->article_id][$value][$this->clang]; else return $this->ARTICLE->getValue($value); } function getArticle() { global $module_id,$FORM,$REX_USER,$REX,$REX_SESSION,$REX_ACTION,$I18N; if ($REX[GG]) { if ($this->article_id != 0) { $this->contents = ""; $filename = $REX[INCLUDE_PATH]."/generated/articles/".$this->article_id.".".$this->clang.".content"; if ($fd = @fopen ($filename, "r")) { $this->contents = fread ($fd, filesize ($filename)); fclose ($fd); eval($this->contents); } } }else { if ($this->article_id != 0) { // ---------- select alle slices eines artikels $sql = "select rex_modultyp.id, rex_modultyp.name, rex_modultyp.ausgabe, rex_modultyp.eingabe, rex_modultyp.php_enable, rex_modultyp.html_enable, rex_article_slice.*, rex_article.re_id from rex_article_slice left join rex_modultyp on rex_article_slice.modultyp_id=rex_modultyp.id left join rex_article on rex_article_slice.article_id=rex_article.id where rex_article_slice.article_id='".$this->article_id."' and rex_article_slice.clang='".$this->clang."' and rex_article.clang='".$this->clang."' order by rex_article_slice.re_article_slice_id"; $this->CONT = new sql; $this->CONT->setQuery($sql); // ---------- SLICE IDS/MODUL SETZEN for ($i=0;$i<$this->CONT->getRows();$i++) { $RE_CONTS[$this->CONT->getValue("re_article_slice_id")] = $this->CONT->getValue("rex_article_slice.id"); $RE_CONTS_CTYPE[$this->CONT->getValue("re_article_slice_id")] = $this->CONT->getValue("rex_article_slice.ctype"); $RE_MODUL_OUT[$this->CONT->getValue("re_article_slice_id")] = $this->CONT->getValue("rex_modultyp.ausgabe"); $RE_MODUL_IN[$this->CONT->getValue("re_article_slice_id")] = $this->CONT->getValue("rex_modultyp.eingabe"); $RE_MODUL_ID[$this->CONT->getValue("re_article_slice_id")] = $this->CONT->getValue("rex_modultyp.id"); $RE_MODUL_NAME[$this->CONT->getValue("re_article_slice_id")] = $this->CONT->getValue("rex_modultyp.name"); $RE_C[$this->CONT->getValue("re_article_slice_id")] = $i; $this->CONT->nextValue(); } // ---------- moduleselect if($this->mode=="edit") { $MODULE = new sql; $MODULE->setQuery("select * from rex_modultyp $add_sql order by name"); $MODULESELECT = new select; $MODULESELECT->set_name("module_id"); $MODULESELECT->set_size(1); $MODULESELECT->set_style("width:100%;' onchange='this.form.submit();"); $MODULESELECT->add_option("---------------------------- ".$I18N->msg("add_block"),''); for ($i=0;$i<$MODULE->getRows();$i++) { if ($REX_USER->isValueOf("rights","module[".$MODULE->getValue("id")."]") || $REX_USER->isValueOf("rights","admin[]") || $REX_USER->isValueOf("rights","dev[]")) $MODULESELECT->add_option($MODULE->getValue("name"),$MODULE->getValue("id")); $MODULE->next(); } } // ---------- SLICE IDS SORTIEREN UND AUSGEBEN $I_ID = 0; $PRE_ID = 0; $this->article_content = ""; $this->CONT->resetCounter(); $tbl_head = "
"; $tbl_bott = "
"; for ($i=0;$i<$this->CONT->getRows();$i++) { // ------------- EINZELNER SLICE - AUSGABE $this->CONT->counter = $RE_C[$I_ID]; $slice_content = ""; $SLICE_SHOW = TRUE; if($this->mode=="edit") { $this->ViewSliceId = $RE_CONTS[$I_ID]; $amodule = " setanker) $amodule .= "#addslice"; $amodule.= " method=get> article_id> mode>
".$MODULESELECT->out()."
"; // ----- add select box einbauen if($this->function=="add" && $this->slice_id == $I_ID) { $slice_content = $this->addSlice($I_ID,$module_id); }else { $slice_content .= $amodule; } // ----- edit / delete if($REX_USER->isValueOf("rights","module[".$RE_MODUL_ID[$I_ID]."]") || $REX_USER->isValueOf("rights","admin[]") || $REX_USER->isValueOf("rights","dev[]")) { // hat rechte zum edit und delete $mne = " "; if ($REX_USER->isValueOf("rights","moveslice[]")) { $mne .= ""; } $mne .= "
$RE_MODUL_NAME[$I_ID] article_id&mode=edit&slice_id=$RE_CONTS[$I_ID]&function=edit&clang=".$this->clang."&ctype=".$this->ctype."#slice$RE_CONTS[$I_ID] class=green12b>".$I18N->msg('edit')." article_id&mode=edit&slice_id=$RE_CONTS[$I_ID]&function=delete&clang=".$this->clang."&ctype=".$this->ctype."&save=1#slice$RE_CONTS[$I_ID] class=red12b onclick='return confirm(\"".$I18N->msg('delete')." ?\")'>".$I18N->msg('delete')."article_id&mode=edit&slice_id=$RE_CONTS[$I_ID]&function=moveup&clang=".$this->clang."&ctype=".$this->ctype." class=green12b>article_id&mode=edit&slice_id=$RE_CONTS[$I_ID]&function=movedown&clang=".$this->clang."&ctype=".$this->ctype." class=green12b>
"; $slice_content .= $mne.$tbl_head; if($this->function=="edit" && $this->slice_id == $RE_CONTS[$I_ID]) { $slice_content .= $this->editSlice($RE_CONTS[$I_ID],$RE_MODUL_IN[$I_ID]); }else { $slice_content .= $RE_MODUL_OUT[$I_ID]; } $slice_content .= $tbl_bott; $slice_content = $this->sliceIn($slice_content); }else { // hat keine rechte an diesem modul $mne = "
$RE_MODUL_NAME[$I_ID] | ".$I18N->msg('no_editing_rights')."
"; $slice_content .= $mne.$tbl_head.$RE_MODUL_OUT[$I_ID].$tbl_bott; $slice_content = $this->sliceIn($slice_content); } }else { // wenn mode nicht edit $slice_content .= $RE_MODUL_OUT[$I_ID]; $slice_content = $this->sliceIn($slice_content); } // --------------- ENDE EINZELNER SLICE // ---------- slice in ausgabe speichern wenn ctype richtig if ($this->ctype == "" or $this->ctype == $RE_CONTS_CTYPE[$I_ID]) $this->article_content .= $slice_content; // zum nachsten slice $I_ID = $RE_CONTS[$I_ID]; $PRE_ID = $I_ID; } if ($this->mode == "edit") { $amodule = " setanker) $amodule .= "#addslice"; $amodule.= " method=get> article_id> mode>
".$MODULESELECT->out()."
"; if($this->function=="add" && $this->slice_id == $I_ID) { $slice_content = $this->addSlice($I_ID,$module_id); }else { $slice_content = $amodule; } $this->article_content .= $slice_content; } // -------------------------- schreibe content if ($REX[RC]) return $this->article_content; else eval("?>".$this->article_content); }else { return $I18N->msg('no_article_available'); } } } function getArticleTemplate() { global $FORM,$REX; if ($this->getValue("template_id") == 0 and $this->article_id != 0) { return $this->getArticle(); }elseif ($this->getValue("template_id") != 0 and $this->article_id != 0) { $template_name = $REX[INCLUDE_PATH]."/generated/templates/".$this->getValue("template_id").".template"; if ($fd = fopen ($template_name, "r")) { $template_content = fread ($fd, filesize ($template_name)); fclose ($fd); }else { $template_content = $this->getValue("template_id")." not found"; } $return = str_replace("REX_ARTICLE_ID",$this->article_id,$template_content); // function in function_rex_modrewrite.inc.php $slice_content = $this->replaceLinks($slice_content); eval("?>".$return); // echo htmlentities($return); }else { return "no template"; } } // ----- ADD Slice // altem inhalt loeschen - sliceClear function addSlice($I_ID,$module_id) { global $REX,$REX_ACTION,$FORM,$I18N; $MOD = new sql; $MOD->setQuery("select * from rex_modultyp where id=$module_id"); if ($MOD->getRows() != 1) { $slice_content = "
".$I18N->msg('module_doesnt_exist')."
"; }else { $slice_content = "
".$I18N->msg('add_block')."
Modul: ".$MOD->getValue("name")."
article_id> mode> ".$MOD->getValue("eingabe")."
"; $slice_content = $this->sliceClear($slice_content); $slice_content .= "
"; } return $slice_content; } function editSlice($RE_CONTS,$RE_MODUL_IN) { global $REX,$REX_ACTION,$FORM,$I18N; $slice_content .= "
article_id> mode> $RE_MODUL_IN

             
"; // werte das erst mal aufgerufen / noch nicht gespeichert / gepspeichert und neu if (!isset($REX_ACTION[SAVE])) $slice_content = $this->sliceIn($slice_content); if (!$REX_ACTION[SAVE]) $slice_content = $this->sliceClear($slice_content); else $slice_content = $this->sliceIn($slice_content); return $slice_content; } // ----- allgemeines suchen und ersetzen function sliceIn($slice_content) { for ($i=1;$i<11;$i++) { // ----------------------------- LIST BUTTONS // REX_FILELIST_BUTTON $medialistvalue = $this->stripPHP($this->convertString($this->CONT->getValue("rex_article_slice.filelist$i"))); $media = ""; $media .= ""; $media .= ""; $media .= ""; $media .= ""; $media .= ""; $media .= "
". "". "
". "
". "
". "". "


"; $slice_content = str_replace("REX_MEDIALIST_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_MEDIALIST[$i]",$medialistvalue,$slice_content); // REX_LINKLIST_BUTTON $media = ""; $media = $this->stripPHP($media); $slice_content = str_replace("REX_LINKLIST_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_LINKLIST[$i]",$this->convertString($this->CONT->getValue("rex_article_slice.linklist$i")),$slice_content); // ----------------------------- REX_MEDIA $media = ""; $media.= ""; $media.= ""; $media.= ""; $media.= ""; $media.= "
clang.");>clang.");>clang.")>
"; $media = $this->stripPHP($media); $slice_content = str_replace("REX_MEDIA_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_FILE[$i]",$this->convertString($this->CONT->getValue("rex_article_slice.file$i")),$slice_content); // ----------------------------- REX_LINK_BUTTON if($this->CONT->getValue("rex_article_slice.link$i")) { $db = new sql; $sql = "SELECT name FROM rex_article WHERE id=".$this->CONT->getValue("rex_article_slice.link$i")." and clang=".$this->clang; $res = $db->get_array($sql); $link_name = $res[0][name]; }else { $link_name = ""; } $media = ""; $media.= ""; $media.= ""; $media.= ""; $media.= "
clang.");>clang.");>
"; $media = $this->stripPHP($media); $slice_content = str_replace("REX_LINK_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_LINK[$i]",$this->generateLink($this->CONT->getValue("rex_article_slice.link$i")),$slice_content); $slice_content = str_replace("REX_LINK_ID[$i]",$this->CONT->getValue("rex_article_slice.link$i"),$slice_content); // -- show:htmlentities -- edit:nl2br/htmlentities $slice_content = str_replace("REX_VALUE[$i]",$this->convertString($this->CONT->getValue("rex_article_slice.value$i")),$slice_content); // -- show:stripphp -- edit:stripphp $slice_content = str_replace("REX_HTML_VALUE[$i]",$this->stripPHP($this->CONT->getValue("rex_article_slice.value$i")),$slice_content); // -- show:stripphp -- edit:stripphp -- $slice_content = str_replace("REX_HTML_BR_VALUE[$i]",nl2br($this->stripPHP($this->CONT->getValue("rex_article_slice.value$i"))),$slice_content); // -- show:- -- edit:- $slice_content = str_replace("REX_PHP_VALUE[$i]",$this->CONT->getValue("rex_article_slice.value$i"),$slice_content); if ($this->CONT->getValue("rex_article_slice.value$i")!="") $slice_content = str_replace("REX_IS_VALUE[$i]","1",$slice_content); } $slice_content = str_replace("REX_PHP",$this->convertString2($this->CONT->getValue("rex_article_slice.php")),$slice_content); $slice_content = str_replace("REX_HTML",$this->convertString2($this->stripPHP($this->CONT->getValue("rex_article_slice.html"))),$slice_content); $slice_content = str_replace("REX_ARTICLE_ID",$this->article_id,$slice_content); $slice_content = str_replace("REX_CUR_CLANG",$this->clang,$slice_content); $slice_content = str_replace("REX_CATEGORY_ID",$this->category_id,$slice_content); // function in function_rex_modrewrite.inc.php if ($this->mode != "edit") $slice_content = $this->replaceLinks($slice_content); return $slice_content; } // ----- Slice loeschen damit Werte in den nächsten Slice nicht übernommen werden function sliceClear($slice_content) { global $REX_ACTION; for ($i=1;$i<11;$i++) { // ----------------------------- LIST BUTTONS // REX_FILELIST_BUTTON $media = ""; $media .= ""; $media .= ""; $media .= ""; $media .= ""; $media .= ""; $media .= "
". "". "
". "
". "
". "". "


"; $slice_content = str_replace("REX_MEDIALIST_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_MEDIALIST[$i]",$REX_ACTION[MEDIALIST][$i],$slice_content); // REX_LINKLIST_BUTTON $media = ""; $media = $this->stripPHP($media); $slice_content = str_replace("REX_LINKLIST_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_LINKLIST[$i]","",$slice_content); // ----------------------------- REX_MEDIA_BUTTON $media = ""; $media.= ""; $media.= ""; $media.= ""; $media.= ""; $media.= "
clang.");>clang.");>clang.")>
"; $media = $this->stripPHP($media); $slice_content = str_replace("REX_MEDIA_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_FILE[$i]",$REX_ACTION[FILE][$i],$slice_content); // ----------------------------- REX_LINK_BUTTON $link_name = ""; if ($REX_ACTION[LINK][$i]>0) { $db = new sql; $sql = "SELECT name FROM rex_article WHERE id=".$REX_ACTION[LINK][$i]." and clang=".$this->clang; $res = $db->get_array($sql); $link_name = $res[0][name]; } $media = ""; $media.= ""; $media.= ""; $media.= ""; $media.= "
clang.");>clang.");>
"; $media = $this->stripPHP($media); $slice_content = str_replace("REX_LINK_BUTTON[$i]",$media,$slice_content); $slice_content = str_replace("REX_LINK[$i]",$REX_ACTION[LINK][$i],$slice_content); $slice_content = str_replace("REX_LINK_ID[$i]",$REX_ACTION[LINK][$i],$slice_content); // ----------------------------- REX_ OTHER $slice_content = str_replace("REX_VALUE[$i]",htmlentities(stripslashes($REX_ACTION[VALUE][$i])),$slice_content); $slice_content = str_replace("REX_HTML_VALUE[$i]","",$slice_content); $slice_content = str_replace("REX_PHP_VALUE[$i]","",$slice_content); $slice_content = str_replace("REX_IS_VALUE[$i]","",$slice_content); } $slice_content = str_replace("REX_PHP",htmlentities(stripslashes($REX_ACTION[PHP])),$slice_content); $slice_content = str_replace("REX_HTML",htmlentities(stripslashes($REX_ACTION[HTML])),$slice_content); $slice_content = str_replace("REX_ARTICLE_ID","",$slice_content); $slice_content = str_replace("REX_CUR_CLANG","",$slice_content); $slice_content = str_replace("REX_CATEGORY_ID","",$slice_content); return $slice_content; } // ------------------------------------- CONVERT function stripPHP($content) { $content = str_replace("","?>",$content); return $content; } function convertString2($content) { if ($this->mode == "edit" && $this->slice_id == $this->ViewSliceId && $this->function=="edit") { return htmlentities($content); }elseif ($this->mode == "edit") { return nl2br(htmlentities($content)); }else { return $content; } } function convertString($content) { $content = str_replace("$","$",htmlentities($content)); if ($this->mode == "edit" && $this->slice_id == $this->ViewSliceId && $this->function=="edit") { return $content; }else { return nl2br($content); } } // ------------------------------------ / CONVERT function generateLink($id) { global $REX; if ($this->mode == "edit") { return $id; }else { if ($REX[GG]) return "aid$id".".php"; else return rex_getURL($id); } } function replaceLinks($content){ // -- preg match REX_LINK_INTERN[ARTICLEID] -- preg_match_all("/REX_LINK_INTERN\[([0-9]*)\]/im",$content,$matches); if($matches[0][0]!=''){ for($m=0;$mDB = 1; $this->logout = false; $this->message = ""; $this->system_id = "default"; $this->setLanguage(); } function setLanguage($lang = "en") { if ($lang == "de") { $this->text[10] = "Session beendet."; $this->text[20] = "ID nicht gefunden."; $this->text[30] = "Fehler beim Login."; $this->text[40] = "Bitte einloggen."; $this->text[50] = "Ausgeloggt."; }else { $this->text[10] = "your session is expired !"; $this->text[20] = "uid not found"; $this->text[30] = "login wrong"; $this->text[40] = "login please"; $this->text[50] = "You logged out."; } } function setSqlDb($DB) { $this->DB = $DB; } function setSysID($system_id) { $this->system_id = $system_id; } function setSessiontime($session_duration) { $this->session_duration = $session_duration; } function setLogin($usr_login,$usr_psw) { $this->usr_login = $usr_login; $this->usr_psw = $usr_psw; } function setLogout($logout) { $this->logout = $logout; } function setUserquery($login_query) { $this->user_query = $login_query; } function setLoginquery($user_query) { $this->login_query = $user_query; } function setUserID($uid) { $this->uid = $uid; } function setMessage($message) { $this->message = $message; } function checkLogin() { // wenn logout dann header schreiben und auf error seite verweisen // message schreiben $ok = false; if (!$this->logout) { if ($this->usr_login != "") { // wenn login daten eingegeben dann checken // auf error seite verweisen und message schreiben $this->USER = new sql($this->DB); $USR_LOGIN = $this->usr_login; $USR_PSW = $this->usr_psw; $query = str_replace("USR_LOGIN",$this->usr_login,$this->login_query); $query = str_replace("USR_PSW",$this->usr_psw,$query); // $this->USER->debugsql = 1; $this->USER->setQuery($query); if ($this->USER->getRows() == 1) { $ok = true; $_SESSION[UID][$this->system_id] = $this->USER->getValue($this->uid); // Erfolgreicher Login in der DB vermerken $sql = new sql(); $sql->setQuery( 'UPDATE rex_user SET lasttrydate ="'. time() .'" WHERE login ="'. $this->usr_login .'"'); }else { $this->message = $this->text[30]; $_SESSION[UID][$this->system_id] = ""; // session_unregister("REX_SESSION"); } }elseif($_SESSION[UID][$this->system_id]!="") { // wenn kein login und kein logout dann nach sessiontime checken // message schreiben und falls falsch auf error verweisen $this->USER = new sql($this->DB); $query = str_replace("USR_UID",$_SESSION[UID][$this->system_id],$this->user_query); // $this->USER->debugsql = 1; $this->USER->setQuery($query); if ($this->USER->getRows() == 1) { // echo $REX_SESSION[ST][$this->system_id]." + ".$this->session_duration." > ".time(); if (($_SESSION[ST][$this->system_id]+$this->session_duration)>time()) { $ok = true; $_SESSION[UID][$this->system_id] = $this->USER->getValue($this->uid); }else { $this->message = $this->text[10]; } }else { $this->message = $this->text[20]; } }else { $this->message = $this->text[40]; $ok = false; } }else { $this->message = $this->text[50]; $_SESSION[UID][$this->system_id] = ""; // session_unregister("REX_SESSION"); } if ($ok) { // wenn alles ok dann REX[UID][system_id) schreiben $_SESSION[ST][$this->system_id] = time(); //session_register("REX_SESSION"); // $_SESSION['REX_SESSION'] = $REX_SESSION; }else { // wenn nicht, dann UID loeschen und error seite $_SESSION[ST][$this->system_id] = ""; $_SESSION[UID][$this->system_id] = ""; // header("Location: $this->error_page"."&FORM[loginmessage]=".urlencode($this->message)); // echo $this->message; } return $ok; } function getValue($value) { return $this->USER->getValue($value); } } ?>$var){ $this->$key = $params[$key]; } } } /* * Nothing but a bugfix ;) * */ function setClang($clang) { $this->clang = $clang; } /* * Class Function: * Returns Object Value */ function getValue($value) { if(substr($value,0,1)!='_'){ $value = "_".$value; } return $this->$value; } /* * CLASS Function: * Returns an Array containing article field names */ function getClassVars(){ $class_vars = get_class_vars('OORedaxo'); foreach($class_vars as $key=>$var){ if(substr($key,1)=='_'){ $class_vars[$key] = substr($key,1); } } return $class_vars; } /* * CLASS Function: * Converts Genernated Array to OOBase Format Array */ function convertGeneratedArray($generatedArray,$clang){ $OORedaxoArray['_id'] = $generatedArray['article_id'][$clang]; $OORedaxoArray['_clang'] = $clang; foreach($generatedArray as $key=>$var){ $OORedaxoArray['_'.$key]=$var[$clang]; } unset($OORedaxoArray['_article_id']); return $OORedaxoArray; } /* * Accessor Method: * returns the clang of the category */ function getClang() { return $this->_clang; } /* * Object Helper Function: * Returns a url for linking to this article */ function getUrl() { return rex_getUrl($this->getId(),$this->getClang()); } /* * Accessor Method: * returns the id of the article */ function getId() { return $this->_id; } /* * Accessor Method: * returns the id of the article */ function getParentId() { return $this->_re_id; } /* * Accessor Method: * returns the name of the article */ function getName() { return $this->_name; } /* * Accessor Method: * returns the name of the article */ function getFile() { return $this->_file; } /* * Accessor Method: * returns the Type ID of the article */ function getTypeId() { return $this->_type_id; } /* * Accessor Method: * returns the article description. */ function getDescription() { return $this->_description; } /* * Accessor Method: * returns the article priority */ function getPriority() { return $this->_prior; } /* * Accessor Method: * returns true if article is online. */ function isOnline() { return $this->_status == 1 ? true : false; } /* * Accessor Method: * Returns a link to this article * * @param [$attributes] array Attribute die dem Link hinzugefügt werden sollen. Default: null * @param [$sorround_tag] string HTML-Tag-Name mit dem der Link umgeben werden soll, z.b. 'li', 'div'. Default: null */ function toLink( $attributes = null, $sorround_tag = null, $sorround_attributes = null) { $link = '_toAttributeString( $attributes) .'>'. $this->getName() .''; if ( $sorround_tag !== null && is_string( $sorround_tag)) { $link = '<'. $sorround_tag . $this->_toAttributeString( $sorround_attributes) .'>'. $link .''; } return $link; } function _toAttributeString( $attributes) { $attr = ''; if ( $attributes !== null && is_array( $attributes)) { foreach ( $attributes as $name => $value) { $attr .= ' '. $name .'="'. $value .'"'; } } return $attr; } /* * Object Helper Function: * Returns a String representation of this object * for debugging purposes. */ function toString() { return $this->_id.", ".$this->_name.", ".($this->isOnline() ? "online" : "offline"); } } ?> isOnline()){ $catlist[]= $category; } } else { $catlist[]= $category; } } return $catlist; } else { return null; } } else { return null; } } /* * CLASS Function: * Return a list of categories which names match the * search string. For now the search string can be either * a simple name or a string containing SQL search placeholders * that you would insert into a 'LIKE '%...%' statement. * * Returns an array of OORedaxo objects. */ function searchCategoriesByName($a_name, $ignore_offlines = false, $clang = false) { return OOArticle::searchArticlesByName($a_name,$ignore_offlines,$clang,true); } /* * CLASS Function: * Return a list of top level categories, ie. * categories that have no parent. * Returns an array of OOCategory objects sorted by $prior. * * If $ignore_offlines is set to TRUE, * all categories with status 0 will be * excempt from this list! */ //function getRootCategories($ignore_offlines = false) { function getRootCategories($ignore_offlines = false, $clang = false){ global $REX; if($clang === false) $clang = $GLOBALS[REX][CUR_CLANG]; return OOCategory::getChildrenById(0,$ignore_offlines,$clang); } /* * Object Function: * Return a list of all subcategories. * Returns an array of OORedaxo objects sorted by $prior. * * If $ignore_offlines is set to TRUE, * all categories with status 0 will be * excempt from this list! */ function getChildren($ignore_offlines = false, $clang = false) { global $REX; if($clang === false) $clang = $GLOBALS[REX][CUR_CLANG]; return OOCategory::getChildrenById($this->_id,$ignore_offlines,$clang); } /* * Object Function: * Returns the parent category */ function getParent() { return OOCategory::getCategoryById($this->re_id); } /* * Object Function: * Returns TRUE if this category is the direct * parent of the other category. */ function isParent($other_cat) { // return $this->_id == $other_cat->_re_category_id; } /* * Object Function: * Returns TRUE if this category is an ancestor * (parent, grandparent, greatgrandparent, etc) * of the other category. */ function isAncestor($other_cat) { // TODO! return false; } /* * Object Function: * Return a list of articles in this category * Returns an array of OOArticle objects sorted by $prior. * * If $ignore_offlines is set to TRUE, * all articles with status 0 will be * excempt from this list! */ function getArticles($ignore_offlines = true) { return OOArticle::getArticlesOfCategory($this->_id, $ignore_offlines); } /* * Object Function: * Return the start article for this category */ function getStartArticle() { return OOArticle::getCategoryStartArticle($this->_id); } /* * Accessor Method: * returns the name of the article */ function getName() { return $this->_catname; } } ?>setQuery("select ".implode(',',OORedaxo::getClassVars())." from rex_article where name like '$article_name' AND clang='$clang' $offline $oocat"); for ($i = 0; $i < $sql->getRows(); $i++) { foreach(OORedaxo::getClassVars() as $var){ $article_data["_".$var] = $sql->getValue($var); } $artlist[] = new OOArticle($article_data); $sql->next(); } return $artlist; } /* * CLASS Function: * Return a list of articles which have a certain type. * * Returns an array of OORedaxo objects. */ function getArticlesByType( $article_type_id, $ignore_offlines = false, $clang = false ) { global $REX; if($clang === false) $clang = $REX[CUR_CLANG]; $offline = $ignore_offlines ? " and status = 1 " : ""; $artlist = array(); $sql = new sql; $sql->setQuery("select ".implode(',',OORedaxo::getClassVars())." FROM rex_article WHERE type_id = '$article_type_id' AND clang='$clang' $offline"); for ($i = 0; $i < $sql->getRows(); $i++) { foreach(OORedaxo::getClassVars() as $var){ $article_data['_'.$var] = $sql->getValue($var); } $artlist[] = new OOArticle($article_data); $sql->next(); } return $artlist; } /* * CLASS Function: * Return the site wide start article */ function getSiteStartArticle($clang=false) { global $REX; if($clang === false) $clang = $REX[CUR_CLANG]; return OOArticle::getArticleById($REX['STARTARTIKEL_ID'],$clang); } /* * CLASS Function: * Return start article for a certain category */ function getCategoryStartArticle($a_category_id, $clang = false) { global $REX; if($clang === false) $clang = $GLOBALS[REX][CUR_CLANG]; return OOArticle::getArticleById($a_category_id,$clang); } /* * CLASS Function: * Return a list of articles for a certain category */ function getArticlesOfCategory($a_category_id, $ignore_offlines = false, $clang = false) { global $REX; if($clang === false) $clang = $GLOBALS[REX][CUR_CLANG]; $articlelist = $REX[HTDOCS_PATH]."redaxo/include/generated/articles/".$a_category_id.".".$clang.".alist"; if(file_exists($articlelist)){ include($articlelist); if(is_array($REX[RE_ID][$a_category_id])){ foreach($REX[RE_ID][$a_category_id] as $var){ $article = OOArticle::getArticleById($var,$clang); if($ignore_offlines){ if($article->isOnline()){ $artlist[]= $article; } } else { $artlist[]= $article; } } return $artlist; } else { return null; } } else { return null; } } /* * CLASS Function: * Return a list of top-level articles */ function getRootArticles($ignore_offlines = false, $clang = false) { global $REX; if($clang === false) $clang = $GLOBALS[REX][CUR_CLANG]; return OOArticle::getArticlesOfCategory(0,$ignore_offlines,$clang); } /* * Accessor Method: * returns true if this Article is the Startpage for the category. */ function isStartPage() { return $this->_startpage; } /* * Accessor Method: * returns true if this Article is the Startpage for the entire site. */ function isSiteStartArticle() { global $REX; return $this->_id == $REX[STARTARTIKEL_ID]; } } ?>, May 2004 */ class OOArticleSlice { var $_id; var $_re_article_slice_id; var $_value; var $_file; var $_link; var $_php; var $_html; var $_article_id; var $_modultyp_id; /* * Constructor */ function OOArticleSlice($id,$re_article_slice_id,$value1,$value2, $value3,$value4,$value5,$value6,$value7,$value8,$value9,$value10, $file1,$file2,$file3,$file4,$file5,$file6,$file7,$file8,$file9, $file10,$link1,$link2,$link3,$link4,$link5,$link6,$link7,$link8, $link9,$link10,$php,$html,$article_id,$modultyp_id) { $this->_id = $id; $this->_re_article_slice_id = $re_article_slice_id; $this->_value = array(); $this->_value[1] = $value1; $this->_value[2] = $value2; $this->_value[3] = $value3; $this->_value[4] = $value4; $this->_value[5] = $value5; $this->_value[6] = $value6; $this->_value[7] = $value7; $this->_value[8] = $value8; $this->_value[9] = $value9; $this->_value[10] = $value10; $this->_file = array(); $this->_file[1] = $file1; $this->_file[2] = $file2; $this->_file[3] = $file3; $this->_file[4] = $file4; $this->_file[5] = $file5; $this->_file[6] = $file6; $this->_file[7] = $file7; $this->_file[8] = $file8; $this->_file[9] = $file9; $this->_file[10] = $file10; $this->_link = array(); $this->_link[1] = $link1; $this->_link[2] = $link2; $this->_link[3] = $link3; $this->_link[4] = $link4; $this->_link[5] = $link5; $this->_link[6] = $link6; $this->_link[7] = $link7; $this->_link[8] = $link8; $this->_link[9] = $link9; $this->_link[10] = $link10; $this->_php = $php; $this->_html = $html; $this->_article_id = $article_id; $this->_modultyp_id = $modultyp_id; } /* * CLASS Function: * Return an ArticleSlice by its id * Returns an OOArticleSlice object */ function getArticleSliceById($an_id) { $sql = new sql; $query = <<setQuery($query); if ($sql->getRows() == 1) { return new OOArticleSlice( $sql->getValue("id"),$sql->getValue("re_article_slice_id"),$sql->getValue("value1"), $sql->getValue("value2"),$sql->getValue("value3"),$sql->getValue("value4"), $sql->getValue("value5"),$sql->getValue("value6"),$sql->getValue("value7"), $sql->getValue("value8"),$sql->getValue("value9"),$sql->getValue("value10"), $sql->getValue("file1"),$sql->getValue("file2"),$sql->getValue("file3"), $sql->getValue("file4"),$sql->getValue("file5"),$sql->getValue("file6"), $sql->getValue("file7"),$sql->getValue("file8"),$sql->getValue("file9"), $sql->getValue("file10"),$sql->getValue("link1"),$sql->getValue("link2"), $sql->getValue("link3"),$sql->getValue("link4"),$sql->getValue("link5"), $sql->getValue("link6"),$sql->getValue("link7"),$sql->getValue("link8"), $sql->getValue("link9"),$sql->getValue("link10"),$sql->getValue("php"), $sql->getValue("html"),$sql->getValue("article_id"),$sql->getValue("modultyp_id") ); } return null; } /* * CLASS Function: * Return the first slice for an article. * This can then be used to iterate over all the * slices in the order as they appear using the * getNextSlice() function. * Returns an OOArticleSlice object */ function getFirstSliceForArticle($an_article_id) { $sql = new sql; $query = <<setQuery($query); if ($sql->getRows() == 1) { return new OOArticleSlice( $sql->getValue("id"),$sql->getValue("re_article_slice_id"),$sql->getValue("value1"), $sql->getValue("value2"),$sql->getValue("value3"),$sql->getValue("value4"), $sql->getValue("value5"),$sql->getValue("value6"),$sql->getValue("value7"), $sql->getValue("value8"),$sql->getValue("value9"),$sql->getValue("value10"), $sql->getValue("file1"),$sql->getValue("file2"),$sql->getValue("file3"), $sql->getValue("file4"),$sql->getValue("file5"),$sql->getValue("file6"), $sql->getValue("file7"),$sql->getValue("file8"),$sql->getValue("file9"), $sql->getValue("file10"),$sql->getValue("link1"),$sql->getValue("link2"), $sql->getValue("link3"),$sql->getValue("link4"),$sql->getValue("link5"), $sql->getValue("link6"),$sql->getValue("link7"),$sql->getValue("link8"), $sql->getValue("link9"),$sql->getValue("link10"),$sql->getValue("php"), $sql->getValue("html"),$sql->getValue("article_id"),$sql->getValue("modultyp_id") ); } return null; } /* * CLASS Function: * Return all slices for an article that have a certain * module type. * Returns an array of OOArticleSlice objects */ function getSlicesForArticleOfType($an_article_id, $a_type_id) { $sql = new sql; $query = <<setQuery($query); $slices = array(); for ($i = 0; $i < $sql->getRows(); $i++) { $slices[] = new OOArticleSlice( $sql->getValue("id"),$sql->getValue("re_article_slice_id"),$sql->getValue("value1"), $sql->getValue("value2"),$sql->getValue("value3"),$sql->getValue("value4"), $sql->getValue("value5"),$sql->getValue("value6"),$sql->getValue("value7"), $sql->getValue("value8"),$sql->getValue("value9"),$sql->getValue("value10"), $sql->getValue("file1"),$sql->getValue("file2"),$sql->getValue("file3"), $sql->getValue("file4"),$sql->getValue("file5"),$sql->getValue("file6"), $sql->getValue("file7"),$sql->getValue("file8"),$sql->getValue("file9"), $sql->getValue("file10"),$sql->getValue("link1"),$sql->getValue("link2"), $sql->getValue("link3"),$sql->getValue("link4"),$sql->getValue("link5"), $sql->getValue("link6"),$sql->getValue("link7"),$sql->getValue("link8"), $sql->getValue("link9"),$sql->getValue("link10"),$sql->getValue("php"), $sql->getValue("html"),$sql->getValue("article_id"),$sql->getValue("modultyp_id") ); $sql->next(); } return $slices; } /* * Object Function: * Return the next slice for this article * Returns an OOArticleSlice object. */ function getNextSlice() { $sql = new sql; $query = <<_id} EOD; $sql->setQuery($query); if ($sql->getRows() == 1) { return new OOArticleSlice( $sql->getValue("id"),$sql->getValue("re_article_slice_id"),$sql->getValue("value1"), $sql->getValue("value2"),$sql->getValue("value3"),$sql->getValue("value4"), $sql->getValue("value5"),$sql->getValue("value6"),$sql->getValue("value7"), $sql->getValue("value8"),$sql->getValue("value9"),$sql->getValue("value10"), $sql->getValue("file1"),$sql->getValue("file2"),$sql->getValue("file3"), $sql->getValue("file4"),$sql->getValue("file5"),$sql->getValue("file6"), $sql->getValue("file7"),$sql->getValue("file8"),$sql->getValue("file9"), $sql->getValue("file10"),$sql->getValue("link1"),$sql->getValue("link2"), $sql->getValue("link3"),$sql->getValue("link4"),$sql->getValue("link5"), $sql->getValue("link6"),$sql->getValue("link7"),$sql->getValue("link8"), $sql->getValue("link9"),$sql->getValue("link10"),$sql->getValue("php"), $sql->getValue("html"),$sql->getValue("article_id"),$sql->getValue("modultyp_id") ); } return null; } /* * CLASS function: * Return all slices that match the search string * Returns an array of OOArticleSlice objects */ function fullTextSearch($searchstring) { // TODO return array(); } /* * Object Function: */ function getPreviousSlice() { return OOArticleSlice::getArticleSliceById($this->_re_article_slice_id); } function getArticle() { return OOArticle::getArticleById($this->_article_id); } function getId() { return $this->_id; } function getValue($index) { return $this->_value[$index]; } function getLink($index) { return $this->_link[$index]; } function getLinkUrl($index) { return $REX['WWW_PATH']."index.php?article_id=".$this->getLink($index); } function getFile($index) { return $this->_file[$index]; } function getFileUrl($index) { return $REX['MEDIAFOLDER']."/".$this->getFile($index); } function getHtml() { return $this->_html; } function getPhp() { return $this->_php; } } ?>