function getTemplate()
 {
     $file = $this->getFile();
     if (!$file) {
         return false;
     }
     return rex_get_file_contents($file);
 }
/**
 * Sendet eine Datei zum Client
 *
 * @param $file string Pfad zur Datei
 * @param $contentType ContentType der Datei
 * @param $environment string Die Umgebung aus der der Inhalt gesendet wird
 * (frontend/backend)
 */
function rex_send_file($file, $contentType, $environment = 'backend')
{
    global $REX;
    // Cachen für Dateien aktivieren
    $temp = $REX['USE_LAST_MODIFIED'];
    $REX['USE_LAST_MODIFIED'] = true;
    header('Content-Type: ' . $contentType);
    header('Content-Disposition: inline; filename="' . basename($file) . '"');
    $content = rex_get_file_contents($file);
    $cacheKey = md5($content . $file . $contentType . $environment);
    rex_send_content($content, filemtime($file), $cacheKey, $environment);
    // Setting zurücksetzen
    $REX['USE_LAST_MODIFIED'] = $temp;
}
 function getTemplate()
 {
     if ($this->getId() < 1) {
         return FALSE;
     }
     $file = $this->getFilePath($this->getId());
     if (file_exists($file)) {
         return rex_get_file_contents($file);
     } else {
         if ($this->generate()) {
             return rex_get_file_contents($file);
         }
     }
     return FALSE;
 }
 function __readTar($filename = '')
 {
     // Set the filename to load
     if (!$filename) {
         $filename = $this->filename;
     }
     // Read in the TAR file
     //    $fp = fopen($filename,"rb");
     //    $this->tar_file = fread($fp,filesize($filename));
     //    fclose($fp);
     // STM: hier mit get_file_contents ist viel schneller
     $this->tar_file = rex_get_file_contents($filename);
     if ($this->tar_file[0] == chr(31) && $this->tar_file[1] == chr(139) && $this->tar_file[2] == chr(8)) {
         if (!function_exists("gzinflate")) {
             return false;
         }
         $this->isGzipped = TRUE;
         $this->tar_file = gzinflate(substr($this->tar_file, 10, -4));
     }
     // Parse the TAR file
     $this->__parseTar();
     return true;
 }
/**
 * Ändert eine Clang
 *
 * @param $id   Id der Clang
 * @param $name Name der Clang
 */
