Exemplo n.º 1
0
function admin($message = '')
{
    global $txp_user;
    pagetop(gTxt('site_administration'), $message);
    if (is_disabled('mail')) {
        echo tag(gTxt('warn_mail_unavailable'), 'p', ' id="warning" ');
    }
    $email = fetch('email', 'txp_users', 'name', $txp_user);
    if (has_privs('admin.edit')) {
        echo author_form();
    }
    if (has_privs('admin.list')) {
        echo author_list();
    }
    echo new_pass_form();
    if (!has_privs('admin.edit')) {
        echo change_email_form($email);
    }
}
Exemplo n.º 2
0
function getDbInfo()
{
    $GLOBALS['textarray'] = setup_load_lang(ps('lang'));
    @(include txpath . '/config.php');
    if (!empty($txpcfg['db'])) {
        exit(graf(gTxt('already_installed', array('{txpath}' => txpath))));
    }
    if (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) {
        $guess_siteurl = @$_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
        $guess_siteurl .= $GLOBALS['rel_siteurl'];
    } else {
        $guess_siteurl = 'mysite.com';
    }
    echo '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', '<table id="setup" cellpadding="0" cellspacing="0" border="0">', tr(tda(hed(gTxt('welcome_to_textpattern'), 3) . graf(gTxt('need_details'), ' style="margin-bottom:3em"') . hed('MySQL', 3) . graf(gTxt('db_must_exist')), ' width="400" height="50" colspan="4" align="left"')), tr(fLabelCell(gTxt('mysql_login')) . fInputCell('duser', '', 1) . fLabelCell(gTxt('mysql_password')) . fInputCell('dpass', '', 2)), tr(fLabelCell(gTxt('mysql_server')) . fInputCell('dhost', 'localhost', 3) . fLabelCell(gTxt('mysql_database')) . fInputCell('ddb', '', 4)), tr(fLabelCell(gTxt('table_prefix')) . fInputCell('dprefix', '', 5) . tdcs(small(gTxt('prefix_warning')), 2)), tr(tdcs('&nbsp;', 4)), tr(tdcs(hed(gTxt('site_url'), 3) . graf(gTxt('please_enter_url')), 4)), tr(fLabelCell('http://') . tdcs(fInput('text', 'siteurl', $guess_siteurl, 'edit', '', '', 40) . popHelp('siteurl'), 3));
    if (is_disabled('mail')) {
        echo tr(tdcs(gTxt('warn_mail_unavailable'), 3, null, '" style="color:red;text-align:center'));
    }
    echo tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish')) . td() . td());
    echo endTable(), hInput('lang', LANG), sInput('printConfig'), '</form>';
}
Exemplo n.º 3
0
function author_edit($message = '')
{
    global $txp_user;
    pagetop(gTxt('site_administration'), $message);
    if (is_disabled('mail')) {
        echo tag(gTxt('warn_mail_unavailable'), 'p', ' id="warning" ');
    }
    $email = fetch('email', 'txp_users', 'name', $txp_user);
    echo n . '<div id="users_container" class="txp-container">';
    if (has_privs('admin.edit')) {
        echo n . '<div class="txp-edit">' . author_form() . '</div>';
    }
    if (has_privs('admin.list')) {
        echo author_list();
    }
    echo new_pass_form();
    if (!has_privs('admin.edit')) {
        echo change_email_form($email);
    }
    echo n . '</div>';
}
Exemplo n.º 4
0
 function updateUpdate($param)
 {
     // This is sort of a hack... The ssl configuration of the ipaddress has to be reflected properly in the domain too. So the web objects are initialized, the ssl parameters are changed on the fly and synced again. All this is because, apache will refuse to start if the ssl files are missing, which is f*****g terrible. (later)... Apache is actually ok. The whole damn problem is with iis. Be careful about the createExtraVariables. As for now, the web object doesn't create objects from the parent domain object, and thus web object will work indepnednely without the help of the domain parent object. Thus the parent of the web can anything. But if in the at any time in the future the web object starts needing any parameter from the domain, then this will have to be rewritten. Then the domain objects have to initialized first, then the web objects are initialized, and the web can be created only UNDER the domain, and not directly under this object.
     global $gbl, $sgbl, $login, $ghtml;
     $driverapp = $gbl->getSyncClass($this->__masterserver, $this->__readserver, 'web');
     $olddom = $this->domain;
     $newdom = $param['domain'];
     if (!csb($newdom, "lxdummy") && !is_disabled($newdom)) {
         $ip = gethostbyname($newdom);
         if ($ip != $this->getParentO()->ipaddr) {
             throw new lxexception("this_domain_does_not_resolve_to_this_ip", 'domain', $newdom);
         }
     }
     $this->domain = $param['domain'];
     $this->ipaddr = $this->getParentO()->ipaddr;
     $this->setUpdateSubaction();
     $this->write();
     if ($olddom) {
         $odo = new Web(null, $this->syncserver, $olddom);
         $odo->get();
         // Need to get the client here itself so that it won't run into problems later. You don't need the client anymore...
         //$odo->getParentO()->getParentO();
         if ($odo->dbaction !== 'add') {
             $odo->setUpdateSubaction('fixipdomain');
             $odo->was();
         }
     }
     if ($olddom === $newdom) {
         return;
     }
     if (is_disabled($newdom)) {
         return;
     }
     $ndo = new Web(null, $this->syncserver, $newdom);
     $ndo->get();
     //$ndo->getParentO()->getParentO(); //you don't need client anymore..
     $ndo->setUpdateSubaction('fixipdomain');
     $ndo->was();
 }
Exemplo n.º 5
0
 static function run_awstats($statsprog, $list)
 {
     global $gbl, $sgbl, $login, $ghtml;
     global $global_dontlogshell;
     log_log("run_stats", "In awstats");
     $global_dontlogshell = true;
     foreach ($list as $p) {
         log_log("run_stats", "In awstats for {$p->nname} {$statsprog}");
         if ($p->priv->isOn('awstats_flag')) {
             lxfile_mkdir("__path_httpd_root/{$p->nname}/webstats/");
             $name = $p->nname;
             web::createstatsConf($p->nname, $p->stats_username, $p->stats_password);
             if (is_disabled($statsprog)) {
                 continue;
             }
             log_log("run_stats", "Execing {$statsprog}");
             //system("rm /home/httpd/$p->nname/webstats/*");
             if ($statsprog === 'webalizer') {
                 print "webalizer: {$p->nname}\n";
                 lxshell_return("nice", "-n", "15", "webalizer", "-n", $p->nname, "-t", $p->nname, "-c", "__path_real_etc_root/webalizer/webalizer.{$p->nname}.conf");
             } else {
                 print "awstats: {$p->nname}\n";
                 putenv("GATEWAY_INTERFACE=");
                 //system("nice -n 15 perl /home/kloxo/httpd/awstats/wwwroot/cgi-bin/awstats.pl -update -config=$name > /tmp/test 2>&1");
                 lxshell_return("nice", "-n", "15", "perl", "__path_kloxo_httpd_root/awstats/wwwroot/cgi-bin/awstats.pl", "-update", "-config={$name}");
                 //lxshell_return("__path_kloxo_httpd_root/awstats/tools/awstats_buildstaticpages.pl", "-awstatsprog=$sgbl->__path_kloxo_httpd_root/awstats/wwwroot/cgi-bin/awstats.pl", "-dir=$sgbl->__path_httpd_root/$name/webstats/", "-config=$name");
                 //lxfile_cp("__path_httpd_root/$name/webstats/awstats.$name.html", "__path_httpd_root/$name/webstats/index.html");
             }
         }
     }
     /// Needed to get the domain list from the files in the /etc/awstats directory.
     /*	$list = lscandir_without_dot("__path_real_etc_root/awstats");
     	foreach($list as $l) {
     		$p = preg_replace("/awstats\.(.*)\.conf/", "$1", $l);
     		dprint($p);
     		dprint("\n");
     */
 }
