[REQ] Need this please

Here you go... :)

On one of my boards we have a daily "say anything" thread.
It became a bit tedious managing it, so I decided to automate it.

nothing earth shattering, and I'm sure it's been done before.. but I figure it might help someone out.

Instructions:
  1. download the attached file
  2. edit the settings
  3. upload into the includes/cron directory
  4. log into the Admin CP
  5. Go to Scheduled Tasks / Add New Scheduled Task
  6. fill in the settings and you're all set
file contents:
PHP:
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
    exit;
}
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
require_once(DIR . '/includes/functions_newpost.php');
require_once(DIR . '/includes/functions_wysiwyg.php');
// ########################################################################
// ######################### Edit These ############################
// ########################################################################


$forumid = 20; // the ID of the forum the thread will be posted in
$closedforum = 60; // the ID of the forum the thread will be moved to when closed (if used)
$botuserid = 4772; //userid of poster
$botusername = "ShoutBox"; // username of poster
$title = " SHOUT BOX"; //Title of the thread
$iconid = 15; // id of the icon to be used.
$daystamp = date("l, F jS, Y"); // I used this in the thread title to specify the day

$threadtitle = $title;
// uncomment below if you want the date stamp to precede the title
//$threadtitle = "[".$daystamp."]  ".$title;


$postmessage = "
[CENTER][SIZE=5][color=Red][b]Welcome to the daily Shout Box Thread.[/b][/color][/SIZE]
[/CENTER]


As a reminder, all forum rules still apply.
this thread will auto close @ midnight, and a new one will be auto created.

enjoy and have fun.

:dancenana:
";
// ########################################################################
// ########################################################################


// uncomment below if you'd like to move the previous threads created by botuserid to an archive forum.
//$vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "thread SET forumid = $closedforum, open = 0 WHERE forumid = $forumid and postuserid = $botuserid ");  



##### THIS creates the thread
$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "thread (title, lastpost, forumid, open, replycount, postusername, postuserid, lastposter, dateline, iconid, visible)
VALUES ('" . addslashes($threadtitle) . "', " . TIMENOW . ", $forumid, 1, 0, '$botusername', $botuserid, '$botusername', " . TIMENOW . ", $iconid, 1)");
$threadid = $vbulletin->db->insert_id();
### This creates the post          
$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "post (threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie, showsignature, ipaddress, iconid, visible)
VALUES ($threadid, 0, '" . addslashes($threadtitle) . "', '$botusername', $botuserid, " . TIMENOW . ", '" . addslashes($postmessage) . "', 1, 0, 0, $iconid, 1) ");
$firstpostid = $vbulletin->db->insert_id();
###links the post and thread
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "thread SET firstpostid = $firstpostid WHERE threadid = $threadid");
### updates forum stat            
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "forum
SET replycount = replycount +  1,
threadcount = threadcount + 1,
lastpost = " . TIMENOW . ",
lastposter = '$botusername',
lastthread = '" . addslashes($threadtitle) . "',
lastthreadid = $threadid,
lasticonid = $iconid
WHERE forumid = $forumid
");
 
Back
Top