function rex_editCLang($id, $name)
{
    global $REX;
    $REX['CLANG'][$id] = $name;
    $file = $REX['INCLUDE_PATH'] . "/clang.inc.php";
    $cont = rex_get_file_contents($file);
    $cont = ereg_replace("(REX\\['CLANG'\\]\\['{$id}\\'].?\\=.?)[^;]*", "\\1\"" . $name . "\"", $cont);
    rex_put_file_contents($file, $cont);
    $edit = new rex_sql();
    $edit->setQuery("update " . $REX['TABLE_PREFIX'] . "clang set name='{$name}' where id='{$id}'");
    // ----- EXTENSION POINT
    rex_register_extension_point('CLANG_UPDATED', '', array('id' => $id, 'name' => $name));
}
Пример #6
0
$fromname = rex_post('fromname', 'string', $testMailer->FromName);
$from = rex_post('from', 'string', $testMailer->From);
$confirmto = rex_post('confirmto', 'string', $testMailer->ConfirmReadingTo);
$mailer = rex_post('mailer', 'string', $testMailer->Mailer);
$host = rex_post('host', 'string', $testMailer->Host);
$charset = rex_post('charset', 'string', $testMailer->CharSet);
$wordwrap = rex_post('wordwrap', 'int', $testMailer->WordWrap);
$encoding = rex_post('encoding', 'string', $testMailer->Encoding);
$priority = rex_post('priority', 'int', $testMailer->Priority);
$message = '';
if (rex_post('btn_save', 'string') != '') {
    $file = $REX['INCLUDE_PATH'] . '/addons/phpmailer/classes/class.rex_mailer.inc.php';
    $message = rex_is_writable($file);
    if ($message === true) {
        $message = $I18N_A93->msg('config_saved_error');
        if ($file_content = rex_get_file_contents($file)) {
            $template = "// --- DYN\n      \$this->From             = '" . $from . "';\n      \$this->FromName         = '" . $fromname . "';\n      \$this->ConfirmReadingTo = '" . $confirmto . "';\n      \$this->Mailer           = '" . $mailer . "';\n      \$this->Host             = '" . $host . "';\n      \$this->CharSet          = '" . $charset . "';\n      \$this->WordWrap         = " . $wordwrap . ";\n      \$this->Encoding         = '" . $encoding . "';\n      \$this->Priority         = " . $priority . ";\n      // --- /DYN";
            $file_content = ereg_replace("(\\/\\/.---.DYN.*\\/\\/.---.\\/DYN)", $template, $file_content);
            if (rex_put_file_contents($file, $file_content)) {
                $message = $I18N_A93->msg('config_saved_successful');
            }
        }
    }
}
$sel_mailer = new rex_select();
$sel_mailer->setId('mailer');
$sel_mailer->setName('mailer');
$sel_mailer->setSize(1);
$sel_mailer->setSelected($mailer);
foreach (array('mail', 'sendmail', 'smtp') as $type) {
    $sel_mailer->addOption($type, $type);
Пример #7
0
 function save($name, $success, $message = '', $id = null)
 {
     global $REX;
     $year = date('Y');
     $month = date('m');
     // in den Log-Dateien festes Datumsformat verwenden
     // wird bei der Ausgabe entsprechend der lokalen Einstellungen umgewandelt
     // rex_formatter nicht verwenden, da im Frontend nicht verfuegbar
     $newline = date('Y-m-d H:i');
     if ($success) {
         $newline .= ' | SUCCESS | ';
     } else {
         $newline .= ' |  ERROR  | ';
     }
     if (!$id) {
         $id = '--';
     } else {
         $id = str_pad($id, 2, ' ', STR_PAD_LEFT);
     }
     $newline .= $id . ' | ' . $name;
     if ($message) {
         $newline .= ' | ' . str_replace(array("\r\n", "\n"), ' | ', trim(strip_tags($message)));
     }
     $dir = REX_CRONJOB_LOG_FOLDER . $year;
     if (!is_dir($dir)) {
         mkdir($dir);
         chmod($dir, $REX['DIRPERM']);
     }
     $content = '';
     $file = $dir . '/' . $year . '-' . $month . '.log';
     if (file_exists($file)) {
         $content = rex_get_file_contents($file);
     }
     $content = $newline . "\n" . $content;
     return rex_put_file_contents($file, $content);
 }
Пример #8
0
 * @author <a href="http://www.yakamara.de">www.yakamara.de</a>
 */
rex_title('XForm', $REX['ADDON']['xform']['SUBPAGES']);
$searchtext = 'module:xform_basic_out';
$gm = rex_sql::factory();
$gm->setQuery('select * from rex_module where ausgabe LIKE "%' . $searchtext . '%"');
$module_id = 0;
$module_name = '';
foreach ($gm->getArray() as $module) {
    $module_id = $module['id'];
    $module_name = $module['name'];
}
if (isset($_REQUEST['install']) && $_REQUEST['install'] == 1) {
    $xform_module_name = 'XForm Formbuilder';
    $in = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/xform/plugins/setup/module/module_in.inc');
    $out = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/xform/plugins/setup/module/module_out.inc');
    $mi = rex_sql::factory();
    // $mi->debugsql = 1;
    $mi->setTable('rex_module');
    $mi->setValue('eingabe', addslashes($in));
    $mi->setValue('ausgabe', addslashes($out));
    if (isset($_REQUEST['module_id']) && $module_id == $_REQUEST['module_id']) {
        $mi->setWhere('id="' . $module_id . '"');
        $mi->update();
        echo rex_info('Modul "' . $module_name . '" wurde aktualisiert');
    } else {
        $mi->setValue('name', $xform_module_name);
        $mi->insert();
        $module_id = (int) $mi->getLastId();
        $module_name = $xform_module_name;
        echo rex_info('XForm Modul wurde angelegt unter "' . $xform_module_name . '"');
Пример #9
0
<?php

/**
 * News Addon 
 * @author Jens Fuchs <fuchs at d-mind.de>
 * @project Redaxo-News-Addon
 * @date 05.11.2012
 */
$mypage = 'news';
$news_input = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/news_input.module.phps');
$news_output = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/news_output.module.phps');
$rss_input = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/rss_input.module.phps');
$rss_output = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/rss_output.module.phps');
$rssGetter_input = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/rssGetter_input.module.phps');
$rssGetter_output = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/rssGetter_output.module.phps');
?>

<div class="rex-addon-output">
	<h2 class="rex-hl2">Einrichtung der Module</h2>
	<div class="rex-addon-content">
		<p class="rex-tx1">Bitte ein neues Modul anlegen, und für Ein- und Ausgabe den Code von unten hineinkopieren.<br />
        Aktuell gibt es drei Module: Newsausgabe, RSS-Ausgabe und RSS-Import eines fremden RSS.<br />
        <br />
        Zu beachten ist, dass bei der RSS-Ausgabe ein leeres Template dem Artikel zuzuweisen ist, also etwas in der Form: 
        <?php 
rex_highlight_string('echo $this->getArticle();');
?>
</p>
	</div>
	<div class="redaxo-addon-content">
       <ul>
Пример #10
0
          <input type="text" value="' . $redaxo_user_pass . '" id="redaxo_user_pass" name="redaxo_user_pass"' . rex_tabindex() . '/>
        </p>';
    if ($user_sql->getRows() > 0) {
        echo '
        <p>
          <input class="rex-chckbx" type="checkbox" id="noadmin" name="noadmin" value="1"' . rex_tabindex() . '/>
          <label class="rex-lbl-right" for="noadmin">' . $I18N->msg("setup_048") . '</label>
        </p>';
    }
    echo '
        <p>
          <input class="rex-sbmt" type="submit" value="' . $I18N->msg("setup_049") . '"' . rex_tabindex() . ' />
        </p>

      </fieldset>
    </form>';
}
// ---------------------------------- MODUS 5 | Setup verschieben ...
if ($checkmodus == 5) {
    $master_file = $REX['INCLUDE_PATH'] . '/master.inc.php';
    $cont = rex_get_file_contents($master_file);
    $cont = ereg_replace("(REX\\['SETUP'\\].?\\=.?)[^;]*", '\\1false', $cont);
    if (rex_put_file_contents($master_file, $cont)) {
        $errmsg = "";
    } else {
        $errmsg = $I18N->msg('setup_050');
    }
    rex_setup_title($I18N->msg('setup_step5'));
    echo $I18N->msg('setup_051', '<h2>', '</h2>', '<a href="index.php">', '</a>');
}
echo '</div>';
Пример #11
0
                    echo rex_warning('Template "' . htmlspecialchars($template[2]) . '" konnte nicht aktualisiert werden, da diese nicht gefunden wurde.');
                }
            } else {
                $mi->insert();
                echo rex_info('Template "' . htmlspecialchars($template[2]) . '" wurde angelegt.');
            }
            rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0);
        }
    }
}
// ***** ADD EMAIL
if ($func == "email" && $request_email != "") {
    $emails = $REX["ADDON"]["community"]["plugins"]["setup"]["emails"];
    foreach ($emails as $email) {
        if ($request_email == $email[0] . "." . $email[1]) {
            $body = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/community/plugins/" . $email[0] . "/emails/" . $email[1] . ".email");
            $body = str_replace("\r", "\n", $body);
            $body = str_replace("\n\n", "\n", $body);
            foreach ($REX["ADDON"]["community"]["plugins"]["setup"]["ids"] as $k) {
                $body = str_replace('###' . $k . '###', constant($k), $body);
            }
            $body = str_replace('###REXCOM_SERVER###', $REX['SERVER'], $body);
            $body = str_replace('###REXCOM_EMAIL###', $REX['ERROR_EMAIL'], $body);
            $mi = new rex_sql();
            // $mi->debugsql = 1;
            $mi->setTable("rex_xform_email_template");
            $mi->setValue("name", addslashes($email[2]));
            $mi->setValue("subject", addslashes($email[3]));
            $mi->setValue("mail_from", addslashes($email[4]));
            $mi->setValue("mail_from_name", addslashes($email[5]));
            $mi->setValue("body", addslashes($body));
Пример #12
0
    public static function getDebugInfo($articleId = 0)
    {
        global $I18N, $REX;
        if ($articleId != 0) {
            self::initArticle($articleId);
        }
        if (!OOArticle::isValid(self::$curArticle)) {
            return '';
        }
        $out = '<div id="seo42-debug">';
        $out .= '<h1>---------- SEO42 DEBUG BEGIN ----------<h1>';
        // general information
        $out .= '<h2>General Information</h2>';
        $out .= '<table>';
        $out .= '<tr><td class="left"><code>REDAXO Version</code></td><td class="right"><code>' . $REX['VERSION'] . '.' . $REX['SUBVERSION'] . '.' . $REX['MINORVERSION'] . '</code></td></tr>';
        $out .= '<tr><td class="left"><code>SEO42 Version</code></td><td class="right"><code>' . $REX['ADDON']['version']['seo42'] . '</code></td></tr>';
        $out .= '<tr><td class="left"><code>PHP Version</code></td><td class="right"><code>' . phpversion() . '</code></td></tr>';
        if (isset($REX['ADDON']['version']['community'])) {
            $out .= '<tr><td class="left"><code>Community Version</code></td><td class="right"><code>' . $REX['ADDON']['version']['community'] . '</code></td></tr>';
        }
        $out .= '</table>';
        // methods
        $out .= '<h2>Class Methods</h2>';
        $out .= '<table>';
        $out .= self::getDebugInfoRow('rex_getUrl', array(self::$curArticle->getId()));
        $out .= self::getDebugInfoRow('seo42::getUrl', array(self::$curArticle->getId()));
        $out .= self::getDebugInfoRow('seo42::getTrimmedUrl', array(self::$curArticle->getId()));
        $out .= self::getDebugInfoRow('seo42::getFullUrl', array(self::$curArticle->getId()));
        $out .= self::getDebugInfoRow('seo42::getTitle');
        $out .= self::getDebugInfoRow('seo42::getTitlePart');
        $out .= self::getDebugInfoRow('seo42::getDescription');
        $out .= self::getDebugInfoRow('seo42::getKeywords');
        $out .= self::getDebugInfoRow('seo42::getRobotRules');
        $out .= self::getDebugInfoRow('seo42::getCanonicalUrl');
        $out .= self::getDebugInfoRow('seo42::getArticleName');
        $out .= self::getDebugInfoRow('seo42::isStartArticle');
        $out .= self::getDebugInfoRow('seo42::getWebsiteName');
        $out .= self::getDebugInfoRow('seo42::getLangCode', array('0'));
        $out .= self::getDebugInfoRow('seo42::getLangSlug', array('0'));
        $out .= self::getDebugInfoRow('seo42::getLangName', array('0'));
        $out .= self::getDebugInfoRow('seo42::getOriginalLangName', array('0'));
        $out .= self::getDebugInfoRow('seo42::getServerProtocol');
        $out .= self::getDebugInfoRow('seo42::getBaseUrl');
        $out .= self::getDebugInfoRow('seo42::getServerUrl');
        $out .= self::getDebugInfoRow('seo42::getServer');
        $out .= self::getDebugInfoRow('seo42::getServerWithSubDir');
        $out .= self::getDebugInfoRow('seo42::getServerSubDir');
        $out .= self::getDebugInfoRow('seo42::isWwwServerUrl');
        $out .= self::getDebugInfoRow('seo42::hasTemplateBaseTag');
        $out .= self::getDebugInfoRow('seo42::isSubDirInstall');
        $out .= self::getDebugInfoRow('seo42::isMultiLangInstall');
        $out .= self::getDebugInfoRow('seo42::getLangCount');
        $out .= self::getDebugInfoRow('seo42::getTitleDelimiter');
        $out .= self::getDebugInfoRow('seo42::getUrlStart');
        $out .= self::getDebugInfoRow('seo42::has404ResponseFlag');
        $out .= self::getDebugInfoRow('seo42::getQueryString');
        $out .= self::getDebugInfoRow('seo42::getMediaDir');
        $out .= self::getDebugInfoRow('seo42::getMediaDirName');
        $out .= self::getDebugInfoRow('seo42::getMediaFile', array('image.png'));
        $out .= self::getDebugInfoRow('seo42::getMediaUrl', array('image.png'));
        $out .= self::getDebugInfoRow('seo42::getAbsoluteMediaFile', array('image.png'));
        $out .= self::getDebugInfoRow('seo42::getMediaAddonDir');
        $out .= self::getDebugInfoRow('seo42::getLangTags');
        $out .= self::getDebugInfoRow('seo42::getHtml');
        $out .= self::getDebugInfoRow('seo42::getImageTag', array('image.png', 'rex_mediapool_detail', '150', '100'));
        $out .= self::getDebugInfoRow('seo42::getImageManagerFile', array('image.png', 'rex_mediapool_detail'));
        $out .= self::getDebugInfoRow('seo42::getDownloadFile', array('doc.pdf'));
        $out .= self::getDebugInfoRow('seo42::getUrlString', array("The Hitchhiker's Guide to the Galaxy!"));
        $out .= self::getDebugInfoRow('seo42::getAnswer');
        $out .= '</table>';
        // settings
        $out .= '<h2>Settings</h2>';
        $out .= '<pre class="rex-code">';
        $out .= seo42_utils::print_r_pretty($REX['ADDON']['seo42']['settings'], true);
        $out .= '</pre>';
        // cached redirects
        $out .= '<h2>Cached Redirects</h2>';
        $out .= '<pre class="rex-code">';
        $out .= seo42_utils::print_r_pretty($REX['SEO42_CACHED_REDIRECTS'], true);
        $out .= '</pre>';
        // pathlist
        $out .= '<h2>Pathlist</h2>';
        $pathlistRoot = SEO42_PATHLIST;
        if (file_exists($pathlistRoot)) {
            $content = rex_get_file_contents($pathlistRoot);
            $out .= rex_highlight_string($content, true);
        } else {
            $out .= 'File not found: ' . $pathlistRoot;
        }
        // .htaccess
        $out .= '<h2>.htaccess</h2>';
        $htaccessRoot = $REX['FRONTEND_PATH'] . '/.htaccess';
        if (file_exists($htaccessRoot)) {
            $content = rex_get_file_contents($htaccessRoot);
            $out .= rex_highlight_string($content, true);
        } else {
            $out .= 'File not found: ' . $htaccessRoot;
        }
        $out .= '<h1>---------- SEO42 DEBUG END ----------</h1>';
        $out .= '</div>';
        $out .= '<style type="text/css">
					#seo42-debug h1 {
						font-size: 16px;
						margin: 10px 0;
					}

					#seo42-debug h2 {
						margin: 15px 0;
						font-size: 14px;
					}

					#seo42-debug .rex-code {
						border: 1px solid #F2353A;
					}

					#seo42-debug code,
					#seo42-debug .rex-code {
						color: #000;
						background: #FAF9F5;
					}

					#seo42-debug table {
						width: 100%;
						border-collapse: collapse;
						border-spacing: 0;
						background: #FAF9F5;
					}

					#seo42-debug table th,
					#seo42-debug table thead td {
						font-weight: bold;
					}

					#seo42-debug table td, 
					#seo42-debug table th {
						padding: 12px;
						border: 1px solid #F2353A;
						text-align: left;
					}

					#seo42-debug table td.left {
						width: 280px;
					}
				</style>';
        return $out;
    }
