vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Auto-creation of threads? (https://vborg.vbsupport.ru/showthread.php?t=61030)

Gryphon 11-09-2004 05:38 PM

This thread has been very helpful, though I am having some trouble. Here is the my current code:

PHP Code:

if ($_POST["action"] == 'add') {
  
query("INSERT INTO psu_news SET author='$user[name]', title='$_POST[title]', date_added='$setting[time]', post_id='$_POST[post_id]'");
  
$psu_news_id mysql_insert_id();

  if (
$_POST["create_post"] == '1' && $_POST["post_id"] == '0') {
    
// vb functions
    
chdir('/home/psuwww/wwwroot/site.com/forums');
    require(
'./global.php');
    require(
'./includes/functions_newpost.php');

    
$userid 5// The user creating the thread
    
$forumid 2// The forum where the thread is to be posted

    // forum & user info
    
$foruminfo fetch_foruminfo($forumid);
    
$bbuserinfo fetch_userinfo($userid);

    
// setup the thread
    
$post[title] = '[News] '.$_POST["title"].'';
    
$post[message] = '[url=http://www.site.com/index.php?newsid='.$psu_news_id.']http://www.site.com/index.php?newsid='.$psu_news_id.'[/url]';
    
$post[poststarttime] = TIMENOW;
    
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']);
    
$post[emailupdate] = 9999;

    
// build the thread
    
build_new_post('thread'$foruminfo, array(), 0$post$errors);

    
// bome back to working dir
    
chdir('/home/psuwww/wwwroot/site.com/admin');
    
query("UPDATE psu_news SET post_id='$post[threadid]' WHERE id='$psu_news_id'");
  }
  echo 
'<hr><font size="3"><b>Post Added '.$psu_news_id.'</b><hr>';


The Thread title posts correctly and the Message also posts, however, $psu_news_id becomes unset. The message url in the created thread is missing the $psu_news_id and the final echo is blank.

Also, this is all done mid template on our site, and all the variables pre-defined at the top of the script are unset after this.

Any info appreciated.

Gryphon 11-11-2004 04:00 PM

That is too bad :(

sabret00the 11-11-2004 04:15 PM

i would love something like this based on

if posts on the forums in XX hours < XX then create thread

zeropaid 11-15-2004 07:38 PM

I am also having problems creating posts... here is my code:

PHP Code:

 chdir('/usr/local/www/htdocs/bbs');

// Load vB-Backend
require('./global.php');
require('/includes/functions_newpost.php');

$userid = $_POST[news_user_id]; // The user creating the thread
$forumid = 120; // The forum where the thread should be posted

// Get forum & user info
$foruminfo = fetch_foruminfo($forumid);
$bbuserinfo = fetch_userinfo($userid);

// Setup the thread
$post[title] = $title;
$post[message] = $article;
$post[poststarttime] = TIMENOW;
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']);
$post[emailupdate] = 9999;

// build the thread
build_new_post('thread', $foruminfo, array(), 0, $post, $errors);

// Errors?
if (sizeof($errors) > 0) {
  ?>There have been errors. <?=$errors?><?
  print_r($errors);
  die('errors');
}

$ThreadID = $post['threadid'];
$PostID = $post['postid'];

print ("the threadid is $ThreadID and the postid is $PostID");

And I get back these errors:

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /usr/local/www/htdocs/bbs/includes/init.php on line 517

Fatal error: Call to a member function query_first() on a non-object in /usr/local/www/htdocs/bbs/includes/functions.php on line 922

Any help is appreciated, kind of lost here.

Thanks!

Gryphon 11-15-2004 08:13 PM

Might be
PHP Code:

require('./includes/functions_newpost.php'); 


zeropaid 11-15-2004 08:52 PM

yep fixed that and i think it would have complained about not being able to find the file... still not working. Maybe something in the data I am passing to it, hmm

zeropaid 11-15-2004 11:37 PM

tried passing it vanilla test data, to no avail. I am logged into the forum and that got rid of one of the errors, but now all I get is:

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /usr/local/www/htdocs/bbs/includes/init.php on line 517

I checked init.php and it is trying to merge an array it just created and $specialtemplates, which appears to not be defined. This is a dev environment, maybe we are missing some templates?

sabret00the 11-16-2004 01:27 PM

has this been released properly?

zeropaid 11-16-2004 03:40 PM

released properly? I upgraded properly if thats what you mean, to 3.0.3

sabret00the 11-16-2004 05:03 PM

i mean did i get released via the releases forum here at vb.org?


All times are GMT. The time now is 09:33 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01255 seconds
  • Memory Usage 1,754KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete