コード例 #1
0
ファイル: functions.inc.php プロジェクト: olien/rexsearch
function a685_search_highlighter_saveSettings($_settings)
{
    global $REX;
    $parent = 'rexsearch';
    $mypage = 'search_highlighter';
    return rex_put_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $parent . '/plugins/' . $mypage . '/settings.conf', serialize($_settings));
}
コード例 #2
0
ファイル: functions.inc.php プロジェクト: olien/rexsearch
function a587_plaintext_saveSettings($_settings)
{
    global $REX;
    $parent = 'rexsearch';
    $mypage = 'plaintext';
    return rex_put_file_contents($REX['INCLUDE_PATH'] . '/addons/' . $parent . '/plugins/' . $mypage . '/settings.conf', serialize($_settings));
}
コード例 #3
0
 public static function updateSettingsFile($showSuccessMsg = true)
 {
     global $REX, $I18N;
     $settingsFile = self::getSettingsFile();
     $msg = self::checkDirForFile($settingsFile);
     if ($msg != '') {
         if ($REX['REDAXO']) {
             echo rex_warning($msg);
         }
     } else {
         if (!file_exists($settingsFile)) {
             self::createDynFile($settingsFile);
         }
         // deprecated settings
         unset($REX['ADDON']['open_graph']['settings']['cached_redirects']);
         unset($REX['ADDON']['open_graph']['settings']['no_double_content_redirects_only_frontend']);
         $content = "<?php\n\n";
         foreach ((array) $REX['ADDON']['open_graph']['settings'] as $key => $value) {
             $content .= "\$REX['ADDON']['open_graph']['settings']['{$key}'] = " . var_export($value, true) . ";\n";
         }
         if (rex_put_file_contents($settingsFile, $content)) {
             if ($REX['REDAXO'] && $showSuccessMsg) {
                 echo rex_info($I18N->msg('open_graph_config_ok'));
             }
         } else {
             if ($REX['REDAXO']) {
                 echo rex_warning($I18N->msg('open_graph_config_error'));
             }
         }
     }
 }
コード例 #4
0
 /**
  * Aktualisiert die gespeicherten Benutzereinstellungen .
  * @global mixed[] $REX Redaxo Variable
  * @global i18n $I18N Objekt mir Übersetzungen fürs Backend
  * @param boolean $showSuccessMsg True, wenn Meldung bei erfolgreichem
  * Speichern angezeigt werden soll.
  */
 public static function updateSettingsFile($showSuccessMsg = true)
 {
     global $REX, $I18N;
     $settingsFile = self::getSettingsFile();
     $msg = self::checkDirForFile($settingsFile);
     if ($msg != '') {
         if ($REX['REDAXO']) {
             echo rex_warning($msg);
         }
     } else {
         if (!file_exists($settingsFile)) {
             self::createDynFile($settingsFile);
         }
         $content = "<?php\n\n";
         foreach ((array) $REX['ADDON']['hr4you_sync']['settings'] as $key => $value) {
             $content .= "\$REX['ADDON']['hr4you_sync']['settings']['{$key}'] = " . var_export($value, true) . ";\n";
         }
         if (rex_put_file_contents($settingsFile, $content)) {
             if ($REX['REDAXO'] && $showSuccessMsg) {
                 echo rex_info($I18N->msg('d2u_stellenmarkt_hr4you_sync_config_ok'));
             }
         } else {
             if ($REX['REDAXO']) {
                 echo rex_warning($I18N->msg('d2u_stellenmarkt_hr4you_sync_config_error'));
             }
         }
     }
 }
コード例 #5
0
ファイル: functions.inc.php プロジェクト: nightstomp/tinymce
 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;
 }
