Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public static function getContainer()
 {
     if (!self::$container) {
         self::$container = new Textpattern_Container_Container();
     }
     return self::$container;
 }
Ejemplo n.º 2
0
 /**
  * Wipes automatically registered superglobals.
  *
  * Protects the server from global registering
  * and overwriting attempts.
  *
  * @throws Textpattern_Security_Exception
  * @return Textpattern_Security_Filter
  */
 public function registerGlobals()
 {
     if (Txp::get('Textpattern_Server_Config')->getRegisterGlobals()) {
         if (array_key_exists('GLOBALS', $_REQUEST) || array_key_exists('GLOBALS', $_FILES)) {
             throw new Textpattern_Security_Exception('GLOBALS overwrite attempt detected. Please consider turning register_globals off.');
         }
         $variables = array_merge(isset($_SESSION) ? (array) $_SESSION : array(), (array) $_ENV, (array) $_GET, (array) $_POST, (array) $_COOKIE, (array) $_FILES, (array) $_SERVER);
         foreach ($variables as $variable => $value) {
             if (!in_array($variable, $this->protectedGlobals, true)) {
                 unset($GLOBALS[$variable]);
             }
         }
     }
     return $this;
 }
Ejemplo n.º 3
0
/**
 * Parse a tag for attributes and hand over to the tag handler function.
 *
 * @param  string      $tag   The tag name
 * @param  string      $atts  The attribute string
 * @param  string|null $thing The tag's content in case of container tags
 * @return string Parsed tag result
 * @package TagParser
 */
function processTags($tag, $atts, $thing = null)
{
    global $production_status, $txp_current_tag, $txp_current_form;
    static $registry = null;
    if ($production_status !== 'live') {
        $old_tag = $txp_current_tag;
        $txp_current_tag = '<txp:' . $tag . $atts . (isset($thing) ? '>' : '/>');
        trace_add($txp_current_tag, 1, "Form='{$txp_current_form}', Tag='{$txp_current_tag}'");
    }
    if ($registry === null) {
        $registry = Txp::get('\\Textpattern\\Tag\\Registry');
    }
    if ($registry->isRegistered($tag)) {
        $out = $registry->process($tag, splat($atts), $thing);
    } elseif (maybe_tag($tag)) {
        $out = $tag(splat($atts), $thing);
        trigger_error(gTxt('unregistered_tag'), E_USER_NOTICE);
    } elseif (isset($GLOBALS['pretext'][$tag])) {
        $out = txpspecialchars($pretext[$tag]);
        trigger_error(gTxt('deprecated_tag'), E_USER_NOTICE);
    } else {
        $out = '';
        trigger_error(gTxt('unknown_tag'), E_USER_WARNING);
    }
    if ($production_status !== 'live') {
        trace_add('', -1);
        if (isset($thing)) {
            trace_add("</txp:{$tag}>");
        }
        $txp_current_tag = $old_tag;
    }
    return $out;
}
Ejemplo n.º 4
0
/**
 * Renders article formatting tips.
 *
 * The rendered widget can be customised via the 'article_ui > sidehelp'
 * pluggable UI callback event.
 *
 * @param array $rs Article data
 */
function article_partial_sidehelp($rs)
{
    // Show markup help for both body and excerpt if they are different.
    $help = Txp::get('\\Textpattern\\Textfilter\\Registry')->getHelp($rs['textile_body']);
    if ($rs['textile_body'] != $rs['textile_excerpt']) {
        $help .= Txp::get('\\Textpattern\\Textfilter\\Registry')->getHelp($rs['textile_excerpt']);
    }
    $out = wrapRegion('txp-textfilter-group', $help, 'txp-textfilter-group-content', 'textfilter_help', 'article_textfilter_help');
    return pluggable_ui('article_ui', 'sidehelp', $out, $rs);
}
Ejemplo n.º 5
0
/**
 * Outputs a diagnostics report.
 *
 * This is the main panel.
 */
