News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1273100106:v:use_geshi-1:v:type-php

Started by SleePy, May 05, 2010, 10:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SleePy

<?php
// SETTINGS
   // Simple Desk Tables.
   $sd_tables = array('tickets', 'ticket_replies', 'log_action', 'log_read', 'attachments');

   // SMF Tables we need to clean up after.
   $smf_tables = array('log_mark_read', 'log_notify', 'log_actions', 'log_activity', );

   // My settings brings all the coders to the yard...
   $reset_settings = array(
      'shd_staff_badge' => 'nobadge',
      'shd_display_avatar' => 0,
      'shd_disable_action_log' => 0,
      'shd_ticketnav_style' => 'sd',
      'shd_allow_ticket_bbc' => 1,
      'shd_allow_ticket_smileys' => 1,
      'shd_enabled_bbc' => 1,
      'shd_helpdesk_only' => 0,
      'shd_attachments_mode' => 'ticket',
      'shd_disable_pm' => 0,
      'shd_disable_mlist' => 0,
      'shd_bbc' => implode(',', $bbc_tags),
      'shd_staff_ticket_self' => 1,
      'shd_privacy_display' => 'smart',
      'settings_updated' => time(),
   );

   // The default topic title.
   $topic = 'Welcome to the SimpleDesk Demo';

   // The default topic body.
   $message = 'Welcome to the SimpleDesk Demo.

We have provided this demo forum as a means to allow you to demo our software.



SimpleDesk Administrator login: Admin / admin

SimpleDesk Staff user login: Staff / staff

SimpleDesk Regular user login: User / user
';

// Join us, SMF.
require_once('SSI.php');

// Clean the tables.
foreach ($sd_tables as $table)
   $smcFunc['db_query']('', 'TRUNCATE {db_prefix}helpdesk_{raw:table}', array('table' => $table));

// Collect bbc.
$bbc_tags = array();
foreach (parse_bbc(false) AS $tag)
   $bbc_tags[] = $tag['tag'];

// Update the Settings table.
updateSettings($reset_settings);

// Clean the SMF topics and messages, leaving only default.  This is done because posts are allowed for move to topic/ticket feature
$smcFunc['db_query']('', 'DELETE FROM {db_prefix}topics WHERE id_topic > 1', array());
$smcFunc['db_query']('', 'DELETE FROM {db_prefix}messages WHERE id_msg > 1', array());

// Reset the auto-increment count.
$smcFunc['db_query']('', 'ALTER TABLE {db_prefix}topics AUTO_INCREMENT = 1', array());
$smcFunc['db_query']('', 'ALTER TABLE {db_prefix}messages AUTO_INCREMENT = 1', array());

// Clean any SMF logs such as read log pretaining to topics and messages caused by SD actions.
foreach ($smf_tables as $table)
   $smcFunc['db_query']('', 'TRUNCATE {db_prefix}{raw:table}', array('table' => $table));

// Do the actual change to message table.
$smcFunc['db_query']('', '
   UPDATE {db_prefix}messages
      SET
         subject = {string:topic},
         body = {string:message},
         id_msg_modified = 1,
         poster_name = {string:name},
         poster_email = {string:email},
         poster_ip = {string:ip},
         smileys_enabled = 1,
         modified_time = 0,
         modified_name = {string:empty},
         icon = {string:xx},
         approved = 1,
         id_member = 0,
         poster_time = {int:time}
   WHERE id_msg = 1',
      array(
         'topic' => $topic,
         'message' => $message,
         'name' => 'SimpleDesk Team',
         'email' => 'void@simpledesk.net',
         'ip' => '127.0.0.1',
         'empty' => '',
         'xx' => 'xx',
         'time' => (int) strtotime('Janurary 1st, 2010'),
      )
   );

// Now topics table.
$smcFunc['db_query']('', '
   UPDATE {db_prefix}topics
      SET
         is_sticky = 0,
         id_first_msg = 1,
         id_last_msg = 1,
         id_member_started = 0,
         id_member_updated = 0,
         id_poll = 0,
         id_previous_board = 0,
         id_previous_topic = 0,
         num_replies = 0,
         num_views = 0,
         locked = 0,
         unapproved_posts = 0,
         approved = 1
   WHERE id_topic = 1', array());

// TODO: Fail checks, email webmaster@simpledesk.net on errors and return false for error handler to show a message (Need to setup that email address first [HA!])

// For now this just redirects.
redirectexit();

return true; exit;
?>
No siggy! :D