コード例 #6
0
 function a724_generatePathnamesFromTable($params)
 {
     $debug = false;
     $sql = new rex_sql();
     $results = $sql->getArray('SELECT article_id, url_table, url_table_parameters FROM rex_a724_frau_schultze WHERE url_table != "" AND url_table_parameters != ""');
     $URLPATH = array();
     if ($sql->getRows() >= 1) {
         a724_deletePathnamesFromTable();
         foreach ($results as $result) {
             if (is_array($result) && count($result) > 0) {
                 $path = rex_getUrl($result['article_id']) . '/';
                 $path = str_replace('.html', '', $path);
                 $table = $result['url_table'];
                 $params = unserialize($result['url_table_parameters']);
                 $col_name = $params[$table][$table . "_name"];
                 $col_id = $params[$table][$table . "_id"];
                 // Daten zum Aufbau der Urls holen
                 $sqlu = new rex_sql();
                 $sqlu->setDebug($debug);
                 $res = $sqlu->getArray('SELECT ' . $col_name . ' AS name, ' . $col_id . ' AS id FROM ' . $table);
                 if ($sqlu->getRows() >= 1) {
                     // Urls in die Datenbank schreiben
                     $sqli = new rex_sql();
                     $sqli->setDebug($debug);
                     foreach ($res as $re) {
                         $table_path = $path . strtolower(rex_parse_article_name($re['name'])) . '.html';
                         $table_id = $re['id'];
                         $URLPATH[$result['url_table']][$table_id] = $table_path;
                         $sqli->setTable('rex_a724_frau_schultze');
                         $sqli->setValue('article_id', $result['article_id']);
                         $sqli->setValue('status', '1');
                         $sqli->setValue('url_table', $result['url_table']);
                         $sqli->setValue('name', $table_path);
                         $sqli->insert();
                     }
                 }
             }
         }
     }
     rex_put_file_contents(A724_URL_TABLE_PATHLIST, "<?php\n\$URLPATH = " . var_export($URLPATH, true) . ";\n");
 }
コード例 #7
0
 function toTar($filename, $useGzip)
 {
     // Encode processed files into TAR file format
     $this->__generateTar();
     // GZ Compress the data if we need to
     if ($useGzip) {
         // Make sure we have gzip support
         if (!function_exists("gzencode")) {
             return false;
         }
         $file = gzencode($this->tar_file);
     } else {
         $file = $this->tar_file;
     }
     // Write the TAR file
     //    $fp = fopen($filename,"wb");
     //    fwrite($fp,$file);
     //    fclose($fp);
     // kein Filename gegeben => Inhalt zurueckgeben
     if (!$filename) {
         return $file;
     }
     // STM: hier mit put_file_contents ist viel schneller
     return rex_put_file_contents($filename, $file) !== false;
 }
コード例 #8
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) !== false) {
        $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>';
コード例 #9
0
$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);
}
$sel_encoding = new rex_select();
$sel_encoding->setId('encoding');
コード例 #10
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);
 }
コード例 #11
0
ファイル: setup.inc.php プロジェクト: omphteliba/seo42
        if (rex_put_file_contents($htaccessRoot, $content) > 0) {
            //echo rex_info($I18N->msg('seo42_setup_htaccess_patch_ok'));
        } else {
            echo rex_warning($I18N->msg('seo42_setup_htaccess_patch_failed'));
        }
    }
} elseif ($func == "apply_settings") {
    $server = str_replace("\\'", "'", rex_post('server', 'string'));
    $servername = str_replace("\\'", "'", rex_post('servername', 'string'));
    $masterFile = $REX['INCLUDE_PATH'] . '/master.inc.php';
    $content = rex_get_file_contents($masterFile);
    $search = array('\\"', "'", '$');
    $destroy = array('"', "\\'", '\\$');
    $replace = array('search' => array("@(REX\\['SERVER'\\].?\\=.?).*\$@m", "@(REX\\['SERVERNAME'\\].?\\=.?).*\$@m"), 'replace' => array("\$1'" . str_replace($search, $destroy, $server) . "';", "\$1'" . str_replace($search, $destroy, $servername) . "';"));
    $content = preg_replace($replace['search'], $replace['replace'], $content);
    if (rex_put_file_contents($masterFile, $content) > 0) {
        echo rex_info($I18N->msg('seo42_setup_settings_saved'));
        $REX['SERVER'] = stripslashes($server);
        $REX['SERVERNAME'] = stripslashes($servername);
        // reinit because of subdir check in step 2
        seo42::init();
    } else {
        echo rex_warning($I18N->msg('seo42_setup_settings_save_failed'));
    }
}
?>

<div class="rex-addon-output">
	<h2 class="rex-hl2"><?php 
echo $I18N->msg('seo42_setup_step1');
?>
コード例 #12
0
ファイル: setup.inc.php プロジェクト: BackupTheBerlios/redaxo
          <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>';
コード例 #13
0
/**
 * Generiert den TemplateCache im Filesystem
 * 
 * @param $template_id Id des zu generierenden Templates
 * 
 * @return TRUE bei Erfolg, sonst FALSE
 */
