• Rejestracja
vBHELP.pl - polskie wsparcie vBulletin
Like Tree1Przydatne posty
  • 1 Autor Seba
  1. #1
    Artos jest nieaktywny Początkujący
    Dołączył
    Jul 2011
    Posty
    12
    Przydatne posty
    1

    Domyślnie Pobieranie IP osoby, która napisała posta.

    Witam.

    Otóż ściągnąłem modyfikacje Thread Stencil i postanowiłem ją lekko zmodyfikować na potrzeby własne.

    Moim problemem jest to, że gdy próbuję użyć zmiennej $vbulletin->userinfo['ipaddress'] nic się nie pojawia.

    Cała dodana linijka wygląda tak:

    Kod php:
    $foruminfo['stencilmsg'] = str_replace("[ip]",$vbulletin->userinfo['ipaddress'],$foruminfo['stencilmsg']); 
    Prosił bym o pomoc.


     
    Kod php:
    <?xml version="1.0" encoding="ISO-8859-1"?>

    <product productid="ej_vb_2" active="1">
        <title>Thread Stencil</title>
        <description>This hack will let you predefine messages for creating new threads in the forums of your choice.</description>
        <version>1.3</version>
        <codes>
            <code version="1.2">
                <installcode><![CDATA[$db->hide_errors();
    $db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum ADD (stencilon varchar(10) NOT NULL DEFAULT '')");
    $db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum ADD (stenciltitle varchar(50) NOT NULL DEFAULT '')");
    $db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum ADD (stencilmsg TEXT NOT NULL DEFAULT '')");
    $db->show_errors();]]></installcode>
                <uninstallcode><![CDATA[$db->hide_errors();
    $db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum DROP stencilon");
    $db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum DROP stenciltitle");
    $db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum DROP stencilmsg");
    $db->show_errors();
    ]]></uninstallcode>
            </code>
        </codes>
        <templates>
        </templates>
        <plugins>
            <plugin active="1">
                <title>Thread Stencil</title>
                <hookname>forumadmin_edit_form</hookname>
                <phpcode><![CDATA[print_table_header($vbphrase['forumstencil_title']);
    print_yes_no_row($vbphrase['stencilon'], 'forum[stencilon]', $forum['stencilon']);
    print_input_row($vbphrase['stenciltitle'], 'forum[stenciltitle]', $forum['stenciltitle']);
    print_textarea_row($vbphrase['stencilmsg'], 'forum[stencilmsg]', $forum['stencilmsg']);]]></phpcode>
            </plugin>
            <plugin active="1">
                <title>Thread Stencil</title>
                <hookname>forumdata_start</hookname>
                <phpcode><![CDATA[$this->validfields['stencilon'] = array(TYPE_BOOL, REQ_NO);
    $this->validfields['stenciltitle'] = array(TYPE_STR, REQ_NO);
    $this->validfields['stencilmsg'] = array(TYPE_STR, REQ_NO);]]></phpcode>
            </plugin>
            <plugin active="1">
                <title>Thread Stencil</title>
                <hookname>newthread_start</hookname>
                <phpcode><![CDATA[//check if forums is supposed to have stencil or not
    if ($foruminfo['stencilon'])
    {
    // Write stencil
        // Replace [username]
        $foruminfo['stenciltitle'] = str_replace("[username]",$vbulletin->userinfo['username'],$foruminfo['stenciltitle']);
        $foruminfo['stencilmsg'] = str_replace("[username]",$vbulletin->userinfo['username'],$foruminfo['stencilmsg']);
        // Replace [date]
        $foruminfo['stenciltitle'] = str_replace("[date]",date("d.m.Y"),$foruminfo['stenciltitle']);
        $foruminfo['stencilmsg'] = str_replace("[date]",date("d.m.Y"),$foruminfo['stencilmsg']);
        // Replace [ip]
        $foruminfo['stenciltitle'] = str_replace("[ip]",$vbulletin->userinfo['ipaddress'],$foruminfo['stenciltitle']);
        $foruminfo['stencilmsg'] = str_replace("[ip]",$vbulletin->userinfo['ipaddress'],$foruminfo['stencilmsg']);
        
        $newpost['title'] = $foruminfo['stenciltitle'];
        $newpost['message'] = $foruminfo['stencilmsg'];
    }]]></phpcode>
            </plugin>
        </plugins>
        <phrases>
            <phrasetype name="Forum-Related" fieldname="forum">
                <phrase name="forumstencil_title"><![CDATA[Thread Stencil]]></phrase>
                <phrase name="stencilmsg"><![CDATA[<b>Predefined Message</b><br />Output info: [username], [date], [ip].<br /><br />You may apply BB Code.]]></phrase>
                <phrase name="stencilon"><![CDATA[<b>Turn On / Off</b><br />Set this to 'yes' to enable the stencil in this forum.]]></phrase>
                <phrase name="stenciltitle"><![CDATA[<b>Predefined Title</b><br />Output info: [username], [date].]]></phrase>
            </phrasetype>
        </phrases>
        <options>
        </options>
    </product>



  2. #2
    Seba jest nieaktywny Advanced Member
    Dołączył
    Feb 2009
    Posty
    1 059
    Przydatne posty
    44

    Domyślnie

    Chcesz adres ip piszącego post?

    Kod php:
    $ip = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; 
    Artos uważa to za przydatne.
    Profesjonalne modyfikacje vBulletin oraz style - gg 1981480 badz PW


  3. #3
    Artos jest nieaktywny Początkujący
    Dołączył
    Jul 2011
    Posty
    12
    Przydatne posty
    1

    Domyślnie

    Działa jak marzenie! Dziękuję serdecznie.

    Mam kolejne pytanie jeśli można.

    Chciałbym tym razem pobrać dane z "Custom Profile Field ", które dodałem poprzez panel. Numer tego pola to 6. Jakiej zmiennej mogę użyć do pobrania zawartości tego pola?


  4. #4
    Awatar Max
    Max
    Max jest nieaktywny There's something in the Air ...
    Dołączył
    Jan 2008
    Posty
    4 775
    Przydatne posty
    252
    Wpisów
    13

    Domyślnie Temat oznaczony jako "ROZWIĄZANY"

    Ten problem został rozwiązany, a wątek zamknięty.

    • Jeśli chcesz zadać nowe pytanie, załóż nowy wątek.
    • Jeśli masz wątpliwości odnośnie rozwiązanego problemu, poproś moderatora o otworzenie wątku.


Chmurka.pl

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67