<?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>NetWater Tech Blog</title>
	<atom:link href="http://techblog.netwater.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://techblog.netwater.com</link>
	<description></description>
	<lastBuildDate>Thu, 14 Jan 2010 23:30:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting Horde logged-in username &amp; full name</title>
		<link>http://techblog.netwater.com/?p=23</link>
		<comments>http://techblog.netwater.com/?p=23#comments</comments>
		<pubDate>Thu, 14 Jan 2010 23:29:14 +0000</pubDate>
		<dc:creator>NetWater</dc:creator>
				<category><![CDATA[Horde / IMP]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Horde]]></category>
		<category><![CDATA[IMP]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Qmail]]></category>

		<guid isPermaLink="false">http://techblog.netwater.com/?p=23</guid>
		<description><![CDATA[A customer wanted to be able to pull the current logged in username AND the full name of the user to use outside of Horde to populate some on-the-fly flyers.
Getting Horde to tell us the current logged in user was no problem.  Three lines of code.  However, the trick was getting the full [...]]]></description>
			<content:encoded><![CDATA[<p>A customer wanted to be able to pull the current logged in username AND the full name of the user to use outside of Horde to populate some on-the-fly flyers.</p>
<p>Getting Horde to tell us the current logged in user was no problem.  Three lines of code.  However, the trick was getting the full name of the user which is set in the Mail Preferences under &#8220;Identities&#8221; when you log into Horde.  Horde has a built in hook to retrieve the full name, but only if you&#8217;re using LDAP authentication, or /etc/passwd authentication.  Because the mail accounts are setup using Plesk, we had to set his Horde Auth to use simple IMAP authentication, which doesn&#8217;t maintain the full name of the user account, just the user account and password and then the standard plesk qmail /var/qmail/mailnames message store.  Everything else about the user is stored in the Horde database.  Took us a few hours, because we tried everything from trying to manipulate session data, to inserting code in Horde, then it dawned on us to why not just pull the query based on the username from the database.  But because the place where Horde stores the full name is not like in a constant table row thats says something like &#8220;full name&#8221;.. the data looks like this:</p>
<p>:startcode:</p>
<pre>a:1:{i:0;a:13:{s:2:"id";s:16:"Default Identity";s:8:"fullname";s:6:"Mark D";s:9:"from_addr";s:15:"markd-notreal@none.com";s:12:"replyto_addr";s:0:"";s:10:"alias_addr";a:0:{}s:10:"tieto_addr";a:0:{}s:8:"bcc_addr";a:0:{}s:9:"signature";s:0:"";s:9:"sig_first";i:0;s:10:"sig_dashes";i:0;s:14:"save_sent_mail";i:1;s:16:"sent_mail_folder";s:4:"Sent";s:16:"default_identity";s:1:"0";}}
</pre>
<p>:endcode:</p>
<p>That&#8217;s one field (prefs_value) that contains that information.  And the next problem was that &#8220;s:6&#8243; doesn&#8217;t always precede every full name.  Sometimes it was &#8220;s:9&#8243;, or &#8220;s:13&#8243;, etc.  The only thing that was constant before the full name was the :&#8221;fullname&#8221;;s:.  So I had to write a function to get whatever was after &#8220;fullname&#8221;;s and the following ;s:, then strip out the characters before the full name and remove the quotes.  And here ya go!</p>
<p>:startcode:</p>
<pre>

&lt;?php

require_once("lib/base.php");
$current = (Auth::getAuth());
echo "Horde says this user is on: &lt;span style="color: blue;"&gt;" . $current . "&lt;/span&gt;";

$link = $link = mysql_connect('localhost', 'admin', 'apassword');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db('newhorde', $link);
$query = sprintf("SELECT pref_uid, pref_scope, pref_name, pref_value FROM horde_prefs WHERE pref_uid='$current' AND pref_scope='horde' AND pref_name='identities'");
$result = mysql_query($query);
mysql_close($link);
while ($row = mysql_fetch_assoc($result)) {
$workit = $row['pref_value'];
}

function get_string_between($string, $start, $end) {
    $string = " ".$string;
    $ini = strpos($string,$start);
    if ($ini == 0) return "";
    $ini += strlen($start);
    $len = strpos($string,$end,$ini) - $ini;
    return substr($string,$ini,$len);
} 

echo "

This is the full string from the pref_value row from table horde_prefs for user &lt;span style="color: red;"&gt; " . $current . "&lt;/span&gt;: &lt;span style="color: blue;"&gt; " . $workit . "&lt;/span&gt;";

$parsed = get_string_between($workit, 'fullname";s:', ';s:'); 

echo "

First passed parsing to strip out everything we can using 'fullname\";s:' as a constant base: &lt;span style="color: blue;"&gt;" . $parsed . "&lt;/span&gt;";

$parsed2 = get_string_between($parsed, ':"', '"'); 

echo "

Second and final parsing to strip out other characters other than the actual user name, giving us end result: &lt;span style="color: blue;"&gt;" . $parsed2 . "&lt;/span&gt;";
?&gt;</pre>
<p>:endcode:</p>
<p>The end result is this:<br />
&#8212;&#8212;&#8211;<br />
Horde says this user is on: markd</p>
<p>This is the full string from the pref_value row from table horde_prefs for user markd:</p>
<pre>a:1:{i:0;a:13:{s:2:"id";s:16:"Default Identity";s:8:"fullname";s:6:"Mark D";s:9:"from_addr";s:15:"markd-notereal@none.com";s:12:"replyto_addr";s:0:"";s:10:"alias_addr";a:0:{}s:10:"tieto_addr";a:0:{}s:8:"bcc_addr";a:0:{}s:9:"signature";s:0:"";s:9:"sig_first";i:0;s:10:"sig_dashes";i:0;s:14:"save_sent_mail";i:1;s:16:"sent_mail_folder";s:4:"Sent";s:16:"default_identity";s:1:"0";}}
</pre>
<p>First passed parsing to strip out everything we can using &#8216;fullname&#8221;;s:&#8217; as a constant base: 6:&#8221;Mark D&#8221;</p>
<p>Second and final parsing to strip out other characters other than the actual user name, giving us end result: Mark D</p>
<p>-nw</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.netwater.com/?feed=rss2&amp;p=23</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show real names in hover in Who&#8217;s Online</title>
		<link>http://techblog.netwater.com/?p=11</link>
		<comments>http://techblog.netwater.com/?p=11#comments</comments>
		<pubDate>Thu, 14 Jan 2010 22:31:47 +0000</pubDate>
		<dc:creator>NetWater</dc:creator>
				<category><![CDATA[DetroitLuv / SMF v1.1.11]]></category>
		<category><![CDATA[DetroitLuv]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Simple Machines Forum]]></category>
		<category><![CDATA[SMF]]></category>

		<guid isPermaLink="false">http://techblog.netwater.com/?p=11</guid>
		<description><![CDATA[To this day, SMF (Simple Machines Forum still doesn&#8217;t show users the real (registered) name of an online user, but whatever custom name they have chosen for themselves.  This makes it hard to know whom someone really is, especially if you want to send them a PM and you can&#8217;t find them by their [...]]]></description>
			<content:encoded><![CDATA[<p>To this day, SMF (<a href="http://www.simplemachines.org" target="_blank">Simple Machines Forum</a> still doesn&#8217;t show users the real (registered) name of an online user, but whatever custom name they have chosen for themselves.  This makes it hard to know whom someone really is, especially if you want to send them a PM and you can&#8217;t find them by their original name.</p>
<p>Basically in your theme&#8217;s BoardIndex.php look for &#8220;//Some basic color coding&#8230;&#8221; and change to below:</p>
<p>:startcode:</p>
<pre>
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '&lt;a title="View the profile of ' . $row['memberName'] . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';"&gt;' . $row['realName'] . '&lt;/a&gt;';
else
$link = '&lt;a title="View the profile of ' . $row['memberName'] . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"&gt;' . $row['realName'] . '&lt;/a&gt;';

$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
</pre>
<p>:endcode:<br />
-nw</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.netwater.com/?feed=rss2&amp;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing SoX w/ MP3 Support on CentOS 5.x</title>
		<link>http://techblog.netwater.com/?p=4</link>
		<comments>http://techblog.netwater.com/?p=4#comments</comments>
		<pubDate>Thu, 14 Jan 2010 22:25:15 +0000</pubDate>
		<dc:creator>NetWater</dc:creator>
				<category><![CDATA[CentOS 5]]></category>

		<guid isPermaLink="false">http://techblog.netwater.com/?p=4</guid>
		<description><![CDATA[First off, this article assumes you already know the basics of using the yum repositories, downloading &#038; extracting tarballs, and compiling sources on a CentOS 5.x box.
So recently we were given the task of installing the latest version (14.3.0) of SoX (Sound eXchange); on a new CentOS 5.x machine.
The base of CentOS already comes with [...]]]></description>
			<content:encoded><![CDATA[<p>First off, this article assumes you already know the basics of using the yum repositories, downloading &#038; extracting tarballs, and compiling sources on a CentOS 5.x box.</p>
<p>So recently we were given the task of installing the latest version (14.3.0) of <a href="http://sox.sourceforge.net/" target=_new>SoX (Sound eXchange)</a>; on a new <a href="http://www.centos.org/" target=_new>CentOS 5.x</a> machine.</p>
<p>The base of CentOS already comes with an older version of SoX (12.18.1), but it doesn&#8217;t have mp3 support built into it.  Unfortunately there were no repos out there with the latest version.  With almost every repo available to CentOS, they all reported that the latest available version was installed.</p>
<p>This version was okay, but trying to manipulate MP3s was impossible, and always kick back the error &#8220;SoX was compiled without MP3 decoding support&#8221;.   So since we were gonna have to rebuild SoX anyway, why not just go with the latest and greatest?</p>
<p>To accomplish installing the latest version with MP3 support, DO NOT uninstall the base version and it pretty much contains all of the dependencies that you will need to compile the source of the latest version.</p>
<p>First off, you are going to need the <a href="http://lame.sourceforge.net/">Lame Encoder</a>.  You do not need to download and compile the source code, as you can use the rpm from the repos to install it.</p>
<p>code:<br />
<code>yum install lame</code></p>
<p>Next, you&#8217;re gonna need the <a href="http://www.underbit.com/products/mad">MAD: MPeg Audio Decoder</a> source.  Note: this project has not been updated since 2004, however it is still the basis of what you need in order to turn on full MP3 support for SoX. You will need to download <a href="http://sourceforge.net/projects/mad/files/madplay/0.15.2b/madplay-0.15.2b.tar.gz/download">madplay-05.15.2b</a>, <a href="http://sourceforge.net/projects/mad/files/libmad/0.15.1b/libmad-0.15.1b.tar.gz/download">libmad-05.15.1b</a>, and <a href="http://sourceforge.net/projects/mad/files/libid3tag/0.15.1b/libid3tag-0.15.1b.tar.gz/download">libid3tag-05.15.1b</a>.  While there are yum based repos for madplay, libmad, &#038; libid3tag, they will NOT be recognized as being installed by the latest version of the SoX compiler, so you must download these tarballs and compile them manually from scratch.</p>
<p>Install each one of these downloads.  The order doesn&#8217;t really matter, though for best results, you should start with libmad first, then libid3tag, followed by madplay.</p>
<p>Once you have those three installed, grab the <a href="http://sourceforge.net/projects/sox/files/sox/14.3.0/sox-14.3.0.tar.gz/download">latest version of SoX</a>, unpack it and just run &#8220;./configure&#8221;, then &#8220;make -s&#8221;, and finally &#8220;make install&#8221;.  SoX will tell you to run &#8220;make -s &#038;&#038; make install&#8221; together, but might break.  Run them separately.</p>
<p>After running the &#8220;./configure&#8221;, you should see this towards the end of the output:<br />
code:<br />
<code><br />
OPTIONAL FILE FORMATS<br />
amrnb......................no<br />
amrwb......................no<br />
ffmpeg.....................yes<br />
flac.......................no<br />
gsm........................yes (in-tree)<br />
lpc10......................yes (in-tree)<br />
mp3........................yes<br />
 id3tag....................yes<br />
 lame......................yes<br />
 dlopen lame...............no<br />
 mad.......................yes<br />
 dlopen mad................no<br />
oggvorbis..................yes<br />
sndfile....................no<br />
wavpack....................no<br />
</code></p>
<p>That&#8217;s all you need.. to make sure &#8220;lame&#8230;.yes&#8221;, &#8220;mad&#8230;.yes&#8221;, and &#8220;id3tag&#8230;yes&#8221;, and it will install and run like a champ.</p>
<p>We put this out there because we had a tough time trying to use the repositories to complete this function, and just compiling it all from scratch worked out best.</p>
<p>-nw</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.netwater.com/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
