PHP 5: Send HTTP post request with file_get_contents

The following code snippet shows an easy way how to send a HTTP post request using the PHP function file_get_contents:

$url = ‘http://server.com/path’;
$data = array(‘key1′ => ‘value1′, ‘key2′ => ‘value2′)

// use key ‘http’ even if you send the request to https://…
$options = array(‘http’ => array(
‘method’ => ‘POST’,
‘content’ => http_build_query($data)
));
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

var_dump($result);

Ubuntu 10.04 & PHP 5.3: Install pecl_http

To install the pecl_http PHP extension on Ubuntu 10.04 follow the instructions below:

  1. Install the required packages:
    # sudo apt-get install php-pear php5-dev libcurl4-openssl-dev
  2. Install pecl_http:
    # sudo pecl install pecl_http
  3. Create file /etc/php5/conf.d/http.ini with the following content:
    extension=http.so
  4. Restart Apache2:
    # sudo /etc/init.d/apache2 restart

After restarting the Apache2 web server a “http” section should be included in the phpinfo() output.

Microsoft CRM 4.0: Fix “TrySetFocusOnSubject” error after installing Update Rollup 12

After installing the Update Rollup 12 for Microsoft Dynamics CRM 4.0, I get an error (“Microsoft Dynamics CRM has encountered an error”) in the web frontend when closing an activity (e.g. a task).

The error report says:

<CrmScriptErrorReport>
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>Object expected</Message>
<Line>1</Line>
<URL>[...]</URL>
<PageURL>[...]</PageURL>
<Function>function anonymous() { TrySetFocusOnSubject() }</Function>
<CallStack>
<Function>function anonymous() { TrySetFocusOnSubject() }</Function>
</CallStack>
</ScriptErrorDetails>
<ClientInformation>
<BrowserUserAgent>[...]</BrowserUserAgent>
<BrowserLanguage>en-us</BrowserLanguage>
<SystemLanguage>en-us</SystemLanguage>
<UserLanguage>en-us</UserLanguage>
<ScreenResolution>1920×1200</ScreenResolution>
<ClientName>Web</ClientName>
</ClientInformation>
<ServerInformation>
<OrgLanguage>1033</OrgLanguage>
<OrgCulture>1033</OrgCulture>
<UserLanguage>1033</UserLanguage>
<UserCulture>1033</UserCulture>
<OrgID>[...]</OrgID>
<UserID>[...]</UserID>
<CRMVersion>4.0.7333.2935</CRMVersion>
</ServerInformation>
</CrmScriptErrorReport>

To fix this problem just delete your temporary Internet files and reload the CRM.

Debian & Ubuntu: Multi network/gateway ip routing setup

If you would like to connect your Debian or Ubuntu system to more than one network (e.g. with more than one physical or virtual network device) you could use the following ip routing setup to use a specific gateway for each network.

Create a configuration file in /etc/network/if-up.d/ (like /etc/network/if-up.d/routing) and add one section for each network card (eth0, eth1, …), like:

#!/bin/bash

IP=/sbin/ip

case “$IFACE” in
eth0)
$IP route flush table 10
$IP route add table 10 to [NETWORK-1]/[MASK-BITS-1] dev eth0
$IP route add table 10 to default via [GATEWAY-1] dev eth0

XenServer 5.6: Network problems with r8169 kernel module

Introduction

Recently, I noticed some network problems (package losts) with an almost fresh XenServer 5.6 installation on a Hetzner EQ root server running a (SSH sessions disconnects, host and client system are not pingable for some minutes). After some research I found some resources that point out problems with the r8169 kernel module:

Summarized the resources suggested to replace the driver r8169 with the r8168 driver to eliminate the network problems. Of course, the driver has to be replaced only in the host.

lspci and lsmod show that the root server has a Realtek network card …

XenServer 5.6: Tutorials to setup on Hetzner EQ root server

Here is a list of tutorials I’ve used to setup the XenServer 5.6 on a Hetzner root server with paravirtualized Ubuntu 10.04 and Debian 5.0 guest systems. Some tutorials were written for XenServer 5.5, but they also worked with the new version 5.6.

Host system

Ubuntu 10.04 & Tomcat 6: Improve performance with Apache Tomcat Native library

To improve the performance of the Apache Tomcat Server you could use the Apache Tomcat Native library.
To install the library just execute:

# sudo aptitude install libtcnative-1

and add the following line to the file $CATALINA_HOME/bin/setenv.sh (create the file if it does not exist):

export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH

To verify the library is running you will find the following message in $CATALINA_HOME/logs/catalina.out:

INFO: Loaded APR based Apache Tomcat Native library 1.1.19.

Without the Apache Tomcat Native library you will find a message like:

INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found …

Howto remove Microsoft Office 2007 if uninstalling failed

If you are not able to uninstall your Office 2007 suite using the Windows “Add or Remove Programs” feature the “Fix it” application in Microsoft’s knowledge base could help you (http://support.microsoft.com/kb/971179).

If the list of installed software still contains the Office suite after the application has removed all files and registry entries just try Window’s “Remove program” feature again and confirm that the software was (manually) removed.

Ubuntu 10.04 & Java: Setup Sun JDK

Since Ubuntu 10.04 the OpenJDK is the recommended default JDK and the Sun JDK has been removed from the multiverse repository. From the release notes:

Sun Java moved to the Partner repository
For Ubuntu 10.04 LTS, the sun-java6 packages have been dropped from the Multiverse section of the Ubuntu archive. It is recommended that you use openjdk-6 instead.

If you cannot or do not want to use the OpenJDK implementation follow the steps below to install the sun-java6-jdk package:

# sudo aptitude install python-software-properties
# sudo add-apt-repository “deb http://archive.canonical.com/ lucid partner”
# sudo aptitude update
# sudo aptitude install sun-java6-jdk

After the …

ActionScript 2: Copy MovieClips with BitmapData on runtime

The flash.display.BitmapData class enables you to copy arbitrary movie clips on runtime, e.g. movie clips attached from the library or external loaded images or swf files. Here is a little helper function that does all the magic stuff:

import flash.display.BitmapData;

/**
* @param sourceMovieClip Movie clip to copy
* @param targetMovieClip (Empty) movie to past into
*/
function copy(sourceMovieClip:MovieClip, targetMovieClip:MovieClip):Void {
var bitmapData:BitmapData = new BitmapData(sourceMovieClip._width, sourceMovieClip._height, false, 0xFFFFFF);
bitmapData.draw(sourceMovieClip);
targetMovieClip.attachBitmap(bitmapData, 1);
}

It is important to know, that the copy function only creates a “visual copy” and does not copy any functionalities or timelines; the copy function works …

Page 1 of 41234