Exemplo n.º 6
0
function getDbInfo()
{
    $lang = ps('lang');
    if ($lang) {
        $_SESSION['lang'] = $lang;
    }
    $GLOBALS['textarray'] = setup_load_lang($_SESSION['lang']);
    global $txpcfg;
    echo n . '<div id="setup_container" class="txp-container">', txp_setup_progress_meter(1), n . '<div class="txp-setup">';
    if (!isset($txpcfg['db'])) {
        @(include txpath . '/config.php');
    }
    if (!empty($txpcfg['db'])) {
        echo graf('<span class="warning">' . setup_gTxt('already_installed', array('{txpath}' => txpath)) . '</span>') . n . setup_back_button(__FUNCTION__) . n . '</div>' . n . '</div>';
        exit;
    }
    if (isset($_SESSION['siteurl'])) {
        $guess_siteurl = $_SESSION['siteurl'];
    } elseif (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) {
        $guess_siteurl = @$_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
        $guess_siteurl .= $GLOBALS['rel_siteurl'];
    } else {
        $guess_siteurl = 'mysite.com';
    }
    echo '<form action="' . txpspecialchars($_SERVER['PHP_SELF']) . '" method="post">' . n . hed(setup_gTxt('need_details'), 1) . n . hed('MySQL', 2) . n . graf(setup_gTxt('db_must_exist')) . n . graf('<span class="edit-label"><label for="setup_mysql_login">' . setup_gTxt('mysql_login') . '</label></span>' . n . '<span class="edit-value">' . fInput('text', 'duser', isset($_SESSION['duser']) ? txpspecialchars($_SESSION['duser']) : '', '', '', '', INPUT_REGULAR, '', 'setup_mysql_login') . '</span>') . n . graf('<span class="edit-label"><label for="setup_mysql_pass">' . setup_gTxt('mysql_password') . '</label></span>' . n . '<span class="edit-value">' . fInput('text', 'dpass', isset($_SESSION['dpass']) ? txpspecialchars($_SESSION['dpass']) : '', '', '', '', INPUT_REGULAR, '', 'setup_mysql_pass') . '</span>') . n . graf('<span class="edit-label"><label for="setup_mysql_server">' . setup_gTxt('mysql_server') . '</label></span>' . n . '<span class="edit-value">' . fInput('text', 'dhost', isset($_SESSION['dhost']) ? txpspecialchars($_SESSION['dhost']) : 'localhost', '', '', '', INPUT_REGULAR, '', 'setup_mysql_server') . '</span>') . n . graf('<span class="edit-label"><label for="setup_mysql_db">' . setup_gTxt('mysql_database') . '</label></span>' . n . '<span class="edit-value">' . fInput('text', 'ddb', isset($_SESSION['ddb']) ? txpspecialchars($_SESSION['ddb']) : '', '', '', '', INPUT_REGULAR, '', 'setup_mysql_db') . '</span>') . n . graf('<span class="edit-label"><label for="setup_table_prefix">' . setup_gTxt('table_prefix') . '</label>' . sp . popHelp('table_prefix') . '</span>' . n . '<span class="edit-value">' . fInput('text', 'dprefix', isset($_SESSION['dprefix']) ? txpspecialchars($_SESSION['dprefix']) : '', '', '', '', INPUT_REGULAR, '', 'setup_table_prefix') . '</span>') . n . hed(setup_gTxt('site_url'), 2) . n . graf(setup_gTxt('please_enter_url')) . n . graf('<span class="edit-label"><label for="setup_site_url">http://</label>' . sp . popHelp('siteurl') . '</span>' . n . '<span class="edit-value">' . fInput('text', 'siteurl', txpspecialchars($guess_siteurl), '', '', '', INPUT_REGULAR, '', 'setup_site_url') . '</span>');
    if (is_disabled('mail')) {
        echo n . graf('<span class="warning">' . setup_gTxt('warn_mail_unavailable') . '</span>');
    }
    echo n . graf(fInput('submit', 'Submit', setup_gTxt('next_step', '', 'raw'), 'publish'));
    echo n . sInput('printConfig') . n . '</form>' . n . '</div>' . n . '</div>';
}
Exemplo n.º 7
0
/**
 * The main author list.
 *
 * @param string|array $message The activity message
 */
function author_list($message = '')
{
    global $txp_user, $author_list_pageby;
    pagetop(gTxt('tab_site_admin'), $message);
    if (is_disabled('mail')) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . gTxt('warn_mail_unavailable'), array('class' => 'alert-block warning'));
    }
    echo hed(gTxt('tab_site_admin'), 1, array('class' => 'txp-heading'));
    echo n . '<div id="users_control" class="txp-control-panel">';
    $buttons = array();
    // Change password button.
    $buttons[] = sLink('admin', 'new_pass_form', gTxt('change_password'));
    if (!has_privs('admin.edit')) {
        // Change email address button.
        $buttons[] = sLink('admin', 'change_email_form', gTxt('change_email_address'));
    } else {
        // New author button.
        $buttons[] = sLink('admin', 'author_edit', gTxt('add_new_author'));
    }
    echo graf(join(n, $buttons), array('class' => 'txp-buttons'));
    // User list.
    if (has_privs('admin.list')) {
        extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
        if ($sort === '') {
            $sort = get_pref('admin_sort_column', 'name');
        }
        if ($dir === '') {
            $dir = get_pref('admin_sort_dir', 'asc');
        }
        $dir = $dir == 'desc' ? 'desc' : 'asc';
        if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) {
            $sort = 'name';
        }
        $sort_sql = $sort . ' ' . $dir;
        set_pref('admin_sort_column', $sort, 'admin', 2, '', 0, PREF_PRIVATE);
        set_pref('admin_sort_dir', $dir, 'admin', 2, '', 0, PREF_PRIVATE);
        $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
        $criteria = 1;
        if ($search_method and $crit != '') {
            $verbatim = preg_match('/^"(.*)"$/', $crit, $m);
            $crit_escaped = $verbatim ? doSlash($m[1]) : doLike($crit);
            $critsql = $verbatim ? array('id' => "user_id in ('" . join("','", do_list($crit_escaped)) . "')", 'login' => "name = '{$crit_escaped}'", 'real_name' => "RealName = '{$crit_escaped}'", 'email' => "email = '{$crit_escaped}'", 'privs' => "convert(privs, char) in ('" . join("','", do_list($crit_escaped)) . "')") : array('id' => "user_id in ('" . join("','", do_list($crit_escaped)) . "')", 'login' => "name like '%{$crit_escaped}%'", 'real_name' => "RealName like '%{$crit_escaped}%'", 'email' => "email like '%{$crit_escaped}%'", 'privs' => "convert(privs, char) in ('" . join("','", do_list($crit_escaped)) . "')");
            if (array_key_exists($search_method, $critsql)) {
                $criteria = $critsql[$search_method];
            } else {
                $search_method = '';
                $crit = '';
            }
        } else {
            $search_method = '';
            $crit = '';
        }
        $criteria .= callback_event('admin_criteria', 'author_list', 0, $criteria);
        $total = getCount('txp_users', $criteria);
        if ($total < 1) {
            if ($criteria != 1) {
                echo n . author_search_form($crit, $search_method) . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
            }
            return;
        }
        $limit = max($author_list_pageby, 15);
        list($page, $offset, $numPages) = pager($total, $limit, $page);
        $use_multi_edit = has_privs('admin.edit') && safe_count('txp_users', '1=1') > 1;
        echo author_search_form($crit, $search_method) . '</div>';
        $rs = safe_rows_start('*, unix_timestamp(last_access) as last_login', 'txp_users', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
        if ($rs) {
            echo n . tag_start('div', array('id' => 'users_container', 'class' => 'txp-container')) . n . tag_start('form', array('action' => 'index.php', 'id' => 'users_form', 'class' => 'multi_edit_form', 'method' => 'post', 'name' => 'longform')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(($use_multi_edit ? hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' scope="col" title="' . gTxt('toggle_all_selected') . '" class="txp-list-col-multi-edit"') : hCell('', '', ' scope="col" class="txp-list-col-multi-edit"')) . column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-login-name name') . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', ('RealName' == $sort ? "{$dir} " : '') . 'txp-list-col-real-name name') . column_head('email', 'email', 'admin', true, $switch_dir, '', '', ('email' == $sort ? "{$dir} " : '') . 'txp-list-col-email') . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', ('privs' == $sort ? "{$dir} " : '') . 'txp-list-col-privs') . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', ('last_login' == $sort ? "{$dir} " : '') . 'txp-list-col-last-login date')) . n . tag_end('thead') . n . tag_start('tbody');
            while ($a = nextRow($rs)) {
                extract(doSpecial($a));
                echo tr(td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name'], 'checkbox') : '', '', 'txp-list-col-multi-edit') . hCell(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, $name) : $name, '', ' scope="row" class="txp-list-col-login-name name"') . td($RealName, '', 'txp-list-col-real-name name') . td(href($email, 'mailto:' . $email), '', 'txp-list-col-email') . td(get_priv_level($privs), '', 'txp-list-col-privs') . td($last_login ? safe_strftime('%b&#160;%Y', $last_login) : '', '', 'txp-list-col-last-login date'));
            }
            echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . ($use_multi_edit ? author_multiedit_form($page, $sort, $dir, $crit, $search_method) : '') . tInput() . n . tag_end('form') . n . tag_start('div', array('id' => 'users_navigation', 'class' => 'txp-navigation')) . pageby_form('admin', $author_list_pageby) . nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method) . n . tag_end('div') . n . tag_end('div');
        }
    } else {
        echo n . tag_end('div');
    }
}
Exemplo n.º 8
0
function author_list($message = '')
{
    global $txp_user, $author_list_pageby;
    pagetop(gTxt('tab_site_admin'), $message);
    if (is_disabled('mail')) {
        echo tag(gTxt('warn_mail_unavailable'), 'p', ' class="alert-block warning" ');
    }
    echo '<h1 class="txp-heading">' . gTxt('tab_site_admin') . '</h1>';
    echo '<div id="users_control" class="txp-control-panel">';
    // Change password button
    echo '<p class="txp-buttons">';
    echo sLink('admin', 'new_pass_form', gTxt('change_password'));
    // Change email address button
    if (!has_privs('admin.edit')) {
        echo n . sLink('admin', 'change_email_form', gTxt('change_email_address'));
    }
    // User list
    if (has_privs('admin.list')) {
        extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
        if ($sort === '') {
            $sort = get_pref('admin_sort_column', 'name');
        }
        if ($dir === '') {
            $dir = get_pref('admin_sort_dir', 'asc');
        }
        $dir = $dir == 'desc' ? 'desc' : 'asc';
        if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) {
            $sort = 'name';
        }
        $sort_sql = $sort . ' ' . $dir;
        set_pref('admin_sort_column', $sort, 'admin', 2, '', 0, PREF_PRIVATE);
        set_pref('admin_sort_dir', $dir, 'admin', 2, '', 0, PREF_PRIVATE);
        $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
        $criteria = 1;
        if ($search_method and $crit != '') {
            $crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit));
            $critsql = array('id' => "user_id in ('" . join("','", do_list($crit_escaped)) . "')", 'login' => "name like '%{$crit_escaped}%'", 'real_name' => "RealName like '%{$crit_escaped}%'", 'email' => "email like '%{$crit_escaped}%'", 'privs' => "privs in ('" . join("','", do_list($crit_escaped)) . "')");
            if (array_key_exists($search_method, $critsql)) {
                $criteria = $critsql[$search_method];
            } else {
                $search_method = '';
                $crit = '';
            }
        } else {
            $search_method = '';
            $crit = '';
        }
        $criteria .= callback_event('admin_criteria', 'author_list', 0, $criteria);
        $total = getCount('txp_users', $criteria);
        // New author button
        if (has_privs('admin.edit')) {
            echo n . sLink('admin', 'author_edit', gTxt('add_new_author'));
        }
        echo '</p>';
        // end txp-buttons
        if ($total < 1) {
            if ($criteria != 1) {
                echo n . author_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
            }
            return;
        }
        $limit = max($author_list_pageby, 15);
        list($page, $offset, $numPages) = pager($total, $limit, $page);
        $use_multi_edit = has_privs('admin.edit') && safe_count('txp_users', '1=1') > 1;
        echo author_search_form($crit, $search_method) . '</div>';
        $rs = safe_rows_start('*, unix_timestamp(last_access) as last_login', 'txp_users', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
        if ($rs) {
            echo n . '<div id="users_container" class="txp-container">';
            echo '<form action="index.php" id="users_form" class="multi_edit_form" method="post" name="longform">' . n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . n . tr(n . ($use_multi_edit ? hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') : hCell('', '', ' class="multi-edit"')) . n . column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name login-name') . n . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', ('RealName' == $sort ? "{$dir} " : '') . 'name real-name') . n . column_head('email', 'email', 'admin', true, $switch_dir, '', '', ('email' == $sort ? "{$dir} " : '') . 'email') . n . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', ('privs' == $sort ? "{$dir} " : '') . 'privs') . n . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', ('last_login' == $sort ? "{$dir} " : '') . 'date last-login modified')) . n . '</thead>';
            echo '<tbody>';
            while ($a = nextRow($rs)) {
                extract(doSpecial($a));
                echo tr(td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name'], 'checkbox') : '', '', 'multi-edit') . td(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, $name) : $name, '', 'name login-name') . td($RealName, '', 'name real-name') . td('<a href="mailto:' . $email . '">' . $email . '</a>', '', 'email') . td(get_priv_level($privs), '', 'privs') . td($last_login ? safe_strftime('%b&#160;%Y', $last_login) : '', '', 'date last-login modified'));
            }
            echo '</tbody>', n, endTable(), n, '</div>', n, $use_multi_edit ? author_multiedit_form($page, $sort, $dir, $crit, $search_method) : '', n, tInput(), n, '</form>', n, '<div id="users_navigation" class="txp-navigation">', n, nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method), n, pageby_form('admin', $author_list_pageby), n, '</div>', n, '</div>';
        }
    } else {
        echo '</div>';
    }
}
Exemplo n.º 9
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>';
}
Exemplo n.º 10
0
/**
 * The main panel listing all authors.
 *
 * @param string|array $message The activity message
 */