function doDiagnostics()
{
    global $prefs, $files, $txpcfg, $event, $step, $theme, $DB;
    extract(get_prefs());
    $urlparts = parse_url(hu);
    $mydomain = $urlparts['host'];
    $is_apache = stristr(serverSet('SERVER_SOFTWARE'), 'Apache') || is_callable('apache_get_version');
    $real_doc_root = isset($_SERVER['DOCUMENT_ROOT']) ? realpath($_SERVER['DOCUMENT_ROOT']) : '';
    // ini_get() returns string values passed via php_value as a string, not boolean.
    $is_register_globals = (strcasecmp(ini_get('register_globals'), 'on') === 0 or ini_get('register_globals') === '1');
    // Check for Textpattern updates, at most once every 24 hours.
    $now = time();
    $updateInfo = unserialize(get_pref('last_update_check', ''));
    if (!$updateInfo || $now > $updateInfo['when'] + 60 * 60 * 24) {
        $updates = checkUpdates();
        $updateInfo['msg'] = $updates ? gTxt($updates['msg'], array('{version}' => $updates['version'])) : '';
        $updateInfo['when'] = $now;
        set_pref('last_update_check', serialize($updateInfo), 'publish', PREF_HIDDEN, 'text_input');
    }
    $fail = array();
    if (!empty($updateInfo['msg'])) {
        $fail['textpattern_version_update'] = diag_msg_wrap($updateInfo['msg'], 'information');
    }
    if (!is_callable('version_compare') || version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) {
        $fail['php_version_required'] = diag_msg_wrap(gTxt('php_version_required', array('{version}' => REQUIRED_PHP_VERSION)));
    }
    if (!isset($path_to_site)) {
        $fail['path_to_site_missing'] = diag_msg_wrap(gTxt('path_to_site_missing'), 'warning');
    }
    if (@gethostbyname($mydomain) === $mydomain) {
        $fail['dns_lookup_fails'] = diag_msg_wrap(gTxt('dns_lookup_fails') . cs . $mydomain, 'warning');
    }
    if (!@is_dir($path_to_site)) {
        $fail['path_to_site_inacc'] = diag_msg_wrap(gTxt('path_to_site_inacc') . cs . $path_to_site);
    }
    if (rtrim($siteurl, '/') != $siteurl) {
        $fail['site_trailing_slash'] = diag_msg_wrap(gTxt('site_trailing_slash') . cs . $path_to_site, 'warning');
    }
    if (!@is_file($path_to_site . "/index.php") || !@is_readable($path_to_site . "/index.php")) {
        $fail['index_inaccessible'] = diag_msg_wrap("{$path_to_site}/index.php " . gTxt('is_inaccessible'));
    }
    $not_readable = array();
    if (!@is_writable($path_to_site . '/' . $img_dir)) {
        $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('img_dir'), gTxt('dir_not_writable')) . ": {$path_to_site}/{$img_dir}", 'warning');
    }
    if (!@is_writable($file_base_path)) {
        $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('file_base_path'), gTxt('dir_not_writable')) . ": {$file_base_path}", 'warning');
    }
    if (!@is_writable($tempdir)) {
        $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('tempdir'), gTxt('dir_not_writable')) . ": {$tempdir}", 'warning');
    }
    if ($not_readable) {
        $fail['dir_not_writable'] = join(n, $not_readable);
    }
    if ($permlink_mode != 'messy' && !$is_apache) {
        $fail['cleanurl_only_apache'] = diag_msg_wrap(gTxt('cleanurl_only_apache'), 'information');
    }
    if ($permlink_mode != 'messy' and !@is_readable($path_to_site . '/.htaccess')) {
        $fail['htaccess_missing'] = diag_msg_wrap(gTxt('htaccess_missing'));
    }
    if ($permlink_mode != 'messy' and is_callable('apache_get_modules') and !apache_module('mod_rewrite')) {
        $fail['mod_rewrite_missing'] = diag_msg_wrap(gTxt('mod_rewrite_missing'));
    }
    if (!ini_get('file_uploads')) {
        $fail['file_uploads_disabled'] = diag_msg_wrap(gTxt('file_uploads_disabled'), 'information');
    }
    if (@is_dir(txpath . DS . 'setup')) {
        $fail['setup_still_exists'] = diag_msg_wrap(txpath . DS . "setup" . DS . ' ' . gTxt('still_exists'), 'warning');
    }
    if (empty($tempdir)) {
        $fail['no_temp_dir'] = diag_msg_wrap(gTxt('no_temp_dir'), 'warning');
    }
    if (is_disabled('mail')) {
        $fail['warn_mail_unavailable'] = diag_msg_wrap(gTxt('warn_mail_unavailable'), 'warning');
    }
    if ($is_register_globals) {
        $fail['warn_register_globals_or_update'] = diag_msg_wrap(gTxt('warn_register_globals_or_update'), 'warning');
    }
    if ($permlink_mode != 'messy') {
        $rs = safe_column("name", "txp_section", "1");
        foreach ($rs as $name) {
            if ($name and @file_exists($path_to_site . '/' . $name)) {
                $fail['old_placeholder_exists'] = diag_msg_wrap(gTxt('old_placeholder') . ": {$path_to_site}/{$name}");
            }
        }
    }
    $cs = check_file_integrity(INTEGRITY_REALPATH);
    if (!$cs) {
        $cs = array();
    }
    // Files that don't match their checksums.
    if ($modified_files = array_keys($cs, INTEGRITY_MODIFIED)) {
        $fail['modified_files'] = diag_msg_wrap(gTxt('modified_files') . cs . n . t . join(', ' . n . t, $modified_files), 'warning');
    }
    // Running development code in live mode is not recommended.
    if (preg_match('/-dev$/', txp_version) and $production_status == 'live') {
        $fail['dev_version_live'] = diag_msg_wrap(gTxt('dev_version_live'), 'warning');
    }
    // Missing files.
    if ($missing = array_merge(array_keys($cs, INTEGRITY_MISSING), array_keys($cs, INTEGRITY_NOT_FILE), array_keys($cs, INTEGRITY_NOT_READABLE))) {
        $fail['missing_files'] = diag_msg_wrap(gTxt('missing_files') . cs . n . t . join(', ' . n . t, $missing));
    }
    // Anything might break if arbitrary functions are disabled.
    if (ini_get('disable_functions')) {
        $disabled_funcs = array_map('trim', explode(',', ini_get('disable_functions')));
        // Commonly disabled functions that we don't need.
        $disabled_funcs = array_diff($disabled_funcs, array('imagefilltoborder', 'escapeshellarg', 'escapeshellcmd', 'exec', 'passthru', 'proc_close', 'proc_get_status', 'proc_nice', 'proc_open', 'proc_terminate', 'shell_exec', 'system', 'popen', 'dl', 'chown'));
        if ($disabled_funcs) {
            $fail['some_php_functions_disabled'] = diag_msg_wrap(gTxt('some_php_functions_disabled') . cs . join(', ', $disabled_funcs), 'warning');
        }
    }
    // Not sure about this one.
    //    if (strncmp(php_sapi_name(), 'cgi', 3) == 0 and ini_get('cgi.rfc2616_headers'))
    //    $fail['cgi_header_config'] = gTxt('cgi_header_config');
    $guess_site_url = $_SERVER['HTTP_HOST'] . preg_replace('#[/\\\\]$#', '', dirname(dirname($_SERVER['SCRIPT_NAME'])));
    if ($siteurl and strip_prefix($siteurl, 'www.') != strip_prefix($guess_site_url, 'www.')) {
        $fail['site_url_mismatch'] = diag_msg_wrap(gTxt('site_url_mismatch') . cs . $guess_site_url, 'warning');
    }
    // Test clean URL server vars.
    if (hu) {
        if (ini_get('allow_url_fopen') and $permlink_mode != 'messy') {
            $s = md5(uniqid(rand(), true));
            ini_set('default_socket_timeout', 10);
            $pretext_data = @file(hu . $s . '/?txpcleantest=1');
            if ($pretext_data) {
                $pretext_req = trim(@$pretext_data[0]);
                if ($pretext_req != md5('/' . $s . '/?txpcleantest=1')) {
                    $fail['clean_url_data_failed'] = diag_msg_wrap(gTxt('clean_url_data_failed') . cs . txpspecialchars($pretext_req), 'warning');
                }
            } else {
                $fail['clean_url_test_failed'] = diag_msg_wrap(gTxt('clean_url_test_failed'), 'warning');
            }
        }
    }
    if ($tables = list_txp_tables()) {
        $table_errors = check_tables($tables);
        if ($table_errors) {
            $fail['mysql_table_errors'] = diag_msg_wrap(gTxt('mysql_table_errors') . cs . n . t . join(', ' . n . t, $table_errors));
        }
    }
    $active_plugins = array();
    if ($rows = safe_rows('name, version, code_md5, md5(code) as md5', 'txp_plugin', 'status > 0')) {
        foreach ($rows as $row) {
            $n = $row['name'] . '-' . $row['version'];
            if (strtolower($row['md5']) != strtolower($row['code_md5'])) {
                $n .= 'm';
            }
            $active_plugins[] = $n;
        }
    }
    $theme_manifest = $theme->manifest();
    // Check GD info.
    if (function_exists('gd_info')) {
        $gd_info = gd_info();
        $gd_support = array();
        if ($gd_info['GIF Create Support']) {
            $gd_support[] = 'GIF';
        }
        // Aside: In PHP 5.3, they chose to add a previously unemployed capital "E" to the array key.
        if (!empty($gd_info['JPEG Support']) || !empty($gd_info['JPG Support'])) {
            $gd_support[] = 'JPG';
        }
        if ($gd_info['PNG Support']) {
            $gd_support[] = 'PNG';
        }
        if ($gd_support) {
            $gd_support = join(', ', $gd_support);
        } else {
            $gd_support = gTxt('none');
        }
        $gd = gTxt('gd_info', array('{version}' => $gd_info['GD Version'], '{supported}' => $gd_support));
    } else {
        $gd = gTxt('gd_unavailable');
    }
    if (realpath($prefs['tempdir']) === realpath($prefs['plugin_cache_dir'])) {
        $fail['tmp_plugin_paths_match'] = diag_msg_wrap(gTxt('tmp_plugin_paths_match'));
    }
    // Database server time.
    extract(doSpecial(getRow('select @@global.time_zone as db_global_timezone, @@session.time_zone as db_session_timezone, now() as db_server_time, unix_timestamp(now()) as db_server_timestamp')));
    $db_server_timeoffset = $db_server_timestamp - $now;
    echo pagetop(gTxt('tab_diagnostics'), '');
    echo hed(gTxt('tab_diagnostics'), 1, array('class' => 'txp-heading'));
    echo n . '<div id="' . $event . '_container" class="txp-container">' . n . '<div id="pre_flight_check">' . hed(gTxt('preflight_check'), 2);
    if ($fail) {
        foreach ($fail as $help => $message) {
            echo graf(nl2br($message) . popHelp($help));
        }
    } else {
        echo graf(diag_msg_wrap(gTxt('all_checks_passed'), 'success'));
    }
    echo '</div>';
    echo '<div id="diagnostics">', hed(gTxt('diagnostic_info'), 2);
    $fmt_date = '%Y-%m-%d %H:%M:%S';
    $out = array('<p><textarea class="code" id="diagnostics-detail" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr" readonly>', gTxt('txp_version') . cs . txp_version . ' (' . check_file_integrity(INTEGRITY_DIGEST) . ')' . n, gTxt('last_update') . cs . gmstrftime($fmt_date, $dbupdatetime) . '/' . gmstrftime($fmt_date, @filemtime(txpath . '/update/_update.php')) . n, gTxt('document_root') . cs . @$_SERVER['DOCUMENT_ROOT'] . ($real_doc_root != @$_SERVER['DOCUMENT_ROOT'] ? ' (' . $real_doc_root . ')' : '') . n, '$path_to_site' . cs . $path_to_site . n, gTxt('txp_path') . cs . txpath . n, gTxt('permlink_mode') . cs . $permlink_mode . n, ini_get('open_basedir') ? 'open_basedir: ' . ini_get('open_basedir') . n : '', ini_get('upload_tmp_dir') ? 'upload_tmp_dir: ' . ini_get('upload_tmp_dir') . n : '', gTxt('tempdir') . cs . $tempdir . n, gTxt('web_domain') . cs . $siteurl . n, gTxt('php_version') . cs . phpversion() . n, $is_register_globals ? gTxt('register_globals') . cs . $is_register_globals . n : '', gTxt('gd_library') . cs . $gd . n, gTxt('server') . ' TZ: ' . Txp::get('Textpattern_Date_Timezone')->getTimeZone() . n, gTxt('server_time') . cs . strftime('%Y-%m-%d %H:%M:%S') . n, strip_tags(gTxt('is_dst')) . cs . $is_dst . n, strip_tags(gTxt('auto_dst')) . cs . $auto_dst . n, strip_tags(gTxt('gmtoffset')) . cs . $timezone_key . sp . "({$gmtoffset})" . n, 'MySQL' . cs . mysql_get_server_info() . n, gTxt('db_server_time') . cs . $db_server_time . n, gTxt('db_server_timeoffset') . cs . $db_server_timeoffset . ' s' . n, gTxt('db_global_timezone') . cs . $db_global_timezone . n, gTxt('db_session_timezone') . cs . $db_session_timezone . n, gTxt('locale') . cs . $locale . n, isset($_SERVER['SERVER_SOFTWARE']) ? gTxt('server') . cs . $_SERVER['SERVER_SOFTWARE'] . n : '', is_callable('apache_get_version') ? gTxt('apache_version') . cs . @apache_get_version() . n : '', gTxt('php_sapi_mode') . cs . PHP_SAPI . n, gTxt('rfc2616_headers') . cs . ini_get('cgi.rfc2616_headers') . n, gTxt('os_version') . cs . php_uname('s') . ' ' . php_uname('r') . n, $active_plugins ? gTxt('active_plugins') . cs . join(', ', $active_plugins) . n : '', gTxt('theme_name') . cs . $theme_name . sp . $theme_manifest['version'] . n, $fail ? n . gTxt('preflight_check') . cs . n . ln . join("\n", doStripTags($fail)) . n . ln : '', is_readable($path_to_site . '/.htaccess') ? n . gTxt('htaccess_contents') . cs . n . ln . txpspecialchars(join('', file($path_to_site . '/.htaccess'))) . n . ln : '');
    if ($step == 'high') {
        $out[] = n . 'Charset (default/config)' . cs . $DB->default_charset . '/' . $DB->charset . n;
        $result = safe_query("SHOW variables like 'character_se%'");
        while ($row = mysql_fetch_row($result)) {
            $out[] = $row[0] . cs . $row[1] . n;
            if ($row[0] == 'character_set_connection') {
                $conn_char = $row[1];
            }
        }
        $table_names = array(PFX . 'textpattern');
        $result = safe_query("SHOW TABLES LIKE '" . PFX . "txp\\_%'");
        while ($row = mysql_fetch_row($result)) {
            $table_names[] = $row[0];
        }
        $table_msg = array();
        foreach ($table_names as $table) {
            $ctr = safe_query("SHOW CREATE TABLE " . $table . "");
            if (!$ctr) {
                unset($table_names[$table]);
                continue;
            }
            $ctcharset = preg_replace('#^CREATE TABLE.*SET=([^ ]+)[^)]*$#is', '\\1', mysql_result($ctr, 0, 'Create Table'));
            if (isset($conn_char) && !stristr($ctcharset, 'CREATE') && $conn_char != $ctcharset) {
                $table_msg[] = "{$table} is {$ctcharset}";
            }
            $ctr = safe_query("CHECK TABLE " . $table);
            if (in_array(mysql_result($ctr, 0, 'Msg_type'), array('error', 'warning'))) {
                $table_msg[] = $table . cs . mysql_result($ctr, 0, 'Msg_Text');
            }
        }
        if ($table_msg == array()) {
            $table_msg = count($table_names) < 17 ? array('-') : array('OK');
        }
        $out[] = count($table_names) . ' Tables' . cs . implode(', ', $table_msg) . n;
        $cf = preg_grep('/^custom_\\d+/', getThings('describe `' . PFX . 'textpattern`'));
        $out[] = n . get_pref('max_custom_fields', 10) . sp . gTxt('custom') . cs . implode(', ', $cf) . sp . '(' . count($cf) . ')' . n;
        $extns = get_loaded_extensions();
        $extv = array();
        foreach ($extns as $e) {
            $extv[] = $e . (phpversion($e) ? '/' . phpversion($e) : '');
        }
        $out[] = n . gTxt('php_extensions') . cs . join(', ', $extv) . n;
        if (is_callable('apache_get_modules')) {
            $out[] = n . gTxt('apache_modules') . cs . join(', ', apache_get_modules()) . n;
        }
        if (@is_array($pretext_data) and count($pretext_data) > 1) {
            $out[] = n . gTxt('pretext_data') . cs . txpspecialchars(join('', array_slice($pretext_data, 1, 20))) . n;
        }
        $out[] = n;
        if ($md5s = check_file_integrity(INTEGRITY_MD5)) {
            foreach ($md5s as $f => $checksum) {
                $out[] = $f . cs . n . t . (!$checksum ? gTxt('unknown') : $checksum) . n;
            }
        }
        $out[] = n . ln;
    }
    $out[] = callback_event('diag_results', $step) . n;
    $out[] = '</textarea></p>';
    $dets = array('low' => gTxt('low'), 'high' => gTxt('high'));
    $out[] = form(graf(eInput('diag') . n . '<label>' . gTxt('detail') . '</label>' . selectInput('step', $dets, $step, 0, 1)));
    echo join('', $out), '</div>', '</div>';
}
Ejemplo n.º 6
0
/**
 * Creates a new user.
 */
