Textpattern - на русском языке

форум общения русскоязычных пользователей CMS Текстпаттерн

Вы не зашли.

#1 29-08-2007 23:02:14

Colin Foster
глаголь
Откуда: Лимерик
Зарегистрирован: 22-08-2007
Сообщений: 32
Вебсайт

Проблема с плагином

Помогите, устанавливал плагин mem_self_register и что-то напортачил в настройках. Теперь выдаёт:

Parse error: syntax error, unexpected T_STRING in /home/aporno/public_html/textpattern/include/txp_auth.php on line 27

Неактивен

 

#2 29-08-2007 23:12:29

the_ghost
ять
Откуда: Минск
Зарегистрирован: 01-05-2007
Сообщений: 1957
Вебсайт

Re: Проблема с плагином

Редактировали файлы?


.      Создание шаблонов для Textpatern http://textpattern.ru/forum/viewtopic.php?id=1665 (<txp:make_template quality="best" />)
КОНСУЛЬТАЦИИ по Textpattern - ICQ#8458496, nemiga@gmail.com <txp:if_question><txp:pay /></txp:if_question>
       Список всех тегов - http://textbook.textpattern.net/wiki/in … _Reference

Неактивен

 

#3 29-08-2007 23:26:05

Colin Foster
глаголь
Откуда: Лимерик
Зарегистрирован: 22-08-2007
Сообщений: 32
Вебсайт

Re: Проблема с плагином

Да, по инструкции.

Неактивен

 

#4 30-08-2007 13:13:57

the_ghost
ять
Откуда: Минск
Зарегистрирован: 01-05-2007
Сообщений: 1957
Вебсайт

Re: Проблема с плагином

Colin Foster написал:

Да, по инструкции.

Значит где-то чтото упустили. Выложите текст проблемного файла куда-нибудь. Можно здесь в тег code его засунуть


.      Создание шаблонов для Textpatern http://textpattern.ru/forum/viewtopic.php?id=1665 (<txp:make_template quality="best" />)
КОНСУЛЬТАЦИИ по Textpattern - ICQ#8458496, nemiga@gmail.com <txp:if_question><txp:pay /></txp:if_question>
       Список всех тегов - http://textbook.textpattern.net/wiki/in … _Reference

Неактивен

 

#5 31-08-2007 03:26:53

Colin Foster
глаголь
Откуда: Лимерик
Зарегистрирован: 22-08-2007
Сообщений: 32
Вебсайт

Re: Проблема с плагином

Поменял файл txp_auth.php. Вроде по инструкции - все эти вещи с правами, может какой-то тег не закрыл?

Код:

<?php

/*
This is Textpattern

Copyright 2005 by Dean Allen
www.textpattern.com
All rights reserved

Use of this software indicates acceptance of the Textpattern license agreement 

$HeadURL$
$LastChangedRevision$

*/

if (!defined('txpinterface')) die('txpinterface is undefined.');