function author_list($message = '')
{
    global $event, $txp_user, $author_list_pageby, $levels;
    pagetop(gTxt('tab_site_admin'), $message);
    if (is_disabled('mail')) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . gTxt('warn_mail_unavailable'), array('class' => 'alert-block warning'));
    }
    $buttons = array();
    // Change password button.
    $buttons[] = sLink('admin', 'new_pass_form', gTxt('change_password'), 'txp-button');
    if (!has_privs('admin.edit')) {
        // Change email address button.
        $buttons[] = sLink('admin', 'change_email_form', gTxt('change_email_address'), 'txp-button');
    } else {
        // New author button.
        $buttons[] = sLink('admin', 'author_edit', gTxt('add_new_author'), 'txp-button');
    }
    // User list.
    if (has_privs('admin.list')) {
        extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
        if ($sort === '') {
            $sort = get_pref('admin_sort_column', 'name');
        } else {
            if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) {
                $sort = 'name';
            }
            set_pref('admin_sort_column', $sort, 'admin', 2, '', 0, PREF_PRIVATE);
        }
        if ($dir === '') {
            $dir = get_pref('admin_sort_dir', 'asc');
        } else {
            $dir = $dir == 'desc' ? "desc" : "asc";
            set_pref('admin_sort_dir', $dir, 'admin', 2, '', 0, PREF_PRIVATE);
        }
        $sort_sql = $sort . ' ' . $dir;
        $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
        $search = new Filter($event, array('login' => array('column' => 'txp_users.name', 'label' => gTxt('login_name')), 'RealName' => array('column' => 'txp_users.RealName', 'label' => gTxt('real_name')), 'email' => array('column' => 'txp_users.email', 'label' => gTxt('email')), 'privs' => array('column' => array('txp_users.privs'), 'label' => gTxt('privileges'), 'type' => 'boolean')));
        $search->setAliases('privs', $levels);
        list($criteria, $crit, $search_method) = $search->getFilter();
        $search_render_options = array('placeholder' => 'search_users');
        $total = getCount('txp_users', $criteria);
        echo n . tag(hed(gTxt('tab_site_admin'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1'));
        $searchBlock = n . tag($search->renderForm('author_list', $search_render_options), 'div', array('class' => 'txp-layout-2col-cell-2', 'id' => 'users_control'));
        $createBlock = array();
        $createBlock[] = n . tag(implode(n, $buttons), 'div', array('class' => 'txp-control-panel'));
        $contentBlockStart = n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => 'users_container'));
        $createBlock = implode(n, $createBlock);
        if ($total < 1) {
            if ($criteria != 1) {
                echo $searchBlock . $contentBlockStart . $createBlock . graf(span(null, array('class' => 'ui-icon ui-icon-info')) . ' ' . gTxt('no_results_found'), array('class' => 'alert-block information')) . n . tag_end('div');
            }
            return;
        }
        $limit = max($author_list_pageby, 15);
        list($page, $offset, $numPages) = pager($total, $limit, $page);
        $use_multi_edit = has_privs('admin.edit') && ($total > 1 or safe_count('txp_users', "1 = 1") > 1);
        echo $searchBlock . $contentBlockStart . $createBlock;
        $rs = safe_rows_start("*, UNIX_TIMESTAMP(last_access) AS last_login", 'txp_users', "{$criteria} ORDER BY {$sort_sql} LIMIT {$offset}, {$limit}");
        if ($rs) {
            echo n . tag_start('form', array('class' => 'multi_edit_form', 'id' => 'users_form', 'name' => 'longform', 'method' => 'post', 'action' => 'index.php')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(($use_multi_edit ? hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' class="txp-list-col-multi-edit" scope="col" title="' . gTxt('toggle_all_selected') . '"') : hCell('', '', ' class="txp-list-col-multi-edit" scope="col"')) . column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-login-name name') . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', ('RealName' == $sort ? "{$dir} " : '') . 'txp-list-col-real-name name') . column_head('email', 'email', 'admin', true, $switch_dir, '', '', ('email' == $sort ? "{$dir} " : '') . 'txp-list-col-email') . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', ('privs' == $sort ? "{$dir} " : '') . 'txp-list-col-privs') . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', ('last_login' == $sort ? "{$dir} " : '') . 'txp-list-col-last-login date')) . n . tag_end('thead') . n . tag_start('tbody');
            while ($a = nextRow($rs)) {
                extract(doSpecial($a));
                echo tr(td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name'], 'checkbox') : '', '', 'txp-list-col-multi-edit') . hCell(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, $name) : $name, '', ' class="txp-list-col-login-name name" scope="row"') . td($RealName, '', 'txp-list-col-real-name name') . td(href($email, 'mailto:' . $email), '', 'txp-list-col-email') . td(get_priv_level($privs), '', 'txp-list-col-privs') . td($last_login ? safe_strftime('%b&#160;%Y', $last_login) : '', '', 'txp-list-col-last-login date'));
            }
            echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . ($use_multi_edit ? author_multiedit_form($page, $sort, $dir, $crit, $search_method) : '') . tInput() . n . tag_end('form') . n . tag_start('div', array('class' => 'txp-navigation', 'id' => 'users_navigation')) . pageby_form('admin', $author_list_pageby) . nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method) . n . tag_end('div');
        }
        echo n . tag_end('div');
    } else {
        echo n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => 'users_container')) . n . tag(implode(n, $buttons), 'div', array('class' => 'txp-control-panel')) . n . tag_end('div');
    }
}
Exemplo n.º 11
0
 function query()
 {
     $args = func_get_args();
     $method = array_shift($args);
     $request = new IXR_Request($method, $args);
     $length = $request->getLength();
     $xml = $request->getXml();
     $r = "\r\n";
     $request = "POST {$this->path} HTTP/1.0{$r}";
     // Merged from WP #8145 - allow custom headers
     $this->headers['Host'] = $this->server;
     $this->headers['Content-Type'] = 'text/xml';
     $this->headers['User-Agent'] = $this->useragent;
     $this->headers['Content-Length'] = $length;
     // Accept gzipped response if zlib and if php4.3+ (fgets turned binary safe)
     if (extension_loaded('zlib') && preg_match('#^(4\\.[3-9])|([5-9])#', phpversion())) {
         $this->headers['Accept-Encoding'] = 'gzip';
     }
     foreach ($this->headers as $header => $value) {
         $request .= "{$header}: {$value}{$r}";
     }
     $request .= $r;
     $request .= $xml;
     // Now send the request
     if ($this->debug) {
         echo '<pre class="ixr_request">' . htmlspecialchars($request) . "\n</pre>\n\n";
     }
     if ($this->timeout) {
         $fp = !is_disabled('fsockopen') ? fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout) : false;
     } else {
         $fp = !is_disabled('fsockopen') ? fsockopen($this->server, $this->port, $errno, $errstr) : false;
     }
     if (!$fp) {
         $this->error = new IXR_Error(-32300, 'transport error - could not open socket (' . $errstr . ')');
         return false;
     }
     fputs($fp, $request);
     $contents = '';
     $debugContents = '';
     $gotFirstLine = false;
     $gettingHeaders = true;
     $is_gzipped = false;
     while (!feof($fp)) {
         $line = fgets($fp, 4096);
         if (!$gotFirstLine) {
             // Check line for '200'
             if (strstr($line, '200') === false) {
                 $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
                 return false;
             }
             $gotFirstLine = true;
         }
         if ($gettingHeaders && trim($line) == '') {
             $gettingHeaders = false;
             continue;
         }
         if (!$gettingHeaders) {
             // We do a binary comparison of the first two bytes, see
             // rfc1952, to check wether the content is gzipped.
             if ($contents == '' && strncmp($line, "‹", 2) === 0) {
                 $is_gzipped = true;
             }
             // merged from WP #12559 - remove trim
             $contents .= $line;
         }
         if ($this->debug) {
             $debugContents .= $line;
         }
     }
     // if gzipped, strip the 10 byte header, and pass it to gzinflate (rfc1952)
     if ($is_gzipped) {
         $contents = gzinflate(substr($contents, 10));
         //simulate trim() for each line; don't know why, but it won't work otherwise
         $contents = preg_replace('#^[\\x20\\x09\\x0A\\x0D\\x00\\x0B]*(.*)[\\x20\\x09\\x0A\\x0D\\x00\\x0B]*$#m', '\\1', $contents);
     }
     if ($this->debug) {
         echo '<pre class="ixr_response">' . htmlspecialchars($debugContents) . "\n</pre>\n\n";
     }
     // Now parse what we've got back
     $this->message = new IXR_Message($contents);
     if (!$this->message->parse()) {
         // XML error
         $this->error = new IXR_Error(-32700, 'parse error. not well formed');
         return false;
     }
     // Is the message a fault?
     if ($this->message->messageType == 'fault') {
         $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
         return false;
     }
     // Message must be OK
     return true;
 }
Exemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function send()
 {
     if (is_disabled('mail')) {
         throw new Textpattern_Mail_Exception(gTxt('disabled_function', array('{name}' => 'mail')));
     }
     if (!$this->mail->from || !$this->mail->to) {
         throw new Textpattern_Mail_Exception(gTxt('from_or_to_address_missing'));
     }
     $headers = array();
     $headers['From'] = $this->encoded->from;
     if ($this->encoded->cc) {
         $headers['Cc'] = $this->encoded->cc;
     }
     if ($this->encoded->bcc) {
         $headers['Bcc'] = $this->encoded->bbc;
     }
     if ($this->encoded->replyTo) {
         $headers['Reply-to'] = $this->encoded->replyTo;
     }
     $headers += $this->encoded->headers;
     foreach ($headers as $name => &$value) {
         $value = $name . ': ' . $value;
     }
     $headers = join($this->separator, $headers) . $this->separator;
     if ($this->smtpFrom) {
         if (mail($this->encoded->to, $this->encoded->subject, $this->encoded->body, $headers, '-f' . $this->smtpFrom) === false) {
             throw new Textpattern_Mail_Exception(gTxt('sending_failed'));
         }
     }
     if (mail($this->encoded->to, $this->encoded->subject, $this->encoded->body, $headers) === false) {
         throw new Textpattern_Mail_Exception(gTxt('sending_failed'));
     }
     return $this;
 }
Exemplo n.º 13
0
function doDiagnostics()
{
    global $prefs, $files, $txpcfg, $event, $step, $theme;
    extract(get_prefs());
    $urlparts = parse_url(hu);
    $mydomain = $urlparts['host'];
    $server_software = @$_SERVER['SERVER_SOFTWARE'] || @$_SERVER['HTTP_HOST'] ? @$_SERVER['SERVER_SOFTWARE'] ? @$_SERVER['SERVER_SOFTWARE'] : $_SERVER['HTTP_HOST'] : '';
    $is_apache = ($server_software and stristr($server_software, 'Apache')) or 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');
    $fail = array('php_version_4_3_0_required' => (!is_callable('version_compare') or version_compare(PHP_VERSION, '4.3.0', '<')) ? gTxt('php_version_4_3_0_required') : '', 'path_to_site_missing' => !isset($path_to_site) ? gTxt('path_to_site_missing') : '', 'dns_lookup_fails' => @gethostbyname($mydomain) == $mydomain ? gTxt('dns_lookup_fails') . cs . $mydomain : '', 'path_to_site_inacc' => !@is_dir($path_to_site) ? gTxt('path_to_site_inacc') . cs . $path_to_site : '', 'site_trailing_slash' => rtrim($siteurl, '/') != $siteurl ? gTxt('site_trailing_slash') . cs . $path_to_site : '', 'index_inaccessible' => (!@is_file($path_to_site . "/index.php") or !@is_readable($path_to_site . "/index.php")) ? "{$path_to_site}/index.php " . gTxt('is_inaccessible') : '', 'dir_not_writable' => trim((!@is_writable($path_to_site . '/' . $img_dir) ? str_replace('{dirtype}', gTxt('img_dir'), gTxt('dir_not_writable')) . ": {$path_to_site}/{$img_dir}" . n : '') . (!@is_writable($file_base_path) ? str_replace('{dirtype}', gTxt('file_base_path'), gTxt('dir_not_writable')) . ": {$file_base_path}" . n : '') . (!@is_writable($tempdir) ? str_replace('{dirtype}', gTxt('tempdir'), gTxt('dir_not_writable')) . ": {$tempdir}" . n : '')), 'cleanurl_only_apache' => ($permlink_mode != 'messy' and !$is_apache) ? gTxt('cleanurl_only_apache') : '', 'htaccess_missing' => ($permlink_mode != 'messy' and !@is_readable($path_to_site . '/.htaccess')) ? gTxt('htaccess_missing') : '', 'mod_rewrite_missing' => ($permlink_mode != 'messy' and is_callable('apache_get_modules') and !apache_module('mod_rewrite')) ? gTxt('mod_rewrite_missing') : '', 'file_uploads_disabled' => !ini_get('file_uploads') ? gTxt('file_uploads_disabled') : '', 'setup_still_exists' => @is_dir(txpath . DS . 'setup') ? txpath . DS . "setup" . DS . ' ' . gTxt('still_exists') : '', 'no_temp_dir' => empty($tempdir) ? gTxt('no_temp_dir') : '', 'warn_mail_unavailable' => is_disabled('mail') ? gTxt('warn_mail_unavailable') : '', 'warn_register_globals_or_update' => $is_register_globals && (version_compare(phpversion(), '4.4.0', '<=') or version_compare(phpversion(), '5.0.0', '>=') and version_compare(phpversion(), '5.0.5', '<=')) ? gTxt('warn_register_globals_or_update') : '');
    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'] = gTxt('old_placeholder') . ": {$path_to_site}/{$name}";
            }
        }
    }
    $missing = array();
    foreach ($files as $f) {
        $realpath = realpath(txpath . $f);
        if (is_readable($realpath)) {
            $found[] = $realpath;
        } else {
            $missing[] = txpath . $f;
        }
    }
    $files = $found;
    unset($found);
    if ($missing) {
        $fail['missing_files'] = gTxt('missing_files') . cs . n . t . join(', ' . n . t, $missing);
    }
    foreach ($fail as $k => $v) {
        if (empty($v)) {
            unset($fail[$k]);
        }
    }
    # Find the highest revision number
    $file_revs = $file_md5 = array();
    $rev = 0;
    foreach ($files as $f) {
        $content = @file_get_contents($f);
        if ($content !== FALSE) {
            if (preg_match('/^\\$' . 'LastChangedRevision: (\\d+) \\$/m', $content, $match)) {
                $file_revs[$f] = $match[1];
                if ($match[1] > $rev) {
                    $rev = $match[1];
                }
            }
            $file_md5[$f] = md5(str_replace('$' . 'HeadURL: http:', '$' . 'HeadURL: https:', str_replace("\r\n", "\n", $content)));
        }
    }
    # Check revs & md5 against stable release, if possible
    $dev_files = $old_files = $modified_files = array();
    if ($cs = @file(txpath . '/checksums.txt')) {
        foreach ($cs as $c) {
            if (preg_match('@^(\\S+): r?(\\S+) \\((.*)\\)$@', trim($c), $m)) {
                list(, $file, $r, $md5) = $m;
                $file = realpath(txpath . $file);
                if (!empty($file_revs[$file]) and $r and $file_revs[$file] < $r) {
                    $old_files[] = $file;
                } elseif (!empty($file_revs[$file]) and $r and $file_revs[$file] > $r) {
                    $dev_files[] = $file;
                } elseif (!empty($file_md5[$file]) and $file_md5[$file] != $md5) {
                    $modified_files[] = $file;
                }
            }
        }
    }
    # files that haven't been updated
    if ($old_files) {
        $fail['old_files'] = gTxt('old_files') . cs . n . t . join(', ' . n . t, $old_files);
    }
    # files that don't match their checksums
    if ($modified_files) {
        $fail['modified_files'] = gTxt('modified_files') . cs . n . t . join(', ' . n . t, $modified_files);
    }
    # running development code in live mode is not recommended
    if ($dev_files and $production_status == 'live') {
        $fail['dev_version_live'] = gTxt('dev_version_live') . cs . n . t . join(', ' . n . t, $dev_files);
    }
    # 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', 'exec', 'system', 'dl', 'passthru', 'chown', 'shell_exec', 'popen', 'proc_open'));
        if ($disabled_funcs) {
            $fail['some_php_functions_disabled'] = gTxt('some_php_functions_disabled') . cs . join(', ', $disabled_funcs);
        }
    }
    # 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'] = gTxt('site_url_mismatch') . cs . $guess_site_url;
    }
    # 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'] = gTxt('clean_url_data_failed') . cs . htmlspecialchars($pretext_req);
                }
            } else {
                $fail['clean_url_test_failed'] = gTxt('clean_url_test_failed');
            }
        }
    }
    if ($tables = list_txp_tables()) {
        $table_errors = check_tables($tables);
        if ($table_errors) {
            $fail['mysql_table_errors'] = 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'] = gTxt('tmp_plugin_paths_match');
    }
    echo pagetop(gTxt('tab_diagnostics'), ''), '<div id="' . $event . '_container" class="txp-container txp-list">', '<div id="pre_flight_check">', startTable('list', '', 'list', '', '510px'), '<thead>', tr(td(hed(gTxt('preflight_check'), 2))), '</thead>';
    echo '<tbody>';
    if ($fail) {
        foreach ($fail as $help => $message) {
            echo tr(tda(nl2br($message) . sp . popHelp($help), ' class="not-ok"'));
        }
    } else {
        echo tr(tda(gTxt('all_checks_passed'), ' class="ok"'));
    }
    echo '</tbody>', endTable(), '</div>';
    echo '<div id="diagnostics">', startTable('list', '', 'list'), '<thead>', tr(td(hed(gTxt('diagnostic_info'), 2))), '</thead>';
    $fmt_date = '%Y-%m-%d %H:%M:%S';
    $out = array('<textarea cols="78" rows="18" readonly="readonly" style="width: 500px; height: 300px;">', gTxt('txp_version') . cs . txp_version . ' (' . ($rev ? 'r' . $rev : 'unknown revision') . ')' . 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: ' . (timezone::is_supported() ? date_default_timezone_get() : (getenv('TZ') ? getenv('TZ') : '-')) . 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('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", $fail) . n . ln : '', is_readable($path_to_site . '/.htaccess') ? n . gTxt('htaccess_contents') . cs . n . ln . htmlspecialchars(join('', file($path_to_site . '/.htaccess'))) . n . ln : '');
    if ($step == 'high') {
        $mysql_client_encoding = is_callable('mysql_client_encoding') ? mysql_client_encoding() : '-';
        $out[] = n . 'Charset (default/config)' . cs . $mysql_client_encoding . '/' . @$txpcfg['dbcharset'] . 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 . htmlspecialchars(join('', array_slice($pretext_data, 1, 20))) . n;
        }
        $out[] = n;
        foreach ($files as $f) {
            $checksum = isset($file_md5[$f]) ? $file_md5[$f] : gTxt('unknown');
            $revision = isset($file_revs[$f]) ? 'r' . $file_revs[$f] : gTxt('unknown');
            $out[] = "{$f}" . cs . n . t . $revision . ' (' . $checksum . ')' . n;
        }
        $out[] = n . ln;
    }
    $out[] = callback_event('diag_results', $step) . n;
    $out[] = '</textarea>' . br;
    $dets = array('low' => gTxt('low'), 'high' => gTxt('high'));
    $out[] = form(eInput('diag') . n . gTxt('detail') . cs . selectInput('step', $dets, $step, 0, 1));
    echo '<tbody>', tr(td(join('', $out))), '</tbody>', endTable(), '</div>', '</div>';
}
Exemplo n.º 14
0
 /**
  * Error printing.
  *
  * This is the action to handle external exceptions.
  */
 public function actionError()
 {
     function var_dump_to_string($var)
     {
         $output = "<pre>";
         _var_dump_to_string($var, $output);
         $output .= "</pre>";
         return $output;
     }
     function _var_dump_to_string($var, &$output, $prefix = "")
     {
         foreach ($var as $key => $value) {
             if (is_array($value)) {
                 $output .= $prefix . $key . ": \n";
                 _var_dump_to_string($value, $output, "  " . $prefix);
             } else {
                 $output .= $prefix . $key . ": " . $value . "\n";
             }
         }
     }
     function is_disabled($function)
     {
         $disabled_functions = explode(',', str_replace(" ", "", ini_get('disable_functions')));
         return in_array($function, $disabled_functions);
     }
     if ($error = Yii::app()->errorHandler->error) {
         if (Yii::app()->request->isAjaxRequest) {
             echo $error['message'];
         } else {
             $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
             $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
             if ($error['code'] == '404') {
                 $request = Yii::app()->request->requestUri;
                 if (preg_match('/opportunity/', $request)) {
                     $request = preg_replace('/opportunity/', 'opportunities', $request);
                     $this->redirect($request);
                 }
                 if (empty($referer)) {
                     $this->render('errorDisplay', $error);
                     Yii::app()->end();
                 }
             }
             if (in_array($error['code'], array('403', '400', '503'))) {
                 $this->render('errorDisplay', $error);
                 Yii::app()->end();
             }
             $request = Yii::app()->request->requestUri;
             if (!is_disabled('phpinfo')) {
                 $info = $this->phpinfo_array(true);
             } else {
                 $info = '';
             }
             if (!empty(Yii::app()->settings->emailFromAddr)) {
                 $email = Yii::app()->settings->emailFromAddr;
             } else {
                 $email = "";
             }
             $get = var_dump_to_string($_GET);
             $post = var_dump_to_string($_POST);
             $phpversion = phpversion();
             $x2version = Yii::app()->params->version;
             unset($error['traces']);
             $error['trace'] = CHtml::encode($error['trace']);
             $phpInfoErrorReport = base64_encode(CJSON::encode(array_merge($error, array('request' => $request, 'phpinfo' => $info, 'referer' => $referer, 'get' => $get, 'post' => $post, 'phpversion' => $phpversion, 'x2version' => $x2version, 'adminEmail' => $email, 'user' => Yii::app()->user->getName(), 'isAdmin' => Yii::app()->params->isAdmin, 'userAgent' => $userAgent))));
             $errorReport = base64_encode(CJSON::encode(array_merge($error, array('request' => $request, 'referer' => $referer, 'get' => $get, 'post' => $post, 'phpversion' => $phpversion, 'x2version' => $x2version, 'adminEmail' => $email, 'user' => Yii::app()->user->getName(), 'isAdmin' => Yii::app()->params->isAdmin, 'userAgent' => $userAgent))));
             $this->render('error', array_merge($error, array('request' => $request, 'info' => $info, 'referer' => $referer, 'get' => $get, 'post' => $post, 'phpversion' => $phpversion, 'x2version' => $x2version, 'errorReport' => $errorReport, 'phpInfoErrorReport' => $phpInfoErrorReport)));
         }
     }
 }
