Showing posts with label Gripe. Show all posts
Showing posts with label Gripe. Show all posts

Thursday, June 17, 2010

Create Excel Data from PHP

Hey All,

It's been a little while since I've written; but everything has been smooth sailing for a while. Tonight, I had a small issue with Excel XML file creation that I thought I'd write about.

The problem stems from word processing programs using left and right oriented apostrophe's instead of single quotes. Notice that the character ' is different from ’ and even different from ‘.

They all have different html codes associated with them. To display the single quotation, we escape the character with a backslash; however, with left apostrophe and right apostrophe, we have to use &lsquo and &rsquo respectively.

Now, php's htmlspecialchars() function does not look after these special html translations, so we have to add in a function like
function myhtmlspecialchars($string) {
    $transTable = get_html_translation_table(HTML_ENTITIES);

    $transTable[chr(145)] = '\'';  // looks after &lsquo
    $transTable[chr(146)] = '\'';  // looks after &rsquo
    $transTable[chr(147)] = '&quot'; // looks after &ldquo
    $transTable[chr(148)] = '&quot'; // looks after &rdquo

    return strtr($string, $transTable);
}

The result of not fixing this on a website is that you get diamonds with question marks in them. The result of not fixing this on a xml file is that it breaks.

The function that I'm using the generate the excel data is as follows

function excelXML($bigArray) {
    $colCount = sizeof($bigArray[0]);
    $colCount2 = $colCount -1;
    $rowCount = sizeof($bigArray)+1;
    $beginOutput = "
         
         
         
             dougler
             dougler
             2010-05-04T04:19:22Z
             12.00
         
         
             14880
             28755
             0
             135
             False
             False
         
         
         
        
        
        \n";  foreach ($bigArray[0] as $key => $value) {       $beginOutput .= "$key\n"; } $beginOutput .= "\n";   $middleOutput = "";  for ($i = 0; $i < sizeof($bigArray); $i++) {
    $middleOutput .= "\n";     foreach ($bigArray[$i] as $key => $value) {         $middleOutput .= "" . myhtmlspecialchars($value) . "\n";     }     $middleOutput .= "\n"; }  $endOutput = "     
300 300 3 55 False False
"; return $beginOutput . $middleOutput . $endOutput; }

Where $bigArray looks something like

Array
(
    [0] => Array
        (
            [id] => 1
            [company] => test
            [address] => test
            [city] => test
            [province] => test
            [postal] => test
            [website] => test
            [contact] => test
            [telephone] => test
            [email] => test@test.ca
            [password] => test
            [Number of Projects] => test
        )

    [1] => Array
        (
            [id] => 2
            [company] => test
            [address] => test
            [city] => test
            [province] => test
            [postal] => test
            [website] => test
            [contact] => test
            [telephone] => test
            [email] => test@test.ca
            [password] => test
            [Number of Projects] => 
        )

    [2] => Array
        (
            [id] => 3
            [company] => test
            [address] => test
            [city] => test
            [province] => test
            [postal] => test
            [website] => test
            [contact] => test
            [telephone] => test
            [email] => test@test.ca
            [password] => test
            [Number of Projects] => test
        )
)

Monday, May 31, 2010

Openvpn 2.1.1 Not Connecting

One of the services that I offer for a company is a VPN. I use the OpenVPN distribution that comes in the FreeBSD ports collection.

I have mine configured as a tunnel device which authenticates over RSA keys. Once the user is connected, I allow them access to port 139 which gives SMB shares mapped from a linksys NAS RAID device. It's a pretty slick service and very stable.

Until today!

Today, none of my clients could connect, and I was curious about why this had happened. After running a port upgrade, I had not manually restarted all of my services, and it wasn't until this weekend, when the server was rebooted that openvpn 2.1.1 was initialized (previously 2.0.9 was installed).

There was no immediate reason as to why openvpn wouldn't work except for a line which said that --script-security 2 was supposed to be in the openvpn command line if it were to execute client scripts. I added the line in rc.conf as openvpn_flags="--script-security 2", restarted the service, and now it works perfectly.

Sunday, May 23, 2010

Gripes with Vpro and Intel i5-661 with Asus P7Q57M-DO

I was so fucking excited when I heard about the new Intel Vpro technology and how RealVNC is integrating it so that you get bios level KVM access because I'm currently administering 2 FreeBSD boxes at the radio station in BC and a production box at home in Calgary.

Finally, I'd be able to stop depending on my sysadmin friends to step in when something horrible happened!

Well, you might be wondering where the gripe is then?  Well, it's the lack of documentation from intel as to what kind of machinery does this 'vpro' stuff, and what it means to be full 'vpro'.

I have the Asus P5E-VM DO which claims to have "Intel® vPro Technology support"; but, the board doesn't have any KVM options in it, and the RealVNC client returns an inappropriate permissions error.  It allows me to have access via SOL and I can do IDE redirection (which is pretty damn cool), but it's not going to help me diagnosing why my RAID didn't come back online. 

Eventually, I decide that my board with the Q35 chipset just wasn't new enough, so I wrote off my chances of buying an IPad and bought a new server for myself with the  Asus P7Q57-M DO board and an Intel i5 661 processor.

The system is awesomely fast; but, the KVM option is STILL not available.  WHY!?!?

Eventually enough searching found this article; note on page 37, it says the ingredients for vPro
What ingredients are required for Intel vPro technology branded platforms? The latest 2010 Intel vPro processor platforms with the Intel vPro brand include the following key ingredients:
• The all new Intel Core vPro processors
• Intel Q57, QS57, or QM57 chipset
• TPM 1.2
• Intel VT capable BIOS
• Intel TXT capable BIOS
• TPM 1.2 capable BIOS
• Intel AMT capable BIOS
• Intel ME firmware 6.0 with Intel AMT 6.0 and Intel AT 2.0
• Intel 82578DM GbE LAN, Intel 82577LM GbE LAN, Intel Centrino® Advanced-N+WiMAX 6250, or Intel Centrino Ultimate-N/Advanced-N 6000 Series
• Intel Management and Security Status Icon (recommended)
Note: Earlier generations of Intel vPro branded platforms have different platform ingredients. Consult your Intel sales representative for the platform ingredients in earlier generations of Intel vPro technology.
Now, the first line says Intel Core vPro Processors, and if we take a look at all of the processors available at most stores, nothing is specified about vPro; but it turns out that only the i5-650, i5-660, and i5-670 processors have the vPro technology enabled.   So, I had to special order one in for Monday - I'll keep you posted as to whether it works or not.