News:

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

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - SleePy

#46
The-SleePy-Laptop:Site jeremy$ svn cleanup
svn: In directory 'public_html/Forums/Themes/default/images'
svn: Error processing command 'modify-wcprop' in 'public_html/Forums/Themes/default/images'
svn: 'public_html/Forums/Themes/default/images/useron.gif' is not under version control
The-SleePy-Laptop:Site jeremy$ svn unlock --force ./
svn: Working copy '/home/svn/Site/trunk' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
#47
// Get our proper database setup.
/*
$sitedb_settings['site'] = array(
   'read' => array(
      'server' => '127.0.0.2',
      'name' => 'site',
      'user' => 'site_read',
      'passwd' => 'foobar',
      'prefix' => '',
   ),
   'write' => array(
      'server' => '127.0.0.1',
      'name' => 'site',
      'user' => 'site_write',
      'passwd' => 'barfoo',
      'prefix' => '',
   ),
);

Called by:
Readonly: site_load_db('site');
Write: site_load_db('site', true);
Both: site_load_db('site', 2); or site_load_db('site', 'both');

Special connection: site_load_db('site', false, $db_connection);
*/
function site_load_db($section, $write = false, &$connection = null)
{
   global $sitedb_settings, $site_connections, $smcFunc, $site_section;

   // No section, how lame is that.
   if (empty($section) && empty($site_section))
      trigger_error('site_query() no section set', E_ERROR);
   $section = empty($section) ? $site_section : $section;

   // Doing both?
   if ($write == 'both')
   {
      site_load_db($section, 'read');
      $write = 'read';
   }

   // Try to include our database information if we haven't already
   if (!empty($section) && !isset($site_connections[$section][$write ? 'write' : 'read']))
      require('/home/sites/xxxx.com/configs/settings_' . $section . '.php');

   // Make the connection!
   $type = $write ? 'write' : 'read';
   if (!isset($site_connections[$section][$type]))
   {
      // No read or write data? Its old skool and needs updating.
      if (!sset($sitedb_settings[$section][$type]))
         $sitedb_settings[$section][$type] = $sitedb_settings[$section];

      // The actual connection.
      $site_connections[$section][$type] = smf_db_initiate($sitedb_settings[$section][$type]['server'], $sitedb_settings[$section][$type]['name'], $sitedb_settings[$section][$type]['user'], $sitedb_settings[$section][$type]['passwd'], $sitedb_settings[$section][$type]['prefix']);

      // Using a special connection?
      if ($connection != null)
         $connection = &$site_connections[$section][$type];
   }
}
#48
// Get our proper database setup.
/*
$sitedb_settings['site'] = array(
   'read' => array(
      'server' => '127.0.0.2',
      'name' => 'site',
      'user' => 'site_read',
      'passwd' => 'foobar',
      'prefix' => '',
   ),
   'write' => array(
      'server' => '127.0.0.1',
      'name' => 'site',
      'user' => 'site_write',
      'passwd' => 'barfoo',
      'prefix' => '',
   ),
);

Called by:
Readonly: site_load_db('site');
Write: site_load_db('site', true);
Both: site_load_db('site', 2); or site_load_db('site', 'both');

Special connection: site_load_db('site', false, $db_connection);
*/
function site_load_db($section, $write = false, &$connection = null)
{
   global $sitedb_settings, $site_connections, $smcFunc, $site_section;

   // No section, how lame is that.
   if (empty($section) && empty($site_section))
      trigger_error('site_query() no section set', E_ERROR);
   $section = empty($section) ? $site_section : $section;

   // Doing both?
   if ($write == 'both')
   {
      site_load_db($section, 'read');
      $write = 'read';
   }

   // Try to include our database information if we haven't already
   if (!empty($section) && !isset($site_connections[$section][$write ? 'write' : 'read']))
      require('/home/sites/xxxx.com/security/settings_' . $section . '.php');

   // Make the connection!
   $type = $write ? 'write' : 'read';
   if (!isset($site_connections[$section][$type]))
   {
      // No read or write data? Its old skool and needs updating.
      if (!sset($sitedb_settings[$section][$type]))
         $sitedb_settings[$section][$type] = $sitedb_settings[$section];

      // The actual connection.
      $site_connections[$section][$type] = smf_db_initiate($sitedb_settings[$section][$type]['server'], $sitedb_settings[$section][$type]['name'], $sitedb_settings[$section][$type]['user'], $sitedb_settings[$section][$type]['passwd'], $sitedb_settings[$section][$type]['prefix']);

      // Using a special connection?
      if ($connection != null)
         $connection = &$site_connections[$section][$type];
   }
}
#49
v
#50
[*****@**** ~]$ ping simplemachines.org
PING simplemachines.org (10.0.100.134) 56(84) bytes of data.
64 bytes from 10.0.100.134: icmp_seq=1 ttl=64 time=0.894 ms
64 bytes from 10.0.100.134: icmp_seq=2 ttl=64 time=0.215 ms
64 bytes from 10.0.100.134: icmp_seq=3 ttl=64 time=0.282 ms

