<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LiveAverage &#187; Coding</title>
	<atom:link href="http://liveaverage.com/category/features/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://liveaverage.com</link>
	<description>I can&#039;t afford to live any other way.</description>
	<lastBuildDate>Tue, 08 May 2012 21:26:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Add &#8216;Submitted Tickets&#8217; Listing Page for Joomla! RSTickets</title>
		<link>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/</link>
		<comments>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 17:15:21 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=202</guid>
		<description><![CDATA[If you haven&#8217;t heard, RSTickets! is an advanced Joomla! Help Desk ticketing system that allows you (or a team of yous) to manage and keep track of your clients&#8217; issues. It&#8217;s actually one of the few effective, useful Help Desk systems available for the Joomla! 1.5+ framework that I would personally recommend. Unfortunately, it&#8217;s still [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Joomla!" src="http://cdn.joomla.org/images/logo.png" alt="" width="235" height="46" /></p>
<p>If you haven&#8217;t heard, <a title="Check out the RSTickets! extension from RSJoomla!" href="http://www.rsjoomla.com/joomla-components/rstickets.html" target="_blank">RSTickets!</a> is an advanced Joomla! Help Desk ticketing system that allows you (or a team of yous) to manage and keep track of your clients&#8217; issues. It&#8217;s actually one of the few effective, useful Help Desk systems available for the Joomla! 1.5+ framework that I would personally recommend. Unfortunately, it&#8217;s still under development and lacks certain features that one may desire, such as a read-only listing page that displays tickets already submitted to you or your department.</p>
<p><span id="more-202"></span><strong>My Problem:</strong></p>
<p>I noticed internal network clients were submitting several duplicate tickets related to a shared problem (i.e. printer trouble, network outages, etc.). I couldn&#8217;t blame them since they couldn&#8217;t view previously submitted tickets, so I decided to create a quick + dirty page that pulls <em>&#8220;open,&#8221; </em>or <em>&#8220;on-hold,&#8221;</em> tickets from a specific department&#8217;s table of submitted [active] tickets and displays them on a Joomla! article page (using the Sourcerer plug-in to execute custom PHP with {source} tags). Pasting this code into an article without the Sourcerer plug-in [or some sort of plug-in for executing PHP] <em>will do nothing. </em>Also note the <em>include</em> file for making a raw connection to your MySQL database. This is required (and should be stored in a directory with the appropriate permissions to prevent outside read access).</p>
<p>If you&#8217;d like to simply list the number (amount) of tickets (open, closed, on-hold) for <em>all</em> departments, you might want to <a title="Try RSJoomla!'s RSTicket Module for a quick count of all tickets." href="http://www.rsjoomla.com/customer-support/forum/38-rstickets/7805-joomla-module-for-rstickets.html" target="_blank">check the unreleased version of RSJoomla!&#8217;s RSTicket Module.</a></p>
<pre class="brush: php;">
{source}
&lt;?php

include (&quot;includes/connect_custom.php&quot;);

$result2 = mysql_query(&quot;SELECT * FROM jos_rstickets_tickets WHERE DepartmentId=3 AND (TicketStatus='open' OR TicketStatus='on-hold') ORDER BY TicketTime ASC&quot;) or die(mysql_error());

echo '&lt;br /&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;padding-bottom: 10px;&quot; colspan=&quot;6&quot;&gt;Please check the open, pending, or on-hold tickets listed below before submitting a support ticket. The list below can be utilized as an informal gauge for IT response times. If a duplicate support ticket is submitted, you may cancel it yourself or it will be deleted by the IT Department upon review. Thank you for your cooperation.&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;font-size: 16px;font-weight: bold;padding-bottom: 10px;&quot; colspan=&quot;6&quot;&gt;SUBMITTED SUPPORT TICKETS:&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;text-align:left; padding-bottom:7px;&quot;&gt;&lt;strong&gt;Submitted:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Username:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Ticket Code:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Subject:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Status:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Priority:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';

while($row = mysql_fetch_array($result2))

{

$custid =  $row['CustomerId'];
$userquery= mysql_query(&quot;SELECT name FROM jos_users WHERE id=$custid&quot;) or die(mysql_error());

$username = mysql_fetch_array($userquery);

echo '&lt;tr style=&quot;font-size: 10px;vertical-align:top;&quot;&gt;&lt;td style=&quot;width: 102px; overflow: hidden;padding: 3px -10px 3px 3px;&quot;&gt;' . date(&quot;Y-m-d H:m&quot;, $row['TicketTime']) .  '&lt;/td&gt;&lt;td&gt;' . $username['name'] . '&lt;/td&gt;&lt;td&gt;' . $row['TicketCode'] . '&lt;/td&gt;&lt;td style=&quot;width: 235px; overflow: hidden;&quot;&gt;' . $row['TicketSubject'] . '&lt;/td&gt;&lt;td&gt;' . strtoupper($row['TicketStatus']) . '&lt;/td&gt;';

if ($row['TicketPriority']=='high'){

echo '&lt;td style=&quot;background-color: red; color: white; font-weight: bold;padding-left: 5px;&quot;&gt;';

} else if ($row['TicketPriority']=='normal'){

echo '&lt;td style=&quot;background-color: blue; color: white; font-weight: bold;padding-left: 5px;&quot;&gt;';

} else if ($row['TicketPriority']=='low'){

echo '&lt;td style=&quot;background-color: yellow; font-color: black; font-weight: bold;padding-left: 5px;&quot;&gt;';}

echo strtoupper($row['TicketPriority']) . '&lt;/td&gt;&lt;/tr&gt;';

}

echo '&lt;tr&gt;&lt;td style=&quot;font-size:16px; padding-top: 20px; padding-bottom: 20px&quot; colspan=&quot;6&quot;&gt;&lt;strong&gt;&lt;a href=&quot;index.php?option=com_rstickets&amp;Itemid=59&quot;&gt;&lt;img src=&quot;images/M_images/onsite_support1.jpg&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;index.php?option=com_rstickets&amp;Itemid=59&quot;&gt;SUBMIT A NEW SUPPORT TICKET&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;br /&gt;';

?&gt;
{/source}
</pre>
<p><strong>connect_custom.php :</strong></p>
<pre class="brush: php;">
&lt;?php

// Script:	connect_custom.php
// Author:	JR
// Date:	20080218
// Use:	    Utilized for custom DB connections to our current database for Fabrik Forms + Joomla 1.5

$hostname=&quot;localhost&quot;;
$mysql_login=&quot;thedude&quot;;
$mysql_password=&quot;sumpasswordhere&quot;;
$database=&quot;datablah&quot;;

if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
die(&quot;Can't connect to database server.&quot;);
}else{
if (!(mysql_select_db(&quot;$database&quot;,$db))){
die(&quot;Can't connect to database.&quot;);
}
}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Altermime, Postfix/Zimbra, and Headaches</title>
		<link>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/</link>
		<comments>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 19:43:11 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=109</guid>
		<description><![CDATA[EDIT: I have since removed altermime after installing a MailScanner spam relay for our Zimbra server to use. Because, by default, MailScanner appends a default signature to all outbound email, it was very simple to modify the signature rules to accomodate our mandatory disclaimers for different domains. I had the pleasure of applying mandatory disclaimers [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>EDIT: I have since removed altermime after installing a MailScanner spam relay for our Zimbra server to use. Because, by default, MailScanner appends a default signature to all outbound email, it was very simple to modify the signature rules to accomodate our mandatory disclaimers for different domains.</em></p></blockquote>
<p>I had the pleasure of applying mandatory disclaimers to all [outbound] emails at my workplace today&#8230; ~Joy~ &#8230; I had the assumption it&#8217;d be rather easy, but Altermime and Postfix were a bit finicky to work with. After editing the <strong>master.cf</strong> I ended up customizing my own &#8216;disclaimer&#8217; shell script.</p>
<p><span id="more-109"></span></p>
<pre class="brush: bash;">
#!/bin/sh
INSPECT_DIR=/var/spool/filter
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail

# Exit codes from
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting.
trap &quot;rm -f in.$$&quot; 0 1 2 3 15

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

cat &gt; in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

# Verify this mail is not incoming or internal-only
# We don't need disclaimers for either one of these cases.

# Debug:
#echo &quot;output: $from_address&quot; &gt;&gt; /tmp/tempoutput.txt

#Grab the from address:

from_address=`grep -m 1 &quot;From:&quot; in.$$ | cut -d &quot;&lt;&quot; -f 2 | cut -d &quot;&gt;&quot; -f 1`

#Verify whether your domain is in the from address.
#If it is, proceed to distinguish WHICH domain is sending outgoing mail and tag it appropriately:
#If not, then that would be incoming mail, so leave it alone:

#Additional (else if) conditional checks will be added to determine if the email is inner-office comm:
# to_address= `grep -m 1 &quot;To:&quot; in.$$ | cut -d &quot;&lt;&quot; -f 2 | cut -d &quot;&gt;&quot; -f 1`
# if [[ $from_address == *domain* &amp;&amp; to_address == *domain* ]]; then ....
#
# This additional condition requires more debugging...

if [[ $from_address == *domain* ]]; then

# Debug:
#echo
#echo &quot;FROM: $from_address&quot; &gt;&gt; /tmp/tempoutput.txt
#echo &quot;THIS GETS ALTERMIMED&quot; &gt;&gt; /tmp/tempoutput.txt
#echo

#Check to see which domain is sending outgoing email,
#then tag it with the appropriate disclaimer:

if [[ $from_address == *subdomain.domain* ]]; then

# Debug		echo &quot;THIS GETS APDD&quot; &gt;&gt; /tmp/tempoutput.txt
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/apd-disclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/apd-disclaimer.txt \
--xheader=&quot;X-Public-Record:&quot; || { echo Message content rejected; exit $EX_UNAVAILABLE; }
else
# Debug		echo &quot;THIS GETS COAD&quot; &gt;&gt; /tmp/tempoutput.txt
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/coa-disclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/coa-disclaimer.txt \
--xheader=&quot;X-Public-Record:&quot; || { echo Message content rejected; exit $EX_UNAVAILABLE; }

fi
fi

# Might need to remove -i switch for truncation problems depending on your MTA version...

$SENDMAIL -i &quot;$@&quot; &lt; in.$$

exit $?
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bashing MySQL Dumps</title>
		<link>http://liveaverage.com/features/coding/bashing-mysql-dumps/</link>
		<comments>http://liveaverage.com/features/coding/bashing-mysql-dumps/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 14:45:14 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dumps]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=9</guid>
		<description><![CDATA[A quick set of scripts to dump specified databases from MySQL and mail a copy of the log to a specified e-mail address (requires Per]]></description>
			<content:encoded><![CDATA[<p>A quick set of batch scripts I wrote up (two of the three scripts, anyway) for dumping all of my (specified) MySQL databases into an archive for backup. The log mailing (<strong>emailsql.pl</strong>)requires Perl and the MIME:Lite module to correctly function. I&#8217;ve also utilized a wrapper script so the log outputs to a separate file [to be mailed]. There&#8217;s also a &#8216;dummy&#8217; log file I use in my crontab file, though this isn&#8217;t really necessary:</p>
<p><span id="more-9"></span></p>
<p><span style="color: #800000;"><strong>mysqlbackupwrapper.sh</strong></span></p>
<pre class="brush: bash;">
#!/bin/bash
#Wrapper script used to call the primary backup script and output to a specified file
sh /home/administrator/scripts/mysqlbackups &gt; /home/administrator/scripts/sql.backup.log 2&gt;&amp;1
</pre>
<p><span style="color: #800000;"><strong>mysqlbackup.sh</strong></span>:</p>
<pre class="brush: bash;">
#!/bin/sh
#Timestamp for your logs:
date

#Dump the databases - Make sure to specify your root or user password following the -p switch:
mysqldump -uroot -p --opt intraforum &gt; /home/administrator/scripts/sqldata/intra_apdforum.sql
mysqldump -uroot -p --opt joomla_intranet &gt; /home/administrator/scripts/sqldata/intra_intranet.sql
mysqldump -uroot -p --opt mysql &gt; /home/administrator/scripts/sqldata/intra_mysql.sql
tar -zcvf /home/administrator/scripts/sqldata.tgz /home/administrator/scripts/sqldata/*.sql
echo
echo &quot;Backup completed successfully for: &quot;
echo
echo &quot;MySQL - PHPbb3 Forum&quot;
echo &quot;MySQL - Joomla 1.0.X Intranet&quot;
echo &quot;MySQL - Intranet MySQL Tables&quot;
echo
echo &quot;Copying to SERVER.yourdomain.local . . . .&quot;
echo

#Use SCP to transfer to file so you can verify successful backups -- Make sure to use identity/keys for SCP instead of a password:
scp -v -i /home/administrator/identity /home/administrator/scripts/sqldata.tgz administrator@this.host:/backup/sqldata_backup.tgz

perl /home/administrator/scripts/emailsql.pl
</pre>
<p><span style="color: #800000;"><strong>emailsql.pl (I did not write this one)</strong></span>:</p>
<p>Instead of just sending the text of the log file, this script attaches the file and sends the message:</p>
<pre class="brush: bash;">

#!/usr/bin/perl -w
use MIME::Lite;

$msg = MIME::Lite-&gt;new(
From    =&gt; 'Backup Log',
To      =&gt; 'liveaverage@yourdomain.org',
Subject =&gt; 'MySQL Data Backup - Intranets',
Type    =&gt; 'text/plain',
Data    =&gt; &quot;See the attached log for details on the most recent MySQL Database Dumps.&quot;);

$msg-&gt;attach(
Type       =&gt;'text/plain',
Path       =&gt;'/home/administrator/scripts/sql.backup.log',
Filename   =&gt;'sql.backup.log',
Disposition        =&gt;'attachment');

$msg-&gt;send;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/bashing-mysql-dumps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl my way to happiness</title>
		<link>http://liveaverage.com/features/coding/perl-my-way-to-happiness/</link>
		<comments>http://liveaverage.com/features/coding/perl-my-way-to-happiness/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 19:00:49 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[perl zimbra zmprov provisioning]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=4</guid>
		<description><![CDATA[If only everything was as easy &#38; straight-forward as account provisioning in Zimbra: !/usr/bin/perl # ZCS IMPORT SCRIPT # Provided by : ZCS Wiki # Modified by : J.R. # Last Change : 2008.04.09 # # Lookup the valid COS (Class of Service) ID in the interface or like this my $cosid = `su - [...]]]></description>
			<content:encoded><![CDATA[<p>If only everything was as easy &amp; straight-forward as account provisioning in Zimbra:</p>
<pre class="brush: bash;">!/usr/bin/perl

# ZCS IMPORT SCRIPT
#       Provided by : ZCS Wiki
#       Modified by : J.R.
#       Last Change : 2008.04.09
#
# Lookup the valid COS (Class of Service) ID in the interface or like this
my $cosid = `su - zimbra -c 'zmprov gc apd |grep zimbraId:'`;
$cosid =~ s/zimbraId:\s*|\s*$//g;

while (&lt;&gt;) {
chomp;

# CHANGE ME: To the actual fields you use in your CSV file
my ($email, $password, $first, $last) = split(/\,/, $_, 4);

my ($uid, $domain) = split(/@/, $email, 2);

print qq{ca $uid\@$domain $password\n};
print qq{ma $uid\@$domain zimbraCOSid &quot;$cosid&quot;\n};
print qq{ma $uid\@$domain givenName &quot;$first&quot;\n};
print qq{ma $uid\@$domain sn &quot;$last&quot;\n};
print qq{ma $uid\@$domain cn &quot;$uid&quot;\n};
print qq{ma $uid\@$domain displayName &quot;$first $last&quot;\n};

#Set the user's reply or canonical address
print qq{ma $uid\@$domain zimbraMailCanonicalAddress $uid\@cityof*****.org\n};

#Add e-mail account alias for multiple domains
#Verify domain is correctly working for provisioning aliases

print qq{aaa $uid\@$domain $uid\@cityof*****.com\n};

#Add all users to a general distribution list and terminate
#Add multiple distro-lists if desired
print qq{adlm dept.all\@cityof*****.org $uid\@cityof*****.org\n};
print qq{\n};

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/perl-my-way-to-happiness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
