A Digital Age Deserves A Digital Leader

setting ADMIN commands in functions_post.php

setting ADMIN commands in functions_post.php

Postby c0ldfyr3 » Fri Sep 22, 2006 12:53 am

so i have added this code to my includes/Functions_post.php file to unlock a topic by just typing "-UNLOCK-" ( with out quotes ).
Code: Select all

   if($userdata['user_level'] == ADMIN)
      {
      if(strstr($post_message, "-UNLOCK-"))
         {
            $sql = "UPDATE " . TOPICS_TABLE . "
               SET topic_status = " . TOPIC_UNLOCKED . "
               WHERE topic_id = $topic_id
                  AND forum_id = $forum_id";
            if ( !($result = $db->sql_query($sql)) )
            {
               message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
            }
         };
      };

and i hiave added this code to lock the topic by typing "-LOCK-" ( again, with out the quotes ).
Code: Select all
   
   if($userdata['user_level'] == ADMIN)
      {
      if(strstr($post_message, "-LOCK-"))
         {
            $sql = "UPDATE " . TOPICS_TABLE . "
               SET topic_status = " . TOPIC_LOCKED . "
               WHERE topic_id = $topic_id
                  AND forum_id = $forum_id";
            if ( !($result = $db->sql_query($sql)) )
            {
               message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
            }
         };
      };
   

now the SET topic_status = " . TOPIC_LOCKED . " or SET topic_status = " . TOPIC_UNLOCKED . " sets the topic locked or unlocked respectivly, what i am having trouble figuring out is how to DELETE the topic via the same method.

is there any one who may know how to do this?
Image
PRO Level 15
User avatar
Posts: 1346
Joined: Sun May 02, 2004 8:49 pm
Location: 127.0.0.1

Postby jbullard » Fri Sep 22, 2006 1:16 am

Are you talking about just deleting if the topic is locked or unlocked?

Code: Select all
$sql = "DELETE FROM " . TOPICS_TABLE . "
               WHERE topic_id = $topic_id
                  AND forum_id = $forum_id
                    AND topic_status = ". TOPIC_UNLOCKED .";"


Or if you only want to delete topics that are locked or unlocked do

Code: Select all
$sql = "DELETE FROM " . TOPICS_TABLE . "
               WHERE topic_status = ". TOPIC_UNLOCKED .";"


HTH,
Jason
VP - Software
User avatar
Posts: 3653
Joined: Sun Jun 06, 2004 10:17 pm
Location: Utah
Real Name: Jason Bullard

Postby c0ldfyr3 » Fri Sep 22, 2006 1:23 am

no, no, no...

i want to be able to type -DELETE- and have the topic deleted, no matter what the status is, locked or unlocked.
Image
PRO Level 15
User avatar
Posts: 1346
Joined: Sun May 02, 2004 8:49 pm
Location: 127.0.0.1

Postby c0ldfyr3 » Sat Sep 23, 2006 1:18 pm

okay so i gave it a try using your code but i get an unexpected } on line xxx error.
if i take the } out then i get an T_STRING error.
Image
PRO Level 15
User avatar
Posts: 1346
Joined: Sun May 02, 2004 8:49 pm
Location: 127.0.0.1

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 6 guests

cron
cron