function author_save_new()
{
    require_privs('admin.edit');
    extract(psa(array('privs', 'name', 'email', 'RealName')));
    $privs = assert_int($privs);
    if (is_valid_username($name) && is_valid_email($email)) {
        if (user_exists($name)) {
            author_edit(array(gTxt('author_already_exists', array('{name}' => $name)), E_ERROR));
            return;
        }
        $password = Txp::get('\\Textpattern\\Password\\Random')->generate(PASSWORD_LENGTH);
        $rs = create_user($name, $email, $password, $RealName, $privs);
        if ($rs) {
            $message = send_account_activation($name);
            author_list($message);
            return;
        }
    }
    author_edit(array(gTxt('error_adding_new_author'), E_ERROR));
}
<?php

# --- BEGIN PLUGIN CODE ---
if (class_exists('\\Textpattern\\Tag\\Registry')) {
    // Register Textpattern tags for TXP 4.6+.
    Txp::get('\\Textpattern\\Tag\\Registry')->register('oui_dailymotion')->register('oui_if_dailymotion');
}
function oui_dailymotion($atts, $thing)
{
    global $thisarticle;
    extract(lAtts(array('video' => '', 'custom' => 'dailymotion ID', 'width' => '0', 'height' => '0', 'ratio' => '4:3', 'api' => '', 'autoplay' => '0', 'chromeless' => '0', 'highlight' => 'ffcc33', 'html' => '0', 'playerid' => '', 'info' => '1', 'logo' => '1', 'network' => '', 'origin' => '', 'quality' => '', 'related' => '1', 'start' => '0', 'startscreen' => '', 'syndication' => '', 'wmode' => 'transparent', 'label' => '', 'labeltag' => '', 'wraptag' => '', 'class' => __FUNCTION__), $atts));
    $custom = strtolower($custom);
    if (!$video && isset($thisarticle[$custom])) {
        $video = $thisarticle[$custom];
    }
    /*
     * Check for dailymotion video ID or dailymotion URL to extract ID from
     */
    $match = _oui_dailymotion($video);
    if ($match) {
        $video = $match;
    } elseif (empty($video)) {
        return '';
    }
    $src = '//www.dailymotion.com/embed/video/' . $video;
    /*
     * Attributes.
     */
    $qAtts = array('highlight' => $highlight, 'id' => $playerid, 'origin' => $origin, 'start' => $start, 'syndication' => $syndication, 'autoplay' => array($autoplay => '0, 1'), 'chromeless' => array($chromeless => '0, 1'), 'html' => array($html => '0, 1'), 'info' => array($info => '0, 1'), 'logo' => array($logo => '0, 1'), 'related' => array($related => '0, 1'), 'api' => array($api => 'postMessage, fragment, location'), 'network' => array($network => 'dsl, cellular'), 'quality' => array($quality => '240, 380, 480, 720, 1080, 1440, 2160'), 'startscreen' => array($startscreen => 'flash, html'), 'wmode' => array($wmode => 'transparent, opaque'));
    $qString = array();
    foreach ($qAtts as $att => $value) {
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function __construct($filename)
 {
     $this->parser = Txp::get('Textpattern_Textpack_Parser');
     parent::__construct($filename);
 }
Ejemplo n.º 9
0
?>
">
<head>
<meta charset="utf-8">
<title><?php 
echo gTxt('build');
?>
 &#124; Textpattern CMS</title><?php 
echo script_js('vendors/jquery/jquery/jquery.js', TEXTPATTERN_SCRIPT_URL) . script_js('vendors/jquery/ui/js/jquery-ui.js', TEXTPATTERN_SCRIPT_URL) . script_js('//code.jquery.com/jquery-migrate-1.2.1.js', TEXTPATTERN_SCRIPT_URL) . script_js('var textpattern = ' . json_encode(array('event' => $event, 'step' => $step, '_txp_token' => form_token(), 'textarray' => (object) null)) . ';') . script_js('textpattern.js', TEXTPATTERN_SCRIPT_URL) . n;
// Mandatory un-themable Textpattern core styles
echo $theme->html_head();
?>
</head>
<body id="tag-event">
<?php 
echo Txp::get('Textpattern_Tag_BuilderTags')->renderTagHelp(gps('tag_name'));
?>
</body>
</html>
<?php 
/**
 * Collection of tag builder functions.
 *
 * @package Admin\Tag
 */
class Textpattern_Tag_BuilderTags
{
    /**
     * HTML block for the header portion of the form tag.
     *
     * @var string
Ejemplo n.º 10
0
 /**
  * Is DST in effect?
  *
  * @param  int    $timestamp    When?
  * @param  string $timezone_key Where?
  * @return bool
  * @deprecated in 4.6.0
  * @see        Textpattern_Date_Timezone::isDst()
  */
 public static function is_dst($timestamp, $timezone_key)
 {
     return Txp::get('Textpattern_Date_Timezone')->isDst($timestamp, $timezone_key);
 }
Ejemplo n.º 11
0
/**
 * Resets the given user's password and emails it.
 *
 * The old password is replaced with a new random-generated one.
 *
 * Should NEVER be used as sending plaintext passwords is wrong.
 * Will be removed in future, in lieu of sending reset request tokens.
 *
 * @param  string $name The login name
 * @return string A localized message string
 * @deprecated in 4.6.0
 * @see    PASSWORD_LENGTH
 * @see    generate_password()
 * @example
 * echo reset_author_pass('username');
 */
function reset_author_pass($name)
{
    $email = safe_field("email", 'txp_users', "name = '" . doSlash($name) . "'");
    $new_pass = Txp::get('\\Textpattern\\Password\\Random')->generate(PASSWORD_LENGTH);
    $rs = change_user_password($name, $new_pass);
    if ($rs) {
        if (send_new_password($new_pass, $email, $name)) {
            return gTxt('password_sent_to') . ' ' . $email;
        } else {
            return gTxt('could_not_mail') . ' ' . $email;
        }
    } else {
        return gTxt('could_not_update_author') . ' ' . txpspecialchars($name);
    }
}
Ejemplo n.º 12
0
 /**
  * Validates filter selection.
  *
  * @return bool
  */
 public function validate()
 {
     return array_key_exists($this->value, Txp::get('Textpattern_Textfilter_Registry')->getMap());
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function __construct($filename)
 {
     $this->parser = \Txp::get('\\Textpattern\\Textpack\\Parser');
     parent::__construct($filename);
 }
Ejemplo n.º 14
0
<head>
    <meta charset="utf-8">
    <title><?php 
echo gTxt('build');
?>
 &#124; Textpattern CMS</title><?php 
echo script_js('vendors/jquery/jquery/jquery.js', TEXTPATTERN_SCRIPT_URL) . script_js('vendors/jquery/jquery-ui/jquery-ui.js', TEXTPATTERN_SCRIPT_URL) . script_js('var textpattern = ' . json_encode(array('event' => $event, 'step' => $step, '_txp_token' => form_token(), 'textarray' => (object) null)) . ';') . script_js('textpattern.js', TEXTPATTERN_SCRIPT_URL) . n;
// Mandatory un-themable Textpattern core styles
?>
    <?php 
echo $theme->html_head();
?>
</head>
<body id="tag-event">
<?php 
echo \Txp::get('\\Textpattern\\Tag\\BuilderTags')->renderTagHelp(gps('tag_name'));
?>
</body>
</html>
<?php 
/**
 * Collection of tag builder functions.
 *
 * @package Admin\Tag
 */
class BuilderTags
{
    /**
     * HTML block for the header portion of the form tag.
     *
     * @var string
Ejemplo n.º 15
0
 * as published by the Free Software Foundation, version 2.
 *
 * Textpattern is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Textpattern. If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Collection of tag functions.
 *
 * @package Tag
 */
Txp::get('Textpattern_Tag_Registry')->register('page_title')->register('css')->register('image')->register('thumbnail')->register('output_form')->register(array('Textpattern_Tag_Syntax_Partial', 'renderYield'), 'yield')->register(array('Textpattern_Tag_Syntax_Partial', 'renderIfYield'), 'if_yield')->register('feed_link')->register('link_feed_link')->register('linklist')->register('tpt_link', 'link')->register('linkdesctitle')->register('link_name')->register('link_url')->register('link_author')->register('link_description')->register('link_date')->register('link_category')->register('link_id')->register(array('Textpattern_Tag_Syntax_Link', 'renderIfFirstLink'), 'if_first_link')->register(array('Textpattern_Tag_Syntax_Link', 'renderIfLastLink'), 'if_last_link')->register('email')->register('password_protect')->register('recent_articles')->register('recent_comments')->register('related_articles')->register('popup')->register('category_list')->register('section_list')->register('search_input')->register('search_term')->register('link_to_next')->register('link_to_prev')->register('next_title')->register('prev_title')->register('site_name')->register('site_slogan')->register('link_to_home')->register('newer')->register('older')->register('text')->register('article_id')->register('article_url_title')->register('if_article_id')->register('posted')->register('expires')->register('if_expires')->register('if_expired')->register('modified')->register('comments_count')->register('comments_invite')->register('comments_form')->register('comments_error')->register('if_comments_error')->register('comments')->register('comments_preview')->register('if_comments_preview')->register('comment_permlink')->register('comment_id')->register('comment_name')->register('comment_email')->register('comment_web')->register('comment_time')->register('comment_message')->register('comment_anchor')->register(array('Textpattern_Tag_Syntax_Authors', 'renderAuthors'), 'authors')->register('author')->register('author_email')->register('if_author')->register('if_article_author')->register('body')->register('title')->register('excerpt')->register('category1')->register('category2')->register('category')->register('section')->register('keywords')->register('if_keywords')->register('if_article_image')->register('article_image')->register('search_result_title')->register('search_result_excerpt')->register('search_result_url')->register('search_result_date')->register('search_result_count')->register('image_index')->register('image_display')->register('images')->register('image_info')->register('image_url')->register('image_author')->register('image_date')->register(array('Textpattern_Tag_Syntax_Image', 'renderIfFirstImage'), 'if_first_image')->register(array('Textpattern_Tag_Syntax_Image', 'renderIfLastImage'), 'if_last_image')->register('if_thumbnail')->register('if_comments')->register('if_comments_allowed')->register('if_comments_disallowed')->register('if_individual_article')->register('if_article_list')->register('meta_keywords')->register('meta_author')->register('permlink')->register('lang')->register('breadcrumb')->register('if_excerpt')->register('if_search')->register('if_search_results')->register('if_category')->register('if_article_category')->register('if_first_category')->register('if_last_category')->register('if_section')->register('if_article_section')->register('if_first_section')->register('if_last_section')->register('php')->register('custom_field')->register('if_custom_field')->register('site_url')->register('error_message')->register('error_status')->register('if_status')->register('page_url')->register('if_different')->register('if_first_article')->register('if_last_article')->register('if_plugin')->register('file_download_list')->register('file_download')->register('file_download_link')->register('file_download_size')->register('file_download_created')->register('file_download_modified')->register('file_download_id')->register('file_download_name')->register('file_download_category')->register('file_download_author')->register('file_download_downloads')->register('file_download_description')->register(array('Textpattern_Tag_Syntax_File', 'renderIfFirstFile'), 'if_first_file')->register(array('Textpattern_Tag_Syntax_File', 'renderIfLastFile'), 'if_last_file')->register('hide')->register('rsd')->register('variable')->register('if_variable')->register('article')->register('article_custom')->register('txp_die')->register('comments_help')->register('comment_name_input')->register('comment_email_input')->register('comment_web_input')->register('comment_message_input')->register('comment_remember')->register('comment_preview')->register('comment_submit');
// -------------------------------------------------------------
function page_title($atts)
{
    global $parentid, $thisarticle, $id, $q, $c, $author, $context, $s, $pg, $sitename;
    extract(lAtts(array('separator' => ': '), $atts));
    $out = txpspecialchars($sitename . $separator);
    $parent_id = (int) $parentid;
    if ($parent_id) {
        $out .= gTxt('comments_on') . ' ' . escape_title(safe_field('Title', 'textpattern', "ID = {$parent_id}"));
    } elseif ($thisarticle['title']) {
        $out .= escape_title($thisarticle['title']);
    } elseif ($q) {
        $out .= gTxt('search_results') . txpspecialchars($separator . $q);
    } elseif ($c) {
        $out .= txpspecialchars(fetch_category_title($c, $context));
Ejemplo n.º 16
0
/**
 * Renders a HTML &lt;select&gt; list of cities for timezone selection.
 *
 * Can be altered by plugins via the 'prefs_ui > gmtoffset'
 * pluggable UI callback event.
 *
 * @param  string $name HTML name of the list
 * @param  string $val  Initial (or current) selected option
 * @return string HTML
 */
function gmtoffset_select($name, $val)
{
    // Fetch *hidden* pref
    $key = get_pref('timezone_key', '', true);
    if ($key === '') {
        $key = (string) Txp::get('Textpattern_Date_Timezone')->getTimezone();
    }
    $tz = new timezone();
    $ui = $tz->selectInput('timezone_key', $key, false, '', 'gmtoffset');
    return pluggable_ui('prefs_ui', 'gmtoffset', $ui, $name, $val);
}
Ejemplo n.º 17
0
 /**
  * Gets accepted language.
  *
  * If $languages is NULL, returns client's favoured language. If
  * string, checks whether the language is supported and
  * if an array, returns the language that the client favours the most.
  *
  * <code>
  * echo Txp::get('\Textpattern\Http\Request')->getAcceptedLanguage('fi-FI');
  * </code>
  *
  * The above will return 'fi-FI' as long as the Accept-Language header
  * contains an indentifier that matches Finnish, such as 'fi-fi', 'fi-Fi'
  * or 'fi'.
  *
  * @param  string|array $languages Languages to check
  * @param  float        $threshold Quality threshold
  * @return string|bool Accepted language, or FALSE
  */
 public function getAcceptedLanguage($languages = null, $threshold = 0.1)
 {
     $accepts = $this->getAcceptsMap($this->request->getVariable('HTTP_ACCEPT_LANGUAGE'));
     if ($languages === null) {
         $accepts = array_keys($accepts);
         return array_shift($accepts);
     }
     $top = 0;
     $acceptedLanguage = false;
     foreach ((array) $languages as $language) {
         $search = array($language);
         if ($identifiers = \Txp::get('\\Textpattern\\L10n\\Locale')->getLocaleIdentifiers($language)) {
             $search = array_map('strtolower', array_merge($search, $identifiers));
         }
         foreach ($accepts as $accept => $params) {
             if (in_array(strtolower($accept), $search, true) && $params['q'] >= $threshold && $params['q'] >= $top) {
                 $top = $quality;
                 // FIXME: $quality is made out of thin air.
                 $acceptedLanguage = $language;
             }
         }
     }
     return $acceptedLanguage;
 }
Ejemplo n.º 18
0
/**
 * Renders a dropdown for selecting Textfilter method preferences.
 *
 * @param  string $name Element name
 * @param  string $val  Current value
 * @param  string $id   HTML id attribute for the select input element
 * @return string HTML
 */
function pref_text($name, $val, $id = '')
{
    $id = $id ? $id : $name;
    $vals = Txp::get('Textpattern_Textfilter_Registry')->getMap();
    return selectInput($name, $vals, $val, '', '', $id);
}
Ejemplo n.º 19
0
/**
 * Saves the active language.
 */
function save_language()
{
    global $textarray, $locale;
    extract(psa(array('language')));
    if (safe_field("lang", 'txp_lang', "lang = '" . doSlash($language) . "' LIMIT 1")) {
        $locale = $prefs['locale'] = Txp::get('\\Textpattern\\L10n\\Locale')->getLanguageLocale($language);
        Txp::get('\\Textpattern\\L10n\\Locale')->setLocale(LC_ALL, $language);
        set_pref('locale', $locale);
        set_pref('language', $language);
        $textarray = load_lang($language);
        list_languages(gTxt('preferences_saved'));
        return;
    }
    list_languages(array(gTxt('language_not_installed', array('{name}' => $language)), E_ERROR));
}
Ejemplo n.º 20
0
abc_one_more => Noch einer
EOT;
**/
// End of textpack
if (!defined('txpinterface')) {
    @(include_once 'zem_tpl.php');
}
# --- BEGIN PLUGIN CODE ---
/**
 * This is pax_grep: A plugin for Textpattern
 * version 0.2.1
 * by John Stephens, adapted from rah_replace by Jukka Svahn
 * https://designop.us/
 */
if (class_exists('\\Textpattern\\Tag\\Registry')) {
    Txp::get('\\Textpattern\\Tag\\Registry')->register('pax_grep');
}
function pax_grep($atts, $thing)
{
    global $pretext;
    extract(lAtts(array('from' => '', 'to' => '', 'delimiter' => ','), $atts));
    $from = explode($delimiter, $from);
    $to = explode($delimiter, $to);
    $count = count($to);
    if ($count == 1) {
        $to = implode('', $to);
    }
    if ($count == 0) {
        $to = '';
    }
    return preg_replace($from, $to, parse($thing));