--- simplemachines.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.215/0.798/1.899/0.779 ms
#51
<?php

$tests = array(
   "123456",
   "123456\n",
);

foreach($tests AS $test)
{
   $good = preg_match('~^[0-9]+$~', $test);

   echo '"', $test, '" ', $good ? 'is' : 'is not', ' good
';
}

?>
#52
<?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;
?>
#53
   // Defaults.
   require_once($sourcedir . '/Subs-SimpleDesk.php');
   $context['helpdeskTickets'] = array(
      'open' => shd_count_helpdesk_tickets('open', true),
      'waiting' => shd_count_helpdesk_tickets('staff', false),
   );
#54
   // Tickets awaiting response.
   $request = shd_db_query('
      SELECT COUNT(id_ticket)
      FROM {db_prefix}helpdesk_tickets AS hdt
      WHERE {query_see_ticket} AND status IN (0,1)', array());
   if ($smcFunc['db_num_rows']($request) > 0)
      list($context['helpdeskTickets']['waiting']) = $smcFunc['db_fetch_row']($request);
   $smcFunc['db_free_result']($request);
#55
The-SleePy-Laptop:simpledesk jeremy$ diff -u /home/svn/simpledesk/trunk/scripts/helpdesk.js /home/smf/public_html/helpdesk/Themes/default/scripts/helpdesk.js
--- /home/svn/simpledesk/trunk/scripts/helpdesk.js   2010-02-28 08:27:39.000000000 -0800
+++ /home/smf/public_html/helpdesk/Themes/default/scripts/helpdesk.js   2010-03-21 13:57:44.000000000 -0700
@@ -206,4 +206,11 @@
    document.getElementById(this.opt.sHeaderId).setAttribute('class', (this.bCollapsed ? 'titlebg grid_header' : 'titlebg'));
 
    this.bCollapsed = !this.bCollapsed;
+}
+
+// The quick jump function
+function shd_quickTicketJump(id_ticket)
+{
+   window.location.href = smf_prepareScriptUrl(smf_scripturl) + '?action=helpdesk;sa=ticket;ticket=' + id_ticket;
+   return false;
 }
\ No newline at end of file
The-SleePy-Laptop:simpledesk jeremy$ diff -u /home/svn/simpledesk/trunk/template/SimpleDesk.template.php /home/smf/public_html/helpdesk/Themes/default/SimpleDesk.template.php
--- /home/svn/simpledesk/trunk/template/SimpleDesk.template.php   2010-03-20 13:28:57.000000000 -0700
+++ /home/smf/public_html/helpdesk/Themes/default/SimpleDesk.template.php   2010-03-21 13:57:41.000000000 -0700
@@ -37,11 +37,12 @@
                <span class="upperframe"><span></span></span>
                <div class="roundframe">
                   <div class="shd_gototicket smalltext">
-                     <form action="', $scripturl, '?action=helpdesk" method="post">
+                     <form action="', $scripturl, '?action=helpdesk;sa=ticket" method="get">
                         ', $txt['shd_go_to_ticket'], ':
-                        <input type="text" name="ticket" size="4" />
-                        <input type="submit" value="', $txt['shd_go'], '" />
+                        <input type="hidden" name="action" value="helpdesk" />
                         <input type="hidden" name="sa" value="ticket" />
+                        <input type="text" id="ticketJump" name="ticket" size="4" />
+                        <input type="submit" value="', $txt['shd_go'], '" onclick="shd_quickTicketJump(this.parentNode.ticketJump.value);" />
                      </form>
                   </div>
                   <div id="welcome">