Пример #13
0
    <?php 
echo $I18N->msg('tinymce_help_module_input');
?>
    </p>
    <?php 
rex_highlight_string(rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/tinymce/modul_input.txt'));
?>
  </div>

</div>

<div class="rex-addon-output">

  <h2 class="rex-hl2"><?php 
echo $I18N->msg('tinymce_title_module_output');
?>
</h2>

  <div class="rex-addon-content">
    <p class="rex-tx1">
    <?php 
echo $I18N->msg('tinymce_help_module_output');
?>
    </p>
    <?php 
rex_highlight_string(rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/tinymce/modul_output.txt'));
?>
  </div>

</div>
Пример #14
0
function rex_replace_dynamic_contents($path, $content)
{
    if (file_exists($path) && ($fcontent = rex_get_file_contents($path))) {
        $content = "// --- DYN\n" . trim($content) . "\n// --- /DYN";
        $fcontent = preg_replace("@(\\/\\/.---.DYN.*\\/\\/.---.\\/DYN)@s", $content, $fcontent, -1, $count);
        return $count && rex_put_file_contents($path, $fcontent);
    }
    return false;
}
/**
 * Erstellt einen SQL Dump, der die aktuellen Datebankstruktur darstellt.
 * Dieser wird in der Datei $filename gespeichert.
 *
 * @return boolean TRUE wenn ein Dump erstellt wurde, sonst FALSE
 */
function rex_a1_export_db($filename, array $tables = null)
{
    global $REX, $I18N;
    $fp = @fopen($filename, 'w');
    if (!$fp) {
        return false;
    }
    // Im Frontend gibts kein I18N
    if (!is_object($I18N)) {
        $I18N = rex_create_lang($REX['LANG']);
    }
    $sql = rex_sql::factory();
    $nl = "\n";
    $insertSize = 5000;
    // ----- EXTENSION POINT
    rex_register_extension_point('A1_BEFORE_DB_EXPORT');
    // Versionsstempel hinzufügen
    fwrite($fp, '## Redaxo Database Dump Version ' . $REX['VERSION'] . $nl);
    fwrite($fp, '## Prefix ' . $REX['TABLE_PREFIX'] . $nl);
    fwrite($fp, '## charset ' . $I18N->msg('htmlcharset') . $nl . $nl);
    //  fwrite($fp, '/*!40110 START TRANSACTION; */'.$nl);
    if (is_null($tables)) {
        $tables = array();
        foreach (rex_sql::showTables(1, $REX['TABLE_PREFIX']) as $table) {
            if ($table != $REX['TABLE_PREFIX'] . 'user' && substr($table, 0, strlen($REX['TABLE_PREFIX'] . $REX['TEMP_PREFIX'])) != $REX['TABLE_PREFIX'] . $REX['TEMP_PREFIX']) {
                // Tabellen die mit rex_tmp_ beginnne, werden nicht exportiert!
                $tables[] = $table;
            }
        }
    }
    foreach ($tables as $table) {
        //---- export metadata
        $create = rex_sql::showCreateTable($table);
        fwrite($fp, "DROP TABLE IF EXISTS `{$table}`;\n");
        fwrite($fp, "{$create};\n");
        $fields = $sql->getArray("SHOW FIELDS FROM `{$table}`");
        foreach ($fields as $idx => $field) {
            if (preg_match('#^(bigint|int|smallint|mediumint|tinyint|timestamp)#i', $field['Type'])) {
                $fields[$idx] = 'int';
            } elseif (preg_match('#^(float|double|decimal)#', $field['Type'])) {
                $fields[$idx] = 'double';
            } elseif (preg_match('#^(char|varchar|text|longtext|mediumtext|tinytext)#', $field['Type'])) {
                $fields[$idx] = 'string';
            }
            // else ?
        }
        //---- export tabledata
        $start = 0;
        $max = $insertSize;
        do {
            $sql->freeResult();
            $sql->setQuery("SELECT * FROM `{$table}` LIMIT {$start},{$max}");
            if ($sql->getRows() > 0 && $start == 0) {
                fwrite($fp, "\nLOCK TABLES `{$table}` WRITE;");
                fwrite($fp, "\n/*!40000 ALTER TABLE `{$table}` DISABLE KEYS */;");
            } elseif ($sql->getRows() == 0) {
                break;
            }
            $start += $max;
            $values = array();
            while ($sql->hasNext()) {
                $record = array();
                foreach ($fields as $idx => $type) {
                    $column = $sql->getValue($idx);
                    switch ($type) {
                        case 'int':
                            $record[] = intval($column);
                            break;
                        case 'double':
                            $record[] = sprintf('%.10F', (double) $column);
                            break;
                        case 'string':
                        default:
                            $record[] = $sql->escape($column, "'", true);
                            break;
                    }
                }
                $values[] = $nl . '  (' . implode(',', $record) . ')';
                $sql->next();
            }
            if (!empty($values)) {
                $values = implode(',', $values);
                fwrite($fp, "\nINSERT INTO `{$table}` VALUES {$values};");
                unset($values);
            }
        } while ($sql->getRows() >= $max);
        if ($start > 0) {
            fwrite($fp, "\n/*!40000 ALTER TABLE `{$table}` ENABLE KEYS */;");
            fwrite($fp, "\nUNLOCK TABLES;\n\n");
        }
    }
    fclose($fp);
    $hasContent = true;
    // Den Dateiinhalt geben wir nur dann weiter, wenn es unbedingt notwendig ist.
    if (rex_extension_is_registered('A1_AFTER_DB_EXPORT')) {
        $content = rex_get_file_contents($filename);
        $hashBefore = md5($content);
        // ----- EXTENSION POINT
        $content = rex_register_extension_point('A1_AFTER_DB_EXPORT', $content);
        $hashAfter = md5($content);
        if ($hashAfter != $hashBefore) {
            rex_put_file_contents($filename, $content);
            $hasContent = !empty($content);
            unset($content);
        }
    }
    return $hasContent;
}
Пример #16
0
    function tinymce_generate_linkscript()
    {
        global $REX;
        while (ob_get_level()) {
            ob_end_clean();
        }
        if (function_exists('header_remove')) {
            header_remove();
        }
        header("Content-type: application/javascript");
        echo '/**
 * Addon TinyMCE Version ' . $REX['ADDON']['version']['tinymce'] . '
 */

// TinyMCE Popup interface
// ------------------------------------------------------------
';
        echo rex_get_file_contents($REX['HTDOCS_PATH'] . '/files/addons/tinymce/tiny_mce/tiny_mce_popup.js');
        echo "\n\n";
        $scriptout = rex_get_file_contents($REX['HTDOCS_PATH'] . '/files/addons/tinymce/rex.linkmap.js');
        echo tinymce_replace_vars($scriptout);
        echo "\n\n";
        die;
    }
 public function getCSS()
 {
     return rex_get_file_contents(dirname(__FILE__) . '/class.rex_checkbox.global.css');
 }
/**
 * 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;
}
    function getArticle($curctype = -1)
    {
        global $module_id, $REX_USER, $REX, $I18N;
        $this->ctype = $curctype;
        $sliceLimit = '';
        if ($this->getSlice) {
            //$REX['GG'] = 0;
            $sliceLimit = " AND " . $REX['TABLE_PREFIX'] . "article_slice.id = '" . $this->getSlice . "' ";
        }
        // ----- start: article caching
        ob_start();
        ob_implicit_flush(0);
        if ($REX['GG'] && !$this->viasql && !$this->getSlice) {
            if ($this->article_id != 0) {
                $this->contents = '';
                $article_content_file = $REX['INCLUDE_PATH'] . '/generated/articles/' . $this->article_id . '.' . $this->clang . '.content';
                if ($cont = rex_get_file_contents($article_content_file)) {
                    $this->contents = $cont;
                    eval($this->contents);
                }
            }
        } else {
            if ($this->article_id != 0) {
                // ---------- alle teile/slices eines artikels auswaehlen
                $sql = "SELECT " . $REX['TABLE_PREFIX'] . "module.id, " . $REX['TABLE_PREFIX'] . "module.name, " . $REX['TABLE_PREFIX'] . "module.ausgabe, " . $REX['TABLE_PREFIX'] . "module.eingabe, " . $REX['TABLE_PREFIX'] . "article_slice.*, " . $REX['TABLE_PREFIX'] . "article.re_id\r\n          FROM\r\n            " . $REX['TABLE_PREFIX'] . "article_slice\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "module ON " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id=" . $REX['TABLE_PREFIX'] . "module.id\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "article ON " . $REX['TABLE_PREFIX'] . "article_slice.article_id=" . $REX['TABLE_PREFIX'] . "article.id\r\n          WHERE\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.article_id='" . $this->article_id . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.clang='" . $this->clang . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article.clang='" . $this->clang . "'\r\n            " . $sliceLimit . "\r\n            ORDER BY " . $REX['TABLE_PREFIX'] . "article_slice.re_article_slice_id";
                $this->CONT = new rex_sql();
                $this->CONT->debugsql = 0;
                $this->CONT->setQuery($sql);
                $RE_CONTS = array();
                $RE_CONTS_CTYPE = array();
                $RE_MODUL_OUT = array();
                $RE_MODUL_IN = array();
                $RE_MODUL_ID = array();
                $RE_MODUL_NAME = array();
                $RE_C = array();
                // ---------- SLICE IDS/MODUL SETZEN - speichern der daten
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    $RE_CONTS[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.id');
                    $RE_CONTS_CTYPE[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.ctype');
                    $RE_MODUL_IN[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.eingabe');
                    $RE_MODUL_OUT[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.ausgabe');
                    $RE_MODUL_ID[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.id');
                    $RE_MODUL_NAME[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.name');
                    $RE_C[$this->CONT->getValue('re_article_slice_id')] = $i;
                    $this->CONT->next();
                }
                // ---------- moduleselect: nur module nehmen auf die der user rechte hat
                if ($this->mode == 'edit') {
                    $MODULE = new rex_sql();
                    $MODULE->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module order by name');
                    $MODULESELECT = new rex_select();
                    $MODULESELECT->setName('module_id');
                    $MODULESELECT->setSize('1');
                    $MODULESELECT->setAttribute('onchange', 'this.form.submit();');
                    $MODULESELECT->addOption('----------------------------  ' . $I18N->msg('add_block'), '');
                    for ($i = 0; $i < $MODULE->getRows(); $i++) {
                        if ($REX_USER->hasPerm('module[' . $MODULE->getValue('id') . ']') || $REX_USER->hasPerm('admin[]')) {
                            $MODULESELECT->addOption(rex_translate($MODULE->getValue('name'), NULL, FALSE), $MODULE->getValue('id'));
                        }
                        $MODULE->next();
                    }
                }
                // ---------- SLICE IDS SORTIEREN UND AUSGEBEN
                $I_ID = 0;
                $PRE_ID = 0;
                $LCTSL_ID = 0;
                $this->CONT->reset();
                $this->article_content = "";
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    // ----- ctype unterscheidung
                    if ($this->mode != "edit" && $i == 0) {
                        $this->article_content = "<?php if (\$this->ctype == '" . $RE_CONTS_CTYPE[$I_ID] . "' || (\$this->ctype == '-1')) { ?>";
                    }
                    // ------------- EINZELNER SLICE - AUSGABE
                    $this->CONT->counter = $RE_C[$I_ID];
                    $slice_content = "";
                    $SLICE_SHOW = TRUE;
                    if ($this->mode == "edit") {
                        $form_url = 'index.php';
                        if ($this->setanker) {
                            $form_url .= '#addslice';
                        }
                        $this->ViewSliceId = $RE_CONTS[$I_ID];
                        // ----- add select box einbauen
                        if ($this->function == "add" && $this->slice_id == $I_ID) {
                            $slice_content = $this->addSlice($I_ID, $module_id);
                        } else {
                            // ----- BLOCKAUSWAHL - SELECT
                            $MODULESELECT->setId("module_id" . $I_ID);
                            $slice_content = '
              <form action="' . $form_url . '" method="get" id="slice' . $RE_CONTS[$I_ID] . '">
                <fieldset>
                  <legend class="rex-lgnd"><span class="rex-hide">' . $I18N->msg("add_block") . '</span></legend>
                  <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                  <input type="hidden" name="page" value="content" />
                  <input type="hidden" name="mode" value="' . $this->mode . '" />
                  <input type="hidden" name="slice_id" value="' . $I_ID . '" />
                  <input type="hidden" name="function" value="add" />
                  <input type="hidden" name="clang" value="' . $this->clang . '" />
                  <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                  <p class="rex-slct">
                    ' . $MODULESELECT->get() . '
                    <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                  </p>

                </fieldset>
              </form>';
                        }
                        // ----- EDIT/DELETE BLOCK - Wenn Rechte vorhanden
                        if ($REX_USER->hasPerm("module[" . $RE_MODUL_ID[$I_ID] . "]") || $REX_USER->hasPerm("admin[]")) {
                            $msg = '';
                            if ($this->slice_id == $RE_CONTS[$I_ID] && $this->message != '') {
                                $msg = rex_warning($this->message);
                            }
                            $sliceUrl = 'index.php?page=content&amp;article_id=' . $this->article_id . '&amp;mode=edit&amp;slice_id=' . $RE_CONTS[$I_ID] . '&amp;clang=' . $this->clang . '&amp;ctype=' . $this->ctype . '%s#slice' . $RE_CONTS[$I_ID];
                            $listElements = array();
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=edit') . '" class="rex-clr-grn">' . $I18N->msg('edit') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=delete&amp;save=1') . '" class="rex-clr-red" onclick="return confirm(\'' . $I18N->msg('delete') . ' ?\')">' . $I18N->msg('delete') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            if ($REX_USER->hasPerm('moveSlice[]')) {
                                $moveUp = $I18N->msg('move_slice_up');
                                $moveDown = $I18N->msg('move_slice_down');
                                // upd stamp übergeben, da sonst ein block nicht mehrfach hintereindander verschoben werden kann
                                // (Links wären sonst gleich und der Browser lässt das klicken auf den gleichen Link nicht zu)
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=moveup') . '" title="' . $moveUp . '"><img src="media/file_up.gif" width="16" height="16" alt="' . $moveUp . '" /> <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=movedown') . '" title="' . $moveDown . '"><img src="media/file_down.gif" width="16" height="16" alt="' . $moveDown . '" /> <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            }
                            // ----- EXTENSION POINT
                            $listElements = rex_register_extension_point('ART_SLICE_MENU', $listElements, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID]));
                            $mne = $msg . '
			       	<div class="rex-cnt-editmode-slc">
                <p class="rex-flLeft">' . htmlspecialchars($RE_MODUL_NAME[$I_ID]) . '</p>
                <ul class="rex-flRight" id="rex-slc-mnu">
              ';
                            foreach ($listElements as $listElement) {
                                $mne .= '<li>' . $listElement . '</li>';
                            }
                            $mne .= '</ul></div>';
                            $slice_content .= $mne;
                            if ($this->function == "edit" && $this->slice_id == $RE_CONTS[$I_ID]) {
                                // **************** Aktueller Slice
                                // ----- PRE VIEW ACTION [EDIT]
                                $REX_ACTION = array();
                                // nach klick auf den übernehmen button,
                                // die POST werte übernehmen
                                if (rex_var::isEditEvent()) {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACRequestValues($REX_ACTION);
                                    }
                                } else {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACDatabaseValues($REX_ACTION, $this->CONT);
                                    }
                                }
                                // TODO: PreviewActions gibts nur im EditMode...?
                                if ($this->function == 'edit') {
                                    $modebit = '2';
                                } elseif ($this->function == 'delete') {
                                    $modebit = '4';
                                } else {
                                    $modebit = '1';
                                }
                                // pre-action and add
                                $ga = new rex_sql();
                                $ga->debugsql = 0;
                                $ga->setQuery('SELECT preview FROM ' . $REX['TABLE_PREFIX'] . 'module_action ma,' . $REX['TABLE_PREFIX'] . 'action a WHERE preview != "" AND ma.action_id=a.id AND module_id=' . $RE_MODUL_ID[$I_ID] . ' AND ((a.previewmode & ' . $modebit . ') = ' . $modebit . ')');
                                for ($t = 0; $t < $ga->getRows(); $t++) {
                                    $iaction = $ga->getValue('preview');
                                    // ****************** VARIABLEN ERSETZEN
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $iaction = $obj->getACOutput($REX_ACTION, $iaction);
                                    }
                                    eval('?>' . $iaction);
                                    // ****************** SPEICHERN FALLS NOETIG
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $obj->setACValues($this->CONT, $REX_ACTION);
                                    }
                                    $ga->next();
                                }
                                // ----- / PRE VIEW ACTION
                                $slice_content .= $this->editSlice($RE_CONTS[$I_ID], $RE_MODUL_IN[$I_ID], $RE_CONTS_CTYPE[$I_ID], $RE_MODUL_ID[$I_ID]);
                            } else {
                                // Modulinhalt ausgeben
                                $slice_content .= '
                <!-- *** OUTPUT OF MODULE-OUTPUT - START *** -->
                <div class="rex-cnt-slc-otp"><div class="rex-cnt-slc-otp2">
                  ' . $RE_MODUL_OUT[$I_ID] . '
                </div></div>
                <!-- *** OUTPUT OF MODULE-OUTPUT - END *** -->
                ';
                                $slice_content = $this->replaceVars($this->CONT, $slice_content);
                            }
                        } else {
                            // ----- hat keine rechte an diesem modul
                            $mne = '
			  	<div class="rex-cnt-editmode-slc">
                <p class="rex-flLeft" id="slice' . $RE_CONTS[$I_ID] . '">' . $RE_MODUL_NAME[$I_ID] . '</p>
                <ul class="rex-flRight">
                  <li>' . $I18N->msg('no_editing_rights') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></li>
                </ul>
				  </div>';
                            $slice_content .= $mne . $RE_MODUL_OUT[$I_ID];
                            $slice_content = $this->replaceVars($this->CONT, $slice_content);
                        }
                    } else {
                        // ----- wenn mode nicht edit
                        if ($this->getSlice) {
                            while (list($k, $v) = each($RE_CONTS)) {
                                $I_ID = $k;
                            }
                        }
                        $slice_content .= $RE_MODUL_OUT[$I_ID];
                        $slice_content = $this->replaceVars($this->CONT, $slice_content);
                    }
                    // --------------- ENDE EINZELNER SLICE
                    // --------------- EP: SLICE_SHOW
                    $slice_content = rex_register_extension_point('SLICE_SHOW', $slice_content, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID], 'function' => $this->function, 'function_slice_id' => $this->slice_id));
                    // ---------- slice in ausgabe speichern wenn ctype richtig
                    if ($this->ctype == -1 or $this->ctype == $RE_CONTS_CTYPE[$I_ID]) {
                        $this->article_content .= $slice_content;
                        // last content type slice id
                        $LCTSL_ID = $RE_CONTS[$I_ID];
                    }
                    // ----- zwischenstand: ctype .. wenn ctype neu dann if
                    if ($this->mode != "edit" && isset($RE_CONTS_CTYPE[$RE_CONTS[$I_ID]]) && $RE_CONTS_CTYPE[$I_ID] != $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] && $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] != "") {
                        $this->article_content .= "<?php } if(\$this->ctype == '" . $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] . "' || \$this->ctype == '-1'){ ?>";
                    }
                    // zum nachsten slice
                    $I_ID = $RE_CONTS[$I_ID];
                    $PRE_ID = $I_ID;
                }
                // ----- end: ctype unterscheidung
                if ($this->mode != "edit" && $i > 0) {
                    $this->article_content .= "<?php } ?>";
                }
                // ----- add module im edit mode
                if ($this->mode == "edit") {
                    $form_url = 'index.php';
                    if ($this->setanker) {
                        $form_url .= '#addslice';
                    }
                    if ($this->function == "add" && $this->slice_id == $LCTSL_ID) {
                        $slice_content = $this->addSlice($LCTSL_ID, $module_id);
                    } else {
                        // ----- BLOCKAUSWAHL - SELECT
                        $MODULESELECT->setId("module_id" . $LCTSL_ID);
                        // $slice_content = $add_select_box;
                        $slice_content = '
            <form action="' . $form_url . '" method="get">
              <fieldset>
                <legend class="rex-lgnd"><span class="rex-hide">' . $I18N->msg("add_block") . '</span></legend>
                <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                <input type="hidden" name="page" value="content" />
                <input type="hidden" name="mode" value="' . $this->mode . '" />
                <input type="hidden" name="slice_id" value="' . $LCTSL_ID . '" />
                <input type="hidden" name="function" value="add" />
                <input type="hidden" name="clang" value="' . $this->clang . '" />
                <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                <p class="rex-slct">
                  ' . $MODULESELECT->get() . '
                  <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                </p>

              </fieldset>
            </form>';
                    }
                    $this->article_content .= $slice_content;
                }
                // -------------------------- schreibe content
                if ($this->mode == "generate" || $this->viasql) {
                    echo $this->replaceLinks($this->article_content);
                } else {
                    eval("?>" . $this->article_content);
                }
            } else {
                echo $I18N->msg('no_article_available');
            }
        }
        // ----- end: article caching
        $CONTENT = ob_get_contents();
        ob_end_clean();
        return $CONTENT;
    }
Пример #20
0
$mypage = 'plaintext';
$dir = dirname(__FILE__);
$REX['ADDON']['version'][$mypage] = '0.2';
$REX['ADDON']['author'][$mypage] = 'Robert Rupf';
$REX['ADDON']['supportpage'][$mypage] = 'forum.redaxo.de';
$REX['EXTRAPERM'][] = $parent . '[' . $mypage . ']';
require_once $dir . '/functions/functions.inc.php';
if (is_object($REX['USER']) and ($REX['USER']->hasPerm($parent . '[' . $mypage . ']') or $REX['USER']->isAdmin())) {
    if ($REX['REDAXO']) {
        $I18N->appendFile(dirname(__FILE__) . '/lang/');
        $REX['ADDON']['rexsearch_plugins'][$parent][$mypage]['subpages'][] = array('plaintext', $I18N->Msg('a587_plaintext_title'));
    }
    rex_register_extension('A587_PLAINTEXT', 'a587_doPlaintext');
    if (!file_exists($settingFile = dirname(__FILE__) . '/settings.conf')) {
        a587_plaintext_saveSettings(array('order' => 'selectors,regex,textile,striptags', 'selectors' => "head,\nscript", 'regex' => '', 'textile' => true, 'striptags' => true, 'processparent' => false));
    }
    $REX['ADDON']['rexsearch_plugins'][$parent][$mypage]['settings'] = a587_config_unserialize(rex_get_file_contents($settingFile));
}
// Including CSS-File for Backend
if ($REX['REDAXO'] and rex_request('page', 'string') == $parent and rex_request('subpage', 'string') == $mypage) {
    function a587_plaintext_add_css($params)
    {
        $parent = 'rexsearch';
        $mypage = 'plaintext';
        if (function_exists('str_ireplace')) {
            return str_ireplace('</head>', "\t" . '<script type="text/javascript" src="../files/addons/' . $parent . '/plugins/' . $mypage . '/jquery.ui.custom.js"></script>' . "\n" . '</head>', $params['subject']);
        }
        return str_replace('</head>', "\t" . '<script type="text/javascript" src="../files/addons/' . $parent . '/plugins/' . $mypage . '/jquery.ui.custom.js"></script>' . "\n" . '</head>', $params['subject']);
    }
    rex_register_extension('OUTPUT_FILTER', 'a587_plaintext_add_css');
}
Пример #21
0
$modul_in = 'a720_demo.modul.in.php';
$modul_out = 'a720_demo.modul.out.php';
$modul_uid = '### UID:m720demo ###';
$modul_id = 0;
$modul_name = '';
$gm = new rex_sql();
$gm->setQuery('select * from rex_module where ausgabe LIKE "%' . $modul_uid . '%"');
foreach ($gm->getArray() as $module) {
    $modul_id = $module["id"];
    $modul_name = $module["name"];
}
if ($func == 'install_modul') {
    $default_module_name = $mypage . ' Demo Modul';
    // Daten einlesen
    $in = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/' . $modul_in);
    $out = rex_get_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/modules/' . $modul_out);
    $mi = new rex_sql();
    // $mi->debugsql = 1;
    $mi->setTable("rex_module");
    $mi->setValue("eingabe", addslashes($in));
    $mi->setValue("ausgabe", addslashes($out));
    if (isset($_REQUEST['demo_module_id']) && $modul_id == $_REQUEST['demo_module_id']) {
        // altes Modul aktualisieren
        $mi->setWhere('id="' . $modul_id . '"');
        $mi->update();
        echo rex_info('Modul "' . $modul_name . '" wurde wiederhergestellt.');
    } else {
        // neues Modul installieren
        $mi->setValue('name', $default_module_name);
        $mi->insert();
        echo rex_info('Modul wurde angelegt als "' . $default_module_name . '"');
Пример #22
0
<?php

$moduleInput = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/magnific_popup/module/gallery/input.php");
$moduleOutput = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/magnific_popup/module/gallery/output.php");
// Ist Modul schon vorhanden ?
$searchtext = 'module: magnific_popup_gallery_out';
$gm = rex_sql::factory();
$gm->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module where ausgabe LIKE "%' . $searchtext . '%"');
$module_id = 0;
$module_name = "";
foreach ($gm->getArray() as $module) {
    $module_id = $module["id"];
    $module_name = $module["name"];
}
if (isset($_REQUEST["install"]) && $_REQUEST["install"] == 1) {
    $module_name = $I18N->msg('magnific_popup_module_name_gallery');
    $mi = rex_sql::factory();
    // $mi->debugsql = 1;
    $mi->setTable("rex_module");
    $mi->setValue("eingabe", addslashes($moduleInput));
    $mi->setValue("ausgabe", addslashes($moduleOutput));
    if (isset($_REQUEST["module_id"]) && $module_id == $_REQUEST["module_id"]) {
        // altes Module aktualisieren
        $mi->setWhere('id="' . $module_id . '"');
        $mi->update();
        // article updaten
        rex_generateAll();
        echo rex_info($I18N->msg('module_updated') . ' | ' . $I18N->msg('delete_cache_message'));
    } else {
        // neues Modul einf&uuml;gen
        $mi->setValue("name", $module_name);
Пример #23
0
        global $REX;
        if(!empty($REX[\'ADDON\'][\'rexsearch_plugins\'][\'' . $mypage . '\']))
        {
          foreach($REX[\'ADDON\'][\'rexsearch_plugins\'][\'' . $mypage . '\'] as $plugin => $pluginsettings)
            if(!empty($pluginsettings[\'subpages\']))
              $REX[\'ADDON\'][\'' . $mypage . '\'][\'SUBPAGES\'] = array_merge($REX[\'ADDON\'][\'' . $mypage . '\'][\'SUBPAGES\'], $pluginsettings[\'subpages\']);
        }
      '));
}
require $REX['ADDON']['dir'][$mypage] . '/classes/class.rexsearch.inc.php';
require $REX['ADDON']['dir'][$mypage] . '/functions/functions.inc.php';
require $REX['ADDON']['dir'][$mypage] . '/functions/functions.mb.inc.php';
if (!file_exists($settingFile = dirname(__FILE__) . '/settings.conf')) {
    a587_saveSettings(array('logicalmode' => 'and', 'textmode' => 'plain', 'searchmode' => 'like', 'similarwordsmode' => 7, 'indexmode' => 1, 'automaticindex' => 1, 'surroundtags' => array('<strong>', '</strong>'), 'limit' => array(0, 20), 'maxteaserchars' => '200', 'maxhighlightchars' => '50', 'highlight' => 'surroundtextsingle', 'fileextensions' => array('pdf'), 'indexmediapool' => '1', 'dirdepth' => 3));
}
$REX['ADDON']['settings'][$mypage] = a587_config_unserialize(rex_get_file_contents($settingFile));
// automatic indexing
if ($REX['REDAXO'] and $REX['ADDON']['settings'][$mypage]['automaticindex'] == '1') {
    $extensionPoints = array('ART_DELETED', 'ART_META_UPDATED', 'ART_STATUS', 'ART_ADDED', 'ART_UPDATED', 'CAT_DELETED', 'CAT_STATUS', 'CAT_ADDED', 'CAT_UPDATED', 'MEDIA_ADDED', 'MEDIA_UPDATED', 'MEDIA_DELETED', 'SLICE_UPDATED');
    a587_register_extensionpoints($extensionPoints);
}
// Including CSS-File for Backend
if ($REX['REDAXO'] and rex_request('page', 'string') == $mypage) {
    function a587_add_css($params)
    {
        $mypage = 'rexsearch';
        if (function_exists('str_ireplace')) {
            return str_ireplace('</head>', "\t" . '<link rel="stylesheet" type="text/css" href="../files/addons/' . $mypage . '/' . $mypage . '.css" />' . "\n" . '</head>', $params['subject']);
        }
        return str_replace('</head>', "\t" . '<link rel="stylesheet" type="text/css" href="../files/addons/' . $mypage . '/' . $mypage . '.css" />' . "\n" . '</head>', $params['subject']);
    }
Пример #24
0
// Ist Modul schon vorhanden ?
$searchtext = '$xform = new rex_xform';
$gm = new rex_sql();
$gm->setQuery('select * from rex_module where ausgabe LIKE "%' . $searchtext . '%"');
$module_id = 0;
$module_name = "";
foreach ($gm->getArray() as $module) {
    $module_id = $module["id"];
    $module_name = $module["name"];
}
if (isset($_REQUEST["install"]) && $_REQUEST["install"] == 1) {
    $xform_module_name = "rex - X-Form";
    // Daten einlesen
    $in = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/xform/module/module_in.inc");
    $out = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/xform/module/module_out.inc");
    $mi = new rex_sql();
    // $mi->debugsql = 1;
    $mi->setTable("rex_module");
    $mi->setValue("eingabe", addslashes($in));
    $mi->setValue("ausgabe", addslashes($out));
    // altes Module aktualisieren
    if (isset($_REQUEST["module_id"]) && $module_id == $_REQUEST["module_id"]) {
        $mi->setWhere('id="' . $module_id . '"');
        $mi->update();
        echo rex_info('Modul "' . $module_name . '" wurde aktualisiert');
    } else {
        $mi->setValue("name", $xform_module_name);
        $mi->insert();
        echo rex_info('XForm Modul wurde angelegt unter "' . $xform_module_name . '"');
    }
 function getArticle($curctype = -1)
 {
     // bc
     if ($this->viasql) {
         return parent::getArticle($curctype);
     }
     global $REX;
     $this->ctype = $curctype;
     if (!$this->getSlice && $this->article_id != 0) {
         // ----- start: article caching
         ob_start();
         ob_implicit_flush(0);
         $article_content_file = $REX['INCLUDE_PATH'] . '/generated/articles/' . $this->article_id . '.' . $this->clang . '.content';
         if (!file_exists($article_content_file)) {
             include_once $REX["INCLUDE_PATH"] . "/functions/function_rex_generate.inc.php";
             $generated = rex_generateArticleContent($this->article_id, $this->clang);
             if ($generated !== true) {
                 // fehlermeldung ausgeben
                 echo $generated;
             }
         }
         if (file_exists($article_content_file)) {
             eval(rex_get_file_contents($article_content_file));
         }
         // ----- end: article caching
         $CONTENT = ob_get_contents();
         ob_end_clean();
     } else {
         // Inhalt ueber sql generierens
         $CONTENT = parent::getArticle($curctype);
     }
     return $CONTENT;
 }
Пример #26
0
 /**
  * Indexes a certain column.
  * Returns the number of the indexed rows or false.
  * 
  * @param string $_table
  * @param mixed $_column
  * @param mixed $_idcol
  * @param mixed $_id
  * @param mixed $_start
  * @param mixed $_count
  * 
  * @return mixed
  */
 function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start = false, $_count = false, $_where = false)
 {
     $delete = new rex_sql();
     $where = sprintf(" `ftable` = '%s' AND `fcolumn` = '%s' AND `texttype` = 'db_column'", $delete->escape($_table), $delete->escape($_column));
     //if(is_string($_idcol) AND ($_id !== false))
     //$where .= sprintf(' AND fid = %d',$_id);
     // delete from cache
     $select = new rex_sql();
     $select->setTable($this->tablePrefix . '587_searchindex');
     $select->setWhere($where);
     $indexIds = array();
     if ($select->select('id')) {
         foreach ($select->getArray() as $result) {
             $indexIds[] = $result['id'];
         }
         $this->deleteCache($indexIds);
     }
     // delete old data
     if ($_start === 0) {
         $delete->setTable($this->tablePrefix . '587_searchindex');
         $delete->setWhere($where);
         $delete->delete();
     }
     $sql = new rex_sql();
     // get primary key column(s)
     $primaryKeys = array();
     foreach ($sql->getArray("SHOW COLUMNS FROM `" . $_table . "` WHERE `KEY` = 'PRI'") as $col) {
         $primaryKeys[] = $col['Field'];
     }
     // index column
     $sql->flush();
     $sql->setTable($_table);
     $where = '1 ';
     if (is_string($_idcol) and $_id) {
         $where .= sprintf(' AND (%s = %d)', $_idcol, $_id);
     }
     if (!empty($_where) and is_string($_where)) {
         $where .= ' AND (' . $_where . ')';
     }
     if (is_numeric($_start) and is_numeric($_count)) {
         $where .= ' LIMIT ' . $_start . ',' . $_count;
     }
     $sql->setWhere($where);
     $count = false;
     if ($sql->select('*')) {
         $this->beginFrontendMode();
         $count = 0;
         $keywords = array();
         foreach ($sql->getArray() as $value) {
             if (!empty($value[$_column]) and ($this->indexOffline or $this->tablePrefix . 'article' != $_table or $value['status'] == '1') and ($this->tablePrefix . 'article' != $_table or !in_array($value['id'], $this->excludeIDs))) {
                 $insert = new rex_sql();
                 $indexData = array();
                 $indexData['texttype'] = 'db_column';
                 $indexData['ftable'] = $_table;
                 $indexData['fcolumn'] = $_column;
                 if (array_key_exists('clang', $value)) {
                     $indexData['clang'] = $value['clang'];
                 } else {
                     $indexData['clang'] = NULL;
                 }
                 $indexData['fid'] = NULL;
                 if (is_string($_idcol) and array_key_exists($_idcol, $value)) {
                     $indexData['fid'] = $value[$_idcol];
                 } elseif ($_table == $this->tablePrefix . 'article') {
                     $indexData['fid'] = $value['id'];
                 } elseif (count($primaryKeys) == 1) {
                     $indexData['fid'] = $value[$primaryKeys[0]];
                 } elseif (count($primaryKeys)) {
                     $fids = array();
                     foreach ($primaryKeys as $pk) {
                         $fids[$pk] = $value[$pk];
                     }
                     $indexData['fid'] = json_encode($fids);
                 }
                 if (is_null($indexData['fid'])) {
                     $indexData['fid'] = $this->getMinFID();
                 }
                 if (array_key_exists('re_id', $value)) {
                     $indexData['catid'] = $value['re_id'];
                     if ($_table == $this->tablePrefix . 'article') {
                         $indexData['catid'] = intval($value['startpage']) ? $value['id'] : $value['re_id'];
                     }
                 } elseif (array_key_exists('category_id', $value)) {
                     $indexData['catid'] = $value['category_id'];
                 } else {
                     $indexData['catid'] = NULL;
                 }
                 $additionalValues = array();
                 foreach ($this->includeColumns[$_table] as $col) {
                     $additionalValues[$col] = $value[$col];
                 }
                 $indexData['values'] = $insert->escape(serialize($additionalValues));
                 $indexData['unchangedtext'] = $insert->escape((string) $value[$_column]);
                 $indexData['plaintext'] = $insert->escape($plaintext = $this->getPlaintext($value[$_column]));
                 foreach (preg_split($this->encodeRegex('~[[:punct:][:space:]]+~ism'), $plaintext) as $keyword) {
                     if ($this->significantCharacterCount <= mb_strlen($keyword, 'UTF-8')) {
                         $keywords[] = array('search' => $keyword, 'clang' => is_null($indexData['clang']) ? false : $indexData['clang']);
                     }
                 }
                 $indexData['teaser'] = '';
                 if ($this->tablePrefix . 'article' == $_table) {
                     $rex_article = new rex_article(intval($value['id']), intval($value['clang']));
                     $teaser = true;
                     $article_content_file = $this->generatedPath . '/articles/' . intval($value['id']) . '.' . intval($value['clang']) . '.content';
                     if (!file_exists($article_content_file)) {
                         include_once $this->includePath . "/functions/function_rex_generate.inc.php";
                         $generated = rex_generateArticleContent(intval($value['id']), intval($value['clang']));
                         if ($generated !== true) {
                             $teaser = false;
                             continue;
                         }
                     }
                     if (file_exists($article_content_file) and preg_match($this->encodeRegex('~(header\\s*\\(\\s*["\']\\s*Location\\s*:)|(rex_redirect\\s*\\()~is'), rex_get_file_contents($article_content_file))) {
                         $teaser = false;
                     }
                     $indexData['teaser'] = $teaser ? $insert->escape($this->getTeaserText($this->getPlaintext($rex_article->getArticle()))) : '';
                 }
                 $insert->setTable($this->tablePrefix . '587_searchindex');
                 $insert->setValues($indexData);
                 $insert->insert();
                 $count++;
             }
         }
         $this->storeKeywords($keywords, false);
         $this->endFrontendMode();
     } else {
         return false;
     }
     return $count;
 }
Пример #27
0
 static function getLogOfMonth($month, $year)
 {
     $file = REX_CRONJOB_LOG_FOLDER . $year . '/' . $year . '-' . $month . '.log';
     return rex_get_file_contents($file);
 }
 function rex_replace_dynamic_contents($path, $content)
 {
     if ($fcontent = rex_get_file_contents($path)) {
         $content = "// --- DYN\n" . trim($content) . "\n// --- /DYN";
         $fcontent = ereg_replace("(\\/\\/.---.DYN.*\\/\\/.---.\\/DYN)", $content, $fcontent);
         return rex_put_file_contents($path, $fcontent);
     }
     return false;
 }
Пример #29
0
 function getArticle($curctype = -1)
 {
     global $REX;
     $this->ctype = $curctype;
     // bc
     if ($this->viasql) {
         $CONTENT = parent::getArticle($curctype);
     } elseif (!$this->getSlice && $this->article_id != 0) {
         // ----- start: article caching
         ob_start();
         ob_implicit_flush(0);
         $article_content_file = $REX['GENERATED_PATH'] . '/articles/' . $this->article_id . '.' . $this->clang . '.content';
         if (!file_exists($article_content_file)) {
             include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php';
             $generated = rex_generateArticleContent($this->article_id, $this->clang);
             if ($generated !== true) {
                 // fehlermeldung ausgeben
                 echo $generated;
             }
         }
         if (file_exists($article_content_file)) {
             eval(rex_get_file_contents($article_content_file));
         }
         // ----- end: article caching
         $CONTENT = ob_get_contents();
         ob_end_clean();
     } else {
         // Inhalt ueber sql generierens
         $CONTENT = parent::getArticle($curctype);
     }
     $CONTENT = rex_register_extension_point('ART_CONTENT', $CONTENT, array('ctype' => $curctype, 'article' => &$this));
     return $CONTENT;
 }