function rex_generateTemplate($template_id)
{
    global $REX;
    $sql = rex_sql::factory();
    $qry = 'SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id = ' . $template_id;
    $sql->setQuery($qry);
    if ($sql->getRows() == 1) {
        $templatesDir = rex_template::getTemplatesDir();
        $templateFile = rex_template::getFilePath($template_id);
        $content = $sql->getValue('content');
        foreach ($REX['VARIABLES'] as $var) {
            $content = $var->getTemplate($content);
        }
        if (rex_put_file_contents($templateFile, $content) !== FALSE) {
            return TRUE;
        } else {
            trigger_error('Unable to generate template ' . $template_id . '!', E_USER_ERROR);
            if (!is_writable()) {
                trigger_error('directory "' . $templatesDir . '" is not writable!', E_USER_ERROR);
            }
        }
    } else {
        trigger_error('Template with id "' . $template_id . '" does not exist!', E_USER_ERROR);
    }
    return FALSE;
}
コード例 #14
0
/**
* seo42_generate_pathlist()
*
* generiert die Pathlist, abhängig von Aktion
* @author markus.staab[at]redaxo[dot]de Markus Staab
* @package redaxo4.2
*/
function seo42_generate_pathlist($params)
{
    global $REX, $SEO42_IDS, $SEO42_URLS;
    // temporary community install workaround
    if (!isset($REX['ADDON']['seo42'])) {
        return;
    }
    // include pathlist file
    if (file_exists(SEO42_PATHLIST)) {
        require_once SEO42_PATHLIST;
    }
    // EXTENSION POINT "SEO42_PATHLIST_BEFORE_REBUILD"
    $subject = array('SEO42_IDS' => $SEO42_IDS, 'SEO42_URLS' => $SEO42_URLS);
    rex_register_extension_point('SEO42_PATHLIST_BEFORE_REBUILD', $subject);
    $SEO42_IDS = array();
    $SEO42_URLS = array();
    $REX['SEO42_URL_CLONE'] = array();
    $db = new rex_sql();
    // REVISION FIX
    $db->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'article SET revision = 0 WHERE revision IS NULL;');
    $db->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'article_slice SET revision = 0 WHERE revision IS NULL;');
    if ($REX['ADDON']['seo42']['settings']['ignore_root_cats']) {
        $sqlQuery = 'SELECT `id`, `clang`, `path`, `startpage`,`seo_custom_url` FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE re_id != 0 OR (re_id = 0 AND catname LIKE "") AND revision=0 OR revision IS NULL ORDER BY id';
    } else {
        $sqlQuery = 'SELECT `id`, `clang`, `path`, `startpage`,`seo_custom_url` FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE revision=0 OR revision IS NULL ORDER BY id';
    }
    $db->setQuery($sqlQuery);
    // redirects start articles withou slash: /xx to /xx/
    if (count($REX['CLANG']) > 1) {
        foreach ($REX['CLANG'] as $clangId => $clangName) {
            if ($REX['ADDON']['seo42']['settings']['url_ending'] == '') {
                $langSlug = seo42::getLangUrlSlug($clangId) . '/';
            } else {
                $langSlug = seo42::getLangUrlSlug($clangId);
            }
            if ($REX['ADDON']['seo42']['settings']['homelang'] != $clangId) {
                $SEO42_URLS[$langSlug] = array('id' => $REX['START_ARTICLE_ID'], 'clang' => $clangId, 'status' => 301);
            }
        }
    }
    while ($db->hasNext()) {
        $pathname = '';
        $id = $db->getValue('id');
        $clang = $db->getValue('clang');
        $path = $db->getValue('path');
        // LANG SLUG
        if (count($REX['CLANG']) > 1 && $clang != $REX['ADDON']['seo42']['settings']['hide_langslug']) {
            $pathname = '';
            $pathname = seo42_appendToPath($pathname, seo42::getLangUrlSlug($clang), $id, $clang);
        }
        // pfad über kategorien bauen
        $path = trim($path, '|');
        if ($path != '') {
            $path = explode('|', $path);
            foreach ($path as $p) {
                $ooc = OOCategory::getCategoryById($p, seo42_utils::getInheritedClang($clang));
                // PREVENT FATALS IN RARE CONDITIONS WHERE DB/CACHE ARE OUT OF SYNC
                if (!is_a($ooc, 'OOCategory')) {
                    continue;
                }
                // 42
                if ($REX['ADDON']['seo42']['settings']['ignore_root_cats'] && $ooc->getParentId() == 0) {
                    continue;
                }
                $name = $ooc->getName();
                unset($ooc);
                $pathname = seo42_appendToPath($pathname, $name, $id, $clang);
            }
        }
        $ooa = OOArticle::getArticleById($id, seo42_utils::getInheritedClang($clang));
        // PREVENT FATALS IN RARE CONDITIONS WHERE DB/CACHE ARE OUT OF SYNC
        if (!is_a($ooa, 'OOArticle')) {
            $db->next();
            continue;
        }
        if ($ooa->isStartArticle()) {
            $ooc = $ooa->getCategory();
            $catname = $ooc->getName();
            unset($ooc);
            $pathname = seo42_appendToPath($pathname, $catname, $id, $clang);
        }
        // url_schema: seo42
        if (!$ooa->isStartArticle()) {
            // eigentlicher artikel anhängen
            $name = $ooa->getName();
            unset($ooa);
            $pathname = seo42_appendToPath($pathname, $name, $id, $clang);
        }
        // ALLGEMEINE URL ENDUNG
        $pathname = substr($pathname, 0, strlen($pathname) - 1) . $REX['ADDON']['seo42']['settings']['url_ending'];
        // STARTSEITEN URL FORMAT
        if ($db->getValue('id') == $REX['START_ARTICLE_ID'] && $db->getValue('clang') == $REX['ADDON']['seo42']['settings']['homelang'] && ($REX['ADDON']['seo42']['settings']['homeurl'] == 1 || $REX['ADDON']['seo42']['settings']['homeurl'] == 2)) {
            $pathname = '';
        } elseif ($REX['ADDON']['seo42']['settings']['homeurl'] == 2 && $db->getValue('id') == $REX['START_ARTICLE_ID'] && count($REX['CLANG']) > 1) {
            if ($REX['ADDON']['seo42']['settings']['url_ending'] == '') {
                $langSlug = seo42::getLangUrlSlug($clang);
            } else {
                $langSlug = seo42::getLangUrlSlug($clang) . '/';
            }
            $pathname = $langSlug;
        }
        // UNSET OLD URL FROM $SEO42_URLS
        if (isset($SEO42_IDS[$id][$clang]['url']) && isset($SEO42_URLS[$SEO42_IDS[$id][$clang]['url']])) {
            unset($SEO42_URLS[$SEO42_IDS[$id][$clang]['url']]);
        }
        $SEO42_IDS[$id][$clang] = array('url' => $pathname);
        $SEO42_URLS[$pathname] = array('id' => (int) $id, 'clang' => (int) $clang);
        // get data from default lang if clone option is enabled for all other langs
        $jsonData = json_decode($db->getValue('seo_custom_url'), true);
        $articleId = $db->getValue('id');
        $clangId = $db->getValue('clang');
        if (isset($jsonData['url_clone']) && $jsonData['url_clone'] == true && $clangId == $REX['START_CLANG_ID']) {
            $REX['SEO42_URL_CLONE'][$articleId] = $jsonData;
        }
        $db->next();
    }
    // URL MANIPULATION BY SEO42
    // -----------------------------------------------------------------------------------------------------------
    $interReplaceIds = array();
    $db->reset();
    for ($i = 0; $i < $db->getRows(); $i++) {
        $urlField = $db->getValue('seo_custom_url');
        $articleId = $db->getValue('id');
        $clangId = $db->getValue('clang');
        if ($urlField != '' || isset($REX['SEO42_URL_CLONE'][$articleId])) {
            $urlData = seo42_utils::getUrlTypeData($urlField);
            $jsonData = json_decode($urlData, true);
            if (isset($REX['SEO42_URL_CLONE'][$articleId]) && !isset($jsonData['url_type'])) {
                $jsonData = $REX['SEO42_URL_CLONE'][$articleId];
            }
            switch ($jsonData['url_type']) {
                case SEO42_URL_TYPE_DEFAULT:
                    // do nothing
                    break;
                case SEO42_URL_TYPE_USERDEF_INTERN:
                    $customUrl = $jsonData['custom_url'];
                    if ($SEO42_IDS[$articleId][$clangId]['url'] != $customUrl) {
                        // only if custom url ist different then auto url
                        $SEO42_URLS[$customUrl] = $SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']];
                        unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    }
                    $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl);
                    break;
                case SEO42_URL_TYPE_USERDEF_EXTERN:
                    $customUrl = $jsonData['custom_url'];
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl);
                    break;
                case SEO42_URL_TYPE_MEDIAPOOL:
                    $customUrl = $REX['MEDIA_DIR'] . '/' . $jsonData['file'];
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl);
                    break;
                case SEO42_URL_TYPE_INTERN_REPLACE:
                    $customArticleId = $jsonData['article_id'];
                    $interReplaceIds[$clangId][$articleId] = array('id' => $customArticleId, 'clang' => $clangId);
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    if (isset($SEO42_IDS[$customArticleId][$clangId]['url'])) {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => $SEO42_IDS[$customArticleId][$clangId]['url']);
                    } else {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => '');
                    }
                    break;
                case SEO42_URL_TYPE_INTERN_REPLACE_CLANG:
                    $customArticleId = $jsonData['article_id'];
                    $customClangId = $jsonData['clang_id'];
                    $interReplaceIds[$clangId][$articleId] = array('id' => $customArticleId, 'clang' => $customClangId);
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    if (isset($SEO42_IDS[$customArticleId][$customClangId]['url'])) {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => $SEO42_IDS[$customArticleId][$customClangId]['url']);
                    } else {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => '');
                    }
                    break;
                case SEO42_URL_TYPE_REMOVE_ROOT_CAT:
                    $curUrl = $SEO42_IDS[$articleId][$clangId]['url'];
                    $newUrl = seo42_utils::removeRootCatFromUrl($curUrl, $clangId);
                    if ($newUrl != '') {
                        // same as SEO42_URL_TYPE_USERDEF_INTERN
                        $SEO42_URLS[$newUrl] = $SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']];
                        unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                        $SEO42_IDS[$articleId][$clangId] = array('url' => $newUrl);
                    }
                    break;
                case SEO42_URL_TYPE_CALL_FUNC:
                    if ($jsonData['no_url']) {
                        unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    }
                    break;
                case SEO42_URL_TYPE_LANGSWITCH:
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    break;
                case SEO42_URL_TYPE_NONE:
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    $SEO42_IDS[$articleId][$clangId] = array('url' => '');
                    break;
            }
            unset($jsonData);
        }
        $db->next();
    }
    // workaround for #177
    foreach ($interReplaceIds as $clangId => $value) {
        foreach ($value as $interReplaceId => $targetArticle) {
            if (isset($SEO42_IDS[$targetArticle['id']][$targetArticle['clang']]['url'])) {
                $SEO42_IDS[$interReplaceId][$clangId] = array('url' => $SEO42_IDS[$targetArticle['id']][$targetArticle['clang']]['url']);
            }
        }
    }
    // -----------------------------------------------------------------------------------------------------------
    // EXTENSION POINT "SEO42_PATHLIST_CREATED"
    $subject = array('SEO42_IDS' => $SEO42_IDS, 'SEO42_URLS' => $SEO42_URLS);
    $subject = rex_register_extension_point('SEO42_PATHLIST_CREATED', $subject);
    // EXTENSION POINT "SEO42_PATHLIST_FINAL" - READ ONLY
    rex_register_extension_point('SEO42_PATHLIST_FINAL', $subject);
    // ASSEMBLE, COMPRESS & WRITE PATHLIST TO FILE
    $pathlist_content = '$SEO42_IDS = ' . var_export($subject['SEO42_IDS'], true) . ';' . PHP_EOL . '$SEO42_URLS = ' . var_export($subject['SEO42_URLS'], true) . ';';
    $pathlist_content = seo42_compressPathlist($pathlist_content);
    rex_put_file_contents(SEO42_PATHLIST, '<?php' . PHP_EOL . $pathlist_content);
    // PURGE *.CONTENT CACHEFILES TO UPDATE INTERNAL LINKS CREATED BY replceLinks() in rex_article_base
    seo42_purgeCacheFiles();
}
コード例 #15
0
ファイル: index.inc.php プロジェクト: BackupTheBerlios/redaxo
                header("Content-Disposition: attachment; filename={$filename}");
                echo $content;
                exit;
            } else {
                // check filename ob vorhanden
                // aendern filename
                // speicher content in files
                $export_path = $REX['INCLUDE_PATH'] . "/addons/{$page}/files/";
                if (file_exists($export_path . $filename . $ext)) {
                    $i = 1;
                    while (file_exists($export_path . $filename . '_' . $i . $ext)) {
                        $i++;
                    }
                    $filename = $filename . '_' . $i;
                }
                if (rex_put_file_contents($export_path . $filename . $ext, $content)) {
                    $msg = $I18N_IM_EXPORT->msg('file_generated_in') . ' ' . strtr($filename . $ext, '\\', '/');
                } else {
                    $msg = $I18N_IM_EXPORT->msg('file_could_not_be_generated') . ' ' . $I18N->msg('check_rights_in_directory') . ' ' . $export_path;
                }
            }
        }
    }
}
require $REX['INCLUDE_PATH'] . "/layout/top.php";
rex_title($I18N_IM_EXPORT->msg("importexport"), "");
if ($msg != '') {
    echo rex_warning($msg);
}
?>
<div class="rex-cnt-cols">
コード例 #16
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;
}
コード例 #17
0
/**
 * 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;
}
コード例 #18
0
 public static function updateSettingsFile($showSuccessMsg = true)
 {
     global $REX, $I18N;
     $settingsFile = self::getSettingsFile();
     $msg = self::checkDirForFile($settingsFile);
     if ($msg != '') {
         if ($REX['REDAXO']) {
             echo rex_warning($msg);
         }
     } else {
         if (!file_exists($settingsFile)) {
             self::createDynFile($settingsFile);
         }
         $content = "<?php\n\n";
         foreach ((array) $REX['WEBSITE_MANAGER_SETTINGS'] as $key => $value) {
             $content .= "\$REX['WEBSITE_MANAGER_SETTINGS']['{$key}'] = " . var_export($value, true) . ";\n";
         }
         if (rex_put_file_contents($settingsFile, $content)) {
             if ($REX['REDAXO'] && $showSuccessMsg) {
                 echo rex_info($I18N->msg('website_manager_config_ok'));
             }
         } else {
             if ($REX['REDAXO']) {
                 echo rex_warning($I18N->msg('website_manager_config_error'));
             }
         }
     }
 }
コード例 #19
0
 /**
  * Erzeugt die Domains
  *
  */
 public static function generatePathFile($params)
 {
     global $REX;
     $myself = 'url_control';
     $addon = $REX['ADDON'][$myself]['addon'];
     $rewriter = $REX['ADDON'][$myself]['rewriter'];
     $query = '  SELECT  `article_id`,
                         `clang`,
                         `table`,
                         `table_parameters`
                 FROM    ' . $REX['TABLE_PREFIX'] . 'url_control_generate
                 ';
     $sql = rex_sql::factory();
     $sql->setQuery($query);
     $paths = array();
     if ($sql->getRows() >= 1) {
         $results = $sql->getArray();
         foreach ($results as $result) {
             $article_id = $result['article_id'];
             $clang = $result['clang'];
             $a = OOArticle::getArticleById($article_id, $clang);
             if ($a instanceof OOArticle) {
                 if (isset($rewriter[$addon]['get_url'])) {
                     $func = $rewriter[$addon]['get_url'];
                     $path = call_user_func($func, $article_id, $clang);
                 } else {
                     $path = $a->getUrl();
                 }
                 $path = parent::getCleanPath($path);
                 $table = $result['table'];
                 $table_params = unserialize($result['table_parameters']);
                 $name = $table_params[$table][$table . '_name'];
                 $name_2 = $table_params[$table][$table . '_name_2'];
                 $id = $table_params[$table][$table . '_id'];
                 $restriction_field = $table_params[$table][$table . '_restriction_field'];
                 $restriction_operator = $table_params[$table][$table . '_restriction_operator'];
                 $restriction_value = $table_params[$table][$table . '_restriction_value'];
                 $qyery_where = '';
                 if ($restriction_field != '' && $restriction_value != '' && in_array($restriction_operator, self::getRestrictionOperators())) {
                     switch ($restriction_operator) {
                         case 'IN (...)':
                         case 'NOT IN (...)':
                             $restriction_operator = str_replace(' (...)', '', $restriction_operator);
                             $values = explode(',', $restriction_value);
                             foreach ($values as $key => $value) {
                                 if (!(int) $value > 0) {
                                     unset($values[$key]);
                                 }
                             }
                             $restriction_value = ' (' . implode(',', $values) . ') ';
                             break;
                         case 'BETWEEN':
                         case 'NOT BETWEEN':
                             $values = explode(',', $restriction_value);
                             if (count($values) == 2) {
                                 $restriction_value = $values[0] . ' AND ' . $values[1];
                             }
                             break;
                         default:
                             $restriction_value = '"' . mysql_real_escape_string($restriction_value) . '"';
                             break;
                     }
                     $qyery_where = ' WHERE ' . $restriction_field . ' ' . $restriction_operator . ' ' . $restriction_value . '';
                 }
                 $query_select = $name_2 != '' ? ', ' . $name_2 . ' AS name_2' : '';
                 $query = '  SELECT  ' . $name . '   AS name,
                                     ' . $id . '     AS id
                                     ' . $query_select . '
                             FROM    ' . $table . '
                             ' . $qyery_where . '
                             ';
                 $s = rex_sql::factory();
                 $s->setQuery($query);
                 if ($s->getRows() >= 1) {
                     $urls = $s->getArray();
                     $save_names = array();
                     foreach ($urls as $url) {
                         if (isset($url['name_2']) && $url['name_2'] != '') {
                             $url['name'] = $url['name'] . ' ' . $url['name_2'];
                         }
                         if (isset($save_names[$url['name']])) {
                             $url['name'] = $url['name'] . '-' . $url['id'];
                         }
                         $paths[$table][$article_id][$clang][$url['id']] = $path . strtolower(rex_parse_article_name($url['name'])) . '.html';
                         $save_names[$url['name']] = '';
                     }
                 }
             }
         }
     }
     rex_put_file_contents(self::$path_file, json_encode($paths));
 }
