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)

version2 02-08-2004 02:44 PM

Quote:

Originally Posted by Wired1
>> $post[postid] is supposed to be $post['postid'] (quotes) correct?
>You can ommit the quotes.

Everywhere, or just within $DB_site->query?



> Hmm, what I was thinking is, a way to do a check on members post count after
> they've done a new post. So the code has to go kinda after their own post sql > query or new post function. Question is, where is the best place to put such a
> code.

oooohhhh I get it now. Hrm... I suppose you'd slap that into the build_new_post function, or right after a call to that function. beats me where the best place would be though.

All right. Here is one for ya. I have my script working great on my test machine. I move it to the production server and boom. Nothing. I get no output. No errors. No posts or threads being created. Nada. Changed the userid and forumid correctly. Everything else is the same.

Anyone got any ideas for me to check out?

Wired1 02-08-2004 06:26 PM

Go back to the last post I made with the full code in it. Does that work on both sites?

version2 02-08-2004 06:39 PM

Quote:

Originally Posted by Wired1
Go back to the last post I made with the full code in it. Does that work on both sites?

Actually, I got it working and I have been doing so many other things...I forgot what I did!

version2 02-08-2004 06:44 PM

Damn. If its not one thing its another. Now, even though I have explicitly names the username and fetched all the bbuserinfo data manually...my script is posting as random members.

Main difference right now is I have vbcron running the script once an hour. Maybe vbcron is the problem.

Wired1 02-09-2004 04:56 AM

I'd copy the code exactly to a test file, run that a couple of times. If it does it correctly each time, then it's probably vbcron.

version2 02-09-2004 06:47 PM

Quote:

Originally Posted by Wired1
I'd copy the code exactly to a test file, run that a couple of times. If it does it correctly each time, then it's probably vbcron.

Using cron has made the user problem disappear. Now my problems are the order in which everything is posted. Here is what I am doing:

Eggdrop bot keeps log of the channel. Every day I am going to pour through that log and post the contents in a specific forum. Now, I didnt want each day to be just one post as that could get quite large, so I am saying every 100 lines post a new post.

Now, the problem is that the posts are not inserted in line! The first post which is the subject post is sometimes located in the middle of the thread created by the script. It should be te first post. Its called before I even start looping through the file and posting the 100 line posts.

I cant figure it out.

Wired1 02-10-2004 04:39 AM

Not sure, perhaps posting some code would help?

Does anyone know of a way of auto-creating a forum, other than a normal mySQL command? Looking for the vB function, if it exists.

version2 02-10-2004 02:03 PM

PHP Code:

$threadinfo['title'] = 'Chatroom Archive Update';
$post['title'] = 'Chatroom Archive Update - ' .  date("F j, Y, g:i a") . ' CST';
$post['message']= 'Chatter from the last hour.';
build_new_post('thread'$foruminfo$threadinfo0$post$errors);
$threadinfo['threadid'] = $post['threadid'];
                                                                                                                                              
$post['title'] = '';
$post['message'] = '';
$lines file('/eggs/mols_pet/logs/mols_pet_talk.log');
$i=0;
for(
$x=0;$x<count($lines);$x++) {
        
$post['message'] .= $lines[$x];
        
$i++;
        if(
$i>=100) {
                
build_new_post('post'$foruminfo$threadinfo0$post$errors);
                
//echo $post['message'];
                
$post['message'] = "";
                
$i=0;
        }
}
if(
$post['message'] != "") {
        
build_new_post('post'$foruminfo$threadinfo0$post$errors);
}
//echo $errors[0];
unset($lines);
$clear fopen('/eggs/mols_pet/logs/mols_pet_talk.log''w');
fwrite($clear'');
fclose($clear); 

This is the test code right now that runs through the file. And for the record, the last 24 hours the script has put the posts in correct order. So this problem is very inconsistent.

And dont make fun of my chicken scratch code! It always look horrible before it is refined! :nervous:

Karri 02-11-2004 04:05 PM

Does any one have a suggestion as to how to use this new method of having an automatic post to a forum to post a welcome message to a new user when the register (preferably after they activate their account)? I was using the hack at https://vborg.vbsupport.ru/showthrea...threadid=35398 for 2.x but haven't been able to modify it for 3.x

Thanks in advance!!!

Wired1 02-11-2004 05:23 PM

You could just set it to a Welcome Forum, and have the script be something like "Welcome ".$username." to this site"

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?

Gryphon 11-16-2004 05:35 PM

Uhhh...no...

zeropaid 11-16-2004 07:26 PM

no, I just copied code from earlier in this thread.. still getting that wierd error even with test data.. still workin on it though.

StefanS 11-25-2004 09:28 AM

Hi,

just tested the following code:

PHP Code:

<?
require('./global.php'); 
require('./includes/functions_newpost.php'); 
$userid = 10;
$forumid = 100;
$foruminfo = fetch_foruminfo($forumid); 
$bbuserinfo = fetch_userinfo($userid); 
$post[title] = 'subject'; 
$post[message] = 'message'; 
$post[poststarttime] = TIMENOW; 
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']); 
build_new_post('thread', $foruminfo, array(), 0, $post, $errors); 
?>

works for me with 3.03 without problems ...

sabret00the 11-25-2004 09:43 AM

Quote:

Originally Posted by StefanS
Hi,

just tested the following code:

PHP Code:

<?
require('./global.php'); 
require('./includes/functions_newpost.php'); 
$userid = 10;
$forumid = 100;
$foruminfo = fetch_foruminfo($forumid); 
$bbuserinfo = fetch_userinfo($userid); 
$post[title] = 'subject'; 
$post[message] = 'message'; 
$post[poststarttime] = TIMENOW; 
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']); 
build_new_post('thread', $foruminfo, array(), 0, $post, $errors); 
?>