Exemplo n.º 15
0
/**
 * Renders stage 1: database details panel.
 */
function getDbInfo()
{
    $lang = ps('lang');
    if ($lang) {
        $_SESSION['lang'] = $lang;
    }
    $GLOBALS['textarray'] = setup_load_lang($_SESSION['lang']);
    global $txpcfg;
    echo txp_setup_progress_meter(1), n . '<div class="txp-setup">';
    if (!isset($txpcfg['db'])) {
        @(include txpath . '/config.php');
    }
    if (!empty($txpcfg['db'])) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . setup_gTxt('already_installed', array('{txpath}' => txpath)), array('class' => 'alert-block warning')) . setup_back_button(__FUNCTION__) . n . '</div>';
        exit;
    }
    if (isset($_SESSION['siteurl'])) {
        $guess_siteurl = $_SESSION['siteurl'];
    } elseif (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) {
        $guess_siteurl = @$_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
        $guess_siteurl .= $GLOBALS['rel_siteurl'];
    } else {
        $guess_siteurl = 'mysite.com';
    }
    echo '<form class="prefs-form" method="post" action="' . txpspecialchars($_SERVER['PHP_SELF']) . '">' . hed(setup_gTxt('need_details'), 1) . hed('MySQL', 2) . graf(setup_gTxt('db_must_exist')) . inputLabel('setup_mysql_login', fInput('text', 'duser', isset($_SESSION['duser']) ? txpspecialchars($_SESSION['duser']) : '', '', '', '', INPUT_REGULAR, '', 'setup_mysql_login'), 'mysql_login', '', array('class' => 'txp-form-field')) . inputLabel('setup_mysql_pass', fInput('password', 'dpass', isset($_SESSION['dpass']) ? txpspecialchars($_SESSION['dpass']) : '', 'txp-maskable', '', '', INPUT_REGULAR, '', 'setup_mysql_pass') . n . tag(checkbox('unmask', 1, false, 0, 'show_password') . n . tag(gTxt('setup_show_password'), 'label', array('for' => 'show_password')), 'div', array('class' => 'show-password')), 'mysql_password', '', array('class' => 'txp-form-field')) . inputLabel('setup_mysql_server', fInput('text', 'dhost', isset($_SESSION['dhost']) ? txpspecialchars($_SESSION['dhost']) : 'localhost', '', '', '', INPUT_REGULAR, '', 'setup_mysql_server', '', true), 'mysql_server', '', array('class' => 'txp-form-field')) . inputLabel('setup_mysql_db', fInput('text', 'ddb', isset($_SESSION['ddb']) ? txpspecialchars($_SESSION['ddb']) : '', '', '', '', INPUT_REGULAR, '', 'setup_mysql_db', '', true), 'mysql_database', '', array('class' => 'txp-form-field')) . inputLabel('setup_table_prefix', fInput('text', 'dprefix', isset($_SESSION['dprefix']) ? txpspecialchars($_SESSION['dprefix']) : '', 'input-medium', '', '', INPUT_MEDIUM, '', 'setup_table_prefix'), 'table_prefix', 'table_prefix', array('class' => 'txp-form-field')) . hed(setup_gTxt('site_url'), 2) . graf(setup_gTxt('please_enter_url')) . inputLabel('setup_site_url', fInput('text', 'siteurl', txpspecialchars($guess_siteurl), '', '', '', INPUT_REGULAR, '', 'setup_site_url', '', true), 'http(s)://', 'siteurl', array('class' => 'txp-form-field'));
    if (is_disabled('mail')) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . setup_gTxt('warn_mail_unavailable'), array('class' => 'alert-block warning'));
    }
    echo graf(fInput('submit', 'Submit', setup_gTxt('next_step', '', 'raw'), 'publish'));
    echo sInput('printConfig') . n . '</form>' . n . '</div>';
}
Exemplo n.º 16
0
function txpMail($to_address, $subject, $body, $reply_to = null)
{
    global $txp_user, $prefs;
    // if mailing isn't possible, don't even try
    if (is_disabled('mail')) {
        return false;
    }
    // Likely sending passwords
    if (isset($txp_user)) {
        extract(safe_row('RealName, email', 'txp_users', "name = '" . doSlash($txp_user) . "'"));
    } else {
        extract(safe_row('RealName, email', 'txp_users', "email = '" . doSlash($to_address) . "'"));
    }
    if ($prefs['override_emailcharset'] and is_callable('utf8_decode')) {
        $charset = 'ISO-8859-1';
        $RealName = utf8_decode($RealName);
        $subject = utf8_decode($subject);
        $body = utf8_decode($body);
    } else {
        $charset = 'UTF-8';
    }
    $RealName = encode_mailheader(strip_rn($RealName), 'phrase');
    $subject = encode_mailheader(strip_rn($subject), 'text');
    $email = strip_rn($email);
    if (!is_null($reply_to)) {
        $reply_to = strip_rn($reply_to);
    }
    $sep = !IS_WIN ? "\n" : "\r\n";
    $body = str_replace("\r\n", "\n", $body);
    $body = str_replace("\r", "\n", $body);
    $body = str_replace("\n", $sep, $body);
    $headers = "From: {$RealName} <{$email}>" . $sep . 'Reply-To: ' . (isset($reply_to) ? $reply_to : "{$RealName} <{$email}>") . $sep . 'X-Mailer: Textpattern' . $sep . 'Content-Transfer-Encoding: 8bit' . $sep . 'Content-Type: text/plain; charset="' . $charset . '"' . $sep;
    if (is_valid_email($prefs['smtp_from'])) {
        if (IS_WIN) {
            ini_set('sendmail_from', $prefs['smtp_from']);
        } elseif (!ini_get('safe_mode')) {
            return mail($to_address, $subject, $body, $headers, '-f' . $prefs['smtp_from']);
        }
    }
    return mail($to_address, $subject, $body, $headers);
}
Exemplo n.º 17
0
 function query()
 {
     $args = func_get_args();
     $method = array_shift($args);
     $request = new IXR_Request($method, $args);
     $length = $request->getLength();
     $xml = $request->getXml();
     $r = "\r\n";
     $request = "POST {$this->path} HTTP/1.0{$r}";
     $request .= "Host: {$this->server}{$r}";
     $request .= "Content-Type: text/xml{$r}";
     $request .= "User-Agent: {$this->useragent}{$r}";
     // Accept gzipped response if zlib and if php4.3+ (fgets turned binary safe)
     if (extension_loaded('zlib') && preg_match('#^(4\\.[3-9])|([5-9])#', phpversion())) {
         $request .= "Accept-Encoding: gzip{$r}";
     }
     $request .= "Content-length: {$length}{$r}{$r}";
     $request .= $xml;
     // Now send the request
     if ($this->debug) {
         echo '<pre>' . htmlspecialchars($request) . "\n</pre>\n\n";
     }
     // This is to find out when the script unexpectedly dies due to fsockopen
     ob_start(NULL, 2048);
     echo "Trying to connect to an RPC Server...";
     $fp = !is_disabled('fsockopen') ? fsockopen($this->server, $this->port, $errno, $errstr, 45) : false;
     ob_end_clean();
     if (!$fp) {
         $this->error = new IXR_Error(-32300, 'transport error - could not open socket (' . $errstr . ')');
         return false;
     }
     fputs($fp, $request);
     $contents = '';
     $gotFirstLine = false;
     $gettingHeaders = true;
     $is_gzipped = false;
     while (!feof($fp)) {
         $line = fgets($fp, 4096);
         if (!$gotFirstLine) {
             // Check line for '200'
             if (strstr($line, '200') === false) {
                 $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
                 return false;
             }
             $gotFirstLine = true;
         }
         if ($gettingHeaders && trim($line) == '') {
             $gettingHeaders = false;
             continue;
         }
         if (!$gettingHeaders) {
             // We do a binary comparison of the first two bytes, see
             // rfc1952, to check wether the content is gzipped.
             if ($contents == '' && strncmp($line, "‹", 2) === 0) {
                 $is_gzipped = true;
             }
             $contents .= $is_gzipped ? $line : trim($line) . "\n";
         }
     }
     # if gzipped, strip the 10 byte header, and pass it to gzinflate (rfc1952)
     if ($is_gzipped) {
         $contents = gzinflate(substr($contents, 10));
         //simulate trim() for each line; don't know why, but it won't work otherwise
         $contents = preg_replace('#^[\\x20\\x09\\x0A\\x0D\\x00\\x0B]*(.*)[\\x20\\x09\\x0A\\x0D\\x00\\x0B]*$#m', '\\1', $contents);
     }
     if ($this->debug) {
         echo '<pre>' . htmlspecialchars($contents) . "\n</pre>\n\n";
     }
     // Now parse what we've got back
     $this->message = new IXR_Message($contents);
     if (!$this->message->parse()) {
         // XML error
         $this->error = new IXR_Error(-32700, 'parse error. not well formed');
         return false;
     }
     // Is the message a fault?
     if ($this->message->messageType == 'fault') {
         $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
         return false;
     }
     // Message must be OK
     return true;
 }