#56
// SleePy is lazy, so I will just check to see if db_query exists
if(!function_exists('db_query'))
{
   db_extend('Packages');
   function db_query($query, $file, $line)
   {
      global $smcFunc;
      return $smcFunc['db_query']('', $query, array('db_error_skip' => true));
   }
}
// All work here is for back support for SMF 1.1, It is easier to support 2.0 and backport.
else
{
   $smcFunc = $func;
   $smcFunc['db_num_rows'] = 'mysql_num_rows';
   $smcFunc['db_free_result'] = 'mysql_free_result';
   $smcFunc['db_fetch_assoc'] = 'mysql_fetch_assoc';
   $smcFunc['db_list_columns'] = 'mysql_show_columns';
   $smcFunc['db_add_column'] = 'mysql_create_columns';

   // Quickly emulate these functions.
   function mysql_show_columns($table_name)
   {
      global $smcFunc, $db_prefix;

      $result = db_query("SHOW FIELDS FROM {$table_name}", __FILE__, __LINE__);;
      $columns = array();
      while ($row = $smcFunc['db_fetch_assoc']($result))
         $columns[] = $row['Field'];
      return $columns;
   }
   function mysql_create_columns($table_name, $column_info)
   {
      global $db_prefix;

      return db_query('ALTER TABLE ' . $table_name . '
         ADD ' . $column_info['name'] . ' ' . $column_info['type'] . ' ' . (empty($column_info['null']) ? 'NOT NULL' : '') . ' ' .
      (empty($column_info['default']) ? '' : 'default \'' . $column_info['default'] . '\'') . ' ' .
      (empty($column_info['auto']) ? '' : 'auto_increment') . ' ', __FILE__, __LINE__);
   }
}
#57
$dir = '/home/svn/simpledesk/trunk/language-php/';
$files = scandir($dir);
$data = array();
foreach ($files as $temp)
{
   $txt = array(); $helptxt = array();
   include($dir . '/' . $temp);

   foreach ($txt as $key => $value)
      $data[$temp][$key] = $value;
}
#58
   function getLegacyAttachmentFilename($filename, $attachment_id)
   {
      // Remove special accented characters - ie. sÃŒ (because they won't write to the filesystem well.)
      $clean_name = strtr($filename, 'äéöûü¿¡¬√Æ'≈«»… ÀÃÕÅ'Å"â€"“”‘’÷ÿŸâ,,â,¬â€¹â€ºâ€¡Â·â€šâ€žâ€°Ã,ÁËÈÍÎÏÌÃ"Ã"Ã'ÚÛÙıˆ¯˘˙˚¸˝ˇ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
      $clean_name = strtr($clean_name, array('fi' => 'TH', 'Ë›' => 'th', 'â€"' => 'DH', '' => 'dh', 'ï¬,' => 'ss', 'Ã¥' => 'OE', 'ú' => 'oe', '∆' => 'AE', 'Ê' => 'ae', 'µ' => 'u'));

      // Get rid of dots, spaces, and other weird characters.
      $clean_name = preg_replace(array('/\s/', '/[^\w_\.\-]/'), array('_', ''), $clean_name);

      return $attachment_id . '_' . strtr($clean_name, '.', '_') . md5($clean_name);
   }

   function getLegacyAttachmentFilenameNew($filename, $attachment_id)
   {
      // Remove special accented characters - ie. sÃŒ (because they won't write to the filesystem well.)
      $clean_name = strtr($filename, array(chr(138) => 'S', chr(142) => 'Z', chr(154) => 's', chr(158) => 'z', chr(159) => 'Y', chr(192) => 'A', chr(193) => 'A', chr(194) => 'A', chr(195) => 'A', chr(196) => 'A', chr(197) => 'A', chr(199) => 'C', chr(200) => 'E', chr(201) => 'E', chr(202) => 'E', chr(203) => 'E', chr(204) => 'I', chr(205) => 'I', chr(206) => 'I', chr(207) => 'I', chr(209) => 'N', chr(210) => 'O', chr(211) => 'O', chr(212) => 'O', chr(213) => 'O', chr(214) => 'O', chr(216) => 'O', chr(217) => 'U', chr(218) => 'U', chr(219) => 'U', chr(220) => 'U', chr(221) => 'Y', chr(224) => 'a', chr(225) => 'a', chr(226) => 'a', chr(227) => 'a', chr(228) => 'a', chr(229) => 'a', chr(231) => 'c', chr(232) => 'e', chr(233) => 'e', chr(234) => 'e', chr(235) => 'e', chr(236) => 'i', chr(237) => 'i', chr(238) => 'i', chr(239) => 'i', chr(241) => 'n', chr(242) => 'o', chr(243) => 'o', chr(244) => 'o', chr(245) => 'o', chr(246) => 'o', chr(248) => 'o', chr(249) => 'u', chr(250) => 'u', chr(251) => 'u', chr(252) => 'u', chr(253) => 'y', chr(255) => 'y'));
      $clean_name = strtr($clean_name, array(chr(222) => 'TH', chr(254) => 'th', chr(208) => 'DH', chr(240) => 'dh', chr(223) => 'ss', chr(140) => 'OE', chr(156) => 'oe', chr(198) => 'AE', chr(230) => 'ae', chr(181) => 'u'));

      // Get rid of dots, spaces, and other weird characters.
      $clean_name = preg_replace(array('/\s/', '/[^\w_\.\-]/'), array('_', ''), $clean_name);

      return $attachment_id . '_' . strtr($clean_name, '.', '_') . md5($clean_name);
   }
#59
   function getLegacyAttachmentFilenameNew($filename, $attachment_id)
   {
      // Remove special accented characters - ie. sÃŒ (because they won't write to the filesystem well.)
      $clean_name = strtr($filename, array(chr(138) => 'S', chr(142) => 'Z', chr(154) => 's', chr(158) => 'z', chr(159) => 'Y', chr(192) => 'A', chr(193) => 'A', chr(194) => 'A', chr(195) => 'A', chr(196) => 'A', chr(197) => 'A', chr(199) => 'C', chr(200) => 'E', chr(201) => 'E', chr(202) => 'E', chr(203) => 'E', chr(204) => 'I', chr(205) => 'I', chr(206) => 'I', chr(207) => 'I', chr(209) => 'N', chr(210) => 'O', chr(211) => 'O', chr(212) => 'O', chr(213) => 'O', chr(214) => 'O', chr(216) => 'O', chr(217) => 'U', chr(218) => 'U', chr(219) => 'U', chr(220) => 'U', chr(221) => 'Y', chr(224) => 'a', chr(225) => 'a', chr(226) => 'a', chr(227) => 'a', chr(228) => 'a', chr(229) => 'a', chr(231) => 'c', chr(232) => 'e', chr(233) => 'e', chr(234) => 'e', chr(235) => 'e', chr(236) => 'i', chr(237) => 'i', chr(238) => 'i', chr(239) => 'i', chr(241) => 'n', chr(242) => 'o', chr(243) => 'o', chr(244) => 'o', chr(245) => 'o', chr(246) => 'o', chr(248) => 'o', chr(249) => 'u', chr(250) => 'u', chr(251) => 'u', chr(252) => 'u', chr(253) => 'y', chr(255) => 'y'));
      $clean_name = strtr($clean_name, array(chr(222) => 'TH', chr(254) => 'th', chr(208) => 'DH', chr(240) => 'dh', chr(223) => 'ss', chr(140) => 'OE', chr(156) => 'oe', chr(198) => 'AE', chr(230) => 'ae', chr(181) => 'u'));

      // Get rid of dots, spaces, and other weird characters.
      $clean_name = preg_replace(array('/\s/', '/[^\w_\.\-]/'), array('_', ''), $clean_name);

      return $attachment_id . '_' . strtr($clean_name, '.', '_') . md5($clean_name);
   }
#60
// Close bugs.
function svnProjectTools($data, $id_member)
{
   global $smcFunc, $sourcedir, $context, $user_profile, $issue, $project;

   $project = 2;

   if (empty($data->log))
      return;

   // First, explode all entires by new line.
   $entries = explode("\n", $data->log);
   $bugs = array();
   foreach ($entries as $entry)
   {
      // Pull out the bug/feature index.
      preg_match('~\[[Bug|Feature]+\s+([\d,]+)\]~i', $entry, $matches);

      // Nothing to log?
      if (empty($matches[1]))
         continue;

      // Only list them once.
      $temp = array_unique(array_map('intval', explode(',', $matches[1])));;

      // Dump this into an array whos key is the bug id.
      foreach ($temp as $id)
         $bugs[$id][] = str_replace($matches[0], 'Revision: ' . $data->revision, $entry);
   }

   // Mash that multi-dimensional array to a single array.
   foreach ($bugs as $id => $bug)
      $bugs[$id] = implode("\n", array_unique($bug));

   // Still nothing?
   if (empty($bugs))
      return;

   // Some junk we need.
   require_once($sourcedir . '/Subs-Post.php');
   require_once($sourcedir . '/Subs-Issue.php');
   require_once($sourcedir . '/Subs-Project.php');
   require_once($sourcedir . '/IssueReport.php');
   require_once($sourcedir . '/IssueComment.php');

   // Call a few friends.
   loadMemberData($id_member);
   loadProjectTools();

   // Prep the changes.
   $posterOptions = array(
      'id' => $id_member,
      'ip' => $user_profile[$id_member]['member_ip'],
      'name' => $data->author,
      'email' => $user_profile[$id_member]['email_address'],
   );
   $issueOptions = array(
      'mark_read' => true,
      'assignee' => $id_member,
      'status' => 5, // Resolved.
   );
   $commentOptions = array('body' => '');

   // Lets do some loops.
   foreach ($bugs as $bug => $message)
   {
      $issue = $bug;
      loadIssue();

      // Update our body message
      $commentOptions['body'] = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);

      // Update status and assigne.
      $event_data = updateIssue($bug, $issueOptions, $posterOptions, true);

      // Fix a Project tracker bug...
      if ($event_data === true)
         $event_data = array();

      // Create a comment.
      $id_comment = createComment($project, $bug, $commentOptions, $posterOptions);
      $commentOptions['id'] = $id_comment;

      // Spam people.
      sendIssueNotification(array('id' => $bug, 'project' => $project), $commentOptions, $event_data, 'new_comment', $id_member);

   }
}