"; print_r($var); echo ""; } // Make sure no one attempts to run this script "directly" if (!defined('PUN')) exit; // Tell admin_loader.php that this is indeed a plugin and that it is loaded define('PUN_PLUGIN_LOADED', 1); // Display the admin navigation menu generate_admin_menu($plugin); //Here starts my code $the_file = "plugins/topiclists.txt"; $filestring = file_get_contents($the_file); $array_from_file = unserialize($filestring); if($_POST["action"]=="create"){ $array_from_file[] = array( "post_id" => $_POST["post_id_tolist"], "forums_ids" => $_POST["forum_id_tolist"], "description" => $_POST["desc_tolist"], "name" => $_POST["name_tolist"] ); $serialized = serialize($array_from_file); //file_put_contents($the_file,$serialized); $handle = fopen($the_file, 'w'); fwrite($handle, $serialized); fclose($handle); } elseif($_POST["action"]=="update"){ foreach($array_from_file as $a_list){ $forum_id = $a_list["forums_ids"]; $post_id = $a_list["post_id"]; $bbcode_topiclist = $a_list["description"]."\n\n"; if ( strstr($forum_id,",") ){ $query = "select * from ".$db->prefix."topics where ".$db->prefix."forum_id in ( $forum_id ) order by UPPER(subject) asc"; } else{ $query = "select * from ".$db->prefix."topics where ".$db->prefix."forum_id=$forum_id order by UPPER(subject) asc"; } $result = $db->query($query); while($row = $db->fetch_assoc($result)){ $bbcode_topiclist .= "[url=".$pun_config['o_base_url']."/viewtopic.php?id=".$row["id"]."]".$row["subject"]."[/url]\n"; } $bbcode_topiclist = $db->escape($bbcode_topiclist); //$bbcode_topiclist = pun_preparsebbcode($bbcode_topiclist); $query = "UPDATE ".$db->prefix."posts SET message='".$bbcode_topiclist."' where id=$post_id"; $db->query($query); $query_stack[]= $query; $error_stack[]= $db->error(); } } elseif($_POST["action"]=="delete"){ $array_to_put_in_file = array(); foreach( $array_from_file as $key => $value ) { if ( $key!=$_POST["list_to_delete"] ) { $array_to_put_in_file[] = $value; } } $serialized = serialize($array_to_put_in_file); //file_put_contents($the_file,$serialized); $handle = fopen($the_file, 'w'); fwrite($handle, $serialized); fclose($handle); //lets update the variables in order not to interfer with the rest of the code $filestring = file_get_contents($the_file); $array_from_file = unserialize($filestring); } ?>

Topiclists Plugin

Please read this note before using this plugin!

This plugin allows you to mantanin alphabetical clickable lists of topics of one or more forums in the content a message.
Using this plugin uncarefully may result on serious data losses. If you are performing other operations besides updating your lists, you might consider backing up your database before proceding.
The posts in which you store the lists must be created previously. Please check their ids carefully as all their content will be overwritten.
Mixing topic ids with post ids is a comon mistake, make sure you enter the post id and not the topic id.
Depending on the database engine you use it's also recomended to hack the datatype of the message body so the list can fit in it
This plugin doesn't suport list edition, if you need to modify a list you have to create a new one and delete the old one.

Topic Lists

Current Lists
$element){ echo "Name: ".$element["name"]."
"; echo "List id: ".$key."
"; echo "Description: ".$element["description"]."
"; echo "Post id: ".$element["post_id"]."
"; echo "Forum ids: ".$element["forums_ids"]."
"; //echo "delete this list"; echo "
"; } ?>
Define a new list.
Name:
Just a title for personal organization, it won't be displayed anywhere but in the admin panel
Post ID: The post where the list will be placed
Forums ID: Insert coma separateed values
Description
(BBcode allowed)

this text will show on the message body right before the list
Delete a list