Exemplo n.º 1
0
function txPageTemplateWizard()
{
    global $DB, $C;
    $intermix = $_REQUEST['submitted_percent'] > 0 && $_REQUEST['permanent_percent'] > 0;
    $rss_feed = strpos($_REQUEST['display'], 'xml') === 0;
    $sections = array();
    $template = '';
    if ($rss_feed) {
        $_REQUEST['inrows'] = 'no';
    }
    if ($_REQUEST['submitted_percent'] > 0) {
        $sections[] =& $_REQUEST['s'];
    }
    if ($_REQUEST['permanent_percent'] > 0) {
        $sections[] =& $_REQUEST['p'];
    }
    $_REQUEST['s']['amount'] = round($_REQUEST['amount'] * ($_REQUEST['submitted_percent'] / 100));
    $_REQUEST['p']['amount'] = $_REQUEST['amount'] - $_REQUEST['s']['amount'];
    foreach ($sections as $section) {
        $options = array('type=' . $section['type'], 'format=' . $section['format'], 'getnew=' . ($section['getnew'] == 'allowused' ? 'true' : $section['getnew']), 'allowused=' . ($section['getnew'] == 'allowused' ? 'true' : 'false'), 'description=' . $section['description'], 'preview=' . $section['preview'], 'amount=' . $section['amount']);
        if ($section['preview'] == 'true') {
            if (empty($section['previewsize']) && !empty($section['customsize']) || !empty($section['previewsize'])) {
                $options[] = 'previewsize=' . (empty($section['previewsize']) ? $section['customsize'] : $section['previewsize']);
            }
        }
        if (!empty($section['weight'])) {
            $options[] = 'weight="' . $section['weight'] . $section['weight_value'] . '"';
        }
        switch ($section['agetype']) {
            case 'exact':
                $options[] = 'age=' . $section['age'];
                break;
            case 'atleast':
                $options[] = 'minage=' . $section['age'];
                break;
            case 'atmost':
                $options[] = 'maxage=' . $section['age'];
                break;
            case 'between':
                $options[] = 'minage=' . $section['age'];
                $options[] = 'maxage=' . $section['endage'];
                break;
        }
        if (in_array('MIXED', $section['categories'])) {
            $categories = array('MIXED');
            foreach ($section['exclude_categories'] as $exclude) {
                if (empty($exclude)) {
                    continue;
                }
                $categories[] = "-{$exclude}";
            }
            $options[] = 'category=' . join(',', $categories);
        } else {
            $categories = array();
            foreach ($section['categories'] as $category) {
                $categories[] = $category;
            }
            $options[] = 'category=' . join(',', $categories);
        }
        if (in_array('', $section['sponsors'])) {
            $sponsors = array('any');
            foreach ($section['exclude_sponsors'] as $exclude) {
                if (empty($exclude)) {
                    continue;
                }
                $sponsors[] = "-{$exclude}";
            }
            $options[] = 'sponsor=' . join(',', $sponsors);
        } else {
            $sponsors = array();
            foreach ($section['sponsors'] as $sponsor) {
                $sponsors[] = $sponsor;
            }
            $options[] = 'sponsor=' . join(',', $sponsors);
        }
        if ($section['getnew'] == 'false') {
            $section['order'] = $section['reorder'];
        }
        $options[] = 'order=' . join(', ', $section['order']);
        if ($section['getnew'] != 'false') {
            $options[] = 'reorder=' . join(', ', $section['reorder']);
        }
        $template .= "{* PULL THE " . strtoupper($section['type']) . " GALLERIES FROM THE DATABASE *}\n" . "{galleries\n" . "var=" . ($intermix ? "\${$section['type']}_gals\n" : "\$galleries\n") . join("\n", $options) . "}\n";
    }
    $code = array('text' => '{$gallery.date|tdate} <a href="{$gallery.gallery_url|htmlspecialchars}" target="_blank">{$gallery.thumbnails|htmlspecialchars} {$gallery.category|htmlspecialchars}</a><br />', 'thumbs' => '<a href="{$gallery.gallery_url|htmlspecialchars}" target="_blank"><img src="{$gallery.preview_url|htmlspecialchars}" border="0" alt="Thumb"></a>', 'xml' => "<item>\n" . "<title>{\$gallery.thumbnails|htmlspecialchars} {\$gallery.category|htmlspecialchars} {\$gallery.format|htmlspecialchars}</title>\n" . "<link>{\$gallery.gallery_url|htmlspecialchars}</link>\n" . "<description>{\$gallery.description|htmlspecialchars}</description>" . "<pubDate>{\$gallery.date|tdate::'D, d M Y H:i:s " . RssTimezone() . "'}</pubDate>\n" . "</item>", 'xmlthumbs' => "<item>\n" . "<title>{\$gallery.thumbnails|htmlspecialchars} {\$gallery.category|htmlspecialchars} {\$gallery.format|htmlspecialchars}</title>\n" . "<link>{\$gallery.gallery_url|htmlspecialchars}</link>\n" . "<description>\n" . "&lt;a href=&quot;{\$gallery.gallery_url|htmlspecialchars}&quot; title=&quot;Thumb&quot;&gt;&lt;img src=&quot;{\$gallery.preview_url|htmlspecialchars}&quot; alt=&quot;Thumb&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;\n" . "&lt;br /&gt;&lt;br /&gt;\n" . "{\$gallery.description|htmlspecialchars}\n" . "</description>\n" . "<pubDate>{\$gallery.date|tdate::'D, d M Y H:i:s " . RssTimezone() . "'}</pubDate>\n" . "</item>");
    if ($intermix) {
        $location = 'random';
        switch ($_REQUEST['mix_method']) {
            case 'interval':
                $_REQUEST['mix_value'] = preg_replace('~[^0-9]~', '', $_REQUEST['mix_value']);
                $location = "+{$_REQUEST['mix_value']}";
                break;
            case 'locations':
                $location = $_REQUEST['mix_value'];
                break;
        }
        $template .= "{* MIX THE PERMANENT AND SUBMITTED GALLERIES TOGETHER *}\n" . "{intermix var=\$galleries from=\$submitted_gals,\$permanent_gals location={$location}}\n\n";
    }
    if ($_REQUEST['inrows'] == 'yes') {
        $template .= "<table align=\"center\" cellpadding=\"5\" border=\"0\">\n" . "<tr>\n";
        $code['thumbs'] = '<td>' . $code['thumbs'] . '</td>';
        $code['text'] = '<td>' . $code['text'] . '</td>';
    }
    $template .= "{* DISPLAY ALL OF THE GALLERIES *}\n" . "{foreach var=\$gallery from=\$galleries counter=\$counter}\n" . $code[$_REQUEST['display']] . "\n";
    if ($_REQUEST['inrows'] == 'yes' && $_REQUEST['amount'] > $_REQUEST['perrow']) {
        $template .= "{insert counter=\$counter location=+{$_REQUEST['perrow']} max=" . ($_REQUEST['amount'] - $_REQUEST['perrow']) . "}\n" . "</tr><tr>\n" . "{/insert}\n";
    }
    $template .= "{/foreach}\n";
    if ($_REQUEST['inrows'] == 'yes') {
        $template .= "</tr>\n" . "</table>\n";
    }
    if ($rss_feed) {
        $template = "{define name=globaldupes value=true}\n" . "{define name=pagedupes value=false}\n" . "{php} echo '<?xml  version=\"1.0\" ?>'; {/php}\n" . "<rss version=\"2.0\">\n" . "  <channel>\n" . "    <title>Your Site Title</title>\n" . "    <description>Your site description</description>\n" . "    <link>http://www.yoursite.com/</link>\n" . $template . "  </channel>\n" . "</rss>";
    }
    include_once 'includes/header.php';
    echo "<div style=\"padding: 10px;\">\n";
    echo "Here is your generated template code:<br /><br />\n<textarea rows=\"40\" cols=\"140\" wrap=\"off\">";
    echo htmlspecialchars($template);
    echo "</textarea>\n</div>\n</body>\n</html>";
}
Exemplo n.º 2
0
function tlxPageTemplateWizard()
{
    global $DB, $C;
    $template = '';
    $replacements = array('%%RANKS%%' => "{$_REQUEST['ranks_start']}-{$_REQUEST['ranks_end']}", '%%RSSTIMEZONE%%' => RssTimezone());
    IniParse("{$GLOBALS['BASE_DIR']}/admin/includes/pages-templates-wizard-code.php", TRUE, $code);
    if (in_array('MIXED', $_REQUEST['categories'])) {
        $categories = array('MIXED');
        foreach ($_REQUEST['exclude_categories'] as $exclude) {
            if (empty($exclude)) {
                continue;
            }
            $categories[] = "-{$exclude}";
        }
        $replacements['%%CATEGORY%%'] = join(',', $categories);
    } else {
        $categories = array();
        foreach ($_REQUEST['categories'] as $category) {
            $categories[] = $category;
        }
        $replacements['%%CATEGORY%%'] = join(',', $categories);
    }
    $replacements['%%ORDER%%'] = trim("{$_REQUEST['order']} {$_REQUEST['direction']}");
    $replacements['%%MINHITS%%'] = $_REQUEST['minhits'];
    $template = $code[$_REQUEST['display']];
    $template = str_replace(array_keys($replacements), array_values($replacements), $template);
    include_once 'includes/header.php';
    echo "<div style=\"padding: 10px;\">\n";
    echo "Here is your generated template code:<br /><br />\n<textarea rows=\"40\" cols=\"140\" wrap=\"off\">";
    echo htmlspecialchars($template);
    echo "</textarea>\n</div>\n</body>\n</html>";
}