function doAuth() {
    global $txp_user;
            
    $txp_user = NULL;
    
    $message = doTxpValidate();
    
    if(!$txp_user) {
        doLoginForm($message) tr(
td().td(graf(gTxt('need_a_login')))    function txp_validate($user,$password) {
        $safe_user = doSlash($user);
        $r = safe_field("name", 
            "txp_users", "name = '$safe_user'
            and (pass = password(lower('".doSlash($password)."')) or pass = password('".doSlash($password)."')) and privs > 0");

        if ($r) {

            // update the last access time
            safe_update("txp_users", "last_access = now()", "name = '$safe_user'");
            return true;

        } else { // try old_password mysql hash

               $r_old = safe_field("name", 
                "txp_users", "name = '$safe_user'
                and (pass = old_password(lower('".doSlash($password)."')) or pass = old_password('".doSlash($password)."')) and privs > 0");
            if ($r_old) {
                safe_update("txp_users", "last_access = now()", "name = '$safe_user'");
                return true;
            }
        }
        return false;
    }
    
// -------------------------------------------------------------

    function doLoginForm($message)        
{
global $txpcfg;
include $txpcfg['txpath'].'/lib/txplib_head.php';
pagetop('log in');
echo
form(
startTable('edit').
tr(
td().td(graf($message))
).
tr(
fLabelCell('name').fInputCell('p_userid')
).
tr(
fLabelCell('password').
td(fInput('password','p_password','','edit'))
).
tr(
td().td(graf(checkbox('stay',1,1).gTxt('stay_logged_in').
popHelp('remember_login')))
).
tr(
td().td(graf(gTxt('need_a_login')))
).
tr(
fLabelCell('').td(fInput('submit','',gTxt('log_in_button'),'publish'))
).
endTable()
);
exit("</div></body></html>");-------------------------------------------------------------
    function doTxpValidate() 
    {
        global $logout,$txpcfg, $txp_user;
        $p_userid = ps('p_userid');
        $p_password = ps('p_password');
        $logout = gps('logout');
        $stay = ps('stay');
        
        if ($logout) {
            setcookie('txp_login','',time()-3600);
        }
        if (!empty($_COOKIE['txp_login']) and !$logout) {    // cookie exists
    
            @list($c_userid,$cookie_hash) = split(',',cs('txp_login'));

            $nonce = safe_field('nonce','txp_users',"name='".doSlash($c_userid)."'");

            if ((md5($c_userid.$nonce) === $cookie_hash) && $nonce) {  // check nonce
    
                $txp_user = $c_userid;    // cookie is good, create $txp_user
                return '';
    
            } else {
                    // something's gone wrong
                $txp_user = '';
                setcookie('txp_login','',time()-3600);
                return gTxt('bad_cookie');
            }
            
        } elseif ($p_userid and $p_password) {    // no cookie, but incoming login vars
        
                sleep(3); // should grind dictionary attacks to a halt
    
                if (txp_validate($p_userid,$p_password)) {

                    $nonce = safe_field('nonce','txp_users',"name='".doSlash($p_userid)."'");

                    if (!$nonce) {
                            define('TXP_UPDATE', 1);
                            include_once txpath.'/update/_update.php';
                            exit(graf('Please reload'));
                    }

                    if ($stay) {    // persistent cookie required

                        setcookie('txp_login',
                            $p_userid.','.md5($p_userid.$nonce),
                            time()+3600*24*365);    // expires in 1 year
                        if (cs('txp_nostay')) setcookie('txp_nostay','',time()-3600);

    
                    } else {    // session-only cookie required
    
                        setcookie('txp_login',$p_userid.','.md5($p_userid.$nonce));                
                        setcookie('txp_nostay','1',
                            time()+3600*24*365);    // remember nostay for 1 year
                    }
                
                    $txp_user = $p_userid;    // login is good, create $txp_user
                    return '';

                } else {
                    $txp_user = '';
                    return gTxt('could_not_log_in');
                }
    
        } else {
            $txp_user = '';
            return gTxt('login_to_textpattern');
        }    
    }
?>

И файл  txp_admin.php:

Код:

<?php

/*
    This is Textpattern

    Copyright 2005 by Dean Allen
    www.textpattern.com
    All rights reserved

    Use of this software indicates acceptance of the Textpattern license agreement

$HeadURL$
$LastChangedRevision$

*/

    if (!defined('txpinterface'))
    {
        die('txpinterface is undefined.');
    }

    $levels = array(
        1 => gTxt('publisher'),
        2 => gTxt('managing_editor'),
        3 => gTxt('copy_editor'),
        4 => gTxt('staff_writer'),
        5 => gTxt('freelancer'),
        6 => gTxt('designer'),
        0 => gTxt('none')
    );

    if ($event == 'admin')
    {
        require_privs('admin');

        $available_steps = array(
            'admin',
            'author_change_pass',
            'author_delete',
            'author_list',
            'author_save',
            'author_save_new',
            'change_email',
            'change_pass'
        );

        if (!$step or !in_array($step, $available_steps))
        {
            admin();
        }

        else
        {
            $step();
        }
    }

// -------------------------------------------------------------

    function admin($message = '')
    {
        global $txp_user;

        pagetop(gTxt('site_administration'), $message);

        if (!is_callable('mail'))
        {
            echo tag(gTxt('warn_mail_unavailable'), 'p',' id="warning" ');
        }

        $email = fetch('email', 'txp_users', 'name', $txp_user);

        echo new_pass_form().
            change_email_form($email);

        if (has_privs('admin.list'))
        {
            echo author_list();
        }

        if (has_privs('admin.edit'))
        {
            echo new_author_form().
                reset_author_pass_form();
        }
    }

// -------------------------------------------------------------

    function change_email()
    {
        global $txp_user;

        require_privs('admin.edit');

        $new_email = gps('new_email');

        if (!is_valid_email($new_email))
        {
            admin(gTxt('email_required'));
            return;
        }

        $rs = safe_update('txp_users', "email = '".doSlash($new_email)."'", "name = '".doSlash($txp_user)."'");

        if ($rs)
        {
            admin(
                gTxt('email_changed', array('{email}' => $new_email))
            );
        }
    }

// -------------------------------------------------------------

    function author_save()
    {
        require_privs('admin.edit');

        extract(doSlash(psa(array('privs', 'user_id', 'RealName', 'email'))));
        $privs   = assert_int($privs);
        $user_id = assert_int($user_id);

        if (!is_valid_email($email))
        {
            admin(gTxt('email_required'));
            return;
        }

        $rs = safe_update('txp_users', "
            privs         = $privs,
            RealName = '$RealName',
            email         = '$email'",
            "user_id = $user_id"
        );

        if ($rs)
        {
            admin(
                gTxt('author_updated', array('{name}' => $RealName))
            );
        }
    }

// -------------------------------------------------------------

    function change_pass()
    {
        global $txp_user;

        extract(doSlash(psa(array('new_pass', 'mail_password'))));

        if (empty($new_pass))
        {
            admin(gTxt('password_required'));
            return;
        }

        $rs = safe_update('txp_users', "pass = password(lower('$new_pass'))", "name = '".doSlash($txp_user)."'");

        if ($rs)
        {
            $message = gTxt('password_changed');

            if ($mail_password)
            {
                $email = fetch('email', 'txp_users', 'name', $txp_user);

                send_new_password($new_pass, $email, $txp_user);

                $message .= sp.gTxt('and_mailed_to').sp.$email;
            }

            else
            {
                echo comment(mysql_error());
            }

            $message .= '.';

            admin($message);
        }
    }

// -------------------------------------------------------------

    function author_save_new()
    {
        require_privs('admin.edit');

        extract(doSlash(psa(array('privs', 'name', 'email', 'RealName'))));
        $privs = assert_int($privs);

        if ($name && is_valid_email($email))
        {
            $password = doSlash(generate_password(6));
            $nonce = doSlash(md5(uniqid(rand(), true)));

            $rs = safe_insert('txp_users', "
                privs         = $privs,
                name         = '$name',
                email         = '$email',
                RealName = '$RealName',
                pass         =    password(lower('$password')),
                nonce         = '$nonce'
            ");

            if ($rs)
            {
                send_password($RealName, $name, $email, $password);

                admin(
                    gTxt('password_sent_to').sp.$email
                );

                return;
            }
        }

        admin(gTxt('error_adding_new_author'));
    }

// -------------------------------------------------------------

    function privs($priv = '')
    {
        global $levels;
        return selectInput('privs', $levels, $priv);
    }

// -------------------------------------------------------------

    function get_priv_level($priv)
    {
        global $levels;
        return $levels[$priv];
    }

// -------------------------------------------------------------

    function send_password($RealName, $name, $email, $password)
    {
        global $sitename;

        require_privs('admin.edit');

        $message = gTxt('greeting').' '.$RealName.','.

            "\r\n"."\r\n".gTxt('you_have_been_registered').' '.$sitename.

            "\r\n"."\r\n".gTxt('your_login_is').': '.$name.
            "\r\n".gTxt('your_password_is').': '.$password.

            "\r\n"."\r\n".gTxt('log_in_at').': '.hu.'textpattern/index.php';

        return txpMail($email, "[$sitename] ".gTxt('your_login_info'), $message);
    }

// -------------------------------------------------------------

    function send_new_password($password, $email, $name)
    {
        global $txp_user, $sitename;

        if ( empty( $name)) $name = $txp_user;
            
        $message = gTxt('greeting').' '.$name.','.

            "\r\n"."\r\n".gTxt('your_password_is').': '.$password.

            "\r\n"."\r\n".gTxt('log_in_at').': '.hu.'textpattern/index.php';

        return txpMail($email, "[$sitename] ".gTxt('your_new_password'), $message);
    }

// -------------------------------------------------------------

    function generate_password($length = 10)
    {
        $pass = '';
        $chars = '023456789bcdfghjkmnpqrstvwxyz';
        $i = 0;

        while ($i < $length)
        {
            $char = substr($chars, mt_rand(0, strlen($chars)-1), 1);

            if (!strstr($pass, $char))
            {
                $pass .= $char;
                $i++;
            }
        }

        return $pass;
    }

// -------------------------------------------------------------

    function new_pass_form()
    {
        return '<div style="margin-top: 3em auto auto auto; text-align: center;">'.
        form(
            tag(gTxt('change_password'), 'h3').

            graf('<label for="new_pass">'.gTxt('new_password').'</label> '.
                fInput('password', 'new_pass', '', 'edit', '', '', '20', '1', 'new_pass').
                checkbox('mail_password', '1', true, '', 'mail_password').'<label for="mail_password">'.gTxt('mail_it').'</label> '.
                fInput('submit', 'change_pass', gTxt('submit'), 'smallerbox').
                eInput('admin').
                sInput('change_pass')
            ,' style="text-align: center;"')
        ).'</div>';
    }

// -------------------------------------------------------------

    function reset_author_pass_form()
    {
        global $txp_user;

        $names = array();

        $them = safe_rows_start('*', 'txp_users', "name != '".doSlash($txp_user)."'");

        while ($a = nextRow($them))
        {
            extract($a);

            $names[$name] = $RealName.' ('.$name.')';
        }

        if ($names)
        {
            return '<div style="margin: 3em auto auto auto; text-align: center;">'.
            form(
                tag(gTxt('reset_author_password'), 'h3').
                graf(gTxt('a_new_password_will_be_mailed')).
                    graf(selectInput('name', $names, '', 1).
                    fInput('submit', 'author_change_pass', gTxt('submit'), 'smallerbox').
                    eInput('admin').
                    sInput('author_change_pass')
                ,' style="text-align: center;"')
            ).'</div>';
        }
    }

// -------------------------------------------------------------

    function author_change_pass()
    {
        require_privs('admin.edit');

        $name = ps('name');

        $email = safe_field('email', 'txp_users', "name = '".doSlash($name)."'");
        $new_pass = doSlash(generate_password(6));

        $rs = safe_update('txp_users', "pass = password(lower('$new_pass'))", "name = '".doSlash($name)."'");

        if ($rs)
        {
            if (send_new_password($new_pass, $email, $name))
            {
                admin(gTxt('password_sent_to').' '.$email);
            }

            else
            {
                admin(gTxt('could_not_mail').' '.$email);
            }
        }

        else
        {
            admin(gTxt('could_not_update_author').' '.$name);
        }
    }

// -------------------------------------------------------------

    function change_email_form($email)
    {
        return '<div style="margin-top: 3em auto auto auto; text-align: center;">'.
        form(
            tag(gTxt('change_email_address'), 'h3').
            graf('<label for="new_email">'.gTxt('new_email').'</label> '.
                fInput('text', 'new_email', $email, 'edit', '', '', '20', '2', 'new_email').
                fInput('submit', 'change_email', gTxt('submit'), 'smallerbox').
                eInput('admin').
                sInput('change_email')
            ,' style="text-align: center;"')
        ).'</div>';
    }

// -------------------------------------------------------------

    function author_list()
    {
        global $txp_user;

        echo n.n.hed(gTxt('authors'), 3,' style="text-align: center;"').

            n.n.startTable('list').

            n.tr(
                n.hCell(gTxt('real_name')).
                n.hCell(gTxt('login_name')).
                n.hCell(gTxt('email')).
                n.hCell(gTxt('privileges')).
                n.hCell().
                n.hCell()
            );

        $rs = safe_rows_start('*', 'txp_users', '1 = 1');

        if ($rs)
        {
            if (has_privs('admin.edit'))
            {
                while ($a = nextRow($rs))
                {
                    extract($a);

                    echo n.n.'<tr>'.

                        n.'<form method="post" action="index.php">'.

                        n.td(
                            fInput('text', 'RealName', $RealName, 'edit')
                        ).

                        td($name).
                        td(
                            fInput('text', 'email', $email, 'edit')
                        );

                    if ($name != $txp_user)
                    {
                        echo td(
                            privs($privs).sp.popHelp('about_privileges')
                        );
                    }

                    else
                    {
                        echo td(
                            get_priv_level($privs).sp.popHelp('about_privileges').
                            hInput('privs', $privs)
                        );
                    }

                    echo td(
                        fInput('submit', 'save', gTxt('save'), 'smallerbox')
                    ).

                    n.hInput('user_id', $user_id).
                    n.eInput('admin').
                    n.sInput('author_save').
                    n.'</form>';

                    if ($name != $txp_user)
                    {
                        echo td(
                            dLink('admin', 'author_delete', 'user_id', $user_id)
                        );
                    }

                    else
                    {
                        echo td();
                    }

                    echo n.'</tr>';
                }
            }

            else
            {
                while ($a = nextRow($rs))
                {
                    extract($a);

                    echo tr(
                        td($RealName).
                        td($name).
                        td('<a href="mailto:'.$email.'">'.$email.'</a>').
                        td(
                            get_priv_level($privs).sp.popHelp('about_privileges').
                            hInput('privs', $privs)
                        ).
                        td().
                        td()
                    );
                }
            }

            echo n.endTable();
        }
    }

// -------------------------------------------------------------

    function author_delete()
    {
        require_privs('admin.edit');

        $user_id = assert_int(ps('user_id'));

        $name = fetch('Realname', 'txp_users', 'user_id', $user_id);

        if ($name)
        {
            $rs = safe_delete('txp_users', "user_id = $user_id");

            if ($rs)
            {
                admin(
                    gTxt('author_deleted', array('{name}' => $name))
                );
            }
        }
    }

// -------------------------------------------------------------

    function new_author_form()
    {
        return form(
            hed(gTxt('add_new_author'), 3,' style="margin-top: 2em; text-align: center;"').
            graf(gTxt('a_message_will_be_sent_with_login'), ' style="text-align: center;"').

            startTable('edit').
            tr(
                fLabelCell('real_name').
                fInputCell('RealName')
            ).

            tr(
                fLabelCell('login_name').
                fInputCell('name')
            ).

            tr(
                fLabelCell('email').
                fInputCell('email')
            ).

            tr(
                fLabelCell('privileges').
                td(
                    privs().sp.popHelp('about_privileges')
                )
            ).

            tr(
                td().
                td(
                    fInput('submit', '', gTxt('save'), 'publish').sp.popHelp('add_new_author')
                )
            ).

            endTable().

            eInput('admin').
            sInput('author_save_new')
        );
    }

?>

Неактивен

 

#6 31-08-2007 10:18:48

the_ghost
ять
Откуда: Минск
Зарегистрирован: 01-05-2007
Сообщений: 1957
Вебсайт

Re: Проблема с плагином

в txp_auth.php на 26-28 строчке не хватает одной закрываюшей скобки.

Код:

    if(!$txp_user) {
        doLoginForm($message) tr(td().td(graf(gTxt('need_a_login'))))
        function txp_validate($user,$password) {

.      Создание шаблонов для Textpatern http://textpattern.ru/forum/viewtopic.php?id=1665 (<txp:make_template quality="best" />)
КОНСУЛЬТАЦИИ по Textpattern - ICQ#8458496, nemiga@gmail.com <txp:if_question><txp:pay /></txp:if_question>
       Список всех тегов - http://textbook.textpattern.net/wiki/in … _Reference

Неактивен

 

#7 01-09-2007 11:10:47

Colin Foster
глаголь
Откуда: Лимерик
Зарегистрирован: 22-08-2007
Сообщений: 32
Вебсайт

Re: Проблема с плагином

the_ghost, эту ошибку исправил. Теперь выдаёт:

Parse error: syntax error, unexpected T_STRING in /home/aporno/public_html/textpattern/include/txp_auth.php on line 19

Неактивен

 

Board footer

RSS   Rambler's Top100
Powered by PunBB
Textpattern.ru