コード例 #20
0
     }
     $filename = $filename . '_' . $i;
 }
 if ($exporttype == 'sql') {
     // ------------------------------ FUNC EXPORT SQL
     $header = 'plain/text';
     $hasContent = rex_a1_export_db($export_path . $filename . $ext);
     // ------------------------------ /FUNC EXPORT SQL
 } elseif ($exporttype == 'files') {
     // ------------------------------ FUNC EXPORT FILES
     $header = 'tar/gzip';
     if (empty($EXPDIR)) {
         $warning = $I18N->msg('im_export_please_choose_folder');
     } else {
         $content = rex_a1_export_files($EXPDIR);
         $hasContent = rex_put_file_contents($export_path . $filename . $ext, $content);
     }
     // ------------------------------ /FUNC EXPORT FILES
 }
 if ($hasContent) {
     if ($exportdl) {
         while (ob_get_level()) {
             ob_end_clean();
         }
         $filename = $filename . $ext;
         header("Content-type: {$header}");
         header("Content-Disposition: attachment; filename={$filename}");
         readfile($export_path . $filename);
         unlink($export_path . $filename);
         exit;
     } else {
コード例 #21
0
/**
 * rex_rewriter_generate_pathnames
 * generiert die Pathlist, abhŠngig von Aktion
 * @author markus.staab[at]redaxo[dot]de Markus Staab
 * @package redaxo4.2
 */
function rex_rewriter_generate_pathnames($params)
{
    global $REX, $REXPATH;
    if (file_exists(FULLNAMES_PATHLIST)) {
        require_once FULLNAMES_PATHLIST;
    }
    if (!isset($REXPATH)) {
        $REXPATH = array();
    }
    if (!isset($params['extension_point'])) {
        $params['extension_point'] = '';
    }
    $where = '';
    switch ($params['extension_point']) {
        // ------- sprachabhängig, einen artikel aktualisieren
        case 'CAT_DELETED':
        case 'ART_DELETED':
            unset($REXPATH[$params['id']]);
            break;
        case 'CAT_ADDED':
        case 'CAT_UPDATED':
        case 'ART_ADDED':
        case 'ART_UPDATED':
            $where = '(id=' . $params['id'] . ' AND clang=' . $params['clang'] . ') OR (path LIKE "%|' . $params['id'] . '|%" AND clang=' . $params['clang'] . ')';
            break;
            // ------- alles aktualisieren
        // ------- alles aktualisieren
        case 'ALL_GENERATED':
        default:
            $where = '1=1';
            break;
    }
    if ($where != '') {
        $db = new rex_sql();
        // $db->debugsql=true;
        $db->setQuery('SELECT id,clang,path,startpage FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE ' . $where . ' and revision=0');
        while ($db->hasNext()) {
            $clang = $db->getValue('clang');
            $pathname = '';
            if (count($REX['CLANG']) > 1) {
                $pathname = $REX['CLANG'][$clang] . '/';
            }
            // pfad über kategorien bauen
            $path = trim($db->getValue('path'), '|');
            if ($path != '') {
                $path = explode('|', $path);
                foreach ($path as $p) {
                    $ooc = OOCategory::getCategoryById($p, $clang);
                    $name = $ooc->getName();
                    unset($ooc);
                    // speicher freigeben
                    $pathname = rex_rewriter_appendToPath($pathname, $name);
                }
            }
            $ooa = OOArticle::getArticleById($db->getValue('id'), $clang);
            if ($ooa->isStartArticle()) {
                $ooc = $ooa->getCategory();
                $catname = $ooc->getName();
                unset($ooc);
                // speicher freigeben
                $pathname = rex_rewriter_appendToPath($pathname, $catname);
            }
            // eigentlicher artikel anhängen
            $name = $ooa->getName();
            unset($ooa);
            // speicher freigeben
            $pathname = rex_rewriter_appendToPath($pathname, $name);
            $pathname = substr($pathname, 0, strlen($pathname) - 1) . '.html';
            $REXPATH[$db->getValue('id')][$db->getValue('clang')] = $pathname;
            $db->next();
        }
    }
    rex_put_file_contents(FULLNAMES_PATHLIST, "<?php\n\$REXPATH = " . var_export($REXPATH, true) . ";\n");
}
コード例 #22
0
 public static function updateRedirectsFile($showSuccessMsg = true)
 {
     global $REX, $I18N;
     $redirectsFile = self::getRedirectsFile();
     $msg = self::checkDirForFile($redirectsFile);
     if ($msg != '') {
         if ($REX['REDAXO']) {
             echo rex_warning($msg);
         }
     } else {
         if (!file_exists($redirectsFile)) {
             self::createDynFile($redirectsFile);
         }
         $sql = rex_sql::factory();
         //$sql->debugsql = true;
         $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'redirects');
         $REX['SEO42_CACHED_REDIRECTS'] = array();
         for ($i = 0; $i < $sql->getRows(); $i++) {
             $REX['SEO42_CACHED_REDIRECTS'][$sql->getValue('source_url')] = $sql->getValue('target_url');
             $sql->next();
         }
         $content = "<?php\n\n";
         $content .= "\$REX['SEO42_CACHED_REDIRECTS'] = " . var_export($REX['SEO42_CACHED_REDIRECTS'], true) . ";\n";
         if (rex_put_file_contents($redirectsFile, $content)) {
             if ($REX['REDAXO'] && $showSuccessMsg) {
                 echo rex_info($I18N->msg('seo42_config_ok'));
             }
         } else {
             if ($REX['REDAXO']) {
                 echo rex_warning($I18N->msg('seo42_config_error'));
             }
         }
     }
 }
コード例 #23
0
$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\r\n      \$this->From             = '" . $from . "';\r\n      \$this->FromName         = '" . $fromname . "';\r\n      \$this->ConfirmReadingTo = '" . $confirmto . "';\r\n      \$this->Mailer           = '" . $mailer . "';\r\n      \$this->Host             = '" . $host . "';\r\n      \$this->CharSet          = '" . $charset . "';\r\n      \$this->WordWrap         = " . $wordwrap . ";\r\n      \$this->Encoding         = '" . $encoding . "';\r\n      \$this->Priority         = " . $priority . ";\r\n      // --- /DYN";
            $file_content = ereg_replace("(\\/\\/.---.DYN.*\\/\\/.---.\\/DYN)", $template, $file_content);
            if (rex_put_file_contents($file, $file_content) !== false) {
                $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);
}
$sel_encoding = new rex_select();
$sel_encoding->setId('encoding');
コード例 #24
0
function a895_htaccessInstall($tool = false, $ip = false)
{
    global $REX, $mypage;
    if (!$tool) {
        return false;
    }
    if (!$ip) {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    $ht_file = $REX['ADDON'][$mypage]['ht_files'][$tool];
    $ht_conts = 'Order Deny,Allow' . PHP_EOL . 'Deny from all' . PHP_EOL . 'Allow from ' . $ip;
    if (rex_put_file_contents($ht_file, $ht_conts)) {
        return true;
    } else {
        return false;
    }
}