Post from an external page

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
Pouzy
Registered User
Posts: 35
Joined: Wed Dec 29, 2004 9:56 am
Location: France
Contact:

Post from an external page

Post by Pouzy »

Hi guys !

I'm actually still running a PhpBB2 version on my website, so it's getting old...
On this website I've got an external page to post new topics, here it is : http://www.aidoforum.com/demande-aide.php (login : usertest / pass : test ).
Sorry that the page is in french, but the log-in form is on the right hand side, and then you'll see the actual page. It's just a text field, with a select to know the right category to post in.

Have you got any clue on how to do this on phpBB3 ? I've been searching for a while but I don't find anything yet.

Or just maybe tell me all the stuffs created in the database when a new topic is created on phpBB3 so I can create them manually ?

Thanks a lot !

Pouzy :mrgreen:
Last edited by ameeck on Mon Mar 16, 2009 1:31 pm, edited 1 time in total.
Reason: Topic icon changed
ameeck
Former Team Member
Posts: 6559
Joined: Mon Mar 21, 2005 6:57 pm

Re: Post from an external page

Post by ameeck »

See Example 1.6 on this page: http://www.phpbb.com/mods/documentation ... nsert-post, it should help you make the basics.

Moving to 3.0.x MODs Writers Discussion
User avatar
Pouzy
Registered User
Posts: 35
Joined: Wed Dec 29, 2004 9:56 am
Location: France
Contact:

Re: Post from an external page

Post by Pouzy »

Hi and thank you very much !

It almost works.

I've got a small problem in fact... :mrgreen: My request_var() function always returns the default text

Code: Select all

$my_text=$_POST['Texte'];
$my_subject=$_POST['Titre'];

echo '<strong>'.$my_text;

// note that multibyte support is enabled here 
$my_subject    = utf8_normalize_nfc(request_var('my_subject', 'Test', true));
$my_text    = utf8_normalize_nfc(request_var('my_text', 'TestText', true)); 
I've put this echo() to see if the $my_subject and $my_text vars are full before using request_var, and they are. But after, they always have the default text (here "Test" and "TestText").

I include includes/functions.php and includes/functions_post.php

Any idea ? Or any trick to prepare the variables without request_var ?

Thanks :D

EDIT : I think I've found, the request_var uses directly the _POST variables and I transfered them in other variables so it didn't work ;)

EDIT2 :

Ok, but now I have a problem with french accents ! When there's no special characters, no problem. But when there is, the variable gets blank.
I tried this :

Code: Select all

// note that multibyte support is enabled here 
$my_subject    = utf8_normalize_nfc(utf8_recode(request_var('Titre', 'Test', true), 'iso-8859-15'));
$my_text    = utf8_normalize_nfc(utf8_recode(request_var('Texte', 'TestText', true), 'iso-8859-15')); 
But still doesn't work... I don't know where to search :D
Thanks !
Last edited by Pouzy on Fri Mar 13, 2009 12:37 pm, edited 2 times in total.
ameeck
Former Team Member
Posts: 6559
Joined: Mon Mar 21, 2005 6:57 pm

Re: Post from an external page

Post by ameeck »

Try it without utf8_recode:

Code: Select all

$my_subject   = utf8_normalize_nfc(request_var('Titre', 'Test', true));
$my_text   = utf8_normalize_nfc(request_var('Texte', 'TestText', true)); 
Last edited by ameeck on Fri Mar 13, 2009 12:53 pm, edited 1 time in total.
User avatar
Pouzy
Registered User
Posts: 35
Joined: Wed Dec 29, 2004 9:56 am
Location: France
Contact:

Re: Post from an external page

Post by Pouzy »

ameeck wrote:Try it without utf8_recode:

Code: Select all

$my_subject   = utf8_normalize_nfc(request_var('Titre', 'Test', true)));
$my_text   = utf8_normalize_nfc(request_var('Texte', 'TestText', true)); 

I've put this utf8_recode because it didn't work without ... So no, it doesn't work either :cry:

Thanks :)
User avatar
Pouzy
Registered User
Posts: 35
Joined: Wed Dec 29, 2004 9:56 am
Location: France
Contact:

Re: Post from an external page

Post by Pouzy »

Hm, I've read some stuffs about this, I'm still trying to figure out why it doesn't work with accentuated characters :S

I tried this too, from this topic but it still doesn't work :

Code: Select all

// note that multibyte support is enabled here 
$my_subject    = utf8_normalize_nfc(request_var('Titre', 'Titre', true));
$my_text    = utf8_normalize_nfc(request_var('Texte', 'Texte', true));
 
But still doesn't work. I'm going crazy, I've tried anything :( ! Might it come from my page encoding ? :|
User avatar
Nelsaidi
Registered User
Posts: 525
Joined: Mon Feb 11, 2008 1:59 pm
Location: London, UK
Contact:

Re: Post from an external page

Post by Nelsaidi »

Are you sure you are submitting it?

Try putting at the top of the page

$_REQUEST['Titre'] = 'If this shows up then I Work.'

Then run it, if it changes then you are not submitting the variable. Note, the data has to be submitted to it via GET/POST in order for it to work, you probably know that, but try the above.

Also try 'echo $_POST['Titre'];' to make sure it actually has something.

If the above dont work then you are not submitting the anything to ti.


Either way as a mod for yourself, $_POST/$_GET/$_REQUEST will suffice, since its all escaped in the submit_post function and stuff, then its fine tbh. Replace the request_var function with $_POST['key']
Image
Click here to find out what eRepublik is.
User avatar
Pouzy
Registered User
Posts: 35
Joined: Wed Dec 29, 2004 9:56 am
Location: France
Contact:

Re: Post from an external page

Post by Pouzy »

Yeah, as I told in my second post, I'm doing an echo at the end of the page :

Code: Select all

<?php echo $_POST['Titre'].'<br />'.$_POST['Texte'].'<br />var forum <br />.'.$my_subject.'<br />.'.$my_text.'</td>'; ?>
Without accents, I've got (if i type : "Title" and "without accents") :
Title
Without accents
var forum
.Title
.Without accents
And the post is correctly inserted in the forum DB.

But is throwing away the request_var function not a bit dangerous ? Or not good for the bbcode understanding, or anything...
And if i put an accent, anywhere, lets say in the text, i've got :
Title
With accents éùà
var forum
.Title
.
I'm going insane :D !
User avatar
Pouzy
Registered User
Posts: 35
Joined: Wed Dec 29, 2004 9:56 am
Location: France
Contact:

Re: Post from an external page

Post by Pouzy »

Have you ever seen something like that or not ? :S

Can it come from my page's encoding ?
Here it is :

Code: Select all

  <meta content="text/html; charset=ISO-8859-15" http-equiv="content-type" />

 
User avatar
Pouzy
Registered User
Posts: 35
Joined: Wed Dec 29, 2004 9:56 am
Location: France
Contact:

Re: Post from an external page

Post by Pouzy »

Ok, I've worked a bit more on ut8_recode, and it works now ;)
Thank you !
Locked

Return to “[3.0.x] MOD Writers Discussion”