Help - Search - Members - Calendar
Full Version: Taskmanager gives error with custom made phpscript
Invision Power Services > Community Forums > Community Web Design and Coding
Ice_Blade
I wrote a script which posts news copied from a certain site into new topics in a certain forum on my board.
The script works nicely, and is working accurately.
I want the script to run once every 30 minutes, so I added it to the task manager, but when I ran it it gave this error:
CODE
Fatal error: Cannot instantiate non-existent class: task_item in /homepages/14/d87274267/htdocs/techforum/sources/admin/ad_task_manager.php on line 357


My board:
PHP VERSION: 4.3.10 (cgi),
SQL: (MYSQL) 4.0.23-standard-log
IPB Version v2.0.3

The script is stand alone, and doesn't require user input or anything.
It works when I open the url myself: /techforums/dailynews.php
But when opened through the taskmanager (I want it run about every half hour) It gives that error.

Is there a certain template the task files have to use? or some kind of data they have to reply to the task manager on completion?

--------------------------------------
I also have a different question, Is there a way to get the board to do the:
QUOTE
Resynchronize Forums
Resynchronize Forums
This will recount topics, posts and the forum last poster for all your forums
AND
Resynchronize Topics
Resynchronize Topics
This will recount replies, attachment count and the topic starter and last poster for all your topics.
script?
somehow call that from one of my other php scripts?
My newsscript updates perfectly, only it doesn't update the most recent topic on the homepage, I have to wait until those processes have been run.
Currently my script edits the _topics, _posts, _members, and _forum tables, but for some reason the most recent post isn't being updated immediatly. (Doesn't really matter, but I was wondering what I was forgetting).

The _newsbot table is a table which 'remembers' which news the script has already posted and which it hasn't.
Some of the strings are in Dutch, but should still be pretty explanatory.
My querys:
CODE
$user = mysql_query("UPDATE `TF_members` SET `ip_address` = '".$botIP."' , `posts` = `posts` +1 , `last_post` = '".$timestamp."' , `last_visit` = '".$timestamp."' , `last_activity` = '".$timestamp."' WHERE `id` = '".$newsbotnr."' LIMIT 1;") or die(mysql_error());


$posts = mysql_query("INSERT INTO `TF_posts`  ( `pid` , `append_edit` , `edit_time` , `author_id` , `author_name` , `use_sig` , `use_emo` , `ip_address` , `post_date` , `icon_id` ,  `post` , `queued` , `topic_id` , `post_title` , `new_topic` , `edit_name` , `post_key` , `post_parent` , `post_htmlstate` ) VALUES ( '".$postid."', '0', '".$timestamp."' , '".$newsbotnr."', '".$newsbotname."', '1', '1', '".$botIP."', '".$timestamp."' , '".$topiciconid."', '".$postdata."', '0', '".$topicid."', NULL , '1', NULL , '0', '0', '1');") or die(mysql_error());


$topics = mysql_query("INSERT INTO `TF_topics`  ( `tid` , `title` , `description` , `state` , `posts` , `starter_id` , `start_date` , `last_poster_id` , `last_post` , `icon_id` , `starter_name` , `last_poster_name` , `poll_state` , `last_vote` , `views` , `forum_id` , `approved` , `author_mode` , `pinned` , `moved_to` , `rating` , `total_votes` , `topic_hasattach` , `topic_firstpost` , `topic_queuedposts` ) VALUES ( '".$topicid."', '".$title."', NULL , 'open', '0', '".$newsbotnr."', '".$timestamp."' , '".$newsbotnr."', '".$timestamp."' , '13', '".$newsbotname."', '".$newsbotname."', '0', '0', '0', '".$newsforumnr."', '1', '1', '0', NULL , NULL , '0', '0', '".$postid."', '0');") or die(mysql_error());


$forum = mysql_query("UPDATE `TF_forums` SET  `topics` = `topics` + 1, `last_post` = '".$timestamp."' , `last_poster_id` = '".$newsbotnr."', `last_poster_name` = '".$newsbotname."', `last_title` = '".$title."', `last_id` = '".$topicid."' WHERE `id` = '".$newsforumnr."' LIMIT 1;") or die(mysql_error());


$list = mysql_query("INSERT INTO `TF_newsbot` ( `id` , `artikel_nr` , `unixdate` , `bron` ) VALUES ('','".$artikelnummer."' , '".$timestamp."' , '".$sitebron."' );") or die(mysql_error());


I was considering using crontab, but my server doesn't support it sad.gif

Could anyone please help? biggrin.gif
Thanks!!!
Chris Griego
Just take a look at one of the other task files and you will see the needed format.
Chad
You are trying to utilize Task Manager functions without including the file.
Its pretty much trying to initiate something that does not exist. Which the error states.

What is the code that tries to initiate the Class of task manager in your script?

Just before you initiate the Task Manager, include the source files of the Task Manager.

For your second question, IPB does not search for the latest info from each Table in the database.
Well, technically, it does. But it stores this information in a different table.

Each time your "Bot" adds new data, update this table with the latest information.
The table is called: "ibf_stats"

Search through it and you'll find the type of data you need it to update.

Chad
Ice_Blade
I have 2.0.3 so i'm guessing you mean the forum_cache row in the ibf_cache_store table... --> just looking at that makes my eyes hurt tongue.gif but I do see how its organised...

I'll look into the other files, see If i understand what's happening.

1 more question, what are the chances that someone posts something while my bot is posting something else, and the 2 posts 'clash' ?

ie: user posts data to _topics table first, and then to the posts table,
and the bot does it using the same id's in the opposite order?
or is the board fast enough to compensate that? (seeing as how hundreds of users can post simultaneously on the forum)

The querys are right after each other, with no script inbetween (see post above), so I'm guessing/thinking (and hoping) it won't be a problem.
There's a sleep() in my script to allow it to gather all the data before processing and posting it.
Chad
Ahh, Yes, I had forgotten about the Cache table.

The ibf_stats table is still there. But is also stored in the cache table.
Reduces the amount of queries to make.

So you will need to update both. You'll want to update the ibf_stats first, then update the cache.

However, you can theoretically, let IPB update the cache as it sees fit. But this could cause an issue with Synchronization of the data between the two tables.

So I wouldn't recommend the second approach.

About your second question...
There is no worry about this. The server, as with every computer, has a queve system to Tasks it needs to perform. It will do only one task at a time and there should be no worries about ID "clashing."

The Table structure for Posts and Topics have IDs that are Primary, so Duplicate IDs are literally not possible. If this happens, it will show a SQL error about having Duplicate IDs.
Unfortuantly, there is not way to recover lost data from this.

Although I haven't experienced this myself, I do not think it will be an issue.
I am not 100% positive on that, however.

Chad
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.