[Function] Insert Post

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Urza
Registered User
Posts: 4
Joined: Tue Dec 21, 2004 7:08 pm

Post by Urza »

I have a few problems adding a poll. I used the following code.

Code: Select all

    // initialise some variables
    $topic_vote = 1; 
    $poll_title = 'Can I join?';
    $poll_options = 'Yes, No';
    $poll_length = '';
    $mode = 'reply'; 
Now it does add [Poll] to the post name. But I don't get a poll. What am I doing wrong?
Lord Raiden
Registered User
Posts: 391
Joined: Sat Jun 26, 2004 11:24 pm
Contact:

Post by Lord Raiden »

Silly question, but as an extra thought in regards to this mod (which I'm just estatic that someone figured this out because it's going to be HUGELY useful to me. :)) is there a way that when my cgi script completes the steps involved in creating the thread in the forums, it can then capture the thread ID so that I can insert a little "discuss this in the forums" link at the bottom of my news posts with a link to the associated thread? Or would I have to add that manually?
Steve Lake
-Owner/Admin/Author of:
-Raiden's Realm - Bringing Linux to the World
leoz
Registered User
Posts: 35
Joined: Wed Nov 12, 2003 6:35 am
Location: Nashville, TN, USA.
Contact:

THANKS!

Post by leoz »

Thanks netcletic for the MOD, it works beautifully for me. It is a pre-requisite for our new genealogy MOD at:

http://www.phpbb.com/phpBB/viewtopic.php?t=256683

Mark.
User avatar
Techie-Micheal
Security Consultant
Posts: 19511
Joined: Sun Oct 14, 2001 12:11 am
Location: In your servers

Post by Techie-Micheal »

Urza wrote: I have a few problems adding a poll. I used the following code.

Code: Select all

    // initialise some variables
    $topic_vote = 1; 
    $poll_title = 'Can I join?';
    $poll_options = 'Yes, No';
    $poll_length = '';
    $mode = 'reply'; 
Now it does add [Poll] to the post name. But I don't get a poll. What am I doing wrong?
Did you ever get this working?
Proven Offensive Security Expertise. OSCP - GXPN
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

The poll options should be an array.

Code: Select all

$poll_length = 0;
	$poll_title = 'Rate this Download';
	$poll_options = array('Good', 'Fair', 'Poor');
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
User avatar
Techie-Micheal
Security Consultant
Posts: 19511
Joined: Sun Oct 14, 2001 12:11 am
Location: In your servers

Post by Techie-Micheal »

A_Jelly_Doughnut wrote: The poll options should be an array.

Code: Select all

$poll_length = 0;
	$poll_title = 'Rate this Download';
	$poll_options = array('Good', 'Fair', 'Poor');
That's what I thought, but I wanted to make sure before I dove in to this.
Proven Offensive Security Expertise. OSCP - GXPN
User avatar
Techie-Micheal
Security Consultant
Posts: 19511
Joined: Sun Oct 14, 2001 12:11 am
Location: In your servers

Post by Techie-Micheal »

General Error

Error in posting

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1106614587, 2, 0, 0, 0)' at line 1

INSERT INTO blah_topics (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('Test', , 1106614587, 2, 0, 0, 0)

Line : 122
File : /home/micheal/www/sites/spsac.net/discuss/extras/functions_insert_post.php

That's the error I get. Unmodified test_insert_post.php and unmodified functions_insert_posts.php. I only changed the paths, and that doesn't appear to be the problem. Anybody? It doesn't appear to be picking up the $user_id variable.
Proven Offensive Security Expertise. OSCP - GXPN
User avatar
Techie-Micheal
Security Consultant
Posts: 19511
Joined: Sun Oct 14, 2001 12:11 am
Location: In your servers

Post by Techie-Micheal »

Seems like none of the $userdata array is being passed along to the function. When I did get it (manually changing the appropriate information in the function arguments), it updated the topic count and post count but the topic is nowhere to be found.
Proven Offensive Security Expertise. OSCP - GXPN
Urza
Registered User
Posts: 4
Joined: Tue Dec 21, 2004 7:08 pm

Post by Urza »

Techie-Micheal wrote:
A_Jelly_Doughnut wrote:The poll options should be an array.

Code: Select all

$poll_length = 0;
	$poll_title = 'Rate this Download';
	$poll_options = array('Good', 'Fair', 'Poor');
That's what I thought, but I wanted to make sure before I dove in to this.


Well this took away the error I got when I entered more then 1 option.
But it still doesn't create a poll :cry: . Still all I get is only the message and the [Poll] infront of the title. But no poll itself.

Also I'm wondering. Do I maby need to add something in the test_insert_post.php file to make the poll work.
In the

Code: Select all

    $subject = stripslashes($HTTP_POST_VARS['subject']);
    $post_details = insert_post($message, $subject, $forum_id, $userdata['user_id'], $userdata['username'], $userdata['user_attachsig']);
    $url = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx . '?' . POST_TOPIC_URL . '=' . $post_details['topic_id']);
    echo '<a href="' . $url . '">new topic, id: ' . $post_details['topic_id'] . '</a><br/>';