works for me with 3.03 without problems ...

is there a form to add the threads you want and create the conditions under which their added?

Wired1 11-30-2004 12:14 AM

Sorry for the delay guys, never did release this as an official hack due to the lack of interest, seemed everyone except for me knew how to do this at the time. Man trying this stuff in the early RCs was a pain! Just switched to a newer license that won't expire, so I'll get all of the updates on the thread from now on :)

I'll have to re-read through the thread later (in class atm), but it sounds like at least sabret00the would like a variable system to set up to do this?

I'll have to dig up the custom forms/code I made that used this function. Worked well, but the project went to ASP so I haven't looked at it in a while. Would've stayed in PHP if I knew how to radically customize the board templates.

Would you guys want me to work this up and release it as an "official" hack?

Undertoad 12-01-2004 05:22 PM

That would be great.

Wired1 12-02-2004 05:41 AM

Ok, just re-read everything and looked at my code. Looks like I made the code at the end of page 2 into a function, as well as a function that auto-creates forums.

To release this as a hack, I'd like to put some safety features in it, e.g. some way of making a simple admin CP module for it (NO CLUE), and a way to enter it into group policies so that to have access to it you have to be in a special group. Perhaps it would show up in the User CP if said user is in this secondary group?

So far, these are the requests for it that I have seen:
Quote:

if posts on the forums in XX hours < XX then create thread
Don't quite understand that. Do you mean "If user X posts every y amount of hours then create a thread?

Quote:

A form to add the threads you want and create the conditions under which they are added
What types of conditions would you like, or would you like them to be user editable conditions?

Comments please! :) I'm about to fall asleep, so tomorrow afternoon (EST) I'll post the code as a beta hack.

sabret00the 12-02-2004 09:49 AM

regarding the last bit, basically you'd have a form with

Code:

THREAD TITLE
 
  FORUM ID THREAD TO BE CREATED FOR
 
  THREAD BODY TEXT
 
  CONDITIONS TO CREATE THREAD; __ POST < __ hours
 
  USERID OF THREAD CREATOR

wouldn't that form in the admincp by the safety measure btw?

Quote:

Don't quite understand that. Do you mean "If user X posts every y amount of hours then create a thread?
what that means is that if theirs less than 100 posts on the forums in the past 5 hours then create a new thread in order to stimulate activity.

Wired1 12-02-2004 02:25 PM

Quote:

Originally Posted by sabret00the
wouldn't that form in the admincp by the safety measure btw?

what that means is that if theirs less than 100 posts on the forums in the past 5 hours then create a new thread in order to stimulate activity.

Gotcha. Think I can release just the functions as a beta hack, then later work on the form code? I'd really only want to release it formally if I could make an admin module though.

sabret00the 12-02-2004 03:26 PM

what do you mean by admin module?

Wired1 12-02-2004 09:20 PM

One of the side menus in the admin section, a dropdown accessible only within that area.

sabret00the 12-02-2004 09:26 PM

Quote:

Originally Posted by Wired1
One of the side menus in the admin section, a dropdown accessible only within that area.

oh that i thought for the form it would've been admincp based anyway, it's not too hard to add a new page, the hardest bit comes when trying to add something to an existing page.

lowspeed 01-14-2005 06:00 PM

I used this code, IT actually adds the thread but i get the following warning

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in \global.php on line 329

Warning: Invalid argument supplied for foreach() in \includes\functions.php on line 2177


Also if the subject in the forum ID is send again then it just exits it doesn't flow through the code.



Help :)

Thanks,
LOW LOW.


Quote:

Originally Posted by StefanS
Hi,

just tested the following code:

PHP Code:

<?
require('./global.php'); 
require('./includes/functions_newpost.php'); 
$userid = 10;
$forumid = 100;
$foruminfo = fetch_foruminfo($forumid); 
$bbuserinfo = fetch_userinfo($userid); 
$post[title] = 'subject'; 
$post[message] = 'message'; 
$post[poststarttime] = TIMENOW; 
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']); 
build_new_post('thread', $foruminfo, array(), 0, $post, $errors); 
?>

works for me with 3.03 without problems ...


Xenon 01-14-2005 11:51 PM

that's a problem with php5

before the require global.php add these lines:

PHP Code:

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array(); 


lowspeed 01-15-2005 01:10 AM

Thanks for the quick help !

I have a small follow up. I know how to get the threadid, but how would i post a reply to that ID ?

Do i put instead of the 0, you put the threadid (lets say 3212) ? example:

build_new_post('thread', $foruminfo, array(), 3212, $post, $errors);

lowspeed 01-16-2005 09:27 PM

I tried doing something like this ...

build_new_post('reply', $foruminfo, array(), 3212, $post, $errors);

where 3212 is the thread i'm replying to, but it didn't work :(

lowspeed 01-17-2005 05:20 PM

Ok i found how to do it

You need these added:

$threadid=1091; // the thread you want to reply to
$threadinfo = fetch_threadinfo($threadid);

build_new_post('reply', $foruminfo, $threadinfo, $_POST['postid'], $post, $errors);

lowspeed 01-17-2005 07:38 PM

Hi Guys,

It works fine when called independently from the rest of my code.

I have a feeling that because my php site uses a database as well it gets confused to which database its refering to.

How can i make sure that when i run the post thread section it looks at the VB db and after it reverts back to my db. ??

Andreas 01-17-2005 08:58 PM

Use a different dbuser/pass for your application

lowspeed 01-17-2005 11:00 PM

doesnt work :(

I decided to use URL stream instead.


All times are GMT. The time now is 04:17 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.01638 seconds
  • Memory Usage 1,879KB
  • 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
  • (1)bbcode_code_printable
  • (8)bbcode_php_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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