lines maby?
User avatar
Techie-Micheal
Security Consultant
Posts: 19511
Joined: Sun Oct 14, 2001 12:11 am
Location: In your servers

Post by Techie-Micheal »

I was told that polls don't completely work in this, and from the code, it doesn't appear to be.

----
Has anybody tried integrating this and had problems with function setup_style($style) on line 313 of an unmodified functions.php? It keeps telling me that sql_query is not defined so it looks like $db is getting lost somewhere, but if I try to reinitialize $db using $db = new sql_db(...) in functions.php, it won't ever get past trying to get the template information in setup_style. I tried both a seperate file and in functions.php. Both give the same problem. But, if I do not try to integrate this with my application, I don't have any problems (got past the one I had above, not sure what happened). So ... Not sure if it is a problem with my app somewhere (probably) or if something else is wrong.
Proven Offensive Security Expertise. OSCP - GXPN
User avatar
Techie-Micheal
Security Consultant
Posts: 19511
Joined: Sun Oct 14, 2001 12:11 am
Location: In your servers

Post by Techie-Micheal »

Okay, now I get this ... Surely someone has run in to this before?
Warning: Empty regular expression in /home/--/includes/functions_post.php on line 118

Warning: Empty regular expression in /home/--/includes/functions_post.php on line 103

Warning: Empty regular expression in /home/--/includes/functions_post.php on line 118

Warning: Empty regular expression in /home/--/includes/functions_post.php on line 118
Proven Offensive Security Expertise. OSCP - GXPN
wcross
Registered User
Posts: 4
Joined: Fri Mar 04, 2005 2:27 pm

Post by wcross »

Regarding getting polls to work properly. This is what I did to make it work. (I know this is not the best way, but it works quite well)

in function insert_post:

look for this line towards the top of the function:

Code: Select all

// initialise some variables
Change it as needed to get this:

Code: Select all

    $topic_vote = 1; 
    $poll_title = 'How would you rate this story?';
    $poll_length = '';
    $poll_options = array();
    array_push($poll_options, "Not Good");
    array_push($poll_options, "Not bad");
    array_push($poll_options, "Pretty Good");
    array_push($poll_options, "Awesome");
then further down in the same function look for:

Code: Select all

 $post_id = $db->sql_nextid();
and follow it with this:

Code: Select all

    // insert our poll and answers
    $btime = time();
    $sql = "INSERT INTO x_phpbb_vote_desc set topic_id='$topic_id', vote_text='$poll_title', vote_start='$btime', vote_length='0'";
    $db->sql_query($sql, BEGIN_TRANSACTION);
    echo mysql_error() . "\n";
    $myvote_id = $db->sql_nextid();

    $mcnt=0;
    foreach($poll_options as $mtex){
      $mcnt++;
      $sql = "INSERT INTO x_phpbb_vote_results set vote_id='$myvote_id', vote_option_id='$mcnt', vote_option_text='$mtex', vote_result='0'";
      $db->sql_query($sql, BEGIN_TRANSACTION);
      echo mysql_error() . "\n";
    }
Thats it. Not a very pretty fix, but it works well. You would want to change the database tables names to whatever you have your prefix set to. Mines x_phpbb_
William Cross
Buy Links from the leader in text link ad sales.
rizzah
Registered User
Posts: 1
Joined: Wed Mar 09, 2005 4:10 am

Inserting message

Post by rizzah »

hello, I'm using this mod to add a thread to my forum from a form. The test page worked to perfection but I'm having some problems now once I add my own form, and I'm only having problems when I try to add things to the $message variable. For instance this is what I have now


Code: Select all

$message = "Forum ID: " . $HTTP_POST_VARS['forum'] . $HTTP_POST_VARS['team'];
Because there's always a message it assumes the form has been sent, is there any way around this so I can actually format whats in $message?
wcross
Registered User
Posts: 4
Joined: Fri Mar 04, 2005 2:27 pm

Post by wcross »

format it before setting $message

$formatted_stuff ='something' . 'something else';
$message = $formatted_stuff
William Cross
Buy Links from the leader in text link ad sales.
Serj21
Registered User
Posts: 137
Joined: Thu Apr 15, 2004 6:23 pm
Contact:

Post by Serj21 »

Hey great function,

Enabled me to create script to auto post a thread every night at midnight :)

Just wondering if you knew how to allow the script to grab the url of the previous thread in that forum?

Because my script is the only person allowed to post threads in that forum so in the new days thread I would like to include a link to yeasterdays thread.

Also anyway to get the function to as well as creating the days post to unsticky the pervious days sticky?

If you had any suggestions it would be great,

Thanks, Serj
Post Reply

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